Changeset 1064


Ignore:
Timestamp:
11/26/09 22:50:21 (2 years ago)
Author:
savin.tiberiu@…
Message:

Added the number of unread personal messages to the "mesaje" tab in the navigation bar.

Solved ticket #248.

Review URL: http://reviewboard.infoarena.ro/r/78/

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/db/smf.php

    r1058 r1064  
    220220} 
    221221 
     222// Counts the number of unread personal messages 
     223function smf_get_pm_count($username) { 
     224   $from_cache = mem_cache_get("smf-new-pm-".$username); 
     225 
     226    if ($from_cache !== false) { 
     227        return $from_cache; 
     228    } 
     229 
     230    $user_smf_id = smf_get_member_id($username); 
     231    $prefix = IA_SMF_DB_PREFIX; 
     232    $query = " 
     233        SELECT COUNT(*) FROM {$prefix}pm_recipients 
     234        WHERE ID_MEMBER = ".$user_smf_id." AND is_read = 0 
     235    "; 
     236 
     237    // Cache value 
     238    $new_pm_count = db_query_value($query); 
     239    mem_cache_set("smf-new-pm-".$username, $new_pm_count, 600); 
     240    return $new_pm_count; 
     241} 
    222242?> 
  • trunk/www/views/sitewide.php

    r938 r1064  
    8484    <li> 
    8585        <?= getattr($pre, 'pm') ?> 
    86         <?= format_link(url_forum() . "?action=pm", "mesaje") ?> 
     86        <?php 
     87        $new_pm_count = smf_get_pm_count($identity_user['username']); 
     88        if ($new_pm_count) { ?> 
     89            <?= format_link(url_forum() . "?action=pm", "<b>mesaje (".$new_pm_count.")</b>", false) ?> 
     90        <?php } else { ?> 
     91            <?= format_link(url_forum() . "?action=pm", "mesaje") ?> 
     92        <?php } ?> 
    8793        <?= getattr($post, 'pm') ?> 
    8894    </li> 
Note: See TracChangeset for help on using the changeset viewer.