• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP field_exists函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP field_get_items函数代码示例发布时间:2022-05-15
下一篇:
PHP field_date函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap