本文整理汇总了PHP中change_field_precision函数的典型用法代码示例。如果您正苦于以下问题:PHP change_field_precision函数的具体用法?PHP change_field_precision怎么用?PHP change_field_precision使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了change_field_precision函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_chat_upgrade
function xmldb_chat_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2007012100) {
/// Changing precision of field lang on table chat_users to (30)
$table = new XMLDBTable('chat_users');
$field = new XMLDBField('lang');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, null, 'course');
/// Launch change of precision for field lang
$result = $result && change_field_precision($table, $field);
}
return $result;
}
示例2: xmldb_resource_upgrade
function xmldb_resource_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
/// And upgrade begins here. For each one, you'll need one
/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
/// $result = result of "/lib/ddllib.php" function calls
/// }
if ($result && $oldversion < 2007011700) {
//move format from options to reference field because it was colliding with course blocks setting
execute_sql("UPDATE {$CFG->prefix}resource SET reference=options WHERE type='text' AND reference='' AND options!='showblocks'");
//ignore result
}
if ($result && $oldversion < 2007012000) {
/// Changing nullability of field summary on table resource to null
$table = new XMLDBTable('resource');
$field = new XMLDBField('summary');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'reference');
/// Launch change of nullability for field summary
$result = $result && change_field_notnull($table, $field);
}
if ($result && $oldversion < 2007012001) {
if ($CFG->dbfamily == 'mysql') {
// Only needed under mysql. The rest are long texts since ages
/// Changing precision of field alltext on table resource to (medium)
$table = new XMLDBTable('resource');
$field = new XMLDBField('alltext');
$field->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null, 'summary');
/// Launch change of precision for field alltext
$result = $result && change_field_precision($table, $field);
}
}
//Set 'Show navigation' setting to "Yes, without frame" for PDF file resources
//Explanation: due to MDL-20320 bug, PDF can now be displayed as 'No', 'Yes, with frame' and 'Yes, without frame'.
//The default being 'no', PDF resources on previous installations need to be set back to 'Yes, without frame'
if ($result && $oldversion < 2007101510) {
$sql = "UPDATE {$CFG->prefix}resource SET options = 'objectframe' WHERE (UPPER(reference) LIKE '%.PDF'\n OR UPPER(reference) LIKE '%.FDF'\n OR UPPER(reference) LIKE '%.XDP'\n OR UPPER(reference) LIKE '%.XFD'\n OR UPPER(reference) LIKE '%.XFDF')\n AND type='file' AND " . sql_isempty('resource', 'popup', false, true) . "\n AND (" . sql_isempty('resource', 'options', false, false) . " OR options = 'frame')";
$result = $result && execute_sql($sql);
}
// MDL-10906. Removing resource_allowlocalfiles setting.
if ($result && $oldversion < 2007101511) {
$result = $result && unset_config('resource_allowlocalfiles');
}
//===== 1.9.0 upgrade line ======//
return $result;
}
示例3: xmldb_quiz_upgrade
function xmldb_quiz_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
/// And upgrade begins here. For each one, you'll need one
/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
if ($result && $oldversion < 2007022800) {
/// Ensure that there are not existing duplicate entries in the database.
$duplicateunits = get_records_select('question_numerical_units', "id > (SELECT MIN(iqnu.id)\n FROM {$CFG->prefix}question_numerical_units iqnu\n WHERE iqnu.question = {$CFG->prefix}question_numerical_units.question AND\n iqnu.unit = {$CFG->prefix}question_numerical_units.unit)", '', 'id');
if ($duplicateunits) {
delete_records_select('question_numerical_units', 'id IN (' . implode(',', array_keys($duplicateunits)) . ')');
}
/// Define index question-unit (unique) to be added to question_numerical_units
$table = new XMLDBTable('question_numerical_units');
$index = new XMLDBIndex('question-unit');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('question', 'unit'));
/// Launch add index question-unit
$result = $result && add_index($table, $index);
}
if ($result && $oldversion < 2007070200) {
/// Changing precision of field timelimit on table quiz to (10)
$table = new XMLDBTable('quiz');
$field = new XMLDBField('timelimit');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timemodified');
/// Launch change of precision for field timelimit
$result = $result && change_field_precision($table, $field);
}
if ($result && $oldversion < 2007072200) {
require_once $CFG->dirroot . '/mod/quiz/lib.php';
// too much debug output
$db->debug = false;
quiz_update_grades();
$db->debug = true;
}
// Separate control for when overall feedback is displayed, independant of the question feedback settings.
if ($result && $oldversion < 2007072600) {
// Adjust the quiz review options so that overall feedback is displayed whenever feedback is.
$result = $result && execute_sql('UPDATE ' . $CFG->prefix . 'quiz SET review = ' . sql_bitor(sql_bitand('review', sql_bitnot(QUIZ_REVIEW_OVERALLFEEDBACK)), sql_bitor(sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY) . ' * 65536', sql_bitor(sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN) . ' * 16384', sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED) . ' * 4096'))));
// Same adjustment to the defaults for new quizzes.
$result = $result && set_config('quiz_review', $CFG->quiz_review & ~QUIZ_REVIEW_OVERALLFEEDBACK | ($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY) << 16 | ($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN) << 14 | ($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED) << 12);
}
//===== 1.9.0 upgrade line ======//
return $result;
}
示例4: xmldb_blocktype_externalfeed_upgrade
function xmldb_blocktype_externalfeed_upgrade($oldversion = 0)
{
if ($oldversion < 2008042100) {
// Add the 'image' column so that information about a feed's image can
// be stored
$table = new XMLDBTable('blocktype_externalfeed_data');
$field = new XMLDBField('image');
$field->setAttributes(XMLDB_TYPE_TEXT);
add_field($table, $field);
}
if ($oldversion < 2008042101) {
// We hit the 255 character limit for feed URLs
if (is_postgres()) {
execute_sql('ALTER TABLE {blocktype_externalfeed_data} ALTER COLUMN url TYPE TEXT');
} else {
if (is_mysql()) {
// If 2 URLs > 255 chars have the same first 255 characters then mahara will error - this is a MySQL issue though, their unique key length limit is to blame
execute_sql('ALTER TABLE {blocktype_externalfeed_data} DROP KEY {blocextedata_url_uix}');
// We have to remove then add the constraint again else the change will make MySQL cry
execute_sql('ALTER TABLE {blocktype_externalfeed_data} MODIFY COLUMN "url" text');
execute_sql('ALTER TABLE {blocktype_externalfeed_data} add unique {blocextedata_url_uix} (url(255))');
}
}
}
if ($oldversion < 2009121600) {
if (is_mysql()) {
// Make content column wider (TEXT is only 65kb in mysql)
$table = new XMLDBTable('blocktype_externalfeed_data');
$field = new XMLDBField('content');
$field->setAttributes(XMLDB_TYPE_TEXT, "big", null, null);
change_field_precision($table, $field);
}
}
if ($oldversion < 2010073000) {
execute_sql('
UPDATE {blocktype_cron}
SET minute = ?
WHERE minute = ? AND hour = ? AND plugin = ? AND callfunction = ?', array('30', '0', '3', 'externalfeed', 'cleanup_feeds'));
}
return true;
}
示例5: xmldb_resource_upgrade
function xmldb_resource_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
/// And upgrade begins here. For each one, you'll need one
/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
/// $result = result of "/lib/ddllib.php" function calls
/// }
if ($result && $oldversion < 2007011700) {
//move format from options to reference field because it was colliding with course blocks setting
execute_sql("UPDATE {$CFG->prefix}resource SET reference=options WHERE type='text' AND reference='' AND options!='showblocks'");
//ignore result
}
if ($result && $oldversion < 2007012000) {
/// Changing nullability of field summary on table resource to null
$table = new XMLDBTable('resource');
$field = new XMLDBField('summary');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'reference');
/// Launch change of nullability for field summary
$result = $result && change_field_notnull($table, $field);
}
if ($result && $oldversion < 2007012001) {
if ($CFG->dbfamily == 'mysql') {
// Only needed under mysql. The rest are long texts since ages
/// Changing precision of field alltext on table resource to (medium)
$table = new XMLDBTable('resource');
$field = new XMLDBField('alltext');
$field->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null, 'summary');
/// Launch change of precision for field alltext
$result = $result && change_field_precision($table, $field);
}
}
//===== 1.9.0 upgrade line ======//
return $result;
}
示例6: xmldb_local_upgrade
/**
* ELIS(TM): Enterprise Learning Intelligence Suite
* Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package elis
* @subpackage curriculummanagement
* @author Remote-Learner.net Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
*
*/
function xmldb_local_upgrade($oldversion)
{
global $CFG, $db;
$result = true;
if ($result && $oldversion < 2010110800) {
$table = new XMLDBTable('user_info_data');
$index = new XMLDBIndex('useridx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
$result = $result && add_index($table, $index);
$index = new XMLDBIndex('fieldidx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('fieldid'));
$result = $result && add_index($table, $index);
}
if ($result && $oldversion < 2011033100) {
// Changing size of field 'name' on 'user_preferences' from 50 to 255
$table = new XMLDBTable('user_preferences');
$field = new XMLDBField('name');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'userid');
// Launch change of precision for field name
$result = $result && change_field_precision($table, $field);
}
return $result;
}
示例7: xmldb_group_upgrade
function xmldb_group_upgrade($oldversion = 0)
{
global $CFG;
$result = true;
if ($result && $oldversion < 2007012000) {
/// Changing nullability of field description on table groups to null
$table = new XMLDBTable('groups');
$field = new XMLDBField('description');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'name');
/// Launch change of nullability for field description
$result = $result && change_field_notnull($table, $field);
/// Changing nullability of field description on table groups_groupings to null
$table = new XMLDBTable('groups_groupings');
$field = new XMLDBField('description');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'name');
/// Launch change of nullability for field description
$result = $result && change_field_notnull($table, $field);
}
if ($result && $oldversion < 2007012100) {
/// Changing precision of field lang on table groups to (30)
$table = new XMLDBTable('groups');
$field = new XMLDBField('lang');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, 'en', 'enrolmentkey');
/// Launch change of precision for field lang
$result = $result && change_field_precision($table, $field);
}
/// Adding all the missing FK + Unique indexes (XMLDB will create the underlying indexes)
if ($result && $oldversion < 2007012200) {
/// Define index groupid-courseid (unique) to be added to groups_members
$table = new XMLDBTable('groups_members');
$index = new XMLDBIndex('groupid-courseid');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('groupid', 'userid'));
/// Launch add index groupid-courseid
$result = $result && add_index($table, $index);
/// Define key courseid (foreign) to be added to groups_courses_groups
$table = new XMLDBTable('groups_courses_groups');
$key = new XMLDBKey('courseid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
/// Launch add key courseid
$result = $result && add_key($table, $key);
/// Define key groupid (foreign) to be added to groups_courses_groups
$table = new XMLDBTable('groups_courses_groups');
$key = new XMLDBKey('groupid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
/// Launch add key groupid
$result = $result && add_key($table, $key);
/// Define index courseid-groupid (unique) to be added to groups_courses_groups
$table = new XMLDBTable('groups_courses_groups');
$index = new XMLDBIndex('courseid-groupid');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('courseid', 'groupid'));
/// Launch add index courseid-groupid
$result = $result && add_index($table, $index);
/// Define key courseid (foreign) to be added to groups_courses_groupings
$table = new XMLDBTable('groups_courses_groupings');
$key = new XMLDBKey('courseid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
/// Launch add key courseid
$result = $result && add_key($table, $key);
/// Define key groupingid (foreign) to be added to groups_courses_groupings
$table = new XMLDBTable('groups_courses_groupings');
$key = new XMLDBKey('groupingid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
/// Launch add key groupingid
$result = $result && add_key($table, $key);
/// Define index courseid-groupingid (unique) to be added to groups_courses_groupings
$table = new XMLDBTable('groups_courses_groupings');
$index = new XMLDBIndex('courseid-groupingid');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('courseid', 'groupingid'));
/// Launch add index courseid-groupingid
$result = $result && add_index($table, $index);
/// Define key groupingid (foreign) to be added to groups_groupings_groups
$table = new XMLDBTable('groups_groupings_groups');
$key = new XMLDBKey('groupingid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
/// Launch add key groupingid
$result = $result && add_key($table, $key);
/// Define key groupid (foreign) to be added to groups_groupings_groups
$table = new XMLDBTable('groups_groupings_groups');
$key = new XMLDBKey('groupid');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
/// Launch add key groupid
$result = $result && add_key($table, $key);
/// Define index groupingid-groupid (unique) to be added to groups_groupings_groups
$table = new XMLDBTable('groups_groupings_groups');
$index = new XMLDBIndex('groupingid-groupid');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('groupingid', 'groupid'));
/// Launch add index groupingid-groupid
$result = $result && add_index($table, $index);
}
if ($result && $oldversion < 2007012400) {
if (table_exists(new XMLDBTable('groups_temp')) && file_exists($CFG->dirroot . '/group/db/install.xml')) {
/// Need to drop foreign keys/indexes added in last upgrade, drop 'new' tables, then start again!!
$result = $result && groups_drop_keys_indexes_db();
$result = $result && groups_revert_db($renametemp = false);
$result = $result && install_from_xmldb_file($CFG->dirroot . '/group/db/install.xml');
$result = $result && groups_transfer_db();
}
}
return $result;
}
示例8: xmldb_blocktype_externalfeed_upgrade
function xmldb_blocktype_externalfeed_upgrade($oldversion = 0)
{
if ($oldversion < 2008042101) {
// We hit the 255 character limit for feed URLs
if (is_postgres()) {
execute_sql('ALTER TABLE {blocktype_externalfeed_data} ALTER COLUMN url TYPE TEXT');
} else {
if (is_mysql()) {
// If 2 URLs > 255 chars have the same first 255 characters then mahara will error - this is a MySQL issue though, their unique key length limit is to blame
execute_sql('ALTER TABLE {blocktype_externalfeed_data} DROP KEY {blocextedata_url_uix}');
// We have to remove then add the constraint again else the change will make MySQL cry
execute_sql('ALTER TABLE {blocktype_externalfeed_data} MODIFY COLUMN "url" text');
execute_sql('ALTER TABLE {blocktype_externalfeed_data} add unique {blocextedata_url_uix} (url(255))');
}
}
}
if ($oldversion < 2009121600) {
if (is_mysql()) {
// Make content column wider (TEXT is only 65kb in mysql)
$table = new XMLDBTable('blocktype_externalfeed_data');
$field = new XMLDBField('content');
$field->setAttributes(XMLDB_TYPE_TEXT, "big", null, null);
change_field_precision($table, $field);
}
}
if ($oldversion < 2010073000) {
execute_sql('
UPDATE {blocktype_cron}
SET minute = ?
WHERE minute = ? AND hour = ? AND plugin = ? AND callfunction = ?', array('30', '0', '3', 'externalfeed', 'cleanup_feeds'));
}
if ($oldversion < 2011091400) {
// Add columns for HTTP basic auth
$table = new XMLDBTable('blocktype_externalfeed_data');
$field1 = new XMLDBField('authuser');
$field1->setAttributes(XMLDB_TYPE_TEXT);
$field2 = new XMLDBField('authpassword');
$field2->setAttributes(XMLDB_TYPE_TEXT);
add_field($table, $field1);
add_field($table, $field2);
// Change unique constraint that's no longer valid
$table = new XMLDBTable('blocktype_externalfeed_data');
$index = new XMLDBIndex('url_uix');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('url'));
drop_index($table, $index);
if (is_postgres()) {
$index = new XMLDBIndex('urlautautix');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('url', 'authuser', 'authpassword'));
add_index($table, $index);
} else {
if (is_mysql()) {
// MySQL needs size limits when indexing text fields
execute_sql('ALTER TABLE {blocktype_externalfeed_data} ADD INDEX
{blocextedata_urlautaut_ix} (url(255), authuser(255), authpassword(255))');
}
}
}
if ($oldversion < 2011091401) {
// Add columns for insecure SSL mode
$table = new XMLDBTable('blocktype_externalfeed_data');
$field = new XMLDBField('insecuresslmode');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
}
if ($oldversion < 2012090700) {
// Reset all feeds to reset themselves
set_field('blocktype_externalfeed_data', 'lastupdate', db_format_timestamp('0'));
safe_require('blocktype', 'externalfeed');
call_static_method('PluginBlocktypeExternalfeed', 'refresh_feeds');
}
if ($oldversion < 2014041500) {
log_debug('Cleaning up duplicate feeds in the externalfeed blocktype');
log_debug('1. Find the duplicate feed urls');
// Setting these to be empty strings instead of NULL will make our SQL a lot simpler in the next section
execute_sql("update {blocktype_externalfeed_data} set authuser='' where authuser is null");
execute_sql("update {blocktype_externalfeed_data} set authpassword='' where authpassword is null");
if ($duplicatefeeds = get_records_sql_array("SELECT COUNT(url), url, authuser, authpassword FROM {blocktype_externalfeed_data} GROUP BY url, authuser, authpassword HAVING COUNT(url) > 1 ORDER BY url, authuser, authpassword", array())) {
log_debug('2. Get all feed ids for the duplicated feed urls');
// Use the 1st one found to be the feed id for the block instances that need updating
$feedstoupdate = array();
foreach ($duplicatefeeds as $feed) {
$feedids = get_column('blocktype_externalfeed_data', 'id', 'url', $feed->url, 'authuser', $feed->authuser, 'authpassword', $feed->authpassword);
$feedstoupdate[$feed->url] = $feedids;
}
log_debug('3. Updating blocks to use correct feed id');
// Find the block instances using external feeds. Check to see if they are not using the 'true' id and update them accordingly
require_once get_config('docroot') . 'blocktype/lib.php';
$blockids = get_records_array('block_instance', 'blocktype', 'externalfeed', 'id ASC', 'id');
foreach ($blockids as $blockid) {
$blockinstance = new BlockInstance($blockid->id);
$configdata = $blockinstance->get('configdata');
if (!empty($configdata['feedid'])) {
foreach ($feedstoupdate as $url => $ids) {
foreach ($ids as $key => $id) {
if ($id == $configdata['feedid'] && $key != '0') {
$configdata['feedid'] = $ids[0];
$blockinstance->set('configdata', $configdata);
$blockinstance->set('dirty', true);
$blockinstance->commit();
break;
//.........这里部分代码省略.........
示例9: upgrade_18_letters
/**
* Migrates the grade_letter data to grade_letters
*/
function upgrade_18_letters()
{
global $CFG;
$table = new XMLDBTable('grade_letters');
if (table_exists($table)) {
// already converted or development site
return true;
}
$result = true;
/// Rename field grade_low on table grade_letter to lowerboundary
$table = new XMLDBTable('grade_letter');
$field = new XMLDBField('grade_low');
$field->setAttributes(XMLDB_TYPE_NUMBER, '5, 2', null, XMLDB_NOTNULL, null, null, null, '0.00', 'grade_high');
/// Launch rename field grade_low
$result = $result && rename_field($table, $field, 'lowerboundary');
/// Define field grade_high to be dropped from grade_letter
$table = new XMLDBTable('grade_letter');
$field = new XMLDBField('grade_high');
/// Launch drop field grade_high
$result = $result && drop_field($table, $field);
/// Define index courseid (not unique) to be dropped form grade_letter
$table = new XMLDBTable('grade_letter');
$index = new XMLDBIndex('courseid');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('courseid'));
/// Launch drop index courseid
$result = $result && drop_index($table, $index);
/// Rename field courseid on table grade_letter to contextid
$table = new XMLDBTable('grade_letter');
$field = new XMLDBField('courseid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
/// Launch rename field courseid
$result = $result && rename_field($table, $field, 'contextid');
$sql = "UPDATE {$CFG->prefix}grade_letter\n SET contextid=COALESCE((SELECT c.id\n FROM {$CFG->prefix}context c\n WHERE c.instanceid={$CFG->prefix}grade_letter.contextid AND c.contextlevel=" . CONTEXT_COURSE . "), 0)";
execute_sql($sql);
/// remove broken records
execute_sql("DELETE FROM {$CFG->prefix}grade_letter WHERE contextid=0");
/// Define table grade_letter to be renamed to grade_letters
$table = new XMLDBTable('grade_letter');
/// Launch rename table for grade_letter
$result = $result && rename_table($table, 'grade_letters');
/// Changing type of field lowerboundary on table grade_letters to number
$table = new XMLDBTable('grade_letters');
$field = new XMLDBField('lowerboundary');
$field->setAttributes(XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, null, 'contextid');
/// Launch change of type for field lowerboundary
$result = $result && change_field_precision($table, $field);
$result = $result && change_field_default($table, $field);
/// Changing the default of field letter on table grade_letters to drop it
$table = new XMLDBTable('grade_letters');
$field = new XMLDBField('letter');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'lowerboundary');
/// Launch change of default for field letter
$result = $result && change_field_precision($table, $field);
$result = $result && change_field_default($table, $field);
/// Define index contextidlowerboundary (not unique) to be added to grade_letters
$table = new XMLDBTable('grade_letters');
$index = new XMLDBIndex('contextid-lowerboundary');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
/// Launch add index contextidlowerboundary
$result = $result && add_index($table, $index);
return $result;
}
示例10: xmldb_core_upgrade
//.........这里部分代码省略.........
// Install a cron job to process the queue
$cron = new StdClass();
$cron->callfunction = 'import_process_queue';
$cron->minute = '*/5';
$cron->hour = '*';
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
insert_record('cron', $cron);
}
if ($oldversion < 2008090800) {
$table = new XMLDBTable('artefact_log');
$table->addFieldInfo('artefact', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('usr', XMLDB_TYPE_INTEGER, 10, null, null);
$table->addFieldInfo('time', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('title', XMLDB_TYPE_TEXT, null);
$table->addFieldInfo('description', XMLDB_TYPE_TEXT, null);
$table->addFieldInfo('parent', XMLDB_TYPE_INTEGER, 10, null, null);
$table->addFieldInfo('created', XMLDB_TYPE_INTEGER, 1, null, null);
$table->addFieldInfo('deleted', XMLDB_TYPE_INTEGER, 1, null, null);
$table->addFieldInfo('edited', XMLDB_TYPE_INTEGER, 1, null, null);
$table->addIndexInfo('artefactix', XMLDB_INDEX_NOTUNIQUE, array('artefact'));
$table->addKeyInfo('usrfk', XMLDB_KEY_FOREIGN, array('usr'), 'usr', array('id'));
create_table($table);
}
if ($oldversion < 2008091500) {
// NOTE: Yes, this number is bigger than the number for the next upgrade
// The next upgrade got committed first. It deletes all users properly,
// but the usr table has a 30 character limit on username, which can be
// violated when people with long usernames are deleted
$table = new XMLDBTable('usr');
$field = new XMLDBField('username');
$field->setAttributes(XMLDB_TYPE_CHAR, 100, null, XMLDB_NOTNULL);
change_field_precision($table, $field);
}
if ($oldversion < 2008091200) {
// Some cleanups for deleted users, based on the new model of handling them
if ($userids = get_column('usr', 'id', 'deleted', 1)) {
foreach ($userids as $userid) {
// We want to append 'deleted.timestamp' to some unique fields in the usr
// table, so they can be reused by new accounts
$fieldstomunge = array('username', 'email');
$datasuffix = '.deleted.' . time();
$user = get_record('usr', 'id', $userid, null, null, null, null, implode(', ', $fieldstomunge));
$deleterec = new StdClass();
$deleterec->id = $userid;
$deleterec->deleted = 1;
foreach ($fieldstomunge as $field) {
if (!preg_match('/\\.deleted\\.\\d+$/', $user->{$field})) {
$deleterec->{$field} = $user->{$field} . $datasuffix;
}
}
// Set authinstance to default internal, otherwise the old authinstance can be blocked from deletion
// by deleted users.
$authinst = get_field('auth_instance', 'id', 'institution', 'mahara', 'instancename', 'internal');
if ($authinst) {
$deleterec->authinstance = $deleterec->lastauthinstance = $authinst;
}
update_record('usr', $deleterec);
// Because the user is being deleted, but their email address may be wanted
// for a new user, we change their email addresses to add
// 'deleted.[timestamp]'
execute_sql("UPDATE {artefact_internal_profile_email}\n SET email = email || ?\n WHERE owner = ? AND NOT email LIKE '%.deleted.%'", array($datasuffix, $userid));
// Remove remote user records
delete_records('auth_remote_user', 'localusr', $userid);
}
示例11: xmldb_tracker_upgrade
//.........这里部分代码省略.........
$result = false;
}
$rpc->function_name = 'tracker_rpc_get_instances';
$rpc->xmlrpc_path = 'mod/tracker/rpclib.php/tracker_rpc_get_instances';
$rpc->parent_type = 'mod';
$rpc->parent = 'tracker';
$rpc->enabled = 0;
$rpc->help = 'Get instances of available trackers for cascading.';
$rpc->profile = '';
if (!($rpcid = insert_record('mnet_rpc', $rpc))) {
notify('Error installing tracker_cascade RPC calls.');
$result = false;
}
$rpcmap->serviceid = $serviceid;
$rpcmap->rpcid = $rpcid;
insert_record('mnet_service2rpc', $rpcmap);
$rpc->function_name = 'tracker_rpc_get_infos';
$rpc->xmlrpc_path = 'mod/tracker/rpclib.php/tracker_rpc_get_infos';
$rpc->parent_type = 'mod';
$rpc->parent = 'tracker';
$rpc->enabled = 0;
$rpc->help = 'Get information about one tracker.';
$rpc->profile = '';
if (!($rpcid = insert_record('mnet_rpc', $rpc))) {
notify('Error installing tracker_cascade RPC calls.');
$result = false;
}
$rpcmap->rpcid = $rpcid;
insert_record('mnet_service2rpc', $rpcmap);
$rpc->function_name = 'tracker_rpc_post_issue';
$rpc->xmlrpc_path = 'mod/tracker/rpclib.php/tracker_rpc_post_issue';
$rpc->parent_type = 'mod';
$rpc->parent = 'tracker';
$rpc->enabled = 0;
$rpc->help = 'Cascades an issue.';
$rpc->profile = '';
if (!($rpcid = insert_record('mnet_rpc', $rpc))) {
notify('Error installing tracker_cascade RPC calls.');
$result = false;
}
$rpcmap->rpcid = $rpcid;
insert_record('mnet_service2rpc', $rpcmap);
}
}
if ($result && $oldversion < 2008092602) {
/// Define field supportmode to be added to tracker
$table = new XMLDBTable('tracker');
$field = new XMLDBField('supportmode');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'bugtracker', 'parent');
/// Launch add field supportmode
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2009042500) {
/// Define field supportmode to be added to tracker
$table = new XMLDBTable('tracker_issue');
$field = new XMLDBField('resolutionpriority');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, 0, 'resolutionformat');
/// Launch add field supportmode
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2009042503) {
/// Reassign all priorities
require_once $CFG->dirroot . '/mod/tracker/locallib.php';
$trackers = get_records('tracker');
if ($trackers) {
foreach ($trackers as $tracker) {
$issues = get_records('tracker_issue', 'trackerid', $tracker->id);
if ($issues) {
$priority = 1;
foreach ($issues as $issue) {
// set once at upgrade and never again.
if ($issue->status < RESOLVED) {
$issue->resolutionpriority = $priority;
$priority++;
update_record('tracker_issue', addslashes_recursive($issue));
}
}
}
}
}
/// Add comment enabling to all events
$ccs = get_records('tracker_issuecc');
if ($ccs) {
foreach ($ccs as $cc) {
$cc->events |= ON_COMMENT;
update_record('tracker_issuecc', $cc);
}
}
}
// fix field size for parent encoding in remote cascade. (long wwwroots)
if ($result && $oldversion < 2009090800) {
/// Changing precision of field parent on table tracker to (80)
$table = new XMLDBTable('tracker');
$field = new XMLDBField('parent');
$field->setAttributes(XMLDB_TYPE_CHAR, '80', null, null, null, null, null, null, 'timemodified');
/// Launch change of precision for field parent
$result = $result && change_field_precision($table, $field);
}
return $result;
}
示例12: xmldb_wiki_upgrade
//.........这里部分代码省略.........
$table->addFieldInfo('lockedsince', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, '0', null);
$table->addFieldInfo('lockedseen', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, '0', null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('wiki_locks_uk', XMLDB_KEY_UNIQUE, array('wikiid', 'pagename'));
$table->addIndexInfo('wiki_locks_ix', XMLDB_INDEX_NOTUNIQUE, array('lockedseen'));
$result = $result && create_table($table);
}
// OLD SENTENCE
// modify_database("","
// CREATE TABLE prefix_wiki_locks
// (
// id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
// wikiid INT(10) UNSIGNED NOT NULL,
// pagename VARCHAR(160) NOT NULL DEFAULT '',
// lockedby INT(10) NOT NULL DEFAULT 0,
// lockedsince INT(10) NOT NULL DEFAULT 0,
// lockedseen INT(10) NOT NULL DEFAULT 0,
// PRIMARY KEY(id),
// UNIQUE INDEX wiki_locks_uk(wikiid,pagename),
// INDEX wiki_locks_ix(lockedseen)
// );");
}
if ($result && $oldversion < 2007072301) {
////////////////////////////
// Fixing some old errors //
////////////////////////////
// Old mysql.php created this field as intergers: int(11)
// They must be smallint(3)
//
// I'm going to change defaults too.
$table = new XMLDBTable('wiki');
$field = new XMLDBField('editorrows');
$field->setAttributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '30', null);
$result = change_field_precision($table, $field);
$result = $result && change_field_default($table, $field);
$field = new XMLDBField('editorcols');
$field->setAttributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '120', null);
$result = $result && change_field_precision($table, $field);
$result = $result && change_field_default($table, $field);
// Changing wikicourse to bigint
$field = new XMLDBField('wikicourse');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
if (!field_exists($table, $field)) {
$result = $result && add_field($table, $field);
} else {
$result = $result && change_field_precision($table, $field);
}
// Renaming key 'course'
$key = new XMLDBIndex('course');
$key->setAttributes(XMLDB_INDEX_UNIQUE, array('course'));
$result = $result && drop_index($table, $key);
$key = new XMLDBIndex('wiki_cou_ix');
$key->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
$result = $result && add_index($table, $key);
/*
// Changing some field in wiki_pages
$table = new XMLDBTable('wiki_pages');
$field = new XMLDBField('evaluation');
$field->setAttributes(XMLDB_TYPE_TEXT,'medium' , null, XMLDB_NOTNULL, null, null, null, "", 'ownerid');
$result = $result && change_field_default($table, $field);
$result = $result && change_field_notnull($table, $field);
*/
}
// Add groupid and ownerid fields to the wiki_locks table
if ($result && $oldversion < 2007121701) {
$table = new XMLDBTable('wiki_locks');
示例13: xmldb_geogebra_upgrade
/**
* Execute geogebra upgrade from the given old version
*
* @param int $oldversion
* @return bool
*/
function xmldb_geogebra_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// loads ddl manager and xmldb classes
if ($oldversion < 2012030100) {
//Add grade field
$table = new XMLDBTable('geogebra');
$field = new XMLDBField('grade');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '100', 'showsubmit');
$result = $result && add_field($table, $field);
//Add autograde field
$field = new XMLDBField('autograde');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'grade');
$result = $result && add_field($table, $field);
//Delete maxgrade field
$field = new XMLDBField('maxgrade');
$result = $result && drop_field($table, $field);
//Make maxattempts signed
$field = new XMLDBField('maxattempts');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, null, null, null, '-1', 'autograde');
$result = $result && change_field_unsigned($table, $field);
//Add gradecomment field
$table = new XMLDBTable('geogebra_attempts');
$field = new XMLDBField('gradecomment');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'vars');
$result = $result && add_field($table, $field);
}
if ($oldversion < 2012030101) {
$table = new XMLDBTable('geogebra_attempts');
$field = new XMLDBField('dateteacher');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'finished');
$result = $result && add_field($table, $field);
}
if ($oldversion < 2012082100) {
$table = new XMLDBTable('geogebra');
$field = new XMLDBField('url');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'intro');
$result = $result && change_field_precision($table, $field);
$table = new XMLDBTable('geogebra_attempts');
$field = new XMLDBField('gradecomment');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, false, null, null, null, null, 'vars');
$result = $result && change_field_notnull($table, $field);
$field = new XMLDBField('date');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$result = $result && rename_field($table, $field, 'datestudent');
}
if ($oldversion < 2011122902) {
/// Define field introformat to be added to geogebra
$table = new xmldb_table('geogebra');
$field = new xmldb_field('introformat');
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
/// 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('geogebra', array('introformat' => FORMAT_MOODLE), '', 'id,intro,introformat');
foreach ($rs as $f) {
$f->intro = text_to_html($f->intro, false, false, true);
$f->introformat = FORMAT_HTML;
$DB->update_record('geogebra', $f);
upgrade_set_timeout();
}
$rs->close();
}
/// geogebra savepoint reached
upgrade_mod_savepoint(true, 2011122902, 'geogebra');
}
//===== 1.9.0 upgrade line ======//
if ($oldversion < 2012042700) {
require_once "{$CFG->dirroot}/mod/geogebra/db/upgradelib.php";
// Add upgrading code from 1.9 (+ new file storage system)
// @TODO: test it!!!!
geogebra_migrate_files();
// geogebra savepoint reached
upgrade_mod_savepoint(true, 2012042700, 'geogebra');
}
if ($oldversion < 2013050600) {
// @TODO: test it!!!!
//Add atrributes field
$table = new xmldb_table('geogebra');
$field = new xmldb_field('attributes');
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'url');
$dbman->add_field($table, $field);
$rs = $DB->get_recordset('geogebra');
foreach ($rs as $f) {
parse_str($f->url, $parsedVarsURL);
if (array_key_exists('filename', $parsedVarsURL)) {
// From Moodle 2, URL field only contains information about the GGB file location
$f->url = $parsedVarsURL['filename'];
// Remove filename from parsedVarsURL array (to avoid save twice)
unset($parsedVarsURL['filename']);
//.........这里部分代码省略.........
示例14: xmldb_main_upgrade
//.........这里部分代码省略.........
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('c1', XMLDB_KEY_FOREIGN, array('c1'), 'context', array('id'));
$table->addKeyInfo('c2', XMLDB_KEY_FOREIGN, array('c2'), 'context', array('id'));
$table->addKeyInfo('c1c2', XMLDB_KEY_UNIQUE, array('c1', 'c2'));
/// Launch create table for context_rel
$result = $result && create_table($table);
/// code here to fill the context_rel table
/// use get record set to iterate slower
build_context_rel();
}
if ($result && $oldversion < 2007011501) {
if (!empty($CFG->enablerecordcache) && empty($CFG->rcache) && empty($CFG->cachetype) && empty($CFG->intcachemax)) {
set_config('cachetype', 'internal');
set_config('rcache', true);
set_config('intcachemax', $CFG->enablerecordcache);
unset_config('enablerecordcache');
unset($CFG->enablerecordcache);
}
}
if ($result && $oldversion < 2007012100) {
/// Some old PG servers have user->firstname & user->lastname with 30cc. They must be 100cc.
/// Fixing that conditionally. MDL-7110
if ($CFG->dbfamily == 'postgres') {
/// Get Metadata from user table
$cols = array_change_key_case($db->MetaColumns($CFG->prefix . 'user'), CASE_LOWER);
/// Process user->firstname if needed
if ($col = $cols['firstname']) {
if ($col->max_length < 100) {
/// Changing precision of field firstname on table user to (100)
$table = new XMLDBTable('user');
$field = new XMLDBField('firstname');
$field->setAttributes(XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null, 'idnumber');
/// Launch change of precision for field firstname
$result = $result && change_field_precision($table, $field);
}
}
/// Process user->lastname if needed
if ($col = $cols['lastname']) {
if ($col->max_length < 100) {
/// Changing precision of field lastname on table user to (100)
$table = new XMLDBTable('user');
$field = new XMLDBField('lastname');
$field->setAttributes(XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null, 'firstname');
/// Launch change of precision for field lastname
$result = $result && change_field_precision($table, $field);
}
}
}
}
if ($result && $oldversion < 2007012101) {
/// Changing precision of field lang on table course to (30)
$table = new XMLDBTable('course');
$field = new XMLDBField('lang');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, null, 'groupmodeforce');
/// Launch change of precision for field course->lang
$result = $result && change_field_precision($table, $field);
/// Changing precision of field lang on table user to (30)
$table = new XMLDBTable('user');
$field = new XMLDBField('lang');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, 'en', 'country');
/// Launch change of precision for field user->lang
$result = $result && change_field_precision($table, $field);
}
if ($result && $oldversion < 2007012400) {
/// Rename field access on table mnet_sso_access_control to accessctrl
$table = new XMLDBTable('mnet_sso_access_control');
示例15: xmldb_game_upgrade
//.........这里部分代码省略.........
/// Launch add field format
$result = $result && add_field($table, $field);
}
//game_hangman.finishedword
if ($result && $oldversion < 2007082807) {
$table = new XMLDBTable('game_hangman');
$field = new XMLDBField('finishedword');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'maxtries');
/// Launch add field format
$result = $result && add_field($table, $field);
}
//game_hangman.corrects
if ($result && $oldversion < 2007082807) {
$table = new XMLDBTable('game_hangman');
$field = new XMLDBField('corrects');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'finishedword');
/// Launch add field format
$result = $result && add_field($table, $field);
}
//game.param7
if ($result && $oldversion < 2007082808) {
$table = new XMLDBTable('game');
$field = new XMLDBField('param7');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'param6');
/// Launch add field format
$result = $result && add_field($table, $field);
}
//game_hangman.letters : change to char( 30)
if ($result && $oldversion < 2007082809) {
$table = new XMLDBTable('game_hangman');
$field = new XMLDBField('letters');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, null);
/// Launch change of precision for field lang
$result = $result && change_field_precision($table, $field);
}
//gamg_hangman.glossaryid
if ($result && $oldversion < 2007082901) {
$table = new XMLDBTable('game_hangman');
$field = new XMLDBField('glossaryid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'quizid');
/// Launch add field format
$result = $result && add_field($table, $field);
}
//game_instances.lastip : change to char( 30)
if ($result && $oldversion < 2007083002) {
$table = new XMLDBTable('game_instances');
$field = new XMLDBField('lastip');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, null, '', 'grade');
/// Launch change of precision for field lang
$result = $result && add_field($table, $field);
}
//game_bookquiz_questions.glossarycategoryid
if ($result && $oldversion < 2007091001) {
$table = new XMLDBTable('game_bookquiz_questions');
$field = new XMLDBField('questioncategoryid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0');
/// Launch add field format
$result = $result && add_field($table, $field);
}
//new table game_bookquiz_chapters
if ($result && $oldversion < 2007091701) {
/// Define table scorm_scoes_data to be created
$table = new XMLDBTable('game_bookquiz_chapters');
/// Adding fields to table scorm_scoes_data
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('gameinstanceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');