Changeset 1282 in ExiteCMS


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

Location:
modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel
Files:
2 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); 
  • modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/new_posts_detail.php

    r1259 r1282  
    5252 
    5353// 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); 
     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) 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} 
    5559if (dbrows($result)) { 
    5660    $data = dbarray($result); 
     
    6064} 
    6165 
    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 
     67if ($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; 
    69124} 
    70  
    71 // make sure rowstart has a valid value 
    72 if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0; 
    73 $variables['rowstart'] = $rowstart; 
    74  
    75 // get this page of unread posts 
    76 $result = dbquery(" 
    77         SELECT p.*, f.forum_name, f.forum_cat, u.user_name, t.thread_subject, t.thread_views, t.thread_lastpost 
    78             FROM ".$db_prefix."posts p 
    79             LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 
    80             LEFT JOIN ".$db_prefix."users u ON p.post_author = u.user_id 
    81             LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id 
    82             LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 
    83             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_PAGE 
    87         ); 
    88  
    89 $posts = array(); 
    90 while ($data = dbarray($result)) { 
    91     // add poll data if present 
    92     $data['poll'] = fpm_panels_poll_exists($data['forum_id'], $data['thread_id']); 
    93     $posts[] = $data; 
    94 } 
    95  
    96 $variables['posts'] = $posts; 
    97125 
    98126// define the search body panel variables 
Note: See TracChangeset for help on using the changeset viewer.