/** * 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; }
public function myresumeAction() { $this->_setTitle(Wpjb_Project::getInstance()->conf("seo_resume_my_resume", __("My resume details", WPJB_DOMAIN))); if (!$this->_isEnabled()) { return false; } $object = Wpjb_Model_Resume::current(); if ($object->id < 1) { $this->view->_flash->addError(__("You need to be logged in to access this page.", WPJB_DOMAIN)); return false; } if (Wpjb_Model_Employer::current()->isEmployer()) { $this->view->_flash->addError(__("You need to be registered as Candidate in order to access this page. Your current account type is Employer.", WPJB_DOMAIN)); return false; } if ($this->_request->post("remove_image") == 1) { $this->view->_flash->addInfo(__("Image removed.", WPJB_DOMAIN)); $object->deleteImage(); $object->save(); } $form = new Wpjb_Form_Resume($object->getId()); if ($this->isPost() && !$this->_request->post("remove_image")) { $isValid = $form->isValid($this->_request->getAll()); if ($isValid) { $this->view->_flash->addInfo(__("Your resume has been saved.", WPJB_DOMAIN)); $form->save(); } else { $this->view->_flash->addError(__("Cannot save your resume. There are errors in your form.", WPJB_DOMAIN)); } } $this->view->resume = $form->getObject(); $this->view->form = $form; return "my-resume"; }