/** * This function loads all needed attributes into the object. * * @param array $attr an array as it is retured from ldap_get_attributes */ function load_attributes($attr) { $this->attributes['objectClass'] = array(); $this->attributes['macAddress'] = array(); $this->orig['objectClass'] = array(); $this->orig['macAddress'] = array(); if (isset($attr['objectClass'])) { unset($attr['objectClass']['count']); $this->attributes['objectClass'] = $attr['objectClass']; $this->orig['objectClass'] = $attr['objectClass']; } if (isset($attr['macAddress'])) { unset($attr['macAddress']['count']); $this->attributes['macAddress'] = $attr['macAddress']; $this->orig['macAddress'] = $attr['macAddress']; } return 0; } |
/** * This function will create the meta HTML code to show a page with all attributes. * * @param array $post HTTP-POST values */ function display_html_attributes($post) { $return = array(); // list current MACs for ($i = 0; $i < sizeof($this->attributes['macAddress']); $i++) { $return[] = array( array('kind' => 'text', 'text' => _('MAC address')), array('kind' => 'input', 'name' => 'macAddress' . $i, 'type' => 'text', 'size' => '17', 'maxlength' => '17', 'value' => $this->attributes['macAddress'][$i]), array('kind' => 'input', 'type' => 'submit', 'name' => 'delMAC' . $i, 'value' => _("Remove")), array('kind' => 'help', 'value' => 'mac')); } // input box for new MAC $return[] = array( array('kind' => 'text', 'text' => _('New MAC address')), array('kind' => 'input', 'name' => 'macAddress', 'type' => 'text', 'size' => '17', 'maxlength' => '17', 'value' => ''), array('kind' => 'input', 'type' => 'submit', 'name' => 'addMAC', 'value' => _("Add")), array('kind' => 'help', 'value' => 'mac'), array('kind' => 'input', 'type' => 'hidden', 'value' => sizeof($this->attributes['macAddress']), 'name' => 'mac_number')); return $return; } |
/** * Write variables into object and do some regex checks * * @param array $post HTTP-POST values */ function process_attributes($post) { $errors = array(); $this->attributes['macAddress'] = array(); // check old MACs if (isset($post['mac_number'])) { for ($i = 0; $i < $post['mac_number']; $i++) { if (isset($post['delMAC' . $i])) continue; if (isset($post['macAddress' . $i]) && ($post['macAddress' . $i] != "")) { // check if address has correct format if (!get_preg($post['macAddress' . $i], 'macAddress')) { $message = $this->messages['mac'][0]; $message[] = $post['macAddress' . $i]; $errors[] = $message; } $this->attributes['macAddress'][] = $post['macAddress' . $i]; } } } // check new MAC if (isset($post['macAddress']) && ($post['macAddress'] != "")) { // check if address has correct format if (get_preg($post['macAddress'], 'macAddress')) { $this->attributes['macAddress'][] = $post['macAddress']; } else { $message = $this->messages['mac'][0]; $message[] = $post['macAddress']; $errors[] = $message; } } $this->attributes['macAddress'] = array_unique($this->attributes['macAddress']); return $errors; } |
/** * This function is used to check if this module page can be displayed. * It returns false if a module depends on data from other modules which was not yet entered. * * @return boolean true, if page can be displayed */ function module_ready() { if ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]=='') return false; if ($_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]=='') return false; if ($this->attributes['uid'][0]=='') return false; return true; } /** * This functions is used to check if all settings for this module have been made. * * @return boolean true, if settings are complete */ function module_complete() { if (!$this->module_ready()) return false; if ($this->attributes['sambaSID'][0] == '') return false; return true; } |
/** * Returns a list of modifications which have to be made to the LDAP account. * * @return array list of modifications * <br>This function returns an array with 3 entries: * <br>array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... ) * <br>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) * <br>"add" are attributes which have to be added to LDAP entry * <br>"remove" are attributes which have to be removed from LDAP entry * <br>"modify" are attributes which have to been modified in LDAP entry */ function save_attributes() { // add object class if needed if (!isset($this->attributes['objectClass']) || !in_array('kolabInetOrgPerson', $this->attributes['objectClass'])) { $this->attributes['objectClass'][] = 'kolabInetOrgPerson'; } return parent::save_attributes(); } |