Changeset 1318 in ExiteCMS for modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/new_posts.php
- Timestamp:
- 02/27/08 22:01:07 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/new_posts.php
r1282 r1318 37 37 WHERE tr.user_id = '".$userdata['user_id']."' 38 38 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 39 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 39 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 40 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 40 41 GROUP BY p.thread_id 41 42 "); 42 43 // update the last_read datestamp of all threads found 43 44 while ($data = dbarray($result)) { 44 $result2 = dbquery("UPDATE ".$db_prefix."threads_read SET thread_ last_read = '".time()."' WHERE user_id = '".$userdata['user_id']."' AND thread_id = '".$data['thread_id']."'");45 $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']."'"); 45 46 } 46 47 // done, fall back to the homepage … … 53 54 // check if there are any unread posts for this user 54 55 if ($userdata['user_posts_unread']) { 55 $result = dbquery("SELECT count(*) as unread, sum(tr.thread_page) AS pages 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 (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); 56 $result = dbquery(" 57 SELECT count(*) as unread 58 FROM ".$db_prefix."posts p 59 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 60 WHERE tr.user_id = '".$userdata['user_id']."' 61 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 62 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 63 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 64 ); 56 65 } else { 57 $result = dbquery("SELECT count(*) as unread, sum(tr.thread_page) AS pages 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 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); 58 } 66 $result = dbquery(" 67 SELECT count(*) as unread 68 FROM ".$db_prefix."posts p 69 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 70 WHERE tr.user_id = '".$userdata['user_id']."' 71 AND p.post_author != '".$userdata['user_id']."' 72 AND p.post_edituser != '".$userdata['user_id']."' 73 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 74 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 75 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 76 ); 77 } 59 78 $variables['unread'] = ($result ? mysql_result($result, 0) : 0); 79 80 // make sure rowstart has a valid value 81 if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0; 82 $variables['rowstart'] = $rowstart; 60 83 61 84 // and if so, get them … … 67 90 $result = dbquery(" 68 91 SELECT p.forum_id, p.thread_id, count( * ) AS unread, f.forum_name, f.forum_cat, t.thread_subject, t.thread_views, t.thread_lastpost, MIN( p.post_id ) AS post_id 69 FROM ".$db_prefix."posts p 92 FROM ".$db_prefix."posts p 70 93 LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 71 94 LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id 72 95 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 73 WHERE tr.user_id = '".$userdata['user_id']."' 96 WHERE tr.user_id = '".$userdata['user_id']."' 74 97 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 75 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 98 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 99 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 76 100 GROUP BY p.thread_id 77 "); 101 ORDER BY t.thread_lastpost ASC 102 LIMIT ".$rowstart.", ".ITEMS_PER_PAGE 103 ); 78 104 } else { 79 105 $result = dbquery(" 80 106 SELECT p.forum_id, p.thread_id, count( * ) AS unread, f.forum_name, f.forum_cat, t.thread_subject, t.thread_views, t.thread_lastpost, MIN( p.post_id ) AS post_id 81 FROM ".$db_prefix."posts p 107 FROM ".$db_prefix."posts p 82 108 LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 83 109 LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id 84 110 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 85 WHERE tr.user_id = '".$userdata['user_id']."' 111 WHERE tr.user_id = '".$userdata['user_id']."' 86 112 AND p.post_author != '".$userdata['user_id']."' 87 113 AND p.post_edituser != '".$userdata['user_id']."' 88 114 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 89 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 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))) 90 117 GROUP BY p.thread_id 91 "); 92 } 118 ORDER BY t.thread_lastpost ASC 119 LIMIT ".$rowstart.", ".ITEMS_PER_PAGE 120 ); 121 } 93 122 // get the number of unread threads 94 123 $rows = dbrows($result); 95 124 $variables['rows'] = $rows; 96 97 // make sure rowstart has a valid value98 if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;99 $variables['rowstart'] = $rowstart;100 125 101 126 // add additional info to the data retrieved
Note: See TracChangeset
for help on using the changeset viewer.
