function apply() { JRequest::checkToken() or jexit('Invalid Token'); $applicant = JArrayHelper::toObject(JRequest::get('POST')); $appl_model =& $this->getModel('Applicant'); if (!$appl_model->save($applicant)) { JError::raiseError(500, $appl_model->getError()); } else { $saved_text = JText::_('COM_JOBBOARD_JOB_APP_SAVED'); $feedback_string = $saved_text; require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_appl.php'; $messg_model =& $this->getModel('Message'); $process_mail = JobBoardApplHelper::processMail($applicant, false, $messg_model); $this->setRedirect('index.php?option=com_jobboard&view=applicants&task=edit&cid[]=' . $applicant->id, $feedback_string); } }
function saveApplication() { JRequest::checkToken() or jexit(JText::_('Invalid Token')); $jobid = JRequest::getInt('jobid'); $selcat = JRequest::getInt('selcat'); $cvid = JRequest::getInt('cvprofile'); $qid = JRequest::getInt('qid'); $qid = $qid > 0 ? $qid : 0; $errors = false; $appl_model =& $this->getModel('Apply'); $aid = $appl_model->saveUserApplication($this->_uid, $cvid, $jobid, $qid); if ($aid > 0 && $qid > 0) { require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_appl.php'; $fields_arr = array(); $fields = json_decode($appl_model->getQuestionnaireFields($qid)); foreach ($fields->fields as $field) { if ($field->restricted == 0) { $field_type = JobBoardApplHelper::setFieldType($field->type); $default_type = $field_type == 'int' ? 0 : ''; if ($field->type == 'select') { $value = JRequest::getVar($field->name, $default_type, 'post', 'array'); $value = count($value) == 1 ? $value[0] : implode(',', $value); } if ($field->type == 'date') { $value = JRequest::getVar($field->name, $default_type, 'post', 'array'); $date_day = !isset($value['day']) ? 1 : intval($value['day']); $date_day = $date_day < 0 || $date_day > 31 ? 1 : $date_day; $date_month = !isset($value['month']) ? 1 : intval($value['month']); $date_month = $date_month < 0 || $date_month > 12 ? 1 : $date_month; $date_year = !isset($value['year']) ? '2000' : intval($value['year']); $date_year = $date_year < 0 ? '2000' : $date_year; $value = $date_year . '-' . sprintf("%02d", $date_month) . '-' . sprintf("%02d", $date_day); } elseif ($field->type != 'select') { $value = JRequest::getVar($field->name, $default_type, 'post', 'string'); } if ($field->type == 'checkbox') { $value = $value == 'yes' ? 1 : 0; } $fields_arr[] = array($field->name, $value, $field_type); } } $errors = !$appl_model->saveQuestionnaire($qid, $this->_uid, $aid, $fields_arr) ? true : false; } $errors = !$appl_model->incrApplications($jobid) ? true : false; if ($aid < 1 && $errors != true) { $msg = JText::_('COM_JOBBOARD_ERRORS_OCCURED') . '<br />'; $msg .= JText::sprintf('COM_JOBBOARD_ENT_UPDERR', JText::_('COM_JOBBOARD_JOBAPPLICATION')); $msgtype = 'error'; } else { $msg = JText::sprintf('COM_JOBBOARD_ENT_CREATED', JText::_('COM_JOBBOARD_JOBAPPLICATION')); $msgtype = 'Message'; } $appl_config = JTable::getInstance('config', 'Table'); $appl_config->load(1); $user_details = $this->_umodel->getJoomlaDetails($this->_uid); $this->sendEmailToUser('usernew', $user_details, $jobid, $appl_config); $record_application =& $this->getModel('Upload'); $dept = $record_application->getDept($jobid); if ($dept->notify_admin == 1 || $dept->notify == 1) { if ($dept->notify_admin == 1 && $dept->notify == 1) { $recipients = array($appl_config->from_mail, $dept->contact_email); } else { if ($dept->notify_admin == 1) { $recipients = $appl_config->from_mail; } if ($dept->notify == 1) { $recipients = $dept->contact_email; } } $user_details['cover_note'] = $this->_umodel->getCvProfileSummary($cvid, $this->_uid); $user_details['cover_note'] = $user_details['cover_note']->summary; $user_details['title'] = $this->_umodel->getCvProfileName($cvid, $this->_uid); $this->sendAdminEmail($dept->name, 'adminnew_application', $recipients, $user_details, $jobid, $appl_config); } $app =& JFactory::getApplication(); $layout = $app->getUserStateFromRequest('com_jobboard.list.layout', 'layout', ''); $layout = $layout == '' ? 'list' : $layout; $app->redirect(JRoute::_('index.php?option=com_jobboard&view=job&id=' . $jobid . '&selcat=' . $selcat . '&layout=' . $layout . '&Itemid=' . $this->_itemid), $msg, $msgtype); }
function saveApplication() { JRequest::checkToken() or jexit(JText::_('Invalid Token')); $appl_data = array('status' => JRequest::getInt('status'), 'admin_notes' => JRequest::getVar('admin_notes', '', 'POST', 'string', JREQUEST_ALLOWRAW)); $jid = JRequest::getInt('jid'); $aid = JRequest::getInt('aid'); $qid = JRequest::getInt('qid'); $applicant_model =& $this->getModel('Uapplicant'); if ($qid > 0) { require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_appl.php'; $fields_arr = array(); $fields = json_decode($applicant_model->getQuestionnaireFields($qid)); foreach ($fields->fields as $field) { if ($field->restricted == 1) { $field_type = JobBoardApplHelper::setFieldType($field->type); $default_type = $field_type == 'int' ? 0 : ''; if ($field->type == 'select') { $value = JRequest::getVar($field->name, $default_type, 'post', 'array'); $value = count($value) == 1 ? $value[0] : implode(',', $value); } if ($field->type == 'date') { $value = JRequest::getVar($field->name, $default_type, 'post', 'array'); $date_day = !isset($value['day']) ? 1 : intval($value['day']); $date_day = $date_day < 0 || $date_day > 31 ? 1 : $date_day; $date_month = !isset($value['month']) ? 1 : intval($value['month']); $date_month = $date_month < 0 || $date_month > 12 ? 1 : $date_month; $date_year = !isset($value['year']) ? '2000' : intval($value['year']); $date_year = $date_year < 0 ? '2000' : $date_year; $value = $date_year . '-' . sprintf("%02d", $date_month) . '-' . sprintf("%02d", $date_day); } elseif ($field->type != 'select') { $value = JRequest::getVar($field->name, $default_type, 'post', 'string'); } if ($field->type == 'checkbox') { $value = $value == 'yes' ? 1 : 0; } $fields_arr[] = array($field->name, $value, $field_type); } } $errors = !$applicant_model->updApplicantQanswers($qid, $aid, $fields_arr) ? true : false; } if (!$applicant_model->saveApplication($aid, $appl_data)) { $msg = JText::_('COM_JOBBOARD_ERRORS_OCCURED') . '<br />'; $msg .= JText::sprintf('COM_JOBBOARD_ENT_UPDERR', JText::_('COM_JOBBOARD_JOBAPPLICATION')); $msgtype = 'error'; } else { $applicant = JArrayHelper::toObject($appl_data); require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_appl.php'; $applicant->job_id = $jid; $applicant->department = JobBoardApplHelper::getDeptId($jid); $applicant->title = JobBoardApplHelper::getJobTitle($jid); $applicant_details = JobBoardApplHelper::getRegUser($aid); $applicant->first_name = $applicant_details['name']; $applicant->last_name = ''; $applicant->email = $applicant_details['email']; $applicant->auid = $applicant_details['id']; $messg_model =& $this->getModel('Message'); $process_mail = JobBoardApplHelper::processMail($applicant, true, $messg_model); $msg = JText::sprintf('COM_JOBBOARD_ENT_UPDATED', JText::_('COM_JOBBOARD_JOBAPPLICATION')); $msgtype = 'Message'; } $savemode = JRequest::getCmd('task'); switch ($savemode) { case 'applyappl': $extra_ids = $applicant_model->getApplIds($aid); $this->setRedirect('index.php?option=com_jobboard&view=applicants&task=edappl&aid=' . $aid . '&sid=' . $extra_ids['sid'] . '&pid=' . $extra_ids['pid'] . '&qid=' . $qid . '&jid=' . $jid, $msg, $msgtype); break; case 'saveappl': $this->setRedirect('index.php?option=com_jobboard&view=applicants', $msg, $msgtype); break; } }