From 17f6f84117f760732ec61f7b1f90fc0e960918f4 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 23 Feb 2010 10:35:40 +0000 Subject: [PATCH] Updated manager attribute handling -Let the user select an entry from a list. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15672 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../plugins/personal/generic/class_user.inc | 54 +++++++++++++++---- .../plugins/personal/generic/generic.tpl | 32 ++++++----- 2 files changed, 62 insertions(+), 24 deletions(-) diff --git a/gosa-core/plugins/personal/generic/class_user.inc b/gosa-core/plugins/personal/generic/class_user.inc index 5185fd9a3..60cc909dd 100644 --- a/gosa-core/plugins/personal/generic/class_user.inc +++ b/gosa-core/plugins/personal/generic/class_user.inc @@ -109,6 +109,7 @@ class user extends plugin var $view_logged = FALSE; var $manager = ""; + var $manager_name = ""; /* attribute list for save action */ @@ -258,6 +259,20 @@ class user extends plugin $this->baseSelector->setSubmitButton(false); $this->baseSelector->setHeight(300); $this->baseSelector->update(true); + + + // Detect the managers name + $this->manager_name = ""; + $ldap = $this->config->get_ldap_link(); + if(!empty($this->manager)){ + $ldap->cat($this->manager, array('cn')); + if($ldap->count()){ + $attrs = $ldap->fetch(); + $this->manager_name = $attrs['cn'][0]; + }else{ + $this->manager_name = "("._("Unknown")."!): ".$this->manager; + } + } } @@ -289,21 +304,37 @@ class user extends plugin new log("view","users/".get_class($this),$this->dn); } + // Clear manager attribute if requested + if(preg_match("/ removeManager/i", " ".implode(array_keys($_POST),' ')." ")){ + $this->manager = ""; + } + + // Allow to select a new inetOrgPersion:manager + if(preg_match("/ editManager/i", " ".implode(array_keys($_POST),' ')." ")){ + $this->dialog = new singleUserSelect($this->config, get_userinfo()); + } + if($this->dialog && count($this->dialog->detectPostActions())){ + $users = $this->dialog->detectPostActions(); + if(isset($users['targets']) && count($users['targets'])){ + + $headpage = $this->dialog->getHeadpage(); + $dn = $users['targets'][0]; + $attrs = $headpage->getEntry($dn); + $this->manager = $dn; + $this->manager_name = $attrs['cn'][0]; + $this->dialog = NULL; + } + } + if(isset($_POST['add_users_cancel'])){ + $this->dialog = NULL; + } + if($this->dialog) return($this->dialog->execute()); + + $smarty= get_smarty(); $smarty->assign("usePrototype", "true"); $smarty->assign("gosaLoginRestrictionWidget", $this->gosaLoginRestrictionWidget->render()); - /* Assign managers */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current["BASE"]); - $ldap->search("(objectClass=inetOrgPerson)", array("cn", "dn")); - $managers = array(); - while($attrs = $ldap->fetch()) { - $managers[$attrs["dn"]] = $attrs["cn"][0]; - } - asort($managers); - $smarty->assign("managers", $managers); - /* Assign sex */ $sex= array(0 => " ", "F" => _("female"), "M" => _("male")); $smarty->assign("gender_list", $sex); @@ -677,6 +708,7 @@ class user extends plugin $smarty->assign("has_phoneaccount", "false"); } $smarty->assign("multiple_support" , $this->multiple_support_active); + $smarty->assign("manager_name",$this->manager_name); return($smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__)))); } diff --git a/gosa-core/plugins/personal/generic/generic.tpl b/gosa-core/plugins/personal/generic/generic.tpl index 7d7a2e735..77a9c1489 100644 --- a/gosa-core/plugins/personal/generic/generic.tpl +++ b/gosa-core/plugins/personal/generic/generic.tpl @@ -316,19 +316,6 @@ {render acl=$departmentNumberACL checkbox=$multiple_support checked=$use_departmentNumber} -{/render} - - - - - -{render acl=$managerACL checkbox=$multiple_support checked=$use_manager} - {/render} @@ -348,6 +335,25 @@ {/render} + {if !$multiple_support} + + + +{render acl=$managerACL} + +{/render} +{render acl=$managerACL} + +{/render} + {if $manager!=""} +{render acl=$managerACL} + +{/render} + {/if} + + + {/if} -- 2.30.2