pmBOX and dpStaffStatus 2.1  Début

  • Hi, vedrine. Sorry for my english (you know that I'm spanish)

    I'm editying the pntemplates/plugins/function.getmessages.php on dpStaffStatus 2.1. I discover that on the count of the total of messages (in the block), it counts the outbox messages of the submitter and my inbox messages.

    I include the code here:

    Code

    <?php

    function smarty_function_getmessages($params, &$smarty)
    {
        extract($params);
        unset($params);

        if(!isset($uid) || !is_numeric($uid)) {
            return false;
        }
        if( pnModAvailable('pmBOX') ) {
            // Base de datos
          list($dbconn) = pnDBGetConn();
          pnModDBInfoLoad('pmBOX', 'pmBOX');
          $pntable = pnDBGetTables();
          $MsgTabla = $pntable['pmbox'];
          $MsgColumn = &$pntable['pmbox_column'];
          $sql1 = "SELECT count(*) FROM $MsgTabla WHERE $MsgColumn[msg_type] ='1' and $MsgColumn[read_msg] ='0' and $MsgColumn[to_userid]=".pnVarPrepForStore($uid);
            $result = $dbconn->Execute($sql1);
             if ($dbconn->ErrorNo() != 0) { return $content; }        
             list($SinLeer) = $result->fields;
          $result->Close();
           
         $sql1 = "SELECT count(*) FROM $MsgTabla WHERE $MsgColumn[msg_type] ='1' and $MsgColumn[to_userid]=" . pnVarPrepForStore($uid);            
            $result = $dbconn->Execute($sql1);
            if ($dbconn->ErrorNo() != 0) { return $content; }                      
            list($total) = $result->fields;
     
            $sql = "SELECT COUNT(*)
                    FROM $MsgTabla
                    WHERE $MsgColumn[to_userid]='"
    .(int)pnVarPrepForStore($uid)."'";               
            $result = $dbconn->Execute($sql);
            list($total) = $result->fields;                
            $result->Close();              
        } else {
            $SinLeer = 0;
            $total = 0;
        }
        $url_inbox_unread = pnModURL('pmBOX');     
        $url_inbox_total = pnModURL('pmBOX');
        $msg = array('unread' => $SinLeer,
                     'total' => $total,
                     'url_inbox_unread' => $url_inbox_unread,
                     'url_inbox_total' => $url_inbox_total);

        if (isset($assign)) {
            $smarty->assign($assign, $msg);
        } else {
            return $msg;
        }
    }
    ?>



    I don't know now how to solve that.

    Thanks



    edited by: anykiller, Oct 24, 2005 - 04:59 PM

    You can found me at Dev-Postnuke.com & PortalEmpanao.es
  • Hello,
    This is weird because it should work
    the msg_type column should contain 1 for inbox, 2 for outbox, 3 for savebox
    So your sql query should count inbox messages only because they contain "$MsgColumn[msg_type] ='1'"
    Can you look with phpmyadmin in your pmbox table to see if all seems correct ?
    can you also echo your sql query to screen to see if all seems correct (the field real name is pn_msg_type so you should see something like
    (your_prefix)_pmbox.pn_msg_type='1' in the query)
  • I found the solution myself.

    I read the function.getmessages.php again and see this:

    Code

    $sql1 = "SELECT count(*) FROM $MsgTabla WHERE $MsgColumn[msg_type] ='1' and $MsgColumn[read_msg] ='0' and $MsgColumn[to_userid]=".pnVarPrepForStore($uid);
            $result = $dbconn->Execute($sql1);
             if ($dbconn->ErrorNo() != 0) { return $content; }        
             list($SinLeer) = $result->fields;
          $result->Close();
           
         $sql1 = "SELECT count(*) FROM $MsgTabla WHERE $MsgColumn[msg_type] ='1' and $MsgColumn[to_userid]=" . pnVarPrepForStore($uid);            
            $result = $dbconn->Execute($sql1);
            if ($dbconn->ErrorNo() != 0) { return $content; }                      
            list($total) = $result->fields;
     
          $sql = "SELECT COUNT(*)
                    FROM $MsgTabla
                    WHERE $MsgColumn[to_userid]='"
    .(int)pnVarPrepForStore($uid)."'";              
            $result = $dbconn->Execute($sql);
            list($total) = $result->fields;                
            $result->Close();



    when it should be:

    Code

    $sql1 = "SELECT count(*) FROM $MsgTabla WHERE $MsgColumn[msg_type] ='1' and $MsgColumn[read_msg] ='0' and $MsgColumn[to_userid]=".pnVarPrepForStore($uid);
            $result = $dbconn->Execute($sql1);
             if ($dbconn->ErrorNo() != 0) { return $content; }        
             list($SinLeer) = $result->fields;
          $result->Close();
           
         $sql1 = "SELECT count(*) FROM $MsgTabla WHERE $MsgColumn[msg_type] ='1' and $MsgColumn[to_userid]=" . pnVarPrepForStore($uid);            
            $result = $dbconn->Execute($sql1);
            if ($dbconn->ErrorNo() != 0) { return $content; }                      
            list($total) = $result->fields;
    $result->Close();



    I made badly the modification xDDDDDD

    Thanks.

    PD: I'll send you the spanish translation of pmBOX, if you wat this ;)

    Best regards

    You can found me at Dev-Postnuke.com & PortalEmpanao.es
  • That's funny I have verified the first and second sql queries but I didn't see there was a wrong third query after !!
  • 8 visiteurs

Données pour les 15 dernières minutes