Code

Added (partly) working fai tagging
[gosa.git] / plugins / admin / fai / class_faiVariable.inc
index f6c4a5562658d6e832de1c1d3d5d1dc7c93c3d56..4a901123ea6128c0fc6f4884ff01dce789cb74d6 100644 (file)
@@ -34,18 +34,36 @@ class faiVariable extends plugin
   var $dialog           = NULL;     // a dialog, e.g. new disk dialog
   var $SubObjects       = array();  // All leafobjects of this object
 
+  var $FAIstate         = "";
+
   function faiVariable ($config, $dn= NULL)
   {
     /* Load Attributes */
     plugin::plugin ($config, $dn);
 
+    $this->acl ="#all#";
+
     /* If "dn==new" we try to create a new entry
      * Else we must read all objects from ldap which belong to this entry.
      * First read SubObjects from ldap ... and then the partition definitions for the SubObjects.
      */
+
     if($dn != "new"){
       $this->dn =$dn;
 
+      /* Set acls
+       */
+      $ui   = get_userinfo();
+      $acl  = get_permissions ($this->dn, $ui->subtreeACL);
+      $acli = get_module_permission($acl, "FAIclass", $this->dn);
+      $this->acl=$acli;
+
+      /* Get FAIstate
+       */
+      if(isset($this->attrs['FAIstate'][0])){
+        $this->FAIstate = $this->attrs['FAIstate'][0];
+      }
+
       /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry)
        */
       $ldap     = $this->config->get_ldap_link();
@@ -85,6 +103,7 @@ class faiVariable extends plugin
     /* Add new sub object */
     if(isset($_POST['AddSubObject'])){
       $this->dialog= new $this->subClassName($this->config,"new");
+      $this->dialog->acl = $this->acl;
       $this->is_dialog=true;
     }
 
@@ -97,8 +116,8 @@ class faiVariable extends plugin
     if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){
 
       $var = $_POST['SubObject'][0];
-    
       $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$var]);
+      $this->dialog->acl = $this->acl;
       $_SESSION['objectinfo'] = $this->SubObjects[$var]['dn'];
       $this->is_dialog=true;
     }
@@ -168,7 +187,6 @@ class faiVariable extends plugin
     }
 
     $smarty->assign("SubObjects",$this->getList());
-    $smarty->assign("SubObjectKeys",array_flip($this->getList()));
 
       /* Magic quotes GPC, escapes every ' " \, to solve some security risks
      * If we post the escaped strings they will be escaped again
@@ -182,6 +200,11 @@ class faiVariable extends plugin
       }
     }
 
+      foreach($this->attributes as $attr){
+      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
+    }
+
+
     $display.= $smarty->fetch(get_template_path('faiVariable.tpl', TRUE));
     return($display);
   }
@@ -226,7 +249,7 @@ class faiVariable extends plugin
    */
   function save_object()
   {
-    if(isset($_POST['FAIvariable_posted'])){
+    if((isset($_POST['FAIvariable_posted'])) && ($this->FAIstate != "freeze") ){
       plugin::save_object();
       foreach($this->attributes as $attrs){
         if(isset($_POST[$attrs])){
@@ -240,7 +263,9 @@ class faiVariable extends plugin
   /* Check supplied data */
   function check()
   {
-    $message= array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
     return ($message);
   }
 
@@ -268,6 +293,10 @@ $ldap->modify ($this->attrs);
     }
     show_ldap_error($ldap->get_error());
  
+    /* Do object tagging */
+    $this->handle_object_tagging();
+    show_ldap_error($ldap->get_error());
     /* Prepare FAIscriptEntry to write it to ldap
      * First sort array.
      *  Because we must delete old entries first.
@@ -333,6 +362,9 @@ $ldap->modify ($tmp);
         $this->handle_post_events("add");
       }
       show_ldap_error($ldap->get_error()); 
+
+      $this->handle_object_tagging($sub_dn, $this->gosaUnitTag);
+      show_ldap_error($ldap->get_error()); 
     }
   }
 }