Пример #1
0
 protected static function _modify(Wpjb_Model_Resume $resume)
 {
     $cb = self::_canBrowse();
     $arr = $resume->allToArray();
     $public = array("id", "user_id", "category_id", "title", "firstname", "lastname", "headline", "experience", "education", "country", "address", "email", "phone", "website", "is_active", "degree", "years_experience", "created_at");
     $publish = new stdClass();
     foreach ($public as $k) {
         $publish->{$k} = $resume->{$k};
     }
     foreach ($arr as $k => $a) {
         if (substr($k, 0, 6) == "field_") {
             $publish->{$k} = $a;
         }
     }
     if (!$cb) {
         $private = array("address", "email", "phone", "website");
         foreach ($private as $p) {
             $publish->{$p} = null;
         }
     }
     $t = strtotime($resume->updated_at);
     if ($t <= strtotime("1970-01-01 00:00:00")) {
         $t = __("never", WPJB_DOMAIN);
     } else {
         $t = date("M, d", $t);
     }
     $publish->url = wpjr_link_to("resume", $resume);
     $publish->image = $resume->getImageUrl();
     $publish->can_browse = $cb;
     $publish->formatted_last_update = $t;
     return $publish;
 }
Пример #2
0
 public function editAction()
 {
     if ($this->_request->post("remove_image") == 1) {
         $id = $this->_request->post("id");
         $resume = new Wpjb_Model_Resume($id);
         $resume->deleteImage();
         $resume->save();
         $form = new Wpjb_Form_Admin_Resume($id);
         $form->init();
         $this->view->form = $form;
     } elseif ($this->_request->post("remove_file") == 1) {
         $id = $this->_request->post("id");
         $resume = new Wpjb_Model_Resume($id);
         $resume->deleteFile();
         $form = new Wpjb_Form_Admin_Resume($id);
         $form->init();
         $this->view->form = $form;
     } else {
         parent::editAction();
     }
 }
 /**
  * Saves resume data
  * 
  * @param array $append Additional data to save
  * @return int Resume ID
  */
 public function save($append = array())
 {
     $user_email = $this->getElement("user_email")->getValue();
     if (!$this->hasElement("user_login")) {
         $user_login = $user_email;
     } else {
         $user_login = $this->getElement("user_login")->getValue();
     }
     $id = wp_insert_user(array("user_login" => $user_login, "user_email" => $user_email, "user_pass" => $this->getElement("user_password")->getValue(), "first_name" => $this->getFieldValue("first_name"), "last_name" => $this->getFieldValue("ldap_start_tlsname"), "role" => "subscriber"));
     $fullname = $this->value("first_name") . " " . $this->value("last_name");
     if (wpjb_conf("cv_approval") == 1) {
         $active = 0;
         // manual approval
     } else {
         $active = 1;
     }
     $resume = new Wpjb_Model_Resume();
     $resume->candidate_slug = Wpjb_Utility_Slug::generate(Wpjb_Utility_Slug::MODEL_RESUME, $fullname);
     $resume->phone = "";
     $resume->user_id = $id;
     $resume->headline = "";
     $resume->description = "";
     $resume->created_at = date("Y-m-d");
     $resume->modified_at = date("Y-m-d");
     $resume->candidate_country = wpjb_locale();
     $resume->candidate_zip_code = "";
     $resume->candidate_state = "";
     $resume->candidate_location = "";
     $resume->is_public = wpjb_conf("cv_is_public", 1);
     $resume->is_active = $active;
     $resume->save();
     $resume->cpt();
     $this->setObject($resume);
     apply_filters("wpjr_form_save_register", $this);
     parent::save($append);
     $resume->created_at = current_time("mysql");
     $resume->candidate_slug = Wpjb_Utility_Slug::generate(Wpjb_Utility_Slug::MODEL_RESUME, $fullname);
     $resume->save();
     return $resume->id;
 }
Пример #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->save();
     self::$_current = $object;
     return $object;
 }
Пример #5
0
 protected function _saveFiles()
 {
     $file = array();
     $application = $this->getObject();
     if ($this->hasElement("resume_id")) {
         $resume_id = $this->getElement("resume_id")->getValue();
     }
     $name = $this->getElement("applicant_name")->getValue();
     $destination = Wpjb_List_Path::getPath("apply_file") . "/" . $application->id;
     if (!is_dir($destination)) {
         mkdir($destination);
     }
     foreach ($this->_getFiles() as $f) {
         if ($f->fileSent()) {
             /* @var $f Daq_Form_Element_File */
             $f->setDestination($destination);
             $this->_files[] = $f->upload();
         }
     }
     if (isset($resume_id) && is_numeric($resume_id)) {
         $filename = sanitize_file_name($name . ".html");
         $resume = new Wpjb_Model_Resume($resume_id);
         $rendered = $resume->renderHTML();
         file_put_contents($destination . "/" . $filename, $rendered);
         $this->_files[] = $destination . "/" . $filename;
     }
 }
/**
 * Payment form which allows to make payment for candidate membership
 *
 * Always use this shortcode with pricing_id param for example
 * [custom_payment_type_form pricing_id="100"]
 * where 100 is actual ID of pricing created in wp-admin / Settings (WPJB) / Pricing
 * panel.
 *
 * @param array $atts List of shortcode params
 * @return string Rendered payment form
 */
function custom_payment_type_form($atts)
{
    $params = shortcode_atts(array("pricing_id" => null), $atts);
    $flash = new Wpjb_Utility_Session();
    $pricing = new Wpjb_Model_Pricing($params["pricing_id"]);
    if (!$pricing->exists()) {
        return;
    }
    if ($pricing->price_for != 210) {
        return;
    }
    $list = new Wpjb_List_Pricing();
    $listing = $list->getBy("id", $pricing->price_for);
    $view = Wpjb_Project::getInstance()->getApplication("frontend")->getView();
    $view->atts = $atts;
    $view->pricing = $pricing;
    $view->gateways = Wpjb_Project::getInstance()->payment->getEnabled();
    $view->pricing_item = $listing["title"] . " &quot;" . $pricing->title . "&quot;";
    $view->defaults = new Daq_Helper_Html("span", array("id" => "wpjb-checkout-defaults", "class" => "wpjb-none", "data-pricing_id" => $pricing->id, "data-object_id" => Wpjb_Model_Resume::current()->id, "data-fullname" => wp_get_current_user()->display_name, "data-email" => wp_get_current_user()->user_email), " ");
    Wpjb_Project::getInstance()->placeHolder = $view;
    wp_enqueue_style("wpjb-css");
    wp_enqueue_script('wpjb-js');
    ob_start();
    $view->render("../default/payment.php");
    $render = ob_get_clean();
    return $render;
}
Пример #7
0
 public function registerAction()
 {
     if (!get_option('users_can_register')) {
         $this->view->_flash->addError(__("User registration is disabled.", WPJB_DOMAIN));
         return false;
     }
     $object = Wpjb_Model_Resume::current();
     if ($object->id > 0) {
         wp_redirect(wpjr_link_to("myresume"));
     }
     $this->_setTitle(__("Register", WPJB_DOMAIN));
     $form = new Wpjb_Form_Resumes_Register();
     $this->view->errors = array();
     if ($this->isPost()) {
         $isValid = $form->isValid($this->getRequest()->getAll());
         if ($isValid) {
             $username = $form->getElement("user_login")->getValue();
             $password = $form->getElement("user_password")->getValue();
             $email = $form->getElement("user_email")->getValue();
             $id = wp_create_user($username, $password, $email);
             $instance = Wpjb_Project::getInstance();
             $router = $instance->getApplication("resumes")->getRouter();
             /* @var $router Daq_Router */
             $url = $instance->getApplication("resumes")->getUrl();
             $url .= "/" . $router->linkTo("myresume");
             $mail = new Wpjb_Utility_Message(10);
             $mail->setTo($email);
             $mail->setParam("username", $username);
             $mail->setParam("password", $password);
             $mail->setParam("login_url", $url);
             $mail->send();
             $this->view->_flash->addInfo(__("You have been registered.", WPJB_DOMAIN));
             $form = new Wpjb_Form_Resumes_Login();
             $form->isValid(array("user_login" => $username, "user_password" => $password, "remember" => 0));
             $redirect = wpjr_link_to("myresume");
             wp_redirect($redirect);
             die;
         } else {
             $this->view->_flash->addError(__("There are errors in your form.", WPJB_DOMAIN));
         }
     }
     $this->view->form = $form;
     return "register";
 }
Пример #8
0
 public function applyAction()
 {
     $text = Wpjb_Project::getInstance()->conf("seo_apply", __("Apply for position: {job_title} (ID: {id})", WPJB_DOMAIN));
     $param = array('job_title' => $this->getObject()->job_title, 'id' => $this->getObject()->id);
     $this->_setTitle($text, $param);
     $job = $this->getObject();
     $this->view->job = $job;
     if (!$this->isMember() && Wpjb_Project::getInstance()->conf("front_apply_members_only", false)) {
         $this->view->members_only = true;
         $this->view->_flash->addError(__("Only registered members can apply for jobs.", WPJB_DOMAIN));
         return;
     }
     if ($job->job_source == 3) {
         wp_redirect($job->company_website);
     }
     $form = new Wpjb_Form_Apply();
     if ($this->isPost()) {
         if ($form->isValid($this->getRequest()->getAll())) {
             // send
             $var = $form->getValues();
             $job = $this->getObject();
             $form->setJobId($job->getId());
             $form->setUserId(Wpjb_Model_Resume::current()->user_id);
             $form->save();
             $files = $form->getFiles();
             $application = $form->getObject();
             $mail = new Wpjb_Model_Email(6);
             $append = array("applicant_email" => $var['email'], "applicant_cv" => $var['resume'], "applicant_name" => $var['applicant_name']);
             list($title, $body) = Wpjb_Utility_Messanger::parse($mail, $job, $append);
             $add = $form->getAdditionalText();
             if (!empty($add)) {
                 $body .= "\r\n--- --- ---\r\n";
             }
             foreach ($add as $field) {
                 if (!$form->hasElement($field)) {
                     continue;
                 }
                 $opt = $form->getElement($field)->getOptions();
                 if (!empty($opt)) {
                     foreach ($opt as $o) {
                         if ($o["value"] == $form->getElement($field)->getValue()) {
                             $fValue = $o["desc"];
                         }
                     }
                 } else {
                     $fValue = $form->getElement($field)->getValue();
                 }
                 $body .= $form->getElement($field)->getLabel() . ": ";
                 $body .= $fValue . "\r\n";
             }
             $headers = "From: " . $var["applicant_name"] . " <" . $var["email"] . ">\r\n";
             $email = $var["email"];
             $title = trim($title);
             if (empty($title)) {
                 $title = __("[Application] ", WPJB_DOMAIN) . $var["name"];
             }
             if (apply_filters("wpjb_job_apply", $form) !== true) {
                 wp_mail($job->company_email, $title, $body, $headers, $files);
             }
             $form->reinit();
             $job->stat_apply++;
             $job->save();
             $this->view->application_sent = true;
             $this->view->_flash->addInfo(__("Your application has been sent.", WPJB_DOMAIN));
             Wpjb_Utility_Messanger::send(8, $job, array('applicant_email' => $var['email']));
         } else {
             $this->view->_flash->addError(__("There are errors in your form.", WPJB_DOMAIN));
         }
     } elseif (Wpjb_Model_Resume::current()->id > 0) {
         $resume = Wpjb_Model_Resume::current();
         if ($form->hasElement("email")) {
             $form->getElement("email")->setValue($resume->email);
         }
         if ($form->hasElement("applicant_name")) {
             $form->getElement("applicant_name")->setValue($resume->firstname . " " . $resume->lastname);
         }
     }
     $this->view->form = $form;
 }