From 61548633949d27437b7801cbe6cafe55a7a84846 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 15 Sep 2010 20:09:57 +0000 Subject: [PATCH] remove hooks of apps, when deleting them (event if sources are no longer there) --- phpgwapi/inc/class.hooks.inc.php | 4 ++-- setup/applications.php | 3 +-- setup/inc/class.setup.inc.php | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpgwapi/inc/class.hooks.inc.php b/phpgwapi/inc/class.hooks.inc.php index e5919caaa0..f928a6c496 100644 --- a/phpgwapi/inc/class.hooks.inc.php +++ b/phpgwapi/inc/class.hooks.inc.php @@ -195,7 +195,7 @@ class hooks * * @param string $appname Application 'name' * @param array $hooks=null hooks to register, eg $setup_info[$app]['hooks'] or not used for only deregister the hooks - * @return boolean false on error, true otherwise + * @return boolean|int false on error, true if new hooks are supplied and registed or number of removed hooks */ function register_hooks($appname,$hooks=null) { @@ -207,7 +207,7 @@ class hooks if (!is_array($hooks) || !count($hooks)) // only deregister { - return True; + return $this->db->affected_rows(); } //echo "

ADDING hooks for: $appname

"; foreach($hooks as $key => $hook) diff --git a/setup/applications.php b/setup/applications.php index 0b5adf54ad..d4de5d5f3a 100644 --- a/setup/applications.php +++ b/setup/applications.php @@ -138,9 +138,8 @@ if(@get_var('submit',Array('POST'))) $GLOBALS['egw_setup']->deregister_app($setup_info[$appname]['name']); echo '
' . $app_title . ' ' . lang('deregistered') . '.'; - if ($setup_info[$appname]['hooks']) + if ($GLOBALS['egw_setup']->deregister_hooks($setup_info[$appname]['name'])) { - $GLOBALS['egw_setup']->deregister_hooks($setup_info[$appname]['name']); echo '
' . $app_title . ' ' . lang('hooks deregistered') . '.'; } $do_langs = true; diff --git a/setup/inc/class.setup.inc.php b/setup/inc/class.setup.inc.php index 1c8d475c28..aa85a437d2 100644 --- a/setup/inc/class.setup.inc.php +++ b/setup/inc/class.setup.inc.php @@ -772,6 +772,7 @@ class setup * de-Register an application's hooks * * @param $appname Application 'name' with a matching $setup_info[$appname] array slice + * @return boolean|int false on error or number of removed hooks */ function deregister_hooks($appname) { @@ -790,7 +791,7 @@ class setup { $this->hooks =& CreateObject('phpgwapi.hooks',$this->db,$this->hooks_table); } - $this->hooks->register_hooks($appname); + return $this->hooks->register_hooks($appname); } /**