summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a8e114f)
raw | patch | inline | side by side (parent: a8e114f)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 3 Nov 2010 08:42:16 +0000 (08:42 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 3 Nov 2010 08:42:16 +0000 (08:42 +0000) |
-Save folder member changes on save() now.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20175 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20175 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/groupware/admin/groups/GroupwareSharedFolder/class_GroupwareSharedFolder.inc | patch | blob | history |
diff --git a/gosa-plugins/groupware/admin/groups/GroupwareSharedFolder/class_GroupwareSharedFolder.inc b/gosa-plugins/groupware/admin/groups/GroupwareSharedFolder/class_GroupwareSharedFolder.inc
index b08e321c0fc8f07b2c40142b5e203fca9e49dfc3..a82a9e63733101d6c5d24587b1a50a7412b89230 100644 (file)
$entry = array();
$entry['name'] = $name;
$entry['status'] = '';
+ $entry['acls'] = array();
$acls = array();
$acls = $rpc->gwFolderGetMembers($path);
if(!$rpc->success()){
msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG);
return;
}
- $entry['acls'] = $acls;
+ foreach($acls as $name => $acl){
+ $entry['acls'][] = array('type' => 'user', 'acl' => $acl, 'name' => $name);
+ }
$folderList[$path] = $entry;
}
}
{
plugin::execute();
-
// Initialization failed - Display a stripped template which allows
// to retry initialization
if(!$this->initialized){
*/
function save()
{
+ $rpc = $this->config->getRpcHandle();
+
// Walk through folders and perform requested actions
foreach($this->folderList as $path => $folder){
$path = preg_replace("/\{%cn\}/", $this->cn, $path);
$folder['name'] = preg_replace("/\{%cn\}/", $this->cn, $folder['name']);
- // Call requested backend methods, for added/removed
+ // Remove shared folder.
if($folder['status'] == 'removed'){
- echo "<br>Remove folder {$path}";
+ $rpc->gwFolderDel($path);
+ if(!$rpc->success()){
+ $message = sprintf(_("Failed to remove shared folder '%s'! Error was: '%s'."),
+ $path, $rpc->get_error());
+ msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG);
+ }
+
+ echo "<br>Removed {$path}";
continue;
}
+
+ // Add newly created folders
if($folder['status'] == 'added'){
- echo "<br>Add folder {$path}";
- continue;
+ $rpc->gwFolderAdd($path);
+ if(!$rpc->success()){
+ $message = sprintf(_("Failed to create shared folder '%s'! Error was: '%s'."),
+ $path, $rpc->get_error());
+ msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG);
+ }
+
+ echo "<br>Added {$path}";
+ }
+
+ // Collect old and new members and their acls, to be able to compare them later.
+ $oldList = $this->saved_attributes['folderList'];
+ $oldAcls = array();
+ $newAcls = array();
+ $oldMembers = array();
+ $newMembers = array();
+ if(isset($oldList[$path])){
+ foreach($oldList[$path]['acls'] as $entry){
+ $oldMembers[] = $entry['name'];
+ $oldAcls[$entry['name']] = $entry['acl'];
+ }
}
-
- // Set members
- echo "<br>Set members for {$path} ";
- $members = array();
- foreach($folder['acls'] as $id => $data) $members[] = $data['name'];
- print_a($members);
-
- // Set permissions
- foreach($folder['acls'] as $id => $data){
- echo "<br>Set acls for {$data['name']} : {$data['acl']}";
+ foreach($folder['acls'] as $entry){
+ $newMembers[] = $entry['name'];
+ $newAcls[$entry['name']] = $entry['acl'];
+ }
+
+ // Check if member list has changed.
+ if(array_differs($newMembers,$oldMembers) || array_differs($oldAcls, $newAcls)){
+ $rpc->gwFolderSetMembers($path, $newAcls);
+ if(!$rpc->success()){
+ $message = sprintf(_("Failed to create shared folder '%s'! Error was: '%s'."),
+ $path, $rpc->get_error());
+ msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG);
+ }
+ echo "<br>Updating members for {$path} ";
}
}
}