Code

Removed duplicated hash detection
[gosa.git] / include / class_plugin.inc
index 15180d73cbd1719b2805435b63ce8ae03a597d83..5f2a567b741e14943f12e995f8806ad7fdf11580 100644 (file)
@@ -83,6 +83,9 @@ class plugin
    */
   var $attrs= array();
 
+  /* Keep set of conflicting plugins */
+  var $conflicts= array();
+
   /* Save unit tags */
   var $gosaUnitTag= "";
 
@@ -104,6 +107,9 @@ class plugin
   var $new= TRUE;
   var $saved_attributes= array();
 
+  /* This can be set to render the tabulators in another stylesheet */
+  var $pl_notify= FALSE;
+
   /*! \brief plugin constructor
 
     If 'dn' is set, the node loads the given 'dn' from LDAP
@@ -111,7 +117,7 @@ class plugin
     \param dn Distinguished name to initialize plugin from
     \sa plugin()
    */
-  function plugin ($config, $dn= NULL)
+  function plugin ($config, $dn= NULL, $parent= NULL)
   {
     /* Configuration is fine, allways */
     $this->config= $config;    
@@ -127,8 +133,12 @@ class plugin
     if ($dn != NULL){
 
       /* Load data to 'attrs' and save 'dn' */
-      $ldap->cat ($dn);
-      $this->attrs= $ldap->fetch();
+      if ($parent != NULL){
+        $this->attrs= $parent->attrs;
+      } else {
+        $ldap->cat ($dn);
+        $this->attrs= $ldap->fetch();
+      }
 
       /* Copy needed attributes */
       foreach ($this->attributes as $val){
@@ -261,7 +271,7 @@ class plugin
     foreach ($this->attributes as $val){
       if (chkacl ($this->acl, "$val") == "" && isset ($_POST["$val"])){
         /* Check for modifications */
-        if (get_magic_quotes_gpc()) {
+        if ((get_magic_quotes_gpc()) && !is_array($_POST["$val"])) {
           $data= stripcslashes($_POST["$val"]);
         } else {
           $data= $this->$val = $_POST["$val"];
@@ -373,6 +383,11 @@ class plugin
         }
       }
     }
+
+    /* Update saved attributes and ensure that next cleanups will be successful too */
+    foreach($this->attrs as $name => $value){
+      $this->saved_attributes[$name] = $value;
+    }
   }
 
   /* Check formular input */
@@ -499,15 +514,20 @@ class plugin
   /* Show header message for tab dialogs */
   function show_header($button_text, $text, $disabled= FALSE)
   {
+    $state = "disabled";
+    if($this->is_account && $this->acl == "#all#"){
+      $state= "";
+    }elseif(!$this->is_account && chkacl($this->acl,"create") == ""){
+      $state= "";
+    }
+
     if ($disabled == TRUE){
       $state= "disabled";
-    } else {
-      $state= "";
     }
+
     $display= "<table summary=\"\" width=\"100%\"><tr>\n<td colspan=2><p><b>$text</b></p>\n";
-    $display.= "<input type=submit value=\"$button_text\" name=\"modify_state\" ".
-      chkacl($this->acl, "all")." ".$state.
-      "><p class=\"seperator\">&nbsp;</p></td></tr></table>";
+    $display.= "<input type=submit value=\"$button_text\" name=\"modify_state\" ".$state.">".
+                "<p class=\"seperator\">&nbsp;</p></td></tr></table>";
 
     return($display);
   }
@@ -663,7 +683,7 @@ class plugin
   {
     /* Rename dn in possible object groups */
     $ldap= $this->config->get_ldap_link();
-    $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.$src_dn.'))',
+    $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.@LDAP::fix($src_dn).'))',
         array('cn'));
     while ($attrs= $ldap->fetch()){
       $og= new ogroup($this->config, $ldap->getDN());
@@ -675,7 +695,7 @@ class plugin
     $ldap->cat($dst_dn);
     $attrs= $ldap->fetch();
     if (count($attrs)){
-      trigger_error("Trying to overwrite $dst_dn, which already exists.",
+      trigger_error("Trying to overwrite ".@LDAP::fix($dst_dn).", which already exists.",
           E_USER_WARNING);
       return (FALSE);
     }
@@ -683,7 +703,7 @@ class plugin
     $ldap->cat($src_dn);
     $attrs= $ldap->fetch();
     if (!count($attrs)){
-      trigger_error("Trying to move $src_dn, which does not seem to exist.",
+      trigger_error("Trying to move ".@LDAP::fix($src_dn).", which does not seem to exist.",
           E_USER_WARNING);
       return (FALSE);
     }
@@ -697,7 +717,7 @@ class plugin
 
     $r=ldap_bind($ds,$this->config->current['ADMIN'], $this->config->current['PASSWORD']);
     error_reporting (0);
-    $sr=ldap_read($ds, $ldap->fix($src_dn), "objectClass=*");
+    $sr=ldap_read($ds, @LDAP::fix($src_dn), "objectClass=*");
 
     /* Fill data from LDAP */
     $new= array();
@@ -725,14 +745,14 @@ class plugin
     /* Adapt naming attribute */
     $dst_name= preg_replace("/^([^=]+)=.*$/", "\\1", $dst_dn);
     $dst_val = preg_replace("/^[^=]+=([^,+]+).*,.*$/", "\\1", $dst_dn);
-    $new[$dst_name]= $dst_val;
+    $new[$dst_name]= @LDAP::fix($dst_val);
 
     /* Check if this is a department.
      * If it is a dep. && there is a , override in his ou 
      *  change \2C to , again, else this entry can't be saved ...
      */
-    if((isset($new['ou'])) &&( preg_match("/\\\\2C/",$new['ou']))){
-      $new['ou'] = preg_replace("/\\\\2C/",",",$new['ou']);
+    if((isset($new['ou'])) &&( preg_match("/\\,/",$new['ou']))){
+      $new['ou'] = preg_replace("/\\\\,/",",",$new['ou']);
     }
 
     /* Save copy */
@@ -857,7 +877,9 @@ class plugin
     }
     $todo[] = "is_account";
     foreach($todo as $var){
-      $this->$var = $source->$var;
+      if (isset($source->$var)){
+        $this->$var= $source->$var;
+      }
     }
   }
 
@@ -924,7 +946,7 @@ class plugin
           echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
           flush();
         }
-        $nattrs= array("gosaUnitTag" => $this->gosaUnitTag);
+        $nattrs= array("gosaUnitTag" => $tag);
         $nattrs['objectClass']= array();
         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
           $oc= $attrs['objectClass'][$i];
@@ -972,6 +994,14 @@ class plugin
     
   }
 
+
+  /* Add possibility to stop remove process */
+  function allow_remove()
+  {
+    $reason= "";
+    return $reason;
+  }
+
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>