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