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

updated the forum_threads_list_panel module to use the new user option to show/hide the users own posts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/new_posts.php

    r1259 r1282  
    5252 
    5353// 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); 
     54if ($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} 
    5559$variables['unread'] = ($result ? mysql_result($result, 0) : 0); 
    5660 
     
    6064    $variables['posts'] = array(); 
    6165    // 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    } 
    7493    // get the number of unread threads 
    7594    $rows = dbrows($result); 
Note: See TracChangeset for help on using the changeset viewer.