Code

Removed duplicated hash detection
[gosa.git] / include / class_plugin.inc
index d1af40e8564fe97326ecaabf22e21edd56b1906f..5f2a567b741e14943f12e995f8806ad7fdf11580 100644 (file)
@@ -107,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
@@ -114,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;    
@@ -130,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){
@@ -376,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 */
@@ -502,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);
   }
@@ -860,7 +877,9 @@ class plugin
     }
     $todo[] = "is_account";
     foreach($todo as $var){
-      $this->$var = $source->$var;
+      if (isset($source->$var)){
+        $this->$var= $source->$var;
+      }
     }
   }