class_user.inc 19.92 KiB
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2013-2018  FusionDirectory
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
class PostalAddressAttribute extends TextAreaAttribute
  function inputValue ($ldapValue)
    return str_replace(
      ['$',  '\24','\5C'],
      ["\n", '$',  '\\'],
      $ldapValue
  function computeLdapValue ()
    return str_replace(
      ["\r\n", "\n", "\r"],
      '$',
      str_replace(
        ['\\', '$'],
        ['\5C','\24'],
        $this->getValue()
class user extends simplePlugin
  private $was_locked;
  static function plInfo (): array
    return [
      'plShortName'   => _('User'),
      'plDescription' => _('User account information'),
      'plIcon'        => 'geticon.php?context=applications&icon=user-info&size=48',
      'plSmallIcon'   => 'geticon.php?context=applications&icon=user-info&size=16',
      'plSelfModify'  => TRUE,
      'plObjectClass' => ['inetOrgPerson','organizationalPerson','person'],
      'plFilter'      => '(objectClass=inetOrgPerson)',
      'plObjectType'  => ['user' => [
        'name'        => _('User'),
        'description' => _('User account'),
        'mainAttr'    => 'uid',
        'nameAttr'    => 'cn',
        'icon'        => 'geticon.php?context=types&icon=user&size=16',
        'ou'          => get_ou('userRDN'),
      ]],
      'plForeignKeys'  => [
        'manager' => ['user','dn','manager=%oldvalue%','*']
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
'plSearchAttrs' => ['uid','description'], 'plProvidedAcls' => array_merge( parent::generatePlProvidedAcls(static::getAttributesInfo()), ['userLock' => _('User lock status')] ) ]; } static function getAttributesInfo (): array { global $config; $languages = Language::getList(TRUE); asort($languages); $languages = array_merge(['' => ''], $languages); $attributesInfo = [ 'perso' => [ 'name' => _('Personal information'), 'icon' => 'geticon.php?context=types&icon=user&size=16', 'attrs' => [ new HiddenAttribute('cn'), new StringAttribute( _('Last name'), _('Last name of this user'), 'sn', TRUE, '', '', '/^[^,+"?()=<>;\\\\]+$/' ), new StringAttribute( _('First name'), _('First name of this user'), 'givenName', ($config->get_cfg_value('GivenNameRequired', 'TRUE') === 'TRUE'), '', '', '/^[^,+"?()=<>;\\\\]+$/' ), new StringAttribute( _('Initials'), _('The initials of some or all of the individual\'s names, but not the surname(s)'), 'initials', FALSE, '', '', '/^[^,+"?()=<>;\\\\]+$/' ), new TextAreaAttribute( _('Description'), _('Short description of the user'), 'description', FALSE ), new ImageAttribute( _('Picture'), _('The avatar for this user'), 'jpegPhoto', FALSE, $config->get_cfg_value('MaxAvatarSize', 200), $config->get_cfg_value('MaxAvatarSize', 200), 'jpeg' ), ] ], 'contact' => [ 'name' => _('Organizational contact information'), 'icon' => 'geticon.php?context=types&icon=contact&size=16', 'attrs' => [ new StringAttribute( _('Location'), _('Location'), 'l', FALSE ), new StringAttribute( _('State'), _('State'), 'st', FALSE ), new PostalAddressAttribute( _('Address'), _('Business postal address'), 'postalAddress', FALSE ), new StringAttribute( _('Room No.'), _('Room number'), 'roomNumber', FALSE ), new PhoneNumberButtonAttribute( _('Phone'), _('Business phone number'), 'telephoneNumber', FALSE,