Esempio n. 1
0
if (_uid) {
    $un_opt = isset($_GET['unread']) ? str_replace('&unread=' . $_GET['unread'], '', $_SERVER['QUERY_STRING']) : $_SERVER['QUERY_STRING'] . '&unread=1';
    $frm_opt = isset($_GET['sub_forum_limit']) ? str_replace('&sub_forum_limit=' . $_GET['sub_forum_limit'], '', $_SERVER['QUERY_STRING']) : $_SERVER['QUERY_STRING'] . '&sub_forum_limit=1';
    $th_opt = isset($_GET['sub_th_limit']) ? str_replace('&sub_th_limit=' . $_GET['sub_th_limit'], '', $_SERVER['QUERY_STRING']) : $_SERVER['QUERY_STRING'] . '&sub_th_limit=1';
    $s_unread = valstat(isset($_GET['unread']));
    $s_subf = valstat(isset($_GET['sub_forum_limit']));
    $s_subt = valstat(isset($_GET['sub_th_limit']));
    $subscribed_thr = '&nbsp;| <a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?' . $th_opt . '" title="Toggle the subscribed topics filter (will only show posts from the topics you are subscribed to)">Subscribed Topics ' . $s_subt . '</a>';
    $subscribed_frm = '&nbsp;| <a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?' . $frm_opt . '" title="Toggle the subscribed forums filter (will only show posts from the forums you are subscribed to)">Subscribed Forums ' . $s_subf . '</a>';
    $unread_messages = '&nbsp;| <a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?' . $un_opt . '" title="Toggle unread message filter (will only show unread messages)">Unread Messages ' . $s_unread . '</a>';
} else {
    $subscribed_thr = $subscribed_frm = $unread_messages = '';
}
$todays_posts = '<a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?' . $dt_opt . '" title="Toggle today&#39;s posts filter (will only show posts made today)">Today&#39;s Posts ' . $s_today . '</a>';
$unanswered = '&nbsp;| <a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?' . $rp_opt . '" title="Toggle the un-answered posts filter (will show only posts that have no replies)">Unanswered Posts ' . $s_unu . '</a>';
make_perms_query($fields, $join);
if (!$unread_limit) {
    $total = (int) q_singleval('SELECT count(*) FROM phpgw_fud_msg m INNER JOIN phpgw_fud_thread t ON m.thread_id=t.id INNER JOIN phpgw_fud_forum f ON t.forum_id=f.id INNER JOIN phpgw_fud_cat c ON f.cat_id=c.id ' . (isset($_GET['sub_forum_limit']) ? 'INNER JOIN phpgw_fud_forum_notify fn ON fn.forum_id=f.id AND fn.user_id=' . _uid : '') . ' ' . (isset($_GET['sub_th_limit']) ? 'INNER JOIN phpgw_fud_thread_notify tn ON tn.thread_id=t.id AND tn.user_id=' . _uid : '') . ' ' . $join . ' LEFT JOIN phpgw_fud_mod mm ON mm.forum_id=f.id AND mm.user_id=' . _uid . ' WHERE m.apr=1 ' . $date_limit . ' ' . ($frm_id ? ' AND f.id=' . $frm_id : '') . ' ' . ($th ? ' AND t.id=' . $th : '') . ' ' . (isset($_GET['reply_count']) ? ' AND t.replies=' . (int) $_GET['reply_count'] : '') . ' ' . $perm_limit);
}
if ($unread_limit || $total) {
    /* figure out the query */
    $c = $query_type('SELECT
			m.*,
			t.thread_opt, t.root_msg_id, t.last_post_id, t.forum_id,
			f.message_threshold, f.name,
			u.id AS user_id, u.alias AS login, u.avatar_loc, u.email, u.posted_msg_count, u.join_date, u.location,
			u.sig, u.custom_status, u.icq, u.jabber, u.affero, u.aim, u.msnm, u.yahoo, u.last_visit AS time_sec, u.users_opt,
			l.name AS level_name, l.level_opt, l.img AS level_img,
			p.max_votes, p.expiry_date, p.creation_date, p.name AS poll_name, p.total_votes,
			pot.id AS cant_vote,
			r.last_view,
function forum_notify_del($user_id, $forum_id)
{
    q('DELETE FROM phpgw_fud_forum_notify WHERE forum_id=' . $forum_id . ' AND user_id=' . $user_id);
}
/* make sure that we have what appears to be a valid forum id */
if (!isset($_GET['frm_id']) || !($frm_id = (int) $_GET['frm_id'])) {
    invl_inp_err();
}
if (!isset($_GET['start']) || !($start = (int) $_GET['start'])) {
    $start = 0;
}
/* This query creates frm object that contains info about the current
 * forum, category & user's subscription status & permissions to the
 * forum.
 */
make_perms_query($fields, $join, $frm_id);
$frm = db_sab('SELECT
			f.id, f.name, f.thread_count,
			c.name AS cat_name,
			fn.forum_id AS subscribed,
			m.forum_id AS md,
			a.ann_id AS is_ann,
			' . $fields . '
		FROM phpgw_fud_forum f
		INNER JOIN phpgw_fud_cat c ON c.id=f.cat_id
		LEFT JOIN phpgw_fud_forum_notify fn ON fn.user_id=' . _uid . ' AND fn.forum_id=' . $frm_id . '
		LEFT JOIN phpgw_fud_mod m ON m.user_id=' . _uid . ' AND m.forum_id=' . $frm_id . '
		' . $join . '
		LEFT JOIN phpgw_fud_ann_forums a ON a.forum_id=' . $frm_id . '
		WHERE f.id=' . $frm_id . ' LIMIT 1');
if (!$frm) {