Code

Centralized copy & paste ACL checks.
[gosa.git] / gosa-core / plugins / admin / acl / class_aclRole.inc
index 03a843fc21eda4dd07f0c2727c9213a9f96507df..2f90c41900d5a5467948e1659901ff33d8cb1757 100644 (file)
@@ -51,6 +51,7 @@ class aclrole extends acl
   var $cn = "";
   var $description = "";
   var $orig_dn;
+  var $orig_base;
   var $base ="";
 
   function aclrole (&$config,  $dn= NULL)
@@ -136,6 +137,8 @@ class aclrole extends acl
 
     /* Finally - we want to get saved... */
     $this->is_account= TRUE;
+    $this->orig_base = $this->base;
+    $this->orig_dn = $this->dn;
   }
 
 
@@ -355,8 +358,8 @@ class aclrole extends acl
       foreach ($this->gosaAclTemplate as $key => $entry){
         $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:100px'");
         $field2= array("string" => $this->assembleAclSummary($entry));
-        $action= "<input type='image' name='sortup_$key' alt='up' title='"._("Up")."' src='images/sort_up.png' align='top'>";
-        $action.= "<input type='image' name='sortdown_$key' alt='down' title='"._("Down")."' src='images/sort_down.png'>";
+        $action= "<input type='image' name='sortup_$key' alt='up' title='"._("Up")."' src='images/lists/sort-up.png' align='top'>";
+        $action.= "<input type='image' name='sortdown_$key' alt='down' title='"._("Down")."' src='images/lists/sort-down.png'>";
         $action.= "<input class='center' type='image' src='images/lists/edit.png' alt='"._("Edit")."' name='acl_edit_$key' title='".msgPool::editButton(_("ACL"))."'>";
         $action.= "<input class='center' type='image' src='images/lists/trash.png' alt='"._("Delete")."' name='acl_del_$key' title='".msgPool::delButton(_("ACL"))."'>";
 
@@ -706,6 +709,29 @@ class aclrole extends acl
         ));
   }
 
+  function check()
+  {
+    $message = plugin::check();
+
+    if(empty($this->cn)){
+      $message[] = msgPool::required(_("Name"));
+    }
+   
+    if(!count($this->gosaAclTemplate)){
+      $message[] = msgPool::required(_("ACL"));
+    }
+    /* Check if we are allowed to create or move this object
+     */
+    if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
+      $message[] = msgPool::permCreate();
+    }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
+      $message[] = msgPool::permMove();
+    }
+
+    return($message);
+  }
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: