Пример #1
0
 public function cityAction()
 {
     $request = Daq_Request::getInstance();
     $pattern = $request->get("q");
     $country = $request->get("country", 0);
     $state = $request->get("state", "");
     $query = new Daq_Db_Query();
     $query->select("*");
     $query->from("Wpjb_Model_Job t");
     if ($country > 0) {
         $query->where("job_country = ?", $country);
     }
     if (!empty($state)) {
         $query->where("job_state LIKE ?", "%{$state}%");
     }
     $query->where("job_location LIKE ?", "%{$pattern}%");
     $query->group("job_location");
     $query->limit(10);
     $result = $query->execute();
     $arr = array();
     foreach ($result as $r) {
         $arr[] = $r->job_location;
     }
     echo join("\r\n", $arr);
     exit;
 }
Пример #2
0
 public function indexAction()
 {
     $this->_delete();
     $this->_multi();
     $page = (int) $this->_request->get("page", 1);
     if ($page < 1) {
         $page = 1;
     }
     $perPage = $this->_getPerPage();
     $qstring = array();
     $sq1 = new Daq_Db_Query();
     $sq1->select("count(*) AS `c_all`")->from("Wpjb_Model_Job t2")->where("t2.job_category=t1.id");
     $query = new Daq_Db_Query();
     $query->select("*");
     $query->from("Wpjb_Model_Application t");
     $query->join("t.job t2");
     $query->order("is_rejected ASC, applied_at DESC");
     $query->limitPage($page, $perPage);
     if ($this->_request->get("job") > 0) {
         $jId = $this->_request->get("job");
         $query->where("job_id = ?", $jId);
         $this->view->job = new Wpjb_Model_Job($jId);
         $qstring["job"] = $jId;
     }
     $result = $query->execute();
     $total = (int) $query->select("COUNT(*) as `total`")->limit(1)->fetchColumn();
     $this->view->current = $page;
     $this->view->total = ceil($total / $perPage);
     $this->view->data = $result;
     $qs = "";
     foreach ($qstring as $k => $v) {
         $qs .= $k . "/" . esc_html((string) $v);
     }
     $this->view->qstring = $qs;
 }
Пример #3
0
 public function indexAction()
 {
     $page = (int) $this->_request->get("page", 1);
     if ($page < 1) {
         $page = 1;
     }
     $id = null;
     if ($this->_request->post("id")) {
         $id = (int) $this->_request->post("id", 1);
     }
     $this->view->id = $id;
     $perPage = $this->_getPerPage();
     $query = new Daq_Db_Query();
     $query = $query->select("t.*, t2.*")->from("Wpjb_Model_Payment t")->joinLeft("t.user t2")->where("made_at > '0000-00-00'")->limitPage($page, $perPage);
     if ($id > 0) {
         $query->where("t.id = ?", $id);
     }
     $this->view->data = $query->execute();
     $query = new Daq_Db_Query();
     $total = $query->select("COUNT(*) AS total")->from("Wpjb_Model_Payment t")->joinLeft("t.user t2")->where("made_at > '0000-00-00'")->limit(1);
     if ($id > 0) {
         $query->where("t.id = ?", $id);
     }
     $total = $total->fetchColumn();
     $this->view->current = $page;
     $this->view->total = ceil($total / $perPage);
 }
Пример #4
0
 public function indexAction()
 {
     $this->_multi();
     $page = (int) $this->_request->get("page", 1);
     if ($page < 1) {
         $page = 1;
     }
     $perPage = $this->_getPerPage();
     $perPage = $this->_getPerPage();
     $query = new Daq_Db_Query();
     $query->select()->from("Wpjb_Model_Employer t")->join("t.users u")->join("t.usermeta um")->where("um.meta_key = ?", "is_employer")->where("um.meta_value > 0");
     $prep = clone $query;
     $show = $this->_request->get("show", "all");
     if ($show == "pending") {
         $query->where("t.is_active=?", 2);
     }
     $total = $query->select("COUNT(*) AS `totoal`")->fetchColumn();
     $this->view->data = $query->select("*")->limitPage($page, $perPage)->execute();
     $this->view->current = $page;
     $this->view->total = ceil($total / $perPage);
     $prep->select("COUNT(*) AS cnt")->limit(1);
     $total = clone $prep;
     $pending = clone $prep;
     $this->view->show = $show;
     $stat = new stdClass();
     $stat->total = $total->where("jobs_posted > 0")->fetchColumn();
     $stat->pending = $pending->where("t.is_active=?", 2)->fetchColumn();
     $this->view->stat = $stat;
     $this->view->qstring = "";
 }
/**
 * Insert attention message
 *
 * This function will show "Attention! This job is ..." message if current user
 * is on job details page and currently viewed job is older than X days.
 *
 * @since 1.0
 * @return void
 */
function push_attention_msg()
{
    $job = null;
    if (is_singular("job")) {
        $query = new Daq_Db_Query();
        $query->from("Wpjb_Model_Job t");
        $query->where("post_id = ?", get_the_ID());
        $query->limit(1);
        $result = $query->execute();
        if (isset($result[0])) {
            $job = $result[0];
        }
    }
    if (is_wpjb() && wpjb_is_routed_to("index.single")) {
        $job = Wpjb_Project::getInstance()->placeHolder->job;
    }
    if ($job === null) {
        return;
    }
    $old = wpjb_conf("front_mark_as_old");
    if ($old > 0 && time() - strtotime($job->job_created_at) > $old * 3600 * 24) {
        $diff = floor((time() - strtotime($job->job_created_at)) / (3600 * 24));
        $msg = _n("Attention! This job posting is one day old and might be already filled.", "Attention! This job posting is %d days old and might be already filled.", $diff, "wpjobboard");
        $flash = new Wpjb_Utility_Session();
        $flash->addInfo(sprintf($msg, $diff));
        $flash->save();
    }
}
Пример #6
0
 public static function generate($model, $title, $id = null)
 {
     $list = array("job" => array("model" => "Wpjb_Model_Job", "field" => "job_slug"), "type" => array("model" => "Wpjb_Model_JobType", "field" => "slug"), "category" => array("model" => "Wpjb_Model_Category", "field" => "slug"));
     $slug = sanitize_title_with_dashes($title);
     $slug = preg_replace("([^A-z0-9\\-]+)", "", $slug);
     $newSlug = $slug;
     $isUnique = true;
     $query = new Daq_Db_Query();
     $query->select("t." . $list[$model]['field'])->from($list[$model]['model'] . " t")->where("(" . $list[$model]['field'] . " = ?", $newSlug)->orWhere($list[$model]['field'] . " LIKE ? )", $newSlug . "%");
     if ($id > 0) {
         $query->where("id <> ?", $id);
     }
     $field = "t__" . $list[$model]['field'];
     $list = array();
     $c = 0;
     foreach ($query->fetchAll() as $q) {
         $list[] = $q->{$field};
         $c++;
     }
     if ($c > 0) {
         $isUnique = false;
         $i = 1;
         do {
             $i++;
             $newSlug = $slug . "-" . $i;
             if (!in_array($newSlug, $list)) {
                 $isUnique = true;
             }
         } while (!$isUnique);
     }
     return $newSlug;
 }
Пример #7
0
 public function indexAction()
 {
     $this->_multi();
     $object = Wpjb_Model_Resume::current();
     $page = (int) $this->_request->get("page", 1);
     if ($page < 1) {
         $page = 1;
     }
     $perPage = $this->_getPerPage();
     $query = new Daq_Db_Query();
     $query->select()->from("Wpjb_Model_Resume t")->join("t.users t2")->order("t.updated_at DESC");
     $prep = clone $query;
     $show = $this->_request->get("show", "all");
     if ($show == "pending") {
         $query->where("t.is_approved=?", Wpjb_Model_Resume::RESUME_PENDING);
     }
     $count = $query->select("COUNT(*) AS cnt")->limit(1)->fetchColumn();
     $result = $query->select("*")->limitPage($page, $perPage)->execute();
     $this->view->data = $result;
     $prep->select("COUNT(*) AS cnt")->limit(1);
     $total = clone $prep;
     $active = clone $prep;
     $this->view->show = $show;
     $stat = new stdClass();
     $stat->total = $total->fetchColumn();
     $stat->pending = $active->where("t.is_approved=?", Wpjb_Model_Resume::RESUME_PENDING)->fetchColumn();
     $this->view->stat = $stat;
     $this->view->current = $page;
     $this->view->total = ceil($stat->total / $perPage);
 }
Пример #8
0
 public function init()
 {
     $this->_perPage = Wpjb_Project::getInstance()->conf("front_jobs_per_page", 20);
     $this->view->baseUrl = Wpjb_Project::getInstance()->getUrl("resumes");
     $query = new Daq_Db_Query();
     $query->select()->from("Wpjb_Model_Resume t1")->join("t1.users t2")->where("is_active = 1")->order("updated_at DESC");
     if (Wpjb_Project::getInstance()->conf("cv_approval") == 1) {
         $query->where("is_approved = ?", Wpjb_Model_Resume::RESUME_APPROVED);
     }
     $this->_query = $query;
 }
Пример #9
0
 public function execute()
 {
     $this->_sql($this->getVersion());
     $query = new Daq_Db_Query();
     $query->select("*");
     $query->from("Wpjb_Model_Employer t1");
     $query->where("jobs_posted > 0");
     $list = $query->execute();
     foreach ($list as $emp) {
         update_usermeta($emp->user_id, "is_employer", 1);
     }
     return;
 }
Пример #10
0
 protected function _exist($value)
 {
     $orm = $this->_orm;
     $field = $this->_field;
     $exclude = $this->_exclude;
     $query = new Daq_Db_Query();
     $query->select("t.*")->from("{$orm} t")->where("t.{$field} = ?", $value);
     foreach ($exclude as $k => $v) {
         $query->where("t.{$k} <> ?", $v);
     }
     $query->limit(1);
     $result = $query->fetch();
     return $result;
 }
Пример #11
0
 public static function render()
 {
     $list = new Daq_Db_Query();
     $list->select("t.payment_currency as curr");
     $list->from("Wpjb_Model_Payment t");
     $list->where("payment_paid > 0");
     $list->group("payment_currency");
     $result = $list->fetchAll();
     $curr = array();
     foreach ($result as $r) {
         $c = Wpjb_List_Currency::getCurrency($r->curr);
         $curr[$r->curr] = $c["name"];
     }
     $view = Wpjb_Project::getInstance()->getAdmin()->getView();
     /* @var $view  Daq_View */
     $view->currency = $curr;
     $view->render("dashboard/stats.php");
 }
Пример #12
0
 protected function _dispatch($route)
 {
     $this->_route = $route;
     if (isset($route['object'])) {
         $class = $route['object']->objClass;
         $query = new Daq_Db_Query();
         $query->select("*")->from("{$class} t");
         $object = new $class();
         $reg = $object->getFieldNames();
         foreach ($route['param'] as $key => $value) {
             if (in_array($key, $reg)) {
                 $query->where("{$key} = ?", $value);
             }
         }
         $object = $query->execute();
         if (empty($object)) {
             throw new Exception("Object does not exist");
         } else {
             $route['object'] = $object[0];
         }
     }
     foreach ($route['param'] as $k => $v) {
         Daq_Request::getInstance()->addParam("GET", $k, $v);
     }
     $index = $route['action'];
     $ctrl = rtrim($this->_controller, "*") . ucfirst($route['module']);
     $action = $route['action'] . "Action";
     if (!class_exists($ctrl)) {
         throw new Exception("Module [{$ctrl}] does not exist");
     }
     $controller = new $ctrl();
     if (!method_exists($controller, $action)) {
         throw new Exception("Method [{$action}] does not exist for controller [{$ctrl}]");
     }
     $controller->setView($this->_view);
     if ($route['object'] && $route['object'] instanceof Daq_Db_OrmAbstract) {
         $controller->setObject($route['object']);
     }
     $this->controller = $controller;
     $this->controller->init();
     $result = $this->controller->{$action}();
     $this->getProject()->placeHolder = $this->_view;
     return $result;
 }
Пример #13
0
 public function applicationsAction()
 {
     $this->_setTitle(__("Applications", WPJB_DOMAIN));
     $job = $this->getObject();
     $emp = $job->getEmployer(true);
     if ($this->_isCandidate()) {
         return false;
     }
     if ($emp->user_id < 1 || $emp->user_id != wp_get_current_user()->ID) {
         $this->view->_flash->addError(__("You are not allowed to access this page.", WPJB_DOMAIN));
         return false;
     }
     $this->view->job = $job;
     $query = new Daq_Db_Query();
     $query->select("*");
     $query->from("Wpjb_Model_Application t");
     $query->where("job_id = ?", $job->getId());
     $query->order("is_rejected ASC, applied_at DESC");
     $result = $query->execute();
     $this->view->applicantList = $result;
     return "job-applications";
 }
Пример #14
0
 public function indexAction()
 {
     $this->_multi();
     $page = (int) $this->_request->get("page", 1);
     if ($page < 1) {
         $page = 1;
     }
     $perPage = $this->_getPerPage();
     $show = $this->_request->get("show", "all");
     $days = $this->_request->post("days", null);
     if ($days === null) {
         $days = $this->_request->get("days", "");
     }
     // list my job ads
     $query = new Daq_Db_Query();
     $query->select()->from("Wpjb_Model_Job t1")->where("employer_id = ?", Wpjb_Model_Employer::current()->getId())->order("t1.job_created_at DESC");
     if (Wpjb_Project::getInstance()->conf("front_hide_filled")) {
         $actAdd = " AND is_filled = 0";
         $expAdd = " AND is_filled = 1";
     } else {
         $actAdd = "";
         $expAdd = "";
     }
     if (is_numeric($days)) {
         $query->where("t1.job_created_at > DATE_SUB(NOW(), INTERVAL ? DAY)", $days);
     }
     $activeQ = "(t1.job_created_at > DATE_SUB(NOW(), INTERVAL t1.job_visible DAY) OR t1.job_visible = 0) AND t1.is_active = 1 {$actAdd}";
     $expiredQ = "((t1.job_created_at < DATE_SUB(NOW(), INTERVAL t1.job_visible DAY) AND  t1.job_visible <> 0) {$expAdd})";
     $awaitingQ = "t1.is_approved = 0";
     $prep = clone $query;
     if ($show == "active") {
         $query->where($activeQ);
     } elseif ($show == "expired") {
         $query->where($expiredQ);
     } elseif ($show == "awaiting") {
         $query->where($awaitingQ);
     }
     $count = $query->select("COUNT(*) AS cnt")->limit(1)->fetchColumn();
     $result = $query->select("*")->limitPage($page, $perPage)->execute();
     $this->view->data = $result;
     $this->view->days = $days;
     $this->view->show = $show;
     $this->view->current = $page;
     $this->view->total = ceil($count / $perPage);
     $this->view->data = $result;
     $stat = new stdClass();
     $prep->select("COUNT(*) AS cnt")->limit(1);
     $total = clone $prep;
     $active = clone $prep;
     $expired = clone $prep;
     $awaiting = clone $prep;
     $stat->total = $total->fetchColumn();
     $stat->active = $active->where($activeQ)->fetchColumn();
     $stat->expired = $expired->where($expiredQ)->fetchColumn();
     $stat->awaiting = $awaiting->where($awaitingQ)->fetchColumn();
     $this->view->stat = $stat;
 }
Пример #15
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;
 }
Пример #16
0
 public static function search($params)
 {
     $category = null;
     $type = null;
     $posted = null;
     $query = null;
     $field = array();
     $location = null;
     $page = null;
     $count = null;
     $order = null;
     $sort = null;
     extract($params);
     $select = Wpjb_Model_Job::activeSelect();
     if (isset($is_featured)) {
         $select->where("t1.is_featured = 1");
     }
     if (isset($employer_id)) {
         $select->where("t1.employer_id IN(?)", $employer_id);
     }
     if (isset($country)) {
         $select->where("t1.job_country = ?", $country);
     }
     if (is_array($category)) {
         $category = array_map("intval", $category);
         $select->join("t1.category t2", "t2.id IN (" . join(",", $category) . ")");
     } elseif (!empty($category)) {
         $select->join("t1.category t2", "t2.id = " . (int) $category);
     } else {
         $select->join("t1.category t2");
     }
     if (is_array($type)) {
         $type = array_map("intval", $type);
         $select->join("t1.type t3", "t3.id IN (" . join(",", $type) . ")");
     } elseif (!empty($type)) {
         $select->join("t1.type t3", "t3.id=" . (int) $type);
     } else {
         $select->join("t1.type t3");
     }
     $days = $posted;
     if ($days == 1) {
         $time = date("Y-m-d");
         $select->where("DATE(job_created_at) = ?", date("Y-m-d"));
     } elseif ($days == 2) {
         $time = date("Y-m-d", strtotime("yesterday"));
         $select->where("DATE(job_created_at) = ?", date("Y-m-d", strtotime("now -1 day")));
     } elseif (is_numeric($days)) {
         $select->where("job_created_at >= DATE_SUB(NOW(), INTERVAL ? DAY)", (int) $days);
     }
     if (is_array($field)) {
         foreach ($field as $k => $v) {
             $k = intval($k);
             $v = trim($v);
             if ($k < 1 || empty($v)) {
                 continue;
             }
             $custom = new Wpjb_Model_AdditionalField($k);
             if ($custom->field_for != 1) {
                 continue;
             }
             $q = new Daq_Db_Query();
             $q->select("COUNT(*) AS c");
             $q->from("Wpjb_Model_FieldValue tf{$k}");
             $q->where("tf{$k}.job_id=t1.id");
             if ($custom->type == 3 || $custom->type == 4) {
                 $q->where("tf{$k}.value = ?", $v);
             } else {
                 $q->where("tf{$k}.value LIKE ?", "%{$v}%");
             }
             $select->where("({$q})>0");
         }
     }
     $searchString = $search = $query;
     $q = "MATCH(t4.title, t4.description, t4.location, t4.company)";
     $q .= "AGAINST (? IN BOOLEAN MODE)";
     $select->select("COUNT(*) AS `cnt`");
     $itemsFound = 0;
     if ($searchString && strlen($searchString) <= 3) {
         $select->join("t1.search t4");
         $select->where("(t4.title LIKE ?", '%' . $searchString . '%');
         $select->orWhere("t4.description LIKE ?)", '%' . $searchString . '%');
         $itemsFound = $select->fetchColumn();
         $search = false;
     } elseif ($searchString) {
         foreach (array(1, 2, 3) as $t) {
             $test = clone $select;
             $test->join("t1.search t4");
             if ($t == 1) {
                 $test->where(str_replace("?", '\'"' . mysql_real_escape_string($search) . '"\'', $q));
             } elseif ($t == 2) {
                 $test->where($q, "+" . str_replace(" ", " +", $search));
             } else {
                 $test->where($q, $search);
             }
             $itemsFound = $test->fetchColumn();
             if ($itemsFound > 0) {
                 break;
             }
         }
     } else {
         $itemsFound = $select->fetchColumn();
     }
     if ($search) {
         $select->join("t1.search t4");
         if ($t == 1) {
             $select->where(str_replace("?", '\'"' . mysql_real_escape_string($search) . '"\'', $q));
         } elseif ($t == 2) {
             $select->where($q, "+" . str_replace(" ", " +", $search));
         } else {
             $select->where($q, $search);
         }
     }
     if ($searchString && $location) {
         $select->where("t4.location LIKE ?", "%{$location}%");
     } elseif ($location) {
         $select->join("t1.search t4");
         $select->where("t4.location LIKE ?", "%{$location}%");
     }
     $select->select("*");
     if ($page && $count) {
         $select->limitPage($page, $count);
     }
     $ord = array("id", "job_created_at", "job_title");
     if (!in_array($order, $ord)) {
         $order = null;
     }
     if ($sort != "desc") {
         $sort = "asc";
     }
     if ($order) {
         $select->order("t1.is_featured DESC, t1.{$order} {$sort}");
     }
     $jobList = $select->execute();
     $response = new stdClass();
     $response->job = $jobList;
     $response->page = $page;
     $response->perPage = $count;
     $response->count = count($jobList);
     $response->total = $itemsFound;
     $link = wpjb_link_to("feed_custom");
     $link2 = wpjb_link_to("search");
     $p2 = $params;
     unset($p2["page"]);
     unset($p2["count"]);
     $q2 = http_build_query($p2);
     $glue = "?";
     if (stripos($link, "?")) {
         $glue = "&";
     }
     $response->url = new stdClass();
     $response->url->feed = $link . $glue . $q2;
     $response->url->search = $link2 . $glue . $q2;
     return $response;
 }
Пример #17
0
 public static function search($query, $category, $degree, $experience, $posted, $count, $page)
 {
     $select = new Daq_Db_Query();
     $select->select()->from("Wpjb_Model_Resume t1")->join("t1.users t2")->where("is_active = 1")->order("updated_at DESC");
     if (Wpjb_Project::getInstance()->conf("cv_approval") == 1) {
         $select->where("is_approved = ?", Wpjb_Model_Resume::RESUME_APPROVED);
     }
     if ($query) {
         $search = $query;
         $q = "MATCH(title, headline, experience, education)";
         $q .= "AGAINST (? IN BOOLEAN MODE)";
         $select->where($q, $search);
     }
     if (is_array($category)) {
         $category = array_map("intval", $category);
         $select->where("category_id IN (?)", join(",", $category));
     } elseif ($category) {
         $select->where("category_id = ?", $category);
     }
     if (is_array($degree)) {
         $degree = array_map("intval", $degree);
         $select->where("category_id IN (?)", join(",", $degree));
     } elseif ($degree) {
         $select->where("degree = ?", $degree);
     }
     if (is_array($experience)) {
         $experience = array_map("intval", $experience);
         $select->where("category_id IN (?)", join(",", $experience));
     } elseif ($experience) {
         $select->where("years_experience = ?", $experience);
     }
     if ($posted) {
         $days = posted;
         if ($days == 1) {
             $time = date("Y-m-d");
             $select->where("DATE(updated_at) = ?", date("Y-m-d"));
         } elseif ($days == 2) {
             $time = date("Y-m-d", strtotime("yesterday"));
             $select->where("DATE(updated_at) = ?", date("Y-m-d", strtotime("now -1 day")));
         } else {
             $select->where("updated_at >= DATE_SUB(NOW(), INTERVAL ? DAY)", (int) $days);
         }
     }
     $itemsFound = $select->select("COUNT(*) AS cnt")->fetchColumn();
     $select->select("*");
     if ($count > 0) {
         $select->limitPage($page, $count);
     }
     $list = $select->execute();
     $response = new stdClass();
     $response->resume = $list;
     $response->page = (int) $page;
     $response->perPage = (int) $count;
     $response->count = count($list);
     $response->total = (int) $itemsFound;
     return $response;
 }
Пример #18
0
 protected function _saveOptions($fId, array $option)
 {
     $list = new Daq_Db_Query();
     $list->select("*");
     $list->from("Wpjb_Model_FieldOption t");
     $list->where("field_id = ?", $fId);
     $list = $list->execute();
     $arr = array();
     foreach ($list as $opt) {
         $arr[$opt->id] = $opt->id;
     }
     foreach ($option as $key => $value) {
         list($x, $id) = explode("_", $key);
         $field = new Wpjb_Model_FieldOption($id);
         $field->field_id = $fId;
         $field->value = $value;
         $field->save();
         unset($arr[$id]);
     }
     foreach ($arr as $id) {
         $field = new Wpjb_Model_FieldOption($id);
         $field->delete();
     }
 }
Пример #19
0
 public function addAdminMenu()
 {
     $ini = Daq_Config::parseIni($this->path("app_config") . "/admin-menu.ini", $this->path("user_config") . "/admin-menu.ini", true);
     $logo = site_url() . "/wp-content/plugins/wpjobboard";
     $logo .= $this->pathRaw("admin_public") . "/wpjb-mini.png";
     if (!$this->conf("cv_enabled")) {
         unset($ini['resumes_manage']);
     }
     $query = new Daq_Db_Query();
     $query->select("COUNT(*) AS cnt")->from("Wpjb_Model_Job t1");
     $query->join("t1.category t2");
     $query->join("t1.type t3");
     $query->where("t1.is_approved = 0");
     $query->where("t1.is_active = 0");
     $pending = $query->fetchColumn();
     if (isset($ini["jobs"]["page_title"])) {
         $warning = __("jobs awaiting approval", WPJB_DOMAIN);
         $ini["jobs"]["menu_title"] = $ini["jobs"]["page_title"];
         $ini["jobs"]["menu_title"] .= "<span class='update-plugins wpjb-bubble-jobs count-{$pending}' title='{$warning}'><span class='update-count'>" . $pending . "</span></span>";
     }
     $query = new Daq_Db_Query();
     $query->select();
     $query->from("Wpjb_Model_Employer t")->join("t.users u")->select("COUNT(*) AS cnt")->limit(1);
     $pending = $query->where("t.is_active=?", 2)->fetchColumn();
     if (isset($ini["companies"]["page_title"])) {
         $warning = __("employers requesting approval", WPJB_DOMAIN);
         $ini["companies"]["menu_title"] = $ini["companies"]["page_title"];
         $ini["companies"]["menu_title"] .= "<span class='update-plugins wpjb-bubble-companies count-{$pending}' title='{$warning}'><span class='update-count'>" . $pending . "</span></span>";
     }
     $query = new Daq_Db_Query();
     $query->select()->from("Wpjb_Model_Resume t")->join("t.users t2")->order("t.updated_at DESC");
     $query->select("COUNT(*) AS cnt")->limit(1);
     $pending = $query->where("t.is_approved=?", Wpjb_Model_Resume::RESUME_PENDING)->fetchColumn();
     if (isset($ini["resumes_manage"]["page_title"])) {
         $warning = __("resumes pending approval", WPJB_DOMAIN);
         $ini["resumes_manage"]["menu_title"] = $ini["resumes_manage"]["page_title"];
         $ini["resumes_manage"]["menu_title"] .= "<span class='update-plugins wpjb-bubble-resumes count-{$pending}' title='{$warning}'><span class='update-count'>" . $pending . "</span></span>";
     }
     foreach ($ini as $key => $conf) {
         if (isset($conf['parent'])) {
             if (isset($conf["menu_title"])) {
                 $menu_title = $conf["menu_title"];
             } else {
                 $menu_title = $conf["page_title"];
             }
             add_submenu_page("wpjb" . $ini[$conf['parent']]['handle'], $conf['page_title'], $menu_title, $conf['access'], "wpjb" . $conf['handle'], array($this, "dispatch"));
         } else {
             add_menu_page($conf['page_title'], $conf['page_title'], $conf['access'], "wpjb" . $conf['handle'], array($this, "dispatch"), $logo);
         }
     }
 }
Пример #20
0
 public function __call($method, $param = array())
 {
     $call = str_replace("get", "", strtolower($method));
     foreach ($this->_reference as $key => $value) {
         if ($key == $call) {
             if (!isset($this->_loaded[$value['foreign']])) {
                 if (isset($param[0]) && $param[0] == true) {
                     $class = $value['foreign'];
                     $local = $value['localId'];
                     $query = new Daq_Db_Query();
                     $query->select()->from($class . " t")->where($value['foreignId'] . " = ?", $this->{$local});
                     if (isset($value['with'])) {
                         $query->where($value['with']);
                     }
                     $result = $query->execute();
                     $this->_loaded[$value['foreign']] = new $class();
                     if (!empty($result)) {
                         $this->_loaded[$value['foreign']] = $result[0];
                     }
                 } else {
                     throw new Exception("Object {$value['foreign']} not loaded for class " . __CLASS__);
                 }
             }
             return $this->_loaded[$value['foreign']];
         }
     }
     throw new Exception("Method {$method} does not exist for class " . __CLASS__);
 }