Changeset 1318 in ExiteCMS


Ignore:
Timestamp:
02/27/08 22:01:07 (4 years ago)
Author:
hverton
Message:

updated the forum_threads_list_panel module to make use of the thread_first_read functionality

Location:
modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel
Files:
5 edited

Legend:

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

    r1113 r1318  
    5353); 
    5454$rows = dbrows($result); 
     55$variables['rows'] = $rows; 
    5556 
    5657// make sure rowstart has a valid value 
    5758if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0; 
     59$variables['rowstart'] = $rowstart; 
    5860 
    5961$result = dbquery( 
     
    6163    INNER JOIN ".$db_prefix."forums tf USING(forum_id) 
    6264    WHERE ".groupaccess('forum_access')." AND post_author='".$id."' 
    63     ORDER BY post_datestamp DESC LIMIT $rowstart,".ITEMS_PER_PAGE 
     65    ORDER BY post_datestamp DESC  
     66    LIMIT $rowstart,".ITEMS_PER_PAGE 
    6467); 
    6568 
     
    7275 
    7376// required template variables 
    74 $variables['rows'] = $rows; 
    75 $variables['rowstart'] = $rowstart; 
    7677$variables['pagenav_url'] = FUSION_SELF."?id=".$id."&"; 
    7778 
  • modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/my_threads.php

    r844 r1318  
    3636); 
    3737$rows = dbrows($result); 
     38$variables['rows'] = $rows; 
    3839 
    3940// make sure rowstart has a valid value 
    4041if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0; 
     42$variables['rowstart'] = $rowstart; 
    4143 
    4244// get the threads for this page 
     
    4648    INNER JOIN ".$db_prefix."users tu ON tt.thread_lastuser=tu.user_id 
    4749    WHERE ".groupaccess('forum_access')." AND thread_author='".$userdata['user_id']."' 
    48     ORDER BY thread_lastpost DESC LIMIT $rowstart,".ITEMS_PER_PAGE 
     50    ORDER BY thread_lastpost DESC  
     51    LIMIT $rowstart,".ITEMS_PER_PAGE 
    4952); 
    5053 
     
    5760$variables['threads'] = $threads; 
    5861 
    59 // required template variables 
    60 $variables['rows'] = $rows; 
    61 $variables['rowstart'] = $rowstart; 
    62  
    6362// define the search body panel variables 
    6463$template_panels[] = array('type' => 'body', 'name' => 'my_threads', 'template' => 'modules.forum_threads_list_panel.my_threads.tpl'); 
  • modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/new_posts.php

    r1282 r1318  
    3737            WHERE tr.user_id = '".$userdata['user_id']."' 
    3838                AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
    39                 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     39                AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     40                    OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 
    4041            GROUP BY p.thread_id 
    4142        "); 
    4243    // update the last_read datestamp of all threads found 
    4344    while ($data = dbarray($result)) { 
    44         $result2 = dbquery("UPDATE ".$db_prefix."threads_read SET thread_last_read = '".time()."' WHERE user_id = '".$userdata['user_id']."' AND thread_id = '".$data['thread_id']."'"); 
     45        $result2 = dbquery("UPDATE ".$db_prefix."threads_read SET thread_first_read = '0', thread_last_read = '".time()."' WHERE user_id = '".$userdata['user_id']."' AND thread_id = '".$data['thread_id']."'"); 
    4546    } 
    4647    // done, fall back to the homepage 
     
    5354// check if there are any unread posts for this user 
    5455if ($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    $result = dbquery(" 
     57        SELECT count(*) as unread  
     58            FROM ".$db_prefix."posts p  
     59                LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     60            WHERE tr.user_id = '".$userdata['user_id']."'  
     61                AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
     62                AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     63                    OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 
     64        ); 
    5665} 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 } 
     66    $result = dbquery(" 
     67        SELECT count(*) as unread  
     68            FROM ".$db_prefix."posts p  
     69                LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     70            WHERE tr.user_id = '".$userdata['user_id']."'  
     71                AND p.post_author != '".$userdata['user_id']."' 
     72                AND p.post_edituser != '".$userdata['user_id']."' 
     73                AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
     74                AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     75                    OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 
     76        ); 
     77}  
    5978$variables['unread'] = ($result ? mysql_result($result, 0) : 0); 
     79 
     80// make sure rowstart has a valid value 
     81if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0; 
     82$variables['rowstart'] = $rowstart; 
    6083 
    6184// and if so, get them 
     
    6790        $result = dbquery(" 
    6891            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 
     92                FROM ".$db_prefix."posts p  
    7093                LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 
    7194                LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id 
    7295                LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 
    73                 WHERE tr.user_id = '".$userdata['user_id']."' 
     96                WHERE tr.user_id = '".$userdata['user_id']."'  
    7497                    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) 
     98                    AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     99                        OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 
    76100                GROUP BY p.thread_id 
    77             "); 
     101                ORDER BY t.thread_lastpost ASC 
     102                LIMIT ".$rowstart.", ".ITEMS_PER_PAGE 
     103            ); 
    78104    } else { 
    79105        $result = dbquery(" 
    80106            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 
     107                FROM ".$db_prefix."posts p  
    82108                LEFT JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 
    83109                LEFT JOIN ".$db_prefix."threads t ON p.thread_id = t.thread_id 
    84110                LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 
    85                 WHERE tr.user_id = '".$userdata['user_id']."' 
     111                WHERE tr.user_id = '".$userdata['user_id']."'  
    86112                    AND p.post_author != '".$userdata['user_id']."' 
    87113                    AND p.post_edituser != '".$userdata['user_id']."' 
    88114                    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) 
     115                    AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     116                        OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 
    90117                GROUP BY p.thread_id 
    91             "); 
    92     } 
     118                ORDER BY t.thread_lastpost ASC 
     119                LIMIT ".$rowstart.", ".ITEMS_PER_PAGE 
     120            ); 
     121    }  
    93122    // get the number of unread threads 
    94123    $rows = dbrows($result); 
    95124    $variables['rows'] = $rows; 
    96  
    97     // make sure rowstart has a valid value 
    98     if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0; 
    99     $variables['rowstart'] = $rowstart; 
    100125 
    101126    // add additional info to the data retrieved 
  • modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/new_posts_detail.php

    r1282 r1318  
    3737            WHERE tr.user_id = '".$userdata['user_id']."' 
    3838                AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
    39                 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     39                AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     40                    OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 
    4041            GROUP BY p.thread_id 
    4142        "); 
    4243    // update the last_read datestamp of all threads found 
    4344    while ($data = dbarray($result)) { 
    44         $result2 = dbquery("UPDATE ".$db_prefix."threads_read SET thread_last_read = '".time()."' WHERE user_id = '".$userdata['user_id']."' AND thread_id = '".$data['thread_id']."'"); 
     45        $result2 = dbquery("UPDATE ".$db_prefix."threads_read SET thread_first_read = '0', thread_last_read = '".time()."' WHERE user_id = '".$userdata['user_id']."' AND thread_id = '".$data['thread_id']."'"); 
    4546    } 
    4647    // done, fall back to the homepage 
     
    5354// check if there are any unread threads for this user 
    5455if ($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    $result = dbquery(" 
     57        SELECT count(*) as unread, tr.thread_id 
     58            FROM ".$db_prefix."posts p  
     59                LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     60            WHERE tr.user_id = '".$userdata['user_id']."'  
     61                AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
     62                AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     63                    OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 
     64            GROUP BY tr.thread_id" 
     65        ); 
    5666} 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 } 
    59 if (dbrows($result)) { 
    60     $data = dbarray($result); 
    61     $variables['threads'] = $data['unread']; 
    62 } else { 
    63     $variables['threads'] = 0; 
    64 } 
     67    $result = dbquery(" 
     68        SELECT count(*) as unread, tr.thread_id  
     69            FROM ".$db_prefix."posts p  
     70                LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     71            WHERE tr.user_id = '".$userdata['user_id']."'  
     72                AND p.post_author != '".$userdata['user_id']."' 
     73                AND p.post_edituser != '".$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                    OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 
     77            GROUP BY tr.thread_id" 
     78        ); 
     79}  
     80$variables['threads'] = dbrows($result); 
    6581 
    66 // if any data found 
     82// if there are unread threads ... 
    6783if ($variables['threads']) { 
    6884 
    69     // check if there are any unread threads for this user 
     85    // get the unread posts 
    7086    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); 
     87        $result = dbquery(" 
     88            SELECT count(*) as unread  
     89                FROM ".$db_prefix."posts p  
     90                    LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     91                WHERE tr.user_id = '".$userdata['user_id']."'  
     92                    AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
     93                    AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     94                        OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 
     95            ); 
    7296    } 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     } 
     97        $result = dbquery(" 
     98            SELECT count(*) as unread  
     99                FROM ".$db_prefix."posts p  
     100                    LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     101                WHERE tr.user_id = '".$userdata['user_id']."'  
     102                    AND p.post_author != '".$userdata['user_id']."' 
     103                    AND p.post_edituser != '".$userdata['user_id']."' 
     104                    AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
     105                    AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     106                        OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 
     107            ); 
     108    }  
     109    $variables['rows'] = ($result ? mysql_result($result, 0) : 0); 
    81110 
    82111    // make sure rowstart has a valid value 
     
    95124                    WHERE tr.user_id = '".$userdata['user_id']."' 
    96125                        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 
     126                        AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     127                            OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 
     128                    ORDER BY post_datestamp ASC  
     129                    LIMIT $rowstart,".ITEMS_PER_PAGE 
    99130                ); 
    100131    } else { 
     
    110141                        AND p.post_edituser != '".$userdata['user_id']."' 
    111142                        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 
     143                        AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     144                            OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 
     145                    ORDER BY post_datestamp ASC  
     146                    LIMIT $rowstart,".ITEMS_PER_PAGE 
    114147                ); 
    115148    } 
  • modules/common/forum_threads_list_panel/php-files/modules/forum_threads_list_panel/templates/modules.forum_threads_list_panel.new_posts_detail.tpl

    r1197 r1318  
    5151    <tr> 
    5252        <td align='center' colspan='4' class='{cycle values='tbl1,tbl2'}'> 
    53             {if $rows == 1} 
    54                 {if $threads == 1} 
     53            {if $threads == 1} 
     54                {if $rows == 1} 
    5555                    <b>{$locale.039a}</b> 
    5656                {else} 
Note: See TracChangeset for help on using the changeset viewer.