Example #1
0
 /**
  * Edit Job Posting
  *
  * @param   integer  $isnew  Is this a new entry?
  * @return  void
  */
 public function editTask($isnew = 0)
 {
     Request::setVar('hidemainmenu', 1);
     $live_site = rtrim(Request::base(), '/');
     // Push some styles to the template
     $this->css();
     // Incoming job ID
     $id = Request::getVar('id', array(0));
     $id = is_array($id) ? $id[0] : $id;
     // Grab some filters for returning to place after editing
     $this->view->return = array();
     $this->view->return['sortby'] = Request::getVar('sortby', 'added');
     $this->view->row = new Job($this->database);
     $this->view->jobadmin = new JobAdmin($this->database);
     $this->view->employer = new Employer($this->database);
     // Is this a new job?
     if (!$id) {
         $this->view->row->created = Date::toSql();
         $this->view->row->created_by = User::get('id');
         $this->view->row->modified = '0000-00-00 00:00:00';
         $this->view->row->modified_by = 0;
         $this->view->row->publish_up = Date::toSql();
         $this->view->row->employerid = 1;
         // admin
     } else {
         if (!$this->view->row->load($id)) {
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_JOBS_ERROR_MISSING_JOB'), 'error');
             return;
         }
     }
     $this->view->job = $this->view->row->get_opening($id, User::get('id'), 1);
     // Get employer information
     if ($this->view->row->employerid != 1) {
         if (!$this->view->employer->loadEmployer($this->view->row->employerid)) {
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_JOBS_ERROR_MISSING_EMPLOYER_INFO'), 'error');
             return;
         }
     } else {
         // site admin
         $this->view->employer->uid = 1;
         $this->view->employer->subscriptionid = 1;
         $this->view->employer->companyName = Config::get('sitename');
         $this->view->employer->companyLocation = '';
         $this->view->employer->companyWebsite = $live_site;
     }
     // Get subscription info
     include_once PATH_CORE . DS . 'components' . DS . 'com_services' . DS . 'tables' . DS . 'subscription.php';
     $this->view->subscription = new \Components\Services\Tables\Subscription($this->database);
     $this->view->subscription->loadSubscription($this->view->employer->subscriptionid, '', '', $status = array(0, 1));
     // Get job types and categories
     $jt = new JobType($this->database);
     $jc = new JobCategory($this->database);
     // get job types
     $this->view->types = $jt->getTypes();
     $this->view->types[0] = Lang::txt('COM_JOBS_TYPE_ANY');
     // get job categories
     $this->view->cats = $jc->getCats();
     $this->view->cats[0] = Lang::txt('COM_JOBS_CATEGORY_UNSPECIFIED');
     $this->view->config = $this->config;
     $this->view->isnew = $isnew;
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }
Example #2
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 #3
0
 /**
  * Remove type
  *
  * @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;
     }
     $jt = new JobType($this->database);
     foreach ($ids as $id) {
         // Delete the type
         $jt->delete(intval($id));
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_JOBS_ITEMS_REMOVED', count($ids)));
 }