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
00026 if (!class_exists('ff_action_abstractprofile')) {
00027 $o_registry =& FF_Registry::singleton();
00028 require_once $o_registry->getAppFile('Action/AbstractProfile.php', 'profile', 'libs');
00029 }
00030
00031
00032
00033
00034
00046
00047 class FF_Action_AlumniProfile extends FF_Action_AbstractProfile {
00048
00049
00060 function createFormElements(&$in_formObj, $in_appName)
00061 {
00062 require_once FASTFRAME_ROOT . 'lib/FastFrame/Util.php';
00063 $a_fields = array(
00064 'student_id' => array('select',
00065 $this->o_registry->getConfigParam('alumni/statuses', array(), $in_appName)),
00066 'maiden_name' => array('text', array('maxlength' => 100, 'size' => 30)),
00067 'title' => array('text', array('maxlength' => 50, 'size' => 30)),
00068 'company' => array('text', array('maxlength' => 200, 'size' => 30)),
00069 'address' => array('text', array('maxlength' => 250, 'size' => 30)),
00070 'city' => array('text', array('maxlength' => 200, 'size' => 30)),
00071 'state' => array('text', array('maxlength' => 2, 'size' => 2)),
00072 'country' => array('text', array('maxlength' => 150, 'size' => 30)),
00073 'postal_code' => array('text', array('maxlength' => 20, 'size' => 10)),
00074 'fax' => array('text', array('maxlength' => 15, 'size' => 15)),
00075 'web_site' => array('text', array('maxlength' => 200, 'size' => 30)),
00076 'concentration' => array('text', array('maxlength' => 150, 'size' => 30)),
00077 'is_public' => array('advcheckbox', null),
00078 'major' => array('select',
00079 $this->o_registry->getConfigParam('alumni/majors', array(), $in_appName)),
00080 'degree' => array('select',
00081 $this->o_registry->getConfigParam('alumni/degrees', array(), $in_appName)),
00082 'grad_year' => array('select',
00083 FF_Util::createNumericOptionList(
00084 $this->o_registry->getConfigParam('alumni/first_grad_year', date('Y'), $in_appName), date('Y'), 1, '%d')),
00085 'grad_month' => array('select', FF_Util::createMonthOptionList()),
00086 'birth_date' => array('date',
00087 array('format' => 'M d Y',
00088 'minYear' => 1900,
00089 'maxYear' => 2000,
00090 'addEmptyOption' => true)));
00091
00092 foreach ($a_fields as $s_field => $a_fieldData) {
00093 if (!$this->_getFieldParam($s_field, 'locked', $in_appName)) {
00094 if ($s_field == 'student_id' && !$this->o_perms->hasPerm('can_edit_student_id')) {
00095 continue;
00096 }
00097
00098 $in_formObj->addElement($a_fieldData[0], $this->_getFieldName($s_field, $in_appName),
00099 null, $a_fieldData[1]);
00100 if ($this->_getFieldParam($s_field, 'required', $in_appName)) {
00101 $in_formObj->addRule($this->_getFieldName($s_field, $in_appName),
00102 sprintf(_('%s cannot be blank.'),
00103 $this->_getFieldParam($s_field, 'desc', $in_appName)),
00104 'required', null, 'client');
00105 }
00106 }
00107 }
00108 }
00109
00110
00111
00112
00124 function getTableData(&$in_rendererObj, $in_appName, $in_readOnly)
00125 {
00126 $a_data = array();
00127 $a_fields = array('is_public' => 'getIsPublic', 'maiden_name' => 'getMaidenName',
00128 'title' => 'getTitle',
00129 'company' => 'getCompany', 'address' => 'getAddress',
00130 'city' => 'getCity', 'state' => 'getState',
00131 'country' => 'getCountry', 'postal_code' => 'getPostalCode',
00132 'fax' => 'getFax', 'web_site' => 'getWebSite', 'major' => 'getMajor',
00133 'degree' => 'getDegree', 'concentration' => 'getConcentration',
00134 'grad_year' => 'getGradYear', 'grad_month' => 'getGradMonth',
00135 'student_id' => 'getStudentId', 'birth_date' => 'getBirthDate');
00136 foreach ($a_fields as $s_field => $s_method) {
00137 if (!$this->_getFieldParam($s_field, 'locked', $in_appName)) {
00138 if ($s_field == 'student_id' && !$this->o_perms->hasPerm('can_edit_student_id')) {
00139 continue;
00140 }
00141
00142 if ($in_readOnly && $s_field == 'birth_date') {
00143 $s_method = 'getFormattedBirthDate';
00144 }
00145
00146 if ($in_readOnly && $s_field == 'is_public') {
00147 $s_method = 'getFormattedIsPublic';
00148 }
00149
00150 $s_data = $in_readOnly ?
00151 $this->o_model->$s_method() :
00152 $in_rendererObj->elementToHtml($this->_getFieldName($s_field, $in_appName));
00153
00154 if (!$in_readOnly && $s_field == 'address') {
00155 $s_data = '<em>Please indicate a mailing address below:</em><br />' . $s_data;
00156 }
00157
00158 $tmp_style = '';
00159 $tmp_prepend = '';
00160 if ($this->_getFieldParam($s_field, 'required', $in_appName)) {
00161 $tmp_style = 'style="font-weight: bold;"';
00162 $tmp_prepend = '* ';
00163 }
00164
00165 $a_data[] = array(
00166 'title' => $tmp_prepend . $this->_getFieldParam($s_field, 'desc', $in_appName),
00167 'titleStyle' => $tmp_style,
00168 'data' => $s_data,
00169 );
00170 }
00171 }
00172
00173 return $a_data;
00174 }
00175
00176
00177
00178
00189 function getFormDefaults($in_appName)
00190 {
00191 $a_fields = array();
00192 $a_fields[$this->_getFieldName('maiden_name', $in_appName)] = $this->o_model->getMaidenName();
00193 $a_fields[$this->_getFieldName('title', $in_appName)] = $this->o_model->getTitle();
00194 $a_fields[$this->_getFieldName('company', $in_appName)] = $this->o_model->getCompany();
00195 $a_fields[$this->_getFieldName('address', $in_appName)] = $this->o_model->getAddress();
00196 $a_fields[$this->_getFieldName('city', $in_appName)] = $this->o_model->getCity();
00197 $a_fields[$this->_getFieldName('state', $in_appName)] = $this->o_model->getState();
00198 $a_fields[$this->_getFieldName('country', $in_appName)] = $this->o_model->getCountry();
00199 $a_fields[$this->_getFieldName('postal_code', $in_appName)] = $this->o_model->getPostalCode();
00200 $a_fields[$this->_getFieldName('fax', $in_appName)] = $this->o_model->getFax();
00201 $a_fields[$this->_getFieldName('web_site', $in_appName)] = $this->o_model->getWebSite();
00202 $a_fields[$this->_getFieldName('major', $in_appName)] = $this->o_model->getMajor();
00203 $a_fields[$this->_getFieldName('degree', $in_appName)] = $this->o_model->getDegree();
00204 $a_fields[$this->_getFieldName('concentration', $in_appName)] = $this->o_model->getConcentration();
00205 $a_fields[$this->_getFieldName('grad_year', $in_appName)] = $this->o_model->getGradYear();
00206 $a_fields[$this->_getFieldName('grad_month', $in_appName)] = $this->o_model->getGradMonth();
00207 $a_fields[$this->_getFieldName('birth_date', $in_appName)] = $this->o_model->getBirthDate();
00208 $a_fields[$this->_getFieldName('student_id', $in_appName)] = $this->o_model->getStudentId();
00209 $a_fields[$this->_getFieldName('is_public', $in_appName)] = $this->o_model->getIsPublic();
00210 return $a_fields;
00211 }
00212
00213
00214
00215
00227 function fillModelWithSubmitData($in_submitData, $in_appName)
00228 {
00229 $a_fields = array('title' => 'setTitle', 'company' => 'setCompany',
00230 'address' => 'setAddress', 'city' => 'setCity',
00231 'state' => 'setState', 'country' => 'setCountry',
00232 'postal_code' => 'setPostalCode',
00233 'fax' => 'setFax', 'web_site' => 'setWebSite', 'major' => 'setMajor',
00234 'degree' => 'setDegree', 'concentration' => 'setConcentration',
00235 'grad_year' => 'setGradYear', 'grad_month' => 'setGradMonth',
00236 'student_id' => 'setStudentId', 'birth_date' => 'setBirthDate',
00237 'is_public' => 'setIsPublic', 'maiden_name' => 'setMaidenName');
00238 foreach ($a_fields as $s_field => $s_method) {
00239 if (isset($in_submitData[$s_field]) &&
00240 !$this->_getFieldParam($s_field, 'locked', $in_appName) &&
00241 !($s_field == 'student_id' && !$this->o_perms->hasPerm('can_edit_student_id'))) {
00242 $this->o_model->$s_method($in_submitData[$s_field]);
00243 }
00244 }
00245 }
00246
00247
00248 }
00249 ?>