Code

Updated role listing
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 20 Apr 2010 12:23:49 +0000 (12:23 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 20 Apr 2010 12:23:49 +0000 (12:23 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17736 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/rolemanagement/admin/roleManagement/class_roleGeneric.inc
gosa-plugins/rolemanagement/admin/roleManagement/roleGeneric.tpl

index 132f3d7e37ab65ed832c158808398207538824e9..9d04d137b054bc3533fe1b2b8c5fc0af7763c06d 100644 (file)
@@ -86,6 +86,17 @@ class roleGeneric extends plugin {
     $this->baseSelector->setSubmitButton(false);
     $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("~",_("Name")));
+    $this->memberList->setColspecs(array('20px','*','20px'));
+    $this->memberList->setDefaultSortColumn(1);
   }
 
 
@@ -152,6 +163,12 @@ class roleGeneric extends plugin {
     if(isset($_POST['edit_membership']) && !$this->dialog instanceOf userSelect){
       $this->dialog = new userSelect($this->config,get_userinfo());
     }
+    $this->memberList->save_object();
+    $action = $this->memberList->getAction();
+    if($action['action'] == 'delete'){
+        $this->roleOccupant = $this->memberList->getMaintainedData();
+    }
+
     if(isset($_POST['delete_membership']) && !$this->dialog instanceOf userSelect){
       if(isset($_POST['members'])){
         foreach($_POST['members'] as $id){
@@ -191,11 +208,32 @@ class roleGeneric extends plugin {
      * Template handling
      ***************/
 
+    $this->memberList->setAcl($this->getacl("roleOccupant"));
+
+    $data = $lData = array();
+    $icon = image('plugins/generic/images/head.png');
+    foreach ($this->roleOccupant as $key => $dn){
+      $data[$key] = $dn;
+      if(isset($this->roleOccCache[$dn])){
+        $entry = $this->roleOccCache[$dn];
+        $name = $entry['cn']['0'];
+        if(isset($entry['description'][0])){
+          $name .= " [".$entry['description'][0]."]";
+        }
+      }else{
+        $name = _("Unknown")."&nbsp;".$dn;
+      }
+      $lData[$key] = array('data' => array($icon,$name));
+    }
+
+    $this->memberList->setListData($data,$lData);
+    $this->memberList->update();
+
     // Get smarty instance and assign required variables.
     $smarty = get_smarty();
     $smarty->assign("usePrototype", "true");
     $smarty->assign("base", $this->baseSelector->render());
-    $smarty->assign("members",$this->convert_list());
+    $smarty->assign("memberList",$this->memberList->render());
     foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
     }
@@ -252,28 +290,6 @@ class roleGeneric extends plugin {
   }
   
 
-  /* Returns list of occupants as <html><option> statements.
-   */
-  function convert_list()
-  {
-    $temp= "";
-    $icon = " style=\"background-image:url('plugins/generic/images/head.png');\" ";
-    foreach ($this->roleOccupant as $key => $dn){
-      if(isset($this->roleOccCache[$dn])){
-        $entry = $this->roleOccCache[$dn];
-        $name = $entry['cn']['0'];
-        if(isset($entry['description'][0])){
-          $name .= " [".$entry['description'][0]."]";
-        }
-      }else{
-        $name = _("Unknown")."&nbsp;".$dn;
-      }
-      $temp.= "<option {$icon} title='{$dn}' value='$key' class='select'>{$name}</option>\n";
-    }
-    return ($temp);
-  }
-
   /* Removes the object from the ldap database
    */ 
   function remove_from_parent()
index 90cd60dde93e2b1d7368100e99ba1b475fbc946c..37bc8cb0cd4806413f0607b97d3d1e266aa4dc5b 100644 (file)
       </h3>
 
 {render acl=$roleOccupantACL}
-      <select style="width:100%; height:450px;" id="members" name="members[]" size="15" multiple>
-        {$members}
-      </select>
+      {$memberList}
 {/render}
       <br>
 {render acl=$roleOccupantACL}
       <button type='submit' name='edit_membership'>{msgPool type=addButton}</button>&nbsp;
-
-{/render}
-{render acl=$roleOccupantACL}
-      <button type='submit' name='delete_membership'>{msgPool type=delButton}</button>
-
 {/render}
     </td>
   </tr>