コード例 #1
0
 $course->publishername = $fromform->publishername;
 $course->publisheremail = $fromform->publisheremail;
 $course->creatorname = $fromform->creatorname;
 $course->contributornames = $fromform->contributornames;
 $course->coverage = $fromform->coverage;
 $course->licenceshortname = $fromform->licence;
 $course->subject = $fromform->subject;
 $course->audience = $fromform->audience;
 $course->educationallevel = $fromform->educationallevel;
 $course->creatornotes = $fromform->creatornotes['text'];
 $course->creatornotesformat = $fromform->creatornotes['format'];
 $course->privacy = empty($fromform->visible) ? 0 : $fromform->visible;
 //delete screenshots that are not needed anymore
 for ($screenshotnumber = 1; $screenshotnumber <= $course->screenshots; $screenshotnumber++) {
     if (!isset($fromform->{'screenshot_' . $screenshotnumber})) {
         if ($hub->screenshot_exists($course->id, $screenshotnumber)) {
             $hub->delete_screenshot($course->id, $screenshotnumber);
         }
     }
 }
 //sanitize course screenshots
 $screenshottotal = $hub->sanitize_screenshots($course->id);
 //save the new screenshots and update the course screenshots value
 if (!empty($fromform->addscreenshots)) {
     $screenshots = $fromform->addscreenshots;
     $fs = get_file_storage();
     $ctx = context_user::instance($USER->id);
     $files = $fs->get_area_files($ctx->id, 'user', 'draft', $screenshots);
     if (!empty($files)) {
         $level1 = floor($course->id / 1000) * 1000;
         $directory = "hub/{$level1}/{$course->id}";