From 31697278d15c9c9b68d3d05c97f52c9077c61ef0 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 1 Oct 2019 14:06:00 +0200 Subject: [PATCH] check for hook attached to parent class in hasHook() --- inc/inc.ClassViewCommon.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/inc/inc.ClassViewCommon.php b/inc/inc.ClassViewCommon.php index 95f3e5d09..8ec9f69bf 100644 --- a/inc/inc.ClassViewCommon.php +++ b/inc/inc.ClassViewCommon.php @@ -181,11 +181,20 @@ class SeedDMS_View_Common { * null if no hook was called */ public function hasHook($hook) { /* {{{ */ + $tmps = array(); $tmp = explode('_', get_class($this)); - if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])])) { - foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])] as $hookObj) { - if (method_exists($hookObj, $hook)) { - return true; + $tmps[] = $tmp[2]; + $tmp = explode('_', get_parent_class($this)); + $tmps[] = $tmp[2]; + /* Run array_unique() in case the parent class has the same suffix */ + $tmps = array_unique($tmps); + $ret = null; + foreach($tmps as $tmp) { + if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)])) { + foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)] as $hookObj) { + if (method_exists($hookObj, $hook)) { + return true; + } } } }