Changeset 1311 in ExiteCMS for trunk/forum/viewforum.php
- Timestamp:
- 02/27/08 11:25:49 (4 years ago)
- File:
-
- 1 edited
-
trunk/forum/viewforum.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/viewforum.php
r1307 r1311 99 99 // update the last_read datestamp of all threads found 100 100 while ($data = dbarray($result)) { 101 $result2 = dbquery("UPDATE ".$db_prefix."threads_read SET thread_ last_read = '".time()."' WHERE user_id = '".$userdata['user_id']."' AND thread_id = '".$data['thread_id']."'");102 } 103 } 104 105 // get the number of unread posts in this forum101 $result2 = dbquery("UPDATE ".$db_prefix."threads_read SET thread_first_read = '0', thread_last_read = '".time()."' WHERE user_id = '".$userdata['user_id']."' AND thread_id = '".$data['thread_id']."'"); 102 } 103 } 104 105 // get the number of unread posts for this user in this forum 106 106 if (iMEMBER) { 107 107 if ($userdata['user_posts_unread']) { 108 // include the users own posts 109 $result = dbquery("SELECT count(*) as unread FROM ".$db_prefix."posts p LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id WHERE tr.user_id = '".$userdata['user_id']."' AND tr.forum_id = '".$forum_id."' AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read)", false); 110 } else { 111 // filter the users own posts 112 $result = dbquery("SELECT count(*) as unread FROM ".$db_prefix."posts p LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id WHERE tr.user_id = '".$userdata['user_id']."' AND tr.forum_id = '".$forum_id."' AND p.post_author != '".$userdata['user_id']."' AND p.post_edituser != '".$userdata['user_id']."' AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read)", false); 113 } 108 $result = dbquery(" 109 SELECT count(*) as unread 110 FROM ".$db_prefix."posts p 111 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 112 WHERE tr.user_id = '".$userdata['user_id']."' 113 AND tr.forum_id = '".$forum_id."' 114 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 115 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 116 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 117 ); 118 } else { 119 $result = dbquery(" 120 SELECT count(*) as unread 121 FROM ".$db_prefix."posts p 122 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 123 WHERE tr.user_id = '".$userdata['user_id']."' 124 AND tr.forum_id = '".$forum_id."' 125 AND p.post_author != '".$userdata['user_id']."' 126 AND p.post_edituser != '".$userdata['user_id']."' 127 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 128 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 129 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 130 ); 131 } 114 132 $variables['unread_posts'] = ($result ? mysql_result($result, 0) : 0); 115 133 } else {
Note: See TracChangeset
for help on using the changeset viewer.
