Browse Source

Merge pull request #156 from emanuele45/other_few_hooks

Other few hooks (i.e. hook in createList and createMenu to allow expand any menu and any list in a centralized way)
emanuele45 12 years ago
parent
commit
2d3995e722

+ 0 - 3
Sources/Admin.php

@@ -457,9 +457,6 @@ function AdminMain()
 		}
 	}
 
-	// Let them modify admin areas easily.
-	call_integration_hook('integrate_admin_areas', array(&$admin_areas));
-
 	// Make sure the administrator has a valid session...
 	validateSession();
 

+ 1 - 0
Sources/Logging.php

@@ -247,6 +247,7 @@ function displayDebug()
 	', $txt['debug_subtemplates'], count($context['debug']['sub_templates']), ': <em>', implode('</em>, <em>', $context['debug']['sub_templates']), '</em>.<br />
 	', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br />
 	', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br />
+	', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br />
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br />';
 
 	// What tokens are active?

+ 0 - 4
Sources/ManageMembergroups.php

@@ -196,8 +196,6 @@ function MembergroupIndex()
 		),
 	);
 
-	call_integration_hook('integrate_modify_regular_groups', array(&$listOptions));
-
 	require_once($sourcedir . '/Subs-List.php');
 	createList($listOptions);
 
@@ -309,8 +307,6 @@ function MembergroupIndex()
 		),
 	);
 
-	call_integration_hook('integrate_modify_post_groups', array(&$listOptions));
-
 	createList($listOptions);
 }
 

+ 0 - 2
Sources/ManageMembers.php

@@ -609,8 +609,6 @@ function ViewMemberlist()
 	if (!allowedTo('profile_remove_any'))
 		unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']);
 
-	call_integration_hook('integrate_view_members_list', array(&$listOptions));
-
 	require_once($sourcedir . '/Subs-List.php');
 	createList($listOptions);
 

+ 0 - 3
Sources/ModerationCenter.php

@@ -154,9 +154,6 @@ function ModerationMain($dont_call = false)
 		),
 	);
 
-	// Let them modify admin areas easily.
-	call_integration_hook('integrate_moderate_areas', array(&$moderation_areas));
-
 	// Make sure the administrator has a valid session...
 	validateSession('moderate');
 

+ 2 - 0
Sources/ScheduledTasks.php

@@ -28,6 +28,8 @@ function AutoTask()
 		ReduceMailQueue();
 	else
 	{
+		call_integration_hook('integrate_autotask_include');
+
 		// Select the next task to do.
 		$request = $smcFunc['db_query']('', '
 			SELECT id_task, task, next_time, time_offset, time_regularity, time_unit

+ 2 - 0
Sources/Subs-List.php

@@ -31,6 +31,8 @@ function createList($listOptions)
 	assert((empty($listOptions['default_sort_col']) || isset($listOptions['columns'][$listOptions['default_sort_col']])));
 	assert((!isset($listOptions['form']) || isset($listOptions['form']['href'])));
 
+	call_integration_hook('integrate_' . $listOptions['id'], array(&$listOptions));
+
 	// All the context data will be easily accessible by using a reference.
 	$context[$listOptions['id']] = array();
 	$list_context = &$context[$listOptions['id']];

+ 4 - 0
Sources/Subs-Menu.php

@@ -66,6 +66,10 @@ function createMenu($menuData, $menuOptions = array())
 	// What is the general action of this menu (i.e. $scripturl?action=XXXX.
 	$menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action'];
 
+	// Allow extend *any* menu with a single hook
+	if (!empty($menuOptions['action']))
+		call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData));
+
 	// What is the current area selected?
 	if (isset($menuOptions['current_area']) || isset($_GET['area']))
 		$menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area'];

+ 4 - 1
Sources/Subs.php

@@ -4046,7 +4046,10 @@ function smf_seed_generator()
  */
 function call_integration_hook($hook, $parameters = array())
 {
-	global $modSettings, $settings, $boarddir, $sourcedir;
+	global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug, $context;
+
+	if ($db_show_debug === true)
+		$context['debug']['hooks'][] = $hook;
 
 	$results = array();
 	if (empty($modSettings[$hook]))

+ 1 - 0
Themes/default/languages/index.english.php

@@ -799,5 +799,6 @@ $txt['debug_show_queries'] = '[Show Queries]';
 $txt['debug_hide_queries'] = '[Hide Queries]';
 $txt['debug_tokens'] = 'Tokens: ';
 $txt['debug_browser'] = 'Browser ID: ';
+$txt['debug_hooks'] = 'Hooks called: ';
 
 ?>