From 8c8b56299676047ab678b97f8df2f55503006114 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 7 Oct 2010 13:55:22 +0000 Subject: [PATCH] Updated folder widget -It lists now git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19935 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../FolderWidget/FolderWidget-filter.xml | 4 +- .../FolderWidget/FolderWidget-list.tpl | 11 +-- .../FolderWidget/FolderWidget-list.xml | 8 +- .../FolderWidget/class_FolderWidget.inc | 70 +++++++++++++++++ .../class_FolderWidgetListing.inc | 76 ++++++++++++++++++- .../FolderWidget/class_filterFolderWidget.inc | 51 +++++++++++++ 6 files changed, 206 insertions(+), 14 deletions(-) create mode 100644 gosa-plugins/groupware/personal/groupware/FolderWidget/class_filterFolderWidget.inc diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-filter.xml b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-filter.xml index 54d213cc4..365a2c793 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-filter.xml +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-filter.xml @@ -6,7 +6,7 @@ Groupware true default - sub + auto - @@ -14,7 +14,7 @@ default - LDAP + FolderWidget $ diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.tpl b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.tpl index c80f9a238..44dcd716e 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.tpl +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.tpl @@ -5,10 +5,8 @@
- - - + @@ -20,5 +18,8 @@
- - +
+
+ + +
diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.xml b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.xml index 66937308a..634409749 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.xml +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderWidget-list.xml @@ -2,9 +2,9 @@ - true - true - true + false + false + false true users @@ -22,7 +22,7 @@
{$ROOT}{$BACK}{$HOME} {$RELOAD}{t}Basis{/t}: {$RELEASE} {$ACTIONS} {$FILTER}
- |20px;c|120px||170px;r| + |20px;c|||170px;r| %{filter:objectType(dn,objectClass)} diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc index 899e20916..904714ff7 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc @@ -7,6 +7,9 @@ class FolderWidget extends plugin { public $config; private $FolderWidgetListing = NULL; + private $folderList; + + private $baseEntryMap = array(); function __construct(&$config) { @@ -14,10 +17,77 @@ class FolderWidget extends plugin } + /*! \brief Tell the widget which folders should be displayed. + */ + function setFolderList($arr) + { + $this->folderList = $this->buildRecursiveList($arr, '/'); + $this->FolderWidgetListing->setBase('cn=/'); + $this->FolderWidgetListing->setFolderRoot('cn=/'); + } + + + /* \brief Builds a hierarchical structure which can then be + * used by the FolderWidgetListing. + * + * @param Array The folder list + * @return Array A hierarchical representation of the input array. + */ + function buildRecursiveList($arr, $seperator) + { + $data = array(); + $base = &$data; + $last = NULL; + $ret = array(); + foreach($arr as $path => $entry){ + $current = &$base; + $pathSteps = preg_split("/".preg_quote($seperator,'/')."/", $path); + + $entryPath = ""; + $entryBase = "cn=/"; + foreach($pathSteps as $name){ + $entryPath = (empty($entryPath)) ? $name : "{$entryPath}{$seperator}{$name}"; + $entryBase = trim("cn={$name},{$entryBase}", ' ,'); + if(!isset($current[$entryPath])){ + $current[$entryPath] = array(); + $current[$entryPath]['children'] = array(); + $current[$entryPath]['name'] = $name; + $current[$entryPath]['path'] = $path; + $current[$entryPath]['status'] = ''; + $current[$entryPath]['type'] = 'manual'; + $current[$entryPath]['base'] = $entryBase; + + $ret['linear'][$entryPath] = &$current[$entryPath]; + + $this->baseEntryMap[$entryBase] = $entryPath; + } + $last = &$current[$entryPath]; + $current = &$current[$entryPath]['children']; + } + $last['acls'] = $entry['acls']; + $last['name'] = $entry['name']; + $last['type'] = 'real'; + $last['status'] = $entry['status']; + + $ret['linear'][$path] = &$last; + + } + $ret['recursive'] = $data; + return($ret); + } + + function execute() { + session::set('FolderWidgetListing::folderList', $this->folderList); + $this->FolderWidgetListing->setFolderList($this->folderList); return($this->FolderWidgetListing->execute()); } + + function save_object() + { + $this->FolderWidgetListing->save_object(); + } } ?> diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc index 3712d2b52..1d74043dd 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc @@ -2,15 +2,20 @@ class FolderWidgetListing extends management { + + private $folderSelector = NULL; + private $folderList = array(); + + private $rootBase = 'cn=/'; + function __construct($config,$ui) { $this->config = $config; $this->ui = $ui; - $this->storagePoints = array(""); // Build filter - if (session::global_is_set(get_class($this)."_filter")){ + if (FALSE && session::global_is_set(get_class($this)."_filter")){ $filter= session::global_get(get_class($this)."_filter"); } else { $filter = new filter(get_template_path("FolderWidget-filter.xml", true, dirname(__FILE__))); @@ -21,12 +26,77 @@ class FolderWidgetListing extends management // Build headpage $headpage = new listing(get_template_path("FolderWidget-list.xml", true, dirname(__FILE__))); $headpage->setFilter($filter); + $headpage->setBase($this->rootBase); + // Create folderSelector using dummy entries, those will be replaced + // once setFolderList is called. + $this->folderSelector = new ItemSelector(array($this->rootBase => '/'),$this->rootBase,$this->rootBase); parent::__construct($config, $ui, "Folder", $headpage); } + + function setFolderList($folderList) + { + $this->folderList = $folderList; + } -} + function getBase() + { + return($this->base); + } + + + function setBase($base) + { + $this->base = $base; + $this->folderSelector->setBase($this->base); + $headpage = $this->getHeadpage(); + $headpage->setBase($this->base); + } + + + function setFolderRoot($base) + { + $this->rootBase = $base; + $this->folderSelector->setRootBase($base); + } + + + /*! \brief Overridden render method of class mangement. + * this allows us to add a release selection box. + */ + function renderList() + { + $this->folderSelector->setBases($this->getSimpleFolderList($this->folderList['recursive'])); + $this->folderSelector->update(true); + $headpage = $this->getHeadpage(); + $headpage->update(); + $smarty = get_smarty(); + $smarty->assign("RELEASE", $this->folderSelector->render()); + $display = $headpage->render(); + return($this->getHeader().$display); + } + + + function getSimpleFolderList($arr) + { + $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'])); + } + } + return($ret); + } + + + function save_object() + { + $this->folderSelector->update(); + $this->setBase($this->folderSelector->getBase()); + } +} ?> diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_filterFolderWidget.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_filterFolderWidget.inc new file mode 100644 index 000000000..17af6b550 --- /dev/null +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_filterFolderWidget.inc @@ -0,0 +1,51 @@ + 1); + $entry[] = 'cn'; + $entry['objectClass'] = array('FAKE_OC_GroupwareFolder','count' => 1); + $entry[] = 'objectClass'; + $entry['count'] = 3; + $ret[] = $entry; + } + + if($recursive && isset($item['children']) && count($item['children'])){ + foreach($item['children'] as $item){ + filterFolderWidget::addEntry($ret, $item, $recursive,$filter); + } + } + } +} +?> -- 2.30.2