Commit 825aeb56 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #4347 Removed support for hooks outside of LDAP config

parent c5457c79
......@@ -900,68 +900,25 @@ class config {
return FALSE;
}
function __search(&$arr, $name, $return)
{
$return = strtoupper($return);
if (is_array($arr)) {
foreach ($arr as &$a) {
if (isset($a['CLASS']) && strcasecmp($name, $a['CLASS']) == 0) {
return (isset($a[$return])?$a[$return]:"");
} else {
$res = $this->__search ($a, $name, $return);
if ($res != "") {
return $res;
}
}
}
unset($a);
}
return "";
}
/*!
* \brief Search for a configuration setting in different categories
*
* Searches for the value of a given key in the configuration data.
* Optionally the list of categories to search (tabs, main, locations) can
* be specified. The first value that matches is returned.
* \brief Search for a hook
*
* Example usage:
* \code
* $postcmd = $this->config->search(get_class($this), "POSTCOMMAND", array("menu", "tabs"));
* $postcmd = $this->config->search(get_class($this), 'POSTMODIFY');
* \endcode
*
* \param string $class The class name
*
* \param string $value Key to search in the configuration data
*
* \param array $categories Array where the search should run
*
* \return string the value you asked for or empty
* \param string $value Key to search in the hooks
*/
function search($class, $value, $categories = "")
function searchHook($class, $value)
{
if (is_array($categories)) {
foreach ($categories as $category) {
$res = $this->__search($this->data[strtoupper($category)], $class, $value);
if ($res != "") {
return $res;
}
}
} else {
if ($categories == "") {
return $this->__search($this->data, $class, $value);
} else {
return $this->__search($this->data[strtoupper($categories)], $class, $value);
}
}
return "";
$class = strtoupper($class);
$value = strtoupper($value);
return (isset($this->data['HOOKS'][$class][$value]) ? $this->data['HOOKS'][$class][$value] : '');
}
/*!
* \brief Get a configuration value from the config
*
......
......@@ -1611,7 +1611,7 @@ class plugin
return;
}
global $config;
$command = $config->search(get_class($this), $cmd, array('menu','tabs','hooks'));
$command = $config->searchHook(get_class($this), $cmd);
if ($command != "") {
// Walk trough attributes list and add the plugins attributes.
......
......@@ -113,47 +113,6 @@ class simpleService extends simplePlugin {
}
$this->status = $value;
$this->action_hook();
}
function action_hook($add_attrs = array())
{
/* Find postcreate entries for this class */
$command = $this->config->search(get_class($this), "SERVICEACTIONHOOK", array('menu', 'tabs'));
if ($command != "") {
/* Walk through attribute list */
foreach ($this->attributes as $attr) { // TODO : use attribuesInfo instead
if (!is_array($this->$attr)) {
$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);
}
/* If there are still some %.. in our command, try to fill these with some other class vars */
if (preg_match("/%/", $command)) {
$attrs = get_object_vars($this);
foreach ($attrs as $name => $value) {
if (!is_string($value)) {
continue;
}
$command = preg_replace("/%$name%/", escapeshellarg($value), $command);
}
}
if (check_command($command)) {
@DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
exec($command);
} else {
msg_dialog::display(_("Configuration error"), msgPool::cmdnotfound("SERVICEACTIONHOOK", get_class($this)), ERROR_DIALOG);
}
}
}
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment