/** * 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(); } }
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; }
/** * Saves candidate in DB * * This function is executed in "init" action. * * Validates and saves resume in database. This action is executed only if * there is $_POST["_wpjb_action"] == reg_candidate_alt. * * @since 1.0 * @return void */ function full_candidate_register_action() { $form = new Wpjb_Form_Resume_Alt(); $request = Daq_Request::getInstance(); $flash = new Wpjb_Utility_Session(); if ($request->post("_wpjb_action") != "reg_candidate_alt") { return; } $isValid = $form->isValid($request->getAll()); if (!$isValid) { return; } $form->save(); $url = wpjr_link_to("login"); $password = $form->value("user_password"); $email = $form->value("user_email"); $username = $form->value("user_login"); if (empty($username)) { $username = $email; } $mail = Wpjb_Utility_Message::load("notify_canditate_register"); $mail->setTo($email); $mail->assign("username", $username); $mail->assign("password", $password); $mail->assign("login_url", $url); $mail->send(); do_action("wpjb_user_registered", "candidate"); $form = new Wpjb_Form_Resumes_Login(); if ($form->hasElement("recaptcha_response_field")) { $form->removeElement("recaptcha_response_field"); } $form->isValid(array("user_login" => $username, "user_password" => $password, "remember" => 0)); $flash->addInfo(__("You have been registered.", "wpjobboard")); $flash->save(); wp_redirect(wpjr_link_to("myresume_home")); exit; }