mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
Modified view_logs to be used in MCP, added get_forum_list() to quickly get a set of forums the user is authed for
git-svn-id: file:///svn/phpbb/trunk@3781 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
af3512e6df
commit
3ce0f98f25
2 changed files with 133 additions and 39 deletions
|
@ -88,8 +88,8 @@ if (isset($_POST['sort']) || $start)
|
||||||
$where_sql = 0;
|
$where_sql = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sort_key = (isset($_POST['sort_key'])) ? $_POST['sort_key'] : '';
|
$sort_key = (isset($_REQUEST['sort_key'])) ? $_REQUEST['sort_key'] : '';
|
||||||
$sort_dir = (isset($_POST['sort_dir'])) ? $_POST['sort_dir'] : '';
|
$sort_dir = (isset($_REQUEST['sort_dir'])) ? $_REQUEST['sort_dir'] : '';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -172,7 +172,7 @@ if ($mode == 'mod')
|
||||||
//
|
//
|
||||||
$log_data = array();
|
$log_data = array();
|
||||||
$log_count = 0;
|
$log_count = 0;
|
||||||
view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, $where_sql, $sort_sql);
|
view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, $where_sql, $sort_sql);
|
||||||
|
|
||||||
if ($log_count)
|
if ($log_count)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,19 +24,14 @@ function make_forum_select($forum_id = false, $ignore_forum = false, $add_select
|
||||||
{
|
{
|
||||||
global $db, $user, $auth;
|
global $db, $user, $auth;
|
||||||
|
|
||||||
$sql = "SELECT forum_id, forum_name, left_id, right_id
|
|
||||||
FROM " . FORUMS_TABLE . "
|
|
||||||
ORDER BY left_id ASC";
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
$right = $cat_right = 0;
|
$right = $cat_right = 0;
|
||||||
$forum_list = $padding = $holding = '';
|
$forum_list = $padding = $holding = '';
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
$rowset = get_forum_list('f_list', FALSE, FALSE, TRUE);
|
||||||
|
foreach ($rowset as $row)
|
||||||
{
|
{
|
||||||
if (!$auth->acl_get('f_list', $row['forum_id']) || $row['forum_id'] == $ignore_forum)
|
if ($row['forum_id'] == $ignore_forum)
|
||||||
{
|
{
|
||||||
// if the user does not have permissions to list this forum skip
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,11 +75,46 @@ function make_forum_select($forum_id = false, $ignore_forum = false, $add_select
|
||||||
$forum_list = '<option value="-1">' . $user->lang['SELECT_FORUM'] . '</option><option value="-1">-----------------</option>' . $forum_list;
|
$forum_list = '<option value="-1">' . $user->lang['SELECT_FORUM'] . '</option><option value="-1">-----------------</option>' . $forum_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
return $forum_list;
|
return $forum_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtain authed forums list
|
||||||
|
function get_forum_list($acl_list = 'f_list', $id_only = TRUE, $postable_only = FALSE, $no_cache = FALSE)
|
||||||
|
{
|
||||||
|
static $forum_rows;
|
||||||
|
global $db, $auth;
|
||||||
|
|
||||||
|
if (!isset($forum_rows))
|
||||||
|
{
|
||||||
|
// This query is identical to the jumpbox one
|
||||||
|
$expire_time = ($no_cache) ? 0 : 120;
|
||||||
|
$sql = 'SELECT forum_id, forum_name, forum_postable, left_id, right_id
|
||||||
|
FROM ' . FORUMS_TABLE . '
|
||||||
|
ORDER BY left_id ASC';
|
||||||
|
$result = $db->sql_query($sql, $expire_time);
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$forum_rows[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$rowset = array();
|
||||||
|
foreach ($forum_rows as $row)
|
||||||
|
{
|
||||||
|
if ($postable_only && !$row['forum_postable'])
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($auth->acl_gets($acl_list, $row['forum_id']))
|
||||||
|
{
|
||||||
|
$rowset[] = ($id_only) ? $row['forum_id'] : $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$db->sql_freeresult();
|
||||||
|
|
||||||
|
return $rowset;
|
||||||
|
}
|
||||||
|
|
||||||
// Posts and topics manipulation
|
// Posts and topics manipulation
|
||||||
function move_topics($topic_ids, $forum_id, $auto_sync = TRUE)
|
function move_topics($topic_ids, $forum_id, $auto_sync = TRUE)
|
||||||
{
|
{
|
||||||
|
@ -120,6 +150,11 @@ function move_topics($topic_ids, $forum_id, $auto_sync = TRUE)
|
||||||
WHERE topic_id " . $where_sql;
|
WHERE topic_id " . $where_sql;
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
$sql = 'UPDATE ' . LOG_MOD_TABLE . "
|
||||||
|
SET forum_id = $forum_id
|
||||||
|
WHERE topic_id " . $where_sql;
|
||||||
|
$db->sql_query($sql);
|
||||||
|
|
||||||
if ($auto_sync)
|
if ($auto_sync)
|
||||||
{
|
{
|
||||||
sync('forum', 'forum_id', $forum_ids, TRUE);
|
sync('forum', 'forum_id', $forum_ids, TRUE);
|
||||||
|
@ -1399,52 +1434,111 @@ function add_log()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC')
|
function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC')
|
||||||
{
|
{
|
||||||
global $db, $user, $phpEx, $SID;
|
global $db, $user, $auth, $phpEx, $SID;
|
||||||
|
$topic_id_list = $is_auth = $is_mod = array();
|
||||||
|
$profile_url = (defined('IN_ADMIN')) ? "admin_users.$phpEx$SID" : "memberlist.$phpEx$SID&mode=viewprofile";
|
||||||
|
|
||||||
$table_sql = ($mode == 'admin') ? LOG_ADMIN_TABLE : LOG_MOD_TABLE;
|
if ($mode == 'admin')
|
||||||
$forum_sql = ($mode == 'mod' && $forum_id) ? "AND l.forum_id = $forum_id" : '';
|
{
|
||||||
$limit_sql = ($limit) ? (($offset) ? "LIMIT $offset, $limit" : "LIMIT $limit") : '';
|
$table_sql = LOG_ADMIN_TABLE;
|
||||||
|
$forum_sql = '';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$table_sql = LOG_MOD_TABLE;
|
||||||
|
|
||||||
$sql = "SELECT l.log_id, l.user_id, l.log_ip, l.log_time, l.log_operation, l.log_data, u.username
|
if ($topic_id)
|
||||||
|
{
|
||||||
|
$forum_sql = 'AND l.topic_id = ' . $topic_id;
|
||||||
|
}
|
||||||
|
elseif (is_array($forum_id))
|
||||||
|
{
|
||||||
|
$forum_sql = 'AND l.forum_id IN (' . implode(', ', $forum_id) . ')';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$forum_sql = ($forum_id) ? "AND l.forum_id = $forum_id" : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT l.*, u.username
|
||||||
FROM $table_sql l, " . USERS_TABLE . " u
|
FROM $table_sql l, " . USERS_TABLE . " u
|
||||||
WHERE u.user_id = l.user_id
|
WHERE u.user_id = l.user_id
|
||||||
AND l.log_time >= $limit_days
|
" . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . "
|
||||||
$forum_sql
|
$forum_sql
|
||||||
ORDER BY $sort_by
|
ORDER BY $sort_by";
|
||||||
$limit_sql";
|
$result = $db->sql_query_limit($sql, $limit, $offset);
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
$log = array();
|
$log = array();
|
||||||
if ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$i = 0;
|
if ($row['topic_id'])
|
||||||
do
|
|
||||||
{
|
{
|
||||||
|
$topic_id_list[] = $row['topic_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$log[$i]['id'] = $row['log_id'];
|
||||||
|
$log[$i]['username'] = '<a href="' . $profile_url . '&u=' . $row['user_id'] . '">' . $row['username'] . '</a>';
|
||||||
|
$log[$i]['ip'] = $row['log_ip'];
|
||||||
|
$log[$i]['time'] = $row['log_time'];
|
||||||
|
$log[$i]['forum_id'] = $row['forum_id'];
|
||||||
|
$log[$i]['topic_id'] = $row['topic_id'];
|
||||||
|
|
||||||
|
$log[$i]['action'] = (!empty($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : ucfirst(str_replace('_', ' ', $row['log_operation']));
|
||||||
|
|
||||||
|
if (!empty($row['log_data']))
|
||||||
|
{
|
||||||
|
<<<<<<< functions_admin.php
|
||||||
|
$log_data_ary = unserialize(stripslashes($row['log_data']));
|
||||||
|
|
||||||
|
foreach ($log_data_ary as $log_data)
|
||||||
|
{
|
||||||
|
$log[$i]['action'] = preg_replace('#%s#', $log_data, $log[$i]['action'], 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
=======
|
||||||
$log[$i]['id'] = $row['log_id'];
|
$log[$i]['id'] = $row['log_id'];
|
||||||
$log[$i]['username'] = '<a href="admin_users.' . $phpEx . $SID . '&u=' . $row['user_id'] . '">' . $row['username'] . '</a>';
|
$log[$i]['username'] = '<a href="admin_users.' . $phpEx . $SID . '&u=' . $row['user_id'] . '">' . $row['username'] . '</a>';
|
||||||
$log[$i]['ip'] = $row['log_ip'];
|
$log[$i]['ip'] = $row['log_ip'];
|
||||||
$log[$i]['time'] = $row['log_time'];
|
$log[$i]['time'] = $row['log_time'];
|
||||||
|
>>>>>>> 1.30
|
||||||
|
|
||||||
$log[$i]['action'] = (!empty($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : ucfirst(str_replace('_', ' ', $row['log_operation']));
|
$i++;
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
if (!empty($row['log_data']))
|
|
||||||
|
if (count($topic_id_list))
|
||||||
|
{
|
||||||
|
// This query is not really needed if move_topics() updates the forum_id field, altough it's also used to determine if the topic still exists in the database
|
||||||
|
$sql = 'SELECT topic_id, forum_id
|
||||||
|
FROM ' . TOPICS_TABLE . '
|
||||||
|
WHERE topic_id IN (' . implode(', ', $topic_id_list) . ')';
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
if ($auth->acl_get('f_read', $row['forum_id']))
|
||||||
{
|
{
|
||||||
$log_data_ary = unserialize(stripslashes($row['log_data']));
|
// DEBUG!!
|
||||||
|
$config['default_forum_id'] = 2;
|
||||||
foreach ($log_data_ary as $log_data)
|
$is_auth[$row['topic_id']] = ($row['forum_id']) ? $row['forum_id'] : $config['default_forum_id'];
|
||||||
{
|
|
||||||
$log[$i]['action'] = preg_replace('#%s#', $log_data, $log[$i]['action'], 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
if ($auth->acl_gets('a_general', 'm_', $row['forum_id']))
|
||||||
|
{
|
||||||
|
$is_mod[$row['topic_id']] = $row['forum_id'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while ($row = $db->sql_fetchrow($result));
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->sql_freeresult($result);
|
foreach ($log as $key => $row)
|
||||||
|
{
|
||||||
|
$log[$key]['viewtopic'] = (isset($is_auth[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "viewtopic.$phpEx$SID&f=" . $is_auth[$row['topic_id']] . '&t=' . $row['topic_id'] : '';
|
||||||
|
$log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "mcp.$phpEx$SID&mode=viewlogs&t=" . $row['topic_id'] : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT COUNT(*) AS total_entries
|
$sql = "SELECT COUNT(*) AS total_entries
|
||||||
FROM $table_sql l
|
FROM $table_sql l
|
||||||
|
|
Loading…
Add table
Reference in a new issue