public function dispatch($path) { $path = rtrim($path, "/") . "/"; $route = $this->getRouter()->match($path); foreach ($route['param'] as $k => $v) { Daq_Request::getInstance()->addParam("GET", $k, $v); } $index = $route['module'] . "/" . $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 (Wpjb_Utility_Seal::check()) { Wpjb_Upgrade_Manager::upgrade(); } $info = wp_get_current_user(); $isAdmin = true; if (!isset($info->wp_capabilities) || !$info->wp_capabilities['administrator']) { $isAdmin = false; } $this->_view->slot("is_admin", $isAdmin); if (!method_exists($controller, $action)) { throw new Exception("Method [{$action}] does not exist for controller [{$ctrl}]"); } $controller->setView($this->_view); $controller->init(); $controller->{$action}(); $controller->view->render($index . ".php"); }
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; }
function user_panel_api_content($content) { $request = Daq_Request::getInstance(); // URL does not have ?panel=my_link param, this means some other panel is being executed // return default content then. if ($request->get("panel") != "my_link") { return $content; } // Make sure to authenticate user! // Load default WPJB styles wp_enqueue_style("wpjb-css"); // Create breadcrumbs, basically two links: // - User Panel home // - Current page $breadcrumbs = array(array("title" => __("Home", "wpjobboard"), "url" => get_permalink(), "glyph" => "wpjb-icon-home"), array("title" => "My Link", "url" => get_permalink() . "?panel=my_link", "glyph" => is_rtl() ? "wpjb-icon-left-open" : "wpjb-icon-right-open")); // initiate view object and add new templates directory so we can load // a custom template file. $view = Wpjb_Project::getInstance()->getApplication("frontend")->getView(); $view->addDir(dirname(__FILE__), true); $view->breadcrumbs = $breadcrumbs; // initatte session to allow flash messages $flash = new Wpjb_Utility_Session(); $flash->addInfo("Custom My Link Panel Loaded!"); $flash->save(); // render template ob_start(); $view->render("custom-template.php"); $render = ob_get_clean(); return $render; }
public function linkTo($page = null, $action = null) { if ($page === null) { $page = Daq_Request::getInstance()->get("page"); } if ($action !== null) { $action = "&action=" . $action; } return "admin.php?page=" . $page . $action; }
public function detailsAction() { $request = Daq_Request::getInstance(); $job = new Wpjb_Model_Job($request->post("id")); if (!$job->is_active || !$job->is_approved || time() > strtotime($job->job_expires_at)) { exit(0); } $publish = self::_modify($job); self::_push($publish); }
public function slugifyAction() { $list = array("job" => 1, "type" => 1, "category" => 1); $id = Daq_Request::getInstance()->post("id"); $title = Daq_Request::getInstance()->post("title"); $model = Daq_Request::getInstance()->post("object"); if (!isset($list[$model])) { die; } die(Wpjb_Utility_Slug::generate($model, $title, $id)); }
protected function _addAlert() { $request = Daq_Request::getInstance(); $form = new Wpjb_Form_Alert(); if ($form->isValid($request->getAll())) { $alert = new Wpjb_Model_Alert(); $alert->created_at = date("Y-m-d H:i:s"); $alert->keyword = $request->post("keyword"); $alert->email = $request->post("email"); $alert->is_active = 1; $alert->save(); } return $form; }
public function xmlAction() { $element = new Daq_Form_Element_File("file", Daq_Form_Element::TYPE_FILE); $element->isRequired(true); $request = Daq_Request::getInstance(); if ($this->isPost() && $element->validate()) { $file = $_FILES["file"]["tmp_name"]; $content = file_get_contents($file); $xml = simplexml_load_string($content); $i = 0; foreach ($xml->job as $job) { $this->_import($job); $i++; } $m = str_replace("{x}", $i, __("Jobs imported: {x}.")); $this->view->_flash->addInfo($m); } }
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; }
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(); * */ }
return; } if (version_compare(PHP_VERSION, "5.1.6", "<")) { die("<b>Cannot activate:</b> WPJobBoard requires at least PHP 5.1.6, your PHP version is " . PHP_VERSION); } define("WPJB_DOMAIN", "wp-job-board-locale"); $basepath = dirname(__FILE__); if (is_file($basepath . "/overload.php")) { include_once $basepath . "/overload.php"; } if (!class_exists("Daq_Loader")) { require_once $basepath . "/framework/Loader.php"; } Daq_Loader::registerFramework($basepath . "/framework"); Daq_Loader::registerAutoloader(); $request = Daq_Request::getInstance(); $db = Daq_Db::getInstance(); $db->setDb($wpdb); $wpjbIni = Daq_Config::parseIni($basepath . "/application/config/project.ini"); $wpjbPaths = Daq_Config::parseIni($basepath . "/application/config/paths.ini"); Daq_Loader::registerLibrary($wpjbIni["prefix_class"], $basepath . "/application/libraries"); $wpjb = Wpjb_Project::getInstance(); $wpjb->loadPaths($wpjbPaths); $wpjb->setUrl(rtrim(get_bloginfo("url"), "/")); $wpjb->setBaseDir($basepath); foreach ($wpjbIni as $wpjbk => $wpjbv) { $wpjb->setEnv($wpjbk, $wpjbv); } Daq_Helper::registerAll(); $routes = Daq_Config::parseIni($wpjb->path("app_config") . "/frontend-routes.ini", $wpjb->path("user_config") . "/frontend-routes.ini", true); $wpjbbase = $wpjb->path("templates") . "/";
/** * Generates content for [wpjb_candidate_register] shortcode. * * This function replaces default [wpjb_candidate_register] shortcode with form * which renders full My Resume form. * * @param array $atts Shortcode params * @return string Shortcode HTML */ function full_candidate_register_ext($atts = array()) { $params = shortcode_atts(array("job_id" => null), $atts); $request = Daq_Request::getInstance(); $view = Wpjb_Project::getInstance()->getApplication("resumes")->getView(); if (get_current_user_id() > 0) { $view->_flash->addError(__("You are already registered.", "wpjobboard")); ob_start(); wpjb_flash(); return ob_get_clean(); } wp_enqueue_script("jquery"); wp_enqueue_script("wpjb-js"); wp_enqueue_script("wpjb-myresume"); wp_enqueue_script("wpjb-plupload"); wp_enqueue_style("wpjb-css"); $form = new Wpjb_Form_Resume_Alt(); if (isset($_POST) && !empty($_POST)) { if ($form->isValid($request->getAll())) { // do nothing } else { $view->_flash->addError(__("There are errors in your form.", "wpjobboard")); } } $form->buildPartials(); $view->form = $form; $view->submit = __("Send Application", "wpjobboard"); $view->breadcrumbs = array(); $view->resume = new Wpjb_Model_Resume(); $view->shortcode = true; if (Wpjb_Project::getInstance()->placeHolder === null) { Wpjb_Project::getInstance()->placeHolder = new stdClass(); } Wpjb_Project::getInstance()->placeHolder->_flash = $view->_flash; add_filter("wpjb_breadcrumbs", "__return_empty_string"); ob_start(); ?> <style type="text/css"> .wpjb.wpjr-page-my-resume #wpjb-resume.wpjb-form > fieldset:nth-of-type(1) { display: none; } </style> <?php $view->render("my-resume.php"); return str_replace('"Update"', '"Register"', ob_get_clean()); }
public function __construct() { $this->_request = Daq_Request::getInstance(); }
/** * FORM HELPERS */ function wpjb_form_helper_logo_upload(Daq_Form_Element $field, array $options = array()) { echo $options["tag"]; $ext = Daq_Request::getInstance()->session("wpjb.job_logo_ext"); if ($ext) { /// some special treatment $path = get_bloginfo("url") . "/wp-content/plugins/wpjobboard"; $path .= Wpjb_List_Path::getRawPath("tmp_images") . "/temp_" . session_id() . "." . $ext; echo '<p class="wpjb-add-job-img"><img src="' . $path . '" alt="" /></p>'; } }
public function detailsAction() { $cb = self::_canBrowse(); $id = Daq_Request::getInstance()->post("id"); $resume = new Wpjb_Model_Resume($id); $publish = self::_modify($resume); self::_push($publish); }
public function searchAction() { $request = $this->getRequest(); $text = Wpjb_Project::getInstance()->conf("seo_search_results", __("Search Results: {keyword}", WPJB_DOMAIN)); $param = array('keyword' => $request->get("query")); $this->_setTitle($text, $param); $request = Daq_Request::getInstance(); $param = array("query" => $request->get("query"), "category" => $request->get("category"), "type" => $request->get("type"), "page" => $request->get("page", 1), "count" => $request->get("count", 20), "country" => $request->get("country"), "posted" => $request->get("posted"), "location" => $request->get("location"), "is_featured" => $request->get("is_featured"), "employer_id" => $request->get("employer_id"), "field" => $request->get("field", array()), "sort" => $request->get("sort"), "order" => $request->get("order")); $result = Wpjb_Model_JobSearch::search($param); $this->view->jobPage = $result->page; $this->view->jobCount = ceil($result->total / $result->perPage); $this->view->jobList = $result->job; $router = Wpjb_Project::getInstance()->router(); $this->view->cDir = $router->linkTo("search", null, $param); $this->view->qString = $this->getServer("QUERY_STRING"); return "index"; }
/** * Set object id and type when creatng a payment * * @param array $data Array("id"=>..., "type"=>...); * @param Wpjb_Model_Pricing $pricing Pricing object * @return array */ function custom_payment_type_object($data, $pricing) { if ($pricing->price_for != 210) { return $data; } return array("id" => Daq_Request::getInstance()->post("object_id"), "type" => 9); }
/** * AJAX File Upload * * This function copies file from Dropbox and tries to upload it using default * WPJB uploader. * * @see Wpjb_Module_AjaxNopriv_Main::uploadAction() * * @since 1.0 * @return void */ function upload_from_dropbox_ajax() { global $blog_id; if ($blog_id > 1) { $bid = "-" . $blog_id; } else { $bid = ""; } $dir = wp_upload_dir(); $d = array(); $d["baseurl"] = $dir["baseurl"] . "/wpjobboard{$bid}-upload-from-dropbox"; $d["basedir"] = $dir["basedir"] . "/wpjobboard{$bid}-upload-from-dropbox"; if (!wp_mkdir_p($d["basedir"])) { $response->msg = sprintf(__("Upload directory %s could not be created.", "wpjobboard"), $dir); die(json_encode($response)); } $file = Daq_Request::getInstance()->post("data"); $response = wp_remote_get($file["link"]); $new_file = $d["basedir"] . "/" . $file["name"]; if (is_wp_error($response)) { $response->msg = $response->get_error_message(); die(json_encode($response)); } file_put_contents($new_file, $response["body"]); $stat = @stat(dirname($new_file)); $perms = $stat['mode'] & 07777; $perms = $perms & 0666; @chmod($new_file, $perms); clearstatcache(); if (!isset($_FILES) || !is_array($_FILES)) { $_FILES = array(); } $type = wp_check_filetype($new_file, wp_get_mime_types()); $_FILES["file"] = array("name" => $file["name"], "type" => $type["type"], "tmp_name" => $new_file, "error" => UPLOAD_ERR_OK, "size" => $file["bytes"]); add_filter("daq_move_uploaded_file", "upload_from_dropbox_move", 10, 3); Wpjb_Module_AjaxNopriv_Main::uploadAction(); exit; }
public function indexAction() { $request = Daq_Request::getInstance(); $chart = $request->post("type", 1); $sDate = $request->post("start"); $eDate = $request->post("end"); $response = new stdClass(); $response->isError = false; $d = new Daq_Validate_Date(); if (!$d->isValid($sDate)) { $response->isError = true; $response->error = "Invalid date format for start date."; die(json_encode($response)); } if (!$d->isValid($eDate)) { $response->isError = true; $response->error = "Invalid date format for end date."; die(json_encode($response)); } if (strtotime($eDate) < strtotime($sDate)) { $response->isError = true; $response->error = "End date cannot be greater then start date."; die(json_encode($response)); } if (!in_array($chart, array(1, 2))) { $response->isError = true; $response->error = "Invalid chart type."; die(json_encode($response)); } $query = new Daq_Db_Query(); $result = $query->select("SUM(payment_sum) AS sum, t.payment_currency AS curr, DATE(t.job_created_at) AS created_at")->from("Wpjb_Model_Job t")->where("job_created_at >= ?", $sDate)->where("job_created_at <= ?", $eDate . " 23:59:59")->group("DATE(job_created_at), payment_currency")->fetchAll(); $min = null; $max = null; $curr = array(); $dt = array(); $response->chart = new stdClass(); $response->chart->meta = array("Date"); $response->chart->data = array(); foreach ($result as $r) { $time = strtotime($r->created_at); if ($min === null || $time < $min) { $min = $time; } if ($time > $max) { $max = $time; } if (!in_array($r->curr, $curr)) { $response->chart->meta[] = $r->curr; $curr[$r->curr] = 0; } } $keyList = array_keys($curr); for ($i = $min; $i <= $max; $i = strtotime(date("Y-m-d", $i) . " +1 DAY")) { $dDay = new stdClass(); $dDay->date = date("Y-m-d", $i); $dDay->data = $curr; foreach ($result as $r) { if ($r->created_at == $dDay->date) { $dDay->data[(int) $r->curr] = $r->sum; } } $response->chart->data[] = $dDay; } echo json_encode($response); die; }