Fork me on GitHub

pnPHPbb2 Message Varibale  Bottom

  • In the core ONLINE block number of read and unread meassages of PN Meassage module are shown.

    If I like to use number of read and unread meassages of pnPHPbb2 which varibales of pnPHPbb2 should I put in ONLINE block file.

    Sample code would be more help.
  • I have the same question as well

    Im using OnlineXp block and well the original code is like this :

    Code

    if (pnUserLoggedIn()) {
            $content .= '<br />';
            if ($vars['icons'] =="1") {$content .= "<img src=images/blocks/authors.gif align=absmiddle>";}
            $content .= ' '._YOUARELOGGED.' <b>' .pnUserGetVar('uname') . '</b>.<br />';
            $column = &$pntable['priv_msgs_column'];
            $result2 = $dbconn->Execute("SELECT count(*) FROM $pntable[priv_msgs] WHERE $column[to_userid]=" . pnUserGetVar('uid'));
            list($numrow) = $result2->fields;
              // get unread messages
       $result3 = $dbconn->Execute("SELECT count(*) FROM $pntable[priv_msgs] WHERE $column[to_userid]=" . pnUserGetVar('uid') . " AND $column[read_msg]='0'");
              list($unreadrow) = $result3->fields;
            if ($numrow == 0) {
                $content .= '<br /></span>';
            } else {
                $content .= "<br />";
                if ($vars['icons'] =="1") {$content .= "<img src=images/blocks/email.gif align=absmiddle vspace=2>";}
                $content .= " "._YOUHAVE." (<a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=Messages&amp;file=index\">".pnVarPrepForDisplay($numrow)."</a>|<a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=Messages&amp;file=index\" title=\""._PRIVATEMSGNEW."\"><b>".pnVarPrepForDisplay($unreadrow)."</b></a>) ";


    What I did is :
    -replace the 'priv_msgs' table with 'phpbb_privmsgs' table
    -replaced the link so it would point to pnphpbb2 link
    -replaced $column[read_msg] with $column[type] as i thought it would be the only identifier of the unread messages.

    so the new code would be:

    Code

    if (pnUserLoggedIn()) {
            $content .= '<br />';
            if ($vars['icons'] =="1") {$content .= "<img src=images/blocks/authors.gif align=absmiddle>";}
            $content .= ' '._YOUARELOGGED.' <b>' .pnUserGetVar('uname') . '</b>.<br />';
            $column = &$pntable['phpbb_privmsgs_column'];
            $result2 = $dbconn->Execute("SELECT count(*) FROM $pntable[phpbb_privmsgs] WHERE $column[to_userid]=" . pnUserGetVar('uid'));
            list($numrow) = $result2->fields;
              // get unread messages
       $result3 = $dbconn->Execute("SELECT count(*) FROM $pntable[phpbb_privmsgs] WHERE $column[to_userid]=" . pnUserGetVar('uid') . " AND $column[type]='1'");
              list($unreadrow) = $result3->fields;
            if ($numrow == 0) {
                $content .= '<br /></span>';
            } else {
                $content .= "<br />";
                if ($vars['icons'] =="1") {$content .= "<img src=images/blocks/email.gif align=absmiddle vspace=2>";}
                $content .= " "._YOUHAVE." (<a class=\"pn-normal\" href=\"index.php?name=PNphpBB2&file=privmsg&folder=inbox\">".pnVarPrepForDisplay($numrow)."</a>|<a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=Messages&amp;file=index\" title=\""._PRIVATEMSGNEW."\"><b>".pnVarPrepForDisplay($unreadrow)."</b></a>) ";
                if ($numrow==1) {
                   $content .= _PRIVATEMSG ;      
               }
               elseif ($numrow>1) {
                   $content .= _PRIVATEMSGS ;
               }


    now, nothing from that is working, I wonder how can I make it work !?
    any help would be much appreciated
  • anim_chowdhury

    Sample code would be more help.

    Lol.

    These are the queries we can use for those variable values.

    Code

    $prefix = $pnconfig['prefix'] . "_phpbb";
    $sql1 = "SELECT user_new_privmsg FROM " . $prefix ."_users WHERE user_id='$uid'";
    $result1 = $dbconn->Execute($sql1);

    Number of new messages = $result1

    Code

    $sql2 = "SELECT user_unread_privmsg FROM " . $prefix ."_users WHERE user_id='$uid'";
    $result2 = $dbconn->Execute($sql2);

    Number of unread messages = $result2

    Code

    $sql3 = "SELECT COUNT(*) FROM " . $prefix ."_privmsgs WHERE privmsgs_to_userid='$uid' AND privmsgs_type!='2'";
    $result3 = $dbconn->Execute($sql3);

    Number of total messages = $result3
  • there's no need for unread and new messages, both would be the same I guess
    I updated the code (which still doest work)

    Code

    if (pnUserLoggedIn()) {
          $uid = pnUserGetVar('uid');
            $content .= '<br />';
            if ($vars['icons'] =="1") {$content .= "<img src=images/blocks/authors.gif align=absmiddle>";}
            $content .= ' '._YOUARELOGGED.' <b>' .pnUserGetVar('uname') . '</b>.<br />';
            $column = &$pntable['phpbb_privmsgs_column'];
           
         $result2 = $dbconn->Execute("SELECT count(*) FROM $pntable[phpbb_privmsgs] WHERE $column[privmsgs_to_userid]=" . $uid AND ($column[privmsgs_type]='1' or $column[privmsgs_type]='5' or $column[privmsgs_type]='0'));
            list($numrow) = $result2->fields;                   //"privmsgs WHERE (privmsgs_type='1' or privmsgs_type='5') and privmsgs_to_userid=" . $uid)
            
            // get unread messages
       
            $result3 = $dbconn->Execute("SELECT count(*) FROM $pntable[phpbb_privmsgs] WHERE $column[privmsgs_to_userid]=" . $uid. " AND ($column[privmsgs_type]='1' or $column[privmsgs_type]='5')");
            list($unreadrow) = $result3->fields;


    this code is the same as the one in pnphpb2 mutiblock, but again it does not work :|

This list is based on users active over the last 60 minutes.