|
From: Josh G. <os...@us...> - 2004-12-24 04:52:54
|
Update of /cvsroot/nanuke/nanuke0.x/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5486/includes Modified Files: functions.php functions_posting.php Log Message: - More minor forum module stuff Index: functions.php =================================================================== RCS file: /cvsroot/nanuke/nanuke0.x/includes/functions.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** functions.php 23 Dec 2004 05:37:05 -0000 1.14 --- functions.php 24 Dec 2004 04:52:43 -0000 1.15 *************** *** 224,390 **** } - // Marks a topic or form as read - function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false) - { - global $config, $db, $user; - - if ($user->data['user_id'] == ANONYMOUS) - { - return; - } - - if (!is_array($forum_id)) - { - $forum_id = array($forum_id); - } - - // Default tracking type - // $type = TRACK_NORMAL; - $current_time = ($marktime) ? $marktime : time(); - $topic_id = (int) $topic_id; - - switch ($mode) - { - case 'mark': - if ($config['load_db_lastread']) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TRACK_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . ' - AND forum_id IN (' . implode(', ', array_map('intval', $forum_id)) . ')'; - $result = $db->sql_query($sql); - - $sql_update = array(); - while ($row = $db->sql_fetchrow($result)) - { - $sql_update[] = $row['forum_id']; - } - $db->sql_freeresult($result); - - if (sizeof($sql_update)) - { - $sql = 'UPDATE ' . FORUMS_TRACK_TABLE . " - SET mark_time = $current_time - WHERE user_id = " . $user->data['user_id'] . ' - AND forum_id IN (' . implode(', ', $sql_update) . ')'; - $db->sql_query($sql); - } - - if ($sql_insert = array_diff($forum_id, $sql_update)) - { - foreach ($sql_insert as $forum_id) - { - $sql = ''; - switch (SQL_LAYER) - { - case 'mysql': - case 'mysql4': - $sql .= (($sql != '') ? ', ' : '') . '(' . $user->data['user_id'] . ", $forum_id, $current_time)"; - $sql = 'VALUES ' . $sql; - break; - - case 'mssql': - case 'sqlite': - $sql .= (($sql != '') ? ' UNION ALL ' : '') . ' SELECT ' . $user->data['user_id'] . ", $forum_id, $current_time"; - break; - - default: - $sql = 'INSERT INTO ' . FORUMS_TRACK_TABLE . ' (user_id, forum_id, mark_time) - VALUES (' . $user->data['user_id'] . ", $forum_id, $current_time)"; - $db->sql_query($sql); - $sql = ''; - } - - if ($sql) - { - $sql = 'INSERT INTO ' . FORUMS_TRACK_TABLE . " (user_id, forum_id, mark_time) $sql"; - $db->sql_query($sql); - } - } - } - unset($sql_update); - unset($sql_insert); - } - else - { - $tracking = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])) : array(); - - foreach ($forum_id as $f_id) - { - unset($tracking[$f_id]); - $tracking[$f_id][0] = base_convert($current_time - $config['board_startdate'], 10, 36); - } - - $user->set_cookie('track', serialize($tracking), time() + 31536000); - unset($tracking); - } - break; - - case 'post': - // Mark a topic as read and mark it as a topic where the user has made a post. - $type = TRACK_POSTED; - - case 'topic': - $forum_id = (int) $forum_id[0]; - - // Mark a topic as read - if ($config['load_db_lastread'] || ($config['load_db_track'] && $type == TRACK_POSTED)) - { - $sql = 'UPDATE ' . MODULE_FORUM_TOPICS_TRACK_TABLE . " - SET mark_time = $current_time - WHERE topic_id = $topic_id - AND user_id = " . $user->data['user_id'] . " - AND mark_time < $current_time"; - if (!$db->sql_query($sql) || !$db->sql_affectedrows()) - { - $type = (!isset($type)) ? TRACK_NORMAL : $type; - - $db->sql_return_on_error(true); - - $sql = 'INSERT INTO ' . MODULE_FORUM_TOPICS_TRACK_TABLE . ' (user_id, topic_id, mark_type, mark_time) - VALUES (' . $user->data['user_id'] . ", $topic_id, $type, $current_time)"; - $db->sql_query($sql); - - $db->sql_return_on_error(false); - } - } - - if (!$config['load_db_lastread']) - { - $tracking = array(); - if (isset($_COOKIE[$config['cookie_name'] . '_track'])) - { - $tracking = unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])); - - // If the cookie grows larger than 2000 characters we will remove - // the smallest value - if (strlen($_COOKIE[$config['cookie_name'] . '_track']) > 2000) - { - foreach ($tracking as $f => $t_ary) - { - if (!isset($m_value) || min($t_ary) < $m_value) - { - $m_value = min($t_ary); - $m_tkey = array_search($m_value, $t_ary); - $m_fkey = $f; - } - } - unset($tracking[$m_fkey][$m_tkey]); - } - } - - if (base_convert($tracking[$forum_id][0], 36, 10) < $current_time) - { - $tracking[$forum_id][base_convert($topic_id, 10, 36)] = base_convert($current_time - $config['board_startdate'], 10, 36); - - $user->set_cookie('track', serialize($tracking), time() + 31536000); - } - unset($tracking); - } - break; - } - } - - // Pagination routine, generates page number sequence // tpl_prefix is for using different pagination blocks at one page --- 224,227 ---- Index: functions_posting.php =================================================================== RCS file: /cvsroot/nanuke/nanuke0.x/includes/functions_posting.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** functions_posting.php 23 Dec 2004 05:37:06 -0000 1.5 --- functions_posting.php 24 Dec 2004 04:52:43 -0000 1.6 *************** *** 99,103 **** $sql = 'SELECT MAX(post_id) as last_post_id ! FROM ' . MODULE_FORUM_POSTS_TABLE . " WHERE post_approved = 1 AND {$type}_id = $id"; --- 99,103 ---- $sql = 'SELECT MAX(post_id) as last_post_id ! FROM ' . POSTS_TABLE . " WHERE post_approved = 1 AND {$type}_id = $id"; *************** *** 108,112 **** { $sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username ! FROM ' . MODULE_FORUM_POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE p.poster_id = u.user_id AND p.post_id = ' . $row['last_post_id']; --- 108,112 ---- { $sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username ! FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE p.poster_id = u.user_id AND p.post_id = ' . $row['last_post_id']; *************** *** 793,797 **** // Go ahead and pull all data for this topic $sql = 'SELECT u.username, u.user_id, p.post_id, p.post_username, p.post_subject, p.post_text, p.enable_smilies, p.bbcode_uid, p.bbcode_bitfield, p.post_time ! FROM ' . MODULE_FORUM_POSTS_TABLE . ' p, ' . USERS_TABLE . " u WHERE p.topic_id = $topic_id AND p.poster_id = u.user_id --- 793,797 ---- // Go ahead and pull all data for this topic $sql = 'SELECT u.username, u.user_id, p.post_id, p.post_username, p.post_subject, p.post_text, p.enable_smilies, p.bbcode_uid, p.bbcode_bitfield, p.post_time ! FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u WHERE p.topic_id = $topic_id AND p.poster_id = u.user_id *************** *** 905,909 **** // -- get forum_userids || topic_userids $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber ! FROM ' . (($topic_notification) ? MODULE_FORUM_TOPICS_WATCH_TABLE : MODULE_FORUM_FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . " AND w.user_id NOT IN ($sql_ignore_users) --- 905,909 ---- // -- get forum_userids || topic_userids $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber ! FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . " AND w.user_id NOT IN ($sql_ignore_users) *************** *** 937,941 **** $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber ! FROM ' . MODULE_FORUM_FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u WHERE fw.forum_id = $forum_id AND fw.user_id NOT IN ($sql_ignore_users) --- 937,941 ---- $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber ! FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u WHERE fw.forum_id = $forum_id AND fw.user_id NOT IN ($sql_ignore_users) *************** *** 1056,1060 **** if (isset($update_notification['topic']) && sizeof($update_notification['topic'])) { ! $db->sql_query('UPDATE ' . MODULE_FORUM_TOPICS_WATCH_TABLE . " SET notify_status = 1 WHERE topic_id = $topic_id --- 1056,1060 ---- if (isset($update_notification['topic']) && sizeof($update_notification['topic'])) { ! $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . " SET notify_status = 1 WHERE topic_id = $topic_id *************** *** 1064,1068 **** if (isset($update_notification['forum']) && sizeof($update_notification['forum'])) { ! $db->sql_query('UPDATE ' . MODULE_FORUM_FORUMS_WATCH_TABLE . " SET notify_status = 1 WHERE forum_id = $forum_id --- 1064,1068 ---- if (isset($update_notification['forum']) && sizeof($update_notification['forum'])) { ! $db->sql_query('UPDATE ' . FORUMS_WATCH_TABLE . " SET notify_status = 1 WHERE forum_id = $forum_id *************** *** 1073,1077 **** if (isset($delete_ids['topic']) && sizeof($delete_ids['topic'])) { ! $db->sql_query('DELETE FROM ' . MODULE_FORUM_TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id AND user_id IN (" . implode(', ', $delete_ids['topic']) . ")"); --- 1073,1077 ---- if (isset($delete_ids['topic']) && sizeof($delete_ids['topic'])) { ! $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id AND user_id IN (" . implode(', ', $delete_ids['topic']) . ")"); *************** *** 1080,1084 **** if (isset($delete_ids['forum']) && sizeof($delete_ids['forum'])) { ! $db->sql_query('DELETE FROM ' . MODULE_FORUM_FORUMS_WATCH_TABLE . " WHERE forum_id = $forum_id AND user_id IN (" . implode(', ', $delete_ids['forum']) . ")"); --- 1080,1084 ---- if (isset($delete_ids['forum']) && sizeof($delete_ids['forum'])) { ! $db->sql_query('DELETE FROM ' . FORUMS_WATCH_TABLE . " WHERE forum_id = $forum_id AND user_id IN (" . implode(', ', $delete_ids['forum']) . ")"); |