AlumniList.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/Action/List.php';
00026 
00027 // }}}
00028 // {{{ class FF_Action_List_Alumni
00029 
00040 // }}}
00041 class FF_Action_List_Alumni extends FF_Action_List {
00042     // {{{ renderAdditionalLinks()
00043 
00050     function renderAdditionalLinks()
00051     {
00052         $o_widget =& new FF_Smarty('emailSearch');
00053         $o_widget->assign('T_email_navTitle', _('Search by graduation year'));
00054         foreach(range($this->o_registry->getConfigParam('alumni/first_grad_year'), date('Y')) as $s_year) {
00055             $s_separator = ($s_year % 5 == 4) ? '<br />' : '';
00056             $o_widget->append('email_navYear', $this->o_output->link(
00057                         FastFrame::selfURL(
00058                             array('searchString[' . $this->o_list->getListId() . ']' => $s_year)),
00059                         substr($s_year, -2)) . $s_separator);
00060         }
00061 
00062         $this->o_output->o_tpl->append('content_right', $o_widget->fetch());
00063     }
00064 
00065     // }}}
00066     // {{{ initList()
00067 
00074     function initList()
00075     {
00076         parent::initList();
00077         // List should always be simple
00078         $this->o_list->setSearchBoxType(SEARCH_BOX_SIMPLE, false);
00079         $this->o_list->toggleTypeLocked(true);
00080         // Initial viewing of the page should have default search
00081         if (is_null($this->o_list->getSearchString())) {
00082             $this->o_list->setSearchString($this->o_registry->getConfigParam('alumni/email_year'));
00083         }
00084     }
00085 
00086     // }}}
00087     // {{{ getFilter()
00088 
00096     function getFilter()
00097     {
00098         return array(ALUMNI_FILTER_EMAILS, array());
00099     }
00100 
00101     // }}}
00102     // {{{ getDefaultSortField()
00103     
00110     function getDefaultSortField()
00111     {
00112         return 'lastname';
00113     }
00114 
00115     // }}}
00116     // {{{ getFieldMap()
00117 
00124     function getFieldMap()
00125     {
00126         return array(
00127             array('field' => 'firstname', 'description' => _('First Name'), 'method' => 'getFirstName'),
00128             array('field' => 'lastname', 'description' => _('Last Name'), 'method' => 'getLastName'),
00129             array('sort' => 'email', 'description' => _('Email'), 'object' => &$this, 'method' => '_getEmail', 'dataIsSafe' => true),
00130             array('field' => 'grad_year', 'description' => _('Grad Year'), 'method' => 'getGradYear'),
00131             array('field' => 'major', 'description' => _('Major'), 'method' => 'getMajor'),
00132             array('field' => 'state', 'description' => _('State'), 'method' => 'getState'),
00133             array('field' => 'city', 'description' => _('City'), 'method' => 'getCity'),
00134             array('description' => _('Web Site'), 'object' => &$this, 'method' => '_getLinkedWebsite', 'dataIsSafe' => true),
00135         );
00136     }
00137 
00138     // }}}
00139     // {{{ getSingularText()
00140 
00147     function getSingularText()
00148     {
00149         return _('Alumnus');
00150     }
00151 
00152     // }}}
00153     // {{{ getPluralText()
00154 
00161     function getPluralText()
00162     {
00163         return _('Alumni');
00164     }
00165 
00166     // }}}
00167     // {{{ checkPerms()
00168 
00175     function checkPerms()
00176     {
00177         if ($this->o_perms->hasPerm('can_list_alumni')) {
00178             return true;
00179         }
00180         else {
00181             $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00182             $this->o_output->setMessage(_('You do not have permission to list alumni.'), FASTFRAME_ERROR_MESSAGE);
00183             return false;
00184         }
00185     }
00186 
00187     // }}}
00188     // {{{ _getEmail()
00189 
00198     function _getEmail()
00199     {
00200         if (FastFrame::isEmpty($this->o_model->getEmail())) {
00201             return '';
00202         }
00203 
00204         if ($this->o_registry->getConfigParam('alumni/emails_as_img')) {
00205             $o_fileCache =& FF_FileCache::singleton();
00206             $a_parts = array('subdir' => 'email_images', 'name' => md5($this->o_model->getEmail()) . '.gif');
00207             if (!$o_fileCache->exists($a_parts, true)) {
00208                 $s_fontNum = 3;
00209                 $s_width = imagefontwidth($s_fontNum) * strlen($this->o_model->getEmail());
00210                 $im = imagecreate($s_width, imagefontheight($s_fontNum));
00211                 $black = imagecolorallocate($im, 0, 0, 0);
00212                 $white = imagecolorallocate($im, 255, 255, 255);
00213                 $white = imagecolortransparent($im, $white);
00214                 imagefill($im, 0, 0, $white);
00215                 imagestring($im, $s_fontNum, 0, 0, $this->o_model->getEmail(), $black);
00216                 $o_fileCache->checkDir($a_parts, true);
00217                 imagegif($im, $o_fileCache->getPath($a_parts, true));
00218                 imagedestroy($im);
00219                 $o_fileCache->makeViewableFromWeb($a_parts, true);
00220             }
00221 
00222             return $this->o_output->imgTag($o_fileCache->getPath($a_parts, true, FASTFRAME_WEBPATH));
00223         }
00224         else {
00225             return $this->o_model->getEmail();
00226         }
00227     }
00228 
00229     // }}}
00230     // {{{ _getLinkedWebsite()
00231 
00238     function _getLinkedWebsite()
00239     {
00240         if (!FastFrame::isEmpty($this->o_model->getWebSite())) {
00241             return $this->o_output->link($this->o_model->getWebSite(),
00242                     $this->o_model->getWebSite(), array('target' => '_blank'));
00243         }
00244         else {
00245             return '';
00246         }
00247     }
00248 
00249     // }}}
00250 }
00251 ?>

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