本文整理汇总了PHP中XMLDBTable::addIndexInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLDBTable::addIndexInfo方法的具体用法?PHP XMLDBTable::addIndexInfo怎么用?PHP XMLDBTable::addIndexInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLDBTable
的用法示例。
在下文中一共展示了XMLDBTable::addIndexInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_blocktype_taggedposts_upgrade
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;
}
示例2: xmldb_format_fn_upgrade
function xmldb_format_fn_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2007060102) {
//New version in version.php
$table = new XMLDBTable('fn_coursemodule_extra');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null, null);
$table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
$table->addFieldInfo('cmid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'courseid');
$table->addFieldInfo('hideingradebook', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'cmid');
$table->addFieldInfo('mandatory', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'hideingradebook');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('courseid', XMLDB_INDEX_NOTUNIQUE, array('courseid'));
$table->addIndexInfo('cmid', XMLDB_INDEX_NOTUNIQUE, array('cmid'));
$result = create_table($table);
}
return $result;
}
示例3: xmldb_auth_oidc_upgrade
/**
* Update plugin.
*
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_oidc_upgrade($oldversion)
{
$result = true;
if ($result && $oldversion < 2009072001) {
// Create the core services tables
$table = new \XMLDBTable('auth_oidc_state');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('sesskey', XMLDB_TYPE_CHAR, 10, null, null);
$table->addFieldInfo('state', XMLDB_TYPE_CHAR, 15, null, null);
$table->addFieldInfo('nonce', XMLDB_TYPE_CHAR, 15, null, null);
$table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, 15, null, null);
$table->addFieldInfo('additionaldata', XMLDB_TYPE_TEXT, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('state', XMLDB_INDEX_NOTUNIQUE, array('state'));
$table->addIndexInfo('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated'));
create_table($table);
}
return $result;
}
示例4: wrsqz_create_program_table
function wrsqz_create_program_table($questionTypeProm)
{
global $CFG;
/// Define table question_wxxxxprom to be created
$promTable = new XMLDBTable('question_' . $questionTypeProm);
/// Adding fields to table question_wxxxxprom
$promTable->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$promTable->addFieldInfo('question', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$promTable->addFieldInfo('program', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
/// Adding keys to table question_wxxxxprom
$promTable->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table question_wxxxxprom
$promTable->addIndexInfo($CFG->prefix . 'ques' . substr($questionTypeProm, 0, 4) . '_que_ix', XMLDB_INDEX_NOTUNIQUE, array('question'));
/// Launch create table
return wrsqz_create_table($promTable);
}
示例5: xmldb_block_php_report_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 php_reports
* @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_block_php_report_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2011040600) {
/// Define table php_report_schedule to be created
$table = new XMLDBTable('php_report_schedule');
/// Adding fields to table php_report_schedule
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('report', XMLDB_TYPE_CHAR, '63', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('config', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table php_report_schedule
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table php_report_schedule
$table->addIndexInfo('report_idx', XMLDB_INDEX_NOTUNIQUE, array('report'));
/// Launch create table for php_report_schedule
$result = $result && create_table($table);
/// Define field userid to be added to php_report_schedule
$table = new XMLDBTable('php_report_schedule');
$field = new XMLDBField('userid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'id');
/// Launch add field userid
$result = $result && add_field($table, $field);
/// Define index userid_idx (not unique) to be added to php_report_schedule
$table = new XMLDBTable('php_report_schedule');
$index = new XMLDBIndex('userid_idx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
/// Launch add index userid_idx
$result = $result && add_index($table, $index);
}
if ($result && $oldversion < 2011042900) {
$query = "name " . sql_ilike() . " 'php_report%'";
$result = $result && delete_records_select('user_preferences', $query);
}
return $result;
}
示例6: xmldb_checklist_upgrade
function xmldb_checklist_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2010022500) {
// Adjust (currently unused) 'teachermark' fields to be 0 when unmarked, not 2
$sql = 'UPDATE ' . $CFG->prefix . 'checklist_check ';
$sql .= 'SET teachermark=0 ';
$sql .= 'WHERE teachermark=2';
$result = execute_sql($sql);
}
if ($result && $oldversion < 2010022800) {
// All checklists created before this point were 'student only' checklists
// Update the default & previously created checklists to reflect this
$sql = 'UPDATE ' . $CFG->prefix . 'checklist ';
$sql .= 'SET teacheredit=0 ';
$sql .= 'WHERE teacheredit=2';
$result = execute_sql($sql);
$table = new XMLDBTable('checklist');
$field = new XMLDBField('teacheredit');
$field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', null);
$result = $result && change_field_type($table, $field);
}
if ($result && $oldversion < 2010031600) {
notify('Processing checklist grades, this may take a while if there are many checklists...', 'notifysuccess');
// too much debug output
$db->debug = false;
checklist_update_all_grades();
$db->debug = true;
}
if ($result && $oldversion < 2010041800) {
$table = new XMLDBTable('checklist_item');
$field = new XMLDBField('duetime');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'itemoptional');
/// Launch add field duetime
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2010041801) {
$table = new XMLDBTable('checklist');
$field = new XMLDBField('duedatesoncalendar');
$field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', 'theme');
/// Launch add field duedatesoncalendar
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2010041900) {
/// Define field eventid to be added to checklist_item
$table = new XMLDBTable('checklist_item');
$field = new XMLDBField('eventid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'duetime');
/// Launch add field eventid
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2010050100) {
/// Define field teachercomments to be added to checklist
$table = new XMLDBTable('checklist');
$field = new XMLDBField('teachercomments');
$field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '1', 'duedatesoncalendar');
/// Launch add field teachercomments
$result = $result && add_field($table, $field);
$table = new XMLDBTable('checklist_comment');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('commentby', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0');
$table->addFieldInfo('text', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, '');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('checklist_item_user', XMLDB_INDEX_UNIQUE, array('itemid', 'userid'));
$result = $result && create_table($table);
}
if ($result && $oldversion < 2010091003) {
$table = new XMLDBTable('checklist_item');
$field = new XMLDBField('colour');
$field->setAttributes(XMLDB_TYPE_CHAR, '15', null, XMLDB_NOTNULL, null, null, null, 'black', 'eventid');
$result = $result && add_field($table, $field);
}
return $result;
}
示例7: xmldb_block_marginalia_upgrade
function xmldb_block_marginalia_upgrade($oldversion)
{
global $CFG;
$result = true;
if ($result && $oldversion < 2008121000) {
/// Define table annotation to be created
$table = new XMLDBTable('marginalia');
/// Adding fields to table annotation
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
// $table->addFieldInfo('userid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
// $table->addFieldInfo('access', XMLDB_TYPE_CHAR, '32', null, null, null, null, null, null);
$table->addFieldInfo('access_perms', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('url', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('start_block', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->addFieldInfo('start_xpath', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->addFieldInfo('start_line', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('start_word', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('start_char', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('end_block', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->addFieldInfo('end_xpath', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->addFieldInfo('end_line', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('end_word', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('end_char', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('note', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
$table->addFieldInfo('quote', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
$table->addFieldInfo('quote_title', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
// $table->addFieldInfo('quote_author', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->addFieldInfo('quote_author_id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('action', XMLDB_TYPE_CHAR, '30', null, null, null, null, null, null);
$table->addFieldInfo('link', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->addFieldInfo('link_title', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
$table->addFieldInfo('created', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('modified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('object_type', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('object_id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
/// Adding keys to table annotation
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table annotation
$table->addIndexInfo('object', XMLDB_INDEX_NOTUNIQUE, array('object_type', 'object_id'));
/// Launch create table for annotation
$result = $result && create_table($table);
// Check for old annotation table and convert its data over
if ($result) {
$query = "SELECT a.*, u.id AS uid, qa.id as aid " . " FROM {$CFG->prefix}annotation a" . " JOIN {$CFG->prefix}user u ON u.username=a.userid" . " LEFT JOIN {$CFG->prefix}user qa ON qa.username=a.quote_author";
$data = get_records_sql($query);
if ($data) {
foreach ($data as $r) {
/* // This method and the range classes are clever enough to handle
// ranges in the old format.
if ( array_key_exists( 'start_block', $r ) && $r->start_block !== null ) {
$r->start_block = preg_replace( '/^\//', '', $r->start_block );
$r->start_block = preg_replace( '/\//', '\.', $r->start_block );
}
if ( array_key_exists( 'end_block', $r ) && $r->end_block !== null ) {
$r->end_block = preg_replace( '/^\//', '', $r->end_block );
$r->end_block = preg_replace( '/\//', '\.', $r->end_block );
}
*/
$r->username = $r->userid;
$r->userid = 0;
$r->quote_author_username = $r->quote_author;
$annotation = annotation_globals::record_to_annotation($r);
// Will handle 'public' or 'private'
if (array_key_exists('access', $r)) {
$annotation->setAccess($r->access);
}
// Fix backslashes (\' and \") in annotation and note
if (AN_DBFIXBACKSLASHES) {
$quote = $annotation->getQuote();
$quote = preg_replace('/\\\\\'/', "'", $quote);
$quote = preg_replace('/\\\\"/', '"', $quote);
$annotation->setQuote($quote);
$note = $annotation->getNote();
$note = preg_replace('/\\\\\'/', "'", $note);
$note = preg_replace('/\\\\"/', '"', $note);
$annotation->setNote($note);
}
$record = annotation_globals::annotation_to_record($annotation);
// Make sure start_line and end_line are not null
if (!array_key_exists('start_line', $r)) {
$record->start_line = 0;
}
if (!array_key_exists('end_line', $r)) {
$record->end_line = 0;
}
$record->userid = $r->uid;
$record->quote_author_id = $r->aid;
$record->object_type = AN_OTYPE_POST;
$record->object_id = $r->object_id;
$x = insert_record(AN_DBTABLE, $record, true);
$result = $result && 0 != $x;
}
}
}
// Should perhaps delete old annotation table?
}
return $result;
}
示例8: xmldb_crlm_user_activity_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 component
* @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_crlm_user_activity_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2010071502) {
/// Define table etl_user_module_activity to be created
$table = new XMLDBTable('etl_user_module_activity');
/// Adding fields to table etl_user_module_activity
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('cmid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('hour', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('duration', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table etl_user_module_activity
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table etl_user_module_activity
$table->addIndexInfo('user_cmid_hour_idx', XMLDB_INDEX_UNIQUE, array('userid', 'cmid', 'hour'));
$table->addIndexInfo('cm_idx', XMLDB_INDEX_NOTUNIQUE, array('cmid'));
$table->addIndexInfo('hour_idx', XMLDB_INDEX_NOTUNIQUE, array('hour'));
/// Launch create table for etl_user_module_activity
if (!table_exists($table)) {
$result = $result && create_table($table);
}
}
if ($result && $oldversion < 2010071503) {
// clear all records -- they may be incorrect, and we'll recalculate
// them all
delete_records_select('etl_user_activity', 'TRUE');
delete_records('crlm_config', 'name', 'user_activity_last_run');
/// Define index user_idx (not unique) to be dropped form etl_user_activity
$table = new XMLDBTable('etl_user_activity');
$index = new XMLDBIndex('user_idx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
/// Launch drop index user_idx
$result = $result && drop_index($table, $index);
/// Define index user_idx (not unique) to be added to etl_user_activity
$table = new XMLDBTable('etl_user_activity');
$index = new XMLDBIndex('user_idx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid', 'courseid', 'hour'));
/// Launch add index user_idx
$result = $result && add_index($table, $index);
}
if ($result && $oldversion < 2010071505) {
$sql = "SELECT userid, courseid, hour, COUNT('x') count\n FROM {$CFG->prefix}etl_user_activity\n GROUP BY userid, courseid, hour\n HAVING COUNT('x') > 1";
if (record_exists_sql($sql)) {
$table = new XMLDBTable('etl_user_activity_temp');
// fields
$field = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$field = $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'id');
$field = $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'userid');
$field = $table->addFieldInfo('hour', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'courseid');
$field = $table->addFieldInfo('duration', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'hour');
// Keys & indexes
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('user_idx', XMLDB_INDEX_UNIQUE, array('userid', 'courseid', 'hour'));
$table->addIndexInfo('course_idx', XMLDB_INDEX_NOTUNIQUE, array('courseid'));
$table->addIndexInfo('hour_idx', XMLDB_INDEX_NOTUNIQUE, array('hour'));
$result = $result && create_table($table);
if ($result) {
$sql = "INSERT INTO {$CFG->prefix}etl_user_activity_temp (userid, courseid, hour, duration)\n SELECT userid, courseid, hour, duration\n FROM {$CFG->prefix}etl_user_activity\n GROUP BY userid, courseid, hour\n ORDER BY id ASC";
$result = $result && execute_sql($sql);
if ($result) {
$oldtable = new XMLDBTable('etl_user_activity');
$result = $result && drop_table($oldtable);
if ($result) {
$result = $result && rename_table($table, 'etl_user_activity');
}
}
}
}
if ($result) {
$sql = "UPDATE {$CFG->prefix}etl_user_activity SET duration = 3600 WHERE duration > 3600";
execute_sql($sql);
}
}
//.........这里部分代码省略.........
示例9: xmldb_core_upgrade
//.........这里部分代码省略.........
$cron->minute = 55;
$cron->hour = 23;
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = 6;
insert_record('cron', $cron);
$cron = new StdClass();
$cron->callfunction = 'cron_site_data_daily';
$cron->minute = 51;
$cron->hour = 23;
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
insert_record('cron', $cron);
// Put best guess at installation time into config table.
set_config('installation_time', get_field_sql("SELECT MIN(ctime) FROM {site_content}"));
// Save the current time so we know when we started collecting stats
set_config('stats_installation_time', db_format_timestamp(time()));
// Add ctime to usr table for daily count of users created
$table = new XMLDBTable('usr');
$field = new XMLDBField('ctime');
$field->setAttributes(XMLDB_TYPE_DATETIME, null, null);
add_field($table, $field);
// Add visits column to view table
$table = new XMLDBTable('view');
$field = new XMLDBField('visits');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
// Add table to store daily view visits
$table = new XMLDBTable('view_visit');
$table->addFieldInfo('ctime', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('view', XMLDB_TYPE_INTEGER, 10, false, XMLDB_NOTNULL);
$table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('view'), 'view', array('id'));
$table->addIndexInfo('ctimeix', XMLDB_INDEX_NOTUNIQUE, array('ctime'));
create_table($table);
// Insert a cron job to check for new versions of Mahara
$cron = new StdClass();
$cron->callfunction = 'cron_check_for_updates';
$cron->minute = rand(0, 59);
$cron->hour = rand(0, 23);
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
insert_record('cron', $cron);
}
if ($oldversion < 2010042600) {
// @todo: Move to notification/internal
$table = new XMLDBTable('notification_internal_activity');
$field = new XMLDBField('parent');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10');
add_field($table, $field);
$key = new XMLDBKey('parentfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('parent'), 'notification_internal_activity', array('id'));
add_key($table, $key);
$field = new XMLDBField('from');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10');
add_field($table, $field);
$key = new XMLDBKey('fromfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('from'), 'usr', array('id'));
add_key($table, $key);
// Set from column for old user messages
$usermessages = get_records_array('notification_internal_activity', 'type', get_field('activity_type', 'id', 'name', 'usermessage'));
if ($usermessages) {
foreach ($usermessages as &$m) {
if (preg_match('/sendmessage\\.php\\?id=(\\d+)/', $m->url, $match)) {
set_field('notification_internal_activity', 'from', $match[1], 'id', $m->id);
示例10: invoke
/**
* Invoke method, every class will have its own
* returns true/false on completion, setting both
* errormsg and output as necessary
*/
function invoke()
{
parent::invoke();
$result = true;
/// Set own core attributes
//$this->does_generate = ACTION_NONE;
$this->does_generate = ACTION_GENERATE_HTML;
/// These are always here
global $CFG, $XMLDB, $db;
/// ADD YOUR CODE HERE
require_once $CFG->libdir . '/ddllib.php';
/// Where all the tests will be stored
$tests = array();
/// The back to edit table button
$b = ' <p class="centerpara buttons">';
$b .= '<a href="index.php">[' . $this->str['back'] . ']</a>';
$b .= '</p>';
$o = $b;
/// Silenty drop any previous test tables
$table = new XMLDBTable('testtable');
if (table_exists($table)) {
$status = drop_table($table, true, false);
}
$table = new XMLDBTable('anothertest');
if (table_exists($table)) {
$status = drop_table($table, true, false);
}
$table = new XMLDBTable('newnameforthetable');
if (table_exists($table)) {
$status = drop_table($table, true, false);
}
/// 1st test. Complete table creation.
$table = new XMLDBTable('testtable');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null);
$table->addFieldInfo('intro', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('logo', XMLDB_TYPE_BINARY, 'big', null, XMLDB_NOTNULL, null, null, null);
$table->addFieldInfo('assessed', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('assesstimestart', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('assesstimefinish', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('scale', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('maxbytes', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('forcesubscribe', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('trackingtype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1');
$table->addFieldInfo('rsstype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('rssarticles', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('grade', XMLDB_TYPE_NUMBER, '20,0', XMLDB_UNSIGNED, null, null, null, null, null);
$table->addFieldInfo('percent', XMLDB_TYPE_NUMBER, '5,2', null, null, null, null, null, null);
$table->addFieldInfo('warnafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('blockafter', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('blockperiod', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('type-name', XMLDB_KEY_UNIQUE, array('type', 'name'));
$table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
$table->addIndexInfo('rsstype', XMLDB_INDEX_UNIQUE, array('rsstype'));
$table->setComment("This is a test'n drop table. You can drop it safely");
/// Get SQL code and execute it
$test = new stdClass();
$test->sql = $table->getCreateTableSQL($CFG->dbtype, $CFG->prefix, true);
$test->status = create_table($table, false, false);
if (!$test->status) {
$test->error = $db->ErrorMsg();
}
$tests['create table'] = $test;
/// 2nd test. drop table
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass();
$test->sql = $table->getDropTableSQL($CFG->dbtype, $CFG->prefix, true);
$test->status = drop_table($table, false, false);
if (!$test->status) {
$test->error = $db->ErrorMsg();
}
$tests['drop table'] = $test;
}
/// 3rd test. creating another, smaller table
if ($test->status) {
$table = new XMLDBTable('anothertest');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
$table->addFieldInfo('secondname', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('intro', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('avatar', XMLDB_TYPE_BINARY, 'medium', null, null, null, null, null, null);
$table->addFieldInfo('grade', XMLDB_TYPE_NUMBER, '20,10', null, null, null, null, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Get SQL code and execute it
$test = new stdClass();
$test->sql = $table->getCreateTableSQL($CFG->dbtype, $CFG->prefix, true);
$test->status = create_table($table, false, false);
if (!$test->status) {
$test->error = $db->ErrorMsg();
//.........这里部分代码省略.........
示例11: xmldb_block_courseprefs_upgrade
function xmldb_block_courseprefs_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 < 2008011700) {
// Adding block_courseprefs_students.status field to table
$table = new XMLDBTable('block_courseprefs_students');
$field = new XMLDBField('status');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('pending', 'enrolled'), 'pending', 'sectionsid');
$result = $result && add_field($table, $field);
// Adding block_courseprefs_teachers.status field to table
$table = new XMLDBTable('block_courseprefs_teachers');
$field = new XMLDBField('status');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('enrolled', 'pending'), 'pending', 'primary_flag');
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2008021400) {
$table = new XMLDBTable('block_courseprefs_enroll');
// Adding block_courseprefs_enroll.sectionsid field to table
$field = new XMLDBField('semestersid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'usersid');
$result = $result && add_field($table, $field);
// Dropping unique index on usersid and coursesid
$index = new XMLDBIndex('blocouenr-usecou-uk');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('usersid', 'coursesid'));
$result = $result && drop_index($table, $index);
// Delete table entries as users will fall back on users' defaults
delete_records('block_courseprefs_enroll');
// Adding unique index on usersid, semestersid, and coursesid
$index = new XMLDBIndex('blocouenr-usesemcou-uix');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('usersid', 'semestersid', 'coursesid'));
$result = $result && add_index($table, $index);
}
if ($result && $oldversion < 2008032400) {
//Upgrade existing users table
$user_table = new XMLDBTable('block_courseprefs_users');
$field = new XMLDBField('idnumber');
$field->setAttributes(XMLDB_TYPE_CHAR, '11', null, XMLDB_NOTNULL, null, null, null, null, 'split_courses');
/// Define table block_courseprefs_config to be created
$table = new XMLDBTable('block_courseprefs_config');
/// Adding fields to table block_courseprefs_config
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '128', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('value', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table block_courseprefs_config
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table block_courseprefs_config
$table->addIndexInfo('blocoucon-nam-uix', XMLDB_INDEX_UNIQUE, array('name'));
/// Launch create table for block_courseprefs_config
$result = $result && create_table($table) && add_field($user_table, $field);
}
if ($result && $oldversion < 2008061102) {
// Upgrade existing updates table
$updates_table = new XMLDBTable('block_courseprefs_updates');
$field = new XMLDBField('action');
$result = $result && drop_field($updates_table, $field);
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, XMLDB_ENUM, array('drop_instructor', 'drop_student', 'enroll_student', 'enroll_instructor', 'enroll_primary_instructor'), null, 'usersid');
/// Launch change of list of values for field action
$result = $result && add_field($updates_table, $field);
/// Define index blocouupd-secuseact-uix (unique) to be dropped form block_courseprefs_updates
$table = new XMLDBTable('block_courseprefs_updates');
$index = new XMLDBIndex('blocouupd-secuseact-uix');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('sectionsid', 'usersid'));
/// Launch drop index blocouupd-secuseact-uix
$result = $result && drop_index($table, $index);
}
if ($result && $oldversion < 2008111200) {
$enrollments = array('students', 'teachers');
//-------Changing of the users table ------------//
/// Define field college to be dropped from block_courseprefs_users
$table = new XMLDBTable('block_courseprefs_users');
$field = new XMLDBField('course_create_days');
/// Launch drop field college
$result = $result && drop_field($table, $field);
/// Define field college to be dropped from block_courseprefs_users
$field = new XMLDBField('split_courses');
/// Launch drop field college
$result = $result && drop_field($table, $field);
/// Define field college to be dropped from block_courseprefs_users
$field = new XMLDBField('course_enroll_days');
/// Launch drop field college
$result = $result && drop_field($table, $field);
$field = new XMLDBField('year');
$field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null, 'idnumber');
/// Launch add field year
$result = $result && add_field($table, $field);
/// Define field college to be added to block_courseprefs_users
$field = new XMLDBField('college');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, null, null, null, null, null, 'year');
/// Launch add field college
$result = $result && add_field($table, $field);
//.........这里部分代码省略.........
示例12: stats_upgrade_table_for_roles
/**
* Upgrades a prefix_stats_* table for the new role based permission system.
*
* @param string $period daily, weekly or monthly: the stat period to upgrade
* @return boolean @todo depends on how this will be called
*/
function stats_upgrade_table_for_roles($period)
{
global $CFG;
static $teacher_role_id, $student_role_id;
if (!in_array($period, array('daily', 'weekly', 'monthly'))) {
return false;
}
if (!$teacher_role_id) {
$role = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW);
$role = array_keys($role);
$teacher_role_id = $role[0];
$role = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW);
$role = array_keys($role);
$student_role_id = $role[0];
}
if (empty($teacher_role_id) || empty($student_role_id)) {
error_log("Couldn't find legacy roles for teacher or student");
return false;
}
execute_sql("CREATE TABLE {$CFG->prefix}stats_{$period}_tmp AS\n SELECT * FROM {$CFG->prefix}stats_{$period}");
$table = new XMLDBTable('stats_' . $period);
if (!drop_table($table)) {
return false;
}
// Create a new stats table
// @todo this definition I have made blindly by looking at how definitions are
// made, it needs work to make sure it works properly
require_once "{$CFG->libdir}/xmldb/classes/XMLDBTable.class.php";
$table = new XMLDBTable('stats_' . $period);
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('roleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('timeend', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('stattype', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('enrolments', 'activity', 'logins'), 'activity');
$table->addFieldInfo('stat1', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('stat2', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table stats_daily
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table stats_daily
$table->addIndexInfo('courseid', XMLDB_INDEX_NOTUNIQUE, array('courseid'));
$table->addIndexInfo('timeend', XMLDB_INDEX_NOTUNIQUE, array('timeend'));
$table->addIndexInfo('roleid', XMLDB_INDEX_NOTUNIQUE, array('roleid'));
if (!create_table($table)) {
return false;
}
//
// Now insert the data from the temporary table into the new one
//
// Student enrolments
execute_sql("INSERT INTO {$CFG->prefix}stats_{$period}\n (courseid, roleid, timeend, stattype, stat1, stat2)\n SELECT courseid, {$student_role_id}, timeend, 'enrolments', students, activestudents\n FROM {$CFG->prefix}stats_{$period}_tmp");
// Teacher enrolments
execute_sql("INSERT INTO {$CFG->prefix}stats_{$period}\n (courseid, roleid, timeend, stattype, stat1, stat2)\n SELECT courseid, {$teacher_role_id}, timeend, 'enrolments', teachers, activeteachers\n FROM {$CFG->prefix}stats_{$period}_tmp");
// Student activity
execute_sql("INSERT INTO {$CFG->prefix}stats_{$period}\n (courseid, roleid, timeend, stattype, stat1, stat2)\n SELECT courseid, {$student_role_id}, timeend, 'activity', studentreads, studentwrites\n FROM {$CFG->prefix}stats_{$period}_tmp");
// Teacher activity
execute_sql("INSERT INTO {$CFG->prefix}stats_{$period}\n (courseid, roleid, timeend, stattype, stat1, stat2)\n SELECT courseid, {$teacher_role_id}, timeend, 'activity', teacherreads, teacherwrites\n FROM {$CFG->prefix}stats_{$period}_tmp");
// Logins
execute_sql("INSERT INTO {$CFG->prefix}stats_{$period}\n (courseid, roleid, timeend, stattype, stat1, stat2)\n SELECT courseid, 0, timeend, 'logins', logins, uniquelogins\n FROM {$CFG->prefix}stats_{$period}_tmp WHERE courseid = " . SITEID);
// Drop the temporary table
$table = new XMLDBTable('stats_' . $period . '_tmp');
if (!drop_table($table)) {
return false;
}
return true;
}
示例13: xmldb_assignment_type_uploadpdf_upgrade
function xmldb_assignment_type_uploadpdf_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2009041700) {
$table = new XMLDBTable('assignment_uploadpdf');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('assignment', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('coversheet', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, '');
$table->addFieldInfo('template', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('onlypdf', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, null, null, '1');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('assignment', XMLDB_INDEX_UNIQUE, array('assignment'));
$table->addIndexInfo('template', XMLDB_INDEX_NOTUNIQUE, array('template'));
$result = $result && create_table($table);
$table = new XMLDBTable('assignment_uploadpdf_template');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, '');
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
$result = $result && create_table($table);
$table = new XMLDBTable('assignment_uploadpdf_template_item');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('template', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('type', XMLDB_TYPE_CHAR, '15', null, XMLDB_NOTNULL, null, null, null, 'shorttext');
$table->addFieldInfo('xpos', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('ypos', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('width', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, '0');
$table->addFieldInfo('setting', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, '');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('template', XMLDB_INDEX_NOTUNIQUE, array('template'));
$result = $result && create_table($table);
$table = new XMLDBTable('assignment_uploadpdf_comment');
$field = new XMLDBField('colour');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, null, null, null, null, 'yellow', null);
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2009111800) {
$table = new XMLDBTable('assignment_uploadpdf_quicklist');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('text', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, '');
$table->addFieldInfo('width', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('colour', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'yellow');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
$result = $result && create_table($table);
}
if ($result && $oldversion < 2009112800) {
$table = new XMLDBTable('assignment_uploadpdf_annotation');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('assignment_submission', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('startx', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('starty', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('endx', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('endy', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('pageno', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('colour', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'red');
$table->addFieldInfo('type', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'line');
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('assignment_submission', XMLDB_INDEX_NOTUNIQUE, array('assignment_submission'));
$table->addIndexInfo('assignment_submission_pageno', XMLDB_INDEX_NOTUNIQUE, array('assignment_submission', 'pageno'));
$result = $result && create_table($table);
}
if ($result && $oldversion < 2009120100) {
// Rename the tables to fit within Oracle's 30 char limits (including 2 char prefix)
$table = new XMLDBTable('assignment_uploadpdf_template');
$result = $result && rename_table($table, 'assignment_uploadpdf_tmpl');
$table = new XMLDBTable('assignment_uploadpdf_template_item');
$result = $result && rename_table($table, 'assignment_uploadpdf_tmplitm');
$table = new XMLDBTable('assignment_uploadpdf_quicklist');
$result = $result && rename_table($table, 'assignment_uploadpdf_qcklist');
$table = new XMLDBTable('assignment_uploadpdf_annotation');
$result = $result && rename_table($table, 'assignment_uploadpdf_annot');
// Change the data type of the text field from 'char' to 'text' (removing 255 char limit)
$table = new XMLDBTable('assignment_uploadpdf_qcklist');
$field = new XMLDBField('text');
$field->setAttributes(XMLDB_TYPE_TEXT . 'medium', null, null, null, null, null, '');
$result = $result && change_field_type($table, $field);
// Remove 255 char limit from comments
$table = new XMLDBTable('assignment_uploadpdf_comment');
$field = new XMLDBField('rawtext');
$field->setAttributes(XMLDB_TYPE_TEXT . 'medium', null, null, null, null, null, '');
$result = $result && change_field_type($table, $field);
// Remove 255 char limit from coversheet path
$table = new XMLDBTable('assignment_uploadpdf');
$field = new XMLDBField('coversheet');
$field->setAttributes(XMLDB_TYPE_TEXT . 'medium', null, null, null, null, null, '');
$result = $result && change_field_type($table, $field);
}
if ($result && $oldversion < 2010031300) {
// Add new fields to allow linking with the checklist module
$table = new XMLDBTable('assignment_uploadpdf');
$field = new XMLDBField('checklist');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'onlypdf');
$result = $result && add_field($table, $field);
$field = new XMLDBField('checklist_percent');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'checklist');
$result = $result && add_field($table, $field);
//.........这里部分代码省略.........
示例14: xmldb_game_upgrade
//.........这里部分代码省略.........
$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');
$table->addFieldInfo('chapterid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
/// Adding keys to table scorm_scoes_data
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table scorm_scoes_data
$table->addIndexInfo('gameinstanceidchapterid', XMLDB_INDEX_NOTUNIQUE, array('gameinstanceid', 'chapterid'));
/// Launch create table for scorm_scoes_data
$result = $result && create_table($table);
}
//new table game_snakes_database
if ($result && $oldversion < 2007092207) {
/// Define table scorm_scoes_data to be created
$table = new XMLDBTable('game_snakes_database');
/// 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('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, '');
$table->addFieldInfo('cols', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('rows', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('data', XMLDB_TYPE_TEXT, '0', null, XMLDB_NOTNULL, null, null, null, '');
$table->addFieldInfo('file', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, '');
$table->addFieldInfo('direction', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('headerx', XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('headery', XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('footerx', XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('footery', XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
/// Adding keys to table scorm_scoes_data
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Launch create table for scorm_scoes_data
$result = $result && create_table($table);
}
if ($result && $oldversion < 2007092208) {
/// Define table scorm_scoes_data to be created
$table = new XMLDBTable('game_snakes');
/// 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('snakesdatabaseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('position', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
/// Adding keys to table scorm_scoes_data
示例15: xmldb_auth_webservice_upgrade
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
function xmldb_auth_webservice_upgrade($oldversion = 0)
{
$status = true;
/**
* Ensure that all the Web Services tables have been created - even if we
* are transitioning from artefact/webservice to webservice
*/
if ($oldversion < 2014112800) {
// Add in the Web Services subsystem
// ensure that redundant tables are removed from early days of artefact/webservice
$table = new XMLDBTable('oauth_consumer_token');
if (table_exists($table)) {
drop_table($table);
}
$table = new XMLDBTable('oauth_consumer_registry');
if (table_exists($table)) {
drop_table($table);
}
// Create the core services tables
$table = new XMLDBTable('external_services');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, 200, null, null);
$table->addFieldInfo('enabled', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
$table->addFieldInfo('restrictedusers', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
$table->addFieldInfo('tokenusers', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
$table->addFieldInfo('component', XMLDB_TYPE_CHAR, 100, null, null);
$table->addFieldInfo('ctime', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('mtime', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('nameuk', XMLDB_INDEX_UNIQUE, array('name'));
create_table($table);
$table = new XMLDBTable('external_functions');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, 200, null, null);
$table->addFieldInfo('classname', XMLDB_TYPE_CHAR, 100, null, null);
$table->addFieldInfo('methodname', XMLDB_TYPE_CHAR, 100, null, null);
$table->addFieldInfo('classpath', XMLDB_TYPE_CHAR, 255, null, null);
$table->addFieldInfo('component', XMLDB_TYPE_CHAR, 100, null, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('nameuk', XMLDB_INDEX_UNIQUE, array('name'));
create_table($table);
$table = new XMLDBTable('external_services_functions');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('externalserviceid', XMLDB_TYPE_INTEGER, 10, null, null);
$table->addFieldInfo('functionname', XMLDB_TYPE_CHAR, 200, null, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('externalserviceidfk', XMLDB_KEY_FOREIGN, array('externalserviceid'), 'external_services', array('id'));
create_table($table);
$table = new XMLDBTable('external_tokens');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('token', XMLDB_TYPE_CHAR, 128, null, null);
$table->addFieldInfo('tokentype', XMLDB_TYPE_INTEGER, 4, null, XMLDB_NOTNULL, null, null, null, 0);
$table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('institution', XMLDB_TYPE_CHAR, 255, null, null);
$table->addFieldInfo('externalserviceid', XMLDB_TYPE_INTEGER, 10, null, null);
$table->addFieldInfo('sid', XMLDB_TYPE_CHAR, 128, null, null);
$table->addFieldInfo('creatorid', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, 1);
$table->addFieldInfo('iprestriction', XMLDB_TYPE_CHAR, 255, null, null);
$table->addFieldInfo('validuntil', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('ctime', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('mtime', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('publickey', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('publickeyexpires', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('wssigenc', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('useridfk', XMLDB_KEY_FOREIGN, array('userid'), 'usr', array('id'));
$table->addKeyInfo('institutionfk', XMLDB_KEY_FOREIGN, array('institution'), 'institution', array('name'));
$table->addKeyInfo('externalserviceidfk', XMLDB_KEY_FOREIGN, array('externalserviceid'), 'external_services', array('id'));
$table->addKeyInfo('creatoridfk', XMLDB_KEY_FOREIGN, array('creatorid'), 'usr', array('id'));
$table->addIndexInfo('tokenuk', XMLDB_INDEX_UNIQUE, array('token'));
create_table($table);
$table = new XMLDBTable('external_services_users');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('externalserviceid', XMLDB_TYPE_INTEGER, 10, null, null);
$table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('institution', XMLDB_TYPE_CHAR, 255, null, null);
$table->addFieldInfo('iprestriction', XMLDB_TYPE_CHAR, 255, null, null);
$table->addFieldInfo('validuntil', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('ctime', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('mtime', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('publickey', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('publickeyexpires', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('wssigenc', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('externalserviceidfk', XMLDB_KEY_FOREIGN, array('externalserviceid'), 'external_services', array('id'));
$table->addKeyInfo('useridfk', XMLDB_KEY_FOREIGN, array('userid'), 'usr', array('id'));
$table->addKeyInfo('institutionfk', XMLDB_KEY_FOREIGN, array('institution'), 'institution', array('name'));
create_table($table);
$table = new XMLDBTable('external_services_logs');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('timelogged', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, null);
//.........这里部分代码省略.........