index 33f750a351abde4216839399a5784ca2d3519d83..ba5c715c72d8504c21f5a1e96a026576399a1f80 100644 (file)
*/
function plugin (&$config, $dn= NULL, $object= NULL)
{
*/
function plugin (&$config, $dn= NULL, $object= NULL)
{
+
+ $this->initTime = microtime(TRUE);
+
/* Configuration is fine, allways */
$this->config= &$config;
$this->dn= $dn;
/* Configuration is fine, allways */
$this->config= &$config;
$this->dn= $dn;
}
}
}
}
+ // 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;
/* Handle new accounts, don't read information from LDAP */
if ($dn == "new"){
return;
session::set('LOCK_VARS_USED_REQUEST',array());
pathNavigator::registerPlugin($this);
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
}
/*! \brief Removes object from parent
/*
$ldap->modify($this->attrs);
*/
/*
$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));
+ }
}
}
/* Save values to object */
foreach ($this->attributes as $val){
if (isset ($_POST["$val"]) && $this->acl_is_writeable($val)){
/* Save values to object */
foreach ($this->attributes as $val){
if (isset ($_POST["$val"]) && $this->acl_is_writeable($val)){
+
/* Check for modifications */
/* 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;
}
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.
/* Okay, how can I explain this fix ...
* In firefox, disabled option fields aren't selectable ... but in IE you can select these fileds.
/* Handle tagging */
$this->tag_attrs($this->attrs);
/* 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;
+ }
}
}
}
/* Find hooks entries for this class */
}
/* Find hooks entries for this class */
- $command = $config->configRegistry->getPropertyValue(get_class($plugin),"check");
+ $command = $this->config->configRegistry->getPropertyValue(get_class($this),"check");
if ($command != ""){
if (!check_command($command)){
if ($command != ""){
if (!check_command($command)){
// Migrate objectgroups if needed
$ogroups = get_sub_list("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))",
// Migrate objectgroups if needed
$ogroups = get_sub_list("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))",
- "ogroups", array(get_ou("ogroupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+ "ogroups", array(get_ou("group", "ogroupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
// Walk through all objectGroups
foreach($ogroups as $ogroup){
// Walk through all objectGroups
foreach($ogroups as $ogroup){
}
// Migrate rfc groups if needed
}
// Migrate rfc groups if needed
- $groups = get_sub_list("(&(objectClass=posixGroup)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))","groups", array(get_ou("groupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+ $groups = get_sub_list("(&(objectClass=posixGroup)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))","groups", array(get_ou("core", "groupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
// Walk through all POSIX groups
foreach($groups as $group){
// Walk through all POSIX groups
foreach($groups as $group){
}
/* Update roles to use the new entry dn */
}
/* Update roles to use the new entry dn */
- $roles = get_sub_list("(&(objectClass=organizationalRole)(roleOccupant=".LDAP::prepare4filter(LDAP::fix($src_dn))."))","roles", array(get_ou("roleRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+ $roles = get_sub_list("(&(objectClass=organizationalRole)(roleOccupant=".LDAP::prepare4filter(LDAP::fix($src_dn))."))","roles", array(get_ou("roleGeneric", "roleRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
// Walk through all roles
foreach($roles as $role){
// Walk through all roles
foreach($roles as $role){
trigger_error(sprintf("Failed to update manager for %s: %s", bold($entry['dn']), $ldap->get_error()));
}
}
trigger_error(sprintf("Failed to update manager for %s: %s", bold($entry['dn']), $ldap->get_error()));
}
}
+
+ // Migrate 'dyn-groups' here. labeledURIObject
+ if(class_available('DynamicLdapGroup')) {
+ DynamicLdapGroup::moveDynGroup($this->config,$src_dn,$dst_dn);
+ }
/* Check if there are gosa departments moved.
If there were deps moved, the force reload of config->deps.
/* Check if there are gosa departments moved.
If there were deps moved, the force reload of config->deps.
return(TRUE);
}
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){
/* Try to move the entry instead of copy & delete
*/
if(TRUE){
}
}
- /*! \brief Return plugin informations for acl handling */
+ /*! \brief Return plugin informations for acl handling
+ * See class_core.inc for examples.
+ */
static function plInfo()
{
return array();
static function plInfo()
{
return array();
if (isset ($_POST["$val"]) && $this->acl_is_writeable($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= $this->$val = get_post($val);
if ($this->$val != $data){
$this->is_modified= TRUE;
}
if ($this->$val != $data){
$this->is_modified= TRUE;
}
* Replaces placeholder by class values of this plugin instance.
* @param Allows to a add special replacements.
*/
* Replaces placeholder by class values of this plugin instance.
* @param Allows to a add special replacements.
*/
- static function callHook($plugin, $cmd, $addAttrs= array())
+ static function callHook($plugin, $cmd, $addAttrs= array(), &$returnOutput = array(), &$returnCode = NULL)
{
global $config;
$command = $config->configRegistry->getPropertyValue(get_class($plugin),$cmd);
{
global $config;
$command = $config->configRegistry->getPropertyValue(get_class($plugin),$cmd);
-
+
if ($command != ""){
// Walk trough attributes list and add the plugins attributes.
if ($command != ""){
// Walk trough attributes list and add the plugins attributes.
$ui = get_userinfo();
$addAttrs['callerDN']=$ui->dn;
$addAttrs['dn']=$plugin->dn;
$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();
// Sort attributes by length, ensures correct replacement
$tmp = array();
}
if (check_command($command)){
}
if (check_command($command)){
+
@DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,$command,"Execute");
@DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,$command,"Execute");
- exec($command,$arr);
- if(is_array($arr)){
+ exec($command, $arr, $returnCode);
+ $returnOutput = $arr;
+
+ if($returnCode != 0){
+ $str = implode("\n",$arr);
+ @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execution failed code: ".$returnCode);
+ $message= msgPool::cmdexecfailed($cmd,$command, get_class($plugin));
+ msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
+ }elseif(is_array($arr)){
$str = implode("\n",$arr);
@DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Result: ".$str);
}
} else {
$str = implode("\n",$arr);
@DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Result: ".$str);
}
} else {
- $message= msgPool::cmdnotfound("POSTCREATE", get_class($plugin));
+ $message= msgPool::cmdinvalid($cmd,$command, get_class($plugin));
msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
}
}
msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
}
}