|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package ucp
|
|
|
ef5584 |
* @version $Id: ucp_main.php 9136 2008-11-30 14:36:59Z acydburn $
|
|
|
ef5584 |
* @copyright (c) 2005 phpBB Group
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @ignore
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if (!defined('IN_PHPBB'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* ucp_main
|
|
|
ef5584 |
* UCP Front Panel
|
|
|
ef5584 |
* @package ucp
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
class ucp_main
|
|
|
ef5584 |
{
|
|
|
ef5584 |
var $p_master;
|
|
|
ef5584 |
var $u_action;
|
|
|
ef5584 |
|
|
|
ef5584 |
function ucp_main(&$p_master)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->p_master = &$p_master;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
function main($id, $mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
|
|
|
ef5584 |
|
|
|
ef5584 |
switch ($mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'front':
|
|
|
ef5584 |
|
|
|
ef5584 |
$user->add_lang('memberlist');
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_from = TOPICS_TABLE . ' t ';
|
|
|
ef5584 |
$sql_select = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($config['load_db_track'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.topic_id = t.topic_id
|
|
|
ef5584 |
AND tp.user_id = ' . $user->data['user_id'] . ')';
|
|
|
ef5584 |
$sql_select .= ', tp.topic_posted';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($config['load_db_lastread'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id
|
|
|
ef5584 |
AND tt.user_id = ' . $user->data['user_id'] . ')';
|
|
|
ef5584 |
$sql_select .= ', tt.mark_time';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
|
|
|
ef5584 |
$folder = 'global_read';
|
|
|
ef5584 |
$folder_new = 'global_unread';
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get cleaned up list... return only those forums not having the f_read permission
|
|
|
ef5584 |
$forum_ary = $auth->acl_getf('!f_read', true);
|
|
|
ef5584 |
$forum_ary = array_unique(array_keys($forum_ary));
|
|
|
ef5584 |
|
|
|
ef5584 |
// Determine first forum the user is able to read into - for global announcement link
|
|
|
ef5584 |
$sql = 'SELECT forum_id
|
|
|
ef5584 |
FROM ' . FORUMS_TABLE . '
|
|
|
ef5584 |
WHERE forum_type = ' . FORUM_POST;
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($forum_ary))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$result = $db->sql_query_limit($sql, 1);
|
|
|
ef5584 |
$g_forum_id = (int) $db->sql_fetchfield('forum_id');
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = "SELECT t.* $sql_select
|
|
|
ef5584 |
FROM $sql_from
|
|
|
ef5584 |
WHERE t.forum_id = 0
|
|
|
ef5584 |
AND t.topic_type = " . POST_GLOBAL . '
|
|
|
ef5584 |
ORDER BY t.topic_last_post_time DESC';
|
|
|
ef5584 |
|
|
|
ef5584 |
$topic_list = $rowset = array();
|
|
|
ef5584 |
// If the user can't see any forums, he can't read any posts because fid of 0 is invalid
|
|
|
ef5584 |
if ($g_forum_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_list[] = $row['topic_id'];
|
|
|
ef5584 |
$rowset[$row['topic_id']] = $row;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$topic_tracking_info = array();
|
|
|
ef5584 |
if ($config['load_db_lastread'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, false, $topic_list);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_tracking_info = get_complete_topic_tracking(0, $topic_list, $topic_list);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($topic_list as $topic_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$row = &$rowset[$topic_id];
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_id = $row['forum_id'];
|
|
|
ef5584 |
$topic_id = $row['topic_id'];
|
|
|
ef5584 |
|
|
|
ef5584 |
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
$folder_img = ($unread_topic) ? $folder_new : $folder;
|
|
|
ef5584 |
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($row['topic_status'] == ITEM_LOCKED)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$folder_img .= '_locked';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Posted image?
|
|
|
ef5584 |
if (!empty($row['topic_posted']) && $row['topic_posted'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$folder_img .= '_mine';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_block_vars('topicrow', array(
|
|
|
ef5584 |
'FORUM_ID' => $forum_id,
|
|
|
ef5584 |
'TOPIC_ID' => $topic_id,
|
|
|
ef5584 |
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
|
ef5584 |
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
|
ef5584 |
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
|
ef5584 |
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
|
|
|
ef5584 |
'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']),
|
|
|
ef5584 |
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
|
|
|
ef5584 |
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
|
|
|
ef5584 |
'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
|
ef5584 |
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
|
ef5584 |
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
|
ef5584 |
'TOPIC_TITLE' => censor_text($row['topic_title']),
|
|
|
ef5584 |
'TOPIC_TYPE' => $topic_type,
|
|
|
ef5584 |
|
|
|
ef5584 |
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
|
|
ef5584 |
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
|
|
|
ef5584 |
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', '') : '',
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_USER_POSTED' => (!empty($row['topic_posted']) && $row['topic_posted']) ? true : false,
|
|
|
ef5584 |
'S_UNREAD' => $unread_topic,
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
|
ef5584 |
'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
|
|
|
ef5584 |
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
|
ef5584 |
'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&view=unread") . '#unread',
|
|
|
ef5584 |
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id"))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($config['load_user_activity'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!function_exists('display_user_activity'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
display_user_activity($user->data);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Do the relevant calculations
|
|
|
ef5584 |
$memberdays = max(1, round((time() - $user->data['user_regdate']) / 86400));
|
|
|
ef5584 |
$posts_per_day = $user->data['user_posts'] / $memberdays;
|
|
|
ef5584 |
$percentage = ($config['num_posts']) ? min(100, ($user->data['user_posts'] / $config['num_posts']) * 100) : 0;
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'USER_COLOR' => (!empty($user->data['user_colour'])) ? $user->data['user_colour'] : '',
|
|
|
ef5584 |
'JOINED' => $user->format_date($user->data['user_regdate']),
|
|
|
ef5584 |
'VISITED' => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit),
|
|
|
ef5584 |
'WARNINGS' => ($user->data['user_warnings']) ? $user->data['user_warnings'] : 0,
|
|
|
ef5584 |
'POSTS' => ($user->data['user_posts']) ? $user->data['user_posts'] : 0,
|
|
|
ef5584 |
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
|
|
|
ef5584 |
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
|
|
|
ef5584 |
|
|
|
ef5584 |
'OCCUPATION' => (!empty($row['user_occ'])) ? $row['user_occ'] : '',
|
|
|
ef5584 |
'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '',
|
|
|
ef5584 |
|
|
|
ef5584 |
// 'S_GROUP_OPTIONS' => $group_options,
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $user->data['user_id'] . '&sr=posts') : '',
|
|
|
ef5584 |
));
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'subscribed':
|
|
|
ef5584 |
|
|
|
ef5584 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$user->add_lang('viewforum');
|
|
|
ef5584 |
|
|
|
ef5584 |
add_form_key('ucp_front_subscribed');
|
|
|
ef5584 |
|
|
|
ef5584 |
$unwatch = (isset($_POST['unwatch'])) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($unwatch)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (check_form_key('ucp_front_subscribed'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forums = array_keys(request_var('f', array(0 => 0)));
|
|
|
ef5584 |
$topics = array_keys(request_var('t', array(0 => 0)));
|
|
|
ef5584 |
$msg = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($forums) || sizeof($topics))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$l_unwatch = '';
|
|
|
ef5584 |
if (sizeof($forums))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . '
|
|
|
ef5584 |
WHERE ' . $db->sql_in_set('forum_id', $forums) . '
|
|
|
ef5584 |
AND user_id = ' . $user->data['user_id'];
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$l_unwatch .= '_FORUMS';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($topics))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . '
|
|
|
ef5584 |
WHERE ' . $db->sql_in_set('topic_id', $topics) . '
|
|
|
ef5584 |
AND user_id = ' . $user->data['user_id'];
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$l_unwatch .= '_TOPICS';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$msg = $user->lang['UNWATCHED' . $l_unwatch];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$msg = $user->lang['NO_WATCHED_SELECTED'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$msg = $user->lang['FORM_INVALID'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$message = $msg . '
' . sprintf($user->lang['RETURN_UCP'], '', '');
|
|
|
ef5584 |
meta_refresh(3, append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=subscribed"));
|
|
|
ef5584 |
trigger_error($message);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$forbidden_forums = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($config['allow_forum_notify'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forbidden_forums = $auth->acl_getf('!f_read', true);
|
|
|
ef5584 |
$forbidden_forums = array_unique(array_keys($forbidden_forums));
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_array = array(
|
|
|
ef5584 |
'SELECT' => 'f.*',
|
|
|
ef5584 |
|
|
|
ef5584 |
'FROM' => array(
|
|
|
ef5584 |
FORUMS_WATCH_TABLE => 'fw',
|
|
|
ef5584 |
FORUMS_TABLE => 'f'
|
|
|
ef5584 |
),
|
|
|
ef5584 |
|
|
|
ef5584 |
'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '
|
|
|
ef5584 |
AND f.forum_id = fw.forum_id
|
|
|
ef5584 |
AND ' . $db->sql_in_set('f.forum_id', $forbidden_forums, true, true),
|
|
|
ef5584 |
|
|
|
ef5584 |
'ORDER_BY' => 'left_id'
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($config['load_db_lastread'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql_array['LEFT_JOIN'] = array(
|
|
|
ef5584 |
array(
|
|
|
ef5584 |
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
|
|
ef5584 |
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'
|
|
|
ef5584 |
)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_array['SELECT'] .= ', ft.mark_time ';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : '';
|
|
|
ef5584 |
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = $db->sql_build_query('SELECT', $sql_array);
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_id = $row['forum_id'];
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($config['load_db_lastread'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_check = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forum_check = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$unread_forum = ($row['forum_last_post_time'] > $forum_check) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
// Which folder should we display?
|
|
|
ef5584 |
if ($row['forum_status'] == ITEM_LOCKED)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$folder_image = ($unread_forum) ? 'forum_unread_locked' : 'forum_read_locked';
|
|
|
ef5584 |
$folder_alt = 'FORUM_LOCKED';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$folder_image = ($unread_forum) ? 'forum_unread' : 'forum_read';
|
|
|
ef5584 |
$folder_alt = ($unread_forum) ? 'NEW_POSTS' : 'NO_NEW_POSTS';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Create last post link information, if appropriate
|
|
|
ef5584 |
if ($row['forum_last_post_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$last_post_time = $user->format_date($row['forum_last_post_time']);
|
|
|
ef5584 |
$last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&p=" . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$last_post_time = $last_post_url = '';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_block_vars('forumrow', array(
|
|
|
ef5584 |
'FORUM_ID' => $forum_id,
|
|
|
ef5584 |
'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt),
|
|
|
ef5584 |
'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'),
|
|
|
ef5584 |
'FORUM_IMAGE' => ($row['forum_image']) ? '' : '',
|
|
|
ef5584 |
'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
|
|
|
ef5584 |
'FORUM_NAME' => $row['forum_name'],
|
|
|
ef5584 |
'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
|
|
|
ef5584 |
'LAST_POST_SUBJECT' => $row['forum_last_post_subject'],
|
|
|
ef5584 |
'LAST_POST_TIME' => $last_post_time,
|
|
|
ef5584 |
|
|
|
ef5584 |
'LAST_POST_AUTHOR' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
|
ef5584 |
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
|
ef5584 |
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
|
ef5584 |
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_LAST_POST' => $last_post_url,
|
|
|
ef5584 |
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Subscribed Topics
|
|
|
ef5584 |
if ($config['allow_topic_notify'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (empty($forbidden_forums))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$forbidden_forums = $auth->acl_getf('!f_read', true);
|
|
|
ef5584 |
$forbidden_forums = array_unique(array_keys($forbidden_forums));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$this->assign_topiclist('subscribed', $forbidden_forums);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_TOPIC_NOTIFY' => $config['allow_topic_notify'],
|
|
|
ef5584 |
'S_FORUM_NOTIFY' => $config['allow_forum_notify'],
|
|
|
ef5584 |
));
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'bookmarks':
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$config['allow_bookmarks'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_NO_DISPLAY_BOOKMARKS' => true)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$user->add_lang('viewforum');
|
|
|
ef5584 |
|
|
|
ef5584 |
if (isset($_POST['unbookmark']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$s_hidden_fields = array('unbookmark' => 1);
|
|
|
ef5584 |
$topics = (isset($_POST['t'])) ? array_keys(request_var('t', array(0 => 0))) : array();
|
|
|
ef5584 |
$url = $this->u_action;
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!sizeof($topics))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NO_BOOKMARKS_SELECTED');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($topics as $topic_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$s_hidden_fields['t'][$topic_id] = 1;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (confirm_box(true))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'DELETE FROM ' . BOOKMARKS_TABLE . '
|
|
|
ef5584 |
WHERE user_id = ' . $user->data['user_id'] . '
|
|
|
ef5584 |
AND ' . $db->sql_in_set('topic_id', $topics);
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
meta_refresh(3, $url);
|
|
|
ef5584 |
$message = $user->lang['BOOKMARKS_REMOVED'] . '
' . sprintf($user->lang['RETURN_UCP'], '', '');
|
|
|
ef5584 |
trigger_error($message);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
confirm_box(false, 'REMOVE_SELECTED_BOOKMARKS', build_hidden_fields($s_hidden_fields));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$forbidden_forums = $auth->acl_getf('!f_read', true);
|
|
|
ef5584 |
$forbidden_forums = array_unique(array_keys($forbidden_forums));
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->assign_topiclist('bookmarks', $forbidden_forums);
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'drafts':
|
|
|
ef5584 |
|
|
|
ef5584 |
$pm_drafts = ($this->p_master->p_name == 'pm') ? true : false;
|
|
|
ef5584 |
$template->assign_var('S_SHOW_DRAFTS', true);
|
|
|
ef5584 |
|
|
|
ef5584 |
$user->add_lang('posting');
|
|
|
ef5584 |
|
|
|
ef5584 |
$edit = (isset($_REQUEST['edit'])) ? true : false;
|
|
|
ef5584 |
$submit = (isset($_POST['submit'])) ? true : false;
|
|
|
ef5584 |
$draft_id = ($edit) ? intval($_REQUEST['edit']) : 0;
|
|
|
ef5584 |
$delete = (isset($_POST['delete'])) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
$s_hidden_fields = ($edit) ? '<input type="hidden" name="edit" value="' . $draft_id . '" />' : '';
|
|
|
ef5584 |
$draft_subject = $draft_message = '';
|
|
|
ef5584 |
add_form_key('ucp_draft');
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($delete)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (check_form_key('ucp_draft'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$drafts = array_keys(request_var('d', array(0 => 0)));
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($drafts))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'DELETE FROM ' . DRAFTS_TABLE . '
|
|
|
ef5584 |
WHERE ' . $db->sql_in_set('draft_id', $drafts) . '
|
|
|
ef5584 |
AND user_id = ' . $user->data['user_id'];
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$msg = $user->lang['DRAFTS_DELETED'];
|
|
|
ef5584 |
unset($drafts);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$msg = $user->lang['FORM_INVALID'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$message = $msg . '
' . sprintf($user->lang['RETURN_UCP'], '', '');
|
|
|
ef5584 |
meta_refresh(3, $this->u_action);
|
|
|
ef5584 |
trigger_error($message);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($submit && $edit)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$draft_subject = utf8_normalize_nfc(request_var('subject', '', true));
|
|
|
ef5584 |
$draft_message = utf8_normalize_nfc(request_var('message', '', true));
|
|
|
ef5584 |
if (check_form_key('ucp_draft'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($draft_message && $draft_subject)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$draft_row = array(
|
|
|
ef5584 |
'draft_subject' => $draft_subject,
|
|
|
ef5584 |
'draft_message' => $draft_message
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'UPDATE ' . DRAFTS_TABLE . '
|
|
|
ef5584 |
SET ' . $db->sql_build_array('UPDATE', $draft_row) . "
|
|
|
ef5584 |
WHERE draft_id = $draft_id
|
|
|
ef5584 |
AND user_id = " . $user->data['user_id'];
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = $user->lang['DRAFT_UPDATED'] . '
' . sprintf($user->lang['RETURN_UCP'], '', '');
|
|
|
ef5584 |
|
|
|
ef5584 |
meta_refresh(3, $this->u_action);
|
|
|
ef5584 |
trigger_error($message);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_var('ERROR', ($draft_message == '') ? $user->lang['EMPTY_DRAFT'] : (($draft_subject == '') ? $user->lang['EMPTY_DRAFT_TITLE'] : ''));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_var('ERROR', $user->lang['FORM_INVALID']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$pm_drafts)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'SELECT d.*, f.forum_name
|
|
|
ef5584 |
FROM ' . DRAFTS_TABLE . ' d, ' . FORUMS_TABLE . ' f
|
|
|
ef5584 |
WHERE d.user_id = ' . $user->data['user_id'] . ' ' .
|
|
|
ef5584 |
(($edit) ? "AND d.draft_id = $draft_id" : '') . '
|
|
|
ef5584 |
AND f.forum_id = d.forum_id
|
|
|
ef5584 |
ORDER BY d.save_time DESC';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'SELECT * FROM ' . DRAFTS_TABLE . '
|
|
|
ef5584 |
WHERE user_id = ' . $user->data['user_id'] . ' ' .
|
|
|
ef5584 |
(($edit) ? "AND draft_id = $draft_id" : '') . '
|
|
|
ef5584 |
AND forum_id = 0
|
|
|
ef5584 |
AND topic_id = 0
|
|
|
ef5584 |
ORDER BY save_time DESC';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$draftrows = $topic_ids = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($row['topic_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_ids[] = (int) $row['topic_id'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$draftrows[] = $row;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($topic_ids))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'SELECT topic_id, forum_id, topic_title
|
|
|
ef5584 |
FROM ' . TOPICS_TABLE . '
|
|
|
ef5584 |
WHERE ' . $db->sql_in_set('topic_id', array_unique($topic_ids));
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_rows[$row['topic_id']] = $row;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
unset($topic_ids);
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_var('S_EDIT_DRAFT', $edit);
|
|
|
ef5584 |
|
|
|
ef5584 |
$row_count = 0;
|
|
|
ef5584 |
foreach ($draftrows as $draft)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$link_topic = $link_forum = $link_pm = false;
|
|
|
ef5584 |
$insert_url = $view_url = $title = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
if (isset($topic_rows[$draft['topic_id']]) && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$link_topic = true;
|
|
|
ef5584 |
$view_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id']);
|
|
|
ef5584 |
$title = $topic_rows[$draft['topic_id']]['topic_title'];
|
|
|
ef5584 |
|
|
|
ef5584 |
$insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if ($auth->acl_get('f_read', $draft['forum_id']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$link_forum = true;
|
|
|
ef5584 |
$view_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $draft['forum_id']);
|
|
|
ef5584 |
$title = $draft['forum_name'];
|
|
|
ef5584 |
|
|
|
ef5584 |
$insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if ($pm_drafts)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$link_pm = true;
|
|
|
ef5584 |
$insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d=" . $draft['draft_id']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template_row = array(
|
|
|
ef5584 |
'DATE' => $user->format_date($draft['save_time']),
|
|
|
ef5584 |
'DRAFT_MESSAGE' => ($submit) ? $draft_message : $draft['draft_message'],
|
|
|
ef5584 |
'DRAFT_SUBJECT' => ($submit) ? $draft_subject : $draft['draft_subject'],
|
|
|
ef5584 |
'TITLE' => $title,
|
|
|
ef5584 |
|
|
|
ef5584 |
'DRAFT_ID' => $draft['draft_id'],
|
|
|
ef5584 |
'FORUM_ID' => $draft['forum_id'],
|
|
|
ef5584 |
'TOPIC_ID' => $draft['topic_id'],
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_VIEW' => $view_url,
|
|
|
ef5584 |
'U_VIEW_EDIT' => $this->u_action . '&edit=' . $draft['draft_id'],
|
|
|
ef5584 |
'U_INSERT' => $insert_url,
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_LINK_TOPIC' => $link_topic,
|
|
|
ef5584 |
'S_LINK_FORUM' => $link_forum,
|
|
|
ef5584 |
'S_LINK_PM' => $link_pm,
|
|
|
ef5584 |
'S_HIDDEN_FIELDS' => $s_hidden_fields
|
|
|
ef5584 |
);
|
|
|
ef5584 |
$row_count++;
|
|
|
ef5584 |
|
|
|
ef5584 |
($edit) ? $template->assign_vars($template_row) : $template->assign_block_vars('draftrow', $template_row);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$edit)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_var('S_DRAFT_ROWS', $row_count);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'L_TITLE' => $user->lang['UCP_MAIN_' . strtoupper($mode)],
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_DISPLAY_MARK_ALL' => ($mode == 'watched' || ($mode == 'drafts' && !isset($_GET['edit']))) ? true : false,
|
|
|
ef5584 |
'S_HIDDEN_FIELDS' => (isset($s_hidden_fields)) ? $s_hidden_fields : '',
|
|
|
ef5584 |
'S_UCP_ACTION' => $this->u_action,
|
|
|
ef5584 |
|
|
|
ef5584 |
'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
|
|
|
ef5584 |
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
|
|
|
ef5584 |
));
|
|
|
ef5584 |
|
|
|
ef5584 |
// Set desired template
|
|
|
ef5584 |
$this->tpl_name = 'ucp_main_' . $mode;
|
|
|
ef5584 |
$this->page_title = 'UCP_MAIN_' . strtoupper($mode);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Build and assign topiclist for bookmarks/subscribed topics
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function assign_topiclist($mode = 'subscribed', $forbidden_forum_ary = array())
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $user, $db, $template, $config, $auth, $phpbb_root_path, $phpEx;
|
|
|
ef5584 |
|
|
|
ef5584 |
$table = ($mode == 'subscribed') ? TOPICS_WATCH_TABLE : BOOKMARKS_TABLE;
|
|
|
ef5584 |
$start = request_var('start', 0);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_array = array(
|
|
|
ef5584 |
'SELECT' => 'COUNT(t.topic_id) as topics_count',
|
|
|
ef5584 |
|
|
|
ef5584 |
'FROM' => array(
|
|
|
ef5584 |
$table => 'i',
|
|
|
ef5584 |
TOPICS_TABLE => 't'
|
|
|
ef5584 |
),
|
|
|
ef5584 |
|
|
|
ef5584 |
'WHERE' => 'i.topic_id = t.topic_id
|
|
|
ef5584 |
AND i.user_id = ' . $user->data['user_id'] . '
|
|
|
ef5584 |
AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true),
|
|
|
ef5584 |
);
|
|
|
ef5584 |
$sql = $db->sql_build_query('SELECT', $sql_array);
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$topics_count = (int) $db->sql_fetchfield('topics_count');
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($topics_count)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'PAGINATION' => generate_pagination($this->u_action, $topics_count, $config['topics_per_page'], $start),
|
|
|
ef5584 |
'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start),
|
|
|
ef5584 |
'TOTAL_TOPICS' => ($topics_count == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $topics_count))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($mode == 'subscribed')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql_array = array(
|
|
|
ef5584 |
'SELECT' => 't.*, f.forum_name',
|
|
|
ef5584 |
|
|
|
ef5584 |
'FROM' => array(
|
|
|
ef5584 |
TOPICS_WATCH_TABLE => 'tw',
|
|
|
ef5584 |
TOPICS_TABLE => 't'
|
|
|
ef5584 |
),
|
|
|
ef5584 |
|
|
|
ef5584 |
'WHERE' => 'tw.user_id = ' . $user->data['user_id'] . '
|
|
|
ef5584 |
AND t.topic_id = tw.topic_id
|
|
|
ef5584 |
AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true),
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
'ORDER_BY' => 't.topic_last_post_time DESC'
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_array['LEFT_JOIN'] = array();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql_array = array(
|
|
|
ef5584 |
'SELECT' => 't.*, f.forum_name, b.topic_id as b_topic_id',
|
|
|
ef5584 |
|
|
|
ef5584 |
'FROM' => array(
|
|
|
ef5584 |
BOOKMARKS_TABLE => 'b',
|
|
|
ef5584 |
),
|
|
|
ef5584 |
|
|
|
ef5584 |
'WHERE' => 'b.user_id = ' . $user->data['user_id'] . '
|
|
|
ef5584 |
AND ' . $db->sql_in_set('f.forum_id', $forbidden_forum_ary, true, true),
|
|
|
ef5584 |
|
|
|
ef5584 |
'ORDER_BY' => 't.topic_last_post_time DESC'
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_array['LEFT_JOIN'] = array();
|
|
|
ef5584 |
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'b.topic_id = t.topic_id');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id = f.forum_id');
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($config['load_db_lastread'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']);
|
|
|
ef5584 |
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']);
|
|
|
ef5584 |
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time AS forum_mark_time';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($config['load_db_track'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']);
|
|
|
ef5584 |
$sql_array['SELECT'] .= ', tp.topic_posted';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = $db->sql_build_query('SELECT', $sql_array);
|
|
|
ef5584 |
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
|
|
ef5584 |
|
|
|
ef5584 |
$topic_list = $topic_forum_list = $global_announce_list = $rowset = array();
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id'];
|
|
|
ef5584 |
|
|
|
ef5584 |
$topic_list[] = $topic_id;
|
|
|
ef5584 |
$rowset[$topic_id] = $row;
|
|
|
ef5584 |
|
|
|
ef5584 |
$topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread']) ? $row['forum_mark_time'] : 0;
|
|
|
ef5584 |
$topic_forum_list[$row['forum_id']]['topics'][] = $topic_id;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($row['topic_type'] == POST_GLOBAL)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$global_announce_list[] = $topic_id;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$topic_tracking_info = array();
|
|
|
ef5584 |
if ($config['load_db_lastread'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
foreach ($topic_forum_list as $f_id => $topic_row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), ($f_id == 0) ? $global_announce_list : false);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
foreach ($topic_forum_list as $f_id => $topic_row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], $global_announce_list);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($topic_list as $topic_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$row = &$rowset[$topic_id];
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_id = $row['forum_id'];
|
|
|
ef5584 |
$topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id'];
|
|
|
ef5584 |
|
|
|
ef5584 |
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
// Replies
|
|
|
ef5584 |
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($row['topic_status'] == ITEM_MOVED && !empty($row['topic_moved_id']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$topic_id = $row['topic_moved_id'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get folder img, topic status/type related information
|
|
|
ef5584 |
$folder_img = $folder_alt = $topic_type = '';
|
|
|
ef5584 |
topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
|
|
|
ef5584 |
|
|
|
ef5584 |
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id");
|
|
|
ef5584 |
|
|
|
ef5584 |
// Send vars to template
|
|
|
ef5584 |
$template->assign_block_vars('topicrow', array(
|
|
|
ef5584 |
'FORUM_ID' => $forum_id,
|
|
|
ef5584 |
'TOPIC_ID' => $topic_id,
|
|
|
ef5584 |
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
|
|
|
ef5584 |
'LAST_POST_SUBJECT' => $row['topic_last_post_subject'],
|
|
|
ef5584 |
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
|
|
|
ef5584 |
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
|
ef5584 |
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
|
ef5584 |
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
|
ef5584 |
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
|
ef5584 |
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
|
ef5584 |
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
|
ef5584 |
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_DELETED_TOPIC' => (!$row['topic_id']) ? true : false,
|
|
|
ef5584 |
'S_GLOBAL_TOPIC' => (!$forum_id) ? true : false,
|
|
|
ef5584 |
|
|
|
ef5584 |
'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . "&t=$topic_id")),
|
|
|
ef5584 |
'REPLIES' => $replies,
|
|
|
ef5584 |
'VIEWS' => $row['topic_views'],
|
|
|
ef5584 |
'TOPIC_TITLE' => censor_text($row['topic_title']),
|
|
|
ef5584 |
'TOPIC_TYPE' => $topic_type,
|
|
|
ef5584 |
'FORUM_NAME' => $row['forum_name'],
|
|
|
ef5584 |
|
|
|
ef5584 |
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
|
|
ef5584 |
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
|
|
|
ef5584 |
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
|
|
|
ef5584 |
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
|
|
|
ef5584 |
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
|
|
|
ef5584 |
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_TOPIC_TYPE' => $row['topic_type'],
|
|
|
ef5584 |
'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false,
|
|
|
ef5584 |
'S_UNREAD_TOPIC' => $unread_topic,
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread',
|
|
|
ef5584 |
'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'],
|
|
|
ef5584 |
'U_VIEW_TOPIC' => $view_topic_url,
|
|
|
ef5584 |
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
|
|
|
ef5584 |
));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|