From: hickert Date: Wed, 3 Nov 2010 08:42:16 +0000 (+0000) Subject: Updated sharedFolder handling X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5627213ee2d1c6c7603a41e2ec6f158c8ce9b9cd;p=gosa.git Updated sharedFolder handling -Save folder member changes on save() now. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20175 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/groupware/admin/groups/GroupwareSharedFolder/class_GroupwareSharedFolder.inc b/gosa-plugins/groupware/admin/groups/GroupwareSharedFolder/class_GroupwareSharedFolder.inc index b08e321c0..a82a9e637 100644 --- a/gosa-plugins/groupware/admin/groups/GroupwareSharedFolder/class_GroupwareSharedFolder.inc +++ b/gosa-plugins/groupware/admin/groups/GroupwareSharedFolder/class_GroupwareSharedFolder.inc @@ -113,6 +113,7 @@ class GroupwareSharedFolder extends plugin $entry = array(); $entry['name'] = $name; $entry['status'] = ''; + $entry['acls'] = array(); $acls = array(); $acls = $rpc->gwFolderGetMembers($path); if(!$rpc->success()){ @@ -123,7 +124,9 @@ class GroupwareSharedFolder extends plugin 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; } } @@ -153,7 +156,6 @@ class GroupwareSharedFolder extends plugin { plugin::execute(); - // Initialization failed - Display a stripped template which allows // to retry initialization if(!$this->initialized){ @@ -264,6 +266,8 @@ class GroupwareSharedFolder extends plugin */ function save() { + $rpc = $this->config->getRpcHandle(); + // Walk through folders and perform requested actions foreach($this->folderList as $path => $folder){ @@ -271,25 +275,57 @@ class GroupwareSharedFolder extends plugin $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 "
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 "
Removed {$path}"; continue; } + + // Add newly created folders if($folder['status'] == 'added'){ - echo "
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 "
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 "
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 "
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 "
Updating members for {$path} "; } } }