config = $config; $this->ui = $ui; // Build filter $filter = new filter(get_template_path("user-filter.xml", true)); $filter->setObjectStorage("ou=people,"); // Build headpage $headpage = new listing(get_template_path("user-list.xml", true)); $headpage->registerElementFilter("lockLabel", "userManagement::filterLockLabel"); $headpage->registerElementFilter("lockImage", "userManagement::filterLockImage"); $headpage->setFilter($filter); $this->cpHandler = new CopyPasteHandler($this->config); $this->snapHandler = new SnapshotHandler($this->config); parent::__construct($config, $ui, "users", $headpage); $this->registerAction("new", "newEntry"); $this->registerAction("edit", "editEntry"); $this->registerAction("apply", "applyChanges"); $this->registerAction("save", "saveChanges"); $this->registerAction("cancel", "cancelEdit"); $this->registerAction("remove", "removeEntryRequested"); $this->registerAction("removeConfirmed", "removeEntryConfirmed"); $this->registerAction("copy", "copyPasteHandler"); $this->registerAction("cut", "copyPasteHandler"); $this->registerAction("paste", "copyPasteHandler"); $this->registerAction("lock", "lockEntry"); $this->registerAction("unlock", "alert"); $this->registerAction("new_template", "newTemplate"); } function lockEntry($action,$entry) { $disallowed = array(); $dns = array(); foreach($entry as $dn){ if (!preg_match("/w/",$this->ui->get_permissions($dn,"users/password"))){ $disallowed[] = $dn; }else{ $allowed[] = $dn; } } if(count($disallowed)){ msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG); } $ldap = $this->config->get_ldap_link(); foreach($allowed as $dn){ $ldap->cat($dn, array('userPassword')); if($ldap->count() == 1){ $val = $ldap->fetch(); $pwd = $val['userPassword'][0]; $method = passwordMethod::get_method($pwd,$val['dn']); $success= false; if($method instanceOf passwordMethod){ if($method->is_locked($this->config,$val['dn'])){ $success= $method->unlock_account($this->config,$val['dn']); }else{ $success= $method->lock_account($this->config,$val['dn']); } /* Check for success */ if (!$success){ $hn= $method->get_hash_name(); if (is_array($hn)){ $hn= $hn[0]; } msg_dialog::display(_("Account locking"), sprintf(_("Password method '%s' does not support locking. Account has not been locked!"), $hn),WARNING_DIALOG); } }else{ // Can't lock unknown methods. } } } } function alert($action,$values) { print_a(array($action,$values)); } function newTemplate($action,$entry) { $this->newEntry(); $this->tabObject->set_template_mode (); } static function filterLockImage($userPassword) { $image= "images/empty.png"; if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){ if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){ $image= "images/lists/locked.png"; }else{ $image= "images/lists/unlocked.png"; } } return $image; } static function filterLockLabel($userPassword) { $label= ""; if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){ if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){ $label= _("Unlock account"); }else{ $label= _("Lock account"); } } return $label; } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>