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


PHP change_field_notnull函数代码示例

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


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

示例1: xmldb_assignment_upgrade

function xmldb_assignment_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2007091900) {
        /// MDL-11268
        /// Changing nullability of field data1 on table assignment_submissions to null
        $table = new XMLDBTable('assignment_submissions');
        $field = new XMLDBField('data1');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'numfiles');
        /// Launch change of nullability for field data1
        $result = $result && change_field_notnull($table, $field);
        /// Changing nullability of field data2 on table assignment_submissions to null
        $field = new XMLDBField('data2');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'data1');
        /// Launch change of nullability for field data2
        $result = $result && change_field_notnull($table, $field);
    }
    if ($result && $oldversion < 2007091902) {
        // add draft tracking default to existing upload assignments
        $sql = "UPDATE {$CFG->prefix}assignment SET var4=1 WHERE assignmenttype='upload'";
        $result = execute_sql($sql);
    }
    //===== 1.9.0 upgrade line ======//
    if ($result && $oldversion < 2007101511) {
        notify('Processing assignment grades, this may take a while if there are many assignments...', 'notifysuccess');
        // change grade typo to text if no grades MDL-13920
        require_once $CFG->dirroot . '/mod/assignment/lib.php';
        // too much debug output
        $db->debug = false;
        assignment_update_grades();
        $db->debug = true;
    }
    return $result;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:35,代码来源:upgrade.php

示例2: xmldb_assignment_upgrade

function xmldb_assignment_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2007072200) {
        require_once $CFG->dirroot . '/mod/assignment/lib.php';
        // too much debug output
        $db->debug = false;
        assignment_update_grades();
        $db->debug = true;
    }
    if ($result && $oldversion < 2007091900) {
        /// MDL-11268
        /// Changing nullability of field data1 on table assignment_submissions to null
        $table = new XMLDBTable('assignment_submissions');
        $field = new XMLDBField('data1');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'numfiles');
        /// Launch change of nullability for field data1
        $result = $result && change_field_notnull($table, $field);
        /// Changing nullability of field data2 on table assignment_submissions to null
        $field = new XMLDBField('data2');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'data1');
        /// Launch change of nullability for field data2
        $result = $result && change_field_notnull($table, $field);
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:27,代码来源:upgrade.php

示例3: xmldb_artefact_resume_upgrade

function xmldb_artefact_resume_upgrade($oldversion = 0)
{
    $status = true;
    if ($oldversion < 2009122100) {
        $table = new XMLDBTable('artefact_resume_employmenthistory');
        $field = new XMLDBField('employeraddress');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field);
        $table = new XMLDBTable('artefact_resume_educationhistory');
        $field = new XMLDBField('institutionaddress');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field);
    }
    if ($oldversion < 2010020300) {
        $table = new XMLDBTable('artefact_resume_educationhistory');
        $field = new XMLDBField('qualtype');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        change_field_notnull($table, $field);
        $table = new XMLDBTable('artefact_resume_educationhistory');
        $field = new XMLDBField('qualname');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        change_field_notnull($table, $field);
    }
    if ($oldversion < 2013071300) {
        $table = new XMLDBTable('artefact_resume_book');
        $field = new XMLDBField('url');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field);
    }
    if ($oldversion < 2013072900) {
        execute_sql("UPDATE {blocktype_installed_category} SET category = 'internal' WHERE category = 'resume'");
    }
    return $status;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:34,代码来源:upgrade.php

示例4: xmldb_block_task_list_upgrade

function xmldb_block_task_list_upgrade($oldversion = 0)
{
    $result = true;
    if ($result and $oldversion < 2007011501) {
        /// Define field format to be added to block_task_list
        $table = new XMLDBTable('block_task_list');
        $field = new XMLDBField('format');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'name');
        /// Launch add field format
        $result = $result and add_field($table, $field);
    }
    if ($result and $oldversion < 2007011503) {
        /// Manually remove bad capabilities
        $result = $result and delete_records('capabilities', 'name', 'block/tast_list:manage');
        $result = $result and delete_records('capabilities', 'name', 'block/tast_list:checkofftasks');
    }
    if ($result and $oldversion < 2007011505) {
        //TODO: The info field might be able to be removed, as it doesn't seem to be used anywhere, but in the meantime, change it to allow nulls
        /// Changing nullability of field info on table block_task_list to allow null
        $table = new XMLDBTable('block_task_list');
        $field = new XMLDBField('info');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'checked');
        /// Launch change of nullability for field info
        $result = $result && change_field_notnull($table, $field);
    }
    return $result;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:27,代码来源:upgrade.php

示例5: xmldb_interaction_forum_upgrade

function xmldb_interaction_forum_upgrade($oldversion = 0)
{
    if ($oldversion < 2009062300) {
        foreach (array('topic', 'forum') as $type) {
            log_debug("Subscription upgrade for {$type}s");
            // Add missing primary key to the subscription tables
            // Step 1: remove duplicates
            if ($dupes = get_records_sql_array('
                SELECT "user", ' . $type . ', COUNT(*)
                FROM {interaction_forum_subscription_' . $type . '}
                GROUP BY "user", ' . $type . '
                HAVING COUNT(*) > 1', array())) {
                // We found duplicate subscriptions to a topic/forum
                foreach ($dupes as $dupe) {
                    log_debug("interaction.forum: Removing duplicate {$type} subscription for {$dupe->user}");
                    delete_records('interaction_forum_subscription_' . $type, 'user', $dupe->user, $type, $dupe->{$type});
                    insert_record('interaction_forum_subscription_' . $type, (object) array('user' => $dupe->user, $type => $dupe->{$type}));
                }
            }
            // Step 2: add the actual key
            $table = new XMLDBTable('interaction_forum_subscription_' . $type);
            $key = new XMLDBKey('primary');
            $key->setAttributes(XMLDB_KEY_PRIMARY, array('user', $type));
            add_key($table, $key);
            // Add a 'key' column, used for unsubscriptions
            $field = new XMLDBField('key');
            $field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, null);
            add_field($table, $field);
            $key = new XMLDBKey('keyuk');
            $key->setAttributes(XMLDB_KEY_UNIQUE, array('key'));
            add_key($table, $key);
            // Populate the key column
            if ($records = get_records_array('interaction_forum_subscription_' . $type, '', '', '', '"user", ' . $type)) {
                foreach ($records as $where) {
                    $new = (object) array('user' => $where->user, $type => $where->{$type}, 'key' => dechex(mt_rand()));
                    update_record('interaction_forum_subscription_' . $type, $new, $where);
                }
            }
            // Now make the key column not null
            $field->setAttributes(XMLDB_TYPE_CHAR, 50, XMLDB_UNSIGNED, XMLDB_NOTNULL);
            change_field_notnull($table, $field);
        }
    }
    if ($oldversion < 2009081700) {
        if (!get_record('interaction_config', 'plugin', 'forum', 'field', 'postdelay')) {
            insert_record('interaction_config', (object) array('plugin' => 'forum', 'field' => 'postdelay', 'value' => 30));
        }
    }
    if ($oldversion < 2009081800) {
        $subscription = (object) array('plugin' => 'forum', 'event' => 'creategroup', 'callfunction' => 'create_default_forum');
        ensure_record_exists('interaction_event_subscription', $subscription, $subscription);
    }
    return true;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:54,代码来源:upgrade.php

示例6: xmldb_bookmarks_upgrade

function xmldb_bookmarks_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($oldversion < 2008062001) {
        $table = new XMLDBTable("bookmarks");
        $field = new XMLDBField("intro");
        $field->setAttributes(XMLDB_TYPE_TEXT, small, null, true, null, null, null, "", null);
        change_field_default($table, $field);
        change_field_type($table, $field);
        change_field_notnull($table, $field);
    }
    return $result;
}
开发者ID:laiello,项目名称:moodle-social-bookmarking,代码行数:14,代码来源:upgrade.php

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

示例8: xmldb_resource_upgrade

function xmldb_resource_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 < 2007011700) {
        //move format from options to reference field because it was colliding with course blocks setting
        execute_sql("UPDATE {$CFG->prefix}resource SET reference=options WHERE type='text' AND reference='' AND options!='showblocks'");
        //ignore result
    }
    if ($result && $oldversion < 2007012000) {
        /// Changing nullability of field summary on table resource to null
        $table = new XMLDBTable('resource');
        $field = new XMLDBField('summary');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'reference');
        /// Launch change of nullability for field summary
        $result = $result && change_field_notnull($table, $field);
    }
    if ($result && $oldversion < 2007012001) {
        if ($CFG->dbfamily == 'mysql') {
            // Only needed under mysql. The rest are long texts since ages
            /// Changing precision of field alltext on table resource to (medium)
            $table = new XMLDBTable('resource');
            $field = new XMLDBField('alltext');
            $field->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null, 'summary');
            /// Launch change of precision for field alltext
            $result = $result && change_field_precision($table, $field);
        }
    }
    //Set 'Show navigation' setting to "Yes, without frame" for PDF file resources
    //Explanation: due to MDL-20320 bug, PDF can now be displayed as 'No', 'Yes, with frame' and 'Yes, without frame'.
    //The default being 'no', PDF resources on previous installations need to be set back to 'Yes, without frame'
    if ($result && $oldversion < 2007101510) {
        $sql = "UPDATE {$CFG->prefix}resource SET options = 'objectframe' WHERE (UPPER(reference) LIKE '%.PDF'\n        OR UPPER(reference) LIKE '%.FDF'\n        OR UPPER(reference) LIKE '%.XDP'\n        OR UPPER(reference) LIKE '%.XFD'\n        OR UPPER(reference) LIKE '%.XFDF')\n        AND type='file' AND " . sql_isempty('resource', 'popup', false, true) . "\n        AND (" . sql_isempty('resource', 'options', false, false) . " OR options = 'frame')";
        $result = $result && execute_sql($sql);
    }
    // MDL-10906. Removing resource_allowlocalfiles setting.
    if ($result && $oldversion < 2007101511) {
        $result = $result && unset_config('resource_allowlocalfiles');
    }
    //===== 1.9.0 upgrade line ======//
    return $result;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:49,代码来源:upgrade.php

示例9: xmldb_blocks_upgrade

function xmldb_blocks_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 < 2007081300) {
        /// Changing nullability of field configdata on table block_instance to null
        $table = new XMLDBTable('block_instance');
        $field = new XMLDBField('configdata');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'visible');
        /// Launch change of nullability for field configdata
        $result = $result && change_field_notnull($table, $field);
    }
    return $result;
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:21,代码来源:upgrade.php

示例10: xmldb_resource_upgrade

function xmldb_resource_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 < 2007011700) {
        //move format from options to reference field because it was colliding with course blocks setting
        execute_sql("UPDATE {$CFG->prefix}resource SET reference=options WHERE type='text' AND reference='' AND options!='showblocks'");
        //ignore result
    }
    if ($result && $oldversion < 2007012000) {
        /// Changing nullability of field summary on table resource to null
        $table = new XMLDBTable('resource');
        $field = new XMLDBField('summary');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'reference');
        /// Launch change of nullability for field summary
        $result = $result && change_field_notnull($table, $field);
    }
    if ($result && $oldversion < 2007012001) {
        if ($CFG->dbfamily == 'mysql') {
            // Only needed under mysql. The rest are long texts since ages
            /// Changing precision of field alltext on table resource to (medium)
            $table = new XMLDBTable('resource');
            $field = new XMLDBField('alltext');
            $field->setAttributes(XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null, 'summary');
            /// Launch change of precision for field alltext
            $result = $result && change_field_precision($table, $field);
        }
    }
    //===== 1.9.0 upgrade line ======//
    return $result;
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:38,代码来源:upgrade.php

示例11: 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);
    }
    if ($result && $oldversion < 2007072200) {
        require_once $CFG->dirroot . '/mod/lesson/lib.php';
        // too much debug output
        $db->debug = false;
        lesson_update_grades();
        $db->debug = true;
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:37,代码来源:upgrade.php

示例12: xmldb_questionnaire_upgrade


//.........这里部分代码省略.........
        $field = new XMLDBField('complete');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, false, null, 'n');
        $result &= change_field_enum($table, $field);
        set_field('questionnaire_response', 'complete', 'y', 'complete', 'Y');
        set_field('questionnaire_response', 'complete', 'n', 'complete', 'N');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, XMLDB_ENUM, array('y', 'n'), 'n');
        $result &= change_field_enum($table, $field);
        $result &= change_field_default($table, $field);
        unset($field);
        unset($table);
        $table = new XMLDBTable('questionnaire_response_bool');
        $field = new XMLDBField('choice_id');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, false, null, 'n');
        $result &= change_field_enum($table, $field);
        set_field('questionnaire_response_bool', 'choice_id', 'y', 'choice_id', 'Y');
        set_field('questionnaire_response_bool', 'choice_id', 'n', 'choice_id', 'N');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, XMLDB_ENUM, array('y', 'n'), 'y');
        $result &= change_field_enum($table, $field);
        $result &= change_field_default($table, $field);
        unset($field);
        unset($table);
        $table = new XMLDBTable('questionnaire_survey');
        $field = new XMLDBField('public');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, false, null, 'n');
        $result &= change_field_enum($table, $field);
        set_field('questionnaire_survey', 'public', 'y', 'public', 'Y');
        set_field('questionnaire_survey', 'public', 'n', 'public', 'N');
        $field->setAttributes(XMLDB_TYPE_CHAR, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, XMLDB_ENUM, array('y', 'n'), 'y');
        $result &= change_field_enum($table, $field);
        $result &= change_field_default($table, $field);
        unset($field);
        /// Upgrade question_type table with corrected 'response_table' fields.
        set_field('questionnaire_question_type', 'response_table', 'resp_single', 'response_table', 'response_single');
        set_field('questionnaire_question_type', 'response_table', 'resp_multiple', 'response_table', 'response_multiple');
    }
    if ($oldversion < 2008031902) {
        $table = new XMLDBTable('questionnaire');
        $field = new XMLDBField('grade');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', false, true, false, false, null, 0, 'navigate');
        $result = $result && add_field($table, $field);
        unset($field);
        unset($table);
        $table = new XMLDBTable('questionnaire_response');
        $field = new XMLDBField('grade');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', false, true, false, false, null, 0, 'complete');
        $result = $result && add_field($table, $field);
    }
    if ($oldversion < 2008031904) {
        $sql = "SELECT q.id, q.resp_eligible, q.resp_view, cm.id as cmid\n                FROM {$CFG->prefix}questionnaire q, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m\n                WHERE m.name='questionnaire' AND m.id=cm.module AND cm.instance=q.id";
        if ($rs = get_recordset_sql($sql)) {
            $studentroleid = get_field('role', 'id', 'shortname', 'student');
            $editteacherroleid = get_field('role', 'id', 'shortname', 'editingteacher');
            $teacherroleid = get_field('role', 'id', 'shortname', 'teacher');
            $capview = 'mod/questionnaire:view';
            $capsubmit = 'mod/questionnaire:submit';
            while ($questionnaire = rs_fetch_next_record($rs)) {
                $context = get_context_instance(CONTEXT_MODULE, $questionnaire->cmid);
                /// Convert questionnaires with resp_eligible = 'all' so that students & teachers have view and submit
                if ($questionnaire->resp_eligible == 'all') {
                    assign_capability($capsubmit, CAP_ALLOW, $editteacherroleid, $context->id, true);
                    assign_capability($capsubmit, CAP_ALLOW, $teacherroleid, $context->id, true);
                    /// Convert questionnaires with resp_eligible = 'students' so that just students have view and submit
                } else {
                    if ($questionnaire->resp_eligible == 'students') {
                        /// This is the default; no changes necessary.
                        /// Convert questionnaires with resp_eligible = 'teachers' so just teachers have view and submit
                    } else {
                        if ($questionnaire->resp_eligible == 'teachers') {
                            assign_capability($capsubmit, CAP_ALLOW, $editteacherroleid, $context->id, true);
                            assign_capability($capsubmit, CAP_ALLOW, $teacherroleid, $context->id, true);
                            assign_capability($capview, CAP_PREVENT, $studentroleid, $context->id, true);
                            assign_capability($capsubmit, CAP_PREVENT, $studentroleid, $context->id, true);
                        }
                    }
                }
            }
            rs_close($rs);
        }
    }
    if ($oldversion < 2008031905) {
        $table = new XMLDBTable('questionnaire_survey');
        $field = new XMLDBField('changed');
        $result = $result && drop_field($table, $field);
    }
    if ($oldversion < 2008031906) {
        $table = new XMLDBTable('questionnaire_response_rank');
        $field = new XMLDBField('rank');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, null, null, '0', 'choice_id');
        $field->setUnsigned(false);
        $result &= change_field_unsigned($table, $field);
    }
    if ($oldversion < 2008060401) {
        $table = new XMLDBTable('questionnaire_question');
        $field = new XMLDBField('name');
        $field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, null, 'survey_id');
        $field->setNotnull(false);
        $result &= change_field_notnull($table, $field);
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:upgrade.php

示例13: xmldb_blended_upgrade


//.........这里部分代码省略.........
    //    }
    //
    ///// Second example, some hours later, the same day 20070401
    ///// two more fields and one index were added (note the increment
    ///// "01" in the last two digits of the version
    //    if ($result && $oldversion < 2007040101) {
    //
    //    /// Define field timecreated to be added to clusterer
    //        $table = new XMLDBTable('clusterer');
    //        $field = new XMLDBField('timecreated');
    //        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'introformat');
    //    /// Launch add field timecreated
    //        $result = $result && add_field($table, $field);
    //
    //    /// Define field timemodified to be added to clusterer
    //        $table = new XMLDBTable('clusterer');
    //        $field = new XMLDBField('timemodified');
    //        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timecreated');
    //    /// Launch add field timemodified
    //        $result = $result && add_field($table, $field);
    //
    //    /// Define index course (not unique) to be added to clusterer
    //        $table = new XMLDBTable('clusterer');
    //        $index = new XMLDBIndex('course');
    //        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
    //    /// Launch add index course
    //        $result = $result && add_index($table, $index);
    //    }
    //
    ///// Third example, the next day, 20070402 (with the trailing 00), some inserts were performed, related with the module
    //    if ($result && $oldversion < 2007040200) {
    //    /// Add some actions to get them properly displayed in the logs
    //        $rec = new stdClass;
    //        $rec->module = 'clusterer';
    //        $rec->action = 'add';
    //        $rec->mtable = 'clusterer';
    //        $rec->filed  = 'name';
    //    /// Insert the add action in log_display
    //        $result = insert_record('log_display', $rec);
    //    /// Now the update action
    //        $rec->action = 'update';
    //        $result = insert_record('log_display', $rec);
    //    /// Now the view action
    //        $rec->action = 'view';
    //        $result = insert_record('log_display', $rec);
    //    }
    /*@var $field XMLDBField*/
    if ($result && $oldversion < 2011111402) {
        $table = new XMLDBTable('blended_jobs');
        $field = new XMLDBField('timestampt');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $result = $result & rename_field($table, $field, 'timestamp');
        $table = new XMLDBTable('blended_scans');
        $field = new XMLDBField('timestampt');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $result = $result & rename_field($table, $field, 'timestamp');
        $table = new XMLDBTable('blended_attempts');
        $field = new XMLDBField('timestampt');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $result = $result & rename_field($table, $field, 'timestamp');
    }
    if ($result && $oldversion < 2011111800) {
        $table = new XMLDBTable('blended_images');
        $field = new XMLDBField('activitycode');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, !XMLDB_NOTNULL);
        $result = $result & change_field_notnull($table, $field);
    }
    if ($result && $oldversion < 2011112800) {
        $table = new XMLDBTable('blended_jobs');
        $field = new XMLDBField('identifylabel');
        $field->setAttributes(XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, !XMLDB_NOTNULL);
        $result = $result & change_field_precision($table, $field);
        $result = $result & rename_field($table, $field, 'options');
    }
    if ($result && $oldversion < 2014071406) {
        $table = new xmldb_table('blended_assign_grouping');
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('id_assign', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'id');
        $table->add_field('id_grouping', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'id_assign');
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        $table1 = new xmldb_table('blended_team');
        $field = new xmldb_field('id_team', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'id');
        if (!$dbman->field_exists($table1, $field)) {
            $dbman->add_field($table1, $field);
        }
        upgrade_mod_savepoint(true, '2014071406', 'blended');
    }
    if ($result && $oldversion < 2015022300) {
        $table = new xmldb_table('blended');
        $field = new xmldb_field('omrenabled', XMLDB_TYPE_INTEGER, '1', true, XMLDB_NOTNULL, false, 0, 'introformat');
        $dbman->add_field($table, $field);
        upgrade_mod_savepoint(true, '2015022300', 'blended');
    }
    /// Final return of upgrade result (true/false) to Moodle. Must be
    /// always the last line in the script
    return $result;
}
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:101,代码来源:upgrade.php

示例14: xmldb_ouwiki_upgrade


//.........这里部分代码省略.........
        /// Adding keys to table ouwiki_sections
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('ouwiki_sections_fk_pageid', XMLDB_KEY_FOREIGN, array('pageid'), 'ouwiki_pages', array('id'));
        /// Launch create table for ouwiki_sections
        $result = $result && create_table($table);
        /// Define table ouwiki_comments to be created
        $table = new XMLDBTable('ouwiki_comments');
        /// Adding fields to table ouwiki_comments
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('pagesectionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('title', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
        $table->addFieldInfo('xhtml', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
        $table->addFieldInfo('timeposted', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('deleted', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
        /// Adding keys to table ouwiki_comments
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('oucontent_comments_pagesectionid_fk', XMLDB_KEY_FOREIGN, array('pagesectionid'), 'ouwiki_sections', array('id'));
        $table->addKeyInfo('oucontent_comments_userid_fk', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
        /// Launch create table for ouwiki_comments
        $result = $result && create_table($table);
        if ($result) {
            $tw->commit();
        } else {
            $tw->rollback();
        }
    }
    if ($result && $oldversion < 2007041007) {
        /// Changing nullability of field title on table ouwiki_sections to not null
        $table = new XMLDBTable('ouwiki_sections');
        $field = new XMLDBField('title');
        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null, 'xhtmlid');
        /// Launch change of nullability for field title
        $result = $result && change_field_notnull($table, $field);
    }
    if ($result && $oldversion < 2007041103) {
        $result &= ouwiki_argh_fix_default('subwikis');
        $result &= ouwiki_argh_fix_default('pages');
        $result &= ouwiki_argh_fix_default('versions');
        $result &= ouwiki_argh_fix_default('links');
        $result &= ouwiki_argh_fix_default('locks');
    }
    if ($result && $oldversion < 2007041700) {
        /// Define key oucontent_comments_sectionid_fk (foreign) to be dropped form ouwiki_comments
        $table = new XMLDBTable('ouwiki_comments');
        $key = new XMLDBKey('oucontent_comments_pagesectionid_fk');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('pagesectionid'), 'ouwiki_sections', array('id'));
        /// Launch drop key oucontent_comments_pagesectionid_fk
        $result = $result && drop_key($table, $key);
        /// Rename field pagesectionid on table ouwiki_comments to sectionid
        $table = new XMLDBTable('ouwiki_comments');
        $field = new XMLDBField('pagesectionid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'id');
        /// Launch rename field pagesectionid
        $result = $result && rename_field($table, $field, 'sectionid');
        /// Define key ouwiki_comments_sectionid_fk (foreign) to be added to ouwiki_comments
        $table = new XMLDBTable('ouwiki_comments');
        $key = new XMLDBKey('ouwiki_comments_sectionid_fk');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('sectionid'), 'ouwiki_sections', array('id'));
        /// Launch add key oucontent_comments_sectionid_fk
        $result = $result && add_key($table, $key);
    }
    if ($result && $oldversion == 2007041700) {
        /// Define key oucontent_comments_sectionid_fk (foreign) to be dropped form ouwiki_comments
        $table = new XMLDBTable('ouwiki_comments');
        $key = new XMLDBKey('oucontent_comments_pagesectionid_fk');
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:67,代码来源:upgrade.php

示例15: xmldb_local_upgrade


//.........这里部分代码省略.........
        $headerimages[6]->url = '/index.php';
        $headerimages[6]->description = 'homepage';
        $headerimages[6]->sortorder = 1;
        $headerimages[7]->image = 'header_login.jpg';
        $headerimages[7]->url = '/';
        $headerimages[7]->description = 'homepage';
        $headerimages[7]->sortorder = 1;
        foreach ($headerimages as $himg) {
            //first check to make sure this record doesn't already exist
            if (!record_exists('header_image', 'image', $himg->image, 'url', $himg->url)) {
                insert_record('header_image', $himg);
            }
        }
    }
    if ($oldversion < 2009031108) {
        set_config('defaultblocks_topics', 'tao_nav:course_list');
        set_config('defaultblocks_weeks', 'tao_nav:course_list');
        set_config('defaultblocks_social', 'tao_nav:course_list');
    }
    if ($oldversion < 2009031109) {
        //add courseid to header_image table
        $table = new XMLDBTable('header_image');
        $field = new XMLDBField('courseid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, null, null, null, null, null);
        if (!field_exists($table, $field)) {
            $result = $result && add_field($table, $field);
        }
    }
    if ($oldversion < 2009031110) {
        //modify url to allow nulls
        $table = new XMLDBTable('header_image');
        $field = new XMLDBField('url');
        $field->setAttributes(XMLDB_TYPE_TEXT, 'big', XMLDB_UNSIGNED, null, null, null, null, null);
        $result = $result && change_field_notnull($table, $field);
    }
    if ($oldversion < 2009052201) {
        // add 'custom' flag to roles table
        $table = new XMLDBTable('role');
        $field = new XMLDBField('custom');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, null, null, null, null, null);
        if (!field_exists($table, $field)) {
            $result = $result && add_field($table, $field);
        }
        // make the assumption that everything with an id over 7 (the standard Moodle installed roles) at this stage is a custom role
        execute_sql("UPDATE {$CFG->prefix}role SET custom = 1 WHERE id > 7");
    }
    if ($oldversion < 2009052501) {
        $table = new XMLDBTable('user_friend');
        $field = new XMLDBField('approved');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, XMLDB_UNSIGNED, null, null, null, null, null);
        if (!field_exists($table, $field)) {
            $result = $result && add_field($table, $field);
        }
    }
    if ($oldversion < 2009062401) {
        $hostid = get_field('mnet_host', 'id', 'name', 'localmahara');
        $host2service = new stdClass();
        $host2service->serviceid = get_field('mnet_service', 'id', 'name', 'local_mahara');
        if (!empty($host2service->serviceid)) {
            $host2service->publish = 0;
            $host2service->subscribe = 1;
            if ($hostrec = get_record('mnet_host2service', 'hostid', $hostid, 'serviceid', $host2service->serviceid)) {
                $host2service->id = $hostrec->id;
                update_record('mnet_host2service', $host2service);
            } else {
                insert_record('mnet_host2service', $host2service);
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:67,代码来源:upgrade.php


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