Code

[hickert]: Added simple folder editing widget just for testing
authorhzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Oct 2010 12:36:32 +0000 (12:36 +0000)
committerhzerres <hzerres@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Oct 2010 12:36:32 +0000 (12:36 +0000)
-Will be updated later

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19924 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/groupware/personal/groupware/class_Groupware.inc
gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc
gosa-plugins/groupware/personal/groupware/generic.tpl

index 44b3b239e516c107a061275f5dd9e623355586c7..907a09ab02175afc1ee19fcb23ca367d2a0bb2b1 100644 (file)
@@ -119,13 +119,12 @@ class Groupware extends plugin
 
                // Initialize file browser list
                $this->fileBrowser= new sortableListing();
-               $this->fileBrowser->setDeleteable(FALSE);
+               $this->fileBrowser->setDeleteable(TRUE);
                $this->fileBrowser->setEditable(TRUE);
                $this->fileBrowser->setColspecs(array('*'));
                $this->fileBrowser->setWidth("100%");
                $this->fileBrowser->setHeight("150px");
                $this->fileBrowser->setAcl("rwcdm");
-               $this->fileBrowser->setListData(array("eins", "zwei"),array("eins" =>array( "data"=> array("Uno") ) , "zwei" =>array( "data"=> array("Due") )) );
                $this->fileBrowser->update();
                $this->fileBrowser->sortingEnabled(FALSE);
 
@@ -488,14 +487,23 @@ class Groupware extends plugin
             if($this->currentSelectedFolder == $folderPath){
                 $name = "<b>{$name}</b>";
             }
+
+            $status = (isset($entries['status']))? $entries['status'] : '';        
             $prefix = preg_replace("/^([^\/]*).*$/","\\1", $folderPath);
             $name = str_pad($name, (substr_count($folderPath, '/')*3-3) + strlen($name),'../', STR_PAD_LEFT);
-            $lData[$folderPath]= array('data' => array($name,$prefix,$cnt));
+            $lData[$folderPath]= array('data' => array($name,$prefix,$status,$cnt));
         }    
         $this->fileBrowser->setListData($data, $lData) ;
         $this->fileBrowser->update();
 
+        
         $smarty->assign("currentSelectedFolder", $this->currentSelectedFolder);
+        $folderEntries = array();
+        if(isset($this->mailFolder[$this->currentSelectedFolder])) {
+            $folderEntries = $this->mailFolder[$this->currentSelectedFolder];
+        }
+               $smarty->assign("folderEntries", $folderEntries);
+
                $smarty->assign("fileBrowser", $this->fileBrowser->render());
         $smarty->assign("mailLocations", $this->mailLocations);
         if (count($this->vacationTemplates)){
@@ -524,16 +532,66 @@ class Groupware extends plugin
     {
         if(isset($_POST['groupwarePluginPosted'])){
 
+            // Update folder name   
+            #$current = &$this->mailFolder[$this->currentSelectedFolder];
+            #if(isset($_POST['currentFolderName'])){
+            #    $new_name = get_post('currentFolderName');
+            #    if($new_name != $current['name']){
+            #        if(!in_array($current['status'],array('del','add'))){
+            #            $current['status'] = 'renamed';
+            #        }
+            #        $current['name'] = get_post('currentFolderName');
+            #    }
+            #}
+            if(isset($this->mailFolder[$this->currentSelectedFolder])){
+                $current = &$this->mailFolder[$this->currentSelectedFolder];
+                foreach($current['acls'] as $key => $data){
+                    if(isset($_POST["permission_{$key}_name"])){
+                        $current['acls'][$key]['name'] = get_post("permission_{$key}_name"); 
+                    }
+                    if(isset($_POST["permission_{$key}_acl"])){
+                        $current['acls'][$key]['acl'] = get_post("permission_{$key}_acl"); 
+                    }
+                    if(isset($_POST["permission_{$key}_del"])){
+                        unset($current['acls'][$key]);
+                    }
+                }
+                $current['acls'] = array_values($current['acls']);
+            }
+
+            if(isset($_POST['folderName_Add']) && isset($_POST['folderName_Input'])){
+                if(isset($this->mailFolder[$this->currentSelectedFolder])){
+                    $newName = get_post('folderName_Input');
+                    $newPath = $this->currentSelectedFolder."/".$newName;
+                    $entry = array();
+                    $entry['acls'] = array();
+                    $entry['name'] = $newName;
+                    $entry['status'] = 'add';
+                    $this->mailFolder[$newPath] = $entry;
+                }
+            }
+
+
             $this->fileBrowser->save_object();
             $action = $this->fileBrowser->getAction();
             if($action['action'] == "edit"){
                 $folderPath = $this->fileBrowser->getKey($action['targets'][0]);
                 $this->currentSelectedFolder = $folderPath;
             }
-            
-            
+            if($action['action'] == "delete"){
+                $folderPath = $this->fileBrowser->getKey($action['targets'][0]);
+                $this->mailFolder[$folderPath]['status'] = 'del';
+                $this->currentSelectedFolder = "";
+            }
+       
  
-            echo $this->currentSelectedFolder;
+            if(isset($_POST['permission_add'])) {
+                $current = &$this->mailFolder[$this->currentSelectedFolder];
+                $current['acls'][] = array('name' => '','type'=>'user','acl' => '');
+            }
+           
  
             // We ran into a communication error with the backend. 
             // Try a simple communication operation with the backend 
@@ -770,6 +828,8 @@ class Groupware extends plugin
             }
         }
 
+        $this->groupwareDao->saveFoldersAndAcls($this->uid, $this->mailFolder);
+
         // Save the primary Email Address.
         if(!empty($this->mailAddress)){
             $this->groupwareDao->save("primaryMail", $this->uid, $this->mailAddress);
index 0f763e06900298a14527e9cf2ab6b1ca65874046..f7ad60711af1d10d01228ff8fb479988b91ac399 100644 (file)
@@ -50,10 +50,15 @@ class GroupwareDao{
             "accountProperties" => array("get"=>"gwAcctGetProperties",
                     "save"=>"gwAcctSetProperties",
                     "delete"=>"gwAcctDelProperties"),
+                       //mailFolder is a composite feature - 
                        "mailFolder" => array( "get"=>"gwFolderList",
-                    "save"=>"gwFolderAdd",
-                    "delete"=>"gwFolderDel")
+                                       "save"=>"gwFolderAdd",
+                    "delete"=>"gwFolderDel"),
+                       "private_folderACLS" => array("get"=>"gwFolderGetMembers",
+                    "save"=>"gwFolderSetMembers",
+                    "delete"=>"gwFolderDelMember")
                 );
+                       
 
 
     /*! \brief Constructor sets the connection to the rpc service 
@@ -188,30 +193,64 @@ class GroupwareDao{
                        "RIGHTS_POST", RIGHTS_READ | POST);
                        "RIGHTS_APPEND", RIGHTS_POST | INSERT);
                        "RIGHTS_WRITE", RIGHTS_APPEND | WRITE | CREATE | DELETE);
-                       ""
-                       */
-                       $resultArr["mailFolder"] = array(
-                               'user/wiwu/Aufgaben' => array( 
-                                       "name" =>"Aufgaben",
-                                       "acls"=> array(         array("wiwu"=> RIGHTS_ALL, "type"=>"user"),
-                                                                               array("2a"=> RIGHTS_ALL, "type"=>"user"))), 
-                               'user/wiwu/Entw\xc3\xbcrfe' =>array(
-                                       "name" => "Entw\xc3\xbcrfe", 
-                                       "acls" => array(        array("wiwu"=> RIGHTS_ALL, "type"=>"user"))), 
-                               'user/wiwu/Gel\xc3\xb6schte Objekte' => array( 
-                                       "name" => "Gel\xc3\xb6schte Objekte", 
-                                       "acls" => array(        array("wiwu"=> RIGHTS_ALL, "type"=>"user"))), 
-                               'user/wiwu/Synchronisierungsprobleme/Lokale Fehler'  => array( 
-                                       "name" =>"Synchronisierungsprobleme/Lokale Fehler",
-                                       "acls"=> array(array("wiwu"=> RIGHTS_ALL, "type"=>"user"))), 
-                               'user/wiwu/Synchronisierungsprobleme/Serverfehler'  => array( 
-                                       "name" =>"Synchronisierungsprobleme/Serverfehler",
-                                       "acls"=> array(array("wiwu"=> RIGHTS_ALL, "type"=>"user"))),
-                               'shared/publicFolder'  => array( 
-                                       "name" =>"publicFolder",
-                                       "acls" => array(array("wiwu"=> RIGHTS_READ, "type"=>"user")))
-                               );
-               }
+            ""
+             */
+            $resultArr["mailFolder"] = array(
+                    'user/wiwu/Aufgaben' => array( 
+                        "name" =>"Aufgaben",
+                        "acls"=> array(        
+                            array(
+                                "name" => "wiwu",
+                                "acl"  => RIGHTS_ALL, 
+                                "type"=>"user"),
+                            array(
+                                "name" => "2a",
+                                "acl" => RIGHTS_ALL, 
+                                "type"=>"user"))), 
+
+                    'user/wiwu/Entw\xc3\xbcrfe' =>array(
+                        "name" => "Entw\xc3\xbcrfe", 
+                        "acls" => array(       
+                            array(
+                                "name" => "wiwu",
+                                "acl" => RIGHTS_ALL, 
+                                "type"=>"user"))), 
+                    'user/wiwu/Gel\xc3\xb6schte Objekte' => array( 
+                        "name" => "Gel\xc3\xb6schte Objekte", 
+                        "acls" => array(       
+                            array(
+                                "name" => "wiwu",
+                                "acl" => RIGHTS_ALL, 
+                                "type"=>"user"))), 
+                    'user/wiwu/Synchronisierungsprobleme/Lokale Fehler'  => array( 
+                            "name" => "Lokale Fehler", 
+                            "acls" => array(   
+                                array(
+                                    "name" => "wiwu",
+                                    "acl" => RIGHTS_ALL, 
+                                    "type"=>"user"))), 
+                    'user/wiwu/Synchronisierungsprobleme/Serverfehler'  => array( 
+                            "name" => "Serverfehler", 
+                            "acls" => array(   
+                                array(
+                                    "name" => "wiwu",
+                                    "acl" => RIGHTS_ALL, 
+                                    "type"=>"user"))), 
+                    'shared/publicFolder'  => array( 
+                            "name" => "publicFolder", 
+                            "acls" => array(   
+                                array(
+                                    "name" => "wiwu",
+                                    "acl" => RIGHTS_ALL, 
+                                    "type"=>"user"))), 
+                    );
+                       
+                       //need a status for the array - setting them now for the example data.
+            foreach($resultArr["mailFolder"] as $id => $folder){
+                $resultArr["mailFolder"][$id]['status'] = '';
+            }
+
+        }
 
         //TODO: getLocation muss ebenfalls geholt werden 
         // Quota quotaUsage, quotaSize
@@ -272,11 +311,37 @@ class GroupwareDao{
        //This is a feature with many datasets inside which should be cut in slices and saved separately.
        //Since the knowledge about the feature is only known in the plugin this has got to be moved.
        
-       function saveFoldersAndAcls($mailFolder){
-       
+       function saveFoldersAndAcls($id, $mailFolder){
+               echo "Hape";
+               /*
+                'user/wiwu/Aufgaben' => array( 
+                        "name" =>"Aufgaben",
+                        "acls"=> array(        
+                            array(
+                                "name" => "wiwu",
+                                "acl"  => RIGHTS_ALL, 
+                                "type"=>"user"),
+                            array(
+                                "name" => "2a",
+                                "acl" => RIGHTS_ALL, 
+                                "type"=>"user"))), 
+               */
                foreach($mailFolder as $key => $val)
                {
-                                       
+                       if(!empty($val["status"])){
+                               switch($val["status"]){
+                                       case "add":
+                                               $this->save("mailFolder", $id, $key);
+                                               break;
+                                       case "del":
+                                               $this->delete("mailFolder", $id, $key);
+                                               break;
+                               }
+                               print_a($val);
+                       }
+                       $this->save("private_folderACLS", $id, $val["acls"]);
+                       //otherwise nothing happened with the entry - no action should be performed.
+                       //TODO: Save the acls: $this->save("folderSetMembers", id, array);
                }
        
        }
index 460adda4fba209a06795cbcaed91c5068c435c76..41482d574aa672ab0a18724e309e84b840a7b692 100644 (file)
@@ -8,6 +8,41 @@
 
 {if $mailFolder_isActive}
     {$fileBrowser}
+
+    {t}Add folder{/t}:&nbsp;
+    <input name='folderName_Input' type='text'><button name="folderName_Add">{msgPool type=addButton}</button>
+
+    {if $currentSelectedFolder != ""}
+    <b>{t}Folder permission{/t}</b><br> 
+
+    <p>
+    {t}Current folder{/t}: <i>{$currentSelectedFolder}</i> <!--<input type='text' name="currentFolderName" value="{$folderEntries.name}">-->
+    <b>{$folderEntries.name}</b>
+    </p>
+
+    <table>
+        <tr>
+            <td>{t}Name{/t}</td>
+            <td>{t}Permission{/t}</td>
+            <td>{t}Type{/t}</td>
+        </tr>
+        {foreach from=$folderEntries.acls item=item key=key}
+            <tr>
+                <td>{$item.type}</td>
+                <td><input type='text' name="permission_{$key}_name" value="{$item.name}"></td>
+                <td><input type='text' name="permission_{$key}_acl" value="{$item.acl}"></td>
+                <td><button name="permission_{$key}_del">{msgPool type=delButton}</button></td>
+            </tr>
+        {/foreach}
+        <tr>
+            <td></td>
+            <td></td>
+            <td></td>
+            <td><button name="permission_add">{msgPool type=addButton}</button></td>
+        </tr>
+    </table>
+    <hr>
+    {/if}
 {/if}
 <table summary="{t}Mail settings{/t}" style='width:100%;'>
     <tr>