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/Validate.php';
00026
00027
00028
00029
00040
00041 class FF_Validate_Alumni extends FF_Validate {
00042
00043
00051 function validate()
00052 {
00053 $this->_validateId();
00054 $this->_validateRequiredFields();
00055 $this->_validateWebSite();
00056 return $this->o_result;
00057 }
00058
00059
00060
00061
00068 function _validateId()
00069 {
00070 if ($this->isUpdate && FastFrame::isEmpty($this->o_model->getId())) {
00071 $this->o_result->addMessage(_('Id cannot be empty'));
00072 $this->o_result->setSuccess(false);
00073 }
00074 }
00075
00076
00077
00078
00085 function _validateWebSite()
00086 {
00087 if (!FastFrame::isEmpty($this->o_model->getWebSite())) {
00088 require_once 'Validate.php';
00089 $a_options = array('allowed_schemes' => array('http', 'https'));
00090 if (!Validate::uri($this->o_model->getWebSite(), $a_options)) {
00091 $this->o_result->addMessage(_('Invalid web site address. It must be in the form of http:
00092 $this->o_result->setSuccess(false);
00093 }
00094 }
00095 }
00096
00097
00098
00099
00106 function _validateRequiredFields()
00107 {
00108 $o_registry =& FF_Registry::singleton();
00109 $a_data = $o_registry->getConfigParam('profile/fields', array(), 'alum_website');
00110 $a_fields = array('title' => 'getTitle', 'company' => 'getCompany',
00111 'address' => 'getAddress', 'city' => 'getCity',
00112 'state' => 'getState', 'country' => 'getCountry',
00113 'fax' => 'getFax',
00114 'web_site' => 'getWebSite', 'major' => 'getMajor',
00115 'grad_year' => 'getGradYear');
00116 foreach ($a_fields as $s_field => $s_method) {
00117
00118 if (empty($a_data[$s_field]['locked']) && !empty($a_data[$s_field]['required'])) {
00119 if (FastFrame::isEmpty($this->o_model->$s_method())) {
00120 $this->o_result->addMessage(sprintf(_('%s cannot be empty'), $a_data[$s_field]['desc']));
00121 $this->o_result->setSuccess(false);
00122 }
00123 }
00124 }
00125 }
00126
00127
00128 }
00129 ?>