当前位置: 首页>>代码示例>>PHP>>正文


PHP XMLDBTable::addFieldInfo方法代码示例

本文整理汇总了PHP中XMLDBTable::addFieldInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLDBTable::addFieldInfo方法的具体用法?PHP XMLDBTable::addFieldInfo怎么用?PHP XMLDBTable::addFieldInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLDBTable的用法示例。


在下文中一共展示了XMLDBTable::addFieldInfo方法的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;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:29,代码来源:upgrade.php

示例2: xmldb_crlm_cluster_classification_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_crlm_cluster_classification_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2010080502) {
        /// Define table crlm_cluster_classification to be created
        $table = new XMLDBTable('crlm_cluster_classification');
        /// Adding fields to table crlm_cluster_classification
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('params', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
        /// Adding keys to table crlm_cluster_classification
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('shortname_idx', XMLDB_KEY_UNIQUE, array('shortname'));
        /// Launch create table for crlm_cluster_classification
        $result = $result && create_table($table);
    }
    if ($result && $oldversion < 2010080503) {
        require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
        $field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_CLASSIFICATION_FIELD));
        // make sure we're set as owner
        if (!isset($field->owners['cluster_classification'])) {
            $owner = new field_owner();
            $owner->fieldid = $field->id;
            $owner->plugin = 'cluster_classification';
            $owner->add();
        }
        // make sure we have a default value set
        if (!field_data::get_for_context_and_field(NULL, $field)) {
            field_data::set_for_context_and_field(NULL, $field, 'regular');
        }
        $default = new clusterclassification();
        $default->shortname = 'regular';
        $default->name = get_string('cluster', 'block_curr_admin');
        $default->param_autoenrol_curricula = 1;
        $default->param_autoenrol_tracks = 1;
        $default->add();
    }
    // make sure 'manual' is an owner
    if ($result && $oldversion < 2010080504) {
        require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
        $field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_CLASSIFICATION_FIELD));
        $owner = new field_owner();
        $owner->fieldid = $field->id;
        $owner->plugin = 'manual';
        $owner->param_view_capability = '';
        $owner->param_edit_capability = 'moodle/user:update';
        $owner->param_control = 'menu';
        $owner->param_options_source = 'cluster_classifications';
        $owner->add();
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:82,代码来源:upgrade.php

示例3: xmldb_artefact_calendar_upgrade

function xmldb_artefact_calendar_upgrade($oldversion = 0)
{
    if ($oldversion < 2013062404) {
        $table = new XMLDBTable('artefact_calendar_reminder');
        drop_table($table);
        $table->addFieldInfo('user', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
        $table->addFieldInfo('reminder_type', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL);
        $table->addFieldInfo('reminder_date', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '-1', null);
        $table->addKeyInfo('reminder_pk', XMLDB_KEY_PRIMARY, array('user'));
        if (!create_table($table)) {
            throw new SQLException($table . " could not be created, check log for errors.");
        }
        execute_sql('ALTER TABLE {artefact_calendar_calendar} DROP COLUMN {reminder_status}');
    }
    if ($oldversion < 2013062501) {
        execute_sql('ALTER TABLE {artefact_calendar_calendar} change {reminder_date} {reminder_date} int(4) NOT NULL;');
    }
    if ($oldversion < 2013063001) {
        $table = new XMLDBTable('artefact_calendar_event');
        $table->addFieldInfo('eventid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
        $table->addFieldInfo('begin', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
        $table->addFieldInfo('end', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
        $table->addFieldInfo('whole_day', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL);
        $table->addFieldInfo('repeat_type', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL);
        $table->addFieldInfo('repeats_every', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL);
        $table->addFieldInfo('end_date', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
        $table->addFieldInfo('ends_after', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL);
        $table->addKeyInfo('event_pk', XMLDB_KEY_PRIMARY, array('eventid'));
        if (!create_table($table)) {
            throw new SQLException($table . " could not be created, check log for errors.");
        }
    }
    return true;
}
开发者ID:vohung96,项目名称:mahara,代码行数:34,代码来源:upgrade.php

示例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);
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:16,代码来源:db.php

示例5: xmldb_qtype_rqp_upgrade

function xmldb_qtype_rqp_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2006032201) {
        $table = new XMLDBTable('question_rqp_servers');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
        $table->addFieldInfo('typeid', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        $table->addFieldInfo('url', XMLDB_TYPE_CHAR, 255);
        $table->addFieldInfo('can_render', XMLDB_TYPE_INTEGER, 2, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        $table->addFieldInfo('can_author', XMLDB_TYPE_INTEGER, 2, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('typeid', XMLDB_KEY_FOREIGN, array('typeid'), 'rqp_types', array('id'));
        $result = $result && create_table($table);
    }
    return $result;
}
开发者ID:veritech,项目名称:pare-project,代码行数:17,代码来源:upgrade.php

示例6: xmldb_artefact_blog_upgrade

function xmldb_artefact_blog_upgrade($oldversion = 0)
{
    if ($oldversion < 2008101602) {
        $table = new XMLDBTable('artefact_blog_blogpost_file_pending');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('oldextension', XMLDB_TYPE_TEXT, null);
        $table->addFieldInfo('filetype', XMLDB_TYPE_TEXT, null);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        create_table($table);
    }
    if ($oldversion < 2009033100) {
        $bloguploadbase = get_config('dataroot') . 'artefact/blog/uploads/';
        if (is_dir($bloguploadbase)) {
            if ($basedir = opendir($bloguploadbase)) {
                while (false !== ($sessionupload = readdir($basedir))) {
                    if ($sessionupload != "." && $sessionupload != "..") {
                        $sessionupload = $bloguploadbase . $sessionupload;
                        $subdir = opendir($sessionupload);
                        while (false !== ($uploadfile = readdir($subdir))) {
                            if ($uploadfile != "." && $uploadfile != "..") {
                                $uploadfile = $sessionupload . '/' . $uploadfile;
                                unlink($uploadfile);
                            }
                        }
                        closedir($subdir);
                        rmdir($sessionupload);
                    }
                }
            }
            @rmdir($bloguploadbase);
        }
    }
    if ($oldversion < 2009081800) {
        $subscription = (object) array('plugin' => 'blog', 'event' => 'createuser', 'callfunction' => 'create_default_blog');
        ensure_record_exists('artefact_event_subscription', $subscription, $subscription);
    }
    if ($oldversion < 2011091400) {
        delete_records('artefact_cron', 'plugin', 'blog', 'callfunction', 'clean_post_files');
    }
    if ($oldversion < 2015011500) {
        delete_records('institution_config', 'field', 'progressbaritem_blog_blog');
    }
    return true;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:44,代码来源:upgrade.php

示例7: 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;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:19,代码来源:upgrade.php

示例8: xmldb_block_ajax_marking_upgrade

function xmldb_block_ajax_marking_upgrade($oldversion = 0)
{
    //echo "oldversion: ".$oldversion;
    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 < 2007052901) {
        //New version in version.php
        /// Define table block_ajax_marking to be created
        $table = new XMLDBTable('block_ajax_marking');
        /// Adding fields to table block_ajax_marking
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
        $table->addFieldInfo('assessmenttype', XMLDB_TYPE_CHAR, '40', null, null, null, null, null, null);
        $table->addFieldInfo('assessmentid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
        $table->addFieldInfo('showhide', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
        $table->addFieldInfo('groups', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
        /// Adding keys to table block_ajax_marking
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('useridkey', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
        /// Launch create table for block_ajax_marking
        $result = $result && create_table($table);
    }
    // run this on every upgrade.
    AMB_update_modules();
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:30,代码来源:upgrade.php

示例9: 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;
}
开发者ID:remotelearner,项目名称:elis.reporting,代码行数:60,代码来源:upgrade.php

示例10: 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;
}
开发者ID:remotelearner,项目名称:mahara-auth_oidc,代码行数:25,代码来源:upgrade.php

示例11: 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();
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:test.class.php

示例12: xmldb_main_upgrade


//.........这里部分代码省略.........
                $setting = substr($k, 5);
                if (set_config($setting, $v, "auth/ldap")) {
                    delete_records('config', 'name', $k);
                    unset($CFG->{$k});
                }
                continue;
            }
            if (strpos($k, 'auth_') !== 0) {
                continue;
            }
            $authsetting = substr($k, 5);
            foreach ($authplugins as $auth) {
                if (strpos($authsetting, $auth) !== 0) {
                    continue;
                }
                $setting = substr($authsetting, strlen($auth));
                if (set_config($setting, $v, "auth/{$auth}")) {
                    delete_records('config', 'name', $k);
                    unset($CFG->{$k});
                }
                break;
                // don't check the rest of the auth plugin names
            }
        }
        upgrade_main_savepoint($result, 2007010300);
    }
    if ($result && $oldversion < 2007010301) {
        //
        // Core MNET tables
        //
        $table = new XMLDBTable('mnet_host');
        $table->comment = 'Information about the local and remote hosts for RPC';
        // fields
        $f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $f->comment = 'Unique Host ID';
        $f = $table->addFieldInfo('deleted', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        $f = $table->addFieldInfo('wwwroot', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $f = $table->addFieldInfo('ip_address', XMLDB_TYPE_CHAR, '39', null, XMLDB_NOTNULL, null, null, null, null);
        $f = $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '80', null, XMLDB_NOTNULL, null, null, null, null);
        $f = $table->addFieldInfo('public_key', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null);
        $f = $table->addFieldInfo('public_key_expires', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        $f = $table->addFieldInfo('transport', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        $f = $table->addFieldInfo('portno', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        $f = $table->addFieldInfo('last_connect_time', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        $f = $table->addFieldInfo('last_log_id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        // PK and indexes
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Create the table
        $result = $result && create_table($table);
        $table = new XMLDBTable('mnet_host2service');
        $table->comment = 'Information about the services for a given host';
        // fields
        $f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $f = $table->addFieldInfo('hostid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
        $f = $table->addFieldInfo('serviceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
        $f = $table->addFieldInfo('publish', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
        $f = $table->addFieldInfo('subscribe', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, NULL, null, null, 0);
        // PK and indexes
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('hostid_serviceid', XMLDB_INDEX_UNIQUE, array('hostid', 'serviceid'));
        // Create the table
        $result = $result && create_table($table);
        $table = new XMLDBTable('mnet_log');
        $table->comment = 'Store session data from users migrating to other sites';
        // fields
        $f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:67,代码来源:upgrade.php

示例13: xmldb_artefact_file_upgrade


//.........这里部分代码省略.........
    }
    if ($oldversion < 2014051200) {
        require_once get_config('docroot') . '/lib/file.php';
        $mimetypes = get_records_assoc('artefact_file_mime_types', '', '', '', 'description,mimetype');
        // Re-examine only those files where their current identified mimetype is
        // different from how we would identify their mimetype based on file extension
        $rs = get_recordset_sql('
            select a.id, aff.oldextension, aff.filetype
            from
                {artefact} a
                inner join {artefact_file_files} aff
                    on a.id = aff.artefact
            where a.artefacttype = \'archive\'
                and not exists (
                    select 1 from {artefact_file_mime_types} afmt
                    where afmt.description = aff.oldextension
                    and afmt.mimetype = aff.filetype
                )
            order by a.id
        ');
        $total = 0;
        $done = 0;
        while ($zf = $rs->FetchRow()) {
            if ($done % 100 == 0) {
                log_debug('Verifying filetypes: ' . $done . '/' . $rs->RecordCount());
            }
            $done++;
            $file = artefact_instance_from_id($zf['id']);
            $path = $file->get_path();
            // Check what our improved file detection system thinks it is
            $guess = file_mime_type($path, 'foo.' . $zf['oldextension']);
            if ($guess != 'application/octet-stream') {
                $data = new stdClass();
                $data->filetype = $data->guess = $guess;
                foreach (array('video', 'audio', 'archive') as $artefacttype) {
                    $classname = 'ArtefactType' . ucfirst($artefacttype);
                    if (call_user_func_array(array($classname, 'is_valid_file'), array($file->get_path(), &$data))) {
                        set_field('artefact', 'artefacttype', $artefacttype, 'id', $zf['id']);
                        set_field('artefact_file_files', 'filetype', $data->filetype, 'artefact', $zf['id']);
                        continue 2;
                    }
                }
                // It wasn't any of those special ones, so just make it a normal file artefact
                set_field('artefact', 'artefacttype', 'file', 'id', $zf['id']);
                set_field('artefact_file_files', 'filetype', $data->filetype, 'artefact', $zf['id']);
            }
        }
        log_debug('Verifying filetypes: ' . $done . '/' . $rs->RecordCount());
        $rs->Close();
    }
    if ($oldversion < 2014060900) {
        $events = array((object) array('plugin' => 'file', 'event' => 'saveartefact', 'callfunction' => 'eventlistener_savedeleteartefact'), (object) array('plugin' => 'file', 'event' => 'deleteartefact', 'callfunction' => 'eventlistener_savedeleteartefact'), (object) array('plugin' => 'file', 'event' => 'deleteartefacts', 'callfunction' => 'eventlistener_savedeleteartefact'), (object) array('plugin' => 'file', 'event' => 'updateuser', 'callfunction' => 'eventlistener_savedeleteartefact'));
        foreach ($events as $event) {
            ensure_record_exists('artefact_event_subscription', $event, $event);
        }
        PluginArtefactFile::set_quota_triggers();
    }
    if ($oldversion < 2014061000) {
        // Remove the not needed quota notify on update config trigger from previous update
        if (is_postgres()) {
            $sql = 'DROP TRIGGER IF EXISTS {unmark_quota_exeed_notified_on_update_setting_trigger} ON {artefact_config};';
        } else {
            $sql = 'DROP TRIGGER IF EXISTS {unmark_quota_exeed_notified_on_update_setting_trigger};';
        }
        execute_sql($sql);
    }
    if ($oldversion < 2014111200) {
        // Create embedded images table
        $table = new XMLDBTable('artefact_file_embedded');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
        $table->addFieldInfo('fileid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
        $table->addFieldInfo('resourcetype', XMLDB_TYPE_CHAR, '100', XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('resourceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('artefactfk', XMLDB_KEY_FOREIGN, array('fileid'), 'artefact', array('id'));
        $status = $status && create_table($table);
    }
    if ($oldversion < 2015101900) {
        log_debug('Need to consolidate "textbox" and "editnote" embedded resource types as they are in fact the same thing');
        if ($records = get_records_sql_array('SELECT * FROM {artefact_file_embedded} WHERE resourcetype IN (?, ?)', array('editnote', 'textbox'))) {
            $newrecords = array();
            // Turn the results into something easier to check against
            foreach ($records as $k => $v) {
                $newrecords[$v->resourcetype . '_' . $v->resourceid . '_' . $v->fileid] = $v;
            }
            foreach ($newrecords as $nk => $nv) {
                // need to sort out the 'editnote' options
                if (preg_match('/^editnote_(.*)$/', $nk, $match)) {
                    // Check to see if there is a corresponding 'textbox' one - if not we need to make one
                    if (!array_key_exists('textbox_' . $match[1], $newrecords)) {
                        insert_record('artefact_file_embedded', (object) array('fileid' => $nv->fileid, 'resourcetype' => 'textbox', 'resourceid' => $nv->resourceid));
                    }
                    // now delete the 'editnote' one
                    delete_records('artefact_file_embedded', 'id', $nv->id);
                }
            }
        }
    }
    return $status;
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:101,代码来源:upgrade.php

示例14: sync_users

 /**
  * Attemp to synchronize Users in Mahara with Users in the LDAP server
  *
  * @param boolean $dryrun dummy execution. Do not perform any database operations
  * @return boolean
  */
 public function sync_users($dryrun = false)
 {
     global $CFG;
     require_once get_config('docroot') . 'lib/ddl.php';
     require_once get_config('docroot') . 'lib/institution.php';
     log_info('---------- started usersync for instance ' . $this->instanceid . ' at ' . date('r', time()) . ' ----------');
     // If they haven't activated the cron, return
     if (!$this->get_config('syncuserscron')) {
         log_info('not set to sync users, so exiting');
         return true;
     }
     // Create a temp table to store the users, for better performance
     $temptable = new XMLDBTable('auth_ldap_extusers_temp');
     $temptable->addFieldInfo('extusername', XMLDB_TYPE_CHAR, 64, null, false);
     $temptable->addFieldInfo('firstname', XMLDB_TYPE_TEXT);
     $temptable->addFieldInfo('lastname', XMLDB_TYPE_TEXT);
     $temptable->addFieldInfo('email', XMLDB_TYPE_CHAR, 255);
     $temptable->addFieldInfo('studentid', XMLDB_TYPE_TEXT);
     $temptable->addFieldInfo('preferredname', XMLDB_TYPE_TEXT);
     $temptable->addKeyInfo('extusers', XMLDB_KEY_PRIMARY, array('extusername'));
     $tablecreated = create_temp_table($temptable, false, true);
     if (!$tablecreated) {
         log_warn('Could not create temp table auth_ldap_extusers_temp', false);
         return false;
     }
     $extrafilterattribute = $this->get_config('syncusersextrafilterattribute');
     $doupdate = $this->get_config('syncusersupdate');
     $docreate = $this->get_config('syncuserscreate');
     $tousersgonefromldap = $this->get_config('syncusersgonefromldap');
     $dodelete = false;
     $dosuspend = false;
     switch ($tousersgonefromldap) {
         case 'delete':
             $dodelete = true;
             break;
         case 'suspend':
             $dosuspend = true;
             break;
     }
     if (get_config('auth_ldap_debug_sync_cron')) {
         log_debug("config. LDAP : ");
         var_dump($this->config);
     }
     // fetch ldap users having the filter attribute on (caution maybe mutlivalued
     // do it on a scalable version by keeping the LDAP users names in a temporary table
     $nbldapusers = $this->ldap_get_users_scalable('auth_ldap_extusers_temp', 'extusername', $extrafilterattribute);
     log_info('LDAP users found : ' . $nbldapusers);
     try {
         $nbupdated = $nbcreated = $nbsuspended = $nbdeleted = $nbignored = $nbpresents = $nbunsuspended = $nberrors = 0;
         // Define ldap attributes in user update
         $ldapattributes = $this->get_ldap_user_fields();
         // Match database and ldap entries and update in database if required
         $fieldstoimport = array_keys($ldapattributes);
         // we fetch only Mahara users of this institution concerned by this authinstance (either cas or ldap)
         // and get also their suspended status since we may have to unsuspend them
         // this search cannot be done by a call to get_institutional_admin_search_results
         // that does not support searching by auth instance id and do not return suspended status
         // and is not suitable for a massive number of users
         if (!$doupdate) {
             log_info('user auto-update disabled');
         } else {
             // users to update (known both in LDAP and Mahara usr table)
             $sql = "\n                    select\n                        u.id as id,\n                        u.username as username,\n                        u.suspendedreason as suspendedreason,\n                        u.firstname as dbfirstname,\n                        u.lastname as dblastname,\n                        u.email as dbemail,\n                        u.studentid as dbstudentid,\n                        u.preferredname as dbpreferredname,\n                        e.firstname as ldapfirstname,\n                        e.lastname as ldaplastname,\n                        e.email as ldapemail,\n                        e.studentid as ldapstudentid,\n                        e.preferredname as ldappreferredname\n                    from\n                        {usr} u\n                        inner join {auth_ldap_extusers_temp} e\n                            on u.username = e.extusername\n                    where\n                        u.deleted = 0\n                        and u.authinstance = ?\n                    order by u.username\n                ";
             $rs = get_recordset_sql($sql, array($this->instanceid));
             log_info($rs->RecordCount() . ' users known to Mahara ');
             while ($record = $rs->FetchRow()) {
                 $nbpresents++;
                 $ldapusername = $record['username'];
                 $updated = false;
                 foreach ($fieldstoimport as $field) {
                     $ldapfield = "ldap{$field}";
                     $dbfield = "db{$field}";
                     $sanitizer = "sanitize_{$field}";
                     $record[$ldapfield] = $sanitizer($record[$ldapfield]);
                     if ($record[$ldapfield] != '' && $record[$dbfield] != $record[$ldapfield]) {
                         $updated = true;
                         if (!$dryrun) {
                             set_profile_field($record['id'], $field, $record[$ldapfield]);
                         }
                     }
                 }
                 if ($updated) {
                     log_debug('updating user ' . $ldapusername);
                 } else {
                     log_debug('no change for user ' . $ldapusername);
                 }
                 if (!$dryrun) {
                     if (!empty($record['ldapstudentid'])) {
                         // caution may be missing ?
                         set_field('usr_institution', 'studentid', $record['ldapstudentid'], 'usr', $record['id'], 'institution', $this->institution);
                     }
                 }
                 unset($ldapdetails);
                 $nbupdated++;
//.........这里部分代码省略.........
开发者ID:vohung96,项目名称:mahara,代码行数:101,代码来源:lib.php

示例15: xmldb_dialogue_upgrade

function xmldb_dialogue_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2007100300) {
        /// Define field recipientid to be added to dialogue_entries
        $table = new XMLDBTable('dialogue_entries');
        $field = new XMLDBField('recipientid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'userid');
        /// Launch add field recipientid
        $result = $result && add_field($table, $field);
        $index = new XMLDBIndex('dialogue_entries_recipientid_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('recipientid'));
        /// Launch add index dialogue_entries_recipientid_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2007100301) {
        /// Define field lastrecipientid to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $field = new XMLDBField('lastrecipientid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'lastid');
        /// Launch add field lastrecipientid
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007100400) {
        /// Define field attachment to be added to dialogue_entries
        $table = new XMLDBTable('dialogue_entries');
        $field = new XMLDBField('attachment');
        $field->setAttributes(XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null, 'text');
        /// Launch add field attachment
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007100800) {
        /// Define field edittime to be added to dialogue
        $table = new XMLDBTable('dialogue');
        $field = new XMLDBField('edittime');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
        /// Launch add field edittime
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007110700) {
        /// Define field groupid to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $field = new XMLDBField('groupid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'subject');
        /// Launch add field groupid
        $result = $result && add_field($table, $field);
        /// Define index dialogue_conversations_groupid_idx (not unique) to be added to dialogue_conversations
        $index = new XMLDBIndex('dialogue_conversations_groupid_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('groupid'));
        /// Launch add index dialogue_conversations_groupid_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2007110800) {
        /// Define field grouping to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $field = new XMLDBField('grouping');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'groupid');
        /// Launch add field grouping
        $result = $result && add_field($table, $field);
        /// Define index dialogue_conversations_grouping_idx (not unique) to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $index = new XMLDBIndex('dialogue_conversations_grouping_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('grouping'));
        /// Launch add index dialogue_conversations_grouping_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2007111401) {
        /// Define field timemodified to be added to dialogue_entries
        $table = new XMLDBTable('dialogue_entries');
        $field = new XMLDBField('timemodified');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, '0', 'timecreated');
        /// Launch add field timemodified
        $result = $result && add_field($table, $field);
        $result = $result && ($result = execute_sql('UPDATE ' . $CFG->prefix . 'dialogue_entries SET timemodified = timecreated'));
    }
    if ($result && $oldversion < 2007112200) {
        /// Define table dialogue_read to be created
        $table = new XMLDBTable('dialogue_read');
        /// Adding fields to table dialogue_read
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('entryid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('firstread', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('lastread', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table dialogue_read
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('dialogueread_entryid_userid_uk', XMLDB_KEY_UNIQUE, array('entryid', 'userid'));
        /// Launch create table for dialogue_read
        $result = $result && create_table($table);
    }
    if ($result && $oldversion < 2007112201) {
        /// Define field conversationid to be added to dialogue_read
        $table = new XMLDBTable('dialogue_read');
        $field = new XMLDBField('conversationid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null, 'lastread');
        /// Launch add field conversationid
        $result = $result && add_field($table, $field);
        /// Define key dialogueread_conversation_fk (foreign) to be added to dialogue_read
        $table = new XMLDBTable('dialogue_read');
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:upgrade.php


注:本文中的XMLDBTable::addFieldInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。