Esempio n. 1
0
 protected static function _modify(Wpjb_Model_Job $job)
 {
     $arr = $job->allToArray();
     foreach (Wpjb_Utility_Registry::getCategories() as $category) {
         if ($category->id == $job->job_category) {
             break;
         }
     }
     foreach (Wpjb_Utility_Registry::getJobTypes() as $type) {
         if ($type->id == $job->job_type) {
             break;
         }
     }
     $public = array("id", "company_name", "company_website", "job_type", "job_category", "job_country", "job_state", "job_zip_code", "job_location", "job_limit_to_country", "job_title", "job_slug", "job_created_at", "job_expires_at", "job_description", "is_active", "is_filled", "is_featured", "stat_view", "stat_unique", "stat_apply");
     $publish = new stdClass();
     foreach ($public as $k) {
         $publish->{$k} = $job->{$k};
     }
     $arr = $job->allToArray();
     foreach ($arr as $k => $a) {
         if (substr($k, 0, 6) == "field_") {
             $publish->{$k} = $a;
         }
     }
     $publish->url = wpjb_link_to("job", $job);
     $publish->image = $job->getImageUrl();
     $publish->formatted_created_at = wpjb_date("M, d", $job->job_created_at);
     $publish->location = $job->locationToString();
     $publish->category = $category->toArray();
     $publish->type = $type->toArray();
     $publish->is_new = $job->isNew();
     $publish->is_free = $job->isFree();
     return $publish;
 }
Esempio n. 2
0
 public function render()
 {
     $router = Wpjb_Project::getInstance()->getApplication("frontend")->getRouter();
     /* @var $router Daq_Router */
     $notify = Wpjb_Project::getInstance()->getUrl() . "/" . $router->linkTo("step_notify", $this->_data);
     $complete = Wpjb_Project::getInstance()->getUrl() . "/" . $router->linkTo("step_complete", $this->_data);
     $amount = $this->_data->payment_sum - $this->_data->payment_paid;
     $currency = self::$_currency[$this->_data->payment_currency]['code'];
     $product = str_replace("{num}", $this->_data->getId(), __("Job Board order #{num} at: ", WPJB_DOMAIN));
     $product .= get_bloginfo("name");
     $html = "";
     $html .= '<form action="' . $this->getUrl() . '" method="post">';
     $html .= '<input type="hidden" name="cmd" value="_xclick">';
     $html .= '<input type="hidden" name="business" value="' . $this->getEmail() . '">';
     $html .= '<input type="hidden" name="lc" value="US">';
     $html .= '<input type="hidden" name="notify_url" value="' . $notify . '">';
     $html .= '<input type="hidden" name="return" value="' . $complete . '">';
     $html .= '<!--input type="hidden" name="rm" value="2"-->';
     $html .= '<input type="hidden" name="item_name" value="' . $product . '">';
     $html .= '<input type="hidden" name="amount" value="' . $amount . '">';
     $html .= '<input type="hidden" name="currency_code" value="' . $currency . '">';
     $html .= '<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">';
     $html .= '<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynow_LG.gif" border="0" name="submit" alt="">';
     $html .= '<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">';
     $html .= '</form>';
     return $html;
 }
Esempio n. 3
0
 protected function _delete()
 {
     extract($this->_virtual[__FUNCTION__]);
     if ($this->isPost() && $this->hasParam("delete")) {
         $id = $this->_request->post("id", 0);
         try {
             $model = new $model($id);
             $job = new Wpjb_Model_Job($model->job_id);
             $model->delete();
             $job->stat_apply--;
             $job->save();
             $this->_addInfo($info);
         } catch (Exception $e) {
             $this->_addError($e->getMessage());
             // @todo: logging
         }
     }
 }
Esempio n. 4
0
 public function editAction()
 {
     $id = $this->_request->get("id");
     $job = new Wpjb_Model_Job($id);
     if ($job->employer_id != Wpjb_Model_Employer::current()->getId()) {
         $this->_addError(__("You do not have access to this page.", WPJB_DOMAIN));
         $this->view->revoke_access = true;
         return;
     }
     if (!Wpjb_Project::getInstance()->conf("front_allow_edition")) {
         $this->_addError(__("Administrator does not allow job postings edition.", WPJB_DOMAIN));
         $this->view->revoke_access = true;
         return;
     }
     if ($this->_request->post("remove_image") == 1) {
         $job->deleteImage();
         $job->save();
         $form = new Wpjb_Form_Admin_AddJob($id);
         $this->view->form = $form;
     } else {
         parent::editAction();
     }
 }
Esempio n. 5
0
 protected function _import($xml)
 {
     $id = null;
     if ($xml->id > 0) {
         $id = (int) $xml->id;
     }
     $job = new Wpjb_Model_Job($id);
     $job->company_name = (string) $xml->company_name;
     $job->company_email = (string) $xml->company_email;
     $job->company_website = (string) $xml->company_website;
     $job->job_title = (string) $xml->job_title;
     $job->job_description = (string) $xml->job_description;
     $job->job_slug = $this->_getUniqueSlug($job->job_title);
     if (strlen($xml->company_logo_ext) >= 3) {
         $job->company_logo_ext = (string) $xml->company_logo_ext;
         $logo = base64_decode((string) $xml->company_logo);
     }
     $job->job_category = $this->_getCategoryId($xml->category);
     $job->job_type = $this->_getJobTypeId($xml->job_type);
     $c = Wpjb_List_Country::getByAlpha2((string) $xml->job_country);
     $job->job_country = $c["code"];
     $job->job_state = (string) $xml->job_state;
     $job->job_zip_code = (string) $xml->job_zip_code;
     $job->job_location = (string) $xml->job_location;
     $job->job_created_at = (string) $xml->job_created_at;
     if (!(string) $xml->job_modified_at) {
         $job->job_modified_at = (string) $xml->job_modified_at;
     } else {
         $job->job_modified_at = (string) $xml->job_created_at;
     }
     $job->job_visible = (int) $xml->job_visible;
     $stt = "{$job->job_created_at} +{$job->job_visible} DAYS";
     $job->job_expires_at = date("Y-m-d H:i:s", strtotime($stt));
     $job->is_approved = (int) $xml->is_approved;
     $job->is_active = (int) $xml->is_approved;
     $job->is_featured = (int) $xml->is_featured;
     $job->is_filled = (int) $xml->is_filled;
     $job->payment_sum = (double) $xml->payment_sum;
     $job->payment_paid = (double) $xml->payment_paid;
     $job->payment_currency = (double) $xml->payment_currency;
     $job->payment_discount = (double) $xml->payment_discount;
     $job->save();
     if ($logo) {
         $baseDir = Wpjb_Project::getInstance()->getProjectBaseDir();
         $baseDir = "/environment/images/job_" . $job->getId() . "." . $job->company_logo_ext;
         file_put_contents($baseDir, $file);
     }
 }
Esempio n. 6
0
 public static function parse(Wpjb_Model_Email $mail, Wpjb_Model_Job $job, array $append)
 {
     $active = "active";
     if (!$job->is_active && !$job->is_approved) {
         $active = "inactive";
     }
     $time = strtotime($job->job_created_at);
     $newdate = strtotime('+' . $job->job_visible . ' day', $time);
     $expiration = date("Y-m-d H:i:s", $newdate);
     /* @var $job Wpjb_Model_Job */
     $exchangeArray = array("id" => $job->getId(), "created" => $job->job_created_at, "visible" => $job->job_visible, "price" => $job->paymentAmount(), "paid" => $job->paymentPaid(), "discount" => $job->paymentDiscount(), "company" => $job->company_name, "location" => $job->locationToString(), "email" => $job->company_email, "position_title" => $job->job_title, "listing_type" => $job->getType(true)->title, "category" => $job->getCategory(true)->title, "active" => $active, "url" => Wpjb_Project::getInstance()->getUrl() . "/" . Wpjb_Project::getInstance()->router()->linkTo("job", $job), "expiration" => $expiration);
     foreach ($append as $k => $v) {
         $exchangeArray[$k] = $v;
     }
     $body = $mail->mail_body;
     $mail_title = $mail->mail_title;
     foreach ($exchangeArray as $key => $value) {
         //$v = esc_html($value, false);
         $v = $value;
         $body = str_replace('{$' . $key . '}', $v, $body);
         $mail_title = str_replace('{$' . $key . '}', $v, $mail_title);
     }
     return array($mail_title, $body);
 }
Esempio n. 7
0
 protected function _setStatus($status)
 {
     $application = $this->getObject();
     $job = new Wpjb_Model_Job($application->job_id);
     $emp = $job->getEmployer(true);
     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;
     }
     $application->is_rejected = $status;
     $application->save();
     if ($status == 1) {
         $this->view->_flash->addInfo(__("Application was moved to archive.", WPJB_DOMAIN));
     } else {
         $this->view->_flash->addInfo(__("Application was accepted.", WPJB_DOMAIN));
     }
     wp_redirect(wpjb_link_to("job_application", $application));
     exit;
 }
Esempio n. 8
0
 public function _filter()
 {
     $query = new Daq_Db_Query();
     $this->view->jobList = Wpjb_Model_Job::activeSelect()->where("t1.is_featured = 1")->limit($this->_get("count", 5))->execute();
 }
Esempio n. 9
0
 protected function _multiApprove($id)
 {
     $object = new Wpjb_Model_Job($id);
     $object->is_approved = 1;
     $object->save();
     return true;
 }
Esempio n. 10
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;
 }
Esempio n. 11
0
 protected function _locate($asyncSave = false)
 {
     $country = Wpjb_List_Country::getByCode($this->job_country);
     $country = trim($country['name']);
     $addr = array($this->job_location, $this->job_zip_code, $this->job_state, $country);
     $query = http_build_query(array("address" => join(", ", $addr), "sensor" => "false"));
     $url = "http://maps.googleapis.com/maps/api/geocode/json?" . $query;
     $response = wp_remote_get($url);
     if ($response instanceof WP_Error) {
         $geo = null;
     } else {
         $geo = json_decode($response["body"]);
     }
     if (!$geo || $geo->status != "OK") {
         $this->geo_status = self::GEO_MISSING;
         $this->geo_latitude = 0;
         $this->geo_longitude = 0;
     } elseif ($geo->status == "OK") {
         $this->geo_status = self::GEO_FOUND;
         $this->geo_latitude = $geo->results[0]->geometry->location->lat;
         $this->geo_longitude = $geo->results[0]->geometry->location->lng;
     }
     if ($this->id > 0 && $asyncSave) {
         $job = new Wpjb_Model_Job($this->id);
         $job->geo_status = $this->geo_status;
         $job->geo_latitude = $this->geo_latitude;
         $job->geo_longitude = $this->geo_longitude;
         $job->_saveGeo();
     }
 }
Esempio n. 12
0
 private function _jobs()
 {
     return Wpjb_Model_Job::activeSelect();
 }
Esempio n. 13
0
 public function init()
 {
     $this->_perPage = Wpjb_Project::getInstance()->conf("front_jobs_per_page", 20);
     $this->_query = Wpjb_Model_Job::activeSelect();
 }
Esempio n. 14
0
 public function saveAction()
 {
     if (!$this->_canPost()) {
         wp_redirect($this->_stepAdd);
     }
     $this->view->current_step = 3;
     $form = new Wpjb_Form_AddJob();
     $request = $this->getRequest();
     $id = $request->session("wpjb.job_id");
     if ($id < 1) {
         if ($form->isValid($request->session("wpjb.job", array()))) {
             $paymentMethod = $form->getElement("payment_method")->getValue();
             $form->save();
             $job = $form->getObject();
             if (strlen($request->session("wpjb.job_logo_ext")) > 0) {
                 $ext = $request->session("wpjb.job_logo_ext");
                 $path1 = Wpjb_List_Path::getPath("tmp_images");
                 $path2 = Wpjb_List_Path::getPath("user_images");
                 $oldName = $path1 . "/temp_" . session_id() . "." . $ext;
                 $newName = $path2 . "/job_" . $job->getId() . "." . $ext;
                 $job->company_logo_ext = $ext;
                 $job->save();
                 rename($oldName, $newName);
             }
             if ($job->payment_sum > 0) {
                 $uid = null;
                 if (wp_get_current_user()->ID > 0) {
                     $uid = wp_get_current_user()->ID;
                 }
                 $payment = new Wpjb_Model_Payment();
                 $payment->user_id = $uid;
                 $payment->object_id = $job->getId();
                 $payment->object_type = Wpjb_Model_Payment::FOR_JOB;
                 $payment->engine = $paymentMethod;
                 $payment->payment_currency = $job->payment_currency;
                 $payment->payment_sum = $job->payment_sum;
                 $payment->payment_paid = 0;
                 $payment->save();
             }
             $request->setSessionParam("wpjb.job", null);
             $request->setSessionParam("wpjb.job_logo_ext", null);
             $request->setSessionParam("wpjb.job_id", $job->getId());
         } else {
             wp_redirect(Wpjb_Project::getInstance()->getUrl() . "/" . $this->_getRouter()->linkTo("step_add"));
         }
     } else {
         $job = new Wpjb_Model_Job($id);
     }
     if ($job->payment_sum > 0) {
         if ($job->payment_sum != $job->payment_paid) {
             $action = "payment_form";
         } else {
             $action = "payment_already_sent";
         }
     } else {
         $action = "job_online";
         if ($job->is_active && $job->is_approved) {
             $online = true;
         } else {
             $online = false;
         }
         $this->view->online = $online;
     }
     if ($action == "payment_form") {
         $payment = Wpjb_Payment_Factory::factory($job->getPayment(true));
         $this->view->payment = $payment->render();
     }
     $this->view->action = $action;
     $this->view->job = $job;
 }
Esempio n. 15
0
function wpjb_panel_features(Wpjb_Model_Job $job)
{
    if ($job->expired()) {
        echo " wpjb-expired";
    } elseif (time() - strtotime($job->job_expires_at) > 24 * 3600 * 3) {
        echo " wpjb-expiring";
    }
}
Esempio n. 16
0
 protected static function _insertIndeedJob($job)
 {
     $request = Daq_Request::getInstance();
     $category = new Wpjb_Model_Category($request->post("category_id"));
     $sTime = strtotime(date("Y-m-d H:i:s"));
     $eTime = strtotime("now +30 day");
     $visible = (int) (($eTime - $sTime) / (24 * 3600));
     if (count(explode(",", (string) $job->jobType)) > 0) {
         $type = explode(",", (string) $job->jobType);
         $jobTypeId = self::_getJobTypeId($type[0]);
     } else {
         $jobTypeId = self::_getJobTypeId((string) $job->jobType);
     }
     $import = new Wpjb_Model_Job();
     $import->company_name = (string) $job->company;
     $import->company_website = (string) $job->url;
     $import->company_email = "";
     $import->company_logo_ext = "";
     $import->job_category = $category->getId();
     $import->job_type = $jobTypeId;
     $import->job_source = 3;
     $country = Wpjb_List_Country::getByAlpha2((string) $job->country);
     $import->job_country = $country['code'];
     $import->job_state = (string) $job->state;
     $import->job_zip_code = "";
     $import->job_location = (string) $job->city;
     $import->job_limit_to_country = 0;
     $import->job_title = (string) $job->jobtitle;
     $import->job_slug = self::_getUniqueSlug((string) $job->jobtitle);
     $import->job_description = html_entity_decode((string) $job->snippet, ENT_NOQUOTES, "UTF-8");
     $import->job_visible = $visible;
     $import->job_created_at = date("Y-m-d H:i:s");
     $import->job_modified_at = date("Y-m-d H:i:s");
     $import->job_expires_at = date("Y-m-d H:i:s", strtotime("now +{$visible} days"));
     $import->is_approved = 1;
     $import->is_active = 1;
     $import->is_filled = 0;
     $import->payment_sum = 0;
     $import->payment_paid = 0;
     $import->payment_currency = 0;
     $import->payment_discount = 0;
     $import->save();
     /*
             $log = new Wpjb_Model_CareerBuilderLog();
             $log->did = $job->Job->DID;
             $log->save();
     *
     */
 }
Esempio n. 17
0
 public function _filter()
 {
     $query = new Daq_Db_Query();
     $this->view->jobList = Wpjb_Model_Job::activeSelect()->order("t1.job_created_at DESC")->limit($this->_get("count", 5))->execute();
 }
Esempio n. 18
0
 public static function scheduleEvent()
 {
     $query = Wpjb_Model_Job::activeSelect();
     $query->select("t1.job_category AS category_id, COUNT(*) AS cnt");
     $query->group("t1.job_category");
     $cAll = array();
     foreach ($query->fetchAll() as $row) {
         $cAll[$row->category_id] = $row->cnt;
     }
     $query = Wpjb_Model_Job::activeSelect();
     $query->select("t1.job_type AS type_id, COUNT(*) AS cnt");
     $query->group("t1.job_type");
     $tAll = array();
     foreach ($query->fetchAll() as $row) {
         $tAll[$row->type_id] = $row->cnt;
     }
     $conf = self::getInstance();
     $conf->setConfigParam("count", array("category" => $cAll, "type" => $tAll));
     $conf->saveConfig();
 }