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 install() { global $wpdb, $wp_rewrite; if (stripos(PHP_OS, "win") !== false || true) { $mods = explode(",", $wpdb->get_var("SELECT @@session.sql_mode")); $mods = array_map("trim", $mods); $invalid = array("STRICT_TRANS_TABLES", "STRICT_ALL_TABLES", "TRADITIONAL"); foreach ($invalid as $m) { if (in_array($m, $mods)) { $wpdb->query("SET @@session.sql_mode='' "); break; } } } $db = Daq_Db::getInstance(); if ($db->getDb() === null) { $db->setDb($wpdb); } wp_clear_scheduled_hook("wpjb_event_counter"); wp_schedule_event(time(), "daily", "wpjb_event_counter"); $instance = self::getInstance(); $appj = $instance->getApplication("frontend"); $appr = $instance->getApplication("resumes"); $config = $instance; $wp_rewrite->flush_rules(); if ($appj->getPage() === null) { // link new page /* @var $appj Wpjb_Application_Frontend */ $jId = wp_insert_post(array('post_type' => 'page', 'post_status' => 'publish', 'post_title' => 'Jobs', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_content' => $appj->getOption("shortcode"))); $config->setConfigParam("link_jobs", $jId); $config->saveConfig(); } if ($appr->getPage() === null) { // link new page $rId = wp_insert_post(array('post_type' => 'page', 'post_status' => 'publish', 'post_title' => 'Resumes', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_content' => $appr->getOption("shortcode"))); $config->setConfigParam("link_resumes", $rId); $config->saveConfig(); } update_usermeta(wp_get_current_user()->ID, "is_employer", 1); if ($this->conf("front_template") !== null) { return true; } $config->setConfigParam("front_show_related_jobs", 1); $config->setConfigParam("cv_enabled", 1); $config->saveConfig(); $file = $this->path("install") . "/install.sql"; $queries = explode("; --", file_get_contents($file)); foreach ($queries as $query) { $wpdb->query($query); } $email = get_option("admin_email"); $query = new Daq_Db_Query(); $result = $query->select("*")->from("Wpjb_Model_Email t")->execute(); foreach ($result as $r) { if ($r->mail_from == "") { $r->mail_from = $email; $r->save(); } } $config = Wpjb_Project::getInstance(); $config->setConfigParam("front_template", "twentyten"); $config->saveConfig(); Wpjb_Upgrade_Manager::upgrade(); $wp_rewrite->flush_rules(); return true; }