From 77a400added4622046e4696f53830728d1fdc270 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 8 Oct 2010 11:21:38 +0000 Subject: [PATCH] Added simple edit mechanism for groupware folder lists git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19952 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../FolderWidget/FolderEditDialog.tpl | 7 +++ .../FolderWidget/class_FolderEditDialog.inc | 22 +++++++++ .../FolderWidget/class_FolderWidget.inc | 48 +++++++++++++++---- .../class_FolderWidgetListing.inc | 2 +- 4 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 gosa-plugins/groupware/personal/groupware/FolderWidget/FolderEditDialog.tpl create mode 100644 gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderEditDialog.inc diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderEditDialog.tpl b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderEditDialog.tpl new file mode 100644 index 000000000..eec1e9e30 --- /dev/null +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/FolderEditDialog.tpl @@ -0,0 +1,7 @@ +adsf + +
+
+ + +
diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderEditDialog.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderEditDialog.inc new file mode 100644 index 000000000..3363021b9 --- /dev/null +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderEditDialog.inc @@ -0,0 +1,22 @@ +config = $config; + $this->item = $item; + } + + function execute() + { + $smarty = get_smarty(); + $smarty->assign('item', $this->item); + return($smarty->fetch(get_template_path("FolderEditDialog.tpl", TRUE, dirname(__FILE__)))); + } +} + + +?> diff --git a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc index 488e761dd..fdbb6ac49 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc @@ -3,7 +3,7 @@ class FolderWidget extends plugin { - private $pathSeperator = "/"; + private $pathSeparator = "/"; private $rootName = "/"; private $fakeCnAttr = "cn="; private $rootBase = ""; @@ -16,6 +16,7 @@ class FolderWidget extends plugin function __construct(&$config, $folderList, $accountPrefix) { + $this->config = $config; // The rootBase is a dn-like representation of the root path // e.g. rootPath is '/' then is the rootBase 'cn=/' // These are just internally used variables and should not have an @@ -35,7 +36,7 @@ class FolderWidget extends plugin function pathToDn($path) { $dn =""; - $list = preg_split("/".preg_quote($this->pathSeperator,'/')."/", $path,0,PREG_SPLIT_NO_EMPTY); + $list = preg_split("/".preg_quote($this->pathSeparator,'/')."/", $path,0,PREG_SPLIT_NO_EMPTY); foreach($list as $entry){ $dn ="cn={$entry},{$dn}"; } @@ -53,8 +54,7 @@ class FolderWidget extends plugin */ function setFolderList($arr) { - $this->folderList = $this->buildRecursiveList($arr, $this->pathSeperator); - print_a($this->folderList); + $this->folderList = $this->buildRecursiveList($arr, $this->pathSeparator); } @@ -64,7 +64,7 @@ class FolderWidget extends plugin * @param Array The folder list * @return Array A hierarchical representation of the input array. */ - function buildRecursiveList($arr, $seperator) + function buildRecursiveList($arr, $separator) { $data = array(); $ret = array(); @@ -90,13 +90,13 @@ class FolderWidget extends plugin if(!preg_match("/^".preg_quote($this->accountPrefix,'/')."/", $path)) continue; $current = &$base; - $pathSteps = preg_split("/".preg_quote($seperator,'/')."/", $path); + $pathSteps = preg_split("/".preg_quote($separator,'/')."/", $path); $entryPath = ""; $parentPath = ""; $entryBase = ""; foreach($pathSteps as $name){ $parentPath = $entryPath; - $entryPath = (empty($entryPath)) ? $name : "{$entryPath}{$seperator}{$name}"; + $entryPath = (empty($entryPath)) ? $name : "{$entryPath}{$separator}{$name}"; $entryBase = $this->pathToDn($entryPath); // Add eventually missing subFolders, to enable the navigation @@ -131,6 +131,21 @@ class FolderWidget extends plugin return($ret); } + + function editByBase($base) + { + $item = NULL; + foreach($this->folderList['linear'] as $item){ + if($item['base'] == $base){ + break; + } + } + if($item){ + $this->currentlyEditedItem = $item; + $this->dialog = new FolderEditDialog($this->config, $item); + } + } + function removeByBase($base) { @@ -186,10 +201,25 @@ class FolderWidget extends plugin function execute() { + // Generate the listing output session::set('FolderWidgetListing::folderList', $this->folderList); - $this->FolderWidgetListing->setFolderList($this->folderList); - return($this->FolderWidgetListing->execute()); + $str = $this->FolderWidgetListing->execute(); + + // Handle dialogs + if(isset($_POST['FolderEditDialog_ok'])){ + $this->dialog = NULL; + } + if(isset($_POST['FolderEditDialog_cancel'])){ + $this->dialog = NULL; + } + if($this->dialog){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + // Return listing HTML + return($str); } function 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 cafff0943..fbbf7a2db 100644 --- a/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc +++ b/gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.inc @@ -49,7 +49,7 @@ class FolderWidgetListing extends management function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") { - print_a($all); + $this->parent->editByBase($target[0]); } protected function removeEntryRequested($action="",$target=array(),$all=array()) -- 2.30.2