aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorDavid King <imkingdavid@gmail.com>2012-08-20 09:09:53 -0400
committerDavid King <imkingdavid@gmail.com>2012-08-20 09:09:53 -0400
commit310c9069328172a7c0cb890d96b5eb4d14523e78 (patch)
tree8a64fcb4ee4e1321e803aef6c79b12895e1d01d5 /phpBB
parent8c62c33f2a8ab48f05938d55c80b1bf37f9a37d5 (diff)
parentb567175c8d49b774e48fe7cf632d96babb434076 (diff)
downloadforums-310c9069328172a7c0cb890d96b5eb4d14523e78.tar
forums-310c9069328172a7c0cb890d96b5eb4d14523e78.tar.gz
forums-310c9069328172a7c0cb890d96b5eb4d14523e78.tar.bz2
forums-310c9069328172a7c0cb890d96b5eb4d14523e78.tar.xz
forums-310c9069328172a7c0cb890d96b5eb4d14523e78.zip
Merge remote-tracking branch 'nickvergessen/feature/php-events-4' into develop
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/common.php15
-rw-r--r--phpBB/includes/acp/acp_forums.php158
-rw-r--r--phpBB/includes/acp/acp_users.php49
-rw-r--r--phpBB/includes/functions.php59
-rw-r--r--phpBB/includes/functions_acp.php84
-rw-r--r--phpBB/includes/functions_display.php114
-rw-r--r--phpBB/includes/functions_posting.php14
-rw-r--r--phpBB/includes/functions_user.php83
-rw-r--r--phpBB/includes/mcp/mcp_forum.php13
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php25
-rw-r--r--phpBB/includes/ucp/ucp_zebra.php30
-rw-r--r--phpBB/includes/user.php36
-rw-r--r--phpBB/index.php14
-rw-r--r--phpBB/memberlist.php37
-rw-r--r--phpBB/ucp.php12
-rw-r--r--phpBB/viewforum.php19
-rw-r--r--phpBB/viewonline.php42
-rw-r--r--phpBB/viewtopic.php80
18 files changed, 820 insertions, 64 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index 5882bbf9fb..c7c5859c25 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -143,3 +143,18 @@ if (!$config['use_system_cron'])
{
$cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver());
}
+
+/**
+* Main event which is triggered on every page
+*
+* You can use this event to load function files and initiate objects
+*
+* NOTE: At this point the global session ($user) and permissions ($auth)
+* do NOT exist yet. If you need to use the user object
+* (f.e. to include language files) or need to check permissions,
+* please use the core.user_setup event instead!
+*
+* @event core.common
+* @since 3.1-A1
+*/
+$phpbb_dispatcher->dispatch('core.common');
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php
index 3a3b2021eb..c6dbf5eb9c 100644
--- a/phpBB/includes/acp/acp_forums.php
+++ b/phpBB/includes/acp/acp_forums.php
@@ -25,7 +25,7 @@ class acp_forums
function main($id, $mode)
{
- global $db, $user, $auth, $template, $cache, $request;
+ global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher;
global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;
$user->add_lang('acp/forums');
@@ -150,6 +150,17 @@ class acp_forums
'forum_password_unset' => request_var('forum_password_unset', false),
);
+ /**
+ * Request forum data and operate on it (parse texts, etc.)
+ *
+ * @event core.acp_manage_forums_request_data
+ * @var string action Type of the action: add|edit
+ * @var array forum_data Array with new forum data
+ * @since 3.1-A1
+ */
+ $vars = array('action', 'forum_data');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_request_data', compact($vars)));
+
// On add, add empty forum_options... else do not consider it (not updating it)
if ($action == 'add')
{
@@ -386,6 +397,9 @@ class acp_forums
$forum_data['forum_flags'] += (request_var('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0;
}
+ // Initialise $row, so we always have it in the event
+ $row = array();
+
// Show form to create/modify a forum
if ($action == 'edit')
{
@@ -453,6 +467,24 @@ class acp_forums
}
}
+ /**
+ * Initialise data before we display the add/edit form
+ *
+ * @event core.acp_manage_forums_initialise_data
+ * @var string action Type of the action: add|edit
+ * @var bool update Do we display the form only
+ * or did the user press submit
+ * @var int forum_id When editing: the forum id,
+ * when creating: the parent forum id
+ * @var array row Array with current forum data
+ * empty when creating new forum
+ * @var array forum_data Array with new forum data
+ * @var string parents_list List of parent options
+ * @since 3.1-A1
+ */
+ $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_initialise_data', compact($vars)));
+
$forum_rules_data = array(
'text' => $forum_data['forum_rules'],
'allow_bbcode' => true,
@@ -582,7 +614,7 @@ class acp_forums
$errors[] = $user->lang['FORUM_PASSWORD_OLD'];
}
- $template->assign_vars(array(
+ $template_data = array(
'S_EDIT_FORUM' => true,
'S_ERROR' => (sizeof($errors)) ? true : false,
'S_PARENT_ID' => $this->parent_id,
@@ -647,7 +679,31 @@ class acp_forums
'S_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false,
'S_ENABLE_QUICK_REPLY' => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false,
'S_CAN_COPY_PERMISSIONS' => ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))) ? true : false,
- ));
+ );
+
+ /**
+ * Modify forum template data before we display the form
+ *
+ * @event core.acp_manage_forums_display_form
+ * @var string action Type of the action: add|edit
+ * @var bool update Do we display the form only
+ * or did the user press submit
+ * @var int forum_id When editing: the forum id,
+ * when creating: the parent forum id
+ * @var array row Array with current forum data
+ * empty when creating new forum
+ * @var array forum_data Array with new forum data
+ * @var string parents_list List of parent options
+ * @var array errors Array of errors, if you add errors
+ * ensure to update the template variables
+ * S_ERROR and ERROR_MSG to display it
+ * @var array template_data Array with new forum data
+ * @since 3.1-A1
+ */
+ $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list', 'errors', 'template_data');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_display_form', compact($vars)));
+
+ $template->assign_vars($template_data);
return;
@@ -872,10 +928,22 @@ class acp_forums
*/
function update_forum_data(&$forum_data)
{
- global $db, $user, $cache, $phpbb_root_path;
+ global $db, $user, $cache, $phpbb_root_path, $phpbb_dispatcher;
$errors = array();
+ /**
+ * Validate the forum data before we create/update the forum
+ *
+ * @event core.acp_manage_forums_validate_data
+ * @var array forum_data Array with new forum data
+ * @var array errors Array of errors, should be strings and not
+ * language key.
+ * @since 3.1-A1
+ */
+ $vars = array('forum_data', 'errors');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars)));
+
if ($forum_data['forum_name'] == '')
{
$errors[] = $user->lang['FORUM_NAME_EMPTY'];
@@ -968,7 +1036,22 @@ class acp_forums
}
unset($forum_data_sql['forum_password_unset']);
- if (!isset($forum_data_sql['forum_id']))
+ /**
+ * Remove invalid values from forum_data_sql that should not be updated
+ *
+ * @event core.acp_manage_forums_update_data_before
+ * @var array forum_data Array with forum data
+ * @var array forum_data_sql Array with data we are going to update
+ * If forum_data_sql[forum_id] is set, we update
+ * that forum, otherwise a new one is created.
+ * @since 3.1-A1
+ */
+ $vars = array('forum_data', 'forum_data_sql');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars)));
+
+ $is_new_forum = !isset($forum_data_sql['forum_id']);
+
+ if ($is_new_forum)
{
// no forum_id means we're creating a new forum
unset($forum_data_sql['type_action']);
@@ -1239,6 +1322,22 @@ class acp_forums
add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']);
}
+ /**
+ * Event after a forum was updated or created
+ *
+ * @event core.acp_manage_forums_update_data_after
+ * @var array forum_data Array with forum data
+ * @var array forum_data_sql Array with data we updated
+ * @var bool is_new_forum Did we create a forum or update one
+ * If you want to overwrite this value,
+ * ensure to set forum_data_sql[forum_id]
+ * @var array errors Array of errors, should be strings and not
+ * language key.
+ * @since 3.1-A1
+ */
+ $vars = array('forum_data', 'forum_data_sql', 'is_new_forum', 'errors');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_after', compact($vars)));
+
return $errors;
}
@@ -1247,7 +1346,7 @@ class acp_forums
*/
function move_forum($from_id, $to_id)
{
- global $db, $user;
+ global $db, $user, $phpbb_dispatcher;
$to_data = $moved_ids = $errors = array();
@@ -1259,10 +1358,30 @@ class acp_forums
if ($to_data['forum_type'] == FORUM_LINK)
{
$errors[] = $user->lang['PARENT_IS_LINK_FORUM'];
- return $errors;
}
}
+ /**
+ * Event when we move all children of one forum to another
+ *
+ * This event may be triggered, when a forum is deleted
+ *
+ * @event core.acp_manage_forums_move_children
+ * @var int from_id If of the current parent forum
+ * @var int to_id If of the new parent forum
+ * @var array errors Array of errors, should be strings and not
+ * language key.
+ * @since 3.1-A1
+ */
+ $vars = array('from_id', 'to_id', 'errors');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_children', compact($vars)));
+
+ // Return if there were errors
+ if (!empty($errors))
+ {
+ return $errors;
+ }
+
$moved_forums = get_forum_branch($from_id, 'children', 'descending');
$from_data = $moved_forums[0];
$diff = sizeof($moved_forums) * 2;
@@ -1342,7 +1461,30 @@ class acp_forums
*/
function move_forum_content($from_id, $to_id, $sync = true)
{
- global $db;
+ global $db, $phpbb_dispatcher;
+
+ $errors = array();
+
+ /**
+ * Event when we move content from one forum to another
+ *
+ * @event core.acp_manage_forums_move_children
+ * @var int from_id If of the current parent forum
+ * @var int to_id If of the new parent forum
+ * @var bool sync Shall we sync the "to"-forum's data
+ * @var array errors Array of errors, should be strings and not
+ * language key. If this array is not empty,
+ * The content will not be moved.
+ * @since 3.1-A1
+ */
+ $vars = array('from_id', 'to_id', 'sync', 'errors');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content', compact($vars)));
+
+ // Return if there were errors
+ if (!empty($errors))
+ {
+ return $errors;
+ }
$table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 62968a17b7..b54257b04a 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -32,6 +32,7 @@ class acp_users
{
global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
+ global $phpbb_dispatcher;
$user->add_lang(array('posting', 'ucp', 'acp/users'));
$this->tpl_name = 'acp_users';
@@ -749,6 +750,19 @@ class acp_users
}
break;
+
+ default:
+ /**
+ * Run custom quicktool code
+ *
+ * @event core.acp_users_overview_run_quicktool
+ * @var array user_row Current user data
+ * @var string action Quick tool that should be run
+ * @since 3.1-A1
+ */
+ $vars = array('action', 'user_row');
+ extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_run_quicktool', compact($vars)));
+ break;
}
// Handle registration info updates
@@ -855,6 +869,18 @@ class acp_users
}
}
+ /**
+ * Modify user data before we update it
+ *
+ * @event core.acp_users_overview_modify_data
+ * @var array user_row Current user data
+ * @var array data Submitted user data
+ * @var array sql_ary User data we udpate
+ * @since 3.1-A1
+ */
+ $vars = array('user_row', 'data', 'sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_modify_data', compact($vars)));
+
if ($update_username !== false)
{
$sql_ary['username'] = $update_username;
@@ -945,12 +971,6 @@ class acp_users
}
}
- $s_action_options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>';
- foreach ($quick_tool_ary as $value => $lang)
- {
- $s_action_options .= '<option value="' . $value . '">' . $user->lang['USER_ADMIN_' . $lang] . '</option>';
- }
-
if ($config['load_onlinetrack'])
{
$sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
@@ -965,6 +985,23 @@ class acp_users
unset($row);
}
+ /**
+ * Add additional quick tool options and overwrite user data
+ *
+ * @event core.acp_users_display_overview
+ * @var array user_row Array with user data
+ * @var array quick_tool_ary Ouick tool options
+ * @since 3.1-A1
+ */
+ $vars = array('user_row', 'quick_tool_ary');
+ extract($phpbb_dispatcher->trigger_event('core.acp_users_display_overview', compact($vars)));
+
+ $s_action_options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>';
+ foreach ($quick_tool_ary as $value => $lang)
+ {
+ $s_action_options .= '<option value="' . $value . '">' . $user->lang['USER_ADMIN_' . $lang] . '</option>';
+ }
+
$last_visit = (!empty($user_row['session_time'])) ? $user_row['session_time'] : $user_row['user_lastvisit'];
$inactive_reason = '';
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index e5b721b1f5..ecec1e5e4a 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -4753,6 +4753,31 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
define('HEADER_INC', true);
+ // A listener can set this variable to `true` when it overrides this function
+ $page_header_override = false;
+
+ /**
+ * Execute code and/or overwrite page_header()
+ *
+ * @event core.page_header
+ * @var string page_title Page title
+ * @var bool display_online_list Do we display online users list
+ * @var string item Restrict online users to a certain
+ * session item, e.g. forum for
+ * session_forum_id
+ * @var int item_id Restrict online users to item id
+ * @var bool page_header_override Shall we return instead of running
+ * the rest of page_header()
+ * @since 3.1-A1
+ */
+ $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override');
+ extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars)));
+
+ if ($page_header_override)
+ {
+ return;
+ }
+
// gzip_compression
if ($config['gzip_compress'])
{
@@ -5033,9 +5058,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')),
));
- $vars = array('page_title', 'display_online_list', 'item_id', 'item');
- extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars)));
-
// application/xhtml+xml not used because of IE
header('Content-type: text/html; charset=UTF-8');
@@ -5058,7 +5080,27 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
function page_footer($run_cron = true)
{
global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx;
- global $request;
+ global $request, $phpbb_dispatcher;
+
+ // A listener can set this variable to `true` when it overrides this function
+ $page_footer_override = false;
+
+ /**
+ * Execute code and/or overwrite page_footer()
+ *
+ * @event core.page_footer
+ * @var bool run_cron Shall we run cron tasks
+ * @var bool page_footer_override Shall we return instead of running
+ * the rest of page_footer()
+ * @since 3.1-A1
+ */
+ $vars = array('run_cron', 'page_footer_override');
+ extract($phpbb_dispatcher->trigger_event('core.page_footer', compact($vars)));
+
+ if ($page_footer_override)
+ {
+ return;
+ }
// Output page creation time
if (defined('DEBUG'))
@@ -5143,6 +5185,15 @@ function page_footer($run_cron = true)
function garbage_collection()
{
global $cache, $db;
+ global $phpbb_dispatcher;
+
+ /**
+ * Unload some objects, to free some memory, before we finish our task
+ *
+ * @event core.garbage_collection
+ * @since 3.1-A1
+ */
+ $phpbb_dispatcher->dispatch('core.garbage_collection');
// Unload cache, must be done before the DB connection if closed
if (!empty($cache))
diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php
index dc61859363..2f0188289b 100644
--- a/phpBB/includes/functions_acp.php
+++ b/phpBB/includes/functions_acp.php
@@ -22,6 +22,7 @@ function adm_page_header($page_title)
{
global $config, $db, $user, $template;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID;
+ global $phpbb_dispatcher;
if (defined('HEADER_INC'))
{
@@ -30,6 +31,26 @@ function adm_page_header($page_title)
define('HEADER_INC', true);
+ // A listener can set this variable to `true` when it overrides this function
+ $adm_page_header_override = false;
+
+ /**
+ * Execute code and/or overwrite adm_page_header()
+ *
+ * @event core.adm_page_header
+ * @var string page_title Page title
+ * @var bool adm_page_header_override Shall we return instead of
+ * running the rest of adm_page_header()
+ * @since 3.1-A1
+ */
+ $vars = array('page_title', 'adm_page_header_override');
+ extract($phpbb_dispatcher->trigger_event('core.adm_page_header', compact($vars)));
+
+ if ($adm_page_header_override)
+ {
+ return;
+ }
+
// gzip_compression
if ($config['gzip_compress'])
{
@@ -96,7 +117,27 @@ function adm_page_footer($copyright_html = true)
{
global $db, $config, $template, $user, $auth, $cache;
global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx;
- global $request;
+ global $request, $phpbb_dispatcher;
+
+ // A listener can set this variable to `true` when it overrides this function
+ $adm_page_footer_override = false;
+
+ /**
+ * Execute code and/or overwrite adm_page_footer()
+ *
+ * @event core.adm_page_footer
+ * @var bool copyright_html Shall we display the copyright?
+ * @var bool adm_page_footer_override Shall we return instead of
+ * running the rest of adm_page_footer()
+ * @since 3.1-A1
+ */
+ $vars = array('copyright_html', 'adm_page_footer_override');
+ extract($phpbb_dispatcher->trigger_event('core.adm_page_footer', compact($vars)));
+
+ if ($adm_page_footer_override)
+ {
+ return;
+ }
// Output page creation time
if (defined('DEBUG'))
@@ -193,7 +234,7 @@ function h_radio($name, $input_ary, $input_default = false, $id = false, $key =
*/
function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
{
- global $user, $module;
+ global $user, $module, $phpbb_dispatcher;
$tpl = '';
$name = 'config[' . $config_key . ']';
@@ -305,6 +346,24 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
$tpl .= $vars['append'];
}
+ /**
+ * Overwrite the html code we display for the config value
+ *
+ * @event core.build_config_template
+ * @var array tpl_type Config type array:
+ * 0 => data type
+ * 1 [optional] => string: size, int: minimum
+ * 2 [optional] => string: max. length, int: maximum
+ * @var string key Should be used for the id attribute in html
+ * @var array new Array with the config values we display
+ * @var string name Should be used for the name attribute
+ * @var array vars Array with the options for the config
+ * @var string tpl The resulting html code we display
+ * @since 3.1-A1
+ */
+ $vars = array('tpl_type', 'key', 'new', 'name', 'vars', 'tpl');
+ extract($phpbb_dispatcher->trigger_event('core.build_config_template', compact($vars)));
+
return $tpl;
}
@@ -314,7 +373,8 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
*/
function validate_config_vars($config_vars, &$cfg_array, &$error)
{
- global $phpbb_root_path, $user;
+ global $phpbb_root_path, $user, $phpbb_dispatcher;
+
$type = 0;
$min = 1;
$max = 2;
@@ -489,6 +549,24 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
}
break;
+
+ default:
+ /**
+ * Validate a config value
+ *
+ * @event core.validate_config_variable
+ * @var array cfg_array Array with config values
+ * @var string config_name Name of the config we validate
+ * @var array config_definition Array with the options for
+ * this config
+ * @var array error Array of errors, the errors should
+ * be strings only, language keys are
+ * not replaced afterwards
+ * @since 3.1-A1
+ */
+ $vars = array('cfg_array', 'config_name', 'config_definition', 'error');
+ extract($phpbb_dispatcher->trigger_event('core.validate_config_variable', compact($vars)));
+ break;
}
}
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index a1ff7a1f99..66e8459c18 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -22,7 +22,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
{
global $db, $auth, $user, $template;
global $phpbb_root_path, $phpEx, $config;
- global $request;
+ global $request, $phpbb_dispatcher;
$forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
$parent_id = $visible_forums = 0;
@@ -119,6 +119,16 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
'ORDER_BY' => 'f.left_id',
);
+ /**
+ * Event to modify the SQL query before the forum data is queried
+ *
+ * @event core.display_forums_modify_sql
+ * @var array sql_ary The SQL array to get the data of the forums
+ * @since 3.1-A1
+ */
+ $vars = array('sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_sql', compact($vars)));
+
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);
@@ -127,6 +137,19 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
while ($row = $db->sql_fetchrow($result))
{
+ /**
+ * Event to modify the data set of a forum
+ *
+ * This event is triggered once per forum
+ *
+ * @event core.display_forums_modify_row
+ * @var int branch_root_id Last top-level forum
+ * @var array row The data of the forum
+ * @since 3.1-A1
+ */
+ $vars = array('branch_root_id', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_row', compact($vars)));
+
$forum_id = $row['forum_id'];
// Mark forums read?
@@ -260,6 +283,22 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
$forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
}
}
+
+ /**
+ * Event to modify the forum rows data set
+ *
+ * This event is triggered once per forum
+ *
+ * @event core.display_forums_modify_forum_rows
+ * @var array forum_rows Data array of all forums we display
+ * @var array subforums Data array of all subforums we display
+ * @var int branch_root_id Current top-level forum
+ * @var int parent_id Current parent forum
+ * @var array row The data of the forum
+ * @since 3.1-A1
+ */
+ $vars = array('forum_rows', 'subforums', 'branch_root_id', 'parent_id', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_forum_rows', compact($vars)));
}
$db->sql_freeresult($result);
@@ -443,7 +482,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
}
}
- $template->assign_block_vars('forumrow', array(
+ $forum_row = array(
'S_IS_CAT' => false,
'S_NO_CAT' => $catless && !$last_catless,
'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false,
@@ -480,9 +519,24 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
'U_UNAPPROVED_TOPICS' => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=unapproved_topics&amp;f=' . $row['forum_id_unapproved_topics']) : '',
'U_VIEWFORUM' => $u_viewforum,
'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
- 'U_LAST_POST' => $last_post_url)
+ 'U_LAST_POST' => $last_post_url,
);
+ /**
+ * Modify the template data block of the forum
+ *
+ * This event is triggered once per forum
+ *
+ * @event core.display_forums_modify_template_vars
+ * @var array forum_row Template data of the forum
+ * @var array row The data of the forum
+ * @since 3.1-A1
+ */
+ $vars = array('forum_row', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_template_vars', compact($vars)));
+
+ $template->assign_block_vars('forumrow', $forum_row);
+
// Assign subforums loop for style authors
foreach ($subforums_list as $subforum)
{
@@ -830,7 +884,7 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
*/
function display_custom_bbcodes()
{
- global $db, $template, $user;
+ global $db, $template, $user, $phpbb_dispatcher;
// Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
$num_predefined_bbcodes = 22;
@@ -850,17 +904,40 @@ function display_custom_bbcodes()
$row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])];
}
- $template->assign_block_vars('custom_tags', array(
+ $custom_tags = array(
'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'",
'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2),
'BBCODE_TAG' => $row['bbcode_tag'],
'BBCODE_HELPLINE' => $row['bbcode_helpline'],
'A_BBCODE_HELPLINE' => str_replace(array('&amp;', '&quot;', "'", '&lt;', '&gt;'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']),
- ));
+ );
+
+ /**
+ * Modify the template data block of a bbcode
+ *
+ * This event is triggered once per bbcode
+ *
+ * @event core.display_custom_bbcodes_modify_row
+ * @var array custom_tags Template data of the bbcode
+ * @var array row The data of the bbcode
+ * @since 3.1-A1
+ */
+ $vars = array('custom_tags', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_row', compact($vars)));
+
+ $template->assign_block_vars('custom_tags', $custom_tags);
$i++;
}
$db->sql_freeresult($result);
+
+ /**
+ * Display custom bbcodes
+ *
+ * @event core.display_custom_bbcodes
+ * @since 3.1-A1
+ */
+ $phpbb_dispatcher->dispatch('core.display_custom_bbcodes');
}
/**
@@ -1248,6 +1325,31 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
{
global $user, $config, $phpbb_root_path, $phpEx;
+ global $phpbb_dispatcher;
+
+ $overwrite_avatar = '';
+
+ /**
+ * Overwrite users avatar
+ *
+ * @event core.display_custom_bbcodes_modify_row
+ * @var string avatar Users assigned avatar name
+ * @var int avatar_type Type of avatar
+ * @var string avatar_width Width of users avatar
+ * @var string avatar_height Height of users avatar
+ * @var string alt Language string for alt tag within image
+ * Can be a language key or text
+ * @var bool ignore_config Ignores config and force displaying avatar
+ * @var string overwrite_avatar If set, this string will be the avatar
+ * @since 3.1-A1
+ */
+ $vars = array('avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'alt', 'ignore_config', 'overwrite_avatar');
+ extract($phpbb_dispatcher->trigger_event('core.user_get_avatar', compact($vars)));
+
+ if ($overwrite_avatar)
+ {
+ return $overwrite_avatar;
+ }
if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
{
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 4d09367934..c50395a5df 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -20,7 +20,7 @@ if (!defined('IN_PHPBB'))
*/
function generate_smilies($mode, $forum_id)
{
- global $db, $user, $config, $template;
+ global $db, $user, $config, $template, $phpbb_dispatcher;
global $phpEx, $phpbb_root_path;
$start = request_var('start', 0);
@@ -123,6 +123,18 @@ function generate_smilies($mode, $forum_id)
}
}
+ /**
+ * This event is called after the smilies are populated
+ *
+ * @event core.generate_smilies_after
+ * @var string mode Mode of the smilies: window|inline
+ * @var int forum_id The forum ID we are currently in
+ * @var bool display_link Shall we display the "more smilies" link?
+ * @since 3.1-A1
+ */
+ $vars = array('mode', 'forum_id', 'display_link');
+ extract($phpbb_dispatcher->trigger_event('core.generate_smilies_after', compact($vars)));
+
if ($mode == 'inline' && $display_link)
{
$template->assign_vars(array(
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 6e658b4ef4..9e33a5122e 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -112,7 +112,7 @@ function update_last_username()
*/
function user_update_name($old_name, $new_name)
{
- global $config, $db, $cache;
+ global $config, $db, $cache, $phpbb_dispatcher;
$update_ary = array(
FORUMS_TABLE => array('forum_last_poster_name'),
@@ -137,6 +137,17 @@ function user_update_name($old_name, $new_name)
set_config('newest_username', $new_name, true);
}
+ /**
+ * Update a username when it is changed
+ *
+ * @event core.update_username
+ * @var string old_name The old username that is replaced
+ * @var string new_name The new username
+ * @since 3.1-A1
+ */
+ $vars = array('old_name', 'new_name');
+ extract($phpbb_dispatcher->trigger_event('core.update_username', compact($vars)));
+
// Because some tables/caches use username-specific data we need to purge this here.
$cache->destroy('sql', MODERATOR_CACHE_TABLE);
}
@@ -331,7 +342,7 @@ function user_add($user_row, $cp_data = false)
*/
function user_delete($mode, $user_id, $post_username = false)
{
- global $cache, $config, $db, $user, $auth;
+ global $cache, $config, $db, $user, $auth, $phpbb_dispatcher;
global $phpbb_root_path, $phpEx;
$sql = 'SELECT *
@@ -346,6 +357,18 @@ function user_delete($mode, $user_id, $post_username = false)
return false;
}
+ /**
+ * Event before a user is deleted
+ *
+ * @event core.delete_user_before
+ * @var string mode Mode of deletion (retain/delete posts)
+ * @var int user_id ID of the deleted user
+ * @var mixed post_username Guest username that is being used or false
+ * @since 3.1-A1
+ */
+ $vars = array('mode', 'user_id', 'post_username');
+ extract($phpbb_dispatcher->trigger_event('core.delete_user_before', compact($vars)));
+
// Before we begin, we will remove the reports the user issued.
$sql = 'SELECT r.post_id, p.topic_id
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
@@ -535,6 +558,18 @@ function user_delete($mode, $user_id, $post_username = false)
$db->sql_transaction('commit');
+ /**
+ * Event after a user is deleted
+ *
+ * @event core.delete_user_after
+ * @var string mode Mode of deletion (retain/delete posts)
+ * @var int user_id ID of the deleted user
+ * @var mixed post_username Guest username that is being used or false
+ * @since 3.1-A1
+ */
+ $vars = array('mode', 'user_id', 'post_username');
+ extract($phpbb_dispatcher->trigger_event('core.delete_user_after', compact($vars)));
+
// Reset newest user info if appropriate
if ($config['newest_user_id'] == $user_id)
{
@@ -2759,7 +2794,7 @@ function avatar_remove_db($avatar_name)
*/
function group_delete($group_id, $group_name = false)
{
- global $db, $phpbb_root_path, $phpEx;
+ global $db, $phpbb_root_path, $phpEx, $phpbb_dispatcher;
if (!$group_name)
{
@@ -2818,6 +2853,17 @@ function group_delete($group_id, $group_name = false)
WHERE group_id = $group_id";
$db->sql_query($sql);
+ /**
+ * Event after a group is deleted
+ *
+ * @event core.delete_group_after
+ * @var int group_id ID of the deleted group
+ * @var string group_name Name of the deleted group
+ * @since 3.1-A1
+ */
+ $vars = array('group_id', 'group_name');
+ extract($phpbb_dispatcher->trigger_event('core.delete_group_after', compact($vars)));
+
// Re-cache moderators
if (!function_exists('cache_moderators'))
{
@@ -2940,7 +2986,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
*/
function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false)
{
- global $db, $auth, $config;
+ global $db, $auth, $config, $phpbb_dispatcher;
if ($config['coppa_enable'])
{
@@ -3039,6 +3085,19 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
}
unset($special_group_data);
+ /**
+ * Event before users are removed from a group
+ *
+ * @event core.group_delete_user_before
+ * @var int group_id ID of the group from which users are deleted
+ * @var string group_name Name of the group
+ * @var array user_id_ary IDs of the users which are removed
+ * @var array username_ary names of the users which are removed
+ * @since 3.1-A1
+ */
+ $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary');
+ extract($phpbb_dispatcher->trigger_event('core.group_delete_user_before', compact($vars)));
+
$sql = 'DELETE FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id
AND " . $db->sql_in_set('user_id', $user_id_ary);
@@ -3356,7 +3415,7 @@ function group_validate_groupname($group_id, $group_name)
*/
function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false)
{
- global $cache, $db;
+ global $cache, $db, $phpbb_dispatcher;
if (empty($user_id_ary))
{
@@ -3452,6 +3511,20 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
}
}
+ /**
+ * Event when the default group is set for an array of users
+ *
+ * @event core.user_set_default_group
+ * @var int group_id ID of the group
+ * @var array user_id_ary IDs of the users
+ * @var array group_attributes Group attributes which were changed
+ * @var array update_listing Update the list of moderators and foes
+ * @var array sql_ary User attributes which were changed
+ * @since 3.1-A1
+ */
+ $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.user_set_default_group', compact($vars)));
+
if ($update_listing)
{
group_update_listings($group_id);
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php
index 4518e7b7cf..7b3bc82093 100644
--- a/phpBB/includes/mcp/mcp_forum.php
+++ b/phpBB/includes/mcp/mcp_forum.php
@@ -22,7 +22,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
{
global $template, $db, $user, $auth, $cache, $module;
global $phpEx, $phpbb_root_path, $config;
- global $request;
+ global $request, $phpbb_dispatcher;
$user->add_lang(array('viewtopic', 'viewforum'));
@@ -288,6 +288,17 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
));
}
+ /**
+ * Modify the topic data before it is assigned to the template in MCP
+ *
+ * @event core.mcp_view_forum_modify_topicrow
+ * @var array row Array with topic data
+ * @var array topic_row Template array with topic data
+ * @since 3.1-A1
+ */
+ $vars = array('row', 'topic_row');
+ extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars)));
+
$template->assign_block_vars('topicrow', $topic_row);
}
unset($topic_rows);
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index c55e8850a6..569232d878 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
{
global $user, $template, $auth, $db, $cache;
- global $phpbb_root_path, $request, $phpEx, $config;
+ global $phpbb_root_path, $request, $phpEx, $config, $phpbb_dispatcher;
$user->add_lang(array('viewtopic', 'memberlist'));
@@ -204,7 +204,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
}
}
- $template->assign_vars(array(
+ $msg_data = array(
'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
'MESSAGE_AUTHOR' => get_username_string('username', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
@@ -265,9 +265,28 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
'S_CUSTOM_FIELDS' => (!empty($cp_row['row'])) ? true : false,
'U_PRINT_PM' => ($config['print_pm'] && $auth->acl_get('u_pm_printpm')) ? "$url&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] . "&amp;view=print" : '',
- 'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&amp;mode=compose&amp;action=forward&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '')
+ 'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&amp;mode=compose&amp;action=forward&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
);
+ /**
+ * Modify pm and sender data before it is assigned to the template
+ *
+ * @event core.ucp_pm_view_messsage
+ * @var mixed id Active module category (can be int or string)
+ * @var string mode Active module
+ * @var int folder_id ID of the folder the message is in
+ * @var int msg_id ID of the private message
+ * var array folder Array with data of user's message folders
+ * @var array message_row Array with message data
+ * @var array cp_row Array with senders custom profile field data
+ * @var array msg_data Template array with message data
+ * @since 3.1-A1
+ */
+ $vars = array('id', 'mode', 'folder_id', 'msg_id', 'folder', 'message_row', 'cp_row', 'msg_data');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_messsage', compact($vars)));
+
+ $template->assign_vars($msg_data);
+
// Display the custom profile fields
if (!empty($cp_row['row']))
{
diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php
index efe928b387..a669c450a4 100644
--- a/phpBB/includes/ucp/ucp_zebra.php
+++ b/phpBB/includes/ucp/ucp_zebra.php
@@ -25,7 +25,7 @@ class ucp_zebra
function main($id, $mode)
{
- global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $request;
+ global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $request, $phpbb_dispatcher;
$submit = (isset($_POST['submit']) || isset($_GET['add']) || isset($_GET['remove'])) ? true : false;
$s_hidden_fields = '';
@@ -54,9 +54,22 @@ class ucp_zebra
// Remove users
if (!empty($data['usernames']))
{
+ $user_ids = $data['usernames'];
+
+ /**
+ * Remove users from friends/foes
+ *
+ * @event core.ucp_remove_zebra
+ * @var string mode Zebra type: friends|foes
+ * @var array user_ids User ids we remove
+ * @since 3.1-A1
+ */
+ $vars = array('user_ids');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_remove_zebra', compact($vars)));
+
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE user_id = ' . $user->data['user_id'] . '
- AND ' . $db->sql_in_set('zebra_id', $data['usernames']);
+ AND ' . $db->sql_in_set('zebra_id', $user_ids);
$db->sql_query($sql);
$updated = true;
@@ -186,6 +199,19 @@ class ucp_zebra
);
}
+ /**
+ * Add users to friends/foes
+ *
+ * @event core.ucp_add_zebra
+ * @var string mode Zebra type:
+ * friends|foes
+ * @var array sql_ary Array of
+ * entries we add
+ * @since 3.1-A1
+ */
+ $vars = array('mode', 'sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_add_zebra', compact($vars)));
+
$db->sql_multi_insert(ZEBRA_TABLE, $sql_ary);
$updated = true;
diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php
index fcbfaaddfa..93557f3558 100644
--- a/phpBB/includes/user.php
+++ b/phpBB/includes/user.php
@@ -76,18 +76,18 @@ class phpbb_user extends phpbb_session
function setup($lang_set = false, $style_id = false)
{
global $db, $phpbb_style, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
+ global $phpbb_dispatcher;
if ($this->data['user_id'] != ANONYMOUS)
{
- $this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']);
-
- $this->date_format = $this->data['user_dateformat'];
+ $user_lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']);
+ $user_date_format = $this->data['user_dateformat'];
$user_timezone = $this->data['user_timezone'];
}
else
{
- $this->lang_name = basename($config['default_lang']);
- $this->date_format = $config['default_dateformat'];
+ $user_lang_name = basename($config['default_lang']);
+ $user_date_format = $config['default_dateformat'];
$user_timezone = $config['board_timezone'];
/**
@@ -107,7 +107,7 @@ class phpbb_user extends phpbb_session
if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx"))
{
- $this->lang_name = $config['default_lang'] = $accept_lang;
+ $user_lang_name = $config['default_lang'] = $accept_lang;
break;
}
else
@@ -118,7 +118,7 @@ class phpbb_user extends phpbb_session
if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx"))
{
- $this->lang_name = $config['default_lang'] = $accept_lang;
+ $user_lang_name = $config['default_lang'] = $accept_lang;
break;
}
}
@@ -127,6 +127,28 @@ class phpbb_user extends phpbb_session
*/
}
+ $user_data = $this->data;
+
+ /**
+ * Event to load language files and modify user data on every page
+ *
+ * @event core.user_setup
+ * @var array user_data Array with user's data row
+ * @var string user_lang_name Basename of the user's langauge
+ * @var string user_date_format User's date/time format
+ * @var string user_timezone User's timezone, should be one of
+ * http://www.php.net/manual/en/timezones.php
+ * @var mixed lang_set String or array of language files
+ * @var mixed style_id Style we are going to display
+ * @since 3.1-A1
+ */
+ $vars = array('user_data', 'user_lang_name', 'user_date_format', 'user_timezone', 'lang_set', 'style_id');
+ extract($phpbb_dispatcher->trigger_event('core.user_setup', compact($vars)));
+
+ $this->data = $user_data;
+ $this->lang_name = $user_lang_name;
+ $this->date_format = $user_date_format;
+
try
{
$this->timezone = new DateTimeZone($user_timezone);
diff --git a/phpBB/index.php b/phpBB/index.php
index c13f3c06ab..0ac8034d7f 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -171,8 +171,20 @@ $template->assign_vars(array(
'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '')
);
+$page_title = $user->lang['INDEX'];
+
+/**
+* You can use this event to modify the page title and load data for the index
+*
+* @event core.index_modify_page_title
+* @var string page_title Title of the index page
+* @since 3.1-A1
+*/
+$vars = array('page_title');
+extract($phpbb_dispatcher->trigger_event('core.index_modify_page_title', compact($vars)));
+
// Output page
-page_header($user->lang['INDEX']);
+page_header($page_title);
$template->set_filenames(array(
'body' => 'index_body.html')
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index 4f9a8cdff3..f142d182bc 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -575,6 +575,26 @@ switch ($mode)
unset($module);
}
+ /**
+ * Modify user data before we display the profile
+ *
+ * @event core.memberlist_view_profile
+ * @var array member Title of the index page
+ * @var bool user_notes_enabled Is the mcp user notes module
+ * enabled?
+ * @var bool warn_user_enabled Is the mcp warnings module
+ * enabled?
+ * @var bool zebra_enabled Is the ucp zebra module
+ * enabled?
+ * @var bool friends_enabled Is the ucp friends module
+ * enabled?
+ * @var bool foes_enabled Is the ucp foes module
+ * enabled?
+ * @since 3.1-A1
+ */
+ $vars = array('member', 'user_notes_enabled', 'warn_user_enabled', 'zebra_enabled', 'friends_enabled', 'foes_enabled');
+ extract($phpbb_dispatcher->trigger_event('core.memberlist_view_profile', compact($vars)));
+
$template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled));
// Custom Profile Fields
@@ -1631,7 +1651,7 @@ page_footer();
*/
function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false)
{
- global $config, $auth, $template, $user, $phpEx, $phpbb_root_path;
+ global $config, $auth, $template, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher;
$username = $data['username'];
$user_id = $data['user_id'];
@@ -1693,7 +1713,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
}
// Dump it out to the template
- return array(
+ $template_data = array(
'AGE' => $age,
'RANK_TITLE' => $rank_title,
'JOINED' => $user->format_date($data['user_regdate']),
@@ -1741,6 +1761,19 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
'L_VIEWING_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $username),
);
+
+ /**
+ * Preparing a user's data before displaying it in profile and memberlist
+ *
+ * @event core.memberlist_prepare_profile_data
+ * @var array data Array with user's data
+ * @var array template_data Template array with user's data
+ * @since 3.1-A1
+ */
+ $vars = array('data', 'template_data');
+ extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars)));
+
+ return $template_data;
}
function _sort_last_active($first, $second)
diff --git a/phpBB/ucp.php b/phpBB/ucp.php
index 64afa0be67..9730591698 100644
--- a/phpBB/ucp.php
+++ b/phpBB/ucp.php
@@ -328,6 +328,18 @@ if (!$auth->acl_get('u_sig'))
$module->set_display('profile', 'signature', false);
}
+/**
+* Use this event to enable and disable additional UCP modules
+*
+* @event core.ucp_display_module_before
+* @var p_master module Object holding all modules and their status
+* @var mixed id Active module category (can be the int or string)
+* @var string mode Active module
+* @since 3.1-A1
+*/
+$vars = array('module', 'id', 'mode');
+extract($phpbb_dispatcher->trigger_event('core.ucp_display_module_before', compact($vars)));
+
// Select the active module
$module->set_active($id, $mode);
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index f4781a09ff..783c7181d2 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -690,7 +690,7 @@ if (sizeof($topic_list))
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&amp;t=$topic_id", true, $user->session_id) : '';
// Send vars to template
- $template->assign_block_vars('topicrow', array(
+ $topic_row = array(
'FORUM_ID' => $row['forum_id'],
'TOPIC_ID' => $topic_id,
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
@@ -742,11 +742,24 @@ if (sizeof($topic_list))
'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports&amp;f=' . $row['forum_id'] . '&amp;t=' . $topic_id, true, $user->session_id),
'U_MCP_QUEUE' => $u_mcp_queue,
- 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test)
+ 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test,
);
+ /**
+ * Modify the topic data before it is assigned to the template
+ *
+ * @event core.viewforum_modify_topicrow
+ * @var array row Array with topic data
+ * @var array topic_row Template array with topic data
+ * @since 3.1-A1
+ */
+ $vars = array('row', 'topic_row');
+ extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topicrow', compact($vars)));
+
+ $template->assign_block_vars('topicrow', $topic_row);
+
phpbb_generate_template_pagination($template, $view_topic_url, 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);
-
+
$s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
if ($unread_topic)
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php
index 48362a9d67..15884a41d8 100644
--- a/phpBB/viewonline.php
+++ b/phpBB/viewonline.php
@@ -121,13 +121,30 @@ if (!$show_guests)
}
// Get user list
-$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_browser, s.session_viewonline, s.session_forum_id
- FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . ' s
- WHERE u.user_id = s.session_user_id
+$sql_ary = array(
+ 'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_browser, s.session_viewonline, s.session_forum_id',
+ 'FROM' => array(
+ USERS_TABLE => 'u',
+ SESSIONS_TABLE => 's',
+ ),
+ 'WHERE' => 'u.user_id = s.session_user_id
AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) .
- ((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : '') . '
- ORDER BY ' . $order_by;
-$result = $db->sql_query($sql);
+ ((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : ''),
+ 'ORDER_BY' => $order_by,
+);
+
+/**
+* Modify the SQL query for getting the user data to display viewonline list
+*
+* @event core.viewonline_modify_sql
+* @var array sql_ary The SQL array
+* @var bool show_guests Do we display guests in the list
+* @since 3.1-A1
+*/
+$vars = array('sql_ary', 'show_guests');
+extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_sql', compact($vars)));
+
+$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
$prev_id = $prev_ip = $user_list = array();
$logged_visible_online = $logged_hidden_online = $counter = 0;
@@ -320,6 +337,19 @@ while ($row = $db->sql_fetchrow($result))
break;
}
+ /**
+ * Overwrite the location's name and URL, which are displayed in the list
+ *
+ * @event core.viewonline_overwrite_location
+ * @var array on_page File name and query string
+ * @var array row Array with the users sql row
+ * @var string location Page name to displayed in the list
+ * @var string location_url Page url to displayed in the list
+ * @since 3.1-A1
+ */
+ $vars = array('on_page', 'row', 'location', 'location_url');
+ extract($phpbb_dispatcher->trigger_event('core.viewonline_overwrite_location', compact($vars)));
+
$template->assign_block_vars('user_row', array(
'USERNAME' => $row['username'],
'USERNAME_COLOUR' => $row['user_colour'],
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index b6df14d42d..3dd7d8a863 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -987,6 +987,16 @@ $sql_ary = array(
AND u.user_id = p.poster_id',
);
+/**
+* Event to modify the SQL query before the post and poster data is retrieved
+*
+* @event core.viewtopic_get_post_data
+* @var array sql_ary The SQL array to get the data of posts and posters
+* @since 3.1-A1
+*/
+$vars = array('sql_ary');
+extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_post_data', compact($vars)));
+
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);
@@ -1063,7 +1073,7 @@ while ($row = $db->sql_fetchrow($result))
{
if ($poster_id == ANONYMOUS)
{
- $user_cache[$poster_id] = array(
+ $user_cache_data = array(
'joined' => '',
'posts' => '',
'from' => '',
@@ -1098,6 +1108,20 @@ while ($row = $db->sql_fetchrow($result))
'allow_pm' => 0,
);
+ /**
+ * Modify the guest user's data displayed with the posts
+ *
+ * @event core.viewtopic_cache_guest_data
+ * @var array user_cache_data Array with the user's data
+ * @var int poster_id Poster's user id
+ * @var array row Array with original user and post data
+ * @since 3.1-A1
+ */
+ $vars = array('user_cache_data', 'poster_id', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_guest_data', compact($vars)));
+
+ $user_cache[$poster_id] = $user_cache_data;
+
get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
}
else
@@ -1112,7 +1136,7 @@ while ($row = $db->sql_fetchrow($result))
$id_cache[] = $poster_id;
- $user_cache[$poster_id] = array(
+ $user_cache_data = array(
'joined' => $user->format_date($row['user_regdate']),
'posts' => $row['user_posts'],
'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0,
@@ -1150,6 +1174,20 @@ while ($row = $db->sql_fetchrow($result))
'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']),
);
+ /**
+ * Modify the users' data displayed with their posts
+ *
+ * @event core.viewtopic_cache_user_data
+ * @var array user_cache_data Array with the user's data
+ * @var int poster_id Poster's user id
+ * @var array row Array with original user and post data
+ * @since 3.1-A1
+ */
+ $vars = array('user_cache_data', 'poster_id', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_user_data', compact($vars)));
+
+ $user_cache[$poster_id] = $user_cache_data;
+
get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
@@ -1493,7 +1531,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
)));
//
- $postrow = array(
+ $post_row = array(
'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR_COLOUR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_username'] : get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
@@ -1569,13 +1607,28 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}" . '">', '</a>') : '',
);
+ $user_poster_data = $user_cache[$poster_id];
+
+ /**
+ * Modify the posts template block
+ *
+ * @event core.viewtopic_modify_post_row
+ * @var array row Array with original post and user data
+ * @var array cp_row Custom profile field data of the poster
+ * @var array user_poster_data Poster's data from user cache
+ * @var array post_row Template block array of the post
+ * @since 3.1-A1
+ */
+ $vars = array('row', 'cp_row', 'user_poster_data', 'post_row');
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars)));
+
if (isset($cp_row['row']) && sizeof($cp_row['row']))
{
- $postrow = array_merge($postrow, $cp_row['row']);
+ $post_row = array_merge($post_row, $cp_row['row']);
}
// Dump vars into template
- $template->assign_block_vars('postrow', $postrow);
+ $template->assign_block_vars('postrow', $post_row);
if (!empty($cp_row['blockrow']))
{
@@ -1729,8 +1782,23 @@ if (!request_var('t', 0) && !empty($topic_id))
$request->overwrite('t', $topic_id);
}
+$page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : '');
+
+/**
+* You can use this event to modify the page title of the viewtopic page
+*
+* @event core.viewtopic_modify_page_title
+* @var string page_title Title of the index page
+* @var array topic_data Array with topic data
+* @var int forum_id Forum ID of the topic
+* @var int start Start offset used to calculate the page
+* @since 3.1-A1
+*/
+$vars = array('page_title', 'topic_data', 'forum_id', 'start');
+extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars)));
+
// Output the page
-page_header($topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : ''), true, $forum_id);
+page_header($page_title, true, $forum_id);
$template->set_filenames(array(
'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html')