From 05452b9ec0dab4fecfbca05fd5598af224d784de Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 3 Jul 2012 23:25:51 -0500 Subject: [PATCH 001/424] [ticket/8323] Do not allow sending of Private Messages to users who do not have permission to read private messages PHPBB3-8323 --- phpBB/includes/ucp/ucp_pm_compose.php | 20 ++++++++++++++++++++ phpBB/language/en/ucp.php | 1 + 2 files changed, 21 insertions(+) diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 1b474457b3..c6a44f6196 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1245,6 +1245,26 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove $error[] = $user->lang['PM_USERS_REMOVED_NO_PM']; } } + + // Check if users have permission to read PMs + // Only check if not a moderator or admin, since they are allowed to override this user setting + if (true)//!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + { + $can_read = $auth->acl_get_list(false, 'u_readpm'); + $can_read = (empty($can_read) || !isset($can_read[0]['u_readpm'])) ? array() : $can_read[0]['u_readpm']; + + $cannot_read_list = array_diff(array_keys($address_list['u']), $can_read); + + if (!empty($cannot_read_list)) + { + foreach ($cannot_read_list as $cannot_read) + { + unset($address_list['u'][$cannot_read]); + } + + $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; + } + } } } diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index e3971c75e2..8af828935b 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -367,6 +367,7 @@ $lang = array_merge($lang, array( 'PM_SENTBOX' => 'Sent messages', 'PM_SUBJECT' => 'Message subject', 'PM_TO' => 'Send to', + 'PM_USERS_REMOVED_NO_PERMISSION' => 'Some users couldn’t be added as they do not have permission to read private messages.', 'PM_USERS_REMOVED_NO_PM' => 'Some users couldn’t be added as they have disabled private message receipt.', 'POPUP_ON_PM' => 'Pop up window on new private message', 'POST_EDIT_PM' => 'Edit message', From c53d7f0b62abf222b159623ccc2c6ef6262f3137 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 3 Jul 2012 23:27:50 -0500 Subject: [PATCH 002/424] [ticket/8323] Remove code used for testing PHPBB3-8323 --- phpBB/includes/ucp/ucp_pm_compose.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index c6a44f6196..fe5b3b7a74 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1248,7 +1248,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove // Check if users have permission to read PMs // Only check if not a moderator or admin, since they are allowed to override this user setting - if (true)//!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) { $can_read = $auth->acl_get_list(false, 'u_readpm'); $can_read = (empty($can_read) || !isset($can_read[0]['u_readpm'])) ? array() : $can_read[0]['u_readpm']; From c38bb4254abec403add35378da67092c8513a3c4 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 3 Jul 2012 23:34:07 -0500 Subject: [PATCH 003/424] [ticket/8323] Do not allow sending of Private Messages to users who are banned PHPBB3-8323 --- phpBB/includes/ucp/ucp_pm_compose.php | 17 +++++++++++++++++ phpBB/language/en/ucp.php | 1 + 2 files changed, 18 insertions(+) diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index fe5b3b7a74..2ab6090533 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1265,6 +1265,23 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; } } + + // Check if users have permission to read PMs + // Only check if not a moderator or admin, since they are allowed to override this user setting + if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + { + $banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u'])); + + if (!empty($banned_user_list)) + { + foreach ($banned_user_list as $banned_user) + { + unset($address_list['u'][$banned_user]); + } + + $error[] = $user->lang['PM_USERS_REMOVED_BANNED']; + } + } } } diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 8af828935b..bc21b6b437 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -367,6 +367,7 @@ $lang = array_merge($lang, array( 'PM_SENTBOX' => 'Sent messages', 'PM_SUBJECT' => 'Message subject', 'PM_TO' => 'Send to', + 'PM_USERS_REMOVED_BANNED' => 'Some users couldn’t be added as they are banned.', 'PM_USERS_REMOVED_NO_PERMISSION' => 'Some users couldn’t be added as they do not have permission to read private messages.', 'PM_USERS_REMOVED_NO_PM' => 'Some users couldn’t be added as they have disabled private message receipt.', 'POPUP_ON_PM' => 'Pop up window on new private message', From e6d4e9bbb98feaee7a413967d6500163ebe7282c Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 3 Jul 2012 23:35:17 -0500 Subject: [PATCH 004/424] [ticket/8323] Correcting the comment PHPBB3-8323 --- phpBB/includes/ucp/ucp_pm_compose.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 2ab6090533..2a2ad48063 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1266,7 +1266,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove } } - // Check if users have permission to read PMs + // Check if users are banned // Only check if not a moderator or admin, since they are allowed to override this user setting if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) { From 6f4538c676ebd3b6e299a606a04f672698ebc487 Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 4 Jul 2012 10:34:09 -0500 Subject: [PATCH 005/424] [ticket/8323] Hide the Send PM link if users cannot receive the PM Updated memberlist/viewtopic to the new rules PHPBB3-8323 --- phpBB/memberlist.php | 10 +++++++++- phpBB/viewtopic.php | 14 +++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index ed87b6c448..8e2ce4d818 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1690,6 +1690,14 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f } } + if (!function_exists('phpbb_get_banned_user_ids')) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + + // Can this user receive a Private Message? + $can_receive_pm = ($data['user_type'] <> USER_IGNORE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($data['user_allow_pm'] && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(phpbb_get_banned_user_ids($user_id))))) ? true : false; + // Dump it out to the template return array( 'AGE' => $age, @@ -1719,7 +1727,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '', 'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '', 'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '', - 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '', + 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '', 'U_EMAIL' => $email, 'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '', 'U_SHORT_WWW' => (!empty($data['user_website'])) ? ((strlen($data['user_website']) > 55) ? substr($data['user_website'], 0, 39) . ' ... ' . substr($data['user_website'], -10) : $data['user_website']) : '', diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index b75f4aeccf..10ec6f4ee7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -16,6 +16,7 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/bbcode.' . $phpEx); +include($phpbb_root_path . 'includes/functions_user.' . $phpEx); // Start session management $user->session_begin(); @@ -1108,6 +1109,7 @@ while ($row = $db->sql_fetchrow($result)) $id_cache[] = $poster_id; $user_cache[$poster_id] = array( + 'user_type' => $row['user_type'], 'joined' => $user->format_date($row['user_regdate']), 'posts' => $row['user_posts'], 'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0, @@ -1315,6 +1317,13 @@ if ($bbcode_bitfield !== '') $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } +// Get the list of users who can receive private messages +$can_receive_pm_list = $auth->acl_get_list(array_keys($user_cache), 'u_readpm'); +$can_receive_pm_list = (empty($can_receive_pm_list) || !isset($can_receive_pm_list[0]['u_readpm'])) ? array() : $can_receive_pm_list[0]['u_readpm']; + +// Get the list of banned users +$banned_users = phpbb_get_banned_user_ids(array_keys($user_cache)); + $i_total = sizeof($rowset) - 1; $prev_post_id = ''; @@ -1487,6 +1496,9 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) !$row['post_edit_locked'] ))); + // Can this user receive a Private Message? + $can_receive_pm = ($user_cache[$poster_id]['user_type'] <> USER_IGNORE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($user_cache[$poster_id]['allow_pm'] && in_array($poster_id, $can_receive_pm_list) && !in_array($poster_id, $banned_users))) ? true : false; + // $postrow = 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']), @@ -1527,7 +1539,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_PROFILE' => $user_cache[$poster_id]['profile'], 'U_SEARCH' => $user_cache[$poster_id]['search'], - 'U_PM' => ($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']) : '', + 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']) : '', 'U_EMAIL' => $user_cache[$poster_id]['email'], 'U_WWW' => $user_cache[$poster_id]['www'], 'U_ICQ' => $user_cache[$poster_id]['icq'], From 0f4956b280468e8890b1c84df41d7bb1eb2447c5 Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 4 Jul 2012 20:52:07 -0500 Subject: [PATCH 006/424] [ticket/8323] Do not allow sending PMs to Inactive users PHPBB3-8323 --- phpBB/includes/ucp/ucp_pm_compose.php | 2 +- phpBB/memberlist.php | 2 +- phpBB/viewtopic.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 2a2ad48063..d7290070a5 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1194,7 +1194,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove if (sizeof($usernames)) { $user_id_ary = array(); - user_get_id_name($user_id_ary, $usernames, array(USER_NORMAL, USER_FOUNDER, USER_INACTIVE)); + user_get_id_name($user_id_ary, $usernames, array(USER_NORMAL, USER_FOUNDER)); // If there are users not existing, we will at least print a notice... if (!sizeof($user_id_ary)) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 8e2ce4d818..3e6b0a453f 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 } // Can this user receive a Private Message? - $can_receive_pm = ($data['user_type'] <> USER_IGNORE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($data['user_allow_pm'] && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(phpbb_get_banned_user_ids($user_id))))) ? true : false; + $can_receive_pm = ($data['user_type'] <> USER_IGNORE && $data['user_type'] <> USER_INACTIVE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($data['user_allow_pm'] && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(phpbb_get_banned_user_ids($user_id))))) ? true : false; // Dump it out to the template return array( diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 10ec6f4ee7..49ed785ec7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1497,7 +1497,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) ))); // Can this user receive a Private Message? - $can_receive_pm = ($user_cache[$poster_id]['user_type'] <> USER_IGNORE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($user_cache[$poster_id]['allow_pm'] && in_array($poster_id, $can_receive_pm_list) && !in_array($poster_id, $banned_users))) ? true : false; + $can_receive_pm = ($user_cache[$poster_id]['user_type'] <> USER_IGNORE && $user_cache[$poster_id]['user_type'] <> USER_INACTIVE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($user_cache[$poster_id]['allow_pm'] && in_array($poster_id, $can_receive_pm_list) && !in_array($poster_id, $banned_users))) ? true : false; // $postrow = array( From 362ba43f18c07c70855e72ebfaea222e04af1183 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 10 Jul 2012 09:58:10 -0500 Subject: [PATCH 007/424] [ticket/8323] Allow sending PMs to temporarily banned users Added an argument to the phpbb_get_banned_user_ids() function to allow specifying a banned end time (default true for current functionality, false for only permanent bans, timestamp to find banned until a specified time) PHPBB3-8323 --- phpBB/includes/functions_privmsgs.php | 23 ++++++++++++----------- phpBB/includes/functions_user.php | 26 +++++++++++++++++++++++--- phpBB/includes/ucp/ucp_pm_compose.php | 2 +- phpBB/memberlist.php | 2 +- phpBB/viewtopic.php | 4 ++-- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 8542e3ab0a..561ba19d10 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -269,46 +269,46 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id) case RULE_IS_LIKE: $result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0); break; - + case RULE_IS_NOT_LIKE: $result = !preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0); break; - + case RULE_IS: $result = ($check0 == $rule_row['rule_string']); break; - + case RULE_IS_NOT: $result = ($check0 != $rule_row['rule_string']); break; - + case RULE_BEGINS_WITH: $result = preg_match("/^" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0); break; - + case RULE_ENDS_WITH: $result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '$/i', $check0); break; - + case RULE_IS_FRIEND: case RULE_IS_FOE: case RULE_ANSWERED: case RULE_FORWARDED: $result = ($check0 == 1); break; - + case RULE_IS_USER: $result = ($check0 == $rule_row['rule_user_id']); break; - + case RULE_IS_GROUP: $result = in_array($rule_row['rule_group_id'], $check0); break; - + case RULE_TO_GROUP: $result = (in_array('g_' . $message_row[$check_ary['check2']], $check0) || in_array('g_' . $message_row[$check_ary['check2']], $message_row[$check_ary['check1']])); break; - + case RULE_TO_ME: $result = (in_array('u_' . $user_id, $check0) || in_array('u_' . $user_id, $message_row[$check_ary['check1']])); break; @@ -1828,11 +1828,12 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i return; } + // Get permanently banned users (do not allow sending to these users) if (!function_exists('phpbb_get_banned_user_ids')) { include($phpbb_root_path . 'includes/functions_user.' . $phpEx); } - $banned_users = phpbb_get_banned_user_ids(array_keys($recipients)); + $banned_users = phpbb_get_banned_user_ids(array_keys($recipients), false); $recipients = array_diff(array_keys($recipients), $banned_users); if (!sizeof($recipients)) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 9b102b7387..8533e47bc4 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3668,9 +3668,12 @@ function remove_newly_registered($user_id, $user_data = false) * * @param array $user_ids Array of users' ids to check for banning, * leave empty to get complete list of banned ids +* @param bool|int $ban_end Bool True to get users currently banned +* Bool False to only get permanently banned users +* Int Unix timestamp to get users banned until that time * @return array Array of banned users' ids if any, empty array otherwise */ -function phpbb_get_banned_user_ids($user_ids = array()) +function phpbb_get_banned_user_ids($user_ids = array(), $ban_end = true) { global $db; @@ -3682,9 +3685,26 @@ function phpbb_get_banned_user_ids($user_ids = array()) $sql = 'SELECT ban_userid FROM ' . BANLIST_TABLE . " WHERE $sql_user_ids - AND ban_exclude <> 1 - AND (ban_end > " . time() . ' + AND ban_exclude <> 1"; + + if ($ban_end === true) + { + // Banned currently + $sql .= " AND (ban_end > " . time() . ' OR ban_end = 0)'; + } + else if ($ban_end === false) + { + // Permanently banned + $sql .= " AND ban_end = 0"; + } + else + { + // Banned until a specified time + $sql .= " AND (ban_end > " . (int) $ban_end . ' + OR ban_end = 0)'; + } + $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index d7290070a5..e65b523cfb 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1270,7 +1270,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove // Only check if not a moderator or admin, since they are allowed to override this user setting if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) { - $banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u'])); + $banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u']), false); if (!empty($banned_user_list)) { diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 3e6b0a453f..c76d242df4 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 } // Can this user receive a Private Message? - $can_receive_pm = ($data['user_type'] <> USER_IGNORE && $data['user_type'] <> USER_INACTIVE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($data['user_allow_pm'] && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(phpbb_get_banned_user_ids($user_id))))) ? true : false; + $can_receive_pm = ($data['user_type'] <> USER_IGNORE && $data['user_type'] <> USER_INACTIVE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($data['user_allow_pm'] && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(phpbb_get_banned_user_ids($user_id, false))))) ? true : false; // Dump it out to the template return array( diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 49ed785ec7..362451fd83 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1321,8 +1321,8 @@ if ($bbcode_bitfield !== '') $can_receive_pm_list = $auth->acl_get_list(array_keys($user_cache), 'u_readpm'); $can_receive_pm_list = (empty($can_receive_pm_list) || !isset($can_receive_pm_list[0]['u_readpm'])) ? array() : $can_receive_pm_list[0]['u_readpm']; -// Get the list of banned users -$banned_users = phpbb_get_banned_user_ids(array_keys($user_cache)); +// Get the list of permanently banned users +$banned_users = phpbb_get_banned_user_ids(array_keys($user_cache), false); $i_total = sizeof($rowset) - 1; $prev_post_id = ''; From 07b9c1e2fdeeab5d394c0b166fb0a6488b049cd1 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 10 Jul 2012 10:05:39 -0500 Subject: [PATCH 008/424] [ticket/8323] Cleanup viewtopic code (not sure how this mess happened) PHPBB3-8323 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 362451fd83..779e6a8fa7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1497,7 +1497,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) ))); // Can this user receive a Private Message? - $can_receive_pm = ($user_cache[$poster_id]['user_type'] <> USER_IGNORE && $user_cache[$poster_id]['user_type'] <> USER_INACTIVE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($user_cache[$poster_id]['allow_pm'] && in_array($poster_id, $can_receive_pm_list) && !in_array($poster_id, $banned_users))) ? true : false; + $can_receive_pm = ($user_cache[$poster_id]['user_type'] <> USER_INACTIVE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($user_cache[$poster_id]['allow_pm'] && in_array($poster_id, $can_receive_pm_list) && !in_array($poster_id, $banned_users)))) ? true : false; // $postrow = array( From 33852e6251cf9eea29efde4aebdd64500b7e7c2b Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 10 Jul 2012 16:07:12 -0500 Subject: [PATCH 009/424] [ticket/8323] Correct PM notification settings (only notify those who can receive them) Also correcting the way it was setup for users to be able to receive PMs (do not allow administrators/moderators to send to banned, inactive, or non-standard users, that just doesn't make sense) PHPBB3-8323 --- phpBB/includes/functions_privmsgs.php | 12 ++++++--- phpBB/includes/ucp/ucp_pm_compose.php | 39 ++++++++++----------------- phpBB/memberlist.php | 8 +++++- phpBB/viewtopic.php | 10 +++++-- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 561ba19d10..55610a923e 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1828,7 +1828,7 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i return; } - // Get permanently banned users (do not allow sending to these users) + // Get permanently banned users (do not notify these users) if (!function_exists('phpbb_get_banned_user_ids')) { include($phpbb_root_path . 'includes/functions_user.' . $phpEx); @@ -1836,12 +1836,18 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i $banned_users = phpbb_get_banned_user_ids(array_keys($recipients), false); $recipients = array_diff(array_keys($recipients), $banned_users); + // Get the list of users who can read PMs (only notify those who can read PMs) + $can_read = $auth->acl_get_list($recipients, 'u_readpm'); + $can_read = (empty($can_read) || !isset($can_read[0]['u_readpm'])) ? array() : $can_read[0]['u_readpm']; + $recipients = array_intersect($recipients, $can_read); + if (!sizeof($recipients)) { return; } - $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber + // Get the list of users who want to receive notifications, are "normal" and not deactivated, and have a non-blank email address + $sql = 'SELECT user_id, username, user_type, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $recipients); $result = $db->sql_query($sql); @@ -1849,7 +1855,7 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i $msg_list_ary = array(); while ($row = $db->sql_fetchrow($result)) { - if ($row['user_notify_pm'] == 1 && trim($row['user_email'])) + if ($row['user_notify_pm'] == 1 && $row['user_type'] != USER_IGNORE && $row['user_type'] != USER_INACTIVE && trim($row['user_email'])) { $msg_list_ary[] = array( 'method' => $row['user_notify_type'], diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index e65b523cfb..8fc99818f4 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1247,40 +1247,29 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove } // Check if users have permission to read PMs - // Only check if not a moderator or admin, since they are allowed to override this user setting - if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + $can_read = $auth->acl_get_list(array_keys($address_list['u']), 'u_readpm'); + $can_read = (empty($can_read) || !isset($can_read[0]['u_readpm'])) ? array() : $can_read[0]['u_readpm']; + $cannot_read_list = array_diff(array_keys($address_list['u']), $can_read); + if (!empty($cannot_read_list)) { - $can_read = $auth->acl_get_list(false, 'u_readpm'); - $can_read = (empty($can_read) || !isset($can_read[0]['u_readpm'])) ? array() : $can_read[0]['u_readpm']; - - $cannot_read_list = array_diff(array_keys($address_list['u']), $can_read); - - if (!empty($cannot_read_list)) + foreach ($cannot_read_list as $cannot_read) { - foreach ($cannot_read_list as $cannot_read) - { - unset($address_list['u'][$cannot_read]); - } - - $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; + unset($address_list['u'][$cannot_read]); } + + $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; } // Check if users are banned - // Only check if not a moderator or admin, since they are allowed to override this user setting - if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + $banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u']), false); + if (!empty($banned_user_list)) { - $banned_user_list = phpbb_get_banned_user_ids(array_keys($address_list['u']), false); - - if (!empty($banned_user_list)) + foreach ($banned_user_list as $banned_user) { - foreach ($banned_user_list as $banned_user) - { - unset($address_list['u'][$banned_user]); - } - - $error[] = $user->lang['PM_USERS_REMOVED_BANNED']; + unset($address_list['u'][$banned_user]); } + + $error[] = $user->lang['PM_USERS_REMOVED_BANNED']; } } } diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index c76d242df4..f468d8543a 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1696,7 +1696,13 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f } // Can this user receive a Private Message? - $can_receive_pm = ($data['user_type'] <> USER_IGNORE && $data['user_type'] <> USER_INACTIVE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($data['user_allow_pm'] && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(phpbb_get_banned_user_ids($user_id, false))))) ? true : false; + $can_receive_pm = ( + $data['user_type'] != USER_IGNORE && // They must be a "normal" user + $data['user_type'] != USER_INACTIVE && // They must not be deactivated by the administrator + sizeof($auth->acl_get_list($user_id, 'u_readpm')) && // They must be able to read PMs + !sizeof(phpbb_get_banned_user_ids($user_id, false)) && // They must not be permanently banned + (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) // They must allow users to contact via PM + ) ? true : false; // Dump it out to the template return array( diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 779e6a8fa7..e892689a1e 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1322,7 +1322,7 @@ $can_receive_pm_list = $auth->acl_get_list(array_keys($user_cache), 'u_readpm'); $can_receive_pm_list = (empty($can_receive_pm_list) || !isset($can_receive_pm_list[0]['u_readpm'])) ? array() : $can_receive_pm_list[0]['u_readpm']; // Get the list of permanently banned users -$banned_users = phpbb_get_banned_user_ids(array_keys($user_cache), false); +$permanently_banned_users = phpbb_get_banned_user_ids(array_keys($user_cache), false); $i_total = sizeof($rowset) - 1; $prev_post_id = ''; @@ -1497,7 +1497,13 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) ))); // Can this user receive a Private Message? - $can_receive_pm = ($user_cache[$poster_id]['user_type'] <> USER_INACTIVE && (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || ($user_cache[$poster_id]['allow_pm'] && in_array($poster_id, $can_receive_pm_list) && !in_array($poster_id, $banned_users)))) ? true : false; + $can_receive_pm = ( + $user_cache[$poster_id]['user_type'] != USER_IGNORE && // They must be a "normal" user + $user_cache[$poster_id]['user_type'] != USER_INACTIVE && // They must not be deactivated by the administrator + in_array($poster_id, $can_receive_pm_list) && // They must be able to read PMs + !in_array($poster_id, $permanently_banned_users) && // They must not be permanently banned + (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) // They must allow users to contact via PM + ) ? true : false; // $postrow = array( From 08bdebb0b578df7df7a3fb451691cb927854b84e Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 10 Jul 2012 16:38:07 -0500 Subject: [PATCH 010/424] [ticket/8323] Allow temporarily banned users to receive PMs, but not a notification PHPBB3-8323 --- phpBB/includes/functions_privmsgs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 55610a923e..99db8d816d 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1828,12 +1828,12 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i return; } - // Get permanently banned users (do not notify these users) + // Get currently banned users (do not notify these users) if (!function_exists('phpbb_get_banned_user_ids')) { include($phpbb_root_path . 'includes/functions_user.' . $phpEx); } - $banned_users = phpbb_get_banned_user_ids(array_keys($recipients), false); + $banned_users = phpbb_get_banned_user_ids(array_keys($recipients)); $recipients = array_diff(array_keys($recipients), $banned_users); // Get the list of users who can read PMs (only notify those who can read PMs) From b25efd744db56f7565453caccf26630404db07c7 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 10 Jul 2012 17:41:27 -0500 Subject: [PATCH 011/424] [ticket/8323] Only disable administrative deactivated accounts from receiving PMs Allow other types of inactive accounts to receive PMs. Remove the banned PM error message and use the string saying they do not have permission (less translation) PHPBB3-8323 --- phpBB/includes/functions_privmsgs.php | 4 ++-- phpBB/includes/ucp/ucp_pm_compose.php | 31 +++++++++++++++++++++++++-- phpBB/language/en/ucp.php | 1 - phpBB/memberlist.php | 2 +- phpBB/viewtopic.php | 6 ++++-- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 99db8d816d..f254014a5b 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1847,7 +1847,7 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i } // Get the list of users who want to receive notifications, are "normal" and not deactivated, and have a non-blank email address - $sql = 'SELECT user_id, username, user_type, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber + $sql = 'SELECT user_id, username, user_type, user_inactive_reason, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $recipients); $result = $db->sql_query($sql); @@ -1855,7 +1855,7 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i $msg_list_ary = array(); while ($row = $db->sql_fetchrow($result)) { - if ($row['user_notify_pm'] == 1 && $row['user_type'] != USER_IGNORE && $row['user_type'] != USER_INACTIVE && trim($row['user_email'])) + if ($row['user_notify_pm'] == 1 && $row['user_type'] != USER_IGNORE && !($row['user_type'] == USER_INACTIVE && $row['user_inactive_reason'] == INACTIVE_MANUAL) && trim($row['user_email'])) { $msg_list_ary[] = array( 'method' => $row['user_notify_type'], diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 8fc99818f4..0084184c65 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1194,7 +1194,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove if (sizeof($usernames)) { $user_id_ary = array(); - user_get_id_name($user_id_ary, $usernames, array(USER_NORMAL, USER_FOUNDER)); + user_get_id_name($user_id_ary, $usernames, array(USER_NORMAL, USER_FOUNDER, USER_INACTIVE)); // If there are users not existing, we will at least print a notice... if (!sizeof($user_id_ary)) @@ -1246,6 +1246,33 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove } } + // Administrator deactivated users check + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . ' + AND user_type = ' . USER_INACTIVE . ' + AND user_inactive_reason = ' . INACTIVE_MANUAL; + $result = $db->sql_query($sql); + + $removed = false; + while ($row = $db->sql_fetchrow($result)) + { + $removed = true; + unset($address_list['u'][$row['user_id']]); + } + $db->sql_freeresult($result); + + // print a notice about users not being added who do not want to receive pms + if ($removed) + { + $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; + } + + if (!sizeof(array_keys($address_list['u']))) + { + return; + } + // Check if users have permission to read PMs $can_read = $auth->acl_get_list(array_keys($address_list['u']), 'u_readpm'); $can_read = (empty($can_read) || !isset($can_read[0]['u_readpm'])) ? array() : $can_read[0]['u_readpm']; @@ -1269,7 +1296,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove unset($address_list['u'][$banned_user]); } - $error[] = $user->lang['PM_USERS_REMOVED_BANNED']; + $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; } } } diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index bc21b6b437..8af828935b 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -367,7 +367,6 @@ $lang = array_merge($lang, array( 'PM_SENTBOX' => 'Sent messages', 'PM_SUBJECT' => 'Message subject', 'PM_TO' => 'Send to', - 'PM_USERS_REMOVED_BANNED' => 'Some users couldn’t be added as they are banned.', 'PM_USERS_REMOVED_NO_PERMISSION' => 'Some users couldn’t be added as they do not have permission to read private messages.', 'PM_USERS_REMOVED_NO_PM' => 'Some users couldn’t be added as they have disabled private message receipt.', 'POPUP_ON_PM' => 'Pop up window on new private message', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index f468d8543a..a69afe36f3 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1698,7 +1698,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f // Can this user receive a Private Message? $can_receive_pm = ( $data['user_type'] != USER_IGNORE && // They must be a "normal" user - $data['user_type'] != USER_INACTIVE && // They must not be deactivated by the administrator + ($data['user_type'] != USER_INACTIVE && $data['user_inactive_reason'] == INACTIVE_MANUAL) && // They must not be deactivated by the administrator sizeof($auth->acl_get_list($user_id, 'u_readpm')) && // They must be able to read PMs !sizeof(phpbb_get_banned_user_ids($user_id, false)) && // They must not be permanently banned (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) // They must allow users to contact via PM diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index e892689a1e..4306ca2f3f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1109,7 +1109,9 @@ while ($row = $db->sql_fetchrow($result)) $id_cache[] = $poster_id; $user_cache[$poster_id] = array( - 'user_type' => $row['user_type'], + 'user_type' => $row['user_type'], + 'user_inactive_reason' => $row['user_inactive_reason'], + 'joined' => $user->format_date($row['user_regdate']), 'posts' => $row['user_posts'], 'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0, @@ -1499,7 +1501,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) // Can this user receive a Private Message? $can_receive_pm = ( $user_cache[$poster_id]['user_type'] != USER_IGNORE && // They must be a "normal" user - $user_cache[$poster_id]['user_type'] != USER_INACTIVE && // They must not be deactivated by the administrator + ($user_cache[$poster_id]['user_type'] != USER_INACTIVE && $user_cache[$poster_id]['user_inactive_reason'] == INACTIVE_MANUAL) && // They must not be deactivated by the administrator in_array($poster_id, $can_receive_pm_list) && // They must be able to read PMs !in_array($poster_id, $permanently_banned_users) && // They must not be permanently banned (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) // They must allow users to contact via PM From 473a26a553c7b3e785634d23fe3de50e78aacf57 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 7 Dec 2012 18:17:53 -0600 Subject: [PATCH 012/424] [ticket/8323] Comments for inactive reasons in constants.php Copied from language output PHPBB3-8323 --- phpBB/includes/constants.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 68af41ab20..78c4051708 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -46,10 +46,10 @@ define('USER_INACTIVE', 1); define('USER_IGNORE', 2); define('USER_FOUNDER', 3); -define('INACTIVE_REGISTER', 1); -define('INACTIVE_PROFILE', 2); -define('INACTIVE_MANUAL', 3); -define('INACTIVE_REMIND', 4); +define('INACTIVE_REGISTER', 1); // Newly registered account +define('INACTIVE_PROFILE', 2); // Profile details changed +define('INACTIVE_MANUAL', 3); // Account deactivated by administrator +define('INACTIVE_REMIND', 4); // Forced user account reactivation // ACL define('ACL_NEVER', 0); From 8e6a69bf0c936d658deeb3714bc2d38b4b8750c8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 7 Dec 2012 18:50:22 -0600 Subject: [PATCH 013/424] [ticket/8323] Unit test for phpbb_get_banned_user_ids PHPBB3-8323 --- tests/functions/fixtures/banned_users.xml | 33 +++++++++++++++++++ tests/functions/phpbb_get_banned_user_ids.php | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 tests/functions/fixtures/banned_users.xml create mode 100644 tests/functions/phpbb_get_banned_user_ids.php diff --git a/tests/functions/fixtures/banned_users.xml b/tests/functions/fixtures/banned_users.xml new file mode 100644 index 0000000000..42b73dd270 --- /dev/null +++ b/tests/functions/fixtures/banned_users.xml @@ -0,0 +1,33 @@ + + + + ban_userid + ban_exclude + ban_end + + 1 + 1 + 0 + + + 2 + 0 + 0 + + + 3 + 0 + 0 + + + 4 + 0 + 2 + + + 5 + 0 + 999999999999999999999 + +
+
diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php new file mode 100644 index 0000000000..226012f68f --- /dev/null +++ b/tests/functions/phpbb_get_banned_user_ids.php @@ -0,0 +1,33 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/banned_users.xml'); + } + + public function test_phpbb_get_banned_user_ids() + { + global $db; + + $db = $this->new_dbal(); + + $user_ids = array(1, 2, 4, 5); + + $this->assertEquals(phpbb_get_banned_user_ids($user_ids, true), array(2 => 2, 5 => 5)); + + $this->assertEquals(phpbb_get_banned_user_ids($user_ids, false), array(2 => 2)); + + $this->assertEquals(phpbb_get_banned_user_ids($user_ids, 2), array(2 => 2, 5 => 5)); + } +} From 4ab07aa45ebdf568a252821edf0837e17f1d9f20 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 7 Dec 2012 18:51:06 -0600 Subject: [PATCH 014/424] [ticket/8323] Comments PHPBB3-8323 --- phpBB/includes/ucp/ucp_pm_compose.php | 2 +- phpBB/viewtopic.php | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index f6192a3588..3e7ed05fdc 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1263,7 +1263,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove } $db->sql_freeresult($result); - // print a notice about users not being added who do not want to receive pms + // print a notice about users not being added who do not have permission to receive PMs if ($removed) { $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 90cb7e9567..f209f61442 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1553,12 +1553,21 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) // Can this user receive a Private Message? $can_receive_pm = ( - $user_cache[$poster_id]['user_type'] != USER_IGNORE && // They must be a "normal" user - ($user_cache[$poster_id]['user_type'] != USER_INACTIVE && $user_cache[$poster_id]['user_inactive_reason'] == INACTIVE_MANUAL) && // They must not be deactivated by the administrator - in_array($poster_id, $can_receive_pm_list) && // They must be able to read PMs - !in_array($poster_id, $permanently_banned_users) && // They must not be permanently banned - (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) // They must allow users to contact via PM - ) ? true : false; + // They must be a "normal" user + $user_cache[$poster_id]['user_type'] != USER_IGNORE && + + // They must not be deactivated by the administrator + ($user_cache[$poster_id]['user_type'] != USER_INACTIVE && $user_cache[$poster_id]['user_inactive_reason'] == INACTIVE_MANUAL) && + + // They must be able to read PMs + in_array($poster_id, $can_receive_pm_list) && + + // They must not be permanently banned + !in_array($poster_id, $permanently_banned_users) && + + // They must allow users to contact via PM + (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) + ); // $post_row = array( From b3dae8fd61a10d82b5bb8e1626214789d3ac7b5c Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 7 Dec 2012 20:26:35 -0600 Subject: [PATCH 015/424] [ticket/8323] dataProvider for the test; better test data PHPBB3-8323 --- tests/functions/fixtures/banned_users.xml | 5 ++++ tests/functions/phpbb_get_banned_user_ids.php | 25 +++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/functions/fixtures/banned_users.xml b/tests/functions/fixtures/banned_users.xml index 42b73dd270..cec3f4e51f 100644 --- a/tests/functions/fixtures/banned_users.xml +++ b/tests/functions/fixtures/banned_users.xml @@ -29,5 +29,10 @@ 0 999999999999999999999 + + 6 + 0 + 3 + diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php index 226012f68f..9f56480235 100644 --- a/tests/functions/phpbb_get_banned_user_ids.php +++ b/tests/functions/phpbb_get_banned_user_ids.php @@ -16,18 +16,29 @@ class phpbb_get_banned_user_ids_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/banned_users.xml'); } - public function test_phpbb_get_banned_user_ids() + public function phpbb_get_banned_user_ids_data() + { + return array( + array(array(array(1, 2, 4, 5, 6), true), array(2 => 2, 5 => 5)), + array(array(array(1, 2, 4, 5, 6), false), array(2 => 2)), + array(array(array(1, 2, 4, 5, 6), 2), array(2 => 2, 5 => 5, 6 => 6)), + ); + } + + public function setUp() { global $db; $db = $this->new_dbal(); - $user_ids = array(1, 2, 4, 5); + return parent::setUp(); + } - $this->assertEquals(phpbb_get_banned_user_ids($user_ids, true), array(2 => 2, 5 => 5)); - - $this->assertEquals(phpbb_get_banned_user_ids($user_ids, false), array(2 => 2)); - - $this->assertEquals(phpbb_get_banned_user_ids($user_ids, 2), array(2 => 2, 5 => 5)); + /** + * @dataProvider phpbb_get_banned_user_ids_data + */ + public function test_phpbb_get_banned_user_ids($input, $expected) + { + $this->assertEquals($expected, call_user_func_array('phpbb_get_banned_user_ids', $input)); } } From e74f4ab6e439fe68a565586504d6376abaa4c253 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 7 Dec 2012 21:01:45 -0600 Subject: [PATCH 016/424] [ticket/8323] Comments PHPBB3-8323 --- phpBB/memberlist.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 1320a2c02e..870598726f 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1719,12 +1719,21 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f // Can this user receive a Private Message? $can_receive_pm = ( - $data['user_type'] != USER_IGNORE && // They must be a "normal" user - ($data['user_type'] != USER_INACTIVE && $data['user_inactive_reason'] == INACTIVE_MANUAL) && // They must not be deactivated by the administrator - sizeof($auth->acl_get_list($user_id, 'u_readpm')) && // They must be able to read PMs - !sizeof(phpbb_get_banned_user_ids($user_id, false)) && // They must not be permanently banned - (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) // They must allow users to contact via PM - ) ? true : false; + // They must be a "normal" user + $data['user_type'] != USER_IGNORE && + + // They must not be deactivated by the administrator + ($data['user_type'] != USER_INACTIVE && $data['user_inactive_reason'] == INACTIVE_MANUAL) && + + // They must be able to read PMs + sizeof($auth->acl_get_list($user_id, 'u_readpm')) && + + // They must not be permanently banned + !sizeof(phpbb_get_banned_user_ids($user_id, false)) && + + // They must allow users to contact via PM + (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) + ); // Dump it out to the template $template_data = array( From 12aa6b4b2cfda48f94c44865209f576654632b41 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 11 Dec 2012 11:24:18 -0600 Subject: [PATCH 017/424] [ticket/8323] More readability in test case PHPBB3-8323 --- tests/functions/phpbb_get_banned_user_ids.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php index 9f56480235..76c0204970 100644 --- a/tests/functions/phpbb_get_banned_user_ids.php +++ b/tests/functions/phpbb_get_banned_user_ids.php @@ -19,9 +19,20 @@ class phpbb_get_banned_user_ids_test extends phpbb_database_test_case public function phpbb_get_banned_user_ids_data() { return array( - array(array(array(1, 2, 4, 5, 6), true), array(2 => 2, 5 => 5)), - array(array(array(1, 2, 4, 5, 6), false), array(2 => 2)), - array(array(array(1, 2, 4, 5, 6), 2), array(2 => 2, 5 => 5, 6 => 6)), + // Input to phpbb_get_banned_user_ids (user_id list, ban_end) + // Expected output + array( + array(array(1, 2, 4, 5, 6), true), + array(2 => 2, 5 => 5), + ), + array( + array(array(1, 2, 4, 5, 6), false), + array(2 => 2), + ), + array( + array(array(1, 2, 4, 5, 6), 2), + array(2 => 2, 5 => 5, 6 => 6), + ), ); } From d68778e7ebd801d396a8ec8694499f2ebdbb809f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 13 Dec 2012 20:05:00 -0600 Subject: [PATCH 018/424] [ticket/8323] Comments on phpbb_get_banned_user_ids input for test PHPBB3-8323 --- tests/functions/phpbb_get_banned_user_ids.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php index 76c0204970..96de5c5767 100644 --- a/tests/functions/phpbb_get_banned_user_ids.php +++ b/tests/functions/phpbb_get_banned_user_ids.php @@ -22,14 +22,17 @@ class phpbb_get_banned_user_ids_test extends phpbb_database_test_case // Input to phpbb_get_banned_user_ids (user_id list, ban_end) // Expected output array( + // True to get users currently banned array(array(1, 2, 4, 5, 6), true), array(2 => 2, 5 => 5), ), array( + // False to only get permanently banned users array(array(1, 2, 4, 5, 6), false), array(2 => 2), ), array( + // Unix timestamp to get users banned until that time array(array(1, 2, 4, 5, 6), 2), array(2 => 2, 5 => 5, 6 => 6), ), From abaa53b0b295358efcf591587485c01a027cd5cb Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 1 May 2013 12:28:31 -0500 Subject: [PATCH 019/424] [ticket/8323] Combine into a single query PHPBB3-8323 --- phpBB/includes/ucp/ucp_pm_compose.php | 62 +++++++++++++-------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 3e7ed05fdc..75b17a4a01 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1222,49 +1222,47 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove // Check for disallowed recipients if (!empty($address_list['u'])) { - // We need to check their PM status (do they want to receive PM's?) - // Only check if not a moderator or admin, since they are allowed to override this user setting - if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . ' - AND user_allow_pm = 0'; - $result = $db->sql_query($sql); - - $removed = false; - while ($row = $db->sql_fetchrow($result)) - { - $removed = true; - unset($address_list['u'][$row['user_id']]); - } - $db->sql_freeresult($result); - - // print a notice about users not being added who do not want to receive pms - if ($removed) - { - $error[] = $user->lang['PM_USERS_REMOVED_NO_PM']; - } - } - - // Administrator deactivated users check - $sql = 'SELECT user_id + // Administrator deactivated users check and we need to check their + // PM status (do they want to receive PM's?) + // Only check PM status if not a moderator or admin, since they + // are allowed to override this user setting + $sql = 'SELECT user_id, user_allow_pm FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', array_keys($address_list['u'])) . ' - AND user_type = ' . USER_INACTIVE . ' - AND user_inactive_reason = ' . INACTIVE_MANUAL; + AND (user_type = ' . USER_INACTIVE . ' + AND user_inactive_reason = ' . INACTIVE_MANUAL . ')'; + + if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + { + $sql .= ' OR user_allow_pm = 0'; + } + $result = $db->sql_query($sql); - $removed = false; + $removed_no_pm = $removed_no_permission = false; while ($row = $db->sql_fetchrow($result)) { - $removed = true; + if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_') && !$row['user_allow_pm']) + { + $removed_no_pm = true; + } + else + { + $removed_no_permission = true; + } + unset($address_list['u'][$row['user_id']]); } $db->sql_freeresult($result); + // print a notice about users not being added who do not want to receive pms + if ($removed_no_pm) + { + $error[] = $user->lang['PM_USERS_REMOVED_NO_PM']; + } + // print a notice about users not being added who do not have permission to receive PMs - if ($removed) + if ($removed_no_permission) { $error[] = $user->lang['PM_USERS_REMOVED_NO_PERMISSION']; } From d14aed0819f2314ab0da1787aa7228025a6a024c Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 5 Sep 2013 13:59:24 -0500 Subject: [PATCH 020/424] [ticket/8323] Cache auth request PHPBB3-8323 --- phpBB/includes/ucp/ucp_pm_compose.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index a1b2bb61f9..9a6aa3f7a0 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1229,7 +1229,8 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove AND (user_type = ' . USER_INACTIVE . ' AND user_inactive_reason = ' . INACTIVE_MANUAL . ')'; - if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + $can_ignore_allow_pm = ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')); + if (!$can_ignore_allow_pm) { $sql .= ' OR user_allow_pm = 0'; } @@ -1239,7 +1240,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove $removed_no_pm = $removed_no_permission = false; while ($row = $db->sql_fetchrow($result)) { - if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_') && !$row['user_allow_pm']) + if (!$can_ignore_allow_pm && !$row['user_allow_pm']) { $removed_no_pm = true; } From 6c3f3ec893b6b5b90bf10016df297e6ba07dc85d Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 23 Sep 2013 14:10:21 +0200 Subject: [PATCH 021/424] [ticket/11860] htaccess: Support for Apache 2.4's "Require" syntax. PHPBB3-11860 --- phpBB/.htaccess | 56 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/phpBB/.htaccess b/phpBB/.htaccess index 474f9774c2..ad5e24d642 100644 --- a/phpBB/.htaccess +++ b/phpBB/.htaccess @@ -8,12 +8,50 @@ #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] # - -Order Allow,Deny -Deny from All - - - -Order Allow,Deny -Deny from All - +# With Apache 2.4 the "Order, Deny" syntax has been deprecated and moved from +# module mod_authz_host to a new module called mod_access_compat (which may be +# disabled) and a new "Require" syntax has been introduced to mod_authz_host. +# We could just conditionally provide both versions, but unfortunately Apache +# does not explicitly tell us its version if the module mod_version is not +# available. In this case, we check for the availability of module +# mod_authz_core (which should be on 2.4 or higher only) as a best guess. + + + + Order Allow,Deny + Deny from All + + + Order Allow,Deny + Deny from All + + + = 2.4> + + Require all denied + + + Require all denied + + + + + + + Order Allow,Deny + Deny from All + + + Order Allow,Deny + Deny from All + + + + + Require all denied + + + Require all denied + + + From ee89ede59faab3809cc61b7773a99f3e24376fb8 Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 2 Oct 2013 14:23:01 -0500 Subject: [PATCH 022/424] [ticket/11881] Timezone migration can take a long time PHPBB3-11881 --- phpBB/phpbb/db/migration/data/v310/timezone.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/db/migration/data/v310/timezone.php b/phpBB/phpbb/db/migration/data/v310/timezone.php index dd0c6a2093..8443f7b492 100644 --- a/phpBB/phpbb/db/migration/data/v310/timezone.php +++ b/phpBB/phpbb/db/migration/data/v310/timezone.php @@ -39,16 +39,22 @@ class timezone extends \phpbb\db\migration\migration ); } - public function update_timezones() + public function update_timezones($start) { + $start = (int) $start; + $limit = 1; + $converted_timezones = 0; + // Update user timezones $sql = 'SELECT user_dst, user_timezone FROM ' . $this->table_prefix . 'users GROUP BY user_timezone, user_dst'; - $result = $this->db->sql_query($sql); + $result = $this->db->sql_query_limit($sql, $limit, $start); while ($row = $this->db->sql_fetchrow($result)) { + $converted_timezones++; + $sql = 'UPDATE ' . $this->table_prefix . "users SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' @@ -57,6 +63,12 @@ class timezone extends \phpbb\db\migration\migration } $this->db->sql_freeresult($result); + if ($converted_timezones == $limit) + { + // There are still more to convert + return $start + $limit; + } + // Update board default timezone $sql = 'UPDATE ' . $this->table_prefix . "config SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "' From 9653276ebcd1a5c24302cb8d06f905f90e158e45 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 4 Oct 2013 12:10:27 -0500 Subject: [PATCH 023/424] [ticket/11881] Better split the timezone conversion into chunks; add test PHPBB3-11881 --- .../phpbb/db/migration/data/v310/timezone.php | 34 ++++--- tests/dbal/convert_timezones.php | 94 +++++++++++++++++++ tests/dbal/fixtures/convert_timezones.xml | 80 ++++++++++++++++ 3 files changed, 195 insertions(+), 13 deletions(-) create mode 100644 tests/dbal/convert_timezones.php create mode 100644 tests/dbal/fixtures/convert_timezones.xml diff --git a/phpBB/phpbb/db/migration/data/v310/timezone.php b/phpBB/phpbb/db/migration/data/v310/timezone.php index 8443f7b492..13e2a5ceb6 100644 --- a/phpBB/phpbb/db/migration/data/v310/timezone.php +++ b/phpBB/phpbb/db/migration/data/v310/timezone.php @@ -42,28 +42,36 @@ class timezone extends \phpbb\db\migration\migration public function update_timezones($start) { $start = (int) $start; - $limit = 1; - $converted_timezones = 0; + $limit = 5000; + $converted = 0; - // Update user timezones - $sql = 'SELECT user_dst, user_timezone + $update_blocks = array(); + + $sql = 'SELECT user_id, user_timezone, user_dst FROM ' . $this->table_prefix . 'users - GROUP BY user_timezone, user_dst'; + ORDER BY user_id ASC'; $result = $this->db->sql_query_limit($sql, $limit, $start); - while ($row = $this->db->sql_fetchrow($result)) { - $converted_timezones++; + $converted++; - $sql = 'UPDATE ' . $this->table_prefix . "users - SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' - WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' - AND user_dst = " . (int) $row['user_dst']; - $this->sql_query($sql); + $update_blocks[$row['user_timezone'] . ':' . $row['user_dst']][] = (int) $row['user_id']; } $this->db->sql_freeresult($result); - if ($converted_timezones == $limit) + // Update blocks of users who share the same timezone/dst + foreach ($update_blocks as $timezone => $user_ids) + { + $timezone = explode(':', $timezone); + $converted_timezone = $this->convert_phpbb30_timezone($timezone[0], $timezone[1]); + + $sql = 'UPDATE ' . $this->table_prefix . "users + SET user_timezone = '" . $this->db->sql_escape($converted_timezone) . "' + WHERE " . $this->db->sql_in_set('user_id', $user_ids); + $this->sql_query($sql); + } + + if ($converted == $limit) { // There are still more to convert return $start + $limit; diff --git a/tests/dbal/convert_timezones.php b/tests/dbal/convert_timezones.php new file mode 100644 index 0000000000..718b28b9ff --- /dev/null +++ b/tests/dbal/convert_timezones.php @@ -0,0 +1,94 @@ +db = $this->new_dbal(); + $db_tools = new \phpbb\db\tools($this->db); + + // user_dst doesn't exist anymore, must re-add it to test this + $db_tools->sql_column_add('phpbb_users', 'user_dst', array('BOOL', 1)); + + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/convert_timezones.xml'); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_dst', + ), + ), + ); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_dst' => array('BOOL', 0), + ), + ), + ); + } + + protected function setUp() + { + parent::setUp(); + + global $phpbb_root_path, $phpEx; + + $this->db = $this->new_dbal(); + + $this->migration = new \phpbb\db\migration\data\v310\timezone( + new \phpbb\config\config(array()), + $this->db, + new \phpbb\db\tools($this->db), + $phpbb_root_path, + $phpEx, + 'phpbb_' + ); + } + + protected $expected_results = array( + //user_id => user_timezone + 1 => 'Etc/GMT+12', + 2 => 'Etc/GMT+11', + 3 => 'Etc/GMT-3', + 4 => 'Etc/GMT-4', + 5 => 'America/St_Johns', + 6 => 'Australia/Eucla', + ); + + public function test_convert() + { + $this->migration->update_timezones(0); + + $sql = 'SELECT user_id, user_timezone + FROM phpbb_users + ORDER BY user_id ASC'; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $this->assertEquals($this->expected_results[$row['user_id']], $row['user_timezone']); + } + $this->db->sql_freeresult($result); + + $db_tools = new \phpbb\db\tools($this->db); + + // Remove the user_dst field again + $db_tools->sql_column_remove('phpbb_users', 'user_dst'); + } +} diff --git a/tests/dbal/fixtures/convert_timezones.xml b/tests/dbal/fixtures/convert_timezones.xml new file mode 100644 index 0000000000..ce941d8b74 --- /dev/null +++ b/tests/dbal/fixtures/convert_timezones.xml @@ -0,0 +1,80 @@ + + + + user_id + username + username_clean + user_permissions + user_sig + user_occ + user_interests + user_timezone + user_dst + + 1 + 1 + 1 + + + + + -12 + 0 + + + 2 + 2 + 2 + + + + + -12 + 1 + + + 3 + 3 + 3 + + + + + 3 + 0 + + + 4 + 4 + 4 + + + + + 3 + 1 + + + 5 + 5 + 5 + + + + + -3.5 + 0 + + + 6 + 6 + 6 + + + + + 8.75 + 0 + +
+
From cd7d29b90edcf292464beaf3ab814750703f3f17 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 4 Oct 2013 15:04:08 -0500 Subject: [PATCH 024/424] [ticket/11881] Make sure user_timezone isn't converted twice PHPBB3-11881 --- phpBB/phpbb/db/migration/data/v310/timezone.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/migration/data/v310/timezone.php b/phpBB/phpbb/db/migration/data/v310/timezone.php index 13e2a5ceb6..6106e179cb 100644 --- a/phpBB/phpbb/db/migration/data/v310/timezone.php +++ b/phpBB/phpbb/db/migration/data/v310/timezone.php @@ -55,7 +55,12 @@ class timezone extends \phpbb\db\migration\migration { $converted++; - $update_blocks[$row['user_timezone'] . ':' . $row['user_dst']][] = (int) $row['user_id']; + // In case this is somehow run twice on a row. + // Otherwise it would just end up as UTC on the second run + if (is_numeric($row['user_timezone'])) + { + $update_blocks[$row['user_timezone'] . ':' . $row['user_dst']][] = (int) $row['user_id']; + } } $this->db->sql_freeresult($result); From efe130bcfc84577294069641621f93f0d9801d99 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 4 Oct 2013 15:04:30 -0500 Subject: [PATCH 025/424] [ticket/11881] Limit to 500 PHPBB3-11881 --- phpBB/phpbb/db/migration/data/v310/timezone.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/migration/data/v310/timezone.php b/phpBB/phpbb/db/migration/data/v310/timezone.php index 6106e179cb..61f8dc488e 100644 --- a/phpBB/phpbb/db/migration/data/v310/timezone.php +++ b/phpBB/phpbb/db/migration/data/v310/timezone.php @@ -42,7 +42,7 @@ class timezone extends \phpbb\db\migration\migration public function update_timezones($start) { $start = (int) $start; - $limit = 5000; + $limit = 500; $converted = 0; $update_blocks = array(); From c6491c9078c4dac365227550c7daa5f8eab01aad Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 30 Dec 2013 14:27:13 -0600 Subject: [PATCH 026/424] [ticket/11881] Fix test filename PHPBB3-11881 --- tests/dbal/{convert_timezones.php => convert_timezones_test.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/dbal/{convert_timezones.php => convert_timezones_test.php} (100%) diff --git a/tests/dbal/convert_timezones.php b/tests/dbal/convert_timezones_test.php similarity index 100% rename from tests/dbal/convert_timezones.php rename to tests/dbal/convert_timezones_test.php From 8ebf5bb8d1070b214ba3bc7a900da46283ebb510 Mon Sep 17 00:00:00 2001 From: marc1706 Date: Fri, 3 Jan 2014 13:30:52 +0100 Subject: [PATCH 027/424] [ticket/12071] Skip tests that depend on fileinfo and fix expected results Tests that depend on fileinfo being enabled will now be skipped to prevent fatal errors while running the test suite. The expected results will be modified to "application/octet-stream" in test_guess_files() if only the extension_guesser is available due to the non-existing extension of those files. PHPBB3-12071 --- tests/mimetype/guesser_test.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index 9f0371262b..244293020f 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -19,7 +19,9 @@ function function_exists($name) class guesser_test extends \phpbb_test_case { - public static $function_exists = true; + public static $function_exists = false; + + protected $fileinfo_supported = false; public function setUp() { @@ -28,7 +30,13 @@ class guesser_test extends \phpbb_test_case $guessers = array( new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), + new \phpbb\mimetype\extension_guesser, + new \phpbb\mimetype\content_guesser, ); + + // Check if any guesser except the extension_guesser is available + $this->fileinfo_supported = (bool) $guessers[0]->isSupported() | $guessers[1]->isSupported() | $guessers[3]->is_supported(); + $this->guesser = new \phpbb\mimetype\guesser($guessers); $this->path = dirname(__FILE__); $this->jpg_file = $this->path . '/fixtures/jpg'; @@ -52,6 +60,12 @@ class guesser_test extends \phpbb_test_case */ public function test_guess_files($expected, $file) { + // We will always get application/octet-stream as mimetype if only the + // extension guesser is supported + if ($expected && !$this->fileinfo_supported) + { + $expected = 'application/octet-stream'; + } $this->assertEquals($expected, $this->guesser->guess($this->path . '/../upload/fixture/' . $file)); } @@ -130,6 +144,11 @@ class guesser_test extends \phpbb_test_case $supported = false; self::$function_exists = !$overload; + if (!\function_exists('mime_content_type')) + { + $this->markTestSkipped('Emulating supported mime_content_type() when it is not supported will cause a fatal error'); + } + // Cover possible LogicExceptions foreach ($guessers as $cur_guesser) { From f111a9262fdca8668e57e3cc4230107e75d957a7 Mon Sep 17 00:00:00 2001 From: marc1706 Date: Fri, 3 Jan 2014 13:45:38 +0100 Subject: [PATCH 028/424] [ticket/12071] Get rid of unneeded cast to boolean in tests PHPBB3-12071 --- tests/mimetype/guesser_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index 244293020f..a211b99147 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -35,7 +35,7 @@ class guesser_test extends \phpbb_test_case ); // Check if any guesser except the extension_guesser is available - $this->fileinfo_supported = (bool) $guessers[0]->isSupported() | $guessers[1]->isSupported() | $guessers[3]->is_supported(); + $this->fileinfo_supported = $guessers[0]->isSupported() | $guessers[1]->isSupported() | $guessers[3]->is_supported(); $this->guesser = new \phpbb\mimetype\guesser($guessers); $this->path = dirname(__FILE__); From 98aebabd73e0be202f91a31f3f689a8bccd01079 Mon Sep 17 00:00:00 2001 From: marc1706 Date: Fri, 3 Jan 2014 16:40:12 +0100 Subject: [PATCH 029/424] [ticket/12071] Add test that covers not available fileinfo The newly added test case will also emulate a non-existing fileinfo in order to check if the mimetype guesser is properly working when fileinfo is not available. PHPBB3-12071 --- tests/mimetype/guesser_test.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index a211b99147..7c58340a7a 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -37,6 +37,9 @@ class guesser_test extends \phpbb_test_case // Check if any guesser except the extension_guesser is available $this->fileinfo_supported = $guessers[0]->isSupported() | $guessers[1]->isSupported() | $guessers[3]->is_supported(); + // Also create a guesser that emulates not having fileinfo available + $this->guesser_no_fileinfo = new \phpbb\mimetype\guesser(array($guessers[2])); + $this->guesser = new \phpbb\mimetype\guesser($guessers); $this->path = dirname(__FILE__); $this->jpg_file = $this->path . '/fixtures/jpg'; @@ -62,13 +65,30 @@ class guesser_test extends \phpbb_test_case { // We will always get application/octet-stream as mimetype if only the // extension guesser is supported - if ($expected && !$this->fileinfo_supported) + if (!$this->fileinfo_supported) { - $expected = 'application/octet-stream'; + $this->markTestSkipped('Unable to run tests depending on fileinfo if it is not available'); } $this->assertEquals($expected, $this->guesser->guess($this->path . '/../upload/fixture/' . $file)); } + public function data_guess_files_no_fileinfo() + { + return array( + array('application/octet-stream', 'gif'), + array('application/octet-stream', 'txt'), + array(false, 'foobar'), + ); + } + + /** + * @dataProvider data_guess_files_no_fileinfo + */ + public function test_guess_files_no_fileinfo($expected, $file) + { + $this->assertEquals($expected, $this->guesser_no_fileinfo->guess($this->path . '/../upload/fixture/' . $file)); + } + public function test_file_not_readable() { @chmod($this->jpg_file, 0000); From 3384e87b6f1f6ba3532257585392a8b7e1034a18 Mon Sep 17 00:00:00 2001 From: PayBas Date: Sun, 6 Apr 2014 16:43:25 +0200 Subject: [PATCH 030/424] [ticket/12363] Mark winning (most votes) results bar PHPBB3-12363 --- phpBB/styles/prosilver/template/ajax.js | 2 ++ phpBB/styles/prosilver/template/viewtopic_body.html | 2 +- phpBB/styles/subsilver2/template/viewtopic_body.html | 2 +- phpBB/viewtopic.php | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index d2a070d11b..2a96c6090c 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -244,10 +244,12 @@ phpbb.addAjaxCallback('vote_poll', function(res) { var option = $(this); var option_id = option.attr('data-poll-option-id'); var voted = (typeof res.user_votes[option_id] !== 'undefined') ? true : false; + var winner = (res.vote_counts[option_id] == most_votes) ? true : false; var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[option_id] / res.total_votes) * 100); var percent_rel = (most_votes == 0) ? 0 : Math.round((res.vote_counts[option_id] / most_votes) * 100); option.toggleClass('voted', voted); + option.toggleClass('winner', winner); // Update the bars var bar = option.find('.resultbar div'); diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 4e3561c4a2..d01d50d07b 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -72,7 +72,7 @@
-
title="{L_POLL_VOTED_OPTION}" data-poll-option-id="{poll_option.POLL_OPTION_ID}"> +
title="{L_POLL_VOTED_OPTION}" data-poll-option-id="{poll_option.POLL_OPTION_ID}">
{poll_option.POLL_OPTION_CAPTION}
checked="checked" /> checked="checked" />
{poll_option.POLL_OPTION_RESULT}
diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index a5a50780fe..c348c25402 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -80,7 +80,7 @@ - + class="winner"> checked="checked" /> diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 1a74ad3e38..422ca1d12f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -864,6 +864,7 @@ if (!empty($topic_data['poll_start'])) $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100)); $option_pct_rel = ($poll_most > 0) ? $poll_option['poll_option_total'] / $poll_most : 0; $option_pct_rel_txt = sprintf("%.1d%%", round($option_pct_rel * 100)); + $option_winner = ($poll_option['poll_option_total'] > 0 && $poll_option['poll_option_total'] == $poll_most) ? true : false; $template->assign_block_vars('poll_option', array( 'POLL_OPTION_ID' => $poll_option['poll_option_id'], @@ -874,6 +875,7 @@ if (!empty($topic_data['poll_start'])) 'POLL_OPTION_PCT' => round($option_pct * 100), 'POLL_OPTION_WIDTH' => round($option_pct * 250), 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false, + 'POLL_OPTION_WINNER' => $option_winner, )); } From b64c5f84abf64a040b5d81b1ab7a214676039c19 Mon Sep 17 00:00:00 2001 From: PayBas Date: Sun, 6 Apr 2014 22:18:52 +0200 Subject: [PATCH 031/424] [ticket/12363] changed _winner_ to _most-votes_ PHPBB3-12363 --- phpBB/styles/prosilver/template/ajax.js | 4 ++-- phpBB/styles/prosilver/template/viewtopic_body.html | 2 +- phpBB/styles/subsilver2/template/viewtopic_body.html | 2 +- phpBB/viewtopic.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 2a96c6090c..97f7f7c9b4 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -244,12 +244,12 @@ phpbb.addAjaxCallback('vote_poll', function(res) { var option = $(this); var option_id = option.attr('data-poll-option-id'); var voted = (typeof res.user_votes[option_id] !== 'undefined') ? true : false; - var winner = (res.vote_counts[option_id] == most_votes) ? true : false; + var most_votes = (res.vote_counts[option_id] == most_votes) ? true : false; var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[option_id] / res.total_votes) * 100); var percent_rel = (most_votes == 0) ? 0 : Math.round((res.vote_counts[option_id] / most_votes) * 100); option.toggleClass('voted', voted); - option.toggleClass('winner', winner); + option.toggleClass('most-votes', most_votes); // Update the bars var bar = option.find('.resultbar div'); diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index d01d50d07b..649129923a 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -72,7 +72,7 @@
-
title="{L_POLL_VOTED_OPTION}" data-poll-option-id="{poll_option.POLL_OPTION_ID}"> +
title="{L_POLL_VOTED_OPTION}" data-poll-option-id="{poll_option.POLL_OPTION_ID}">
{poll_option.POLL_OPTION_CAPTION}
checked="checked" /> checked="checked" />
{poll_option.POLL_OPTION_RESULT}
diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index c348c25402..307ed0f391 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -80,7 +80,7 @@ - class="winner"> + class="most-votes"> checked="checked" /> diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 422ca1d12f..e7358d682d 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -864,7 +864,7 @@ if (!empty($topic_data['poll_start'])) $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100)); $option_pct_rel = ($poll_most > 0) ? $poll_option['poll_option_total'] / $poll_most : 0; $option_pct_rel_txt = sprintf("%.1d%%", round($option_pct_rel * 100)); - $option_winner = ($poll_option['poll_option_total'] > 0 && $poll_option['poll_option_total'] == $poll_most) ? true : false; + $option_most_votes = ($poll_option['poll_option_total'] > 0 && $poll_option['poll_option_total'] == $poll_most) ? true : false; $template->assign_block_vars('poll_option', array( 'POLL_OPTION_ID' => $poll_option['poll_option_id'], @@ -875,7 +875,7 @@ if (!empty($topic_data['poll_start'])) 'POLL_OPTION_PCT' => round($option_pct * 100), 'POLL_OPTION_WIDTH' => round($option_pct * 250), 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false, - 'POLL_OPTION_WINNER' => $option_winner, + 'POLL_OPTION_MOST_VOTES' => $option_most_votes, )); } From 41b0b8c5f92c77e406c8fc96c810749cf99b4409 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 6 Apr 2014 23:55:46 -0700 Subject: [PATCH 032/424] [ticket/12254] Better language switching on registration page PHPBB3-12254 --- phpBB/includes/ucp/ucp_register.php | 1 - phpBB/phpbb/user.php | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index ff51ca7b3c..f866e8ec26 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -65,7 +65,6 @@ class ucp_register } $user->lang_name = $user_lang = $use_lang; - $user->lang = array(); $user->data['user_lang'] = $user->lang_name; $user->add_lang(array('common', 'ucp')); } diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index b9b3896606..fceeb53946 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -80,7 +80,21 @@ class user extends \phpbb\session } else { - $user_lang_name = basename($config['default_lang']); + $change_lang = request_var('change_lang', ''); + if ($change_lang) + { + global $SID, $_EXTRA_URL; + + $use_lang = basename($change_lang); + $user_lang_name = (file_exists($this->lang_path . $use_lang . "/common.$phpEx")) ? $use_lang : basename($config['default_lang']); + $this->data['user_lang'] = $user_lang_name; + $SID .= '&change_lang=' . $user_lang_name; + $_EXTRA_URL[] = 'change_lang=' . $user_lang_name; + } + else + { + $user_lang_name = basename($config['default_lang']); + } $user_date_format = $config['default_dateformat']; $user_timezone = $config['board_timezone']; @@ -189,7 +203,7 @@ class user extends \phpbb\session $style_id = $style_request; $SID .= '&style=' . $style_id; - $_EXTRA_URL = array('style=' . $style_id); + $_EXTRA_URL[] = 'style=' . $style_id; } else { From a5940ede5bc8a7594b84fd4b489ada2110ecbdcc Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 7 Apr 2014 01:38:24 -0700 Subject: [PATCH 033/424] [ticket/12254] Stop using deprecated request_var in user class PHPBB3-12254 --- phpBB/phpbb/user.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index fceeb53946..d9ff75b997 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -69,7 +69,7 @@ class user extends \phpbb\session */ function setup($lang_set = false, $style_id = false) { - global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; + global $db, $request, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; global $phpbb_dispatcher; if ($this->data['user_id'] != ANONYMOUS) @@ -80,7 +80,7 @@ class user extends \phpbb\session } else { - $change_lang = request_var('change_lang', ''); + $change_lang = $request->variable('change_lang', ''); if ($change_lang) { global $SID, $_EXTRA_URL; @@ -196,7 +196,7 @@ class user extends \phpbb\session } unset($lang_set_ext); - $style_request = request_var('style', 0); + $style_request = $request->variable('style', 0); if ($style_request && (!$config['override_user_style'] || $auth->acl_get('a_styles')) && !defined('ADMIN_START')) { global $SID, $_EXTRA_URL; From daae87d65a20664af09a002f90483cc75e84d01f Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 7 Apr 2014 09:14:58 -0700 Subject: [PATCH 034/424] [ticket/12254] Use new set_lang var to avoid conflict with change_lang PHPBB3-12254 --- phpBB/includes/ucp/ucp_register.php | 6 +++--- phpBB/phpbb/user.php | 6 +++--- phpBB/styles/prosilver/template/ucp_agreement.html | 1 + phpBB/styles/prosilver/template/ucp_register.html | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index f866e8ec26..fe4eeec1ef 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -64,9 +64,7 @@ class ucp_register $agreed = false; } - $user->lang_name = $user_lang = $use_lang; - $user->data['user_lang'] = $user->lang_name; - $user->add_lang(array('common', 'ucp')); + $user_lang = $use_lang; } else { @@ -105,6 +103,7 @@ class ucp_register $s_hidden_fields = array_merge($s_hidden_fields, array( 'change_lang' => '', + 'set_lang' => $user_lang, )); // If we change the language, we want to pass on some more possible parameter. @@ -412,6 +411,7 @@ class ucp_register $s_hidden_fields = array_merge($s_hidden_fields, array( 'agreed' => 'true', 'change_lang' => 0, + 'set_lang' => $user_lang, )); if ($config['coppa_enable']) diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index d9ff75b997..36f72a69b9 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -80,7 +80,7 @@ class user extends \phpbb\session } else { - $change_lang = $request->variable('change_lang', ''); + $change_lang = $request->variable('set_lang', ''); if ($change_lang) { global $SID, $_EXTRA_URL; @@ -88,8 +88,8 @@ class user extends \phpbb\session $use_lang = basename($change_lang); $user_lang_name = (file_exists($this->lang_path . $use_lang . "/common.$phpEx")) ? $use_lang : basename($config['default_lang']); $this->data['user_lang'] = $user_lang_name; - $SID .= '&change_lang=' . $user_lang_name; - $_EXTRA_URL[] = 'change_lang=' . $user_lang_name; + $SID .= '&set_lang=' . $user_lang_name; + $_EXTRA_URL[] = 'set_lang=' . $user_lang_name; } else { diff --git a/phpBB/styles/prosilver/template/ucp_agreement.html b/phpBB/styles/prosilver/template/ucp_agreement.html index 6c96be864a..5fabd40f9d 100644 --- a/phpBB/styles/prosilver/template/ucp_agreement.html +++ b/phpBB/styles/prosilver/template/ucp_agreement.html @@ -11,6 +11,7 @@ function change_language(lang_iso) { document.forms['register'].change_lang.value = lang_iso; + document.forms['register'].set_lang.value = lang_iso; document.forms['register'].submit(); } diff --git a/phpBB/styles/prosilver/template/ucp_register.html b/phpBB/styles/prosilver/template/ucp_register.html index fc469eff36..22314babff 100644 --- a/phpBB/styles/prosilver/template/ucp_register.html +++ b/phpBB/styles/prosilver/template/ucp_register.html @@ -8,6 +8,7 @@ function change_language(lang_iso) { document.forms['register'].change_lang.value = lang_iso; + document.forms['register'].set_lang.value = lang_iso; document.forms['register'].submit.click(); } // ]]> From 8af9092cf677707d8c17554f833964d748be444b Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 7 Apr 2014 09:21:28 -0700 Subject: [PATCH 035/424] [ticket/12254] Add set_lang var changes to subsilver2 files PHPBB3-12254 --- phpBB/styles/subsilver2/template/ucp_agreement.html | 1 + phpBB/styles/subsilver2/template/ucp_register.html | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/styles/subsilver2/template/ucp_agreement.html b/phpBB/styles/subsilver2/template/ucp_agreement.html index 054d25282f..f2e904a66e 100644 --- a/phpBB/styles/subsilver2/template/ucp_agreement.html +++ b/phpBB/styles/subsilver2/template/ucp_agreement.html @@ -11,6 +11,7 @@ function change_language(lang_iso) { document.forms['register'].change_lang.value = lang_iso; + document.forms['register'].set_lang.value = lang_iso; document.forms['register'].submit(); } diff --git a/phpBB/styles/subsilver2/template/ucp_register.html b/phpBB/styles/subsilver2/template/ucp_register.html index 3392c557a2..4d429f1d10 100644 --- a/phpBB/styles/subsilver2/template/ucp_register.html +++ b/phpBB/styles/subsilver2/template/ucp_register.html @@ -8,6 +8,7 @@ function change_language(lang_iso) { document.forms['register'].change_lang.value = lang_iso; + document.forms['register'].set_lang.value = lang_iso; document.forms['register'].submit.click(); } From af6cabc1067b29850c1b037e878df2781e5c3de7 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 7 Apr 2014 13:58:47 -0700 Subject: [PATCH 036/424] [ticket/12254] Persist set_lang after reg only if changed from default PHPBB3-12254 --- phpBB/includes/ucp/ucp_register.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index fe4eeec1ef..b7f60304e1 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -103,7 +103,7 @@ class ucp_register $s_hidden_fields = array_merge($s_hidden_fields, array( 'change_lang' => '', - 'set_lang' => $user_lang, + 'set_lang' => ($user_lang != $config['default_lang']) ? $user_lang : '', )); // If we change the language, we want to pass on some more possible parameter. @@ -411,7 +411,7 @@ class ucp_register $s_hidden_fields = array_merge($s_hidden_fields, array( 'agreed' => 'true', 'change_lang' => 0, - 'set_lang' => $user_lang, + 'set_lang' => ($user_lang != $config['default_lang']) ? $user_lang : '', )); if ($config['coppa_enable']) From f1201a8ec5b5b65ebcb24cddda60ea29fb1c222f Mon Sep 17 00:00:00 2001 From: PayBas Date: Mon, 7 Apr 2014 23:39:49 +0200 Subject: [PATCH 037/424] [ticket/12363] Fix typo PHPBB3-12363 --- phpBB/styles/prosilver/template/ajax.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 97f7f7c9b4..4df38f4275 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -244,12 +244,12 @@ phpbb.addAjaxCallback('vote_poll', function(res) { var option = $(this); var option_id = option.attr('data-poll-option-id'); var voted = (typeof res.user_votes[option_id] !== 'undefined') ? true : false; - var most_votes = (res.vote_counts[option_id] == most_votes) ? true : false; + var most_voted = (res.vote_counts[option_id] == most_votes) ? true : false; var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[option_id] / res.total_votes) * 100); var percent_rel = (most_votes == 0) ? 0 : Math.round((res.vote_counts[option_id] / most_votes) * 100); option.toggleClass('voted', voted); - option.toggleClass('most-votes', most_votes); + option.toggleClass('most-votes', most_voted); // Update the bars var bar = option.find('.resultbar div'); From 09804bbae80c36989aba6631afca0dbdd3781f75 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 10 Apr 2014 16:06:00 +0200 Subject: [PATCH 038/424] [ticket/12382] Add template test for subloops inside events PHPBB3-12382 --- .../all/template/event/test_event_subloop.html | 2 ++ .../styles/silver/template/event_subloop.html | 3 +++ tests/template/template_events_test.php | 13 +++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/test_event_subloop.html create mode 100644 tests/template/datasets/ext_trivial/styles/silver/template/event_subloop.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/test_event_subloop.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/test_event_subloop.html new file mode 100644 index 0000000000..4fdba859f3 --- /dev/null +++ b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/test_event_subloop.html @@ -0,0 +1,2 @@ +[{event_loop.S_ROW_COUNT}[subloop:{event_loop.subloop.S_ROW_COUNT}] +] diff --git a/tests/template/datasets/ext_trivial/styles/silver/template/event_subloop.html b/tests/template/datasets/ext_trivial/styles/silver/template/event_subloop.html new file mode 100644 index 0000000000..233b32a4c7 --- /dev/null +++ b/tests/template/datasets/ext_trivial/styles/silver/template/event_subloop.html @@ -0,0 +1,3 @@ + +event_loop + diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index 41e00e86a7..4416dc4b2c 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -90,6 +90,19 @@ Zeta test event in all', array(), 'event_loop0|event_loop1|event_loop2', ), + array( + 'EVENT with subloop in loop', + 'ext_trivial', + array('silver'), + 'event_subloop.html', + array(), + array( + 'event_loop' => array(array()), + 'event_loop.subloop' => array(array()), + ), + array(), + 'event_loop[0[subloop:0]]', + ), ); } From 4abcdd9a18db75e4293ae08f7473f8f231829c44 Mon Sep 17 00:00:00 2001 From: PayBas Date: Fri, 11 Apr 2014 11:41:02 +0200 Subject: [PATCH 039/424] [ticket/12347] Changed to the new navbar templates PHPBB3-12347 --- phpBB/styles/prosilver/template/navbar_footer.html | 3 ++- phpBB/styles/prosilver/template/navbar_header.html | 7 ++++--- phpBB/styles/prosilver/theme/common.css | 12 ++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/phpBB/styles/prosilver/template/navbar_footer.html b/phpBB/styles/prosilver/template/navbar_footer.html index 32cbecdf8c..62631f5796 100644 --- a/phpBB/styles/prosilver/template/navbar_footer.html +++ b/phpBB/styles/prosilver/template/navbar_footer.html @@ -2,7 +2,8 @@
+ +
diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 4e3561c4a2..b528fc18a5 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -143,26 +143,54 @@ - - + + {% set CELL_BREAK = {1: 1, 2: 1, 3: 2, 4: 2, 5: 3, 6: 3, 7: 4, 8: 4, 9: 5, 10: 5, 11: 4, 12: 4, 13: 5, 14: 5, 16: 4} %} + {% set CONTACT_CNT = 0 %} + {% set CNT = 0 %} + {% set CONTACT_CNT = CONTACT_CNT + 1 %} + {% set CONTACT_CNT = CONTACT_CNT + 1 %} + {% set CONTACT_CNT = CONTACT_CNT + 1 %} + + {% set CONTACT_CNT = CONTACT_CNT + 1 %} + + {% set DIV_CNT = CELL_BREAK[CONTACT_CNT] %}{% set DIV_CNT = 4 %} +
- + {L_CONTACT_USER}{L_COLON} +
-
diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index 93c325e416..7f271ee648 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -235,20 +235,49 @@ ul.profile-icons.responsive a.responsive-menu-link:before { max-width: 40%; } +.contact-icons.dropdown-contents { + min-width: 0; + padding: 0; +} + +.contact-icon { + background-repeat: no-repeat; + display: block; + height: 16px; + width: 16px; +} +.contact-icons a { + border-bottom: 1px dotted; + border-right: 1px dotted; + display: block; + float: left; + padding: 8px; +} + +.contact-icons div:last-child a { + border-bottom: none; +} + +.contact-icons .last-cell { + border-right: none; +} + + /* Profile & navigation icons */ -.email-icon, .email-icon a { background: none top left no-repeat; } -.aim-icon, .aim-icon a { background: none top left no-repeat; } -.phpbb_aol-icon, .phpbb_aol-icon a { background: none top left no-repeat; } -.yahoo-icon, .yahoo-icon a { background: none top left no-repeat; } -.phpbb_yahoo-icon, .phpbb_yahoo-icon a { background: none top left no-repeat; } -.web-icon, .web-icon a { background: none top left no-repeat; } -.phpbb_website-icon, .phpbb_website-icon a { background: none top left no-repeat; } -.msnm-icon, .msnm-icon a { background: none top left no-repeat; } -.phpbb_wlm-icon, .phpbb_wlm-icon a { background: none top left no-repeat; } -.icq-icon, .icq-icon a { background: none top left no-repeat; } -.phpbb_icq-icon, .phpbb_icq-icon a { background: none top left no-repeat; } -.jabber-icon, .jabber-icon a { background: none top left no-repeat; } -.pm-icon, .pm-icon a { background: none top left no-repeat; } +.pm-icon { background-position: 0 0; } +.email-icon { background-position: -21px 0; } +.jabber-icon { background-position: -82px 0; } +.phpbb_icq-icon { background-position: -61px 0 ; } +.phpbb_wlm-icon { background-position: -182px 0; } +.phpbb_aol-icon { background-position: -245px 0; } +.phpbb_website-icon { background-position: -40px 0; } +.phpbb_youtube-icon { background-position: -98px 0; } +.phpbb_facebook-icon { background-position: -119px 0; } +.phpbb_google_plus-icon { background-position: -140px 0; } +.phpbb_skype-icon { background-position: -161px 0; } +.phpbb_twitter-icon { background-position: -203px 0; } +.phpbb_yahoo-icon { background-position: -224px 0; } + .quote-icon, .quote-icon a { background: none top left no-repeat; } /* Moderator icons */ diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 5f6ca4929c..bf47546b22 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -718,6 +718,14 @@ a.sendemail { background-image: url("images/buttons.png"); } +.contact-icons a { + border-color: #DCDCDC; +} + +.contact-icons a:hover { + background-color: #F2F6F9; +} + /* Icon images ---------------------------------------- */ .icon-faq { background-image: url("./images/icon_faq.gif"); } @@ -738,19 +746,8 @@ a.sendemail { .icon-mark { background-image: url("./images/icon_mark.gif"); } /* Profile & navigation icons */ -.email-icon, .email-icon a { background-image: url("./images/icon_contact_email.gif"); } -.phpbb_aol-icon, .phpbb_aol-icon a { background-image: url("./images/icon_contact_aim.gif"); } -.aim-icon, .aim-icon a { background-image: url("./images/icon_contact_aim.gif"); } -.yahoo-icon, .yahoo-icon a { background-image: url("./images/icon_contact_yahoo.gif"); } -.phpbb_yahoo-icon, .phpbb_yahoo-icon a { background-image: url("./images/icon_contact_yahoo.gif"); } -.web-icon, .web-icon a { background-image: url("./images/icon_contact_www.gif"); } -.phpbb_website-icon, .phpbb_website-icon a { background-image: url("./images/icon_contact_www.gif"); } -.msnm-icon, .msnm-icon a { background-image: url("./images/icon_contact_msnm.gif"); } -.phpbb_wlm-icon, .phpbb_wlm-icon a { background-image: url("./images/icon_contact_msnm.gif"); } -.icq-icon, .icq-icon a { background-image: url("./images/icon_contact_icq.gif"); } -.phpbb_icq-icon, .phpbb_icq-icon a { background-image: url("./images/icon_contact_icq.gif"); } -.jabber-icon, .jabber-icon a { background-image: url("./images/icon_contact_jabber.gif"); } -.pm-icon, .pm-icon a { background-image: url("./en/icon_contact_pm.gif"); } +.contact-icon { background-image: url("./images/icons_contact.png"); } + .quote-icon, .quote-icon a { background-image: url("./en/icon_post_quote.gif"); } ul.profile-icons.responsive a.responsive-menu-link { background-image: url("./images/icon_post_menu.png"); } diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index d27fb81fee..6d39e675ce 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -731,6 +731,10 @@ fieldset.polls dd div { height: auto !important; } +dd.profile-contact { + overflow: visible; +} + .online { background-image: none; background-position: 100% 0; diff --git a/phpBB/styles/prosilver/theme/en/stylesheet.css b/phpBB/styles/prosilver/theme/en/stylesheet.css index 82b7df0830..d8ca2558e5 100644 --- a/phpBB/styles/prosilver/theme/en/stylesheet.css +++ b/phpBB/styles/prosilver/theme/en/stylesheet.css @@ -7,16 +7,10 @@ ul.profile-icons li.edit-icon { width: 42px; height: 20px; } .online { background-image: url("./icon_user_online.gif"); } /* Icon images */ -.pm-icon, .pm-icon a { background-image: url("./icon_contact_pm.gif"); } .quote-icon, .quote-icon a { background-image: url("./icon_post_quote.gif"); } .edit-icon, .edit-icon a { background-image: url("./icon_post_edit.gif"); } /* EN Language Pack */ -.imageset.icon_contact_pm { - background-image: url("./icon_contact_pm.gif"); - padding-left: 28px; - padding-top: 20px; -} .imageset.icon_post_edit { background-image: url("./icon_post_edit.gif"); padding-left: 42px; diff --git a/phpBB/styles/prosilver/theme/images/icon_contact_aim.gif b/phpBB/styles/prosilver/theme/images/icon_contact_aim.gif deleted file mode 100644 index be039fcde28e1e6b73245800200bbdbb38a44e61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 546 zcmV+-0^R*bNk%w1VH5x;0K@&dJrZBht~$$j8Iv z?dT>Mgf2$7LAPp2T)}J9taDLjE)coTTulE2#$>-4;Bv|JY1b- zjisce2vDC%2T=hJxDT%#0S0iP4LotVx*ZJ-9R>jb2*(`{0mjG9($o;s4G-AV+uhzB zA}8V{A0Hm)=;`X{=I0t7@A2^S^6nb<_z)Ih4fy!>{va&a03bkx4*uSGP{6REg#;TM zH~=uAA;WVP8CFQ(fB}OH6)j@SXaNBRj~gPNWIP9hNaWZB?agN+wFcFgdnXoGXuDrkuKF#`q+03u8~N6dl%suutN(12h{o&a}^eF;E2+L*tZeFEC5`A1Aq$?5pZw}6oA|?=Y()D kAU3Xq$yp~;5ONO3i+!B`0ua#>Wt9O%FoWp)zr|@(9F5Gw70gh2@YEZ6}QQNy| zjd(`S&(F5Dw*UYCA^8LW0018VEC2ui02BZy000I5;Ma|0X_Deat!(R3*Z9uvSlxK8 zsAqqdynuYEx=>1_XN-5Lsyh0zr6p26`h9W^`);mrDi%dk_%-b!=ac1`rUFiF1s2 ztO5s{ryZsN2DP@gwE(6g5xu^@z`i36#Kp$P#Ul^P%+1cs$_Uca)YS+N9U>>&B_AIi z;Njxq;olw;=;`X~6X6o?@bU8S;1UTDartHYaSjO*;O-sZkbxk<3o!2pGn6*5Sa`O=~W z3_uMiKmZPb0-Y>1xV-2xC5LAe=qA6D-iXZiQX|r{Wc^zZ_tIJECAg;ldIXFi@<3!jZv8B1@he8QhM`I*QVu NLDU?%&*ee@06Y2#?CJmj diff --git a/phpBB/styles/prosilver/theme/images/icon_contact_icq.gif b/phpBB/styles/prosilver/theme/images/icon_contact_icq.gif deleted file mode 100644 index 48a09373ebb2fdf4404a8de6db6b8616ea895d0e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 562 zcmV-20?qwLNk%w1VH5x;0K@o z`-GjnyTs1{OalP_007zm0I2~62nOHZ+u7OH>+9+90m1+fPhw6h%-7#AJI2nHSk1DkZT2=O+%Q2vg9scV zK!6Zo!oqzXE=q{t;DJO34jNq0r%;|k421-*KyVPD0mugYCS1TM5JSrd92>ZNsB^%C ze=!3*c!^VDgrO`o0OgQ@BS@AOEF676k;6}U+&0{dV4*^VqBsp*z}i8=fCvBpMDXgg zV+0Cg31XOlRxMbUFEb33OCdl}2M}E1eBhD7UPBou^c_kOZ~y@TD8P^>NkRs^6bTbh z3}b@4ED|Uj4e7zJWYC|pNcQU?vEn66`Nk%w1VH5x;0OkMy?D6*6N zrFfvJcd@*5mzsBri+8-bbg8FulahD4wREK(cIkG*Voj>#>4;nHUIDz+s``w>O{!7O8ed-+s9wQzOUHV(#y)lcbx z;osZZ*weg}vXWf2mSMf8gwMaE|FcEjqe|AbhRU>)&!}|cAh3*m6%V!v0|U4V9xIEZ91_9|2zvpzyE@CUi_Oml0Mob) zG1rV76vC(m1i2AN;)@{}<_rnB3LWe{qdp!N5EH`%4I+5BmoEf|3J4b*aKORC2Py3s z9kIY7M2sCESRj$|3LiE`Ot@b;0D$89Hy| zbg8k�V0t!>oXj)yWDlXW+O|{v?HS5;DAyZc_dF@#J!Z$SCo=wTl*FvWi)uga{k$ z%7x4TKg0|kDokX>#0pDHaYh|!%#qs-G~l2{4o3hHL|8$r;6oBbaM6YuUZi2e7jbOy z5)dndwL%pw6j((bONekn6ezR+gJ@Nh=*J2`fT9EyO01B>9wMM11{F;(0R#|N9Z3aK z6?#pf!;dPc-~t#*_|O89e)yneC`n8K#11NmAjJ`2@X&*nS1qBYno58{r5G{90D}@r ktVtK0bSB~E9Zb03LKsQlxq}~8U4<1`h=yh8AAtY>J2fv0)c^nh diff --git a/phpBB/styles/prosilver/theme/images/icon_contact_msnm.gif b/phpBB/styles/prosilver/theme/images/icon_contact_msnm.gif deleted file mode 100644 index e25469c3a547aaaeebfc0a3823ec365171295357..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1466 zcmV;r1x5NtNk%w1VH5x;0QUd@00030|NrFU-{a!l&(F`x%Eq>~wqAs=Vv4p{e57WK zw{4TXbDG9%khpuJ&Ul{4f~nMLg{6I-#FM$>hpNzSh^2Fkr@`L-p0?1KuExvb{?zFI zX_CBekh6D}xS`1JsLuAKzuAeNw3e;Jm#e^(q_tUssEoGUldZ&@wal~4<)*mFtGUMH z^8Z_ry=aW9e4@dZyV|wc_=~2!p0UBd)#s_U!MVZ6D{-hwiMeB|;8&K#YNO3!jI5Ne z!^PwK%G>DB;OswyvrUr2U!l=pn80L~x=wVDgum#2xZjz_=%?2Bs=dm%$kVgE#Bs9R zY>}wO-tA?p)o!uaY_8Ic$m^4~%Z;$Zx#Rn=(&ewr+{@C|(AC&umaxX^{kq%irNPh3 zz+I^dnQJa0*-`v#M)?=Y|oU)?V z-q@+htK8q*+1%Nk&zp?Zht%WKY`$S|plVQ$MvcjYc*tpXv}$CRTZYDZkk)^a#e}Tn zox1a@ztOsIwp@nOaH#2(qT-Op(ZtZ@$%w~lx$2&((30NZ+~()yu+Mkh_NeFR<>2An z)##Ps;@#HXvFrG&;^ooA&w1tMkK*Fp@9*sE>*(p}=Huhw;o;xc*VW0%$Lr{v@#u)= z<=eZoeCOGQ)ys?S?dQF;iR0O;+uGIF*3s3}&(P1x%*)2)gVd|=HK4i+}qgK*3;J2((v!??Ca^^-`&5yy~M=Cy}iA< zy1KWwxBvhDA^8LW00930EC2ui02BZy000R80RIsfNU)$mf&z;TSje!U!vVzxKAh-K zBE>B#Vz8)4prIc-br5m+(Ez%^5w5GCWw&;l{#SvLxP$)Tfc5FKJ+0Xt6B`n;JpFd_ZtQLSe%MA_dBG=S>?t zJt#y0qQV1(2bdNP{FO-0nKpdxm~gN}Mu-$4Fl@PWOC^{*SLi^Y4FW=f1{Ai)>Wy=u zfMLT1EdcSsfr%p)ZmDkW&$e%PF9UqK6k=R6)cGx4bybeA{dj4JxFll8PsQAc4daJ6I4- zklW0s&6Kuu;)y4y%+f;+E|{>zIND%S&wSEE6Amw#d=g3~l~}<;5k@p|OEl-O!;b;b zn4^v_yVL^9D2!mS#~w250L?k?*x8Rc=q!WFF~}g(%OPIufyD_)P=d}n;ux?`I_kut z$tkeV(#taCY@);vNu0q>IM8^Py3RYVfO3i{uRtP)F3T|Uh#5R26Hcf8G@}kJoUFo1 zDv;=~1Rs_tcJ2F&A4JeG_yN-C2`F~=NJ2+@Tg&sd9XIN=Bo&pp5ZqsR_% z#6d+4IB)e# U@y8$wV2lCs-Dh%r{{#d8JNsN~L;wH) diff --git a/phpBB/styles/prosilver/theme/images/icon_contact_www.gif b/phpBB/styles/prosilver/theme/images/icon_contact_www.gif deleted file mode 100644 index 83cee9728d7cd0cad1ad53b0148266c353d614a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 590 zcmV-U0{ zs(6#OOk8o0sL6zmoZsvFey7=2Y=>ujmy5XUt} z;^E%U&(F5Dw*UYCA^8LW0018VEC2ui02BZy000I5;Ma|0X_8{bVc6QTZk&zWS|0|r zNK{g&Hd>8SpgfL`L13`3427H=GPzVLJT>8=VLVV25y@cekZ3p~RUy%M5F`?XVkt>T z9J5X)(?}>16cP~;0t{hr3}|`=4G4k}3KTj50}+M{c^L)?2@47cfRYUgf(#5ABN`SB zeVz#h1r4#Kn5i9|opK2itYD_6sTvLo#GVR$zNTiu7I1QKWtP7e8W+LQg0#OC)Fspo zmeRir+|?u27wH=kzXJ>s7U|aK^70!M`0@4g`~CeRB2J(~XX3*L4+s+~T$u3SLJJ!9 zNbF#N;RX*IHl%9+fq(!ApgLT*coE|U3mrJiN}4bsfJ*`eMwZN&lFLdZE&~u~(4l0! z4hkSpfG~j)fSd#n9JqkcLWTqg5EKOfK!5<30HP{5&@{sW0$?EspsHkmRRjV!Ak<($ zfz>erCUhJFU;tGNYukeLhyVgnv{vil^}zNMSOEke6kA|*?BFv|_X(tiZ!NvRtGU;)K)SaiYtgY)SPufswNo%@OdAx|A z$7qhg!_L;O#LwX1+vVlq+}zmN+11t6(aOrl?Ck2$&&tov$>QPM($USky0*EvwB+O8 z85D+M%XN+*5XWYrY(TV#v>NgShm#9NM4_aR z6YNf8zh}S|2?`W*2n%_9d{t=*4tsQRBNCF69d|I2bPp1dladp65t0}R3ly6j5*Voy z9)ODt9it5q7$X?B6@E-f2@Den3#qoZ7#0!~$SV{N9SXA*BNfuq)Ya1?7TMa{+}haP z;M*M{C*>s{A0F!K?CtC69vboU^7ZuW8u|MB{QBw{00Rmf7*O4W2yWbTAXv~t1Ooyh z3V=u;7O_nhGN{8qfWU!>1_)#bFrcJK0ul_GR*>{DBnOfpAsXOdaKZ!(5LyO!FhIb8 z0xciZv?(C~!~+8i{KU}n08J0uDnuY4@qiNuJqbYANDPAtnGIk(IAFko19hGD0Qh)d z0t5*c1{}z6K^-3m0ANlW5CB<8FzVbmSZkng;R8Db44|;pL&66E)D@Uq00V^q1szPH diff --git a/phpBB/styles/prosilver/theme/images/icons_contact.png b/phpBB/styles/prosilver/theme/images/icons_contact.png new file mode 100644 index 0000000000000000000000000000000000000000..f84abd36a5f8a25c190bba0e45b8550f52b077da GIT binary patch literal 8507 zcmV-BA;jK^P)z@;j(q!3lK=n!AY({UO#lFTa{vHh!is!8JT1m7?}JR82)Yh|Nq~8W=0l676$hE z|4jch82&M={=@jQ?ccwD-|?C8dEdUE*E46vykEQ4{_o$voQw<%e}VWHuf6?c$*QVF zd~R<0fXaRV@fRqjIk1VCmkgwOftZ~{tv`Xd_{fT+xwsVk`~Hpj%l@5Leq6pF`ThI} zhCgp#GcXH_F);J;G4Q$h{^Adf6(iNX6=y&GpML!t!>2$07}%K^8Qi4U8Ms&&8NLGf zN<1tKPLk|f-KE+6IhdLLB1az(53NLu1S}Y9{xdQ#-ulDvZw)IG!zBhr=DR=tvOZ&F zVEpl);q#Z1|2u!d)S7W-^D_V8mSOtCt?`fXcM#C)0muI}^OBa<855<%7^56>#ovGb8UFo) zg!O+=m;=TB|NF=A=kMP;fB*c+UfdqBi(UbjSig3XhJjhGxP~ml_pb~LUq5|eUkVc!h)+yhFnnB&8(M+f&VE5o0C`6N?0g2-9j2hd(y24>Di){g$PNiR({` zLh>I45pxEHd-E9?UhQUS|MTxx6+UxLGc!MC;^r0;jfvUGsj2ypftB^gzi;2Tz8*cQ z{bBQFBhjp^6|xg1bb`taAbv%s!T=ab3|xfN{Q+jSztA{l1BNFs!GM_GfQ11!)`H;c z7q(X&wLiJctiSO2hVcG+aM$)lL-C>izkV@D)OE+OYiKVe)vX~1-u+*D3s^=1Gd}|p zBP4tO`46GN+5JB#vKTDH*cj>zd6#)gb4HV5e&N1Y;lFSH{+krK?0xi%JOcG zA{nP|z5I6S$lFpAh21b{Wg8(`jJWBASRiQzxvUj}9dHlWv882$ofSpV|^>!p7TEdRL} zn1DwAWO&E$2Pl5*e*+^41%bVv6T^Wy?FvoL@P17;v*VP=A4d}thi5(=yZ@gG_k{QV0o%YOfPJ-;OcqXq~om^2ee zrD0SzKYv0K-ybjytU-~bXYH6*la9+H$xR!lYN#t@iRkKs(+eliGtVD>W9Tc%XLxr1 zK7)XWDA>I3Ks%zdvKjvW{*^bo+GjGM0J1i*PkSVOWTxxZe+(CZb?Ai>76z5{KMdA0 zAZhT`bq0nLp1ijtxfHZ6U%T`dmpPYYWe+MYT)2$a$>|VO=sy&*e!p@>`(9{holsod z2Fc3GDWHUbuK(-TFaLkcn9A^b?`~jj`^UiW=@TT(LE-)TH`pU#kFQ{?Ffk8RVt-8AJrRz`5?u!*>ine*Oj}oS(qL zfCHPpck`$H|FUm8gWTfHa63Qm-1Ou{OSv?UtqX%>+hj&kGV1gjUv_03dhg1>$_NQ` za3c8!tR$JhEd!9y7a*VE4VW`HEy zzu-UxW=2jOozu$e*O%Q54Q&$&4c*PIqJmKv{Mx;X;oDST*~J319OyR&CMM(}9h!T8 zBFY(1K>;i@eqFi*tgD0>cea^tn z#*9<%k4tBO1rsZZ7^k6`Ig5zclV6YSG5q`SotcS)^DnW9wD;OqS8%Ao8vHVoj-rPyZGTJ6T|y=Um4zf{>kv~&wrL5zyDi;8h8Yp3TheX0r5Uy#xDYu zGr$b~A6gKofEqYh^ne0N2wEs$W>9eb&&$BUC;%+A|1t1z2{M!}(`C4O_$b52SHFPS zjFEv?jFq8$g(btL?k5bqj9-BH?hgawe^8(E18L1KMqm%@4h>7G{Qj(Dcdx z5P%Y^32hn-!%xySNt?D%w_3XDCWumh5b=jy#*pqdEAFTVJqs!b!rXBOg@K43MRq9z zcTkH5H;{=84?+*4>ljrO99o6VwX<8(=C4hBlXOy9JM{1plJI?eU%uyke&ROm6CffW zl{wfOvhwpE9NFh$I9APULW`kQXcRP7zLj92Gbvd_@ak;_{b$c09B@&rFj3PSe3h#X zs3l24I-N!$k+8_1<6PZ-X1Z9^p($U`9o>i5&!5p|$j*{V?ukTES7dCgt$`!E5I@yV zgeHI`gnd?+Br4bzB^Z`(9Rbo9wsa!mbJ<1|Tozpnl4q z=MNv9v7ZHktJbbPksh=Xfl;e+rN)+cK1=3A){7G2G~5l${2@*y?Y1xas& zW()G5hh@xUFK?WS3UY{Ny^oe8=oBHw7q^nbF@g2E8Kcu$f8@(p5VJZTWbw1`3t?Ya zXO%|o#k-G}c&{6(tU%dVHrK@A{m=4lA9FkE}{3o=#!M8OK2paE8%%Cnysr=0o-3`s^tQyC8C5s+$dCpo~ZrxjZ?2U7~-9#aNzJ{OQfBg$E^_!UF7&^}|YnFk8q(nI5 z-#`DKJ$^Lx#>O5*0e#zpnL%|2ww4XZ{TqNd71k4j;$P5)H?Dwtj&mRum_+_D{soT_ z{0D|V2e8bao^XdDZ@C(SrUNfH1M0Z&Gfa-T#lXn{%3FVc-3FkZ|9?np6fiPsn`krC zR^~7;l(aH1T)WG_@Zc%9U|R!}%K*}%00G1TYI3oF+6q8gMvNC&F#kuiM4>Iz$1lHt z`z`;#Z3sx=!OF_S@Z$&WS_IS$02K(Jf?&sv9SjZ*4h%dzJn({G<;s-|zP`Q;-@bjr z>j@4v7Mm}hUo(9A_!d|?{$;rN@Girxi)R@mWaSv#Lt+_z19R=w^A{N|oj%L(;mu11 zegQ6qH(y^faB(s*u<>FaXk}yJD3*!+%phX|$*qoyfbs9iz;F!MQIVHpVBiNv>rO{d z`<{Wp<2VC@usX0%cmb?sfcYgVIttfJ0Jzn~@adv1!~Z|*3_MzofH?tF1bl!M4s0?q zFMr&)A&yP+uQ%_2aR8cwKvZ)7fMLU7VaXtvn8fgQ%VvfT3+6NYxqJnph7nQRGk*C_ za;xC`&p+@?fA#h&h8J(YF!1xRGqABTgX0$;;PVO;24?>MpSG=I_}5nTpF>^y@3%9@ znZ=6gmT{R{g9rA0KYnQNY5V%~|ADPG(7@vRMKeA#vU7YCPAd>VH!nkt`(57aUqY}V z_1(|^oFHZju&clhOn^sU|71A#_BVstnwQ|N4S3K9+K=1+;%5!M!r;=?P~VK`h$uEz z9>&M7pEF%~d@{>#(ktEoza%YDK^9;|@}2Rftc16A{Ip$H7iMi?c;v#(@b#YqQ0rDK z#%Tg^EVd+t)G9;=pd@x5cP<4D3;tyI%lH%AJqLEZ84j#?!VuOX%aAf%8Jr1U-TT3C zVCiE94h|NeJg}<{EO-8cx(bX;B=is%TKX#)glvH6+QAUm9|9($+YcDTe*9uszz@tO zz4I9U0R-U0>|UD&qcHxYX|^_L(PsUCDL6j|qSJlR3bO@WofmFb8w%bymTR0_bx8{$Cu2i5c2urIad_@_gUHxlL@4YzF1tH^ zWf+lc7OVFkz+711w&7PYuygxI9+6H$K;T^aSMez;*n`qDX-<^VQt3VtVn1c#3G@T(T8s(p+O-bO-ax z2BtpfSTo!PMSQoKIE0Uv`#r?&cEtO}jw_+C>D90r2n(WhtXB?=^bU1*pq)ferg2jV z^@w5UGw-ykqg|=cAVm9plULR1mSA`f;jPfN_&0X3`!D0JQ|l@t-rZ@5ej-Kc=Mp9hoXX{ zIopC15rfhQt+Z$>RE3zXvF$dAv)Nt0nT_Jlmg>O3!tMrfFc59n$Hvc*hw5 zmkpd9aKGSB3Go}O+Dg07{QoHdP(6#-RDQyScgF%vhl@2YkM=I9bwEb6d;rC zZfXg^u6QHo!_4H+^=t9_qbEj>Qio`y5L6nGfg3d(KH`3p=m&}>M2Dn`Az52%`!qIot~Hf<>U;i$nQZ*Rtq2!>N z8;DeOBvcC@q(!K;Ht3bT$Ss%fcC~=+*#155jrgtJ*vp%!NmE{3lJ2*Y50(e(hTG|S zBHXDwqIR3xgEN7FQ>9Am+~*T>$@gb|x{QxY2DoT{^<c2H zhM*jB9js?L0^A9pyMq!P{n?upSh?4D{#^h{ttYf;C=P#V(xh39tXrX)`6mYz)RQPE z>d~Dxy!0rFGCb*dH}SBOf*^>fsEBwH?KXGNli)!;coB5UpgZ(XyZ%{c+cjxllfL+S zNp&FYrVm2$LU=rW@8$b_-|u@0=iP$sFjH2#M4uG`gRr0>vcA`&tio;-^pO)lh|Sa? zEz6ionc6LERRs593u%`oOysu8Dg!*;Iur9#)ug(2bwkzWWF}q%{vDr{qY6bC};FIKG+QR?^UtO zq+ruhKYI!sy+wNV{6-NV`?95dz8t$MY|uVq%1{$^SQp=6_}DUv^Cw`YKL$Whsf=YO zCT^;!RB7k*bYBnNH@3qqRUj!FKPi`^Xny;S`lTsUXXl6wsG>L*!tZY|;5-1o|7rPR z14dkWxL7*q)7a5CwaehD_Ho+)fxz%OxvVoIH8+)7#u>upFS`te+7l#iV!l%Mm z_Uz=$>=xmx3!?UqKp<)b54QTK3rehTAp63}BRKF05ELIji%!7GeVM`Y1sHg=?3|w6 zAWpo$LGd>$II`cu%oVYZdy3rJO_G;n@AKDqLEYQEd9M5tfKjUnZ6XMxFG+Vd613YU zk|+&&h*&Ry9%`kBUc}OhS_GvP@!;R3SWxkxf`=mNLA;5A2P*|Bip4?|Jk&scgrb5} z549lnpshwLo2J>#Zen(Qlb`mIRTmz+!|V*qH{ZPPdwk=ytlTLxYiWkg&D2szY0F5b zRv2}4ScXnbl@W&?X4a&>&mzsXuA3rCYmQwwU5yMxyn2nSd17YGul5JBY; zM36`%To?1;O2<+j(p;^-RH;)GiKHb%rhZyjNW&pvNpzMKI`X$bVg%u38#?H96>IHqd(;(3{E5eYDW{nhx4>2&jumk*ejk+1W8~(y z8tr5tWo9t`C4h&EyD^PUWa&G50uwkHoj_cE4OO20aiq=>uf+9` zf0+9c|DXRWvC{hrqB`IhOi~T*DPbGP**atfL7D5f_-!Fw?l+4hkQXQ0<@PWMAV_Q{ z`dgbY_UtYq;cz*k5u543F9v{}aT)?w*w8~ zXJ-Xf!;GIKgt>j^wT7O7=7;}SXsj+ONrSWkF5LSF?oxdJ{vBLMz!n<83J6da0aPHI zK8<^d_s!@3(F(#WXFmS~Hj;q(jDrJWC8)K`$n=Nd>zCgQPoDo~U}Ixq;NS#yDS)M_ zAh0|9{wGH)E;E~2T5h&hRx?ch^^xJ&`_KQG9RD)9tz=-hIu+QD1UkiT83V)d6b6Pv zLBNtU6NrJ{xj2o1L6$+|HP%e>=MT@5l9J+|_wTET<>qex|5x)1!{^T;4|B3}gp-oC zO4iiOfX*sl4KF@VH-^`%*D^2y3uQ*oI16;T2|QK4h806-z5oQ(^g%8TGDX1J4uWX5Vk{iF|*Ztel zq_~HljpOh&6-(!(}h=pUDux7u;60mWO()dB`_WGf(Pkd{#Rgl^jnnS;Y%q7 z#jKCWI zJ1{dbLRtjC^bLxIKR|D>f(k&;7~NlBn)t^IjQ4+#>EHjLZUSib0eiEEo0H*$j{}2> zpCbc9IIz3R%+CN`2w&L+3~OGX!?J*Cfc3}HZU!E+P=-06)&sCG_y7<+u9R1jbV%*@QQT!Yi#D-eHx=E~8V|GzLwbezkF z7u2|)&FtDaM^2bA<>BkU3_lrxy?oFDDVARhpFVzPc=M5&fs301*p*=c)*^oyB>Da` zy#2&cTUf?;7tf4_Jk^Sre+nwgjPBa4K@YYr8ar@(?> z8g%;UH?}br5D@hAV32LBV|cf9JHwxkpBVoA`~@svfc?VXe}Ju@zmQr0SYtCXGcz!Q zrXV>u7?^=A2VoN<28rA(26};y8&)u|N=h>@ar0n=Et{g+3Kn7UB`iWBB%52N!^5-p z`HwGGUjAe_{QMV#{q{EukxHBlIs(9!ATZ-U{PK-q?Smf-r-1VC*#uxJ6veTqjX`bq zdtjINu~Ra=iQdHTTEg-wZ#2Vf*|W55vWW@(jn{aWRPh zW8O5?>)cWSj=%qLtUv^nx}e(B5IUtOh(+05P+bTt2sRKmpbKpL{|9FF|4iUD2h6}s z4_XNf>=-cc33Gr8>Yt#kEdN*_s}cW0rtU$l30&KXxHuVpECyzLRw)MXE|}ZEqOH6W z*lpj#09qmW^T`W_jLG%D?wK~Q6&%T+&^nU=H1InWAb>DB)%zD@opMZ=>IN!rmvzUS zf-a=^hp$#c2U}-XrsG;oNG_OO=AN3-we!1-2y^bc&%YVI{9*=Xe0E^-?;nF89~&@W z{s3D9-x-8~{ovPMS<+@zxXdPCc!0G!8xuG8AJB5nUymOPv#Y5+ zfieMZidHz5ITm3?Ei4WO%=F;UA&+3=}n=cW?Q?A|lGb z>+Ua1s%27K%wLz=3CZ~Hef#9zyWb3tKmB3oI`;`aYXBZ20kM(BR6qj;PLlYyUYN@o zodRJPKj+j2#>=lRi}7>(xBvg|ALp;n@BXv@`|{=H^@rzge*0K1P_+%;JS}KtoE8x4 zLl+;x^1~a@3@rm>F9K-5kc5RFpsB*2V3Qz&hs+F2|A2)8>wg9}={B%D7qDgc8=U$7 zf(DYnt%AS*e*;xx9}|21j^W1IT?{(kfOYVm<3L9pWVrtEGs8q+VKNiijd&|A!cbjX z4h#=qF))1vLncsc20#E|HEsWb>{CdKXMQ6srWsH$qs%=ozIo>iV1}Q=%KX#v&4)h> ze|~)i4=l2?Ffnj)3vGJ#nI(B)t=k)7&D1m0W!ZP-I(T>(RL4Bt&%h8C82RAg*6R{m z)?MHT)QY^$#Qtx0Q&aOZeCE7gv&QJp%a>xpadF3fJ$=gm@AGFCW-hMR%z}dNp$k%e zLr0;R=on;wsjXKyy+{yP(0zWtZ0?`$r;mMLQ`G-R~(P)pqgAv!(aGF?{*{2Wiq8Y2N}U3;z1Ypd`%3P^ZtwMT#9$asxoRBgk`t(Nbur>jN-H9Z z!D$XOMGETTp8^&H$Z=BFGM&NN$Bx0_4Y1e(HmKD>raLSodFDnT9OR2R-R>;y5ux?b^*3735ZLNtVo(Y zQ1N^1;~(3dPkwB@`{ge$Y`k#a^B)ZNfGq~lDnu7ac7_^5URiB^)+Y=@7+5mZeE!4m zc|WjMewdYo@eU))|Le!UPq=|itrcgX`kz04wf_BKQekBLZ_CWU<9Om_KJLTc^v=%002ovPDHLkV1nvOJNf_s literal 0 HcmV?d00001 From df8832455d48a8dd741c5d62f62071562b6615b4 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 8 Apr 2014 04:48:57 -0700 Subject: [PATCH 052/424] [ticket/12265] Remove ugly logic. PHPBB3-12265 --- .../template/ucp_pm_viewmessage.html | 24 ++----------------- .../prosilver/template/viewtopic_body.html | 23 ++---------------- phpBB/styles/prosilver/theme/buttons.css | 12 ++++++---- 3 files changed, 12 insertions(+), 47 deletions(-) diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index efc45e1af8..6cc70c4225 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -35,18 +35,6 @@ - {% set CELL_BREAK = {1: 1, 2: 1, 3: 2, 4: 2, 5: 3, 6: 3, 7: 4, 8: 4, 9: 5, 10: 5, 11: 4, 12: 4, 13: 5, 14: 5, 16: 4} %} - {% set CONTACT_CNT = 0 %} - {% set CNT = 0 %} - {% set CONTACT_CNT = CONTACT_CNT + 1 %} - {% set CONTACT_CNT = CONTACT_CNT + 1 %} - {% set CONTACT_CNT = CONTACT_CNT + 1 %} - - - {% set CONTACT_CNT = CONTACT_CNT + 1 %} - - {% set DIV_CNT = CELL_BREAK[CONTACT_CNT] %}{% set DIV_CNT = 4 %} -
{L_CONTACT_USER}{L_COLON} diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index b528fc18a5..d9e800d1e6 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -144,17 +144,6 @@ - {% set CELL_BREAK = {1: 1, 2: 1, 3: 2, 4: 2, 5: 3, 6: 3, 7: 4, 8: 4, 9: 5, 10: 5, 11: 4, 12: 4, 13: 5, 14: 5, 16: 4} %} - {% set CONTACT_CNT = 0 %} - {% set CNT = 0 %} - {% set CONTACT_CNT = CONTACT_CNT + 1 %} - {% set CONTACT_CNT = CONTACT_CNT + 1 %} - {% set CONTACT_CNT = CONTACT_CNT + 1 %} - - {% set CONTACT_CNT = CONTACT_CNT + 1 %} - - {% set DIV_CNT = CELL_BREAK[CONTACT_CNT] %}{% set DIV_CNT = 4 %} -
{L_CONTACT_USER}{L_COLON} diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index 7f271ee648..b17903c958 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -254,12 +254,16 @@ ul.profile-icons.responsive a.responsive-menu-link:before { padding: 8px; } -.contact-icons div:last-child a { - border-bottom: none; +.contact-icons a:nth-child(4) { + border-right: none; } -.contact-icons .last-cell { - border-right: none; +.contact-icons a:nth-child(5) { + clear: left; +} + +.contact-icons div:last-child a { + border-bottom: none; } From ec145419eddce662e0afe050f14f0f690ecf40e2 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Thu, 10 Apr 2014 05:18:57 -0700 Subject: [PATCH 053/424] [ticket/12265] Fix issue with dropdown being restricted by the width of parent PHPBB3-12265 --- phpBB/assets/javascript/core.js | 12 ++++++++++-- phpBB/styles/prosilver/theme/common.css | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index ac866f7c78..759d4f3229 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -917,9 +917,10 @@ phpbb.toggleDropdown = function() { // Check dimensions when showing dropdown // !visible because variable shows state of dropdown before it was toggled if (!visible) { + var windowWidth = $(window).width(); + options.dropdown.find('.dropdown-contents').each(function() { - var $this = $(this), - windowWidth = $(window).width(); + var $this = $(this); $this.css({ marginLeft: 0, @@ -937,6 +938,13 @@ phpbb.toggleDropdown = function() { $this.css('margin-left', (windowWidth - offset - width - 2) + 'px'); } }); + var freeSpace = parent.offset().left - 4; + + if (direction == 'left') { + options.dropdown.css('margin-left', '-' + freeSpace + 'px'); + } else { + options.dropdown.css('margin-right', '-' + (windowWidth + freeSpace) + 'px'); + } } // Prevent event propagation diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 298d310ab1..8f32decd19 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -470,6 +470,7 @@ ul.linklist.bulletin li.no-bulletin:before { border: 1px solid transparent; border-radius: 5px; padding: 9px 0 0; + margin-right: -500px; } .dropdown-container.topic-tools { @@ -485,6 +486,8 @@ ul.linklist.bulletin li.no-bulletin:before { .dropdown-left .dropdown, .nojs .rightside .dropdown { left: auto; right: 0; + margin-left: -500px; + margin-right: 0; } .dropdown-button-control .dropdown { From 11dd010f84044d8533a5eff387c2b57f62b4298f Mon Sep 17 00:00:00 2001 From: Cesar G Date: Thu, 10 Apr 2014 05:58:20 -0700 Subject: [PATCH 054/424] [ticket/12265] Add contact icon and remove border from last row & cells. PHPBB3-12265 --- .../template/ucp_pm_viewmessage.html | 47 +++++++++++------- .../prosilver/template/viewtopic_body.html | 43 +++++++++------- phpBB/styles/prosilver/theme/buttons.css | 6 +-- phpBB/styles/prosilver/theme/content.css | 9 ++++ .../prosilver/theme/images/icon_contact.png | Bin 0 -> 340 bytes phpBB/styles/prosilver/theme/imageset.css | 11 ++-- 6 files changed, 70 insertions(+), 46 deletions(-) create mode 100644 phpBB/styles/prosilver/theme/images/icon_contact.png diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index 6cc70c4225..2b170bc45b 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -35,31 +35,40 @@ +
{L_CONTACT_USER}{L_COLON} -
{L_CONTACT_USER}{L_COLON} -
{L_CONTACT_USER}{L_COLON}
diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index efdf5e9993..5069a406a3 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -143,8 +143,7 @@ - - +
{L_CONTACT_USER}{L_COLON} diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 1a74ad3e38..5d7314635e 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1586,6 +1586,14 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) !$row['post_edit_locked'] ))); + $u_pm = ''; + + if (($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') + && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')))) + { + $u_pm = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']); + } + // $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']), @@ -1625,7 +1633,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_DELETE' => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&f=$forum_id&p={$row['post_id']}") : '', 'U_SEARCH' => $user_cache[$poster_id]['search'], - 'U_PM' => ($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']) : '', + 'U_PM' => $u_pm, 'U_EMAIL' => $user_cache[$poster_id]['email'], 'U_JABBER' => $user_cache[$poster_id]['jabber'], @@ -1695,11 +1703,46 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) // Dump vars into template $template->assign_block_vars('postrow', $post_row); + $contact_fields = array( + array( + 'ID' => 'pm', + 'NAME' => $user->lang['PRIVATE_MESSAGES'], + 'U_CONTACT' => $u_pm, + ), + array( + 'ID' => 'email', + 'NAME' => $user->lang['SEND_EMAIL'], + 'U_CONTACT' => $user_cache[$poster_id]['email'], + ), + array( + 'ID' => 'jabber', + 'NAME' => $user->lang['JABBER'], + 'U_CONTACT' => $user_cache[$poster_id]['jabber'], + ), + ); + + foreach ($contact_fields as $field) + { + if ($field['U_CONTACT']) + { + $template->assign_block_vars('postrow.contact', $field); + } + } + if (!empty($cp_row['blockrow'])) { foreach ($cp_row['blockrow'] as $field_data) { $template->assign_block_vars('postrow.custom_fields', $field_data); + + if ($field_data['S_PROFILE_CONTACT']) + { + $template->assign_block_vars('postrow.contact', array( + 'ID' => $field_data['PROFILE_FIELD_IDENT'], + 'NAME' => $field_data['PROFILE_FIELD_NAME'], + 'U_CONTACT' => $field_data['PROFILE_FIELD_CONTACT'], + )); + } } } From 05dec34917a057a4f28894869e5d3872d0ea1f3b Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 15 Apr 2014 09:00:14 -0700 Subject: [PATCH 060/424] [ticket/12265] Ensure that dropdown is always at the very left of the container PHPBB3-12265 --- phpBB/styles/prosilver/theme/content.css | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index 998b139262..dc6ab9aef3 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -737,6 +737,7 @@ dd.profile-contact { .profile-contact .dropdown-container { display: inline-block; + text-align: left; width: 30px; } From ed4b72d1f2e1cc96ebec845f9af97db406065c6b Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 15 Apr 2014 09:15:52 -0700 Subject: [PATCH 061/424] [ticket/12265] Actually use $u_pm. PHPBB3-12265 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 1cdb87ebf0..44d067b5fc 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -271,7 +271,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) array( 'ID' => 'pm', 'NAME' => $user->lang['PRIVATE_MESSAGE'], - 'U_CONTACT' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $author_id) + 'U_CONTACT' => $u_pm, ), array( 'ID' => 'email', From efe667130d9c133e07653dff4729731f1fc6c747 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sat, 15 Feb 2014 23:45:51 -0800 Subject: [PATCH 062/424] [ticket/12201] Separate pagination from table. PHPBB3-12201 --- phpBB/adm/style/acp_attachments.html | 2 +- phpBB/adm/style/acp_logs.html | 2 +- phpBB/adm/style/admin.css | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index 82fb229fae..f012298e29 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -378,7 +378,7 @@
{L_TITLE} -
-
From 01464e2451893b73489cb83d45c9655a0c791395 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sun, 16 Feb 2014 00:19:09 -0800 Subject: [PATCH 065/424] [ticket/12201] Only the top pagination should be floated to the right. PHPBB3-12201 --- phpBB/adm/style/admin.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index e93a09ff21..edfcf3ab41 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -1671,10 +1671,10 @@ input.button1:focus, input.button2:focus { width: auto; text-align: right; margin-top: 5px; - float: right; } .top-pagination { + float: right; margin: 15px 0 2px 0; } From 38775fc06371fd0aebea2794f480dde6d7e643e7 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sun, 16 Feb 2014 00:32:09 -0800 Subject: [PATCH 066/424] [ticket/12201] Display error and sorting options when there are no attachments PHPBB3-12201 --- phpBB/adm/style/acp_attachments.html | 8 +++++++- phpBB/language/en/acp/attachments.php | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index e026b81ad0..5d35666fdd 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -389,6 +389,7 @@ + @@ -412,6 +413,11 @@
+ +
+

{L_NO_ATTACHMENTS}

+
+ +
{L_DISPLAY_LOG}{L_COLON}  {S_LIMIT_DAYS} {L_SORT_BY}{L_COLON} {S_SORT_KEY} {S_SORT_DIR} @@ -429,7 +436,6 @@

-
diff --git a/phpBB/language/en/acp/attachments.php b/phpBB/language/en/acp/attachments.php index c7d68d29c2..1eab22839b 100644 --- a/phpBB/language/en/acp/attachments.php +++ b/phpBB/language/en/acp/attachments.php @@ -130,6 +130,7 @@ $lang = array_merge($lang, array( 'NOT_ALLOWED_IN_PM' => 'Only allowed in posts', 'NOT_ALLOWED_IN_PM_POST' => 'Not allowed', 'NOT_ASSIGNED' => 'Not assigned', + 'NO_ATTACHMENTS' => 'No attachments found for this period.', 'NO_EXT_GROUP' => 'None', 'NO_EXT_GROUP_NAME' => 'No group name entered', 'NO_EXT_GROUP_SPECIFIED' => 'No extension group specified.', From 52251acefabb8f093dc3681e0830b3c474a24c53 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sun, 16 Feb 2014 00:37:39 -0800 Subject: [PATCH 067/424] [ticket/12201] Fix typos in language pack. PHPBB3-12201 --- phpBB/language/en/acp/common.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 5794a7c833..f27a4ce199 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -242,7 +242,7 @@ $lang = array_merge($lang, array( 'EXPORT_STORE' => 'Store', 'FILES_GONE' => 'Some of the attachments you selected for deletion do not exist. They may have been already deleted. Attachments that did exist were deleted.', - 'FILES_STATS_WRONG' => 'Your files statistics are probably inaccurate and need to be resynchronised. Actual values: number of attachments = %1$d, total size of attachments = %2$s.', + 'FILES_STATS_WRONG' => 'Your file statistics are likely inaccurate and need to be resynchronised. Actual values: number of attachments = %1$d, total size of attachments = %2$s.', 'GENERAL_OPTIONS' => 'General options', 'GENERAL_SETTINGS' => 'General settings', @@ -286,7 +286,7 @@ $lang = array_merge($lang, array( 'REMIND' => 'Remind', 'RESYNC' => 'Resynchronise', - 'RESYNC_FILES_STATS' => 'Resynchronise files statistics', + 'RESYNC_FILES_STATS' => 'Resynchronise file statistics', 'RESYNC_FILES_STATS_EXPLAIN' => 'Recalculates the total number and size of files attached to posts and private messages.', 'SELECT_ANONYMOUS' => 'Select anonymous user', @@ -388,7 +388,7 @@ $lang = array_merge($lang, array( 'RESET_ONLINE' => 'Reset most users ever online', 'RESET_ONLINE_CONFIRM' => 'Are you sure you wish to reset the most users ever online counter?', 'RESET_ONLINE_SUCCESS' => 'Most users ever online reset', - 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise files statistics?', + 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise file statistics?', 'RESYNC_POSTCOUNTS' => 'Resynchronise post counts', 'RESYNC_POSTCOUNTS_EXPLAIN' => 'Only existing posts will be taken into consideration. Pruned posts will not be counted.', 'RESYNC_POSTCOUNTS_CONFIRM' => 'Are you sure you wish to resynchronise post counts?', @@ -696,7 +696,7 @@ $lang = array_merge($lang, array( 'LOG_REFERER_INVALID' => 'Referer validation failed
»Referer was “%1$s”. The request was rejected and the session killed.', 'LOG_RESET_DATE' => 'Board start date reset', 'LOG_RESET_ONLINE' => 'Most users online reset', - 'LOG_RESYNC_FILES_STATS' => 'Files statistics resynchronised', + 'LOG_RESYNC_FILES_STATS' => 'File statistics resynchronised', 'LOG_RESYNC_POSTCOUNTS' => 'User post counts resynchronised', 'LOG_RESYNC_POST_MARKING' => 'Dotted topics resynchronised', 'LOG_RESYNC_STATS' => 'Post, topic and user statistics resynchronised', From 7824535839aab0cc9a8b0100abc2dde592ae6ec0 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Tue, 15 Apr 2014 23:18:41 +0200 Subject: [PATCH 068/424] [ticket/11978] Fix width of topic search text field PHPBB3-11978 --- phpBB/styles/prosilver/theme/forms.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/theme/forms.css b/phpBB/styles/prosilver/theme/forms.css index 64d2df2d1a..88f2bd65c5 100644 --- a/phpBB/styles/prosilver/theme/forms.css +++ b/phpBB/styles/prosilver/theme/forms.css @@ -284,7 +284,7 @@ fieldset.submit-buttons input { input.inputbox { width: 85%; } input.medium { width: 50%; } input.narrow { width: 25%; } -input.tiny { width: 125px; } +input.tiny { width: 150px; } textarea.inputbox { width: 85%; From b73e22ae718981df2ac699c8c27d1dc12d8f1c0c Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 15 Apr 2014 14:19:47 -0700 Subject: [PATCH 069/424] [ticket/12201] Add link to resync file stats after error. PHPBB3-12201 --- phpBB/includes/acp/acp_attachments.php | 15 +++++++++------ phpBB/language/en/acp/attachments.php | 8 ++++++-- phpBB/language/en/acp/common.php | 6 ------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index f68fd76587..d8d382b2bd 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -1115,11 +1115,6 @@ class acp_attachments if ($stats_error) { $error[] = $stats_error; - - // Show option to resync stats - $this->template->assign_vars(array( - 'S_ACTION_OPTIONS' => $auth->acl_get('a_board'), - )); } $template->assign_vars(array( @@ -1321,7 +1316,15 @@ class acp_attachments if (($num_files != $stats['num_files']) || ($total_size != $stats['upload_dir_size'])) { - return $this->user->lang('FILES_STATS_WRONG', (int) $stats['num_files'], get_formatted_filesize($stats['upload_dir_size'])); + $u_resync = $this->u_action . '&action=stats'; + + return $this->user->lang( + 'FILES_STATS_WRONG', + (int) $stats['num_files'], + get_formatted_filesize($stats['upload_dir_size']), + '', + '' + ); } return false; } diff --git a/phpBB/language/en/acp/attachments.php b/phpBB/language/en/acp/attachments.php index 1eab22839b..6ca2865383 100644 --- a/phpBB/language/en/acp/attachments.php +++ b/phpBB/language/en/acp/attachments.php @@ -107,6 +107,9 @@ $lang = array_merge($lang, array( 'EXT_GROUP_REAL_MEDIA' => 'Real Media', 'EXT_GROUP_WINDOWS_MEDIA' => 'Windows Media', + 'FILES_GONE' => 'Some of the attachments you selected for deletion do not exist. They may have been already deleted. Attachments that did exist were deleted.', + 'FILES_STATS_WRONG' => 'Your file statistics are likely inaccurate and need to be resynchronised. Actual values: number of attachments = %1$d, total size of attachments = %2$s.
Click %3$shere%4$s to resynchronise them.', + 'GO_TO_EXTENSIONS' => 'Go to extension management screen', 'GROUP_NAME' => 'Group name', @@ -144,8 +147,9 @@ $lang = array_merge($lang, array( 'ORDER_ALLOW_DENY' => 'Allow', 'ORDER_DENY_ALLOW' => 'Deny', - 'REMOVE_ALLOWED_IPS' => 'Remove or un-exclude allowed IPs/hostnames', - 'REMOVE_DISALLOWED_IPS' => 'Remove or un-exclude disallowed IPs/hostnames', + 'REMOVE_ALLOWED_IPS' => 'Remove or un-exclude allowed IPs/hostnames', + 'REMOVE_DISALLOWED_IPS' => 'Remove or un-exclude disallowed IPs/hostnames', + 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise file statistics?', 'SEARCH_IMAGICK' => 'Search for Imagemagick', 'SECURE_ALLOW_DENY' => 'Allow/Deny list', diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index f27a4ce199..6f16dfabd4 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -241,9 +241,6 @@ $lang = array_merge($lang, array( 'EXPORT_DOWNLOAD' => 'Download', 'EXPORT_STORE' => 'Store', - 'FILES_GONE' => 'Some of the attachments you selected for deletion do not exist. They may have been already deleted. Attachments that did exist were deleted.', - 'FILES_STATS_WRONG' => 'Your file statistics are likely inaccurate and need to be resynchronised. Actual values: number of attachments = %1$d, total size of attachments = %2$s.', - 'GENERAL_OPTIONS' => 'General options', 'GENERAL_SETTINGS' => 'General settings', 'GLOBAL_MASK' => 'Global permission mask', @@ -286,8 +283,6 @@ $lang = array_merge($lang, array( 'REMIND' => 'Remind', 'RESYNC' => 'Resynchronise', - 'RESYNC_FILES_STATS' => 'Resynchronise file statistics', - 'RESYNC_FILES_STATS_EXPLAIN' => 'Recalculates the total number and size of files attached to posts and private messages.', 'SELECT_ANONYMOUS' => 'Select anonymous user', 'SELECT_OPTION' => 'Select option', @@ -388,7 +383,6 @@ $lang = array_merge($lang, array( 'RESET_ONLINE' => 'Reset most users ever online', 'RESET_ONLINE_CONFIRM' => 'Are you sure you wish to reset the most users ever online counter?', 'RESET_ONLINE_SUCCESS' => 'Most users ever online reset', - 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise file statistics?', 'RESYNC_POSTCOUNTS' => 'Resynchronise post counts', 'RESYNC_POSTCOUNTS_EXPLAIN' => 'Only existing posts will be taken into consideration. Pruned posts will not be counted.', 'RESYNC_POSTCOUNTS_CONFIRM' => 'Are you sure you wish to resynchronise post counts?', From ccadda530deeca6239b5d0cdbced412e1c820f58 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 15 Apr 2014 15:00:34 -0700 Subject: [PATCH 070/424] [ticket/12201] Increase sort font size just slightly. PHPBB3-12201 --- phpBB/adm/style/admin.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index edfcf3ab41..69c8e19e8b 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -1242,7 +1242,7 @@ fieldset.display-options { border: none; background-color: transparent; text-align: center; - font-size: 0.75em; + font-size: 0.85em; } fieldset.display-options select, fieldset.display-options input, fieldset.display-options label { From e174e29b41e57765295edc59a288cddc017269b4 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 15 Apr 2014 15:10:15 -0700 Subject: [PATCH 071/424] [ticket/12201] Update select element to follow same design as prosilver. PHPBB3-12201 --- phpBB/adm/style/admin.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index 69c8e19e8b..4e34aff919 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -1130,11 +1130,14 @@ input.langvalue, textarea.langvalue { } optgroup, select { + background-color: #FAFAFA; + border: 1px solid #666666; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 0.85em; font-weight: normal; font-style: normal; cursor: pointer; + padding: 1px; vertical-align: middle; width: auto; color: #000; From a9fbc34cf43ef1b70ba5930ca08d355cad4c982b Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 15 Apr 2014 15:14:47 -0700 Subject: [PATCH 072/424] [ticket/12201] Decreased pagination font size. PHPBB3-12201 --- phpBB/adm/style/admin.css | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index 4e34aff919..6f2d65afc0 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -1670,6 +1670,7 @@ input.button1:focus, input.button2:focus { /* Pagination ---------------------------------------- */ .pagination { + font-size: .85em; height: 1%; /* IE tweak (holly hack) */ width: auto; text-align: right; From 1f44b4da18622c526e89858f7f89df9857f3a00e Mon Sep 17 00:00:00 2001 From: n-aleha Date: Mon, 14 Apr 2014 01:14:44 +0300 Subject: [PATCH 073/424] [ticket/12345] Improve search flood interval message for ascraeus Show to guests and users the remaining seconds until their next allowed search, if a search flood limit is enabled for them. PHPBB3-12345 --- phpBB/language/en/search.php | 5 ++++- phpBB/search.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/phpBB/language/en/search.php b/phpBB/language/en/search.php index f65022fbcb..13aa66514c 100644 --- a/phpBB/language/en/search.php +++ b/phpBB/language/en/search.php @@ -69,7 +69,10 @@ $lang = array_merge($lang, array( 'NO_RECENT_SEARCHES' => 'No searches have been carried out recently.', 'NO_SEARCH' => 'Sorry but you are not permitted to use the search system.', 'NO_SEARCH_RESULTS' => 'No suitable matches were found.', - 'NO_SEARCH_TIME' => 'Sorry but you cannot use search at this time. Please try again in a few minutes.', + 'NO_SEARCH_TIME' => array( + 1 => 'Sorry but you cannot use search at this time. Please try again in %d second.', + 2 => 'Sorry but you cannot use search at this time. Please try again in %d seconds.', + ), 'NO_SEARCH_UNREADS' => 'Sorry but searching for unread posts has been disabled on this board.', 'WORD_IN_NO_POST' => 'No posts were found because the word %s is not contained in any post.', 'WORDS_IN_NO_POST' => 'No posts were found because the words %s are not contained in any post.', diff --git a/phpBB/search.php b/phpBB/search.php index 4756a941f5..749aec45fd 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -108,7 +108,7 @@ if ($interval && !in_array($search_id, array('unreadposts', 'unanswered', 'activ if ($user->data['user_last_search'] > time() - $interval) { $template->assign_var('S_NO_SEARCH', true); - trigger_error('NO_SEARCH_TIME'); + trigger_error($user->lang('NO_SEARCH_TIME', (int) ($user->data['user_last_search'] + $interval - time()))); } } From 3d1a07f8f066461b58d2b04f4b4dba900556f430 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 15 Apr 2014 21:11:01 -0700 Subject: [PATCH 074/424] [ticket/12121] Preserve link redirect counts when updating from 3.0.x. PHPBB3-12121 --- phpBB/phpbb/db/migration/data/v310/softdelete_p1.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php b/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php index d5da54b888..10243dc77f 100644 --- a/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php +++ b/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php @@ -149,6 +149,15 @@ class softdelete_p1 extends \phpbb\db\migration\migration $limit = 10; $converted_forums = 0; + if (!$start) + { + // Preserve the forum_posts value for link forums as it represents redirects. + $sql = 'UPDATE ' . $this->table_prefix . 'forums + SET forum_posts_approved = forum_posts + WHERE forum_type = ' . FORUM_LINK; + $this->db->sql_query($sql); + } + $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS sum_topics, SUM(topic_posts_approved) AS sum_posts_approved, SUM(topic_posts_unapproved) AS sum_posts_unapproved FROM ' . $this->table_prefix . 'topics GROUP BY forum_id, topic_visibility From 7e7647c1594fc009a071b6b24bbf2eff5c5b2dfd Mon Sep 17 00:00:00 2001 From: Markus Stenudd Date: Sat, 30 Nov 2013 16:01:26 +0100 Subject: [PATCH 075/424] [ticket/8558] Add display name in emails from board PHPBB3-8558 --- phpBB/includes/functions_messenger.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index db2dea33e8..333914f02f 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -488,12 +488,12 @@ class messenger if (empty($this->replyto)) { - $this->replyto = '<' . $config['board_contact'] . '>'; + $this->replyto = '"' . $config['sitename'] . '" <' . $config['board_contact'] . '>'; } if (empty($this->from)) { - $this->from = '<' . $config['board_contact'] . '>'; + $this->from = '"' . $config['sitename'] . '" <' . $config['board_contact'] . '>'; } $encode_eol = ($config['smtp_delivery']) ? "\r\n" : $this->eol; From e0151abdb5372176e4139307390d71de18a39dca Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 16 Apr 2014 17:48:05 +0200 Subject: [PATCH 076/424] [ticket/8558] Do string concatenation only once and do htmlspecialchars PHPBB3-8558 --- phpBB/includes/functions_messenger.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 333914f02f..a303bdac57 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -486,14 +486,16 @@ class messenger $use_queue = true; } + $board_contact = '"' . mail_encode(htmlspecialchars($config['sitename'])) . '" <' . $config['board_contact'] . '>'; + if (empty($this->replyto)) { - $this->replyto = '"' . $config['sitename'] . '" <' . $config['board_contact'] . '>'; + $this->replyto = $board_contact; } if (empty($this->from)) { - $this->from = '"' . $config['sitename'] . '" <' . $config['board_contact'] . '>'; + $this->from = $board_contact; } $encode_eol = ($config['smtp_delivery']) ? "\r\n" : $this->eol; From 013cc2c66f4ca594e8ffa09511d054604ac615e5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Apr 2014 20:16:03 +0200 Subject: [PATCH 077/424] [ticket/12390] Move cleaning of vendor into it's own target PHPBB3-12390 --- build/build.xml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/build/build.xml b/build/build.xml index ea12e60e3c..c1f81fb947 100644 --- a/build/build.xml +++ b/build/build.xml @@ -273,6 +273,22 @@ + + + + + + + + + + + + + + + + @@ -355,16 +371,6 @@ - - - - - - - - - - From 23bf9d0c42771639ea7df948e4bdbe02eeda7564 Mon Sep 17 00:00:00 2001 From: Crizzo Date: Wed, 16 Apr 2014 21:03:03 +0200 Subject: [PATCH 078/424] [ticket/12404] Adds a new event before and after the Timezone display PHPBB3-12404 --- phpBB/docs/events.md | 16 ++++++++++++++++ .../styles/prosilver/template/navbar_footer.html | 4 +++- .../styles/subsilver2/template/breadcrumbs.html | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 6897c3f22e..6d241e4356 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -275,6 +275,22 @@ overall_footer_page_body_after * Since: 3.1.0-b3 * Purpose: Add content after the page-body, but before the footer +overall_footer_timezone_prepend +=== +* Locations: + + styles/prosilver/template/navbar_footer.html + + styles/subsilver2/template/breadcrumbs.html +* Since: 3.1.0-b3 +* Purpose: Add new List-Elements to the navbar in the page footer, before Timezone + +overall_footer_timezone_append +=== +* Locations: + + styles/prosilver/template/navbar_footer.html + + styles/subsilver2/template/breadcrumbs.html +* Since: 3.1.0-b3 +* Purpose: Add new List-Elements to the navbar in the page footer, after "The Team" + overall_header_body_before === * Locations: diff --git a/phpBB/styles/prosilver/template/navbar_footer.html b/phpBB/styles/prosilver/template/navbar_footer.html index 32cbecdf8c..9e52a7d969 100644 --- a/phpBB/styles/prosilver/template/navbar_footer.html +++ b/phpBB/styles/prosilver/template/navbar_footer.html @@ -8,9 +8,11 @@
  • {S_WATCH_FORUM_TITLE}
  • +
  • {S_TIMEZONE}
  • {L_DELETE_COOKIES}
  • -
  • {L_THE_TEAM} +
  • {L_THE_TEAM}
  • + diff --git a/phpBB/styles/subsilver2/template/breadcrumbs.html b/phpBB/styles/subsilver2/template/breadcrumbs.html index 09ee9a8606..55f8c70a9c 100644 --- a/phpBB/styles/subsilver2/template/breadcrumbs.html +++ b/phpBB/styles/subsilver2/template/breadcrumbs.html @@ -4,7 +4,9 @@ +

    {S_TIMEZONE}

    + From 04893e3f988ee80df4fd959dfea413d191d8cd22 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 16 Apr 2014 22:16:52 +0200 Subject: [PATCH 079/424] [ticket/12417] Revert "No longer allow Travis CI HHVM environment to fail." hhvm-nightly 2014.04.16~precise introduced "Attempted to serialize unserializable builtin class DOMElement" errors when running functional tests. This reverts commit ff7cc77f9db66b7fddacd77f215d85cf0243b2fa. PHPBB3-12417 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index da9236a82f..5e70ef97ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,3 +33,5 @@ matrix: env: DB=mariadb - php: 5.4 env: DB=postgres + allow_failures: + - php: hhvm From 31e11d81e8de4a4f5ca5c91590681edab887f2aa Mon Sep 17 00:00:00 2001 From: n-aleha Date: Thu, 17 Apr 2014 01:47:18 +0300 Subject: [PATCH 080/424] [ticket/12406] Fix variable description of core.viewtopic_modify_page_title Variable page_title should be described as "Title of the viewtopic page". PHPBB3-12406 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index ad7e8c29bc..25d79a2527 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1877,7 +1877,7 @@ $page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang * 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 string page_title Title of the viewtopic 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 From 743d816631292a2081af4c5f7fc2fad2aff17c58 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 17:08:01 +0200 Subject: [PATCH 081/424] [ticket/12012] Correctly drop default value constraints on MSSQL We need to drop the default constraints of a column, before being able to change their type or deleting them. PHPBB3-12012 --- phpBB/phpbb/db/tools.php | 144 ++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 85 deletions(-) diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 3d480b7e1c..87c205c6c0 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -1846,49 +1846,7 @@ class tools case 'mssql': case 'mssqlnative': - $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - // Remove default constraints - if ($row['mssql_version'][0] == '8') // SQL Server 2000 - { - // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx - // Deprecated in SQL Server 2005 - $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) - SET @drop_default_name = - (SELECT so.name FROM sysobjects so - JOIN sysconstraints sc ON so.id = sc.constid - WHERE object_name(so.parent_obj) = '{$table_name}' - AND so.xtype = 'D' - AND sc.colid = (SELECT colid FROM syscolumns - WHERE id = object_id('{$table_name}') - AND name = '{$column_name}')) - IF @drop_default_name <> '' - BEGIN - SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' - EXEC(@cmd) - END"; - } - else - { - $sql = "SELECT dobj.name AS def_name - FROM sys.columns col - LEFT OUTER JOIN sys.objects dobj ON (dobj.object_id = col.default_object_id AND dobj.type = 'D') - WHERE col.object_id = object_id('{$table_name}') - AND col.name = '{$column_name}' - AND dobj.name IS NOT NULL"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($row) - { - $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; - } - } - + $statements = $this->mssql_drop_default_constraints($table_name, $column_name); $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; break; @@ -2371,52 +2329,12 @@ class tools case 'mssql': case 'mssqlnative': + $statements = $this->mssql_drop_default_constraints($table_name, $column_name); $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; if (!empty($column_data['default'])) { - $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - // Using TRANSACT-SQL for this statement because we do not want to have colliding data if statements are executed at a later stage - if ($row['mssql_version'][0] == '8') // SQL Server 2000 - { - $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) - SET @drop_default_name = - (SELECT so.name FROM sysobjects so - JOIN sysconstraints sc ON so.id = sc.constid - WHERE object_name(so.parent_obj) = '{$table_name}' - AND so.xtype = 'D' - AND sc.colid = (SELECT colid FROM syscolumns - WHERE id = object_id('{$table_name}') - AND name = '{$column_name}')) - IF @drop_default_name <> '' - BEGIN - SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' - EXEC(@cmd) - END - SET @cmd = 'ALTER TABLE [{$table_name}] ADD CONSTRAINT [DF_{$table_name}_{$column_name}_1] {$column_data['default']} FOR [{$column_name}]' - EXEC(@cmd)"; - } - else - { - $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) - SET @drop_default_name = - (SELECT dobj.name FROM sys.columns col - LEFT OUTER JOIN sys.objects dobj ON (dobj.object_id = col.default_object_id AND dobj.type = 'D') - WHERE col.object_id = object_id('{$table_name}') - AND col.name = '{$column_name}' - AND dobj.name IS NOT NULL) - IF @drop_default_name <> '' - BEGIN - SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' - EXEC(@cmd) - END - SET @cmd = 'ALTER TABLE [{$table_name}] ADD CONSTRAINT [DF_{$table_name}_{$column_name}_1] {$column_data['default']} FOR [{$column_name}]' - EXEC(@cmd)"; - } + $statements[] = 'ALTER TABLE [' . $table_name . '] ADD CONSTRAINT [DF_' . $table_name . '_' . $column_name . '_1] ' . $this->db->sql_escape($column_data['default']) . ' FOR [' . $column_name . ']'; } break; @@ -2551,4 +2469,60 @@ class tools return $this->_sql_run_sql($statements); } + + /** + * Drop the default constraints of a column + * + * We need to drop the default constraints of a column, + * before being able to change their type or deleting them. + * + * @param string $table_name + * @param string $column_name + * @return array Array with SQL statements + */ + protected function mssql_drop_default_constraints($table_name, $column_name) + { + $statements = array(); + $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; + $result = $this->db->sql_query($sql); + $mssql_server_properties = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + // Remove default constraints + if ($mssql_server_properties['mssql_version'][0] == '8') // SQL Server 2000 + { + // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx + // Deprecated in SQL Server 2005 + $sql = "SELECT so.name AS def_name FROM sysobjects so + JOIN sysconstraints sc ON so.id = sc.constid + WHERE object_name(so.parent_obj) = '{$table_name}' + AND so.xtype = 'D' + AND sc.colid = (SELECT colid FROM syscolumns + WHERE id = object_id('{$table_name}') + AND name = '{$column_name}')"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; + } + $this->db->sql_freeresult($result); + } + else + { + $sql = "SELECT dobj.name AS def_name + FROM sys.columns col + LEFT OUTER JOIN sys.objects dobj ON (dobj.object_id = col.default_object_id AND dobj.type = 'D') + WHERE col.object_id = object_id('{$table_name}') + AND col.name = '{$column_name}' + AND dobj.name IS NOT NULL"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; + } + $this->db->sql_freeresult($result); + } + + return $statements; + } } From 29ba06968d383dd63a869345352117d7ed82497b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 12 Apr 2014 09:53:45 +0200 Subject: [PATCH 082/424] [ticket/12012] Fix query layout PHPBB3-12012 --- phpBB/phpbb/db/tools.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 87c205c6c0..a746099a14 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -2493,7 +2493,8 @@ class tools { // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx // Deprecated in SQL Server 2005 - $sql = "SELECT so.name AS def_name FROM sysobjects so + $sql = "SELECT so.name AS def_name + FROM sysobjects so JOIN sysconstraints sc ON so.id = sc.constid WHERE object_name(so.parent_obj) = '{$table_name}' AND so.xtype = 'D' From 9036cdaaa2d45664bca1a0e0cdeaaf2bd13c662a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 12 Apr 2014 12:37:34 +0200 Subject: [PATCH 083/424] [ticket/12012] Drop and recreate indexes when changing a column on MSSQL PHPBB3-12012 --- phpBB/phpbb/db/tools.php | 111 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index a746099a14..1299df51dd 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -1846,6 +1846,13 @@ class tools case 'mssql': case 'mssqlnative': + $indexes = $this->mssql_get_existing_indexes($table_name, $column_name); + + if (!empty($indexes)) + { + trigger_error("Column '$column_name' on table '$table_name' is still part of an index and can not be removed: " . implode(', ', array_keys($indexes)), E_USER_ERROR); + } + $statements = $this->mssql_drop_default_constraints($table_name, $column_name); $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; break; @@ -2329,6 +2336,16 @@ class tools case 'mssql': case 'mssqlnative': + $indexes = $this->mssql_get_existing_indexes($table_name, $column_name); + + if (!empty($indexes)) + { + foreach ($indexes as $index_name => $index_data) + { + $this->sql_index_drop($table_name, $index_name); + } + } + $statements = $this->mssql_drop_default_constraints($table_name, $column_name); $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; @@ -2336,6 +2353,15 @@ class tools { $statements[] = 'ALTER TABLE [' . $table_name . '] ADD CONSTRAINT [DF_' . $table_name . '_' . $column_name . '_1] ' . $this->db->sql_escape($column_data['default']) . ' FOR [' . $column_name . ']'; } + + if (!empty($indexes)) + { + // Recreate indexes after we changed the column + foreach ($indexes as $index_name => $index_data) + { + $this->sql_create_index($table_name, $index_name, $index_data); + } + } break; case 'mysql_40': @@ -2526,4 +2552,89 @@ class tools return $statements; } + + /** + * Get a list with existing indexes for the column + * + * @param string $table_name + * @param string $column_name + * @return array Array with Index name => columns + */ + protected function mssql_get_existing_indexes($table_name, $column_name) + { + $existing_indexes = array(); + $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; + $result = $this->db->sql_query($sql); + $mssql_server_properties = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + // Remove default constraints + if ($mssql_server_properties['mssql_version'][0] == '8') // SQL Server 2000 + { + // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx + // Deprecated in SQL Server 2005 + /** + * @todo Fix for SQL Server 2000 + $sql = "SELECT so.name AS def_name + FROM sysobjects so + JOIN sysconstraints sc ON so.id = sc.constid + WHERE object_name(so.parent_obj) = '{$table_name}' + AND so.xtype = 'D' + AND sc.colid = (SELECT colid FROM syscolumns + WHERE id = object_id('{$table_name}') + AND name = '{$column_name}')"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; + } + $this->db->sql_freeresult($result); + */ + } + else + { + $sql = "SELECT DISTINCT ix.name AS phpbb_index_name + FROM sys.indexes ix + INNER JOIN sys.index_columns ixc + ON ixc.object_id = ix.object_id + AND ixc.index_id = ix.index_id + INNER JOIN sys.columns cols + ON cols.column_id = ixc.column_id + AND cols.object_id = ix.object_id + WHERE ix.object_id = object_id('{$table_name}') + AND cols.name = '{$column_name}'"; + $result = $this->db->sql_query($sql); + $existing_indexes = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $existing_indexes[$row['phpbb_index_name']] = array(); + } + $this->db->sql_freeresult($result); + + if (empty($existing_indexes)) + { + return array(); + } + + $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name + FROM sys.indexes ix + INNER JOIN sys.index_columns ixc + ON ixc.object_id = ix.object_id + AND ixc.index_id = ix.index_id + INNER JOIN sys.columns cols + ON cols.column_id = ixc.column_id + AND cols.object_id = ix.object_id + WHERE ix.object_id = object_id('{$table_name}') + AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $existing_indexes[$row['phpbb_index_name']][] = $row['phpbb_column_name']; + } + $this->db->sql_freeresult($result); + } + + return $existing_indexes; + } } From e2784d01cee227a56f2ad7bcaee4b796dbf6dde6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 12 Apr 2014 12:42:32 +0200 Subject: [PATCH 084/424] [ticket/12012] Fix tools::mssql_get_existing_indexes() for SQL Server 2000 PHPBB3-12012 --- phpBB/phpbb/db/tools.php | 50 +++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 1299df51dd..c2285bcf80 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -2568,28 +2568,50 @@ class tools $mssql_server_properties = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); - // Remove default constraints if ($mssql_server_properties['mssql_version'][0] == '8') // SQL Server 2000 { // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx // Deprecated in SQL Server 2005 - /** - * @todo Fix for SQL Server 2000 - $sql = "SELECT so.name AS def_name - FROM sysobjects so - JOIN sysconstraints sc ON so.id = sc.constid - WHERE object_name(so.parent_obj) = '{$table_name}' - AND so.xtype = 'D' - AND sc.colid = (SELECT colid FROM syscolumns - WHERE id = object_id('{$table_name}') - AND name = '{$column_name}')"; + $sql = "SELECT DISTINCT ix.name AS phpbb_index_name + FROM sysindexes ix + INNER JOIN sysindexkeys ixc + ON ixc.id = ix.id + AND ixc.indid = ix.indid + INNER JOIN syscolumns cols + ON cols.colid = ixc.colid + AND cols.id = ix.id + WHERE ix.id = object_id('{$table_name}') + AND cols.name = '{$column_name}'"; $result = $this->db->sql_query($sql); + $existing_indexes = array(); while ($row = $this->db->sql_fetchrow($result)) { - $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; + $existing_indexes[$row['phpbb_index_name']] = array(); + } + $this->db->sql_freeresult($result); + + if (empty($existing_indexes)) + { + return array(); + } + + $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name + FROM sysindexes ix + INNER JOIN sysindexkeys ixc + ON ixc.id = ix.id + AND ixc.indid = ix.indid + INNER JOIN syscolumns cols + ON cols.colid = ixc.colid + AND cols.id = ix.id + WHERE ix.id = object_id('{$table_name}') + AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $existing_indexes[$row['phpbb_index_name']][] = $row['phpbb_column_name']; } $this->db->sql_freeresult($result); - */ } else { @@ -2600,7 +2622,7 @@ class tools AND ixc.index_id = ix.index_id INNER JOIN sys.columns cols ON cols.column_id = ixc.column_id - AND cols.object_id = ix.object_id + AND cols.object_id = ix.object_id WHERE ix.object_id = object_id('{$table_name}') AND cols.name = '{$column_name}'"; $result = $this->db->sql_query($sql); From 190b4282df5c5c81123b1ed371eeada385831e99 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 16:43:57 +0200 Subject: [PATCH 085/424] [ticket/12012] Return SQL statements for index drop/create Otherwise we recreate the index before changing the column PHPBB3-12012 --- phpBB/phpbb/db/tools.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index c2285bcf80..113059900a 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -2336,21 +2336,32 @@ class tools case 'mssql': case 'mssqlnative': + // We need the data here + $old_return_statements = $this->return_statements; + $this->return_statements = true; + $indexes = $this->mssql_get_existing_indexes($table_name, $column_name); + // Drop any indexes if (!empty($indexes)) { foreach ($indexes as $index_name => $index_data) { - $this->sql_index_drop($table_name, $index_name); + $result = $this->sql_index_drop($table_name, $index_name); + $statements = array_merge($statements, $result); } } - $statements = $this->mssql_drop_default_constraints($table_name, $column_name); + // Drop default value constraint + $result = $this->mssql_drop_default_constraints($table_name, $column_name); + $statements = array_merge($statements, $result); + + // Change the column $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; if (!empty($column_data['default'])) { + // Add new default value constraint $statements[] = 'ALTER TABLE [' . $table_name . '] ADD CONSTRAINT [DF_' . $table_name . '_' . $column_name . '_1] ' . $this->db->sql_escape($column_data['default']) . ' FOR [' . $column_name . ']'; } @@ -2359,9 +2370,12 @@ class tools // Recreate indexes after we changed the column foreach ($indexes as $index_name => $index_data) { - $this->sql_create_index($table_name, $index_name, $index_data); + $result = $this->sql_create_index($table_name, $index_name, $index_data); + $statements = array_merge($statements, $result); } } + + $this->return_statements = $old_return_statements; break; case 'mysql_40': From a48f1abf6693eaee3343abd4f4a7e6412ecc10d9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 14 Apr 2014 16:29:21 +0200 Subject: [PATCH 086/424] [ticket/12012] Add a unit test for changing the column type PHPBB3-12012 --- tests/dbal/db_tools_test.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index e25335165a..0715b09ea3 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -11,7 +11,9 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_dbal_db_tools_test extends phpbb_database_test_case { + /** @var \phpbb\db\driver\driver_interface */ protected $db; + /** @var \phpbb\db\tools */ protected $tools; protected $table_exists; protected $table_data; @@ -207,6 +209,32 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'column_does_not_exist')); } + public function test_column_change_with_index() + { + // Create column + $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012')); + $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_12012', array('DECIMAL', 0))); + $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012')); + + // Create index over the column + $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012')); + $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'i_bug_12012', array('c_bug_12012', 'c_bool'))); + $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012')); + + // Change type from int to string + $this->assertTrue($this->tools->sql_column_change('prefix_table_name', 'c_bug_12012', array('VCHAR:100', ''))); + + // Remove the index + $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012')); + $this->assertTrue($this->tools->sql_index_drop('prefix_table_name', 'i_bug_12012')); + $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012')); + + // Remove the column + $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012')); + $this->assertTrue($this->tools->sql_column_remove('prefix_table_name', 'c_bug_12012')); + $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012')); + } + public function test_column_remove() { $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_int_size')); @@ -252,7 +280,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case $this->assertFalse($this->tools->sql_table_exists('prefix_test_table')); } - public function test_peform_schema_changes_drop_tables() + public function test_perform_schema_changes_drop_tables() { $db_tools = $this->getMock('\phpbb\db\tools', array( 'sql_table_exists', @@ -278,7 +306,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case )); } - public function test_peform_schema_changes_drop_columns() + public function test_perform_schema_changes_drop_columns() { $db_tools = $this->getMock('\phpbb\db\tools', array( 'sql_column_exists', From 540384890258a22860d655086521c968b30bcbea Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 14 Apr 2014 17:21:27 +0200 Subject: [PATCH 087/424] [ticket/12012] Add a unit test for removing a column with indexes PHPBB3-12012 --- tests/dbal/db_tools_test.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 0715b09ea3..df8f22083b 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -244,6 +244,28 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_int_size')); } + public function test_column_remove_with_index() + { + // Create column + $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2')); + $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_12012_2', array('UINT', 4))); + $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2')); + + // Create index over the column + $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_2')); + $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'i_bug_12012_2', array('c_bug_12012_2', 'c_bool'))); + $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_2')); + + $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_3')); + $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'i_bug_12012_3', array('c_bug_12012_2'))); + $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_3')); + + // Remove the column + $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2')); + $this->assertTrue($this->tools->sql_column_remove('prefix_table_name', 'c_bug_12012_2')); + $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2')); + } + public function test_column_remove_primary() { $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_id')); From 7dc163f2b7f483e4abb46015c0e41b47cddfd757 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 14 Apr 2014 17:21:53 +0200 Subject: [PATCH 088/424] [ticket/12012] Drop and recreate indexes when removing columns PHPBB3-12012 --- phpBB/phpbb/db/tools.php | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 113059900a..bc505010ba 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -1846,15 +1846,46 @@ class tools case 'mssql': case 'mssqlnative': + // We need the data here + $old_return_statements = $this->return_statements; + $this->return_statements = true; + $indexes = $this->mssql_get_existing_indexes($table_name, $column_name); + // Drop any indexes + $recreate_indexes = array(); if (!empty($indexes)) { - trigger_error("Column '$column_name' on table '$table_name' is still part of an index and can not be removed: " . implode(', ', array_keys($indexes)), E_USER_ERROR); + foreach ($indexes as $index_name => $index_data) + { + $result = $this->sql_index_drop($table_name, $index_name); + $statements = array_merge($statements, $result); + if (sizeof($index_data) > 1) + { + // Remove this column from the index and recreate it + $recreate_indexes[$index_name] = array_diff($index_data, array($column_name)); + } + } } - $statements = $this->mssql_drop_default_constraints($table_name, $column_name); + // Drop default value constraint + $result = $this->mssql_drop_default_constraints($table_name, $column_name); + $statements = array_merge($statements, $result); + + // Remove the column $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; + + if (!empty($recreate_indexes)) + { + // Recreate indexes after we removed the column + foreach ($recreate_indexes as $index_name => $index_data) + { + $result = $this->sql_create_index($table_name, $index_name, $index_data); + $statements = array_merge($statements, $result); + } + } + + $this->return_statements = $old_return_statements; break; case 'mysql_40': From a75ac5efd24694bf8edb85d0e4f8cb35853f94ca Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Apr 2014 20:59:28 +0200 Subject: [PATCH 089/424] [ticket/12012] Handle begin and commit transactions in tests PHPBB3-12012 --- .../phpbb_database_test_connection_manager.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index f6429b1ccb..431cee5588 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -14,6 +14,7 @@ class phpbb_database_test_connection_manager { private $config; private $dbms; + /** @var PDO */ private $pdo; /** @@ -363,9 +364,21 @@ class phpbb_database_test_connection_manager $table_name, $table_data ); + foreach ($queries as $query) { - $this->pdo->exec($query); + if ($query === 'begin') + { + $this->pdo->beginTransaction(); + } + else if ($query === 'commit') + { + $this->pdo->commit(); + } + else + { + $this->pdo->exec($query); + } } } } From 40c685e6fcbe3e5e9d2626f2b5ce46b6665d8a33 Mon Sep 17 00:00:00 2001 From: Markus Stenudd Date: Sat, 30 Nov 2013 16:01:26 +0100 Subject: [PATCH 090/424] [ticket/8558] Add display name in emails from board PHPBB3-8558 --- phpBB/includes/acp/acp_board.php | 1 + phpBB/includes/functions_messenger.php | 18 ++++++++++++++++-- phpBB/language/en/acp/board.php | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 2c0eb95cd5..731218a835 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -434,6 +434,7 @@ class acp_board 'email_function_name' => array('lang' => 'EMAIL_FUNCTION_NAME', 'validate' => 'string', 'type' => 'text:20:50', 'explain' => true), 'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'validate' => 'int:0', 'type' => 'number:0:99999', 'explain' => true), 'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'email', 'type' => 'email:25:100', 'explain' => true), + 'board_contact_name' => array('lang' => 'CONTACT_EMAIL_NAME', 'validate' => 'string', 'type' => 'text:30:50', 'explain' => true), 'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'email', 'type' => 'email:25:100', 'explain' => true), 'board_email_sig' => array('lang' => 'EMAIL_SIG', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true), 'board_hide_emails' => array('lang' => 'BOARD_HIDE_EMAILS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 907252f6d8..ddbceae4de 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -486,12 +486,26 @@ class messenger if (empty($this->replyto)) { - $this->replyto = '<' . $config['board_contact'] . '>'; + if ($config['board_contact_name']) + { + $this->replyto = '"' . mail_encode($config['board_contact_name']) . '" <' . $config['board_contact'] . '>'; + } + else + { + $this->replyto = '<' . $config['board_contact'] . '>'; + } } if (empty($this->from)) { - $this->from = '<' . $config['board_contact'] . '>'; + if ($config['board_contact_name']) + { + $this->from = '"' . mail_encode($config['board_contact_name']) . '" <' . $config['board_contact'] . '>'; + } + else + { + $this->from = '<' . $config['board_contact'] . '>'; + } } $encode_eol = ($config['smtp_delivery']) ? "\r\n" : $this->eol; diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 1d2c979e0c..5ca2c9ea45 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -524,6 +524,8 @@ $lang = array_merge($lang, array( 'BOARD_HIDE_EMAILS_EXPLAIN' => 'This function keeps email addresses completely private.', 'CONTACT_EMAIL' => 'Contact email address', 'CONTACT_EMAIL_EXPLAIN' => 'This address will be used whenever a specific contact point is needed, e.g. spam, error output, etc. It will always be used as the From and Reply-To address in emails.', + 'CONTACT_EMAIL_NAME' => 'Contact name', + 'CONTACT_EMAIL_NAME_EXPLAIN' => 'This is the contact name that e-mail recipients see. Leave blank to just send the e-mail address', 'EMAIL_FUNCTION_NAME' => 'Email function name', 'EMAIL_FUNCTION_NAME_EXPLAIN' => 'The email function used to send mails through PHP.', 'EMAIL_PACKAGE_SIZE' => 'Email package size', From 71422e51801e81a69465530bfe9e8409fef0460f Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 15 Apr 2014 00:42:22 +0800 Subject: [PATCH 091/424] [ticket/12409] Add acp_users.php core events to modify users preferences data There're events to modify UCP user preferences in ucp_prefs.php, so it makes sense to add related events to acp_users.php to control new user's prefs via ACP. PHPBB3-12409 --- phpBB/includes/acp/acp_users.php | 90 +++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 25 deletions(-) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index a720334ed2..67d5f62696 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1503,6 +1503,17 @@ class acp_users 'notify' => request_var('notify', $user_row['user_notify']), ); + /** + * Modify users preferences data + * + * @event core.acp_users_prefs_modify_data + * @var array data Array with users preferences data + * @var array user_row Array with user data + * @since 3.1.0-b3 + */ + $vars = array('data', 'user_row'); + extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_data', compact($vars))); + if ($submit) { $error = validate_data($data, array( @@ -1559,37 +1570,53 @@ class acp_users 'user_notify' => $data['notify'], ); - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE user_id = $user_id"; - $db->sql_query($sql); + /** + * Modify SQL query before users preferences are updated + * + * @event core.acp_users_prefs_modify_sql + * @var array data Array with users preferences data + * @var array user_row Array with user data + * @var array sql_ary SQL array with users preferences data to update + * @var array error Array with errors data + * @since 3.1.0-b3 + */ + $vars = array('data', 'user_row', 'sql_ary', 'error'); + extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_sql', compact($vars))); - // Check if user has an active session - if ($user_row['session_id']) + if (!sizeof($error)) { - // We'll update the session if user_allow_viewonline has changed and the user is a bot - // Or if it's a regular user and the admin set it to hide the session - if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE - || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline']) + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE user_id = $user_id"; + $db->sql_query($sql); + + // Check if user has an active session + if ($user_row['session_id']) { - // We also need to check if the user has the permission to cloak. - $user_auth = new \phpbb\auth\auth(); - $user_auth->acl($user_row); + // We'll update the session if user_allow_viewonline has changed and the user is a bot + // Or if it's a regular user and the admin set it to hide the session + if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE + || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline']) + { + // We also need to check if the user has the permission to cloak. + $user_auth = new \phpbb\auth\auth(); + $user_auth->acl($user_row); - $session_sql_ary = array( - 'session_viewonline' => ($user_auth->acl_get('u_hideonline')) ? $sql_ary['user_allow_viewonline'] : true, - ); + $session_sql_ary = array( + 'session_viewonline' => ($user_auth->acl_get('u_hideonline')) ? $sql_ary['user_allow_viewonline'] : true, + ); - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . " - WHERE session_user_id = $user_id"; - $db->sql_query($sql); + $sql = 'UPDATE ' . SESSIONS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . " + WHERE session_user_id = $user_id"; + $db->sql_query($sql); - unset($user_auth); + unset($user_auth); + } } - } - trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); + trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); + } } // Replace "error" strings with their real, localised form @@ -1653,7 +1680,7 @@ class acp_users } $timezone_selects = phpbb_timezone_select($user, $data['tz'], true); - $template->assign_vars(array( + $user_prefs_data = array( 'S_PREFS' => true, 'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true, @@ -1693,9 +1720,22 @@ class acp_users 'S_STYLE_OPTIONS' => style_select($data['style']), 'S_TZ_OPTIONS' => $timezone_selects['tz_select'], 'S_TZ_DATE_OPTIONS' => $timezone_selects['tz_dates'], - ) ); + /** + * Modify users preferences data before assigning it to the template + * + * @event core.acp_users_prefs_modify_template_data + * @var array data Array with users preferences data + * @var array user_row Array with user data + * @var array user_prefs_data Array with users preferences data to be assigned to the template + * @since 3.1.0-b3 + */ + $vars = array('data', 'user_row', 'user_prefs_data'); + extract($phpbb_dispatcher->trigger_event('core.acp_users_prefs_modify_template_data', compact($vars))); + + $template->assign_vars($user_prefs_data); + break; case 'avatar': From 809054abfd18d08cc209e7adfbe99e805276aeb7 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 17 Apr 2014 15:17:54 +0200 Subject: [PATCH 092/424] [ticket/8558] Add config in migrations and schema_data PHPBB3-8558 --- phpBB/install/schemas/schema_data.sql | 1 + .../data/v310/board_contact_name.php | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/board_contact_name.php diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index bc76bf55b9..fbf1374346 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -56,6 +56,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_min_width', INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_path', 'images/avatars/upload'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_salt', 'phpbb_avatar'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact', 'contact@yourdomain.tld'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact_name', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable_msg', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email', 'address@yourdomain.tld'); diff --git a/phpBB/phpbb/db/migration/data/v310/board_contact_name.php b/phpBB/phpbb/db/migration/data/v310/board_contact_name.php new file mode 100644 index 0000000000..37b4d50545 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/board_contact_name.php @@ -0,0 +1,30 @@ +config['board_contact_name']); + } + + static public function depends_on() + { + return array('\phpbb\db\migration\data\v310\beta2'); + } + + public function update_data() + { + return array( + array('config.add', array('board_contact_name', '')), + ); + } +} From 59cdc26fb41d2bccb6da42af86125ea7fe2af8c8 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 17 Apr 2014 21:59:23 +0200 Subject: [PATCH 093/424] [ticket/8558] Use only one variable and improve explain string PHPBB3-8558 --- phpBB/includes/functions_messenger.php | 20 ++++---------------- phpBB/language/en/acp/board.php | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index ddbceae4de..73604d591b 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -484,28 +484,16 @@ class messenger $use_queue = true; } + $board_contact = (($config['board_contact_name']) ? '"' . mail_encode($config['board_contact_name']) . '" ' : '') . '<' . $config['board_contact'] . '>'; + if (empty($this->replyto)) { - if ($config['board_contact_name']) - { - $this->replyto = '"' . mail_encode($config['board_contact_name']) . '" <' . $config['board_contact'] . '>'; - } - else - { - $this->replyto = '<' . $config['board_contact'] . '>'; - } + $this->replyto = $board_contact; } if (empty($this->from)) { - if ($config['board_contact_name']) - { - $this->from = '"' . mail_encode($config['board_contact_name']) . '" <' . $config['board_contact'] . '>'; - } - else - { - $this->from = '<' . $config['board_contact'] . '>'; - } + $this->from = $board_contact; } $encode_eol = ($config['smtp_delivery']) ? "\r\n" : $this->eol; diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 5ca2c9ea45..696e82324c 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -525,7 +525,7 @@ $lang = array_merge($lang, array( 'CONTACT_EMAIL' => 'Contact email address', 'CONTACT_EMAIL_EXPLAIN' => 'This address will be used whenever a specific contact point is needed, e.g. spam, error output, etc. It will always be used as the From and Reply-To address in emails.', 'CONTACT_EMAIL_NAME' => 'Contact name', - 'CONTACT_EMAIL_NAME_EXPLAIN' => 'This is the contact name that e-mail recipients see. Leave blank to just send the e-mail address', + 'CONTACT_EMAIL_NAME_EXPLAIN' => 'This is the contact name that e-mail recipients will see. If you don’t want to have a contact name, leave this field empty.', 'EMAIL_FUNCTION_NAME' => 'Email function name', 'EMAIL_FUNCTION_NAME_EXPLAIN' => 'The email function used to send mails through PHP.', 'EMAIL_PACKAGE_SIZE' => 'Email package size', From 933dcde805faa2cd0c74ba797c65281af65ed3a8 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 17 Apr 2014 23:13:36 +0200 Subject: [PATCH 094/424] [ticket/8558] Fix field length in ACP PHPBB3-8558 --- phpBB/includes/acp/acp_board.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 731218a835..6b52fbbdb2 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -434,7 +434,7 @@ class acp_board 'email_function_name' => array('lang' => 'EMAIL_FUNCTION_NAME', 'validate' => 'string', 'type' => 'text:20:50', 'explain' => true), 'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'validate' => 'int:0', 'type' => 'number:0:99999', 'explain' => true), 'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'email', 'type' => 'email:25:100', 'explain' => true), - 'board_contact_name' => array('lang' => 'CONTACT_EMAIL_NAME', 'validate' => 'string', 'type' => 'text:30:50', 'explain' => true), + 'board_contact_name' => array('lang' => 'CONTACT_EMAIL_NAME', 'validate' => 'string', 'type' => 'text:25:50', 'explain' => true), 'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'email', 'type' => 'email:25:100', 'explain' => true), 'board_email_sig' => array('lang' => 'EMAIL_SIG', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true), 'board_hide_emails' => array('lang' => 'BOARD_HIDE_EMAILS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), From 5008cbf903114047d45f93c88d8ea1444ed377cc Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 17 Apr 2014 17:39:42 +0200 Subject: [PATCH 095/424] [ticket/12418] Notice displayed for feed.php https://tracker.phpbb.com/browse/PHPBB3-12418 language/viewtopic.php isn't loaded, so MISSING_INLINE_ATTACHMENT isn't available. PHPBB3-12418 --- phpBB/feed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index c31a6b6b1d..9ff8c66b9d 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -37,7 +37,7 @@ if (!empty($config['feed_http_auth']) && request_var('auth', '') == 'http') } $auth->acl($user->data); -$user->setup(); +$user->setup('viewtopic'); // Initial var setup $forum_id = request_var('f', 0); From 22de4a5927eccf05d614a6da7f6eb6f993838487 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 17 Apr 2014 15:00:14 +0200 Subject: [PATCH 096/424] [ticket/12273] Add a basic set of tests for the exporter PHPBB3-12273 --- phpBB/develop/event_exporter.php | 424 ++++++++++++++++++ tests/event/exporter_test.php | 341 ++++++++++++++ tests/event/fixtures/default.test | 9 + tests/event/fixtures/extra_description.test | 11 + .../event/fixtures/legacy_alpha1_version.test | 9 + 5 files changed, 794 insertions(+) create mode 100644 phpBB/develop/event_exporter.php create mode 100644 tests/event/exporter_test.php create mode 100644 tests/event/fixtures/default.test create mode 100644 tests/event/fixtures/extra_description.test create mode 100644 tests/event/fixtures/legacy_alpha1_version.test diff --git a/phpBB/develop/event_exporter.php b/phpBB/develop/event_exporter.php new file mode 100644 index 0000000000..6277433423 --- /dev/null +++ b/phpBB/develop/event_exporter.php @@ -0,0 +1,424 @@ +root_path = $phpbb_root_path; + } + + function export_from_eventsmd($filter) + { + $file_content = file_get_contents($this->root_path . 'docs/events.md'); + + $events = explode("\n\n", $file_content); + foreach ($events as $event) + { + // Last row of the file + if (strpos($event, "\n===\n") === false) continue; + + list($event_name, $details) = explode("\n===\n", $event); + + if ($filter == 'acp' && strpos($event_name, 'acp_') !== 0) continue; + if ($filter == 'styles' && strpos($event_name, 'acp_') === 0) continue; + + list($file_details, $details) = explode("\n* Since: ", $details); + list($version, $explanition) = explode("\n* Purpose: ", $details); + + echo "|- id=\"{$event_name}\"\n"; + echo "| [[#{$event_name}|{$event_name}]] || "; + + if (strpos($file_details, "* Locations:\n + ") === 0) + { + $file_details = substr($file_details, strlen("* Locations:\n + ")); + $files = explode("\n + ", $file_details); + $prosilver = $subsilver2 = $adm = array(); + foreach ($files as $file) + { + if (strpos($file, 'styles/prosilver/template/') === 0) + { + $prosilver[] = substr($file, strlen('styles/prosilver/template/')); + } + if (strpos($file, 'styles/subsilver2/template/') === 0) + { + $subsilver2[] = substr($file, strlen('styles/subsilver2/template/')); + } + if (strpos($file, 'adm/style/') === 0) + { + $adm[] = substr($file, strlen('adm/style/')); + } + } + if ($filter == 'acp') + { + echo implode(', ', $adm); + } + else + { + echo implode(', ', $prosilver) . ' || ' . implode(', ', $subsilver2); + } + } + else if ($filter == 'acp') + { + echo substr($file_details, strlen("* Location: adm/style/")); + } + echo " || {$version} || " . str_replace("\n", ' ', $explanition) . "\n"; + + } + } + + function export_from_php() + { + $files = $this->get_file_list($this->root_path); + $events = array(); + foreach ($files as $file) + { + $file_events = $this->check_for_events($file); + if (!empty($file_events)) + { + $events = array_merge($events, $file_events); + } + } + ksort($events); + + foreach ($events as $event) + { + echo '|- id="' . $event['event'] . '"' . "\n"; + echo '| [[#' . $event['event'] . '|' . $event['event'] . ']] || ' . $event['file'] . ' || ' . implode(', ', $event['arguments']) . ' || ' . $event['since'] . ' || ' . $event['description'] . "\n"; + } + } + + public function check_for_events($file) + { + $events = array(); + $content = file_get_contents($this->root_path . $file); + + if (strpos($content, "phpbb_dispatcher->trigger_event('") || strpos($content, "phpbb_dispatcher->dispatch('")) + { + $lines = explode("\n", $content); + for ($i = 0, $num_lines = sizeof($lines); $i < $num_lines; $i++) + { + $event_line = 0; + $found_trigger_event = strpos($lines[$i], "phpbb_dispatcher->trigger_event('"); + if ($found_trigger_event !== false) + { + $event_line = $i; + $event_name = $lines[$event_line]; + $event_name = substr($event_name, $found_trigger_event + strlen("phpbb_dispatcher->trigger_event('")); + $event_name = substr($event_name, 0, strpos($event_name, "'")); + + $current_line = trim($lines[$event_line]); + $arguments = array(); + $found_inline_array = strpos($current_line, "', compact(array('"); + if ($found_inline_array !== false) + { + $varsarray = substr($current_line, $found_inline_array + strlen("', compact(array('"), -6); + $arguments = explode("', '", $varsarray); + } + + if (empty($arguments)) + { + // Find $vars array lines + $find_varsarray_line = 1; + while (strpos($lines[$event_line - $find_varsarray_line], "\$vars = array('") === false) + { + $find_varsarray_line++; + + if ($find_varsarray_line > min(50, $event_line)) + { + throw new LogicException('Can not find "$vars = array()"-line for event "' . $event_name . '" in file "' . $file . '"'); + } + } + $varsarray = substr(trim($lines[$event_line - $find_varsarray_line]), strlen("\$vars = array('"), -3); + $arguments = explode("', '", $varsarray); + } + + // Validate $vars array with @var + $find_vars_line = 3; + $doc_vars = array(); + while (strpos(trim($lines[$event_line - $find_vars_line]), '*') === 0) + { + $var_line = trim($lines[$event_line - $find_vars_line]); + $var_line = preg_replace('!\s+!', ' ', $var_line); + if (strpos($var_line, '* @var ') === 0) + { + $doc_line = explode(' ', $var_line); + if (isset($doc_line[3])) + { + $doc_vars[] = $doc_line[3]; + } + } + $find_vars_line++; + } + if (sizeof($arguments) !== sizeof($doc_vars) && array_intersect($arguments, $doc_vars)) + { + throw new LogicException('$vars array does not match the list of @var tags for event "' . $event_name . '" in file "' . $file . '"'); + } + } + $found_dispatch = strpos($lines[$i], "phpbb_dispatcher->dispatch('"); + if ($found_dispatch !== false) + { + $event_line = $i; + $event_name = $lines[$event_line]; + $event_name = substr($event_name, $found_dispatch + strlen("phpbb_dispatcher->dispatch('")); + $event_name = substr($event_name, 0, strpos($event_name, "'")); + $arguments = array(); + } + + if ($event_line) + { + // Validate @event + $event_line_num = $this->find_event($file, $event_name, $lines, $event_line); + $this->validate_event($file, $event_name, $lines[$event_line_num]); + + // Validate @since + $since_line_num = $this->find_since($file, $event_name, $lines, $event_line); + $since = $this->validate_since($file, $event_name, $lines[$since_line_num]); + + // Find event description line + $description_line_num = $this->find_description($file, $event_name, $lines, $event_line); + $description = substr(trim($lines[$description_line_num]), strlen('* ')); + + $events[$event_name] = array( + 'event' => $event_name, + 'file' => $file, + 'arguments' => $arguments, + 'since' => $since, + 'description' => $description, + ); + } + } + } + + return $events; + } + + /** + * Find the "@since" Information line + * + * @param string $file + * @param string $event_name + * @param string $lines + * @param int $event_line Index of the event call in $lines + * @return int Absolute line number + */ + public function find_since($file, $event_name, $lines, $event_line) + { + return $this->find_tag($file, $event_name, $lines, $event_line, 'since', array('event', 'var')); + } + + /** + * Find the "@event" Information line + * + * @param string $file + * @param string $event_name + * @param string $lines + * @param int $event_line Index of the event call in $lines + * @return int Absolute line number + */ + public function find_event($file, $event_name, $lines, $event_line) + { + return $this->find_tag($file, $event_name, $lines, $event_line, 'event', array()); + } + + /** + * Find a "@*" Information line + * + * @param string $file + * @param string $event_name + * @param string $lines + * @param int $event_line Index of the event call in $lines + * @param string $find_tag Name of the tag we are trying to find + * @param array $disallowed_tags List of tags that must not appear between + * the tag and the actual event + * @return int Absolute line number + */ + public function find_tag($file, $event_name, $lines, $event_line, $find_tag, $disallowed_tags) + { + $find_tag_line = 0; + $found_comment_end = false; + while (strpos(ltrim($lines[$event_line - $find_tag_line], "\t"), '* @' . $find_tag . ' ') !== 0) + { + if ($found_comment_end && ltrim($lines[$event_line - $find_tag_line], "\t") === '/**') + { + // Reached the start of this doc block + throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $event_name . '" in file "' . $file . '"', 1); + } + + foreach ($disallowed_tags as $disallowed_tag) + { + if ($found_comment_end && strpos(ltrim($lines[$event_line - $find_tag_line], "\t"), '* @' . $disallowed_tag) === 0) + { + // Found @var after the @since + throw new LogicException('Found @' . $disallowed_tag . ' information after @' . $find_tag . ' for event "' . $event_name . '" in file "' . $file . '"', 3); + } + } + + if (ltrim($lines[$event_line - $find_tag_line], "\t") === '*/') + { + $found_comment_end = true; + } + + $find_tag_line++; + if ($find_tag_line >= $event_line) + { + // Reached the start of the file + throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $event_name . '" in file "' . $file . '"', 2); + } + } + + return $event_line - $find_tag_line; + } + + /** + * Find a "@*" Information line + * + * @param string $file + * @param string $event_name + * @param string $lines + * @param int $event_line Index of the event call in $lines + * @return int Absolute line number + */ + public function find_description($file, $event_name, $lines, $event_line) + { + $find_desc_line = 0; + while (ltrim($lines[$event_line - $find_desc_line], "\t") !== '/**') + { + $find_desc_line++; + if ($find_desc_line > $event_line) + { + // Reached the start of the file + throw new LogicException('Can not find a description for event "' . $event_name . '" in file "' . $file . '"', 1); + } + } + + $find_desc_line = $event_line - $find_desc_line + 1; + + $desc = trim($lines[$find_desc_line]); + if (strpos($desc, '* @') === 0 || $desc[0] !== '*' || substr($desc, 1) == '') + { + // First line of the doc block is a @-line, empty or only contains "*" + throw new LogicException('Can not find a description for event "' . $event_name . '" in file "' . $file . '"', 2); + } + + return $find_desc_line; + } + + /** + * Validate "@since" Information + * + * @param string $file + * @param string $event_name + * @param string $line + * @return string + */ + public function validate_since($file, $event_name, $line) + { + $since = substr(ltrim($line, "\t"), strlen('* @since ')); + + if ($since !== trim($since)) + { + throw new LogicException('Invalid @since information for event "' . $event_name . '" in file "' . $file . '"', 1); + } + + $since = ($since === '3.1-A1') ? '3.1.0-a1' : $since; + + if (!preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|rc|pl)\d+)?$#', $since)) + { + throw new LogicException('Invalid @since information for event "' . $event_name . '" in file "' . $file . '"', 2); + } + + return $since; + } + + /** + * Validate "@event" Information + * + * @param string $file + * @param string $event_name + * @param string $line + * @return string + */ + public function validate_event($file, $event_name, $line) + { + $event = substr(ltrim($line, "\t"), strlen('* @event ')); + + if ($event !== trim($event)) + { + throw new LogicException('Invalid @event information for event "' . $event_name . '" in file "' . $file . '"', 1); + } + + if ($event !== $event_name) + { + throw new LogicException('Event name does not match @event tag for event "' . $event_name . '" in file "' . $file . '"', 2); + } + + return $event; + } + + /** + * Returns a list of files in that directory + * + * Works recursive with any depth + * + * @param string $dir Directory to go through + * @return array List of files (including directories from within $dir + */ + function get_file_list($dir, $path = '') + { + try + { + $iterator = new \DirectoryIterator($dir); + } + catch (Exception $e) + { + return array(); + } + + $files = array(); + foreach ($iterator as $file_info) + { + if ($file_info->isDot()) + { + continue; + } + + // Do not scan some directories + if ($file_info->isDir() && ( + ($path == '' && in_array($file_info->getFilename(), array('cache', 'develop', 'ext', 'files', 'language', 'store', 'vendor'))) + || ($path == '/includes' && in_array($file_info->getFilename(), array('utf'))) + || ($path == '/phpbb/db/migration' && in_array($file_info->getFilename(), array('data'))) + || ($path == '/phpbb' && in_array($file_info->getFilename(), array('event'))) + )) + { + continue; + } + else if ($file_info->isDir()) + { + $sub_dir = $this->get_file_list($file_info->getPath() . '/' . $file_info->getFilename(), $path . '/' . $file_info->getFilename()); + foreach ($sub_dir as $file) + { + $files[] = $file_info->getFilename() . '/' . $file; + } + } + else if (substr($file_info->getFilename(), -4) == '.php') + { + $files[] = $file_info->getFilename(); + } + } + + return $files; + } +} diff --git a/tests/event/exporter_test.php b/tests/event/exporter_test.php new file mode 100644 index 0000000000..ee9c9267b2 --- /dev/null +++ b/tests/event/exporter_test.php @@ -0,0 +1,341 @@ +exporter = new \event_exporter(dirname(__FILE__) . '/fixtures/'); + } + + static public function check_for_events_data() + { + return array( + array( + 'default.test', + array( + 'default.dispatch' => array( + 'event' => 'default.dispatch', + 'file' => 'default.test', + 'arguments' => array(), + 'since' => '3.1.0-b2', + 'description' => 'Description', + ), + ), + ), + array( + 'extra_description.test', + array( + 'extra_description.dispatch' => array( + 'event' => 'extra_description.dispatch', + 'file' => 'extra_description.test', + 'arguments' => array(), + 'since' => '3.1.0-b2', + 'description' => 'Description', + ), + ), + ), + array( + 'legacy_alpha1_version.test', + array( + 'legacy_alpha1_version.dispatch' => array( + 'event' => 'legacy_alpha1_version.dispatch', + 'file' => 'legacy_alpha1_version.test', + 'arguments' => array(), + 'since' => '3.1.0-a1', + 'description' => 'Description', + ), + ), + ), + ); + } + + /** + * @dataProvider check_for_events_data + */ + public function test_check_for_events($file, $expected) + { + $this->assertEquals($expected, $this->exporter->check_for_events($file)); + } + + static public function validate_since_data() + { + return array( + array('* @since 3.1.0-a1', '3.1.0-a1'), + array('* @since 3.1.0-b3', '3.1.0-b3'), + array(' * @since 3.1.0-b3', '3.1.0-b3'), + array('* @since 3.1-A1', '3.1.0-a1'), + ); + } + + /** + * @dataProvider validate_since_data + */ + public function test_validate_since($since, $expected) + { + $this->assertEquals($expected, $this->exporter->validate_since('', '', $since)); + } + + static public function validate_since_throws_data() + { + return array( + array(' * @since 3.1.0-a1', 1), + array('* @since 3.1.0-a1 ', 1), + array('* @since 3.1.0-a1 bertie is cool', 2), + array('bertie* @since 3.1.0-a1', 2), + array('* @since 3.1-A2', 2), + array('* @since 3.1-B3', 2), + ); + } + + /** + * @dataProvider validate_since_throws_data + * @expectedException LogicException + */ + public function test_validate_since_throws($since, $exception_code) + { + $this->setExpectedException('LogicException', '', $exception_code); + $this->exporter->validate_since('', '', $since); + } + + static public function validate_event_data() + { + return array( + array('test.event', '* @event test.event', 'test.event'), + array('test.event2', ' * @event test.event2', 'test.event2'), + ); + } + + /** + * @dataProvider validate_event_data + */ + public function test_validate_event($event_name, $event, $expected) + { + $this->assertEquals($expected, $this->exporter->validate_event('', $event_name, $event)); + } + + static public function validate_event_throws_data() + { + return array( + array('test.event', ' * @event test.event', 1), + array('test.event', '* @event test.event bertie is cool', 2), + array('test.event', 'bertie* @event test.event', 2), + ); + } + + /** + * @dataProvider validate_event_throws_data + * @expectedException LogicException + */ + public function test_validate_event_throws($event_name, $event, $exception_code) + { + $this->setExpectedException('LogicException', '', $exception_code); + $this->exporter->validate_event('', $event_name, $event); + } + + static public function find_since_data() + { + return array( + array( + array( + '/**', + '* @since 3.1.0-a1', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 3, + 1, + ), + array( + array( + '* @since 3.1.0-a1', + '/**', + '* @since 3.1.0-a1', + '* @changed 3.1.0-a2', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 5, + 2, + ), + ); + } + + /** + * @dataProvider find_since_data + */ + public function test_find_since($lines, $event_line, $expected) + { + $this->assertEquals($expected, $this->exporter->find_since('', '', $lines, $event_line)); + } + + static public function find_since_throws_data() + { + return array( + array( + array( + '/**', + '* @since 3.1.0-a1', + '*/', + '/**', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 5, + 1, + ), + array( + array( + '/**', + '* @changed 3.1.0-a1', + '* @changed 3.1.0-a2', + '* @changed 3.1.0-a3', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 5, + 2, + ), + array( + array( + '/**', + '* @since 3.1.0-a2', + '* @var', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 4, + 3, + ), + array( + array( + '/**', + '* @since 3.1.0-a2', + '* @event', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 4, + 3, + ), + ); + } + + /** + * @dataProvider find_since_throws_data + * @expectedException LogicException + */ + public function test_find_since_throws($lines, $event_line, $exception_code) + { + $this->setExpectedException('LogicException', '', $exception_code); + $this->exporter->find_since('', '', $lines, $event_line); + } + + static public function find_description_data() + { + return array( + array( + array( + '/**', + '* Hello Bertie!', + '* @since 3.1.0-a1', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 4, + 1, + ), + array( + array( + ' /**', + ' * Hello Bertie!', + ' *', + ' * @since 3.1.0-a1', + ' * @changed 3.1.0-a2', + ' */', + ' $phpbb_dispatcher->dispatch(\'test\');', + ), + 6, + 1, + ), + ); + } + + /** + * @dataProvider find_description_data + */ + public function test_find_description($lines, $event_line, $expected) + { + $this->assertEquals($expected, $this->exporter->find_description('', '', $lines, $event_line)); + } + + static public function find_description_throws_data() + { + return array( + array( + array( + '$vars = array();', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 1, + 1, + ), + array( + array( + '/**', + '* @changed 3.1.0-a1', + '* @changed 3.1.0-a2', + '* @changed 3.1.0-a3', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 5, + 2, + ), + array( + array( + '/**', + '*', + '* @since 3.1.0-a2', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 4, + 2, + ), + array( + array( + '/**', + '* ', + '* @event', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 4, + 2, + ), + ); + } + + /** + * @dataProvider find_description_throws_data + * @expectedException LogicException + */ + public function test_find_description_throws($lines, $event_line, $exception_code) + { + $this->setExpectedException('LogicException', '', $exception_code); + $this->exporter->find_description('', '', $lines, $event_line); + } +} diff --git a/tests/event/fixtures/default.test b/tests/event/fixtures/default.test new file mode 100644 index 0000000000..edfe4823dc --- /dev/null +++ b/tests/event/fixtures/default.test @@ -0,0 +1,9 @@ +dispatch('default.dispatch'); diff --git a/tests/event/fixtures/extra_description.test b/tests/event/fixtures/extra_description.test new file mode 100644 index 0000000000..ce8f97ce89 --- /dev/null +++ b/tests/event/fixtures/extra_description.test @@ -0,0 +1,11 @@ +dispatch('extra_description.dispatch'); diff --git a/tests/event/fixtures/legacy_alpha1_version.test b/tests/event/fixtures/legacy_alpha1_version.test new file mode 100644 index 0000000000..064af4daf8 --- /dev/null +++ b/tests/event/fixtures/legacy_alpha1_version.test @@ -0,0 +1,9 @@ +dispatch('legacy_alpha1_version.dispatch'); From 6c57edf3a3f9ff260ef0b1d5dbe7db004dd9a51d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 17 Apr 2014 15:03:48 +0200 Subject: [PATCH 097/424] [ticket/12273] Use the new class PHPBB3-12273 --- phpBB/develop/export_events_for_wiki.php | 280 +---------------------- 1 file changed, 5 insertions(+), 275 deletions(-) diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php index 3021b64e05..0c4f14a4b4 100644 --- a/phpBB/develop/export_events_for_wiki.php +++ b/phpBB/develop/export_events_for_wiki.php @@ -13,6 +13,7 @@ if (php_sapi_name() != 'cli') $phpEx = substr(strrchr(__FILE__, '.'), 1); $phpbb_root_path = __DIR__ . '/../'; +require __DIR__ . '/event_exporter.' . $phpEx; function usage() { @@ -29,278 +30,6 @@ function usage() exit(2); } -function export_from_eventsmd($phpbb_root_path, $filter) -{ - $file_content = file_get_contents($phpbb_root_path . 'docs/events.md'); - - $events = explode("\n\n", $file_content); - foreach ($events as $event) - { - // Last row of the file - if (strpos($event, "\n===\n") === false) continue; - - list($event_name, $details) = explode("\n===\n", $event); - - if ($filter == 'acp' && strpos($event_name, 'acp_') !== 0) continue; - if ($filter == 'styles' && strpos($event_name, 'acp_') === 0) continue; - - list($file_details, $details) = explode("\n* Since: ", $details); - list($version, $explanition) = explode("\n* Purpose: ", $details); - - echo "|- id=\"{$event_name}\"\n"; - echo "| [[#{$event_name}|{$event_name}]] || "; - - if (strpos($file_details, "* Locations:\n + ") === 0) - { - $file_details = substr($file_details, strlen("* Locations:\n + ")); - $files = explode("\n + ", $file_details); - $prosilver = $subsilver2 = $adm = array(); - foreach ($files as $file) - { - if (strpos($file, 'styles/prosilver/template/') === 0) - { - $prosilver[] = substr($file, strlen('styles/prosilver/template/')); - } - if (strpos($file, 'styles/subsilver2/template/') === 0) - { - $subsilver2[] = substr($file, strlen('styles/subsilver2/template/')); - } - if (strpos($file, 'adm/style/') === 0) - { - $adm[] = substr($file, strlen('adm/style/')); - } - } - if ($filter == 'acp') - { - echo implode(', ', $adm); - } - else - { - echo implode(', ', $prosilver) . ' || ' . implode(', ', $subsilver2); - } - } - else if ($filter == 'acp') - { - echo substr($file_details, strlen("* Location: adm/style/")); - } - echo " || {$version} || " . str_replace("\n", ' ', $explanition) . "\n"; - - } -} - -function export_from_php($phpbb_root_path) -{ - $files = get_file_list($phpbb_root_path); - $events = array(); - foreach ($files as $file) - { - $file_events = check_for_events($phpbb_root_path, $file); - if (!empty($file_events)) - { - $events = array_merge($events, $file_events); - } - } - - ksort($events); - - foreach ($events as $event) - { - echo '|- id="' . $event['event'] . '"' . "\n"; - echo '| [[#' . $event['event'] . '|' . $event['event'] . ']] || ' . $event['file'] . ' || ' . implode(', ', $event['arguments']) . ' || ' . $event['since'] . ' || ' . $event['description'] . "\n"; - } -} - -function check_for_events($phpbb_root_path, $file) -{ - $events = array(); - $content = file_get_contents($phpbb_root_path . $file); - - if (strpos($content, "phpbb_dispatcher->trigger_event('") || strpos($content, "phpbb_dispatcher->dispatch('")) - { - $lines = explode("\n", $content); - for ($i = 0, $num_lines = sizeof($lines); $i < $num_lines; $i++) - { - $event_line = 0; - $found_trigger_event = strpos($lines[$i], "phpbb_dispatcher->trigger_event('"); - if ($found_trigger_event !== false) - { - $event_line = $i; - $event_name = $lines[$event_line]; - $event_name = substr($event_name, $found_trigger_event + strlen("phpbb_dispatcher->trigger_event('")); - $event_name = substr($event_name, 0, strpos($event_name, "'")); - - $current_line = trim($lines[$event_line]); - $arguments = array(); - $found_inline_array = strpos($current_line, "', compact(array('"); - if ($found_inline_array !== false) - { - $varsarray = substr($current_line, $found_inline_array + strlen("', compact(array('"), -6); - $arguments = explode("', '", $varsarray); - } - - if (empty($arguments)) - { - // Find $vars array lines - $find_varsarray_line = 1; - while (strpos($lines[$event_line - $find_varsarray_line], "vars = array('") === false) - { - $find_varsarray_line++; - - if ($find_varsarray_line > min(50, $event_line)) - { - throw new LogicException('Can not find "$vars = array()"-line for event "' . $event_name . '" in file "' . $file . '"'); - } - } - $varsarray = substr(trim($lines[$event_line - $find_varsarray_line]), strlen("\$vars = array('"), -3); - $arguments = explode("', '", $varsarray); - } - - // Validate $vars array with @var - $find_vars_line = 3; - $doc_vars = array(); - while (strpos(trim($lines[$event_line - $find_vars_line]), '*') === 0) - { - $var_line = trim($lines[$event_line - $find_vars_line]); - $var_line = preg_replace('!\s+!', ' ', $var_line); - if (strpos($var_line, '* @var ') === 0) - { - $doc_line = explode(' ', $var_line); - if (isset($doc_line[3])) - { - $doc_vars[] = $doc_line[3]; - } - } - $find_vars_line++; - } - if (sizeof($arguments) !== sizeof($doc_vars) && array_intersect($arguments, $doc_vars)) - { - throw new LogicException('$vars array does not match the list of @var tags for event "' . $event_name . '" in file "' . $file . '"'); - } - } - $found_dispatch = strpos($lines[$i], "phpbb_dispatcher->dispatch('"); - if ($found_dispatch !== false) - { - $event_line = $i; - $event_name = $lines[$event_line]; - $event_name = substr($event_name, $found_dispatch + strlen("phpbb_dispatcher->dispatch('")); - $event_name = substr($event_name, 0, strpos($event_name, "'")); - $arguments = array(); - } - - if ($event_line) - { - // Validate @event name - $find_event_line = 1; - while (strpos($lines[$event_line - $find_event_line], '* @event ') === false) - { - $find_event_line++; - - if ($find_event_line > min(50, $event_line)) - { - throw new LogicException('Can not find @event tag for event "' . $event_name . '" in file "' . $file . '"'); - } - } - $event_name_tag = substr(trim($lines[$event_line - $find_event_line]), strlen('* @event ')); - if ($event_name_tag !== $event_name) - { - throw new LogicException('Event name does not match @event tag for event "' . $event_name . '" in file "' . $file . '"'); - } - - // Find @since - $find_since_line = 1; - while (strpos($lines[$event_line - $find_since_line], '* @since ') === false) - { - $find_since_line++; - - if ($find_since_line > min(50, $event_line)) - { - throw new LogicException('Can not find @since tag for event "' . $event_name . '" in file "' . $file . '"'); - } - } - $since = substr(trim($lines[$event_line - $find_since_line]), strlen('* @since ')); - $since = ($since == '3.1-A1') ? '3.1.0-a1' : $since; - - // Find event description line - $find_description_line = 3; - while (strpos(trim($lines[$event_line - $find_description_line]), '*') === 0) - { - $find_description_line++; - - if ($find_description_line > min(50, $event_line)) - { - throw new LogicException('Can not find description-line for event "' . $event_name . '" in file "' . $file . '"'); - } - } - $description = substr(trim($lines[$event_line - $find_description_line + 1]), strlen('* ')); - - $events[$event_name] = array( - 'event' => $event_name, - 'file' => $file, - 'arguments' => $arguments, - 'since' => $since, - 'description' => $description, - ); - } - } - } - - return $events; -} - -/** -* Returns a list of files in that directory -* -* Works recursive with any depth -* -* @param string $dir Directory to go through -* @return array List of files (including directories from within $dir -*/ -function get_file_list($dir, $path = '') -{ - try - { - $iterator = new \DirectoryIterator($dir); - } - catch (Exception $e) - { - return array(); - } - - $files = array(); - foreach ($iterator as $file_info) - { - if ($file_info->isDot()) - { - continue; - } - - // Do not scan some directories - if ($file_info->isDir() && ( - ($path == '' && in_array($file_info->getFilename(), array('cache', 'develop', 'ext', 'files', 'language', 'store', 'vendor'))) - || ($path == '/includes' && in_array($file_info->getFilename(), array('utf'))) - || ($path == '/phpbb/db/migration' && in_array($file_info->getFilename(), array('data'))) - || ($path == '/phpbb' && in_array($file_info->getFilename(), array('event'))) - )) - { - continue; - } - else if ($file_info->isDir()) - { - $sub_dir = get_file_list($file_info->getPath() . '/' . $file_info->getFilename(), $path . '/' . $file_info->getFilename()); - foreach ($sub_dir as $file) - { - $files[] = $file_info->getFilename() . '/' . $file; - } - } - else if (substr($file_info->getFilename(), -4) == '.php') - { - $files[] = $file_info->getFilename(); - } - } - - return $files; -} - function validate_argument_count($arguments, $count) { if ($arguments <= $count) @@ -312,19 +41,20 @@ function validate_argument_count($arguments, $count) validate_argument_count($argc, 1); $action = $argv[1]; +$exporter = new \event_exporter($phpbb_root_path); switch ($action) { case 'acp': - export_from_eventsmd($phpbb_root_path, 'acp'); + $exporter->export_from_eventsmd('acp'); break; case 'styles': - export_from_eventsmd($phpbb_root_path, 'styles'); + $exporter->export_from_eventsmd('styles'); break; case 'php': - export_from_php($phpbb_root_path); + $exporter->export_from_php(); break; default: From 5387511f89dbb8e7a8edb70b90f5f510aad8779b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 17 Apr 2014 16:55:36 +0200 Subject: [PATCH 098/424] [ticket/12273] Grab name of events with a function PHPBB3-12273 --- phpBB/develop/event_exporter.php | 115 +++++++++++++++++++++---------- 1 file changed, 80 insertions(+), 35 deletions(-) diff --git a/phpBB/develop/event_exporter.php b/phpBB/develop/event_exporter.php index 6277433423..3b4f054ad0 100644 --- a/phpBB/develop/event_exporter.php +++ b/phpBB/develop/event_exporter.php @@ -105,45 +105,26 @@ class event_exporter $events = array(); $content = file_get_contents($this->root_path . $file); - if (strpos($content, "phpbb_dispatcher->trigger_event('") || strpos($content, "phpbb_dispatcher->dispatch('")) + if (strpos($content, "dispatcher->trigger_event('") || strpos($content, "dispatcher->dispatch('")) { $lines = explode("\n", $content); for ($i = 0, $num_lines = sizeof($lines); $i < $num_lines; $i++) { $event_line = 0; - $found_trigger_event = strpos($lines[$i], "phpbb_dispatcher->trigger_event('"); + $found_trigger_event = strpos($lines[$i], "dispatcher->trigger_event('"); if ($found_trigger_event !== false) { $event_line = $i; - $event_name = $lines[$event_line]; - $event_name = substr($event_name, $found_trigger_event + strlen("phpbb_dispatcher->trigger_event('")); - $event_name = substr($event_name, 0, strpos($event_name, "'")); + $event_name = $this->get_trigger_event_name($file, $lines[$event_line]); - $current_line = trim($lines[$event_line]); - $arguments = array(); - $found_inline_array = strpos($current_line, "', compact(array('"); - if ($found_inline_array !== false) + // Find $vars array lines + $vars_line = ltrim($lines[$event_line - 1], "\t"); + if (strpos($vars_line, "\$vars = array('") !== 0) { - $varsarray = substr($current_line, $found_inline_array + strlen("', compact(array('"), -6); - $arguments = explode("', '", $varsarray); - } - - if (empty($arguments)) - { - // Find $vars array lines - $find_varsarray_line = 1; - while (strpos($lines[$event_line - $find_varsarray_line], "\$vars = array('") === false) - { - $find_varsarray_line++; - - if ($find_varsarray_line > min(50, $event_line)) - { - throw new LogicException('Can not find "$vars = array()"-line for event "' . $event_name . '" in file "' . $file . '"'); - } - } - $varsarray = substr(trim($lines[$event_line - $find_varsarray_line]), strlen("\$vars = array('"), -3); - $arguments = explode("', '", $varsarray); + throw new LogicException('Can not find "$vars = array()"-line for event "' . $event_name . '" in file "' . $file . '"'); } + $varsarray = substr($vars_line, strlen("\$vars = array('"), 0 - strlen('\');')); + $arguments = explode("', '", $varsarray); // Validate $vars array with @var $find_vars_line = 3; @@ -167,14 +148,16 @@ class event_exporter throw new LogicException('$vars array does not match the list of @var tags for event "' . $event_name . '" in file "' . $file . '"'); } } - $found_dispatch = strpos($lines[$i], "phpbb_dispatcher->dispatch('"); - if ($found_dispatch !== false) + + if (!$event_line) { - $event_line = $i; - $event_name = $lines[$event_line]; - $event_name = substr($event_name, $found_dispatch + strlen("phpbb_dispatcher->dispatch('")); - $event_name = substr($event_name, 0, strpos($event_name, "'")); - $arguments = array(); + $found_dispatch = strpos($lines[$i], "dispatcher->dispatch('"); + if ($found_dispatch !== false) + { + $event_line = $i; + $event_name = $this->get_dispatch_name($file, $lines[$event_line]); + $arguments = array(); + } } if ($event_line) @@ -205,6 +188,68 @@ class event_exporter return $events; } + /** + * Find the name of the event inside the dispatch() line + * + * @param string $file + * @param string $event_line + * @return int Absolute line number + */ + public function get_dispatch_name($file, $event_line) + { + $event_line = ltrim($event_line, "\t"); + + $regex = '#\$([a-z](?:[a-z0-9_]|->)*)'; + $regex .= '->dispatch\('; + $regex .= '\'' . $this->preg_match_event_name() . '\''; + $regex .= '\);#'; + + $match = array(); + preg_match($regex, $event_line, $match); + if (!isset($match[2])) + { + throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $file . '"', 1); + } + + return $match[2]; + } + + /** + * Find the name of the event inside the trigger_event() line + * + * @param string $file + * @param string $event_line + * @return int Absolute line number + */ + public function get_trigger_event_name($file, $event_line) + { + $event_line = ltrim($event_line, "\t"); + + $regex = '#extract\(\$([a-z](?:[a-z0-9_]|->)*)'; + $regex .= '->trigger_event\('; + $regex .= '\'' . $this->preg_match_event_name() . '\''; + $regex .= ', compact\(\$vars\)\)\);#'; + + $match = array(); + preg_match($regex, $event_line, $match); + if (!isset($match[2])) + { + throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $file . '"', 1); + } + + return $match[2]; + } + + /** + * Find the name of the event inside the trigger_event() line + * + * @return string Returns a regex match for the event name + */ + protected function preg_match_event_name() + { + return '([a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+)'; + } + /** * Find the "@since" Information line * From 4a3756741c9d1689430c557166a43d79739e98fe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 17 Apr 2014 18:21:18 +0200 Subject: [PATCH 099/424] [ticket/12273] Move grabbing the $vars array line to a method PHPBB3-12273 --- phpBB/develop/event_exporter.php | 60 ++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/phpBB/develop/event_exporter.php b/phpBB/develop/event_exporter.php index 3b4f054ad0..644063df2b 100644 --- a/phpBB/develop/event_exporter.php +++ b/phpBB/develop/event_exporter.php @@ -110,21 +110,15 @@ class event_exporter $lines = explode("\n", $content); for ($i = 0, $num_lines = sizeof($lines); $i < $num_lines; $i++) { - $event_line = 0; + $event_line = false; $found_trigger_event = strpos($lines[$i], "dispatcher->trigger_event('"); if ($found_trigger_event !== false) { $event_line = $i; $event_name = $this->get_trigger_event_name($file, $lines[$event_line]); - // Find $vars array lines - $vars_line = ltrim($lines[$event_line - 1], "\t"); - if (strpos($vars_line, "\$vars = array('") !== 0) - { - throw new LogicException('Can not find "$vars = array()"-line for event "' . $event_name . '" in file "' . $file . '"'); - } - $varsarray = substr($vars_line, strlen("\$vars = array('"), 0 - strlen('\');')); - $arguments = explode("', '", $varsarray); + // Find $vars array + $arguments = $this->get_vars_from_array($file, $event_name, $lines, $event_line); // Validate $vars array with @var $find_vars_line = 3; @@ -143,13 +137,13 @@ class event_exporter } $find_vars_line++; } + if (sizeof($arguments) !== sizeof($doc_vars) && array_intersect($arguments, $doc_vars)) { throw new LogicException('$vars array does not match the list of @var tags for event "' . $event_name . '" in file "' . $file . '"'); } } - - if (!$event_line) + else { $found_dispatch = strpos($lines[$i], "dispatcher->dispatch('"); if ($found_dispatch !== false) @@ -250,12 +244,48 @@ class event_exporter return '([a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+)'; } + /** + * Find the $vars array + * + * @param string $file + * @param string $event_name + * @param array $lines + * @param int $event_line Index of the event call in $lines + * @return array List of variables + */ + public function get_vars_from_array($file, $event_name, $lines, $event_line) + { + $vars_line = ltrim($lines[$event_line - 1], "\t"); + if (strpos($vars_line, "\$vars = array('") !== 0 || substr($vars_line, -3) !== '\');') + { + throw new LogicException('Can not find "$vars = array();"-line for event "' . $event_name . '" in file "' . $file . '"', 1); + } + + $vars_array = substr($vars_line, strlen("\$vars = array('"), 0 - strlen('\');')); + if ($vars_array === '') + { + throw new LogicException('Found empty $vars array for event "' . $event_name . '" in file "' . $file . '"', 2); + } + + $vars_array = explode("', '", $vars_array); + + foreach ($vars_array as $var) + { + if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var)) + { + throw new LogicException('Found invalid var "' . $var . '" in array for event "' . $event_name . '" in file "' . $file . '"', 3); + } + } + + return $vars_array; + } + /** * Find the "@since" Information line * * @param string $file * @param string $event_name - * @param string $lines + * @param array $lines * @param int $event_line Index of the event call in $lines * @return int Absolute line number */ @@ -269,7 +299,7 @@ class event_exporter * * @param string $file * @param string $event_name - * @param string $lines + * @param array $lines * @param int $event_line Index of the event call in $lines * @return int Absolute line number */ @@ -283,7 +313,7 @@ class event_exporter * * @param string $file * @param string $event_name - * @param string $lines + * @param array $lines * @param int $event_line Index of the event call in $lines * @param string $find_tag Name of the tag we are trying to find * @param array $disallowed_tags List of tags that must not appear between @@ -332,7 +362,7 @@ class event_exporter * * @param string $file * @param string $event_name - * @param string $lines + * @param array $lines * @param int $event_line Index of the event call in $lines * @return int Absolute line number */ From 91deb4419b3f7c93288e969cf97fb9e1541c2ecf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Apr 2014 00:31:06 +0200 Subject: [PATCH 100/424] [ticket/12273] Add more tests for the event exporter PHPBB3-12273 --- phpBB/develop/event_exporter.php | 112 +++++-- tests/event/exporter_test.php | 301 +++++++++++++++++- .../event/fixtures/legacy_alpha1_version.test | 9 - tests/event/fixtures/missing_var.test | 18 ++ tests/event/fixtures/none.test | 6 + tests/event/fixtures/trigger.test | 18 ++ 6 files changed, 424 insertions(+), 40 deletions(-) delete mode 100644 tests/event/fixtures/legacy_alpha1_version.test create mode 100644 tests/event/fixtures/missing_var.test create mode 100644 tests/event/fixtures/none.test create mode 100644 tests/event/fixtures/trigger.test diff --git a/phpBB/develop/event_exporter.php b/phpBB/develop/event_exporter.php index 644063df2b..c17e714764 100644 --- a/phpBB/develop/event_exporter.php +++ b/phpBB/develop/event_exporter.php @@ -117,31 +117,10 @@ class event_exporter $event_line = $i; $event_name = $this->get_trigger_event_name($file, $lines[$event_line]); - // Find $vars array + // Find variables of the event $arguments = $this->get_vars_from_array($file, $event_name, $lines, $event_line); - - // Validate $vars array with @var - $find_vars_line = 3; - $doc_vars = array(); - while (strpos(trim($lines[$event_line - $find_vars_line]), '*') === 0) - { - $var_line = trim($lines[$event_line - $find_vars_line]); - $var_line = preg_replace('!\s+!', ' ', $var_line); - if (strpos($var_line, '* @var ') === 0) - { - $doc_line = explode(' ', $var_line); - if (isset($doc_line[3])) - { - $doc_vars[] = $doc_line[3]; - } - } - $find_vars_line++; - } - - if (sizeof($arguments) !== sizeof($doc_vars) && array_intersect($arguments, $doc_vars)) - { - throw new LogicException('$vars array does not match the list of @var tags for event "' . $event_name . '" in file "' . $file . '"'); - } + $doc_vars = $this->get_vars_from_docblock($file, $event_name, $lines, $event_line); + $this->validate_vars_docblock_array($file, $event_name, $arguments, $doc_vars); } else { @@ -277,9 +256,73 @@ class event_exporter } } + sort($vars_array); return $vars_array; } + /** + * Find the $vars array + * + * @param string $file + * @param string $event_name + * @param array $lines + * @param int $event_line Index of the event call in $lines + * @return array List of variables + */ + public function get_vars_from_docblock($file, $event_name, $lines, $event_line) + { + $doc_vars = array(); + $current_doc_line = 1; + $found_comment_end = false; + while (ltrim($lines[$event_line - $current_doc_line], "\t") !== '/**') + { + if (ltrim($lines[$event_line - $current_doc_line], "\t") === '*/') + { + $found_comment_end = true; + } + + if ($found_comment_end) + { + $var_line = trim($lines[$event_line - $current_doc_line]); + $var_line = preg_replace('!\s+!', ' ', $var_line); + if (strpos($var_line, '* @var ') === 0) + { + $doc_line = explode(' ', $var_line, 5); + if (sizeof($doc_line) !== 5) + { + throw new LogicException('Found invalid line "' . $lines[$event_line - $current_doc_line] + . '" for event "' . $event_name . '" in file "' . $file . '"', 1); + } + $doc_vars[] = $doc_line[3]; + } + } + + $current_doc_line++; + if ($current_doc_line > $event_line) + { + // Reached the start of the file + throw new LogicException('Can not find end of docblock for event "' . $event_name . '" in file "' . $file . '"', 2); + } + } + + if (empty($doc_vars)) + { + // Reached the start of the file + throw new LogicException('Can not find @var lines for event "' . $event_name . '" in file "' . $file . '"', 3); + } + + foreach ($doc_vars as $var) + { + if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var)) + { + throw new LogicException('Found invalid @var "' . $var . '" in docblock for event "' . $event_name . '" in file "' . $file . '"', 4); + } + } + + sort($doc_vars); + return $doc_vars; + } + /** * Find the "@since" Information line * @@ -443,6 +486,27 @@ class event_exporter return $event; } + /** + * Validates that two arrays contain the same strings + * + * @param string $file + * @param string $event_name + * @param array $vars_array Variables found in the array line + * @param array $vars_docblock Variables found in the doc block + * @return null + */ + public function validate_vars_docblock_array($file, $event_name, $vars_array, $vars_docblock) + { + $vars_array = array_unique($vars_array); + $vars_docblock = array_unique($vars_docblock); + $sizeof_vars_array = sizeof($vars_array); + + if ($sizeof_vars_array !== sizeof($vars_docblock) || $sizeof_vars_array !== sizeof(array_intersect($vars_array, $vars_docblock))) + { + throw new LogicException('$vars array does not match the list of @var tags for event "' . $event_name . '" in file "' . $file . '"'); + } + } + /** * Returns a list of files in that directory * diff --git a/tests/event/exporter_test.php b/tests/event/exporter_test.php index ee9c9267b2..06a66abb04 100644 --- a/tests/event/exporter_test.php +++ b/tests/event/exporter_test.php @@ -48,17 +48,21 @@ class phpbb_event_exporter_test extends phpbb_test_case ), ), array( - 'legacy_alpha1_version.test', + 'trigger.test', array( - 'legacy_alpha1_version.dispatch' => array( - 'event' => 'legacy_alpha1_version.dispatch', - 'file' => 'legacy_alpha1_version.test', - 'arguments' => array(), - 'since' => '3.1.0-a1', - 'description' => 'Description', + 'core.trigger' => array( + 'event' => 'core.trigger', + 'file' => 'trigger.test', + 'arguments' => array('attachments', 'cp_row', 'current_row_number', 'end', 'post_row', 'row', 'start', 'user_poster_data'), + 'since' => '3.1.0-a3', + 'description' => 'Event after the post data has been assigned to the template', ), ), ), + array( + 'none.test', + array(), + ), ); } @@ -145,6 +149,289 @@ class phpbb_event_exporter_test extends phpbb_test_case $this->exporter->validate_event('', $event_name, $event); } + static public function validate_vars_docblock_array_data() + { + return array( + array(array('abc', 'def'), array('abc', 'def')), + ); + } + + /** + * @dataProvider validate_vars_docblock_array_data + */ + public function test_validate_vars_docblock_array($vars_array, $vars_docblock) + { + $this->assertNull($this->exporter->validate_vars_docblock_array('', '', $vars_array, $vars_docblock)); + } + + static public function validate_vars_docblock_array_throws_data() + { + return array( + array(array('abc', 'def'), array()), + array(array('abc', 'def'), array('abc')), + array(array('abc', 'defg'), array('abc', 'def')), + array(array('abc'), array('abc', 'def')), + array(array(), array('abc', 'def')), + ); + } + + /** + * @dataProvider validate_vars_docblock_array_throws_data + * @expectedException LogicException + */ + public function test_validate_vars_docblock_array_throws($vars_array, $vars_docblock) + { + $this->exporter->validate_vars_docblock_array('', '', $vars_array, $vars_docblock); + } + + static public function get_dispatch_name_data() + { + return array( + array("\$phpbb_dispatcher->dispatch('dispatch.one2');", 'dispatch.one2'), + array("\t\$phpbb_dispatcher->dispatch('dispatch.one2.thr_ee4');", 'dispatch.one2.thr_ee4'), + array("\$this->dispatcher->dispatch('dispatch.one2');", 'dispatch.one2'), + array("\$phpbb_dispatcher->dispatch('dis_patch.one');", 'dis_patch.one'), + ); + } + + /** + * @dataProvider get_dispatch_name_data + */ + public function test_get_dispatch_name($event_line, $expected) + { + $this->assertEquals($expected, $this->exporter->get_dispatch_name('', $event_line)); + } + + static public function get_dispatch_name_throws_data() + { + return array( + array("\$phpbb_dispatcher->dispatch();"), + array("\$phpbb_dispatcher->dispatch('');"), + array("\$phpbb_dispatcher->dispatch('dispatch.2one');"), + array("\$phpbb_dispatcher->dispatch('dispatch');"), + ); + } + + /** + * @dataProvider get_dispatch_name_throws_data + * @expectedException LogicException + */ + public function test_get_dispatch_name_throws($event_line) + { + $this->exporter->get_dispatch_name('', $event_line); + } + + static public function get_trigger_event_name_data() + { + return array( + array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one2', compact(\$vars)));", 'dispatch.one2'), + array("\textract(\$phpbb_dispatcher->trigger_event('dispatch.one2.thr_ee4', compact(\$vars)));", 'dispatch.one2.thr_ee4'), + array("extract(\$this->dispatcher->trigger_event('dispatch.one2', compact(\$vars)));", 'dispatch.one2'), + array("extract(\$phpbb_dispatcher->trigger_event('dis_patch.one', compact(\$vars)));", 'dis_patch.one'), + ); + } + + /** + * @dataProvider get_trigger_event_name_data + */ + public function test_get_trigger_event_name($event_line, $expected) + { + $this->assertEquals($expected, $this->exporter->get_trigger_event_name('', $event_line)); + } + + static public function get_trigger_event_name_throws_data() + { + return array( + array("extract(\$phpbb_dispatcher->trigger_event());"), + array("extract(\$phpbb_dispatcher->trigger_event(''));"), + array("extract(\$phpbb_dispatcher->trigger_event('dispatch.2one'));"), + array("extract(\$phpbb_dispatcher->trigger_event('dispatch'));"), + array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', \$vars));"), + array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', compact(\$var)));"), + array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', compact(\$array)));"), + array("\$phpbb_dispatcher->trigger_event('dis_patch.one', compact(\$vars));", 'dis_patch.one'), + ); + } + + /** + * @dataProvider get_trigger_event_name_throws_data + * @expectedException LogicException + */ + public function test_get_trigger_event_name_throws($event_line) + { + $this->exporter->get_trigger_event_name('', $event_line); + } + + static public function get_vars_from_array_data() + { + return array( + array( + array( + '/**', + '*/', + '$vars = array(\'bertie\');', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 3, + array('bertie'), + ), + array( + array( + "\t/**", + "\t*/", + "\t\$vars = array('_Strange123', 'phpBB3_Test');", + "\t\$this->dispatcher->dispatch('test');", + ), + 3, + array('_Strange123', 'phpBB3_Test'), + ), + ); + } + + /** + * @dataProvider get_vars_from_array_data + */ + public function test_get_vars_from_array($lines, $event_line, $expected) + { + $this->assertEquals($expected, $this->exporter->get_vars_from_array('', '', $lines, $event_line)); + } + + static public function get_vars_from_array_throws_data() + { + return array( + array( + array( + '/**', + '*/', + '$vars = $bertie;', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 3, + 1, + ), + array( + array( + '/**', + '*/', + '$vars = array();', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 3, + 1, + ), + array( + array( + '/**', + '*/', + '$vars = array(\'\');', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 3, + 2, + ), + array( + array( + '/**', + '*/', + '$vars = array(\'$bertie\');', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 3, + 3, + ), + ); + } + + /** + * @dataProvider get_vars_from_array_throws_data + * @expectedException LogicException + */ + public function test_get_vars_from_array_throws($lines, $event_line, $exception_code) + { + $this->setExpectedException('LogicException', '', $exception_code); + $this->exporter->get_vars_from_array('', '', $lines, $event_line); + } + + static public function get_vars_from_docblock_data() + { + return array( + array( + array( + '/**', + '* @var int name1 Description', + '* @var array name2 Description test', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 4, + array('name1', 'name2'), + ), + ); + } + + /** + * @dataProvider get_vars_from_docblock_data + */ + public function test_get_vars_from_docblock($lines, $event_line, $expected) + { + $this->assertEquals($expected, $this->exporter->get_vars_from_docblock('', '', $lines, $event_line)); + } + + static public function get_vars_from_docblock_throws_data() + { + return array( + array( + array( + '$vars = array();', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 1, + 2, + ), + array( + array( + '/**', + '* @var int name1', + '* @var array name2 Description test', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 4, + 1, + ), + array( + array( + '/**', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 2, + 3, + ), + array( + array( + '/**', + '* @var int name1 Description', + '* @var array $name2 Description', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 4, + 4, + ), + ); + } + + /** + * @dataProvider get_vars_from_docblock_throws_data + * @expectedException LogicException + */ + public function test_get_vars_from_docblock_throws($lines, $event_line, $exception_code) + { + $this->setExpectedException('LogicException', '', $exception_code); + $this->exporter->get_vars_from_docblock('', '', $lines, $event_line); + } + static public function find_since_data() { return array( diff --git a/tests/event/fixtures/legacy_alpha1_version.test b/tests/event/fixtures/legacy_alpha1_version.test deleted file mode 100644 index 064af4daf8..0000000000 --- a/tests/event/fixtures/legacy_alpha1_version.test +++ /dev/null @@ -1,9 +0,0 @@ -dispatch('legacy_alpha1_version.dispatch'); diff --git a/tests/event/fixtures/missing_var.test b/tests/event/fixtures/missing_var.test new file mode 100644 index 0000000000..9df6e5b386 --- /dev/null +++ b/tests/event/fixtures/missing_var.test @@ -0,0 +1,18 @@ +trigger_event('core.trigger', compact($vars))); diff --git a/tests/event/fixtures/none.test b/tests/event/fixtures/none.test new file mode 100644 index 0000000000..6e2267024b --- /dev/null +++ b/tests/event/fixtures/none.test @@ -0,0 +1,6 @@ +trigger_event('core.trigger', compact($vars))); From b831e96aafc4b8c2bc883dd47c4f2452f329e5b2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Apr 2014 02:08:23 +0200 Subject: [PATCH 101/424] [ticket/12273] Use class properties instead of parameters PHPBB3-12273 --- phpBB/develop/event_exporter.php | 237 ++++++++++++---------- tests/event/exporter_test.php | 76 +++++-- tests/event/fixtures/duplicate_event.test | 26 +++ tests/event/fixtures/missing_var.test | 1 - 4 files changed, 211 insertions(+), 129 deletions(-) create mode 100644 tests/event/fixtures/duplicate_event.test diff --git a/phpBB/develop/event_exporter.php b/phpBB/develop/event_exporter.php index c17e714764..a84b18db26 100644 --- a/phpBB/develop/event_exporter.php +++ b/phpBB/develop/event_exporter.php @@ -12,12 +12,30 @@ class event_exporter /** @var string */ protected $root_path; + /** @var string */ + protected $current_file; + + /** @var string */ + protected $current_event; + + /** @var int */ + protected $current_event_line; + + /** @var array */ + protected $events; + + /** @var array */ + protected $file_lines; + /** * @param string $phpbb_root_path */ public function __construct($phpbb_root_path) { $this->root_path = $phpbb_root_path; + $this->events = $this->file_lines = array(); + $this->current_file = $this->current_event = ''; + $this->current_event_line = 0; } function export_from_eventsmd($filter) @@ -82,53 +100,70 @@ class event_exporter function export_from_php() { $files = $this->get_file_list($this->root_path); - $events = array(); + $this->events = array(); foreach ($files as $file) { - $file_events = $this->check_for_events($file); - if (!empty($file_events)) - { - $events = array_merge($events, $file_events); - } + $this->check_for_events($file); } - ksort($events); + ksort($this->events); - foreach ($events as $event) + foreach ($this->events as $event) { echo '|- id="' . $event['event'] . '"' . "\n"; echo '| [[#' . $event['event'] . '|' . $event['event'] . ']] || ' . $event['file'] . ' || ' . implode(', ', $event['arguments']) . ' || ' . $event['since'] . ' || ' . $event['description'] . "\n"; } } + public function get_events() + { + return $this->events; + } + + public function set_current_event($name, $line) + { + $this->current_event = $name; + $this->current_event_line = $line; + } + + public function set_content($content) + { + $this->file_lines = $content; + } + + /** + * @param $file + * @throws LogicException + */ public function check_for_events($file) { - $events = array(); - $content = file_get_contents($this->root_path . $file); + $this->current_file = $file; + $this->file_lines = array(); + $content = file_get_contents($this->root_path . $this->current_file); if (strpos($content, "dispatcher->trigger_event('") || strpos($content, "dispatcher->dispatch('")) { - $lines = explode("\n", $content); - for ($i = 0, $num_lines = sizeof($lines); $i < $num_lines; $i++) + $this->set_content(explode("\n", $content)); + for ($i = 0, $num_lines = sizeof($this->file_lines); $i < $num_lines; $i++) { $event_line = false; - $found_trigger_event = strpos($lines[$i], "dispatcher->trigger_event('"); + $found_trigger_event = strpos($this->file_lines[$i], "dispatcher->trigger_event('"); if ($found_trigger_event !== false) { $event_line = $i; - $event_name = $this->get_trigger_event_name($file, $lines[$event_line]); + $this->set_current_event($this->get_trigger_event_name($this->file_lines[$event_line]), $event_line); // Find variables of the event - $arguments = $this->get_vars_from_array($file, $event_name, $lines, $event_line); - $doc_vars = $this->get_vars_from_docblock($file, $event_name, $lines, $event_line); - $this->validate_vars_docblock_array($file, $event_name, $arguments, $doc_vars); + $arguments = $this->get_vars_from_array(); + $doc_vars = $this->get_vars_from_docblock(); + $this->validate_vars_docblock_array($arguments, $doc_vars); } else { - $found_dispatch = strpos($lines[$i], "dispatcher->dispatch('"); + $found_dispatch = strpos($this->file_lines[$i], "dispatcher->dispatch('"); if ($found_dispatch !== false) { $event_line = $i; - $event_name = $this->get_dispatch_name($file, $lines[$event_line]); + $this->set_current_event($this->get_dispatch_name($this->file_lines[$event_line]), $event_line); $arguments = array(); } } @@ -136,20 +171,26 @@ class event_exporter if ($event_line) { // Validate @event - $event_line_num = $this->find_event($file, $event_name, $lines, $event_line); - $this->validate_event($file, $event_name, $lines[$event_line_num]); + $event_line_num = $this->find_event(); + $this->validate_event($this->current_event, $this->file_lines[$event_line_num]); // Validate @since - $since_line_num = $this->find_since($file, $event_name, $lines, $event_line); - $since = $this->validate_since($file, $event_name, $lines[$since_line_num]); + $since_line_num = $this->find_since(); + $since = $this->validate_since($this->file_lines[$since_line_num]); // Find event description line - $description_line_num = $this->find_description($file, $event_name, $lines, $event_line); - $description = substr(trim($lines[$description_line_num]), strlen('* ')); + $description_line_num = $this->find_description(); + $description = substr(trim($this->file_lines[$description_line_num]), strlen('* ')); - $events[$event_name] = array( - 'event' => $event_name, - 'file' => $file, + if (isset($this->events[$this->current_event])) + { + throw new LogicException('The event "' . $this->current_event . '" from file "' . $this->current_file + . '" already exists in file "'. $this->events[$this->current_event]['file'] . '"', 10); + } + + $this->events[$this->current_event] = array( + 'event' => $this->current_event, + 'file' => $this->current_file, 'arguments' => $arguments, 'since' => $since, 'description' => $description, @@ -157,18 +198,16 @@ class event_exporter } } } - - return $events; } /** * Find the name of the event inside the dispatch() line * - * @param string $file * @param string $event_line * @return int Absolute line number + * @throws LogicException */ - public function get_dispatch_name($file, $event_line) + public function get_dispatch_name($event_line) { $event_line = ltrim($event_line, "\t"); @@ -181,7 +220,7 @@ class event_exporter preg_match($regex, $event_line, $match); if (!isset($match[2])) { - throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $file . '"', 1); + throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $this->current_file . '"', 1); } return $match[2]; @@ -190,11 +229,11 @@ class event_exporter /** * Find the name of the event inside the trigger_event() line * - * @param string $file * @param string $event_line * @return int Absolute line number + * @throws LogicException */ - public function get_trigger_event_name($file, $event_line) + public function get_trigger_event_name($event_line) { $event_line = ltrim($event_line, "\t"); @@ -207,7 +246,7 @@ class event_exporter preg_match($regex, $event_line, $match); if (!isset($match[2])) { - throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $file . '"', 1); + throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $this->current_file . '"', 1); } return $match[2]; @@ -226,24 +265,21 @@ class event_exporter /** * Find the $vars array * - * @param string $file - * @param string $event_name - * @param array $lines - * @param int $event_line Index of the event call in $lines * @return array List of variables + * @throws LogicException */ - public function get_vars_from_array($file, $event_name, $lines, $event_line) + public function get_vars_from_array() { - $vars_line = ltrim($lines[$event_line - 1], "\t"); + $vars_line = ltrim($this->file_lines[$this->current_event_line - 1], "\t"); if (strpos($vars_line, "\$vars = array('") !== 0 || substr($vars_line, -3) !== '\');') { - throw new LogicException('Can not find "$vars = array();"-line for event "' . $event_name . '" in file "' . $file . '"', 1); + throw new LogicException('Can not find "$vars = array();"-line for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); } $vars_array = substr($vars_line, strlen("\$vars = array('"), 0 - strlen('\');')); if ($vars_array === '') { - throw new LogicException('Found empty $vars array for event "' . $event_name . '" in file "' . $file . '"', 2); + throw new LogicException('Found empty $vars array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); } $vars_array = explode("', '", $vars_array); @@ -252,7 +288,7 @@ class event_exporter { if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var)) { - throw new LogicException('Found invalid var "' . $var . '" in array for event "' . $event_name . '" in file "' . $file . '"', 3); + throw new LogicException('Found invalid var "' . $var . '" in array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); } } @@ -263,59 +299,56 @@ class event_exporter /** * Find the $vars array * - * @param string $file - * @param string $event_name - * @param array $lines - * @param int $event_line Index of the event call in $lines * @return array List of variables + * @throws LogicException */ - public function get_vars_from_docblock($file, $event_name, $lines, $event_line) + public function get_vars_from_docblock() { $doc_vars = array(); $current_doc_line = 1; $found_comment_end = false; - while (ltrim($lines[$event_line - $current_doc_line], "\t") !== '/**') + while (ltrim($this->file_lines[$this->current_event_line - $current_doc_line], "\t") !== '/**') { - if (ltrim($lines[$event_line - $current_doc_line], "\t") === '*/') + if (ltrim($this->file_lines[$this->current_event_line - $current_doc_line], "\t") === '*/') { $found_comment_end = true; } if ($found_comment_end) { - $var_line = trim($lines[$event_line - $current_doc_line]); + $var_line = trim($this->file_lines[$this->current_event_line - $current_doc_line]); $var_line = preg_replace('!\s+!', ' ', $var_line); if (strpos($var_line, '* @var ') === 0) { $doc_line = explode(' ', $var_line, 5); if (sizeof($doc_line) !== 5) { - throw new LogicException('Found invalid line "' . $lines[$event_line - $current_doc_line] - . '" for event "' . $event_name . '" in file "' . $file . '"', 1); + throw new LogicException('Found invalid line "' . $this->file_lines[$this->current_event_line - $current_doc_line] + . '" for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); } $doc_vars[] = $doc_line[3]; } } $current_doc_line++; - if ($current_doc_line > $event_line) + if ($current_doc_line > $this->current_event_line) { // Reached the start of the file - throw new LogicException('Can not find end of docblock for event "' . $event_name . '" in file "' . $file . '"', 2); + throw new LogicException('Can not find end of docblock for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); } } if (empty($doc_vars)) { // Reached the start of the file - throw new LogicException('Can not find @var lines for event "' . $event_name . '" in file "' . $file . '"', 3); + throw new LogicException('Can not find @var lines for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); } foreach ($doc_vars as $var) { if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var)) { - throw new LogicException('Found invalid @var "' . $var . '" in docblock for event "' . $event_name . '" in file "' . $file . '"', 4); + throw new LogicException('Found invalid @var "' . $var . '" in docblock for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 4); } } @@ -326,109 +359,96 @@ class event_exporter /** * Find the "@since" Information line * - * @param string $file - * @param string $event_name - * @param array $lines - * @param int $event_line Index of the event call in $lines * @return int Absolute line number + * @throws LogicException */ - public function find_since($file, $event_name, $lines, $event_line) + public function find_since() { - return $this->find_tag($file, $event_name, $lines, $event_line, 'since', array('event', 'var')); + return $this->find_tag('since', array('event', 'var')); } /** * Find the "@event" Information line * - * @param string $file - * @param string $event_name - * @param array $lines - * @param int $event_line Index of the event call in $lines * @return int Absolute line number */ - public function find_event($file, $event_name, $lines, $event_line) + public function find_event() { - return $this->find_tag($file, $event_name, $lines, $event_line, 'event', array()); + return $this->find_tag('event', array()); } /** * Find a "@*" Information line * - * @param string $file - * @param string $event_name - * @param array $lines - * @param int $event_line Index of the event call in $lines * @param string $find_tag Name of the tag we are trying to find * @param array $disallowed_tags List of tags that must not appear between * the tag and the actual event * @return int Absolute line number + * @throws LogicException */ - public function find_tag($file, $event_name, $lines, $event_line, $find_tag, $disallowed_tags) + public function find_tag($find_tag, $disallowed_tags) { $find_tag_line = 0; $found_comment_end = false; - while (strpos(ltrim($lines[$event_line - $find_tag_line], "\t"), '* @' . $find_tag . ' ') !== 0) + while (strpos(ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t"), '* @' . $find_tag . ' ') !== 0) { - if ($found_comment_end && ltrim($lines[$event_line - $find_tag_line], "\t") === '/**') + if ($found_comment_end && ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t") === '/**') { // Reached the start of this doc block - throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $event_name . '" in file "' . $file . '"', 1); + throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); } foreach ($disallowed_tags as $disallowed_tag) { - if ($found_comment_end && strpos(ltrim($lines[$event_line - $find_tag_line], "\t"), '* @' . $disallowed_tag) === 0) + if ($found_comment_end && strpos(ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t"), '* @' . $disallowed_tag) === 0) { // Found @var after the @since - throw new LogicException('Found @' . $disallowed_tag . ' information after @' . $find_tag . ' for event "' . $event_name . '" in file "' . $file . '"', 3); + throw new LogicException('Found @' . $disallowed_tag . ' information after @' . $find_tag . ' for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); } } - if (ltrim($lines[$event_line - $find_tag_line], "\t") === '*/') + if (ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t") === '*/') { $found_comment_end = true; } $find_tag_line++; - if ($find_tag_line >= $event_line) + if ($find_tag_line >= $this->current_event_line) { // Reached the start of the file - throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $event_name . '" in file "' . $file . '"', 2); + throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); } } - return $event_line - $find_tag_line; + return $this->current_event_line - $find_tag_line; } /** * Find a "@*" Information line * - * @param string $file - * @param string $event_name - * @param array $lines - * @param int $event_line Index of the event call in $lines * @return int Absolute line number + * @throws LogicException */ - public function find_description($file, $event_name, $lines, $event_line) + public function find_description() { $find_desc_line = 0; - while (ltrim($lines[$event_line - $find_desc_line], "\t") !== '/**') + while (ltrim($this->file_lines[$this->current_event_line - $find_desc_line], "\t") !== '/**') { $find_desc_line++; - if ($find_desc_line > $event_line) + if ($find_desc_line > $this->current_event_line) { // Reached the start of the file - throw new LogicException('Can not find a description for event "' . $event_name . '" in file "' . $file . '"', 1); + throw new LogicException('Can not find a description for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); } } - $find_desc_line = $event_line - $find_desc_line + 1; + $find_desc_line = $this->current_event_line - $find_desc_line + 1; - $desc = trim($lines[$find_desc_line]); + $desc = trim($this->file_lines[$find_desc_line]); if (strpos($desc, '* @') === 0 || $desc[0] !== '*' || substr($desc, 1) == '') { // First line of the doc block is a @-line, empty or only contains "*" - throw new LogicException('Can not find a description for event "' . $event_name . '" in file "' . $file . '"', 2); + throw new LogicException('Can not find a description for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); } return $find_desc_line; @@ -437,25 +457,24 @@ class event_exporter /** * Validate "@since" Information * - * @param string $file - * @param string $event_name * @param string $line * @return string + * @throws LogicException */ - public function validate_since($file, $event_name, $line) + public function validate_since($line) { $since = substr(ltrim($line, "\t"), strlen('* @since ')); if ($since !== trim($since)) { - throw new LogicException('Invalid @since information for event "' . $event_name . '" in file "' . $file . '"', 1); + throw new LogicException('Invalid @since information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); } $since = ($since === '3.1-A1') ? '3.1.0-a1' : $since; if (!preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|rc|pl)\d+)?$#', $since)) { - throw new LogicException('Invalid @since information for event "' . $event_name . '" in file "' . $file . '"', 2); + throw new LogicException('Invalid @since information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); } return $since; @@ -464,23 +483,23 @@ class event_exporter /** * Validate "@event" Information * - * @param string $file * @param string $event_name * @param string $line * @return string + * @throws LogicException */ - public function validate_event($file, $event_name, $line) + public function validate_event($event_name, $line) { $event = substr(ltrim($line, "\t"), strlen('* @event ')); if ($event !== trim($event)) { - throw new LogicException('Invalid @event information for event "' . $event_name . '" in file "' . $file . '"', 1); + throw new LogicException('Invalid @event information for event "' . $event_name . '" in file "' . $this->current_file . '"', 1); } if ($event !== $event_name) { - throw new LogicException('Event name does not match @event tag for event "' . $event_name . '" in file "' . $file . '"', 2); + throw new LogicException('Event name does not match @event tag for event "' . $event_name . '" in file "' . $this->current_file . '"', 2); } return $event; @@ -489,13 +508,12 @@ class event_exporter /** * Validates that two arrays contain the same strings * - * @param string $file - * @param string $event_name * @param array $vars_array Variables found in the array line * @param array $vars_docblock Variables found in the doc block * @return null + * @throws LogicException */ - public function validate_vars_docblock_array($file, $event_name, $vars_array, $vars_docblock) + public function validate_vars_docblock_array($vars_array, $vars_docblock) { $vars_array = array_unique($vars_array); $vars_docblock = array_unique($vars_docblock); @@ -503,7 +521,7 @@ class event_exporter if ($sizeof_vars_array !== sizeof($vars_docblock) || $sizeof_vars_array !== sizeof(array_intersect($vars_array, $vars_docblock))) { - throw new LogicException('$vars array does not match the list of @var tags for event "' . $event_name . '" in file "' . $file . '"'); + throw new LogicException('$vars array does not match the list of @var tags for event "' . $this->current_event . '" in file "' . $this->current_file . '"'); } } @@ -513,6 +531,7 @@ class event_exporter * Works recursive with any depth * * @param string $dir Directory to go through + * @param string $path Path from root to $dir * @return array List of files (including directories from within $dir */ function get_file_list($dir, $path = '') diff --git a/tests/event/exporter_test.php b/tests/event/exporter_test.php index 06a66abb04..df5a258bbb 100644 --- a/tests/event/exporter_test.php +++ b/tests/event/exporter_test.php @@ -71,7 +71,25 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_check_for_events($file, $expected) { - $this->assertEquals($expected, $this->exporter->check_for_events($file)); + $this->exporter->check_for_events($file); + $this->assertEquals($expected, $this->exporter->get_events()); + } + + static public function check_for_events_throws_data() + { + return array( + array('missing_var.test', null), + array('duplicate_event.test', 10), + ); + } + + /** + * @dataProvider check_for_events_throws_data + */ + public function test_check_for_events_throws($file, $exception_code) + { + $this->setExpectedException('LogicException', '', $exception_code); + $this->assertNull($this->exporter->check_for_events($file)); } static public function validate_since_data() @@ -89,7 +107,7 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_validate_since($since, $expected) { - $this->assertEquals($expected, $this->exporter->validate_since('', '', $since)); + $this->assertEquals($expected, $this->exporter->validate_since($since)); } static public function validate_since_throws_data() @@ -111,7 +129,7 @@ class phpbb_event_exporter_test extends phpbb_test_case public function test_validate_since_throws($since, $exception_code) { $this->setExpectedException('LogicException', '', $exception_code); - $this->exporter->validate_since('', '', $since); + $this->exporter->validate_since($since); } static public function validate_event_data() @@ -127,7 +145,7 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_validate_event($event_name, $event, $expected) { - $this->assertEquals($expected, $this->exporter->validate_event('', $event_name, $event)); + $this->assertEquals($expected, $this->exporter->validate_event($event_name, $event)); } static public function validate_event_throws_data() @@ -146,7 +164,7 @@ class phpbb_event_exporter_test extends phpbb_test_case public function test_validate_event_throws($event_name, $event, $exception_code) { $this->setExpectedException('LogicException', '', $exception_code); - $this->exporter->validate_event('', $event_name, $event); + $this->exporter->validate_event($event_name, $event); } static public function validate_vars_docblock_array_data() @@ -161,7 +179,7 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_validate_vars_docblock_array($vars_array, $vars_docblock) { - $this->assertNull($this->exporter->validate_vars_docblock_array('', '', $vars_array, $vars_docblock)); + $this->assertNull($this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock)); } static public function validate_vars_docblock_array_throws_data() @@ -181,7 +199,7 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_validate_vars_docblock_array_throws($vars_array, $vars_docblock) { - $this->exporter->validate_vars_docblock_array('', '', $vars_array, $vars_docblock); + $this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock); } static public function get_dispatch_name_data() @@ -199,7 +217,7 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_get_dispatch_name($event_line, $expected) { - $this->assertEquals($expected, $this->exporter->get_dispatch_name('', $event_line)); + $this->assertEquals($expected, $this->exporter->get_dispatch_name($event_line)); } static public function get_dispatch_name_throws_data() @@ -218,7 +236,7 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_get_dispatch_name_throws($event_line) { - $this->exporter->get_dispatch_name('', $event_line); + $this->exporter->get_dispatch_name($event_line); } static public function get_trigger_event_name_data() @@ -236,7 +254,7 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_get_trigger_event_name($event_line, $expected) { - $this->assertEquals($expected, $this->exporter->get_trigger_event_name('', $event_line)); + $this->assertEquals($expected, $this->exporter->get_trigger_event_name($event_line)); } static public function get_trigger_event_name_throws_data() @@ -259,7 +277,7 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_get_trigger_event_name_throws($event_line) { - $this->exporter->get_trigger_event_name('', $event_line); + $this->exporter->get_trigger_event_name($event_line); } static public function get_vars_from_array_data() @@ -293,7 +311,9 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_get_vars_from_array($lines, $event_line, $expected) { - $this->assertEquals($expected, $this->exporter->get_vars_from_array('', '', $lines, $event_line)); + $this->exporter->set_current_event('', $event_line); + $this->exporter->set_content($lines); + $this->assertEquals($expected, $this->exporter->get_vars_from_array()); } static public function get_vars_from_array_throws_data() @@ -349,7 +369,10 @@ class phpbb_event_exporter_test extends phpbb_test_case public function test_get_vars_from_array_throws($lines, $event_line, $exception_code) { $this->setExpectedException('LogicException', '', $exception_code); - $this->exporter->get_vars_from_array('', '', $lines, $event_line); + + $this->exporter->set_current_event('', $event_line); + $this->exporter->set_content($lines); + $this->exporter->get_vars_from_array(); } static public function get_vars_from_docblock_data() @@ -374,7 +397,9 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_get_vars_from_docblock($lines, $event_line, $expected) { - $this->assertEquals($expected, $this->exporter->get_vars_from_docblock('', '', $lines, $event_line)); + $this->exporter->set_current_event('', $event_line); + $this->exporter->set_content($lines); + $this->assertEquals($expected, $this->exporter->get_vars_from_docblock()); } static public function get_vars_from_docblock_throws_data() @@ -429,7 +454,10 @@ class phpbb_event_exporter_test extends phpbb_test_case public function test_get_vars_from_docblock_throws($lines, $event_line, $exception_code) { $this->setExpectedException('LogicException', '', $exception_code); - $this->exporter->get_vars_from_docblock('', '', $lines, $event_line); + + $this->exporter->set_current_event('', $event_line); + $this->exporter->set_content($lines); + $this->exporter->get_vars_from_docblock(); } static public function find_since_data() @@ -465,7 +493,9 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_find_since($lines, $event_line, $expected) { - $this->assertEquals($expected, $this->exporter->find_since('', '', $lines, $event_line)); + $this->exporter->set_current_event('', $event_line); + $this->exporter->set_content($lines); + $this->assertEquals($expected, $this->exporter->find_since()); } static public function find_since_throws_data() @@ -527,7 +557,10 @@ class phpbb_event_exporter_test extends phpbb_test_case public function test_find_since_throws($lines, $event_line, $exception_code) { $this->setExpectedException('LogicException', '', $exception_code); - $this->exporter->find_since('', '', $lines, $event_line); + + $this->exporter->set_current_event('', $event_line); + $this->exporter->set_content($lines); + $this->exporter->find_since(); } static public function find_description_data() @@ -565,7 +598,9 @@ class phpbb_event_exporter_test extends phpbb_test_case */ public function test_find_description($lines, $event_line, $expected) { - $this->assertEquals($expected, $this->exporter->find_description('', '', $lines, $event_line)); + $this->exporter->set_current_event('', $event_line); + $this->exporter->set_content($lines); + $this->assertEquals($expected, $this->exporter->find_description()); } static public function find_description_throws_data() @@ -623,6 +658,9 @@ class phpbb_event_exporter_test extends phpbb_test_case public function test_find_description_throws($lines, $event_line, $exception_code) { $this->setExpectedException('LogicException', '', $exception_code); - $this->exporter->find_description('', '', $lines, $event_line); + + $this->exporter->set_current_event('', $event_line); + $this->exporter->set_content($lines); + $this->exporter->find_description(); } } diff --git a/tests/event/fixtures/duplicate_event.test b/tests/event/fixtures/duplicate_event.test new file mode 100644 index 0000000000..f5fa580c2b --- /dev/null +++ b/tests/event/fixtures/duplicate_event.test @@ -0,0 +1,26 @@ +trigger_event('duplicate.trigger', compact($vars))); + + /** + * Event after the post data has been assigned to the template + * + * @event duplicate.trigger + * @since 3.1.0-b1 + */ + $phpbb_dispatcher->dispatch('duplicate.trigger'); diff --git a/tests/event/fixtures/missing_var.test b/tests/event/fixtures/missing_var.test index 9df6e5b386..7ced5e93dc 100644 --- a/tests/event/fixtures/missing_var.test +++ b/tests/event/fixtures/missing_var.test @@ -11,7 +11,6 @@ * @var array cp_row Custom profile field data of the poster * @var array attachments List of attachments * @var array user_poster_data Poster's data from user cache - * @var array post_row Template block array of the post * @since 3.1.0-a3 */ $vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row'); From d213e09a40cb0ee9c94c35b3aecb1814d740184a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Apr 2014 11:06:04 +0200 Subject: [PATCH 102/424] [ticket/12273] Crawl the phpBB directory for events PHPBB3-12273 --- phpBB/develop/event_exporter.php | 178 +++++++++++++---------- phpBB/develop/export_events_for_wiki.php | 3 +- tests/event/exporter_test.php | 27 ++-- 3 files changed, 122 insertions(+), 86 deletions(-) diff --git a/phpBB/develop/event_exporter.php b/phpBB/develop/event_exporter.php index a84b18db26..223f9318ba 100644 --- a/phpBB/develop/event_exporter.php +++ b/phpBB/develop/event_exporter.php @@ -34,6 +34,7 @@ class event_exporter { $this->root_path = $phpbb_root_path; $this->events = $this->file_lines = array(); + $this->events['php'] = array(); $this->current_file = $this->current_event = ''; $this->current_event_line = 0; } @@ -97,23 +98,6 @@ class event_exporter } } - function export_from_php() - { - $files = $this->get_file_list($this->root_path); - $this->events = array(); - foreach ($files as $file) - { - $this->check_for_events($file); - } - ksort($this->events); - - foreach ($this->events as $event) - { - echo '|- id="' . $event['event'] . '"' . "\n"; - echo '| [[#' . $event['event'] . '|' . $event['event'] . ']] || ' . $event['file'] . ' || ' . implode(', ', $event['arguments']) . ' || ' . $event['since'] . ' || ' . $event['description'] . "\n"; - } - } - public function get_events() { return $this->events; @@ -130,11 +114,108 @@ class event_exporter $this->file_lines = $content; } + /** + * Crawl the phpBB/ directory for php events + * @return int The number of events found + */ + public function crawl_phpbb_directory_php() + { + $files = $this->get_recursive_file_list($this->root_path); + $this->events['php'] = array(); + foreach ($files as $file) + { + $this->crawl_php_file($file); + } + ksort($this->events['php']); + + return sizeof($this->events['php']); + } + + /** + * Returns a list of files in $dir + * + * Works recursive with any depth + * + * @param string $dir Directory to go through + * @param string $path Path from root to $dir + * @return array List of files (including directories) + */ + public function get_recursive_file_list($dir, $path = '') + { + try + { + $iterator = new \DirectoryIterator($dir); + } + catch (Exception $e) + { + return array(); + } + + $files = array(); + foreach ($iterator as $file_info) + { + /** @var \DirectoryIterator $file_info */ + if ($file_info->isDot()) + { + continue; + } + + // Do not scan some directories + if ($file_info->isDir() && ( + ($path == '' && in_array($file_info->getFilename(), array( + 'cache', + 'develop', + 'ext', + 'files', + 'language', + 'store', + 'vendor', + ))) + || ($path == '/includes' && in_array($file_info->getFilename(), array('utf'))) + || ($path == '/phpbb/db/migration' && in_array($file_info->getFilename(), array('data'))) + || ($path == '/phpbb' && in_array($file_info->getFilename(), array('event'))) + )) + { + continue; + } + else if ($file_info->isDir()) + { + $sub_dir = $this->get_recursive_file_list($file_info->getPath() . '/' . $file_info->getFilename(), $path . '/' . $file_info->getFilename()); + foreach ($sub_dir as $file) + { + $files[] = $file_info->getFilename() . '/' . $file; + } + } + else if ($file_info->getExtension() == 'php') + { + $files[] = $file_info->getFilename(); + } + } + + return $files; + } + + /** + * Format the php events as a wiki table + * @return string + */ + public function export_php_events_for_wiki() + { + $wiki_page = ''; + foreach ($this->events['php'] as $event) + { + $wiki_page .= '|- id="' . $event['event'] . '"' . "\n"; + $wiki_page .= '| [[#' . $event['event'] . '|' . $event['event'] . ']] || ' . $event['file'] . ' || ' . implode(', ', $event['arguments']) . ' || ' . $event['since'] . ' || ' . $event['description'] . "\n"; + } + + return $wiki_page; + } + /** * @param $file * @throws LogicException */ - public function check_for_events($file) + public function crawl_php_file($file) { $this->current_file = $file; $this->file_lines = array(); @@ -182,13 +263,13 @@ class event_exporter $description_line_num = $this->find_description(); $description = substr(trim($this->file_lines[$description_line_num]), strlen('* ')); - if (isset($this->events[$this->current_event])) + if (isset($this->events['php'][$this->current_event])) { throw new LogicException('The event "' . $this->current_event . '" from file "' . $this->current_file - . '" already exists in file "'. $this->events[$this->current_event]['file'] . '"', 10); + . '" already exists in file "'. $this->events['php'][$this->current_event]['file'] . '"', 10); } - $this->events[$this->current_event] = array( + $this->events['php'][$this->current_event] = array( 'event' => $this->current_event, 'file' => $this->current_file, 'arguments' => $arguments, @@ -524,59 +605,4 @@ class event_exporter throw new LogicException('$vars array does not match the list of @var tags for event "' . $this->current_event . '" in file "' . $this->current_file . '"'); } } - - /** - * Returns a list of files in that directory - * - * Works recursive with any depth - * - * @param string $dir Directory to go through - * @param string $path Path from root to $dir - * @return array List of files (including directories from within $dir - */ - function get_file_list($dir, $path = '') - { - try - { - $iterator = new \DirectoryIterator($dir); - } - catch (Exception $e) - { - return array(); - } - - $files = array(); - foreach ($iterator as $file_info) - { - if ($file_info->isDot()) - { - continue; - } - - // Do not scan some directories - if ($file_info->isDir() && ( - ($path == '' && in_array($file_info->getFilename(), array('cache', 'develop', 'ext', 'files', 'language', 'store', 'vendor'))) - || ($path == '/includes' && in_array($file_info->getFilename(), array('utf'))) - || ($path == '/phpbb/db/migration' && in_array($file_info->getFilename(), array('data'))) - || ($path == '/phpbb' && in_array($file_info->getFilename(), array('event'))) - )) - { - continue; - } - else if ($file_info->isDir()) - { - $sub_dir = $this->get_file_list($file_info->getPath() . '/' . $file_info->getFilename(), $path . '/' . $file_info->getFilename()); - foreach ($sub_dir as $file) - { - $files[] = $file_info->getFilename() . '/' . $file; - } - } - else if (substr($file_info->getFilename(), -4) == '.php') - { - $files[] = $file_info->getFilename(); - } - } - - return $files; - } } diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php index 0c4f14a4b4..0019fbaa44 100644 --- a/phpBB/develop/export_events_for_wiki.php +++ b/phpBB/develop/export_events_for_wiki.php @@ -54,7 +54,8 @@ switch ($action) break; case 'php': - $exporter->export_from_php(); + $exporter->crawl_phpbb_directory_php(); + echo $exporter->export_php_events_for_wiki(); break; default: diff --git a/tests/event/exporter_test.php b/tests/event/exporter_test.php index df5a258bbb..5736476f45 100644 --- a/tests/event/exporter_test.php +++ b/tests/event/exporter_test.php @@ -20,7 +20,7 @@ class phpbb_event_exporter_test extends phpbb_test_case $this->exporter = new \event_exporter(dirname(__FILE__) . '/fixtures/'); } - static public function check_for_events_data() + static public function crawl_php_file_data() { return array( array( @@ -67,15 +67,17 @@ class phpbb_event_exporter_test extends phpbb_test_case } /** - * @dataProvider check_for_events_data + * @dataProvider crawl_php_file_data */ - public function test_check_for_events($file, $expected) + public function test_crawl_php_file($file, $expected) { - $this->exporter->check_for_events($file); - $this->assertEquals($expected, $this->exporter->get_events()); + $this->exporter->crawl_php_file($file); + $events = $this->exporter->get_events(); + $this->assertArrayHasKey('php', $events); + $this->assertEquals($expected, $events['php']); } - static public function check_for_events_throws_data() + static public function crawl_php_file_throws_data() { return array( array('missing_var.test', null), @@ -84,12 +86,12 @@ class phpbb_event_exporter_test extends phpbb_test_case } /** - * @dataProvider check_for_events_throws_data + * @dataProvider crawl_php_file_throws_data */ - public function test_check_for_events_throws($file, $exception_code) + public function test_crawl_php_file_throws($file, $exception_code) { $this->setExpectedException('LogicException', '', $exception_code); - $this->assertNull($this->exporter->check_for_events($file)); + $this->exporter->crawl_php_file($file); } static public function validate_since_data() @@ -663,4 +665,11 @@ class phpbb_event_exporter_test extends phpbb_test_case $this->exporter->set_content($lines); $this->exporter->find_description(); } + + public function test_crawl_phpbb_directory_php() + { + global $phpbb_root_path; + $exporter = new \event_exporter($phpbb_root_path); + $this->assertGreaterThan(0, $exporter->crawl_phpbb_directory_php()); + } } From 3352d9fd344c14172bd690f20ee50a912032db7f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Apr 2014 11:13:02 +0200 Subject: [PATCH 103/424] [ticket/12273] Move event exporter to namespace PHPBB3-12273 --- phpBB/develop/export_events_for_wiki.php | 4 +- .../event/exporter.php} | 70 ++++++++++--------- tests/event/exporter_test.php | 6 +- 3 files changed, 40 insertions(+), 40 deletions(-) rename phpBB/{develop/event_exporter.php => phpbb/event/exporter.php} (81%) diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php index 0019fbaa44..ff64dc493e 100644 --- a/phpBB/develop/export_events_for_wiki.php +++ b/phpBB/develop/export_events_for_wiki.php @@ -13,7 +13,7 @@ if (php_sapi_name() != 'cli') $phpEx = substr(strrchr(__FILE__, '.'), 1); $phpbb_root_path = __DIR__ . '/../'; -require __DIR__ . '/event_exporter.' . $phpEx; +require __DIR__ . '/../phpbb/event/exporter.' . $phpEx; function usage() { @@ -41,7 +41,7 @@ function validate_argument_count($arguments, $count) validate_argument_count($argc, 1); $action = $argv[1]; -$exporter = new \event_exporter($phpbb_root_path); +$exporter = new \phpbb\event\exporter($phpbb_root_path); switch ($action) { diff --git a/phpBB/develop/event_exporter.php b/phpBB/phpbb/event/exporter.php similarity index 81% rename from phpBB/develop/event_exporter.php rename to phpBB/phpbb/event/exporter.php index 223f9318ba..e3dd85f5ac 100644 --- a/phpBB/develop/event_exporter.php +++ b/phpBB/phpbb/event/exporter.php @@ -7,7 +7,9 @@ * */ -class event_exporter +namespace phpbb\event; + +class exporter { /** @var string */ protected $root_path; @@ -146,7 +148,7 @@ class event_exporter { $iterator = new \DirectoryIterator($dir); } - catch (Exception $e) + catch (\Exception $e) { return array(); } @@ -213,7 +215,7 @@ class event_exporter /** * @param $file - * @throws LogicException + * @throws \LogicException */ public function crawl_php_file($file) { @@ -228,6 +230,7 @@ class event_exporter { $event_line = false; $found_trigger_event = strpos($this->file_lines[$i], "dispatcher->trigger_event('"); + $arguments = array(); if ($found_trigger_event !== false) { $event_line = $i; @@ -245,7 +248,6 @@ class event_exporter { $event_line = $i; $this->set_current_event($this->get_dispatch_name($this->file_lines[$event_line]), $event_line); - $arguments = array(); } } @@ -265,7 +267,7 @@ class event_exporter if (isset($this->events['php'][$this->current_event])) { - throw new LogicException('The event "' . $this->current_event . '" from file "' . $this->current_file + throw new \LogicException('The event "' . $this->current_event . '" from file "' . $this->current_file . '" already exists in file "'. $this->events['php'][$this->current_event]['file'] . '"', 10); } @@ -286,7 +288,7 @@ class event_exporter * * @param string $event_line * @return int Absolute line number - * @throws LogicException + * @throws \LogicException */ public function get_dispatch_name($event_line) { @@ -301,7 +303,7 @@ class event_exporter preg_match($regex, $event_line, $match); if (!isset($match[2])) { - throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $this->current_file . '"', 1); + throw new \LogicException('Can not find event name in line "' . $event_line . '" in file "' . $this->current_file . '"', 1); } return $match[2]; @@ -312,7 +314,7 @@ class event_exporter * * @param string $event_line * @return int Absolute line number - * @throws LogicException + * @throws \LogicException */ public function get_trigger_event_name($event_line) { @@ -327,7 +329,7 @@ class event_exporter preg_match($regex, $event_line, $match); if (!isset($match[2])) { - throw new LogicException('Can not find event name in line "' . $event_line . '" in file "' . $this->current_file . '"', 1); + throw new \LogicException('Can not find event name in line "' . $event_line . '" in file "' . $this->current_file . '"', 1); } return $match[2]; @@ -347,20 +349,20 @@ class event_exporter * Find the $vars array * * @return array List of variables - * @throws LogicException + * @throws \LogicException */ public function get_vars_from_array() { $vars_line = ltrim($this->file_lines[$this->current_event_line - 1], "\t"); if (strpos($vars_line, "\$vars = array('") !== 0 || substr($vars_line, -3) !== '\');') { - throw new LogicException('Can not find "$vars = array();"-line for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); + throw new \LogicException('Can not find "$vars = array();"-line for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); } $vars_array = substr($vars_line, strlen("\$vars = array('"), 0 - strlen('\');')); if ($vars_array === '') { - throw new LogicException('Found empty $vars array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); + throw new \LogicException('Found empty $vars array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); } $vars_array = explode("', '", $vars_array); @@ -369,7 +371,7 @@ class event_exporter { if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var)) { - throw new LogicException('Found invalid var "' . $var . '" in array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); + throw new \LogicException('Found invalid var "' . $var . '" in array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); } } @@ -381,7 +383,7 @@ class event_exporter * Find the $vars array * * @return array List of variables - * @throws LogicException + * @throws \LogicException */ public function get_vars_from_docblock() { @@ -404,7 +406,7 @@ class event_exporter $doc_line = explode(' ', $var_line, 5); if (sizeof($doc_line) !== 5) { - throw new LogicException('Found invalid line "' . $this->file_lines[$this->current_event_line - $current_doc_line] + throw new \LogicException('Found invalid line "' . $this->file_lines[$this->current_event_line - $current_doc_line] . '" for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); } $doc_vars[] = $doc_line[3]; @@ -415,21 +417,21 @@ class event_exporter if ($current_doc_line > $this->current_event_line) { // Reached the start of the file - throw new LogicException('Can not find end of docblock for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); + throw new \LogicException('Can not find end of docblock for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); } } if (empty($doc_vars)) { // Reached the start of the file - throw new LogicException('Can not find @var lines for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); + throw new \LogicException('Can not find @var lines for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); } foreach ($doc_vars as $var) { if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var)) { - throw new LogicException('Found invalid @var "' . $var . '" in docblock for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 4); + throw new \LogicException('Found invalid @var "' . $var . '" in docblock for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 4); } } @@ -441,7 +443,7 @@ class event_exporter * Find the "@since" Information line * * @return int Absolute line number - * @throws LogicException + * @throws \LogicException */ public function find_since() { @@ -465,7 +467,7 @@ class event_exporter * @param array $disallowed_tags List of tags that must not appear between * the tag and the actual event * @return int Absolute line number - * @throws LogicException + * @throws \LogicException */ public function find_tag($find_tag, $disallowed_tags) { @@ -476,7 +478,7 @@ class event_exporter if ($found_comment_end && ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t") === '/**') { // Reached the start of this doc block - throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); + throw new \LogicException('Can not find @' . $find_tag . ' information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); } foreach ($disallowed_tags as $disallowed_tag) @@ -484,7 +486,7 @@ class event_exporter if ($found_comment_end && strpos(ltrim($this->file_lines[$this->current_event_line - $find_tag_line], "\t"), '* @' . $disallowed_tag) === 0) { // Found @var after the @since - throw new LogicException('Found @' . $disallowed_tag . ' information after @' . $find_tag . ' for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); + throw new \LogicException('Found @' . $disallowed_tag . ' information after @' . $find_tag . ' for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); } } @@ -497,7 +499,7 @@ class event_exporter if ($find_tag_line >= $this->current_event_line) { // Reached the start of the file - throw new LogicException('Can not find @' . $find_tag . ' information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); + throw new \LogicException('Can not find @' . $find_tag . ' information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); } } @@ -508,7 +510,7 @@ class event_exporter * Find a "@*" Information line * * @return int Absolute line number - * @throws LogicException + * @throws \LogicException */ public function find_description() { @@ -519,7 +521,7 @@ class event_exporter if ($find_desc_line > $this->current_event_line) { // Reached the start of the file - throw new LogicException('Can not find a description for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); + throw new \LogicException('Can not find a description for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); } } @@ -529,7 +531,7 @@ class event_exporter if (strpos($desc, '* @') === 0 || $desc[0] !== '*' || substr($desc, 1) == '') { // First line of the doc block is a @-line, empty or only contains "*" - throw new LogicException('Can not find a description for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); + throw new \LogicException('Can not find a description for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); } return $find_desc_line; @@ -540,7 +542,7 @@ class event_exporter * * @param string $line * @return string - * @throws LogicException + * @throws \LogicException */ public function validate_since($line) { @@ -548,14 +550,14 @@ class event_exporter if ($since !== trim($since)) { - throw new LogicException('Invalid @since information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); + throw new \LogicException('Invalid @since information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); } $since = ($since === '3.1-A1') ? '3.1.0-a1' : $since; if (!preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|rc|pl)\d+)?$#', $since)) { - throw new LogicException('Invalid @since information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); + throw new \LogicException('Invalid @since information for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); } return $since; @@ -567,7 +569,7 @@ class event_exporter * @param string $event_name * @param string $line * @return string - * @throws LogicException + * @throws \LogicException */ public function validate_event($event_name, $line) { @@ -575,12 +577,12 @@ class event_exporter if ($event !== trim($event)) { - throw new LogicException('Invalid @event information for event "' . $event_name . '" in file "' . $this->current_file . '"', 1); + throw new \LogicException('Invalid @event information for event "' . $event_name . '" in file "' . $this->current_file . '"', 1); } if ($event !== $event_name) { - throw new LogicException('Event name does not match @event tag for event "' . $event_name . '" in file "' . $this->current_file . '"', 2); + throw new \LogicException('Event name does not match @event tag for event "' . $event_name . '" in file "' . $this->current_file . '"', 2); } return $event; @@ -592,7 +594,7 @@ class event_exporter * @param array $vars_array Variables found in the array line * @param array $vars_docblock Variables found in the doc block * @return null - * @throws LogicException + * @throws \LogicException */ public function validate_vars_docblock_array($vars_array, $vars_docblock) { @@ -602,7 +604,7 @@ class event_exporter if ($sizeof_vars_array !== sizeof($vars_docblock) || $sizeof_vars_array !== sizeof(array_intersect($vars_array, $vars_docblock))) { - throw new LogicException('$vars array does not match the list of @var tags for event "' . $this->current_event . '" in file "' . $this->current_file . '"'); + throw new \LogicException('$vars array does not match the list of @var tags for event "' . $this->current_event . '" in file "' . $this->current_file . '"'); } } } diff --git a/tests/event/exporter_test.php b/tests/event/exporter_test.php index 5736476f45..1608964b42 100644 --- a/tests/event/exporter_test.php +++ b/tests/event/exporter_test.php @@ -7,8 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/develop/event_exporter.php'; - class phpbb_event_exporter_test extends phpbb_test_case { /** @var \event_exporter */ @@ -17,7 +15,7 @@ class phpbb_event_exporter_test extends phpbb_test_case public function setUp() { parent::setUp(); - $this->exporter = new \event_exporter(dirname(__FILE__) . '/fixtures/'); + $this->exporter = new \phpbb\event\exporter(dirname(__FILE__) . '/fixtures/'); } static public function crawl_php_file_data() @@ -669,7 +667,7 @@ class phpbb_event_exporter_test extends phpbb_test_case public function test_crawl_phpbb_directory_php() { global $phpbb_root_path; - $exporter = new \event_exporter($phpbb_root_path); + $exporter = new \phpbb\event\exporter($phpbb_root_path); $this->assertGreaterThan(0, $exporter->crawl_phpbb_directory_php()); } } From 6da52acb3ce849b25adbf0ef9533a0acb7286ddf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Apr 2014 12:50:23 +0200 Subject: [PATCH 104/424] [ticket/12273] Rename exporter to php_exporter PHPBB3-12273 --- .../event/{exporter.php => php_exporter.php} | 93 +++++-------------- ...xporter_test.php => php_exporter_test.php} | 12 +-- 2 files changed, 26 insertions(+), 79 deletions(-) rename phpBB/phpbb/event/{exporter.php => php_exporter.php} (86%) rename tests/event/{exporter_test.php => php_exporter_test.php} (97%) diff --git a/phpBB/phpbb/event/exporter.php b/phpBB/phpbb/event/php_exporter.php similarity index 86% rename from phpBB/phpbb/event/exporter.php rename to phpBB/phpbb/event/php_exporter.php index e3dd85f5ac..51fe878d41 100644 --- a/phpBB/phpbb/event/exporter.php +++ b/phpBB/phpbb/event/php_exporter.php @@ -9,7 +9,13 @@ namespace phpbb\event; -class exporter +/** +* Class php_exporter +* Crawls through a list of files and grabs all php-events +* +* @package phpbb\event +*/ +class php_exporter { /** @var string */ protected $root_path; @@ -36,70 +42,10 @@ class exporter { $this->root_path = $phpbb_root_path; $this->events = $this->file_lines = array(); - $this->events['php'] = array(); $this->current_file = $this->current_event = ''; $this->current_event_line = 0; } - function export_from_eventsmd($filter) - { - $file_content = file_get_contents($this->root_path . 'docs/events.md'); - - $events = explode("\n\n", $file_content); - foreach ($events as $event) - { - // Last row of the file - if (strpos($event, "\n===\n") === false) continue; - - list($event_name, $details) = explode("\n===\n", $event); - - if ($filter == 'acp' && strpos($event_name, 'acp_') !== 0) continue; - if ($filter == 'styles' && strpos($event_name, 'acp_') === 0) continue; - - list($file_details, $details) = explode("\n* Since: ", $details); - list($version, $explanition) = explode("\n* Purpose: ", $details); - - echo "|- id=\"{$event_name}\"\n"; - echo "| [[#{$event_name}|{$event_name}]] || "; - - if (strpos($file_details, "* Locations:\n + ") === 0) - { - $file_details = substr($file_details, strlen("* Locations:\n + ")); - $files = explode("\n + ", $file_details); - $prosilver = $subsilver2 = $adm = array(); - foreach ($files as $file) - { - if (strpos($file, 'styles/prosilver/template/') === 0) - { - $prosilver[] = substr($file, strlen('styles/prosilver/template/')); - } - if (strpos($file, 'styles/subsilver2/template/') === 0) - { - $subsilver2[] = substr($file, strlen('styles/subsilver2/template/')); - } - if (strpos($file, 'adm/style/') === 0) - { - $adm[] = substr($file, strlen('adm/style/')); - } - } - if ($filter == 'acp') - { - echo implode(', ', $adm); - } - else - { - echo implode(', ', $prosilver) . ' || ' . implode(', ', $subsilver2); - } - } - else if ($filter == 'acp') - { - echo substr($file_details, strlen("* Location: adm/style/")); - } - echo " || {$version} || " . str_replace("\n", ' ', $explanition) . "\n"; - - } - } - public function get_events() { return $this->events; @@ -123,14 +69,14 @@ class exporter public function crawl_phpbb_directory_php() { $files = $this->get_recursive_file_list($this->root_path); - $this->events['php'] = array(); + $this->events = array(); foreach ($files as $file) { $this->crawl_php_file($file); } - ksort($this->events['php']); + ksort($this->events); - return sizeof($this->events['php']); + return sizeof($this->events); } /** @@ -201,14 +147,17 @@ class exporter * Format the php events as a wiki table * @return string */ - public function export_php_events_for_wiki() + public function export_events_for_wiki() { - $wiki_page = ''; - foreach ($this->events['php'] as $event) + $wiki_page = '= PHP Events (Hook Locations) =' . "\n"; + $wiki_page .= '{| class="sortable zebra" cellspacing="0" cellpadding="5"' . "\n"; + $wiki_page .= '! Identifier !! Placement !! Arguments !! Added in Release !! Explanation' . "\n"; + foreach ($this->events as $event) { $wiki_page .= '|- id="' . $event['event'] . '"' . "\n"; $wiki_page .= '| [[#' . $event['event'] . '|' . $event['event'] . ']] || ' . $event['file'] . ' || ' . implode(', ', $event['arguments']) . ' || ' . $event['since'] . ' || ' . $event['description'] . "\n"; } + $wiki_page .= '|}' . "\n"; return $wiki_page; } @@ -265,13 +214,13 @@ class exporter $description_line_num = $this->find_description(); $description = substr(trim($this->file_lines[$description_line_num]), strlen('* ')); - if (isset($this->events['php'][$this->current_event])) + if (isset($this->events[$this->current_event])) { throw new \LogicException('The event "' . $this->current_event . '" from file "' . $this->current_file - . '" already exists in file "'. $this->events['php'][$this->current_event]['file'] . '"', 10); + . '" already exists in file "'. $this->events[$this->current_event]['file'] . '"', 10); } - $this->events['php'][$this->current_event] = array( + $this->events[$this->current_event] = array( 'event' => $this->current_event, 'file' => $this->current_file, 'arguments' => $arguments, @@ -336,9 +285,9 @@ class exporter } /** - * Find the name of the event inside the trigger_event() line + * Returns a regex match for the event name * - * @return string Returns a regex match for the event name + * @return string */ protected function preg_match_event_name() { diff --git a/tests/event/exporter_test.php b/tests/event/php_exporter_test.php similarity index 97% rename from tests/event/exporter_test.php rename to tests/event/php_exporter_test.php index 1608964b42..2a23d1a6c1 100644 --- a/tests/event/exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -7,15 +7,15 @@ * */ -class phpbb_event_exporter_test extends phpbb_test_case +class phpbb_event_php_exporter_test extends phpbb_test_case { - /** @var \event_exporter */ + /** @var \phpbb\event\php_exporter */ protected $exporter; public function setUp() { parent::setUp(); - $this->exporter = new \phpbb\event\exporter(dirname(__FILE__) . '/fixtures/'); + $this->exporter = new \phpbb\event\php_exporter(dirname(__FILE__) . '/fixtures/'); } static public function crawl_php_file_data() @@ -70,9 +70,7 @@ class phpbb_event_exporter_test extends phpbb_test_case public function test_crawl_php_file($file, $expected) { $this->exporter->crawl_php_file($file); - $events = $this->exporter->get_events(); - $this->assertArrayHasKey('php', $events); - $this->assertEquals($expected, $events['php']); + $this->assertEquals($expected, $this->exporter->get_events()); } static public function crawl_php_file_throws_data() @@ -667,7 +665,7 @@ class phpbb_event_exporter_test extends phpbb_test_case public function test_crawl_phpbb_directory_php() { global $phpbb_root_path; - $exporter = new \phpbb\event\exporter($phpbb_root_path); + $exporter = new \phpbb\event\php_exporter($phpbb_root_path); $this->assertGreaterThan(0, $exporter->crawl_phpbb_directory_php()); } } From 17a1ed6fb59e36dcefa43d9755a69ab146e11576 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Apr 2014 12:51:13 +0200 Subject: [PATCH 105/424] [ticket/12273] Move MD Exporter to separate file PHPBB3-12273 --- phpBB/phpbb/event/md_exporter.php | 223 ++++++++++++++++++++++++++++++ tests/event/md_exporter_test.php | 30 ++++ 2 files changed, 253 insertions(+) create mode 100644 phpBB/phpbb/event/md_exporter.php create mode 100644 tests/event/md_exporter_test.php diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php new file mode 100644 index 0000000000..6a8a9b1adb --- /dev/null +++ b/phpBB/phpbb/event/md_exporter.php @@ -0,0 +1,223 @@ +root_path = $phpbb_root_path; + $this->events = array(); + $this->filter = $this->current_event = ''; + } + + public function get_events() + { + return $this->events; + } + + /** + * @param string $md_file + * @param string $filter + * @return int Number of events found + * @throws \LogicException + */ + public function crawl_eventsmd($md_file, $filter) + { + $file_content = file_get_contents($this->root_path . $md_file); + $this->filter = $filter; + + $events = explode("\n\n", $file_content); + foreach ($events as $event) + { + // Last row of the file + if (strpos($event, "\n===\n") === false) continue; + + list($event_name, $details) = explode("\n===\n", $event, 2); + $this->validate_event_name($event_name); + $this->current_event = $event_name; + + if (isset($this->events[$this->current_event])) + { + throw new \LogicException('The event "' . $this->current_event . '" is defined multiple times'); + } + + if ($this->filter == 'adm' && strpos($this->current_event, 'acp_') !== 0) continue; + if ($this->filter == 'styles' && strpos($this->current_event, 'acp_') === 0) continue; + + list($file_details, $details) = explode("\n* Since: ", $details, 2); + list($since, $description) = explode("\n* Purpose: ", $details, 2); + + $files = $this->validate_file_list($file_details); + $since = $this->validate_since($since); + + $this->events[$event_name] = array( + 'event' => $this->current_event, + 'files' => $files, + 'since' => $since, + 'description' => $description, + ); + } + + return sizeof($this->events); + } + + /** + * Format the php events as a wiki table + * @return string Number of events found + */ + public function export_events_for_wiki() + { + if ($this->filter === 'acp') + { + $wiki_page = '= ACP Template Events =' . "\n"; + $wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n"; + $wiki_page .= '! Identifier !! Placement !! Added in Release !! Explanation' . "\n"; + } + else + { + $wiki_page = '= Template Events =' . "\n"; + $wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n"; + $wiki_page .= '! Identifier !! Prosilver Placement (If applicable) !! Subsilver Placement (If applicable) !! Added in Release !! Explanation' . "\n"; + } + + foreach ($this->events as $event_name => $event) + { + $wiki_page .= "|- id=\"{$event_name}\"\n"; + $wiki_page .= "| [[#{$event_name}|{$event_name}]] || "; + + if ($this->filter === 'adm') + { + $wiki_page .= implode(', ', $event['files']['adm']); + } + else + { + $wiki_page .= implode(', ', $event['files']['prosilver']) . ' || ' . implode(', ', $event['files']['subsilver2']); + } + + $wiki_page .= " || {$event['since']} || " . str_replace("\n", ' ', $event['description']) . "\n"; + } + $wiki_page .= '|}' . "\n"; + + return $wiki_page; + } + + /** + * Validates a template event name + * + * @param $event_name + * @return null + * @throws \LogicException + */ + public function validate_event_name($event_name) + { + if (!preg_match('#^([a-z][a-z0-9]*(?:_[a-z][a-z0-9]*)+)$#', $event_name)) + { + throw new \LogicException('Found invalid event name "' . $event_name . '"'); + } + } + + /** + * Validate "Since" Information + * + * @param string $since + * @return string + * @throws \LogicException + */ + public function validate_since($since) + { + $since = ($since === '3.1-A1') ? '3.1.0-a1' : $since; + + if (!preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|rc|pl)\d+)?$#', $since)) + { + throw new \LogicException('Invalid since information for event "' . $this->current_event . '"'); + } + + return $since; + } + + /** + * Validate the files list + * + * @param string $file_details + * @return array + * @throws \LogicException + */ + public function validate_file_list($file_details) + { + $files_list = array( + 'prosilver' => array(), + 'subsilver2' => array(), + 'adm' => array(), + ); + + // Multi file list + if (strpos($file_details, "* Locations:\n + ") === 0) + { + $file_details = substr($file_details, strlen("* Locations:\n + ")); + $files = explode("\n + ", $file_details); + foreach ($files as $file) + { + if (!file_exists($this->root_path . $file)) + { + throw new \LogicException('File "' . $file . '" not found for event "' . $this->current_event . '"', 2); + } + + if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0) + { + $files_list['prosilver'][] = substr($file, strlen('styles/prosilver/template/')); + } + else if (($this->filter !== 'adm') && strpos($file, 'styles/subsilver2/template/') === 0) + { + $files_list['subsilver2'][] = substr($file, strlen('styles/subsilver2/template/')); + } + else if (($this->filter === 'adm') && strpos($file, 'adm/style/') === 0) + { + $files_list['adm'][] = substr($file, strlen('adm/style/')); + } + else + { + throw new \LogicException('Invalid file "' . $file . '" found for event "' . $this->current_event . '"', 2); + } + } + } + else if ($this->filter == 'adm') + { + $files_list['adm'][] = substr($file_details, strlen("* Location: adm/style/")); + } + else + { + throw new \LogicException('Invalid file list found for event "' . $this->current_event . '"', 2); + } + + return $files_list; + } +} diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php new file mode 100644 index 0000000000..52d10bd3e3 --- /dev/null +++ b/tests/event/md_exporter_test.php @@ -0,0 +1,30 @@ +assertGreaterThan(0, $exporter->crawl_eventsmd('docs/events.md', $filter)); + } +} From 3566325874a7d6da00ec7cd0e95543db34e1e811 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Apr 2014 12:51:45 +0200 Subject: [PATCH 106/424] [ticket/12273] Fix export script PHPBB3-12273 --- phpBB/develop/export_events_for_wiki.php | 63 +++++++++++++++++------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php index ff64dc493e..69b09ff136 100644 --- a/phpBB/develop/export_events_for_wiki.php +++ b/phpBB/develop/export_events_for_wiki.php @@ -13,20 +13,23 @@ if (php_sapi_name() != 'cli') $phpEx = substr(strrchr(__FILE__, '.'), 1); $phpbb_root_path = __DIR__ . '/../'; -require __DIR__ . '/../phpbb/event/exporter.' . $phpEx; function usage() { echo "Usage: export_events_for_wiki.php COMMAND\n"; echo "\n"; - echo "acp:\n"; - echo " Export all events for files in the acp style.\n"; - echo "\n"; - echo "styles:\n"; - echo " Export all events for files in the prosilver and subsilver2 styles.\n"; + echo "all:\n"; + echo " Generate the complete wikipage for https://wiki.phpbb.com/Event_List\n"; echo "\n"; echo "php:\n"; - echo " Export all events for php-files.\n"; + echo " Generate the PHP event section of Event_List\n"; + echo "\n"; + echo "acp:\n"; + echo " Generate the ACP Template event section of Event_List\n"; + echo "\n"; + echo "styles:\n"; + echo " Generate the Styles Template event section of Event_List\n"; + echo "\n"; exit(2); } @@ -41,22 +44,48 @@ function validate_argument_count($arguments, $count) validate_argument_count($argc, 1); $action = $argv[1]; -$exporter = new \phpbb\event\exporter($phpbb_root_path); +require __DIR__ . '/../phpbb/event/php_exporter.' . $phpEx; +require __DIR__ . '/../phpbb/event/md_exporter.' . $phpEx; switch ($action) { - case 'acp': - $exporter->export_from_eventsmd('acp'); - break; - - case 'styles': - $exporter->export_from_eventsmd('styles'); - break; + case 'all': + echo '__FORCETOC__' . "\n"; case 'php': + $exporter = new \phpbb\event\php_exporter($phpbb_root_path); $exporter->crawl_phpbb_directory_php(); - echo $exporter->export_php_events_for_wiki(); - break; + echo $exporter->export_events_for_wiki(); + + if ($action === 'php') + { + break; + } + echo "\n"; + // no break; + + case 'styles': + $exporter = new \phpbb\event\md_exporter($phpbb_root_path); + $exporter->crawl_eventsmd('docs/events.md', 'styles'); + echo $exporter->export_events_for_wiki(); + + if ($action === 'styles') + { + break; + } + echo "\n"; + // no break; + + case 'adm': + $exporter = new \phpbb\event\md_exporter($phpbb_root_path); + $exporter->crawl_eventsmd('docs/events.md', 'adm'); + echo $exporter->export_events_for_wiki(); + + if ($action === 'all') + { + echo "\n" . '[[Category:Events and Listeners]]' . "\n"; + } + break; default: usage(); From 9ba9a024d6a72eb81d77347eb866e73556b81051 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Apr 2014 13:06:13 +0200 Subject: [PATCH 107/424] [ticket/12273] Make event exporter compatible with php 5.3.3 PHPBB3-12273 --- phpBB/phpbb/event/php_exporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php index 51fe878d41..eb9e8f72b3 100644 --- a/phpBB/phpbb/event/php_exporter.php +++ b/phpBB/phpbb/event/php_exporter.php @@ -134,7 +134,7 @@ class php_exporter $files[] = $file_info->getFilename() . '/' . $file; } } - else if ($file_info->getExtension() == 'php') + else if (substr($file_info->getFilename(), -4) == '.php') { $files[] = $file_info->getFilename(); } From 7b5321092639b0f508fe160f5a58b834247982dd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 17 Apr 2014 15:06:24 +0200 Subject: [PATCH 108/424] [ticket/12273] Fix invalid @event and @since tags PHPBB3-12273 --- phpBB/includes/functions_module.php | 2 +- phpBB/includes/functions_posting.php | 2 +- phpBB/includes/functions_privmsgs.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index be066de0f0..7531883ed9 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -409,7 +409,7 @@ class p_master * @var string module_auth The module_auth of the current * module * @var int forum_id The current forum_id - * @since 3.1-A3 + * @since 3.1.0-a3 */ $vars = array('valid_tokens', 'module_auth', 'forum_id'); extract($phpbb_dispatcher->trigger_event('core.module_auth', compact($vars))); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 51bbcb8bae..638b94c220 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2345,7 +2345,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @var string url The "Return to topic" URL * @var array data Array of post data about the * submitted post - * @since 3.1-A3 + * @since 3.1.0-a3 */ $vars = array('url', 'data'); extract($phpbb_dispatcher->trigger_event('core.submit_post_end', compact($vars))); diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 9b44984dfa..7b075fc4a1 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1588,7 +1588,7 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) /** * Get all parts of the PM that are to be submited to the DB. * - * @event core.submit_pm_before + * @event core.submit_pm_before * @var string mode PM Post mode - post|reply|quote|quotepost|forward|edit * @var string subject Subject of the private message * @var array data The whole row data of the PM. From 8f57880edb9fac353754976eeec0c1e0f1f2f502 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 17 Apr 2014 16:33:12 +0200 Subject: [PATCH 109/424] [ticket/12273] Fix missing $vars line PHPBB3-12273 --- phpBB/includes/functions_posting.php | 3 ++- phpBB/mcp.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 638b94c220..df55c4540c 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1497,7 +1497,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @var bool update_search_index Flag indicating if the search index will be updated * @since 3.1.0-a4 */ - extract($phpbb_dispatcher->trigger_event('core.modify_submit_post_data', compact(array('mode', 'subject', 'username', 'topic_type', 'poll', 'data', 'update_message', 'update_search_index')))); + $vars = array('mode', 'subject', 'username', 'topic_type', 'poll', 'data', 'update_message', 'update_search_index'); + extract($phpbb_dispatcher->trigger_event('core.modify_submit_post_data', compact($vars))); // We do not handle erasing posts here if ($mode == 'delete') diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 1449346deb..5676c399af 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -197,7 +197,8 @@ if ($quickmod) * @var bool is_valid_action Flag indicating if the action was handled properly * @since 3.1.0-a4 */ - extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_options', compact(array('module', 'action', 'is_valid_action')))); + $vars = array('module', 'action', 'is_valid_action'); + extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_options', compact($vars))); if (!$is_valid_action) { From be48d1258354b83f64b3ae70e6b26e638221be58 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Apr 2014 12:52:02 +0200 Subject: [PATCH 110/424] [ticket/12273] Fix Markdown layout PHPBB3-12273 --- phpBB/docs/events.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 6897c3f22e..514b39fee2 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -549,16 +549,16 @@ Display Options screen ucp_friend_list_before === * Locations: - + styles/prosilver/template/ucp_zebra_friends.html - + styles/subsilver2/template/ucp_zebra_friends.html + + styles/prosilver/template/ucp_zebra_friends.html + + styles/subsilver2/template/ucp_zebra_friends.html * Since: 3.1.0-a4 * Purpose: Add optional elements before list of friends in UCP ucp_friend_list_after === * Locations: - + styles/prosilver/template/ucp_zebra_friends.html - + styles/subsilver2/template/ucp_zebra_friends.html + + styles/prosilver/template/ucp_zebra_friends.html + + styles/subsilver2/template/ucp_zebra_friends.html * Since: 3.1.0-a4 * Purpose: Add optional elements after list of friends in UCP From 1a913d6e0f9f1e0f5df2acbfdc5a5f43a0c83be0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Apr 2014 14:05:38 +0200 Subject: [PATCH 111/424] [ticket/12273] Do not use Inline control structures PHPBB3-12273 --- phpBB/phpbb/event/md_exporter.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php index 6a8a9b1adb..44b990c5ed 100644 --- a/phpBB/phpbb/event/md_exporter.php +++ b/phpBB/phpbb/event/md_exporter.php @@ -59,7 +59,10 @@ class md_exporter foreach ($events as $event) { // Last row of the file - if (strpos($event, "\n===\n") === false) continue; + if (strpos($event, "\n===\n") === false) + { + continue; + } list($event_name, $details) = explode("\n===\n", $event, 2); $this->validate_event_name($event_name); @@ -70,8 +73,11 @@ class md_exporter throw new \LogicException('The event "' . $this->current_event . '" is defined multiple times'); } - if ($this->filter == 'adm' && strpos($this->current_event, 'acp_') !== 0) continue; - if ($this->filter == 'styles' && strpos($this->current_event, 'acp_') === 0) continue; + if (($this->filter == 'adm' && strpos($this->current_event, 'acp_') !== 0) + || ($this->filter == 'styles' && strpos($this->current_event, 'acp_') === 0)) + { + continue; + } list($file_details, $details) = explode("\n* Since: ", $details, 2); list($since, $description) = explode("\n* Purpose: ", $details, 2); From 8b61ba238f77dd36256ecefc4b020b5d7916e158 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 18 Apr 2014 08:48:40 -0700 Subject: [PATCH 112/424] [ticket/12419] Improve font size in notifications drop-down PHPBB3-12419 --- phpBB/styles/prosilver/theme/common.css | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 298d310ab1..c85232de1a 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -1096,6 +1096,7 @@ form > p.post-notice strong { .notification_list ul li p { margin: 0; + font-size: 1em; } .notification_list div.notifications { From 34533a86dac64d36280ae7db393e10db6b4ba21b Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 18 Apr 2014 09:17:36 -0700 Subject: [PATCH 113/424] [ticket/12419] Also shrink the size of "See All" in footer a little bit PHPBB3-12419 --- phpBB/styles/prosilver/theme/common.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index c85232de1a..3e0046ba2e 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -1078,7 +1078,7 @@ form > p.post-notice strong { .dropdown-extended .footer { text-align: center; - font-size: 1.2em; + font-size: 1.1em; } .dropdown-extended ul li a, .notification_list dt > a, .dropdown-extended .footer > a { From 7cccd59cdc0f89d13b57c1aacad72dc5687dd453 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 5 Apr 2014 19:48:52 +0200 Subject: [PATCH 114/424] [ticket/12193] Fix broken HTML if SQL error occurs during migration PHPBB3-12193 --- phpBB/includes/functions.php | 10 ++++++++++ phpBB/install/database_update.php | 2 ++ 2 files changed, 12 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8c29bc7171..ef17076def 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3849,6 +3849,16 @@ function msg_handler($errno, $msg_text, $errfile, $errline) if (defined('IN_INSTALL') || defined('DEBUG') || isset($auth) && $auth->acl_get('a_')) { $msg_text = $log_text; + + // If this is defined there already was some output + // So let's not break it + if (defined('IN_DB_UPDATE')) + { + echo '
    ' . $msg_text . '
    '; + + $db->sql_return_on_error(true); + phpbb_end_update($cache, $config); + } } if ((defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index bad51e2fe3..6c9eeb6a75 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -169,6 +169,8 @@ header('Content-type: text/html; charset=UTF-8'); Date: Sat, 19 Apr 2014 09:42:45 -0700 Subject: [PATCH 115/424] [ticket/12405] Valid timezone and dateformat for create_user() in tests PHPBB3-12405 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 1f372fff0c..95ed334ed0 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -522,8 +522,8 @@ class phpbb_functional_test_case extends phpbb_test_case 'user_email' => 'nobody@example.com', 'user_type' => 0, 'user_lang' => 'en', - 'user_timezone' => 0, - 'user_dateformat' => '', + 'user_timezone' => 'UTC', + 'user_dateformat' => 'r', 'user_password' => $passwords_manager->hash($username . $username), ); return user_add($user_row); From 1757fdd4b7b1f8c461e1d4bbc949eb6eb35c3fe8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Apr 2014 20:25:45 +0200 Subject: [PATCH 116/424] [ticket/12390] Add comment to composer.json to update the build target PHPBB3-12390 --- phpBB/composer.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/composer.json b/phpBB/composer.json index 3cf83a8fe9..2941293e81 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -1,4 +1,8 @@ { + "_readme": [ + "You MUST update the clean-vendor-dir target in build/build.xml", + "accordingly when adding or upgrading dependencies." + ], "minimum-stability": "beta", "require": { "lusitanian/oauth": "0.2.*", From 0a953ddb1505087f77eab1d2ee96033f99a08294 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 12:54:19 +0200 Subject: [PATCH 117/424] [ticket/12012] Remove duplicated code (only the $sql are different) PHPBB3-12012 --- phpBB/phpbb/db/tools.php | 103 ++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 60 deletions(-) diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index bc505010ba..0e3ab59da0 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -2572,12 +2572,6 @@ class tools AND sc.colid = (SELECT colid FROM syscolumns WHERE id = object_id('{$table_name}') AND name = '{$column_name}')"; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; - } - $this->db->sql_freeresult($result); } else { @@ -2587,14 +2581,15 @@ class tools WHERE col.object_id = object_id('{$table_name}') AND col.name = '{$column_name}' AND dobj.name IS NOT NULL"; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; - } - $this->db->sql_freeresult($result); } + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $statements[] = 'ALTER TABLE [' . $table_name . '] DROP CONSTRAINT [' . $row['def_name'] . ']'; + } + $this->db->sql_freeresult($result); + return $statements; } @@ -2627,36 +2622,6 @@ class tools AND cols.id = ix.id WHERE ix.id = object_id('{$table_name}') AND cols.name = '{$column_name}'"; - $result = $this->db->sql_query($sql); - $existing_indexes = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $existing_indexes[$row['phpbb_index_name']] = array(); - } - $this->db->sql_freeresult($result); - - if (empty($existing_indexes)) - { - return array(); - } - - $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name - FROM sysindexes ix - INNER JOIN sysindexkeys ixc - ON ixc.id = ix.id - AND ixc.indid = ix.indid - INNER JOIN syscolumns cols - ON cols.colid = ixc.colid - AND cols.id = ix.id - WHERE ix.id = object_id('{$table_name}') - AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $existing_indexes[$row['phpbb_index_name']][] = $row['phpbb_column_name']; - } - $this->db->sql_freeresult($result); } else { @@ -2670,19 +2635,36 @@ class tools AND cols.object_id = ix.object_id WHERE ix.object_id = object_id('{$table_name}') AND cols.name = '{$column_name}'"; - $result = $this->db->sql_query($sql); - $existing_indexes = array(); - while ($row = $this->db->sql_fetchrow($result)) - { - $existing_indexes[$row['phpbb_index_name']] = array(); - } - $this->db->sql_freeresult($result); + } - if (empty($existing_indexes)) - { - return array(); - } + $result = $this->db->sql_query($sql); + $existing_indexes = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $existing_indexes[$row['phpbb_index_name']] = array(); + } + $this->db->sql_freeresult($result); + if (empty($existing_indexes)) + { + return array(); + } + + if ($mssql_server_properties['mssql_version'][0] == '8') // SQL Server 2000 + { + $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name + FROM sysindexes ix + INNER JOIN sysindexkeys ixc + ON ixc.id = ix.id + AND ixc.indid = ix.indid + INNER JOIN syscolumns cols + ON cols.colid = ixc.colid + AND cols.id = ix.id + WHERE ix.id = object_id('{$table_name}') + AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); + } + else + { $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name FROM sys.indexes ix INNER JOIN sys.index_columns ixc @@ -2693,15 +2675,16 @@ class tools AND cols.object_id = ix.object_id WHERE ix.object_id = object_id('{$table_name}') AND " . $this->db->sql_in_set('ix.name', array_keys($existing_indexes)); - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $existing_indexes[$row['phpbb_index_name']][] = $row['phpbb_column_name']; - } - $this->db->sql_freeresult($result); } + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $existing_indexes[$row['phpbb_index_name']][] = $row['phpbb_column_name']; + } + $this->db->sql_freeresult($result); + return $existing_indexes; } } From 4775ad59b00631bfa3ff57ee8aaa025612301586 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 12:58:46 +0200 Subject: [PATCH 118/424] [ticket/12012] Fix docs in connection manager PHPBB3-12012 --- .../test_framework/phpbb_database_test_connection_manager.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 431cee5588..887dad5b50 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -12,9 +12,11 @@ require_once dirname(__FILE__) . '/phpbb_database_connection_odbc_pdo_wrapper.ph class phpbb_database_test_connection_manager { + /** @var array */ private $config; + /** @var array */ private $dbms; - /** @var PDO */ + /** @var \PDO */ private $pdo; /** From 8ddc9ff185527128d74b618107edde2f57637dde Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 14:15:54 +0200 Subject: [PATCH 119/424] [ticket/12273] Allow multiple $vars lines PHPBB3-12273 --- phpBB/phpbb/event/php_exporter.php | 36 ++++++++++++----- tests/event/fixtures/duplicate_event.test | 9 +---- tests/event/fixtures/trigger.test | 5 +-- tests/event/fixtures/trigger_many_vars.test | 45 +++++++++++++++++++++ tests/event/php_exporter_test.php | 37 ++++++++++++++--- 5 files changed, 106 insertions(+), 26 deletions(-) create mode 100644 tests/event/fixtures/trigger_many_vars.test diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php index eb9e8f72b3..9044168980 100644 --- a/phpBB/phpbb/event/php_exporter.php +++ b/phpBB/phpbb/event/php_exporter.php @@ -302,25 +302,43 @@ class php_exporter */ public function get_vars_from_array() { - $vars_line = ltrim($this->file_lines[$this->current_event_line - 1], "\t"); - if (strpos($vars_line, "\$vars = array('") !== 0 || substr($vars_line, -3) !== '\');') + $vars_array_line = 1; + $found_vars_array = false; + $vars_array = array(); + while (ltrim($this->file_lines[$this->current_event_line - $vars_array_line], "\t") !== '*/') { - throw new \LogicException('Can not find "$vars = array();"-line for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); + $line = ltrim($this->file_lines[$this->current_event_line - $vars_array_line], "\t"); + $match = array(); + preg_match('#^\$vars (?:\+)?= array\(\'([a-zA-Z0-9_\' ,]+)\'\);$#', $line, $match); + + if (isset($match[1])) + { + $found_vars_array = true; + if (strlen($match[1]) > 90) + { + throw new \LogicException('Should use multiple lines for $vars definition' + . ' for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 1); + } + $vars_array = array_merge($vars_array, explode("', '", $match[1])); + } + + $vars_array_line++; + if ($this->current_event_line - $vars_array_line === 0) + { + throw new \LogicException('Can not find "$vars = array();"-line for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); + } } - $vars_array = substr($vars_line, strlen("\$vars = array('"), 0 - strlen('\');')); - if ($vars_array === '') + if (!$found_vars_array) { - throw new \LogicException('Found empty $vars array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 2); + throw new \LogicException('Can not find "$vars = array();"-line for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); } - $vars_array = explode("', '", $vars_array); - foreach ($vars_array as $var) { if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var)) { - throw new \LogicException('Found invalid var "' . $var . '" in array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 3); + throw new \LogicException('Found invalid var "' . $var . '" in array for event "' . $this->current_event . '" in file "' . $this->current_file . '"', 4); } } diff --git a/tests/event/fixtures/duplicate_event.test b/tests/event/fixtures/duplicate_event.test index f5fa580c2b..b042ca0377 100644 --- a/tests/event/fixtures/duplicate_event.test +++ b/tests/event/fixtures/duplicate_event.test @@ -5,16 +5,9 @@ * * @event duplicate.trigger * @var int start Start item of this page - * @var int current_row_number Number of the post on this page - * @var int end Number of posts on this page - * @var array row Array with original post and user data - * @var array cp_row Custom profile field data of the poster - * @var array attachments List of attachments - * @var array user_poster_data Poster's data from user cache - * @var array post_row Template block array of the post * @since 3.1.0-a3 */ - $vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row'); + $vars = array('start'); extract($phpbb_dispatcher->trigger_event('duplicate.trigger', compact($vars))); /** diff --git a/tests/event/fixtures/trigger.test b/tests/event/fixtures/trigger.test index 9df6e5b386..7cd6a7b956 100644 --- a/tests/event/fixtures/trigger.test +++ b/tests/event/fixtures/trigger.test @@ -9,10 +9,7 @@ * @var int end Number of posts on this page * @var array row Array with original post and user data * @var array cp_row Custom profile field data of the poster - * @var array attachments List of attachments - * @var array user_poster_data Poster's data from user cache - * @var array post_row Template block array of the post * @since 3.1.0-a3 */ - $vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row'); + $vars = array('start', 'current_row_number', 'end', 'row', 'cp_row'); extract($phpbb_dispatcher->trigger_event('core.trigger', compact($vars))); diff --git a/tests/event/fixtures/trigger_many_vars.test b/tests/event/fixtures/trigger_many_vars.test new file mode 100644 index 0000000000..79f121cd7b --- /dev/null +++ b/tests/event/fixtures/trigger_many_vars.test @@ -0,0 +1,45 @@ +assign_vars() + * @var object message_parser The message parser object + * @since 3.1-A1 + * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, + * s_topic_icons, form_enctype, s_action, s_hidden_fields, + * post_id, topic_id, forum_id, submit, preview, save, load, + * delete, cancel, refresh, error, page_data, message_parser + */ + $vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons', 'form_enctype'); + $vars += array('s_action', 's_hidden_fields', 'post_id', 'topic_id', 'forum_id', 'submit', 'preview'); + $vars += array('save', 'load', 'delete', 'cancel', 'refresh', 'error', 'page_data', 'message_parser'); + extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 2a23d1a6c1..fca7698c71 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -51,12 +51,30 @@ class phpbb_event_php_exporter_test extends phpbb_test_case 'core.trigger' => array( 'event' => 'core.trigger', 'file' => 'trigger.test', - 'arguments' => array('attachments', 'cp_row', 'current_row_number', 'end', 'post_row', 'row', 'start', 'user_poster_data'), + 'arguments' => array('cp_row', 'current_row_number', 'end', 'row', 'start'), 'since' => '3.1.0-a3', 'description' => 'Event after the post data has been assigned to the template', ), ), ), + array( + 'trigger_many_vars.test', + array( + 'core.posting_modify_template_vars' => array( + 'event' => 'core.posting_modify_template_vars', + 'file' => 'trigger_many_vars.test', + 'arguments' => array( + 'cancel', 'delete', 'error', 'form_enctype', 'forum_id', + 'load', 'message_parser', 'mode', 'moderators', 'page_data', + 'page_title', 'post_data', 'post_id', 'preview', 'refresh', + 's_action', 's_hidden_fields', 's_topic_icons', 'save', + 'submit', 'topic_id', + ), + 'since' => '3.1.0-a1', + 'description' => 'This event allows you to modify template variables for the posting screen', + ), + ), + ), array( 'none.test', array(), @@ -317,6 +335,15 @@ class phpbb_event_php_exporter_test extends phpbb_test_case static public function get_vars_from_array_throws_data() { return array( + array( + array( + '/**', + '*/', + '$phpbb_dispatcher->dispatch(\'test\');', + ), + 2, + 3, + ), array( array( '/**', @@ -325,7 +352,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case '$phpbb_dispatcher->dispatch(\'test\');', ), 3, - 1, + 3, ), array( array( @@ -335,17 +362,17 @@ class phpbb_event_php_exporter_test extends phpbb_test_case '$phpbb_dispatcher->dispatch(\'test\');', ), 3, - 1, + 3, ), array( array( '/**', '*/', - '$vars = array(\'\');', + '$vars = array(\'test2\', \'\');', '$phpbb_dispatcher->dispatch(\'test\');', ), 3, - 2, + 4, ), array( array( From b83a555da5df5b6916e4ae15aee10815bdac65d5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 14:28:09 +0200 Subject: [PATCH 120/424] [ticket/12273] Move phpBB test to new file and use a data provider PHPBB3-12273 --- phpBB/phpbb/event/php_exporter.php | 7 ++++- tests/event/export_php_test.php | 45 ++++++++++++++++++++++++++++++ tests/event/php_exporter_test.php | 7 ----- 3 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 tests/event/export_php_test.php diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php index 9044168980..1e680ec896 100644 --- a/phpBB/phpbb/event/php_exporter.php +++ b/phpBB/phpbb/event/php_exporter.php @@ -163,7 +163,8 @@ class php_exporter } /** - * @param $file + * @param string $file + * @return int Number of events found in this file * @throws \LogicException */ public function crawl_php_file($file) @@ -171,6 +172,7 @@ class php_exporter $this->current_file = $file; $this->file_lines = array(); $content = file_get_contents($this->root_path . $this->current_file); + $num_events_found = 0; if (strpos($content, "dispatcher->trigger_event('") || strpos($content, "dispatcher->dispatch('")) { @@ -227,9 +229,12 @@ class php_exporter 'since' => $since, 'description' => $description, ); + $num_events_found++; } } } + + return $num_events_found; } /** diff --git a/tests/event/export_php_test.php b/tests/event/export_php_test.php new file mode 100644 index 0000000000..f38b524ffe --- /dev/null +++ b/tests/event/export_php_test.php @@ -0,0 +1,45 @@ +exporter = new \phpbb\event\php_exporter($phpbb_root_path); + } + + static public function crawl_php_file_data() + { + global $phpbb_root_path; + $exporter = new \phpbb\event\php_exporter($phpbb_root_path); + $files = $exporter->get_recursive_file_list($phpbb_root_path); + + $data_provider = array(); + foreach ($files as $file) + { + $data_provider[] = array($file); + } + + return $data_provider; + } + + /** + * @dataProvider crawl_php_file_data + */ + public function test_crawl_php_file($file) + { + $this->assertGreaterThanOrEqual(0, $this->exporter->crawl_php_file($file)); + } +} diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index fca7698c71..a289f5f6e4 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -688,11 +688,4 @@ class phpbb_event_php_exporter_test extends phpbb_test_case $this->exporter->set_content($lines); $this->exporter->find_description(); } - - public function test_crawl_phpbb_directory_php() - { - global $phpbb_root_path; - $exporter = new \phpbb\event\php_exporter($phpbb_root_path); - $this->assertGreaterThan(0, $exporter->crawl_phpbb_directory_php()); - } } From f251a8b50dede80365b11a8a86ad3ba179e04bce Mon Sep 17 00:00:00 2001 From: PayBas Date: Sun, 20 Apr 2014 14:32:19 +0200 Subject: [PATCH 121/424] [ticket/12347] IE8 compatible CSS selector PHPBB3-12347 --- phpBB/styles/prosilver/template/navbar_footer.html | 3 ++- phpBB/styles/prosilver/theme/common.css | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/navbar_footer.html b/phpBB/styles/prosilver/template/navbar_footer.html index 62631f5796..0bc67a4417 100644 --- a/phpBB/styles/prosilver/template/navbar_footer.html +++ b/phpBB/styles/prosilver/template/navbar_footer.html @@ -3,7 +3,8 @@
    From f2e74354a34561940c3203f24816af2496b95b0b Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sat, 12 Apr 2014 04:26:51 -0700 Subject: [PATCH 171/424] [ticket/10737] Enforce allow_live_searches setting in memberlist.php. PHPBB3-10737 --- phpBB/language/en/common.php | 1 + phpBB/memberlist.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 677b228cc6..030559eeb5 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -348,6 +348,7 @@ $lang = array_merge($lang, array( 'LDAP_NO_SERVER_CONNECTION' => 'Could not connect to LDAP server.', 'LDAP_SEARCH_FAILED' => 'An error occurred while searching the LDAP directory.', 'LEGEND' => 'Legend', + 'LIVE_SEARCHES_NOT_ALLOWED' => 'Live searches are not allowed.', 'LOADING' => 'Loading', 'LOCATION' => 'Location', 'LOCK_POST' => 'Lock post', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index acda40c8fb..3d9f4aa028 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -50,6 +50,13 @@ switch ($mode) case 'email': break; + case 'livesearch': + if (!$config['allow_live_searches']) + { + trigger_error('LIVE_SEARCHES_NOT_ALLOWED'); + } + // No break + default: // Can this user view profiles/memberlist? if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) From a62b672530f1134af98f27d5318ceeae38b65f05 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 23 Apr 2014 09:14:42 -0700 Subject: [PATCH 172/424] [ticket/10737] Remove loading indicator. PHPBB3-10737 --- phpBB/styles/prosilver/template/memberlist_search.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index 0975ae947c..f4439b6934 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -10,7 +10,7 @@
    - autocomplete="off" data-filter="phpbb.search.filter" data-ajax="member_search" data-min-length="3" data-url="{U_LIVE_SEARCH}" data-results="#user-search" /> + autocomplete="off" data-filter="phpbb.search.filter" data-ajax="member_search" data-min-length="3" data-url="{U_LIVE_SEARCH}" data-results="#user-search" data-overlay="false" /> - - -
    -
    diff --git a/phpBB/styles/prosilver/template/mcp_footer.html b/phpBB/styles/prosilver/template/mcp_footer.html index e5768bdc6b..89ce7c34ab 100644 --- a/phpBB/styles/prosilver/template/mcp_footer.html +++ b/phpBB/styles/prosilver/template/mcp_footer.html @@ -1,9 +1,8 @@
    -
    - + diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index 57d6fe0911..6665019ab8 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -50,14 +50,14 @@
    - +
    -
    +

    {L_CONTACT_USER} {USERNAME}

    @@ -103,7 +103,8 @@
    -
    + +
    @@ -115,7 +116,7 @@
    {SIGNATURE}
    - + diff --git a/phpBB/styles/prosilver/template/posting_pm_header.html b/phpBB/styles/prosilver/template/posting_pm_header.html index 114b361e9a..dea50b5daf 100644 --- a/phpBB/styles/prosilver/template/posting_pm_header.html +++ b/phpBB/styles/prosilver/template/posting_pm_header.html @@ -76,7 +76,6 @@
    - -
    +
    diff --git a/phpBB/styles/prosilver/template/ucp_footer.html b/phpBB/styles/prosilver/template/ucp_footer.html index ea546f7a82..f2f1a68db3 100644 --- a/phpBB/styles/prosilver/template/ucp_footer.html +++ b/phpBB/styles/prosilver/template/ucp_footer.html @@ -1,9 +1,8 @@ -
    - +
    {S_FORM_TOKEN}
    From 69865852a0789289f17e41eb5ed77a4f1ef5d45a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 24 Apr 2014 13:16:50 +0200 Subject: [PATCH 175/424] [ticket/12436] Data passed to sql_multi_insert is expected to be multi-dim. PHPBB3-12436 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 95ed334ed0..3759097319 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -422,7 +422,7 @@ class phpbb_functional_test_case extends phpbb_test_case } else { - $db->sql_multi_insert(STYLES_TABLE, array( + $db->sql_multi_insert(STYLES_TABLE, array(array( 'style_id' => $style_id, 'style_name' => $style_path, 'style_copyright' => '', @@ -431,7 +431,7 @@ class phpbb_functional_test_case extends phpbb_test_case 'bbcode_bitfield' => 'kNg=', 'style_parent_id' => $parent_style_id, 'style_parent_tree' => $parent_style_path, - )); + ))); } } From bbc2e6c7b29603ab311828b34f3f55d0a44f0d7f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 24 Apr 2014 14:53:33 +0200 Subject: [PATCH 176/424] [ticket/12012] Move MS SQL server comparison into a method PHPBB3-12012 --- phpBB/phpbb/db/tools.php | 46 ++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 0e3ab59da0..9cd3e64d20 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -1869,7 +1869,7 @@ class tools } // Drop default value constraint - $result = $this->mssql_drop_default_constraints($table_name, $column_name); + $result = $this->mssql_get_drop_default_constraints_queries($table_name, $column_name); $statements = array_merge($statements, $result); // Remove the column @@ -2384,7 +2384,7 @@ class tools } // Drop default value constraint - $result = $this->mssql_drop_default_constraints($table_name, $column_name); + $result = $this->mssql_get_drop_default_constraints_queries($table_name, $column_name); $statements = array_merge($statements, $result); // Change the column @@ -2542,7 +2542,7 @@ class tools } /** - * Drop the default constraints of a column + * Get queries to drop the default constraints of a column * * We need to drop the default constraints of a column, * before being able to change their type or deleting them. @@ -2551,16 +2551,10 @@ class tools * @param string $column_name * @return array Array with SQL statements */ - protected function mssql_drop_default_constraints($table_name, $column_name) + protected function mssql_get_drop_default_constraints_queries($table_name, $column_name) { $statements = array(); - $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; - $result = $this->db->sql_query($sql); - $mssql_server_properties = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - // Remove default constraints - if ($mssql_server_properties['mssql_version'][0] == '8') // SQL Server 2000 + if ($this->mssql_is_sql_server_2000()) { // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx // Deprecated in SQL Server 2005 @@ -2603,12 +2597,7 @@ class tools protected function mssql_get_existing_indexes($table_name, $column_name) { $existing_indexes = array(); - $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; - $result = $this->db->sql_query($sql); - $mssql_server_properties = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if ($mssql_server_properties['mssql_version'][0] == '8') // SQL Server 2000 + if ($this->mssql_is_sql_server_2000()) { // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx // Deprecated in SQL Server 2005 @@ -2650,7 +2639,7 @@ class tools return array(); } - if ($mssql_server_properties['mssql_version'][0] == '8') // SQL Server 2000 + if ($this->mssql_is_sql_server_2000()) { $sql = "SELECT DISTINCT ix.name AS phpbb_index_name, cols.name AS phpbb_column_name FROM sysindexes ix @@ -2687,4 +2676,25 @@ class tools return $existing_indexes; } + + protected $is_sql_server_2000; + + /** + * Is the used MS SQL Server a SQL Server 2000? + * + * @return bool + */ + protected function mssql_is_sql_server_2000() + { + if ($this->is_sql_server_2000 === null) + { + $sql = "SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(25)) AS mssql_version"; + $result = $this->db->sql_query($sql); + $properties = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + $this->is_sql_server_2000 = $properties['mssql_version'][0] == '8'; + } + + return $this->is_sql_server_2000; + } } From c7dcc6d7007d1500fc5007b2b33916e9f20f137b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 15:48:04 +0200 Subject: [PATCH 177/424] [ticket/12273] Verify that the events are still in the named files PHPBB3-12273 --- phpBB/phpbb/event/md_exporter.php | 53 +++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php index 44b990c5ed..8714bdb2f7 100644 --- a/phpBB/phpbb/event/md_exporter.php +++ b/phpBB/phpbb/event/md_exporter.php @@ -36,6 +36,7 @@ class md_exporter { $this->root_path = $phpbb_root_path; $this->events = array(); + $this->events_by_file = array(); $this->filter = $this->current_event = ''; } @@ -70,7 +71,7 @@ class md_exporter if (isset($this->events[$this->current_event])) { - throw new \LogicException('The event "' . $this->current_event . '" is defined multiple times'); + throw new \LogicException("The event '{$this->current_event}' is defined multiple times"); } if (($this->filter == 'adm' && strpos($this->current_event, 'acp_') !== 0) @@ -93,6 +94,11 @@ class md_exporter ); } + foreach ($this->events_by_file as $file => $events) + { + $this->validate_events_for_file($file, $events); + } + return sizeof($this->events); } @@ -147,7 +153,7 @@ class md_exporter { if (!preg_match('#^([a-z][a-z0-9]*(?:_[a-z][a-z0-9]*)+)$#', $event_name)) { - throw new \LogicException('Found invalid event name "' . $event_name . '"'); + throw new \LogicException("Invalid event name '{$event_name}'"); } } @@ -164,7 +170,7 @@ class md_exporter if (!preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|rc|pl)\d+)?$#', $since)) { - throw new \LogicException('Invalid since information for event "' . $this->current_event . '"'); + throw new \LogicException("Invalid since information found for event '{$this->current_event}'"); } return $since; @@ -192,10 +198,6 @@ class md_exporter $files = explode("\n + ", $file_details); foreach ($files as $file) { - if (!file_exists($this->root_path . $file)) - { - throw new \LogicException('File "' . $file . '" not found for event "' . $this->current_event . '"', 2); - } if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0) { @@ -211,19 +213,50 @@ class md_exporter } else { - throw new \LogicException('Invalid file "' . $file . '" found for event "' . $this->current_event . '"', 2); + throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2); } + + $this->events_by_file[$file][] = $this->current_event; } } else if ($this->filter == 'adm') { - $files_list['adm'][] = substr($file_details, strlen("* Location: adm/style/")); + $file = substr($file_details, strlen('* Location: ')); + $files_list['adm'][] = substr($file, strlen('adm/style/')); + + $this->events_by_file[$file][] = $this->current_event; } else { - throw new \LogicException('Invalid file list found for event "' . $this->current_event . '"', 2); + throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 2); } return $files_list; } + + /** + * Validates whether a list of events is named in $file + * + * @param string $file + * @param array $events + * @return null + * @throws \LogicException + */ + public function validate_events_for_file($file, array $events) + { + if (!file_exists($this->root_path . $file)) + { + $event_list = implode("', '", $events); + throw new \LogicException("File '{$file}' not found for event '{$event_list}'", 1); + } + + $file_content = file_get_contents($this->root_path . $file); + foreach ($events as $event) + { + if (strpos($file_content, '') === false) + { + throw new \LogicException("Event '{$event}' not found in file '{$file}'", 2); + } + } + } } From 23dbddc59d864a71d99b1fd024533cb24ffff626 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 15:51:08 +0200 Subject: [PATCH 178/424] [ticket/12273] Fix some locations of existing events PHPBB3-12273 --- phpBB/docs/events.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 514b39fee2..db73989616 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -66,13 +66,13 @@ acp_simple_header_body_before acp_simple_header_head_append === -* Location: adm/style/overall_header.html +* Location: adm/style/simple_header.html * Since: 3.1.0-a1 * Purpose: Add assets within the `` tags in the simple header of the ACP acp_users_overview_options_append === -* Location: adm/style/acp_users.html +* Location: adm/style/acp_users_overview.html * Since: 3.1.0-a1 * Purpose: Add options and settings on user overview page From f676f50c22a2e8d4a6c5671c5cf2f9f7372ed40d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 15:55:24 +0200 Subject: [PATCH 179/424] [ticket/12273] Only check selected files PHPBB3-12273 --- phpBB/phpbb/event/md_exporter.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php index 8714bdb2f7..089115b91f 100644 --- a/phpBB/phpbb/event/md_exporter.php +++ b/phpBB/phpbb/event/md_exporter.php @@ -198,7 +198,6 @@ class md_exporter $files = explode("\n + ", $file_details); foreach ($files as $file) { - if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0) { $files_list['prosilver'][] = substr($file, strlen('styles/prosilver/template/')); @@ -253,9 +252,13 @@ class md_exporter $file_content = file_get_contents($this->root_path . $file); foreach ($events as $event) { - if (strpos($file_content, '') === false) + if (($this->filter !== 'adm') && strpos($file, 'adm/style/') !== 0 + || ($this->filter === 'adm') && strpos($file, 'adm/style/') === 0) { - throw new \LogicException("Event '{$event}' not found in file '{$file}'", 2); + if (strpos($file_content, '') === false) + { + throw new \LogicException("Event '{$event}' not found in file '{$file}'", 2); + } } } } From 7dc32a45e5c43f29b19b8a8138b515c9e09d23de Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 17:00:18 +0200 Subject: [PATCH 180/424] [ticket/12273] Verify the result of the .md file to the source PHPBB3-12273 --- phpBB/phpbb/event/md_exporter.php | 172 ++++++++++++++++++++++++++---- 1 file changed, 154 insertions(+), 18 deletions(-) diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php index 089115b91f..8dba963f11 100644 --- a/phpBB/phpbb/event/md_exporter.php +++ b/phpBB/phpbb/event/md_exporter.php @@ -45,6 +45,54 @@ class md_exporter return $this->events; } + /** + * @param string $md_file + * @param string $filter + * @return int Number of events found + * @throws \LogicException + */ + public function crawl_phpbb_directory_adm($md_file) + { + $this->crawl_eventsmd($md_file, 'adm'); + + $file_list = $this->get_recursive_file_list($this->root_path . 'adm/style/', 'adm/style/'); + foreach ($file_list as $file) + { + $file_name = 'adm/style/' . $file; + $this->validate_events_from_file($file_name, $this->crawl_file_for_events($file_name)); + } + + return sizeof($this->events); + } + + /** + * @param string $md_file + * @param string $filter + * @return int Number of events found + * @throws \LogicException + */ + public function crawl_phpbb_directory_styles($md_file) + { + $this->crawl_eventsmd($md_file, 'styles'); + + $styles = array('prosilver', 'subsilver2'); + foreach ($styles as $style) + { + $file_list = $this->get_recursive_file_list( + $this->root_path . 'styles/' . $style . '/template/', + 'styles/' . $style . '/template/' + ); + + foreach ($file_list as $file) + { + $file_name = 'styles/' . $style . '/template/' . $file; + $this->validate_events_from_file($file_name, $this->crawl_file_for_events($file_name)); + } + } + + return sizeof($this->events); + } + /** * @param string $md_file * @param string $filter @@ -94,11 +142,6 @@ class md_exporter ); } - foreach ($this->events_by_file as $file => $events) - { - $this->validate_events_for_file($file, $events); - } - return sizeof($this->events); } @@ -233,33 +276,126 @@ class md_exporter return $files_list; } + public function crawl_file_for_events($file) + { + if (!file_exists($this->root_path . $file)) + { + throw new \LogicException("File '{$file}' does not exist", 1); + } + + $event_list = array(); + $file_content = file_get_contents($this->root_path . $file); + + $events = explode('', $event, 2); + $event_list[] = $event_name; + } + + return $event_list; + } + /** - * Validates whether a list of events is named in $file + * Validates whether all events from $file are in the md file and vice-versa * * @param string $file * @param array $events * @return null * @throws \LogicException */ - public function validate_events_for_file($file, array $events) + public function validate_events_from_file($file, array $events) { - if (!file_exists($this->root_path . $file)) + if (empty($this->events_by_file[$file]) && empty($events)) { - $event_list = implode("', '", $events); - throw new \LogicException("File '{$file}' not found for event '{$event_list}'", 1); + return true; + } + else if (empty($events)) + { + $event_list = implode("', '", $this->events_by_file[$file]); + throw new \LogicException("File '{$file}' contains no events, but should contain: " + . "'{$event_list}'", 1); } - $file_content = file_get_contents($this->root_path . $file); - foreach ($events as $event) + $missing_events_from_file = array(); + foreach ($this->events_by_file[$file] as $event) { - if (($this->filter !== 'adm') && strpos($file, 'adm/style/') !== 0 - || ($this->filter === 'adm') && strpos($file, 'adm/style/') === 0) + if (!in_array($event, $events)) { - if (strpos($file_content, '') === false) - { - throw new \LogicException("Event '{$event}' not found in file '{$file}'", 2); - } + $missing_events_from_file[] = $event; } } + + if (!empty($missing_events_from_file)) + { + $event_list = implode("', '", $missing_events_from_file); + throw new \LogicException("File '{$file}' does not contain events: '{$event_list}'", 2); + } + + $missing_events_from_md = array(); + foreach ($events as $event) + { + if (!in_array($event, $this->events_by_file[$file])) + { + $missing_events_from_md[] = $event; + } + } + + if (!empty($missing_events_from_md)) + { + $event_list = implode("', '", $missing_events_from_md); + throw new \LogicException("File '{$file}' contains additional events: '{$event_list}'", 3); + } + + return true; + } + + /** + * Returns a list of files in $dir + * + * Works recursive with any depth + * + * @param string $dir Directory to go through + * @param string $path Path from root to $dir + * @return array List of files (including directories) + */ + public function get_recursive_file_list($dir, $path = '') + { + try + { + $iterator = new \DirectoryIterator($dir); + } + catch (\Exception $e) + { + return array(); + } + + $files = array(); + foreach ($iterator as $file_info) + { + /** @var \DirectoryIterator $file_info */ + if ($file_info->isDot()) + { + continue; + } + + // Do not scan some directories + if ($file_info->isDir()) + { + $sub_dir = $this->get_recursive_file_list($file_info->getPath() . '/' . $file_info->getFilename(), $path . '/' . $file_info->getFilename()); + foreach ($sub_dir as $file) + { + $files[] = $file_info->getFilename() . '/' . $file; + } + } + else if (substr($file_info->getFilename(), -5) == '.html') + { + $files[] = $file_info->getFilename(); + } + } + + return $files; } } From 58892555299ad9df5bdd2c5401a854068860e68d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 17:01:00 +0200 Subject: [PATCH 181/424] [ticket/12273] Test source files and compare with events.md PHPBB3-12273 --- phpBB/develop/export_events_for_wiki.php | 6 ++-- tests/event/md_exporter_test.php | 37 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/phpBB/develop/export_events_for_wiki.php b/phpBB/develop/export_events_for_wiki.php index 69b09ff136..cc4aa4444f 100644 --- a/phpBB/develop/export_events_for_wiki.php +++ b/phpBB/develop/export_events_for_wiki.php @@ -24,7 +24,7 @@ function usage() echo "php:\n"; echo " Generate the PHP event section of Event_List\n"; echo "\n"; - echo "acp:\n"; + echo "adm:\n"; echo " Generate the ACP Template event section of Event_List\n"; echo "\n"; echo "styles:\n"; @@ -66,7 +66,7 @@ switch ($action) case 'styles': $exporter = new \phpbb\event\md_exporter($phpbb_root_path); - $exporter->crawl_eventsmd('docs/events.md', 'styles'); + $exporter->crawl_phpbb_directory_styles('docs/events.md'); echo $exporter->export_events_for_wiki(); if ($action === 'styles') @@ -78,7 +78,7 @@ switch ($action) case 'adm': $exporter = new \phpbb\event\md_exporter($phpbb_root_path); - $exporter->crawl_eventsmd('docs/events.md', 'adm'); + $exporter->crawl_phpbb_directory_adm('docs/events.md'); echo $exporter->export_events_for_wiki(); if ($action === 'all') diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php index 52d10bd3e3..5fb3a99254 100644 --- a/tests/event/md_exporter_test.php +++ b/tests/event/md_exporter_test.php @@ -27,4 +27,41 @@ class phpbb_event_md_exporter_test extends phpbb_test_case $exporter = new \phpbb\event\md_exporter($phpbb_root_path); $this->assertGreaterThan(0, $exporter->crawl_eventsmd('docs/events.md', $filter)); } + + static public function crawl_adm_files_data() + { + global $phpbb_root_path; + $exporter = new \phpbb\event\md_exporter($phpbb_root_path); + $data_provider = array(); + + $styles = array( + 'adm/style/' => 'adm', + 'styles/prosilver/template/' => 'styles', + 'styles/subsilver2/template/' => 'styles', + ); + foreach ($styles as $path => $filter) + { + $files = $exporter->get_recursive_file_list($phpbb_root_path . $path, $path); + foreach ($files as $file) + { + $data_provider[] = array($filter, $path . $file); + } + } + + return $data_provider; + } + + /** + * @dataProvider crawl_adm_files_data + */ + public function test_crawl_adm_files($filter, $file) + { + global $phpbb_root_path; + $exporter = new \phpbb\event\md_exporter($phpbb_root_path); + $exporter->crawl_eventsmd('docs/events.md', $filter); + $events = $exporter->crawl_file_for_events($file); + + $this->assertGreaterThanOrEqual(0, sizeof($events)); + $this->assertTrue($exporter->validate_events_from_file($file, $events)); + } } From a2c3b2534a3a187a7ccc3e4b86ba69735c4b8b1a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 17:08:06 +0200 Subject: [PATCH 182/424] [ticket/12273] Fix method name of test and fix undefined index PHPBB3-12273 --- phpBB/phpbb/event/md_exporter.php | 11 +++++++++++ tests/event/md_exporter_test.php | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php index 8dba963f11..708900c693 100644 --- a/phpBB/phpbb/event/md_exporter.php +++ b/phpBB/phpbb/event/md_exporter.php @@ -241,6 +241,11 @@ class md_exporter $files = explode("\n + ", $file_details); foreach ($files as $file) { + if (!file_exists($this->root_path . $file)) + { + throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 1); + } + if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0) { $files_list['prosilver'][] = substr($file, strlen('styles/prosilver/template/')); @@ -312,6 +317,12 @@ class md_exporter { return true; } + else if (empty($this->events_by_file[$file])) + { + $event_list = implode("', '", $events); + throw new \LogicException("File '{$file}' should not contain events, but contains: " + . "'{$event_list}'", 1); + } else if (empty($events)) { $event_list = implode("', '", $this->events_by_file[$file]); diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php index 5fb3a99254..b62b55accd 100644 --- a/tests/event/md_exporter_test.php +++ b/tests/event/md_exporter_test.php @@ -28,7 +28,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case $this->assertGreaterThan(0, $exporter->crawl_eventsmd('docs/events.md', $filter)); } - static public function crawl_adm_files_data() + static public function crawl_template_file_data() { global $phpbb_root_path; $exporter = new \phpbb\event\md_exporter($phpbb_root_path); @@ -52,9 +52,9 @@ class phpbb_event_md_exporter_test extends phpbb_test_case } /** - * @dataProvider crawl_adm_files_data + * @dataProvider crawl_template_file_data */ - public function test_crawl_adm_files($filter, $file) + public function test_crawl_template_file($filter, $file) { global $phpbb_root_path; $exporter = new \phpbb\event\md_exporter($phpbb_root_path); From 8e4b4bc72e201d5511e5dc45fc19fae88b182a22 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 17:13:22 +0200 Subject: [PATCH 183/424] [ticket/12273] Fix subsilver2 missing from simple_footer_after docs PHPBB3-12273 --- phpBB/docs/events.md | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index db73989616..578bad3187 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -423,6 +423,7 @@ simple_footer_after === * Locations: + styles/prosilver/template/simple_footer.html + + styles/subsilver2/template/simple_footer.html * Since: 3.1.0-a1 * Purpose: Add content directly prior to the `` tag of the simple footer From 320a2f75789bf124a3300f91c8275aa650fd3271 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 17:23:32 +0200 Subject: [PATCH 184/424] [ticket/12273] Fix number of = in events.md PHPBB3-12273 --- phpBB/docs/events.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 578bad3187..2a6adcb94f 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -91,7 +91,7 @@ acp_users_signature_editor_buttons_before * Purpose: Add content before BBCode posting buttons in the ACP user signature forumlist_body_category_header_after -==== +=== * Locations: + styles/prosilver/template/forumlist_body.html + styles/subsilver2/template/forumlist_body.html @@ -99,7 +99,7 @@ forumlist_body_category_header_after * Purpose: Add content after the header of the category on the forum list. forumlist_body_category_header_before -==== +=== * Locations: + styles/prosilver/template/forumlist_body.html + styles/subsilver2/template/forumlist_body.html @@ -107,7 +107,7 @@ forumlist_body_category_header_before * Purpose: Add content before the header of the category on the forum list. forumlist_body_last_post_title_prepend -==== +=== * Locations: + styles/prosilver/template/forumlist_body.html + styles/subsilver2/template/forumlist_body.html @@ -115,7 +115,7 @@ forumlist_body_last_post_title_prepend * Purpose: Add content before the post title of the latest post in a forum on the forum list. forumlist_body_subforums_after -==== +=== * Locations: + styles/prosilver/template/forumlist_body.html + styles/subsilver2/template/forumlist_body.html @@ -123,7 +123,7 @@ forumlist_body_subforums_after * Purpose: Add content after the list of subforums (if any) for each forum on the forum list. forumlist_body_subforums_before -==== +=== * Locations: + styles/prosilver/template/forumlist_body.html + styles/subsilver2/template/forumlist_body.html @@ -131,7 +131,7 @@ forumlist_body_subforums_before * Purpose: Add content before the list of subforums (if any) for each forum on the forum list. forumlist_body_last_row_after -==== +=== * Locations: + styles/prosilver/template/forumlist_body.html + styles/subsilver2/template/forumlist_body.html From d2ab30590988511778e9448ac68ad4db379e6f8a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 17:35:48 +0200 Subject: [PATCH 185/424] [ticket/12273] Add missing event documentation PHPBB3-12273 --- phpBB/docs/events.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 2a6adcb94f..686f5e6203 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -455,6 +455,22 @@ topiclist_row_append * Since: 3.1.0-a1 * Purpose: Add content into topic rows (inside the elements containing topic titles) +ucp_pm_viewmessage_contact_fields_after +=== +* Locations: + + styles/prosilver/template/ucp_pm_viewmessage.html +* Since: 3.1.0-b1 +* Purpose: Add data after the contact fields on the user profile when viewing +a private message + +ucp_pm_viewmessage_contact_fields_before +=== +* Locations: + + styles/prosilver/template/ucp_pm_viewmessage.html +* Since: 3.1.0-b1 +* Purpose: Add data before the contact fields on the user profile when viewing +a private message + ucp_pm_viewmessage_custom_fields_after === * Locations: From b0a9acd8ff953736d6aeb39095aca278c0869563 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 24 Apr 2014 17:14:12 +0200 Subject: [PATCH 186/424] [ticket/12273] Use array_merge instead of += PHPBB3-12273 --- phpBB/phpbb/event/php_exporter.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php index 3956be600b..8de3051d9b 100644 --- a/phpBB/phpbb/event/php_exporter.php +++ b/phpBB/phpbb/event/php_exporter.php @@ -302,17 +302,17 @@ class php_exporter { $line = ltrim($this->file_lines[$this->current_event_line - $vars_array_line], "\t"); $match = array(); - preg_match('#^\$vars (?:\+)?= array\(\'([a-zA-Z0-9_\' ,]+)\'\);$#', $line, $match); + preg_match('#^\$vars = (array_merge\(\$vars, )?array\(\'([a-zA-Z0-9_\' ,]+)\'\)(?(1)\));$#', $line, $match); - if (isset($match[1])) + if (isset($match[2])) { $found_vars_array = true; - if (strlen($match[1]) > 90) + if (strlen($match[2]) > 90) { throw new \LogicException('Should use multiple lines for $vars definition ' . "for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 3); } - $vars_array = array_merge($vars_array, explode("', '", $match[1])); + $vars_array = array_merge($vars_array, explode("', '", $match[2])); } $vars_array_line++; From 8599554443deee1d655ffc4ae0ad97c60ba0a123 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 24 Apr 2014 17:14:45 +0200 Subject: [PATCH 187/424] [ticket/12273] Fix unit test for multi line $vars PHPBB3-12273 --- tests/event/fixtures/trigger_many_vars.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/event/fixtures/trigger_many_vars.test b/tests/event/fixtures/trigger_many_vars.test index 79f121cd7b..fadfcffefc 100644 --- a/tests/event/fixtures/trigger_many_vars.test +++ b/tests/event/fixtures/trigger_many_vars.test @@ -40,6 +40,6 @@ * delete, cancel, refresh, error, page_data, message_parser */ $vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons', 'form_enctype'); - $vars += array('s_action', 's_hidden_fields', 'post_id', 'topic_id', 'forum_id', 'submit', 'preview'); - $vars += array('save', 'load', 'delete', 'cancel', 'refresh', 'error', 'page_data', 'message_parser'); + $vars = array_merge($vars, array('s_action', 's_hidden_fields', 'post_id', 'topic_id', 'forum_id', 'submit', 'preview')); + $vars = array_merge($vars, array('save', 'load', 'delete', 'cancel', 'refresh', 'error', 'page_data', 'message_parser')); extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); From c2dace762ec295c7a2d67758006b1fff56f1f573 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 15:13:13 +0200 Subject: [PATCH 188/424] [ticket/12273] Fix long $vars lines for existing events PHPBB3-12273 --- phpBB/includes/acp/acp_bbcodes.php | 4 +++- phpBB/includes/acp/acp_forums.php | 3 ++- phpBB/includes/functions_admin.php | 9 ++++++--- phpBB/includes/functions_content.php | 3 ++- phpBB/includes/functions_posting.php | 3 ++- phpBB/memberlist.php | 3 ++- phpBB/phpbb/log/log.php | 4 +++- phpBB/phpbb/user.php | 3 ++- phpBB/posting.php | 7 +++++-- phpBB/viewtopic.php | 12 +++++++++--- 10 files changed, 36 insertions(+), 15 deletions(-) diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php index 84382b6276..a05b1df760 100644 --- a/phpBB/includes/acp/acp_bbcodes.php +++ b/phpBB/includes/acp/acp_bbcodes.php @@ -159,7 +159,9 @@ class acp_bbcodes * submitting form when $warn_text is true * @since 3.1.0-a3 */ - $vars = array('action', 'sql_ary', 'bbcode_id', 'display_on_posting', 'bbcode_match', 'bbcode_tpl', 'bbcode_helpline', 'hidden_fields'); + $vars = array('action', 'sql_ary', 'bbcode_id', 'display_on_posting'); + $vars = array_merge($vars, array('bbcode_match', 'bbcode_tpl')); + $vars = array_merge($vars, array('bbcode_helpline', 'hidden_fields')); extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create', compact($vars))); $warn_text = preg_match('%<[^>]*\{text[\d]*\}[^>]*>%i', $bbcode_tpl); diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index c47d9bc185..0163d12ed0 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -707,7 +707,8 @@ class acp_forums * @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'); + $vars = array('action', 'update', 'forum_id', 'row', 'forum_data'); + $vars = array_merge($vars, array('parents_list', 'errors', 'template_data')); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_display_form', compact($vars))); $template->assign_vars($template_data); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index d72f89b6ac..28cb2c2f63 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -755,7 +755,8 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = * @var array delete_notifications_types Array with notifications types to delete * @since 3.1.0-a4 */ - $vars = array('where_type', 'where_ids', 'auto_sync', 'posted_sync', 'post_count_sync', 'call_delete_topics', 'delete_notifications_types'); + $vars = array('where_type', 'where_ids', 'auto_sync', 'posted_sync', 'post_count_sync'); + $vars = array_merge($vars, array('call_delete_topics', 'delete_notifications_types')); extract($phpbb_dispatcher->trigger_event('core.delete_posts_before', compact($vars))); if ($where_type === 'range') @@ -912,7 +913,8 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = * @var array delete_notifications_types Array with notifications types to delete * @since 3.1.0-a4 */ - $vars = array('post_ids', 'poster_ids', 'topic_ids', 'forum_ids', 'where_type', 'where_ids', 'delete_notifications_types'); + $vars = array('post_ids', 'poster_ids', 'topic_ids', 'forum_ids', 'where_type'); + $vars = array_merge($vars, array('where_ids', 'delete_notifications_types')); extract($phpbb_dispatcher->trigger_event('core.delete_posts_in_transaction', compact($vars))); $db->sql_transaction('commit'); @@ -930,7 +932,8 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = * @var array delete_notifications_types Array with notifications types to delete * @since 3.1.0-a4 */ - $vars = array('post_ids', 'poster_ids', 'topic_ids', 'forum_ids', 'where_type', 'where_ids', 'delete_notifications_types'); + $vars = array('post_ids', 'poster_ids', 'topic_ids', 'forum_ids', 'where_type'); + $vars = array_merge($vars, array('where_ids', 'delete_notifications_types')); extract($phpbb_dispatcher->trigger_event('core.delete_posts_after', compact($vars))); // Resync topics_posted table diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index b1f69c5756..bd711541c2 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1410,7 +1410,8 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', * @var array _profile_cache Array of original return templates * @since 3.1-A1 */ - $vars = array('mode', 'user_id', 'username', 'username_colour', 'guest_username', 'custom_profile_url', 'username_string', '_profile_cache'); + $vars = array('mode', 'user_id', 'username', 'username_colour', 'guest_username'); + $vars = array_merge($vars, array('custom_profile_url', 'username_string', '_profile_cache')); extract($phpbb_dispatcher->trigger_event('core.modify_username_string', compact($vars))); return $username_string; diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index df55c4540c..b3d8ccdb39 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1497,7 +1497,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @var bool update_search_index Flag indicating if the search index will be updated * @since 3.1.0-a4 */ - $vars = array('mode', 'subject', 'username', 'topic_type', 'poll', 'data', 'update_message', 'update_search_index'); + $vars = array('mode', 'subject', 'username', 'topic_type', 'poll', 'data'); + $vars = array_merge($vars, array('update_message', 'update_search_index')); extract($phpbb_dispatcher->trigger_event('core.modify_submit_post_data', compact($vars))); // We do not handle erasing posts here diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 8fceb4ac5b..0a96f6c418 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -604,7 +604,8 @@ switch ($mode) * @since 3.1-A1 * @changed 3.1.0-b2 Added friend and foe status */ - $vars = array('member', 'user_notes_enabled', 'warn_user_enabled', 'zebra_enabled', 'friends_enabled', 'foes_enabled', 'friend', 'foe'); + $vars = array('member', 'user_notes_enabled', 'warn_user_enabled', 'zebra_enabled'); + $vars = array_merge($vars, array('friends_enabled', 'foes_enabled', 'friend', 'foe')); extract($phpbb_dispatcher->trigger_event('core.memberlist_view_profile', compact($vars))); $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled)); diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 44fba06d9d..b0aa637002 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -405,7 +405,9 @@ class log implements \phpbb\log\log_interface * e.g.: 'AND l.forum_id = 1' * @since 3.1-A1 */ - $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); + $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id'); + $vars = array_merge($vars, array('user_id', 'log_time', 'sort_by', 'keywords')); + $vars = array_merge($vars, array('profile_url', 'log_type', 'sql_additional')); extract($this->dispatcher->trigger_event('core.get_logs_modify_type', compact($vars))); if ($log_type === false) diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index b9b3896606..1f65b63522 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -145,7 +145,8 @@ class user extends \phpbb\session * @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', 'lang_set_ext', 'style_id'); + $vars = array('user_data', 'user_lang_name', 'user_date_format', 'lang_set'); + $vars = array_merge($vars, array('user_timezone', 'lang_set_ext', 'style_id')); extract($phpbb_dispatcher->trigger_event('core.user_setup', compact($vars))); $this->data = $user_data; diff --git a/phpBB/posting.php b/phpBB/posting.php index ed1268e84b..3d48a67e60 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -82,7 +82,9 @@ $current_time = time(); * language keys. * @since 3.1-A1 */ -$vars = array('post_id', 'topic_id', 'forum_id', 'draft_id', 'lastclick', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error'); +$vars = array('post_id', 'topic_id', 'forum_id', 'draft_id', 'lastclick'); +$vars = array_merge($vars, array('submit', 'preview', 'save', 'load', 'delete')); +$vars = array_merge($vars, array('cancel', 'refresh', 'mode', 'error')); extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars))); // Was cancel pressed? If so then redirect to the appropriate page @@ -1561,7 +1563,8 @@ $template->assign_vars(array( * @since 3.1-A1 * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, s_topic_icons, form_enctype, s_action, s_hidden_fields */ -$vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons', 'form_enctype', 's_action', 's_hidden_fields'); +$vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons'); +$vars = array_merge($vars, array('form_enctype', 's_action', 's_hidden_fields')); extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); // Build custom bbcodes array diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index ad7e8c29bc..5be578423f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1000,7 +1000,8 @@ $sql_ary = array( * @since 3.1-A1 * @change 3.1.0-a2 Added vars forum_id, topic_id, topic_data, post_list, sort_days, sort_key, sort_dir, start */ -$vars = array('forum_id', 'topic_id', 'topic_data', 'post_list', 'sort_days', 'sort_key', 'sort_dir', 'start', 'sql_ary'); +$vars = array('forum_id', 'topic_id', 'topic_data', 'post_list', 'sort_days'); +$vars = array_merge($vars, array('sort_key', 'sort_dir', 'start', 'sql_ary')); extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_post_data', compact($vars))); $sql = $db->sql_build_query('SELECT', $sql_ary); @@ -1679,7 +1680,8 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) * @change 3.1.0-a3 Added vars start, current_row_number, end, attachments * @change 3.1.0-b3 Added topic_data array, total_posts */ - $vars = array('start', 'current_row_number', 'end', 'total_posts', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row', 'topic_data'); + $vars = array('start', 'current_row_number', 'end', 'total_posts', 'row', 'cp_row'); + $vars = array_merge($vars, array('attachments', 'user_poster_data', 'post_row', 'topic_data')); extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars))); $i = $current_row_number; @@ -1726,14 +1728,18 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) * @var int start Start item of this page * @var int current_row_number Number of the post on this page * @var int end Number of posts on this page + * @var int total_posts Total posts count * @var array row Array with original post and user data * @var array cp_row Custom profile field data of the poster * @var array attachments List of attachments * @var array user_poster_data Poster's data from user cache * @var array post_row Template block array of the post + * @var array topic_data Array with topic data * @since 3.1.0-a3 + * @change 3.1.0-b3 Added topic_data array, total_posts */ - $vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row'); + $vars = array('start', 'current_row_number', 'end', 'total_posts', 'row', 'cp_row'); + $vars = array_merge($vars, array('attachments', 'user_poster_data', 'post_row', 'topic_data')); extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_row_after', compact($vars))); $i = $current_row_number; From 65c8280fb6a7ca9382d3d57c51bcd2aeecb128c8 Mon Sep 17 00:00:00 2001 From: PayBas Date: Thu, 24 Apr 2014 22:09:15 +0200 Subject: [PATCH 189/424] [ticket/12389] Change "PM" to "Message" PHPBB3-12389 --- phpBB/language/en/ucp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 0af2ffe039..5148589471 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -412,7 +412,7 @@ $lang = array_merge($lang, array( 'PM_SENTBOX' => 'Sent messages', 'PM_SUBJECT' => 'Message subject', 'PM_TO' => 'Send to', - 'PM_TOOLS' => 'PM tools', + 'PM_TOOLS' => 'Message tools', 'PM_USERS_REMOVED_NO_PM' => 'Some users couldn’t be added as they have disabled private message receipt.', 'POST_EDIT_PM' => 'Edit message', 'POST_FORWARD_PM' => 'Forward message', From d5ea4906ca3a85a278518cc91189176174422bde Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 24 Apr 2014 22:57:35 +0200 Subject: [PATCH 190/424] [ticket/12012] Move property to the top PHPBB3-12012 --- phpBB/phpbb/db/tools.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 9cd3e64d20..2b0132075b 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -33,6 +33,12 @@ class tools */ var $dbms_type_map = array(); + /** + * Is the used MS SQL Server a SQL Server 2000? + * @var bool + */ + protected $is_sql_server_2000; + /** * Get the column types for every database we support * @@ -2677,8 +2683,6 @@ class tools return $existing_indexes; } - protected $is_sql_server_2000; - /** * Is the used MS SQL Server a SQL Server 2000? * From 142fe1a0e57797aa77059edda42ebedd91b11397 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 11:45:54 +0200 Subject: [PATCH 191/424] [ticket/12273] Use multiline arrays instead of array_merge() PHPBB3-12273 --- phpBB/phpbb/event/php_exporter.php | 88 ++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 28 deletions(-) diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php index 8de3051d9b..2a69f15802 100644 --- a/phpBB/phpbb/event/php_exporter.php +++ b/phpBB/phpbb/event/php_exporter.php @@ -295,43 +295,21 @@ class php_exporter */ public function get_vars_from_array() { - $vars_array_line = 1; - $found_vars_array = false; - $vars_array = array(); - while (ltrim($this->file_lines[$this->current_event_line - $vars_array_line], "\t") !== '*/') + $line = ltrim($this->file_lines[$this->current_event_line - 1], "\t"); + if ($line === ');') { - $line = ltrim($this->file_lines[$this->current_event_line - $vars_array_line], "\t"); - $match = array(); - preg_match('#^\$vars = (array_merge\(\$vars, )?array\(\'([a-zA-Z0-9_\' ,]+)\'\)(?(1)\));$#', $line, $match); - - if (isset($match[2])) - { - $found_vars_array = true; - if (strlen($match[2]) > 90) - { - throw new \LogicException('Should use multiple lines for $vars definition ' - . "for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 3); - } - $vars_array = array_merge($vars_array, explode("', '", $match[2])); - } - - $vars_array_line++; - if ($this->current_event_line - $vars_array_line === 0) - { - throw new \LogicException("Can not find '\$vars = array();'-line for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 2); - } + $vars_array = $this->get_vars_from_multi_line_array(); } - - if (!$found_vars_array) + else { - throw new \LogicException("Can not find '\$vars = array();'-line for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 3); + $vars_array = $this->get_vars_from_single_line_array($line); } foreach ($vars_array as $var) { if (!preg_match('#^([a-zA-Z_][a-zA-Z0-9_]*)$#', $var)) { - throw new \LogicException("Found invalid var '{$var}' in array for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 4); + throw new \LogicException("Found invalid var '{$var}' in array for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 3); } } @@ -339,6 +317,60 @@ class php_exporter return $vars_array; } + /** + * Find the variables in single line array + * + * @param string $line + * @return array List of variables + * @throws \LogicException + */ + public function get_vars_from_single_line_array($line, $throw_multiline = true) + { + $match = array(); + preg_match('#^\$vars = array\(\'([a-zA-Z0-9_\' ,]+)\'\);$#', $line, $match); + + if (isset($match[1])) + { + $vars_array = explode("', '", $match[1]); + if ($throw_multiline && sizeof($vars_array) > 6) + { + throw new \LogicException('Should use multiple lines for $vars definition ' + . "for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 2); + } + return $vars_array; + } + else + { + throw new \LogicException("Can not find '\$vars = array();'-line for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 1); + } + } + + /** + * Find the variables in single line array + * + * @param string $line + * @return array List of variables + * @throws \LogicException + */ + public function get_vars_from_multi_line_array() + { + $current_vars_line = 2; + $var_lines = array(); + while (ltrim($this->file_lines[$this->current_event_line - $current_vars_line], "\t") !== '$vars = array(') + { + $var_lines[] = substr(trim($this->file_lines[$this->current_event_line - $current_vars_line]), 0, -1); + + $current_vars_line++; + if ($current_vars_line > $this->current_event_line) + { + // Reached the start of the file + throw new \LogicException("Can not find end of \$vars array for event '{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 2); + } + } + + return $this->get_vars_from_single_line_array('$vars = array(' . implode(", ", $var_lines) . ');', false); + } + /** * Find the $vars array * From 01e2d7c26c9974405c073d43ecd12614aca6faa5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 11:46:24 +0200 Subject: [PATCH 192/424] [ticket/12273] Fix unit tests for multi line arrays PHPBB3-12273 --- tests/event/fixtures/trigger_many_vars.test | 26 ++++++- tests/event/php_exporter_test.php | 80 ++++++++++++++------- 2 files changed, 78 insertions(+), 28 deletions(-) diff --git a/tests/event/fixtures/trigger_many_vars.test b/tests/event/fixtures/trigger_many_vars.test index fadfcffefc..da72f4c57f 100644 --- a/tests/event/fixtures/trigger_many_vars.test +++ b/tests/event/fixtures/trigger_many_vars.test @@ -39,7 +39,27 @@ * post_id, topic_id, forum_id, submit, preview, save, load, * delete, cancel, refresh, error, page_data, message_parser */ - $vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons', 'form_enctype'); - $vars = array_merge($vars, array('s_action', 's_hidden_fields', 'post_id', 'topic_id', 'forum_id', 'submit', 'preview')); - $vars = array_merge($vars, array('save', 'load', 'delete', 'cancel', 'refresh', 'error', 'page_data', 'message_parser')); + $vars = array( + 'post_data', + 'moderators', + 'mode', + 'page_title', + 's_topic_icons', + 'form_enctype', + 's_action', + 's_hidden_fields', + 'post_id', + 'topic_id', + 'forum_id', + 'submit', + 'preview', + 'save', + 'load', + 'delete', + 'cancel', + 'refresh', + 'error', + 'page_data', + 'message_parser', + ); extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 5df7713bdf..03f6974af1 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -343,47 +343,77 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array( '/**', '*/', - '$phpbb_dispatcher->dispatch(\'test\');', + '$phpbb_dispatcher->trigger_event(\'test\', compact($vars));', ), 2, - 3, + 1, ), array( array( '/**', '*/', '$vars = $bertie;', - '$phpbb_dispatcher->dispatch(\'test\');', + '$phpbb_dispatcher->trigger_event(\'test\', compact($vars));', ), 3, - 3, - ), - array( - array( - '/**', - '*/', - '$vars = array();', - '$phpbb_dispatcher->dispatch(\'test\');', - ), - 3, - 3, - ), - array( - array( - '/**', - '*/', - '$vars = array(\'test2\', \'\');', - '$phpbb_dispatcher->dispatch(\'test\');', - ), - 3, - 4, + 1, ), array( array( '/**', '*/', '$vars = array(\'$bertie\');', - '$phpbb_dispatcher->dispatch(\'test\');', + '$phpbb_dispatcher->trigger_event(\'test\', compact($vars));', + ), + 3, + 1, + ), + array( + array( + '/**', + '*/', + '$vars = array();', + '$phpbb_dispatcher->trigger_event(\'test\', compact($vars));', + ), + 3, + 1, + ), + array( + array( + '/**', + '*/', + '$vars = array(\'t1\', \'t2\', \'t3\', \'t4\', \'t5\', \'t6\', \'t7\');', + '$phpbb_dispatcher->trigger_event(\'test\', compact($vars));', + ), + 3, + 2, + ), + array( + array( + '/**', + '*/', + '$vars = array(\'test2\', \'\');', + '$phpbb_dispatcher->trigger_event(\'test\', compact($vars));', + ), + 3, + 3, + ), + array( + array( + '/**', + '*/', + '$vars = array(\'bertie\'\');', + '$phpbb_dispatcher->trigger_event(\'test\', compact($vars));', + ), + 3, + 3, + ), + array( + array( + '/**', + '*/', + '$vars = array(\'bertie\',\'basically_valid\');', + '$phpbb_dispatcher->trigger_event(\'test\', compact($vars));', ), 3, 3, From 87899b0e140400e23341ea1286d50e330132be90 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 11:46:44 +0200 Subject: [PATCH 193/424] [ticket/12273] Update existing events PHPBB3-12273 --- phpBB/includes/acp/acp_bbcodes.php | 13 +++++-- phpBB/includes/acp/acp_forums.php | 12 +++++-- phpBB/includes/functions_admin.php | 33 ++++++++++++++---- phpBB/includes/functions_content.php | 22 ++++++++++-- phpBB/includes/functions_posting.php | 12 +++++-- phpBB/includes/ucp/ucp_pm_viewmessage.php | 11 +++++- phpBB/mcp.php | 11 +++++- phpBB/memberlist.php | 12 +++++-- phpBB/phpbb/log/log.php | 28 +++++++++++++--- phpBB/phpbb/user.php | 11 ++++-- phpBB/posting.php | 31 ++++++++++++++--- phpBB/viewtopic.php | 41 +++++++++++++++++++---- 12 files changed, 200 insertions(+), 37 deletions(-) diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php index a05b1df760..7cc52024cf 100644 --- a/phpBB/includes/acp/acp_bbcodes.php +++ b/phpBB/includes/acp/acp_bbcodes.php @@ -159,9 +159,16 @@ class acp_bbcodes * submitting form when $warn_text is true * @since 3.1.0-a3 */ - $vars = array('action', 'sql_ary', 'bbcode_id', 'display_on_posting'); - $vars = array_merge($vars, array('bbcode_match', 'bbcode_tpl')); - $vars = array_merge($vars, array('bbcode_helpline', 'hidden_fields')); + $vars = array( + 'action', + 'sql_ary', + 'bbcode_id', + 'display_on_posting', + 'bbcode_match', + 'bbcode_tpl', + 'bbcode_helpline', + 'hidden_fields', + ); extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create', compact($vars))); $warn_text = preg_match('%<[^>]*\{text[\d]*\}[^>]*>%i', $bbcode_tpl); diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 0163d12ed0..4d100d32c2 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -707,8 +707,16 @@ class acp_forums * @var array template_data Array with new forum data * @since 3.1-A1 */ - $vars = array('action', 'update', 'forum_id', 'row', 'forum_data'); - $vars = array_merge($vars, array('parents_list', 'errors', 'template_data')); + $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); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 28cb2c2f63..9342582346 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -755,8 +755,15 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = * @var array delete_notifications_types Array with notifications types to delete * @since 3.1.0-a4 */ - $vars = array('where_type', 'where_ids', 'auto_sync', 'posted_sync', 'post_count_sync'); - $vars = array_merge($vars, array('call_delete_topics', 'delete_notifications_types')); + $vars = array( + 'where_type', + 'where_ids', + 'auto_sync', + 'posted_sync', + 'post_count_sync', + 'call_delete_topics', + 'delete_notifications_types', + ); extract($phpbb_dispatcher->trigger_event('core.delete_posts_before', compact($vars))); if ($where_type === 'range') @@ -913,8 +920,15 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = * @var array delete_notifications_types Array with notifications types to delete * @since 3.1.0-a4 */ - $vars = array('post_ids', 'poster_ids', 'topic_ids', 'forum_ids', 'where_type'); - $vars = array_merge($vars, array('where_ids', 'delete_notifications_types')); + $vars = array( + 'post_ids', + 'poster_ids', + 'topic_ids', + 'forum_ids', + 'where_type', + 'where_ids', + 'delete_notifications_types', + ); extract($phpbb_dispatcher->trigger_event('core.delete_posts_in_transaction', compact($vars))); $db->sql_transaction('commit'); @@ -932,8 +946,15 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = * @var array delete_notifications_types Array with notifications types to delete * @since 3.1.0-a4 */ - $vars = array('post_ids', 'poster_ids', 'topic_ids', 'forum_ids', 'where_type'); - $vars = array_merge($vars, array('where_ids', 'delete_notifications_types')); + $vars = array( + 'post_ids', + 'poster_ids', + 'topic_ids', + 'forum_ids', + 'where_type', + 'where_ids', + 'delete_notifications_types', + ); extract($phpbb_dispatcher->trigger_event('core.delete_posts_after', compact($vars))); // Resync topics_posted table diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index bd711541c2..89a0c2823e 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -527,7 +527,15 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb * @var bool allow_smilies Whether or not to parse Smilies * @since 3.1-A1 */ - $vars = array('text', 'uid', 'bitfield', 'flags', 'allow_bbcode', 'allow_urls', 'allow_smilies'); + $vars = array( + 'text', + 'uid', + 'bitfield', + 'flags', + 'allow_bbcode', + 'allow_urls', + 'allow_smilies', + ); extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_before', compact($vars))); $uid = $bitfield = ''; @@ -1410,8 +1418,16 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', * @var array _profile_cache Array of original return templates * @since 3.1-A1 */ - $vars = array('mode', 'user_id', 'username', 'username_colour', 'guest_username'); - $vars = array_merge($vars, array('custom_profile_url', 'username_string', '_profile_cache')); + $vars = array( + 'mode', + 'user_id', + 'username', + 'username_colour', + 'guest_username', + 'custom_profile_url', + 'username_string', + '_profile_cache', + ); extract($phpbb_dispatcher->trigger_event('core.modify_username_string', compact($vars))); return $username_string; diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index b3d8ccdb39..7dbcae7f6e 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1497,8 +1497,16 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @var bool update_search_index Flag indicating if the search index will be updated * @since 3.1.0-a4 */ - $vars = array('mode', 'subject', 'username', 'topic_type', 'poll', 'data'); - $vars = array_merge($vars, array('update_message', 'update_search_index')); + $vars = array( + 'mode', + 'subject', + 'username', + 'topic_type', + 'poll', + 'data', + 'update_message', + 'update_search_index', + ); extract($phpbb_dispatcher->trigger_event('core.modify_submit_post_data', compact($vars))); // We do not handle erasing posts here diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 03064a31d3..44a6982a8e 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -250,7 +250,16 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) * @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'); + $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); diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 5676c399af..8e124bf526 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -267,7 +267,16 @@ if (!$user_id && $username == '') * @var int id Parent module id * @since 3.1.0-b2 */ -$vars = array('module', 'mode', 'user_id', 'forum_id', 'topic_id', 'post_id', 'username', 'id'); +$vars = array( + 'module', + 'mode', + 'user_id', + 'forum_id', + 'topic_id', + 'post_id', + 'username', + 'id', +); extract($phpbb_dispatcher->trigger_event('core.modify_mcp_modules_display_option', compact($vars))); // Load and execute the relevant module diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 0a96f6c418..7f78e694b9 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -604,8 +604,16 @@ switch ($mode) * @since 3.1-A1 * @changed 3.1.0-b2 Added friend and foe status */ - $vars = array('member', 'user_notes_enabled', 'warn_user_enabled', 'zebra_enabled'); - $vars = array_merge($vars, array('friends_enabled', 'foes_enabled', 'friend', 'foe')); + $vars = array( + 'member', + 'user_notes_enabled', + 'warn_user_enabled', + 'zebra_enabled', + 'friends_enabled', + 'foes_enabled', + 'friend', + 'foe', + ); extract($phpbb_dispatcher->trigger_event('core.memberlist_view_profile', compact($vars))); $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled)); diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index b0aa637002..ea04344c59 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -307,7 +307,15 @@ class log implements \phpbb\log\log_interface * we won't add the entry to the database. * @since 3.1-A1 */ - $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); + $vars = array( + 'mode', + 'user_id', + 'log_ip', + 'log_operation', + 'log_time', + 'additional_data', + 'sql_ary', + ); extract($this->dispatcher->trigger_event('core.add_log', compact($vars))); // We didn't find a log_type, so we don't save it in the database. @@ -405,9 +413,21 @@ class log implements \phpbb\log\log_interface * e.g.: 'AND l.forum_id = 1' * @since 3.1-A1 */ - $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id'); - $vars = array_merge($vars, array('user_id', 'log_time', 'sort_by', 'keywords')); - $vars = array_merge($vars, array('profile_url', 'log_type', 'sql_additional')); + $vars = array( + 'mode', + 'count_logs', + 'limit', + 'offset', + 'forum_id', + 'topic_id', + 'user_id', + 'log_time', + 'sort_by', + 'keywords', + 'profile_url', + 'log_type', + 'sql_additional', + ); extract($this->dispatcher->trigger_event('core.get_logs_modify_type', compact($vars))); if ($log_type === false) diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 1f65b63522..417cc71fd3 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -145,8 +145,15 @@ class user extends \phpbb\session * @var mixed style_id Style we are going to display * @since 3.1-A1 */ - $vars = array('user_data', 'user_lang_name', 'user_date_format', 'lang_set'); - $vars = array_merge($vars, array('user_timezone', 'lang_set_ext', 'style_id')); + $vars = array( + 'user_data', + 'user_lang_name', + 'user_date_format', + 'user_timezone', + 'lang_set', + 'lang_set_ext', + 'style_id', + ); extract($phpbb_dispatcher->trigger_event('core.user_setup', compact($vars))); $this->data = $user_data; diff --git a/phpBB/posting.php b/phpBB/posting.php index 3d48a67e60..11f0898440 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -82,9 +82,22 @@ $current_time = time(); * language keys. * @since 3.1-A1 */ -$vars = array('post_id', 'topic_id', 'forum_id', 'draft_id', 'lastclick'); -$vars = array_merge($vars, array('submit', 'preview', 'save', 'load', 'delete')); -$vars = array_merge($vars, array('cancel', 'refresh', 'mode', 'error')); +$vars = array( + 'post_id', + 'topic_id', + 'forum_id', + 'draft_id', + 'lastclick', + 'submit', + 'preview', + 'save', + 'load', + 'delete', + 'cancel', + 'refresh', + 'mode', + 'error', +); extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars))); // Was cancel pressed? If so then redirect to the appropriate page @@ -1563,8 +1576,16 @@ $template->assign_vars(array( * @since 3.1-A1 * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, s_topic_icons, form_enctype, s_action, s_hidden_fields */ -$vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons'); -$vars = array_merge($vars, array('form_enctype', 's_action', 's_hidden_fields')); +$vars = array( + 'post_data', + 'moderators', + 'mode', + 'page_title', + 's_topic_icons', + 'form_enctype', + 's_action', + 's_hidden_fields', +); extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); // Build custom bbcodes array diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 5be578423f..0dbda7564f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1000,8 +1000,17 @@ $sql_ary = array( * @since 3.1-A1 * @change 3.1.0-a2 Added vars forum_id, topic_id, topic_data, post_list, sort_days, sort_key, sort_dir, start */ -$vars = array('forum_id', 'topic_id', 'topic_data', 'post_list', 'sort_days'); -$vars = array_merge($vars, array('sort_key', 'sort_dir', 'start', 'sql_ary')); +$vars = array( + 'forum_id', + 'topic_id', + 'topic_data', + 'post_list', + 'sort_days', + 'sort_key', + 'sort_dir', + 'start', + 'sql_ary', +); extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_post_data', compact($vars))); $sql = $db->sql_build_query('SELECT', $sql_ary); @@ -1680,8 +1689,18 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) * @change 3.1.0-a3 Added vars start, current_row_number, end, attachments * @change 3.1.0-b3 Added topic_data array, total_posts */ - $vars = array('start', 'current_row_number', 'end', 'total_posts', 'row', 'cp_row'); - $vars = array_merge($vars, array('attachments', 'user_poster_data', 'post_row', 'topic_data')); + $vars = array( + 'start', + 'current_row_number', + 'end', + 'total_posts', + 'row', + 'cp_row', + 'attachments', + 'user_poster_data', + 'post_row', + 'topic_data', + ); extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars))); $i = $current_row_number; @@ -1738,8 +1757,18 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) * @since 3.1.0-a3 * @change 3.1.0-b3 Added topic_data array, total_posts */ - $vars = array('start', 'current_row_number', 'end', 'total_posts', 'row', 'cp_row'); - $vars = array_merge($vars, array('attachments', 'user_poster_data', 'post_row', 'topic_data')); + $vars = array( + 'start', + 'current_row_number', + 'end', + 'total_posts', + 'row', + 'cp_row', + 'attachments', + 'user_poster_data', + 'post_row', + 'topic_data', + ); extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_row_after', compact($vars))); $i = $current_row_number; From ed40846590ea3b80af35aa845dba7e05da88c223 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 12:16:45 +0200 Subject: [PATCH 194/424] [ticket/12371] Do not group "quote" notifications Grouping these notification makes no sense, as the user will not find the posts he is quoted in, when they are spread over multiple pages PHPBB3-12371 --- phpBB/phpbb/notification/type/quote.php | 31 +++++++------------------ 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php index 745430e114..f4b4d763eb 100644 --- a/phpBB/phpbb/notification/type/quote.php +++ b/phpBB/phpbb/notification/type/quote.php @@ -113,29 +113,6 @@ class quote extends \phpbb\notification\type\post $notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options); - // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications - $update_notifications = array(); - $sql = 'SELECT n.* - FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt - WHERE n.notification_type_id = ' . (int) $this->notification_type_id . ' - AND n.item_parent_id = ' . (int) self::get_item_parent_id($post) . ' - AND n.notification_read = 0 - AND nt.notification_type_id = n.notification_type_id - AND nt.notification_type_enabled = 1'; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - // Do not create a new notification - unset($notify_users[$row['user_id']]); - - $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row); - $sql = 'UPDATE ' . $this->notifications_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . ' - WHERE notification_id = ' . $row['notification_id']; - $this->db->sql_query($sql); - } - $this->db->sql_freeresult($result); - return $notify_users; } @@ -190,6 +167,14 @@ class quote extends \phpbb\notification\type\post return true; } + /** + * {inheritDoc} + */ + public function get_redirect_url() + { + return $this->get_url(); + } + /** * Get email template * From e0fadfb4d675df71b359b5d64b614051dda4017e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 12:19:04 +0200 Subject: [PATCH 195/424] [ticket/12371] Allow notification types to redirect to a different url This way we can redirect the post and bookmark notification to the first unread post in the topic PHPBB3-12371 --- phpBB/index.php | 2 +- phpBB/phpbb/notification/type/base.php | 8 ++++++++ phpBB/phpbb/notification/type/post.php | 8 ++++++++ phpBB/phpbb/notification/type/type_interface.php | 7 +++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/phpBB/index.php b/phpBB/index.php index 32bc118e8c..6927705f91 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -63,7 +63,7 @@ if (($mark_notification = $request->variable('mark_notification', 0))) redirect(append_sid($phpbb_root_path . $redirect)); } - redirect($notification->get_url()); + redirect($notification->get_redirect_url()); } } } diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index 0719540bdb..7d08521d40 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -275,6 +275,14 @@ abstract class base implements \phpbb\notification\type\type_interface return $this->mark(true, $return); } + /** + * {inheritDoc} + */ + public function get_redirect_url() + { + return $this->get_url(); + } + /** * Prepare to output the notification to the template * diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index f973becc3b..7d4bc06879 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -269,6 +269,14 @@ class post extends \phpbb\notification\type\base return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "p={$this->item_id}#p{$this->item_id}"); } + /** + * {inheritDoc} + */ + public function get_redirect_url() + { + return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "t={$this->item_parent_id}&view=unread#unread"); + } + /** * Users needed to query before this notification can be displayed * diff --git a/phpBB/phpbb/notification/type/type_interface.php b/phpBB/phpbb/notification/type/type_interface.php index e3e6898172..2f465aae2b 100644 --- a/phpBB/phpbb/notification/type/type_interface.php +++ b/phpBB/phpbb/notification/type/type_interface.php @@ -98,6 +98,13 @@ interface type_interface */ public function get_url(); + /** + * Get the url to redirect after the item has been marked as read + * + * @return string URL + */ + public function get_redirect_url(); + /** * URL to unsubscribe to this notification * From 92db22c8827abfad8615b0537fdc6fd89ab4203f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 12:28:14 +0200 Subject: [PATCH 196/424] [ticket/12371] Do not delete post related notifications when a post is deleted When a post is marked edited and therefor marked as softdeleted/unapproved, we should not delete the notifications, just like we can't delete the emails. Links are out there anyway and just keeping the notification is fail save. If we keep the notification we can just continue to update it when more posts are added. Also when we delete a post, we don't have to go though the table and find all related notifications to be able to delete them or even update them, when they have responders set. PHPBB3-12371 --- phpBB/includes/functions_admin.php | 2 -- phpBB/includes/functions_posting.php | 25 ++----------------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index d72f89b6ac..01cba10b40 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -736,8 +736,6 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = // Notifications types to delete $delete_notifications_types = array( 'quote', - 'bookmark', - 'post', 'approve_post', 'post_in_queue', ); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 51bbcb8bae..ebd2d77887 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2272,16 +2272,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'edit_first_post': case 'edit': case 'edit_last_post': - if ($data['topic_visibility'] != ITEM_APPROVED) - { - $phpbb_notifications->delete_notifications('topic', $data['topic_id']); - } - - $phpbb_notifications->delete_notifications(array( - 'quote', - 'bookmark', - 'post', - ), $data['post_id']); + // Nothing to do here break; } } @@ -2292,23 +2283,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'post': case 'reply': case 'quote': - // Nothing to do here - break; - case 'edit_topic': case 'edit_first_post': case 'edit': case 'edit_last_post': - if ($data['topic_visibility'] != ITEM_APPROVED) - { - $phpbb_notifications->delete_notifications('topic', $data['topic_id']); - } - - $phpbb_notifications->delete_notifications(array( - 'quote', - 'bookmark', - 'post', - ), $data['post_id']); + // Nothing to do here break; } } From 418747ed341f0c4d2f1d1c1b5ea177fadde9ce7e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 12:44:31 +0200 Subject: [PATCH 197/424] [ticket/12371] Do not update the notification entry unneccessarily When the data did not change, we also don't have to run the query at all. PHPBB3-12371 --- phpBB/phpbb/notification/type/bookmark.php | 12 ++++++++---- phpBB/phpbb/notification/type/post.php | 19 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/phpBB/phpbb/notification/type/bookmark.php b/phpBB/phpbb/notification/type/bookmark.php index 003998677d..c981695f74 100644 --- a/phpBB/phpbb/notification/type/bookmark.php +++ b/phpBB/phpbb/notification/type/bookmark.php @@ -110,10 +110,14 @@ class bookmark extends \phpbb\notification\type\post unset($notify_users[$row['user_id']]); $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row); - $sql = 'UPDATE ' . $this->notifications_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . ' - WHERE notification_id = ' . $row['notification_id']; - $this->db->sql_query($sql); + $update_responders = $notification->add_responders($post); + if (!empty($update_responders)) + { + $sql = 'UPDATE ' . $this->notifications_table . ' + SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . ' + WHERE notification_id = ' . $row['notification_id']; + $this->db->sql_query($sql); + } } $this->db->sql_freeresult($result); diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 7d4bc06879..987651887f 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -152,10 +152,14 @@ class post extends \phpbb\notification\type\base unset($notify_users[$row['user_id']]); $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row); - $sql = 'UPDATE ' . $this->notifications_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . ' - WHERE notification_id = ' . $row['notification_id']; - $this->db->sql_query($sql); + $update_responders = $notification->add_responders($post); + if (!empty($update_responders)) + { + $sql = 'UPDATE ' . $this->notifications_table . ' + SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . ' + WHERE notification_id = ' . $row['notification_id']; + $this->db->sql_query($sql); + } } $this->db->sql_freeresult($result); @@ -392,7 +396,7 @@ class post extends \phpbb\notification\type\base // Do not add them as a responder if they were the original poster that created the notification if ($this->get_data('poster_id') == $post['poster_id']) { - return array('notification_data' => serialize($this->get_data(false))); + return array(); } $responders = $this->get_data('responders'); @@ -404,7 +408,7 @@ class post extends \phpbb\notification\type\base // Do not add them as a responder multiple times if ($responder['poster_id'] == $post['poster_id']) { - return array('notification_data' => serialize($this->get_data(false))); + return array(); } } @@ -415,6 +419,7 @@ class post extends \phpbb\notification\type\base $this->set_data('responders', $responders); - return array('notification_data' => serialize($this->get_data(false))); + $serialized_data = serialize($this->get_data(false)); + return array('notification_data' => $serialized_data); } } From 37751b51f95a3f05ea9a40f74978989edd2af69e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 12:50:29 +0200 Subject: [PATCH 198/424] [ticket/12371] Do not add unlimited users as responders We run into the risc that the data is longer then the character limit of the table column. However as we trim the users list anyway, we can also just stop adding them and display "many others" instead of "x others" PHPBB3-12371 --- phpBB/language/en/common.php | 7 +++++-- phpBB/phpbb/notification/type/post.php | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 677b228cc6..956b593476 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -422,14 +422,16 @@ $lang = array_merge($lang, array( 'NOT_WATCHING_FORUM' => 'You are no longer subscribed to updates on this forum.', 'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.', 'NOTIFICATIONS' => 'Notifications', - // This applies for NOTIFICATION_BOOKMARK, NOTIFICATION_POST, and NOTIFICATION_QUOTE. + // This applies for NOTIFICATION_BOOKMARK and NOTIFICATION_POST. // %1$s will return a list of users that's concatenated using "," and "and" - see STRING_LIST // Once the user count reaches 5 users or more, the list is trimmed using NOTIFICATION_X_OTHERS + // Once the user count reaches 20 users or more, the list is trimmed using NOTIFICATION_MANY_OTHERS // Examples: // A replied... // A and B replied... // A, B and C replied... // A, B, C and 2 others replied... + // A, B, C and many others replied... 'NOTIFICATION_BOOKMARK' => array( 1 => '%1$s replied to the topic “%2$s” you have bookmarked.', ), @@ -454,7 +456,8 @@ $lang = array_merge($lang, array( 'NOTIFICATION_TOPIC_IN_QUEUE' => 'A new topic titled "%2$s" was posted by %1$s and needs approval.', 'NOTIFICATION_TYPE_NOT_EXIST' => 'The notification type "%s" is missing from the file system.', 'NOTIFICATION_ADMIN_ACTIVATE_USER' => 'The user “%1$s” is newly registered and requires activation.', - // Used in conjuction with NOTIFICATION_BOOKMARK, NOTIFICATION_POST, and NOTIFICATION_QUOTE. + // Used in conjuction with NOTIFICATION_BOOKMARK and NOTIFICATION_POST. + 'NOTIFICATION_MANY_OTHERS' => 'many others', 'NOTIFICATION_X_OTHERS' => array( 2 => '%d others', ), diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 987651887f..826be0c992 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -210,7 +210,11 @@ class post extends \phpbb\notification\type\base } } - if ($trimmed_responders_cnt) + if ($trimmed_responders_cnt > 20) + { + $usernames[] = $this->user->lang('NOTIFICATION_MANY_OTHERS'); + } + else if ($trimmed_responders_cnt) { $usernames[] = $this->user->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt); } @@ -403,6 +407,14 @@ class post extends \phpbb\notification\type\base $responders = ($responders === null) ? array() : $responders; + // Do not add more then 25 responder, + // we trim the username list to "a, b, c and x others" anyway + // so there is no use to add all of them anyway. + if (sizeof($responders) > 25) + { + return array(); + } + foreach ($responders as $responder) { // Do not add them as a responder multiple times @@ -420,6 +432,15 @@ class post extends \phpbb\notification\type\base $this->set_data('responders', $responders); $serialized_data = serialize($this->get_data(false)); + + // If the data is longer then 4000 characters, it would cause a SQL error + // so we just don't add the username to the list, when this would be the + // case. + if (utf8_strlen($serialized_data) >= 4000) + { + return array(); + } + return array('notification_data' => $serialized_data); } } From dac01e8ca534b4d145d99e49a6aee173b85925f5 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Thu, 19 Dec 2013 14:01:07 -0800 Subject: [PATCH 199/424] [ticket/12052] Add support for ITEM_UNAPPROVED to set_post_visibility method PHPBB3-12052 --- phpBB/phpbb/content_visibility.php | 63 +++++++++++------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index f3db37e478..165a2c3a56 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -215,7 +215,7 @@ class content_visibility /** * Change visibility status of one post or all posts of a topic * - * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED} + * @param $visibility int Element of {ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED} * @param $post_id mixed Post ID or array of post IDs to act on, * if it is empty, all posts of topic_id will be modified * @param $topic_id int Topic where $post_id is found @@ -231,7 +231,7 @@ class content_visibility */ public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false) { - if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED))) + if (!in_array($visibility, array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED))) { return array(); } @@ -326,7 +326,7 @@ class content_visibility // Update users postcounts foreach ($postcounts as $num_posts => $poster_ids) { - if ($visibility == ITEM_DELETED) + if (in_array($visibility, array(ITEM_UNAPPROVED, ITEM_DELETED))) { $sql = 'UPDATE ' . $this->users_table . ' SET user_posts = 0 @@ -387,54 +387,35 @@ class content_visibility // Update the topic's reply count and the forum's post count if ($update_topic_postcount) { - $cur_posts = $cur_unapproved_posts = $cur_softdeleted_posts = 0; + $field_alias = array( + ITEM_APPROVED => 'posts_approved', + ITEM_UNAPPROVED => 'posts_unapproved', + ITEM_DELETED => 'posts_softdeleted', + ); + $cur_posts = array_fill_keys($field_alias, 0); + foreach ($postcount_visibility as $post_visibility => $visibility_posts) { - // We need to substract the posts from the counters ... - if ($post_visibility == ITEM_APPROVED) - { - $cur_posts += $visibility_posts; - } - else if ($post_visibility == ITEM_UNAPPROVED) - { - $cur_unapproved_posts += $visibility_posts; - } - else if ($post_visibility == ITEM_DELETED) - { - $cur_softdeleted_posts += $visibility_posts; - } + $cur_posts[$field_alias[(int) $post_visibility]] += $visibility_posts; } $sql_ary = array(); - if ($visibility == ITEM_DELETED) + $recipient_field = $field_alias[$visibility]; + + foreach ($cur_posts as $field => $count) { - if ($cur_posts) + // Decrease the count for the old statuses. + if ($count && $field != $recipient_field) { - $sql_ary['posts_approved'] = ' - ' . $cur_posts; - } - if ($cur_unapproved_posts) - { - $sql_ary['posts_unapproved'] = ' - ' . $cur_unapproved_posts; - } - if ($cur_posts + $cur_unapproved_posts) - { - $sql_ary['posts_softdeleted'] = ' + ' . ($cur_posts + $cur_unapproved_posts); + $sql_ary[$field] = " - $count"; } } - else + // Add up the count from all statuses excluding the recipient status. + $count_increase = array_sum(array_diff($cur_posts, array($recipient_field))); + + if ($count_increase) { - if ($cur_unapproved_posts) - { - $sql_ary['posts_unapproved'] = ' - ' . $cur_unapproved_posts; - } - if ($cur_softdeleted_posts) - { - $sql_ary['posts_softdeleted'] = ' - ' . $cur_softdeleted_posts; - } - if ($cur_softdeleted_posts + $cur_unapproved_posts) - { - $sql_ary['posts_approved'] = ' + ' . ($cur_softdeleted_posts + $cur_unapproved_posts); - } + $sql_ary[$recipient_field] = " + $count_increase"; } if (sizeof($sql_ary)) From 2ec9c08a2bce2cb83c68339d2d07039cabc44d68 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 14:10:58 +0200 Subject: [PATCH 200/424] [ticket/12052] Use different visibility when post was edited ... and needs to be reapproved. PHPBB3-12052 --- phpBB/includes/acp/acp_prune.php | 2 +- phpBB/includes/acp/acp_users.php | 3 ++- phpBB/includes/constants.php | 1 + phpBB/includes/functions_admin.php | 8 +++--- phpBB/includes/functions_posting.php | 39 +++++++++++++++++++++++++--- phpBB/includes/mcp/mcp_forum.php | 2 +- phpBB/includes/mcp/mcp_front.php | 4 +-- phpBB/includes/mcp/mcp_main.php | 4 ++- phpBB/includes/mcp/mcp_post.php | 2 +- phpBB/includes/mcp/mcp_queue.php | 12 ++++----- phpBB/includes/mcp/mcp_reports.php | 2 +- phpBB/includes/mcp/mcp_topic.php | 6 ++--- phpBB/mcp.php | 7 ++--- phpBB/memberlist.php | 2 +- phpBB/phpbb/content_visibility.php | 17 ++++++------ phpBB/search.php | 2 +- phpBB/viewforum.php | 2 +- phpBB/viewtopic.php | 6 ++--- 18 files changed, 79 insertions(+), 42 deletions(-) diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index d0e5dfb5f4..542f2502dd 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -533,7 +533,7 @@ class acp_prune WHERE u.user_id <> ' . ANONYMOUS . ' AND u.user_type <> ' . USER_FOUNDER . ((!empty($user_ids)) ? 'AND ' . $db->sql_in_set('p.poster_id', $user_ids) : '') . ' - AND p.post_visibility = ' . ITEM_UNAPPROVED . ' + AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . ' AND u.user_id = p.poster_id GROUP BY p.poster_id HAVING queue_posts ' . $key_match[$queue_select] . ' ' . $posts_on_queue; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index a720334ed2..3cd5e990cf 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -657,6 +657,7 @@ class acp_users { if ($topic_id_ary[$row['topic_id']][ITEM_APPROVED] == $row['topic_posts_approved'] && $topic_id_ary[$row['topic_id']][ITEM_UNAPPROVED] == $row['topic_posts_unapproved'] + && $topic_id_ary[$row['topic_id']][ITEM_REAPPROVE] == $row['topic_posts_unapproved'] && $topic_id_ary[$row['topic_id']][ITEM_DELETED] == $row['topic_posts_softdeleted']) { $move_topic_ary[] = $row['topic_id']; @@ -1050,7 +1051,7 @@ class acp_users $sql = 'SELECT COUNT(post_id) as posts_in_queue FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $user_id . ' - AND post_visibility = ' . ITEM_UNAPPROVED; + AND post_visibility = ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); $result = $db->sql_query($sql); $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $db->sql_freeresult($result); diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 11bbcd4154..a59b4a8add 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -91,6 +91,7 @@ define('ITEM_MOVED', 2); define('ITEM_UNAPPROVED', 0); // => has not yet been approved define('ITEM_APPROVED', 1); // => has been approved, and has not been soft deleted define('ITEM_DELETED', 2); // => has been soft deleted +define('ITEM_REAPPROVE', 3); // => has been edited and needs to be re-approved // Forum Flags define('FORUM_FLAG_LINK_TRACK', 1); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 01cba10b40..fdf40c8564 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1487,7 +1487,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, ITEM_DELETED => (!empty($topics_softdeleted)) ? ' WHERE ' . $db->sql_in_set('topic_id', $topics_softdeleted) : '', ); - foreach ($topic_visiblities as $visibility => $sql_where) + foreach ($update_ary as $visibility => $sql_where) { if ($sql_where) { @@ -1776,7 +1776,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, { $forum_data[$forum_id]['topics_approved'] = $row['total_topics']; } - else if ($row['topic_visibility'] == ITEM_UNAPPROVED) + else if ($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) { $forum_data[$forum_id]['topics_unapproved'] = $row['total_topics']; } @@ -1999,7 +1999,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, { $topic_data[$topic_id]['posts_approved'] = $row['total_posts']; } - else if ($row['post_visibility'] == ITEM_UNAPPROVED) + else if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) { $topic_data[$topic_id]['posts_unapproved'] = $row['total_posts']; } @@ -2021,7 +2021,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_data[$topic_id]['first_post_id'] = (!empty($topic_data[$topic_id]['first_post_id'])) ? min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']) : $row['first_post_id']; $topic_data[$topic_id]['last_post_id'] = max($topic_data[$topic_id]['last_post_id'], $row['last_post_id']); - if ($topic_data[$topic_id]['visibility'] == ITEM_UNAPPROVED) + if ($topic_data[$topic_id]['visibility'] == ITEM_UNAPPROVED || $topic_data[$topic_id]['visibility'] == ITEM_REAPPROVE) { // Soft delete status is stronger than unapproved. $topic_data[$topic_id]['visibility'] = $row['post_visibility']; diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index ebd2d77887..887c73f7de 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1296,7 +1296,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ { $sql_data[FORUMS_TABLE] .= 'forum_posts_approved = forum_posts_approved - 1, forum_topics_approved = forum_topics_approved - 1'; } - else if ($data['topic_visibility'] == ITEM_UNAPPROVED) + else if ($data['topic_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE) { $sql_data[FORUMS_TABLE] .= 'forum_posts_unapproved = forum_posts_unapproved - 1, forum_topics_unapproved = forum_topics_unapproved - 1'; } @@ -1403,7 +1403,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ { $phpbb_content_visibility->remove_post_from_statistic($data, $sql_data); } - else if ($data['post_visibility'] == ITEM_UNAPPROVED) + else if ($data['post_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE) { $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_unapproved = forum_posts_unapproved - 1'; $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_unapproved = topic_posts_unapproved - 1'; @@ -1555,16 +1555,25 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u { // Post not approved, but in queue $post_visibility = ITEM_UNAPPROVED; + switch ($post_mode) + { + case 'edit_first_post': + case 'edit': + case 'edit_last_post': + case 'edit_topic': + $post_visibility = ITEM_REAPPROVE; + break; + } } // MODs/Extensions are able to force any visibility on posts if (isset($data['force_approved_state'])) { - $post_visibility = (in_array((int) $data['force_approved_state'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED))) ? (int) $data['force_approved_state'] : $post_visibility; + $post_visibility = (in_array((int) $data['force_approved_state'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data['force_approved_state'] : $post_visibility; } if (isset($data['force_visibility'])) { - $post_visibility = (in_array((int) $data['force_visibility'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED))) ? (int) $data['force_visibility'] : $post_visibility; + $post_visibility = (in_array((int) $data['force_visibility'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data['force_visibility'] : $post_visibility; } // Start the transaction here @@ -2032,6 +2041,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $first_post_has_topic_info = ($post_mode == 'edit_first_post' && (($post_visibility == ITEM_DELETED && $data['topic_posts_softdeleted'] == 1) || ($post_visibility == ITEM_UNAPPROVED && $data['topic_posts_unapproved'] == 1) || + ($post_visibility == ITEM_REAPPROVE && $data['topic_posts_unapproved'] == 1) || ($post_visibility == ITEM_APPROVED && $data['topic_posts_approved'] == 1))); // Fix the post's and topic's visibility and first/last post information, when the post is edited if (($post_mode != 'post' && $post_mode != 'reply') && $data['post_visibility'] != $post_visibility) @@ -2276,6 +2286,27 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u break; } } + else if ($post_visibility == ITEM_REAPPROVE) + { + switch ($mode) + { + case 'edit_topic': + case 'edit_first_post': + $phpbb_notifications->add_notifications('topic_in_queue', $notification_data); + break; + + case 'edit': + case 'edit_last_post': + $phpbb_notifications->add_notifications('post_in_queue', $notification_data); + break; + + case 'post': + case 'reply': + case 'quote': + // Nothing to do here + break; + } + } else if ($post_visibility == ITEM_DELETED) { switch ($mode) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 7c1c61dae7..60b508990d 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -224,7 +224,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $topic_title = censor_text($row['topic_title']); - $topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; + $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : ''; diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 44cab5d910..aee43c471d 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -39,7 +39,7 @@ function mcp_front_view($id, $mode, $action) $sql = 'SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' - AND post_visibility = ' . ITEM_UNAPPROVED; + AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); @@ -60,7 +60,7 @@ function mcp_front_view($id, $mode, $action) $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' - AND post_visibility = ' . ITEM_UNAPPROVED . ' + AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . ' ORDER BY post_time DESC'; $result = $db->sql_query_limit($sql, 5); diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 55440bf192..6b2e9266b3 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -493,7 +493,7 @@ function mcp_move_topic($topic_ids) { $topics_moved++; } - elseif ($topic_info['topic_visibility'] == ITEM_UNAPPROVED) + elseif ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE) { $topics_moved_unapproved++; } @@ -1230,6 +1230,7 @@ function mcp_fork_topic($topic_ids) $total_topics++; break; case ITEM_UNAPPROVED: + case ITEM_REAPPROVE: $total_topics_unapproved++; break; case ITEM_DELETED: @@ -1316,6 +1317,7 @@ function mcp_fork_topic($topic_ids) $total_posts++; break; case ITEM_UNAPPROVED: + case ITEM_REAPPROVE: $total_posts_unapproved++; break; case ITEM_DELETED: diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index e2d6cd15c9..5925575577 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -203,7 +203,7 @@ function mcp_post_details($id, $mode, $action) 'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']), 'S_POST_REPORTED' => ($post_info['post_reported']) ? true : false, - 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED) ? true : false, + 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE) ? true : false, 'S_POST_DELETED' => ($post_info['post_visibility'] == ITEM_DELETED) ? true : false, 'S_POST_LOCKED' => ($post_info['post_edit_locked']) ? true : false, 'S_USER_NOTES' => true, diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 8d998919e5..3b1081c5c7 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -115,10 +115,10 @@ class mcp_queue if (!empty($topic_id_list)) { - $post_visibility = ($mode == 'deleted_topics') ? ITEM_DELETED : ITEM_UNAPPROVED; + $post_visibility = ($mode == 'deleted_topics') ? ITEM_DELETED : array(ITEM_UNAPPROVED, ITEM_REAPPROVE); $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' - WHERE post_visibility = ' . $post_visibility . ' + WHERE ' . $db->sql_in_set('post_visibility', $post_visibility) . ' AND ' . $db->sql_in_set('topic_id', $topic_id_list); $result = $db->sql_query($sql); @@ -281,7 +281,7 @@ class mcp_queue 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f=$forum_id"), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], - 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED), + 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, 'S_POST_DELETED' => ($post_info['post_visibility'] == ITEM_DELETED), @@ -331,7 +331,7 @@ class mcp_queue $m_perm = 'm_approve'; $is_topics = ($mode == 'unapproved_topics' || $mode == 'deleted_topics') ? true : false; $is_restore = ($mode == 'deleted_posts' || $mode == 'deleted_topics') ? true : false; - $visibility_const = (!$is_restore) ? ITEM_UNAPPROVED : ITEM_DELETED; + $visibility_const = (!$is_restore) ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED; $user->add_lang(array('viewtopic', 'viewforum')); @@ -419,7 +419,7 @@ class mcp_queue $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' - AND p.post_visibility = ' . $visibility_const . ' + AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) . ' ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id @@ -472,7 +472,7 @@ class mcp_queue $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_attachment AS post_attachment, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' - AND topic_visibility = ' . $visibility_const . " + AND ' . $db->sql_in_set('topic_visibility', $visibility_const) . " AND topic_delete_user <> 0 $limit_time_sql ORDER BY $sort_order_sql"; diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 8026e071cd..d4c0c368cb 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -187,7 +187,7 @@ class mcp_reports 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], - 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED), + 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_REPORT_CLOSED' => $report['report_closed'], 'S_USER_NOTES' => true, diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index cdb88bf2bf..48efa330d4 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -212,7 +212,7 @@ function mcp_topic_view($id, $mode, $action) parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); } - if ($row['post_visibility'] == ITEM_UNAPPROVED) + if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) { $has_unapproved_posts = true; } @@ -239,7 +239,7 @@ function mcp_topic_view($id, $mode, $action) 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])), - 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $topic_info['forum_id'])), + 'S_POST_UNAPPROVED' => (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $topic_info['forum_id'])), 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id'])), 'S_CHECKED' => (($submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list)) || in_array(intval($row['post_id']), $checked_ids)) ? true : false, 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, @@ -462,7 +462,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) while ($row = $db->sql_fetchrow($result)) { // If split from selected post (split_beyond), we split the unapproved items too. - if ($row['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $row['forum_id'])) + if (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $row['forum_id'])) { // continue; } diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 1449346deb..d77dfbd227 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -677,7 +677,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, case 'unapproved_posts': case 'deleted_posts': - $visibility_const = ($mode == 'unapproved_posts') ? ITEM_UNAPPROVED : ITEM_DELETED; + $visibility_const = ($mode == 'unapproved_posts') ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED; $type = 'posts'; $default_key = 't'; $default_dir = 'd'; @@ -687,6 +687,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t $where_sql " . $db->sql_in_set('p.forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . ' AND p.post_visibility = ' . $visibility_const . ' + AND ' . $db->sql_in_set('topic_visibility', $visibility_const) .' AND t.topic_id = p.topic_id AND t.topic_visibility <> p.post_visibility'; @@ -698,7 +699,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, case 'unapproved_topics': case 'deleted_topics': - $visibility_const = ($mode == 'unapproved_topics') ? ITEM_UNAPPROVED : ITEM_DELETED; + $visibility_const = ($mode == 'unapproved_topics') ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED; $type = 'topics'; $default_key = 't'; $default_dir = 'd'; @@ -706,7 +707,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, $sql = 'SELECT COUNT(topic_id) AS total FROM ' . TOPICS_TABLE . " $where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . ' - AND topic_visibility = ' . $visibility_const; + AND ' . $db->sql_in_set('topic_visibility', $visibility_const); if ($min_time) { diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 8fceb4ac5b..1e59c2abde 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -624,7 +624,7 @@ switch ($mode) $sql = 'SELECT COUNT(post_id) as posts_in_queue FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $user_id . ' - AND post_visibility = ' . ITEM_UNAPPROVED; + AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); $result = $db->sql_query($sql); $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $db->sql_freeresult($result); diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 165a2c3a56..881a8f2c54 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -215,23 +215,23 @@ class content_visibility /** * Change visibility status of one post or all posts of a topic * - * @param $visibility int Element of {ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED} + * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} * @param $post_id mixed Post ID or array of post IDs to act on, * if it is empty, all posts of topic_id will be modified * @param $topic_id int Topic where $post_id is found * @param $forum_id int Forum where $topic_id is found * @param $user_id int User performing the action * @param $time int Timestamp when the action is performed - * @param $reason string Reason why the visibilty was changed. + * @param $reason string Reason why the visibility was changed. * @param $is_starter bool Is this the first post of the topic changed? * @param $is_latest bool Is this the last post of the topic changed? * @param $limit_visibility mixed Limit updating per topic_id to a certain visibility * @param $limit_delete_time mixed Limit updating per topic_id to a certain deletion time - * @return array Changed post data, empty array if an error occured. + * @return array Changed post data, empty array if an error occurred. */ public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false) { - if (!in_array($visibility, array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED))) + if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE))) { return array(); } @@ -326,7 +326,7 @@ class content_visibility // Update users postcounts foreach ($postcounts as $num_posts => $poster_ids) { - if (in_array($visibility, array(ITEM_UNAPPROVED, ITEM_DELETED))) + if (in_array($visibility, array(ITEM_REAPPROVE, ITEM_DELETED))) { $sql = 'UPDATE ' . $this->users_table . ' SET user_posts = 0 @@ -391,6 +391,7 @@ class content_visibility ITEM_APPROVED => 'posts_approved', ITEM_UNAPPROVED => 'posts_unapproved', ITEM_DELETED => 'posts_softdeleted', + ITEM_REAPPROVE => 'posts_unapproved', ); $cur_posts = array_fill_keys($field_alias, 0); @@ -456,7 +457,7 @@ class content_visibility * as soft deleted. * If you want to update all posts, use the force option. * - * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED} + * @param $visibility int Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} * @param $topic_id mixed Topic ID to act on * @param $forum_id int Forum where $topic_id is found * @param $user_id int User performing the action @@ -467,7 +468,7 @@ class content_visibility */ public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false) { - if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED))) + if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE))) { return array(); } @@ -513,7 +514,7 @@ class content_visibility } else if (!$force_update_all && $original_topic_data['topic_visibility'] == ITEM_APPROVED && $visibility == ITEM_DELETED) { - // If we're soft deleting a topic we only approved posts are soft deleted. + // If we're soft deleting a topic we only mark approved posts as soft deleted. $this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true, $original_topic_data['topic_visibility']); } else diff --git a/phpBB/search.php b/phpBB/search.php index fbb4e93089..778e985bce 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -879,7 +879,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false; - $topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $forum_id)) ? true : false; + $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $forum_id)) ? true : false; $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$result_topic_id", true, $user->session_id) : ''; diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index a7396f9c72..4345f4236e 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -749,7 +749,7 @@ if (sizeof($topic_list)) $view_topic_url_params = 'f=' . $row['forum_id'] . '&t=' . $topic_id; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); - $topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $row['forum_id'])); + $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id'])); $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])); $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 9dc965240f..87ba09f66b 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -266,7 +266,7 @@ if ($topic_data['topic_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_appro if ($post_id) { // are we where we are supposed to be? - if ($topic_data['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $topic_data['forum_id'])) + if (($topic_data['post_visibility'] == ITEM_UNAPPROVED || $topic_data['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $topic_data['forum_id'])) { // If post_id was submitted, we try at least to display the topic as a last resort... if ($topic_id) @@ -1028,7 +1028,7 @@ while ($row = $db->sql_fetchrow($result)) { $attach_list[] = (int) $row['post_id']; - if ($row['post_visibility'] == ITEM_UNAPPROVED) + if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) { $has_attachments = true; } @@ -1642,7 +1642,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]) > 1, - 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED) ? true : false, + 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) ? true : false, 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false, 'L_POST_DELETED_MESSAGE' => $l_deleted_message, 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, From 5512e62c3c436215de6db0b45c693308e1b6dfed Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 14:26:55 +0200 Subject: [PATCH 201/424] [ticket/11772] Do not send out new topic/post notifications when reapproving Only add notifications, if we are not reapproving post When the topic was already approved, but was edited and now needs re-approval, we don't want to notify the users again. PHPBB3-11772 --- phpBB/includes/mcp/mcp_queue.php | 33 +++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 3b1081c5c7..2cbb0b03f6 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -660,11 +660,18 @@ class mcp_queue } $phpbb_notifications->delete_notifications('post_in_queue', $post_id); - $phpbb_notifications->add_notifications(array( - 'quote', - 'bookmark', - 'post', - ), $post_data); + // Only add notifications, if we are not reapproving post + // When the topic was already approved, but was edited and + // now needs re-approval, we don't want to notify the users + // again. + if ($post_data['post_visibility'] == ITEM_UNAPPROVED) + { + $phpbb_notifications->add_notifications(array( + 'quote', + 'bookmark', + 'post', + ), $post_data); + } $phpbb_notifications->mark_notifications_read(array( 'quote', @@ -832,10 +839,18 @@ class mcp_queue )); $phpbb_notifications->delete_notifications('topic_in_queue', $topic_id); - $phpbb_notifications->add_notifications(array( - 'quote', - 'topic', - ), $topic_data); + + // Only add notifications, if we are not reapproving post + // When the topic was already approved, but was edited and + // now needs re-approval, we don't want to notify the users + // again. + if ($topic_data['topic_visibility'] == ITEM_UNAPPROVED) + { + $phpbb_notifications->add_notifications(array( + 'quote', + 'topic', + ), $topic_data); + } $phpbb_notifications->mark_notifications_read('quote', $topic_data['post_id'], $user->data['user_id']); $phpbb_notifications->mark_notifications_read('topic', $topic_id, $user->data['user_id']); From 8375c3f78909f8926ca48bb9649aa3e1f95bd117 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 11 Apr 2014 14:40:03 +0200 Subject: [PATCH 202/424] [ticket/12371] Fix SQL query PHPBB3-12371 --- phpBB/includes/acp/acp_users.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 3cd5e990cf..a139dad052 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1051,7 +1051,7 @@ class acp_users $sql = 'SELECT COUNT(post_id) as posts_in_queue FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $user_id . ' - AND post_visibility = ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); + AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); $result = $db->sql_query($sql); $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $db->sql_freeresult($result); From 84a77d07be48fcb63f22e7dadefbb4ed0e4e0658 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 12 Apr 2014 09:56:57 +0200 Subject: [PATCH 203/424] [ticket/12371] We do not group quote notifications anymore PHPBB3-12371 --- tests/notification/submit_post_type_quote_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/notification/submit_post_type_quote_test.php b/tests/notification/submit_post_type_quote_test.php index a849cb7b1b..9956f3b58e 100644 --- a/tests/notification/submit_post_type_quote_test.php +++ b/tests/notification/submit_post_type_quote_test.php @@ -55,7 +55,7 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ * 2 => Poster, should NOT receive a notification * 3 => Quoted, should receive a notification * 4 => Quoted, but unauthed to read, should NOT receive a notification - * 5 => Quoted, but already notified, should NOT receive a new notification + * 5 => Quoted, but already notified, should STILL receive a new notification * 6 => Quoted, but option disabled, should NOT receive a notification * 7 => Quoted, option set to default, should receive a notification */ @@ -78,6 +78,7 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ array( array('user_id' => 3, 'item_id' => 2, 'item_parent_id' => 1), array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1), + array('user_id' => 5, 'item_id' => 2, 'item_parent_id' => 1), array('user_id' => 7, 'item_id' => 2, 'item_parent_id' => 1), ), ), From 1d61fcf3c9cb9a92a6c9124cc15e4fd6d61fff6e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 20:45:09 +0200 Subject: [PATCH 204/424] [ticket/12371] Rename disapprove and softdelete tests PHPBB3-12371 --- .../{disapprove_test.php => visibility_disapprove_test.php} | 2 +- .../{softdelete_test.php => visibility_softdelete_test.php} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename tests/functional/{disapprove_test.php => visibility_disapprove_test.php} (99%) rename tests/functional/{softdelete_test.php => visibility_softdelete_test.php} (99%) diff --git a/tests/functional/disapprove_test.php b/tests/functional/visibility_disapprove_test.php similarity index 99% rename from tests/functional/disapprove_test.php rename to tests/functional/visibility_disapprove_test.php index ea594b1062..ca6f6f5f37 100644 --- a/tests/functional/disapprove_test.php +++ b/tests/functional/visibility_disapprove_test.php @@ -10,7 +10,7 @@ /** * @group functional */ -class phpbb_functional_disapprove_test extends phpbb_functional_test_case +class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_case { protected $data = array(); diff --git a/tests/functional/softdelete_test.php b/tests/functional/visibility_softdelete_test.php similarity index 99% rename from tests/functional/softdelete_test.php rename to tests/functional/visibility_softdelete_test.php index 1c86d00b9b..f8ada9687c 100644 --- a/tests/functional/softdelete_test.php +++ b/tests/functional/visibility_softdelete_test.php @@ -10,7 +10,7 @@ /** * @group functional */ -class phpbb_functional_softdelete_test extends phpbb_functional_test_case +class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_case { protected $data = array(); From 70f5686efb668f656310c168f1d43be483f1dd60 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 20:45:29 +0200 Subject: [PATCH 205/424] [ticket/12371] Fix query in mcp_sorting() PHPBB3-12371 --- phpBB/mcp.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpBB/mcp.php b/phpBB/mcp.php index d77dfbd227..3c6953b37c 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -686,8 +686,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, $sql = 'SELECT COUNT(p.post_id) AS total FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t $where_sql " . $db->sql_in_set('p.forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . ' - AND p.post_visibility = ' . $visibility_const . ' - AND ' . $db->sql_in_set('topic_visibility', $visibility_const) .' + AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) .' AND t.topic_id = p.topic_id AND t.topic_visibility <> p.post_visibility'; From 793680478bb751a4541aadd6ab4c973f24f5d8f2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 20:46:27 +0200 Subject: [PATCH 206/424] [ticket/12371] Add functional tests for reapproving PHPBB3-12371 --- .../functional/visibility_reapprove_test.php | 406 ++++++++++++++++++ 1 file changed, 406 insertions(+) create mode 100644 tests/functional/visibility_reapprove_test.php diff --git a/tests/functional/visibility_reapprove_test.php b/tests/functional/visibility_reapprove_test.php new file mode 100644 index 0000000000..ae97c7e785 --- /dev/null +++ b/tests/functional/visibility_reapprove_test.php @@ -0,0 +1,406 @@ +login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Reapprove Test #1', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + $crawler = self::submit($form); + + // Set flood interval to 0 + $this->set_flood_interval(0); + } + + public function test_create_posts() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Reapprove Test #1', + ), + )); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'initial comparison'); + + // Test creating topic #1 + $post = $this->create_topic($this->data['forums']['Reapprove Test #1'], 'Reapprove Test Topic #1', 'This is a test topic posted by the testing framework.'); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + + $this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text()); + $this->data['topics']['Reapprove Test Topic #1'] = (int) $post['topic_id']; + $this->data['posts']['Reapprove Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #1'], + ), 'after creating topic #1'); + + $this->logout(); + $this->create_user('reapprove_testuser'); + $this->add_user_group('NEWLY_REGISTERED', array('reapprove_testuser')); + $this->login('reapprove_testuser'); + + // Test creating a reply + $post2 = $this->create_post($this->data['forums']['Reapprove Test #1'], $post['topic_id'], 'Re: Reapprove Test Topic #1-#2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}"); + $this->assertNotContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 1, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #1'], + ), 'after replying'); + + // Test creating topic #2 + $post = $this->create_topic($this->data['forums']['Reapprove Test #1'], 'Reapprove Test Topic #2', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD'); + $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Reapprove Test #1']}&sid={$this->sid}"); + + $this->assertNotContains('Reapprove Test Topic #2', $crawler->filter('html')->text()); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 2, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 1, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #1'], + ), 'after creating topic #2'); + + $this->logout(); + } + + public function test_approve_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Reapprove Test #1', + ), + 'topics' => array( + 'Reapprove Test Topic #1', + 'Reapprove Test Topic #2', + ), + 'posts' => array( + 'Reapprove Test Topic #1', + 'Re: Reapprove Test Topic #1-#2', + 'Reapprove Test Topic #2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 2, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 1, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #1'], + ), 'before approving post'); + + $this->add_lang('posting'); + $this->add_lang('viewtopic'); + $this->add_lang('mcp'); + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}"); + $this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text()); + $this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); + + $form = $crawler->selectButton($this->lang('APPROVE'))->form(); + $crawler = self::submit($form); + $form = $crawler->selectButton($this->lang('YES'))->form(); + $crawler = self::submit($form); + $this->assertContainsLang('POST_APPROVED_SUCCESS', $crawler->text()); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 2, + 'forum_posts_unapproved' => 1, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 1, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Re: Reapprove Test Topic #1-#2'], + ), 'after approving post'); + + $link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link(); + $link_url = $link->getUri(); + $this->assertContains('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'] . '&t=' . $this->data['topics']['Reapprove Test Topic #1'], $link_url); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}"); + $this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text()); + $this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); + } + + public function test_approve_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Reapprove Test #1', + ), + 'topics' => array( + 'Reapprove Test Topic #1', + 'Reapprove Test Topic #2', + ), + 'posts' => array( + 'Reapprove Test Topic #1', + 'Re: Reapprove Test Topic #1-#2', + 'Reapprove Test Topic #2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 2, + 'forum_posts_unapproved' => 1, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 1, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Re: Reapprove Test Topic #1-#2'], + ), 'before approving topic'); + + $this->add_lang('posting'); + $this->add_lang('viewtopic'); + $this->add_lang('mcp'); + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}"); + $this->assertContains('Reapprove Test Topic #2', $crawler->filter('h2')->text()); + + $form = $crawler->selectButton($this->lang('APPROVE'))->form(); + $crawler = self::submit($form); + $form = $crawler->selectButton($this->lang('YES'))->form(); + $crawler = self::submit($form); + //@todo $this->assertContainsLang('TOPIC_APPROVED_SUCCESS', $crawler->text()); + $this->assertContainsLang('POST_APPROVED_SUCCESS', $crawler->text()); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 3, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 2, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #2'], + ), 'after approving topic'); + + $link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link(); + $link_url = $link->getUri(); + $this->assertContains('viewtopic.php?f=' . $this->data['topic']['Reapprove Test Topic #2'], $link_url); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}"); + $this->assertContains('Reapprove Test Topic #2', $crawler->filter('h2')->text()); + } + + public function test_edit_posts() + { + $this->load_ids(array( + 'forums' => array( + 'Reapprove Test #1', + ), + 'topics' => array( + 'Reapprove Test Topic #1', + 'Reapprove Test Topic #2', + ), + 'posts' => array( + 'Reapprove Test Topic #1', + 'Re: Reapprove Test Topic #1-#2', + 'Reapprove Test Topic #2', + ), + )); + $this->add_lang('posting'); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 3, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 2, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #2'], + ), 'before editing post'); + + $this->login('reapprove_testuser'); + $this->add_user_group('NEWLY_REGISTERED', array('reapprove_testuser')); + + // Test editing a post + $posting_url = "posting.php?mode=edit&f={$this->data['forums']['Reapprove Test #1']}&p={$this->data['posts']['Re: Reapprove Test Topic #1-#2']}&sid={$this->sid}"; + $form_data = array( + 'message' => 'Post edited by testing framework', + 'subject' => 'Re: Reapprove Test Topic #1-#2', + 'post' => true, + ); + $this->submit_post($posting_url, 'EDIT_POST', $form_data, 'POST_EDITED_MOD'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}"); + $this->assertNotContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertNotContains('Post edited by testing framework', $crawler->filter('#page-body')->text()); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 2, + 'forum_posts_unapproved' => 1, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 2, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #2'], + ), 'after editing post'); + + // Test editing a topic + $posting_url = "posting.php?mode=edit&f={$this->data['forums']['Reapprove Test #1']}&p={$this->data['posts']['Reapprove Test Topic #2']}&sid={$this->sid}"; + $form_data = array( + 'message' => 'Post edited by testing framework', + 'subject' => 'Reapprove Test Topic #2', + 'post' => true, + ); + $this->submit_post($posting_url, 'EDIT_POST', $form_data, 'POST_EDITED_MOD'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}", array(), false); + self::assert_response_html(404); + $this->assertNotContains('Reapprove Test Topic #2', $crawler->filter('#page-body')->text()); + $this->assertNotContains('Post edited by testing framework', $crawler->filter('#page-body')->text()); + + $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 2, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 1, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Reapprove Test Topic #1'], + ), 'after editing topic'); + + $this->logout(); + $this->login(); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}"); + $this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertContains('Post edited by testing framework', $crawler->filter('#page-body')->text()); + } + + public function test_reset_flood_interval() + { + $this->login(); + $this->admin_login(); + + // Set flood interval back to 15 + $this->set_flood_interval(15); + } + + protected function assert_forum_details($forum_id, $details, $additional_error_message = '') + { + $this->db = $this->get_db(); + + $sql = 'SELECT ' . implode(', ', array_keys($details)) . ' + FROM phpbb_forums + WHERE forum_id = ' . (int) $forum_id; + $result = $this->db->sql_query($sql); + $data = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->assertEquals($details, $data, "Forum {$forum_id} does not match expected {$additional_error_message}"); + } + + protected function set_flood_interval($flood_interval) + { + $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post'); + + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + + $values["config[flood_interval]"] = $flood_interval; + $form->setValues($values); + $crawler = self::submit($form); + $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + } + + protected function load_ids($data) + { + $this->db = $this->get_db(); + + if (!empty($data['forums'])) + { + $sql = 'SELECT * + FROM phpbb_forums + WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['forum_name'], $data['forums'])) + { + $this->data['forums'][$row['forum_name']] = (int) $row['forum_id']; + } + } + $this->db->sql_freeresult($result); + } + + if (!empty($data['topics'])) + { + $sql = 'SELECT * + FROM phpbb_topics + WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['topic_title'], $data['topics'])) + { + $this->data['topics'][$row['topic_title']] = (int) $row['topic_id']; + } + } + $this->db->sql_freeresult($result); + } + + if (!empty($data['posts'])) + { + $sql = 'SELECT * + FROM phpbb_posts + WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['post_subject'], $data['posts'])) + { + $this->data['posts'][$row['post_subject']] = (int) $row['post_id']; + } + } + $this->db->sql_freeresult($result); + } + } +} From ddbb521e57e0a6e3accb8fc3aeebe938aacf9000 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 21:09:07 +0200 Subject: [PATCH 207/424] [ticket/12371] Correctly set is_starter when editing first post of the topic PHPBB3-12371 --- 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 887c73f7de..73e95ae89a 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2049,7 +2049,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // If the post was not approved, it could also be the starter, // so we sync the starter after approving/restoring, to ensure that the stats are correct // Same applies for the last post - $is_starter = ($post_mode == 'edit_first_post' || $data['post_visibility'] != ITEM_APPROVED); + $is_starter = ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED); $is_latest = ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED); $phpbb_content_visibility = $phpbb_container->get('content.visibility'); From 16329c7ad90299a620855252902b3ef4d6959019 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 13 Apr 2014 21:15:08 +0200 Subject: [PATCH 208/424] [ticket/12371] Reapprove the post and topic again in tests PHPBB3-12371 --- tests/functional/visibility_reapprove_test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/functional/visibility_reapprove_test.php b/tests/functional/visibility_reapprove_test.php index ae97c7e785..70134ef724 100644 --- a/tests/functional/visibility_reapprove_test.php +++ b/tests/functional/visibility_reapprove_test.php @@ -315,6 +315,16 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $this->assertContains('Post edited by testing framework', $crawler->filter('#page-body')->text()); } + public function test_approve_post_again() + { + $this->test_approve_post(); + } + + public function test_approve_topic_again() + { + $this->test_approve_topic(); + } + public function test_reset_flood_interval() { $this->login(); From 465aa9c346f3d710d6d7e86de1667719d63364a7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Apr 2014 19:47:37 +0200 Subject: [PATCH 209/424] [ticket/12371] Fix language in comment PHPBB3-12371 --- phpBB/phpbb/notification/type/post.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 826be0c992..bb5f3dfc5e 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -433,9 +433,8 @@ class post extends \phpbb\notification\type\base $serialized_data = serialize($this->get_data(false)); - // If the data is longer then 4000 characters, it would cause a SQL error - // so we just don't add the username to the list, when this would be the - // case. + // If the data is longer then 4000 characters, it would cause a SQL error. + // We don't add the username to the list if this is the case. if (utf8_strlen($serialized_data) >= 4000) { return array(); From 40d91a5d6ee26fceed430856532c6786f5dcf954 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 19 Apr 2014 11:14:01 +0200 Subject: [PATCH 210/424] [ticket/12371] Delete the approve_post notification when editing a post We need to delete the initial approve notification, so we can notify the user again, when his post got reapproved. PHPBB3-12371 --- phpBB/includes/functions_posting.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 73e95ae89a..32eb2505f8 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2293,11 +2293,19 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'edit_topic': case 'edit_first_post': $phpbb_notifications->add_notifications('topic_in_queue', $notification_data); + + // Delete the approve_post notification so we can notify the user again, + // when his post got reapproved + $phpbb_notifications->delete_notifications('approve_post', $notification_data['post_id']); break; case 'edit': case 'edit_last_post': $phpbb_notifications->add_notifications('post_in_queue', $notification_data); + + // Delete the approve_post notification so we can notify the user again, + // when his post got reapproved + $phpbb_notifications->delete_notifications('approve_post', $notification_data['post_id']); break; case 'post': From 7324cb051f4c655bd8027ab8078a1f5d42b60154 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 19 Apr 2014 11:22:46 +0200 Subject: [PATCH 211/424] [ticket/12371] Fix redirect link for approve_post and post_in_queue PHPBB3-12371 --- phpBB/phpbb/notification/type/approve_post.php | 8 ++++++++ phpBB/phpbb/notification/type/post_in_queue.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/phpBB/phpbb/notification/type/approve_post.php b/phpBB/phpbb/notification/type/approve_post.php index e51ff12b3e..5912ad62b4 100644 --- a/phpBB/phpbb/notification/type/approve_post.php +++ b/phpBB/phpbb/notification/type/approve_post.php @@ -138,4 +138,12 @@ class approve_post extends \phpbb\notification\type\post { return 'post_approved'; } + + /** + * {inheritDoc} + */ + public function get_redirect_url() + { + return $this->get_url(); + } } diff --git a/phpBB/phpbb/notification/type/post_in_queue.php b/phpBB/phpbb/notification/type/post_in_queue.php index db16763583..56dfcce588 100644 --- a/phpBB/phpbb/notification/type/post_in_queue.php +++ b/phpBB/phpbb/notification/type/post_in_queue.php @@ -118,6 +118,14 @@ class post_in_queue extends \phpbb\notification\type\post return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "i=queue&mode=approve_details&f={$this->get_data('forum_id')}&p={$this->item_id}"); } + /** + * {inheritDoc} + */ + public function get_redirect_url() + { + return parent::get_url(); + } + /** * Function for preparing the data for insertion in an SQL query * (The service handles insertion) From b32895308d13d5d9b0cd954fd8ce871a1fa073da Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 12:15:44 +0200 Subject: [PATCH 212/424] [ticket/12273] Update since version to 3.1.0-a* style PHPBB3-12273 --- phpBB/common.php | 2 +- phpBB/includes/acp/acp_forums.php | 16 ++++++++-------- phpBB/includes/acp/acp_users.php | 6 +++--- phpBB/includes/functions.php | 8 ++++---- phpBB/includes/functions_acp.php | 8 ++++---- phpBB/includes/functions_content.php | 14 +++++++------- phpBB/includes/functions_display.php | 12 ++++++------ phpBB/includes/functions_posting.php | 2 +- phpBB/includes/functions_user.php | 14 +++++++------- phpBB/includes/mcp/mcp_forum.php | 2 +- phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 +- phpBB/includes/ucp/ucp_prefs.php | 12 ++++++------ phpBB/includes/ucp/ucp_zebra.php | 4 ++-- phpBB/index.php | 2 +- phpBB/memberlist.php | 4 ++-- phpBB/phpbb/log/log.php | 8 ++++---- phpBB/phpbb/permissions.php | 2 +- phpBB/phpbb/user.php | 2 +- phpBB/posting.php | 4 ++-- phpBB/search.php | 4 ++-- phpBB/ucp.php | 2 +- phpBB/viewforum.php | 6 +++--- phpBB/viewonline.php | 4 ++-- phpBB/viewtopic.php | 12 ++++++------ 24 files changed, 76 insertions(+), 76 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index b1da2215fb..12dbe5a62c 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -151,6 +151,6 @@ if (!$config['use_system_cron']) * please use the core.user_setup event instead! * * @event core.common -* @since 3.1-A1 +* @since 3.1.0-a1 */ $phpbb_dispatcher->dispatch('core.common'); diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 4d100d32c2..160bfc05de 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -158,7 +158,7 @@ class acp_forums * @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 + * @since 3.1.0-a1 */ $vars = array('action', 'forum_data'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_request_data', compact($vars))); @@ -484,7 +484,7 @@ class acp_forums * 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 + * @since 3.1.0-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))); @@ -705,7 +705,7 @@ class acp_forums * 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 + * @since 3.1.0-a1 */ $vars = array( 'action', @@ -955,7 +955,7 @@ class acp_forums * @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 + * @since 3.1.0-a1 */ $vars = array('forum_data', 'errors'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars))); @@ -1063,7 +1063,7 @@ class acp_forums * @var array forum_data_sql Array with data we are going to update * If forum_data_sql[forum_id] is set, we update * that forum, otherwise a new one is created. - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('forum_data', 'forum_data_sql'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars))); @@ -1356,7 +1356,7 @@ class acp_forums * 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 + * @since 3.1.0-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))); @@ -1394,7 +1394,7 @@ class acp_forums * @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 + * @since 3.1.0-a1 */ $vars = array('from_id', 'to_id', 'errors'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_children', compact($vars))); @@ -1498,7 +1498,7 @@ class acp_forums * @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 + * @since 3.1.0-a1 */ $vars = array('from_id', 'to_id', 'sync', 'errors'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content', compact($vars))); diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index a720334ed2..f6d46188b8 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -772,7 +772,7 @@ class acp_users * @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 + * @since 3.1.0-a1 */ $vars = array('action', 'user_row'); extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_run_quicktool', compact($vars))); @@ -893,7 +893,7 @@ class acp_users * @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 + * @since 3.1.0-a1 */ $vars = array('user_row', 'data', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_modify_data', compact($vars))); @@ -1008,7 +1008,7 @@ class acp_users * @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 + * @since 3.1.0-a1 */ $vars = array('user_row', 'quick_tool_ary'); extract($phpbb_dispatcher->trigger_event('core.acp_users_display_overview', compact($vars))); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 69f7c3f162..685784190a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2022,7 +2022,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) * the global one (false) * @var bool|string append_sid_overwrite Overwrite function (string * URL) or not (false) - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_overwrite'); extract($phpbb_dispatcher->trigger_event('core.append_sid', compact($vars))); @@ -4735,7 +4735,7 @@ function page_header($page_title = '', $display_online_list = false, $item_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 + * @since 3.1.0-a1 */ $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override'); extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars))); @@ -5100,7 +5100,7 @@ function page_footer($run_cron = true, $display_template = true, $exit_handler = * @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 + * @since 3.1.0-a1 */ $vars = array('run_cron', 'page_footer_override'); extract($phpbb_dispatcher->trigger_event('core.page_footer', compact($vars))); @@ -5208,7 +5208,7 @@ function garbage_collection() * Unload some objects, to free some memory, before we finish our task * * @event core.garbage_collection - * @since 3.1-A1 + * @since 3.1.0-a1 */ $phpbb_dispatcher->dispatch('core.garbage_collection'); } diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index cb44ed2794..2c66f6009c 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -41,7 +41,7 @@ function adm_page_header($page_title) * @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 + * @since 3.1.0-a1 */ $vars = array('page_title', 'adm_page_header_override'); extract($phpbb_dispatcher->trigger_event('core.adm_page_header', compact($vars))); @@ -132,7 +132,7 @@ function adm_page_footer($copyright_html = true) * @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 + * @since 3.1.0-a1 */ $vars = array('copyright_html', 'adm_page_footer_override'); extract($phpbb_dispatcher->trigger_event('core.adm_page_footer', compact($vars))); @@ -396,7 +396,7 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars) * @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 + * @since 3.1.0-a1 */ $vars = array('tpl_type', 'key', 'new', 'name', 'vars', 'tpl'); extract($phpbb_dispatcher->trigger_event('core.build_config_template', compact($vars))); @@ -606,7 +606,7 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) * @var array error Array of errors, the errors should * be strings only, language keys are * not replaced afterwards - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('cfg_array', 'config_name', 'config_definition', 'error'); extract($phpbb_dispatcher->trigger_event('core.validate_config_variable', compact($vars))); diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 89a0c2823e..6ea1b378e8 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -445,7 +445,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text * @var string bitfield The BBCode Bitfield * @var int flags The BBCode Flags * @var bool censor_text Whether or not to apply word censors - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('text', 'uid', 'bitfield', 'flags', 'censor_text'); extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars))); @@ -487,7 +487,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text * @var string uid The BBCode UID * @var string bitfield The BBCode Bitfield * @var int flags The BBCode Flags - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('text', 'uid', 'bitfield', 'flags'); extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_after', compact($vars))); @@ -525,7 +525,7 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb * @var bool allow_bbcode Whether or not to parse BBCode * @var bool allow_urls Whether or not to parse URLs * @var bool allow_smilies Whether or not to parse Smilies - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array( 'text', @@ -573,7 +573,7 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb * @var string uid The BBCode UID * @var string bitfield The BBCode Bitfield * @var int flags The BBCode Flags - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('text', 'uid', 'bitfield', 'flags'); extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_after', compact($vars))); @@ -596,7 +596,7 @@ function generate_text_for_edit($text, $uid, $flags) * @var string text The text to parse * @var string uid The BBCode UID * @var int flags The BBCode Flags - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('text', 'uid', 'flags'); extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_before', compact($vars))); @@ -609,7 +609,7 @@ function generate_text_for_edit($text, $uid, $flags) * @event core.modify_text_for_edit_after * @var string text The text to parse * @var int flags The BBCode Flags - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('text', 'flags'); extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_after', compact($vars))); @@ -1416,7 +1416,7 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', * profile url. * @var string username_string The string that has been generated * @var array _profile_cache Array of original return templates - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array( 'mode', diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 2b11d00f1e..acbcb57c36 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -138,7 +138,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod * * @event core.display_forums_modify_sql * @var array sql_ary The SQL array to get the data of the forums - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('sql_ary'); extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_sql', compact($vars))); @@ -161,7 +161,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod * @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 + * @since 3.1.0-a1 */ $vars = array('branch_root_id', 'row'); extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_row', compact($vars))); @@ -318,7 +318,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod * @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 + * @since 3.1.0-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))); @@ -568,7 +568,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod * @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 + * @since 3.1.0-a1 */ $vars = array('forum_row', 'row'); extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_template_vars', compact($vars))); @@ -975,7 +975,7 @@ function display_custom_bbcodes() * @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 + * @since 3.1.0-a1 */ $vars = array('custom_tags', 'row'); extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_row', compact($vars))); @@ -990,7 +990,7 @@ function display_custom_bbcodes() * Display custom bbcodes * * @event core.display_custom_bbcodes - * @since 3.1-A1 + * @since 3.1.0-a1 */ $phpbb_dispatcher->dispatch('core.display_custom_bbcodes'); } diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 7dbcae7f6e..09b9434a2d 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -133,7 +133,7 @@ function generate_smilies($mode, $forum_id) * @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 + * @since 3.1.0-a1 */ $vars = array('mode', 'forum_id', 'display_link'); extract($phpbb_dispatcher->trigger_event('core.generate_smilies_after', compact($vars))); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 6682622d94..e44aa4dacd 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -143,7 +143,7 @@ function user_update_name($old_name, $new_name) * @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 + * @since 3.1.0-a1 */ $vars = array('old_name', 'new_name'); extract($phpbb_dispatcher->trigger_event('core.update_username', compact($vars))); @@ -259,7 +259,7 @@ function user_add($user_row, $cp_data = false) * * @event core.user_add_modify_data * @var array sql_ary Array of data to be inserted when a user is added - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('sql_ary'); extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars))); @@ -386,7 +386,7 @@ function user_delete($mode, $user_ids, $retain_username = true) * @var array user_ids IDs of the deleted user * @var mixed retain_username True if username should be retained * or false if not - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('mode', 'user_ids', 'retain_username'); extract($phpbb_dispatcher->trigger_event('core.delete_user_before', compact($vars))); @@ -615,7 +615,7 @@ function user_delete($mode, $user_ids, $retain_username = true) * @var array user_ids IDs of the deleted user * @var mixed retain_username True if username should be retained * or false if not - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('mode', 'user_ids', 'retain_username'); extract($phpbb_dispatcher->trigger_event('core.delete_user_after', compact($vars))); @@ -2504,7 +2504,7 @@ function group_delete($group_id, $group_name = false) * @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 + * @since 3.1.0-a1 */ $vars = array('group_id', 'group_name'); extract($phpbb_dispatcher->trigger_event('core.delete_group_after', compact($vars))); @@ -2752,7 +2752,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, * @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 + * @since 3.1.0-a1 */ $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary'); extract($phpbb_dispatcher->trigger_event('core.group_delete_user_before', compact($vars))); @@ -3198,7 +3198,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal * @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 + * @since 3.1.0-a1 */ $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.user_set_default_group', compact($vars))); diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 7c1c61dae7..e4603ad0ce 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -302,7 +302,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) * @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 + * @since 3.1.0-a1 */ $vars = array('row', 'topic_row'); extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars))); diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 44a6982a8e..2911eb57bc 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -248,7 +248,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) * @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 + * @since 3.1.0-a1 */ $vars = array( 'id', diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index e80cc2dce3..e3339c4c0b 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -64,7 +64,7 @@ class ucp_prefs * @var bool submit Do we display the form only * or did the user press submit * @var array data Array with current ucp options data - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('submit', 'data'); extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_data', compact($vars))); @@ -113,7 +113,7 @@ class ucp_prefs * @event core.ucp_prefs_personal_update_data * @var array data Submitted display options data * @var array sql_ary Display options data we udpate - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('data', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_update_data', compact($vars))); @@ -243,7 +243,7 @@ class ucp_prefs * @var bool submit Do we display the form only * or did the user press submit * @var array data Array with current ucp options data - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('submit', 'data'); extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_data', compact($vars))); @@ -292,7 +292,7 @@ class ucp_prefs * @event core.ucp_prefs_view_update_data * @var array data Submitted display options data * @var array sql_ary Display options data we udpate - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('data', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_update_data', compact($vars))); @@ -394,7 +394,7 @@ class ucp_prefs * @var bool submit Do we display the form only * or did the user press submit * @var array data Array with current ucp options data - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('submit', 'data'); extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_post_data', compact($vars))); @@ -418,7 +418,7 @@ class ucp_prefs * @event core.ucp_prefs_post_update_data * @var array data Submitted display options data * @var array sql_ary Display options data we udpate - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('data', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_post_update_data', compact($vars))); diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index 090f9bf34c..3bbbdb6726 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -62,7 +62,7 @@ class ucp_zebra * @event core.ucp_remove_zebra * @var string mode Zebra type: friends|foes * @var array user_ids User ids we remove - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('mode', 'user_ids'); extract($phpbb_dispatcher->trigger_event('core.ucp_remove_zebra', compact($vars))); @@ -207,7 +207,7 @@ class ucp_zebra * friends|foes * @var array sql_ary Array of * entries we add - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('mode', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.ucp_add_zebra', compact($vars))); diff --git a/phpBB/index.php b/phpBB/index.php index 32bc118e8c..716b6c99a0 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -188,7 +188,7 @@ $page_title = $user->lang['INDEX']; * * @event core.index_modify_page_title * @var string page_title Title of the index page -* @since 3.1-A1 +* @since 3.1.0-a1 */ $vars = array('page_title'); extract($phpbb_dispatcher->trigger_event('core.index_modify_page_title', compact($vars))); diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 7f78e694b9..dd886a4014 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -601,7 +601,7 @@ switch ($mode) * enabled? * @var bool friend Is the user friend? * @var bool foe Is the user foe? - * @since 3.1-A1 + * @since 3.1.0-a1 * @changed 3.1.0-b2 Added friend and foe status */ $vars = array( @@ -1764,7 +1764,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f * @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 + * @since 3.1.0-a1 */ $vars = array('data', 'template_data'); extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars))); diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index ea04344c59..d1a09f9a2b 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -305,7 +305,7 @@ class log implements \phpbb\log\log_interface * @var array sql_ary Array with log data we insert into the * database. If sql_ary[log_type] is not set, * we won't add the entry to the database. - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array( 'mode', @@ -411,7 +411,7 @@ class log implements \phpbb\log\log_interface * is false, no entries will be returned. * @var string sql_additional Additional conditions for the entries, * e.g.: 'AND l.forum_id = 1' - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array( 'mode', @@ -521,7 +521,7 @@ class log implements \phpbb\log\log_interface * @event core.get_logs_modify_entry_data * @var array row Entry data from the database * @var array log_entry_data Entry's data which is returned - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('row', 'log_entry_data'); extract($this->dispatcher->trigger_event('core.get_logs_modify_entry_data', compact($vars))); @@ -598,7 +598,7 @@ class log implements \phpbb\log\log_interface * get the permission data * @var array reportee_id_list Array of additional user IDs we * get the username strings for - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('log', 'topic_id_list', 'reportee_id_list'); extract($this->dispatcher->trigger_event('core.get_logs_get_additional_data', compact($vars))); diff --git a/phpBB/phpbb/permissions.php b/phpBB/phpbb/permissions.php index a3fddb0b9e..3cf39b5126 100644 --- a/phpBB/phpbb/permissions.php +++ b/phpBB/phpbb/permissions.php @@ -57,7 +57,7 @@ class permissions * 'lang' => 'ACL_U_VIEWPROFILE', * 'cat' => 'profile', * ), - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('types', 'categories', 'permissions'); extract($phpbb_dispatcher->trigger_event('core.permissions', compact($vars))); diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 417cc71fd3..18b7a3d096 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -143,7 +143,7 @@ class user extends \phpbb\session * that are absolutely needed globally using this * event. Use local events otherwise. * @var mixed style_id Style we are going to display - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array( 'user_data', diff --git a/phpBB/posting.php b/phpBB/posting.php index 11f0898440..cfd6524e62 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -80,7 +80,7 @@ $current_time = time(); * form submission. * NOTE: Should be actual language strings, NOT * language keys. -* @since 3.1-A1 +* @since 3.1.0-a1 */ $vars = array( 'post_id', @@ -1573,7 +1573,7 @@ $template->assign_vars(array( * this is "multipart/form-data" else it is the empty string * @var string s_action The URL to submit the POST data to * @var string s_hidden_fields The concatenated input tags of the form's hidden fields -* @since 3.1-A1 +* @since 3.1.0-a1 * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, s_topic_icons, form_enctype, s_action, s_hidden_fields */ $vars = array( diff --git a/phpBB/search.php b/phpBB/search.php index fbb4e93089..6364539ab3 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -681,7 +681,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) * @var string sql_select The SQL SELECT string used by search to get topic data * @var string sql_from The SQL FROM string used by search to get topic data * @var string sql_where The SQL WHERE string used by search to get topic data - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('sql_select', 'sql_from', 'sql_where'); extract($phpbb_dispatcher->trigger_event('core.search_get_topic_data', compact($vars))); @@ -1004,7 +1004,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) * @event core.search_modify_tpl_ary * @var array row Array with topic data * @var array tpl_ary Template block array with topic data - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('row', 'tpl_ary'); extract($phpbb_dispatcher->trigger_event('core.search_modify_tpl_ary', compact($vars))); diff --git a/phpBB/ucp.php b/phpBB/ucp.php index eaa40a07a2..73eaeaa127 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -337,7 +337,7 @@ if (!$config['allow_topic_notify'] && !$config['allow_forum_notify']) * @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 +* @since 3.1.0-a1 */ $vars = array('module', 'id', 'mode'); extract($phpbb_dispatcher->trigger_event('core.ucp_display_module_before', compact($vars))); diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index a7396f9c72..552f8dfa8b 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -387,7 +387,7 @@ $sql_array = array( * * @event core.viewforum_get_topic_data * @var array sql_array The SQL array to get the data of all topics -* @since 3.1-A1 +* @since 3.1.0-a1 */ $vars = array('sql_array'); extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_data', compact($vars))); @@ -582,7 +582,7 @@ if (sizeof($shadow_topic_list)) * * @event core.viewforum_get_shadowtopic_data * @var array sql_array SQL array to get the data of any shadowtopics - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('sql_array'); extract($phpbb_dispatcher->trigger_event('core.viewforum_get_shadowtopic_data', compact($vars))); @@ -819,7 +819,7 @@ if (sizeof($topic_list)) * @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 + * @since 3.1.0-a1 */ $vars = array('row', 'topic_row'); extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topicrow', compact($vars))); diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index 1738005786..9b462b2656 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -143,7 +143,7 @@ $sql_ary = array( * @var bool show_guests Do we display guests in the list * @var int guest_counter Number of guests displayed * @var array forum_data Array with forum data -* @since 3.1-A1 +* @since 3.1.0-a1 * @change 3.1.0-a2 Added vars guest_counter and forum_data */ $vars = array('sql_ary', 'show_guests', 'guest_counter', 'forum_data'); @@ -351,7 +351,7 @@ while ($row = $db->sql_fetchrow($result)) * @var string location Page name to displayed in the list * @var string location_url Page url to displayed in the list * @var array forum_data Array with forum data - * @since 3.1-A1 + * @since 3.1.0-a1 * @change 3.1.0-a2 Added var forum_data */ $vars = array('on_page', 'row', 'location', 'location_url', 'forum_data'); diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 0dbda7564f..76e20b8492 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -997,7 +997,7 @@ $sql_ary = array( * @var string sort_dir Direction the posts are sorted by * @var int start Pagination information * @var array sql_ary The SQL array to get the data of posts and posters -* @since 3.1-A1 +* @since 3.1.0-a1 * @change 3.1.0-a2 Added vars forum_id, topic_id, topic_data, post_list, sort_days, sort_key, sort_dir, start */ $vars = array( @@ -1083,7 +1083,7 @@ while ($row = $db->sql_fetchrow($result)) * @event core.viewtopic_post_rowset_data * @var array rowset_data Array with the rowset data for this post * @var array row Array with original user and post data - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('rowset_data', 'row'); extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_rowset_data', compact($vars))); @@ -1139,7 +1139,7 @@ while ($row = $db->sql_fetchrow($result)) * @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 + * @since 3.1.0-a1 */ $vars = array('user_cache_data', 'poster_id', 'row'); extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_guest_data', compact($vars))); @@ -1199,7 +1199,7 @@ while ($row = $db->sql_fetchrow($result)) * @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 + * @since 3.1.0-a1 */ $vars = array('user_cache_data', 'poster_id', 'row'); extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_user_data', compact($vars))); @@ -1685,7 +1685,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) * @var array user_poster_data Poster's data from user cache * @var array post_row Template block array of the post * @var array topic_data Array with topic data - * @since 3.1-A1 + * @since 3.1.0-a1 * @change 3.1.0-a3 Added vars start, current_row_number, end, attachments * @change 3.1.0-b3 Added topic_data array, total_posts */ @@ -1916,7 +1916,7 @@ $page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang * @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 +* @since 3.1.0-a1 */ $vars = array('page_title', 'topic_data', 'forum_id', 'start'); extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars))); From 48278f122cf9a2b23c39eccdd998b0c9b0552b2a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 12:31:57 +0200 Subject: [PATCH 213/424] [ticket/12273] Do not allow 3.1-A1 version PHPBB3-12273 --- phpBB/phpbb/event/php_exporter.php | 18 +++++------------- tests/event/fixtures/trigger_many_vars.test | 2 +- tests/event/php_exporter_test.php | 15 ++++++--------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php index 2a69f15802..ac88ffa8b5 100644 --- a/phpBB/phpbb/event/php_exporter.php +++ b/phpBB/phpbb/event/php_exporter.php @@ -544,23 +544,15 @@ class php_exporter */ public function validate_since($line) { - $since = substr(ltrim($line, "\t"), strlen('* @since ')); - - if ($since !== trim($since)) + $match = array(); + preg_match('#^\* @since (\d+\.\d+\.\d+(?:-(?:a|b|rc|pl)\d+)?)$#', ltrim($line, "\t"), $match); + if (!isset($match[1])) { throw new \LogicException("Invalid '@since' information for event " - . "'{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 1); + . "'{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'"); } - $since = ($since === '3.1-A1') ? '3.1.0-a1' : $since; - - if (!preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|rc|pl)\d+)?$#', $since)) - { - throw new \LogicException("Invalid '@since' information for event " - . "'{$this->current_event}' in file '{$this->current_file}:{$this->current_event_line}'", 2); - } - - return $since; + return $match[1]; } /** diff --git a/tests/event/fixtures/trigger_many_vars.test b/tests/event/fixtures/trigger_many_vars.test index da72f4c57f..a624138588 100644 --- a/tests/event/fixtures/trigger_many_vars.test +++ b/tests/event/fixtures/trigger_many_vars.test @@ -33,7 +33,7 @@ * @var array page_data Posting page data that should be passed to the * posting page via $template->assign_vars() * @var object message_parser The message parser object - * @since 3.1-A1 + * @since 3.1.0-a1 * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, * s_topic_icons, form_enctype, s_action, s_hidden_fields, * post_id, topic_id, forum_id, submit, preview, save, load, diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 03f6974af1..9917f8309b 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -114,7 +114,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array('* @since 3.1.0-a1', '3.1.0-a1'), array('* @since 3.1.0-b3', '3.1.0-b3'), array(' * @since 3.1.0-b3', '3.1.0-b3'), - array('* @since 3.1-A1', '3.1.0-a1'), ); } @@ -129,12 +128,11 @@ class phpbb_event_php_exporter_test extends phpbb_test_case static public function validate_since_throws_data() { return array( - array(' * @since 3.1.0-a1', 1), - array('* @since 3.1.0-a1 ', 1), - array('* @since 3.1.0-a1 bertie is cool', 2), - array('bertie* @since 3.1.0-a1', 2), - array('* @since 3.1-A2', 2), - array('* @since 3.1-B3', 2), + array(' * @since 3.1.0-a1'), + array('* @since 3.1.0-a1 '), + array('* @since 3.1.0-a1 bertie is cool'), + array('bertie* @since 3.1.0-a1'), + array('* @since 3.1-A2'), ); } @@ -142,9 +140,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case * @dataProvider validate_since_throws_data * @expectedException LogicException */ - public function test_validate_since_throws($since, $exception_code) + public function test_validate_since_throws($since) { - $this->setExpectedException('LogicException', '', $exception_code); $this->exporter->validate_since($since); } From 3bcda97e28f096558baa46be63e8bb40f43c59c8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 12:37:39 +0200 Subject: [PATCH 214/424] [ticket/12273] Sort arguments alphabetically before exporting PHPBB3-12273 --- phpBB/phpbb/event/php_exporter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php index ac88ffa8b5..a92bd2671d 100644 --- a/phpBB/phpbb/event/php_exporter.php +++ b/phpBB/phpbb/event/php_exporter.php @@ -223,6 +223,7 @@ class php_exporter . "'{$this->events[$this->current_event]['file']}'", 10); } + sort($arguments); $this->events[$this->current_event] = array( 'event' => $this->current_event, 'file' => $this->current_file, From 9c689ef8dd6313ec52cc1b06dcadba79bfd70b96 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 12:45:48 +0200 Subject: [PATCH 215/424] [ticket/11917] Replace space with tabs PHPBB3-11917 --- phpBB/install/install_install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index a0c9cf9c5c..dcf2756850 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1669,13 +1669,13 @@ class install_install extends module WHERE module_basename = 'ucp_notifications' AND module_class = 'ucp' AND module_mode = 'notification_options'"; - $result = $db->sql_query($sql); + $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $_module->move_module_by($row, 'move_down', 4); - // Move OAuth module 5 down... + // Move OAuth module 5 down... $sql = 'SELECT * FROM ' . MODULES_TABLE . " WHERE module_basename = 'ucp_auth_link' From 5109d3a12f09447c8f74f0619f8703ecd8c56ba6 Mon Sep 17 00:00:00 2001 From: PayBas Date: Fri, 25 Apr 2014 12:56:58 +0200 Subject: [PATCH 216/424] [ticket/12442] Add CSS classes to important headings PHPBB3-12442 --- phpBB/styles/prosilver/template/confirm_body.html | 2 +- phpBB/styles/prosilver/template/confirm_delete_body.html | 2 +- phpBB/styles/prosilver/template/faq_body.html | 4 ++-- phpBB/styles/prosilver/template/login_body.html | 2 +- phpBB/styles/prosilver/template/login_forum.html | 4 ++-- phpBB/styles/prosilver/template/mcp_approve.html | 2 +- phpBB/styles/prosilver/template/mcp_header.html | 2 +- phpBB/styles/prosilver/template/mcp_message.html | 2 +- phpBB/styles/prosilver/template/mcp_move.html | 2 +- phpBB/styles/prosilver/template/memberlist_body.html | 2 +- phpBB/styles/prosilver/template/memberlist_view.html | 2 +- phpBB/styles/prosilver/template/message_body.html | 2 +- phpBB/styles/prosilver/template/posting_layout.html | 4 ++-- phpBB/styles/prosilver/template/posting_pm_layout.html | 2 +- phpBB/styles/prosilver/template/quickreply_editor.html | 2 +- phpBB/styles/prosilver/template/search_results.html | 2 +- phpBB/styles/prosilver/template/ucp_agreement.html | 4 ++-- phpBB/styles/prosilver/template/ucp_header.html | 2 +- phpBB/styles/prosilver/template/viewforum_body.html | 2 +- phpBB/styles/prosilver/template/viewonline_body.html | 2 +- phpBB/styles/prosilver/template/viewonline_whois.html | 2 +- phpBB/styles/prosilver/template/viewtopic_body.html | 4 ++-- 22 files changed, 27 insertions(+), 27 deletions(-) diff --git a/phpBB/styles/prosilver/template/confirm_body.html b/phpBB/styles/prosilver/template/confirm_body.html index a0428025cf..aaea5cfd05 100644 --- a/phpBB/styles/prosilver/template/confirm_body.html +++ b/phpBB/styles/prosilver/template/confirm_body.html @@ -17,7 +17,7 @@
    -

    {MESSAGE_TITLE}

    +

    {MESSAGE_TITLE}

    {MESSAGE_TEXT}

    diff --git a/phpBB/styles/prosilver/template/confirm_delete_body.html b/phpBB/styles/prosilver/template/confirm_delete_body.html index dc09974d1c..2d4dde5cd5 100644 --- a/phpBB/styles/prosilver/template/confirm_delete_body.html +++ b/phpBB/styles/prosilver/template/confirm_delete_body.html @@ -33,7 +33,7 @@
    -

    {MESSAGE_TITLE}

    +

    {MESSAGE_TITLE}

    {MESSAGE_TEXT}

    diff --git a/phpBB/styles/prosilver/template/faq_body.html b/phpBB/styles/prosilver/template/faq_body.html index 46f738aa3a..4444272920 100644 --- a/phpBB/styles/prosilver/template/faq_body.html +++ b/phpBB/styles/prosilver/template/faq_body.html @@ -1,6 +1,6 @@ -

    {L_FAQ_TITLE}

    +

    {L_FAQ_TITLE}