Ejemplo n.º 1
0
 public function myinbox()
 {
     $id = Account::getMyID();
     $inbox = new Inbox();
     $begin = isset($_GET['begin']) ? addslashes($_GET['begin']) : 0;
     $limit = 10;
     $w = isset($_GET['word']) ? addslashes($_GET['word']) : '';
     //search if commbook
     if (isset($_GET['cb'])) {
         if ($w != '') {
             $retArr = $inbox->searchCb($w, $id, $begin, $limit);
             $arrMsg = $retArr['arrMsg'];
             $return['total'] = $retArr['total'];
         } else {
             $whereClause = "(inbox_from = '{$id}' OR inbox_to = '{$id}') AND inbox_type = 'cb' ORDER BY inbox_changedate DESC LIMIT {$begin},{$limit}";
             $arrMsg = $inbox->getWhere($whereClause);
             $clause = " (inbox_from = '{$id}' OR inbox_to = '{$id}') AND inbox_type = 'cb' ";
             $return['total'] = $inbox->getJumlah($clause);
         }
     } elseif (isset($_GET['search'])) {
         //get search word
         //sementara di off in
         //yg bs dicari nama_depan pengirim dan judul dan msg nya saja,
         $retArr = $inbox->search($w, $id, $begin, $limit);
         $arrMsg = $retArr['arrMsg'];
         $return['total'] = $retArr['total'];
     } else {
         $whereClause = "inbox_from = '{$id}' OR inbox_to = '{$id}' ORDER BY inbox_changedate DESC LIMIT {$begin},{$limit}";
         $arrMsg = $inbox->getWhere($whereClause);
         $clause = "inbox_from = '{$id}' OR inbox_to = '{$id}'";
         $return['total'] = $inbox->getJumlah($clause);
     }
     //ambil last reply
     foreach ($arrMsg as $obja) {
         //ambil last conversations
         $reply = new InboxReply();
         $reply->getLastReply($obja->inbox_id);
         if (isset($reply->inbox_msg) && $reply->inbox_msg != '') {
             $obja->inbox_msg = $reply->inbox_msg;
         }
     }
     $return['limit'] = $limit;
     $return['begin'] = $begin;
     $return['arrMsg'] = $arrMsg;
     $return['webClass'] = __CLASS__;
     $return['method'] = __FUNCTION__;
     $return['word'] = $w;
     $return['cb'] = isset($_GET['cb']) ? $_GET['cb'] : 0;
     Mold::both("inbox/myinbox", $return);
     //pr($arrMsg);
 }