From f1c124851ec2db2e0a1f2b4e42a98756b5905c21 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Mon, 25 Apr 2011 17:57:04 +0000 Subject: [PATCH] allow to lock password --- lam/lib/modules/inetOrgPerson.inc | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index a9d8380f..fb8f47ca 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -861,8 +861,17 @@ class inetOrgPerson extends baseModule implements passwordService { if (!get_preg($this->attributes['cn'][0], 'cn')) { $errors[] = $this->messages['cn'][0]; } + if (isset($_POST['lockPassword'])) { + $this->attributes['userPassword'][0] = pwd_disable($this->attributes['userPassword'][0]); + } + if (isset($_POST['unlockPassword'])) { + $this->attributes['userPassword'][0] = pwd_enable($this->attributes['userPassword'][0]); + } + if (isset($_POST['removePassword'])) { + unset($this->attributes['userPassword']); + } } - + if (isset($_POST['delPhoto'])) { $this->attributes['jpegPhoto'] = array(); } @@ -1022,6 +1031,20 @@ class inetOrgPerson extends baseModule implements passwordService { $managerElement->setSortElements(false); $fieldContainer->addElement($managerElement, true); } + // password buttons + if (!in_array('posixAccount', $modules) && checkIfWriteAccessIsAllowed() && isset($this->attributes['userPassword'][0])) { + $fieldContainer->addElement(new htmlOutputText(_('Password'))); + $pwdContainer = new htmlTable(); + if (pwd_is_enabled($this->attributes['userPassword'][0])) { + $pwdContainer->addElement(new htmlButton('lockPassword', _('Lock password'))); + } + else { + $pwdContainer->addElement(new htmlButton('unlockPassword', _('Unlock password'))); + } + $pwdContainer->addElement(new htmlButton('removePassword', _('Remove password'))); + $pwdContainer->colspan = 2; + $fieldContainer->addElement($pwdContainer); + } // photo $photoFile = '../../graphics/userDefault.png'; $noPhoto = true; @@ -1943,7 +1966,7 @@ class inetOrgPerson extends baseModule implements passwordService { for ($i = 0; $i < sizeof($dnUsers); $i++) { $dnUsers[$i] = $dnUsers[$i]['dn']; } - usort($dnUsers, array($_SESSION['ldap'], 'cmp_array')); + usort($dnUsers, 'compareDN'); array_unshift($dnUsers, '-'); $this->cachedManagers = array(); for ($i = 0; $i < sizeof($dnUsers); $i++) {