Code

Added Translation Strings.
[gosa.git] / include / class_plugin.inc
index f6b453acb18953eb946d22d2439de271059bcbc1..624714b6febbd10dc4cf70e3bb7af0998a3753d4 100644 (file)
@@ -151,7 +151,7 @@ class plugin
         if (preg_match('/top/i', $obj)){
           continue;
         }
-        if (!in_array_ics ($obj, $this->attrs['objectClass'])){
+        if (!isset($this->attrs['objectClass']) || !in_array_ics ($obj, $this->attrs['objectClass'])){
           $found= FALSE;
           break;
         }
@@ -174,15 +174,8 @@ class plugin
    */
   function execute()
   {
-    /* Do we represent a valid account? */
-    if (!$this->is_account){
-      echo "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
-        _("This 'dn' has no account extensions.")."</b>";
-      return;
-    }
-
-    /* Show dummy message */
-    echo _("This is an empty plugin.");
+    # This one is empty currently. Fabian - please fill in the docu code
+    $_SESSION['current_class_for_help'] = get_class($this);
   }
 
   /* remove object from parent */
@@ -233,7 +226,6 @@ class plugin
     /* Save values to object */
     foreach ($this->attributes as $val){
       if (chkacl ($this->acl, "$val") == "" && isset ($_POST["$val"])){
-
         /* Check for modifications */
         if (get_magic_quotes_gpc()) {
           $data= stripcslashes($_POST["$val"]);
@@ -243,6 +235,17 @@ class plugin
         if ($this->$val != $data){
           $this->is_modified= TRUE;
         }
+    
+        /* Okay, how can I explain this fix ... 
+         * In firefox, disabled option fields aren't selectable ... but in IE you can select these fileds. 
+         * So IE posts these 'unselectable' option, with value = chr(194) 
+         * chr(194) seems to be the &nbsp; in between the ...option>&nbsp;</option.. because there is no value=".." specified in these option fields  
+         * This &nbsp; was added for W3c compliance, but now causes these ... ldap errors ... 
+         * So we set these Fields to ""; a normal empty string, and we can check these values in plugin::check() again ...
+         */
+        if(isset($data[0]) && $data[0] == chr(194)) {
+          $data = "";  
+        }
         $this->$val= $data;
       }
     }
@@ -355,7 +358,7 @@ class plugin
     } else {
       $state= "";
     }
-    $display= "<table width=\"100%\"><tr>\n<td colspan=2><p><b>$text</b></p>\n";
+    $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>";
@@ -366,15 +369,17 @@ class plugin
   function postcreate()
   {
     /* Find postcreate entries for this class */
-    $command= $this->search($this->config->data['MENU'], get_class($this), "POSTCREATE");
-    if ($command == ""){
-      $command= $this->search($this->config->data['SERVICE'], get_class($this), "POSTCREATE");
+    $command= search_config($this->config->data['MENU'], get_class($this), "POSTCREATE");
+    if ($command == "" && isset($this->config->data['TABS'])){
+      $command= search_config($this->config->data['TABS'], get_class($this), "POSTCREATE");
     }
 
     if ($command != ""){
       /* Walk through attribute list */
       foreach ($this->attributes as $attr){
-        $command= preg_replace("/%$attr/", $this->$attr, $command);
+        if (!is_array($this->$attr)){
+          $command= preg_replace("/%$attr/", $this->$attr, $command);
+        }
       }
       $command= preg_replace("/%dn/", $this->dn, $command);
       if (check_command($command)){
@@ -392,15 +397,17 @@ class plugin
   function postmodify()
   {
     /* Find postcreate entries for this class */
-    $command= $this->search($this->config->data['MENU'], get_class($this), "POSTMODIFY");
-    if ($command == ""){
-      $command= $this->search($this->config->data['SERVICE'], get_class($this), "POSTMODIFY");
+    $command= search_config($this->config->data['MENU'], get_class($this), "POSTMODIFY");
+    if ($command == "" && isset($this->config->data['TABS'])){
+      $command= search_config($this->config->data['TABS'], get_class($this), "POSTMODIFY");
     }
 
     if ($command != ""){
       /* Walk through attribute list */
       foreach ($this->attributes as $attr){
-        $command= preg_replace("/%$attr/", $this->$attr, $command);
+        if (!is_array($this->$attr)){
+          $command= preg_replace("/%$attr/", $this->$attr, $command);
+        }
       }
       $command= preg_replace("/%dn/", $this->dn, $command);
       if (check_command($command)){
@@ -418,15 +425,17 @@ class plugin
   function postremove()
   {
     /* Find postremove entries for this class */
-    $command= $this->search($this->config->data['MENU'], get_class($this), "POSTREMOVE");
-    if ($command == ""){
-      $command= $this->search($this->config->data['SERVICE'], get_class($this), "POSTREMOVE");
+    $command= search_config($this->config->data['MENU'], get_class($this), "POSTREMOVE");
+    if ($command == "" && isset($this->config->data['TABS'])){
+      $command= search_config($this->config->data['TABS'], get_class($this), "POSTREMOVE");
     }
 
     if ($command != ""){
       /* Walk through attribute list */
       foreach ($this->attributes as $attr){
-        $command= preg_replace("/%$attr/", $this->$attr, $command);
+        if (!is_array($this->$attr)){
+          $command= preg_replace("/%$attr/", $this->$attr, $command);
+        }
       }
       $command= preg_replace("/%dn/", $this->dn, $command);
       if (check_command($command)){
@@ -441,29 +450,6 @@ class plugin
     }
   }
 
-  function search($arr, $name, $return)
-  {
-    if (is_array($arr)){
-      foreach ($arr as $a){
-        if (isset($a['CLASS']) &&
-            strtolower($a['CLASS']) == strtolower($name)){
-
-          if (isset($a[$return])){
-            return ($a[$return]);
-          } else {
-            return ("");
-          }
-        } else {
-          $res= $this->search ($a, $name, $return);
-          if ($res != ""){
-            return $res;
-          }
-        }
-      }
-    }
-    return ("");
-  }
-
   /* Create unique DN */
   function create_unique_dn($attribute, $base)
   {
@@ -503,7 +489,7 @@ class plugin
       $this->reconnect= true;
       return (0);
     } else {
-      $this->error = "Could not bind to " . $binddn;
+      $this->error = "Could not bind to " . $credentials['ADMIN'];
       return NULL;
     }
   }