$ending) { /*translation:Beginning date should be smaller than ending date.*/ register_error(elgg_echo('koolielu:error_beginning_larger_than_end')); $errors = true; } } if ($errors) { forward("mod/poster/add_job_offering.php"); // Otherwise, save job offering } else { // Initialise a new ElggObject $poster = new ElggObject(); // Tell the system it's a job offering $poster->subtype = $jobtype; // Set its owner to the current user $poster->owner_guid = $_SESSION['user']->getGUID(); // If moderator or above set its access to public and status to approved if (isModerator()) { $poster->access_id = 2; $poster->approved = 1; } else { $poster->access_id = 1; $poster->approved = 0; } $poster->title = $title; $poster->brief_description = $brief_desc; $poster->description = $body; $poster->place = $place; // Make date to timestamp conversions if (!empty($beginning_date)) $beginning_date = dateIntoTimestamp($beginning_date); $poster->beginning_date = $beginning_date; if (!empty($ending_date)) $ending_date = dateIntoTimestamp($ending_date); $poster->ending_date = $ending_date; $poster->contact_person = $contact_person; $poster->telephone = $telephone; $poster->email = $email; $poster->subjects = $subjects; // Before we can set metadata, we need to save the job advertisement if (!$poster->save()) { /*translation:Wasn't able to create job advertisement. Please try again.*/ register_error(elgg_echo('koolielu:job_ad_creation_failure')); forward("mod/poster/add_job_offering.php"); } // Send data to base /*$sql = "INSERT INTO {$CONFIG->dbprefix}koolielu_calendar_objects (guid, type, title, description, approved, time1_begin, time1_end) VALUES (".$poster->getGUID().",'job_offering:search','".$poster->title."','".$poster->brief_description."',".$poster->approved.",'".$poster->beginning_date."','".$poster->ending_date."')"; insert_data($sql); foreach ($subjects as $s) { $sql = "INSERT INTO {$CONFIG->dbprefix}koolielu_calendar_subject_refs (cal_object_id, subject_id) VALUES (".$poster->getGUID().", ".$s.")"; insert_data($sql); }*/ $poster->archived = 0; // send internal notification mails to editors (0-not approved, 1-approved) if (!(isModerator())) { // get all editors $editors = getAllEditors(); if (is_array($editors) && sizeof($editors) > 0) { foreach($editors as $editor) { // send message /*translation:Job advertisement notification*/ $msg_title= elgg_echo('koolielu:job_ad_notification'); $msg_desc = ""; if ($jobtype == "job_offering") { /*translation:New job offer %s has been added and requires your approval.*/ $msg_desc = sprintf(elgg_echo('koolielu:job_offer_notif_req_app'), $poster->getURL(), $poster->title); } else if ( $jobtype == "job_wanted_ad") { /*translation:New job search %s has been added and requires your approval.*/ $msg_desc = sprintf(elgg_echo('koolielu:job_search_notif_req_app'), $poster->getURL(), $poster->title); } $messages = array('title' => $msg_title, 'description' => $msg_desc); send_system_message($editor->getGUID(), $messages); } } // Success message /*translation:Job advertisement added and waiting editor approval before publishing.*/ system_message(elgg_echo('koolielu:job_ad_added_waiting_approval')); } else { /*translation:Job advertisement added.*/ system_message(elgg_echo('koolielu:job_ad_added')); // river if ($jobtype == "job_offering") { add_to_river('river/object/job_offering/create','create',$_SESSION['user']->guid,$poster->guid); } else if ($jobtype == "job_wanted_ad") { add_to_river('river/object/job_wanted_ad/create','create',$_SESSION['user']->guid,$poster->guid); } } // Remove from cache unset($_SESSION['adtitle']); unset($_SESSION['jobtype']); unset($_SESSION['brief_description']); unset($_SESSION['adbody']); unset($_SESSION['place']); unset($_SESSION['beginning_date']); unset($_SESSION['ending_date']); unset($_SESSION['contact_person']); unset($_SESSION['telephone']); unset($_SESSION['email']); unset($_SESSION['subjects']); // Forward to advertisement view forward("pg/poster/read/" . $poster->getGUID()); } ?>