コード例 #1
0
 /**
  * get a list of tickers for this image
  */
 function &getTroubleTickets($aStatus)
 {
     global $MESSAGES;
     if (!is_array($aStatus)) {
         die("GridImage::getTroubleTickets expects array param");
     }
     $db =& $this->_getDB();
     $statuses = "'" . implode("','", $aStatus) . "'";
     $tickets = array();
     $recordSet =& $db->Execute("select t.*,u.realname as suggester_name,DATEDIFF(NOW(),t.updated) as days from gridimage_ticket as t " . "inner join user as u using(user_id) " . "where t.gridimage_id={$this->gridimage_id} and t.status in ({$statuses}) order by t.updated desc");
     while (!$recordSet->EOF) {
         //create new ticket object
         $t = new GridImageTroubleTicket();
         $t->loadFromRecordset($recordSet);
         if ($t->days > 365) {
             $t->days = $MESSAGES['class_gridimage']['days_365'];
         } elseif ($t->days > 30) {
             $t->days = sprintf($MESSAGES['class_gridimage']['days_30'], intval($t->days / 30));
         } elseif ($t->days > 14) {
             $t->days = sprintf($MESSAGES['class_gridimage']['days_14'], intval($t->days / 7));
         } elseif ($t->days > 7) {
             $t->days = $MESSAGES['class_gridimage']['days_7'];
         } elseif ($t->days > 1) {
             $t->days = sprintf($MESSAGES['class_gridimage']['days_gt1'], $t->days);
         } elseif ($t->days < 1) {
             $t->days = $MESSAGES['class_gridimage']['days_lt1'];
         } else {
             $t->days = $MESSAGES['class_gridimage']['days_eq1'];
         }
         //load its ticket items (should this be part of load from Recordset?
         $t->loadItems();
         $t->loadComments();
         $tickets[] = $t;
         $recordSet->MoveNext();
     }
     $recordSet->Close();
     return $tickets;
 }