/** * Given an object containing all the necessary data, * (defined by the form in mod_form.php) this function * will create a new instance and return the id number * of the new instance. * * @param object $scheduler An object from the form in mod_form.php * @return int The id of the newly inserted scheduler record */ function scheduler_add_instance($scheduler) { $scheduler->timecreated = time(); # You may have to add extra stuff in here # echo 'new scheduler added'; return insert_record('scheduler', $scheduler); }
/** * Processes the message (sends by email). * @param object $message the message to be sent */ function send_message($message) { //send an email //if fails saved as read message //first try to get preference $usertoemail = get_user_preferences('message_processor_email_email', '', $message->useridto); //if fails use user profile default if ($usertoemail == NULL) { $userto = get_record('user', 'id', $message->useridto); $usertoemail = $userto->email; } $userfrom = get_record('user', 'id', $message->useridfrom); if (email_to_user($usertoemail, $userfrom->email, $message->subject, $message->fullmessage, $message->fullmessagehtml)) { /// Move the entry to the other table $message->timeread = time(); $messageid = $message->id; unset($message->id); //if there is no more processor that want to process this can move message if (count_records('message_working', array('unreadmessageid' => $messageid)) == 0) { if (insert_record('message_read', $message)) { delete_records('message', 'id', $messageid); } } } else { //delete what we've processed and check if can move message if (count_records('message_working', 'unreadmessageid', $messageid) == 0) { if (insert_record('message_read', $message)) { delete_records('message', 'id', $messageid); } } } return true; }
function save_question_options($question) { $result = true; $update = true; $answer = get_record("question_answers", "question", $question->id); if (!$answer) { $answer = new stdClass(); $answer->question = $question->id; $update = false; } $answer->answer = $question->feedback; $answer->feedback = $question->feedback; $answer->fraction = $question->fraction; if ($update) { if (!update_record("question_answers", $answer)) { $result = new stdClass(); $result->error = "Could not update quiz answer!"; } } else { if (!($answer->id = insert_record("question_answers", $answer))) { $result = new stdClass(); $result->error = "Could not insert quiz answer!"; } } return $result; }
function block_openshare_updategroup($courseid, $groupid) { $sql = 'SELECT u.id FROM mdl_user u JOIN mdl_role_assignments ra ON ra.userid = u.id JOIN mdl_role r ON ra.roleid = r.id JOIN mdl_context con ON ra.contextid = con.id JOIN mdl_course c ON c.id = con.instanceid AND con.contextlevel = 50 WHERE (r.shortname = \'student\' OR r.shortname = \'teacher\' OR r.shortname = \'editingteacher\' OR r.shortname = \'coursecreator\') AND c.id = ' . $courseid; $rs = get_recordset_sql($sql); if (!empty($rs)) { while ($rec = rs_fetch_next_record($rs)) { //prep dataobject for door $groupenroll = new object(); $groupenroll->timeadded = time(); $groupenroll->groupid = $groupid; $groupenroll->userid = $rec->id; $ingroup = get_record("groups_members", "groupid", $groupid, "userid", $rec->id); if (empty($ingroup)) { insert_record("groups_members", $groupenroll); print 'updated' . $groupenroll->groupid . $groupenroll->userid . '<br/>'; } } } else { print_error("No users in this course!"); } // Close the recordset to save memory rs_close($rs); }
function requestfriendship_submit(Pieform $form, $values) { global $USER, $SESSION, $id, $goto; $loggedinid = $USER->get('id'); $user = get_record('usr', 'id', $id); // friend db record $f = new StdClass(); $f->ctime = db_format_timestamp(time()); // notification info $n = new StdClass(); $n->url = profile_url($USER, false); $n->users = array($user->id); $n->fromuser = $loggedinid; $lang = get_user_language($user->id); $displayname = display_name($USER, $user); $n->strings = new stdClass(); $n->strings->urltext = (object) array('key' => 'Requests'); $f->owner = $id; $f->requester = $loggedinid; $f->message = $values['message']; insert_record('usr_friend_request', $f); $n->subject = get_string_from_language($lang, 'requestedfriendlistsubject', 'group'); if (isset($values['message']) && !empty($values['message'])) { $n->message = get_string_from_language($lang, 'requestedfriendlistmessageexplanation', 'group', $displayname) . $values['message']; } else { $n->message = get_string_from_language($lang, 'requestedfriendlistinboxmessage', 'group', $displayname); } require_once 'activity.php'; activity_occurred('maharamessage', $n); handle_event('addfriendrequest', array('requester' => $loggedinid, 'owner' => $id)); $SESSION->add_ok_msg(get_string('friendformrequestsuccess', 'group', display_name($id))); redirect($goto); }
function lms_get_folder($installid, $foldername, $user) { // look for the installid folder first. if (!($folder = get_record('file_folders', 'owner', $user->ident, 'name', $installid))) { // we have to make it. $folder = new StdClass(); $folder->name = $installid; $folder->owner = $user->ident; $folder->files_owner = $user->ident; $folder->parent = -1; $folder->access = 'user' . $user->ident; // ew $folder->ident = insert_record('file_folders', $folder); } if (!($subfolder = get_record('file_folders', 'owner', $user->ident, 'name', $foldername, 'parent', $folder->ident))) { // we have to make it. $subfolder = new StdClass(); $subfolder->name = $foldername; $subfolder->owner = $user->ident; $subfolder->files_owner = $user->ident; $subfolder->parent = $folder->ident; $subfolder->access = 'user' . $user->ident; // ew $subfolder->ident = insert_record('file_folders', $subfolder); } return $subfolder; }
function save_question_options($question) { if ($answer = get_record("question_answers", "question", $question->id)) { // Existing answer, so reuse it $answer->answer = $question->feedback; $answer->feedback = $question->feedback; $answer->fraction = $question->fraction; if (!update_record("question_answers", $answer)) { $result = new stdClass(); $result->error = "Could not update quiz answer!"; return $result; } } else { $answer = new stdClass(); $answer->question = $question->id; $answer->answer = $question->feedback; $answer->feedback = $question->feedback; $answer->fraction = $question->fraction; if (!($answer->id = insert_record("question_answers", $answer))) { $result = new stdClass(); $result->error = "Could not insert quiz answer!"; return $result; } } return true; }
function slideshow_captions_restore_mods($old_slideshow_id, $new_slideshow_id, $info, $restore) { global $CFG; $status = true; //Get the captions array $captions = $info['MOD']['#']['CAPTIONS']['0']['#']['CAPTION']; //Iterate over captions for ($i = 0; $i < sizeof($captions); $i++) { $cap_info = $captions[$i]; //traverse_xmlize($cap_info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug //We'll need this later!! $oldid = backup_todb($cap_info['#']['ID']['0']['#']); $olduserid = backup_todb($cap_info['#']['USERID']['0']['#']); //Now, build the SLIDESHOW_MESSAGES record structure $caption->slideshow = $new_slideshow_id; $caption->image = backup_todb($cap_info['#']['IMAGE']['0']['#']); $caption->title = backup_todb($cap_info['#']['TITLE']['0']['#']); $caption->caption = backup_todb($cap_info['#']['CAPTION']['0']['#']); //The structure is equal to the db, so insert the slideshow_message $newid = insert_record("slideshow_captions", $caption); //Do some output if (($i + 1) % 50 == 0) { if (!defined('RESTORE_SILENTLY')) { echo "."; if (($i + 1) % 1000 == 0) { echo "<br />"; } } backup_flush(300); } } return $status; }
public function commit() { if ($this->initialized == self::UNINITIALIZED) { return false; } if (false == $this->changed) { return true; } if (empty($this->members['displayname'])) { $this->members['displayname'] = $this->members['name']; } if (false == $this->changed) { return true; } $application = new stdClass(); $application->name = $this->members['name']; $application->displayname = $this->members['displayname']; $application->xmlrpcserverurl = $this->members['xmlrpcserverurl']; if ($this->initialized == self::INITIALIZED) { $this->initialized = self::PERSISTENT; return insert_record('application', $application); } elseif ($this->initialized == self::PERSISTENT) { return update_record('application', $application, array('name' => $application->oldname)); } return false; }
function AppendSudokuB() { $level1 = required_param('level1', PARAM_NUMBER); // action $level2 = required_param('level2', PARAM_NUMBER); // action $count = required_param('count', PARAM_NUMBER); // action $level = $level1; for ($i = 1; $i <= $count; $i++) { set_time_limit(30); Create($si, $sp, $level); $newrec->data = PackSudoku($si, $sp); if (strlen($newrec->data) != 81) { return 0; } $newrec->level = $level; $newrec->opened = GetOpened($si); insert_record("game_sudoku_database", $newrec, true); $level++; if ($level > $level2) { $level = $level1; } echo get_string('sudoku_creating', 'game', $i) . "<br>\r\n"; } }
function forumng_add_instance($forumng) { // Avoid including forum libraries in large areas of Moodle code that // require this lib.php; only include when functions are called require_once dirname(__FILE__) . '/forum.php'; $useshared = !empty($forumng->usesharedgroup['useshared']); if ($useshared) { $idnumber = $forumng->usesharedgroup['originalcmidnumber']; if (!($originalcm = get_record('course_modules', 'idnumber', $idnumber, 'module', get_field('modules', 'id', 'name', 'forumng')))) { return false; } if (!($originalforumng = get_record('forumng', 'id', $originalcm->instance))) { return false; } // Create appropriate data for forumng table $forumng = (object) array('name' => addslashes($originalforumng->name), 'course' => $forumng->course, 'type' => 'clone', 'originalcmid' => $originalcm->id); } // Pick a random magic number $part1 = mt_rand(0, 99999999); $part2 = mt_rand(0, 99999999); while (strlen($part2) < 8) { $part2 = '0' . $part2; } $forumng->magicnumber = $part1 . $part2; if (!($id = insert_record('forumng', $forumng))) { return false; } // Handle post-creation actions (but only if a new forum actually was // created, and not just a new reference to a shared one!) if (!$useshared) { $forum = forum::get_from_id($id, forum::CLONE_DIRECT, false); $forum->created($forumng->cmidnumber); } return $id; }
function diplome_restore_mods($mod, $restore) { global $CFG; $status = true; //Get record from backup_ids $data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id); if ($data) { //Now get completed xmlized object $info = $data->info; //Now, build the ACCOUNTING record structure $diplome->course = $restore->course_id; $diplome->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); $diplome->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']); $diplome->introformat = backup_todb($info['MOD']['#']['INTROFORMAT']['0']['#']); $diplome->timecreated = time(); $diplome->timemodified = time(); //The structure is equal to the db, so insert the label $newid = insert_record("diplome", $diplome); //Do some output if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("modulename", "diplome") . " \"" . format_string(stripslashes($diplome->name), true) . "\"</li>"; } backup_flush(300); if ($newid) { //We have the newid, update backup_ids backup_putid($restore->backup_unique_code, $mod->modtype, $mod->id, $newid); } else { $status = false; } } else { $status = false; } return $status; }
function sclipowebclass_add_event($sclipo) { $sclipo->timemodified = time(); # May have to add extra stuff in here # $returnid = insert_record("event", $sclipo); return $returnid; }
function xmldb_blocktype_taggedposts_upgrade($oldversion = 0) { if ($oldversion < 2015011500) { $table = new XMLDBTable('blocktype_taggedposts_tags'); $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE); $table->addFieldInfo('block_instance', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL); $table->addFieldInfo('tag', XMLDB_TYPE_CHAR, 128, null, XMLDB_NOTNULL); $table->addFieldInfo('tagtype', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL); $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); $table->addIndexInfo('tagtagtypeix', XMLDB_INDEX_NOTUNIQUE, array('tag', 'tagtype')); if (!table_exists($table)) { create_table($table); $rs = get_recordset('block_instance', 'blocktype', 'taggedposts', 'id', 'id, configdata'); while ($bi = $rs->FetchRow()) { // Each block will have only one tag (because we combined this upgrade block // with the upgrade block for the "multiple tags" enhancement. $configdata = unserialize($bi['configdata']); if (!empty($configdata['tagselect'])) { $todb = new stdClass(); $todb->block_instance = $bi['id']; $todb->tag = $configdata['tagselect']; $todb->tagtype = PluginBlocktypeTaggedposts::TAGTYPE_INCLUDE; insert_record('blocktype_taggedposts_tags', $todb); } } } } return true; }
function lightboxgallery_restore_metadata($galleryid, $info, $restore) { $status = true; if (isset($info['MOD']['#']['IMAGEMETAS']['0']['#']['IMAGEMETA'])) { $imagemetas = $info['MOD']['#']['IMAGEMETAS']['0']['#']['IMAGEMETA']; } else { $imagemetas = array(); } for ($i = 0; $i < sizeof($imagemetas); $i++) { $sub_info = $imagemetas[$i]; $oldid = backup_todb($sub_info['#']['ID']['0']['#']); $record = new object(); $record->gallery = $galleryid; $record->image = backup_todb($sub_info['#']['IMAGE']['0']['#']); $record->metatype = backup_todb($sub_info['#']['METATYPE']['0']['#']); $record->description = backup_todb($sub_info['#']['DESCRIPTION']['0']['#']); $newid = insert_record('lightboxgallery_image_meta', $record); if (($i + 1) % 50 == 0) { if (!defined('RESTORE_SILENTLY')) { echo '.'; if (($i + 1) % 1000 == 0) { echo '<br />'; } } backup_flush(300); } if ($newid) { backup_putid($restore->backup_unique_code, 'lightboxgallery_image_meta', $oldid, $newid); } else { $status = false; } } return $status; }
/** * @desc Creates a new Moodle assignment <-> Webwork problem set tie. * @param $wwassignment object The data of the record to be entered in the DB. * @return integer The ID of the new record. */ function wwassignment_add_instance($wwassignment) { global $COURSE; debugLog("Begin wwassignment_add_instance"); debugLog("input wwassignment "); //debugLog( print_r($wwassignment, true) ); //Get data about the set from WebWorK $wwclient = new wwassignment_client(); $wwassignment->webwork_course = _wwassignment_mapped_course($COURSE->id, false); $wwsetdata = $wwclient->get_assignment_data($wwassignment->webwork_course, $wwassignment->webwork_set, false); //Attaching Moodle Set to WeBWorK Set debugLog("saving wwassignment "); debugLog(print_r($wwassignment, true)); $wwassignment->timemodified = time(); if ($returnid = insert_record("wwassignment", $wwassignment)) { $wwassignment->id = $returnid; //Creating events _wwassignment_create_events($wwassignment, $wwsetdata); debugLog("notify gradebook"); //notify gradebook wwassignment_grade_item_update($wwassignment); } debugLog("End wwassignment_add_instance"); return $returnid; }
/** * Library of functions used by the RQP question type * * @version $Id: lib.php,v 1.2 2006/09/18 13:24:45 moodler Exp $ * @author Alex Smith and other members of the Serving Mathematics project * {@link http://maths.york.ac.uk/serving_maths} * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package quiz */ function question_rqp_save_type($type) { if (empty($type->id)) { return insert_record('question_rqp_types', $type, false); } return update_record('question_rqp_types', $type); }
/** * セクション名を取得する * * @param object $course // コースオブジェクト * @param int $sectionid // course_sections のID :タイトルの取得に必要 * @param int $sectionnumber // sectionの連番 :存在しない場合のデフォルト名称に必要 * @param object &$mods // モジュール配列 * @return string セクションタイトル(存在しない場合は新規作成される) */ function topicsadv_format_get_title(&$course, $sectionid, $sectionnumber = 0) { global $CFG; // 引数のチェック if (!$sectionid) { return false; } // タイトルを取得 if (!($sectiontitle = get_record('course_topicsadv_title', 'sectionid', $sectionid))) { // タイトルが取得できなかった(新規のプロジェクトフォーマットアクセス) // 新規でタイトルとフォルダ名を作成する $directoryname = sprintf('section%02d', $sectionnumber); // DBインサート用オブジェクトの生成 $newtitle = new stdClass(); $newtitle->sectionid = $sectionid; $newtitle->directoryname = $directoryname; if (!($newtitle->id = insert_record('course_topicsadv_title', $newtitle))) { error('Could not create titles. Project format database is not ready. Aceess admin notify.'); } else { // 新規でタイトルを作成しました表示 notify(get_string('createnewtitle', 'format_topicsadv')); // セクション内のモジュールのリンクを書き換える topicsadv_format_rename_section_links($course, $sectionid, $directoryname); } $sectiontitle =& $newtitle; } return $sectiontitle; }
/** * Sign up a new user ready for confirmation. * Password is passed in plaintext. * * @param object $user new user object (with system magic quotes) * @param boolean $notify print notice with link and terminate */ function user_signup($user, $notify = true) { global $CFG; require_once $CFG->dirroot . '/user/profile/lib.php'; $user->password = hash_internal_user_password($user->password); if (!($user->id = insert_record('user', $user))) { print_error('auth_emailnoinsert', 'auth'); } /// Save any custom profile field information profile_save_data($user); $user = get_record('user', 'id', $user->id); events_trigger('user_created', $user); if (!send_confirmation_email($user)) { print_error('auth_emailnoemail', 'auth'); } if ($notify) { global $CFG; $emailconfirm = get_string('emailconfirm'); $navlinks = array(); $navlinks[] = array('name' => $emailconfirm, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header($emailconfirm, $emailconfirm, $navigation); notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php"); } else { return true; } }
function exercise_add_instance($exercise) { // Given an object containing all the necessary data, // (defined by the form in mod.html) this function // will create a new instance and return the id number // of the new instance. $exercise->timemodified = time(); // encode password if necessary if (!empty($exercise->password)) { $exercise->password = md5($exercise->password); } else { unset($exercise->password); } if ($returnid = insert_record("exercise", $exercise)) { $event = NULL; $event->name = $exercise->name; $event->description = $exercise->description; $event->courseid = $exercise->course; $event->groupid = 0; $event->userid = 0; $event->modulename = 'exercise'; $event->instance = $returnid; $event->eventtype = 'deadline'; $event->timestart = $exercise->deadline; $event->timeduration = 0; add_event($event); } return $returnid; }
/** * TODO comment this */ function process_data($data) { global $CFG, $USER; foreach ($data->unit as $idx => $v) { $qual = get_record('ilp_qual_units', 'UniqueReferenceNumber', $idx, 'courseid', $data->course_id); if (empty($qual)) { $course = get_record('course', 'id', $data->course_id); $qualificationunits = $this->db->return_table_values('ofqual_qualification_units', array('UniqueReferenceNumber' => array('=' => "'{$idx}'"), 'qualificationid' => array('=' => "'{$course->idnumber}'"))); if (!empty($qualificationunits)) { $qual = new stdClass(); $q = $qualificationunits[0]; $qual->courseid = $data->course_id; //$qual->academic_year = $q['academic_year']; $qual->qualificationid = $q['QualificationID']; $qual->UniqueReferenceNumber = $q['UniqueReferenceNumber']; $qual->title = $q['Title']; $qual->unitownerreference = $q['UnitOwnerReference']; $qual->selected = !empty($v) ? 1 : 0; $qual->title = mysql_real_escape_string($qual->title); $qual->title = str_replace("'", "", $qual->title); insert_record('ilp_qual_units', $qual); } } else { $qual->title = mysql_real_escape_string($qual->title); $qual->title = str_replace("'", "", $qual->title); $qual->selected = !empty($v) ? 1 : 0; update_record('ilp_qual_units', $qual); } } }
public static function notify_user($user, $data) { $toinsert = new StdClass(); $toinsert->type = $data->type; $toinsert->usr = $user->id; if (!empty($user->markasread)) { $toinsert->read = 1; } else { $toinsert->read = 0; } $toinsert->message = $data->message; $toinsert->subject = $data->subject; $toinsert->parent = $data->parent; $toinsert->ctime = db_format_timestamp(time()); if (!empty($data->url)) { $toinsert->url = $data->url; } if (!empty($data->urltext)) { $toinsert->urltext = $data->urltext; } if (!empty($data->fromuser)) { $toinsert->from = $data->fromuser; } return insert_record('notification_internal_activity', $toinsert, 'id', true); }
/** * Checks to see if user has visited blogpages before, if not, install 2 * default blocks (blog_menu and blog_tags). */ function blog_check_and_install_blocks() { global $USER; if (isloggedin() && !isguest()) { // if this user has not visited this page before if (!get_user_preferences('blogpagesize')) { // find the correct ids for blog_menu and blog_from blocks $menublock = get_record('block', 'name', 'blog_menu'); $tagsblock = get_record('block', 'name', 'blog_tags'); // add those 2 into block_instance page // add blog_menu block $newblock = new object(); $newblock->blockid = $menublock->id; $newblock->pageid = $USER->id; $newblock->pagetype = 'blog-view'; $newblock->position = 'r'; $newblock->weight = 0; $newblock->visible = 1; insert_record('block_instance', $newblock); // add blog_tags menu $newblock->blockid = $tagsblock->id; $newblock->weight = 1; insert_record('block_instance', $newblock); // finally we set the page size pref set_user_preference('blogpagesize', 10); } } }
/** * Given an object containing all the necessary data, * (defined by the form in mod.html) this function * will create a new instance and return the id number * of the new instance. * * @param object $instance An object from the form in mod.html * @return int The id of the newly inserted newmodule record **/ function mindmap_add_instance($mindmap) { global $USER; $mindmap->xmldata = '<MindMap> <MM> <Node x_Coord="400" y_Coord="270"> <Text>Moodle</Text> <Format Underlined="0" Italic="0" Bold="0"> <Font>Trebuchet MS</Font> <FontSize>14</FontSize> <FontColor>ffffff</FontColor> <BackgrColor>ff0000</BackgrColor> </Format> </Node> </MM> </MindMap>'; $mindmap->userid = $USER->id; if (isset($mindmap->editable)) { $mindmap->editable = '1'; } else { $mindmap->editable = '0'; } $mindmap->timecreated = time(); return insert_record("mindmap", $mindmap); }
function label_restore_mods($mod, $restore) { global $CFG; $status = true; //Get record from backup_ids $data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id); if ($data) { //Now get completed xmlized object $info = $data->info; //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug //Now, build the LABEL record structure $label->course = $restore->course_id; $label->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); $label->content = backup_todb($info['MOD']['#']['CONTENT']['0']['#']); $label->timemodified = $info['MOD']['#']['TIMEMODIFIED']['0']['#']; //The structure is equal to the db, so insert the label $newid = insert_record("label", $label); //Do some output if (!defined('RESTORE_SILENTLY')) { echo "<li>" . get_string("modulename", "label") . " \"" . format_string(stripslashes($label->name), true) . "\"</li>"; } backup_flush(300); if ($newid) { //We have the newid, update backup_ids backup_putid($restore->backup_unique_code, $mod->modtype, $mod->id, $newid); } else { $status = false; } } else { $status = false; } return $status; }
function xmldb_block_graph_stats_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2006051300) { $graphwidth->name = 'block_graph_stats_graphwidth'; $graphwidth->value = 180; insert_record('config', $graphwidth); $graphheight->name = 'block_graph_stats_graphheight'; $graphheight->value = 150; insert_record('config', $graphheight); $daysnb->name = 'block_graph_stats_daysnb'; $daysnb->value = 30; insert_record('config', $daysnb); $result = true; } if ($result && $oldversion < 2007082200) { $color1->name = 'block_graph_stats_color1'; $color1->value = 'blue'; insert_record('config', $color1); $color2->name = 'block_graph_stats_color2'; $color2->value = 'green'; insert_record('config', $color2); $multi->name = 'block_graph_stats_multi'; $multi->value = 1; insert_record('config', $multi); $result = true; } return $result; }
function game_importsnakes_do($newrec) { if (!insert_record('game_snakes_database', $newrec)) { print_object($newrec); error("Can't insert to table game_snakes_database"); } }
function update_instance($bookings) { /// set up a new item with properties for this appointment unset($prop); $book = get_record('bookings', 'id', $bookings->instance); $itemid = $book->itemid; $prop->itemid = $itemid; delete_records('bookings_item_property', 'itemid', $itemid); $prop->name = 'days'; $prop->value = $bookings->colnames; insert_record('bookings_item_property', $prop); $prop->name = 'slots'; $prop->value = $bookings->rownames; insert_record('bookings_item_property', $prop); $prop->name = 'multiple'; $prop->value = $bookings->multiple; insert_record('bookings_item_property', $prop); $prop->name = 'exclusive'; $prop->value = $bookings->exclusive; insert_record('bookings_item_property', $prop); $prop->name = 'edit_group'; $prop->value = $bookings->editgroup; insert_record('bookings_item_property', $prop); $p = parent::update_instance($bookings); return $p; }
function textanalysis_add_instance($textanalysis) { global $CFG, $USER; $id = $textanalysis->courseid; $textanalysis->timemodified = time(); return insert_record("textanalysis", $textanalysis); }
/** * refreshes the tree data if new responses where in in the meanwhile * */ function hierarchize_refresh_tree($brainstormid, $groupid = 0) { global $CFG, $USER; // get those responses who are new $sql = "\r\n SELECT\r\n r.id,r.id\r\n FROM\r\n {$CFG->prefix}brainstorm_responses as r\r\n WHERE\r\n r.brainstormid = {$brainstormid} AND\r\n r.groupid = {$groupid} AND\r\n r.id NOT IN\r\n (SELECT\r\n od.itemsource\r\n FROM\r\n {$CFG->prefix}brainstorm_operatordata as od\r\n WHERE\r\n od.brainstormid = {$brainstormid} AND\r\n operatorid = 'hierarchize' AND\r\n od.groupid = {$groupid} AND\r\n od.userid = {$USER->id})\r\n "; // echo $sql; $diff = get_records_sql($sql); $maxordering = brainstorm_tree_get_max_ordering($brainstormid, null, $groupid, 1, 0); if ($diff) { $treerecord->brainstormid = $brainstormid; $treerecord->userid = $USER->id; $treerecord->groupid = $groupid; $treerecord->operatorid = 'hierarchize'; $treerecord->itemdest = 0; $treerecord->intvalue = $maxordering + 1; $treerecord->timemodified = time(); foreach ($diff as $adif) { $treerecord->itemsource = $adif->id; if (!insert_record('brainstorm_operatordata', $treerecord)) { error("Could not insert tree regeneration records"); } $treerecord->intvalue++; } } }