Changeset 1318 in ExiteCMS for modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/new_posts_detail.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_detail.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 threads 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) GROUP BY tr.thread_id", false); 56 $result = dbquery(" 57 SELECT count(*) as unread, tr.thread_id 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 GROUP BY tr.thread_id" 65 ); 56 66 } 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_edittime != '".$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) GROUP BY tr.thread_id", false); 58 } 59 if (dbrows($result)) { 60 $data = dbarray($result); 61 $variables['threads'] = $data['unread']; 62 } else { 63 $variables['threads'] = 0; 64 } 67 $result = dbquery(" 68 SELECT count(*) as unread, tr.thread_id 69 FROM ".$db_prefix."posts p 70 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 71 WHERE tr.user_id = '".$userdata['user_id']."' 72 AND p.post_author != '".$userdata['user_id']."' 73 AND p.post_edituser != '".$userdata['user_id']."' 74 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) 76 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 77 GROUP BY tr.thread_id" 78 ); 79 } 80 $variables['threads'] = dbrows($result); 65 81 66 // if any data found82 // if there are unread threads ... 67 83 if ($variables['threads']) { 68 84 69 // check if there are any unread threads for this user85 // get the unread posts 70 86 if ($userdata['user_posts_unread']) { 71 $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); 87 $result = dbquery(" 88 SELECT count(*) as unread 89 FROM ".$db_prefix."posts p 90 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 91 WHERE tr.user_id = '".$userdata['user_id']."' 92 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 93 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 94 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 95 ); 72 96 } else { 73 $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); 74 } 75 if (dbrows($result)) { 76 $data = dbarray($result); 77 $variables['rows'] = $data['unread']; 78 } else { 79 $variables['rows'] = 0; 80 } 97 $result = dbquery(" 98 SELECT count(*) as unread 99 FROM ".$db_prefix."posts p 100 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 101 WHERE tr.user_id = '".$userdata['user_id']."' 102 AND p.post_author != '".$userdata['user_id']."' 103 AND p.post_edituser != '".$userdata['user_id']."' 104 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 105 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 106 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 107 ); 108 } 109 $variables['rows'] = ($result ? mysql_result($result, 0) : 0); 81 110 82 111 // make sure rowstart has a valid value … … 95 124 WHERE tr.user_id = '".$userdata['user_id']."' 96 125 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 97 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 98 ORDER BY post_datestamp ASC LIMIT $rowstart,".ITEMS_PER_PAGE 126 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 127 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 128 ORDER BY post_datestamp ASC 129 LIMIT $rowstart,".ITEMS_PER_PAGE 99 130 ); 100 131 } else { … … 110 141 AND p.post_edituser != '".$userdata['user_id']."' 111 142 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 112 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 113 ORDER BY post_datestamp ASC LIMIT $rowstart,".ITEMS_PER_PAGE 143 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 144 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 145 ORDER BY post_datestamp ASC 146 LIMIT $rowstart,".ITEMS_PER_PAGE 114 147 ); 115 148 }
Note: See TracChangeset
for help on using the changeset viewer.
