From 84c204f0dd1968da768b10c380cfb73232b98ada Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 8 Oct 2010 09:02:31 +0000 Subject: [PATCH] Allow to remove folder entries in the new folder widget git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19949 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../FolderWidget/FolderWidget-list.xml | 2 +- .../FolderWidget/class_FolderWidget.inc | 32 ++++++++++++++++++- .../class_FolderWidgetListing.inc | 26 ++++++++++++--- .../FolderWidget/class_filterFolderWidget.inc | 2 +- 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.xml b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.xml index 52335f43d..10d9e6078 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.xml +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.xml @@ -114,7 +114,7 @@ - edit + editEntry entry images/lists/edit.png diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc index 65c4875e1..fc94f2818 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc @@ -20,7 +20,7 @@ class FolderWidget extends plugin function __construct(&$config) { $this->rootBase = $this->fakeCnAttr.$this->rootName; - $this->FolderWidgetListing = new FolderWidgetListing($this->config, get_userinfo(), $this->rootBase); + $this->FolderWidgetListing = new FolderWidgetListing($this->config, get_userinfo(), $this->rootBase, $this); $this->FolderWidgetListing->setBase($this->rootBase); $this->FolderWidgetListing->setFolderRoot($this->rootBase); } @@ -104,6 +104,35 @@ class FolderWidget extends plugin } + function removeByBase($base) + { + $this->_recursiveRemoveByBase($this->folderList['recursive'], $base); + $this->_recursiveRemoveByBase($this->folderList['linear'], $base); + $this->FolderWidgetListing->setFolderList($this->folderList); + } + + function _recursiveRemoveByBase(&$arr, $base) + { + $ret = array(); + foreach($arr as $path => $item){ + if($item['base'] == $base){ + + // remove all children too + if(isset($item['children']) && count($item['children'])){ + foreach($item['children'] as $child){ + $this->_recursiveRemoveByBase($this->folderList['recursive'], $child['base']); + } + } + + $arr[$path]['status'] = 'removed'; + }elseif(isset($item['children']) && count($item['children'])){ + $ret = array_merge($ret, $this->_recursiveRemoveByBase($arr[$path]['children'], $base)); + } + } + return($ret); + + } + function _saveRecursive($arr) { $ret = array(); @@ -130,6 +159,7 @@ class FolderWidget extends plugin function execute() { session::set('FolderWidgetListing::folderList', $this->folderList); + $this->FolderWidgetListing->setFolderList($this->folderList); return($this->FolderWidgetListing->execute()); } diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc index 14bdf17fe..cafff0943 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc @@ -7,13 +7,15 @@ class FolderWidgetListing extends management private $folderList = array(); private $rootBase = ''; + private $parent; - function __construct($config,$ui, $rootBase) + function __construct($config,$ui, $rootBase, $parent) { $this->config = $config; $this->ui = $ui; $this->storagePoints = array(""); $this->rootBase = $rootBase; + $this->parent = &$parent; // Build filter if (FALSE && session::global_is_set(get_class($this)."_filter")){ @@ -44,7 +46,19 @@ class FolderWidgetListing extends management { $this->setBase($targets[0]); } - + + function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") + { + print_a($all); + } + + protected function removeEntryRequested($action="",$target=array(),$all=array()) + { + foreach($target as $tar){ + $this->parent->removeByBase($tar); + if($tar == $this->base) $this->setBase($this->rootBase); + } + } function setFolderList($folderList) { @@ -95,9 +109,11 @@ class FolderWidgetListing extends management { $ret = array($this->rootBase => '/'); foreach($arr as $path => $entry){ - $ret[$entry['base']] = $entry['name']; - if(isset($entry['children'])){ - $ret = array_merge($ret, $this->getSimpleFolderList($entry['children'])); + if($entry['status'] != 'removed'){ + $ret[$entry['base']] = $entry['name']; + if(isset($entry['children'])){ + $ret = array_merge($ret, $this->getSimpleFolderList($entry['children'])); + } } } return($ret); diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_filterFolderWidget.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_filterFolderWidget.inc index f6f82a114..6d5166908 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_filterFolderWidget.inc +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_filterFolderWidget.inc @@ -38,7 +38,7 @@ class filterFolderWidget { static function addEntry(&$ret, $item, $recursive = FALSE, $filter) { - if(preg_match("/".$filter."/",$item['name'])){ + if(preg_match("/".$filter."/",$item['name']) && $item['status'] != 'removed'){ $entry = array(); $entry['dn'] = $item['base']; $entry[] = 'dn'; -- 2.30.2