Changeset 1282 in ExiteCMS
- Timestamp:
- 02/14/08 15:23:58 (4 years ago)
- Location:
- modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel
- Files:
-
- 2 edited
-
new_posts.php (modified) (2 diffs)
-
new_posts_detail.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/new_posts.php
r1259 r1282 52 52 53 53 // check if there are any unread posts for this user 54 $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); 54 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 } 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 } 55 59 $variables['unread'] = ($result ? mysql_result($result, 0) : 0); 56 60 … … 60 64 $variables['posts'] = array(); 61 65 // get all threads with unread posts, and a count of the unread posts per thread 62 $result = dbquery(" 63 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 64 FROM ".$db_prefix."posts p 65 LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 66 LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id 67 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 68 WHERE tr.user_id = '".$userdata['user_id']."' 69 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 70 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 71 GROUP BY p.thread_id 72 "); 73 66 if ($userdata['user_posts_unread']) { 67 $result = dbquery(" 68 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 70 LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 71 LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id 72 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 73 WHERE tr.user_id = '".$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 GROUP BY p.thread_id 77 "); 78 } else { 79 $result = dbquery(" 80 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 82 LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 83 LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id 84 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 85 WHERE tr.user_id = '".$userdata['user_id']."' 86 AND p.post_author != '".$userdata['user_id']."' 87 AND p.post_edituser != '".$userdata['user_id']."' 88 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) 90 GROUP BY p.thread_id 91 "); 92 } 74 93 // get the number of unread threads 75 94 $rows = dbrows($result); -
modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/new_posts_detail.php
r1259 r1282 52 52 53 53 // check if there are any unread threads for this user 54 $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); 54 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 } 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 } 55 59 if (dbrows($result)) { 56 60 $data = dbarray($result); … … 60 64 } 61 65 62 // check if there are any unread threads for this user 63 $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); 64 if (dbrows($result)) { 65 $data = dbarray($result); 66 $variables['rows'] = $data['unread']; 67 } else { 68 $variables['rows'] = 0; 66 // if any data found 67 if ($variables['threads']) { 68 69 // check if there are any unread threads for this user 70 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); 72 } 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 } 81 82 // make sure rowstart has a valid value 83 if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0; 84 $variables['rowstart'] = $rowstart; 85 86 // get this page of unread posts 87 if ($userdata['user_posts_unread']) { 88 $result = dbquery(" 89 SELECT p.*, f.forum_name, f.forum_cat, u.user_name, t.thread_subject, t.thread_views, t.thread_lastpost 90 FROM ".$db_prefix."posts p 91 LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 92 LEFT JOIN ".$db_prefix."users u ON p.post_author = u.user_id 93 LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id 94 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 95 WHERE tr.user_id = '".$userdata['user_id']."' 96 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 99 ); 100 } else { 101 $result = dbquery(" 102 SELECT p.*, f.forum_name, f.forum_cat, u.user_name, t.thread_subject, t.thread_views, t.thread_lastpost 103 FROM ".$db_prefix."posts p 104 LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 105 LEFT JOIN ".$db_prefix."users u ON p.post_author = u.user_id 106 LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id 107 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 108 WHERE tr.user_id = '".$userdata['user_id']."' 109 AND p.post_author != '".$userdata['user_id']."' 110 AND p.post_edituser != '".$userdata['user_id']."' 111 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 114 ); 115 } 116 117 $posts = array(); 118 while ($data = dbarray($result)) { 119 // add poll data if present 120 $data['poll'] = fpm_panels_poll_exists($data['forum_id'], $data['thread_id']); 121 $posts[] = $data; 122 } 123 $variables['posts'] = $posts; 69 124 } 70 71 // make sure rowstart has a valid value72 if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;73 $variables['rowstart'] = $rowstart;74 75 // get this page of unread posts76 $result = dbquery("77 SELECT p.*, f.forum_name, f.forum_cat, u.user_name, t.thread_subject, t.thread_views, t.thread_lastpost78 FROM ".$db_prefix."posts p79 LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id80 LEFT JOIN ".$db_prefix."users u ON p.post_author = u.user_id81 LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id82 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id83 WHERE tr.user_id = '".$userdata['user_id']."'84 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].")85 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read)86 ORDER BY post_datestamp ASC LIMIT $rowstart,".ITEMS_PER_PAGE87 );88 89 $posts = array();90 while ($data = dbarray($result)) {91 // add poll data if present92 $data['poll'] = fpm_panels_poll_exists($data['forum_id'], $data['thread_id']);93 $posts[] = $data;94 }95 96 $variables['posts'] = $posts;97 125 98 126 // define the search body panel variables
Note: See TracChangeset
for help on using the changeset viewer.
