base = $base; // Do some error checks if (!$base) trigger_error(_('Please create a base object with $var = new accountContainer();'), E_USER_ERROR); if (!is_string($base)) trigger_error(_('Please create a new module object with $accountContainer->add_objectClass(\'account\');'), E_USER_ERROR); if ($_SESSION[$this->base]->get_type() != 'host') trigger_error(_('account can only be used for hosts.'), E_USER_WARNING); // load attribtues which are used in account objectClass $this->attributes = $_SESSION[$this->base]->get_module_attributes('account'); // Create copy of attributes $this->orig = $this->attributes ; // Add objectClass to attributes $this->attributes['objectClass'][0] = 'account'; // Set aliasname $this->alias = _('account'); } // Variables // Alias Name. This name is shown in the menu instead of 'account' var $alias; // name of account_container in session so we can read other classes in account_container var $base; // This variable contains all account 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'); } /* This function returns true if all required attributes from other * modules are set. This is required to prevent undefined states */ function module_ready() { return true; } /* This function returns a list of all html-pages in module * This is usefull for mass upload and pdf-files * because lam can walk trough all pages itself and do some * error checkings */ function pages() { return array('attributes'); } /* Write variables into object and do some regexp checks */ function proccess_attributes($post) { // Load attributes $this->attributes['description'][0] = $post['form_account_description']; 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) { // 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]); } } // Add objectClass to orig because we don't want to add objectClass if it's already set $this->orig['objectClass'][0] = 'account'; // Values are kept as copy so we can compare old attributes with new attributes $this->attributes = $this->orig; return 0; } /* This function returns an array with 4 entries: * array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr), 'lamdaemon' => array(cmds)), 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 * lamdaemon are lamdaemon commands to modify homedir, quotas, ... */ function save_attributes() { // Get easy attributes $return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig); // Return attributes return $return; } /* This function returns all ldap attributes * which are part of account 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\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
" . _('Description') . "attributes['description'][0]."\">" . _('Help') . "
\n"; return 0; } } ?>