add_objectClass(\'inetOrgPerson\');'), E_USER_ERROR); $this->base = $base; // inetOrgPerson is only a valid objectClass for users if ($_SESSION[$this->base]->get_type() != 'user') trigger_error(_('inetOrgPerson can only be used for users.'), E_USER_WARNING); // Add Array with all attributes and type $this->attributes = $_SESSION[$this->base]->get_module_attributes('inetOrgPerson'); $_SESSION[$this->base]->add_attributes ('inetOrgPerson'); $this->orig = $this->attributes ; $this->attributes['objectClass'][0] = 'inetOrgPerson'; $this->alias = _('inetOrgPerson'); } // Variables // Alias Name. This name is shown in the menu instead of posixAccount var $alias; // reference to base-array so we can read other classes in basearray var $base; // This variable contains all inetOrgPerson attributes var $attributes; /* If an account was loaded all attributes are kept in this array * to compare it with new changed attributes */ var $orig; /* This function returns a list with all required modules */ function dependencies() { return array('main'); } function module_ready() { return true; } /* Write variables into object and do some regexp checks */ function proccess_attributes($post) { // Load attributes $this->attributes['description'][0] = $post['form_inetOrgPerson_description']; $this->attributes['sn'][0] = $post['form_inetOrgPerson_sn']; $this->attributes['givenName'][0] = $post['form_inetOrgPerson_givenName']; $this->attributes['title'][0] = $post['form_inetOrgPerson_title']; $this->attributes['mail'][0] = $post['form_inetOrgPerson_mail']; $this->attributes['telephoneNumber'][0] = $post['form_inetOrgPerson_telephoneNumber']; $this->attributes['mobileTelephoneNumber'][0] = $post['form_inetOrgPerson_mobileTelephoneNumber']; $this->attributes['facsimileTelephoneNumber'][0] = $post['form_inetOrgPerson_facsimileTelephoneNumber']; $this->attributes['street'][0] = $post['form_inetOrgPerson_street']; $this->attributes['postalCode'][0] = $post['form_inetOrgPerson_postalCode']; $this->attributes['postalAddress'][0] = $post['form_inetOrgPerson_postalAddress']; $this->attributes['employeeType'][0] = $post['form_inetOrgPerson_employeeType']; if (isset($this->attributes['host'])) { $host = $post['form_inetOrgPerson_host']; if ((!$host=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-])+(([,])+([ ])*([a-z]|[A-Z]|[0-9]|[.]|[-])+)*$', $host)) $errors[] = array('ERROR', _('Unix workstations'), _('Unix workstations is invalid.')); $hosts = explode(" ", $host); $this->attributes['host'] = array(); foreach ($hosts as $host) if ($host!="") $this->attributes['host'][] = $host; } // Check if givenname is valid if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['givenName'][0])) $errors[] = array('ERROR', _('Given name'), _('Given name contains invalid characters')); // Check if surname is valid if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['sn'][0])) $errors[] = array('ERROR', _('Surname'), _('Surname contains invalid characters')); if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['telephoneNumber'][0])) $errors[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!')); if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['mobileTelephoneNumber'][0])) $errors[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!')); if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['facsimileTelephoneNumber'][0])) $errors[] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!')); if ( !ereg('^(([0-9]|[A-Z]|[a-z]|[.]|[-]|[_])+[@]([0-9]|[A-Z]|[a-z]|[-])+([.]([0-9]|[A-Z]|[a-z]|[-])+)*)*$', $this->attributes['mail'][0])) $errors[] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!')); if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['street'][0])) $errors[] = array('ERROR', _('Street'), _('Please enter a valid street name!')); if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['postalAddress'][0])) $errors[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!')); if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['title'][0])) $errors[] = array('ERROR', _('Title'), _('Please enter a valid title!')); if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['employeeType'][0])) $errors[] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!')); if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $this->attributes['personal_postalCode'][0])) $errors[] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!')); // Return error-messages if (is_array($errors)) return $errors; return 0; } /* This function loads all attributes into the object * $attr is an array as it's retured from ldap_get_attributes */ function load_attributes($attr) { // Load attributes which are displayed // unset count entries unset ($attr['count']); $attributes = array_keys($attr); foreach ($attributes as $attribute) unset ($attr[$attribute]['count']); // unset double entries for ($i=0; $iorig[$attribute])) { $this->orig[$attribute] = $attr[$attribute]; // decode as unicode for ($i=0; $iorig[$attribute]); $i++) $this->orig[$attribute][$i] = utf8_decode ($this->orig[$attribute][$i]); } } // Values are kept as copy so we can compare old attributes with new attributes $this->orig['objectClass'][0] = 'inetOrgPerson'; $this->attributes = $this->orig; return 0; } /* This function returns an array with 3 entries: * array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... ) * DN is the DN to change. It may be possible to change several DNs, * e.g. create a new user and add him to some groups via attribute memberUid * add are attributes which have to be added to ldap entry * remove are attributes which have to be removed from ldap entry */ function save_attributes() { $return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig); if (isset($return[$_SESSION[$this->base]->dn]['modify']['userPassword'])) unset($return[$_SESSION[$this->base]->dn]['modify']['userPassword']); return $return; } /* This function returns all ldap attributes * which are part of inetOrgPerson and returns * also their values. */ function get_attributes() { return $this->attributes; } /* This function will create the html-page * to show a page with all attributes. * It will output a complete html-table */ function display_html_attributes($post) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (isset($this->attributes['host'])) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n" ; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
" . _('Description') . "attributes['description'][0]."\">" . _('Help') . "
" . _('Unix workstations') . "attributes['host'])) foreach ($this->attributes['host'] as $host) echo $host." "; echo "\">" . _('Help') . "
" . _('Title') . "attributes['title'][0]."\">" . _('Help') . "
" . _('First name') . "*attributes['givenName'][0]."\">" . _('Help') . "
" . _('Last name') . "*attributes['sn'][0]."\">" . _('Help') . "
" . _('Employee type') . "attributes['employeeType'][0]."\">" . _('Help') . "
" . _('Street') . "attributes['street'][0]."\">" . _('Help') . "
" . _('Postal code') . "attributes['postalCode'][0]."\">" . _('Help') . "
" . _('Postal address') . "attributes['postalAddress'][0]."\">" . _('Help') . "
" . _('Telephone number') . "attributes['telephoneNumber'][0]."\">" . _('Help') . "
" . _('Mobile number') . "attributes['mobileTelephoneNumber'][0]."\">" . _('Help') . "
" . _('Fax number') . "attributes['facsimileTelephoneNumber'][0]."\">" . _('Help') . "
" . _('eMail address') . "attributes['mail'][0]."\">" . _('Help') . "
\n"; return 0; } } ?>