DataAccess/mysql/Alumni.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 // {{{ constants
00029 
00030 // The filters for the list/display pages
00031 define('ALUMNI_FILTER_WEB_SITE', 1);
00032 define('ALUMNI_FILTER_EMAILS', 2);
00033 
00034 // }}}
00035 // {{{ class FF_DataAccess_Alumni_mysql 
00036 
00047 // }}}
00048 class FF_DataAccess_Alumni_mysql extends FF_DataAccess {
00049     // {{{ constructor
00050 
00057     function FF_DataAccess_Alumni_mysql()
00058     {
00059         FF_DataAccess::FF_DataAccess();
00060         $this->table = $this->o_registry->getConfigParam('data/alums_table', 'alumni_alums', 'alum_website');
00061     }
00062 
00063     // }}}
00064     // {{{ update()
00065 
00074     function update($in_data)
00075     {
00076         return parent::update($in_data);
00077     }
00078 
00079     // }}}
00080     // {{{ add()
00081 
00090     function add($in_data)
00091     {
00092         return parent::add($in_data);
00093     }
00094 
00095     // }}}
00096     // {{{ getDataByPrimaryKey()
00097 
00107     function getDataByPrimaryKey($in_id, $in_fields = '*')
00108     {
00109         return parent::getDataByPrimaryKey($in_id, $this->_getSelectFields());
00110     }
00111 
00112     // }}}
00113     // {{{ getListData()
00114 
00126     function getListData($in_where, $in_orderByField, $in_orderByDir, $in_fields = '*')
00127     {
00128         $s_profileTable = $this->o_registry->getConfigParam('data/table', 'profile', 'profile');
00129         $s_query = "SELECT a.id, student_id, maiden_name, title, company, address, city, 
00130                     state, country, postal_code, p.phone, fax, web_site, 
00131                     major, degree, concentration, grad_year, grad_month, 
00132                     UNIX_TIMESTAMP(birth_date) AS birth_date,
00133                     p.firstname, p.lastname, p.email
00134                     FROM $this->table AS a 
00135                     INNER JOIN $s_profileTable AS p ON a.id = p.id
00136                     WHERE p.lastname != '' AND $in_where ORDER BY $in_orderByField " . $this->_getOrderByDirection($in_orderByDir); 
00137         return $this->o_data->query($s_query);
00138     }
00139 
00140     // }}}
00141     // {{{ getListFilter()
00142 
00155     function getListFilter($in_searchString, $in_searchFields, $in_filter, $in_filterData)
00156     {
00157         // Get only those alumni who have web sites and whose name
00158         // begins with the specified letter
00159         if ($in_filter == ALUMNI_FILTER_WEB_SITE) {
00160             return sprintf('web_site != "" AND lastname LIKE %s',
00161                     $this->o_data->quoteSmart($in_searchString . '%'));
00162         }
00163         // Get only those alumni who have chosen to make their record public
00164         elseif ($in_filter == ALUMNI_FILTER_EMAILS) {
00165             $s_filter = 'is_public = 1 AND ';
00166         }
00167         else {
00168             $s_filter = '';
00169         }
00170 
00171         return $s_filter . '(' . parent::getListFilter($in_searchString, $in_searchFields, $in_filter, $in_filterData) . ')';
00172     }
00173 
00174     // }}}
00175     // {{{ _getSelectFields()
00176 
00184     function _getSelectFields()
00185     {
00186         // Birth date can be before unix epoch so we use DATE_FORMAT and
00187         // strtotime(), but note that some platforms don't support negative
00188         // timestamps
00189         return '*, DATE_FORMAT(birth_date, "%m/%d/%Y") AS birth_date';
00190     }
00191 
00192     // }}}
00193 }
00194 ?>

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