$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("pg/poster/edit_course/" . $course_guid); // Otherwise, save changes } else { $course = get_entity($course_guid); $course->title = $title; $course->brief_description = $brief_desc; $course->subjects = $subjects; $course->targetgroup = $targetgroup; $course->description = $description; $course->additional_info = $additional_info; $course->place = $place; $course->capacity = $capacity; $course->cost = $cost; // Make date to timestamp conversions if (!empty($beginning_date)) $beginning_date = dateIntoTimestamp($beginning_date); $course->beginning_date = $beginning_date; if (!empty($ending_date)) { $ending_date = dateIntoTimestamp($ending_date); // if ending date is bigger than current time, then it should not be archived anymore if ($ending_date > time()) $course->archived = 0; // also if course is approved, we need to make it public again if ($course->approved == 1) { $course->access_id = 2; } } $course->ending_date = $ending_date; $course->contact_person = $contact_person; $course->telephone = $telephone; $course->email = $email; $course->clearMetadata('gmaplocation'); $course->gmaplocation = $gmaplocation; // Send data to base delete_data("DELETE from {$CONFIG->dbprefix}koolielu_calendar_objects where guid=".$course->getGUID()); $sql = "INSERT INTO {$CONFIG->dbprefix}koolielu_calendar_objects (guid, type, title, description, approved, time1_begin, time1_end) VALUES (".$course->getGUID().",'course','".mysql_real_escape_string($course->title)."','".mysql_real_escape_string($course->brief_description)."',".(int)$course->approved.",'".$course->beginning_date."','".$course->ending_date."')"; insert_data($sql); foreach ($subjects as $s) { $sql = "INSERT INTO {$CONFIG->dbprefix}koolielu_calendar_subject_refs (cal_object_id, subject_id) VALUES (".$course->getGUID().", ".$s.")"; insert_data($sql); } // Deal with image if ((isset($_FILES['image'])) && (substr_count($_FILES['image']['type'],'image/'))) { $supported_formats = getSupportedImageFormats(); // See if we even support the format first if (in_array(exif_imagetype($_FILES['image']['tmp_name']), $supported_formats)) { // Delete old files deleteKeObjectImages($course->getGUID(), $course->getOwner()); // Write original file name into objects metadata $course->original_file_name = $_FILES['image']['name']; // Save new ones saveKeObjectImages('image', $course->getGUID(), $course->getOwner()); } else { /*translation:Image format not supported. Supported formats are: .jpg, .png, .jpeg and .gif.*/ register_error(elgg_echo('koolielu:error_supported_image_formats')); } } if (!isModerator()) { if ($course->access_id == 2) { /*translation:Course changes saved. Editor needs to review it before publishing it again.*/ system_message("koolielu:course_changes_saved_needs_moderating"); // send message to editor(s) $editors = getAllEditors(); if (is_array($editors) && sizeof($editors) > 0) { foreach($editors as $editor) { /*translation:Course edited notification*/ $msg_title= elgg_echo('koolielu:course_edited_notification'); $msg_desc = ""; /*translation:Course %s has been edited and needs reviewing.*/ $msg_desc = sprintf(elgg_echo('koolielu:course_edited_notif_req_app'), $course->getURL(), $course->title); $messages = array('title' => $msg_title, 'description' => $msg_desc); send_system_message($editor->getGUID(), $messages); } } } else { /*translation:Course changes saved.*/ system_message(elgg_echo("koolielu:course_changes_saved")); } $course->access_id = 1; $course->approved = 0; } else { /*translation:Course changes saved.*/ system_message(elgg_echo("koolielu:course_changes_saved")); } $course->save(); // Remove course from cache unset($_SESSION['title']); unset($_SESSION['subjects']); unset($_SESSION['targetgroup']); unset($_SESSION['brief_description']); unset($_SESSION['description']); unset($_SESSION['additional_info']); unset($_SESSION['place']); unset($_SESSION['capacity']); unset($_SESSION['cost']); unset($_SESSION['beginning_date']); unset($_SESSION['ending_date']); unset($_SESSION['contact_person']); unset($_SESSION['telephone']); unset($_SESSION['email']); unset($_SESSION['gmaplocation']); forward("pg/poster/read/" . $course_guid); } ?>