Code

Fixecd exec call.
[gosa.git] / include / class_plugin.inc
index 9a25100ff3f3e3b25b20975f4325c4c02c8999aa..8c57c441961039ba3c5a21867a7f34a92ba27179 100644 (file)
@@ -88,6 +88,7 @@ class plugin
 
   /* Save unit tags */
   var $gosaUnitTag= "";
+  var $skipTagging= FALSE;
 
   /*!
     \brief Used standard values
@@ -546,22 +547,25 @@ class plugin
 
       /* Additional attributes */
       foreach ($add_attrs as $name => $value){
-        $command= preg_replace("/%$name/", $value, $command);
+        $command= preg_replace("/%$name( |$)/", "$value ", $command);
       }
 
       /* Walk through attribute list */
       foreach ($this->attributes as $attr){
         if (!is_array($this->$attr)){
-          $command= preg_replace("/%$attr/", $this->$attr, $command);
+          $command= preg_replace("/%$attr( |$)/", $this->$attr." ", $command);
         }
       }
-      $command= preg_replace("/%dn/", $this->dn, $command);
+      $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
 
       if (check_command($command)){
         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
             $command, "Execute");
-
-        exec($command);
+        exec($command,$arr);
+        foreach($arr as $str){
+          @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
+            $command, "Result: ".$str);
+        }
       } else {
         $message= sprintf(_("Command '%s', specified as POSTCREATE for plugin '%s' doesn't seem to exist."), $command, get_class($this));
         print_red ($message);
@@ -581,22 +585,26 @@ class plugin
 
       /* Additional attributes */
       foreach ($add_attrs as $name => $value){
-        $command= preg_replace("/%$name/", $value, $command);
+        $command= preg_replace("/%$name( |$)/", "$value ", $command);
       }
 
       /* Walk through attribute list */
       foreach ($this->attributes as $attr){
         if (!is_array($this->$attr)){
-          $command= preg_replace("/%$attr/", $this->$attr, $command);
+          $command= preg_replace("/%$attr( |$)/", $this->$attr." ", $command);
         }
       }
-      $command= preg_replace("/%dn/", $this->dn, $command);
+      $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
 
       if (check_command($command)){
         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
             $command, "Execute");
 
-        exec($command);
+        exec($command,$arr);
+        foreach($arr as $str){
+          @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
+            $command, "Result: ".$str);
+        }
       } else {
         $message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, get_class($this));
         print_red ($message);
@@ -616,27 +624,26 @@ class plugin
 
       /* Additional attributes */
       foreach ($add_attrs as $name => $value){
-        $command= preg_replace("/%$name/", $value, $command);
+        $command= preg_replace("/%$name( |$)/", "$value ", $command);
       }
 
       /* Walk through attribute list */
       foreach ($this->attributes as $attr){
         if (!is_array($this->$attr)){
-          $command= preg_replace("/%$attr/", $this->$attr, $command);
+          $command= preg_replace("/%$attr( |$)/", $this->$attr." ", $command);
         }
       }
-      $command= preg_replace("/%dn/", $this->dn, $command);
-
-      /* Additional attributes */
-      foreach ($add_attrs as $name => $value){
-        $command= preg_replace("/%$name/", $value, $command);
-      }
+      $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
 
       if (check_command($command)){
         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
             $command, "Execute");
 
-        exec($command);
+        exec($command,$arr);
+        foreach($arr as $str){
+          @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
+            $command, "Result: ".$str);
+        }
       } else {
         $message= sprintf(_("Command '%s', specified as POSTREMOVE for plugin '%s' doesn't seem to exist."), $command, get_class($this));
         print_red ($message);
@@ -792,6 +799,12 @@ class plugin
 
   function move($src_dn, $dst_dn)
   {
+
+    /* Do not copy if only upper- lowercase has changed */
+    if(strtolower($src_dn) == strtolower($dst_dn)){
+      return(TRUE);
+    }
+
     /* Copy source to destination */
     if (!$this->copy($src_dn, $dst_dn)){
       return (FALSE);
@@ -896,6 +909,14 @@ class plugin
 
   function tag_attrs($at, $dn= "", $tag= "", $show= false)
   {
+    /* Skip tagging? 
+       If this is called from departmentGeneric, we have to skip this
+        tagging procedure. 
+     */
+    if($this->skipTagging){
+      return;
+    }
+
     /* No dn? Self-operation... */
     if ($dn == ""){
       $dn= $this->dn;