X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_plugin.inc;h=ba5c715c72d8504c21f5a1e96a026576399a1f80;hb=f04b7b95f6468a806353f05cdd3faf97dd744d5c;hp=436aee0da1fac639264f176181c7d26d2de16971;hpb=72528950e1a5aa06d0dd88c393e43060a59ca311;p=gosa.git diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index 436aee0da..ba5c715c7 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -145,6 +145,9 @@ class plugin */ function plugin (&$config, $dn= NULL, $object= NULL) { + + $this->initTime = microtime(TRUE); + /* Configuration is fine, allways */ $this->config= &$config; $this->dn= $dn; @@ -161,6 +164,10 @@ class plugin } } + // Create statistic table entry + stats::log('plugin', $class = get_class($this), $category = array($this->acl_category), $action = 'open', + $amount = 1, $duration = (microtime(TRUE) - $this->initTime)); + /* Handle new accounts, don't read information from LDAP */ if ($dn == "new"){ return; @@ -282,6 +289,10 @@ class plugin session::set('LOCK_VARS_USED_REQUEST',array()); pathNavigator::registerPlugin($this); + + // Create statistic table entry + stats::log('plugin', $class = get_class($this), $category = array($this->acl_category), $action = 'view', + $amount = 1, $duration = (microtime(TRUE) - $this->initTime)); } /*! \brief Removes object from parent @@ -319,6 +330,13 @@ class plugin /* $ldap->modify($this->attrs); */ + if($this->initially_was_account){ + $this->handle_pre_events('remove'); + + // Create statistic table entry + stats::log('plugin', $class = get_class($this), $category = array($this->acl_category), $action = 'remove', + $amount = 1, $duration = (microtime(TRUE) - $this->initTime)); + } } @@ -334,15 +352,13 @@ class plugin /* Save values to object */ foreach ($this->attributes as $val){ if (isset ($_POST["$val"]) && $this->acl_is_writeable($val)){ + /* Check for modifications */ - if (get_magic_quotes_gpc()) { - $data= stripcslashes($_POST["$val"]); - } else { - $data= $this->$val = $_POST["$val"]; - } + $data= get_post($val); if ($this->$val != $data){ $this->is_modified= TRUE; } + $this->$val = $data; /* Okay, how can I explain this fix ... * In firefox, disabled option fields aren't selectable ... but in IE you can select these fileds. @@ -400,6 +416,45 @@ class plugin /* Handle tagging */ $this->tag_attrs($this->attrs); + + if($this->is_new){ + $this->handle_pre_events('add'); + + // Create statistic table entry + stats::log('plugin', $class = get_class($this), $category = array($this->acl_category), $action = 'create', + $amount = 1, $duration = (microtime(TRUE) - $this->initTime)); + }else{ + $this->handle_pre_events('modify'); + + // Create statistic table entry + stats::log('plugin', $class = get_class($this), $category = array($this->acl_category), $action = 'modify', + $amount = 1, $duration = (microtime(TRUE) - $this->initTime)); + } + } + + + /*! \brief Forward command execution requests + * to the hook execution method. + */ + function handle_pre_events($mode, $addAttrs= array()) + { + if(!in_array($mode, array('add','remove','modify'))){ + trigger_error(sprintf("Invalid pre event type given %s! Valid types are [add,modify,remove].", $mode)); + return; + } + switch ($mode){ + case "add": + plugin::callHook($this,"PRECREATE", $addAttrs); + break; + + case "modify": + plugin::callHook($this,"PREMODIFY", $addAttrs); + break; + + case "remove": + plugin::callHook($this,"PREREMOVE", $addAttrs); + break; + } } @@ -947,7 +1002,10 @@ class plugin return(TRUE); } - + // Create statistic table entry + stats::log('plugin', $class = get_class($this), $category = array($this->acl_category), $action = 'move', + $amount = 1, $duration = (microtime(TRUE) - $this->initTime)); + /* Try to move the entry instead of copy & delete */ if(TRUE){ @@ -1449,12 +1507,7 @@ class plugin if (isset ($_POST["$val"]) && $this->acl_is_writeable($val)){ - /* Check for modifications */ - if (get_magic_quotes_gpc()) { - $data= stripcslashes($_POST["$val"]); - } else { - $data= $this->$val = $_POST["$val"]; - } + $data= $this->$val = get_post($val); if ($this->$val != $data){ $this->is_modified= TRUE; } @@ -1534,7 +1587,7 @@ class plugin { global $config; $command = $config->configRegistry->getPropertyValue(get_class($plugin),$cmd); - + if ($command != ""){ // Walk trough attributes list and add the plugins attributes. @@ -1546,6 +1599,7 @@ class plugin $ui = get_userinfo(); $addAttrs['callerDN']=$ui->dn; $addAttrs['dn']=$plugin->dn; + $addAttrs['location']=$config->current['NAME']; // Sort attributes by length, ensures correct replacement $tmp = array();