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


PHP drop_field函数代码示例

本文整理汇总了PHP中drop_field函数的典型用法代码示例。如果您正苦于以下问题:PHP drop_field函数的具体用法?PHP drop_field怎么用?PHP drop_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drop_field函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xmldb_block_student_gradeviewer_upgrade

function xmldb_block_student_gradeviewer_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2010070912) {
        /// Define field opt to be dropped from block_teacher_referral_opt
        $table = new XMLDBTable('block_teacher_referral_opt');
        // First let's drop the index
        $index = new XMLDBIndex('bloc_tea_usesec_uix');
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('usersid', 'sectionsid'));
        $failing_field = new XMLDBField('failing');
        $lagging_field = new XMLDBField('lagging');
        $usersid_field = new XMLDBField('usersid');
        /// Launch drop field opt
        $result = $result && drop_index($table, $index) && drop_field($table, $usersid_field) && drop_field($table, $lagging_field) && drop_field($table, $failing_field);
        // Add the following fields
        $fields = array('sectionsid', 'primary_instructor', 'non_primary_instructor', 'student', 'non_primary_control');
        foreach (range(1, count($fields) - 1) as $index) {
            $field = new XMLDBField($fields[$index]);
            $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', $fields[$index - 1]);
            $result = $result && add_field($table, $field);
        }
        $index = new XMLDBIndex('bloc_tea_usesec_uix');
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('sectionsid'));
        $result = $result && add_index($table, $index);
    }
    return $result;
}
开发者ID:rrusso,项目名称:EARS,代码行数:28,代码来源:upgrade.php

示例2: xmldb_elis_core_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 core
 * @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_elis_core_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2011030402) {
        /***********************************************************************
         * Replace plugintype and pluginname with plugin field
         **********************************************************************/
        /// Define field plugin to be added to elis_scheduled_tasks
        $table = new XMLDBTable('elis_scheduled_tasks');
        $field = new XMLDBField('plugin');
        $field->setAttributes(XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null, null, null, 'id');
        /// Launch add field plugin
        $result = $result && add_field($table, $field);
        /// Define index plugin_idx (not unique) to be dropped form elis_scheduled_tasks
        $index = new XMLDBIndex('plugin_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('plugintype', 'pluginname', 'taskname'));
        /// Launch drop index plugin_idx
        $result = $result && drop_index($table, $index);
        /// Define index plugin_idx (not unique) to be added to elis_scheduled_tasks
        $index = new XMLDBIndex('plugin_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('plugin', 'taskname'));
        /// Launch add index plugin_idx
        $result = $result && add_index($table, $index);
        /// Define field plugin to be dropped from elis_scheduled_tasks
        $field = new XMLDBField('plugintype');
        /// Launch drop field plugin
        $result = $result && drop_field($table, $field);
        /// Define field plugin to be dropped from elis_scheduled_tasks
        $field = new XMLDBField('pluginname');
        /// Launch drop field plugin
        $result = $result && drop_field($table, $field);
        /***********************************************************************
         * Change callfunction from text to char
         **********************************************************************/
        /// Changing type of field callfunction on table elis_scheduled_tasks to char
        $field = new XMLDBField('callfunction');
        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'callfile');
        /// Launch change of type for field callfunction
        $result = $result && change_field_type($table, $field);
    }
    if ($result && $oldversion < 2011030403) {
        /// Define field startdate to be added to elis_scheduled_tasks
        $table = new XMLDBTable('elis_scheduled_tasks');
        $field = new XMLDBField('startdate');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'runsremaining');
        /// Launch add field startdate
        $result = $result && add_field($table, $field);
    }
    return $result;
}
开发者ID:benavidesrobert,项目名称:elis.base,代码行数:75,代码来源:upgrade.php

示例3: xmldb_glossary_upgrade

function xmldb_glossary_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 < 2006111400) {
        /// MDL-10475, set override for legacy:student before dropping studentcanpost
        /// if the glossary disables student postings
        if ($glossaries = get_records('glossary', 'studentcanpost', '0')) {
            foreach ($glossaries as $glossary) {
                if ($cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
                    // add student override in this instance
                    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                    // find all roles with legacy:student
                    if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
                        foreach ($studentroles as $studentrole) {
                            assign_capability('mod/glossary:write', CAP_PREVENT, $studentrole->id, $context->id);
                        }
                    }
                }
            }
        }
        /// Define field studentcanpost to be dropped from glossary
        $table = new XMLDBTable('glossary');
        $field = new XMLDBField('studentcanpost');
        /// Launch drop field studentcanpost
        $result = $result && drop_field($table, $field);
    }
    if ($result && $oldversion < 2007072200) {
        require_once $CFG->dirroot . '/mod/glossary/lib.php';
        // too much debug output
        $db->debug = false;
        glossary_update_grades();
        $db->debug = true;
    }
    //===== 1.9.0 upgrade line ======//
    return $result;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:44,代码来源:upgrade.php

示例4: xmldb_interaction_forum_upgrade


//.........这里部分代码省略.........
                    insert_record('interaction_forum_subscription_' . $type, (object) array('user' => $dupe->user, $type => $dupe->{$type}));
                }
            }
            // Step 2: add the actual key
            $table = new XMLDBTable('interaction_forum_subscription_' . $type);
            $key = new XMLDBKey('primary');
            $key->setAttributes(XMLDB_KEY_PRIMARY, array('user', $type));
            add_key($table, $key);
            // Add a 'key' column, used for unsubscriptions
            $field = new XMLDBField('key');
            $field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, null);
            add_field($table, $field);
            $key = new XMLDBKey('keyuk');
            $key->setAttributes(XMLDB_KEY_UNIQUE, array('key'));
            add_key($table, $key);
            // Populate the key column
            if ($records = get_records_array('interaction_forum_subscription_' . $type, '', '', '', '"user", ' . $type)) {
                foreach ($records as $where) {
                    $new = (object) array('user' => $where->user, $type => $where->{$type}, 'key' => dechex(mt_rand()));
                    update_record('interaction_forum_subscription_' . $type, $new, $where);
                }
            }
            // Now make the key column not null
            $field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, XMLDB_NOTNULL);
            change_field_notnull($table, $field);
        }
    }
    if ($oldversion < 2009081700) {
        if (!get_record('interaction_config', 'plugin', 'forum', 'field', 'postdelay')) {
            insert_record('interaction_config', (object) array('plugin' => 'forum', 'field' => 'postdelay', 'value' => 30));
        }
    }
    if ($oldversion < 2009081800) {
        $subscription = (object) array('plugin' => 'forum', 'event' => 'creategroup', 'callfunction' => 'create_default_forum');
        ensure_record_exists('interaction_event_subscription', $subscription, $subscription);
    }
    if ($oldversion < 2012071100) {
        // Add new column 'path' to table interaction_forum_post used for diplaying posts by threads
        $table = new XMLDBTable('interaction_forum_post');
        $field = new XMLDBField('path');
        $field->setAttributes(XMLDB_TYPE_CHAR, 2048, null, null);
        add_field($table, $field);
        $index = new XMLDBIndex('pathix');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('path'));
        add_index($table, $index);
        // Update the column 'path' for all posts in the old database
        $done = 0;
        $lastid = 0;
        $pwcount = count_records('interaction_forum_post');
        if (is_mysql()) {
            $mp = mysql_get_variable('max_allowed_packet');
            $limit = $mp && is_numeric($mp) && $mp > 1048576 ? $mp / 8192 : 100;
        } else {
            $limit = 2000;
        }
        while ($posts = get_records_select_array('interaction_forum_post', 'id > ?', array($lastid), 'id', 'id, parent', 0, $limit)) {
            foreach ($posts as $post) {
                // Update the column 'path'
                $path = sprintf('%010d', $post->id);
                $parentid = $post->parent;
                while (!empty($parentid)) {
                    if ($p = get_record_select('interaction_forum_post', 'id = ?', array($parentid), 'parent, path')) {
                        if (!empty($p->path)) {
                            $path = $p->path . '/' . $path;
                            break;
                        }
                        $path = sprintf('%010d', $parentid) . '/' . $path;
                        $parentid = $p->parent;
                    } else {
                        throw new SQLException("Can't find the post with id = '{$parentid}'");
                    }
                }
                $post->path = $path;
                update_record('interaction_forum_post', $post);
                $lastid = $post->id;
            }
            $done += count($posts);
            log_debug("Updating posts' path: {$done}/{$pwcount}");
            set_time_limit(50);
        }
    }
    if ($oldversion < 2014050800) {
        // Subscribe admins to new activity.
        $adminusers = get_column('usr', 'id', 'admin', 1, 'deleted', 0);
        activity_add_admin_defaults($adminusers);
    }
    if ($oldversion < 2014060500) {
        // Drop unused fields.
        $table = new XMLDBTable('interaction_forum_post');
        $field = new XMLDBField('reported');
        if (field_exists($table, $field)) {
            drop_field($table, $field, true);
        }
        $field = new XMLDBField('reportedreason');
        if (field_exists($table, $field)) {
            drop_field($table, $field, true);
        }
    }
    return true;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:upgrade.php

示例5: question_upgrade_context_etc

function question_upgrade_context_etc()
{
    global $CFG;
    $result = true;
    $result = $result && question_delete_unused_random();
    $question_categories = get_records('question_categories');
    if ($question_categories) {
        //prepare content for new db structure
        $tofix = question_cwqpfs_to_update($question_categories);
        foreach ($tofix as $catid => $publish) {
            $question_categories[$catid]->publish = $publish;
        }
        foreach ($question_categories as $id => $question_category) {
            $course = $question_categories[$id]->course;
            unset($question_categories[$id]->course);
            if ($question_categories[$id]->publish) {
                $context = get_context_instance(CONTEXT_SYSTEM);
                //new name with old course name in brackets
                $coursename = get_field('course', 'shortname', 'id', $course);
                $question_categories[$id]->name .= " ({$coursename})";
            } else {
                $context = get_context_instance(CONTEXT_COURSE, $course);
            }
            $question_categories[$id]->contextid = $context->id;
            unset($question_categories[$id]->publish);
        }
        $question_categories = question_category_checking($question_categories);
    }
    /// Define index course (not unique) to be dropped form question_categories
    $table = new XMLDBTable('question_categories');
    $index = new XMLDBIndex('course');
    $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
    /// Launch drop index course
    $result = $result && drop_index($table, $index);
    /// Define field course to be dropped from question_categories
    $field = new XMLDBField('course');
    /// Launch drop field course
    $result = $result && drop_field($table, $field);
    /// Define field context to be added to question_categories
    $field = new XMLDBField('contextid');
    $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'name');
    $field->comment = 'context that this category is shared in';
    /// Launch add field context
    $result = $result && add_field($table, $field);
    /// Define index context (not unique) to be added to question_categories
    $index = new XMLDBIndex('contextid');
    $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('contextid'));
    $index->comment = 'links to context table';
    /// Launch add index context
    $result = $result && add_index($table, $index);
    $field = new XMLDBField('publish');
    /// Launch drop field publish
    $result = $result && drop_field($table, $field);
    /// update table contents with previously calculated new contents.
    if ($question_categories) {
        foreach ($question_categories as $question_category) {
            $question_category->name = addslashes($question_category->name);
            $question_category->info = addslashes($question_category->info);
            if (!($result = update_record('question_categories', $question_category))) {
                notify('Couldn\'t update question_categories "' . $question_category->name . '"!');
            }
        }
    }
    /// Define field timecreated to be added to question
    $table = new XMLDBTable('question');
    $field = new XMLDBField('timecreated');
    $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'hidden');
    /// Launch add field timecreated
    $result = $result && add_field($table, $field);
    /// Define field timemodified to be added to question
    $table = new XMLDBTable('question');
    $field = new XMLDBField('timemodified');
    $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timecreated');
    /// Launch add field timemodified
    $result = $result && add_field($table, $field);
    /// Define field createdby to be added to question
    $table = new XMLDBTable('question');
    $field = new XMLDBField('createdby');
    $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'timemodified');
    /// Launch add field createdby
    $result = $result && add_field($table, $field);
    /// Define field modifiedby to be added to question
    $table = new XMLDBTable('question');
    $field = new XMLDBField('modifiedby');
    $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'createdby');
    /// Launch add field modifiedby
    $result = $result && add_field($table, $field);
    /// Define key createdby (foreign) to be added to question
    $table = new XMLDBTable('question');
    $key = new XMLDBKey('createdby');
    $key->setAttributes(XMLDB_KEY_FOREIGN, array('createdby'), 'user', array('id'));
    /// Launch add key createdby
    $result = $result && add_key($table, $key);
    /// Define key modifiedby (foreign) to be added to question
    $table = new XMLDBTable('question');
    $key = new XMLDBKey('modifiedby');
    $key->setAttributes(XMLDB_KEY_FOREIGN, array('modifiedby'), 'user', array('id'));
    /// Launch add key modifiedby
    $result = $result && add_key($table, $key);
    return $result;
//.........这里部分代码省略.........
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:upgrade.php

示例6: xmldb_block_email_list_upgrade

function xmldb_block_email_list_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 < 2007062205) {
        $fields = array('mod/email:viewmail', 'mod/email:addmail', 'mod/email:reply', 'mod/email:replyall', 'mod/email:forward', 'mod/email:addsubfolder', 'mod/email:updatesubfolder', 'mod/email:removesubfolder');
        /// Remove no more used fields
        $table = new XMLDBTable('capabilities');
        foreach ($fields as $name) {
            $field = new XMLDBField($name);
            $result = $result && drop_field($table, $field);
        }
        // Active cron block of email_list
        if ($result) {
            if ($email_list = get_record('block', 'name', 'email_list')) {
                $email_list->cron = 1;
                update_record('block', $email_list);
            }
        }
    }
    // force
    $result = true;
    if ($result && $oldversion < 2007072003) {
        // Add marriedfolder2courses flag on email_preferences
        $table = new XMLDBTable('email_preference');
        $field = new XMLDBField('marriedfolders2courses');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
        $result = $result && add_field($table, $field);
        // Add course ID on email_folder
        $table = new XMLDBTable('email_folder');
        $field = new XMLDBField('course');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
        $result = $result && add_field($table, $field);
        // Add index
        $key = new XMLDBKey('course');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'course', array('id'));
        $result = $result && add_key($table, $key);
    }
    if ($result && $oldversion < 2008061400) {
        // Add reply and forwarded info field on email_mail.
        $table = new XMLDBTable('email_send');
        $field = new XMLDBField('answered');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
        $result = $result && add_field($table, $field);
    }
    // Solve old problems
    if ($result && $oldversion < 2008061600) {
        $table = new XMLDBTable('email_preference');
        $field = new XMLDBField('marriedfolders2courses');
        if (!field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
            $result = $result && add_field($table, $field);
        }
        $table = new XMLDBTable('email_folder');
        $field = new XMLDBField('course');
        if (!field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
            $result = $result && add_field($table, $field);
            // Add index
            $key = new XMLDBKey('course');
            $key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'course', array('id'));
            $result = $result && add_key($table, $key);
        }
    }
    // Add new index
    if ($result and $oldversion < 2008081600) {
        // Add combine key on foldermail
        $table = new XMLDBTable('email_foldermail');
        $index = new XMLDBIndex('folderid-mailid');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('folderid', 'mailid'));
        if (!index_exists($table, $index)) {
            /// Launch add index
            $result = $result && add_index($table, $index);
        }
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:81,代码来源:upgrade.php

示例7: install_group_db


//.........这里部分代码省略.........
    $table->addFieldInfo('viewallgroupsactivities', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
    $table->addFieldInfo('teachersgroupmark', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
    $table->addFieldInfo('teachersgroupview', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
    $table->addFieldInfo('teachersoverride', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
    $table->addFieldInfo('teacherdeletable', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
    /// Adding keys to table groups_groupings
    $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
    /// Launch create table for groups_groupings
    $result = $result && create_table($table);
    /// 7) Add the whole groups_courses_groups table (as is in 1.8.2+)
    /// Define table groups_courses_groups to be created
    $table = new XMLDBTable('groups_courses_groups');
    /// Adding fields to table groups_courses_groups
    $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
    $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
    $table->addFieldInfo('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
    /// Adding keys to table groups_courses_groups
    $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
    $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
    $table->addKeyInfo('groupid', XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
    /// Adding indexes to table groups_courses_groups
    $table->addIndexInfo('courseid-groupid', XMLDB_INDEX_UNIQUE, array('courseid', 'groupid'));
    /// Launch create table for groups_courses_groups
    $result = $result && create_table($table);
    /// 8) Add the whole groups_courses_groupings table (as is in 1.8.2+)
    /// Define table groups_courses_groupings to be created
    $table = new XMLDBTable('groups_courses_groupings');
    /// Adding fields to table groups_courses_groupings
    $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
    $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
    $table->addFieldInfo('groupingid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
    /// Adding keys to table groups_courses_groupings
    $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
    $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
    $table->addKeyInfo('groupingid', XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
    /// Adding indexes to table groups_courses_groupings
    $table->addIndexInfo('courseid-groupingid', XMLDB_INDEX_UNIQUE, array('courseid', 'groupingid'));
    /// Launch create table for groups_courses_groupings
    $result = $result && create_table($table);
    /// 9) Add the whole groups_groupings_groups table (as is in 1.8.2+)
    /// Define table groups_groupings_groups to be created
    $table = new XMLDBTable('groups_groupings_groups');
    /// Adding fields to table groups_groupings_groups
    $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
    $table->addFieldInfo('groupingid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
    $table->addFieldInfo('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
    $table->addFieldInfo('timeadded', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
    /// Adding keys to table groups_groupings_groups
    $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
    $table->addKeyInfo('groupingid', XMLDB_KEY_FOREIGN, array('groupingid'), 'groups_groupings', array('id'));
    $table->addKeyInfo('groupid', XMLDB_KEY_FOREIGN, array('groupid'), 'groups', array('id'));
    /// Adding indexes to table groups_groupings_groups
    $table->addIndexInfo('groupingid-groupid', XMLDB_INDEX_UNIQUE, array('groupingid', 'groupid'));
    /// Launch create table for groups_groupings_groups
    $result = $result && create_table($table);
    /// 10) Insert one record in log_display (module, action, mtable, field)
    ///     VALUES ('group', 'view', 'groups', 'name') IF it doesn't exist.
    if (!record_exists('log_display', 'module', 'group', 'action', 'view')) {
        $rec = new object();
        $rec->module = 'group';
        $rec->action = 'view';
        $rec->mtable = 'groups';
        $rec->field = 'name';
        $result = $result && insert_record('log_display', $rec);
    }
    /// 11) PERFORM ALL THE NEEDED MOVEMENTS OF DATA
    $db->debug = false;
    // suppressing because there can be too many
    /// a) get the current groups, foreach one add an entry in groups_courses_groups
    if ($result and $oldgroups = get_records('groups')) {
        foreach ($oldgroups as $oldgroup) {
            $rec = new Object();
            $rec->courseid = $oldgroup->courseid;
            $rec->groupid = $oldgroup->id;
            $rec->timeadded = $oldgroup->timemodified;
            // I think this is not needed since the field is gone?
            $result = $result && insert_record('groups_courses_groups', $rec);
        }
    }
    $db->debug = true;
    /// TODO, TODO, TODO. At this point is where all the data must be populated to new tables!!
    /// 12) Drop the groups->courseid index
    /// Define index courseid (not unique) to be dropped form groups
    $table = new XMLDBTable('groups');
    $index = new XMLDBIndex('courseid');
    $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('courseid'));
    /// Launch drop index courseid
    $result = $result && drop_index($table, $index);
    /// 13) Drop the groups->courseid field
    /// Define field courseid to be dropped from groups
    $field = new XMLDBField('courseid');
    /// Launch drop field courseid
    $result = $result && drop_field($table, $field);
    $db->debug = false;
    if (!$result or !set_config('group_version', $group_version)) {
        error("Upgrade of group system failed!");
    }
    notify(get_string('databasesuccess'), 'green');
    notify(get_string('databaseupgradegroups', '', $group_version), 'green');
}
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:upgrade.php

示例8: invoke


//.........这里部分代码省略.........
     }
     /// Insert two records to do the work with real data
     $rec->course = 1;
     $rec->name = 'Martin';
     $rec->secondname = 'Dougiamas';
     $rec->intro = 'The creator of Moodle';
     $rec->grade = 10.0001;
     insert_record('anothertest', $rec);
     $rec->course = 2;
     $rec->name = 'Eloy';
     $rec->secondname = 'Lafuente';
     $rec->intro = 'One poor developer';
     $rec->grade = 9.99;
     insert_record('anothertest', $rec);
     /// 4th test. Adding one complex enum field
     if ($test->status) {
         /// Create a new field with complex specs (enums are good candidates)
         $field = new XMLDBField('type');
         $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
         /// Get SQL code and execute it
         $test = new stdClass();
         $test->sql = $table->getAddFieldSQL($CFG->dbtype, $CFG->prefix, $field, true);
         $test->status = add_field($table, $field, false, false);
         if (!$test->status) {
             $test->error = $db->ErrorMsg();
         }
         $tests['add enum field'] = $test;
     }
     /// 5th test. Dropping one complex enum field
     if ($test->status) {
         /// Create a new field with complex specs (enums are good candidates)
         $test = new stdClass();
         $test->sql = $table->getDropFieldSQL($CFG->dbtype, $CFG->prefix, $field, true);
         $test->status = drop_field($table, $field, false, false);
         if (!$test->status) {
             $test->error = $db->ErrorMsg();
         }
         $tests['drop enum field'] = $test;
     }
     /// 6th test. Adding one complex enum field
     if ($test->status) {
         /// Create a new field with complex specs (enums are good candidates)
         $field = new XMLDBField('type');
         $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
         /// Get SQL code and execute it
         $test = new stdClass();
         $test->sql = $table->getAddFieldSQL($CFG->dbtype, $CFG->prefix, $field, true);
         $test->status = add_field($table, $field, false, false);
         if (!$test->status) {
             $test->error = $db->ErrorMsg();
         }
         $tests['add enum field again'] = $test;
     }
     /// 7th test. Adding one numeric field
     if ($test->status) {
         /// Create a new field (numeric)
         $field = new XMLDBField('onenumber');
         $field->setAttributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'type');
         /// Get SQL code and execute it
         $test = new stdClass();
         $test->sql = $table->getAddFieldSQL($CFG->dbtype, $CFG->prefix, $field, true);
         $test->status = add_field($table, $field, false, false);
         if (!$test->status) {
             $test->error = $db->ErrorMsg();
         }
         $tests['add numeric field'] = $test;
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:67,代码来源:test.class.php

示例9: xmldb_scorm_upgrade

function xmldb_scorm_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2006103100) {
        /// Create the new sco optionals data table
        /// Define table scorm_scoes_data to be created
        $table = new XMLDBTable('scorm_scoes_data');
        /// 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('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', 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 scorm_scoes_data
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        /// Adding indexes to table scorm_scoes_data
        $table->addIndexInfo('scoid', XMLDB_INDEX_NOTUNIQUE, array('scoid'));
        /// Launch create table for scorm_scoes_data
        $result = $result && create_table($table);
        /// The old fields used in scorm_scoes
        $fields = array('parameters' => '', 'prerequisites' => '', 'maxtimeallowed' => '', 'timelimitaction' => '', 'datafromlms' => '', 'masteryscore' => '', 'next' => '0', 'previous' => '0');
        /// Retrieve old datas
        if ($scorms = get_records('scorm')) {
            foreach ($scorms as $scorm) {
                if ($olddatas = get_records('scorm_scoes', 'scorm', $scorm->id)) {
                    foreach ($olddatas as $olddata) {
                        $newdata = new stdClass();
                        $newdata->scoid = $olddata->id;
                        foreach ($fields as $field => $value) {
                            if ($olddata->{$field} != $value) {
                                $newdata->name = addslashes($field);
                                $newdata->value = addslashes($olddata->{$field});
                                $id = insert_record('scorm_scoes_data', $newdata);
                                $result = $result && $id != 0;
                            }
                        }
                    }
                }
            }
        }
        /// Remove no more used fields
        $table = new XMLDBTable('scorm_scoes');
        foreach ($fields as $field => $value) {
            $field = new XMLDBField($field);
            $result = $result && drop_field($table, $field);
        }
    }
    if ($result && $oldversion < 2006120900) {
        /// Define table scorm_seq_objective to be created
        $table = new XMLDBTable('scorm_seq_objective');
        /// Adding fields to table scorm_seq_objective
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('primaryobj', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('objectiveid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('satisfiedbymeasure', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
        $table->addFieldInfo('minnormalizedmeasure', XMLDB_TYPE_FLOAT, '11, 4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0.0000');
        /// Adding keys to table scorm_seq_objective
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('scorm_objective_uniq', XMLDB_KEY_UNIQUE, array('scoid', 'id'));
        $table->addKeyInfo('scorm_objective_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
        /// Launch create table for scorm_seq_objective
        $result = $result && create_table($table);
        /// Define table scorm_seq_mapinfo to be created
        $table = new XMLDBTable('scorm_seq_mapinfo');
        /// Adding fields to table scorm_seq_mapinfo
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('objectiveid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('targetobjectiveid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('readsatisfiedstatus', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
        $table->addFieldInfo('readnormalizedmeasure', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
        $table->addFieldInfo('writesatisfiedstatus', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('writenormalizedmeasure', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '0');
        /// Adding keys to table scorm_seq_mapinfo
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('scorm_mapinfo_uniq', XMLDB_KEY_UNIQUE, array('scoid', 'id', 'objectiveid'));
        $table->addKeyInfo('scorm_mapinfo_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
        $table->addKeyInfo('scorm_mapinfo_objectiveid', XMLDB_KEY_FOREIGN, array('objectiveid'), 'scorm_seq_objective', array('id'));
        /// Launch create table for scorm_seq_mapinfo
        $result = $result && create_table($table);
        /// Define table scorm_seq_ruleconds to be created
        $table = new XMLDBTable('scorm_seq_ruleconds');
        /// Adding fields to table scorm_seq_ruleconds
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('conditioncombination', XMLDB_TYPE_CHAR, '3', null, XMLDB_NOTNULL, null, null, null, 'all');
        $table->addFieldInfo('ruletype', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('action', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table scorm_seq_ruleconds
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('scorm_ruleconds_un', XMLDB_KEY_UNIQUE, array('scoid', 'id'));
        $table->addKeyInfo('scorm_ruleconds_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
        /// Launch create table for scorm_seq_ruleconds
        $result = $result && create_table($table);
        /// Define table scorm_seq_rulecond to be created
        $table = new XMLDBTable('scorm_seq_rulecond');
        /// Adding fields to table scorm_seq_rulecond
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('scoid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:upgrade.php

示例10: xmldb_assignment_type_onlinejudge_upgrade

function xmldb_assignment_type_onlinejudge_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2010032700) {
        /// Define field ratiope to be added to assignment_oj
        $table = new XMLDBTable('assignment_oj');
        $field = new XMLDBField('ratiope');
        $field->setAttributes(XMLDB_TYPE_NUMBER, '20, 10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0.0', 'compileonly');
        /// Launch add field ratiope
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2010040701) {
        /// Define index judged (not unique) to be added to assignment_oj_submissions
        $table = new XMLDBTable('assignment_oj_submissions');
        $index = new XMLDBIndex('judged');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('judged'));
        /// Launch add index judged
        $result = $result && add_index($table, $index);
        /// Define index judgetime (not unique) to be added to assignment_oj_results
        $table = new XMLDBTable('assignment_oj_results');
        $index = new XMLDBIndex('judgetime');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('judgetime'));
        /// Launch add index judgetime
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2010042800) {
        /// Define field duejudge to be dropped from assignment_oj
        $table = new XMLDBTable('assignment_oj');
        $field = new XMLDBField('duejudge');
        /// Launch drop field duejudge
        $result = $result && drop_field($table, $field);
        /// Define key test (foreign) to be dropped form assignment_oj_results
        $table = new XMLDBTable('assignment_oj_results');
        $key = new XMLDBKey('test');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('test'), 'assignment_oj_tests', array('id'));
        /// Launch drop key test
        $result = $result && drop_key($table, $key);
        /// Define field test to be dropped from assignment_oj_results
        $field = new XMLDBField('test');
        /// Launch drop field test
        $result = $result && drop_field($table, $field);
    }
    if ($result && $oldversion < 2010070400) {
        /// Define field usefile to be added to assignment_oj_tests
        $table = new XMLDBTable('assignment_oj_tests');
        $field = new XMLDBField('usefile');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'output');
        /// Launch add field usefile
        $result = $result && add_field($table, $field);
        /// Define field inputfile to be added to assignment_oj_tests
        $table = new XMLDBTable('assignment_oj_tests');
        $field = new XMLDBField('inputfile');
        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'usefile');
        /// Launch add field inputfile
        $result = $result && add_field($table, $field);
        /// Define field outputfile to be added to assignment_oj_tests
        $table = new XMLDBTable('assignment_oj_tests');
        $field = new XMLDBField('outputfile');
        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'inputfile');
        /// Launch add field outputfile
        $result = $result && add_field($table, $field);
        /// Changing type of field subgrade on table assignment_oj_tests to number
        $table = new XMLDBTable('assignment_oj_tests');
        $field = new XMLDBField('subgrade');
        $field->setAttributes(XMLDB_TYPE_NUMBER, '20, 10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'feedback');
        /// Launch change of type for field subgrade
        $result = $result && change_field_type($table, $field);
        /// Upgrade the value in subgrade field
        if ($result) {
            $ojs = get_records('assignment_oj');
            foreach ($ojs as $oj) {
                $modgrade = get_field('assignment', 'grade', 'id', $oj->assignment);
                if ($modgrade) {
                    $sql = 'UPDATE ' . $CFG->prefix . 'assignment_oj_tests ' . 'SET subgrade=subgrade/' . $modgrade . ' ' . 'WHERE assignment=' . $oj->assignment;
                    $result = $result && execute_sql($sql);
                }
            }
        }
    }
    // Tell the daemon to exit
    set_config('assignment_oj_daemon_pid', '0');
    return $result;
}
开发者ID:hit-moodle,项目名称:onlinejudge,代码行数:84,代码来源:upgrade.php

示例11: xmldb_block_email_list_upgrade

function xmldb_block_email_list_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $DB;
    $result = true;
    // If is set upgrade_blocks_savepoint function
    $existfunction = false;
    if (!function_exists('upgrade_blocks_savepoint')) {
        $existfunction = 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 < 2007062205) {
        $fields = array('mod/email:viewmail', 'mod/email:addmail', 'mod/email:reply', 'mod/email:replyall', 'mod/email:forward', 'mod/email:addsubfolder', 'mod/email:updatesubfolder', 'mod/email:removesubfolder');
        /// Remove no more used fields
        $table = new XMLDBTable('capabilities');
        foreach ($fields as $name) {
            $field = new XMLDBField($name);
            $result = $result && drop_field($table, $field);
        }
        // Active cron block of email_list
        if ($result) {
            if ($email_list = get_record('block', 'name', 'email_list')) {
                $email_list->cron = 1;
                update_record('block', $email_list);
            }
        }
        if ($existfunction) {
            /// Block savepoint reached
            upgrade_blocks_savepoint($result, 2007062205, 'email_list');
        }
    }
    // force
    $result = true;
    if ($result && $oldversion < 2007072003) {
        // Add marriedfolder2courses flag on email_preferences
        $table = new XMLDBTable('email_preference');
        $field = new XMLDBField('marriedfolders2courses');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
        $result = $result && add_field($table, $field);
        // Add course ID on email_folder
        $table = new XMLDBTable('email_folder');
        $field = new XMLDBField('course');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
        $result = $result && add_field($table, $field);
        // Add index
        $key = new XMLDBKey('course');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'course', array('id'));
        $result = $result && add_key($table, $key);
        if ($existfunction) {
            /// Block savepoint reached
            upgrade_blocks_savepoint($result, 2007072003, 'email_list');
        }
    }
    if ($result && $oldversion < 2008061400) {
        // Add reply and forwarded info field on email_mail.
        $table = new XMLDBTable('email_send');
        $field = new XMLDBField('answered');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
        $result = $result && add_field($table, $field);
        if ($existfunction) {
            /// Block savepoint reached
            upgrade_blocks_savepoint($result, 2008061400, 'email_list');
        }
    }
    // Solve old problems
    if ($result && $oldversion < 2008061600) {
        $table = new XMLDBTable('email_preference');
        $field = new XMLDBField('marriedfolders2courses');
        if (!field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
            $result = $result && add_field($table, $field);
        }
        $table = new XMLDBTable('email_folder');
        $field = new XMLDBField('course');
        if (!field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
            $result = $result && add_field($table, $field);
            // Add index
            $key = new XMLDBKey('course');
            $key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'course', array('id'));
            $result = $result && add_key($table, $key);
        }
        if ($existfunction) {
            /// Block savepoint reached
            upgrade_blocks_savepoint($result, 2008061600, 'email_list');
        }
    }
    // Add new index
    if ($result and $oldversion < 2008081602) {
        // Add combine key on foldermail
        $table = new XMLDBTable('email_foldermail');
        $index = new XMLDBIndex('folderid-mailid');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('folderid', 'mailid'));
        if (!index_exists($table, $index)) {
            /// Launch add index
            $result = $result && add_index($table, $index);
        }
        if ($existfunction) {
//.........这里部分代码省略.........
开发者ID:henriquecrang,项目名称:e-UNI,代码行数:101,代码来源:upgrade.php

示例12: xmldb_geogebra_upgrade

/**
 * Execute geogebra upgrade from the given old version
 *
 * @param int $oldversion
 * @return bool
 */
function xmldb_geogebra_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // loads ddl manager and xmldb classes
    if ($oldversion < 2012030100) {
        //Add grade field
        $table = new XMLDBTable('geogebra');
        $field = new XMLDBField('grade');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '100', 'showsubmit');
        $result = $result && add_field($table, $field);
        //Add autograde field
        $field = new XMLDBField('autograde');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'grade');
        $result = $result && add_field($table, $field);
        //Delete maxgrade field
        $field = new XMLDBField('maxgrade');
        $result = $result && drop_field($table, $field);
        //Make maxattempts signed
        $field = new XMLDBField('maxattempts');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', false, XMLDB_NOTNULL, null, null, null, '-1', 'autograde');
        $result = $result && change_field_unsigned($table, $field);
        //Add gradecomment field
        $table = new XMLDBTable('geogebra_attempts');
        $field = new XMLDBField('gradecomment');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'vars');
        $result = $result && add_field($table, $field);
    }
    if ($oldversion < 2012030101) {
        $table = new XMLDBTable('geogebra_attempts');
        $field = new XMLDBField('dateteacher');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'finished');
        $result = $result && add_field($table, $field);
    }
    if ($oldversion < 2012082100) {
        $table = new XMLDBTable('geogebra');
        $field = new XMLDBField('url');
        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'intro');
        $result = $result && change_field_precision($table, $field);
        $table = new XMLDBTable('geogebra_attempts');
        $field = new XMLDBField('gradecomment');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, false, null, null, null, null, 'vars');
        $result = $result && change_field_notnull($table, $field);
        $field = new XMLDBField('date');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $result = $result && rename_field($table, $field, 'datestudent');
    }
    if ($oldversion < 2011122902) {
        /// Define field introformat to be added to geogebra
        $table = new xmldb_table('geogebra');
        $field = new xmldb_field('introformat');
        $field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
        /// Launch add field introformat
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // conditionally migrate to html format in intro
        if ($CFG->texteditors !== 'textarea') {
            $rs = $DB->get_recordset('geogebra', array('introformat' => FORMAT_MOODLE), '', 'id,intro,introformat');
            foreach ($rs as $f) {
                $f->intro = text_to_html($f->intro, false, false, true);
                $f->introformat = FORMAT_HTML;
                $DB->update_record('geogebra', $f);
                upgrade_set_timeout();
            }
            $rs->close();
        }
        /// geogebra savepoint reached
        upgrade_mod_savepoint(true, 2011122902, 'geogebra');
    }
    //===== 1.9.0 upgrade line ======//
    if ($oldversion < 2012042700) {
        require_once "{$CFG->dirroot}/mod/geogebra/db/upgradelib.php";
        // Add upgrading code from 1.9 (+ new file storage system)
        // @TODO: test it!!!!
        geogebra_migrate_files();
        // geogebra savepoint reached
        upgrade_mod_savepoint(true, 2012042700, 'geogebra');
    }
    if ($oldversion < 2013050600) {
        // @TODO: test it!!!!
        //Add atrributes field
        $table = new xmldb_table('geogebra');
        $field = new xmldb_field('attributes');
        $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'url');
        $dbman->add_field($table, $field);
        $rs = $DB->get_recordset('geogebra');
        foreach ($rs as $f) {
            parse_str($f->url, $parsedVarsURL);
            if (array_key_exists('filename', $parsedVarsURL)) {
                // From Moodle 2, URL field only contains information about the GGB file location
                $f->url = $parsedVarsURL['filename'];
                // Remove filename from parsedVarsURL array (to avoid save twice)
                unset($parsedVarsURL['filename']);
//.........这里部分代码省略.........
开发者ID:ninelanterns,项目名称:moodle-mod_geogebra,代码行数:101,代码来源:upgrade.php

示例13: xmldb_sloodle_upgrade


//.........这里部分代码省略.........
        $table->addFieldInfo('course', 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('position', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
        $table->addIndexInfo('userid', XMLDB_INDEX_UNIQUE, array('userid'));
        $result = $result && create_table($table);
        if (!$result) {
            echo "error<br/>";
        }
        /// Insert 'sloodle_user_object' table
        echo " - sloodle_user_object<br/>";
        $table = new XMLDBTable('sloodle_user_object');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('avuuid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('objuuid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('objname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('password', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('authorised', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('timeupdated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('objuuid', XMLDB_INDEX_UNIQUE, array('objuuid'));
        $result = $result && create_table($table);
        if (!$result) {
            echo "error<br/>";
        }
        /// Upgrade sloodle_users table
        echo "Upgrading sloodle_users table...<br/>";
        $table = new XMLDBTable('sloodle_users');
        echo " - dropping old fields<br/>";
        // Drop the loginzone fields (we don't care about success or otherwise... not all fields will be present in all versions)
        $field = new XMLDBField('loginposition');
        drop_field($table, $field);
        $field = new XMLDBField('loginpositionexpires');
        drop_field($table, $field);
        $field = new XMLDBField('loginpositionregion');
        drop_field($table, $field);
        $field = new XMLDBField('loginsecuritytoken');
        drop_field($table, $field);
        // Drop the old 'online' field (was going to be a boolean, but was never used)
        $field = new XMLDBField('online');
        drop_field($table, $field);
        // Add the new 'lastactive' field
        echo " - adding lastactive field<br/>";
        $field = new XMLDBField('lastactive');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'avname');
        $result = $result && add_field($table, $field);
        if (!$result) {
            echo "error<br/>";
        }
        /// Purge redundant avatar entries
        echo "Purging redundant avatar entries...<br/>";
        $sql = "    DELETE FROM {$CFG->prefix}sloodle_users\n                    WHERE userid = 0 OR uuid = '' OR avname = ''\n        ";
        execute_sql($sql);
    }
    if ($result && $oldversion < 2009020201) {
        /// Define table sloodle_presenter_entry to be created
        $table = new XMLDBTable('sloodle_presenter_entry');
        /// Adding fields to table sloodle_presenter_entry
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('sloodleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('source', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('type', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, 'web');
        $table->addFieldInfo('ordering', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table sloodle_presenter_entry
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:67,代码来源:upgrade.php

示例14: die

    die('HAL');
}
plugins_load_config();
LoadPluginLang('guestbook', 'config', '', 'gbconfig', '#');
switch ($_REQUEST['action']) {
    case 'manage_fields':
        manage_fields();
        break;
    case 'add_field':
        add_field();
        break;
    case 'edit_field':
        edit_field();
        break;
    case 'drop_field':
        drop_field();
        manage_fields();
        break;
    case 'insert_field':
        $result = insert_field();
        if ($result === TRUE) {
            manage_fields();
        } else {
            add_field();
        }
        break;
    case 'update_field':
        $result = update_field();
        if ($result === TRUE) {
            manage_fields();
        } else {
开发者ID:web-padawan,项目名称:ng_guestbook,代码行数:31,代码来源:config.php

示例15: wiki_drop_wikipagestable_fields

/**
 * Private function.
 *
 * This function drop useless fields of ewiki 'wiki_pages table'
 * after migration.
 *
 * @return boolean. true for success and false in case of error
 */
function wiki_drop_wikipagestable_fields()
{
    $table = new XMLDBTable('wiki_pages');
    $field = new XMLDBField('flags');
    $result = drop_field($table, $field);
    $field = new XMLDBField('meta');
    $result = $result && drop_field($table, $field);
    // We have to drop this key before dropping wiki field
    $key = new XMLDBKey('wiki');
    $key->setAttributes(XMLDB_KEY_UNIQUE, array("pagename", "version", "wiki"));
    $result = $result && drop_key($table, $key);
    $field = new XMLDBField('wiki');
    $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
    $result = $result && drop_field($table, $field);
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:24,代码来源:ewiki_migrate.php


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