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; }
/** * 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 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 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; }
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"); }
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 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; }
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(); } }
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); } } }
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); }
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; }