Code

Added simple edit mechanism for groupware folder lists
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 8 Oct 2010 11:21:38 +0000 (11:21 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 8 Oct 2010 11:21:38 +0000 (11:21 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19952 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/groupware/personal/groupware/FolderWidget/FolderEditDialog.tpl [new file with mode: 0644]
gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderEditDialog.inc [new file with mode: 0644]
gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidget.inc
gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderWidgetListing.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 (file)
index 0000000..eec1e9e
--- /dev/null
@@ -0,0 +1,7 @@
+adsf
+
+<hr>
+<div class='plugin-actions'>
+    <button name="FolderEditDialog_ok">{msgPool type='okButton'}</button>
+    <button name="FolderEditDialog_cancel">{msgPool type='cancelButton'}</button>
+</div>
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 (file)
index 0000000..3363021
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+class FolderEditDialog extends plugin
+{
+    private $item = NULL;    
+
+    function __construct($config, $item)
+    {
+        $this->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__))));
+    }
+}
+
+
+?>
index 488e761dd204186caf8e8691c8f78b7902b2fcff..fdbb6ac492d67461ca678b740c4414eb8ec9c433 100644 (file)
@@ -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()
index cafff0943bb480391d14b826e9b3c5a0312cbbcf..fbbf7a2dbf249e8823bb3ac5253b09c3ec910d23 100644 (file)
@@ -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())