Code

Prepare sortedlist for additional attributes
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 22 Jan 2010 15:50:18 +0000 (15:50 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 22 Jan 2010 15:50:18 +0000 (15:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15268 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_sortableListing.inc
gosa-core/plugins/personal/generic/class_user.inc
gosa-core/plugins/personal/posix/class_posixAccount.inc

index 48babc45568aeb9ab4971c1a7b57e1fb6b4ca8fd..7d12f4878cbea635510366f2966057b571777804 100644 (file)
@@ -53,12 +53,12 @@ class sortableListing {
   private $acl= "";
   private $modified= false;
 
-  public function sortableListing($data= array(), $displayData= null, $modes= null, $reorderable= false)
+  public function sortableListing($data= array(), $displayData= null, $reorderable= false)
   {
     global $config;
 
     // Save data to display
-    $this->setListData($data, $displayData, $modes);
+    $this->setListData($data, $displayData);
 
     // Generate instance wide unique ID
     $tmp= gettimeofday();
@@ -72,25 +72,17 @@ class sortableListing {
   }
 
 
-  public function setListData($data, $displayData= null, $modes= null)
+  public function setListData($data, $displayData= null)
   {
     // Save data to display
     $this->setData($data);
     if (!$displayData) {
       $displayData= array();
       foreach ($data as $key => $value) {
-        $displayData[$key]= array($value);
+        $displayData[$key]= array("data" => array($value));
       }
     }
-    if (!$modes) {
-      $modes= array();
-      foreach ($data as $key => $value) {
-        $modes[$key]= LIST_NORMAL;
-      }
-    }
-
     $this->setDisplayData($displayData);
-    $this->setModes($modes);
   }
 
 
@@ -100,12 +92,6 @@ class sortableListing {
   }
 
 
-  private function setModes($modes)
-  {
-    $this->modes= array_values($modes);
-  }
-
-
   private function setDisplayData($data)
   {
     if (!is_array($data)) {
@@ -113,7 +99,10 @@ class sortableListing {
     }
 
     // Transfer information
-    $this->displayData= array_values($data);
+    $this->displayData= array();
+    foreach ($data as $key => $value) {
+      $this->displayData[]= $value['data'];
+    }
     $this->keys= array_keys($data);
 
     // Create initial mapping
@@ -253,14 +242,16 @@ class sortableListing {
         $editable= $this->editable?" onclick='$(\"edit_".$this->id."_$nr\").click()'":"";
 
         $id= "";
-        switch ($this->modes[$row]) {
-          case LIST_DISABLED:
-            $id= " sortableListItemDisabled";
-            $editable= false;
-            break;
-          case LIST_MARKED:
-            $id= " sortableListItemMarked";
-            break;
+        if (isset($this->modes[$row])) {
+          switch ($this->modes[$row]) {
+            case LIST_DISABLED:
+              $id= " sortableListItemDisabled";
+              $editable= false;
+              break;
+            case LIST_MARKED:
+              $id= " sortableListItemMarked";
+              break;
+          }
         }
 
         $result.= "  <tr class='sortableListItem".((($nr&1)||!$this->colorAlternate)?'':'Odd')."$id' id='item_".$this->id."_$nr'$reorderable>\n";
@@ -467,7 +458,7 @@ class sortableListing {
   }
 
 
-  public function addEntry($entry, $displayEntry= null, $key= null, $mode= null)
+  public function addEntry($entry, $displayEntry= null, $key= null)
   {
     // Only add if not already there
     if (!$key) {
@@ -482,7 +473,7 @@ class sortableListing {
 
     // Prefill with default value if not specified
     if (!$displayEntry) {
-      $displayEntry= array($entry);
+      $displayEntry= array('data' => array($entry));
     }
 
     // Append to data and mapping
@@ -493,10 +484,12 @@ class sortableListing {
       $this->data[]= $entry;
       $this->keys[]= count($this->mapping);
     }
-    $this->modes[]= $mode;
-    $this->displayData[]= $displayEntry;
+    $this->displayData[]= $displayEntry['data'];
     $this->mapping[]= count($this->mapping);
     $this->modified= true;
+
+    // Sort data after we've added stuff
+    $this->sortData();
   }
 
 
index cf2d762d6b91cb20132f0c87a800aaf1515dd513..36dbd589a3fc2250de948ffaf371b1e0337c6b1a 100644 (file)
@@ -259,9 +259,8 @@ class user extends plugin
     /* Call parent execute */
     plugin::execute();
 
-    /* Let the lists update themselves */
+    /* Set list ACL */
     $this->gosaLoginRestrictionWidget->setAcl($this->getacl('gosaLoginRestriction', (!is_object($this->parent) && !session::is_set('edit'))));
-    $this->gosaLoginRestrictionWidget->update();
 
     /* Handle add/delete for restriction mode */
     if (isset($_POST['add_res']) && isset($_POST['res'])) {
@@ -756,6 +755,7 @@ class user extends plugin
       plugin::save_object ();
 
       /* Sync lists */
+      $this->gosaLoginRestrictionWidget->update();
       if ($this->gosaLoginRestrictionWidget->isModified()) {
         $this->gosaLoginRestriction= $this->gosaLoginRestrictionWidget->getMaintainedData();
       }
index cbdf7366a01cb3914e0f2cfd8088bf0946357e93..a3dbf1f1d1b7e8bc0dfff1122392f40ab80af9d7 100644 (file)
@@ -282,9 +282,8 @@ class posixAccount extends plugin
     plugin::execute();
     $display= "";
 
-    /* Let the lists update themselves */
+    /* Assign list acl */
     $this->groupMembershipList->setAcl($this->getacl('memberUid', (!is_object($this->parent) && !session::is_set('edit'))));
-    $this->groupMembershipList->update();
 
     /* Log view */
     if($this->is_account && !$this->view_logged){
@@ -569,16 +568,6 @@ class posixAccount extends plugin
     $smarty->assign("shells", $this->loginShellList);
     $smarty->assign("secondaryGroups", $this->secondaryGroups);
     $smarty->assign("primaryGroup", $this->primaryGroup);
-    if(!$this->multiple_support_active){
-      if (!count($this->groupMembership)){
-        $smarty->assign("groupMembership", array("&nbsp;"));
-      } else {
-        $smarty->assign("groupMembership", $this->groupMembership);
-      }
-    }else{
-      $smarty->assign("groupMembership", $this->groupMembership);
-      $smarty->assign("groupMembership_some", $this->groupMembership_some);
-    }
     if (count($this->groupMembership) > 16){
       $smarty->assign("groups", "too_many_for_nfs");
     } else {
@@ -748,6 +737,8 @@ class posixAccount extends plugin
       /* Save values to object */
       plugin::save_object();
 
+      /* Maintain list */
+      $this->groupMembershipList->update();
 
       /* Save force GID checkbox */
       if($this->acl_is_writeable("gidNumber") || $this->acl_is_writeable("uidNumber")){
@@ -1835,9 +1826,9 @@ class posixAccount extends plugin
 
     foreach ($this->groupMembership as $key => $value) {
       if (!preg_match('/^([^[]+)\[(.*)\]$/', $value, $m)) {
-        $tmp[$key]= array($value, "");
+        $tmp[$key]= array("data" => array($value, ""));
       } else {
-        $tmp[$key]= array(rtrim($m[1]), $m[2]);
+        $tmp[$key]= array("data" => array(rtrim($m[1]), $m[2]));
       }
     }