protected static function _modify(Wpjb_Model_Job $job) { $arr = $job->allToArray(); foreach (Wpjb_Utility_Registry::getCategories() as $category) { if ($category->id == $job->job_category) { break; } } foreach (Wpjb_Utility_Registry::getJobTypes() as $type) { if ($type->id == $job->job_type) { break; } } $public = array("id", "company_name", "company_website", "job_type", "job_category", "job_country", "job_state", "job_zip_code", "job_location", "job_limit_to_country", "job_title", "job_slug", "job_created_at", "job_expires_at", "job_description", "is_active", "is_filled", "is_featured", "stat_view", "stat_unique", "stat_apply"); $publish = new stdClass(); foreach ($public as $k) { $publish->{$k} = $job->{$k}; } $arr = $job->allToArray(); foreach ($arr as $k => $a) { if (substr($k, 0, 6) == "field_") { $publish->{$k} = $a; } } $publish->url = wpjb_link_to("job", $job); $publish->image = $job->getImageUrl(); $publish->formatted_created_at = wpjb_date("M, d", $job->job_created_at); $publish->location = $job->locationToString(); $publish->category = $category->toArray(); $publish->type = $type->toArray(); $publish->is_new = $job->isNew(); $publish->is_free = $job->isFree(); return $publish; }
public function addAction() { $this->view->current_step = 1; $canPost = $this->_canPost(); if (!$canPost) { return false; } if (!is_user_logged_in() && Wpjb_Project::getInstance()->conf("posting_encourage_reg")) { $eUrl = wpjb_link_to("employer_new"); $m = __("<b>Quick Tip</b>: If you login before posting a job, you will be able to manage all your jobs from <a href=\"{url}\">employer account</a>.", WPJB_DOMAIN); $m = str_replace("{url}", $eUrl, $m); $this->view->_flash->addInfo($m); } $query = new Daq_Db_Query(); $l = $query->select("*")->from("Wpjb_Model_Listing t")->execute(); $listing = array(); foreach ($l as $li) { $listing[$li->getId()] = $li; } $this->view->listing = $listing; $form = new Wpjb_Form_AddJob(); $request = $this->getRequest(); $request->setSessionParam("wpjb.job_id", null); $job = new Wpjb_Model_Job($this->getRequest()->get("republish", null)); $empId = Wpjb_Model_Employer::current()->getId(); $arr = array(); if ($request->session("wpjb.reset_job", false)) { $ext = $request->session("wpjb.job_logo_ext"); $request->setSessionParam("wpjb.job", null); $request->setSessionParam("wpjb.reset_job", null); $request->setSessionParam("wpjb.job_logo_ext", null); $file = Wpjb_List_Path::getPath("tmp_images") . "/temp_" . session_id() . "." . $ext; if (is_file($file)) { unlink($file); } } elseif ($empId > 0 && $job->employer_id == $empId || current_user_can("manage_options")) { $arr = $job->allToArray(); if ($job->hasImage()) { $ext = $job->company_logo_ext; $path = Wpjb_List_Path::getPath("tmp_images"); copy($job->getImagePath(), $path . "/temp_" . session_id() . "." . $ext); $request->setSessionParam("wpjb.job_logo_ext", $ext); } } elseif ($empId > 0 && wp_get_current_user()->ID > 0 && $request->session("wpjb.job") == null) { $emp = Wpjb_Model_Employer::current(); $arr = $emp->toArray(); $arr['company_email'] = wp_get_current_user()->user_email; $arr['job_location'] = $emp->company_location; $arr['job_country'] = $emp->company_country; $arr['job_state'] = $emp->company_state; $arr['job_zip_code'] = $emp->company_zip_code; $m = __("<b>Note</b>: Data from your company profile is being used to fill 'Company Information' fields.", WPJB_DOMAIN); $this->view->_flash->addInfo($m); if ($emp->hasImage()) { $ext = $emp->company_logo_ext; $path = Wpjb_List_Path::getPath("tmp_images"); copy($emp->getImagePath(), $path . "/temp_" . session_id() . "." . $ext); $request->setSessionParam("wpjb.job_logo_ext", $ext); } } $jobArr = $request->session("wpjb.job", null); if (is_array($jobArr)) { if (!$form->isValid($jobArr)) { $this->view->_flash->addError(__("There are errors in your form. Please correct them before proceeding", WPJB_DOMAIN)); } } else { $form->setDefaults($arr); } $this->view->form = $form; }