Changeset 1280 in ExiteCMS for trunk/forum/viewthread.php


Ignore:
Timestamp:
02/14/08 15:02:48 (4 years ago)
Author:
hverton
Message:

added user option to show/hide the users own posts from the unread posts count

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/forum/viewthread.php

    r1260 r1280  
    191191// number of unread posts in this thread 
    192192if (iMEMBER) { 
    193     $result = dbquery(" 
    194         SELECT count(*) as unread, tr.thread_last_read, tr.thread_page 
    195             FROM ".$db_prefix."posts p 
    196             LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 
    197             WHERE tr.user_id = '".$userdata['user_id']."'  
    198                 AND tr.thread_id = '".$thread_id."'  
    199                 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].")  
    200                 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
    201             GROUP BY tr.thread_id 
    202         "); 
     193    if ($userdata['user_posts_unread']) { 
     194        // include the users own posts 
     195        $result = dbquery(" 
     196            SELECT count(*) as unread, tr.thread_last_read, tr.thread_page 
     197                FROM ".$db_prefix."posts p 
     198                LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 
     199                WHERE tr.user_id = '".$userdata['user_id']."'  
     200                    AND tr.thread_id = '".$thread_id."'  
     201                    AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].")  
     202                    AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     203                GROUP BY tr.thread_id 
     204            "); 
     205    } else { 
     206        // filter the users own posts 
     207        $result = dbquery(" 
     208            SELECT count(*) as unread, tr.thread_last_read, tr.thread_page 
     209                FROM ".$db_prefix."posts p 
     210                LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 
     211                WHERE tr.user_id = '".$userdata['user_id']."' 
     212                    AND p.post_author != '".$userdata['user_id']."' 
     213                    AND p.post_edituser != '".$userdata['user_id']."' 
     214                    AND tr.thread_id = '".$thread_id."'  
     215                    AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].")  
     216                    AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     217                GROUP BY tr.thread_id 
     218            "); 
     219    } 
    203220    if (dbrows($result)) { 
    204221        $data = dbarray($result); 
Note: See TracChangeset for help on using the changeset viewer.