mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 22:08:54 +00:00
Merge remote-tracking branch 'github-nickvergessen/ticket/12612-ascraeus' into develop-ascraeus
* github-nickvergessen/ticket/12612-ascraeus: [ticket/12612] Move functions from mcp.php to functions_mcp.php [ticket/12612] Move function from ucp.php to functions_user.php [ticket/12612] Move functions from memberlist.php to functions_display.php [ticket/12612] Move functions from posting.php to functions_posting.php
This commit is contained in:
commit
1f9e1fd177
8 changed files with 984 additions and 963 deletions
|
@ -1444,3 +1444,166 @@ function phpbb_gen_download_links($param_key, $param_val, $phpbb_root_path, $php
|
|||
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare profile data
|
||||
*/
|
||||
function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false)
|
||||
{
|
||||
global $config, $auth, $template, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher;
|
||||
|
||||
$username = $data['username'];
|
||||
$user_id = $data['user_id'];
|
||||
|
||||
$rank_title = $rank_img = $rank_img_src = '';
|
||||
get_user_rank($data['user_rank'], (($user_id == ANONYMOUS) ? false : $data['user_posts']), $rank_title, $rank_img, $rank_img_src);
|
||||
|
||||
if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user'))
|
||||
{
|
||||
$email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$email = '';
|
||||
}
|
||||
|
||||
if ($config['load_onlinetrack'])
|
||||
{
|
||||
$update_time = $config['load_online_time'] * 60;
|
||||
$online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$online = false;
|
||||
}
|
||||
|
||||
if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
|
||||
{
|
||||
$last_active = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_active = '';
|
||||
}
|
||||
|
||||
$age = '';
|
||||
|
||||
if ($config['allow_birthdays'] && $data['user_birthday'])
|
||||
{
|
||||
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));
|
||||
|
||||
if ($bday_year)
|
||||
{
|
||||
$now = $user->create_datetime();
|
||||
$now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
|
||||
|
||||
$diff = $now['mon'] - $bday_month;
|
||||
if ($diff == 0)
|
||||
{
|
||||
$diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$diff = ($diff < 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
$age = max(0, (int) ($now['year'] - $bday_year - $diff));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('phpbb_get_banned_user_ids'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||
}
|
||||
|
||||
// Can this user receive a Private Message?
|
||||
$can_receive_pm = (
|
||||
// They must be a "normal" user
|
||||
$data['user_type'] != USER_IGNORE &&
|
||||
|
||||
// They must not be deactivated by the administrator
|
||||
($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) &&
|
||||
|
||||
// They must be able to read PMs
|
||||
sizeof($auth->acl_get_list($user_id, 'u_readpm')) &&
|
||||
|
||||
// They must not be permanently banned
|
||||
!sizeof(phpbb_get_banned_user_ids($user_id, false)) &&
|
||||
|
||||
// They must allow users to contact via PM
|
||||
(($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm'])
|
||||
);
|
||||
|
||||
// Dump it out to the template
|
||||
$template_data = array(
|
||||
'AGE' => $age,
|
||||
'RANK_TITLE' => $rank_title,
|
||||
'JOINED' => $user->format_date($data['user_regdate']),
|
||||
'LAST_ACTIVE' => (empty($last_active)) ? ' - ' : $user->format_date($last_active),
|
||||
'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0,
|
||||
'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0,
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']),
|
||||
'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']),
|
||||
'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']),
|
||||
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']),
|
||||
|
||||
'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])),
|
||||
|
||||
'AVATAR_IMG' => phpbb_get_user_avatar($data),
|
||||
'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
|
||||
'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false,
|
||||
'RANK_IMG' => $rank_img,
|
||||
'RANK_IMG_SRC' => $rank_img_src,
|
||||
'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false,
|
||||
|
||||
'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false,
|
||||
|
||||
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '',
|
||||
'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '',
|
||||
'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '',
|
||||
'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '',
|
||||
'U_EMAIL' => $email,
|
||||
'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '',
|
||||
|
||||
'USER_JABBER' => $data['user_jabber'],
|
||||
'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',
|
||||
|
||||
'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username),
|
||||
'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username),
|
||||
'L_VIEWING_PROFILE' => $user->lang('VIEWING_PROFILE', $username),
|
||||
);
|
||||
|
||||
/**
|
||||
* Preparing a user's data before displaying it in profile and memberlist
|
||||
*
|
||||
* @event core.memberlist_prepare_profile_data
|
||||
* @var array data Array with user's data
|
||||
* @var array template_data Template array with user's data
|
||||
* @since 3.1.0-a1
|
||||
*/
|
||||
$vars = array('data', 'template_data');
|
||||
extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars)));
|
||||
|
||||
return $template_data;
|
||||
}
|
||||
|
||||
function _sort_last_active($first, $second)
|
||||
{
|
||||
global $id_cache, $sort_dir;
|
||||
|
||||
$lesser_than = ($sort_dir === 'd') ? -1 : 1;
|
||||
|
||||
if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader']))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader'])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']);
|
||||
}
|
||||
}
|
||||
|
|
666
phpBB/includes/functions_mcp.php
Normal file
666
phpBB/includes/functions_mcp.php
Normal file
|
@ -0,0 +1,666 @@
|
|||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions used to generate additional URL paramters
|
||||
*/
|
||||
function _module__url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_notes_url($mode, &$module_row)
|
||||
{
|
||||
if ($mode == 'front')
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
global $user_id;
|
||||
return ($user_id) ? "&u=$user_id" : '';
|
||||
}
|
||||
|
||||
function _module_warn_url($mode, &$module_row)
|
||||
{
|
||||
if ($mode == 'front' || $mode == 'list')
|
||||
{
|
||||
global $forum_id;
|
||||
|
||||
return ($forum_id) ? "&f=$forum_id" : '';
|
||||
}
|
||||
|
||||
if ($mode == 'warn_post')
|
||||
{
|
||||
global $forum_id, $post_id;
|
||||
|
||||
$url_extra = ($forum_id) ? "&f=$forum_id" : '';
|
||||
$url_extra .= ($post_id) ? "&p=$post_id" : '';
|
||||
|
||||
return $url_extra;
|
||||
}
|
||||
else
|
||||
{
|
||||
global $user_id;
|
||||
|
||||
return ($user_id) ? "&u=$user_id" : '';
|
||||
}
|
||||
}
|
||||
|
||||
function _module_main_url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_logs_url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_ban_url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_queue_url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_reports_url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function extra_url()
|
||||
{
|
||||
global $forum_id, $topic_id, $post_id, $report_id, $user_id;
|
||||
|
||||
$url_extra = '';
|
||||
$url_extra .= ($forum_id) ? "&f=$forum_id" : '';
|
||||
$url_extra .= ($topic_id) ? "&t=$topic_id" : '';
|
||||
$url_extra .= ($post_id) ? "&p=$post_id" : '';
|
||||
$url_extra .= ($user_id) ? "&u=$user_id" : '';
|
||||
$url_extra .= ($report_id) ? "&r=$report_id" : '';
|
||||
|
||||
return $url_extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get simple topic data
|
||||
*/
|
||||
function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false)
|
||||
{
|
||||
global $auth, $db, $config, $user;
|
||||
static $rowset = array();
|
||||
|
||||
$topics = array();
|
||||
|
||||
if (!sizeof($topic_ids))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
// cache might not contain read tracking info, so we can't use it if read
|
||||
// tracking information is requested
|
||||
if (!$read_tracking)
|
||||
{
|
||||
$cache_topic_ids = array_intersect($topic_ids, array_keys($rowset));
|
||||
$topic_ids = array_diff($topic_ids, array_keys($rowset));
|
||||
}
|
||||
else
|
||||
{
|
||||
$cache_topic_ids = array();
|
||||
}
|
||||
|
||||
if (sizeof($topic_ids))
|
||||
{
|
||||
$sql_array = array(
|
||||
'SELECT' => 't.*, f.*',
|
||||
|
||||
'FROM' => array(
|
||||
TOPICS_TABLE => 't',
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(FORUMS_TABLE => 'f'),
|
||||
'ON' => 'f.forum_id = t.forum_id'
|
||||
)
|
||||
),
|
||||
|
||||
'WHERE' => $db->sql_in_set('t.topic_id', $topic_ids)
|
||||
);
|
||||
|
||||
if ($read_tracking && $config['load_db_lastread'])
|
||||
{
|
||||
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
|
||||
|
||||
$sql_array['LEFT_JOIN'][] = array(
|
||||
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
|
||||
'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
|
||||
);
|
||||
|
||||
$sql_array['LEFT_JOIN'][] = array(
|
||||
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
|
||||
);
|
||||
}
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rowset[$row['topic_id']] = $row;
|
||||
|
||||
if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$topics[$row['topic_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
foreach ($cache_topic_ids as $id)
|
||||
{
|
||||
if (!$acl_list || $auth->acl_gets($acl_list, $rowset[$id]['forum_id']))
|
||||
{
|
||||
$topics[$id] = $rowset[$id];
|
||||
}
|
||||
}
|
||||
|
||||
return $topics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get simple post data
|
||||
*/
|
||||
function get_post_data($post_ids, $acl_list = false, $read_tracking = false)
|
||||
{
|
||||
global $db, $auth, $config, $user;
|
||||
|
||||
$rowset = array();
|
||||
|
||||
if (!sizeof($post_ids))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql_array = array(
|
||||
'SELECT' => 'p.*, u.*, t.*, f.*',
|
||||
|
||||
'FROM' => array(
|
||||
USERS_TABLE => 'u',
|
||||
POSTS_TABLE => 'p',
|
||||
TOPICS_TABLE => 't',
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(FORUMS_TABLE => 'f'),
|
||||
'ON' => 'f.forum_id = t.forum_id'
|
||||
)
|
||||
),
|
||||
|
||||
'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . '
|
||||
AND u.user_id = p.poster_id
|
||||
AND t.topic_id = p.topic_id',
|
||||
);
|
||||
|
||||
if ($read_tracking && $config['load_db_lastread'])
|
||||
{
|
||||
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
|
||||
|
||||
$sql_array['LEFT_JOIN'][] = array(
|
||||
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
|
||||
'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
|
||||
);
|
||||
|
||||
$sql_array['LEFT_JOIN'][] = array(
|
||||
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
|
||||
);
|
||||
}
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
$result = $db->sql_query($sql);
|
||||
unset($sql_array);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($row['post_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $row['forum_id']))
|
||||
{
|
||||
// Moderators without the permission to approve post should at least not see them. ;)
|
||||
continue;
|
||||
}
|
||||
|
||||
$rowset[$row['post_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $rowset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get simple forum data
|
||||
*/
|
||||
function get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false)
|
||||
{
|
||||
global $auth, $db, $user, $config, $phpbb_container;
|
||||
|
||||
$rowset = array();
|
||||
|
||||
if (!is_array($forum_id))
|
||||
{
|
||||
$forum_id = array($forum_id);
|
||||
}
|
||||
|
||||
if (!sizeof($forum_id))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($read_tracking && $config['load_db_lastread'])
|
||||
{
|
||||
$read_tracking_join = ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
|
||||
AND ft.forum_id = f.forum_id)';
|
||||
$read_tracking_select = ', ft.mark_time';
|
||||
}
|
||||
else
|
||||
{
|
||||
$read_tracking_join = $read_tracking_select = '';
|
||||
}
|
||||
|
||||
$sql = "SELECT f.* $read_tracking_select
|
||||
FROM " . FORUMS_TABLE . " f$read_tracking_join
|
||||
WHERE " . $db->sql_in_set('f.forum_id', $forum_id);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$row['forum_topics_approved'] = $phpbb_content_visibility->get_count('forum_topics', $row, $row['forum_id']);
|
||||
|
||||
$rowset[$row['forum_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $rowset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get simple pm data
|
||||
*/
|
||||
function get_pm_data($pm_ids)
|
||||
{
|
||||
global $db, $auth, $config, $user;
|
||||
|
||||
$rowset = array();
|
||||
|
||||
if (!sizeof($pm_ids))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql_array = array(
|
||||
'SELECT' => 'p.*, u.*',
|
||||
|
||||
'FROM' => array(
|
||||
USERS_TABLE => 'u',
|
||||
PRIVMSGS_TABLE => 'p',
|
||||
),
|
||||
|
||||
'WHERE' => $db->sql_in_set('p.msg_id', $pm_ids) . '
|
||||
AND u.user_id = p.author_id',
|
||||
);
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
$result = $db->sql_query($sql);
|
||||
unset($sql_array);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rowset[$row['msg_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $rowset;
|
||||
}
|
||||
|
||||
/**
|
||||
* sorting in mcp
|
||||
*
|
||||
* @param string $where_sql should either be WHERE (default if ommited) or end with AND or OR
|
||||
*
|
||||
* $mode reports and reports_closed: the $where parameters uses aliases p for posts table and r for report table
|
||||
* $mode unapproved_posts: the $where parameters uses aliases p for posts table and t for topic table
|
||||
*/
|
||||
function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, &$sort_order_sql, &$total, $forum_id = 0, $topic_id = 0, $where_sql = 'WHERE')
|
||||
{
|
||||
global $db, $user, $auth, $template;
|
||||
|
||||
$sort_days = request_var('st', 0);
|
||||
$min_time = ($sort_days) ? time() - ($sort_days * 86400) : 0;
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case 'viewforum':
|
||||
$type = 'topics';
|
||||
$default_key = 't';
|
||||
$default_dir = 'd';
|
||||
|
||||
$sql = 'SELECT COUNT(topic_id) AS total
|
||||
FROM ' . TOPICS_TABLE . "
|
||||
$where_sql forum_id = $forum_id
|
||||
AND topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")
|
||||
AND topic_last_post_time >= $min_time";
|
||||
|
||||
if (!$auth->acl_get('m_approve', $forum_id))
|
||||
{
|
||||
$sql .= 'AND topic_visibility = ' . ITEM_APPROVED;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'viewtopic':
|
||||
$type = 'posts';
|
||||
$default_key = 't';
|
||||
$default_dir = 'a';
|
||||
|
||||
$sql = 'SELECT COUNT(post_id) AS total
|
||||
FROM ' . POSTS_TABLE . "
|
||||
$where_sql topic_id = $topic_id
|
||||
AND post_time >= $min_time";
|
||||
|
||||
if (!$auth->acl_get('m_approve', $forum_id))
|
||||
{
|
||||
$sql .= 'AND post_visibility = ' . ITEM_APPROVED;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'unapproved_posts':
|
||||
case 'deleted_posts':
|
||||
$visibility_const = ($mode == 'unapproved_posts') ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
|
||||
$type = 'posts';
|
||||
$default_key = 't';
|
||||
$default_dir = 'd';
|
||||
$where_sql .= ($topic_id) ? ' p.topic_id = ' . $topic_id . ' AND' : '';
|
||||
|
||||
$sql = 'SELECT COUNT(p.post_id) AS total
|
||||
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
|
||||
$where_sql " . $db->sql_in_set('p.forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
|
||||
AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) .'
|
||||
AND t.topic_id = p.topic_id
|
||||
AND t.topic_visibility <> p.post_visibility';
|
||||
|
||||
if ($min_time)
|
||||
{
|
||||
$sql .= ' AND post_time >= ' . $min_time;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'unapproved_topics':
|
||||
case 'deleted_topics':
|
||||
$visibility_const = ($mode == 'unapproved_topics') ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
|
||||
$type = 'topics';
|
||||
$default_key = 't';
|
||||
$default_dir = 'd';
|
||||
|
||||
$sql = 'SELECT COUNT(topic_id) AS total
|
||||
FROM ' . TOPICS_TABLE . "
|
||||
$where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
|
||||
AND ' . $db->sql_in_set('topic_visibility', $visibility_const);
|
||||
|
||||
if ($min_time)
|
||||
{
|
||||
$sql .= ' AND topic_time >= ' . $min_time;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'pm_reports':
|
||||
case 'pm_reports_closed':
|
||||
case 'reports':
|
||||
case 'reports_closed':
|
||||
$pm = (strpos($mode, 'pm_') === 0) ? true : false;
|
||||
|
||||
$type = ($pm) ? 'pm_reports' : 'reports';
|
||||
$default_key = 't';
|
||||
$default_dir = 'd';
|
||||
$limit_time_sql = ($min_time) ? "AND r.report_time >= $min_time" : '';
|
||||
|
||||
if ($topic_id)
|
||||
{
|
||||
$where_sql .= ' p.topic_id = ' . $topic_id . ' AND ';
|
||||
}
|
||||
else if ($forum_id)
|
||||
{
|
||||
$where_sql .= ' p.forum_id = ' . $forum_id . ' AND ';
|
||||
}
|
||||
else if (!$pm)
|
||||
{
|
||||
$where_sql .= ' ' . $db->sql_in_set('p.forum_id', get_forum_list(array('!f_read', '!m_report')), true, true) . ' AND ';
|
||||
}
|
||||
|
||||
if ($mode == 'reports' || $mode == 'pm_reports')
|
||||
{
|
||||
$where_sql .= ' r.report_closed = 0 AND ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$where_sql .= ' r.report_closed = 1 AND ';
|
||||
}
|
||||
|
||||
if ($pm)
|
||||
{
|
||||
$sql = 'SELECT COUNT(r.report_id) AS total
|
||||
FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . " p
|
||||
$where_sql r.post_id = 0
|
||||
AND p.msg_id = r.pm_id
|
||||
$limit_time_sql";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT COUNT(r.report_id) AS total
|
||||
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . " p
|
||||
$where_sql r.pm_id = 0
|
||||
AND p.post_id = r.post_id
|
||||
$limit_time_sql";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'viewlogs':
|
||||
$type = 'logs';
|
||||
$default_key = 't';
|
||||
$default_dir = 'd';
|
||||
|
||||
$sql = 'SELECT COUNT(log_id) AS total
|
||||
FROM ' . LOG_TABLE . "
|
||||
$where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_'))) . '
|
||||
AND log_time >= ' . $min_time . '
|
||||
AND log_type = ' . LOG_MOD;
|
||||
break;
|
||||
}
|
||||
|
||||
$sort_key = request_var('sk', $default_key);
|
||||
$sort_dir = request_var('sd', $default_dir);
|
||||
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'topics':
|
||||
$limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'tt' => $user->lang['TOPIC_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
|
||||
|
||||
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'tt' => 't.topic_time', 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 't.topic_title', 'v' => 't.topic_views');
|
||||
$limit_time_sql = ($min_time) ? "AND t.topic_last_post_time >= $min_time" : '';
|
||||
break;
|
||||
|
||||
case 'posts':
|
||||
$limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
|
||||
$sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.post_time', 's' => 'p.post_subject');
|
||||
$limit_time_sql = ($min_time) ? "AND p.post_time >= $min_time" : '';
|
||||
break;
|
||||
|
||||
case 'reports':
|
||||
$limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
|
||||
$sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.post_time', 't' => 'r.report_time', 's' => 'p.post_subject');
|
||||
break;
|
||||
|
||||
case 'pm_reports':
|
||||
$limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
|
||||
$sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.message_time', 't' => 'r.report_time', 's' => 'p.message_subject');
|
||||
break;
|
||||
|
||||
case 'logs':
|
||||
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
|
||||
|
||||
$sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
|
||||
$limit_time_sql = ($min_time) ? "AND l.log_time >= $min_time" : '';
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isset($sort_by_sql[$sort_key]))
|
||||
{
|
||||
$sort_key = $default_key;
|
||||
}
|
||||
|
||||
$sort_order_sql = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
||||
|
||||
$s_limit_days = $s_sort_key = $s_sort_dir = $sort_url = '';
|
||||
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $sort_url);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||
'S_SELECT_SORT_KEY' => $s_sort_key,
|
||||
'S_SELECT_SORT_DAYS' => $s_limit_days)
|
||||
);
|
||||
|
||||
if (($sort_days && $mode != 'viewlogs') || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts', 'deleted_topics', 'deleted_posts')) || $where_sql != 'WHERE')
|
||||
{
|
||||
$result = $db->sql_query($sql);
|
||||
$total = (int) $db->sql_fetchfield('total');
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$total = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ids
|
||||
*
|
||||
* @param array &$ids The relevant ids to check
|
||||
* @param string $table The table to find the ids in
|
||||
* @param string $sql_id The ids relevant column name
|
||||
* @param array $acl_list A list of permissions the user need to have
|
||||
* @param mixed $singe_forum Limit to one forum id (int) or the first forum found (true)
|
||||
*
|
||||
* @return mixed False if no ids were able to be retrieved, true if at least one id left.
|
||||
* Additionally, this value can be the forum_id assigned if $single_forum was set.
|
||||
* Therefore checking the result for with !== false is the best method.
|
||||
*/
|
||||
function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = false)
|
||||
{
|
||||
global $db, $auth;
|
||||
|
||||
if (!is_array($ids) || empty($ids))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "SELECT $sql_id, forum_id FROM $table
|
||||
WHERE " . $db->sql_in_set($sql_id, $ids);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$ids = array();
|
||||
$forum_id = false;
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($acl_list && $row['forum_id'] && !$auth->acl_gets($acl_list, $row['forum_id']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($acl_list && !$row['forum_id'] && !$auth->acl_getf_global($acl_list))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Limit forum? If not, just assign the id.
|
||||
if ($single_forum === false)
|
||||
{
|
||||
$ids[] = $row[$sql_id];
|
||||
continue;
|
||||
}
|
||||
|
||||
// Limit forum to a specific forum id?
|
||||
// This can get really tricky, because we do not want to create a failure on global topics. :)
|
||||
if ($row['forum_id'])
|
||||
{
|
||||
if ($single_forum !== true && $row['forum_id'] == (int) $single_forum)
|
||||
{
|
||||
$forum_id = (int) $single_forum;
|
||||
}
|
||||
else if ($forum_id === false)
|
||||
{
|
||||
$forum_id = $row['forum_id'];
|
||||
}
|
||||
|
||||
if ($row['forum_id'] == $forum_id)
|
||||
{
|
||||
$ids[] = $row[$sql_id];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Always add a global topic
|
||||
$ids[] = $row[$sql_id];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!sizeof($ids))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If forum id is false and ids populated we may have only global announcements selected (returning 0 because of (int) $forum_id)
|
||||
|
||||
return ($single_forum === false) ? true : (int) $forum_id;
|
||||
}
|
|
@ -2485,3 +2485,137 @@ function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false)
|
|||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show upload popup (progress bar)
|
||||
*/
|
||||
function upload_popup($forum_style = 0)
|
||||
{
|
||||
global $template, $user;
|
||||
|
||||
($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting');
|
||||
|
||||
page_header($user->lang['PROGRESS_BAR']);
|
||||
|
||||
$template->set_filenames(array(
|
||||
'popup' => 'posting_progress_bar.html')
|
||||
);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS']))
|
||||
);
|
||||
|
||||
$template->display('popup');
|
||||
|
||||
garbage_collection();
|
||||
exit_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the various checks required for removing posts as well as removing it
|
||||
*/
|
||||
function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $soft_delete_reason = '')
|
||||
{
|
||||
global $user, $db, $auth, $config, $request;
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$perm_check = ($is_soft) ? 'softdelete' : 'delete';
|
||||
|
||||
// If moderator removing post or user itself removing post, present a confirmation screen
|
||||
if ($auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])))
|
||||
{
|
||||
$s_hidden_fields = array(
|
||||
'p' => $post_id,
|
||||
'f' => $forum_id,
|
||||
'mode' => ($is_soft) ? 'soft_delete' : 'delete',
|
||||
);
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$data = array(
|
||||
'topic_first_post_id' => $post_data['topic_first_post_id'],
|
||||
'topic_last_post_id' => $post_data['topic_last_post_id'],
|
||||
'topic_posts_approved' => $post_data['topic_posts_approved'],
|
||||
'topic_posts_unapproved' => $post_data['topic_posts_unapproved'],
|
||||
'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted'],
|
||||
'topic_visibility' => $post_data['topic_visibility'],
|
||||
'topic_type' => $post_data['topic_type'],
|
||||
'post_visibility' => $post_data['post_visibility'],
|
||||
'post_reported' => $post_data['post_reported'],
|
||||
'post_time' => $post_data['post_time'],
|
||||
'poster_id' => $post_data['poster_id'],
|
||||
'post_postcount' => $post_data['post_postcount'],
|
||||
);
|
||||
|
||||
$next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $soft_delete_reason);
|
||||
$post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username'];
|
||||
|
||||
if ($next_post_id === false)
|
||||
{
|
||||
add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), $post_data['topic_title'], $post_username, $soft_delete_reason);
|
||||
|
||||
$meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id");
|
||||
$message = $user->lang['POST_DELETED'];
|
||||
}
|
||||
else
|
||||
{
|
||||
add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), $post_data['post_subject'], $post_username, $soft_delete_reason);
|
||||
|
||||
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id";
|
||||
$message = $user->lang['POST_DELETED'];
|
||||
|
||||
if (!$request->is_ajax())
|
||||
{
|
||||
$message .= '<br /><br />' . $user->lang('RETURN_TOPIC', '<a href="' . $meta_info . '">', '</a>');
|
||||
}
|
||||
}
|
||||
|
||||
meta_refresh(3, $meta_info);
|
||||
if (!$request->is_ajax())
|
||||
{
|
||||
$message .= '<br /><br />' . $user->lang('RETURN_FORUM', '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>');
|
||||
}
|
||||
trigger_error($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
global $user, $template, $request;
|
||||
|
||||
$can_delete = $auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id));
|
||||
$can_softdelete = $auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED,
|
||||
'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '',
|
||||
'S_ALLOWED_DELETE' => $can_delete,
|
||||
'S_ALLOWED_SOFTDELETE' => $can_softdelete,
|
||||
));
|
||||
|
||||
$l_confirm = 'DELETE_POST';
|
||||
if ($post_data['post_visibility'] == ITEM_DELETED)
|
||||
{
|
||||
$l_confirm .= '_PERMANENTLY';
|
||||
$s_hidden_fields['delete_permanent'] = '1';
|
||||
}
|
||||
else if (!$can_softdelete)
|
||||
{
|
||||
$s_hidden_fields['delete_permanent'] = '1';
|
||||
}
|
||||
|
||||
confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html');
|
||||
}
|
||||
}
|
||||
|
||||
// If we are here the user is not able to delete - present the correct error message
|
||||
if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id))
|
||||
{
|
||||
trigger_error('DELETE_OWN_POSTS');
|
||||
}
|
||||
|
||||
if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id'])
|
||||
{
|
||||
trigger_error('CANNOT_DELETE_REPLIED');
|
||||
}
|
||||
|
||||
trigger_error('USER_CANNOT_DELETE');
|
||||
}
|
||||
|
|
|
@ -3545,3 +3545,23 @@ function phpbb_get_banned_user_ids($user_ids = array(), $ban_end = true)
|
|||
|
||||
return $banned_ids_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for assigning a template var if the zebra module got included
|
||||
*/
|
||||
function _module_zebra($mode, &$module_row)
|
||||
{
|
||||
global $template;
|
||||
|
||||
$template->assign_var('S_ZEBRA_ENABLED', true);
|
||||
|
||||
if ($mode == 'friends')
|
||||
{
|
||||
$template->assign_var('S_ZEBRA_FRIENDS_ENABLED', true);
|
||||
}
|
||||
|
||||
if ($mode == 'foes')
|
||||
{
|
||||
$template->assign_var('S_ZEBRA_FOES_ENABLED', true);
|
||||
}
|
||||
}
|
||||
|
|
647
phpBB/mcp.php
647
phpBB/mcp.php
|
@ -19,6 +19,7 @@ $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
|
|||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
include($phpbb_root_path . 'common.' . $phpEx);
|
||||
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
||||
include($phpbb_root_path . 'includes/functions_mcp.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
|
||||
|
||||
// Start session management
|
||||
|
@ -299,649 +300,3 @@ $template->assign_vars(array(
|
|||
|
||||
// Generate the page, do not display/query online list
|
||||
$module->display($module->get_page_title());
|
||||
|
||||
/**
|
||||
* Functions used to generate additional URL paramters
|
||||
*/
|
||||
function _module__url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_notes_url($mode, &$module_row)
|
||||
{
|
||||
if ($mode == 'front')
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
global $user_id;
|
||||
return ($user_id) ? "&u=$user_id" : '';
|
||||
}
|
||||
|
||||
function _module_warn_url($mode, &$module_row)
|
||||
{
|
||||
if ($mode == 'front' || $mode == 'list')
|
||||
{
|
||||
global $forum_id;
|
||||
|
||||
return ($forum_id) ? "&f=$forum_id" : '';
|
||||
}
|
||||
|
||||
if ($mode == 'warn_post')
|
||||
{
|
||||
global $forum_id, $post_id;
|
||||
|
||||
$url_extra = ($forum_id) ? "&f=$forum_id" : '';
|
||||
$url_extra .= ($post_id) ? "&p=$post_id" : '';
|
||||
|
||||
return $url_extra;
|
||||
}
|
||||
else
|
||||
{
|
||||
global $user_id;
|
||||
|
||||
return ($user_id) ? "&u=$user_id" : '';
|
||||
}
|
||||
}
|
||||
|
||||
function _module_main_url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_logs_url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_ban_url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_queue_url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function _module_reports_url($mode, &$module_row)
|
||||
{
|
||||
return extra_url();
|
||||
}
|
||||
|
||||
function extra_url()
|
||||
{
|
||||
global $forum_id, $topic_id, $post_id, $report_id, $user_id;
|
||||
|
||||
$url_extra = '';
|
||||
$url_extra .= ($forum_id) ? "&f=$forum_id" : '';
|
||||
$url_extra .= ($topic_id) ? "&t=$topic_id" : '';
|
||||
$url_extra .= ($post_id) ? "&p=$post_id" : '';
|
||||
$url_extra .= ($user_id) ? "&u=$user_id" : '';
|
||||
$url_extra .= ($report_id) ? "&r=$report_id" : '';
|
||||
|
||||
return $url_extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get simple topic data
|
||||
*/
|
||||
function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false)
|
||||
{
|
||||
global $auth, $db, $config, $user;
|
||||
static $rowset = array();
|
||||
|
||||
$topics = array();
|
||||
|
||||
if (!sizeof($topic_ids))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
// cache might not contain read tracking info, so we can't use it if read
|
||||
// tracking information is requested
|
||||
if (!$read_tracking)
|
||||
{
|
||||
$cache_topic_ids = array_intersect($topic_ids, array_keys($rowset));
|
||||
$topic_ids = array_diff($topic_ids, array_keys($rowset));
|
||||
}
|
||||
else
|
||||
{
|
||||
$cache_topic_ids = array();
|
||||
}
|
||||
|
||||
if (sizeof($topic_ids))
|
||||
{
|
||||
$sql_array = array(
|
||||
'SELECT' => 't.*, f.*',
|
||||
|
||||
'FROM' => array(
|
||||
TOPICS_TABLE => 't',
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(FORUMS_TABLE => 'f'),
|
||||
'ON' => 'f.forum_id = t.forum_id'
|
||||
)
|
||||
),
|
||||
|
||||
'WHERE' => $db->sql_in_set('t.topic_id', $topic_ids)
|
||||
);
|
||||
|
||||
if ($read_tracking && $config['load_db_lastread'])
|
||||
{
|
||||
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
|
||||
|
||||
$sql_array['LEFT_JOIN'][] = array(
|
||||
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
|
||||
'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
|
||||
);
|
||||
|
||||
$sql_array['LEFT_JOIN'][] = array(
|
||||
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
|
||||
);
|
||||
}
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rowset[$row['topic_id']] = $row;
|
||||
|
||||
if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$topics[$row['topic_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
foreach ($cache_topic_ids as $id)
|
||||
{
|
||||
if (!$acl_list || $auth->acl_gets($acl_list, $rowset[$id]['forum_id']))
|
||||
{
|
||||
$topics[$id] = $rowset[$id];
|
||||
}
|
||||
}
|
||||
|
||||
return $topics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get simple post data
|
||||
*/
|
||||
function get_post_data($post_ids, $acl_list = false, $read_tracking = false)
|
||||
{
|
||||
global $db, $auth, $config, $user;
|
||||
|
||||
$rowset = array();
|
||||
|
||||
if (!sizeof($post_ids))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql_array = array(
|
||||
'SELECT' => 'p.*, u.*, t.*, f.*',
|
||||
|
||||
'FROM' => array(
|
||||
USERS_TABLE => 'u',
|
||||
POSTS_TABLE => 'p',
|
||||
TOPICS_TABLE => 't',
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(FORUMS_TABLE => 'f'),
|
||||
'ON' => 'f.forum_id = t.forum_id'
|
||||
)
|
||||
),
|
||||
|
||||
'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . '
|
||||
AND u.user_id = p.poster_id
|
||||
AND t.topic_id = p.topic_id',
|
||||
);
|
||||
|
||||
if ($read_tracking && $config['load_db_lastread'])
|
||||
{
|
||||
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
|
||||
|
||||
$sql_array['LEFT_JOIN'][] = array(
|
||||
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
|
||||
'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
|
||||
);
|
||||
|
||||
$sql_array['LEFT_JOIN'][] = array(
|
||||
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
|
||||
);
|
||||
}
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
$result = $db->sql_query($sql);
|
||||
unset($sql_array);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($row['post_visibility'] != ITEM_APPROVED && !$auth->acl_get('m_approve', $row['forum_id']))
|
||||
{
|
||||
// Moderators without the permission to approve post should at least not see them. ;)
|
||||
continue;
|
||||
}
|
||||
|
||||
$rowset[$row['post_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $rowset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get simple forum data
|
||||
*/
|
||||
function get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false)
|
||||
{
|
||||
global $auth, $db, $user, $config, $phpbb_container;
|
||||
|
||||
$rowset = array();
|
||||
|
||||
if (!is_array($forum_id))
|
||||
{
|
||||
$forum_id = array($forum_id);
|
||||
}
|
||||
|
||||
if (!sizeof($forum_id))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($read_tracking && $config['load_db_lastread'])
|
||||
{
|
||||
$read_tracking_join = ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . '
|
||||
AND ft.forum_id = f.forum_id)';
|
||||
$read_tracking_select = ', ft.mark_time';
|
||||
}
|
||||
else
|
||||
{
|
||||
$read_tracking_join = $read_tracking_select = '';
|
||||
}
|
||||
|
||||
$sql = "SELECT f.* $read_tracking_select
|
||||
FROM " . FORUMS_TABLE . " f$read_tracking_join
|
||||
WHERE " . $db->sql_in_set('f.forum_id', $forum_id);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$row['forum_topics_approved'] = $phpbb_content_visibility->get_count('forum_topics', $row, $row['forum_id']);
|
||||
|
||||
$rowset[$row['forum_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $rowset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get simple pm data
|
||||
*/
|
||||
function get_pm_data($pm_ids)
|
||||
{
|
||||
global $db, $auth, $config, $user;
|
||||
|
||||
$rowset = array();
|
||||
|
||||
if (!sizeof($pm_ids))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql_array = array(
|
||||
'SELECT' => 'p.*, u.*',
|
||||
|
||||
'FROM' => array(
|
||||
USERS_TABLE => 'u',
|
||||
PRIVMSGS_TABLE => 'p',
|
||||
),
|
||||
|
||||
'WHERE' => $db->sql_in_set('p.msg_id', $pm_ids) . '
|
||||
AND u.user_id = p.author_id',
|
||||
);
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
$result = $db->sql_query($sql);
|
||||
unset($sql_array);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$rowset[$row['msg_id']] = $row;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $rowset;
|
||||
}
|
||||
|
||||
/**
|
||||
* sorting in mcp
|
||||
*
|
||||
* @param string $where_sql should either be WHERE (default if ommited) or end with AND or OR
|
||||
*
|
||||
* $mode reports and reports_closed: the $where parameters uses aliases p for posts table and r for report table
|
||||
* $mode unapproved_posts: the $where parameters uses aliases p for posts table and t for topic table
|
||||
*/
|
||||
function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, &$sort_order_sql, &$total, $forum_id = 0, $topic_id = 0, $where_sql = 'WHERE')
|
||||
{
|
||||
global $db, $user, $auth, $template;
|
||||
|
||||
$sort_days = request_var('st', 0);
|
||||
$min_time = ($sort_days) ? time() - ($sort_days * 86400) : 0;
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case 'viewforum':
|
||||
$type = 'topics';
|
||||
$default_key = 't';
|
||||
$default_dir = 'd';
|
||||
|
||||
$sql = 'SELECT COUNT(topic_id) AS total
|
||||
FROM ' . TOPICS_TABLE . "
|
||||
$where_sql forum_id = $forum_id
|
||||
AND topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")
|
||||
AND topic_last_post_time >= $min_time";
|
||||
|
||||
if (!$auth->acl_get('m_approve', $forum_id))
|
||||
{
|
||||
$sql .= 'AND topic_visibility = ' . ITEM_APPROVED;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'viewtopic':
|
||||
$type = 'posts';
|
||||
$default_key = 't';
|
||||
$default_dir = 'a';
|
||||
|
||||
$sql = 'SELECT COUNT(post_id) AS total
|
||||
FROM ' . POSTS_TABLE . "
|
||||
$where_sql topic_id = $topic_id
|
||||
AND post_time >= $min_time";
|
||||
|
||||
if (!$auth->acl_get('m_approve', $forum_id))
|
||||
{
|
||||
$sql .= 'AND post_visibility = ' . ITEM_APPROVED;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'unapproved_posts':
|
||||
case 'deleted_posts':
|
||||
$visibility_const = ($mode == 'unapproved_posts') ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
|
||||
$type = 'posts';
|
||||
$default_key = 't';
|
||||
$default_dir = 'd';
|
||||
$where_sql .= ($topic_id) ? ' p.topic_id = ' . $topic_id . ' AND' : '';
|
||||
|
||||
$sql = 'SELECT COUNT(p.post_id) AS total
|
||||
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
|
||||
$where_sql " . $db->sql_in_set('p.forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
|
||||
AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) .'
|
||||
AND t.topic_id = p.topic_id
|
||||
AND t.topic_visibility <> p.post_visibility';
|
||||
|
||||
if ($min_time)
|
||||
{
|
||||
$sql .= ' AND post_time >= ' . $min_time;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'unapproved_topics':
|
||||
case 'deleted_topics':
|
||||
$visibility_const = ($mode == 'unapproved_topics') ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
|
||||
$type = 'topics';
|
||||
$default_key = 't';
|
||||
$default_dir = 'd';
|
||||
|
||||
$sql = 'SELECT COUNT(topic_id) AS total
|
||||
FROM ' . TOPICS_TABLE . "
|
||||
$where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
|
||||
AND ' . $db->sql_in_set('topic_visibility', $visibility_const);
|
||||
|
||||
if ($min_time)
|
||||
{
|
||||
$sql .= ' AND topic_time >= ' . $min_time;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'pm_reports':
|
||||
case 'pm_reports_closed':
|
||||
case 'reports':
|
||||
case 'reports_closed':
|
||||
$pm = (strpos($mode, 'pm_') === 0) ? true : false;
|
||||
|
||||
$type = ($pm) ? 'pm_reports' : 'reports';
|
||||
$default_key = 't';
|
||||
$default_dir = 'd';
|
||||
$limit_time_sql = ($min_time) ? "AND r.report_time >= $min_time" : '';
|
||||
|
||||
if ($topic_id)
|
||||
{
|
||||
$where_sql .= ' p.topic_id = ' . $topic_id . ' AND ';
|
||||
}
|
||||
else if ($forum_id)
|
||||
{
|
||||
$where_sql .= ' p.forum_id = ' . $forum_id . ' AND ';
|
||||
}
|
||||
else if (!$pm)
|
||||
{
|
||||
$where_sql .= ' ' . $db->sql_in_set('p.forum_id', get_forum_list(array('!f_read', '!m_report')), true, true) . ' AND ';
|
||||
}
|
||||
|
||||
if ($mode == 'reports' || $mode == 'pm_reports')
|
||||
{
|
||||
$where_sql .= ' r.report_closed = 0 AND ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$where_sql .= ' r.report_closed = 1 AND ';
|
||||
}
|
||||
|
||||
if ($pm)
|
||||
{
|
||||
$sql = 'SELECT COUNT(r.report_id) AS total
|
||||
FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . " p
|
||||
$where_sql r.post_id = 0
|
||||
AND p.msg_id = r.pm_id
|
||||
$limit_time_sql";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT COUNT(r.report_id) AS total
|
||||
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . " p
|
||||
$where_sql r.pm_id = 0
|
||||
AND p.post_id = r.post_id
|
||||
$limit_time_sql";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'viewlogs':
|
||||
$type = 'logs';
|
||||
$default_key = 't';
|
||||
$default_dir = 'd';
|
||||
|
||||
$sql = 'SELECT COUNT(log_id) AS total
|
||||
FROM ' . LOG_TABLE . "
|
||||
$where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_'))) . '
|
||||
AND log_time >= ' . $min_time . '
|
||||
AND log_type = ' . LOG_MOD;
|
||||
break;
|
||||
}
|
||||
|
||||
$sort_key = request_var('sk', $default_key);
|
||||
$sort_dir = request_var('sd', $default_dir);
|
||||
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'topics':
|
||||
$limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'tt' => $user->lang['TOPIC_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
|
||||
|
||||
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'tt' => 't.topic_time', 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 't.topic_title', 'v' => 't.topic_views');
|
||||
$limit_time_sql = ($min_time) ? "AND t.topic_last_post_time >= $min_time" : '';
|
||||
break;
|
||||
|
||||
case 'posts':
|
||||
$limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
|
||||
$sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.post_time', 's' => 'p.post_subject');
|
||||
$limit_time_sql = ($min_time) ? "AND p.post_time >= $min_time" : '';
|
||||
break;
|
||||
|
||||
case 'reports':
|
||||
$limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
|
||||
$sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.post_time', 't' => 'r.report_time', 's' => 'p.post_subject');
|
||||
break;
|
||||
|
||||
case 'pm_reports':
|
||||
$limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
|
||||
$sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.message_time', 't' => 'r.report_time', 's' => 'p.message_subject');
|
||||
break;
|
||||
|
||||
case 'logs':
|
||||
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
|
||||
|
||||
$sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
|
||||
$limit_time_sql = ($min_time) ? "AND l.log_time >= $min_time" : '';
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isset($sort_by_sql[$sort_key]))
|
||||
{
|
||||
$sort_key = $default_key;
|
||||
}
|
||||
|
||||
$sort_order_sql = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
||||
|
||||
$s_limit_days = $s_sort_key = $s_sort_dir = $sort_url = '';
|
||||
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $sort_url);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||
'S_SELECT_SORT_KEY' => $s_sort_key,
|
||||
'S_SELECT_SORT_DAYS' => $s_limit_days)
|
||||
);
|
||||
|
||||
if (($sort_days && $mode != 'viewlogs') || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts', 'deleted_topics', 'deleted_posts')) || $where_sql != 'WHERE')
|
||||
{
|
||||
$result = $db->sql_query($sql);
|
||||
$total = (int) $db->sql_fetchfield('total');
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$total = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ids
|
||||
*
|
||||
* @param array &$ids The relevant ids to check
|
||||
* @param string $table The table to find the ids in
|
||||
* @param string $sql_id The ids relevant column name
|
||||
* @param array $acl_list A list of permissions the user need to have
|
||||
* @param mixed $singe_forum Limit to one forum id (int) or the first forum found (true)
|
||||
*
|
||||
* @return mixed False if no ids were able to be retrieved, true if at least one id left.
|
||||
* Additionally, this value can be the forum_id assigned if $single_forum was set.
|
||||
* Therefore checking the result for with !== false is the best method.
|
||||
*/
|
||||
function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = false)
|
||||
{
|
||||
global $db, $auth;
|
||||
|
||||
if (!is_array($ids) || empty($ids))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "SELECT $sql_id, forum_id FROM $table
|
||||
WHERE " . $db->sql_in_set($sql_id, $ids);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$ids = array();
|
||||
$forum_id = false;
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($acl_list && $row['forum_id'] && !$auth->acl_gets($acl_list, $row['forum_id']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($acl_list && !$row['forum_id'] && !$auth->acl_getf_global($acl_list))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Limit forum? If not, just assign the id.
|
||||
if ($single_forum === false)
|
||||
{
|
||||
$ids[] = $row[$sql_id];
|
||||
continue;
|
||||
}
|
||||
|
||||
// Limit forum to a specific forum id?
|
||||
// This can get really tricky, because we do not want to create a failure on global topics. :)
|
||||
if ($row['forum_id'])
|
||||
{
|
||||
if ($single_forum !== true && $row['forum_id'] == (int) $single_forum)
|
||||
{
|
||||
$forum_id = (int) $single_forum;
|
||||
}
|
||||
else if ($forum_id === false)
|
||||
{
|
||||
$forum_id = $row['forum_id'];
|
||||
}
|
||||
|
||||
if ($row['forum_id'] == $forum_id)
|
||||
{
|
||||
$ids[] = $row[$sql_id];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Always add a global topic
|
||||
$ids[] = $row[$sql_id];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!sizeof($ids))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If forum id is false and ids populated we may have only global announcements selected (returning 0 because of (int) $forum_id)
|
||||
|
||||
return ($single_forum === false) ? true : (int) $forum_id;
|
||||
}
|
||||
|
|
|
@ -1485,166 +1485,3 @@ $template->set_filenames(array(
|
|||
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
|
||||
|
||||
page_footer();
|
||||
|
||||
/**
|
||||
* Prepare profile data
|
||||
*/
|
||||
function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false)
|
||||
{
|
||||
global $config, $auth, $template, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher;
|
||||
|
||||
$username = $data['username'];
|
||||
$user_id = $data['user_id'];
|
||||
|
||||
$rank_title = $rank_img = $rank_img_src = '';
|
||||
get_user_rank($data['user_rank'], (($user_id == ANONYMOUS) ? false : $data['user_posts']), $rank_title, $rank_img, $rank_img_src);
|
||||
|
||||
if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user'))
|
||||
{
|
||||
$email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$email = '';
|
||||
}
|
||||
|
||||
if ($config['load_onlinetrack'])
|
||||
{
|
||||
$update_time = $config['load_online_time'] * 60;
|
||||
$online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$online = false;
|
||||
}
|
||||
|
||||
if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
|
||||
{
|
||||
$last_active = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_active = '';
|
||||
}
|
||||
|
||||
$age = '';
|
||||
|
||||
if ($config['allow_birthdays'] && $data['user_birthday'])
|
||||
{
|
||||
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));
|
||||
|
||||
if ($bday_year)
|
||||
{
|
||||
$now = $user->create_datetime();
|
||||
$now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
|
||||
|
||||
$diff = $now['mon'] - $bday_month;
|
||||
if ($diff == 0)
|
||||
{
|
||||
$diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$diff = ($diff < 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
$age = max(0, (int) ($now['year'] - $bday_year - $diff));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('phpbb_get_banned_user_ids'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||
}
|
||||
|
||||
// Can this user receive a Private Message?
|
||||
$can_receive_pm = (
|
||||
// They must be a "normal" user
|
||||
$data['user_type'] != USER_IGNORE &&
|
||||
|
||||
// They must not be deactivated by the administrator
|
||||
($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) &&
|
||||
|
||||
// They must be able to read PMs
|
||||
sizeof($auth->acl_get_list($user_id, 'u_readpm')) &&
|
||||
|
||||
// They must not be permanently banned
|
||||
!sizeof(phpbb_get_banned_user_ids($user_id, false)) &&
|
||||
|
||||
// They must allow users to contact via PM
|
||||
(($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm'])
|
||||
);
|
||||
|
||||
// Dump it out to the template
|
||||
$template_data = array(
|
||||
'AGE' => $age,
|
||||
'RANK_TITLE' => $rank_title,
|
||||
'JOINED' => $user->format_date($data['user_regdate']),
|
||||
'LAST_ACTIVE' => (empty($last_active)) ? ' - ' : $user->format_date($last_active),
|
||||
'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0,
|
||||
'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0,
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']),
|
||||
'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']),
|
||||
'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']),
|
||||
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']),
|
||||
|
||||
'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])),
|
||||
|
||||
'AVATAR_IMG' => phpbb_get_user_avatar($data),
|
||||
'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
|
||||
'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false,
|
||||
'RANK_IMG' => $rank_img,
|
||||
'RANK_IMG_SRC' => $rank_img_src,
|
||||
'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false,
|
||||
|
||||
'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false,
|
||||
|
||||
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '',
|
||||
'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '',
|
||||
'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '',
|
||||
'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '',
|
||||
'U_EMAIL' => $email,
|
||||
'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '',
|
||||
|
||||
'USER_JABBER' => $data['user_jabber'],
|
||||
'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',
|
||||
|
||||
'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username),
|
||||
'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username),
|
||||
'L_VIEWING_PROFILE' => $user->lang('VIEWING_PROFILE', $username),
|
||||
);
|
||||
|
||||
/**
|
||||
* Preparing a user's data before displaying it in profile and memberlist
|
||||
*
|
||||
* @event core.memberlist_prepare_profile_data
|
||||
* @var array data Array with user's data
|
||||
* @var array template_data Template array with user's data
|
||||
* @since 3.1.0-a1
|
||||
*/
|
||||
$vars = array('data', 'template_data');
|
||||
extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars)));
|
||||
|
||||
return $template_data;
|
||||
}
|
||||
|
||||
function _sort_last_active($first, $second)
|
||||
{
|
||||
global $id_cache, $sort_dir;
|
||||
|
||||
$lesser_than = ($sort_dir === 'd') ? -1 : 1;
|
||||
|
||||
if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader']))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader'])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1722,137 +1722,3 @@ if ($mode == 'reply' || $mode == 'quote')
|
|||
}
|
||||
|
||||
page_footer();
|
||||
|
||||
/**
|
||||
* Show upload popup (progress bar)
|
||||
*/
|
||||
function upload_popup($forum_style = 0)
|
||||
{
|
||||
global $template, $user;
|
||||
|
||||
($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting');
|
||||
|
||||
page_header($user->lang['PROGRESS_BAR']);
|
||||
|
||||
$template->set_filenames(array(
|
||||
'popup' => 'posting_progress_bar.html')
|
||||
);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS']))
|
||||
);
|
||||
|
||||
$template->display('popup');
|
||||
|
||||
garbage_collection();
|
||||
exit_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the various checks required for removing posts as well as removing it
|
||||
*/
|
||||
function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $soft_delete_reason = '')
|
||||
{
|
||||
global $user, $db, $auth, $config, $request;
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$perm_check = ($is_soft) ? 'softdelete' : 'delete';
|
||||
|
||||
// If moderator removing post or user itself removing post, present a confirmation screen
|
||||
if ($auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])))
|
||||
{
|
||||
$s_hidden_fields = array(
|
||||
'p' => $post_id,
|
||||
'f' => $forum_id,
|
||||
'mode' => ($is_soft) ? 'soft_delete' : 'delete',
|
||||
);
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$data = array(
|
||||
'topic_first_post_id' => $post_data['topic_first_post_id'],
|
||||
'topic_last_post_id' => $post_data['topic_last_post_id'],
|
||||
'topic_posts_approved' => $post_data['topic_posts_approved'],
|
||||
'topic_posts_unapproved' => $post_data['topic_posts_unapproved'],
|
||||
'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted'],
|
||||
'topic_visibility' => $post_data['topic_visibility'],
|
||||
'topic_type' => $post_data['topic_type'],
|
||||
'post_visibility' => $post_data['post_visibility'],
|
||||
'post_reported' => $post_data['post_reported'],
|
||||
'post_time' => $post_data['post_time'],
|
||||
'poster_id' => $post_data['poster_id'],
|
||||
'post_postcount' => $post_data['post_postcount'],
|
||||
);
|
||||
|
||||
$next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $soft_delete_reason);
|
||||
$post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username'];
|
||||
|
||||
if ($next_post_id === false)
|
||||
{
|
||||
add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), $post_data['topic_title'], $post_username, $soft_delete_reason);
|
||||
|
||||
$meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id");
|
||||
$message = $user->lang['POST_DELETED'];
|
||||
}
|
||||
else
|
||||
{
|
||||
add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), $post_data['post_subject'], $post_username, $soft_delete_reason);
|
||||
|
||||
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id";
|
||||
$message = $user->lang['POST_DELETED'];
|
||||
|
||||
if (!$request->is_ajax())
|
||||
{
|
||||
$message .= '<br /><br />' . $user->lang('RETURN_TOPIC', '<a href="' . $meta_info . '">', '</a>');
|
||||
}
|
||||
}
|
||||
|
||||
meta_refresh(3, $meta_info);
|
||||
if (!$request->is_ajax())
|
||||
{
|
||||
$message .= '<br /><br />' . $user->lang('RETURN_FORUM', '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>');
|
||||
}
|
||||
trigger_error($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
global $user, $template, $request;
|
||||
|
||||
$can_delete = $auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id));
|
||||
$can_softdelete = $auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED,
|
||||
'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '',
|
||||
'S_ALLOWED_DELETE' => $can_delete,
|
||||
'S_ALLOWED_SOFTDELETE' => $can_softdelete,
|
||||
));
|
||||
|
||||
$l_confirm = 'DELETE_POST';
|
||||
if ($post_data['post_visibility'] == ITEM_DELETED)
|
||||
{
|
||||
$l_confirm .= '_PERMANENTLY';
|
||||
$s_hidden_fields['delete_permanent'] = '1';
|
||||
}
|
||||
else if (!$can_softdelete)
|
||||
{
|
||||
$s_hidden_fields['delete_permanent'] = '1';
|
||||
}
|
||||
|
||||
confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html');
|
||||
}
|
||||
}
|
||||
|
||||
// If we are here the user is not able to delete - present the correct error message
|
||||
if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id))
|
||||
{
|
||||
trigger_error('DELETE_OWN_POSTS');
|
||||
}
|
||||
|
||||
if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id'])
|
||||
{
|
||||
trigger_error('CANNOT_DELETE_REPLIED');
|
||||
}
|
||||
|
||||
trigger_error('USER_CANNOT_DELETE');
|
||||
}
|
||||
|
|
|
@ -357,23 +357,3 @@ $module->assign_tpl_vars(append_sid("{$phpbb_root_path}ucp.$phpEx"));
|
|||
|
||||
// Generate the page, do not display/query online list
|
||||
$module->display($module->get_page_title());
|
||||
|
||||
/**
|
||||
* Function for assigning a template var if the zebra module got included
|
||||
*/
|
||||
function _module_zebra($mode, &$module_row)
|
||||
{
|
||||
global $template;
|
||||
|
||||
$template->assign_var('S_ZEBRA_ENABLED', true);
|
||||
|
||||
if ($mode == 'friends')
|
||||
{
|
||||
$template->assign_var('S_ZEBRA_FRIENDS_ENABLED', true);
|
||||
}
|
||||
|
||||
if ($mode == 'foes')
|
||||
{
|
||||
$template->assign_var('S_ZEBRA_FOES_ENABLED', true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue