/** * Updates an instance of the mediagallery in the database * * Given an object containing all the necessary data, * (defined by the form in mod_form.php) this function * will update an existing instance with new data. * * @param object $mediagallery An object from the form in mod_form.php * @param mod_mediagallery_mod_form $mform * @return boolean Success/Fail */ function mediagallery_update_instance(stdClass $mediagallery, mod_mediagallery_mod_form $mform = null) { global $DB, $USER; if (empty($mediagallery->enforcedefaults)) { $mediagallery->enforcedefaults = 0; } // We never change the mode once set. unset($mediagallery->mode); $mediagallery = mediagallery_formfield_transform($mediagallery); $mediagallery->timemodified = time(); $mediagallery->id = $mediagallery->instance; $result = $DB->update_record('mediagallery', $mediagallery); $collection = new \mod_mediagallery\collection($mediagallery); $collection->set_tags($mediagallery->tags); return $result; }