Changeset 1311 in ExiteCMS for trunk/forum/index.php


Ignore:
Timestamp:
02/27/08 11:25:49 (4 years ago)
Author:
hverton
Message:

added the new thread_first_read field to all posts unread queries, to get a more accurante unread posts number

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/forum/index.php

    r1307 r1311  
    8181    if (iMEMBER) { 
    8282        if ($userdata['user_posts_unread']) { 
    83             // include the users own posts 
    84             $result2 = 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 = '".$data['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); 
     83            $result = dbquery(" 
     84                SELECT count(*) as unread  
     85                    FROM ".$db_prefix."posts p  
     86                        LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     87                    WHERE tr.user_id = '".$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                            OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 
     91                ); 
    8592        } else { 
    86             // filter the users own posts 
    87             $result2 = 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 = '".$data['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); 
    88         } 
     93            $result = dbquery(" 
     94                SELECT count(*) as unread  
     95                    FROM ".$db_prefix."posts p  
     96                        LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     97                    WHERE tr.user_id = '".$userdata['user_id']."'  
     98                        AND p.post_author != '".$userdata['user_id']."' 
     99                        AND p.post_edituser != '".$userdata['user_id']."' 
     100                        AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
     101                        AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     102                            OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 
     103                ); 
     104        }  
    89105        $data['unread_posts'] = ($result2 ? mysql_result($result2, 0) : 0); 
    90106    } else { 
Note: See TracChangeset for help on using the changeset viewer.