Code

Updated manager attribute handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 23 Feb 2010 10:35:40 +0000 (10:35 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 23 Feb 2010 10:35:40 +0000 (10:35 +0000)
-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

gosa-core/plugins/personal/generic/class_user.inc
gosa-core/plugins/personal/generic/generic.tpl

index 5185fd9a35dca2b1b545e017b3502114a985f5d3..60cc909dd0d86c2830313a22d7f44c7b639d05b4 100644 (file)
@@ -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 => "&nbsp;", "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__))));
   }
 
index 7d7a2e7356571c4d01572fa6d605e90011e84c8e..77a9c1489943ae77eeafdded3bc2fa736f4a5fd1 100644 (file)
      <td>
 {render acl=$departmentNumberACL checkbox=$multiple_support checked=$use_departmentNumber}
              <input type="text" id="departmentNumber" name="departmentNumber" size=22 maxlength=60 value="{$departmentNumber}">
-{/render}
-     </td>
-    </tr>
-    <tr>
-     <td><label for="manager">{t}Manager{/t}</label></td>
-     <td>
-{render acl=$managerACL checkbox=$multiple_support checked=$use_manager}
-       <select id="manager" name="manager">
-               <option value="">None</option>
-               {foreach item=cn key=dn from=$managers}
-                       <option value="{$dn}" {if $manager == $dn}selected="selected"{/if}>{$cn}</option>
-               {/foreach}>
-       </select>
 {/render}
      </td>
     </tr>
 {/render}
      </td>
     </tr>
+    {if !$multiple_support}
+    <tr>
+     <td><label for="manager">{t}Manager{/t}</label></td>
+     <td>
+{render acl=$managerACL}
+        <input type='text' name='manager_name' id='manager_name' value='{$manager_name}' disabled
+          title='{$manager}'>
+{/render}
+{render acl=$managerACL}
+        <input type='image' src='images/lists/edit.png' name='editManager' class='center'>
+{/render}
+        {if $manager!=""}
+{render acl=$managerACL}
+        <input type='image' src='images/lists/trash.png' name='removeManager' class='center'>
+{/render}
+        {/if}
+     </td>
+    </tr>
+    {/if}
    </table>
   </td>