From 4fdbf1ef63db3516ccd8924bc8d2cf9cc5cf5ab0 Mon Sep 17 00:00:00 2001 From: hzerres Date: Wed, 6 Oct 2010 12:36:32 +0000 Subject: [PATCH] [hickert]: Added simple folder editing widget just for testing -Will be updated later git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19924 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../personal/groupware/class_Groupware.inc | 72 +++++++++- .../personal/groupware/class_GroupwareDao.inc | 123 +++++++++++++----- .../groupware/personal/groupware/generic.tpl | 35 +++++ 3 files changed, 195 insertions(+), 35 deletions(-) diff --git a/gosa-plugins/groupware/personal/groupware/class_Groupware.inc b/gosa-plugins/groupware/personal/groupware/class_Groupware.inc index 44b3b239e..907a09ab0 100644 --- a/gosa-plugins/groupware/personal/groupware/class_Groupware.inc +++ b/gosa-plugins/groupware/personal/groupware/class_Groupware.inc @@ -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 = "{$name}"; } + + $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); diff --git a/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc b/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc index 0f763e069..f7ad60711 100644 --- a/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc +++ b/gosa-plugins/groupware/personal/groupware/class_GroupwareDao.inc @@ -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); } } diff --git a/gosa-plugins/groupware/personal/groupware/generic.tpl b/gosa-plugins/groupware/personal/groupware/generic.tpl index 460adda4f..41482d574 100644 --- a/gosa-plugins/groupware/personal/groupware/generic.tpl +++ b/gosa-plugins/groupware/personal/groupware/generic.tpl @@ -8,6 +8,41 @@ {if $mailFolder_isActive} {$fileBrowser} + + {t}Add folder{/t}:  + + + {if $currentSelectedFolder != ""} + {t}Folder permission{/t}
+ +

+ {t}Current folder{/t}: {$currentSelectedFolder} + {$folderEntries.name} +

+ + + + + + + + {foreach from=$folderEntries.acls item=item key=key} + + + + + + + {/foreach} + + + + + + +
{t}Name{/t}{t}Permission{/t}{t}Type{/t}
{$item.type}
+
+ {/if} {/if} -- 2.30.2