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

PHP XMLDBTable类代码示例

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

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



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

示例1: xmldb_block_ajax_marking_upgrade

function xmldb_block_ajax_marking_upgrade($oldversion = 0)
{
    //echo "oldversion: ".$oldversion;
    global $CFG, $THEME, $db;
    $result = true;
    /// And upgrade begins here. For each one, you'll need one
    /// block of code similar to the next one. Please, delete
    /// this comment lines once this file start handling proper
    /// upgrade code.
    if ($result && $oldversion < 2007052901) {
        //New version in version.php
        /// Define table block_ajax_marking to be created
        $table = new XMLDBTable('block_ajax_marking');
        /// Adding fields to table block_ajax_marking
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
        $table->addFieldInfo('assessmenttype', XMLDB_TYPE_CHAR, '40', null, null, null, null, null, null);
        $table->addFieldInfo('assessmentid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
        $table->addFieldInfo('showhide', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '1');
        $table->addFieldInfo('groups', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null);
        /// Adding keys to table block_ajax_marking
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('useridkey', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
        /// Launch create table for block_ajax_marking
        $result = $result && create_table($table);
    }
    // run this on every upgrade.
    AMB_update_modules();
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:30,代码来源:upgrade.php


示例2: xmldb_assignment_team_upgrade

function xmldb_assignment_team_upgrade($oldversion)
{
    global $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2011013000) {
        //add table 'assignment_team'
        $table1 = new XMLDBTable('assignment_team');
        $table1->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'assignment');
        $table1->add_field('assignment', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'id', 'name');
        $table1->add_field('name', XMLDB_TYPE_CHAR, '100', XMLDB_NOTNULL, XMLDB_SEQUENCE, 'assignment', 'membershipopen');
        $table1->add_field('membershipopen', XMLDB_TYPE_INTEGER, '1', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'name', 'timemodified');
        $table1->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'membershipopen');
        $table1->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table1->add_key('assignment', XMLDB_KEY_FOREIGN, array('assignment'));
        if (!$dbman->table_exists($table1)) {
            $dbman->create_table($table1);
        }
        //add table 'assignment_team_student'
        $table2 = new XMLDBTable('assignment_team_student');
        $table2->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'true');
        $table2->add_field('student', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'id', 'team');
        $table2->add_field('team', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'student', 'timemodified');
        $table2->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_NOTNULL, XMLDB_UNSIGNED, XMLDB_SEQUENCE, 'team');
        $table2->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table2->add_key('student', XMLDB_KEY_FOREIGN, array('student'));
        $table2->add_key('team', XMLDB_KEY_FOREIGN, array('team'));
        $table2->add_index('student-team', XMLDB_INDEX_UNIQUE, array('student', 'team'));
        if (!$dbman->table_exists($table2)) {
            $dbman->create_table($table2);
        }
        upgrade_plugin_savepoint(true, 2011013000, 'assignment', 'team');
    }
    return true;
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:34,代码来源:upgrade.php


示例3: xmldb_hotquestion_upgrade

function xmldb_hotquestion_upgrade($oldversion = 0)
{
    global $CFG, $DB;
    $result = true;
    //===== 1.9.0 upgrade line ======//
    if ($result && $oldversion < 2007040100) {
        /// Define field course to be added to hotquestion
        $table = new XMLDBTable('hotquestion');
        $field = new XMLDBField('course');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
        /// Launch add field course
        $result = $result && $table->add_field($field);
        /// Define field intro to be added to hotquestion
        $field = new xmldb_field('intro');
        $field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, 'name');
        /// Launch add field intro
        $result = $result && $table->add_field($field);
        /// Define field introformat to be added to hotquestion
        $field = new xmldb_field('introformat');
        $field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
        /// Launch add field introformat
        $result = $result && $table->add_field($field);
    }
    if ($result && $oldversion < 2007040101) {
        /// Define field timecreated to be added to hotquestion
        $table = new xmldb_table('hotquestion');
        $field = new xmldb_field('timecreated');
        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'introformat');
        /// Launch add field timecreated
        $result = $result && $table->add_field($field);
        $field = new xmldb_field('timemodified');
        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timecreated');
        /// Launch add field timemodified
        $result = $result && $table->add_field($table, $field);
        /// Define index course (not unique) to be added to hotquestion
        $result = $result && $table->add_index('course', XMLDB_INDEX_NOTUNIQUE, array('course'));
    }
    if ($result && $oldversion < 2007040200) {
        /// Add some actions to get them properly displayed in the logs
        $rec = new stdClass();
        $rec->module = 'hotquestion';
        $rec->action = 'add';
        $rec->mtable = 'hotquestion';
        $rec->filed = 'name';
        /// Insert the add action in log_display
        $result = $DB->insert_record('log_display', $rec);
        /// Now the update action
        $rec->action = 'update';
        $result = $DB->insert_record('log_display', $rec);
        /// Now the view action
        $rec->action = 'view';
        $result = $DB->insert_record('log_display', $rec);
    }
    //===== 2.0 upgrade start here ======//
    return $result;
}
开发者ID:hgthirty,项目名称:moodle-mod_hotquestion,代码行数:56,代码来源:upgrade.php


示例4: xmldb_blocktype_taggedposts_upgrade

function xmldb_blocktype_taggedposts_upgrade($oldversion = 0)
{
    if ($oldversion < 2015011500) {
        $table = new XMLDBTable('blocktype_taggedposts_tags');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
        $table->addFieldInfo('block_instance', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
        $table->addFieldInfo('tag', XMLDB_TYPE_CHAR, 128, null, XMLDB_NOTNULL);
        $table->addFieldInfo('tagtype', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('tagtagtypeix', XMLDB_INDEX_NOTUNIQUE, array('tag', 'tagtype'));
        if (!table_exists($table)) {
            create_table($table);
            $rs = get_recordset('block_instance', 'blocktype', 'taggedposts', 'id', 'id, configdata');
            while ($bi = $rs->FetchRow()) {
                // Each block will have only one tag (because we combined this upgrade block
                // with the upgrade block for the "multiple tags" enhancement.
                $configdata = unserialize($bi['configdata']);
                if (!empty($configdata['tagselect'])) {
                    $todb = new stdClass();
                    $todb->block_instance = $bi['id'];
                    $todb->tag = $configdata['tagselect'];
                    $todb->tagtype = PluginBlocktypeTaggedposts::TAGTYPE_INCLUDE;
                    insert_record('blocktype_taggedposts_tags', $todb);
                }
            }
        }
    }
    return true;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:29,代码来源:upgrade.php


示例5: xmldb_crlm_cluster_classification_upgrade

/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    elis
 * @subpackage curriculummanagement
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_crlm_cluster_classification_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2010080502) {
        /// Define table crlm_cluster_classification to be created
        $table = new XMLDBTable('crlm_cluster_classification');
        /// Adding fields to table crlm_cluster_classification
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('params', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
        /// Adding keys to table crlm_cluster_classification
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('shortname_idx', XMLDB_KEY_UNIQUE, array('shortname'));
        /// Launch create table for crlm_cluster_classification
        $result = $result && create_table($table);
    }
    if ($result && $oldversion < 2010080503) {
        require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
        $field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_CLASSIFICATION_FIELD));
        // make sure we're set as owner
        if (!isset($field->owners['cluster_classification'])) {
            $owner = new field_owner();
            $owner->fieldid = $field->id;
            $owner->plugin = 'cluster_classification';
            $owner->add();
        }
        // make sure we have a default value set
        if (!field_data::get_for_context_and_field(NULL, $field)) {
            field_data::set_for_context_and_field(NULL, $field, 'regular');
        }
        $default = new clusterclassification();
        $default->shortname = 'regular';
        $default->name = get_string('cluster', 'block_curr_admin');
        $default->param_autoenrol_curricula = 1;
        $default->param_autoenrol_tracks = 1;
        $default->add();
    }
    // make sure 'manual' is an owner
    if ($result && $oldversion < 2010080504) {
        require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
        $field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_CLASSIFICATION_FIELD));
        $owner = new field_owner();
        $owner->fieldid = $field->id;
        $owner->plugin = 'manual';
        $owner->param_view_capability = '';
        $owner->param_edit_capability = 'moodle/user:update';
        $owner->param_control = 'menu';
        $owner->param_options_source = 'cluster_classifications';
        $owner->add();
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:82,代码来源:upgrade.php


示例6: xmldb_format_fn_upgrade

function xmldb_format_fn_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2007060102) {
        //New version in version.php
        $table = new XMLDBTable('fn_coursemodule_extra');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null, null);
        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'id');
        $table->addFieldInfo('cmid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'courseid');
        $table->addFieldInfo('hideingradebook', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'cmid');
        $table->addFieldInfo('mandatory', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'hideingradebook');
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('courseid', XMLDB_INDEX_NOTUNIQUE, array('courseid'));
        $table->addIndexInfo('cmid', XMLDB_INDEX_NOTUNIQUE, array('cmid'));
        $result = create_table($table);
    }
    return $result;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:19,代码来源:upgrade.php


示例7: xmldb_qtype_rqp_upgrade

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


示例8: wrsqz_create_program_table

function wrsqz_create_program_table($questionTypeProm)
{
    global $CFG;
    /// Define table question_wxxxxprom to be created
    $promTable = new XMLDBTable('question_' . $questionTypeProm);
    /// Adding fields to table question_wxxxxprom
    $promTable->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
    $promTable->addFieldInfo('question', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
    $promTable->addFieldInfo('program', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
    /// Adding keys to table question_wxxxxprom
    $promTable->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
    /// Adding indexes to table question_wxxxxprom
    $promTable->addIndexInfo($CFG->prefix . 'ques' . substr($questionTypeProm, 0, 4) . '_que_ix', XMLDB_INDEX_NOTUNIQUE, array('question'));
    /// Launch create table
    return wrsqz_create_table($promTable);
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:16,代码来源:db.php


示例9: xmldb_artefact_blog_upgrade

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


示例10: xmldb_block_php_report_upgrade

/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    elis
 * @subpackage php_reports
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_block_php_report_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2011040600) {
        /// Define table php_report_schedule to be created
        $table = new XMLDBTable('php_report_schedule');
        /// Adding fields to table php_report_schedule
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('report', XMLDB_TYPE_CHAR, '63', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('config', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null);
        /// Adding keys to table php_report_schedule
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        /// Adding indexes to table php_report_schedule
        $table->addIndexInfo('report_idx', XMLDB_INDEX_NOTUNIQUE, array('report'));
        /// Launch create table for php_report_schedule
        $result = $result && create_table($table);
        /// Define field userid to be added to php_report_schedule
        $table = new XMLDBTable('php_report_schedule');
        $field = new XMLDBField('userid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'id');
        /// Launch add field userid
        $result = $result && add_field($table, $field);
        /// Define index userid_idx (not unique) to be added to php_report_schedule
        $table = new XMLDBTable('php_report_schedule');
        $index = new XMLDBIndex('userid_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
        /// Launch add index userid_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2011042900) {
        $query = "name " . sql_ilike() . " 'php_report%'";
        $result = $result && delete_records_select('user_preferences', $query);
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.reporting,代码行数:60,代码来源:upgrade.php


示例11: xmldb_artefact_file_upgrade

function xmldb_artefact_file_upgrade($oldversion = 0)
{
    $status = true;
    if ($oldversion < 2009033000) {
        if (!get_record('artefact_config', 'plugin', 'file', 'field', 'uploadagreement')) {
            insert_record('artefact_config', (object) array('plugin' => 'file', 'field' => 'uploadagreement', 'value' => 1));
            insert_record('artefact_config', (object) array('plugin' => 'file', 'field' => 'usecustomagreement', 'value' => 1));
        }
    }
    if ($oldversion < 2009091700) {
        execute_sql("DELETE FROM {artefact_file_files} WHERE artefact IN (SELECT id FROM {artefact} WHERE artefacttype = 'folder')");
    }
    if ($oldversion < 2009091701) {
        $table = new XMLDBTable('artefact_file_files');
        $key = new XMLDBKey('artefactpk');
        $key->setAttributes(XMLDB_KEY_PRIMARY, array('artefact'));
        add_key($table, $key);
        $table = new XMLDBTable('artefact_file_image');
        $key = new XMLDBKey('artefactpk');
        $key->setAttributes(XMLDB_KEY_PRIMARY, array('artefact'));
        add_key($table, $key);
    }
    if ($oldversion < 2009092300) {
        insert_record('artefact_installed_type', (object) array('plugin' => 'file', 'name' => 'archive'));
        // update old files
        if (function_exists('zip_open')) {
            $files = get_records_select_array('artefact_file_files', "filetype IN ('application/zip', 'application/x-zip')");
            if ($files) {
                $checked = array();
                foreach ($files as $file) {
                    $path = get_config('dataroot') . 'artefact/file/originals/' . $file->fileid % 256 . '/' . $file->fileid;
                    $zip = zip_open($path);
                    if (is_resource($zip)) {
                        $checked[] = $file->artefact;
                        zip_close($zip);
                    }
                }
                if (!empty($checked)) {
                    set_field_select('artefact', 'artefacttype', 'archive', "artefacttype = 'file' AND id IN (" . join(',', $checked) . ')', array());
                }
            }
        }
    }
    if ($oldversion < 2010012702) {
        if ($records = get_records_sql_array("SELECT * FROM {artefact_file_files} WHERE filetype='application/octet-stream'", array())) {
            require_once 'file.php';
            foreach ($records as &$r) {
                $path = get_config('dataroot') . 'artefact/file/originals/' . $r->fileid % 256 . '/' . $r->fileid;
                set_field('artefact_file_files', 'filetype', file_mime_type($path), 'fileid', $r->fileid, 'artefact', $r->artefact);
            }
        }
    }
    if ($oldversion < 2011052500) {
        // Set default quota to 50MB
        set_config_plugin('artefact', 'file', 'defaultgroupquota', 52428800);
    }
    if ($oldversion < 2011070700) {
        // Create an images folder for everyone with a profile icon
        $imagesdir = get_string('imagesdir', 'artefact.file');
        $imagesdirdesc = get_string('imagesdirdesc', 'artefact.file');
        execute_sql("\n            INSERT INTO {artefact} (artefacttype, container, owner, ctime, mtime, atime, title, description, author)\n            SELECT 'folder', 1, owner, current_timestamp, current_timestamp, current_timestamp, ?, ?, owner\n            FROM {artefact} WHERE owner IS NOT NULL AND artefacttype = 'profileicon'\n            GROUP BY owner", array($imagesdir, $imagesdirdesc));
        // Put profileicons into the images folder and update the description
        $profileicondesc = get_string('uploadedprofileicon', 'artefact.file');
        if (is_postgres()) {
            execute_sql("\n                UPDATE {artefact}\n                SET parent = f.folderid, description = ?\n                FROM (\n                    SELECT owner, MAX(id) AS folderid\n                    FROM {artefact}\n                    WHERE artefacttype = 'folder' AND title = ? AND description = ?\n                    GROUP BY owner\n                ) f\n                WHERE artefacttype = 'profileicon' AND {artefact}.owner = f.owner", array($profileicondesc, $imagesdir, $imagesdirdesc));
        } else {
            execute_sql("\n                UPDATE {artefact}, (\n                    SELECT owner, MAX(id) AS folderid\n                    FROM {artefact}\n                    WHERE artefacttype = 'folder' AND title = ? AND description = ?\n                    GROUP BY owner\n                ) f\n                SET parent = f.folderid, description = ?\n                WHERE artefacttype = 'profileicon' AND {artefact}.owner = f.owner", array($imagesdir, $imagesdirdesc, $profileicondesc));
        }
    }
    if ($oldversion < 2011082200) {
        // video file type
        if (!get_record('artefact_installed_type', 'plugin', 'file', 'name', 'video')) {
            insert_record('artefact_installed_type', (object) array('plugin' => 'file', 'name' => 'video'));
        }
        // update existing records
        $videotypes = get_records_sql_array('
            SELECT DISTINCT description
            FROM {artefact_file_mime_types}
            WHERE mimetype ' . db_ilike() . ' \'%video%\'', array());
        if ($videotypes) {
            $mimetypes = array();
            foreach ($videotypes as $type) {
                $mimetypes[] = $type->description;
            }
            $files = get_records_sql_array('
                SELECT *
                FROM {artefact_file_files}
                WHERE filetype IN (
                    SELECT mimetype
                    FROM {artefact_file_mime_types}
                    WHERE description IN (' . join(',', array_map('db_quote', array_values($mimetypes))) . ')
                )', array());
            if ($files) {
                $checked = array();
                foreach ($files as $file) {
                    $checked[] = $file->artefact;
                }
                if (!empty($checked)) {
                    set_field_select('artefact', 'artefacttype', 'video', "artefacttype = 'file' AND id IN (" . join(',', $checked) . ')', array());
                }
//.........这里部分代码省略.........
开发者ID:sarahjcotton,项目名称:mahara,代码行数:101,代码来源:upgrade.php


示例12: invoke

 /**
  * Invoke method, every class will have its own
  * returns true/false on completion, setting both
  * errormsg and output as necessary
  */
 function invoke()
 {
     parent::invoke();
     $result = true;
     /// Set own core attributes
     $this->does_generate = ACTION_GENERATE_HTML;
     /// These are always here
     global $CFG, $XMLDB, $db;
     /// Do the job, setting result as needed
     /// Get the dir containing the file
     $dirpath = required_param('dir', PARAM_PATH);
     $dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
     /// Get the correct dirs
     if (!empty($XMLDB->dbdirs)) {
         $dbdir =& $XMLDB->dbdirs[$dirpath];
     } else {
         return false;
     }
     if (!empty($XMLDB->editeddirs)) {
         $editeddir =& $XMLDB->editeddirs[$dirpath];
         $structure =& $editeddir->xml_file->getStructure();
     }
     /// ADD YOUR CODE HERE
     $tableparam = optional_param('table', NULL, PARAM_CLEAN);
     /// If no table, show form
     if (!$tableparam) {
         /// No postaction here
         $this->postaction = NULL;
         /// Get list of tables
         $dbtables = $db->MetaTables('TABLES');
         $selecttables = array();
         foreach ($dbtables as $dbtable) {
             $dbtable = strtolower(str_replace($CFG->prefix, '', $dbtable));
             $i = $structure->findTableInArray($dbtable);
             if ($i === NULL) {
                 $selecttables[$dbtable] = $dbtable;
             }
         }
         /// Get list of after tables
         $aftertables = array();
         if ($tables =& $structure->getTables()) {
             foreach ($tables as $aftertable) {
                 $aftertables[$aftertable->getName()] = $aftertable->getName();
             }
         }
         if (!$selecttables) {
             $this->errormsg = 'No tables available to be retrofitted';
             return false;
         }
         /// Now build the form
         $o = '<form id="form" action="index.php" method="post">';
         $o .= '<div>';
         $o .= '    <input type="hidden" name ="dir" value="' . str_replace($CFG->dirroot, '', $dirpath) . '" />';
         $o .= '    <input type="hidden" name ="action" value="new_table_from_mysql" />';
         $o .= '    <input type="hidden" name ="postaction" value="edit_table" />';
         $o .= '    <table id="formelements" class="boxaligncenter" cellpadding="5">';
         $o .= '      <tr><td><label for="table" accesskey="t">' . $this->str['createtable'] . ' </label>' . choose_from_menu($selecttables, 'table', '', 'choose', '', 0, true) . '<label for="after" accesskey="a">' . $this->str['aftertable'] . ' </label>' . choose_from_menu($aftertables, 'after', '', 'choose', '', 0, true) . '</td></tr>';
         $o .= '      <tr><td colspan="2" align="center"><input type="submit" value="' . $this->str['create'] . '" /></td></tr>';
         $o .= '      <tr><td colspan="2" align="center"><a href="index.php?action=edit_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a></td></tr>';
         $o .= '    </table>';
         $o .= '</div></form>';
         $this->output = $o;
         /// If table, retrofit information and, if everything works,
         /// go to the table edit action
     } else {
         /// Get some params (table is mandatory here)
         $tableparam = required_param('table', PARAM_CLEAN);
         $afterparam = required_param('after', PARAM_CLEAN);
         /// Create one new XMLDBTable
         $table = new XMLDBTable(strtolower(trim($tableparam)));
         $table->setComment($table->getName() . ' table retrofitted from MySQL');
         /// Get fields info from ADODb
         if (!($dbfields = $db->MetaColumns($CFG->prefix . $tableparam))) {
             ///Try it without prefix if doesn't exist
             $dbfields = $db->MetaColumns($tableparam);
         }
         if ($dbfields) {
             foreach ($dbfields as $dbfield) {
                 /// Create new XMLDB field
                 $field = new XMLDBField(strtolower($dbfield->name));
                 /// Set field with info retrofitted
                 $field->setFromADOField($dbfield);
                 /// Add field to the table
                 $table->addField($field);
             }
         }
         /// Get PK, UK and indexes info from ADODb
         $dbindexes = $db->MetaIndexes($CFG->prefix . $tableparam, true);
         if ($dbindexes) {
             $lastkey = NULL;
             //To temp store the last key processed
             foreach ($dbindexes as $indexname => $dbindex) {
                 /// Add the indexname to the array
                 $dbindex['name'] = $indexname;
                 /// We are handling one XMLDBKey (primaries + uniques)
//.........这里部分代码省略.........
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:new_table_from_mysql.class.php


示例13: sync_users

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


示例14: xmldb_dialogue_upgrade

function xmldb_dialogue_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2007100300) {
        /// Define field recipientid to be added to dialogue_entries
        $table = new XMLDBTable('dialogue_entries');
        $field = new XMLDBField('recipientid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'userid');
        /// Launch add field recipientid
        $result = $result && add_field($table, $field);
        $index = new XMLDBIndex('dialogue_entries_recipientid_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('recipientid'));
        /// Launch add index dialogue_entries_recipientid_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2007100301) {
        /// Define field lastrecipientid to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $field = new XMLDBField('lastrecipientid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0', 'lastid');
        /// Launch add field lastrecipientid
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007100400) {
        /// Define field attachment to be added to dialogue_entries
        $table = new XMLDBTable('dialogue_entries');
        $field = new XMLDBField('attachment');
        $field->setAttributes(XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null, 'text');
        /// Launch add field attachment
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007100800) {
        /// Define field edittime to be added to dialogue
        $table = new XMLDBTable('dialogue');
        $field = new XMLDBField('edittime');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
        /// Launch add field edittime
        $result = $result && add_field($table, $field);
    }
    if ($result && $oldversion < 2007110700) {
        /// Define field groupid to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $field = new XMLDBField('groupid');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'subject');
        /// Launch add field groupid
        $result = $result && add_field($table, $field);
        /// Define index dialogue_conversations_groupid_idx (not unique) to be added to dialogue_conversations
        $index = new XMLDBIndex('dialogue_conversations_groupid_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('groupid'));
        /// Launch add index dialogue_conversations_groupid_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2007110800) {
        /// Define field grouping to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $field = new XMLDBField('grouping');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, '0', 'groupid');
        /// Launch add field grouping
        $result = $result && add_field($table, $field);
        /// Define index dialogue_conversations_grouping_idx (not unique) to be added to dialogue_conversations
        $table = new XMLDBTable('dialogue_conversations');
        $index = new XMLDBIndex('dialogue_conversations_grouping_idx');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('grouping'));
        /// Launch add index dialogue_conversations_grouping_idx
        $result = $result && add_index($table, $index);
    }
    if ($result && $oldversion < 2007111401) {
        /// Define field timemodified to be added to dialogue_entries
        $table = new XMLDBTable('dialogue_entries');
        $field = new XMLDBField('timemodified');
        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, '0', 'timecreated');
        /// Launch add field timemodified
        $result = $result && add_field($table, $field);
        $result = $result && ($result = execute_sql('UPDATE ' . $CFG->prefix . 'dialogue_entries SET timemodified = timecreated'));
    }
    if ($result && $oldversion < 2007112200) {
        /// Define table dialogue_read to be created
        $table = new XMLDBTable('dialogue_read');
        /// Adding fields to table dialogue_read
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('entryid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('fi 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP XMLElement类代码示例发布时间:2022-05-23
下一篇:
PHP XMLDBIndex类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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