Code

Added check to folder editor dialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 15 Oct 2010 10:09:26 +0000 (10:09 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 15 Oct 2010 10:09:26 +0000 (10:09 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20057 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/groupware/personal/groupware/FolderWidget/class_FolderEditDialog.inc

index ec54aa69cac4b964f3700cc5175dbe8ad17023cf..ef8556130b3ff05fa496a691a2de183e173fb990 100644 (file)
@@ -59,6 +59,7 @@ class FolderEditDialog extends plugin
 
             // Name or ACL modified?
             if(isset($_POST["permission_{$id}_name"])) {
+                $name = get_post("permission_{$id}_name");
                 $this->folderItem['acls'][$id]['name'] = get_post("permission_{$id}_name");
             }
             if(isset($_POST["permission_{$id}_acl"])) {
@@ -75,16 +76,42 @@ class FolderEditDialog extends plugin
         if(isset($_POST['permission_add'])){
             $this->folderItem['acls'][] = array('name' => '', 'acl' => 0, 'type' => 'user');
         }
+
         $this->folderItem['acls'] = array_values($this->folderItem['acls']);
     }
 
+    
     function isNew()
     {
         return($this->isNew);
     }
 
+
+    function check()
+    {
+        $message = array();
+
+        // Check if we've duplicate ACL definitions for a user 
+        $aclNames = array();
+        foreach($this->folderItem['acls'] as $entry){
+            if(!isset($aclNames[$entry['name']])){
+                $aclNames[$entry['name']] = TRUE;
+            }else{
+                $message[] = sprintf(_("Duplicate permission setting for user '%s'."), $entry['name']);
+            }
+        }
+
+        return($message);
+    }
+
+
     function save()
     {
+        // Remove empty ACL defintions
+        foreach($this->folderItem['acls'] as $id => $entry){
+            if(empty($entry['name'])) unset($this->folderItem['acls'][$id]);
+        }
+
         return($this->folderItem);
     }
 }