/** * 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(); } }
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; }
public function execute() { $this->_sql($this->getVersion()); set_time_limit(0); $query = new Daq_Db_Query(); $query->select()->from("Wpjb_Model_Job t")->joinLeft("t.search s")->where("is_active = 1")->where("s.job_id IS NULL"); foreach ($query->execute() as $job) { Wpjb_Model_JobSearch::createFrom($job); } $db = Daq_Db::getInstance(); $wpdb = $db->getDb(); $config = Wpjb_Project::getInstance(); $config->setConfigParam("front_template", "twentyten"); $config->saveConfig(); if (!Wpjb_Project::getInstance()->conf("link_jobs")) { $jId = wp_insert_post(array('post_type' => 'page', 'post_status' => 'publish', 'post_title' => 'Jobs', 'comment_status' => 'closed', 'ping_status' => 'closed')); $config->setConfigParam("link_jobs", $jId); $config->saveConfig(); } if (!Wpjb_Project::getInstance()->conf("link_resumes")) { $rId = wp_insert_post(array('post_type' => 'page', 'post_status' => 'publish', 'post_title' => 'Resumes', 'comment_status' => 'closed', 'ping_status' => 'closed')); $config->setConfigParam("link_resumes", $rId); $config->saveConfig(); } return; }
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; }
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; }
public function editAction() { $section = $this->_request->getParam("section"); $this->view->section = $section; $fArr = array("payment", "posting", "frontend", "seo", "integration", "resume"); $fList = array(); if ($section === null || !in_array($section, $fArr)) { foreach ($fArr as $key) { $class = "Wpjb_Form_Admin_Config_" . ucfirst($key); $fList[$key] = new $class(); } } else { $class = "Wpjb_Form_Admin_Config_" . ucfirst($section); $fList[$section] = new $class(); } if ($this->isPost() && apply_filters("_wpjb_can_save_config", $this)) { $isValid = true; foreach ($fList as $k => $obj) { if (!$obj->isValid($this->_request->getAll())) { $isValid = false; } $fList[$k] = $obj; } if ($isValid) { $instance = Wpjb_Project::getInstance(); foreach ($fList as $k => $obj) { // @todo: save config foreach ($obj->getValues() as $k => $v) { $instance->setConfigParam($k, $v); } } $instance->saveConfig(); $this->_addInfo(__("Configuration saved.", WPJB_DOMAIN)); } else { $this->_addError(__("There are errors in the form.", WPJB_DOMAIN)); } } if ($this->_request->getParam("saventest")) { $list = new Daq_Db_Query(); $list->select("*"); $list->from("Wpjb_Model_Job t"); $list->limit(1); $result = $list->execute(); if (empty($result)) { $this->_addError(__("Twitter: You need to have at least one posted job to send test tweet.", WPJB_DOMAIN)); } else { $job = $result[0]; try { Wpjb_Service_Twitter::tweet($job); $this->_addInfo(__("Tweet has been posted, please check your Twitter account.", WPJB_DOMAIN)); } catch (Exception $e) { $this->_addError($e->getMessage()); } } } $this->view->fList = $fList; }
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; }
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; }
public function indexAction() { $this->_delete(); $this->_multi(); $page = (int) $this->_request->get("page", 1); if ($page < 1) { $page = 1; } $perPage = $this->_getPerPage(); $sq1 = new Daq_Db_Query(); $sq1->select("count(*) AS `c_all`")->from("Wpjb_Model_Job t2")->where("t2.job_type=t1.id"); $sq2 = new Daq_Db_Query(); $sq2->select("count(*) AS `c_active`")->from("Wpjb_Model_Job t3")->where("t3.job_type=t1.id")->where("t3.is_active = 1")->where("t3.is_approved = 1")->where("(t3.job_created_at > DATE_SUB(NOW(), INTERVAL t3.job_visible DAY)")->orWhere("t3.job_visible = 0)"); $query = new Daq_Db_Query(); $result = $query->select("t1.*, (" . $sq1->toString() . ") AS `c_all`, (" . $sq2->toString() . ") AS `c_active`")->from("Wpjb_Model_JobType t1")->limitPage($page, $perPage); $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; }
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"; }
public function removeUser($id) { $query = new Daq_Db_Query(); $result = $query->select()->from("Wpjb_Model_Employer t")->where("user_id = ?", $id)->limit(1)->execute(); if ($result[0]) { $employer = $result[0]; $query = new Daq_Db_Query(); $query->select(); $query->from("Wpjb_Model_Job t"); $query->where("employer_id = ?", $employer->id); $result = $query->execute(); foreach ($result as $job) { $job->delete(); } $employer->delete(); } $query = new Daq_Db_Query(); $result = $query->select()->from("Wpjb_Model_Resume t")->where("user_id = ?", $id)->limit(1)->execute(); if ($result[0]) { $employer = $result[0]; $employer->delete(); } }
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__); }
public function typesAction() { $select = new Daq_Db_Query(); $select->select("*"); $select->from("Wpjb_Model_JobType t"); $result = $select->execute(); $response = array(); foreach ($result as $r) { $row = $r->toArray(); $row["url"] = wpjb_link_to("jobtype", $r); $response[] = $row; } self::_push($response); }