示例#1
0
 protected function _notifyResume($id)
 {
     $object = new Wpjb_Model_ResumesAccess($id);
     $emp = new Wpjb_Model_Employer($object->employer_id);
     $emp->addAccess($object->extend);
     $emp->save();
 }
示例#2
0
 protected function _multiDecline($id)
 {
     $object = new Wpjb_Model_Employer($id);
     $object->is_active = Wpjb_Model_Employer::ACCOUNT_DECLINED;
     $object->save();
     return true;
 }
示例#3
0
 /**
  * Returns currently loggedin user employer object
  *
  * @return Wpjb_Model_Employer
  */
 public static function current()
 {
     if (self::$_current instanceof self) {
         return self::$_current;
     }
     $current_user = wp_get_current_user();
     if ($current_user->ID < 1) {
         return new self();
     }
     $query = new Daq_Db_Query();
     $object = $query->select()->from(__CLASS__ . " t")->where("user_id = ?", $current_user->ID)->limit(1)->execute();
     if ($object[0]) {
         self::$_current = $object[0];
         return self::$_current;
     }
     // quick create
     $object = new self();
     $object->user_id = $current_user->ID;
     $object->company_name = "";
     $object->company_website = "";
     $object->company_info = "";
     $object->company_logo_ext = "";
     $object->company_location = "";
     $object->is_public = 0;
     $object->is_active = self::ACCOUNT_ACTIVE;
     $object->save();
     self::$_current = $object;
     return $object;
 }
示例#4
0
 public function _filter()
 {
     $info = wp_get_current_user();
     $isAdmin = true;
     if (!isset($info->wp_capabilities) || !$info->wp_capabilities['administrator']) {
         $isAdmin = false;
     }
     if (Wpjb_Model_Employer::current()->isEmployer()) {
         $this->view->is_employee = false;
     } else {
         $this->view->is_employee = true;
     }
     if ($info->ID > 0) {
         $this->view->is_loggedin = true;
     } else {
         $this->view->is_loggedin = false;
     }
 }
示例#5
0
 protected static function _canBrowse()
 {
     $can_browse = true;
     $employer = Wpjb_Model_Employer::current();
     if (Wpjb_Project::getInstance()->conf("cv_access") == 2) {
         if ($employer->is_active != Wpjb_Model_Employer::ACCOUNT_FULL_ACCESS) {
             $can_browse = false;
         }
     } elseif (Wpjb_Project::getInstance()->conf("cv_access") == 3) {
         if (strtotime($employer->access_until) < time()) {
             $can_browse = false;
         }
     } elseif (Wpjb_Project::getInstance()->conf("cv_access") == 4) {
         if (!wp_get_current_user()->ID) {
             $can_browse = false;
         }
     } else {
         // grant to all
     }
     if (wp_get_current_user()->has_cap("administrator")) {
         $can_browse = true;
     }
     return $can_browse;
 }
示例#6
0
 protected function _activeUntil()
 {
     $activeUntil = Wpjb_Model_Employer::current()->access_until;
     $activeUntil = strtotime($activeUntil);
     if ($activeUntil < time()) {
         $activeUntil = time();
     }
     $extend = Wpjb_Project::getInstance()->conf("cv_extend") * 3600 * 24;
     return $activeUntil + $extend;
 }
示例#7
0
 private function _getEmployerId()
 {
     if (!is_user_logged_in()) {
         return null;
     }
     $company = Wpjb_Model_Employer::current();
     return $company->getId();
 }
示例#8
0
 public function indexAction()
 {
     $this->_delete();
     $this->_multi();
     $this->_employers();
     $page = (int) $this->_request->get("page", 1);
     if ($page < 1) {
         $page = 1;
     }
     $perPage = $this->_getPerPage();
     $qstring = array();
     $employer = 0;
     if ($this->_request->get("employer") > 0) {
         $emp = new Wpjb_Model_Employer($this->_request->get("employer"));
         if ($emp->getId() > 0) {
             $employer = $emp->getId();
             $this->view->company = $emp;
             $this->view->repr = $emp->getUsers(true);
             $qstring['employer'] = $employer;
         }
     }
     $show = $this->_request->get("show", "all");
     $days = $this->_request->post("days", null);
     if ($days === null) {
         $days = $this->_request->get("days", "");
     }
     $query1 = new Daq_Db_Query();
     $query1->select("*")->from("Wpjb_Model_Job t1")->join("t1.category t2")->join("t1.type t3");
     $query2 = new Daq_Db_Query();
     $query2->select("COUNT(*) AS total")->from("Wpjb_Model_Job t1")->join("t1.category t2")->join("t1.type t3");
     if ($show == "active") {
         $query1->where("t1.is_active = 1");
         $query1->where("(t1.job_created_at > DATE_SUB(NOW(), INTERVAL t1.job_visible DAY)");
         $query1->orWhere("t1.job_visible = 0)");
         $query2->where("t1.is_active = 1");
         $query2->where("(t1.job_created_at > DATE_SUB(NOW(), INTERVAL t1.job_visible DAY)");
         $query2->orWhere("t1.job_visible = 0)");
     } elseif ($show == "inactive") {
         $query1->where("t1.is_active = 0");
         $query1->orWhere("(t1.job_created_at < DATE_SUB(NOW(), INTERVAL t1.job_visible DAY)");
         $query1->Where("t1.job_visible > 0)");
         $query2->where("t1.is_active = 0");
         $query2->orWhere("(t1.job_created_at < DATE_SUB(NOW(), INTERVAL t1.job_visible DAY)");
         $query2->Where("t1.job_visible > 0)");
     } elseif ($show == "awaiting") {
         $query1->where("t1.is_approved = 0");
         $query1->where("t1.is_active = 0");
         $query2->where("t1.is_approved = 0");
         $query2->where("t1.is_active = 0");
     }
     if (is_numeric($days)) {
         $query1->where("t1.job_created_at > DATE_SUB(NOW(), INTERVAL ? DAY)", $days);
         $query2->where("t1.job_created_at > DATE_SUB(NOW(), INTERVAL ? DAY)", $days);
     }
     if ($employer > 0) {
         $query1->where("t1.employer_id = ?", $employer);
         $query2->where("t1.employer_id = ?", $employer);
     }
     $result = $query1->order("t1.job_created_at DESC")->limitPage($page, $perPage)->execute();
     $total = $query2->limit(1)->fetchColumn();
     $this->view->employer = $employer;
     $this->view->days = $days;
     $this->view->show = $show;
     $this->view->current = $page;
     $this->view->total = ceil($total / $perPage);
     $this->view->data = $result;
     $query = new Daq_Db_Query();
     $list = array("COUNT(*) AS c_total", "SUM(t1.is_approved) AS c_awaiting");
     $query->select(join(", ", $list));
     $query->from("Wpjb_Model_Job t1");
     if (is_numeric($days)) {
         $query->where("t1.job_created_at > DATE_SUB(NOW(), INTERVAL ? DAY)", $days);
         $qstring['days'] = $days;
     }
     if ($employer > 0) {
         $query->where("t1.employer_id = ?", $employer);
     }
     $summary1 = $query->fetch();
     $query = new Daq_Db_Query();
     $query = $query->select("COUNT(*) AS c_active")->from("Wpjb_Model_Job t1")->where("t1.is_active = 1")->where("t1.is_approved = 1")->where("(t1.job_created_at > DATE_SUB(NOW(), INTERVAL t1.job_visible DAY)")->orWhere("t1.job_visible = 0)");
     if (is_numeric($days)) {
         $query->where("t1.job_created_at > DATE_SUB(NOW(), INTERVAL ? DAY)", $days);
     }
     if ($employer > 0) {
         $query->where("t1.employer_id = ?", $employer);
     }
     $summary2 = $query->fetch();
     $stat = new stdClass();
     $stat->total = $summary1->c_total;
     $stat->active = $summary2->c_active;
     $stat->inactive = $summary1->c_total - $summary2->c_active;
     $stat->awaiting = $summary1->c_total - $summary1->c_awaiting;
     $this->view->stat = $stat;
     $qs = "";
     foreach ($qstring as $k => $v) {
         $qs .= $k . "/" . esc_html((string) $v);
     }
     $this->view->qstring = $qs;
 }
示例#9
0
 public function accessAction()
 {
     $object = Wpjb_Model_Employer::current();
     $access = Wpjb_Project::getInstance()->conf("cv_access");
     if ($access == 2) {
         $this->_register();
     } elseif ($access == 3) {
         $this->_premium();
     }
     $this->view->access = $access;
 }
示例#10
0
        <p>
            Each purchase cost <strong><?php 
        echo $payment;
        ?>
</strong> and extends your access for next
            <strong><?php 
        echo Wpjb_Project::getInstance()->conf("cv_extend");
        ?>
 days</strong>.
            Until <?php 
        echo date("Y-m-d", $active_until);
        ?>
        </p>

        <?php 
        $employer = Wpjb_Model_Employer::current();
        ?>
        <?php 
        $time = strtotime($employer->access_until);
        ?>
        <?php 
        if ($time !== false) {
            ?>
        <ul>
            <?php 
            if ($time > time()) {
                ?>
            <li><?php 
                _e("Your access expires on", WPJB_DOMAIN);
                ?>
:
示例#11
0
 public function delete()
 {
     $this->deleteImage();
     $query = new Daq_Db_Query();
     $object = $query->select()->from("Wpjb_Model_JobSearch t")->where("t.job_id = ?", $this->getId())->limit(1)->execute();
     if (!empty($object)) {
         $object[0]->delete();
     }
     $employer = new Wpjb_Model_Employer($this->employer_id);
     if ($employer->getId() > 0) {
         $employer->jobs_posted--;
         $employer->save();
     }
     $result = parent::delete();
     Wpjb_Project::scheduleEvent();
     return $result;
 }
示例#12
0
            <td class="wpjb-form-spacer" colspan="2"><h3><?php 
    _e("Job Information", WPJB_DOMAIN);
    ?>
</h3></td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
    _e("Posted by", WPJB_DOMAIN);
    ?>
</th>
            <td class="wpjb-normal-td">
            <?php 
    if ($form->getObject()->employer_id > 0) {
        ?>
                <?php 
        $item = new Wpjb_Model_Employer($form->getObject()->employer_id);
        ?>
                <a href="<?php 
        echo $this->_url->linkTo("wpjb/employers", "edit/id/" . $item->getId());
        ?>
">
                    <?php 
        echo strlen($item->company_name) ? esc_html($item->company_name) : "-";
        ?>
                    (ID: <?php 
        echo $item->getId();
        ?>
)
                </a>
            <?php 
    } else {
示例#13
0
 public function myresumeAction()
 {
     $this->_setTitle(Wpjb_Project::getInstance()->conf("seo_resume_my_resume", __("My resume details", WPJB_DOMAIN)));
     if (!$this->_isEnabled()) {
         return false;
     }
     $object = Wpjb_Model_Resume::current();
     if ($object->id < 1) {
         $this->view->_flash->addError(__("You need to be logged in to access this page.", WPJB_DOMAIN));
         return false;
     }
     if (Wpjb_Model_Employer::current()->isEmployer()) {
         $this->view->_flash->addError(__("You need to be registered as Candidate in order to access this page. Your current account type is Employer.", WPJB_DOMAIN));
         return false;
     }
     if ($this->_request->post("remove_image") == 1) {
         $this->view->_flash->addInfo(__("Image removed.", WPJB_DOMAIN));
         $object->deleteImage();
         $object->save();
     }
     $form = new Wpjb_Form_Resume($object->getId());
     if ($this->isPost() && !$this->_request->post("remove_image")) {
         $isValid = $form->isValid($this->_request->getAll());
         if ($isValid) {
             $this->view->_flash->addInfo(__("Your resume has been saved.", WPJB_DOMAIN));
             $form->save();
         } else {
             $this->view->_flash->addError(__("Cannot save your resume. There are errors in your form.", WPJB_DOMAIN));
         }
     }
     $this->view->resume = $form->getObject();
     $this->view->form = $form;
     return "my-resume";
 }
示例#14
0
 public function previewAction()
 {
     if (!$this->_canPost()) {
         wp_redirect($this->_stepAdd);
     }
     $this->view->current_step = 2;
     $accept = array("company_name", "company_email", "company_website", "job_type", "job_category", "job_country", "job_state", "job_zip_code", "job_location", "job_title", "job_description");
     $form = new Wpjb_Form_AddJob();
     $request = $this->getRequest();
     $request->setSessionParam("wpjb.job_id", null);
     $jobArr = $request->session("wpjb.job", array());
     if ($this->isPost()) {
         if ($request->post("wpjb_preview", false)) {
             $jobArr = $request->getAll();
             $request->setSessionParam("wpjb.job", $jobArr);
         }
         if ($request->post("wpjb_reset", false)) {
             $request->setSessionParam("wpjb.job", null);
             $request->setSessionParam("wpjb.reset_job", true);
             wp_redirect($this->_stepAdd);
         }
     }
     if (!$form->isValid($jobArr)) {
         wp_redirect($this->_stepAdd);
     } else {
         if ($form->hasElement("company_logo")) {
             $file = $form->getElement("company_logo");
             if ($file->fileSent()) {
                 $file->setDestination(Wpjb_List_Path::getPath("tmp_images"));
                 $file->upload("temp_" . session_id() . "." . $file->getExt());
                 $request->setSessionParam("wpjb.job_logo_ext", $file->getExt());
             }
         }
         $mock = new Wpjb_Model_JobMock();
         $values = $form->getValues();
         $arr = array();
         foreach ($form->getElements() as $f) {
             /* @var $f Daq_Form_Element */
             if (stripos($f->getName(), "field_") !== 0) {
                 continue;
             }
             $class = new Wpjb_Model_FieldMock();
             $class->id = str_replace("field_", "", $f->getName());
             $class->is_required = $f->isRequired();
             $class->hint = $f->getHint();
             $class->type = $f->getType();
             $class->label = $f->getLabel();
             $class->value = $f->getValue();
             if ($f->isMultiOption()) {
                 foreach ((array) $f->getOptions() as $opt) {
                     if ($opt["key"] == $f->getValue()) {
                         $class->value = $opt["desc"];
                         break;
                     }
                 }
             }
             $arr[] = $class;
         }
         foreach ($accept as $field) {
             $mock->set($field, $values[$field]);
         }
         $mock->set("job_created_at", date("Y-m-d H:i:s"));
         $mock->set("company_logo_ext", $request->session("wpjb.job_logo_ext", null));
         $mock->setType(new Wpjb_Model_JobType($values["job_type"]));
         $mock->setCategory(new Wpjb_Model_Category($values["job_category"]));
         $mock->setAdditionalFields($arr);
         $text = Wpjb_Project::getInstance()->conf("seo_single", __("{job_title}", WPJB_DOMAIN));
         $param = array('job_title' => $values["job_title"], 'id' => 0);
         $this->_setTitle($text, $param);
         $this->view->job = $mock;
         $company = Wpjb_Model_Employer::current();
         if ($company->getId() > 0) {
             $this->view->company = $company;
         }
     }
 }