/** * Undoes any magic quote slashing from an array, like the GET or POST * @param array $a Probably either $_GET or $_POST or $_COOKIES * @return array The array with all of the values in it noslashed * * In many cases, this can be a drop-in replacement for stripslashes_recursive * since this is what we typically use stripslashes_recursive for. This is * somewhat different in that if we ever turn off magic quotes, it will still * behave correctly and not double stripslashes. * */ function noslashes_recursive($a) { if (get_magic_quotes_gpc()) { $a = stripslashes_recursive($a); } return $a; }
function remove_magic_quotes() { if (get_magic_quotes_gpc()) { $_GET = stripslashes_recursive($_GET); $_POST = stripslashes_recursive($_POST); } }
function useredit_update_user_preference($usernew) { $ua = (array) $usernew; foreach ($ua as $key => $value) { if (strpos($key, 'preference_') === 0) { $name = substr($key, strlen('preference_')); set_user_preference($name, stripslashes_recursive($value), $usernew->id); } } }
function stripslashes_recursive($value) { if (is_array($value)) { foreach ($value as $index => $val) { $value[$index] = stripslashes_recursive($val); } return $value; } else { return stripslashes($value); } }
function form_process_data($cform) { if ($this->form) { $data = $cform->get_data(); // cr_serialize() will add slashes $data = stripslashes_recursive($data); $components = cr_unserialize($this->config->components); $components['columns']['config'] = $data; $this->config->components = cr_serialize($components); update_record('block_configurable_reports_report', $this->config); } }
/** * 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 $checklist An object from the form in mod_form.php * @return boolean Success/Fail */ function checklist_update_instance($checklist) { $checklist->timemodified = time(); $checklist->id = $checklist->instance; $returnid = update_record('checklist', $checklist); // Add or remove all calendar events, as needed $course = get_record('course', 'id', $checklist->course); $cm = get_coursemodule_from_instance('checklist', $checklist->id, $course->id); $chk = new checklist_class($cm->id, 0, $checklist, $cm, $course); $chk->setallevents(); $checklist = stripslashes_recursive($checklist); checklist_grade_item_update($checklist); return $returnid; }
/** * 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 $lesson Lesson post data from the form * @return boolean **/ function lesson_update_instance($lesson) { $lesson->id = $lesson->instance; lesson_process_pre_save($lesson); if (!($result = update_record("lesson", $lesson))) { return false; // Awe man! } lesson_process_post_save($lesson); // update grade item definition lesson_grade_item_update(stripslashes_recursive($lesson)); // update grades - TODO: do it only when grading style changes lesson_update_grades(stripslashes_recursive($lesson), 0, false); return $result; }
function form_process_data($cform) { if ($this->form) { $data = $cform->get_data(); // cr_serialize() will add slashes $data = stripslashes_recursive($data); $components = cr_unserialize($this->config->components); $components['permissions']['config'] = $data; if (isset($components['permissions']['config']->conditionexpr)) { $components['permissions']['config']->conditionexpr = $this->add_missing_conditions($components['permissions']['config']->conditionexpr); } $this->config->components = cr_serialize($components); update_record('block_configurable_reports_report', $this->config); } }
function glossary_update_instance($glossary) { /// Given an object containing all the necessary data, /// (defined by the form in mod.html) this function /// will update an existing instance with new data. global $CFG; if (empty($glossary->globalglossary)) { $glossary->globalglossary = 0; } if (!has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_SYSTEM))) { // keep previous unset($glossary->globalglossary); } $glossary->timemodified = time(); $glossary->id = $glossary->instance; if (empty($glossary->userating)) { $glossary->assessed = 0; } if (empty($glossary->ratingtime) or empty($glossary->assessed)) { $glossary->assesstimestart = 0; $glossary->assesstimefinish = 0; } //Check displayformat is a valid one $formats = get_list_of_plugins('mod/glossary/formats', 'TEMPLATE'); if (!in_array($glossary->displayformat, $formats)) { error("This format doesn't exist!"); } if ($return = update_record("glossary", $glossary)) { if ($glossary->defaultapproval) { execute_sql("update {$CFG->prefix}glossary_entries SET approved = 1 where approved != 1 and glossaryid = " . $glossary->id, false); } $glossary = stripslashes_recursive($glossary); glossary_grade_item_update($glossary); } return $return; }
/** * Updates a new assignment activity * * Given an object containing all the necessary data, * (defined by the form in mod.html) this function * will update the assignment instance and return the id number * The due date is updated in the calendar * This is common to all assignment types. * * @param $assignment object The data from the form on mod.html * @return int The assignment id */ function update_instance($assignment) { global $COURSE; $assignment->timemodified = time(); $assignment->id = $assignment->instance; $assignment->courseid = $assignment->course; if (!update_record('assignment', $assignment)) { return false; } if ($assignment->timedue) { $event = new object(); if ($event->id = get_field('event', 'id', 'modulename', 'assignment', 'instance', $assignment->id)) { $event->name = $assignment->name; $event->description = $assignment->description; $event->timestart = $assignment->timedue; update_event($event); } else { $event = new object(); $event->name = $assignment->name; $event->description = $assignment->description; $event->courseid = $assignment->course; $event->groupid = 0; $event->userid = 0; $event->modulename = 'assignment'; $event->instance = $assignment->id; $event->eventtype = 'due'; $event->timestart = $assignment->timedue; $event->timeduration = 0; add_event($event); } } else { delete_records('event', 'modulename', 'assignment', 'instance', $assignment->id); } // get existing grade item $assignment = stripslashes_recursive($assignment); assignment_grade_item_update($assignment); return true; }
/** * Processes and stores configuration data for this authentication plugin. */ function process_config($config) { // set to defaults if undefined if (!isset($config->host)) { $config->host = 'localhost'; } if (!isset($config->type)) { $config->type = 'mysql'; } if (!isset($config->sybasequoting)) { $config->sybasequoting = 0; } if (!isset($config->name)) { $config->name = ''; } if (!isset($config->user)) { $config->user = ''; } if (!isset($config->pass)) { $config->pass = ''; } if (!isset($config->table)) { $config->table = ''; } if (!isset($config->fielduser)) { $config->fielduser = ''; } if (!isset($config->fieldpass)) { $config->fieldpass = ''; } if (!isset($config->passtype)) { $config->passtype = 'plaintext'; } if (!isset($config->extencoding)) { $config->extencoding = 'utf-8'; } if (!isset($config->setupsql)) { $config->setupsql = ''; } if (!isset($config->debugauthdb)) { $config->debugauthdb = 0; } if (!isset($config->removeuser)) { $config->removeuser = 0; } if (!isset($config->changepasswordurl)) { $config->changepasswordurl = ''; } $config = stripslashes_recursive($config); // save settings set_config('host', $config->host, 'auth/db'); set_config('type', $config->type, 'auth/db'); set_config('sybasequoting', $config->sybasequoting, 'auth/db'); set_config('name', $config->name, 'auth/db'); set_config('user', $config->user, 'auth/db'); set_config('pass', $config->pass, 'auth/db'); set_config('table', $config->table, 'auth/db'); set_config('fielduser', $config->fielduser, 'auth/db'); set_config('fieldpass', $config->fieldpass, 'auth/db'); set_config('passtype', $config->passtype, 'auth/db'); set_config('extencoding', trim($config->extencoding), 'auth/db'); set_config('setupsql', trim($config->setupsql), 'auth/db'); set_config('debugauthdb', $config->debugauthdb, 'auth/db'); set_config('removeuser', $config->removeuser, 'auth/db'); set_config('changepasswordurl', trim($config->changepasswordurl), 'auth/db'); return true; }
/** * This function is called at the end of game_add_instance * and game_update_instance, to do the common processing. * * @param object $game the game object. */ function game_after_add_or_update($game) { //update related grade item game_grade_item_update(stripslashes_recursive($game)); }
$response->setError(1404, 'Operation not found: ' . $operation); } if ($response !== false) { echo $response->emitJSON(); } } } /** Take care of stripping the slashes */ function stripslashes_recursive($value) { $value = is_array($value) ? array_map('stripslashes_recursive', $value) : stripslashes($value); return $value; } /** END **/ if (!defined('MOBILE_API_CONTROLLER_AVOID_TRIGGER')) { $clientRequestValues = $_POST; // $_REQUEST or $_GET $clientRequestValuesRaw = array(); // Set of request key few controllers are interested in raw values (example, SaveRecord) /*$rawValueHeaders = array('values'); foreach($rawValueHeaders as $rawValueHeader) { if(isset($clientRequestValues[$rawValueHeader])) { $clientRequestValuesRaw[$rawValueHeader] = $clientRequestValues[$rawValueHeader]; } }*/ // END if (get_magic_quotes_gpc()) { $clientRequestValues = stripslashes_recursive($clientRequestValues); } Mobile_API_Controller::process(new Mobile_API_Request($clientRequestValues, $clientRequestValuesRaw)); }
/** * Recursively un-quotes a quoted variable * * @param mixed $var * @return mixed */ function stripslashes_recursive($var) { if (is_array($var)) { $unquoted = array(); foreach ($var as $key => $value) { $unquoted[$key] = stripslashes_recursive($value); } return $unquoted; } elseif (is_scalar($var)) { return stripslashes($var); } else { return $var; } }
function data_update_instance($data) { global $CFG; $data->timemodified = time(); $data->id = $data->instance; if (empty($data->assessed)) { $data->assessed = 0; } if (empty($data->notification)) { $data->notification = 0; } if (!update_record('data', $data)) { return false; } $data = stripslashes_recursive($data); data_grade_item_update($data); return true; }
/** * Update grouping * @param object $data grouping properties (with magic quotes) * @return boolean success */ function groups_update_grouping($data) { global $CFG; $data->timemodified = time(); $data->name = trim($data->name); $result = update_record('groupings', $data); if ($result) { //trigger groups events events_trigger('groups_grouping_updated', stripslashes_recursive($data)); } return $result; }
/** * Recursive implementation of stripslashes() * * This function will allow you to strip the slashes from a variable. * If the variable is an array or object, slashes will be stripped * from the items (or properties) it contains, even if they are arrays * or objects themselves. * * @param mixed the variable to remove slashes from * @return mixed */ function stripslashes_recursive($var) { if (is_object($var)) { $new_var = new object(); $properties = get_object_vars($var); foreach ($properties as $property => $value) { $new_var->{$property} = stripslashes_recursive($value); } } else { if (is_array($var)) { $new_var = array(); foreach ($var as $property => $value) { $new_var[$property] = stripslashes_recursive($value); } } else { if (is_string($var)) { $new_var = stripslashes($var); } else { $new_var = $var; } } } return $new_var; }
// $Id: search.php,v 1.12.2.2 2007/03/23 01:16:22 nicolasconnault Exp $ // searches for admin settings require_once '../config.php'; require_once $CFG->libdir . '/adminlib.php'; $query = trim(stripslashes_safe(required_param('query', PARAM_NOTAGS))); // Search string $adminroot = admin_get_root(); admin_externalpage_setup('search', $adminroot); // now hidden page $CFG->adminsearchquery = $query; // So we can reference it in search boxes later in this invocation // now we'll deal with the case that the admin has submitted the form with changed settings $statusmsg = ''; if ($data = data_submitted()) { $unslashed = (array) stripslashes_recursive($data); if (confirm_sesskey()) { $olddbsessions = !empty($CFG->dbsessions); $changedsettings = search_settings(admin_get_root(), $query); $errors = ''; foreach ($changedsettings as $changedsetting) { if (!isset($unslashed['s_' . $changedsetting->name])) { $unslashed['s_' . $changedsetting->name] = ''; // needed for checkboxes } $errors .= $changedsetting->write_setting($unslashed['s_' . $changedsetting->name]); } if ($olddbsessions != !empty($CFG->dbsessions)) { require_logout(); } if (empty($errors)) {
/** * Serialize and store config data * @return boolean * @todo finish documenting this function */ function instance_config_save($data, $pinned = false) { $data = stripslashes_recursive($data); $this->config = $data; $table = 'block_instance'; if (!empty($pinned)) { $table = 'block_pinned'; } return set_field($table, 'configdata', base64_encode(serialize($data)), 'id', $this->instance->id); }
/** * Given an object containing all the necessary data, * (defined by the form in mod.html) this function * will update an existing instance with new data. * @param object $forum forum instance (with magic quotes) * @return bool success */ function forum_update_instance($forum) { $forum->timemodified = time(); $forum->id = $forum->instance; if (empty($forum->assessed)) { $forum->assessed = 0; } if (empty($forum->ratingtime) or empty($forum->assessed)) { $forum->assesstimestart = 0; $forum->assesstimefinish = 0; } $oldforum = get_record('forum', 'id', $forum->id); // MDL-3942 - if the aggregation type or scale (i.e. max grade) changes then recalculate the grades for the entire forum // if scale changes - do we need to recheck the ratings, if ratings higher than scale how do we want to respond? // for count and sum aggregation types the grade we check to make sure they do not exceed the scale (i.e. max score) when calculating the grade if ($oldforum->assessed != $forum->assessed or $oldforum->scale != $forum->scale) { forum_update_grades($forum); // recalculate grades for the forum } if ($forum->type == 'single') { // Update related discussion and post. if (!($discussion = get_record('forum_discussions', 'forum', $forum->id))) { if ($discussions = get_records('forum_discussions', 'forum', $forum->id, 'timemodified ASC')) { notify('Warning! There is more than one discussion in this forum - using the most recent'); $discussion = array_pop($discussions); } else { error('Could not find the discussion in this forum'); } } if (!($post = get_record('forum_posts', 'id', $discussion->firstpost))) { error('Could not find the first post in this forum discussion'); } $post->subject = $forum->name; $post->message = $forum->intro; $post->modified = $forum->timemodified; if (!update_record('forum_posts', $post)) { error('Could not update the first post'); } $discussion->name = $forum->name; if (!update_record('forum_discussions', $discussion)) { error('Could not update the discussion'); } } if (!update_record('forum', $forum)) { error('Can not update forum'); } $forum = stripslashes_recursive($forum); forum_grade_item_update($forum); return true; }
/** * This function is called at the end of quiz_add_instance * and quiz_update_instance, to do the common processing. * * @param object $quiz the quiz object. */ function quiz_after_add_or_update($quiz) { // Save the feedback delete_records('quiz_feedback', 'quizid', $quiz->id); for ($i = 0; $i <= $quiz->feedbackboundarycount; $i += 1) { $feedback = new stdClass(); $feedback->quizid = $quiz->id; $feedback->feedbacktext = $quiz->feedbacktext[$i]; $feedback->mingrade = $quiz->feedbackboundaries[$i]; $feedback->maxgrade = $quiz->feedbackboundaries[$i - 1]; if (!insert_record('quiz_feedback', $feedback, false)) { return "Could not save quiz feedback."; } } // Update the events relating to this quiz. // This is slightly inefficient, deleting the old events and creating new ones. However, // there are at most two events, and this keeps the code simpler. if ($events = get_records_select('event', "modulename = 'quiz' and instance = '{$quiz->id}'")) { foreach ($events as $event) { delete_event($event->id); } } $event = new stdClass(); $event->description = $quiz->intro; $event->courseid = $quiz->course; $event->groupid = 0; $event->userid = 0; $event->modulename = 'quiz'; $event->instance = $quiz->id; $event->timestart = $quiz->timeopen; $event->timeduration = $quiz->timeclose - $quiz->timeopen; $event->visible = instance_is_visible('quiz', $quiz); $event->eventtype = 'open'; if ($quiz->timeclose and $quiz->timeopen and $event->timeduration <= QUIZ_MAX_EVENT_LENGTH) { // Single event for the whole quiz. $event->name = $quiz->name; add_event($event); } else { // Separate start and end events. $event->timeduration = 0; if ($quiz->timeopen) { $event->name = $quiz->name . ' (' . get_string('quizopens', 'quiz') . ')'; add_event($event); unset($event->id); // So we can use the same object for the close event. } if ($quiz->timeclose) { $event->name = $quiz->name . ' (' . get_string('quizcloses', 'quiz') . ')'; $event->timestart = $quiz->timeclose; $event->eventtype = 'close'; add_event($event); } } //update related grade item quiz_grade_item_update(stripslashes_recursive($quiz)); }
function html_safe($value) { if (get_magic_quotes_gpc()) { $value = stripslashes_recursive($value); } //function in config.inc.php return htmlentities($value, ENT_QUOTES); }
} // OK, now redirect to day view redirect(CALENDAR_URL . 'view.php?view=day&course=' . $urlcourse . '&cal_d=' . $form->startday . '&cal_m=' . $form->startmon . '&cal_y=' . $form->startyr); } else { foreach ($err as $key => $value) { $focus = 'form.' . $key; } } } break; default: // no action $title = ''; break; } $form = stripslashes_recursive($form); if (!empty($SESSION->cal_course_referer)) { // TODO: This is part of the Great $course Hack in Moodle. Replace it at some point. $course = get_record('course', 'id', $SESSION->cal_course_referer); } else { $course = $site; } require_login($course, false); $navlinks[] = $calendar_navlink; $navlinks[] = array('name' => $title, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header($site->shortname . ': ' . $strcalendar . ': ' . $title, $strcalendar, $navigation, 'eventform.name', '', true, '', user_login_string($site)); echo calendar_overlib_html(); echo '<table id="calendar">'; echo '<tr><td class="maincalendar">'; switch ($action) {
function hotpot_update_instance(&$hotpot) { if (hotpot_set_form_values($hotpot)) { $hotpot->id = $hotpot->instance; if ($result = update_record('hotpot', $hotpot)) { hotpot_update_events($hotpot); //hotpot_grade_item_update(stripslashes_recursive($hotpot)); hotpot_update_grades(stripslashes_recursive($hotpot)); } } else { $result = false; } return $result; }
/** * Given an ID of an instance of this module, * this function will permanently delete the instance * and any data that depends on it. * * @param int $id Scorm instance id * @return boolean */ function scorm_delete_instance($id) { global $CFG; if (!($scorm = get_record('scorm', 'id', $id))) { return false; } $result = true; $scorm->dir = $CFG->dataroot . '/' . $scorm->course . '/moddata/scorm'; if (is_dir($scorm->dir . '/' . $scorm->id)) { // Delete any dependent files require_once 'locallib.php'; scorm_delete_files($scorm->dir . '/' . $scorm->id); } // Delete any dependent records if (!delete_records('scorm_scoes_track', 'scormid', $scorm->id)) { $result = false; } if ($scoes = get_records('scorm_scoes', 'scorm', $scorm->id)) { foreach ($scoes as $sco) { if (!delete_records('scorm_scoes_data', 'scoid', $sco->id)) { $result = false; } } delete_records('scorm_scoes', 'scorm', $scorm->id); } else { $result = false; } if (!delete_records('scorm', 'id', $scorm->id)) { $result = false; } /*if (! delete_records('scorm_sequencing_controlmode', 'scormid', $scorm->id)) { $result = false; } if (! delete_records('scorm_sequencing_rolluprules', 'scormid', $scorm->id)) { $result = false; } if (! delete_records('scorm_sequencing_rolluprule', 'scormid', $scorm->id)) { $result = false; } if (! delete_records('scorm_sequencing_rollupruleconditions', 'scormid', $scorm->id)) { $result = false; } if (! delete_records('scorm_sequencing_rolluprulecondition', 'scormid', $scorm->id)) { $result = false; } if (! delete_records('scorm_sequencing_rulecondition', 'scormid', $scorm->id)) { $result = false; } if (! delete_records('scorm_sequencing_ruleconditions', 'scormid', $scorm->id)) { $result = false; }*/ scorm_grade_item_delete(stripslashes_recursive($scorm)); return $result; }
} error_reporting(E_ALL); ignore_user_abort(true); umask(0); ob_start(); // disable gzip compression if possible if (is_callable('apache_setenv')) { apache_setenv('no-gzip', '1'); } if (@ini_get('session.save_handler') == 'user') { @ini_set('session.save_handler', 'files'); } @session_start(); // Add slashes, as long as they aren't already being added. if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0) { $_POST = stripslashes_recursive($_POST); } $config = new Configurator(); $config->lang_dir = BASEDIR . '/Languages'; try { $lng = new Lang(); $lng->loadLang($config->lang_dir); } catch (Exception $e) { ImportException::exception_handler($e); } $template = new Template($lng); global $import; $importer = new Importer($config, $lng, $template); $response = new HttpResponse(new ResponseHeader()); $template->setResponse($response); $import = new ImportManager($config, $importer, $template, new Cookie(), $response);
<? if (!$current_user || !in_array($is_admin,$allowed)) { $smarty->assign('titulo', 'Login | '.$site_nome); $smarty->display('admin/login.tpl'); exit; } if (get_magic_quotes_gpc()) { $_GET = stripslashes_recursive($_GET); $_POST = stripslashes_recursive($_POST); $_COOKIE = stripslashes_recursive($_COOKIE); } function stripslashes_recursive($var) { return (is_array($var) ? array_map('stripslashes_recursive', $var) : stripslashes($var)); } ?>
/** * Store changed settings, this function updates the errors variable in $ADMIN * @param object $formdata from form (without magic quotes) * @return int number of changed settings */ function admin_write_settings($formdata) { global $CFG, $SITE, $COURSE; $olddbsessions = !empty($CFG->dbsessions); $formdata = (array) stripslashes_recursive($formdata); $data = array(); foreach ($formdata as $fullname => $value) { if (strpos($fullname, 's_') !== 0) { continue; // not a config value } $data[$fullname] = $value; } $adminroot =& admin_get_root(); $settings = admin_find_write_settings($adminroot, $data); $count = 0; foreach ($settings as $fullname => $setting) { $original = serialize($setting->get_setting()); // comparison must work for arrays too $error = $setting->write_setting($data[$fullname]); if ($error !== '') { $adminroot->errors[$fullname] = new object(); $adminroot->errors[$fullname]->data = $data[$fullname]; $adminroot->errors[$fullname]->id = $setting->get_id(); $adminroot->errors[$fullname]->error = $error; } if ($original !== serialize($setting->get_setting())) { $count++; $callbackfunction = $setting->updatedcallback; if (function_exists($callbackfunction)) { $callbackfunction($fullname); } } } if ($olddbsessions != !empty($CFG->dbsessions)) { require_logout(); } // now update $SITE - it might have been changed $SITE = get_record('course', 'id', $SITE->id); $COURSE = clone $SITE; // now reload all settings - some of them might depend on the changed admin_get_root(true); return $count; }
} else { $response = new Mobile_API_Response(); $response->setError(1404, 'Operation not found: ' . $operation); } if ($response !== false) { if ($response->hasError()) { include_once dirname(__FILE__) . '/ui/Error.php'; $errorController = new Mobile_UI_Error(); $errorController->setError($response->getError()); echo $errorController->process($request)->emitHTML(); } else { echo $response->emitHTML(); } } } } /** Take care of stripping the slashes */ function stripslashes_recursive($value) { $value = is_array($value) ? array_map('stripslashes_recursive', $value) : stripslashes($value); return $value; } if (get_magic_quotes_gpc()) { //$_GET = stripslashes_recursive($_GET ); //$_POST = stripslashes_recursive($_POST ); $_REQUEST = stripslashes_recursive($_REQUEST); } /** END **/ if (!defined('MOBILE_INDEX_CONTROLLER_AVOID_TRIGGER')) { Mobile_Index_Controller::process(new Mobile_API_Request($_REQUEST)); }
/** * Given an object containing all the necessary data, * (defined by the form in mod.html) this function * will update an existing instance with new data. * * @param object $instance An object from the form in mod.html * @return boolean Success/Fail **/ function webquestscorm_update_instance($webquestscorm) { $webquestscorm->id = $webquestscorm->instance; $webquestscorm->timemodified = time(); /* if (empty($webquestscorm->dueenable)) { $webquestscorm->timedue = 0; $webquestscorm->preventlate = 0; } else { $webquestscorm->timedue = make_timestamp($webquestscorm->dueyear, $webquestscorm->duemonth, $webquestscorm->dueday, $webquestscorm->duehour, $webquestscorm->dueminute); } if (empty($webquestscorm->availableenable)) { $webquestscorm->timeavailable = 0; } else { $webquestscorm->timeavailable = make_timestamp($webquestscorm->availableyear, $webquestscorm->availablemonth, $webquestscorm->availableday, $webquestscorm->availablehour, $webquestscorm->availableminute); } */ $result = update_record("webquestscorm", $webquestscorm); if ($result) { if ($webquestscorm->timedue) { $event = NULL; if ($event->id = get_field('event', 'id', 'modulename', 'webquestscorm', 'instance', $webquestscorm->id)) { $event->name = $webquestscorm->name; $event->description = $webquestscorm->description; $event->timestart = $webquestscorm->timedue; update_event($event); } else { $event = NULL; $event->id = $webquestscorm->id; $event->name = $webquestscorm->name; $event->description = $webquestscorm->name; $event->courseid = $webquestscorm->course; $event->groupid = 0; $event->userid = 0; $event->modulename = 'webquestscorm'; $webquestscorm->id = $webquestscorm->instance; $event->eventtype = 'due'; $event->timestart = $webquestscorm->timedue; $event->timeduration = 0; add_event($event); } } else { delete_records('event', 'modulename', 'webquestscorm', 'instance', $webquestscorm->id); } } $webquestscorm = stripslashes_recursive($webquestscorm); webquestscorm_grade_item_update($webquestscorm); return $result; }