Code

closes #411
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 9 Apr 2008 10:21:35 +0000 (10:21 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 9 Apr 2008 10:21:35 +0000 (10:21 +0000)
-Postcreate/modify/remove fixed replacements

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10297 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_plugin.inc

index 047b218983372683ee6a609d473c5877163d40bd..8ae807992ea217da787fb42990ede73407aa53c4 100644 (file)
@@ -608,18 +608,25 @@ class plugin
 
     if ($command != ""){
 
-      /* Additional attributes */
-      foreach ($add_attrs as $name => $value){
-        $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);
+          $add_attrs[$attr] = $this->$attr;
         }
       }
-      $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
+      $add_attrs['dn']=$this->dn;
+
+      $tmp = array();
+      foreach($add_attrs as $name => $value){
+        $tmp[$name] =  strlen($name);
+      }
+      arsort($tmp);
+      
+      /* Additional attributes */
+      foreach ($tmp as $name => $len){
+        $value = $add_attrs[$name];
+        $command= preg_replace("/%$name/", "$value ", $command);
+      }
 
       if (check_command($command)){
         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
@@ -640,23 +647,28 @@ class plugin
 
     if ($command != ""){
 
-      /* Additional attributes */
-      foreach ($add_attrs as $name => $value){
-        $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);
+          $add_attrs[$attr] = $this->$attr;
         }
       }
-      $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
+      $add_attrs['dn']=$this->dn;
 
-      if (check_command($command)){
-        @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
-            $command, "Execute");
+      $tmp = array();
+      foreach($add_attrs as $name => $value){
+        $tmp[$name] =  strlen($name);
+      }
+      arsort($tmp);
+      
+      /* Additional attributes */
+      foreach ($tmp as $name => $len){
+        $value = $add_attrs[$name];
+        $command= preg_replace("/%$name/", "$value ", $command);
+      }
 
+      if (check_command($command)){
+        @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,$command, "Execute");
         exec($command);
       } else {
         $message[]= msgPool::cmdnotfound("POSTMODIFY", get_class($this));
@@ -671,18 +683,25 @@ class plugin
     $command= $this->config->search(get_class($this), "POSTREMOVE",array('menu','tabs'));
     if ($command != ""){
 
-      /* Additional attributes */
-      foreach ($add_attrs as $name => $value){
-        $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);
+          $add_attrs[$attr] = $this->$attr;
         }
       }
-      $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
+      $add_attrs['dn']=$this->dn;
+
+      $tmp = array();
+      foreach($add_attrs as $name => $value){
+        $tmp[$name] =  strlen($name);
+      }
+      arsort($tmp);
+      
+      /* Additional attributes */
+      foreach ($tmp as $name => $len){
+        $value = $add_attrs[$name];
+        $command= preg_replace("/%$name/", "$value ", $command);
+      }
 
       if (check_command($command)){
         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,