From 94bb62e8df90fee5e738494672a025d0ec49c348 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 14 Aug 2007 08:28:45 +0000 Subject: [PATCH] Added lock/unlock button to user management list git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7055 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/users/class_divListUsers.inc | 27 ++++++++++-- plugins/admin/users/class_userManagement.inc | 45 +++++++++++++++++++- 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/plugins/admin/users/class_divListUsers.inc b/plugins/admin/users/class_divListUsers.inc index b1d5d201e..c796b1869 100644 --- a/plugins/admin/users/class_divListUsers.inc +++ b/plugins/admin/users/class_divListUsers.inc @@ -46,7 +46,7 @@ class divListUsers extends MultiSelectWindow $this->EnableSaveButton (false); /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 104; + $action_col_size = 122; if($this->parent->snapshotEnabled()){ $action_col_size += 38; } @@ -163,7 +163,6 @@ class divListUsers extends MultiSelectWindow "  "; - /* Multiple options */ $listhead .= "  "; @@ -204,7 +203,7 @@ class divListUsers extends MultiSelectWindow $editlink = "%s"; /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 104; + $action_col_size = 122; if($this->parent->snapshotEnabled()){ $action_col_size += 38; } @@ -251,7 +250,7 @@ class divListUsers extends MultiSelectWindow // Test Every Entry and generate divlist Array foreach($list as $key => $val){ - + /* Create action icons */ $action= ""; @@ -265,10 +264,30 @@ class divListUsers extends MultiSelectWindow src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> "; } + /* Add deactivate status */ + $lock_status = ""; + + if(isset($val['userPassword'][0]) && preg_match("/^\{[^\}]/",$val['userPassword'][0])){ + if(preg_match("/^[^\}]*+\}!/",$val['userPassword'][0])){ + $lock_status = ""; + }else{ + $lock_status = ""; + } + }else{ + $lock_status = " "; + } + /* Generate edit icon */ $action.= ""; + /* Add deactivate status if we are allowed to */ + if (preg_match("/w/",$acl_all)){ + $action.= $lock_status; + } + /* Add Password change icon, if we are able to write users/password */ if(!in_array_ics("gosaUserTemplate",$val['objectClass']) && preg_match("/w/",$ui->get_permissions($val['dn'],"users/password"))) { $action.= " "multiple_copy_users", "cut_multiple" => "multiple_cut_users", "copy" => "^copy", + "toggle_lock_status" => "toggle_lock_status", "cut" => "^cut") as $act => $name){ if (preg_match("/".$name.".*/", $key)){ @@ -378,6 +379,46 @@ class userManagement extends plugin } } + + /******************** + Toggle lock status for user + ********************/ + + if($s_action == "toggle_lock_status" && isset($this->list[$s_entry])){ + + /* Get entry check current status */ + $val = $this->list[$s_entry]; + $pwd = $val['userPassword'][0]; + + if(!preg_match("/^\{[^\}]/",$pwd)){ + trigger_error("Can not deactivate user which is using clear password encryption."); + }else{ + + $locked = false; + if(preg_match("/^[^\}]*+\}!/",$pwd)){ + $locked = true; + } + + /* Create ldap array to update status */ + $attrs = array("userPassword" => $pwd); + if($locked){ + $attrs['userPassword'] = preg_replace("/(^[^\}]+\})!(.*$)/","\\1\\2",$attrs['userPassword']); + }else{ + $attrs['userPassword'] = preg_replace("/(^[^\}]+\})(.*$)/","\\1!\\2",$attrs['userPassword']); + } + + /* Write new status back to ldap */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($val['dn']); + $ldap->modify($attrs); + if($locked){ + show_ldap_error($ldap->get_error(),_("Could not set user status from locked to unlocked.")); + }else{ + show_ldap_error($ldap->get_error(),_("Could not set user status from unlocked to locked.")); + } + } + } + /******************** Delete entry requested, display confirm dialog @@ -832,11 +873,11 @@ class userManagement extends plugin if ($SubSearch){ $ListTemp = get_list($filter, "users", $base, - array("uid", "givenName", "sn", "objectClass"), GL_SUBSEARCH | GL_SIZELIMIT); + array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SUBSEARCH | GL_SIZELIMIT); } else { $base= get_people_ou().$base; $ListTemp = get_list($filter, "users", $base, - array("uid", "givenName", "sn", "objectClass"), GL_SIZELIMIT); + array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SIZELIMIT); } $SortTemp = array(); $List = array(); -- 2.30.2