Code

Updated ogroup to use the new listing
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 20 Apr 2010 06:46:44 +0000 (06:46 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 20 Apr 2010 06:46:44 +0000 (06:46 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17721 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/admin/ogroups/class_ogroup.inc
gosa-core/plugins/admin/ogroups/generic.tpl

index 79913f63ed8dd234b27fb832308ecf9bc4c9a810..f793e779a9fcec4f2236d3b3985b9b2e138892c2 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/* Sort multidimensional arrays for key 'text' */
-function sort_list($val1, $val2)
-{
-  $v1= strtolower($val1['text']);
-  $v2= strtolower($val2['text']);
-  if ($v1 > $v2){
-    return 1;
-  }
-  if ($v1 < $v2){
-    return -1;
-  }
-  return 0;
-}
-
-
 class ogroup extends plugin
 {
-  /* Variables */
-  var $cn= "";
-  var $description= "";
-  var $base= "";
-  var $gosaGroupObjects= "";
-  var $objects= array();
-  var $objcache= array();
-  var $memberList= array();
-  var $member= array();
-  var $orig_dn= "";
-  var $orig_cn= "";
-  var $orig_base= "";
-  var $objectSelect= FALSE;
-  var $view_logged = FALSE;
-
-  var $baseSelector;
-
-  /* Already assigned Workstations. Will be hidden in selection. 
-   */
-  var $used_workstations = array();
-
-  /* attribute list for save action */
-  var $attributes= array("cn", "description", "gosaGroupObjects","member");
-  var $objectclasses= array("top", "gosaGroupOfNames");
+    var $typeToClass = array(  
+            "Y" => "gosaUserTemplate",
+            "U" => "gosaAccount",
+            "G" => "posixGroup",
+            "A" => "gosaApplication",
+            "D" => "gosaDepartment",
+            "S" => "goServer",
+            "W" => "gotoWorkstation",
+            "O" => "opsiClient",
+            "T" => "gotoTerminal",
+            "F" => "goFonHardware",
+            "P" => "gotoPrinter");
+
+    var  $typeToImage = array(
+            "Y" => "plugins/users/images/select_template.png",
+            "U" => "plugins/users/images/select_user.png",
+            "G" => "plugins/groups/images/select_group.png",
+            "A" => "plugins/ogroups/images/application.png",
+            "D" => "plugins/departments/images/department.png",
+            "S" => "plugins/ogroups/images/server.png",
+            "W" => "plugins/ogroups/images/workstation.png",
+            "O" => "plugins/ogroups/images/winstation.png",
+            "T" => "plugins/ogroups/images/terminal.png",
+            "F" => "plugins/ogroups/images/phone.png",
+            "P" => "plugins/ogroups/images/printer.png",
+            "I" => "images/false.png");
+
+
+    /* Variables */
+    var $cn= "";
+    var $description= "";
+    var $base= "";
+    var $gosaGroupObjects= "";
+    var $objects= array();
+    var $objcache= array();
+    var $memberList= array();
+    var $member= array();
+    var $orig_dn= "";
+    var $orig_cn= "";
+    var $orig_base= "";
+    var $objectSelect= FALSE;
+    var $view_logged = FALSE;
+
+    var $baseSelector;
+
+    /* Already assigned Workstations. Will be hidden in selection. 
+     */
+    var $used_workstations = array();
+
+    /* attribute list for save action */
+    var $attributes= array("cn", "description", "gosaGroupObjects","member");
+    var $objectclasses= array("top", "gosaGroupOfNames");
 
   function ogroup (&$config, $dn= NULL)
   {
@@ -131,6 +144,16 @@ class ogroup extends plugin
     $this->baseSelector->setSubmitButton(false);
     $this->baseSelector->setHeight(300);
     $this->baseSelector->update(true);
+    
+    // Prepare lists
+    $this->memberListing = new sortableListing();
+    $this->memberListing->setDeleteable(true);
+    $this->memberListing->setEditable(false);
+    $this->memberListing->setWidth("100%");
+    $this->memberListing->setHeight("300px");
+    $this->memberListing->setHeader(array("~",_("Name")));
+    $this->memberListing->setColspecs(array('20px','*','20px'));
+    $this->memberListing->setDefaultSortColumn(1);
 
     $this->reload();
   }
@@ -144,19 +167,15 @@ class ogroup extends plugin
 
       $this->memberList[$NewMember]= $this->objcache[$NewMember];
       unset ($this->objects[$NewMember]);
-      uasort ($this->memberList, 'sort_list');
       reset ($this->memberList);
       $this->reload(); 
     }else{
-      /* Delete objects from group */
-      if (isset($_POST['delete_membership']) && isset($_POST['members'])){
-        foreach ($_POST['members'] as $value){
-          $this->objects["$value"]= $this->memberList[$value];
-          unset ($this->memberList["$value"]);
-          unset ($this->member["$value"]);
-          uasort ($this->objects, 'sort_list');
-          reset ($this->objects);
-        }
+
+      // Act on list modifications 
+      $this->memberListing->save_object();
+      $action = $this->memberListing->getAction();
+      if($action['action'] == 'delete'){
+        $this->member = $this->memberListing->getMaintainedData();
         $this->reload();
       }
 
@@ -192,7 +211,6 @@ class ogroup extends plugin
 
             $this->memberList["$dn"]= $object;
             $this->member["$dn"]= $dn;
-            uasort ($this->memberList, 'sort_list');
             reset ($this->memberList);
           }
         }
@@ -326,10 +344,26 @@ class ogroup extends plugin
 
     /* Assign variables */
     $smarty->assign("base", $this->baseSelector->render());
-    $smarty->assign("members", $this->convert_list($this->memberList));
 
-    /* Objects have to be tuned... */
-    $smarty->assign("objects", $this->convert_list($this->objects));
+
+
+    $this->memberListing->setAcl('rwcdm');
+    $data = $lData = array();
+    foreach($this->member as $key => $dn){
+        $image = 'images/lists/element.png';
+        $name = $dn;
+        if(isset($this->memberList[$dn])){
+            $name  = $this->memberList[$dn]['text'];
+            if(isset($this->typeToImage[$this->memberList[$dn]['type']])){
+                $image = $this->typeToImage[$this->memberList[$dn]['type']];
+            }
+        }
+        $data[$key] = $dn;
+        $lData[$key] = array('data'=> array(image($image),$name));
+    }
+    $this->memberListing->setListData($data,$lData);
+    $this->memberListing->update();
+    $smarty->assign("memberList",$this->memberListing->render());
 
     /* Fields */
     foreach ($this->attributes as $val){
@@ -476,7 +510,6 @@ class ogroup extends plugin
         }
       }
     }
-    uasort ($this->objects, 'sort_list');
     reset ($this->objects);
 
     
@@ -538,7 +571,6 @@ class ogroup extends plugin
         $this->memberList[$dn]= $this->objects[$attrs["dn"]];
       }
     }
-    uasort ($this->memberList, 'sort_list');
     reset ($this->memberList);
 
     /* Assemble types of currently combined objects */
@@ -559,54 +591,16 @@ class ogroup extends plugin
   }
 
 
-  function convert_list($input)
-  {
-    $temp= "";
-    $conv= array(  
-        "Y" => "plugins/users/images/select_template.png",
-        "U" => "plugins/generic/images/head.png",
-        "G" => "plugins/groups/images/select_group.png",
-        "A" => "plugins/ogroups/images/application.png",
-        "D" => "plugins/departments/images/department.png",
-        "S" => "plugins/ogroups/images/server.png",
-        "W" => "plugins/ogroups/images/workstation.png",
-        "O" => "plugins/ogroups/images/winstation.png",
-        "T" => "plugins/ogroups/images/terminal.png",
-        "F" => "plugins/ogroups/images/phone.png",
-        "P" => "plugins/ogroups/images/printer.png",
-        "I" => "images/false.png");
-
-    foreach ($input as $key => $value){
-      /* Generate output */
-      $temp.= "<option title='".addslashes( $key)."' value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path($conv[$value['type']])."');\">".$value['text']."</option>\n";
-    }
-
-    return ($temp);
-  }
-
-
   function getObjectType($attrs)
   {
     $type= "I";
 
-    foreach(array(  
-          "Y" => "gosaUserTemplate",
-          "U" => "gosaAccount",
-          "G" => "posixGroup",
-          "A" => "gosaApplication",
-          "D" => "gosaDepartment",
-          "S" => "goServer",
-          "W" => "gotoWorkstation",
-          "O" => "opsiClient",
-          "T" => "gotoTerminal",
-          "F" => "goFonHardware",
-          "P" => "gotoPrinter") as $index => $class){
+    foreach($this->typeToClass as $index => $class){
       if (in_array($class, $attrs['objectClass'])){
         $type= $index;
         break;
       }
     }
-
     return ($type);
   }
 
index c56a808dbb9b020a73c33ad7f278e7240cdfec27..81579ce892ecf2d55dfd4d57dde5656189982ef5 100644 (file)
@@ -41,9 +41,7 @@
    <b><LABEL for="members">{t}Member objects{/t}</LABEL></b>&nbsp;({$combinedObjects})
    <br>
 {render acl=$memberACL}
-   <select style="width:100%; height:450px;" id="members" name="members[]" size="15" multiple>
-    {$members}
-   </select>
+   {$memberList}
 {/render}
    <br>
 {render acl=$memberACL}