Code

Updated management class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Jan 2010 08:59:01 +0000 (08:59 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Jan 2010 08:59:01 +0000 (08:59 +0000)
-We may want to send post events from the mangement plugins too

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

gosa-core/include/class_management.inc

index 81a798b5876e808fb4728848a4f9d7c178c33136..516f0b476ffd81be76e4addaf5f5a19967d34cb2 100644 (file)
@@ -335,8 +335,8 @@ class management
         $this->dn = $dn;
         $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory, true, true);
         $this->tabObject->set_acl_base($this->dn);
-        $this->tabObject->delete ();
         $this->tabObject->parent = &$this;
+        $this->tabObject->delete ();
 
         // Remove the lock for the current object.
         del_lock($this->dn);        
@@ -850,6 +850,59 @@ class management
     $this->filter = $str;
   }
 
+
+  function postcreate() {
+    $this->_handlePostEvent('POSTCREATE');
+  }
+  function postmodify(){
+    $this->_handlePostEvent('POSTMODIFY');
+  }
+  function postremove(){
+    $this->_handlePostEvent('POSTREMOVE');
+  }
+
+  function _handlePostEvent($type)
+  {
+
+    /* Find postcreate entries for this class */
+    $command= $this->config->search(get_class($this), $type,array('menu', 'tabs'));
+    if ($command != ""){
+
+      /* Walk through attribute list */
+      foreach ($this->attributes as $attr){
+        if (!is_array($this->$attr)){
+          $add_attrs[$attr] = $this->$attr;
+        }
+      }
+      $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= str_replace("%$name", "$value", $command);
+      }
+
+      if (check_command($command)){
+        @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
+            $command, "Execute");
+        exec($command,$arr);
+        foreach($arr as $str){
+          @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
+              $command, "Result: ".$str);
+        }
+      } else {
+        $message= msgPool::cmdnotfound($type, get_class($this));
+        msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
+      }
+    }
+
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: