00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/DataAccess.php';
00026
00027
00028
00029
00040
00041 class FF_DataAccess_TicketWatchlist_mysql extends FF_DataAccess {
00042
00043
00050 function FF_DataAccess_TicketWatchlist_mysql()
00051 {
00052 FF_DataAccess::FF_DataAccess();
00053 $this->table = $this->o_registry->getConfigParam('data/ticket_watchlist_table');
00054 }
00055
00056
00057
00058
00068 function remove($in_ticketId, $in_userId)
00069 {
00070 $o_result = new FF_Result();
00071 $s_stmt = $this->o_data->prepare("DELETE FROM $this->table WHERE ticket_id = ? AND user_id = ? LIMIT 1");
00072 if (DB::isError($result = $this->o_data->execute($s_stmt, array($in_ticketId, $in_userId)))) {
00073 $o_result->addMessage($result->getMessage());
00074 $o_result->setSuccess(false);
00075 }
00076
00077 return $o_result;
00078 }
00079
00080
00081
00082
00092 function getWatchlistByTicketId($in_ticketId)
00093 {
00094 $s_profileTable = $this->o_registry->getConfigParam('data/table', 'profile', 'profile');
00095 $s_query = "SELECT tw.user_id, CONCAT(p.firstname, ' ', p.lastname) AS fullname
00096 FROM $this->table AS tw
00097 LEFT JOIN $s_profileTable AS p ON tw.user_id = p.id
00098 WHERE tw.ticket_id = ? ORDER BY fullname";
00099
00100 if (is_null($in_ticketId) ||
00101 DB::isError($result = $this->o_data->getAssoc($s_query, false, $in_ticketId))) {
00102 return array();
00103 }
00104 else {
00105 return $result;
00106 }
00107 }
00108
00109
00110
00111
00120 function getWatchlistEmailsByTicketId($in_ticketId)
00121 {
00122 $s_profileTable = $this->o_registry->getConfigParam('data/table', 'profile', 'profile');
00123 $s_query = "SELECT p.email FROM $this->table AS tw
00124 LEFT JOIN $s_profileTable AS p ON tw.user_id = p.id
00125 WHERE tw.ticket_id = ?";
00126
00127 if (DB::isError($result = $this->o_data->getCol($s_query, 0, $in_ticketId))) {
00128 return array();
00129 }
00130 else {
00131 return $result;
00132 }
00133 }
00134
00135
00136
00137
00144 function getNextId()
00145 {
00146
00147 $this->o_data->setOption('seqname_format', '%s');
00148 return $this->o_data->nextId($this->o_registry->getConfigParam('data/sequence_table'));
00149 }
00150
00151
00152 }
00153 ?>