From: hickert Date: Tue, 14 Aug 2007 08:15:14 +0000 (+0000) Subject: Added deactivate user option to divlist in user management X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=32bb26a33a351067747b535378359880077b62d0;p=gosa.git Added deactivate user option to divlist in user management git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7054 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/users/class_divListUsers.inc b/plugins/admin/users/class_divListUsers.inc index 2314a077a..2842145d4 100644 --- a/plugins/admin/users/class_divListUsers.inc +++ b/plugins/admin/users/class_divListUsers.inc @@ -49,7 +49,7 @@ class divListUsers extends MultiSelectWindow $this->AddHeader(array("string"=>" ", "attach"=>"style='width:20px;'")); $this->AddHeader(array("string"=>_("Username")." / "._("Department"))); $this->AddHeader(array("string"=>_("Properties"), "attach" => "style='width:166px;'")); - $this->AddHeader(array("string"=>_("Actions"), "attach" => "style='width:102px;border-right:0px;text-align:right;'")); + $this->AddHeader(array("string"=>_("Actions"), "attach" => "style='width:122px;border-right:0px;text-align:right;'")); $this->AddCheckBox("ShowTemplates" ,_("Select to see template pseudo users") ,_("Show templates") , false); $this->AddCheckBox("ShowFunctionalUsers",_("Select to see users that have only a GOsa object"),_("Show functional users") , true); @@ -167,7 +167,7 @@ class divListUsers extends MultiSelectWindow // Test Every Entry and generate divlist Array foreach($list as $key => $val){ - + /* Create action icons */ $action = ""; @@ -175,6 +175,21 @@ class divListUsers extends MultiSelectWindow $acl= get_permissions ($dn, $this->ui->subtreeACL); $acl= get_module_permission($acl, "user", $dn); + /* 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 = " "; + } + /* Append copy&paste icons if allowed */ if($acl == "#all#" && $this->parent->CopyPasteHandler){ $action .= ""; } + /* Add deactivate status if we are allowed to */ + if (chkacl($acl, "lock_status") == ""){ + $action.= $lock_status; + } + /* Add delete icon if delete user is allowed */ if (chkacl($acl, "delete") == ""){ $action.= " sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); $field3 = array("string" => $UseImg, "attach" => "style='width:166px;'"); $field4 = array("string" => $s_img_create_from_template.preg_replace("/%KEY%/", "$key", $action), - "attach" => "style='width:102px;border-right:0px; text-align:right;'"); + "attach" => "style='width:122px;border-right:0px; text-align:right;'"); /* Add to list */ $add = array($field1,$field2,$field3,$field4); $this->AddElement($add); diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index fbb89c73d..8b3acec2e 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -83,7 +83,8 @@ class userManagement extends plugin "create_user_from_tpl" => "userfrom_tpl", "change_pw" => "user_chgpw", "editPaste" => "editPaste", "copy" => "copy", - "cut" => "cut") as $act => $name){ + "cut" => "cut", + "toggle_lock_status" => "toggle_lock_status" ) as $act => $name){ if (preg_match("/".$name.".*/", $key)){ $s_action= $act; @@ -133,6 +134,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.")); + } + } + } + /******************** Edit existing entry @@ -719,11 +760,11 @@ class userManagement extends plugin $ldap= $this->config->get_ldap_link(TRUE); if ($SubSearch){ $ListTemp = get_list($filter, $this->ui->subtreeACL, $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, $this->ui->subtreeACL, $base, - array("uid", "givenName", "sn", "objectClass"), GL_SIZELIMIT); + array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SIZELIMIT); } $SortTemp = array(); $List = array();