Code

Fixed mangement handling;
[gosa.git] / gosa-core / plugins / admin / acl / class_aclRole.inc
index 8229059306094d3df7974a0364b4db228b282ba2..5f96b0dea1bda890c2ce83412e2cc720995bafea 100644 (file)
@@ -49,6 +49,7 @@ class aclrole extends acl
   /* Role attributes */
   var $gosaAclTemplate= "";
   var $cn = "";
+  var $orig_cn = "";
   var $description = "";
   var $orig_dn;
   var $orig_base;
@@ -60,7 +61,7 @@ class aclrole extends acl
     plugin::plugin($config, $dn);
 
     if($this->dn == "new"){
-      $this->base  = session::global_get('CurrentMainBase');
+      $this->base  = session::get('CurrentMainBase');
     }else{
       $this->base = preg_replace("/^[^,]+,[^,]+,/","",$this->dn);
       new log("view","acl/".get_class($this),$this->dn);
@@ -77,7 +78,7 @@ class aclrole extends acl
     ksort($this->gosaAclTemplate);
 
     /* Extract available categories from plugin info list */
-    $tmp= session::global_get('plist');
+    $tmp= session::get('plist');
     $plist= $tmp->info;
     $oc = array();
     foreach ($plist as $class => $acls){
@@ -139,6 +140,7 @@ class aclrole extends acl
     $this->is_account= TRUE;
     $this->orig_base = $this->base;
     $this->orig_dn = $this->dn;
+    $this->orig_cn = $this->cn;
   }
 
 
@@ -177,7 +179,7 @@ class aclrole extends acl
       }
     }
 
-    $tmp= session::global_get('plist');
+    $tmp= session::get('plist');
     $plist= $tmp->info;
 
     /* Handle posts */
@@ -191,6 +193,18 @@ class aclrole extends acl
     $new_acl= array();
     $aclDialog= FALSE;
     $firstedit= FALSE;
+
+    /* Act on HTML post and gets here.
+     */
+    if(isset($_GET['id']) && isset($_GET['act']) && $_GET['act'] == "edit"){
+      $id = trim($_GET['id']);
+      $this->dialogState= 'create';
+      $firstedit= TRUE;
+      $this->dialog= TRUE;
+      $this->currentIndex= $id;
+      $this->loadAclEntry();
+    }
+
     foreach($_POST as $name => $post){
 
       /* Actions... */
@@ -252,7 +266,7 @@ class aclrole extends acl
 
       /* ACL saving... */
       if (preg_match('/^acl_.*_[^xy]$/', $name) && $this->acl_is_writeable("gosaAclEntry")){
-        list($dummy, $object, $attribute, $value)= split('_', $name);
+        list($dummy, $object, $attribute, $value)= explode('_', $name);
 
         /* Skip for detection entry */
         if ($object == 'dummy') {
@@ -364,8 +378,15 @@ class aclrole extends acl
 
       /* Fill in entries */
       foreach ($this->gosaAclTemplate as $key => $entry){
-        $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:100px'");
-        $field2= array("string" => $this->assembleAclSummary($entry));
+
+        if($this->acl_is_readable("")){
+          $link = "<a href=?plug=".$_GET['plug']."&amp;id=".$key."&amp;act=edit>".$this->assembleAclSummary($entry)."</a>";
+        }else{
+          $link = $this->assembleAclSummary($entry);
+        }
+
+        $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'");
+        $field2= array("string" => $link);
 
         $action ="";
         if($this->acl_is_writeable("gosaAclEntry")){
@@ -405,9 +426,7 @@ class aclrole extends acl
             $summary.= "$oc, ";
             continue;
           }
-          if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"]) && isset($this->aclContents["$section/$oc"][0]) &&
-              $this->aclContents["$section/$oc"][0] != ""){
-
+          if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){
             $summary.= "$oc, ";
             continue;
           }
@@ -477,7 +496,7 @@ class aclrole extends acl
 
   function sort_by_priority($list)
   {
-    $tmp= session::global_get('plist');
+    $tmp= session::get('plist');
     $plist= $tmp->info;
     asort($plist);
     $newSort = array();
@@ -619,7 +638,7 @@ class aclrole extends acl
     /* Refresh users ACL */
     $ui= get_userinfo();
     $ui->loadACL();
-    session::global_set('ui',$ui);
+    session::set('ui',$ui);
   }
 
 
@@ -744,7 +763,20 @@ class aclrole extends acl
     if(empty($this->cn)){
       $message[] = msgPool::required(_("Name"));
     }
-   
+  
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    if($this->cn != $this->orig_cn){
+      $ldap->search("(&(objectClass=gosaRole)(cn=".$this->cn."))");
+      if($ldap->count()) {
+        while($attrs = $ldap->fetch()){
+          if($attrs['dn'] != $this->orig_dn){
+            $message[] = msgPool::duplicated(_("Name"));
+          }
+        }
+      }
+    } 
     if(!count($this->gosaAclTemplate)){
       $message[] = msgPool::required(_("ACL"));
     }