diff options
-rw-r--r-- | phpBB/docs/CREDITS.txt | 2 | ||||
-rw-r--r-- | phpBB/docs/events.md | 7 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_profile.php | 10 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_search.php | 23 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_users.php | 17 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 34 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_forum.php | 30 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/tool/module.php | 37 | ||||
-rw-r--r-- | phpBB/phpbb/event/kernel_exception_subscriber.php | 3 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/overall_header.html | 1 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/ucp_main_subscribed.html | 6 | ||||
-rw-r--r-- | tests/dbal/fixtures/migrator_module.xml | 39 | ||||
-rw-r--r-- | tests/dbal/migrator_tool_module_test.php | 120 | ||||
-rw-r--r-- | tests/functional/search/base.php | 24 | ||||
-rw-r--r-- | tests/functional/user_password_reset_test.php | 43 |
15 files changed, 314 insertions, 82 deletions
diff --git a/phpBB/docs/CREDITS.txt b/phpBB/docs/CREDITS.txt index 471e6b3c88..26ff8fcc80 100644 --- a/phpBB/docs/CREDITS.txt +++ b/phpBB/docs/CREDITS.txt @@ -27,7 +27,6 @@ phpBB Lead Developer: Marc (Marc Alexander) phpBB Developers: bantu (Andreas Fischer) CHItA (Máté Bartus) Elsensee (Oliver Schramm) - nickvergessen (Joas Schilling) Nicofuma (Tristan Darricau) prototech (Cesar Gallegos) @@ -60,6 +59,7 @@ phpBB Developers: A_Jelly_Doughnut (Josh Woody) [01/2010 - 11/2010] igorw (Igor Wiedler) [08/2010 - 02/2013] imkingdavid (David King) [11/2012 - 06/2014] kellanved (Henry Sudhof) [04/2007 - 03/2011] + nickvergessen (Joas Schilling)[04/2010 - 12/2015] Oleg (Oleg Pudeyev) [01/2011 - 05/2013] rxu (Ruslan Uzdenov) [04/2010 - 12/2012] TerraFrost (Jim Wigginton) [04/2009 - 01/2011] diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 35c6877a89..0abda89706 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -1453,6 +1453,13 @@ overall_header_page_body_before * Since: 3.1.0-b3 * Purpose: Add content after the page-header, but before the page-body +overall_header_searchbox_after +=== +* Locations: + + styles/prosilver/template/overall_header.html +* Since: 3.1.11-RC1 +* Purpose: Add content after the search box in the header + overall_header_searchbox_before === * Locations: diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 485f849f51..2012d3c513 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -597,13 +597,13 @@ class acp_profile if (!sizeof($error)) { - if (!check_form_key($form_key)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - if (($step == 3 && (sizeof($this->lang_defs['iso']) == 1 || $save)) || ($action == 'edit' && $save)) { + if (!check_form_key($form_key)) + { + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); + } + $this->save_profile_field($cp, $field_type, $action); } } diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index f15a75e9a1..cc1e5df084 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -50,14 +50,12 @@ class acp_search function settings($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $submit = (isset($_POST['submit'])) ? true : false; - $form_key = 'acp_search'; - add_form_key($form_key); - if ($submit && !check_form_key($form_key)) + if ($submit && !check_link_hash($request->variable('hash', ''), 'acp_search')) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } @@ -233,7 +231,7 @@ class acp_search 'S_YES_SEARCH' => (bool) $config['load_search'], 'S_SETTINGS' => true, - 'U_ACTION' => $this->u_action) + 'U_ACTION' => $this->u_action . '&hash=' . generate_link_hash('acp_search')) ); } @@ -253,10 +251,7 @@ class acp_search } $submit = $request->is_set_post('submit', false); - $form_key = 'acp_search'; - add_form_key($form_key); - - if (!check_form_key($form_key) && in_array($action, array('delete', 'create'))) + if (!check_link_hash($request->variable('hash', ''), 'acp_search') && in_array($action, array('create', 'delete'))) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } @@ -310,7 +305,7 @@ class acp_search if (method_exists($this->search, 'delete_index')) { // pass a reference to myself so the $search object can make use of save_state() and attributes - if ($error = $this->search->delete_index($this, append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&mode=$mode&action=delete", false))) + if ($error = $this->search->delete_index($this, append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&mode=$mode&action=delete&hash=" . generate_link_hash('acp_search'), false))) { $this->state = array(''); $this->save_state(); @@ -355,7 +350,7 @@ class acp_search $mtime = explode(' ', microtime()); $totaltime = $mtime[0] + $mtime[1] - $starttime; $rows_per_second = $row_count / $totaltime; - meta_refresh(1, append_sid($this->u_action . '&action=delete&skip_rows=' . $post_counter)); + meta_refresh(1, append_sid($this->u_action . '&action=delete&skip_rows=' . $post_counter . '&hash=' . generate_link_hash('acp_search'))); trigger_error($user->lang('SEARCH_INDEX_DELETE_REDIRECT', (int) $row_count, $post_counter, $rows_per_second)); } } @@ -445,7 +440,7 @@ class acp_search $mtime = explode(' ', microtime()); $totaltime = $mtime[0] + $mtime[1] - $starttime; $rows_per_second = $row_count / $totaltime; - meta_refresh(1, append_sid($this->u_action . '&action=create&skip_rows=' . $post_counter)); + meta_refresh(1, append_sid($this->u_action . '&action=create&skip_rows=' . $post_counter . '&hash=' . generate_link_hash('acp_search'))); trigger_error($user->lang('SEARCH_INDEX_CREATE_REDIRECT', (int) $row_count, $post_counter) . $user->lang('SEARCH_INDEX_CREATE_REDIRECT_RATE', $rows_per_second)); } } @@ -524,7 +519,7 @@ class acp_search $template->assign_vars(array( 'S_INDEX' => true, - 'U_ACTION' => $this->u_action, + 'U_ACTION' => $this->u_action . '&hash=' . generate_link_hash('acp_search'), 'U_PROGRESS_BAR' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&mode=$mode&action=progress_bar"), 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&mode=$mode&action=progress_bar")), )); @@ -533,7 +528,7 @@ class acp_search { $template->assign_vars(array( 'S_CONTINUE_INDEXING' => $this->state[1], - 'U_CONTINUE_INDEXING' => $this->u_action . '&action=' . $this->state[1], + 'U_CONTINUE_INDEXING' => $this->u_action . '&action=' . $this->state[1] . '&hash=' . generate_link_hash('acp_search'), 'L_CONTINUE' => ($this->state[1] == 'create') ? $user->lang['CONTINUE_INDEXING'] : $user->lang['CONTINUE_DELETING_INDEX'], 'L_CONTINUE_EXPLAIN' => ($this->state[1] == 'create') ? $user->lang['CONTINUE_INDEXING_EXPLAIN'] : $user->lang['CONTINUE_DELETING_INDEX_EXPLAIN']) ); diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 1e453e88ad..008cc02471 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -373,11 +373,6 @@ class acp_users if ($user_row['user_type'] == USER_NORMAL) { user_active_flip('deactivate', $user_id, INACTIVE_REMIND); - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_actkey = '" . $db->sql_escape($user_actkey) . "' - WHERE user_id = $user_id"; - $db->sql_query($sql); } else { @@ -386,8 +381,18 @@ class acp_users FROM ' . USERS_TABLE . ' WHERE user_id = ' . $user_id; $result = $db->sql_query($sql); - $user_actkey = (string) $db->sql_fetchfield('user_actkey'); + $user_activation_key = (string) $db->sql_fetchfield('user_actkey'); $db->sql_freeresult($result); + + $user_actkey = empty($user_activation_key) ? $user_actkey : $user_activation_key; + } + + if ($user_row['user_type'] == USER_NORMAL || empty($user_activation_key)) + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_actkey = '" . $db->sql_escape($user_actkey) . "' + WHERE user_id = $user_id"; + $db->sql_query($sql); } $messenger = new messenger(false); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 12ca5540ca..a152d9b620 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2233,13 +2233,6 @@ function generate_board_url($without_script_path = false) global $config, $user, $request; $server_name = $user->host; - $server_port = $request->server('SERVER_PORT', 0); - $forwarded_proto = $request->server('HTTP_X_FORWARDED_PROTO'); - - if (!empty($forwarded_proto) && $forwarded_proto === 'https') - { - $server_port = 443; - } // Forcing server vars is the only way to specify/override the protocol if ($config['force_server_vars'] || !$server_name) @@ -2254,6 +2247,13 @@ function generate_board_url($without_script_path = false) } else { + $server_port = $request->server('SERVER_PORT', 0); + $forwarded_proto = $request->server('HTTP_X_FORWARDED_PROTO'); + + if (!empty($forwarded_proto) && $forwarded_proto === 'https') + { + $server_port = 443; + } // Do not rely on cookie_secure, users seem to think that it means a secured cookie instead of an encrypted connection $cookie_secure = $request->is_secure() ? 1 : 0; $url = (($cookie_secure) ? 'https://' : 'http://') . $server_name; @@ -2609,8 +2609,9 @@ function check_link_hash($token, $link_name) /** * Add a secret token to the form (requires the S_FORM_TOKEN template variable) * @param string $form_name The name of the form; has to match the name used in check_form_key, otherwise no restrictions apply +* @param string $template_variable_suffix A string that is appended to the name of the template variable to which the form elements are assigned */ -function add_form_key($form_name) +function add_form_key($form_name, $template_variable_suffix = '') { global $config, $template, $user, $phpbb_dispatcher; @@ -2627,13 +2628,15 @@ function add_form_key($form_name) * Perform additional actions on creation of the form token * * @event core.add_form_key - * @var string form_name The form name - * @var int now Current time timestamp - * @var string s_fields Generated hidden fields - * @var string token Form token - * @var string token_sid User session ID + * @var string form_name The form name + * @var int now Current time timestamp + * @var string s_fields Generated hidden fields + * @var string token Form token + * @var string token_sid User session ID + * @var string template_variable_suffix The string that is appended to template variable name * * @since 3.1.0-RC3 + * @changed 3.1.11-RC1 Added template_variable_suffix */ $vars = array( 'form_name', @@ -2641,12 +2644,11 @@ function add_form_key($form_name) 's_fields', 'token', 'token_sid', + 'template_variable_suffix', ); extract($phpbb_dispatcher->trigger_event('core.add_form_key', compact($vars))); - $template->assign_vars(array( - 'S_FORM_TOKEN' => $s_fields, - )); + $template->assign_var('S_FORM_TOKEN' . $template_variable_suffix, $s_fields); } /** diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 7df712f65f..e4c0640ec7 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -396,7 +396,7 @@ function mcp_resync_topics($topic_ids) */ function merge_topics($forum_id, $topic_ids, $to_topic_id) { - global $db, $template, $user, $phpEx, $phpbb_root_path, $auth; + global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $phpbb_dispatcher; if (!sizeof($topic_ids)) { @@ -411,9 +411,9 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) $sync_topics = array_merge($topic_ids, array($to_topic_id)); - $topic_data = phpbb_get_topic_data($sync_topics, 'm_merge'); + $all_topic_data = phpbb_get_topic_data($sync_topics, 'm_merge'); - if (!sizeof($topic_data) || empty($topic_data[$to_topic_id])) + if (!sizeof($all_topic_data) || empty($all_topic_data[$to_topic_id])) { $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']); return; @@ -421,13 +421,13 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) $sync_forums = array(); $topic_views = 0; - foreach ($topic_data as $data) + foreach ($all_topic_data as $data) { $sync_forums[$data['forum_id']] = $data['forum_id']; - $topic_views += $data['topic_views']; + $topic_views = max($topic_views, $data['topic_views']); } - $topic_data = $topic_data[$to_topic_id]; + $to_topic_data = $all_topic_data[$to_topic_id]; $post_id_list = request_var('post_id_list', array(0)); $start = request_var('start', 0); @@ -475,10 +475,10 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) if (confirm_box(true)) { - $to_forum_id = $topic_data['forum_id']; + $to_forum_id = $to_topic_data['forum_id']; move_posts($post_id_list, $to_topic_id, false); - add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']); + add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $to_topic_data['topic_title']); // Update topic views count $sql = 'UPDATE ' . TOPICS_TABLE . ' @@ -511,6 +511,20 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); + /** + * Perform additional actions after merging topics. + * + * @event core.mcp_forum_merge_topics_after + * @var array all_topic_data The data from all topics involved in the merge + * @var int to_topic_id The ID of the topic into which the rest are merged + * @since 3.1.11-RC1 + */ + $vars = array( + 'all_topic_data', + 'to_topic_id', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_forum_merge_topics_after', compact($vars))); + meta_refresh(3, $redirect); trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link); } diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index 6d5378e35f..7ea7d1dac1 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -90,7 +90,12 @@ class module implements \phpbb\db\migration\tool\tool_interface $parent_sql = ''; if ($parent !== false) { - $parent = $this->get_parent_module_id($parent, $module); + $parent = $this->get_parent_module_id($parent, $module, false); + if ($parent === false) + { + return false; + } + $parent_sql = 'AND parent_id = ' . (int) $parent; } @@ -197,7 +202,7 @@ class module implements \phpbb\db\migration\tool\tool_interface if ($this->exists($class, $parent, $data['module_langname'])) { - throw new \phpbb\db\migration\exception('MODULE_EXISTS', $module_id); + throw new \phpbb\db\migration\exception('MODULE_EXISTS', $data['module_langname']); } if (!class_exists('acp_modules')) @@ -448,12 +453,11 @@ class module implements \phpbb\db\migration\tool\tool_interface protected function get_categories_list() { // Select the top level categories - // and 2nd level [sub]categories which exist for ACP only + // and 2nd level [sub]categories $sql = 'SELECT m2.module_id, m2.module_langname FROM ' . $this->modules_table . ' m1, ' . $this->modules_table . " m2 WHERE m1.parent_id = 0 - AND (m1.module_id = m2.module_id - OR m2.module_class = 'acp' AND m2.parent_id = m1.module_id) + AND (m1.module_id = m2.module_id OR m2.parent_id = m1.module_id) ORDER BY m1.module_id, m2.module_id ASC"; $result = $this->db->sql_query($sql); @@ -469,11 +473,15 @@ class module implements \phpbb\db\migration\tool\tool_interface * * @param string|int $parent_id The parent module_id|module_langname * @param int|string|array $data The module_id, module_langname for existance checking or module data array for adding - * @return int The parent module_id + * @param bool $throw_exception The flag indicating if exception should be thrown on error + * @return mixed The int parent module_id or false * @throws \phpbb\db\migration\exception */ - public function get_parent_module_id($parent_id, $data = '') + public function get_parent_module_id($parent_id, $data = '', $throw_exception = true) { + // Initialize exception object placeholder + $exception = false; + // Allow '' to be sent as 0 $parent_id = $parent_id ?: 0; @@ -495,7 +503,7 @@ class module implements \phpbb\db\migration\tool\tool_interface { // No parent with the given module_langname exist case 0: - throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent_id); + $exception = new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent_id); break; // Return the module id @@ -517,7 +525,7 @@ class module implements \phpbb\db\migration\tool\tool_interface $parent_id = (int) $this->db->sql_fetchfield('parent_id'); if (!$parent_id) { - throw new \phpbb\db\migration\exception('PARENT_MODULE_FIND_ERROR', $data['parent_id']); + $exception = new \phpbb\db\migration\exception('PARENT_MODULE_FIND_ERROR', $data['parent_id']); } } else if (!empty($data) && !is_array($data)) @@ -535,12 +543,21 @@ class module implements \phpbb\db\migration\tool\tool_interface else { //Unable to get the parent module id, throwing an exception - throw new \phpbb\db\migration\exception('MODULE_EXIST_MULTIPLE', $parent_id); + $exception = new \phpbb\db\migration\exception('MODULE_EXIST_MULTIPLE', $parent_id); } break; } } + if ($exception !== false) + { + if ($throw_exception) + { + throw $exception; + } + return false; + } + return $parent_id; } } diff --git a/phpBB/phpbb/event/kernel_exception_subscriber.php b/phpBB/phpbb/event/kernel_exception_subscriber.php index 34c8422b0a..9d15f9370e 100644 --- a/phpBB/phpbb/event/kernel_exception_subscriber.php +++ b/phpBB/phpbb/event/kernel_exception_subscriber.php @@ -68,6 +68,9 @@ class kernel_exception_subscriber implements EventSubscriberInterface $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($message), $exception->get_parameters())); } + // Show <strong> text in bold + $message = preg_replace('#<(/?strong)>#i', '<$1>', $message); + if (!$event->getRequest()->isXmlHttpRequest()) { page_header($this->user->lang('INFORMATION')); diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 5093d81919..e583c6e890 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -99,6 +99,7 @@ </form> </div> <!-- ENDIF --> + <!-- EVENT overall_header_searchbox_after --> </div> <!-- EVENT overall_header_headerbar_after --> diff --git a/phpBB/styles/prosilver/template/ucp_main_subscribed.html b/phpBB/styles/prosilver/template/ucp_main_subscribed.html index ef03317578..2d65b800a0 100644 --- a/phpBB/styles/prosilver/template/ucp_main_subscribed.html +++ b/phpBB/styles/prosilver/template/ucp_main_subscribed.html @@ -30,7 +30,7 @@ {forumrow.FORUM_DESC} <!-- IF forumrow.LAST_POST_TIME --> <div class="responsive-show" style="display: none;"> - {L_LAST_POST} {L_POST_BY_AUTHOR} {forumrow.LAST_POST_AUTHOR_FULL} « <a href="{topicrow.U_LAST_POST}">{forumrow.LAST_POST_TIME}</a> + {L_LAST_POST} {L_POST_BY_AUTHOR} {forumrow.LAST_POST_AUTHOR_FULL} « <a href="{forumrow.U_LAST_POST}">{forumrow.LAST_POST_TIME}</a> </div> <!-- ENDIF --> </div> @@ -113,9 +113,9 @@ <div class="action-bar bottom"> <div class="pagination"> {TOTAL_TOPICS} - <!-- IF .pagination --> + <!-- IF .pagination --> <!-- INCLUDE pagination.html --> - <!-- ELSE --> + <!-- ELSE --> • {PAGE_NUMBER} <!-- ENDIF --> </div> diff --git a/tests/dbal/fixtures/migrator_module.xml b/tests/dbal/fixtures/migrator_module.xml index e172d7a145..e85c43ee25 100644 --- a/tests/dbal/fixtures/migrator_module.xml +++ b/tests/dbal/fixtures/migrator_module.xml @@ -90,5 +90,44 @@ <value></value> <value></value> </row> + <row> + <value>7</value> + <value>1</value> + <value>1</value> + <value></value> + <value>ucp</value> + <value>0</value> + <value>13</value> + <value>18</value> + <value>UCP_MAIN_CAT</value> + <value></value> + <value></value> + </row> + <row> + <value>8</value> + <value>1</value> + <value>1</value> + <value>ucp_subcat</value> + <value>ucp</value> + <value>7</value> + <value>14</value> + <value>17</value> + <value>UCP_SUBCATEGORY</value> + <value>ucp_test</value> + <value></value> + </row> + <row> + <value>9</value> + <value>1</value> + <value>1</value> + <value>ucp_module</value> + <value>ucp</value> + <value>8</value> + <value>15</value> + <value>16</value> + <value>UCP_MODULE</value> + <value>ucp_module_test</value> + <value></value> + </row> </table> </dataset> diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index 49dff8b929..bbe543f347 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -42,10 +42,10 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $this->tool = new \phpbb\db\migration\tool\module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx, 'phpbb_modules'); } - public function exists_data() + public function exists_data_acp() { return array( - // Test the category + // Test the existing category array( '', 'ACP_CAT', @@ -57,7 +57,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case true, ), - // Test the module + // Test the existing module array( '', 'ACP_MODULE', @@ -73,17 +73,88 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case 'ACP_MODULE', true, ), + + // Test for non-existant modules + array( + '', + 'ACP_NON_EXISTANT_CAT', + false, + ), + array( + 'ACP_CAT', + 'ACP_NON_EXISTANT_MODULE', + false, + ), ); } /** - * @dataProvider exists_data + * @dataProvider exists_data_acp */ - public function test_exists($parent, $module, $expected) + public function test_exists_acp($parent, $module, $expected) { $this->assertEquals($expected, $this->tool->exists('acp', $parent, $module)); } + public function exists_data_ucp() + { + return array( + // Test the existing category + array( + '', + 'UCP_MAIN_CAT', + true, + ), + array( + 0, + 'UCP_MAIN_CAT', + true, + ), + + // Test the existing module + array( + '', + 'UCP_SUBCATEGORY', + false, + ), + array( + false, + 'UCP_SUBCATEGORY', + true, + ), + array( + 'UCP_MAIN_CAT', + 'UCP_SUBCATEGORY', + true, + ), + array( + 'UCP_SUBCATEGORY', + 'UCP_MODULE', + true, + ), + + // Test for non-existant modules + array( + '', + 'UCP_NON_EXISTANT_CAT', + false, + ), + array( + 'UCP_MAIN_CAT', + 'UCP_NON_EXISTANT_MODULE', + false, + ), + ); + } + + /** + * @dataProvider exists_data_ucp + */ + public function test_exists_ucp($parent, $module, $expected) + { + $this->assertEquals($expected, $this->tool->exists('ucp', $parent, $module)); + } + public function test_add() { try @@ -156,6 +227,45 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $this->fail($e); } $this->assertEquals(true, $this->tool->exists('acp', 'ACP_FORUM_BASED_PERMISSIONS', 'ACP_NEW_PERMISSIONS_MODULE')); + + // Test adding UCP modules + // Test adding new UCP category + try + { + $this->tool->add('ucp', 0, 'UCP_NEW_CAT'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('ucp', 0, 'UCP_NEW_CAT')); + + // Test adding new UCP subcategory + try + { + $this->tool->add('ucp', 'UCP_NEW_CAT', 'UCP_NEW_SUBCAT'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_SUBCAT')); + + // Test adding new UCP module + try + { + $this->tool->add('ucp', 'UCP_NEW_SUBCAT', array( + 'module_basename' => 'ucp_new_module', + 'module_langname' => 'UCP_NEW_MODULE', + 'module_mode' => 'ucp_test', + 'module_auth' => '', + )); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_SUBCAT', 'UCP_NEW_MODULE')); } public function test_remove() diff --git a/tests/functional/search/base.php b/tests/functional/search/base.php index d41e3ec925..f1e9b517d4 100644 --- a/tests/functional/search/base.php +++ b/tests/functional/search/base.php @@ -76,18 +76,16 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case { $this->add_lang('acp/search'); $crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid); - $form_values = $crawler->selectButton('Delete index')->form()->getValues(); - $crawler = self::request( - 'POST', - 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid, + $form = $crawler->selectButton('Create index')->form(); + $form_values = $form->getValues(); + $form_values = array_merge($form_values, array( 'search_type' => $this->search_backend, 'action' => 'create', - 'submit' => true, - 'form_token' => $form_values['form_token'], - 'creation_time' => $form_values['creation_time'], ) ); + $form->setValues($form_values); + $crawler = self::submit($form); $this->assertContainsLang('SEARCH_INDEX_CREATED', $crawler->text()); } @@ -95,18 +93,16 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case { $this->add_lang('acp/search'); $crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid); - $form_values = $crawler->selectButton('Delete index')->form()->getValues(); - $crawler = self::request( - 'POST', - 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid, + $form = $crawler->selectButton('Delete index')->form(); + $form_values = $form->getValues(); + $form_values = array_merge($form_values, array( 'search_type' => $this->search_backend, 'action' => 'delete', - 'submit' => true, - 'form_token' => $form_values['form_token'], - 'creation_time' => $form_values['creation_time'], ) ); + $form->setValues($form_values); + $crawler = self::submit($form); $this->assertContainsLang('SEARCH_INDEX_REMOVED', $crawler->text()); } } diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php index f9406f0eb5..3da78407cf 100644 --- a/tests/functional/user_password_reset_test.php +++ b/tests/functional/user_password_reset_test.php @@ -113,6 +113,49 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca $this->assertContains($this->lang('LOGIN_ERROR_PASSWORD', '', ''), $crawler->filter('html')->text()); } + /** + * @depends test_login + */ + public function test_acivateAfterDeactivate() + { + // User is active, actkey should not exist + $this->get_user_data(); + $this->assertEmpty($this->user_data['user_actkey']); + + $this->login(); + $this->admin_login(); + $this->add_lang('acp/users'); + + // Go to user account page + $crawler = self::request('GET', 'adm/index.php?i=acp_users&mode=overview&sid=' . $this->sid); + $this->assertContainsLang('FIND_USERNAME', $crawler->filter('html')->text()); + + $form = $crawler->selectButton('Submit')->form(); + $crawler = self::submit($form, array('username' => 'reset-password-test-user')); + + // Deactivate account and go back to overview of current user + $this->assertContainsLang('USER_TOOLS', $crawler->filter('html')->text()); + $form = $crawler->filter('input[name=update]')->selectButton('Submit')->form(); + $crawler = self::submit($form, array('action' => 'active')); + + $this->assertContainsLang('USER_ADMIN_DEACTIVED', $crawler->filter('html')->text()); + $link = $crawler->selectLink('Back to previous page')->link(); + $crawler = self::request('GET', preg_replace('#(.+)(adm/index.php.+)#', '$2', $link->getUri())); + + // Ensure again that actkey is empty after deactivation + $this->get_user_data(); + $this->assertEmpty($this->user_data['user_actkey']); + + // Force reactivation of account and check that act key is not empty anymore + $this->assertContainsLang('USER_TOOLS', $crawler->filter('html')->text()); + $form = $crawler->filter('input[name=update]')->selectButton('Submit')->form(); + $crawler = self::submit($form, array('action' => 'reactivate')); + $this->assertContainsLang('FORCE_REACTIVATION_SUCCESS', $crawler->filter('html')->text()); + + $this->get_user_data(); + $this->assertNotEmpty($this->user_data['user_actkey']); + } + protected function get_user_data() { $db = $this->get_db(); |