diff options
-rw-r--r-- | phpBB/includes/acp/acp_logs.php | 10 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_logs.php | 4 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/driver/local.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/log/log.php | 31 | ||||
-rw-r--r-- | phpBB/posting.php | 1 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/forum_fn.js | 1 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/posting_editor.html | 2 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/posting_layout.html | 1 | ||||
-rw-r--r-- | phpBB/styles/prosilver/theme/content.css | 4 | ||||
-rw-r--r-- | phpBB/viewtopic.php | 2 | ||||
-rw-r--r-- | tests/log/delete_test.php | 161 |
12 files changed, 156 insertions, 65 deletions
diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index 6b7ed1d269..80dee1d620 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -58,13 +58,7 @@ class acp_logs if ($deletemark && sizeof($marked)) { - $sql_in = array(); - foreach ($marked as $mark) - { - $sql_in[] = $mark; - } - $conditions['log_id'] = $sql_in; - unset($sql_in); + $conditions['log_id'] = array('IN' => $marked); } if ($deleteall) @@ -78,8 +72,6 @@ class acp_logs $conditions['keywords'] = $keywords; } - $conditions['log_type'] = $this->log_type; - $phpbb_log = $phpbb_container->get('log'); $phpbb_log->delete($mode, $conditions); } diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index a0c1bc02ec..2945e1ec8a 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -115,9 +115,8 @@ class mcp_logs if ($deletemark && sizeof($marked)) { $conditions = array( - 'log_type' => LOG_MOD, 'forum_id' => $forum_list, - 'log_id' => $marked, + 'log_id' => array('IN' => $marked), ); $phpbb_log->delete('mod', $conditions); @@ -127,7 +126,6 @@ class mcp_logs $keywords = utf8_normalize_nfc(request_var('keywords', '', true)); $conditions = array( - 'log_type' => LOG_MOD, 'forum_id' => $forum_list, 'keywords' => $keywords, ); diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 53c69ceeb7..fc568abc68 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -283,7 +283,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) $contact_fields = array( array( 'ID' => 'pm', - 'NAME' => $user->lang['PRIVATE_MESSAGE'], + 'NAME' => $user->lang['SEND_PRIVATE_MESSAGE'], 'U_CONTACT' => $u_pm, ), array( diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php index 00e519e3f2..c9e6781205 100644 --- a/phpBB/phpbb/avatar/driver/local.php +++ b/phpBB/phpbb/avatar/driver/local.php @@ -36,7 +36,7 @@ class local extends \phpbb\avatar\driver\driver public function prepare_form($request, $template, $user, $row, &$error) { $avatar_list = $this->get_avatar_list($user); - $category = $request->variable('avatar_local_cat', ''); + $category = $request->variable('avatar_local_cat', key($avatar_list)); foreach ($avatar_list as $cat => $null) { diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 453cb740bb..10efe5fd1c 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -391,28 +391,29 @@ class log implements \phpbb\log\log_interface } $sql_where = 'WHERE log_type = ' . $log_type; + + if (isset($conditions['keywords'])) + { + $sql_where .= $this->generate_sql_keyword($conditions['keywords'], ''); + + unset($conditions['keywords']); + } + foreach ($conditions as $field => $field_value) { $sql_where .= ' AND '; - if ($field == 'keywords') + if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1])) + { + $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; + } + else if (is_array($field_value) && isset($field_value['IN']) && is_array($field_value['IN'])) { - $sql_where .= $this->generate_sql_keyword($field_value, '', ''); + $sql_where .= $this->db->sql_in_set($field, $field_value['IN']); } else { - if (is_array($field_value) && sizeof($field_value) == 2 && !is_array($field_value[1])) - { - $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; - } - else if (is_array($field_value) && isset($field_value['IN']) && is_array($field_value['IN'])) - { - $sql_where .= $this->db->sql_in_set($field, $field_value['IN']); - } - else - { - $sql_where .= $field . ' = ' . $field_value; - } + $sql_where .= $field . ' = ' . $field_value; } } @@ -781,7 +782,7 @@ class log implements \phpbb\log\log_interface } } - $sql_keywords = $statement_operator . ' ('; + $sql_keywords = ' ' . $statement_operator . ' ('; if (!empty($operations)) { $sql_keywords .= $this->db->sql_in_set($table_alias . 'log_operation', $operations) . ' OR '; diff --git a/phpBB/posting.php b/phpBB/posting.php index 2516067aae..60bb595da6 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1546,6 +1546,7 @@ $page_data = array( 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], 'EDIT_REASON' => $request->variable('edit_reason', ''), + 'SHOW_PANEL' => $request->variable('show_panel', ''), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"), 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"), diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 52293a8f2a..ef7ca23ef4 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -117,6 +117,7 @@ jQuery(document).ready(function() { if (typeof(p) === 'string') { show_panel = p; } + $('input[name="show_panel"]').val(show_panel); for (i = 0; i < panels.length; i++) { jQuery('#' + panels[i]).css('display', panels[i] === show_panel ? 'block' : 'none'); diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index e311b85cbe..081c267a94 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -99,7 +99,7 @@ <!-- ENDIF --> <!-- IF not S_PRIVMSGS and not S_SHOW_DRAFTS and not $SIG_EDIT eq 1 --> - <div id="tabs" class="sub-panels" data-show-panel="options-panel"> + <div id="tabs" class="sub-panels" data-show-panel="<!-- IF SHOW_PANEL -->{SHOW_PANEL}<!-- ELSE -->options-panel<!-- ENDIF -->"> <ul> <li id="options-panel-tab" class="activetab"><a href="#tabs" data-subpanel="options-panel"><span>{L_OPTIONS}</span></a></li> <!-- IF S_SHOW_ATTACH_BOX --> diff --git a/phpBB/styles/prosilver/template/posting_layout.html b/phpBB/styles/prosilver/template/posting_layout.html index 4ef0954200..630afdb832 100644 --- a/phpBB/styles/prosilver/template/posting_layout.html +++ b/phpBB/styles/prosilver/template/posting_layout.html @@ -68,6 +68,7 @@ <!-- DEFINE $EXTRA_POSTING_OPTIONS = 1 --> <!-- INCLUDE posting_editor.html --> + <input type="hidden" name="show_panel" value="options-panel" /> {S_FORM_TOKEN} </div> </div> diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index b66c841d7c..a018b25ef7 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -37,7 +37,7 @@ ul.topiclist dt { } ul.topiclist.missing-column dt { - margin-right: -330px; + margin-right: -345px; } ul.topiclist.two-long-columns dt { @@ -55,7 +55,7 @@ ul.topiclist dt .list-inner { } ul.topiclist.missing-column dt .list-inner { - margin-right: 330px; + margin-right: 345px; } ul.topiclist.two-long-columns dt .list-inner { diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 385a4cfe55..789d53c676 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1809,7 +1809,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) $contact_fields = array( array( 'ID' => 'pm', - 'NAME' => $user->lang['PRIVATE_MESSAGES'], + 'NAME' => $user->lang['SEND_PRIVATE_MESSAGE'], 'U_CONTACT' => $u_pm, ), array( diff --git a/tests/log/delete_test.php b/tests/log/delete_test.php index f10e3e582b..b8be15efa5 100644 --- a/tests/log/delete_test.php +++ b/tests/log/delete_test.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2012 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -13,48 +17,141 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_log_delete_test extends phpbb_database_test_case { + protected $log; + public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/delete_log.xml'); } - public function test_log_delete() + protected function setUp() { global $phpbb_root_path, $phpEx, $db, $phpbb_dispatcher, $auth; $db = $this->new_dbal(); - $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $user = $this->getMock('\phpbb\user'); $user->data['user_id'] = 1; $auth = $this->getMock('\phpbb\auth\auth'); - $log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); - - // Delete all admin logs - $this->assertCount(2, $log->get_logs('admin')); - $log->delete('admin'); - // One entry is added to the admin log when the logs are purged - $this->assertCount(1, $log->get_logs('admin')); - - // Delete with keyword - $this->assertCount(1, $log->get_logs('mod', false, 0, 0, 0, 0, 0, 0, 'l.log_time DESC', 'guest')); - $log->delete('mod', array('keywords' => 'guest')); - $this->assertEmpty($log->get_logs('mod', false, 0, 0, 0, 0, 0, 0, 'l.log_time DESC', 'guest')); - - // Delete with simples conditions - $this->assertCount(3, $log->get_logs('mod', false, 0, 0, 12, 0, 1, 0, 'l.log_time DESC')); - $log->delete('mod', array('forum_id' => 12, 'user_id' => 1)); - $this->assertEmpty($log->get_logs('mod', false, 0, 0, 12, 0, 1, 0, 'l.log_time DESC')); - - // Delete with IN condition - $this->assertCount(2, $log->get_logs('mod', false, 0, 0, array(13, 14), 0, 0, 0, 'l.log_time DESC')); - $log->delete('mod', array('forum_id' => array('IN' => array(14, 13)))); - $this->assertEmpty($log->get_logs('mod', false, 0, 0, array(13, 14), 0, 0, 0, 'l.log_time DESC')); - - // Delete with a custom condition (ie: WHERE x >= 10) - $this->assertCount(3, $log->get_logs('critical', false, 0, 0, 0, 0, 0, 0, 'l.log_time DESC')); - $log->delete('critical', array('user_id' => array('>', 1))); - $this->assertCount(1, $log->get_logs('critical', false, 0, 0, 0, 0, 0, 0, 'l.log_time DESC')); + $this->log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + + parent::setUp(); + } + + public function log_delete_data() + { + return array( + array( + array(1, 2), + array(16), + array(), + 'admin', + false, + 0, + 0, + 0, + 0, + 0, + 0, + 'l.log_id ASC', + '', + ), + array( + array(11), + array(), + array('keywords' => 'guest'), + 'mod', + false, + 0, + 0, + 0, + 0, + 0, + 0, + 'l.log_id ASC', + 'guest', + ), + array( + array(4, 5, 7), + array(), + array('forum_id' => 12, 'user_id' => 1), + 'mod', + false, + 0, + 0, + 12, + 0, + 1, + 0, + 'l.log_id ASC', + '', + ), + array( + array(12, 13), + array(), + array('forum_id' => array('IN' => array(14, 13))), + 'mod', + false, + 0, + 0, + array(13, 14), + 0, + 0, + 0, + 'l.log_id ASC', + '', + ), + array( + array(3, 14, 15), + array(3), + array('user_id' => array('>', 1)), + 'critical', + false, + 0, + 0, + 0, + 0, + 0, + 0, + 'l.log_id ASC', + '', + ), + array( + array(3, 14, 15), + array(), + array('keywords' => ''), + 'critical', + false, + 0, + 0, + 0, + 0, + 0, + 0, + 'l.log_id ASC', + '', + ), + ); + } + + /** + * @dataProvider log_delete_data + */ + public function test_log_delete($expected_before, $expected_after, $delete_conditions, $mode, $count_logs, $limit, $offset, $forum_id, $topic_id, $user_id, $log_time, $sort_by, $keywords) + { + $this->assertSame($expected_before, $this->get_ids($this->log->get_logs($mode, $count_logs, $limit, $offset, $forum_id, $topic_id, $user_id, $log_time, $sort_by, $keywords)), 'before'); + $this->log->delete($mode, $delete_conditions); + $this->assertSame($expected_after, $this->get_ids($this->log->get_logs($mode, $count_logs, $limit, $offset, $forum_id, $topic_id, $user_id, $log_time, $sort_by, $keywords)), 'after'); + } + + public function get_ids($logs) + { + $ids = array(); + foreach ($logs as $log_entry) + { + $ids[] = (int) $log_entry['id']; + } + return $ids; } } |