1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-21 16:22:22 +02:00

Merge pull request #3870 from Zoddo/ticket/9485

[ticket/9485] Add a "View post" link in the moderation logs

* Zoddo/ticket/9485:
  [ticket/9485] Fix tests
  [ticket/9485] Add post_id to relevant $phpbb_log->add()
  [ticket/9485] Add a "View post" link in the moderation logs
This commit is contained in:
Tristan Darricau 2015-09-09 11:04:13 +02:00
commit 542d75b3a9
14 changed files with 107 additions and 2 deletions

View File

@ -1700,6 +1700,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_EDITED', false, array(
'forum_id' => $data['forum_id'],
'topic_id' => $data['topic_id'],
'post_id' => $data['post_id'],
$log_subject,
(!empty($username)) ? $username : $user->lang['GUEST'],
$data['post_edit_reason']
@ -2666,6 +2667,7 @@ function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), false, array(
'forum_id' => $forum_id,
'topic_id' => $topic_id,
'post_id' => $post_id,
$post_data['post_subject'],
$post_username,
$delete_reason

View File

@ -205,7 +205,7 @@ class mcp_logs
{
$data = array();
$checks = array('viewtopic', 'viewforum');
$checks = array('viewpost', 'viewtopic', 'viewforum');
foreach ($checks as $check)
{
if (isset($row[$check]) && $row[$check])

View File

@ -322,6 +322,7 @@ function lock_unlock($action, $ids)
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_' . strtoupper($action), false, array(
'forum_id' => $row['forum_id'],
'topic_id' => $row['topic_id'],
'post_id' => isset($row['post_id']) ? $row['post_id'] : 0,
$row['topic_title']
));
}
@ -1022,6 +1023,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SOFTDELETE_POST', false, array(
'forum_id' => $row['forum_id'],
'topic_id' => $row['topic_id'],
'post_id' => $row['post_id'],
$row['post_subject'],
$post_username,
$soft_delete_reason
@ -1071,6 +1073,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_POST', false, array(
'forum_id' => $row['forum_id'],
'topic_id' => $row['topic_id'],
'post_id' => $row['post_id'],
$row['post_subject'],
$post_username,
$soft_delete_reason

View File

@ -574,6 +574,7 @@ function change_poster(&$post_info, $userdata)
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_MCP_CHANGE_POSTER', false, array(
'forum_id' => $post_info['forum_id'],
'topic_id' => $post_info['topic_id'],
'post_id' => $post_info['post_id'],
$post_info['topic_title'],
$from_username,
$to_username

View File

@ -678,6 +678,7 @@ class mcp_queue
$approve_log[] = array(
'forum_id' => $post_data['forum_id'],
'topic_id' => $post_data['topic_id'],
'post_id' => $post_id,
'post_subject' => $post_data['post_subject'],
);
}
@ -694,6 +695,7 @@ class mcp_queue
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_' . strtoupper($action) . 'D', false, array(
'forum_id' => $log_data['forum_id'],
'topic_id' => $log_data['topic_id'],
'post_id' => $log_data['post_id'],
$log_data['post_subject']
));
}

View File

@ -716,6 +716,7 @@ function close_report($report_id_list, $mode, $action, $pm = false)
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_REPORT_' . strtoupper($action) . 'D', false, array(
'forum_id' => $post_info[$report['post_id']]['forum_id'],
'topic_id' => $post_info[$report['post_id']]['topic_id'],
'post_id' => $report['post_id'],
$post_info[$report['post_id']]['post_subject']
));
$phpbb_notifications->delete_notifications('notification.type.report_post', $report['post_id']);

View File

@ -589,6 +589,7 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0)
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_WARNING', false, array(
'forum_id' => $row['forum_id'],
'topic_id' => $row['topic_id'],
'post_id' => $post_id,
$user_row['username']
));
}

View File

@ -135,6 +135,7 @@ $lang = array_merge($lang, array(
'LOCK_TOPICS_CONFIRM' => 'Are you sure you want to lock all selected topics?',
'LOGS_CURRENT_TOPIC' => 'Currently viewing logs of:',
'LOGIN_EXPLAIN_MCP' => 'To moderate this forum you must login.',
'LOGVIEW_VIEWPOST' => 'View post',
'LOGVIEW_VIEWTOPIC' => 'View topic',
'LOGVIEW_VIEWLOGS' => 'View topic log',
'LOGVIEW_VIEWFORUM' => 'View forum',

View File

@ -0,0 +1,44 @@
<?php
/**
*
* 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.
*
*/
namespace phpbb\db\migration\data\v320;
class log_post_id extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\dev');
}
public function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'log' => array(
'post_id' => array('UINT', 0, 'after' => 'topic_id'),
),
),
);
}
public function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'log' => array(
'post_id',
),
),
);
}
}

View File

@ -249,10 +249,13 @@ class log implements \phpbb\log\log_interface
unset($additional_data['forum_id']);
$topic_id = isset($additional_data['topic_id']) ? (int) $additional_data['topic_id'] : 0;
unset($additional_data['topic_id']);
$post_id = isset($additional_data['post_id']) ? (int) $additional_data['post_id'] : 0;
unset($additional_data['post_id']);
$sql_ary += array(
'log_type' => LOG_MOD,
'forum_id' => $forum_id,
'topic_id' => $topic_id,
'post_id' => $post_id,
'log_data' => (!empty($additional_data)) ? serialize($additional_data) : '',
);
break;
@ -417,7 +420,7 @@ class log implements \phpbb\log\log_interface
$this->entry_count = 0;
$this->last_page_offset = $offset;
$topic_id_list = $reportee_id_list = array();
$post_id_list = $topic_id_list = $reportee_id_list = array();
$profile_url = ($this->get_is_admin() && $this->phpbb_admin_path) ? append_sid("{$this->phpbb_admin_path}index.{$this->php_ext}", 'i=users&amp;mode=overview') : append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile');
@ -643,6 +646,7 @@ class log implements \phpbb\log\log_interface
'time' => (int) $row['log_time'],
'forum_id' => (int) $row['forum_id'],
'topic_id' => (int) $row['topic_id'],
'post_id' => (int) $row['post_id'],
'viewforum' => ($row['forum_id'] && $this->auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']) : false,
'action' => (isset($this->user->lang[$row['log_operation']])) ? $row['log_operation'] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}',
@ -743,6 +747,7 @@ class log implements \phpbb\log\log_interface
foreach ($log as $key => $row)
{
$log[$key]['viewtopic'] = (isset($topic_auth['f_read'][$row['topic_id']])) ? append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $topic_auth['f_read'][$row['topic_id']] . '&amp;t=' . $row['topic_id']) : false;
$log[$key]['viewpost'] = (isset($topic_auth['f_read'][$row['topic_id']]) && $row['post_id']) ? append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $topic_auth['f_read'][$row['topic_id']] . '&amp;t=' . $row['topic_id'] . '&amp;p=' . $row['post_id']) : false;
$log[$key]['viewlogs'] = (isset($topic_auth['m_'][$row['topic_id']])) ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=logs&amp;mode=topic_logs&amp;t=' . $row['topic_id'], true, $this->user->session_id) : false;
}
}

View File

@ -6,6 +6,7 @@
<column>user_id</column>
<column>forum_id</column>
<column>topic_id</column>
<column>post_id</column>
<column>reportee_id</column>
<column>log_ip</column>
<column>log_time</column>
@ -18,6 +19,7 @@
<value>0</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_INSTALL_INSTALLED</value>
@ -30,6 +32,7 @@
<value>0</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_KEY_NOT_EXISTS</value>
@ -42,6 +45,7 @@
<value>0</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_CRITICAL</value>
@ -54,6 +58,7 @@
<value>12</value>
<value>34</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_MOD</value>
@ -66,6 +71,7 @@
<value>12</value>
<value>45</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_MOD</value>
@ -78,6 +84,7 @@
<value>23</value>
<value>56</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_MOD</value>
@ -90,6 +97,7 @@
<value>12</value>
<value>45</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_MOD2</value>
@ -101,6 +109,7 @@
<value>1</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>2</value>
<value>127.0.0.1</value>
<value>1</value>
@ -113,6 +122,7 @@
<value>1</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>1</value>
<value>127.0.0.1</value>
<value>1</value>
@ -126,6 +136,7 @@
<value>0</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_SINGULAR_PLURAL</value>
@ -138,6 +149,7 @@
<value>15</value>
<value>3</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_MOD3</value>
@ -150,6 +162,7 @@
<value>13</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value></value>
@ -162,6 +175,7 @@
<value>14</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value></value>
@ -174,6 +188,7 @@
<value>0</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value></value>
@ -186,6 +201,7 @@
<value>0</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value></value>

View File

@ -6,6 +6,7 @@
<column>user_id</column>
<column>forum_id</column>
<column>topic_id</column>
<column>post_id</column>
<column>reportee_id</column>
<column>log_ip</column>
<column>log_time</column>

View File

@ -6,6 +6,7 @@
<column>user_id</column>
<column>forum_id</column>
<column>topic_id</column>
<column>post_id</column>
<column>reportee_id</column>
<column>log_ip</column>
<column>log_time</column>
@ -18,6 +19,7 @@
<value>0</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_INSTALL_INSTALLED</value>
@ -30,6 +32,7 @@
<value>0</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_KEY_NOT_EXISTS</value>
@ -42,6 +45,7 @@
<value>0</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_CRITICAL</value>
@ -54,6 +58,7 @@
<value>12</value>
<value>34</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_MOD</value>
@ -66,6 +71,7 @@
<value>12</value>
<value>45</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_MOD</value>
@ -78,6 +84,7 @@
<value>23</value>
<value>56</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_MOD</value>
@ -90,6 +97,7 @@
<value>12</value>
<value>45</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_MOD2</value>
@ -101,6 +109,7 @@
<value>1</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>2</value>
<value>127.0.0.1</value>
<value>1</value>
@ -113,6 +122,7 @@
<value>1</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>1</value>
<value>127.0.0.1</value>
<value>1</value>
@ -126,6 +136,7 @@
<value>0</value>
<value>0</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_SINGULAR_PLURAL</value>
@ -138,6 +149,7 @@
<value>15</value>
<value>3</value>
<value>0</value>
<value>0</value>
<value>127.0.0.1</value>
<value>1</value>
<value>LOG_MOD3</value>

View File

@ -46,6 +46,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 0,
'topic_id' => 0,
'post_id' => 0,
'viewforum' => '',
'action' => 'LOG_INSTALL_INSTALLED 3.1.0-dev',
@ -65,6 +66,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 0,
'topic_id' => 0,
'post_id' => 0,
'viewforum' => '',
'action' => '{LOG KEY NOT EXISTS}<br />additional_data',
@ -84,6 +86,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 0,
'topic_id' => 0,
'post_id' => 0,
'viewforum' => '',
'action' => '{LOG CRITICAL}<br />critical data',
@ -103,10 +106,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 12,
'topic_id' => 34,
'post_id' => 0,
'viewforum' => '',
'action' => '{LOG MOD}',
'viewtopic' => '',
'viewpost' => '',
'viewlogs' => '',
),
5 => array(
@ -124,10 +129,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 12,
'topic_id' => 45,
'post_id' => 0,
'viewforum' => '',
'action' => '{LOG MOD}',
'viewtopic' => '',
'viewpost' => '',
'viewlogs' => '',
),
6 => array(
@ -145,10 +152,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 23,
'topic_id' => 56,
'post_id' => 0,
'viewforum' => append_sid("phpBB/viewforum.$phpEx", 'f=23'),
'action' => '{LOG MOD}',
'viewtopic' => append_sid("phpBB/viewtopic.$phpEx", 'f=23&amp;t=56'),
'viewpost' => '',
'viewlogs' => append_sid("phpBB/mcp.$phpEx", 'i=logs&amp;mode=topic_logs&amp;t=56'),
),
7 => array(
@ -166,10 +175,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 12,
'topic_id' => 45,
'post_id' => 0,
'viewforum' => '',
'action' => 'LOG_MOD2',
'viewtopic' => '',
'viewpost' => '',
'viewlogs' => '',
),
8 => array(
@ -187,6 +198,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 0,
'topic_id' => 0,
'post_id' => 0,
'viewforum' => '',
'action' => 'LOG_USER admin',
@ -206,6 +218,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 0,
'topic_id' => 0,
'post_id' => 0,
'viewforum' => '',
'action' => 'LOG_USER guest',
@ -225,6 +238,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 0,
'topic_id' => 0,
'post_id' => 0,
'viewforum' => '',
'action' => 'LOG_SINGULAR_PLURAL 2',
@ -244,10 +258,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'time' => 1,
'forum_id' => 15,
'topic_id' => 3,
'post_id' => 0,
'viewforum' => '',
'action' => 'LOG_MOD3 guest ',
'viewtopic' => '',
'viewpost' => '',
'viewlogs' => '',
),
);