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


PHP field_exists函数代码示例

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


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

示例1: xmldb_taoresource_upgrade

function xmldb_taoresource_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
    /// }
    //===== 1.9.0 upgrade line ======//
    // change the remoteid key to be non-unique
    if ($result && $oldversion < 2007101510) {
        $table = new XMLDBTable('taoresource_entry');
        $index = new XMLDBIndex('remoteid');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('remoteid'));
        if (index_exists($table, $index)) {
            $result = $result && drop_index($table, $index);
        }
        $result = $result && add_index($table, $index);
    }
    // change the remoteid key to be non-unique
    if ($result && $oldversion < 2007101511) {
        $table = new XMLDBTable('taoresource_metadata');
        $field = new XMLDBField('entry_id');
        // change the field type from ext to int
        if (field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
            $result = $result && change_field_type($table, $field);
        }
    }
    return $result;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:34,代码来源:upgrade.php

示例2: xmldb_lesson_upgrade

function xmldb_lesson_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2006091802) {
        /// Changing nullability of field response on table lesson_answers to null
        $table = new XMLDBTable('lesson_answers');
        $field = new XMLDBField('response');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'answer');
        /// Launch change of nullability for field response
        $result = $result && change_field_notnull($table, $field);
    }
    if ($result && $oldversion < 2006091803) {
        /// Changing nullability of field useranswer on table lesson_attempts to null
        $table = new XMLDBTable('lesson_attempts');
        $field = new XMLDBField('useranswer');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'correct');
        /// Launch change of nullability for field useranswer
        $result = $result && change_field_notnull($table, $field);
    }
    if ($result && $oldversion < 2007020201) {
        /// Changing nullability of field answer on table lesson_answers to null
        $table = new XMLDBTable('lesson_answers');
        $field = new XMLDBField('answer');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'timemodified');
        /// Launch change of nullability for field answer
        $result = $result && change_field_notnull($table, $field);
    }
    //===== 1.9.0 upgrade line ======//
    if ($result && $oldversion < 2007072201) {
        $table = new XMLDBTable('lesson');
        $field = new XMLDBField('usegrademax');
        $field2 = new XMLDBField('usemaxgrade');
        /// Rename lesson->usegrademax to lesson->usemaxgrade. Some old sites can have it incorrect. MDL-13177
        if (field_exists($table, $field) && !field_exists($table, $field2)) {
            /// Set field specs
            $field->setAttributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '0', 'ongoing');
            /// Launch rename field usegrademax to usemaxgrade
            $result = $result && rename_field($table, $field, 'usemaxgrade');
        }
    }
    if ($result && $oldversion < 2008112601) {
        require_once $CFG->dirroot . '/mod/lesson/lib.php';
        // too much debug output
        $db->debug = false;
        lesson_update_grades();
        $db->debug = true;
    }
    return $result;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:50,代码来源:upgrade.php

示例3: xmldb_enrol_authorize_upgrade

function xmldb_enrol_authorize_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2006111700) {
        $table = new XMLDBTable('enrol_authorize');
        if (!field_exists($table, new XMLDBField('refundinfo'))) {
            $field = new XMLDBField('cclastfour');
            $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'paymentmethod');
            $result = $result && rename_field($table, $field, 'refundinfo');
        }
    }
    if ($result && $oldversion < 2006112900) {
        if (isset($CFG->an_login)) {
            if (empty($CFG->an_login)) {
                unset_config('an_login');
            } else {
                $result = $result && set_config('an_login', rc4encrypt($CFG->an_login), 'enrol/authorize') && unset_config('an_login');
            }
        }
        if (isset($CFG->an_tran_key)) {
            if (empty($CFG->an_tran_key)) {
                unset_config('an_tran_key');
            } else {
                $result = $result && set_config('an_tran_key', rc4encrypt($CFG->an_tran_key), 'enrol/authorize') && unset_config('an_tran_key');
            }
        }
        if (isset($CFG->an_password)) {
            if (empty($CFG->an_password)) {
                unset_config('an_password');
            } else {
                $result = $result && set_config('an_password', rc4encrypt($CFG->an_password), 'enrol/authorize') && unset_config('an_password');
            }
        }
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:37,代码来源:upgrade.php

示例4: xmldb_tab_upgrade

function xmldb_tab_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 < 2010072101) {
        /// Define field anonymous_response to be added to feedback_completed
        $table = new XMLDBTable('tab');
        $field = new XMLDBField('displayfp');
        if (!field_exists($table, $field)) {
            // if field does not exists... add it
            $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
            $result = $result && add_field($table, $field);
        }
        // original mysql sql code: "ALTER TABLE `mdl_tab` CHANGE `displayfp` `displayfp` TINYINT( 1 ) NOT NULL DEFAULT '0'"
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:24,代码来源:upgrade.php

示例5: xmldb_data_upgrade

function xmldb_data_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 < 2006121300) {
        /// Define field format to be added to data_comments
        $table = new XMLDBTable('data_comments');
        $field = new XMLDBField('format');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'content');
        /// Launch add field format
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007022600) {
        /// Define field asearchtemplate to be added to data
        $table = new XMLDBTable('data');
        $field = new XMLDBField('asearchtemplate');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
        /// Launch add field asearchtemplate
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007072200) {
        require_once $CFG->dirroot . '/mod/data/lib.php';
        // too much debug output
        $db->debug = false;
        data_update_grades();
        $db->debug = true;
    }
    if ($result && $oldversion < 2007081400) {
        /// Define field notification to be added to data
        $table = new XMLDBTable('data');
        $field = new XMLDBField('notification');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'editany');
        /// Launch add field notification
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007081402) {
        /// Define index type-dataid (not unique) to be added to data_fields
        $table = new XMLDBTable('data_fields');
        $index = new XMLDBIndex('type-dataid');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('type', 'dataid'));
        /// Launch add index type-dataid
        if (!index_exists($table, $index)) {
            $result = $result && add_index($table, $index);
        }
        /// Define index course (not unique) to be added to data
        $table = new XMLDBTable('data');
        $index = new XMLDBIndex('course');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
        /// Launch add index course
        if (!index_exists($table, $index)) {
            $result = $result && add_index($table, $index);
        }
    }
    //===== 1.9.0 upgrade line ======//
    if ($result && $oldversion < 2007101512) {
        /// Launch add field asearchtemplate again if does not exists yet - reported on several sites
        $table = new XMLDBTable('data');
        $field = new XMLDBField('asearchtemplate');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
        if (!field_exists($table, $field)) {
            $result = $result && add_field($table, $field);
        }
    }
    return $result;
}
开发者ID:r007,项目名称:PMoodle,代码行数:72,代码来源:upgrade.php

示例6: xmldb_core_upgrade


//.........这里部分代码省略.........
        create_table($table);
        $table = new XMLDBTable('style_property');
        $table->addFieldInfo('style', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
        $table->addFieldInfo('field', XMLDB_TYPE_CHAR, 100, null, XMLDB_NOTNULL);
        $table->addFieldInfo('value', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('style', 'field'));
        $table->addKeyInfo('stylefk', XMLDB_KEY_FOREIGN, array('style'), 'style', array('id'));
        create_table($table);
        $table = new XMLDBTable('institution');
        $field = new XMLDBField('style');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10');
        add_field($table, $field);
        $key = new XMLDBKey('stylefk');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('style'), 'style', array('id'));
        add_key($table, $key);
    }
    if ($oldversion < 2011082200) {
        // Doing a direct insert of the new artefact type instead of running upgrade_plugin(), in order to support the
        // transition from old profile fields to the new socialprofile artefact in Mahara 1.10
        if (!record_exists('artefact_installed_type', 'name', 'html', 'plugin', 'internal')) {
            insert_record('artefact_installed_type', (object) array('name' => 'html', 'plugin' => 'internal'));
        }
        // Move the textbox blocktype into artefact/internal
        set_field('blocktype_installed', 'artefactplugin', 'internal', 'name', 'textbox');
        if ($data = check_upgrades("blocktype.internal/textbox")) {
            upgrade_plugin($data);
        }
    }
    if ($oldversion < 2011082300) {
        // Add institution to view_access table
        $table = new XMLDBTable('view_access');
        $field = new XMLDBField('institution');
        $field->setAttributes(XMLDB_TYPE_CHAR, 255, null, null);
        if (!field_exists($table, $field)) {
            add_field($table, $field);
            // Add foreign key
            $key = new XMLDBKey('institutionfk');
            $key->setAttributes(XMLDB_KEY_FOREIGN, array('institution'), 'institution', array('name'));
            add_key($table, $key);
            if (is_postgres()) {
                // Update constraint checks
                execute_sql('ALTER TABLE {view_access} DROP CONSTRAINT {view_access_check}');
                execute_sql('ALTER TABLE {view_access} ADD CHECK (
                    (accesstype IS NOT NULL AND "group" IS NULL     AND usr IS NULL     AND token IS NULL     AND institution IS NULL    ) OR
                    (accesstype IS NULL     AND "group" IS NOT NULL AND usr IS NULL     AND token IS NULL     AND institution IS NULL    ) OR
                    (accesstype IS NULL     AND "group" IS NULL     AND usr IS NOT NULL AND token IS NULL     AND institution IS NULL    ) OR
                    (accesstype IS NULL     AND "group" IS NULL     AND usr IS NULL     AND token IS NOT NULL AND institution IS NULL    ) OR
                    (accesstype IS NULL     AND "group" IS NULL     AND usr IS NULL     AND token IS NULL     AND institution IS NOT NULL))');
            } else {
                // MySQL doesn't support these types of constraints
            }
        }
    }
    if ($oldversion < 2011082400) {
        // Add cron entry for cache cleanup
        $cron = new StdClass();
        $cron->callfunction = 'file_cleanup_old_cached_files';
        $cron->minute = '0';
        $cron->hour = '1';
        $cron->day = '*';
        $cron->month = '*';
        $cron->dayofweek = '*';
        insert_record('cron', $cron);
    }
    if ($oldversion < 2011082401) {
        // Set config value for logged-in profile view access
开发者ID:patkira,项目名称:mahara,代码行数:67,代码来源:upgrade.php

示例7: wrsqz_update_database

/**
 * This function sets the data in the database to the good format. This function
 * have this properties:
 * 1 - does not depend on the previous version: it has to discover which changes to apply
 * 2 - (a corolary of 1) is idempotent, i.e, f(f(x)) = f(x)
 * **/
function wrsqz_update_database()
{
    //update shortanswer wirisCASForComputations field
    $updates = 0;
    $shortanswertable = new XMLDBTable('question_shortanswerwiris');
    if (table_exists($shortanswertable)) {
        $eqoptionfield = new XMLDBField('eqoption');
        if (field_exists($shortanswertable, $eqoptionfield)) {
            $saq = get_records('question_shortanswerwiris');
            foreach ($saq as $question) {
                if (trim($question->eqoption) != '') {
                    $decodedEqoption = array();
                    mb_parse_str($question->eqoption, $decodedEqoption);
                    if (isset($decodedEqoption['wirisCASForComputations'])) {
                        $wirisCASForComputations = $decodedEqoption['wirisCASForComputations'];
                        unset($decodedEqoption['wirisCASForComputations']);
                        $question->eqoption = http_build_query($decodedEqoption, null, '&');
                        if (!empty($question->options)) {
                            $options = unserialize($question->options);
                        } else {
                            $options = array();
                        }
                        $options['wirisCASForComputations'] = $wirisCASForComputations;
                        $question->options = serialize($options);
                        update_record('question_shortanswerwiris', $question);
                        $updates++;
                    }
                }
            }
        }
    }
    if ($updates) {
        echo utf8_htmlentities(translate('Updated shortanswer wirisCASForComputations field: ')) . $updates . utf8_htmlentities(translate(' records')) . '<br />';
    }
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:41,代码来源:db.php

示例8: xmldb_lightboxgallery_upgrade

function xmldb_lightboxgallery_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2007111400) {
        // Insert perpage and comments fields into lightboxgallery
        $table = new XMLDBTable('lightboxgallery');
        $field = new XMLDBField('perpage');
        if (!field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'description');
            $result = $result && add_field($table, $field);
        }
        $field = new XMLDBField('comments');
        if (!field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'perpage');
            $result = $result && add_field($table, $field);
        }
        // Create new lightboxgallery_comments table
        $table = new XMLDBTable('lightboxgallery_comments');
        if (!table_exists($table)) {
            $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
            $table->addFieldInfo('gallery', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
            $table->addFieldInfo('user', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
            $table->addFieldInfo('comment', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
            $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
            $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
            $table->addIndexInfo('gallery', XMLDB_INDEX_NOTUNIQUE, array('gallery'));
            $result = $result && create_table($table);
        }
        // Insert add_to_log entry to log_display table
        if (!record_exists('log_display', 'module', 'lightboxgallery', 'action', 'comment')) {
            $record = new object();
            $record->module = 'lightboxgallery';
            $record->action = 'comment';
            $record->mtable = 'lightboxgallery';
            $record->field = 'name';
            $result = $result && insert_record('log_display', $record);
        }
    }
    if ($result && $oldversion < 2007121700) {
        // Insert extinfo field into lightboxgallery
        $table = new XMLDBTable('lightboxgallery');
        $field = new XMLDBField('extinfo');
        if (!field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'comments');
            $result = $result && add_field($table, $field);
        }
        // Create lightboxgallery_captions table
        $table = new XMLDBTable('lightboxgallery_captions');
        if (!table_exists($table)) {
            $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
            $table->addFieldInfo('gallery', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
            $table->addFieldInfo('image', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
            $table->addFieldInfo('caption', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
            $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
            $table->addIndexInfo('gallery', XMLDB_INDEX_NOTUNIQUE, array('gallery'));
            $result = $result && create_table($table);
        }
    }
    if ($result && $oldversion < 2008110600) {
        // Insert public, rss, autoresize, resize fields into lightboxgallery
        $table = new XMLDBTable('lightboxgallery');
        $newfields = array('public', 'rss', 'autoresize', 'resize');
        $previousfield = 'comments';
        foreach ($newfields as $newfield) {
            $field = new XMLDBField($newfield);
            if (!field_exists($table, $field)) {
                $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', $previousfield);
                $result = $result && add_field($table, $field);
                $previousfield = $newfield;
            }
        }
        // Rename user field to userid in lightboxgallery_comments (for postgres)
        $table = new XMLDBTable('lightboxgallery_comments');
        $field = new XMLDBField('user');
        if (field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
            $result = $result && rename_field($table, $field, 'userid');
        }
        // Rename caption field to description and insert metatype field in lightboxgallery_captions
        $table = new XMLDBTable('lightboxgallery_captions');
        $field = new XMLDBField('caption');
        if (field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'image');
            $result = $result && rename_field($table, $field, 'description');
        }
        $field = new XMLDBField('metatype');
        if (table_exists($table) && !field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('caption', 'tag'), 'caption', 'image');
            $result = $result && add_field($table, $field);
        }
        // Rename table lightboxgallery_captions to lightboxgallery_image_meta
        $result = $result && rename_table($table, 'lightboxgallery_image_meta');
    }
    if ($result && $oldversion < 2009051200) {
        // Rename public field to ispublic in lightboxgallery (for mssql)
        $table = new XMLDBTable('lightboxgallery');
        $field = new XMLDBField('public');
        if (field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'comments');
//.........这里部分代码省略.........
开发者ID:itziko,项目名称:Moodle-jQuery-Lightbox-Gallery,代码行数:101,代码来源:upgrade.php

示例9: xmldb_scorm_upgrade


//.........这里部分代码省略.........
        $table->addKeyInfo('scorm_rulecond_ruleconditionsid', XMLDB_KEY_FOREIGN, array('ruleconditionsid'), 'scorm_seq_ruleconds', array('id'));
        /// Launch create table for scorm_seq_rulecond
        $result = $result && create_table($table);
        /// Define table scorm_seq_rolluprule to be created
        $table = new XMLDBTable('scorm_seq_rolluprule');
        /// Adding fields to table scorm_seq_rolluprule
        $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('childactivityset', XMLDB_TYPE_CHAR, '15', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('minimumcount', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('minimumpercent', XMLDB_TYPE_FLOAT, '11, 4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0.0000');
        $table->addFieldInfo('conditioncombination', XMLDB_TYPE_CHAR, '3', null, XMLDB_NOTNULL, null, null, null, 'all');
        $table->addFieldInfo('action', XMLDB_TYPE_CHAR, '15', null, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table scorm_seq_rolluprule
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('scorm_rolluprule_uniq', XMLDB_KEY_UNIQUE, array('scoid', 'id'));
        $table->addKeyInfo('scorm_rolluprule_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
        /// Launch create table for scorm_seq_rolluprule
        $result = $result && create_table($table);
        /// Define table scorm_seq_rolluprulecond to be created
        $table = new XMLDBTable('scorm_seq_rolluprulecond');
        /// Adding fields to table scorm_seq_rolluprulecond
        $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('rollupruleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        $table->addFieldInfo('operator', XMLDB_TYPE_CHAR, '5', null, XMLDB_NOTNULL, null, null, null, 'noOp');
        $table->addFieldInfo('cond', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table scorm_seq_rolluprulecond
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('scorm_rulluprulecond_uniq', XMLDB_KEY_UNIQUE, array('scoid', 'rollupruleid', 'id'));
        $table->addKeyInfo('scorm_rolluprulecond_scoid', XMLDB_KEY_FOREIGN, array('scoid'), 'scorm_scoes', array('id'));
        $table->addKeyInfo('scorm_rolluprulecond_rolluprule', XMLDB_KEY_FOREIGN, array('rollupruleid'), 'scorm_seq_rolluprule', array('id'));
        /// Launch create table for scorm_seq_rolluprulecond
        $result = $result && create_table($table);
    }
    //Adding new field to table scorm
    if ($result && $oldversion < 2007011800) {
        /// Define field format to be added to data_comments
        $table = new XMLDBTable('scorm');
        $field = new XMLDBField('md5_result');
        $field->setAttributes(XMLDB_TYPE_CHAR, '32', null, null, null, null, null, null, null);
        /// Launch add field format
        $result = $result && add_field($table, $field);
        $field = new XMLDBField('external');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007012400) {
        /// Rename field external on table scorm to updatefreq
        $table = new XMLDBTable('scorm');
        $field = new XMLDBField('external');
        if (field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'maxattempt');
            /// Launch rename field updatefreq
            $result = $result && rename_field($table, $field, 'updatefreq');
        } else {
            $field = new XMLDBField('updatefreq');
            $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'maxattempt');
            $result = $result && add_field($table, $field);
        }
        /// Rename field md5_result on table scorm to md5hash
        $field = new XMLDBField('md5_result');
        if (field_exists($table, $field)) {
            $field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, null, 'updatefreq');
            /// Launch rename field md5hash
            $result = $result && rename_field($table, $field, 'md5hash');
        } else {
            $field = new XMLDBField('md5hash');
            $field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, '', 'updatefreq');
            $result = $result && add_field($table, $field);
        }
    }
    if ($result && $oldversion < 2007031300) {
        if ($scorms = get_records('scorm')) {
            foreach ($scorms as $scorm) {
                if ($scoes = get_records('scorm_scoes', 'scorm', $scorm->id)) {
                    foreach ($scoes as $sco) {
                        if ($tracks = get_records('scorm_scoes_track', 'scoid', $sco->id)) {
                            foreach ($tracks as $track) {
                                $element = preg_replace('/\\.N(\\d+)\\./', ".\$1.", $track->element);
                                if ($track->element != $element) {
                                    $track->element = $element;
                                    update_record('scorm_scoes_track', $track);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if ($result && $oldversion < 2007081001) {
        require_once $CFG->dirroot . '/mod/scorm/lib.php';
        // too much debug output
        $db->debug = false;
        scorm_update_grades();
        $db->debug = true;
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:upgrade.php

示例10: xmldb_local_upgrade

function xmldb_local_upgrade($oldversion)
{
    global $CFG, $db;
    $result = true;
    $reassigncaps = false;
    $resetcustomroles = false;
    $resetstickyblocks = false;
    // learning path approval status changes
    if ($result && $oldversion < 2008091803) {
        // fields added to the course table
        $table = new XMLDBTable('course');
        $field = new XMLDBField('approval_status_id');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, null, null, null, null, null, null, null);
        //function setAttributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
        if (!field_exists($table, $field)) {
            /// Launch add field shortname
            $result = $result && add_field($table, $field);
        }
    }
    if ($oldversion < 2008092100) {
        // create the roles we need
        $roles = array('superadmin' => array('name' => 'Super Admin', 'description' => 'The highest level site administrator', 'legacy' => 'admin'), 'headteacher' => array('name' => 'Head Teacher', 'description' => 'Oversees the professional development of the teachers at his/her school and other schools that s/he has been assigned to cover.'), 'headeditor' => array('name' => 'Head Editor', 'description' => 'Approves Learning Plans'), 'seniorteacher' => array('name' => 'Senior Teacher', 'description' => 'Has already achieved Participating Teacher and Master Teacher certification and is now pursuing Senior Teacher certification.'), 'masterteacher' => array('name' => 'Master Teacher', 'description' => 'Has already achieved Participating Teacher certification and is now pursuing Master Teacher certification. Is assigned to an Senior Teacher.'), 'participatingteacher' => array('name' => 'Participating Teacher', 'description' => 'Pursuing Participating Teacher certification. Is assigned to an Master Teacher.'), 'translator' => array('name' => 'Translator', 'description' => 'Localizes User Interface'));
        foreach ($roles as $shortname => $roledata) {
            if (!array_key_exists('legacy', $roledata)) {
                $roledata['legacy'] = '';
            }
            $roles[$shortname]['id'] = create_role($roledata['name'], $shortname, $roledata['description'], $roledata['legacy']);
        }
        // boostrap superadmin to the same as admin
        $admin = get_record('role', 'shortname', 'admin');
        role_cap_duplicate($admin, $roles['superadmin']['id']);
    }
    // try to start over!!!
    if ($result && $oldversion < 2008092400) {
        $table = new XMLDBTable('course_status_history');
        if (table_exists($table)) {
            drop_table($table);
        }
        // fields added to the course table
        $table = new XMLDBTable('course');
        $field = new XMLDBField('approval_status_id');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, null, null, null, null, null, null, null);
        /// Launch add field approval_status_id
        if (!field_exists($table, $field)) {
            $result = $result && add_field($table, $field);
        }
        /// Define table mdl_course_approval_status_history to be created
        $table = new XMLDBTable('course_status_history');
        /// Adding fields to table mdl_course_approval_status
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('timestamp', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('approval_status_id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('reason', XMLDB_TYPE_TEXT, '1000', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $result = $result && create_table($table);
    }
    if ($oldversion < 2008092401) {
        $roles = get_records_select('role', "shortname IN ('headteacher', 'headeditor', 'seniorteacher', 'masterteacher', 'participatingteacher', 'translator')");
        set_config('messageenabledroles', implode(',', array_keys($roles)));
    }
    if ($oldversion < 2008092500) {
        // add course classification stuff
        $table = new XMLDBTable('classification_type');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('name', XMLDB_TYPE_CHAR, 100, null, XMLDB_NOTNULL);
        $table->addFieldInfo('type', XMLDB_TYPE_CHAR, 100, null, XMLDB_NOTNULL, false, true, array('filter', 'topcategory', 'secondcategory'), 'filter');
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $result = $result && create_table($table);
        $table = new XMLDBTable('classification_value');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('type', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('value', XMLDB_TYPE_CHAR, 100, null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $result = $result && create_table($table);
        $table = new XMLDBTable('course_classification');
        $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, null);
        $table->addFieldInfo('value', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $result = $result && create_table($table);
    }
    if ($oldversion < 2008092501) {
        // bootstrap out classification system based on the TAO website.
        $types = array(array('name' => 'Teaching strategies', 'type' => 'filter', 'values' => array('Connected Model', 'Constructivist Model', 'Integrated Model', 'Nested Model', 'Networked/Extended Model', 'Sequenced Model', 'Shared Model')), array('name' => 'Teaching methods', 'type' => 'filter', 'values' => array('Action-Oriented Learning', 'Active video work', 'Ball Bearings', 'Case Study', 'Creative writing', 'Discovery of learning', 'Excursion', 'Experiment', 'Free work', 'Group Puzzle', 'Learning Circle', 'Learning through teaching', 'Letter method', 'Mind mapping', 'Portfolio', 'Project Work', 'SOL method', 'Station Work', 'Traffic Lights', 'Using Tools and Resources', 'Web quest', 'Weekly Plan', 'Workshop', 'Other')), array('name' => 'Learning styles', 'type' => 'filter', 'values' => array('Visual/spatial', 'Verbal/linguistic', 'Logical/mathematical', 'Musical/rhythmic', 'Bodily/kinaesthetic', 'Interpersonal/social', 'Intrapersonal/introspective', 'Communication', 'Information', 'Simulation', 'Presentation', 'Production', 'Visualisation')), array('name' => 'Key Stages', 'type' => 'topcategory', 'values' => array('1 and 2', '3 and 4')), array('name' => 'Subject', 'type' => 'secondcategory', 'values' => array('English', 'Mathematics', 'Science', 'Design and Technology', 'ICT', 'History', 'Geography', 'Art and Design', 'Music', 'Physical Education')));
        foreach ($types as $t) {
            $values = $t['values'];
            $newid = insert_record('classification_type', (object) $t);
            foreach ($values as $v) {
                insert_record('classification_value', (object) array('type' => $newid, 'value' => $v));
            }
        }
    }
    if ($result && $oldversion < 2008100703) {
        // change course status values - seemingly have to drop and recreate the table to reset the serial with xmldb
        $table = new XMLDBTable('course_approval_status');
        if (table_exists($table)) {
            drop_table($table);
        }
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:101,代码来源:upgrade.php

示例11: xmldb_data_upgrade

function xmldb_data_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 < 2006121300) {
        /// Define field format to be added to data_comments
        $table = new XMLDBTable('data_comments');
        $field = new XMLDBField('format');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'content');
        /// Launch add field format
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007022600) {
        /// Define field asearchtemplate to be added to data
        $table = new XMLDBTable('data');
        $field = new XMLDBField('asearchtemplate');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
        /// Launch add field asearchtemplate
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007072200) {
        require_once $CFG->dirroot . '/mod/data/lib.php';
        // too much debug output
        $db->debug = false;
        data_update_grades();
        $db->debug = true;
    }
    if ($result && $oldversion < 2007081400) {
        /// Define field notification to be added to data
        $table = new XMLDBTable('data');
        $field = new XMLDBField('notification');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'editany');
        /// Launch add field notification
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007081402) {
        /// Define index type-dataid (not unique) to be added to data_fields
        $table = new XMLDBTable('data_fields');
        $index = new XMLDBIndex('type-dataid');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('type', 'dataid'));
        /// Launch add index type-dataid
        if (!index_exists($table, $index)) {
            $result = $result && add_index($table, $index);
        }
        /// Define index course (not unique) to be added to data
        $table = new XMLDBTable('data');
        $index = new XMLDBIndex('course');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
        /// Launch add index course
        if (!index_exists($table, $index)) {
            $result = $result && add_index($table, $index);
        }
    }
    //===== 1.9.0 upgrade line ======//
    if ($result && $oldversion < 2007101512) {
        /// Launch add field asearchtemplate again if does not exists yet - reported on several sites
        $table = new XMLDBTable('data');
        $field = new XMLDBField('asearchtemplate');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
        if (!field_exists($table, $field)) {
            $result = $result && add_field($table, $field);
        }
    }
    ///Display a warning message about "Required Entries" fix from MDL-16999
    if ($result && $oldversion < 2007101514) {
        if (!get_config('data', 'requiredentriesfixflag')) {
            set_config('requiredentriesfixflag', true, 'data');
            // remove old flag
            $databases = get_records_sql("SELECT d.*, c.fullname\n                                              FROM {$CFG->prefix}data d, {$CFG->prefix}course c\n                                              WHERE d.course = c.id\n                                              AND (d.requiredentries > 0 OR d.requiredentriestoview > 0)\n                                              ORDER BY c.fullname, d.name");
            if (!empty($databases)) {
                $a = new object();
                $a->text = '';
                foreach ($databases as $database) {
                    $a->text .= "<p>" . $database->fullname . " - " . $database->name . " (course id: " . $database->course . " - database id: " . $database->id . ")</p>";
                }
                notify(get_string('requiredentrieschanged', 'data', $a));
            }
        }
    }
    if ($result && $oldversion < 2007101515) {
        // Upgrade all the data->notification currently being
        // NULL to 0
        $sql = "UPDATE {$CFG->prefix}data SET notification=0 WHERE notification IS NULL";
        $result = execute_sql($sql);
        $table = new XMLDBTable('data');
        $field = new XMLDBField('notification');
        // First step, Set NOT NULL
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'editany');
        $result = $result && change_field_notnull($table, $field);
        // Second step, Set default to 0
        $result = $result && change_field_default($table, $field);
    }
    return $result;
//.........这里部分代码省略.........
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:upgrade.php

示例12: xmldb_wiki_upgrade


//.........这里部分代码省略.........
        //			CREATE TABLE prefix_wiki_locks
        //			(
        //			  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
        //			  wikiid INT(10) UNSIGNED NOT NULL,
        //			  pagename VARCHAR(160) NOT NULL DEFAULT '',
        //			  lockedby INT(10) NOT NULL DEFAULT 0,
        //			  lockedsince INT(10) NOT NULL DEFAULT 0,
        //			  lockedseen INT(10) NOT NULL DEFAULT 0,
        //			  PRIMARY KEY(id),
        //			  UNIQUE INDEX wiki_locks_uk(wikiid,pagename),
        //			  INDEX wiki_locks_ix(lockedseen)
        //			);");
    }
    if ($result && $oldversion < 2007072301) {
        ////////////////////////////
        // Fixing some old errors //
        ////////////////////////////
        // Old mysql.php created this field as intergers: int(11)
        // They must be smallint(3)
        //
        // I'm going to change defaults too.
        $table = new XMLDBTable('wiki');
        $field = new XMLDBField('editorrows');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '30', null);
        $result = change_field_precision($table, $field);
        $result = $result && change_field_default($table, $field);
        $field = new XMLDBField('editorcols');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '120', null);
        $result = $result && change_field_precision($table, $field);
        $result = $result && change_field_default($table, $field);
        // Changing wikicourse to bigint
        $field = new XMLDBField('wikicourse');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', null);
        if (!field_exists($table, $field)) {
            $result = $result && add_field($table, $field);
        } else {
            $result = $result && change_field_precision($table, $field);
        }
        // Renaming key 'course'
        $key = new XMLDBIndex('course');
        $key->setAttributes(XMLDB_INDEX_UNIQUE, array('course'));
        $result = $result && drop_index($table, $key);
        $key = new XMLDBIndex('wiki_cou_ix');
        $key->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
        $result = $result && add_index($table, $key);
        /*	
        	// Changing some field in wiki_pages
        	$table = new XMLDBTable('wiki_pages');
        	$field = new XMLDBField('evaluation');
        	$field->setAttributes(XMLDB_TYPE_TEXT,'medium' , null, XMLDB_NOTNULL, null, null, null, "", 'ownerid');
        	$result = $result && change_field_default($table, $field);
        	$result = $result && change_field_notnull($table, $field);
        */
    }
    // Add groupid and ownerid fields to the wiki_locks table
    if ($result && $oldversion < 2007121701) {
        $table = new XMLDBTable('wiki_locks');
        $field = new XMLDBField('groupid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, 0, null);
        $result = add_field($table, $field);
        $field = new XMLDBField('ownerid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, null);
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2008013105) {
        // To create a new tables: wiki_evaluation and wiki_evaluation_edition
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:67,代码来源:upgrade.php

示例13: xmldb_feedback_upgrade

function xmldb_feedback_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2007012310) {
        //create a new table feedback_completedtmp and the field-definition
        $table = new XMLDBTable('feedback_completedtmp');
        $field = new XMLDBField('id');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null, null, null);
        $table->addField($field);
        $field = new XMLDBField('feedback');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
        $table->addField($field);
        $field = new XMLDBField('userid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
        $table->addField($field);
        $field = new XMLDBField('guestid');
        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, null, false, null, null, '', null);
        $table->addField($field);
        $field = new XMLDBField('timemodified');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
        $table->addField($field);
        $key = new XMLDBKey('PRIMARY');
        $key->setAttributes(XMLDB_KEY_PRIMARY, array('id'));
        $table->addKey($key);
        $key = new XMLDBKey('feedback');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('feedback'), 'feedback', 'id');
        $table->addKey($key);
        $result = $result && create_table($table);
        ////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////
        //create a new table feedback_valuetmp and the field-definition
        $table = new XMLDBTable('feedback_valuetmp');
        $field = new XMLDBField('id');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null, null, null);
        $table->addField($field);
        $field = new XMLDBField('course_id');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
        $table->addField($field);
        $field = new XMLDBField('item');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
        $table->addField($field);
        $field = new XMLDBField('completed');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
        $table->addField($field);
        $field = new XMLDBField('tmp_completed');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
        $table->addField($field);
        $field = new XMLDBField('value');
        $field->setAttributes(XMLDB_TYPE_TEXT, null, null, null, false, null, null, '', null);
        $table->addField($field);
        $key = new XMLDBKey('PRIMARY');
        $key->setAttributes(XMLDB_KEY_PRIMARY, array('id'));
        $table->addKey($key);
        $key = new XMLDBKey('feedback');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('item'), 'feedback_item', 'id');
        $table->addKey($key);
        $result = $result && create_table($table);
        ////////////////////////////////////////////////////////////
    }
    if ($result && $oldversion < 2007050504) {
        /// Define field random_response to be added to feedback_completed
        $table = new XMLDBTable('feedback_completed');
        $field = new XMLDBField('random_response');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
        /// Launch add field1
        $result = $result && add_field($table, $field);
        /// Define field anonymous_response to be added to feedback_completed
        $table = new XMLDBTable('feedback_completed');
        $field = new XMLDBField('anonymous_response');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
        /// Launch add field2
        $result = $result && add_field($table, $field);
        /// Define field random_response to be added to feedback_completed
        $table = new XMLDBTable('feedback_completedtmp');
        $field = new XMLDBField('random_response');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
        /// Launch add field1
        $result = $result && add_field($table, $field);
        /// Define field anonymous_response to be added to feedback_completed
        $table = new XMLDBTable('feedback_completedtmp');
        $field = new XMLDBField('anonymous_response');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
        /// Launch add field2
        $result = $result && add_field($table, $field);
        ////////////////////////////////////////////////////////////
    }
    if ($result && $oldversion < 2007102600) {
        // public is a reserved word on Oracle
        $table = new XMLDBTable('feedback_template');
        $field = new XMLDBField('ispublic');
        if (!field_exists($table, $field)) {
            $result = $result && table_column('feedback_template', 'public', 'ispublic', 'integer', 1);
        }
    }
    if ($result && $oldversion < 2008042400) {
        //New version in version.php
        if ($all_nonanonymous_feedbacks = get_records('feedback', 'anonymous', 2)) {
            $update_sql = 'UPDATE ' . $CFG->prefix . 'feedback_completed SET anonymous_response = 2 WHERE feedback = ';
            foreach ($all_nonanonymous_feedbacks as $fb) {
//.........这里部分代码省略.........
开发者ID:kai707,项目名称:ITSA-backup,代码行数:101,代码来源:upgrade.php

示例14: upgrade_to_1_8_9_4

 private function upgrade_to_1_8_9_4($version)
 {
     global $wpdb;
     // Try to enable the expired ads, bug in 1.0.6.17:
     if ($version == '1.0.6.17') {
         $query = "UPDATE " . AWPCP_TABLE_ADS . " SET DISABLED=0 WHERE ad_enddate >= NOW()";
         $wpdb->query($query);
     }
     if (version_compare($version, '1.8.7.1', "<")) {
         // Fix the problem with disabled_date not being nullable from 1.8.7
         $query = "ALTER TABLE " . AWPCP_TABLE_ADS . " MODIFY disabled_date DATETIME";
         $wpdb->query($query);
     }
     // Upgrade featured ad columns for module
     if (!awpcp_column_exists(AWPCP_TABLE_ADS, 'is_featured_ad')) {
         $wpdb->query("ALTER TABLE " . AWPCP_TABLE_ADS . "  ADD `is_featured_ad` TINYINT(1) DEFAULT NULL");
     }
     // Upgrade for tracking poster's IP address
     if (!awpcp_column_exists(AWPCP_TABLE_ADS, 'posterip')) {
         $wpdb->query("ALTER TABLE " . AWPCP_TABLE_ADS . "  ADD `posterip` VARCHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL");
     }
     if (!awpcp_column_exists(AWPCP_TABLE_ADS, 'flagged')) {
         $wpdb->query("ALTER TABLE " . AWPCP_TABLE_ADS . "  ADD `flagged` TINYINT(1) DEFAULT NULL");
     }
     // Upgrade for deleting ads that are marked as disabled or deleted
     if (!awpcp_column_exists(AWPCP_TABLE_ADS, 'disabled_date')) {
         $wpdb->query("ALTER TABLE " . AWPCP_TABLE_ADS . "  ADD `disabled_date` DATETIME DEFAULT NULL");
     }
     if (!awpcp_column_exists(AWPCP_TABLE_ADFEES, 'is_featured_ad_pricing')) {
         $wpdb->query("ALTER TABLE " . AWPCP_TABLE_ADFEES . "  ADD `is_featured_ad_pricing` TINYINT(1) DEFAULT NULL");
     }
     if (!awpcp_column_exists(AWPCP_TABLE_ADFEES, 'categories')) {
         $wpdb->query("ALTER TABLE " . AWPCP_TABLE_ADFEES . "  ADD `categories` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci");
     }
     if (!awpcp_column_exists(AWPCP_TABLE_CATEGORIES, 'category_order')) {
         $wpdb->query("ALTER TABLE " . AWPCP_TABLE_CATEGORIES . "  ADD `category_order` INT(10) NULL DEFAULT 0 AFTER category_name");
         $wpdb->query("UPDATE " . AWPCP_TABLE_CATEGORIES . " SET category_order=0");
     }
     // Fix the shortcode issue if present in installed version
     $sql = "UPDATE " . $wpdb->posts . " SET post_content='[AWPCPCLASSIFIEDSUI]' ";
     $sql .= "WHERE post_content='[[AWPCPCLASSIFIEDSUI]]'";
     $wpdb->query($sql);
     $settings_table_exists = checkfortable(AWPCP_TABLE_ADSETTINGS);
     if ($settings_table_exists && !field_exists('tos')) {
         // add terms of service field
         $sql = 'INSERT INTO ' . AWPCP_TABLE_ADSETTINGS . '(`config_option`,`config_value`,`config_diz`,`config_group_id`,`option_type`)
             VALUES ("tos","Terms of service go here...","Terms of Service for posting an ad - modify this to fit your needs:","1","0")';
         $wpdb->query($sql);
         $sql = 'INSERT INTO ' . AWPCP_TABLE_ADSETTINGS . '(`config_option`,`config_value`,`config_diz`,`config_group_id`,`option_type`)
             VALUES ("requiredtos", "Display and require Terms of Service","Display and require Terms of Service","1","0")';
         $wpdb->query($sql);
     }
     if ($settings_table_exists && !field_exists('notifyofadexpired')) {
         //add notify of an expired ad field
         $sql = 'insert into ' . AWPCP_TABLE_ADSETTINGS . '(`config_option`,`config_value`,`config_diz`,`config_group_id`,`option_type`)
             values ("notifyofadexpired","Notify admin of expired ads.","Notify admin of expired ads.","1","0")';
         $wpdb->query($sql);
     }
     if ($settings_table_exists && field_exists('notifyofadexpired')) {
         //Fix bug from 1.8.6.4:
         $wpdb->query("UPDATE " . AWPCP_TABLE_ADSETTINGS . " SET option_type =0 where config_option='notifyofadexpired'");
     }
     // Update ad_settings table to ad field config groud ID if field does not exist in installed version
     $cgid_column_name_exists = $wpdb->get_var("SELECT config_group_id FROM " . AWPCP_TABLE_ADSETTINGS);
     if ($settings_table_exists && ($cgid_column_name_exists === false || is_null($cgid_column_name_exists))) {
         $query = "ALTER TABLE " . AWPCP_TABLE_ADSETTINGS . "  ADD `config_group_id` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1 AFTER config_diz";
         $wpdb->query($query);
         $myconfig_group_ops_1 = array('showlatestawpcpnews', 'uiwelcome', 'main_page_display', 'useakismet', 'contactformcheckhuman', 'contactformcheckhumanhighnumval', 'awpcptitleseparator', 'showcityinpagetitle', 'showstateinpagetitle', 'showcountryinpagetitle', 'showcategoryinpagetitle', 'showcountyvillageinpagetitle', 'awpcppagefilterswitch', 'activatelanguages', 'sidebarwidgetbeforecontent', 'sidebarwidgetaftercontent', 'sidebarwidgetbeforetitle', 'sidebarwidgetaftertitle', 'usesenderemailinsteadofadmin', 'awpcpadminaccesslevel', 'awpcpadminemail', 'useakismet');
         $myconfig_group_ops_2 = array('addurationfreemode', 'autoexpiredisabledelete', 'maxcharactersallowed', 'notifyofadexpiring', 'notifyofadposted', 'adapprove', 'disablependingads', 'showadcount', 'displayadviews', 'onlyadmincanplaceads', 'allowhtmlinadtext', 'hyperlinkurlsinadtext', 'notice_awaiting_approval_ad', 'buildsearchdropdownlists', 'visitwebsitelinknofollow', 'groupbrowseadsby', 'groupsearchresultsby', 'displayadthumbwidth', 'adresultsperpage', 'displayadlayoutcode', 'awpcpshowtheadlayout');
         $myconfig_group_ops_3 = array('freepay', 'paylivetestmode', 'paypalemail', 'paypalcurrencycode', 'displaycurrencycode', '2checkout', 'activatepaypal', 'activate2checkout', 'twocheckoutpaymentsrecurring', 'paypalpaymentsrecurring');
         $myconfig_group_ops_4 = array('imagesallowdisallow', 'awpcp_thickbox_disabled', 'imagesapprove', 'imagesallowedfree', 'uploadfoldername', 'maximagesize', 'minimagesize', 'imgthumbwidth', 'imgmaxheight', 'imgmaxwidth');
         $myconfig_group_ops_5 = array('useadsense', 'adsense', 'adsenseposition');
         $myconfig_group_ops_6 = array('displayphonefield', 'displayphonefieldreqop', 'displaycityfield', 'displaycityfieldreqop', 'displaystatefield', 'displaystatefieldreqop', 'displaycountryfield', 'displaycountryfieldreqop', 'displaycountyvillagefield', 'displaycountyvillagefieldreqop', 'displaypricefield', 'displaypricefieldreqop', 'displaywebsitefield', 'displaywebsitefieldreqop', 'displaypostedbyfield');
         $myconfig_group_ops_7 = array('requireuserregistration', 'postloginformto', 'registrationurl');
         $myconfig_group_ops_8 = array('contactformsubjectline', 'contactformbodymessage', 'listingaddedsubject', 'listingaddedbody', 'resendakeyformsubjectline', 'resendakeyformbodymessage', 'paymentabortedsubjectline', 'paymentabortedbodymessage', 'adexpiredsubjectline', 'adexpiredbodymessage');
         $myconfig_group_ops_9 = array('usesmtp', 'smtphost', 'smtpport', 'smtpusername', 'smtppassword');
         $myconfig_group_ops_10 = array('userpagename', 'showadspagename', 'placeadpagename', 'page-name-renew-ad', 'browseadspagename', 'browsecatspagename', 'editadpagename', 'paymentthankyoupagename', 'paymentcancelpagename', 'replytoadpagename', 'searchadspagename', 'categoriesviewpagename');
         $myconfig_group_ops_11 = array('seofriendlyurls', 'pathvaluecontact', 'pathvalueshowad', 'pathvaluebrowsecategory', 'pathvalueviewcategories', 'pathvaluecancelpayment', 'pathvaluepaymentthankyou');
         // assign a group value to each setting
         foreach ($myconfig_group_ops_1 as $myconfig_group_op_1) {
             add_config_group_id($cvalue = 1, $myconfig_group_op_1);
         }
         foreach ($myconfig_group_ops_2 as $myconfig_group_op_2) {
             add_config_group_id($cvalue = '2', $myconfig_group_op_2);
         }
         foreach ($myconfig_group_ops_3 as $myconfig_group_op_3) {
             add_config_group_id($cvalue = '3', $myconfig_group_op_3);
         }
         foreach ($myconfig_group_ops_4 as $myconfig_group_op_4) {
             add_config_group_id($cvalue = '4', $myconfig_group_op_4);
         }
         foreach ($myconfig_group_ops_5 as $myconfig_group_op_5) {
             add_config_group_id($cvalue = '5', $myconfig_group_op_5);
         }
         foreach ($myconfig_group_ops_6 as $myconfig_group_op_6) {
             add_config_group_id($cvalue = '6', $myconfig_group_op_6);
         }
         foreach ($myconfig_group_ops_7 as $myconfig_group_op_7) {
             add_config_group_id($cvalue = '7', $myconfig_group_op_7);
         }
//.........这里部分代码省略.........
开发者ID:sabdev1,项目名称:ljcdevsab,代码行数:101,代码来源:install.php

示例15: 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


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