diff options
-rw-r--r-- | phpBB/adm/admin_viewlogs.php | 6 | ||||
-rw-r--r-- | phpBB/includes/functions_admin.php | 164 |
2 files changed, 132 insertions, 38 deletions
diff --git a/phpBB/adm/admin_viewlogs.php b/phpBB/adm/admin_viewlogs.php index e544fd144a..c64549c85b 100644 --- a/phpBB/adm/admin_viewlogs.php +++ b/phpBB/adm/admin_viewlogs.php @@ -88,8 +88,8 @@ if (isset($_POST['sort']) || $start) $where_sql = 0; } - $sort_key = (isset($_POST['sort_key'])) ? $_POST['sort_key'] : ''; - $sort_dir = (isset($_POST['sort_dir'])) ? $_POST['sort_dir'] : ''; + $sort_key = (isset($_REQUEST['sort_key'])) ? $_REQUEST['sort_key'] : ''; + $sort_dir = (isset($_REQUEST['sort_dir'])) ? $_REQUEST['sort_dir'] : ''; } else { @@ -172,7 +172,7 @@ if ($mode == 'mod') // $log_data = array(); $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) { diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index f8eadeafc2..ea7404cbdc 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -24,19 +24,14 @@ function make_forum_select($forum_id = false, $ignore_forum = false, $add_select { 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; $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; } @@ -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; } - $db->sql_freeresult($result); - 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 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; $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) { sync('forum', 'forum_id', $forum_ids, TRUE); @@ -1399,53 +1434,112 @@ function add_log() 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; - $forum_sql = ($mode == 'mod' && $forum_id) ? "AND l.forum_id = $forum_id" : ''; - $limit_sql = ($limit) ? (($offset) ? "LIMIT $offset, $limit" : "LIMIT $limit") : ''; + if ($mode == 'admin') + { + $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 WHERE u.user_id = l.user_id - AND l.log_time >= $limit_days + " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . " $forum_sql - ORDER BY $sort_by - $limit_sql"; - $result = $db->sql_query($sql); + ORDER BY $sort_by"; + $result = $db->sql_query_limit($sql, $limit, $offset); + $i = 0; $log = array(); - if ($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { - $i = 0; - do + if ($row['topic_id']) { + $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]['username'] = '<a href="admin_users.' . $phpEx . $SID . '&u=' . $row['user_id'] . '">' . $row['username'] . '</a>'; $log[$i]['ip'] = $row['log_ip']; $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; + $is_auth[$row['topic_id']] = ($row['forum_id']) ? $row['forum_id'] : $config['default_forum_id']; + } - foreach ($log_data_ary as $log_data) - { - $log[$i]['action'] = preg_replace('#%s#', $log_data, $log[$i]['action'], 1); - } + if ($auth->acl_gets('a_general', 'm_', $row['forum_id'])) + { + $is_mod[$row['topic_id']] = $row['forum_id']; } + } - $i++; + 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'] : ''; } - while ($row = $db->sql_fetchrow($result)); } - $db->sql_freeresult($result); - $sql = "SELECT COUNT(*) AS total_entries FROM $table_sql l WHERE l.log_time >= $limit_days |