Code

Added toggling of remove flag for packages
[gosa.git] / plugins / admin / fai / class_faiVariable.inc
index baa760623810ce89323f695b221bcc1f95f318e8..1c596cb50dd73d913a81b31be0722c74106bacb5 100644 (file)
@@ -116,7 +116,6 @@ 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'];
@@ -188,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
@@ -265,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);
   }
 
@@ -277,12 +277,12 @@ class faiVariable extends plugin
  
     $ldap = $this->config->get_ldap_link();
   
-    $ldap->cat($this->dn);
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()!=0){
       /* Write FAIscript to ldap*/
       $ldap->cd($this->dn);
       $this->cleanup();
-$ldap->modify ($this->attrs); 
+      $ldap->modify ($this->attrs); 
 
     }else{
       /* Write FAIscript to ldap*/
@@ -291,7 +291,10 @@ $ldap->modify ($this->attrs);
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
     }
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Saving FAI variable base failed"));
+    /* Do object tagging */
+    $this->handle_object_tagging();
  
     /* Prepare FAIscriptEntry to write it to ldap
      * First sort array.
@@ -329,9 +332,20 @@ $ldap->modify ($this->attrs);
       $sub_dn = "cn=".$obj['cn'].",".$this->dn;
 
       if($obj['status']=="new"){
-        $ldap->cat($sub_dn);
+        $ldap->cat($sub_dn,array("objectClass"));
         if($ldap->count()){
-          $obj['status']="modify";
+          $obj['status']="edited";
+        }
+      }
+
+      /* Check if gosaAdministrativeUnitTag is required as object class */
+      if($obj['status'] == "edited"){
+        $ldap->cat($sub_dn,array("objectClass"));
+        $attrs = $ldap->fetch();
+        if(isset($attrs['objectClass'])){
+          if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
+            $tmp['objectClass'][] = "gosaAdministrativeUnitTag";
+          }
         }
       }
  
@@ -339,12 +353,14 @@ $ldap->modify ($this->attrs);
         $ldap->cd($sub_dn);
         $ldap->rmdir_recursive($sub_dn);
         $this->handle_post_events("remove");
+        show_ldap_error($ldap->get_error(), _("Removing FAI variable failed")); 
       }elseif($obj['status'] == "edited"){
         $ldap->cd($sub_dn);
         $this->cleanup();
-$ldap->modify ($tmp); 
+        $ldap->modify ($tmp); 
 
         $this->handle_post_events("modify");
+        show_ldap_error($ldap->get_error(), _("Saving FAI variable failed")); 
       }elseif($obj['status']=="new"){
 
         if($tmp['description'] == array()){
@@ -356,8 +372,10 @@ $ldap->modify ($tmp);
         $ldap->cd($sub_dn);
         $ldap->add($tmp); 
         $this->handle_post_events("add");
+        show_ldap_error($ldap->get_error(), _("Saving FAI variable failed")); 
       }
-      show_ldap_error($ldap->get_error()); 
+
+      $this->handle_object_tagging($sub_dn, $this->gosaUnitTag);
     }
   }
 }