Example #1
0
 /**
  * Add/edit job form
  *
  * @return     void
  */
 public function editjobTask()
 {
     $live_site = rtrim(Request::base(), '/');
     // Incoming
     $code = Request::getVar('code', '');
     $empid = $this->_admin ? 1 : User::get('id');
     $code = !$code && $this->_jobCode ? $this->_jobCode : $code;
     // Login required
     if (User::isGuest()) {
         \Notify::warning(Lang::txt('COM_JOBS_PLEASE_LOGIN_ACCESS_EMPLOYER'));
         $this->login();
         return;
     }
     $job = new Job($this->database);
     $jobadmin = new JobAdmin($this->database);
     $employer = new Employer($this->database);
     if (!$this->_emp && !$this->_admin) {
         // need to subscribe first
         $employer = new Employer($this->database);
         if ($employer->loadEmployer($empid)) {
             //do we have a pending subscription?
             $subscription = new Subscription($this->database);
             if ($subscription->loadSubscription($employer->subscriptionid, User::get('id'), '', $status = array(0))) {
                 App::redirect(Route::url('index.php?option=com_jobs&task=dashboard'), Lang::txt('COM_JOBS_WARNING_SUBSCRIPTION_PENDING'), 'warning');
                 return;
             }
         }
         // send to subscription page
         App::redirect(Route::url('index.php?option=com_jobs&task=subscribe'));
         return;
     }
     if ($code) {
         if (!$job->loadJob($code)) {
             App::abort(404, Lang::txt('COM_JOBS_ERROR_JOB_NOT_FOUND'));
         }
         // check if user is authorized to edit
         if ($this->_admin or $jobadmin->isAdmin(User::get('id'), $job->id) or User::get('id') == $job->employerid) {
             // we are editing
             $code = $job->code;
         } else {
             App::abort(403, Lang::txt('COM_JOBS_ALERTNOTAUTH'));
         }
     }
     // display with errors
     if ($this->_job) {
         $job = $this->_job;
     }
     $uid = $code ? $job->employerid : User::get('id');
     $job->admins = $code ? $jobadmin->getAdmins($job->id) : array(User::get('id'));
     // Get the member's info
     $profile = new \Hubzero\User\Profile();
     $profile->load($uid);
     // load Employer
     if (!$employer->loadEmployer($uid) && !$this->_admin) {
         App::abort(404, Lang::txt('COM_JOBS_ERROR_EMPLOYER_NOT_FOUND'));
     } else {
         if (!$employer->id && $this->_admin) {
             $employer->uid = 1;
             $employer->subscriptionid = 1;
             $employer->companyName = Config::get('sitename');
             $employer->companyLocation = '';
             $employer->companyWebsite = $live_site;
             $uid = 1;
             // site admin
         }
     }
     // Push some styles to the template
     $this->css();
     // Push some scripts to the template
     $this->js();
     // Push some styles to the tmeplate
     $this->css('calendar.css');
     $jt = new JobType($this->database);
     $jc = new JobCategory($this->database);
     // get job types
     $types = $jt->getTypes();
     $types[0] = Lang::txt('COM_JOBS_TYPE_ANY');
     // get job categories
     $cats = $jc->getCats();
     $cats[0] = Lang::txt('COM_JOBS_CATEGORY_NO_SPECIFIC');
     // Set page title
     $this->_buildTitle();
     // Set the pathway
     $this->_jobid = $job->id;
     $this->_jobtitle = $job->title;
     $this->_buildPathway();
     // Output HTML
     $this->view->title = $this->_title;
     $this->view->config = $this->config;
     $this->view->uid = $uid;
     $this->view->profile = $profile;
     $this->view->emp = $this->_emp;
     $this->view->job = $job;
     $this->view->jobid = $job->id;
     $this->view->types = $types;
     $this->view->cats = $cats;
     $this->view->employer = $employer;
     $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('editjob')->setLayout('default')->display();
 }
Example #2
0
 /**
  * Remove Job Posting
  *
  * @return  void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming (expecting an array)
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Ensure we have an ID to work with
     if (empty($ids)) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_JOBS_ERROR_NO_ITEM_SELECTED'), 'error');
         return;
     }
     $row = new Job($this->database);
     foreach ($ids as $id) {
         // Delete the type
         $row->delete($id);
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_JOBS_ITEMS_REMOVED', count($ids)));
 }