Changeset 1311 in ExiteCMS for trunk/profile.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/profile.php

    r1307 r1311  
    9292    $data['user_posts'] = number_format($data['user_posts']); 
    9393    $data['show_viewposts_button'] = ($data['user_posts'] > 0 and file_exists(PATH_MODULES."forum_threads_list_panel/my_posts.php")); 
    94     $result = 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 = '".$data['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); 
     94    if ($data['user_posts_unread']) { 
     95        $result = dbquery(" 
     96            SELECT count(*) as unread  
     97                FROM ".$db_prefix."posts p  
     98                    LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     99                WHERE tr.user_id = '".$data['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            , false); 
     104    } else { 
     105        $result = dbquery(" 
     106            SELECT count(*) as unread  
     107                FROM ".$db_prefix."posts p  
     108                    LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     109                WHERE tr.user_id = '".$data['user_id']."'  
     110                    AND p.post_author != '".$data['user_id']."' 
     111                    AND p.post_edituser != '".$data['user_id']."' 
     112                    AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
     113                    AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     114                        OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 
     115            , false); 
     116    }  
    95117    $data['unread_count'] = ($result ? mysql_result($result, 0) : 0); 
    96118    $data['user_email'] = str_replace("@","&#64;",$data['user_email']); 
Note: See TracChangeset for help on using the changeset viewer.