From e70815fe6d2bc67645d521578a8c40e55b348e7d Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 22 Jan 2010 15:50:18 +0000 Subject: [PATCH] Prepare sortedlist for additional attributes git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15268 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_sortableListing.inc | 55 ++++++++----------- .../plugins/personal/generic/class_user.inc | 4 +- .../personal/posix/class_posixAccount.inc | 19 ++----- 3 files changed, 31 insertions(+), 47 deletions(-) diff --git a/gosa-core/include/class_sortableListing.inc b/gosa-core/include/class_sortableListing.inc index 48babc455..7d12f4878 100644 --- a/gosa-core/include/class_sortableListing.inc +++ b/gosa-core/include/class_sortableListing.inc @@ -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.= " \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(); } diff --git a/gosa-core/plugins/personal/generic/class_user.inc b/gosa-core/plugins/personal/generic/class_user.inc index cf2d762d6..36dbd589a 100644 --- a/gosa-core/plugins/personal/generic/class_user.inc +++ b/gosa-core/plugins/personal/generic/class_user.inc @@ -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(); } diff --git a/gosa-core/plugins/personal/posix/class_posixAccount.inc b/gosa-core/plugins/personal/posix/class_posixAccount.inc index cbdf7366a..a3dbf1f1d 100644 --- a/gosa-core/plugins/personal/posix/class_posixAccount.inc +++ b/gosa-core/plugins/personal/posix/class_posixAccount.inc @@ -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(" ")); - } 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])); } } -- 2.30.2