function lti_update_type($type, $config) { global $DB, $CFG; lti_prepare_type_for_save($type, $config); $clearcache = false; if (lti_request_is_using_ssl() && !empty($type->secureicon)) { $clearcache = !isset($config->oldicon) || $config->oldicon !== $type->secureicon; } else { $clearcache = isset($type->icon) && (!isset($config->oldicon) || $config->oldicon !== $type->icon); } unset($config->oldicon); if ($DB->update_record('lti_types', $type)) { foreach ($config as $key => $value) { if (substr($key, 0, 4) == 'lti_' && !is_null($value)) { $record = new \StdClass(); $record->typeid = $type->id; $record->name = substr($key, 4); $record->value = $value; lti_update_config($record); } } require_once $CFG->libdir . '/modinfolib.php'; if ($clearcache) { rebuild_course_cache(); } } }
function lti_update_type($type, $config) { global $DB; lti_prepare_type_for_save($type, $config); if ($DB->update_record('lti_types', $type)) { foreach ($config as $key => $value) { if (substr($key, 0, 4)=='lti_' && !is_null($value)) { $record = new StdClass(); $record->typeid = $type->id; $record->name = substr($key, 4); $record->value = $value; lti_update_config($record); } } } }
function lti_update_type($type, $config) { global $DB, $CFG; lti_prepare_type_for_save($type, $config); $clearcache = false; if (lti_request_is_using_ssl() && !empty($type->secureicon)) { $clearcache = !isset($config->oldicon) || ($config->oldicon !== $type->secureicon); } else { $clearcache = isset($type->icon) && (!isset($config->oldicon) || ($config->oldicon !== $type->icon)); } unset($config->oldicon); if ($DB->update_record('lti_types', $type)) { foreach ($config as $key => $value) { if (substr($key, 0, 4) == 'lti_' && !is_null($value)) { $record = new \StdClass(); $record->typeid = $type->id; $record->name = substr($key, 4); $record->value = $value; lti_update_config($record); } } require_once($CFG->libdir.'/modinfolib.php'); if ($clearcache) { $sql = "SELECT DISTINCT course FROM {lti} WHERE typeid = ?"; $courses = $DB->get_fieldset_sql($sql, array($type->id)); foreach ($courses as $courseid) { rebuild_course_cache($courseid, true); } } } }