Code

Replaced user list in groups
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 20 Apr 2010 13:46:41 +0000 (13:46 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 20 Apr 2010 13:46:41 +0000 (13:46 +0000)
-Multi edit still missing

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17744 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/admin/groups/class_group.inc
gosa-core/plugins/admin/groups/generic.tpl

index ac7ebe894a93bd2c5cdd5056d139f546868753cb..330718c50e9417921cadabd00199af8b558247f6 100644 (file)
@@ -191,6 +191,17 @@ class group extends plugin
     $this->baseSelector->setHeight(300);
     $this->baseSelector->update(true);
 
+    // Prepare lists
+    $this->memberList = new sortableListing();
+    $this->memberList->setDeleteable(true);
+    $this->memberList->setInstantDelete(true);
+    $this->memberList->setEditable(false);
+    $this->memberList->setWidth("100%");
+    $this->memberList->setHeight("300px");
+    $this->memberList->setHeader(array('~',_("Given name"),_("Surename"),_("Uid")));
+    $this->memberList->setColspecs(array('20px','*','*','*','20px'));
+    $this->memberList->setDefaultSortColumn(1);
+
     $this->reload(TRUE);
   }
 
@@ -212,8 +223,11 @@ class group extends plugin
     }
 
     /* Delete user from group */
-    if (isset($_POST['del_users']) && isset($_POST['members']) && preg_match("/w/",$this->getacl("memberUid"))){
-      foreach ($_POST['members'] as $value){
+    $this->memberList->save_object();
+    $action = $this->memberList->getAction();
+    if($action['action'] == 'delete' && preg_match("/w/",$this->getacl("memberUid"))){
+      foreach ($action['targets'] as $id){
+        $value = $this->memberList->getKey($id);
         unset ($this->members["$value"]);
         $this->removeUser($value);
       }
@@ -301,7 +315,28 @@ class group extends plugin
     
 
     /* Members and users */
-    $smarty->assign("members", $this->members);
+    $this->memberList->setAcl($this->getacl("memberUid"));
+    $data = $lData = array();
+
+    foreach($this->members as $uid => $member){
+        
+        $data[$uid] = $member;
+        $givenName = $sn = _("Unknown");
+        if(isset($member['sn'][0])) $sn = $member['sn'][0];
+        if(isset($member['givenName'][0])) $givenName = $member['givenName'][0];
+        
+        $image = image('images/false.png');
+        if(isset($member['sn'])){
+            $image = image('plugins/users/images/select_user.png');
+        }
+
+        $lData[$uid] = array('data' => array($image,$sn, $givenName, $uid));
+    }
+
+    $this->memberList->setListData($data,$lData);
+    $this->memberList->update();
+
+    $smarty->assign("memberList", $this->memberList->render());
 
     /* Checkboxes */
     foreach (array("force_gid", "smbgroup") as $val){
@@ -401,8 +436,8 @@ class group extends plugin
       }else{
         while($attrs = $ldap->fetch()){
           $this->dnMapping[$attrs['uid'][0]] = $attrs['dn'];
-          $this->members[$attrs['uid'][0]] = $this->createResultName($attrs);
-          $this->allusers[$attrs['uid'][0]]= $this->createResultName($attrs);
+          $this->members[$attrs['uid'][0]] = $attrs;
+          $this->allusers[$attrs['uid'][0]]= $atrts;
         }
       }
     }
@@ -457,8 +492,8 @@ class group extends plugin
       $ldap->search("(&(objectClass=gosaAccount)(|".$filter."))",array("dn", "uid","sn","givenName"));
       while($attrs = $ldap->fetch()){
         $this->dnMapping[$attrs['uid'][0]] = $attrs['dn'];
-        $this->members[$attrs['uid'][0]] = $this->createResultName($attrs);
-        $this->allusers[$attrs['uid'][0]]= $this->createResultName($attrs);
+        $this->members[$attrs['uid'][0]] = $attrs;
+        $this->allusers[$attrs['uid'][0]]= $attrs;
       } 
     }
   
@@ -467,18 +502,14 @@ class group extends plugin
         count($this->memberUid) < $this->config->get_cfg_value("ldapFilterNestingLimit")){
       foreach ($this->memberUid as $value){
         if(!isset($this->members[$value])){
-          $this->members[$value] =  _("! unknown UID")." [".$value."]"; 
+          $this->members[$value] = "";
         }
       }  
     }else{
       foreach ($this->memberUid as $value){
-        $this->members[$value] = $value; 
+        $this->members[$value] = "";
       }  
     }
-  
-    /* Sort lists */
-    natcasesort($this->members);
-    reset($this->members);
   }
 
 
index 5e4c64ade37dde90b4453549106bbcdbb49559e0..0df8e52d17e61ab055f45da0f62a0d8d06ba5056 100644 (file)
      <td style="width:50%">
       <b><LABEL for="members">{t}Group members{/t}</LABEL></b>
       <br>
-{render acl=$memberUidACL}
 
        {if $multiple_support}
+{render acl=$memberUidACL}
          <select style="width:100%; height:380px;" id="members" name="members[]" size=15 multiple>
                {foreach from=$memberUid_All item=name key=key}
                        <option value="{$key}">{$name}&nbsp;({t}In all groups{/t})</option>
         <option value="{$key}" style='color: #888888; background: #DDDDDD;background-color: #DDDDDD;'>{$name}&nbsp;({t}Not in all groups{/t})</option>
                {/foreach}
          </select>
+{/render}
        {else}
-      <select style="width:100%; height:380px;" id="members" name="members[]" size=15 multiple>
-       {html_options options=$members}
-               <option disabled>&nbsp;</option>
-      </select>
+        {render acl=$memberUidACL}
+            {$memberList}
+        {/render}
        {/if}
-{/render}
       <br>
 {render acl=$memberUidACL}
       <button type='submit' name='edit_membership'>{msgPool type=addButton}</button>