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/modules/user_info_panel/user_info_panel.php

    r1307 r1311  
    1818$variables = array(); 
    1919 
    20 if (isset($userdata['user_id'])) { 
     20if (iMEMBER) { 
    2121    // store the user's ID and name 
    2222    $variables['user_id'] = isset($userdata['user_id'])?$userdata['user_id']:0; 
     
    3131        $variables['adminpage5'] = checkrights("T"); 
    3232    } 
     33    // new PM messages 
    3334    $variables['new_pm_msg'] = dbcount("(pmindex_id)", "pm_index", "pmindex_user_id ='".$userdata['user_id']."' AND pmindex_to_id='".$userdata['user_id']."' AND pmindex_read_datestamp = '0'"); 
     35    // new forum messages 
    3436    if ($userdata['user_posts_unread']) { 
    35         // include the users own posts 
    36         $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 = '".$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); 
     37        $result = dbquery(" 
     38            SELECT count(*) as unread  
     39                FROM ".$db_prefix."posts p  
     40                    LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     41                WHERE tr.user_id = '".$userdata['user_id']."'  
     42                    AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
     43                    AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     44                        OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 
     45            ); 
    3746    } else { 
    38         // filter the users own posts 
    39         $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 = '".$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); 
    40     } 
     47        $result = dbquery(" 
     48            SELECT count(*) as unread  
     49                FROM ".$db_prefix."posts p  
     50                    LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id  
     51                WHERE tr.user_id = '".$userdata['user_id']."'  
     52                    AND p.post_author != '".$userdata['user_id']."' 
     53                    AND p.post_edituser != '".$userdata['user_id']."' 
     54                    AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 
     55                    AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 
     56                        OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 
     57            ); 
     58    }  
    4159    $variables['new_post_msg'] = ($result ? mysql_result($result, 0) : 0); 
    4260    // check if the forum_threads_list_panel module is installed 
Note: See TracChangeset for help on using the changeset viewer.