本文整理汇总了PHP中upgrade_mod_savepoint函数的典型用法代码示例。如果您正苦于以下问题:PHP upgrade_mod_savepoint函数的具体用法?PHP upgrade_mod_savepoint怎么用?PHP upgrade_mod_savepoint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了upgrade_mod_savepoint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_lti_upgrade
/**
* xmldb_lti_upgrade is the function that upgrades
* the lti module database when is needed
*
* This function is automaticly called when version number in
* version.php changes.
*
* @param int $oldversion New old version number.
*
* @return boolean
*/
function xmldb_lti_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.4.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.5.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.6.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.7.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2014060201) {
// Changing type of field grade on table lti to int.
$table = new xmldb_table('lti');
$field = new xmldb_field('grade', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '100', 'instructorchoiceacceptgrades');
// Launch change of type for field grade.
$dbman->change_field_type($table, $field);
// Lti savepoint reached.
upgrade_mod_savepoint(true, 2014060201, 'lti');
}
return true;
}
示例2: xmldb_scormcloud_upgrade
/**
* xmldb_scormcloud_upgrade
*
* @param int $oldversion
* @return bool
*/
function xmldb_scormcloud_upgrade($oldversion)
{
global $DB;
global $CFG;
$dbman = $DB->get_manager();
$module = new stdClass();
require $CFG->dirroot . '/mod/scormcloud/version.php';
$result = true;
if ($result && $oldversion < 2011100700) {
$table = new xmldb_table('scormcloud');
$field = new xmldb_field('cloudid', XMLDB_TYPE_CHAR, '255', null, 'XMLDB_NULL', null, null, 'id');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$rs = $DB->get_recordset('scormcloud');
foreach ($rs as $record) {
if (!isset($record->cloudid) || empty($record->cloudid)) {
$record->cloudid = $record->id;
$DB->update_record('scormcloud', $record, true);
}
}
$rs->close();
$field->setNotNull();
$dbman->change_field_notnull($table, $field);
}
upgrade_mod_savepoint($result, $module->version, 'scormcloud');
return $result;
}
示例3: xmldb_trainingevent_upgrade
function xmldb_trainingevent_upgrade($oldversion)
{
global $CFG, $DB;
$result = true;
$dbman = $DB->get_manager();
if ($oldversion < 2011111701) {
// Define table trainingevent_users to be created.
$table = new xmldb_table('trainingevent_users');
// Adding fields to table trainingevent_users.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('trainingeventid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, null);
// Adding keys to table trainingevent_users.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
// Conditionally launch create table for trainingevent_users.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Label savepoint reached.
upgrade_mod_savepoint(true, 2011111701, 'trainingevent');
}
if ($oldversion < 2014012301) {
// Define field approvaltype to be added to trainingevent.
$table = new xmldb_table('trainingevent');
$field = new xmldb_field('approvaltype', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'classroomid');
// Conditionally launch add field approvaltype.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Trainingevent savepoint reached.
upgrade_mod_savepoint(true, 2014012301, 'trainingevent');
}
return $result;
}
示例4: xmldb_survey_upgrade
function xmldb_survey_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
//===== 1.9.0 upgrade line ======//
if ($oldversion < 2009042002) {
/// Define field introformat to be added to survey
$table = new xmldb_table('survey');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
/// Conditionally launch add field introformat
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// conditionally migrate to html format in intro
if ($CFG->texteditors !== 'textarea') {
$rs = $DB->get_recordset('survey', array('introformat' => FORMAT_MOODLE), '', 'id,intro,introformat');
foreach ($rs as $s) {
$s->intro = text_to_html($s->intro, false, false, true);
$s->introformat = FORMAT_HTML;
$DB->update_record('survey', $s);
upgrade_set_timeout();
}
$rs->close();
}
/// survey savepoint reached
upgrade_mod_savepoint(true, 2009042002, 'survey');
}
return true;
}
示例5: xmldb_choice_upgrade
function xmldb_choice_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.4.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.5.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.6.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.7.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2014051201) {
// Define field allowmultiple to be added to choice.
$table = new xmldb_table('choice');
$field = new xmldb_field('allowmultiple', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'allowupdate');
// Conditionally launch add field allowmultiple.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Choice savepoint reached.
upgrade_mod_savepoint(true, 2014051201, 'choice');
}
// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.
return true;
}
示例6: xmldb_workshop_upgrade
/**
* Performs upgrade of the database structure and data
*
* Workshop supports upgrades from version 1.9.0 and higher only. During 1.9 > 2.0 upgrade,
* there are significant database changes.
*
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_workshop_upgrade($oldversion)
{
global $CFG, $DB;
// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
$dbman = $DB->get_manager();
if ($oldversion < 2016022200) {
// Add field submissionfiletypes to the table workshop.
$table = new xmldb_table('workshop');
$field = new xmldb_field('submissionfiletypes', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'nattachments');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Add field overallfeedbackfiletypes to the table workshop.
$field = new xmldb_field('overallfeedbackfiletypes', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'overallfeedbackfiles');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2016022200, 'workshop');
}
// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
return true;
}
示例7: xmldb_choicegroup_upgrade
function xmldb_choicegroup_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
if ($oldversion < 2013070900) {
if ($oldversion < 2012042500) {
/// remove the no longer needed choicegroup_answers DB table
$choicegroup_answers = new xmldb_table('choicegroup_answers');
$dbman->drop_table($choicegroup_answers);
/// change the choicegroup_options.text (text) field as choicegroup_options.groupid (int)
$choicegroup_options = new xmldb_table('choicegroup_options');
$field_text = new xmldb_field('text', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'choicegroupid');
$field_groupid = new xmldb_field('groupid', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'choicegroupid');
$dbman->rename_field($choicegroup_options, $field_text, 'groupid');
$dbman->change_field_type($choicegroup_options, $field_groupid);
}
// Define table choicegroup to be created
$table = new xmldb_table('choicegroup');
// Adding fields to table choicegroup
$newField = $table->add_field('multipleenrollmentspossible', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
$dbman->add_field($table, $newField);
upgrade_mod_savepoint(true, 2013070900, 'choicegroup');
}
if ($oldversion < 2015022301) {
$table = new xmldb_table('choicegroup');
// Adding field to table choicegroup
$newField = $table->add_field('sortgroupsby', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
if (!$dbman->field_exists($table, $newField)) {
$dbman->add_field($table, $newField);
}
upgrade_mod_savepoint(true, 2015022301, 'choicegroup');
}
return true;
}
示例8: xmldb_survey_upgrade
function xmldb_survey_upgrade($oldversion)
{
global $DB;
$dbman = $DB->get_manager();
// Loads ddl manager and xmldb classes.
// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2016061400) {
// Define field completionsubmit to be added to survey.
$table = new xmldb_table('survey');
$field = new xmldb_field('completionsubmit', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'questions');
// Conditionally launch add field completionsubmit.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Survey savepoint reached.
upgrade_mod_savepoint(true, 2016061400, 'survey');
}
return true;
}
示例9: xmldb_label_upgrade
function xmldb_label_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
//===== 1.9.0 upgrade line ======//
if ($oldversion < 2007101510) {
$sql = "UPDATE {log_display} SET mtable = 'label' WHERE module = 'label'";
$result = $DB->execute($sql);
upgrade_mod_savepoint($result, 2007101510, 'label');
}
if ($result && $oldversion < 2009042200) {
/// Rename field content on table label to intro
$table = new xmldb_table('label');
$field = new xmldb_field('content', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name');
/// Launch rename field content
$dbman->rename_field($table, $field, 'intro');
/// label savepoint reached
upgrade_mod_savepoint($result, 2009042200, 'label');
}
if ($result && $oldversion < 2009042201) {
/// Define field introformat to be added to label
$table = new xmldb_table('label');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, '4', 'intro');
/// Launch add field introformat
$dbman->add_field($table, $field);
/// label savepoint reached
upgrade_mod_savepoint($result, 2009042201, 'label');
}
return $result;
}
示例10: xmldb_label_upgrade
function xmldb_label_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
//===== 1.9.0 upgrade line ======//
if ($oldversion < 2009042200) {
/// Rename field content on table label to intro
$table = new xmldb_table('label');
$field = new xmldb_field('content', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name');
/// Launch rename field content
$dbman->rename_field($table, $field, 'intro');
/// label savepoint reached
upgrade_mod_savepoint(true, 2009042200, 'label');
}
if ($oldversion < 2009042201) {
/// Define field introformat to be added to label
$table = new xmldb_table('label');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, '0', 'intro');
/// Launch add field introformat
$dbman->add_field($table, $field);
// all existing lables in 1.9 are in HTML format
$DB->set_field('label', 'introformat', FORMAT_HTML, array());
/// label savepoint reached
upgrade_mod_savepoint(true, 2009042201, 'label');
}
// Moodle v2.1.0 release upgrade line
// Put any upgrade step following this
return true;
}
示例11: xmldb_glossary_upgrade
function xmldb_glossary_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2015060200) {
// Define field showtabs to be added to glossary_formats.
$table = new xmldb_table('glossary_formats');
$field = new xmldb_field('showtabs', XMLDB_TYPE_CHAR, '100', null, null, null, null, 'showgroup');
// Conditionally launch add field showtabs.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Glossary savepoint reached.
upgrade_mod_savepoint(true, 2015060200, 'glossary');
}
// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
return true;
}
示例12: xmldb_assignment_upgrade
function xmldb_assignment_upgrade($oldversion) {
global $CFG, $DB, $OUTPUT;
$dbman = $DB->get_manager();
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this
if ($oldversion < 2012061701) {
// Fixed/updated numfiles field in assignment_submissions table to count the actual
// number of files has been uploaded when sendformarking is disabled
upgrade_set_timeout(600); // increase excution time for in large sites
$fs = get_file_storage();
// Fetch the moduleid for use in the course_modules table
$moduleid = $DB->get_field('modules', 'id', array('name' => 'assignment'), MUST_EXIST);
$selectcount = 'SELECT COUNT(s.id) ';
$select = 'SELECT s.id, cm.id AS cmid ';
$query = 'FROM {assignment_submissions} s
JOIN {assignment} a ON a.id = s.assignment
JOIN {course_modules} cm ON a.id = cm.instance AND cm.module = :moduleid
WHERE assignmenttype = :assignmenttype';
$params = array('moduleid' => $moduleid, 'assignmenttype' => 'upload');
$countsubmissions = $DB->count_records_sql($selectcount.$query, $params);
$submissions = $DB->get_recordset_sql($select.$query, $params);
$pbar = new progress_bar('assignmentupgradenumfiles', 500, true);
$i = 0;
foreach ($submissions as $sub) {
$i++;
if ($context = context_module::instance($sub->cmid)) {
$sub->numfiles = count($fs->get_area_files($context->id, 'mod_assignment', 'submission', $sub->id, 'sortorder', false));
$DB->update_record('assignment_submissions', $sub);
}
$pbar->update($i, $countsubmissions, "Counting files of submissions ($i/$countsubmissions)");
}
$submissions->close();
// assignment savepoint reached
upgrade_mod_savepoint(true, 2012061701, 'assignment');
}
// Moodle v2.4.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.5.0 release upgrade line.
// Put any upgrade step following this.
return true;
}
示例13: xmldb_mediaboard_upgrade
function xmldb_mediaboard_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB;
$result = true;
$dbman = $DB->get_manager();
if ($oldversion < 2015030200) {
// Define table assign_user_mapping to be created.
$table = new xmldb_table('mediaboard_likes');
// Adding fields to table assign_user_mapping.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('instance', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('fileid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('time', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
// Adding keys to table assign_user_mapping.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('user', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
// Conditionally launch create table for assign_user_mapping.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Assign savepoint reached.
upgrade_mod_savepoint(true, 2015030200, 'mediaboard');
}
return $result;
}
示例14: xmldb_recordingsbn_upgrade
/**
* Execute recordingsbn upgrade from the given old version
*
* @param int $oldversion
* @return bool
*/
function xmldb_recordingsbn_upgrade($oldversion)
{
global $DB;
$dbman = $DB->get_manager();
// loads ddl manager and xmldb classes
if ($oldversion < 2012040200) {
// Define field intro to be droped from recordingsbn
$table = new xmldb_table('recordingsbn');
$field = new xmldb_field('intro', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'name');
// Drop field intro
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field, $continue = true, $feedback = true);
}
// Define field introformat to be droped from recordingsbn
$table = new xmldb_table('recordingsbn');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
// Add field introformat
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field, $continue = true, $feedback = true);
}
// Once we reach this point, we can store the new version and consider the module
// upgraded to the version 2012040200 so the next time this block is skipped
upgrade_mod_savepoint(true, 2012040200, 'recordingsbn');
}
// Final return of upgrade result (true, all went good) to Moodle.
return true;
}
示例15: xmldb_glossary_upgrade
function xmldb_glossary_upgrade($oldversion)
{
global $CFG, $DB, $OUTPUT;
$dbman = $DB->get_manager();
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
if ($oldversion < 2012022000) {
// Define field approvaldisplayformat to be added to glossary
$table = new xmldb_table('glossary');
$field = new xmldb_field('approvaldisplayformat', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, 'default', 'defaultapproval');
// Conditionally launch add field approvaldisplayformat
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// glossary savepoint reached
upgrade_mod_savepoint(true, 2012022000, 'glossary');
}
// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.4.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.5.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.6.0 release upgrade line.
// Put any upgrade step following this.
return true;
}