DataAccess/mysql/TicketWatchlist.php

Go to the documentation of this file.
00001 <?php
00003 // {{{ license
00004 
00005 // +----------------------------------------------------------------------+
00006 // | FastFrame Application Framework                                      |
00007 // +----------------------------------------------------------------------+
00008 // | Copyright (c) 2002-2006 The Codejanitor Group                        |
00009 // +----------------------------------------------------------------------+
00010 // | This source file is subject to the GNU Lesser Public License (LGPL), |
00011 // | that is bundled with this package in the file LICENSE, and is        |
00012 // | available at through the world-wide-web at                           |
00013 // | http://www.fsf.org/copyleft/lesser.html                              |
00014 // | If you did not receive a copy of the LGPL and are unable to          |
00015 // | obtain it through the world-wide-web, you can get it by writing the  |
00016 // | Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
00017 // | MA 02111-1307, USA.                                                  |
00018 // +----------------------------------------------------------------------+
00019 // | Authors: Jason Rust <jrust@codejanitor.com>                          |
00020 // +----------------------------------------------------------------------+
00021 
00022 // }}}
00023 // {{{ requires
00024 
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/DataAccess.php';
00026 
00027 // }}}
00028 // {{{ class FF_DataAccess_TicketWatchlist_mysql 
00029 
00040 // }}}
00041 class FF_DataAccess_TicketWatchlist_mysql extends FF_DataAccess {
00042     // {{{ constructor
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     // {{{ remove()
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     // {{{ getWatchlistByTicketId()
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     // {{{ getWatchlistEmailsByTicketId()
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     // {{{ getNextId()
00137 
00144     function getNextId()
00145     {
00146         // change sequence name since we give it the full table name
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 ?>

Generated on Fri Jun 23 11:38:18 2006 for FastFrame by  doxygen 1.4.4