Code

Fixecd exec call.
[gosa.git] / include / class_plugin.inc
index c02a3b86c263d8b8af8c73faf535006763063b0b..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);
@@ -902,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;