From 3c20ac71c51c9e8033884f5694fbad2fa6040ca6 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 4 Mar 2011 02:00:54 -0500 Subject: [PATCH 001/140] [feature/events] Started on hooks for advanced last topic titles mod. PHPBB3-9550 --- phpBB/includes/functions_display.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 00efd281c0..b23540bcbd 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -119,6 +119,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'ORDER_BY' => 'f.left_id', ); + run_hooks('display_forums_sql_inject', &$sql_ary); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); @@ -127,6 +129,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod while ($row = $db->sql_fetchrow($result)) { + run_hooks('display_forums_row_inject', &$row); + $forum_id = $row['forum_id']; // Mark forums read? @@ -223,6 +227,9 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id']; $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; + + $data = array(&$forum_rows, &$parent_id, &$row); + run_hooks('display_forums_row_values_inject', &$data); } else if ($row['forum_type'] != FORUM_CAT) { @@ -482,6 +489,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod '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) ); + + run_hooks('display_forums_assign_block_vars', &$row); // Assign subforums loop for style authors foreach ($subforums_list as $subforum) From 4da001625df4cc13d71e0ae6a61d573207165a7f Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 3 Feb 2012 02:22:29 -0500 Subject: [PATCH 002/140] [feature/events] Replace run_hooks calls with event dispatcher. PHPBB3-9550 --- phpBB/includes/functions_display.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index b23540bcbd..b320d35e09 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,7 +119,10 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'ORDER_BY' => 'f.left_id', ); - run_hooks('display_forums_sql_inject', &$sql_ary); + $vars = array('sql_ary'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.display_forums_sql_inject', $event); + extract($event->get_data_filtered($vars)); $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); @@ -129,7 +132,10 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod while ($row = $db->sql_fetchrow($result)) { - run_hooks('display_forums_row_inject', &$row); + $vars = array('row'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.display_forums_row_inject', $event); + extract($event->get_data_filtered($vars)); $forum_id = $row['forum_id']; @@ -227,9 +233,11 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id']; $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; - - $data = array(&$forum_rows, &$parent_id, &$row); - run_hooks('display_forums_row_values_inject', &$data); + + $vars = array('forum_rows', 'parent_id', 'row'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.display_forums_row_values_inject', $event); + extract($event->get_data_filtered($vars)); } else if ($row['forum_type'] != FORUM_CAT) { @@ -489,8 +497,11 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod '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) ); - - run_hooks('display_forums_assign_block_vars', &$row); + + $vars = array('row'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.display_forums_assign_block_vars', $event); + extract($event->get_data_filtered($vars)); // Assign subforums loop for style authors foreach ($subforums_list as $subforum) From 9877ab1ff36dd66ccc517ffeb00832ff12ee7995 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 4 Feb 2012 07:12:00 -0500 Subject: [PATCH 003/140] [feature/events] Add core.memberlist_profile_data ledge. This is needed by the avatars on memberlist modification. PHPBB3-9550 --- phpBB/memberlist.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 4f9a8cdff3..0845eb23f6 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1693,7 +1693,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f } // Dump it out to the template - return array( + $data = array( 'AGE' => $age, 'RANK_TITLE' => $rank_title, 'JOINED' => $user->format_date($data['user_regdate']), @@ -1741,6 +1741,13 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f 'L_VIEWING_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $username), ); + + $vars = array('data'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.memberlist_profile_data', $event); + extract($event->get_data_filtered($vars)); + + return $data; } function _sort_last_active($first, $second) From eda9bcc65de97b9ffb2c432756907ff0411b281f Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 15 Mar 2012 15:14:01 +0000 Subject: [PATCH 004/140] [feature/events] Add core.common_template_vars ledge Needed by board3portal PHPBB3-9550 --- phpBB/includes/functions.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e5b721b1f5..a16e8d6eeb 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4909,7 +4909,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 } // The following assigns all _common_ variables that may be used at any point in a template. - $template->assign_vars(array( + $template_vars = array( 'SITENAME' => $config['sitename'], 'SITE_DESCRIPTION' => $config['site_desc'], 'PAGE_TITLE' => $page_title, @@ -5031,7 +5031,15 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'SITE_LOGO_IMG' => $user->img('site_logo'), '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('template_vars'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.common_template_vars', $event); + extract($event->get_data_filtered($vars)); + + $template->assign_vars($template_vars); + $vars = array('page_title', 'display_online_list', 'item_id', 'item'); extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars))); From 77845c147818b4199005363a3168bbb44dc46641 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 20:55:17 +0100 Subject: [PATCH 005/140] [feature/events] Adding ledge user_update_name Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_user.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 6e658b4ef4..b50dcac49c 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,11 @@ function user_update_name($old_name, $new_name) set_config('newest_username', $new_name, true); } + $vars = array('old_name', 'new_name'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.user_update_name', $event); + extract($event->get_data_filtered($vars)); + // Because some tables/caches use username-specific data we need to purge this here. $cache->destroy('sql', MODERATOR_CACHE_TABLE); } From 5b226c400280588349eb3a4cab9780ae98d20c0f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 20:58:22 +0100 Subject: [PATCH 006/140] [feature/events] Adding ledges user_delete Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_user.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index b50dcac49c..32529ec308 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -336,7 +336,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 * @@ -540,6 +540,11 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); + $vars = array('mode', 'user_id', 'post_username'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.user_delete', $event); + extract($event->get_data_filtered($vars)); + // Reset newest user info if appropriate if ($config['newest_user_id'] == $user_id) { From ae49d6dca2fd17b2b4735c2026871d1a9250b4ad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 20:59:15 +0100 Subject: [PATCH 007/140] [feature/events] Adding ledge group_delete Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_user.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 32529ec308..0e751ba890 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2769,7 +2769,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 +2818,11 @@ function group_delete($group_id, $group_name = false) $teampage->delete_group($group_id); unset($teampage); + $vars = array('group_id', 'group_name'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.group_delete', $event); + extract($event->get_data_filtered($vars)); + // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; From d4ace75370febea0f9a18ed2f744bee8caecedb2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 21:00:20 +0100 Subject: [PATCH 008/140] [feature/events] Adding ledge group_user_del Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_user.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 0e751ba890..a32f14e48f 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2955,7 +2955,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']) { @@ -3054,6 +3054,11 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, } unset($special_group_data); + $vars = array('group_id', 'user_id_ary', 'username_ary', 'group_name'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.group_user_del', $event); + extract($event->get_data_filtered($vars)); + $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " WHERE group_id = $group_id AND " . $db->sql_in_set('user_id', $user_id_ary); From 4d87b2254c7762db129b2706b372538451279d13 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 21:01:49 +0100 Subject: [PATCH 009/140] [feature/events] Adding ledge group_set_user_default Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_user.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index a32f14e48f..82400de932 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3376,7 +3376,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)) { @@ -3472,6 +3472,11 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } } + $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.group_set_user_default', $event); + extract($event->get_data_filtered($vars)); + if ($update_listing) { group_update_listings($group_id); From bd3024b31875b220f8f00cafd81846b1f6aeeff2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 00:05:18 +0100 Subject: [PATCH 010/140] [feature/events] Adding ledge viewonline_location Used by phpBB Gallery PHPBB3-9550 --- phpBB/viewonline.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index 48362a9d67..e709955653 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -317,6 +317,11 @@ while ($row = $db->sql_fetchrow($result)) default: $location = $user->lang['INDEX']; $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); + + $vars = array('on_page', 'row', 'location', 'location_url'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.viewonline_location', $event); + extract($event->get_data_filtered($vars)); break; } From 433442b40261d7d18427b6cd21fbf9acb15edd93 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 00:14:20 +0100 Subject: [PATCH 011/140] [feature/events] Adding ledge viewonline_get_userdata Used by phpBB Gallery PHPBB3-9550 --- phpBB/viewonline.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index e709955653..55d663de20 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -121,13 +121,24 @@ 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, +); + +$vars = array('sql_ary', 'show_guests'); +$event = new phpbb_event_data(compact($vars)); +$phpbb_dispatcher->dispatch('core.viewonline_get_userdata', $event); +extract($event->get_data_filtered($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; From 60b21863cada022b9fdcda17de82aa484c4ac571 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 00:38:45 +0100 Subject: [PATCH 012/140] [feature/events] Adding ledge index Used by phpBB Gallery and various others PHPBB3-9550 --- phpBB/index.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/index.php b/phpBB/index.php index a477a876ad..87b0adeafd 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -171,8 +171,15 @@ $template->assign_vars(array( 'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '') ); +$page_title = $user->lang['INDEX']; + +$vars = array('page_title'); +$event = new phpbb_event_data(compact($vars)); +$phpbb_dispatcher->dispatch('core.index', $event); +extract($event->get_data_filtered($vars)); + // Output page -page_header($user->lang['INDEX']); +page_header($page_title); $template->set_filenames(array( 'body' => 'index_body.html') From 34a85639422214af23c6e56d175e5634c24db798 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 00:43:52 +0100 Subject: [PATCH 013/140] [feature/events] Adding ledge ucp_modules Used by phpBB Gallery PHPBB3-9550 --- phpBB/ucp.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 64afa0be67..2b129f3ec7 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -328,6 +328,11 @@ if (!$auth->acl_get('u_sig')) $module->set_display('profile', 'signature', false); } +$vars = array('module'); +$event = new phpbb_event_data(compact($vars)); +$phpbb_dispatcher->dispatch('core.ucp_modules', $event); +extract($event->get_data_filtered($vars)); + // Select the active module $module->set_active($id, $mode); From ca8de4129cbedf8eff2d97350300f59b4bf47230 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 00:49:38 +0100 Subject: [PATCH 014/140] [feature/events] Adding ledge memberlist_viewprofile Used by phpBB Gallery Note: this one is NOT obsoleted by the ledge in show_profile() PHPBB3-9550 --- phpBB/memberlist.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 0845eb23f6..108195dad8 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -575,6 +575,11 @@ switch ($mode) unset($module); } + $vars = array('member', 'user_notes_enabled', 'warn_user_enabled'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.memberlist_viewprofile', $event); + extract($event->get_data_filtered($vars)); + $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled)); // Custom Profile Fields From 57c417157761cea7e4c0cdece0bdf9068f25dbbe Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 15 Mar 2012 20:47:59 +0000 Subject: [PATCH 015/140] [feature/events] Add core.viewforum_forumrow PHPBB3-9550 --- phpBB/viewforum.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 18d247f0b6..2d5b7e0758 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&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : ''; // Send vars to template - $template->assign_block_vars('topicrow', array( + $forumrow = 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,18 @@ if (sizeof($topic_list)) 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $row['forum_id'] . '&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 ); + $vars = array('forumrow'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.viewforum_forumrow', $event); + extract($event->get_data_filtered($vars)); + + $template->assign_block_vars('topicrow', $forumrow); + 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) From 6c50f6610f66b865e6fa6ee82235c3ff373fdfd3 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 16 Mar 2012 00:02:35 +0000 Subject: [PATCH 016/140] [feature/events] Fix core.viewforum_topicrow ledge PHPBB3-9550 --- phpBB/viewforum.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 2d5b7e0758..dac4230ce0 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&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : ''; // Send vars to template - $forumrow = array( + $topicrow = 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,15 +742,15 @@ if (sizeof($topic_list)) 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $row['forum_id'] . '&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, ); - $vars = array('forumrow'); + $vars = array('topicrow'); $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.viewforum_forumrow', $event); + $phpbb_dispatcher->dispatch('core.viewforum_topicrow', $event); extract($event->get_data_filtered($vars)); - $template->assign_block_vars('topicrow', $forumrow); + $template->assign_block_vars('topicrow', $topicrow); phpbb_generate_template_pagination($template, $view_topic_url, 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); From 54caef8f902cf5ea40da0d818b770d15b6d7e7e2 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 15 Mar 2012 20:49:33 +0000 Subject: [PATCH 017/140] [feature/events] Add core.viewtopic_postrow ledge PHPBB3-9550 --- phpBB/viewtopic.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 349f53cbe2..4f95d40e73 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1574,6 +1574,11 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) $postrow = array_merge($postrow, $cp_row['row']); } + $vars = array('postrow'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.viewtopic_postrow', $event); + extract($event->get_data_filtered($vars)); + // Dump vars into template $template->assign_block_vars('postrow', $postrow); From eb7a04d32427d2070befdd10fcec657222bc8fa8 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 15 Mar 2012 21:06:44 +0000 Subject: [PATCH 018/140] [feature/events] Add core.acp_foruns_add_forum_data ledge PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 3a3b2021eb..f4d0a93b8d 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -220,6 +220,11 @@ class acp_forums } trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); + + $vars = array('forum_data'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.acp_forums_add_forum_data', $event); + extract($event->get_data_filtered($vars)); } break; From 19a3164e80e9e34cab13d25f205789d7eb27aa66 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 15 Mar 2012 23:59:40 +0000 Subject: [PATCH 019/140] [feature/events] Fixing core.acp_forums_add_forum_data PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index f4d0a93b8d..11843384ed 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -107,6 +107,11 @@ class acp_forums 'forum_id' => $forum_id ); + $vars = array('forum_data'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.acp_forums_add_forum_data', $event); + extract($event->get_data_filtered($vars)); + // No break here case 'add': @@ -220,11 +225,6 @@ class acp_forums } trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - - $vars = array('forum_data'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.acp_forums_add_forum_data', $event); - extract($event->get_data_filtered($vars)); } break; From 365a71d63f01d6a8d65b5eafcd4d5fa2fb7ab0ac Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 16 Mar 2012 02:12:29 -0400 Subject: [PATCH 020/140] [feature/events] Add missing dispatcher globalization. PHPBB3-9550 --- phpBB/memberlist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 108195dad8..81369a9b57 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1636,7 +1636,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']; From 5c0decf4cf7d6f73ffa686e8861aa3c444f51124 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 16 Mar 2012 12:34:26 +0000 Subject: [PATCH 021/140] [feature/events] Adding core.acp_users_overview ledge PHPBB3-9550 --- phpBB/includes/acp/acp_users.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 79c91dd7ee..68077b4048 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1039,6 +1039,11 @@ class acp_users 'USER_INACTIVE_REASON' => $inactive_reason, )); + $vars = array('data', 'check_ary', 'sql_ary', 'user_row', 'quick_tool_ary'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.acp_users_overview', $event); + extract($event->get_data_filtered($vars)); + break; case 'feedback': From 74d3555c4c510a76c947bd7c445f254e5b9b104e Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 16 Mar 2012 13:09:33 +0000 Subject: [PATCH 022/140] [feature/events] Adding core.acp_modules_modules ledge PHPBB3-9550 --- phpBB/includes/acp/info/acp_modules.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/acp/info/acp_modules.php b/phpBB/includes/acp/info/acp_modules.php index c9d2cffa72..fc04eec698 100644 --- a/phpBB/includes/acp/info/acp_modules.php +++ b/phpBB/includes/acp/info/acp_modules.php @@ -14,16 +14,27 @@ class acp_modules_info { function module() { - return array( - 'filename' => 'acp_modules', - 'title' => 'ACP_MODULE_MANAGEMENT', - 'version' => '1.0.0', - 'modes' => array( + global $phpbb_dispatcher; + + $modules = array( 'acp' => array('title' => 'ACP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), 'ucp' => array('title' => 'UCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), 'mcp' => array('title' => 'MCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), - ), + ), + + $vars = array('modules'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.acp_modules_modules', $event); + extract($event->get_data_filtered($vars)); + + $data = array( + 'filename' => 'acp_modules', + 'title' => 'ACP_MODULE_MANAGEMENT', + 'version' => '1.0.0', + 'modes' => $modules ); + + return $data } function install() From f362d374cc8e421951d25de038708b06b5b4695d Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 16 Mar 2012 13:33:02 +0000 Subject: [PATCH 023/140] [feature/events] Adding core.acp_profile_edit ledge PHPBB3-9550 --- phpBB/includes/acp/acp_profile.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 3ffffd3047..6704fce26f 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -876,6 +876,11 @@ class acp_profile } } + $vars = array('field_row', 'visibility_ary', 'exclude'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.acp_profile_edit', $event); + extract($event->get_data_filtered($vars)); + break; } From 3339935db316859b38a820b7cf3ebff204b72d7f Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 16 Mar 2012 14:58:29 +0000 Subject: [PATCH 024/140] [feature/events] Adding core.common ledge PHPBB3-9550 --- phpBB/common.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/common.php b/phpBB/common.php index 81fe275008..9cf2617b07 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -143,3 +143,5 @@ if (!$config['use_system_cron']) { $cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver()); } + +$phpbb_dispatcher->dispatch('core.common'); From a47ac64e5f5ad1c01e6ecbb64a5e1c80ab2c90b2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 10:30:28 +0100 Subject: [PATCH 025/140] [feature/events] Adding ledge viewtopic_page_header Used by phpBB Gallery PHPBB3-9550 --- phpBB/viewtopic.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 4f95d40e73..148446490e 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1734,8 +1734,15 @@ 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) : ''); + +$vars = array('page_title', 'topic_data', 'forum_id', 'start'); +$event = new phpbb_event_data(compact($vars)); +$phpbb_dispatcher->dispatch('core.viewtopic_page_header', $event); +extract($event->get_data_filtered($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') From dcf97714a56801bcaf41addeadb08bcacc4514df Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 10:38:29 +0100 Subject: [PATCH 026/140] [feature/events] Adding ledge viewtopic_get_userdata Used by phpBB Gallery PHPBB3-9550 --- phpBB/viewtopic.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 148446490e..8bca1973a7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -987,6 +987,11 @@ $sql_ary = array( AND u.user_id = p.poster_id', ); +$vars = array('sql_ary'); +$event = new phpbb_event_data(compact($vars)); +$phpbb_dispatcher->dispatch('core.viewtopic_get_userdata', $event); +extract($event->get_data_filtered($vars)); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); From 2581b0e1e3c68bfae8357dddc1d379914fd67654 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 10:42:40 +0100 Subject: [PATCH 027/140] [feature/events] Adding ledge viewtopic_user_cache_guest Used by phpBB Gallery PHPBB3-9550 --- phpBB/viewtopic.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 8bca1973a7..256bada0d9 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1068,7 +1068,7 @@ while ($row = $db->sql_fetchrow($result)) { if ($poster_id == ANONYMOUS) { - $user_cache[$poster_id] = array( + $user_cache_data = array( 'joined' => '', 'posts' => '', 'from' => '', @@ -1103,6 +1103,13 @@ while ($row = $db->sql_fetchrow($result)) 'allow_pm' => 0, ); + $vars = array('user_cache_data', 'row', 'poster_id'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.viewtopic_user_cache_guest', $event); + extract($event->get_data_filtered($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 From 713f8e4782cd4c808d6f4a1cbb26f45144eef74e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 10:51:35 +0100 Subject: [PATCH 028/140] [feature/events] Adding ledge viewtopic_user_cache Used by phpBB Gallery PHPBB3-9550 --- phpBB/viewtopic.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 256bada0d9..99b875ae3d 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1124,7 +1124,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, @@ -1162,6 +1162,13 @@ while ($row = $db->sql_fetchrow($result)) 'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']), ); + $vars = array('user_cache_data', 'row', 'poster_id'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.viewtopic_user_cache', $event); + extract($event->get_data_filtered($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')) From ddcd1890065258ca5a5d443b8790a9d2287891ad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 11:03:03 +0100 Subject: [PATCH 029/140] [feature/events] Adding ledge generate_smilies_footer Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_posting.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 6c21b0f412..d3550aafba 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); @@ -131,6 +131,11 @@ function generate_smilies($mode, $forum_id) ); } + $vars = array('mode', 'forum_id', 'display_link'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.generate_smilies_footer', $event); + extract($event->get_data_filtered($vars)); + if ($mode == 'window') { page_footer(); From 69407cae7bc50af526db86a3be3718d68f57d2bc Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 11:21:12 +0100 Subject: [PATCH 030/140] [feature/events] Adding ledge display_custom_bbcodes_row Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_display.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index b320d35e09..604197b2eb 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -850,7 +850,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; @@ -870,13 +870,20 @@ 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('&', '"', "'", '<', '>'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']), - )); + ); + + $vars = array('custom_tags', 'row'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.display_custom_bbcodes_row', $event); + extract($event->get_data_filtered($vars)); + + $template->assign_block_vars('custom_tags', $custom_tags); $i++; } From 1a7f83948eb9f4c1b8ab7fa411444a11e967fcd0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 11:22:31 +0100 Subject: [PATCH 031/140] [feature/events] Adding ledge display_custom_bbcodes Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_display.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 604197b2eb..684729fc0d 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -888,6 +888,8 @@ function display_custom_bbcodes() $i++; } $db->sql_freeresult($result); + + $phpbb_dispatcher->dispatch('core.display_custom_bbcodes'); } /** From 8d4c7d2e80a17b2ec5134e4dbe7fea5bfe57d02f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 11:29:49 +0100 Subject: [PATCH 032/140] [feature/events] Adding ledge ucp_pm_viewmesssage Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index c55e8850a6..caaecfb741 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')); @@ -268,6 +268,11 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&mode=compose&action=forward&f=$folder_id&p=" . $message_row['msg_id'] : '') ); + $vars = array('id', 'mode', 'folder_id', 'msg_id', 'folder', 'message_row', 'cp_row'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.ucp_pm_viewmesssage', $event); + extract($event->get_data_filtered($vars)); + // Display the custom profile fields if (!empty($cp_row['row'])) { From 02244397d1ecb149322c0c7847718e14742c14a2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 11:37:46 +0100 Subject: [PATCH 033/140] [feature/events] Adding ledge ucp_zebra_remove Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/ucp/ucp_zebra.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index efe928b387..fd4f4ccaf4 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,6 +54,11 @@ class ucp_zebra // Remove users if (!empty($data['usernames'])) { + $vars = array('data'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.ucp_zebra_remove', $event); + extract($event->get_data_filtered($vars)); + $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' AND ' . $db->sql_in_set('zebra_id', $data['usernames']); From 4b4e2afd800d34b2f92f709f9199c38334f43b29 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 11:40:01 +0100 Subject: [PATCH 034/140] [feature/events] Adding ledge ucp_zebra_add Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/ucp/ucp_zebra.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index fd4f4ccaf4..f8012fdcdf 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -191,6 +191,11 @@ class ucp_zebra ); } + $vars = array('mode', 'sql_ary'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.ucp_zebra_add', $event); + extract($event->get_data_filtered($vars)); + $db->sql_multi_insert(ZEBRA_TABLE, $sql_ary); $updated = true; From 1aa7bc81f6200389499080fa3863f6708d94dc70 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2012 11:47:27 +0100 Subject: [PATCH 035/140] [feature/events] Remove unnecessary ledge common_template_vars core.page_header is more powerful and includes all functionality of this one. PHPBB3-9550 --- phpBB/includes/functions.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index a16e8d6eeb..de0cb8766b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4909,7 +4909,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 } // The following assigns all _common_ variables that may be used at any point in a template. - $template_vars = array( + $template->assign_vars(array( 'SITENAME' => $config['sitename'], 'SITE_DESCRIPTION' => $config['site_desc'], 'PAGE_TITLE' => $page_title, @@ -5031,14 +5031,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'SITE_LOGO_IMG' => $user->img('site_logo'), '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('template_vars'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.common_template_vars', $event); - extract($event->get_data_filtered($vars)); - - $template->assign_vars($template_vars); + )); $vars = array('page_title', 'display_online_list', 'item_id', 'item'); From e17d0daf518f2f4bb22146c195a342858faf1fce Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 16 Mar 2012 18:58:46 +0000 Subject: [PATCH 036/140] [feature/events] Adding core.mcp_check_ids ledge PHPBB3-9550 --- phpBB/mcp.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/mcp.php b/phpBB/mcp.php index d04a297cf9..b5cfa99d4c 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -823,7 +823,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, */ function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = false) { - global $db, $auth; + global $db, $auth, $phpbb_dispatcher; if (!is_array($ids) || empty($ids)) { @@ -889,5 +889,7 @@ function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = fa // If forum id is false and ids populated we may have only global announcements selected (returning 0 because of (int) $forum_id) + $phpbb_dispatcher->dispatch('core.mcp_check_ids'); + return ($single_forum === false) ? true : (int) $forum_id; } From 643081d56c1a984e3b0cf4f942392c5a392c9ed6 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 16 Mar 2012 19:03:52 +0000 Subject: [PATCH 037/140] [feature/events] Adding core.mcp_forum_topicrow ledge PHPBB3-9550 --- phpBB/includes/mcp/mcp_forum.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 4518e7b7cf..d40b8b5279 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -288,6 +288,11 @@ function mcp_forum_view($id, $mode, $action, $forum_info) )); } + $vars = array('topic_row', 'row'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.mcp_forum_topicrow', $event); + extract($event->get_data_filtered($vars)); + $template->assign_block_vars('topicrow', $topic_row); } unset($topic_rows); From b966551e6bef9dfd272734587fe4bc9ca7e4611c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 17 Mar 2012 00:46:43 +0100 Subject: [PATCH 038/140] [feature/events] Fix ledges in ACP and apply coding guidelines PHPBB3-9550 --- phpBB/includes/acp/acp_profile.php | 2 +- phpBB/includes/acp/acp_users.php | 2 +- phpBB/includes/acp/info/acp_modules.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 6704fce26f..43426e86a7 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -27,7 +27,7 @@ class acp_profile function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template, $cache, $phpbb_dispatcher; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; global $request; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 68077b4048..f6c2ecfc87 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -30,7 +30,7 @@ class acp_users function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template, $cache, $phpbb_dispatcher; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; $user->add_lang(array('posting', 'ucp', 'acp/users')); diff --git a/phpBB/includes/acp/info/acp_modules.php b/phpBB/includes/acp/info/acp_modules.php index fc04eec698..97616af22d 100644 --- a/phpBB/includes/acp/info/acp_modules.php +++ b/phpBB/includes/acp/info/acp_modules.php @@ -17,9 +17,9 @@ class acp_modules_info global $phpbb_dispatcher; $modules = array( - 'acp' => array('title' => 'ACP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), - 'ucp' => array('title' => 'UCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), - 'mcp' => array('title' => 'MCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), + 'acp' => array('title' => 'ACP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), + 'ucp' => array('title' => 'UCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), + 'mcp' => array('title' => 'MCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), ), $vars = array('modules'); @@ -31,7 +31,7 @@ class acp_modules_info 'filename' => 'acp_modules', 'title' => 'ACP_MODULE_MANAGEMENT', 'version' => '1.0.0', - 'modes' => $modules + 'modes' => $modules, ); return $data From ba63df2dce9da69caa31f1f4404b3b79a7f4f75e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 17 Mar 2012 11:45:09 +0100 Subject: [PATCH 039/140] [feature/events] Fix info/acp_modules.php completly PHPBB3-9550 --- phpBB/includes/acp/info/acp_modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/info/acp_modules.php b/phpBB/includes/acp/info/acp_modules.php index 97616af22d..39091875d1 100644 --- a/phpBB/includes/acp/info/acp_modules.php +++ b/phpBB/includes/acp/info/acp_modules.php @@ -20,7 +20,7 @@ class acp_modules_info 'acp' => array('title' => 'ACP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), 'ucp' => array('title' => 'UCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), 'mcp' => array('title' => 'MCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), - ), + ); $vars = array('modules'); $event = new phpbb_event_data(compact($vars)); @@ -34,7 +34,7 @@ class acp_modules_info 'modes' => $modules, ); - return $data + return $data; } function install() From 8af7d225ef481cd26e6fd7862847183d25727117 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Tue, 20 Mar 2012 11:23:03 +0000 Subject: [PATCH 040/140] [feature/events] Change to use the new method of adding events PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 4 +--- phpBB/includes/functions_display.php | 20 +++++--------------- phpBB/includes/functions_posting.php | 4 +--- phpBB/includes/functions_user.php | 20 +++++--------------- phpBB/includes/ucp/ucp_pm_viewmessage.php | 4 +--- phpBB/includes/ucp/ucp_zebra.php | 8 ++------ phpBB/index.php | 4 +--- phpBB/memberlist.php | 8 ++------ phpBB/ucp.php | 4 +--- phpBB/viewforum.php | 4 +--- phpBB/viewonline.php | 8 ++------ phpBB/viewtopic.php | 20 +++++--------------- 12 files changed, 27 insertions(+), 81 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 11843384ed..d86925dfab 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -108,9 +108,7 @@ class acp_forums ); $vars = array('forum_data'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.acp_forums_add_forum_data', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_add_forum_data', compact($vars), $vars)); // No break here diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 684729fc0d..507576b1d6 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -120,9 +120,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod ); $vars = array('sql_ary'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.display_forums_sql_inject', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.display_forums_sql_inject', compact($vars), $vars)); $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); @@ -133,9 +131,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod while ($row = $db->sql_fetchrow($result)) { $vars = array('row'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.display_forums_row_inject', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.display_forums_row_inject', compact($vars), $vars)); $forum_id = $row['forum_id']; @@ -235,9 +231,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; $vars = array('forum_rows', 'parent_id', 'row'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.display_forums_row_values_inject', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.display_forums_row_values_inject', compact($vars), $vars)); } else if ($row['forum_type'] != FORUM_CAT) { @@ -499,9 +493,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod ); $vars = array('row'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.display_forums_assign_block_vars', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.display_forums_assign_block_vars', compact($vars), $vars)); // Assign subforums loop for style authors foreach ($subforums_list as $subforum) @@ -879,9 +871,7 @@ function display_custom_bbcodes() ); $vars = array('custom_tags', 'row'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.display_custom_bbcodes_row', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_row', compact($vars), $vars)); $template->assign_block_vars('custom_tags', $custom_tags); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index d3550aafba..6c7cb3f0b2 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -132,9 +132,7 @@ function generate_smilies($mode, $forum_id) } $vars = array('mode', 'forum_id', 'display_link'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.generate_smilies_footer', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.generate_smilies_footer', compact($vars), $vars)); if ($mode == 'window') { diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 82400de932..761ce6436a 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -138,9 +138,7 @@ function user_update_name($old_name, $new_name) } $vars = array('old_name', 'new_name'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.user_update_name', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.user_update_name', compact($vars), $vars)); // Because some tables/caches use username-specific data we need to purge this here. $cache->destroy('sql', MODERATOR_CACHE_TABLE); @@ -541,9 +539,7 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); $vars = array('mode', 'user_id', 'post_username'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.user_delete', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.user_delete', compact($vars), $vars)); // Reset newest user info if appropriate if ($config['newest_user_id'] == $user_id) @@ -2819,9 +2815,7 @@ function group_delete($group_id, $group_name = false) unset($teampage); $vars = array('group_id', 'group_name'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.group_delete', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.group_delete', compact($vars), $vars)); // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " @@ -3055,9 +3049,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, unset($special_group_data); $vars = array('group_id', 'user_id_ary', 'username_ary', 'group_name'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.group_user_del', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.group_user_del', compact($vars), $vars)); $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " WHERE group_id = $group_id @@ -3473,9 +3465,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.group_set_user_default', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.group_set_user_default', compact($vars), $vars)); if ($update_listing) { diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index caaecfb741..a381521813 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -269,9 +269,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) ); $vars = array('id', 'mode', 'folder_id', 'msg_id', 'folder', 'message_row', 'cp_row'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.ucp_pm_viewmesssage', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.ucp_pm_viewmesssage', compact($vars), $vars)); // 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 f8012fdcdf..a2eb5dbdaa 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -55,9 +55,7 @@ class ucp_zebra if (!empty($data['usernames'])) { $vars = array('data'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.ucp_zebra_remove', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.ucp_zebra_remove', compact($vars), $vars)); $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' @@ -192,9 +190,7 @@ class ucp_zebra } $vars = array('mode', 'sql_ary'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.ucp_zebra_add', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.ucp_zebra_add', compact($vars), $vars)); $db->sql_multi_insert(ZEBRA_TABLE, $sql_ary); diff --git a/phpBB/index.php b/phpBB/index.php index 87b0adeafd..b7d53b5a7a 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -174,9 +174,7 @@ $template->assign_vars(array( $page_title = $user->lang['INDEX']; $vars = array('page_title'); -$event = new phpbb_event_data(compact($vars)); -$phpbb_dispatcher->dispatch('core.index', $event); -extract($event->get_data_filtered($vars)); +extract($phpbb_dispatcher->trigger_event('core.index', compact($vars), $vars)); // Output page page_header($page_title); diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 81369a9b57..f0c0065261 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -576,9 +576,7 @@ switch ($mode) } $vars = array('member', 'user_notes_enabled', 'warn_user_enabled'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.memberlist_viewprofile', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.memberlist_viewprofile', compact($vars), $vars)); $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled)); @@ -1748,9 +1746,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f ); $vars = array('data'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.memberlist_profile_data', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.memberlist_profile_data', compact($vars), $vars)); return $data; } diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 2b129f3ec7..02434cc3c8 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -329,9 +329,7 @@ if (!$auth->acl_get('u_sig')) } $vars = array('module'); -$event = new phpbb_event_data(compact($vars)); -$phpbb_dispatcher->dispatch('core.ucp_modules', $event); -extract($event->get_data_filtered($vars)); +extract($phpbb_dispatcher->trigger_event('core.ucp_modules', compact($vars), $vars)); // Select the active module $module->set_active($id, $mode); diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index dac4230ce0..393e8db26c 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -746,9 +746,7 @@ if (sizeof($topic_list)) ); $vars = array('topicrow'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.viewforum_topicrow', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.viewforum_topicrow', compact($vars), $vars)); $template->assign_block_vars('topicrow', $topicrow); diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index 55d663de20..08c02464e5 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -134,9 +134,7 @@ $sql_ary = array( ); $vars = array('sql_ary', 'show_guests'); -$event = new phpbb_event_data(compact($vars)); -$phpbb_dispatcher->dispatch('core.viewonline_get_userdata', $event); -extract($event->get_data_filtered($vars)); +extract($phpbb_dispatcher->trigger_event('core.viewonline_get_userdata', compact($vars), $vars)); $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); @@ -330,9 +328,7 @@ while ($row = $db->sql_fetchrow($result)) $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); $vars = array('on_page', 'row', 'location', 'location_url'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.viewonline_location', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.viewonline_location', compact($vars), $vars)); break; } diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 99b875ae3d..34c8bfbc0f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -988,9 +988,7 @@ $sql_ary = array( ); $vars = array('sql_ary'); -$event = new phpbb_event_data(compact($vars)); -$phpbb_dispatcher->dispatch('core.viewtopic_get_userdata', $event); -extract($event->get_data_filtered($vars)); +extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_userdata', compact($vars), $vars)); $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); @@ -1104,9 +1102,7 @@ while ($row = $db->sql_fetchrow($result)) ); $vars = array('user_cache_data', 'row', 'poster_id'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.viewtopic_user_cache_guest', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.viewtopic_user_cache_guest', compact($vars), $vars)); $user_cache[$poster_id] = $user_cache_data; @@ -1163,9 +1159,7 @@ while ($row = $db->sql_fetchrow($result)) ); $vars = array('user_cache_data', 'row', 'poster_id'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.viewtopic_user_cache', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.viewtopic_user_cache', compact($vars), $vars)); $user_cache[$poster_id] = $user_cache_data; @@ -1594,9 +1588,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) } $vars = array('postrow'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.viewtopic_postrow', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.viewtopic_postrow', compact($vars), $vars)); // Dump vars into template $template->assign_block_vars('postrow', $postrow); @@ -1756,9 +1748,7 @@ if (!request_var('t', 0) && !empty($topic_id)) $page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : ''); $vars = array('page_title', 'topic_data', 'forum_id', 'start'); -$event = new phpbb_event_data(compact($vars)); -$phpbb_dispatcher->dispatch('core.viewtopic_page_header', $event); -extract($event->get_data_filtered($vars)); +extract($phpbb_dispatcher->trigger_event('core.viewtopic_page_header', compact($vars), $vars)); // Output the page page_header($page_title, true, $forum_id); From 8da33e2654f89e55352012b197dfef4ae7a1fc7e Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 23 Mar 2012 12:11:45 +0000 Subject: [PATCH 041/140] [feature/events] Remove core.acp_modules_modules event PHPBB3-9550 --- phpBB/includes/acp/info/acp_modules.php | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/phpBB/includes/acp/info/acp_modules.php b/phpBB/includes/acp/info/acp_modules.php index 39091875d1..c9d2cffa72 100644 --- a/phpBB/includes/acp/info/acp_modules.php +++ b/phpBB/includes/acp/info/acp_modules.php @@ -14,27 +14,16 @@ class acp_modules_info { function module() { - global $phpbb_dispatcher; - - $modules = array( - 'acp' => array('title' => 'ACP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), - 'ucp' => array('title' => 'UCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), - 'mcp' => array('title' => 'MCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), - ); - - $vars = array('modules'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.acp_modules_modules', $event); - extract($event->get_data_filtered($vars)); - - $data = array( + return array( 'filename' => 'acp_modules', 'title' => 'ACP_MODULE_MANAGEMENT', 'version' => '1.0.0', - 'modes' => $modules, + 'modes' => array( + 'acp' => array('title' => 'ACP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), + 'ucp' => array('title' => 'UCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), + 'mcp' => array('title' => 'MCP', 'auth' => 'acl_a_modules', 'cat' => array('ACP_MODULE_MANAGEMENT')), + ), ); - - return $data; } function install() From 3f1b4e83aef7f7344cd551463b59de71bb4bd6fe Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Sat, 31 Mar 2012 13:39:41 +0100 Subject: [PATCH 042/140] [feature/events] Removing the third trigger_event parameter PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 2 +- phpBB/includes/functions_display.php | 10 +++++----- phpBB/includes/functions_posting.php | 2 +- phpBB/includes/functions_user.php | 10 +++++----- phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 +- phpBB/includes/ucp/ucp_zebra.php | 4 ++-- phpBB/index.php | 2 +- phpBB/memberlist.php | 4 ++-- phpBB/ucp.php | 2 +- phpBB/viewforum.php | 2 +- phpBB/viewonline.php | 4 ++-- phpBB/viewtopic.php | 10 +++++----- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index d86925dfab..f71e5f85b0 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -108,7 +108,7 @@ class acp_forums ); $vars = array('forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_add_forum_data', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_add_forum_data', compact($vars))); // No break here diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 507576b1d6..003724a8f5 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -120,7 +120,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod ); $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_sql_inject', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.display_forums_sql_inject', compact($vars))); $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); @@ -131,7 +131,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod while ($row = $db->sql_fetchrow($result)) { $vars = array('row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_row_inject', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.display_forums_row_inject', compact($vars))); $forum_id = $row['forum_id']; @@ -231,7 +231,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; $vars = array('forum_rows', 'parent_id', 'row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_row_values_inject', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.display_forums_row_values_inject', compact($vars))); } else if ($row['forum_type'] != FORUM_CAT) { @@ -493,7 +493,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod ); $vars = array('row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_assign_block_vars', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.display_forums_assign_block_vars', compact($vars))); // Assign subforums loop for style authors foreach ($subforums_list as $subforum) @@ -871,7 +871,7 @@ function display_custom_bbcodes() ); $vars = array('custom_tags', 'row'); - extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_row', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_row', compact($vars))); $template->assign_block_vars('custom_tags', $custom_tags); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 6c7cb3f0b2..0476c9b5d5 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -132,7 +132,7 @@ function generate_smilies($mode, $forum_id) } $vars = array('mode', 'forum_id', 'display_link'); - extract($phpbb_dispatcher->trigger_event('core.generate_smilies_footer', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.generate_smilies_footer', compact($vars))); if ($mode == 'window') { diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 761ce6436a..cf6a99c2b7 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -138,7 +138,7 @@ function user_update_name($old_name, $new_name) } $vars = array('old_name', 'new_name'); - extract($phpbb_dispatcher->trigger_event('core.user_update_name', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.user_update_name', compact($vars))); // Because some tables/caches use username-specific data we need to purge this here. $cache->destroy('sql', MODERATOR_CACHE_TABLE); @@ -539,7 +539,7 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); $vars = array('mode', 'user_id', 'post_username'); - extract($phpbb_dispatcher->trigger_event('core.user_delete', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.user_delete', compact($vars))); // Reset newest user info if appropriate if ($config['newest_user_id'] == $user_id) @@ -2815,7 +2815,7 @@ function group_delete($group_id, $group_name = false) unset($teampage); $vars = array('group_id', 'group_name'); - extract($phpbb_dispatcher->trigger_event('core.group_delete', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.group_delete', compact($vars))); // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " @@ -3049,7 +3049,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, unset($special_group_data); $vars = array('group_id', 'user_id_ary', 'username_ary', 'group_name'); - extract($phpbb_dispatcher->trigger_event('core.group_user_del', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.group_user_del', compact($vars))); $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " WHERE group_id = $group_id @@ -3465,7 +3465,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.group_set_user_default', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.group_set_user_default', compact($vars))); if ($update_listing) { diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index a381521813..ba297b96dd 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -269,7 +269,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) ); $vars = array('id', 'mode', 'folder_id', 'msg_id', 'folder', 'message_row', 'cp_row'); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_viewmesssage', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.ucp_pm_viewmesssage', compact($vars))); // 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 a2eb5dbdaa..f153fd6aed 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -55,7 +55,7 @@ class ucp_zebra if (!empty($data['usernames'])) { $vars = array('data'); - extract($phpbb_dispatcher->trigger_event('core.ucp_zebra_remove', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.ucp_zebra_remove', compact($vars))); $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' @@ -190,7 +190,7 @@ class ucp_zebra } $vars = array('mode', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.ucp_zebra_add', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.ucp_zebra_add', compact($vars))); $db->sql_multi_insert(ZEBRA_TABLE, $sql_ary); diff --git a/phpBB/index.php b/phpBB/index.php index b7d53b5a7a..00dcbb5855 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -174,7 +174,7 @@ $template->assign_vars(array( $page_title = $user->lang['INDEX']; $vars = array('page_title'); -extract($phpbb_dispatcher->trigger_event('core.index', compact($vars), $vars)); +extract($phpbb_dispatcher->trigger_event('core.index', compact($vars))); // Output page page_header($page_title); diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index f0c0065261..a417eaac1a 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -576,7 +576,7 @@ switch ($mode) } $vars = array('member', 'user_notes_enabled', 'warn_user_enabled'); - extract($phpbb_dispatcher->trigger_event('core.memberlist_viewprofile', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.memberlist_viewprofile', compact($vars))); $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled)); @@ -1746,7 +1746,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f ); $vars = array('data'); - extract($phpbb_dispatcher->trigger_event('core.memberlist_profile_data', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.memberlist_profile_data', compact($vars))); return $data; } diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 02434cc3c8..53cd9d2b74 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -329,7 +329,7 @@ if (!$auth->acl_get('u_sig')) } $vars = array('module'); -extract($phpbb_dispatcher->trigger_event('core.ucp_modules', compact($vars), $vars)); +extract($phpbb_dispatcher->trigger_event('core.ucp_modules', compact($vars))); // Select the active module $module->set_active($id, $mode); diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 393e8db26c..524d5c212a 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -746,7 +746,7 @@ if (sizeof($topic_list)) ); $vars = array('topicrow'); - extract($phpbb_dispatcher->trigger_event('core.viewforum_topicrow', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.viewforum_topicrow', compact($vars))); $template->assign_block_vars('topicrow', $topicrow); diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index 08c02464e5..227a88f962 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -134,7 +134,7 @@ $sql_ary = array( ); $vars = array('sql_ary', 'show_guests'); -extract($phpbb_dispatcher->trigger_event('core.viewonline_get_userdata', compact($vars), $vars)); +extract($phpbb_dispatcher->trigger_event('core.viewonline_get_userdata', compact($vars))); $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); @@ -328,7 +328,7 @@ while ($row = $db->sql_fetchrow($result)) $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); $vars = array('on_page', 'row', 'location', 'location_url'); - extract($phpbb_dispatcher->trigger_event('core.viewonline_location', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.viewonline_location', compact($vars))); break; } diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 34c8bfbc0f..7a1b9ba9e4 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -988,7 +988,7 @@ $sql_ary = array( ); $vars = array('sql_ary'); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_userdata', compact($vars), $vars)); +extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_userdata', compact($vars))); $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); @@ -1102,7 +1102,7 @@ while ($row = $db->sql_fetchrow($result)) ); $vars = array('user_cache_data', 'row', 'poster_id'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_user_cache_guest', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.viewtopic_user_cache_guest', compact($vars))); $user_cache[$poster_id] = $user_cache_data; @@ -1159,7 +1159,7 @@ while ($row = $db->sql_fetchrow($result)) ); $vars = array('user_cache_data', 'row', 'poster_id'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_user_cache', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.viewtopic_user_cache', compact($vars))); $user_cache[$poster_id] = $user_cache_data; @@ -1588,7 +1588,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) } $vars = array('postrow'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_postrow', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.viewtopic_postrow', compact($vars))); // Dump vars into template $template->assign_block_vars('postrow', $postrow); @@ -1748,7 +1748,7 @@ if (!request_var('t', 0) && !empty($topic_id)) $page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : ''); $vars = array('page_title', 'topic_data', 'forum_id', 'start'); -extract($phpbb_dispatcher->trigger_event('core.viewtopic_page_header', compact($vars), $vars)); +extract($phpbb_dispatcher->trigger_event('core.viewtopic_page_header', compact($vars))); // Output the page page_header($page_title, true, $forum_id); From a247bfc2b6ee8f4aeb53f639294932fa16688666 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Sun, 1 Apr 2012 20:19:47 +0100 Subject: [PATCH 043/140] [feature/events] Fixing issues with events PHPBB3-9550 --- phpBB/includes/functions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index de0cb8766b..e5b721b1f5 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5033,7 +5033,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))); From 6b1ca27a86ea8122d98d26ed4252754237d6cc1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 2 Apr 2012 11:53:12 +0200 Subject: [PATCH 044/140] [feature/events] Add `core.page_header_override` Add a ledge that will allow listeners to override the build in `page_header` function. http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=42741&p=237037 PHPBB3-9550 --- phpBB/includes/functions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e5b721b1f5..4ad1ba5c82 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4753,6 +4753,16 @@ 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; + + $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override'); + extract($phpbb_dispatcher->trigger_event('core.page_header_override', compact($vars))); + if ($page_header_override) + { + return; + } + // gzip_compression if ($config['gzip_compress']) { From 1a1ae60d8d8c84f39f5d6a2497d5e1965e5d1f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 2 Apr 2012 11:57:25 +0200 Subject: [PATCH 045/140] [feature/events] Add `core.page_footer_override` Add a ledge that will allow listeners to override the build in `page_footer` function. http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=42741&p=237037 PHPBB3-9550 --- phpBB/includes/functions.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4ad1ba5c82..f31a657687 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5069,6 +5069,17 @@ function page_footer($run_cron = true) { global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx; global $request; + global $phpbb_dispatcher; + + // A listener can set this variable to `true` when it overrides this function + $page_footer_override = false; + + $vars = array('run_cron', 'page_footer_override'); + extract($phpbb_dispatcher->trigger_event('core.page_footer_override', compact($vars))); + if ($page_footer_override) + { + return; + } // Output page creation time if (defined('DEBUG')) From 3d4946f5f017a51c7ae358ae450f4d9bb1cac70c Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Sat, 7 Apr 2012 15:47:57 +0100 Subject: [PATCH 046/140] [feature/events] Fixing events issues PHPBB3-9550 --- phpBB/includes/functions.php | 1 + phpBB/includes/mcp/mcp_forum.php | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f31a657687..86a2d14315 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5076,6 +5076,7 @@ function page_footer($run_cron = true) $vars = array('run_cron', 'page_footer_override'); extract($phpbb_dispatcher->trigger_event('core.page_footer_override', compact($vars))); + if ($page_footer_override) { return; diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index d40b8b5279..a43e896b07 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -289,9 +289,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) } $vars = array('topic_row', 'row'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.mcp_forum_topicrow', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.mcp_forum_topicrow', compact($vars))); $template->assign_block_vars('topicrow', $topic_row); } From c7b84eb32935ad78ae56fbf6382f95e8df11cdfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Tue, 10 Apr 2012 20:29:40 +0200 Subject: [PATCH 047/140] [feature/events] Adding core.build_cfg_template event See: http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=42801 for referance. PHPBB3-9550 --- phpBB/includes/functions_acp.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index dc61859363..47caecef02 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -194,6 +194,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 $phpbb_dispatcher; $tpl = ''; $name = 'config[' . $config_key . ']'; @@ -305,6 +306,9 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars) $tpl .= $vars['append']; } + $vars = array('tpl_type', 'key', 'new', 'config_key', 'vars', 'tpl'); + extract($phpbb_dispatcher->trigger_event('core.build_cfg_template', compact($vars))); + return $tpl; } From 95e81fb402c1eccf2c7772914ef301fd4043d9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Tue, 10 Apr 2012 20:18:05 +0200 Subject: [PATCH 048/140] [feature/events] Adding core.adm_page_header_override event Add an event that adds the possibility to override the phpBB `adm_page_header` function. PHPBB3-9550 --- phpBB/includes/functions_acp.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 47caecef02..c2ed623ece 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,16 @@ 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; + + $vars = array('page_title', 'adm_page_header_override'); + extract($phpbb_dispatcher->trigger_event('core.adm_page_header_override', compact($vars))); + if ($adm_page_header_override) + { + return; + } + // gzip_compression if ($config['gzip_compress']) { From 586912882833707a51edc44a810c5f174bdce72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Tue, 10 Apr 2012 20:21:45 +0200 Subject: [PATCH 049/140] [feature/events] Adding adm_page_footer_override event Add an event that adds the possibility to override the phpBB `adm_page_footer` function. PHPBB3-9550 --- phpBB/includes/functions_acp.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index c2ed623ece..c8dc68fea1 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -108,6 +108,18 @@ 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 $phpbb_dispatcher; + + // A listener can set this variable to `true` when it overrides this function + $adm_page_footer_override = false; + + $vars = array('copyright_html', 'adm_page_footer_override'); + extract($phpbb_dispatcher->trigger_event('core.adm_page_footer_override', compact($vars))); + + if ($adm_page_footer_override) + { + return; + } // Output page creation time if (defined('DEBUG')) From e21861b488ad4daf88b02aedf4e93d218d250ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Tue, 10 Apr 2012 20:35:30 +0200 Subject: [PATCH 050/140] [feature/events] Adding core.garbage_collection event See: http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=42799 for reference. PHPBB3-9550 --- phpBB/includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 86a2d14315..086755f49d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5165,6 +5165,9 @@ function page_footer($run_cron = true) function garbage_collection() { global $cache, $db; + global $phpbb_dispatcher; + + $phpbb_dispatcher->dispatch('core.garbage_collection'); // Unload cache, must be done before the DB connection if closed if (!empty($cache)) From b04141b14f2fe5a804e55c6e4f94869b9f4e4a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Tue, 10 Apr 2012 22:22:29 +0200 Subject: [PATCH 051/140] [feature/events] Correct core.acp_users_overview event The event still used the "old" method. PHPBB3-9550 --- phpBB/includes/acp/acp_users.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index f6c2ecfc87..de1e9afc83 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -30,8 +30,9 @@ class acp_users function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache, $phpbb_dispatcher; + 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'; @@ -1040,9 +1041,7 @@ class acp_users )); $vars = array('data', 'check_ary', 'sql_ary', 'user_row', 'quick_tool_ary'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.acp_users_overview', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.acp_users_overview', compact($vars))); break; From 05c0d1ad177342eb40ee97c1ae7452aa90f6583f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Tue, 10 Apr 2012 22:19:18 +0200 Subject: [PATCH 052/140] [feature/events] Correct core.acp_profile_edit event Still used the "old" way. PHPBB3-9550 --- phpBB/includes/acp/acp_profile.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 43426e86a7..1b542c2bfb 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -27,9 +27,10 @@ class acp_profile function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache, $phpbb_dispatcher; + global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; global $request; + global $phpbb_dispatcher; include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); include($phpbb_root_path . 'includes/functions_user.' . $phpEx); @@ -876,10 +877,8 @@ class acp_profile } } - $vars = array('field_row', 'visibility_ary', 'exclude'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.acp_profile_edit', $event); - extract($event->get_data_filtered($vars)); + $vars = array('field_row', 'visibility_ary', 'exclude'); + extract($phpbb_dispatcher->trigger_event('core.acp_profile_edit', compact($vars))); break; } From 57617b048f7ab1deb2a7019be29a24d782a00fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Tue, 10 Apr 2012 22:56:45 +0200 Subject: [PATCH 053/140] [feature/events] Adding core.validate_config_vars event Allows a MOD author to define additional "configuration types" and add the logic to validate these option types as well. PHPBB3-9550 --- phpBB/includes/functions_acp.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index c8dc68fea1..4ff126260f 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -342,6 +342,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_dispatcher; + $type = 0; $min = 1; $max = 2; @@ -516,6 +518,11 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) } break; + + default: + $vars = array('cfg_array', 'config_name', 'config_definition', 'error'); + extract($phpbb_dispatcher->trigger_event('core.validate_config_vars', compact($vars))); + break; } } From c51e8716c5a2d0f5efc02abb7de08cab087f9442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Thu, 19 Apr 2012 13:00:28 +0200 Subject: [PATCH 054/140] [feature/events] Add blank line Add an additional blank line as requested in #680 PHPBB3-9550 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 086755f49d..85449a8cd3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4758,6 +4758,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override'); extract($phpbb_dispatcher->trigger_event('core.page_header_override', compact($vars))); + if ($page_header_override) { return; From 6059bc7b45a098e4bc846fe3704543137cc1aba1 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 25 May 2012 18:18:27 -0400 Subject: [PATCH 055/140] [feature/events] Added core.user_default_avatar event This way, extension authors can overwrite the empty value returned when a user does not have an avatar with a default value to display instead of nothing in the avatar space. PHPBB3-9550 --- phpBB/includes/functions_display.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 003724a8f5..53a07d5591 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1267,10 +1267,19 @@ 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; if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config)) { - return ''; + $empty_avatar = ''; + if ($config['allow_avatar'] || $ignore_config) + { + // This allows extensions to change the default return when no avatar is given + // Useful for default avatars + $vars = array('empty_avatar'); + extract($phpbb_dispatcher->trigger_event('core.user_default_avatar', compact($vars))); + } + return $empty_avatar; } $avatar_img = ''; From 611d965b043c2a566e817f29d618ff841aa02c34 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 11 Jun 2012 08:26:44 -0400 Subject: [PATCH 056/140] [feature/events] Renamed $empty_avatar to $default_avatar PHPBB3-9550 --- phpBB/includes/functions_display.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 53a07d5591..6b145ea422 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1271,15 +1271,15 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $ if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config)) { - $empty_avatar = ''; + $default_avatar = ''; if ($config['allow_avatar'] || $ignore_config) { // This allows extensions to change the default return when no avatar is given // Useful for default avatars - $vars = array('empty_avatar'); + $vars = array('default_avatar'); extract($phpbb_dispatcher->trigger_event('core.user_default_avatar', compact($vars))); } - return $empty_avatar; + return $default_avatar; } $avatar_img = ''; From 2be60b80ae6fc1da09af8eeaffc8d72aafc0c3b1 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 11 Jun 2012 17:49:07 -0400 Subject: [PATCH 057/140] [feature/events] Rename core.index to core.index_page_title This makes it clearer as to what the event actually does. PHPBB3-9550 --- phpBB/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/index.php b/phpBB/index.php index 00dcbb5855..febd630a2b 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -174,7 +174,7 @@ $template->assign_vars(array( $page_title = $user->lang['INDEX']; $vars = array('page_title'); -extract($phpbb_dispatcher->trigger_event('core.index', compact($vars))); +extract($phpbb_dispatcher->trigger_event('core.index_page_title', compact($vars))); // Output page page_header($page_title); From 0f78b4699acd823f773214497f68840178a8b82e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 15:41:02 +0200 Subject: [PATCH 058/140] [feature/php-events] Replace core.acp_forums_add_forum_data Add missing global $phpbb_dispatcher, add $action and name the event better PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index f71e5f85b0..b634a3d9a0 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'); @@ -107,9 +107,6 @@ class acp_forums 'forum_id' => $forum_id ); - $vars = array('forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_add_forum_data', compact($vars))); - // No break here case 'add': @@ -153,6 +150,9 @@ class acp_forums 'forum_password_unset' => request_var('forum_password_unset', false), ); + $vars = array('action', 'forum_data'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_modify_forum_data', compact($vars))); + // On add, add empty forum_options... else do not consider it (not updating it) if ($action == 'add') { From 8637f09b356f2b26a33e9ab2a7d245fb0e016f85 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 15:43:22 +0200 Subject: [PATCH 059/140] [feature/php-events] Fix name of event when changing a profile field PHPBB3-9550 --- phpBB/includes/acp/acp_profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 1b542c2bfb..d84c4c2ed5 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -878,7 +878,7 @@ class acp_profile } $vars = array('field_row', 'visibility_ary', 'exclude'); - extract($phpbb_dispatcher->trigger_event('core.acp_profile_edit', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.acp_profile_field_edit', compact($vars))); break; } From 3a9b7c9acf7ab0e9bd78cf76d59c30c48fb17c6a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 15:47:56 +0200 Subject: [PATCH 060/140] [feature/php-events] Remove duplicated event and name the events properly PHPBB3-9550 --- phpBB/includes/functions.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 85449a8cd3..442b125657 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4757,7 +4757,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $page_header_override = false; $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override'); - extract($phpbb_dispatcher->trigger_event('core.page_header_override', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars))); if ($page_header_override) { @@ -5044,9 +5044,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'); @@ -5076,7 +5073,7 @@ function page_footer($run_cron = true) $page_footer_override = false; $vars = array('run_cron', 'page_footer_override'); - extract($phpbb_dispatcher->trigger_event('core.page_footer_override', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.page_footer', compact($vars))); if ($page_footer_override) { From e126c37ea8a0c47ce8a78959a71ca8f9da8340ea Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 15:49:41 +0200 Subject: [PATCH 061/140] [feature/php-events] Remove _override from event name PHPBB3-9550 --- phpBB/includes/functions_acp.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 4ff126260f..f59c8cd4c6 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -35,7 +35,7 @@ function adm_page_header($page_title) $adm_page_header_override = false; $vars = array('page_title', 'adm_page_header_override'); - extract($phpbb_dispatcher->trigger_event('core.adm_page_header_override', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.adm_page_header', compact($vars))); if ($adm_page_header_override) { return; @@ -114,7 +114,7 @@ function adm_page_footer($copyright_html = true) $adm_page_footer_override = false; $vars = array('copyright_html', 'adm_page_footer_override'); - extract($phpbb_dispatcher->trigger_event('core.adm_page_footer_override', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.adm_page_footer', compact($vars))); if ($adm_page_footer_override) { From 730bd6eb08aa76dc54e661b03207e2d695d9a8c5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 15:52:45 +0200 Subject: [PATCH 062/140] [feature/php-events] Rename display_forums_sql_inject to be less misleading PHPBB3-9550 --- phpBB/includes/functions_display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 6b145ea422..68c49c2457 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -120,7 +120,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod ); $vars = array('sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_sql_inject', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.display_forums_build_query', compact($vars))); $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); From 3af0ae69eed6955a23b29087891258efb1a06e33 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 15:54:55 +0200 Subject: [PATCH 063/140] [feature/php-events] Properly name user_default_avatar and add additional vars PHPBB3-9550 --- phpBB/includes/functions_display.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 68c49c2457..ca2bfc3b65 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1276,8 +1276,8 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $ { // This allows extensions to change the default return when no avatar is given // Useful for default avatars - $vars = array('default_avatar'); - extract($phpbb_dispatcher->trigger_event('core.user_default_avatar', compact($vars))); + $vars = array('avatar', 'avatar_type', 'ignore_config', 'default_avatar'); + extract($phpbb_dispatcher->trigger_event('core.get_user_avatar_default', compact($vars))); } return $default_avatar; } From 758fb67a7dc3bcc39ec0284c7045b2668f049408 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 15:58:12 +0200 Subject: [PATCH 064/140] [feature/php-events] Add missing global $phpbb_dispatcher PHPBB3-9550 --- phpBB/includes/mcp/mcp_forum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index a43e896b07..9b3c002968 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')); From 4745d4ec6c5c25757818bf528f1019da4ebd2534 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 16:01:51 +0200 Subject: [PATCH 065/140] [feature/php-events] Do not override the data parameter, so data is available PHPBB3-9550 --- phpBB/memberlist.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index a417eaac1a..06c55e7956 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1696,7 +1696,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f } // Dump it out to the template - $data = array( + $template_data = array( 'AGE' => $age, 'RANK_TITLE' => $rank_title, 'JOINED' => $user->format_date($data['user_regdate']), @@ -1745,10 +1745,10 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f 'L_VIEWING_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $username), ); - $vars = array('data'); + $vars = array('data', 'template_data'); extract($phpbb_dispatcher->trigger_event('core.memberlist_profile_data', compact($vars))); - return $data; + return $template_data; } function _sort_last_active($first, $second) From 45d534978b4d5f20666dbf9b8de721fe02197746 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 16:03:46 +0200 Subject: [PATCH 066/140] [feature/php-events] Make topic db row available in event PHPBB3-9550 --- phpBB/viewforum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 524d5c212a..bc385a6a7a 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -745,7 +745,7 @@ if (sizeof($topic_list)) 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test, ); - $vars = array('topicrow'); + $vars = array('row', 'topicrow'); extract($phpbb_dispatcher->trigger_event('core.viewforum_topicrow', compact($vars))); $template->assign_block_vars('topicrow', $topicrow); From f01d742b5649678de3e5ba4aa45f4176c8ff5aac Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 16:07:49 +0200 Subject: [PATCH 067/140] [feature/php-events] Add additional vars and control to viewtopic_postrow event PHPBB3-9550 --- phpBB/viewtopic.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 7a1b9ba9e4..20d4c2af1b 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1582,14 +1582,16 @@ 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']), '', '') : '', ); + $user_poster_data = $user_cache[$poster_id]; + + $vars = array('row', 'cp_row', 'user_poster_data', 'postrow'); + extract($phpbb_dispatcher->trigger_event('core.viewtopic_postrow', compact($vars))); + if (isset($cp_row['row']) && sizeof($cp_row['row'])) { $postrow = array_merge($postrow, $cp_row['row']); } - $vars = array('postrow'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_postrow', compact($vars))); - // Dump vars into template $template->assign_block_vars('postrow', $postrow); From 2e5a7ae4dda587bc1f47f2f1fddb4e13235217d4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 16:22:22 +0200 Subject: [PATCH 068/140] [feature/php-events] Add additional events to acp_forums.php PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index b634a3d9a0..1c798a12da 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -151,7 +151,7 @@ class acp_forums ); $vars = array('action', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_modify_forum_data', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_get_forum_data', compact($vars))); // On add, add empty forum_options... else do not consider it (not updating it) if ($action == 'add') @@ -416,6 +416,9 @@ class acp_forums $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false); $forum_data['forum_password_confirm'] = $forum_data['forum_password']; + + $vars = array('forum_id', 'row', 'forum_data'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_modify_forum_data', compact($vars))); } else { @@ -453,6 +456,9 @@ class acp_forums 'forum_password' => '', 'forum_password_confirm'=> '', ); + + $vars = array('forum_id', 'forum_data'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_init_forum_data', compact($vars))); } } @@ -585,7 +591,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, @@ -650,7 +656,12 @@ 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, - )); + ); + + $vars = array('forum_id', 'action', 'forum_data', 'template_data', 'old_forum_type', 'forum_desc_data', 'forum_rules_data'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_assign_template_forum_data', compact($vars))); + + $template->assign_vars($template_data); return; @@ -875,10 +886,13 @@ 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(); + $vars = array('forum_data', 'errors'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_update_forum_data', compact($vars))); + if ($forum_data['forum_name'] == '') { $errors[] = $user->lang['FORUM_NAME_EMPTY']; @@ -1242,6 +1256,9 @@ class acp_forums add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']); } + $vars = array('forum_data', 'errors'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_update_forum_data_after', compact($vars))); + return $errors; } @@ -1250,10 +1267,13 @@ class acp_forums */ function move_forum($from_id, $to_id) { - global $db, $user; + global $db, $user, $phpbb_dispatcher; $to_data = $moved_ids = $errors = array(); + $vars = array('from_id', 'to_id'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_move_forum', compact($vars))); + // Check if we want to move to a parent with link type if ($to_id > 0) { From b1582ece91e7ebd9f635040bbb1a4c6c47786135 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 16:42:47 +0200 Subject: [PATCH 069/140] [feature/php-events] Proper name for request forum data to avoid confusion PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 1c798a12da..6631edf438 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -151,7 +151,7 @@ class acp_forums ); $vars = array('action', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_get_forum_data', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_request_forum_data', compact($vars))); // On add, add empty forum_options... else do not consider it (not updating it) if ($action == 'add') From bdfedba521ee38ef6b8915bfb130b2f164c040c0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 16:43:08 +0200 Subject: [PATCH 070/140] [feature/php-events] Make handling of forumrow consistent with others PHPBB3-9550 --- phpBB/includes/functions_display.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index ca2bfc3b65..9ab90a6482 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -452,7 +452,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, @@ -489,12 +489,14 @@ 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&mode=unapproved_topics&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, ); - $vars = array('row'); + $vars = array('row', 'forum_row'); extract($phpbb_dispatcher->trigger_event('core.display_forums_assign_block_vars', compact($vars))); + $template->assign_block_vars('forumrow', $forum_row); + // Assign subforums loop for style authors foreach ($subforums_list as $subforum) { From b2884449159305420f52881b7fe9841c1a50c2ed Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 16:43:32 +0200 Subject: [PATCH 071/140] [feature/php-events] Make naming of topicrow consistent with others (topic_row) PHPBB3-9550 --- phpBB/viewforum.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index bc385a6a7a..df5678def1 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&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : ''; // Send vars to template - $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']), @@ -745,10 +745,10 @@ if (sizeof($topic_list)) 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test, ); - $vars = array('row', 'topicrow'); + $vars = array('row', 'topic_row'); extract($phpbb_dispatcher->trigger_event('core.viewforum_topicrow', compact($vars))); - $template->assign_block_vars('topicrow', $topicrow); + $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); From 16736d4e4cfabc65f84c6339bf81ae01f1edffc2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 16:43:48 +0200 Subject: [PATCH 072/140] [feature/php-events] Make naming of postrow consistent with others (post_row) PHPBB3-9550 --- phpBB/viewtopic.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 20d4c2af1b..ce73001c78 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1506,7 +1506,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']), @@ -1584,16 +1584,16 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) $user_poster_data = $user_cache[$poster_id]; - $vars = array('row', 'cp_row', 'user_poster_data', 'postrow'); + $vars = array('row', 'cp_row', 'user_poster_data', 'post_row'); extract($phpbb_dispatcher->trigger_event('core.viewtopic_postrow', 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'])) { From 97f50c9771fb331d131695db9e3e0f7deedb18be Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 15:02:05 +0200 Subject: [PATCH 073/140] [feature/php-events] Add docs and fix naming of core.viewonline_modify_sql PHPBB3-9550 --- phpBB/viewonline.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index 227a88f962..32ea23c182 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -133,8 +133,16 @@ $sql_ary = array( '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_get_userdata', compact($vars))); +extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_sql', compact($vars))); $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); From 0ebe1f876452edbf2daeaf1e11bfe0b776fdc8af Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 16:12:05 +0200 Subject: [PATCH 074/140] [feature/php-events] Fix docs and naming of core.viewonline_override_location PHPBB3-9550 --- phpBB/viewonline.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index 32ea23c182..193fa61dd7 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -335,8 +335,18 @@ while ($row = $db->sql_fetchrow($result)) $location = $user->lang['INDEX']; $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); + /** + * Modify the location name and url which are displayed in the list + * + * @event core.viewonline_override_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_location', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.viewonline_override_location', compact($vars))); break; } From c903b1512c9926dfbc54e4e48233904385c137c6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 16:53:20 +0200 Subject: [PATCH 075/140] [feature/php-events] Fix docs and naming of core.update_username PHPBB3-9550 --- phpBB/includes/functions_user.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index cf6a99c2b7..eef75b8430 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -137,8 +137,16 @@ function user_update_name($old_name, $new_name) set_config('newest_username', $new_name, true); } + /** + * Update 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.user_update_name', compact($vars))); + 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); From ec957350c14c8b0bb6dc4768b5ad363a39715cab Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 17:02:18 +0200 Subject: [PATCH 076/140] [feature/php-events] Fix docs and naming of core.delete_user_after PHPBB3-9550 --- phpBB/includes/functions_user.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index eef75b8430..de65d86e3f 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -546,8 +546,17 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); + /** + * Event after an 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.user_delete', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.delete_user_after', compact($vars))); // Reset newest user info if appropriate if ($config['newest_user_id'] == $user_id) From 3affe7f229f4c8a3bb4ddb1abd79aca0dc0c15a9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 17:03:04 +0200 Subject: [PATCH 077/140] [feature/php-events] Fix docs and naming of core.delete_user_before PHPBB3-9550 --- phpBB/includes/functions_user.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index de65d86e3f..8f91a66549 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -357,6 +357,18 @@ function user_delete($mode, $user_id, $post_username = false) return false; } + /** + * Event before an 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 From 8d3389448bf65f1bfc78efbfc80d0b658661f3da Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 18:54:00 +0200 Subject: [PATCH 078/140] [feature/php-events] Fix docs and naming of core.delete_group_after PHPBB3-9550 --- phpBB/includes/functions_user.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 8f91a66549..c78c74bd76 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2843,9 +2843,6 @@ function group_delete($group_id, $group_name = false) $teampage->delete_group($group_id); unset($teampage); - $vars = array('group_id', 'group_name'); - extract($phpbb_dispatcher->trigger_event('core.group_delete', compact($vars))); - // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; @@ -2856,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')) { From 3ced9f58ea5493e13796766d55059b70bc6d6a3e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 19:27:58 +0200 Subject: [PATCH 079/140] [feature/php-events] Fix docs and naming of core.group_delete_user_before PHPBB3-9550 --- phpBB/includes/functions_user.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index c78c74bd76..d65d59f6c5 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3085,8 +3085,18 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, } unset($special_group_data); - $vars = array('group_id', 'user_id_ary', 'username_ary', 'group_name'); - extract($phpbb_dispatcher->trigger_event('core.group_user_del', compact($vars))); + /** + * 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 From a05cd6d837ad9d2202561ded9c100a9b1350c0c2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 19:50:58 +0200 Subject: [PATCH 080/140] [feature/php-events] Fix docs and naming of core.user_set_default_group PHPBB3-9550 --- phpBB/includes/functions_user.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index d65d59f6c5..733a6fd9bd 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3511,8 +3511,19 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } } + /** + * Event when the default group is set for an array of user + * + * @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.group_set_user_default', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.user_set_default_group', compact($vars))); if ($update_listing) { From 099aaab7208123a5fb8195ccd5bdccee80ea2460 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 22:47:00 +0200 Subject: [PATCH 081/140] [feature/php-events] Fix docs and naming of core.display_forums_modify_sql PHPBB3-9550 --- phpBB/includes/functions_display.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 9ab90a6482..7111153fd4 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -119,8 +119,15 @@ 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_build_query', compact($vars))); + 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); From 14edfd2856b602ea435f5d473322950e23868b6e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 30 Jul 2012 14:12:12 +0200 Subject: [PATCH 082/140] [feature/php-events] Fix docs of core.display_forums_modify_row PHPBB3-9550 --- phpBB/includes/functions_display.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 7111153fd4..a022b9a807 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -137,8 +137,18 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod while ($row = $db->sql_fetchrow($result)) { - $vars = array('row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_row_inject', compact($vars))); + /** + * 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']; From d4f9442e8749152d08ff50ca678b105d0ed2b703 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 30 Jul 2012 15:34:53 +0200 Subject: [PATCH 083/140] [feature/php-events] Move core.display_forums_modify_forum_rows to better point PHPBB3-9550 --- phpBB/includes/functions_display.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index a022b9a807..3f37f227f6 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -246,9 +246,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id']; $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; - - $vars = array('forum_rows', 'parent_id', 'row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_row_values_inject', compact($vars))); } else if ($row['forum_type'] != FORUM_CAT) { @@ -286,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); From 8b7e3739a04bd3ea707493894fa2ebf8dc81410e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 30 Jul 2012 15:47:42 +0200 Subject: [PATCH 084/140] [feature/php-events] Fix docs and naming of display_forums_modify_template_vars PHPBB3-9550 --- phpBB/includes/functions_display.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 3f37f227f6..448c261580 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -522,8 +522,18 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'U_LAST_POST' => $last_post_url, ); - $vars = array('row', 'forum_row'); - extract($phpbb_dispatcher->trigger_event('core.display_forums_assign_block_vars', compact($vars))); + /** + * 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); From 96f20160bcfa7a08870602b25fa528370f034128 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 30 Jul 2012 16:00:19 +0200 Subject: [PATCH 085/140] [feature/php-events] Fix docs and naming of display_custom_bbcodes_modify_row PHPBB3-9550 --- phpBB/includes/functions_display.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 448c261580..807f5a2192 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -912,8 +912,18 @@ function display_custom_bbcodes() 'A_BBCODE_HELPLINE' => str_replace(array('&', '"', "'", '<', '>'), 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_row', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_row', compact($vars))); $template->assign_block_vars('custom_tags', $custom_tags); From 4f13b049f813916e6393c8c4cc0227d3f52c2318 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 30 Jul 2012 16:35:01 +0200 Subject: [PATCH 086/140] [feature/php-events] Fix docs of core.display_custom_bbcodes PHPBB3-9550 --- phpBB/includes/functions_display.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 807f5a2192..1e093e6811 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -931,6 +931,12 @@ function display_custom_bbcodes() } $db->sql_freeresult($result); + /** + * Display custom bbcodes + * + * @event core.display_custom_bbcodes + * @since 3.1-A1 + */ $phpbb_dispatcher->dispatch('core.display_custom_bbcodes'); } From 39869d46b1c4f3dcc178cdb7cd05e8f28fcc1f47 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 30 Jul 2012 17:01:35 +0200 Subject: [PATCH 087/140] [feature/php-events] Allow core.user_get_avatar to overwrite all avatars PHPBB3-9550 --- phpBB/includes/functions_display.php | 34 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 1e093e6811..bf379a40f4 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1327,17 +1327,33 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $ 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)) { - $default_avatar = ''; - if ($config['allow_avatar'] || $ignore_config) - { - // This allows extensions to change the default return when no avatar is given - // Useful for default avatars - $vars = array('avatar', 'avatar_type', 'ignore_config', 'default_avatar'); - extract($phpbb_dispatcher->trigger_event('core.get_user_avatar_default', compact($vars))); - } - return $default_avatar; + return ''; } $avatar_img = ''; From 01369dd7f826a27e9970e0c0acb126cb2349c87c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 31 Jul 2012 23:50:31 +0200 Subject: [PATCH 088/140] [feature/php-events] Add docs to core.common @todo: Add event to user::setup() after branch is updated to develop, so timezone handling is there PHPBB3-9550 --- phpBB/common.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/phpBB/common.php b/phpBB/common.php index 9cf2617b07..e18c27abd1 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -144,4 +144,17 @@ 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 objec +* (f.e. to use 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'); From d152c20e4b53f26bfcf9425f1efed9d9d4ccef9f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 1 Aug 2012 11:07:34 +0200 Subject: [PATCH 089/140] [feature/php-events] Add core.user_setup event This event can be used to load language files globally so it fixes PHPBB3-8270 PHPBB3-8270 PHPBB3-9550 --- phpBB/includes/user.php | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) 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); From e85afc6b83559742e87d85e7a385bf08b27a8c25 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 2 Aug 2012 20:59:38 +0200 Subject: [PATCH 090/140] [feature/php-events] Fix naming and docs of core.index_modify_page_title PHPBB3-9550 --- phpBB/index.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/index.php b/phpBB/index.php index febd630a2b..90d1d352e0 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -173,8 +173,15 @@ $template->assign_vars(array( $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_page_title', compact($vars))); +extract($phpbb_dispatcher->trigger_event('core.index_modify_page_title', compact($vars))); // Output page page_header($page_title); From d06adb06e907e31918130a6ef010b73d454f396c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 2 Aug 2012 21:22:52 +0200 Subject: [PATCH 091/140] [feature/php-events] Remove core.mcp_check_ids and invalid comment. We couldn't find a reason for this event, as it even doesn't have any arguments The comment is not correct anymore either. Since 3.1global announcements still have a valid forum_id PHPBB3-9550 --- phpBB/mcp.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/phpBB/mcp.php b/phpBB/mcp.php index b5cfa99d4c..730af65e3d 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -823,7 +823,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, */ function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = false) { - global $db, $auth, $phpbb_dispatcher; + global $db, $auth; if (!is_array($ids) || empty($ids)) { @@ -887,9 +887,5 @@ function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = fa return false; } - // If forum id is false and ids populated we may have only global announcements selected (returning 0 because of (int) $forum_id) - - $phpbb_dispatcher->dispatch('core.mcp_check_ids'); - return ($single_forum === false) ? true : (int) $forum_id; } From a2c59bba858255e3dd9f0dd36983714bf33c27e0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 2 Aug 2012 21:56:35 +0200 Subject: [PATCH 092/140] [feature/php-events] Fix naming, vars and docs of core.memberlist_view_profile PHPBB3-9550 --- phpBB/memberlist.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 06c55e7956..29a042409a 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -575,8 +575,25 @@ switch ($mode) unset($module); } - $vars = array('member', 'user_notes_enabled', 'warn_user_enabled'); - extract($phpbb_dispatcher->trigger_event('core.memberlist_viewprofile', compact($vars))); + /** + * 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)); From fab13f75590e33beeda2a12bb9653b1fd0ec60bf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 2 Aug 2012 22:05:39 +0200 Subject: [PATCH 093/140] [feature/php-events] Fix naming and docs of memberlist_prepare_profile_data PHPBB3-9550 --- phpBB/memberlist.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 29a042409a..e1e4517643 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1762,8 +1762,16 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f 'L_VIEWING_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $username), ); + /** + * Preparing 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_profile_data', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars))); return $template_data; } From 63d17e51813f1b80fd5c2ee33bcc67603c8da78b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 3 Aug 2012 23:26:50 +0200 Subject: [PATCH 094/140] [feature/php-events] Fix naming and doc of core.viewforum_modify_topicrow PHPBB3-9550 --- phpBB/viewforum.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index df5678def1..adf875114b 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -745,8 +745,16 @@ if (sizeof($topic_list)) '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_topicrow', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topicrow', compact($vars))); $template->assign_block_vars('topicrow', $topic_row); From b153637cb8bd58d571748f9539e81822be11d8bb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 3 Aug 2012 23:41:00 +0200 Subject: [PATCH 095/140] [feature/php-events] Fix naming and doc of core.ucp_display_module_before PHPBB3-9550 --- phpBB/ucp.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 53cd9d2b74..9730591698 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -328,8 +328,17 @@ if (!$auth->acl_get('u_sig')) $module->set_display('profile', 'signature', false); } -$vars = array('module'); -extract($phpbb_dispatcher->trigger_event('core.ucp_modules', compact($vars))); +/** +* 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); From 0d182d9e9376a56b314b072c9d4395c18b900478 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 4 Aug 2012 17:07:35 +0200 Subject: [PATCH 096/140] [feature/php-events] Fix naming and doc of core.generate_smilies_after PHPBB3-9550 --- phpBB/includes/functions_posting.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 0476c9b5d5..7ac56588af 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -123,6 +123,18 @@ function generate_smilies($mode, $forum_id) } } + /** + * This event is called when the smilies got 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( @@ -131,9 +143,6 @@ function generate_smilies($mode, $forum_id) ); } - $vars = array('mode', 'forum_id', 'display_link'); - extract($phpbb_dispatcher->trigger_event('core.generate_smilies_footer', compact($vars))); - if ($mode == 'window') { page_footer(); From a9d4ed0cfcc58f3993bb09f230ad2b11482ddde8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 4 Aug 2012 17:19:25 +0200 Subject: [PATCH 097/140] [feature/php-events] Fix naming and doc of core.mcp_view_forum_modify_topicrow PHPBB3-9550 --- phpBB/includes/mcp/mcp_forum.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 9b3c002968..7b3bc82093 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -288,8 +288,16 @@ function mcp_forum_view($id, $mode, $action, $forum_info) )); } - $vars = array('topic_row', 'row'); - extract($phpbb_dispatcher->trigger_event('core.mcp_forum_topicrow', compact($vars))); + /** + * 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); } From 63a00efdd4eae8c3ad6a52c654107a83db5a2128 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 4 Aug 2012 17:37:54 +0200 Subject: [PATCH 098/140] [feature/php-events] Fix naming and doc of core.ucp_pm_view_messsage PHPBB3-9550 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index ba297b96dd..569232d878 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -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,11 +265,27 @@ 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&f=$folder_id&p=" . $message_row['msg_id'] . "&view=print" : '', - 'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&mode=compose&action=forward&f=$folder_id&p=" . $message_row['msg_id'] : '') + 'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&mode=compose&action=forward&f=$folder_id&p=" . $message_row['msg_id'] : '', ); - $vars = array('id', 'mode', 'folder_id', 'msg_id', 'folder', 'message_row', 'cp_row'); - extract($phpbb_dispatcher->trigger_event('core.ucp_pm_viewmesssage', compact($vars))); + /** + * 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'])) From a53ddec5a32dd208d52e12945490464ed2d363af Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 4 Aug 2012 17:44:46 +0200 Subject: [PATCH 099/140] [feature/php-events] Fix naming and doc of core.ucp_remove_zebra PHPBB3-9550 --- phpBB/includes/ucp/ucp_zebra.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index f153fd6aed..2e3bada7bc 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -54,12 +54,22 @@ class ucp_zebra // Remove users if (!empty($data['usernames'])) { - $vars = array('data'); - extract($phpbb_dispatcher->trigger_event('core.ucp_zebra_remove', compact($vars))); + $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; From 4eefba9b3f59618f78f338aa40a05f39ef8214e9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 4 Aug 2012 17:50:16 +0200 Subject: [PATCH 100/140] [feature/php-events] Fix naming and doc of core.ucp_add_zebra PHPBB3-9550 --- phpBB/includes/ucp/ucp_zebra.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index 2e3bada7bc..a669c450a4 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -199,8 +199,18 @@ 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_zebra_add', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.ucp_add_zebra', compact($vars))); $db->sql_multi_insert(ZEBRA_TABLE, $sql_ary); From 6571ea1fc8fa636cb418344f87cc7b010dd8f187 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 14:50:33 +0200 Subject: [PATCH 101/140] [feature/php-events] Remove event core.acp_profile_field_edit The currently implemented event is useless and we couldn't find a MOD, which requires editing this file in that position. PHPBB3-9550 --- phpBB/includes/acp/acp_profile.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index d84c4c2ed5..3ffffd3047 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -30,7 +30,6 @@ class acp_profile global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; global $request; - global $phpbb_dispatcher; include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); include($phpbb_root_path . 'includes/functions_user.' . $phpEx); @@ -877,9 +876,6 @@ class acp_profile } } - $vars = array('field_row', 'visibility_ary', 'exclude'); - extract($phpbb_dispatcher->trigger_event('core.acp_profile_field_edit', compact($vars))); - break; } From 5db76ee8b0e42cb9773f1b100c533af8ce666098 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 15:03:08 +0200 Subject: [PATCH 102/140] [feature/php-events] Move and fix event core.acp_users_display_overview The event had some invalid variables, so the event was moved to give it some more power. PHPBB3-9550 --- phpBB/includes/acp/acp_users.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index de1e9afc83..20d93ed525 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -946,12 +946,6 @@ class acp_users } } - $s_action_options = ''; - foreach ($quick_tool_ary as $value => $lang) - { - $s_action_options .= ''; - } - if ($config['load_onlinetrack']) { $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline @@ -966,6 +960,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 = ''; + foreach ($quick_tool_ary as $value => $lang) + { + $s_action_options .= ''; + } + $last_visit = (!empty($user_row['session_time'])) ? $user_row['session_time'] : $user_row['user_lastvisit']; $inactive_reason = ''; @@ -1040,9 +1051,6 @@ class acp_users 'USER_INACTIVE_REASON' => $inactive_reason, )); - $vars = array('data', 'check_ary', 'sql_ary', 'user_row', 'quick_tool_ary'); - extract($phpbb_dispatcher->trigger_event('core.acp_users_overview', compact($vars))); - break; case 'feedback': From be61bcb7b559d5804f4e6f666e55bf37cd199cb2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 15:27:08 +0200 Subject: [PATCH 103/140] [feature/php-events] Add core.acp_users_overview_modify_data This event was split from core.acp_users_display_overview to make it work as expected. PHPBB3-9550 --- phpBB/includes/acp/acp_users.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 20d93ed525..ae345b99cf 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -856,6 +856,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; From 171c07a0847f695a1c8e2f1f35784c453c47546a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 15:39:42 +0200 Subject: [PATCH 104/140] [feature/php-events] Add core.acp_users_overview_run_quicktool This event was split from core.acp_users_display_overview to make it work as expected. PHPBB3-9550 --- phpBB/includes/acp/acp_users.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index ae345b99cf..ceda41c764 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -750,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 From 1f9b23e721008ca2903b9b4e79008867554eddf4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 16:42:46 +0200 Subject: [PATCH 105/140] [feature/php-events] Add docs for core.page_header PHPBB3-9550 --- phpBB/includes/functions.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 442b125657..e39d5ee13e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4756,6 +4756,20 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // 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))); From 997075a008b594f62306184aeb9105d5180fdd6d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 16:46:57 +0200 Subject: [PATCH 106/140] [feature/php-events] Add docs for core.page_footer PHPBB3-9550 --- phpBB/includes/functions.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e39d5ee13e..43bdb757e5 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5080,12 +5080,20 @@ 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 $phpbb_dispatcher; + 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))); From e926ec9934348c1e2e556782edbb47630c58facc Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 16:51:51 +0200 Subject: [PATCH 107/140] [feature/php-events] Add docs for core.garbage_collection PHPBB3-9550 --- phpBB/includes/functions.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 43bdb757e5..949b66072b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5187,6 +5187,12 @@ 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 From 296ab5c168dfb324821c0ba965028be690745eb3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 21:17:29 +0200 Subject: [PATCH 108/140] [feature/php-events] Add docs for core.adm_page_header PHPBB3-9550 --- phpBB/includes/functions_acp.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index f59c8cd4c6..19f2873208 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -34,8 +34,18 @@ function adm_page_header($page_title) // 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; From a326dc10cf2aa6f0ec631cbb23625831002da2ff Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 21:24:33 +0200 Subject: [PATCH 109/140] [feature/php-events] Add docs for core.adm_page_footer PHPBB3-9550 --- phpBB/includes/functions_acp.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 19f2873208..8ee506377d 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -117,12 +117,20 @@ 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 $phpbb_dispatcher; + 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))); From 48a8482d23d7ab6fb0ef4c14f3d8464a78c14477 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 22:24:15 +0200 Subject: [PATCH 110/140] [feature/php-events] Fix docs and naming of core.build_config_template PHPBB3-9550 --- phpBB/includes/functions_acp.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 8ee506377d..23517f23aa 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -234,8 +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 $phpbb_dispatcher; + global $user, $module, $phpbb_dispatcher; $tpl = ''; $name = 'config[' . $config_key . ']'; @@ -347,8 +346,23 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars) $tpl .= $vars['append']; } - $vars = array('tpl_type', 'key', 'new', 'config_key', 'vars', 'tpl'); - extract($phpbb_dispatcher->trigger_event('core.build_cfg_template', compact($vars))); + /** + * 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; } From c28bd7cc609fecd6750ae0e7b4f1b4256f660818 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 23:09:44 +0200 Subject: [PATCH 111/140] [feature/php-events] Fix docs and naming of core.validate_config_variable PHPBB3-9550 --- phpBB/includes/functions_acp.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 23517f23aa..2f0188289b 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -373,8 +373,7 @@ 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_dispatcher; + global $phpbb_root_path, $user, $phpbb_dispatcher; $type = 0; $min = 1; @@ -552,8 +551,21 @@ 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_vars', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.validate_config_variable', compact($vars))); break; } } From 93912a2649eadae1e8cf0f3e24b0ddf7223316b3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 5 Aug 2012 23:11:36 +0200 Subject: [PATCH 112/140] [feature/php-events] Remove double space in comments PHPBB3-9550 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 949b66072b..ecec1e5e4a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4757,7 +4757,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $page_header_override = false; /** - * Execute code and/or overwrite page_header() + * Execute code and/or overwrite page_header() * * @event core.page_header * @var string page_title Page title @@ -5086,7 +5086,7 @@ function page_footer($run_cron = true) $page_footer_override = false; /** - * Execute code and/or overwrite page_footer() + * Execute code and/or overwrite page_footer() * * @event core.page_footer * @var bool run_cron Shall we run cron tasks From 3f710b58a5a7c371b8016c808a756616a77f4503 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 6 Aug 2012 15:37:02 +0200 Subject: [PATCH 113/140] [feature/php-events] Fix doc and naming of core.viewtopic_get_post_data PHPBB3-9550 --- phpBB/viewtopic.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index ce73001c78..22b1bd9dea 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -987,8 +987,15 @@ $sql_ary = array( AND u.user_id = p.poster_id', ); +/** +* Event to modify the SQL query before the post and poster data is queried +* +* @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_userdata', compact($vars))); +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); From ff12de97b72ef46a8bde5aca561e3cc18b7fa614 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 6 Aug 2012 16:12:17 +0200 Subject: [PATCH 114/140] [feature/php-events] Fix doc and naming of core.viewtopic_cache_guest_data PHPBB3-9550 --- phpBB/viewtopic.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 22b1bd9dea..1939d1f73b 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1108,8 +1108,17 @@ while ($row = $db->sql_fetchrow($result)) 'allow_pm' => 0, ); - $vars = array('user_cache_data', 'row', 'poster_id'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_user_cache_guest', compact($vars))); + /** + * Modify the guests user 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; From eb80d280b15ddb442f290c9722d394f63a9036e3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 6 Aug 2012 16:17:29 +0200 Subject: [PATCH 115/140] [feature/php-events] Fix doc and naming of core.viewtopic_cache_user_data PHPBB3-9550 --- phpBB/viewtopic.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 1939d1f73b..cad3789fd4 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1174,8 +1174,17 @@ while ($row = $db->sql_fetchrow($result)) 'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']), ); - $vars = array('user_cache_data', 'row', 'poster_id'); - extract($phpbb_dispatcher->trigger_event('core.viewtopic_user_cache', compact($vars))); + /** + * 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; From dcb4d3b92612faefc9c7b08c843be24f79d31c21 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 6 Aug 2012 16:42:13 +0200 Subject: [PATCH 116/140] [feature/php-events] Fix doc and naming of core.viewtopic_modify_post_row PHPBB3-9550 --- phpBB/viewtopic.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index cad3789fd4..0881fb3e48 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1609,8 +1609,18 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) $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_postrow', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars))); if (isset($cp_row['row']) && sizeof($cp_row['row'])) { From c277c240f83780b527511339068bd25d793712a9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 6 Aug 2012 17:05:22 +0200 Subject: [PATCH 117/140] [feature/php-events] Fix doc and naming of core.viewtopic_modify_page_title PHPBB3-9550 --- phpBB/viewtopic.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 0881fb3e48..43aacbff0c 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1784,8 +1784,18 @@ if (!request_var('t', 0) && !empty($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_page_header', compact($vars))); +extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars))); // Output the page page_header($page_title, true, $forum_id); From e3a9bf0376a9e4d6e9f5730e5118d11ce75296bd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 6 Aug 2012 17:43:46 +0200 Subject: [PATCH 118/140] [feature/php-events] Fix doc and naming of core.acp_forums_request_forum_data PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 6631edf438..564181be9e 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -150,8 +150,16 @@ 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_forums_request_forum_data', compact($vars))); + 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') From 38ba09e707c1fd97fe79d6b8165e1315346cbfef Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 12:01:09 +0200 Subject: [PATCH 119/140] [feature/php-events] Fix naming and doc of acp_manage_forums_initialise_data PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 564181be9e..54085d856b 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -397,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') { @@ -424,9 +427,6 @@ class acp_forums $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false); $forum_data['forum_password_confirm'] = $forum_data['forum_password']; - - $vars = array('forum_id', 'row', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_modify_forum_data', compact($vars))); } else { @@ -464,12 +464,27 @@ class acp_forums 'forum_password' => '', 'forum_password_confirm'=> '', ); - - $vars = array('forum_id', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_init_forum_data', compact($vars))); } } + /** + * 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, From 3beda0cbabe704b661e3d810db4c62a8d28a6bd6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 12:44:28 +0200 Subject: [PATCH 120/140] [feature/php-events] Fix naming and doc of core.acp_manage_forums_display_form PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 54085d856b..c9225744bf 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -681,8 +681,27 @@ class acp_forums '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, ); - $vars = array('forum_id', 'action', 'forum_data', 'template_data', 'old_forum_type', 'forum_desc_data', 'forum_rules_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_assign_template_forum_data', compact($vars))); + /** + * 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); From caf76b4cebccbfd7e348c89f7bce8d731fa2fd43 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 12:50:47 +0200 Subject: [PATCH 121/140] [feature/php-events] Fix naming and doc of core.acp_manage_forums_validate_data PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index c9225744bf..7af2fb822e 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -932,8 +932,17 @@ class acp_forums $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_forums_update_forum_data', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars))); if ($forum_data['forum_name'] == '') { From cfd5fcbe2609024f57c900435b02346d5c7e28e0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 12:58:20 +0200 Subject: [PATCH 122/140] [feature/php-events] Add new event core.acp_manage_forums_update_data_before Allows you to remove data from forum_data_sql before we update/create the forum PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 7af2fb822e..151e03f18f 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1036,7 +1036,25 @@ class acp_forums } unset($forum_data_sql['forum_password_unset']); - if (!isset($forum_data_sql['forum_id'])) + $is_new_forum = !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 + * @var bool is_new_forum Do we create a forum or update one + * If you want to overwrite this value, + * ensure to set forum_data_sql[forum_id] + * @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']); From 70c90bea4f8ba6cc0c4f34f2f55f8171f1b7ba87 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 13:06:20 +0200 Subject: [PATCH 123/140] [feature/php-events] Fix doc and naming of acp_manage_forums_update_data_after PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 151e03f18f..542c3ffd77 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1325,8 +1325,21 @@ class acp_forums add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']); } - $vars = array('forum_data', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_update_forum_data_after', compact($vars))); + /** + * 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; } From 43d17b2337eefa0530dea57516138eaf9724862b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 13:16:18 +0200 Subject: [PATCH 124/140] [feature/php-events] Fix doc and naming of core.acp_manage_forums_move_children PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 542c3ffd77..d6d8879f7b 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1353,9 +1353,6 @@ class acp_forums $to_data = $moved_ids = $errors = array(); - $vars = array('from_id', 'to_id'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_move_forum', compact($vars))); - // Check if we want to move to a parent with link type if ($to_id > 0) { @@ -1364,10 +1361,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; From cdcadf72c4d613e262a06589e7dfe4c81803344c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 13:20:34 +0200 Subject: [PATCH 125/140] [feature/php-events] Add event core.acp_manage_forums_move_content PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index d6d8879f7b..6fb246458c 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1464,7 +1464,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); From c362434890c075a5c04cfcd40f2809226e33c229 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 13:24:31 +0200 Subject: [PATCH 126/140] [feature/php-events] Fix typos in core.common docs block PHPBB3-9550 --- phpBB/common.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index e18c27abd1..cf990dbc3a 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -150,9 +150,9 @@ if (!$config['use_system_cron']) * 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 objec -* (f.e. to use language files) or need to check permissions, please use -* the core.user_setup event instead! +* 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 From 06c8e19af3544e0eb3462c24096c4db3da685d6b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 11 Aug 2012 11:49:48 +0200 Subject: [PATCH 127/140] [feature/php-events] Readd comment from d06adb06e907e31918130a6ef010b73d454f396c PHPBB3-9550 --- phpBB/mcp.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 730af65e3d..d04a297cf9 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -887,5 +887,7 @@ function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = fa return false; } + // If forum id is false and ids populated we may have only global announcements selected (returning 0 because of (int) $forum_id) + return ($single_forum === false) ? true : (int) $forum_id; } From 815e8ef9e173e24bd6d3d99321cc68e6d44f742b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 11 Aug 2012 15:25:14 +0200 Subject: [PATCH 128/140] [feature/php-events] Add mock for unit tests and create it were needed PHPBB3-9550 --- tests/functions_acp/build_cfg_template_test.php | 15 ++++++++++----- tests/mock/event_dispatcher.php | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 tests/mock/event_dispatcher.php diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php index 12121f6678..bf5330fd88 100644 --- a/tests/functions_acp/build_cfg_template_test.php +++ b/tests/functions_acp/build_cfg_template_test.php @@ -46,8 +46,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case */ public function test_build_cfg_template_text($tpl_type, $key, $new, $config_key, $vars, $expected) { - global $user; + global $user, $phpbb_dispatcher; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $user->lang = new phpbb_mock_lang(); $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); @@ -80,8 +81,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case */ public function test_build_cfg_template_dimension($tpl_type, $key, $new, $config_key, $vars, $expected) { - global $user; + global $user, $phpbb_dispatcher; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $user->lang = new phpbb_mock_lang(); $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); @@ -106,8 +108,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case */ public function test_build_cfg_template_textarea($tpl_type, $key, $new, $config_key, $vars, $expected) { - global $user; + global $user, $phpbb_dispatcher; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $user->lang = new phpbb_mock_lang(); $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); @@ -156,8 +159,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case */ public function test_build_cfg_template_radio($tpl_type, $key, $new, $config_key, $vars, $expected) { - global $user; + global $user, $phpbb_dispatcher; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $user->lang = new phpbb_mock_lang(); $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); @@ -182,8 +186,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case */ public function test_build_cfg_template_append($tpl_type, $key, $new, $config_key, $vars, $expected) { - global $user; + global $user, $phpbb_dispatcher; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $user->lang = new phpbb_mock_lang(); $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); diff --git a/tests/mock/event_dispatcher.php b/tests/mock/event_dispatcher.php new file mode 100644 index 0000000000..8887b16163 --- /dev/null +++ b/tests/mock/event_dispatcher.php @@ -0,0 +1,16 @@ + Date: Sat, 18 Aug 2012 20:25:11 +0200 Subject: [PATCH 129/140] [feature/php-events] Fix core.acp_manage_forums_update_data_after vars PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 6fb246458c..39bc7e39ad 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1338,7 +1338,7 @@ class acp_forums * language key. * @since 3.1-A1 */ - $vars = array('forum_data', 'forum_data_sql' 'is_new_forum', 'errors'); + $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; From 90ed6e734d7a8587e73fb0e37251982adc8d10ab Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 18 Aug 2012 20:28:14 +0200 Subject: [PATCH 130/140] [feature/php-events] Fix acp_manage_forums_update_data_before and is_new_forum PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 39bc7e39ad..c6dbf5eb9c 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1036,17 +1036,14 @@ class acp_forums } unset($forum_data_sql['forum_password_unset']); - $is_new_forum = !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 - * @var bool is_new_forum Do we create a forum or update one - * If you want to overwrite this value, - * ensure to set forum_data_sql[forum_id] + * 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'); From 6ad805713d4105372d4b4aabd8f2498662a10369 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 09:52:35 +0200 Subject: [PATCH 131/140] [feature/php-events] Fix doc of core.viewtopic_cache_guest_data PHPBB3-9550 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 43aacbff0c..1da962bbaa 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1109,7 +1109,7 @@ while ($row = $db->sql_fetchrow($result)) ); /** - * Modify the guests user data displayed with the posts + * 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 From 64bc658c044451c4808fac3bd5781196c604ac38 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 09:54:12 +0200 Subject: [PATCH 132/140] [feature/php-events] Fix doc of core.viewtopic_get_post_data PHPBB3-9550 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 1da962bbaa..c0dd800a99 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -988,7 +988,7 @@ $sql_ary = array( ); /** -* Event to modify the SQL query before the post and poster data is queried +* 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 From 7f156c9798ae56746176f3269930a340364b1ca8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:04:43 +0200 Subject: [PATCH 133/140] [feature/php-events] Fix doc and position of viewonline_overwrite_location PHPBB3-9550 --- phpBB/viewonline.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index 193fa61dd7..7d587978ed 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -334,22 +334,22 @@ while ($row = $db->sql_fetchrow($result)) default: $location = $user->lang['INDEX']; $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); - - /** - * Modify the location name and url which are displayed in the list - * - * @event core.viewonline_override_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_override_location', compact($vars))); break; } + /** + * Overwrite the location 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'], From f2c0b55665f815957fc773481511aceba2030f33 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:07:05 +0200 Subject: [PATCH 134/140] [feature/php-events] Fix doc of core.memberlist_prepare_profile_data PHPBB3-9550 --- phpBB/memberlist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index e1e4517643..f142d182bc 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1763,7 +1763,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f ); /** - * Preparing user's data before displaying it in profile and memberlist + * 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 From aea60f9323e8753535d0dbf5ffa1ffa09ff3c02e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:08:28 +0200 Subject: [PATCH 135/140] [feature/php-events] Fix doc of core.update_username PHPBB3-9550 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 733a6fd9bd..a561daa334 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -138,7 +138,7 @@ function user_update_name($old_name, $new_name) } /** - * Update username when it is changed + * Update a username when it is changed * * @event core.update_username * @var string old_name The old username that is replaced From 74d9ef0becb1558d12a7372ba68553421963ccbe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:08:59 +0200 Subject: [PATCH 136/140] [feature/php-events] Fix doc of core.delete_user_before PHPBB3-9550 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index a561daa334..1a75e96dd6 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -358,7 +358,7 @@ function user_delete($mode, $user_id, $post_username = false) } /** - * Event before an user is deleted + * Event before a user is deleted * * @event core.delete_user_before * @var string mode Mode of deletion (retain/delete posts) From 48b54ed1e0e5b354618fb92f9559b653e61fb530 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:09:29 +0200 Subject: [PATCH 137/140] [feature/php-events] Fix doc of core.delete_user_after PHPBB3-9550 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 1a75e96dd6..3de7b5d7c7 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -559,7 +559,7 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); /** - * Event after an user is deleted + * Event after a user is deleted * * @event core.delete_user_after * @var string mode Mode of deletion (retain/delete posts) From 01db8144d49e263a1cb36621090b54854b0f8bff Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:10:52 +0200 Subject: [PATCH 138/140] [feature/php-events] Fix doc of core.generate_smilies_after PHPBB3-9550 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 7ac56588af..1161dd8462 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -124,7 +124,7 @@ function generate_smilies($mode, $forum_id) } /** - * This event is called when the smilies got populated + * This event is called after the smilies are populated * * @event core.generate_smilies_after * @var string mode Mode of the smilies: window|inline From 365d95c1fee2b5e73dd16d0d741df6cc64956ed7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:11:52 +0200 Subject: [PATCH 139/140] [feature/php-events] Fix doc of core.user_set_default_group PHPBB3-9550 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 3de7b5d7c7..9e33a5122e 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3512,7 +3512,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } /** - * Event when the default group is set for an array of user + * 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 From b567175c8d49b774e48fe7cf632d96babb434076 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:15:04 +0200 Subject: [PATCH 140/140] [feature/php-events] Fix doc of core.viewonline_overwrite_location PHPBB3-9550 --- phpBB/viewonline.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index 7d587978ed..15884a41d8 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -338,7 +338,7 @@ while ($row = $db->sql_fetchrow($result)) } /** - * Overwrite the location name and URL, which are displayed in the list + * 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