/** * Job posting * * @return void */ public function jobTask() { // Incoming $code = Request::getVar('code', ''); $code = !$code && $this->_jobCode ? $this->_jobCode : $code; $obj = new Job($this->database); $job = $obj->get_opening(0, User::get('id'), $this->_masterAdmin, $code); // Push some styles to the template $this->css(); // Push some scripts to the template $this->js(); if (!$job) { $this->setError(Lang::txt('COM_JOBS_ERROR_JOB_INACTIVE')); // Set the pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_name)), 'index.php?option=' . $this->_option); } // Output HTML $view = new View(array('name' => 'error')); $view->title = Lang::txt(strtoupper($this->_name)); if ($this->getError()) { $view->setError($this->getError()); } $view->display(); return; } if (User::get('id') == $job->employerid && !$this->_emp && !$this->_masterAdmin) { // check validity of subscription App::redirect(Route::url('index.php?option=com_jobs&task=dashboard'), Lang::txt('COM_JOBS_WARNING_SUBSCRIPTION_INVALID'), 'warning'); return; } // Set the pathway $this->_jobid = $job->id; $this->_jobtitle = $job->title; $this->_buildPathway(); if (User::isGuest() && $job->status != 1) { // Not authorized $error = Lang::txt('COM_JOBS_ERROR_NOT_AUTHORIZED_JOB_VIEW'); $error .= User::isGuest() ? ' ' . Lang::txt('COM_JOBS_WARNING_LOGIN_REQUIRED') : ''; $this->setError($error); // Output HTML $view = new View(array('name' => 'error')); $view->title = Lang::txt(strtoupper($this->_name)); if ($this->getError()) { $view->setError($this->getError()); } $view->display(); return; } if ($job->status != 1 && !$this->_admin && (!$this->_emp && User::get('id') != $job->employerid)) { // Not authorized App::abort(403, Lang::txt('COM_JOBS_ERROR_NOT_AUTHORIZED_JOB_VIEW')); } // Set page title $this->_subtitle = $job->status == 4 ? Lang::txt('COM_JOBS_ACTION_PREVIEW_AD') . ' ' . $job->code : $job->title; $this->_buildTitle(); // Get category & type names $jt = new JobType($this->database); $jc = new JobCategory($this->database); $job->type = $jt->getType($job->type); $job->cat = $jc->getCat($job->cid); // Get applications $ja = new JobApplication($this->database); $job->applications = ($this->_admin or $this->_emp && User::get('id') == $job->employerid) ? $ja->getApplications($job->id) : array(); // Get profile info of applicants $job->withdrawnlist = array(); if (count($job->applications) > 0) { $js = new JobSeeker($this->database); foreach ($job->applications as $ap) { $seeker = $js->getSeeker($ap->uid, $job->employerid); $ap->seeker = (!$seeker or count($seeker) == 0) ? NULL : $seeker[0]; if ($ap->status == 2) { $job->withdrawnlist[] = $ap; } } } // Output HTML $this->view->title = $this->_title; $this->view->config = $this->config; $this->view->emp = $this->_emp; $this->view->job = $job; $this->view->admin = $this->_admin; $this->view->task = $this->_task; $this->view->option = $this->_option; // Set any errors if ($this->getError()) { \Notify::error($this->getError()); } $this->view->setName('job')->setLayout('default')->display(); }