diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc index 26d8c50f6d2ec1c4094c0094b393509e966a2f0a..c005a8431a7e4d7f3cb0c4fd69d808d4f67037ab 100644 --- a/include/simpleplugin/class_simplePlugin.inc +++ b/include/simpleplugin/class_simplePlugin.inc @@ -1422,6 +1422,16 @@ class simplePlugin implements SimpleTab return $this->handle_hooks('PRE', $mode, $addAttrs); } + function fillHookAttrs (array &$addAttrs) + { + // Walk trough attributes list and add the plugins attributes. + foreach ($this->attributes as $attr) { + if (!isset($addAttrs[$attr])) { + $addAttrs[$attr] = $this->$attr; + } + } + } + /*! * \brief Calls external hooks which are defined for this plugin (fusiondirectory.conf) * Replaces placeholder by class values of this plugin instance. @@ -1438,10 +1448,7 @@ class simplePlugin implements SimpleTab $messages = []; foreach ($commands as $command) { - // Walk trough attributes list and add the plugins attributes. - foreach ($this->attributes as $attr) { - $addAttrs[$attr] = $this->$attr; - } + $this->fillHookAttrs($addAttrs); $ui = get_userinfo(); @@ -1455,11 +1462,9 @@ class simplePlugin implements SimpleTab $addAttrs['location'] = $config->current['NAME']; if (isset($this->parent->by_object)) { - foreach ($this->parent->by_object as $object) { - foreach ($object->attributes as $attr) { - if (!isset($addAttrs[$attr])) { - $addAttrs[$attr] = $object->$attr; - } + foreach ($this->parent->by_object as $class => $object) { + if ($class != get_class($this)) { + $object->fillHookAttrs($addAttrs); } } } diff --git a/include/simpleplugin/interface_SimpleTab.inc b/include/simpleplugin/interface_SimpleTab.inc index bf3e362991ca1e077f861ce8a7b62d4ec2a3ddcf..7a6070f7c00449c757f51c6c8bf454a04bcc875a 100644 --- a/include/simpleplugin/interface_SimpleTab.inc +++ b/include/simpleplugin/interface_SimpleTab.inc @@ -142,4 +142,11 @@ interface SimpleTab * Used by prepare_save and template::apply */ public function mergeObjectClasses (array $oc): array; + + /*! + * \brief Fill attributes which may be used in hooks + * + * Used by simplePlugin::callHook + */ + public function fillHookAttrs (array &$addAttrs); } diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index 4e20f2bcf603604a359d0387e9d27bfe5be4e5a3..0332c69374df5e7df899470034fdb916c2f1a3e2 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -389,12 +389,12 @@ class user extends simplePlugin } } - function callHook ($cmd, array $addAttrs = [], &$returnOutput = [], &$returnCode = NULL): array + function fillHookAttrs (array &$addAttrs) { + parent::fillHookAttrs($addAttrs); $addAttrs['passwordMethod'] = $this->attributesAccess['userPassword']->getMethod(); $addAttrs['userLocked'] = (int)($this->attributesAccess['userPassword']->isLocked()); $addAttrs['passwordClear'] = $this->attributesAccess['userPassword']->getClear(); - return parent::callHook($cmd, $addAttrs, $returnOutput, $returnCode); } static function reportPasswordProblems ($user, $new_password, $repeated_password, $current_password = NULL)