Exemple #1
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;
 }
Exemple #2
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 = "";
 }
Exemple #3
0
 public function isValid($value)
 {
     $query = new Daq_Db_Query();
     $result = $query->select("*")->from("Wpjb_Model_Discount t")->where("code = ?", $value)->limit(1)->execute();
     if (!isset($result[0])) {
         $this->setError(__("Coupon code does not exist.", WPJB_DOMAIN));
         return false;
     }
     $discount = $result[0];
     if (!$discount->is_active) {
         $this->setError(__("Coupon code is not active.", WPJB_DOMAIN));
         return false;
     }
     if (strtotime("now") > strtotime($discount->expires_at)) {
         $this->setError(__("Coupon code expired.", WPJB_DOMAIN));
         return false;
     }
     if ($discount->max_uses > 0 && $discount->used >= $discount->max_uses) {
         $this->setError(__("Coupon code expired.", WPJB_DOMAIN));
         return false;
     }
     if ($this->_currency !== null && $discount->type == 2 && $this->_currency != $discount->currency) {
         $this->setError(__("Currency does not match.", WPJB_DOMAIN));
         return false;
     }
     return true;
 }
Exemple #4
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;
 }
Exemple #5
0
 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;
 }
/**
 * 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();
    }
}
Exemple #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);
 }
Exemple #8
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);
 }
Exemple #9
0
 public function execute()
 {
     $query = new Daq_Db_Query();
     $result = $query->select("*")->from("Wpjb_Model_Job t")->execute();
     foreach ($result as $job) {
         Wpjb_Model_JobSearch::createFrom($job);
     }
 }
Exemple #10
0
 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;
 }
Exemple #11
0
 public static function getCategories()
 {
     if (self::has("_job_categories")) {
         return self::get("_job_categories");
     }
     $query = new Daq_Db_Query();
     $result = $query->select("*")->from("Wpjb_Model_Category t")->order("t.title ASC")->execute();
     self::set("_job_categories", $result);
     return $result;
 }
Exemple #12
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;
 }
Exemple #13
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;
 }
Exemple #14
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;
 }
Exemple #15
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;
 }
Exemple #16
0
 public function _loadAdditionalFields()
 {
     $query = new Daq_Db_Query();
     $fields = $query->select("*")->from("Wpjb_Model_FieldValue t")->join("t.field t3")->where("t3.field_for = 2")->where("t3.is_active = 1")->where("t.job_id = ?", $this->getId())->execute();
     $this->_fields = array();
     $this->_textareas = array();
     foreach ($fields as $field) {
         if ($field->getField()->type != Daq_Form_Element::TYPE_TEXTAREA) {
             $this->_fields[] = $field;
         } else {
             $this->_textareas[] = $field;
         }
     }
 }
Exemple #17
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;
 }
Exemple #18
0
 public function indexAction()
 {
     $query = new Daq_Db_Query();
     $data = $query->select("t1.*")->from("Wpjb_Model_Email t1")->order("sent_to")->execute();
     $item = array();
     foreach ($data as $d) {
         if (!isset($item[$d->sent_to]) || !is_array($item[$d->sent_to])) {
             $item[$d->sent_to] = array();
         }
         $item[$d->sent_to][] = $d;
     }
     $desc = array(1 => __("Emails sent to admin (emails are sent From and To email address specified in Mail From field)", WPJB_DOMAIN), 2 => __("Emails sent to job poster (to email address specified in Company Email field)", WPJB_DOMAIN), 3 => __("Other Emails", WPJB_DOMAIN));
     $this->view->desc = $desc;
     $this->view->data = $item;
 }
Exemple #19
0
 public function indexAction()
 {
     $this->_delete();
     $this->_multi();
     $page = (int) $this->_request->get("page", 1);
     if ($page < 1) {
         $page = 1;
     }
     $perPage = $this->_getPerPage();
     $query = new Daq_Db_Query();
     $this->view->data = $query->select("t.*")->from("Wpjb_Model_Discount t")->limitPage($page, $perPage)->execute();
     $query = new Daq_Db_Query();
     $total = $query->select("COUNT(*) AS total")->from("Wpjb_Model_Discount")->limit(1)->fetchColumn();
     $this->view->current = $page;
     $this->view->total = ceil($total / $perPage);
 }
 public function getOptionList()
 {
     if (!is_null($this->_option)) {
         return $this->_option;
     }
     if ($this->getId() < 1) {
         throw new Exception("Cannot get list for unsaved additional field");
     }
     if ($this->type != Daq_Form_Element::TYPE_SELECT) {
         return array();
     }
     $query = new Daq_Db_Query();
     $result = $query->select("*")->from("Wpjb_Model_FieldOption t")->where("field_id = ?", (int) $this->getId())->execute();
     $this->_option = $result;
     return $result;
 }
Exemple #21
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;
 }
Exemple #22
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;
 }
Exemple #23
0
 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;
 }
Exemple #24
0
 public function _injectMedia()
 {
     $dir = Wpjb_Project::getInstance()->media();
     $include = array("css" => true, "js" => true);
     $include = apply_filters("wpjb_inject_media", $include);
     $css = trim($dir, "/") . "/style.css";
     if ($include["css"]) {
         echo "\n" . '<link rel="stylesheet" href="' . $css . '" type="text/css" media="screen" />' . "\n";
     }
     echo '<script type="text/javascript">';
     $query = new Daq_Db_Query();
     $listing = array();
     $result = $query->select("*")->from("Wpjb_Model_Listing t")->where("is_active = 1")->execute();
     foreach ($result as $l) {
         /* @var $l Wpjb_Model_Listing */
         $temp = $l->toArray();
         $temp['symbol'] = Wpjb_List_Currency::getCurrencySymbol($l->currency);
         $listing[] = $temp;
     }
     echo 'Wpjb.Listing = ' . json_encode($listing) . ';';
     $class = new stdClass();
     $class->Check = __("check", WPJB_DOMAIN);
     $class->SelectListingType = __("Select listing type", WPJB_DOMAIN);
     $class->ListingCost = __("Listing cost", WPJB_DOMAIN);
     $class->Discount = __("Discount", WPJB_DOMAIN);
     $class->Total = __("Total", WPJB_DOMAIN);
     $class->Remove = __("remove", WPJB_DOMAIN);
     $class->CurrencyMismatch = __("Cannot use selected coupon with this listing. Currencies does not match.", WPJB_DOMAIN);
     $class->ResetForm = __("Reset all form fields?", WPJB_DOMAIN);
     echo 'Wpjb.Lang = ' . json_encode($class) . ';';
     echo 'Wpjb.Ajax = "' . admin_url("admin-ajax.php") . '";';
     echo 'Wpjb.AjaxRequest = "' . esc_html(Wpjb_Project::getInstance()->getUrl() . "/plain/discount") . '";';
     echo 'Wpjb.Protection = "' . esc_html(Wpjb_Project::getInstance()->conf("front_protection", "pr0t3ct1on")) . '";';
     echo 'Wpjb.PerPage = 20;';
     echo '</script>';
 }
Exemple #25
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");
 }
Exemple #26
0
 protected static function _getJobTypeId($title)
 {
     $slug = sanitize_title_with_dashes($title);
     $query = new Daq_Db_Query();
     $result = $query->select("*")->from("Wpjb_Model_JobType t")->where("t.title LIKE ?", "%" . $title . "%")->orWhere("t.slug LIKE ?", "%" . $slug . "%")->execute();
     if (count($result) > 0) {
         $jobType = $result[0];
         return $jobType->getId();
     } else {
         $jobType = new Wpjb_Model_JobType();
         $jobType->title = $title;
         $jobType->slug = $slug;
         $jobType->save();
         return $jobType->getId();
     }
 }
Exemple #27
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";
 }
Exemple #28
0
 public function isValid($values)
 {
     if (!$this->hasElement("listing")) {
         $listing = new Daq_Db_Query();
         $listing->select("*")->from("Wpjb_Model_Listing t")->limit(1);
         list($listing) = $listing->execute();
         $e = new Daq_Form_Element("listing");
         $e->setValue($listing->id);
         $this->addElement($e);
         $values["listing"] = $listing->id;
     }
     if (!$this->hasElement("payment_method")) {
         $payment = new Wpjb_Payment_Factory();
         $engine = new ArrayIterator($payment->getEngines());
         $engine = $engine->key();
         $e = new Daq_Form_Element("payment_method");
         $e->setValue($engine);
         $this->addElement($e);
         $values["payment_method"] = $engine;
     }
     $listing = new Wpjb_Model_Listing($values["listing"]);
     $validator = new Wpjb_Validate_Coupon($listing->currency);
     if ($this->hasElement("coupon")) {
         $this->getElement("coupon")->addValidator($validator);
     }
     $valid = parent::isValid($values);
     $discountObject = null;
     if (strlen($values['coupon']) > 0 && $valid) {
         $query = new Daq_Db_Query();
         $result = $query->select("*")->from("Wpjb_Model_Discount t")->where("code = ?", $values['coupon'])->limit(1)->execute();
         $discountObject = $result[0];
         $listing->addDiscount($discountObject);
     }
     if ($valid) {
         list($price, $discount) = $listing->calculatePrice();
         if ($discountObject) {
             $e = new Daq_Form_Element("discount_id");
             $e->setValue($discountObject->id);
             $this->addElement($e);
         }
         $e = new Daq_Form_Element("job_modified_at");
         $e->setValue(date("Y-m-d H:i:s"));
         $this->addElement($e);
         $e = new Daq_Form_Element("job_created_at");
         $e->setValue(date("Y-m-d H:i:s"));
         $this->addElement($e);
         $e = new Daq_Form_Element("job_expires_at");
         if ($listing->visible == 0) {
             $expiresAt = "9999-12-31 23:59:59";
         } else {
             $expiresAt = strtotime("now +" . $listing->visible . " days");
             $expiresAt = date("Y-m-d H:i:s", $expiresAt);
         }
         $e->setValue($expiresAt);
         $this->addElement($e);
         $e = new Daq_Form_Element("job_visible");
         $e->setValue($listing->visible);
         $this->addElement($e);
         $e = new Daq_Form_Element("job_source");
         $e->setValue(1);
         $this->addElement($e);
         $e = new Daq_Form_Element("is_filled");
         $e->setValue(0);
         $this->addElement($e);
         $isActive = Wpjb_Project::getInstance()->getConfig("posting_moderation");
         $isActive = !(bool) $isActive;
         if ($price > 0) {
             $isActive = false;
         }
         $e = new Daq_Form_Element("is_approved");
         $e->setValue($isActive);
         $this->addElement($e);
         $e = new Daq_Form_Element("is_active");
         $e->setValue($isActive);
         $this->addElement($e);
         $e = new Daq_Form_Element("is_featured");
         $e->setValue($listing->is_featured);
         $this->addElement($e);
         $e = new Daq_Form_Element("payment_sum");
         $e->setValue($price);
         $this->addElement($e);
         $e = new Daq_Form_Element("payment_paid");
         $e->setValue(0);
         $this->addElement($e);
         $e = new Daq_Form_Element("payment_currency");
         $e->setValue($listing->currency);
         $this->addElement($e);
         $e = new Daq_Form_Element("payment_discount");
         $e->setValue($discount);
         $this->addElement($e);
         $slug = Wpjb_Utility_Slug::generate(Wpjb_Utility_Slug::MODEL_JOB, $values['job_title']);
         $e = new Daq_Form_Element("job_slug");
         $e->setValue($slug);
         $this->addElement($e);
         $e = new Daq_Form_Element("employer_id");
         $e->setValue($this->_getEmployerId());
         $this->addElement($e);
     }
     return $valid;
 }
Exemple #29
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;
 }
Exemple #30
0
 protected function _getUniqueSlug($title)
 {
     $slug = sanitize_title_with_dashes($title);
     $newSlug = $slug;
     $isUnique = true;
     $query = new Daq_Db_Query();
     $query->select("t.job_slug")->from("Wpjb_Model_Job t")->where("(t.job_slug = ?", $newSlug)->orWhere("t.job_slug LIKE ? )", $newSlug . "%");
     $list = array();
     $c = 0;
     foreach ($query->fetchAll() as $q) {
         $list[] = $q->t__job_slug;
         $c++;
     }
     if ($c > 0) {
         $isUnique = false;
         $i = 1;
         do {
             $i++;
             $newSlug = $slug . "-" . $i;
             if (!in_array($newSlug, $list)) {
                 $isUnique = true;
             }
         } while (!$isUnique);
     }
     return $newSlug;
 }