1
PatTang
Multimenu PM Inbox Count
  • 2008/3/10 3:25

  • PatTang

  • Just popping in

  • Posts: 9

  • Since: 2008/3/8 4


I have created a User Menu same as the default but I need the In-box message count to show in a different colour from the rest of the link text, like it does in the default menu it shows red so it stands out.
Also i wish to show the logged in Display name in the menu, i can show ID but thats just a number.

Using 2.2.6

2
blueteen
Re: Multimenu PM Inbox Count
  • 2008/3/10 9:14

  • blueteen

  • Quite a regular

  • Posts: 379

  • Since: 2004/7/16


Hello,
in your menu, you can use something like this :
PM <font color="red">({pm_new})font>


Same with {pm_total}

For your second question, you can modify multimenu's code to create your own variable (to display name instead of user_id).

Here's a file with this new variable {user_name} : /modules/multiMenu/blocks/multimenu_functions.php
Based on multimenu 1.9 code (rc1 but really stable since months).

/**
* XOOPS - PHP Content Management System
* Copyright (c) 2001 - 2006 
*
* Module: multiMenu 1.90
* Licence : GPL
* Authors :
*           - solo (http://www.wolfpackclan.com/wolfactory)
*            - herve
*            - blueteen
*            - DuGris
*/

function multimenu_makelink$options$myrow ) {
    global 
$xoopsUser$xoopsConfig;
    global 
$columns_limit$columns_limit_drop$align;

    
$myts =& MyTextSanitizer::getInstance();
    
$imenu['submenu'] = $myrow['submenu'];

    
///////////////////////// Create Titles /////////////////////////
    // Link title
    
if ( eregi('{alt}'$myrow['title']) )  {
        
$titles explode'{alt}'$myrow['title'] );
        
$title $myts->makeTareaData4Show($titles[0]);
        
$alt_title strip_tags$myts->makeTareaData4Show$titles[1] ) );
     } else {
        
$title $myts->makeTareaData4Show($myrow['title']);
        
$alt_title strip_tags($myts->makeTareaData4Show($myrow['title']));
    }

    if ( ((
$options[0] == 'dyn_02' OR $options[0] == 'dyn_03' )
    AND ( 
$myrow['submenu'] == 1  OR $myrow['submenu'] == ) ) OR $options[0] == 'dyn_06' OR $options[0] == 'dyn_07' OR $options[0] == 'dyn_10' )
    { 
$title addslashes($title);  $alt_title addslashes($alt_title); }  // Get ride of special characters which cause dynamic's menu crash

    // If link title is too long...
    
if ( $options[4] ) {
         
//if ( $options[0] == 'dyn_06') { $title = strip_tags($title); } //Get ride of html if context menu
        
if (strlen($title) >= $options[5]) {
            
$mm_title $myts->makeTboxData4Show(substr($title,0,($options[5]-1)))."...";
        } else {
            
$mm_title $myts->makeTareaData4Show($title);
        }
        
$imenu['title'] = $mm_title;
    } else {
        
$imenu['title'] = '';
    }

    
// PM detection and conversion
    
if ( eregi("{pm_new}"$title) || eregi("{pm_readed}"$title) || eregi("{pm_total}"$title) || eregi("{user_id}"$title) || eregi("{user_name}"$title) ) {  //xoops username
        
$new_messages 0;
        
$old_messages 0;
        
$som 0;
        
$user_id 0;
        
$user_name '';//xoops username
        
if (is_object($xoopsUser)) {
            
$user_id $xoopsUser->getVar('uid');
            
$user_name XoopsUser::getUnameFromId($user_id);//xoops username
            
$pm_handler =& xoops_gethandler('privmessage');
            
$uid $xoopsUser->getVar('uid');
            
$criteria_new = new CriteriaCompo(new Criteria('read_msg'0));
            
$criteria_new->add(new Criteria('to_userid'$xoopsUser->getVar('uid')));
            
$new_messages $pm_handler->getCount($criteria_new);

            
$criteria_old = new CriteriaCompo(new Criteria('read_msg'1));
            
$criteria_old->add(new Criteria('to_userid'$xoopsUser->getVar('uid')));
            
$old_messages $pm_handler->getCount($criteria_old);
            
$som =  $old_messages +  $new_messages;

            
$title preg_replace('/{pm_new}/',     $new_messages,     $title);
            
$title preg_replace('/{pm_readed}/',     $old_messages,     $title);
            
$title preg_replace('/{pm_total}/',     $som,         $title);
            
$title preg_replace('/{user_id}/',     $user_id,         $title);
            
$title preg_replace('/{user_name}/',     $user_name,         $title);//xoops username

            
$imenu['title'] = $title;

        } else {
            
$imenu['title'] = 'Message';
        }

        
//    $links = XOOPS_URL."/viewpmsg.php"; // Unquote if you want to automatically send to the PM box
    
}

    
// Create and remove html for alt title
    // $alt_title = strip_tags($myts->makeTareaData4Show($title));
    
$imenu['alt_title'] = $alt_title;

    if (
is_object($xoopsUser))    {
        
$user_id $xoopsUser->getVar('uid');
        
$user_name XoopsUser::getUnameFromId($user_id);//xoops username
    
}

    
//gère ces balises PM dans le title et le alt (pour les blocs)
    
if ( eregi("{pm_new}"$imenu['alt_title']) || eregi("{pm_readed}"$imenu['alt_title']) ||
         
eregi("{pm_total}"$imenu['alt_title']) || eregi("{user_id}"$imenu['alt_title']) || eregi("{user_name}"$imenu['alt_title']) ) {      //xoops username

        
$imenu['alt_title'] = preg_replace('/{pm_new}/'$new_messages$imenu['alt_title']);
        
$imenu['alt_title'] = preg_replace('/{pm_readed}/'$old_messages$imenu['alt_title']);
        
$imenu['alt_title'] = preg_replace('/{pm_total}/'$som$imenu['alt_title']);
        
$imenu['alt_title'] = preg_replace('/{user_id}/'$user_id$imenu['alt_title']);
        
$imenu['alt_title'] = preg_replace('/{user_name}/'$user_name$imenu['alt_title']);
    }
    
//fin gestion de ces balises PM dans le title et le alt (pour les blocs)


    ///////////////////////// Create urls /////////////////////////
    // Link url
    
if ($myrow['link']) {
        
$user_id 0;
        
$user_name '';//xoops username
        
if (is_object($xoopsUser)) {
            
$user_id $xoopsUser->getVar('uid');
            
$user_name XoopsUser::getUnameFromId($user_id);//xoops username
            
}

        
// Link Type
        
if ((eregi("mailto:"$myrow['link'])) || (eregi("http://"$myrow['link']))  ||
            (
eregi("https://"$myrow['link'])) || (eregi("file://"$myrow['link']))  || (eregi("ftp://"$myrow['link']))) {

            
$link $myrow['link'];
            
$link preg_replace('/{user_id}/'$user_id$link);
            
$link preg_replace('/{user_name}/'$user_name$link);//xoops username
        
} else {
            
$link XOOPS_URL."/".$myrow['link'];
            
$link preg_replace('/{user_id}/'$user_id$link);
            
$link preg_replace('/{user_name}/'$user_name$link);//xoops username
        
}

        
// Target function
        
if ($myrow['target'] != '_self') {
            
$target 'target="'.$myrow['target'].'" ';
        } else {
            
$target ' ';
        }
        
$imenu['target'] = $target;
        
$imenu['target_context'] = $myrow['target']; // utilisé dans le menu contextuel 2

        // Create link
        
$imenu['link'] = '.$link.'" '.$target.'title="'.$alt_title.'">';
        
$imenu['linkurl'] = $link;
        
$imenu['a'] = '';
    } else {
        
$imenu['link'] = '';
        
$imenu['linkurl'] = '';
        
$imenu['a'] = '';
    }

    
///////////////////////// Create images /////////////////////////
    // Create image
    
if( $myrow['imageurl'] AND $options[6] ) {

//        Image type : relative or absolute link
/*
        if ((eregi("http://", $myrow['imageurl'])) || (eregi("file://", $myrow['imageurl'])) || (eregi("https://", $myrow['imageurl']))) {
            $image = $myrow['imageurl'];
        } else {
*/
            
$image XOOPS_URL.'/uploads/multiMenu/'.$myrow['imageurl'];
/*
        }
*/

        // Theme and module tag replace
        
$image str_replace('{theme}'$xoopsConfig['theme_set'], $image);
        if ( !empty(
$xoopsModule) ) {
               
$image str_replace('{module}'$xoopsModule->getVar('dirname'), $image); } else { $image str_replace('{module}''default'$image);
        }

        
// Image resize if bigger
        
if     ( $options[7] == '' ) {
            
$image_width '';
            
$width '1';
        } else {
            
$image_size getimagesize("$image");
            
$width     $image_size[0];
            if (
$options[1] <= $width) {
                
$image_width 'width="'.$options[7].'" ';
            } else {
                
$image_width 'width="'.$width.'" ';
            }
        }

        
// Create image
        
$imenu['image'] = '.$image.'" '.$image_width.'alt="'.$alt_title.'" '.$align.' style="vertical-align:middle;" />';
        
$imenu['imageurl'] = $image;

        if ( !
$width ) {
            
$imenu['image'] = '.XOOPS_URL.'/modules/multiMenu/images/error.gif" '.$image_width.'alt="'.$alt_title.'" '.$align.' style="vertical-align:middle;" />';
        }
    } else {
        
$imenu['image'] = "";
    }

    return 
$imenu;
}

?>

3
PatTang
Re: Multimenu PM Inbox Count
  • 2008/3/10 9:54

  • PatTang

  • Just popping in

  • Posts: 9

  • Since: 2008/3/8 4


Message inbox color works perfect.
Will try out other mod soon.
Thank you very much

Login

Who's Online

337 user(s) are online (282 user(s) are browsing Support Forums)


Members: 0


Guests: 337


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits