From f02c3d5bea4a67ab8b9a2238bad3a71a7f7920bf Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 16 Sep 2010 11:38:58 +0000 Subject: [PATCH] Added user selection git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19706 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../goto/admin/systems/goto/Device/Device.tpl | 24 +++++- .../systems/goto/Device/class_Device.inc | 76 ++++++++++++++++++- 2 files changed, 97 insertions(+), 3 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/goto/Device/Device.tpl b/gosa-plugins/goto/admin/systems/goto/Device/Device.tpl index 3a99b999f..d07dfeecf 100644 --- a/gosa-plugins/goto/admin/systems/goto/Device/Device.tpl +++ b/gosa-plugins/goto/admin/systems/goto/Device/Device.tpl @@ -37,9 +37,20 @@ + + - + + + + {image path="images/lists/edit.png" action="editOwner" acl=$ownerACL} + {if $owner!=""} + {image path="images/info_small.png" title="{$owner}" acl=$ownerACL} + {image path="images/lists/trash.png" action="removeOwner" acl=$ownerACL} + {/if} + @@ -48,7 +59,16 @@ - + diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc index be4276193..f336a2738 100644 --- a/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc +++ b/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc @@ -30,6 +30,8 @@ class Device extends plugin public $base = ""; public $orig_dn =""; + + private $resolvedNamesCache = array(); function __construct(&$config, $dn) { @@ -38,20 +40,92 @@ class Device extends plugin $this->orig_dn = $this->dn; } + function execute() { plugin::execute(); + + if($this->dialog instanceOf singleUserSelect) return($this->dialog->execute()); + + $smarty = get_smarty(); + + // Assign ACL settings + $plInfo = $this->plInfo(); + foreach($plInfo['plProvidedAcls'] as $name => $desc){ + $smarty->assign("{$name}ACL", $this->getacl($name)); + } + + // Assign just user names instead of the complete dn. + $smarty->assign("owner_name", $this->getUserName($this->owner)); + $smarty->assign("manager_name", $this->getUserName($this->manager)); + foreach($this->attributes as $attr){ $smarty->assign($attr, $this->$attr); } return($smarty->fetch(get_template_path('goto/Device/Device.tpl', TRUE))); } + + /*! \brief Detect an object's name by querying the ldap + * for the object's cn. + * @param String The object's dn to query for. + */ + function getUserName($dn) + { + // First asked the cache if we've already queried this name. + if(isset($this->resolvedNamesCache[$dn])) { + return($this->resolvedNamesCache[$dn]); + } - function save() + // Try to detect the object's name via ldap search. + $ldap = $this->config->get_ldap_link(); + $this->resolvedNamesCache[$dn] = ""; + if(!empty($dn)){ + $ldap->cat($dn, array('cn')); + if($ldap->count()){ + $attrs = $ldap->fetch(); + $this->resolvedNamesCache[$dn] = $attrs['cn'][0]; + return( $attrs['cn'][0]); + }else{ + $this->resolvedNamesCache[$dn] = "("._("unknown")."!): ".$dn; + } + } + return($this->resolvedNamesCache[$dn]); + } + + + function save_object() { + plugin::save_object(); + if(isset($_POST['editOwner'])){ + $this->currentUserSelect = "owner"; + $this->dialog = new singleUserSelect($this->config, get_userinfo()); + } + if(isset($_POST['editManager'])){ + $this->currentUserSelect = "manager"; + $this->dialog = new singleUserSelect($this->config, get_userinfo()); + } + if($this->dialog && $this->dialog instanceOf singleUserSelect && count($this->dialog->detectPostActions())){ + $users = $this->dialog->detectPostActions(); + if(isset($users['action']) && $users['action'] == 'userSelected' && isset($users['targets']) && count($users['targets'])){ + $headpage = $this->dialog->getHeadpage(); + $dn = $users['targets'][0]; + $attr = $this->currentUserSelect; + $this->$attr = $dn; + $this->dialog = NULL; + } + } + if(isset($_POST['add_users_cancel'])){ + $this->dialog = NULL; + } + + } + + + function save() + { plugin::save(); // Append and remove dynmic object classes -- 2.30.2
+ + + {image path="images/lists/edit.png" action="editManager" acl=$managerACL} + {if $manager!=""} + {image path="images/info_small.png" title="{$manager}" acl=$managerACL} + {image path="images/lists/trash.png" action="removeManager" acl=$managerACL} + {/if} +