Пример #1
0
 public function getModelFromArray(array $data)
 {
     $fields = array('author_id' => null, 'vacancy_id' => null, 'title' => null, 'description' => null, 'phone' => null, 'mobile' => null, 'email' => null, 'term' => null, 'region' => null, 'category_id' => null, 'hours' => null, 'seeker_name' => null, 'seeker_fname' => null, 'date_expired' => null, 'date_published' => null);
     foreach ($data as $key => $value) {
         if (array_key_exists($key, $fields)) {
             $fields[$key] = $value;
         }
     }
     $vacancy = new SxCms_Job();
     $vacancy->setId($fields['vacancy_id'])->setJobtitle($fields['title'])->setDescription($fields['description'])->setPhone($fields['phone'])->setMobile($fields['mobile'])->setEmail($fields['email'])->setTerm($fields['term'])->setSeekerFirstName($fields['seeker_name'])->setSeekerName($fields['seeker_fname']);
     $address = new SxCms_Address();
     $address->setRegion($fields['region']);
     $category = new SxCms_Job_Category();
     $category->setId($fields['category_id']);
     $vacancy->setCategory($category);
     $vacancy->setAddress($address)->setHours($fields['hours'])->setExpireDate($fields['date_expired'])->setPublicationDate($fields['date_published']);
     return $vacancy;
 }
Пример #2
0
 /**
  * Validates expiration date
  *
  * @return boolean
  */
 protected function _validatePublicationDate()
 {
     $validator = new Zend_Validate_Date();
     $validator->setFormat('dd-MM-YYYY');
     if (!$validator->isValid($this->_job->getPublicationDate())) {
         $msg = Sanmax_MessageStack::getInstance('SxCms_Job');
         $msg->addMessage('publication_date', $validator->getMessages(), 'save');
         return false;
     }
     return true;
 }