本文整理汇总了PHP中xmldb_field::set_attributes方法的典型用法代码示例。如果您正苦于以下问题:PHP xmldb_field::set_attributes方法的具体用法?PHP xmldb_field::set_attributes怎么用?PHP xmldb_field::set_attributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmldb_field
的用法示例。
在下文中一共展示了xmldb_field::set_attributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_customlabel_upgrade
function xmldb_customlabel_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB;
$result = true;
$dbman = $DB->get_manager();
//===== 1.9.0 upgrade line ======//
if ($result && $oldversion < 2012062401) {
// Define field fallbacktype to be added to customlabel.
$table = new xmldb_table('customlabel');
$field = new xmldb_field('fallbacktype');
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null, null, null, null, 'labelclass');
// Launch add field parent.
$result = $result || $dbman->add_field($table, $field);
// customlabel savepoint reached.
upgrade_mod_savepoint($result, 2012062401, 'customlabel');
}
if ($result && $oldversion < 2013041802) {
// Regenerates all contents to match template changes.
$sql = "\n SELECT DISTINCT\n c.id,\n c.shortname,\n c.fullname,\n c.idnumber,\n c.summary,\n c.category,\n c.summaryformat\n FROM\n {course} c,\n {course_modules} cm,\n {modules} m\n WHERE\n c.id = cm.course AND\n cm.module = m.id AND\n m.name = 'customlabel'\n ";
$courses = $DB->get_records_sql($sql);
if ($courses) {
echo '<pre>';
foreach ($courses as $c) {
customlabel_course_preprocess_filepickers($c);
customlabel_course_regenerate($c, 'all');
}
echo '</pre>';
}
upgrade_mod_savepoint($result, 2013041802, 'customlabel');
}
return $result;
}
示例2: 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;
}
示例3: xmldb_groupselect_upgrade
function xmldb_groupselect_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB;
$result = true;
$dbman = $DB->get_manager();
if ($result && $oldversion < 2009020600) {
/// Define field signuptype to be added to groupselect
$table = new xmldb_table('groupselect');
$field = new xmldb_field('signuptype');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, '0', 'intro');
$dbman->add_field($table, $field);
/// Define field timecreated to be added to groupselect
$table = new xmldb_table('groupselect');
$field = new xmldb_field('timecreated');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timedue');
$dbman->add_field($table, $field);
}
if ($result && $oldversion < 2009030500) {
/// Define field targetgrouping to be added to groupselect
$table = new xmldb_table('groupselect');
$field = new xmldb_field('targetgrouping');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
$dbman->add_field($table, $field);
}
if ($result && $oldversion < 2009061200) {
$table = new xmldb_table('groupselect');
$field = new xmldb_field('individual_limits');
$field->set_attributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$dbman->add_field($table, $field);
$table = new xmldb_table('groupselect_limits');
if ($result && !$dbman->table_exists($table)) {
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->add_field('groupselect', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->add_field('lim', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_index('groupselect', XMLDB_INDEX_NOTUNIQUE, array('groupselect'));
$dbman->create_table($table);
}
}
// Define field introformat to be added to groupselect
if ($result && $oldversion < 2010101300) {
$table = new xmldb_table('groupselect');
$field = new xmldb_field('introformat');
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$dbman->add_field($table, $field);
}
return $result;
}
示例4: xmldb_local_lae_install
function xmldb_local_lae_install()
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// Migrate the old config setting, if present.
if (!empty($CFG->forum_anonymous)) {
set_config('forum_enableanonymousposts', $CFG->forum_anonymous);
set_config('forum_anonymous', null);
}
// Extend forum tables.
$table = new xmldb_table('forum');
$field = new xmldb_field('anonymous');
$field->set_attributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completionposts');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$table = new xmldb_table('forum_posts');
$field = new xmldb_field('hiddenuserid');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, 'mailnow');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Add anonymous user.
if (empty($CFG->anonymous_userid)) {
$anon_user = new stdClass();
$anon_user->username = 'anonymous_user';
// The password needs strings.
$anon_user->password = hash_internal_user_password(str_shuffle($anon_user->username) . (string) mt_rand());
$anon_user->auth = 'nologin';
$anon_user->firstname = get_string('auser_firstname', 'local_lae');
$anon_user->lastname = get_string('auser_lastname', 'local_lae');
$anon_user->mnethostid = $CFG->mnet_localhost_id;
$anon_user->email = get_string('auser_email', 'local_lae');
if ($result = $DB->insert_record('user', $anon_user)) {
set_config('anonymous_userid', $result);
context_user::instance($result);
} else {
print_error("Failed to create anonymous user");
return false;
}
}
// Update course table to support display defaults
$table = new xmldb_table('course');
$field = new xmldb_field('filedisplaydefault', XMLDB_TYPE_INTEGER, '2', null, null, null, null, null);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
return true;
}
示例5: xmldb_block_poll_upgrade
function xmldb_block_poll_upgrade($oldversion)
{
global $DB;
$dbman = $DB->get_manager();
// Add a new column for anonymous polls.
if ($oldversion < 2011041400) {
$table = new xmldb_table('block_poll');
$field = new xmldb_field('anonymous');
$field->set_attributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'created');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
}
return true;
}
示例6: xmldb_customlabel_upgrade
function xmldb_customlabel_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB;
$result = true;
$dbman = $DB->get_manager();
//===== 1.9.0 upgrade line ======//
if ($result && $oldversion < 2012062401) {
/// Define field fallbacktype to be added to customlabel
$table = new xmldb_table('customlabel');
$field = new xmldb_field('fallbacktype');
$field->set_attributes(XMLDB_TYPE_CHAR, '32', null, null, null, null, 'labelclass');
/// Launch add field parent
$result = $result || $dbman->add_field($table, $field);
/// customlabel savepoint reached
upgrade_mod_savepoint($result, 2012062401, 'customlabel');
}
return $result;
}
示例7: xmldb_conceptmap_upgrade
function xmldb_conceptmap_upgrade($oldversion = 0)
{
if ($oldversion < 20151231) {
// Add new fields to certificate table.
$table = new xmldb_table('concept-map');
$field = new xmldb_field('showcode');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'savecert');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Add new fields to certificate_issues table.
$table = new xmldb_table('certificate_issues');
$field = new xmldb_field('code');
$field->set_attributes(XMLDB_TYPE_CHAR, '50', null, null, null, null, 'certificateid');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Certificate savepoint reached.
upgrade_mod_savepoint(true, 2012091800, 'certificate');
}
}
示例8: xmldb_engagement_upgrade
/**
* Upgrades for engagement
*
* @package mod_engagement
* @copyright 2012 NetSpot Pty Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_engagement_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
if ($oldversion < 2012061900) {
if (!$dbman->table_exists('engagement_cache')) {
$dbman->install_one_table_from_xmldb_file($CFG->dirroot . '/mod/engagement/db/install.xml', 'engagement_cache');
}
upgrade_mod_savepoint(true, 2012061900, 'engagement');
}
if ($oldversion < 2012080700) {
$table = new xmldb_table('engagement_cache');
$field = new xmldb_field('rawdata');
$field->set_attributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field, 'settings');
}
upgrade_mod_savepoint(true, 2012080700, 'engagement');
}
return true;
}
示例9: xmldb_groupreg_upgrade
function xmldb_groupreg_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// loads ddl manager and xmldb classes
if ($oldversion < 2011100201) {
$table = new xmldb_table('groupreg');
$field = new xmldb_field('groupmembers');
$field->set_attributes(XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '4', 'assigned');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
}
if ($oldversion < 2011112601) {
// Adding DB field: boolean (int-1) "finalized", telling whether the students have already been put in their groups.
$table = new xmldb_table('groupreg');
$field = new xmldb_field('finalized');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'groupmembers');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
}
return true;
}
示例10: xmldb_mindmap_upgrade
/**
* Mindmap plugin upgrade code
*
* @package mod
* @subpackage mindmap
* @author ekpenso.com
* @copyright 2011 Tõnis Tartes <tonis.tartes@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_mindmap_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB;
$dbman = $DB->get_manager();
/// loads ddl manager and xmldb classes
$result = true;
if ($oldversion < 2012032300) {
upgrade_mod_savepoint(true, 2012032300, 'mindmap');
}
if ($oldversion < 2012061300) {
$table = new xmldb_table('mindmap');
$field = new xmldb_field('editable', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'userid');
$dbman->change_field_type($table, $field);
upgrade_mod_savepoint(true, 2012061300, 'mindmap');
}
if ($oldversion < 2012070400) {
upgrade_mod_savepoint(true, 2012070400, 'mindmap');
}
//Locking functionality
if ($oldversion < 2013030100) {
$table = new xmldb_table('mindmap');
$field = new xmldb_field('locking');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'timemodified');
$dbman->add_field($table, $field);
$table = new xmldb_table('mindmap');
$field = new xmldb_field('locked');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'locking');
$dbman->add_field($table, $field);
$table = new xmldb_table('mindmap');
$field = new xmldb_field('lockedbyuser');
$field->set_attributes(XMLDB_TYPE_INTEGER, '12', null, XMLDB_NOTNULL, null, '0', 'locked');
$dbman->add_field($table, $field);
upgrade_mod_savepoint(true, 2013030100, 'mindmap');
}
return $result;
}
示例11: xmldb_block_quickmail_upgrade
function xmldb_block_quickmail_upgrade($oldversion)
{
global $DB;
$result = true;
$dbman = $DB->get_manager();
// 1.9 to 2.0 upgrade
if ($oldversion < 2011021812) {
// Changing type of field attachment on table block_quickmail_log to text
$table = new xmldb_table('block_quickmail_log');
$field = new xmldb_field('attachment', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'message');
// Launch change of type for field attachment
$dbman->change_field_type($table, $field);
// Rename field timesent on table block_quickmail_log to time
$table = new xmldb_table('block_quickmail_log');
$field = new xmldb_field('timesent', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'format');
// Conditionally launch rename field timesent
if ($dbman->field_exists($table, $field)) {
$dbman->rename_field($table, $field, 'time');
}
// Define table block_quickmail_signatures to be created
$table = new xmldb_table('block_quickmail_signatures');
// Adding fields to table block_quickmail_signatures
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '11', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('title', XMLDB_TYPE_CHAR, '125', null, null, null, null);
$table->add_field('signature', XMLDB_TYPE_TEXT, 'medium', null, null, null, null);
$table->add_field('default_flag', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
// Adding keys to table block_quickmail_signatures
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
// Conditionally launch create table for block_quickmail_signatures
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Define table block_quickmail_drafts to be created
$table = new xmldb_table('block_quickmail_drafts');
// Adding fields to table block_quickmail_drafts
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('courseid', XMLDB_TYPE_INTEGER, '11', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('userid', XMLDB_TYPE_INTEGER, '11', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('mailto', XMLDB_TYPE_TEXT, 'medium', null, null, null, null);
$table->add_field('subject', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('message', XMLDB_TYPE_TEXT, 'medium', null, null, null, null);
$table->add_field('attachment', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null);
$table->add_field('format', XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
$table->add_field('time', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
// Adding keys to table block_quickmail_drafts
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
// Conditionally launch create table for block_quickmail_drafts
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Define table block_quickmail_config to be created
$table = new xmldb_table('block_quickmail_config');
// Adding fields to table block_quickmail_config
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('coursesid', XMLDB_TYPE_INTEGER, '11', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('name', XMLDB_TYPE_CHAR, '25', null, XMLDB_NOTNULL, null, null);
$table->add_field('value', XMLDB_TYPE_CHAR, '125', null, null, null, null);
// Adding keys to table block_quickmail_config
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
// Conditionally launch create table for block_quickmail_config
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// quickmail savepoint reached
upgrade_block_savepoint($result, 2011021812, 'quickmail');
}
if ($oldversion < 2012021014) {
$table = new xmldb_table('block_quickmail_alternate');
$field = new xmldb_field('id');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null);
$table->addField($field);
$field = new xmldb_field('courseid');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, 'id');
$table->addField($field);
$field = new xmldb_field('address');
$field->set_attributes(XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, false, null, 'courseid');
$table->addField($field);
$field = new xmldb_field('valid');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', 'address');
$table->addField($field);
$key = new xmldb_key('PRIMARY');
$key->set_attributes(XMLDB_KEY_PRIMARY, array('id'));
$table->addKey($key);
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
foreach (array('log', 'drafts') as $table) {
// Define field alternateid to be added to block_quickmail_log
$table = new xmldb_table('block_quickmail_' . $table);
$field = new xmldb_field('alternateid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'userid');
// Conditionally launch add field alternateid
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
}
// quickmail savepoint reached
upgrade_block_savepoint($result, 2012021014, 'quickmail');
}
if ($oldversion < 2012061112) {
//.........这里部分代码省略.........
示例12: xmldb_scorm_upgrade
function xmldb_scorm_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
//===== 1.9.0 upgrade line ======//
// Adding missing 'whatgrade' field to table scorm
if ($result && $oldversion < 2008073000) {
$table = new xmldb_table('scorm');
$field = new xmldb_field('whatgrade');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'grademethod');
/// Launch add field whatgrade
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint($result, 2008073000, 'scorm');
}
if ($result && $oldversion < 2008082500) {
/// Define field scormtype to be added to scorm
$table = new xmldb_table('scorm');
$field = new xmldb_field('scormtype', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, 'local', 'name');
/// Launch add field scormtype
$dbman->add_field($table, $field);
/// scorm savepoint reached
upgrade_mod_savepoint($result, 2008082500, 'scorm');
}
if ($result && $oldversion < 2008090300) {
/// Define field sha1hash to be added to scorm
$table = new xmldb_table('scorm');
$field = new xmldb_field('sha1hash', XMLDB_TYPE_CHAR, '40', null, null, null, null, 'updatefreq');
/// Launch add field sha1hash
$dbman->add_field($table, $field);
/// scorm savepoint reached
upgrade_mod_savepoint($result, 2008090300, 'scorm');
}
if ($result && $oldversion < 2008090301) {
/// Define field revision to be added to scorm
$table = new xmldb_table('scorm');
$field = new xmldb_field('revision', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'md5hash');
/// Launch add field revision
$dbman->add_field($table, $field);
/// scorm savepoint reached
upgrade_mod_savepoint($result, 2008090301, 'scorm');
}
if ($result && $oldversion < 2008090302) {
$sql = "UPDATE {scorm}\n SET scormtype = 'external'\n WHERE reference LIKE ? OR reference LIKE ? OR reference LIKE ?";
$DB->execute($sql, array('http://%imsmanifest.xml', 'https://%imsmanifest.xml', 'www.%imsmanifest.xml'));
$sql = "UPDATE {scorm}\n SET scormtype = 'localsync'\n WHERE reference LIKE ? OR reference LIKE ? OR reference LIKE ?\n OR reference LIKE ? OR reference LIKE ? OR reference LIKE ?";
$DB->execute($sql, array('http://%.zip', 'https://%.zip', 'www.%.zip', 'http://%.pif', 'https://%.pif', 'www.%.pif'));
$sql = "UPDATE {scorm} SET scormtype = 'imsrepository' WHERE reference LIKE ?";
$DB->execute($sql, array('#%'));
/// scorm savepoint reached
upgrade_mod_savepoint($result, 2008090302, 'scorm');
}
if ($result && $oldversion < 2008090303) {
//remove obsoleted config settings
unset_config('scorm_advancedsettings');
unset_config('scorm_windowsettings');
/// scorm savepoint reached
upgrade_mod_savepoint($result, 2008090303, 'scorm');
}
if ($result && $oldversion < 2008090304) {
/////////////////////////////////////
/// new file storage upgrade code ///
/////////////////////////////////////
function scorm_migrate_content_files($context, $base, $path)
{
global $CFG, $OUTPUT;
$fullpathname = $base . $path;
$fs = get_file_storage();
$filearea = 'scorm_content';
$items = new DirectoryIterator($fullpathname);
foreach ($items as $item) {
if ($item->isDot()) {
unset($item);
// release file handle
continue;
}
if ($item->isLink()) {
// do not follow symlinks - they were never supported in moddata, sorry
unset($item);
// release file handle
continue;
}
if ($item->isFile()) {
if (!$item->isReadable()) {
echo $OUTPUT->notification(" File not readable, skipping: " . $fullpathname . $item->getFilename());
unset($item);
// release file handle
continue;
}
$filepath = clean_param($path, PARAM_PATH);
$filename = clean_param($item->getFilename(), PARAM_FILE);
$oldpathname = $fullpathname . $item->getFilename();
if ($filename === '') {
continue;
unset($item);
// release file handle
}
if (!$fs->file_exists($context->id, $filearea, '0', $filepath, $filename)) {
//.........这里部分代码省略.........
示例13: xmldb_block_email_list_upgrade
function xmldb_block_email_list_upgrade($oldversion = 0)
{
global $CFG, $THEME, $DB;
$dbman = $DB->get_manager();
/// loads ddl manager and xmldb classes
$result = true;
// If is set upgrade_blocks_savepoint function
$existfunction = false;
if (!function_exists('upgrade_blocks_savepoint')) {
$existfunction = true;
}
/// And upgrade begins here. For each one, you'll need one
/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
if ($result && $oldversion < 2007062205) {
$fields = array('mod/email:viewmail', 'mod/email:addmail', 'mod/email:reply', 'mod/email:replyall', 'mod/email:forward', 'mod/email:addsubfolder', 'mod/email:updatesubfolder', 'mod/email:removesubfolder');
/// Remove no more used fields
$table = new xmldb_table('capabilities');
foreach ($fields as $name) {
$field = new xmldb_field($name);
$result = $result && $dbman->drop_field($table, $field);
}
// Active cron block of email_list
if ($result) {
if ($email_list = $DB->get_record('block', array('name' => 'email_list'))) {
$email_list->cron = 1;
update_record('block', $email_list);
}
}
if ($existfunction) {
/// Block savepoint reached
upgrade_blocks_savepoint($result, 2007062205, 'email_list');
}
}
// force
$result = true;
if ($result && $oldversion < 2007072003) {
// Add marriedfolder2courses flag on email_preferences
$table = new xmldb_table('email_preference');
$field = new xmldb_field('marriedfolders2courses');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$result = $result && $dbman->add_field($table, $field);
// Add course ID on email_folder
$table = new xmldb_table('email_folder');
$field = new xmldb_field('course');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$result = $result && $dbman->add_field($table, $field);
// Add index
$key = new xmldb_key('course');
$key->set_attributes(XMLDB_KEY_FOREIGN, array('course'), 'course', array('id'));
$result = $result && $dbman->add_key($table, $key);
if ($existfunction) {
/// Block savepoint reached
upgrade_blocks_savepoint($result, 2007072003, 'email_list');
}
}
if ($result && $oldversion < 2008061400) {
// Add reply and forwarded info field on email_mail.
$table = new xmldb_table('email_send');
$field = new xmldb_field('answered');
$field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$result = $result && $dbman->add_field($table, $field);
if ($existfunction) {
/// Block savepoint reached
upgrade_blocks_savepoint($result, 2008061400, 'email_list');
}
}
// Solve old problems
if ($result && $oldversion < 2008061600) {
$table = new xmldb_table('email_preference');
$field = new xmldb_field('marriedfolders2courses');
if (!$dbman->field_exists($table, $field)) {
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$result = $result && $dbman->add_field($table, $field);
}
$table = new xmldb_table('email_folder');
$field = new xmldb_field('course');
if (!$dbman->field_exists($table, $field)) {
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
$result = $result && $dbman->add_field($table, $field);
// Add index
$key = new xmldb_key('course');
$key->set_attributes(XMLDB_KEY_FOREIGN, array('course'), 'course', array('id'));
$result = $result && $dbman->add_key($table, $key);
}
if ($existfunction) {
/// Block savepoint reached
upgrade_blocks_savepoint($result, 2008061600, 'email_list');
}
}
// Add new index
if ($result and $oldversion < 2008081602) {
// Add combine key on foldermail
$table = new xmldb_table('email_foldermail');
$index = new xmldb_index('folderid-mailid');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('folderid', 'mailid'));
if (!$dbman->index_exists($table, $index)) {
/// Launch add index
$result = $result && $dbman->add_index($table, $index);
//.........这里部分代码省略.........
示例14: xmldb_referentiel_upgrade
/**
* This file keeps track of upgrades to
* the referentiel module
*
* Sometimes, changes between versions involve
* alterations to database structures and other
* major things that may break installations.
*
* The upgrade function in this file will attempt
* to perform all the necessary actions to upgrade
* your older installation to the current version.
*
* If there's something it cannot do itself, it
* will tell you what you need to do.
*
* The commands in here will all be database-neutral,
* using the methods of database_manager class
*
* Please do not forget to use upgrade_set_timeout()
* before any action that may take longer time to finish.
*
* @package mod-forum
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @copyright 2011 onwards Jean Fruitet(jfruitet) {@link http://www.univ-nantes.fr}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_referentiel_upgrade($oldversion)
{
global $CFG, $DB, $OUTPUT;
$dbman = $DB->get_manager();
// loads ddl manager and xmldb classes
// VERSION Moodle 2.x
/// Add intro to table referentiel description
$table = new xmldb_table('referentiel');
/// Adding fields
$field = new xmldb_field('intro');
$field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'config_impression');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
$rs = $DB->get_recordset_sql("SELECT * FROM {referentiel}", null);
foreach ($rs as $res) {
if (!empty($res->description_instance)) {
$res->intro = $res->description_instance;
}
$DB->update_record('referentiel', $res);
}
$rs->close();
}
/// Adding fields
$field = new xmldb_field('introformat');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'intro');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
/// And upgrade begins here.
//===== 1.9.0 upgrade line ======//
if ($oldversion < 2008052700) {
/// Define field evaluation to be added to referentiel_certificat
$table = new xmldb_table('referentiel_certificat');
$field = new xmldb_field('evaluation');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'valide');
/// Launch add field evaluation
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2008052700, 'referentiel');
}
if ($oldversion < 2008052800) {
/// Define field logo_etablissement to be added to referentiel_etablissement
$table = new xmldb_table('referentiel_etablissement');
$field = new xmldb_field('logo_etablissement');
$field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'adresse_etablissement');
/// Launch add field referentiel_etablissement
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
/// Add some values to referentiel_etablissement
$rec = new stdClass();
$rec->num_etablissement = 'INCONNU';
$rec->nom_etablissement = 'A COMPLETER';
$rec->adresse_etablissement = 'A COMPLETER';
$rec->logo_etablissement = ' ';
/// Insert the add action in log_display
$DB->insert_record('referentiel_etablissement', $rec, false, false);
upgrade_mod_savepoint(true, 2008052800, 'referentiel');
}
if ($oldversion < 2008062300) {
// VERSION 1.2
/// Define new field liste_codes_competence to be added to referentiel_referentiel
$table1 = new xmldb_table('referentiel_referentiel');
$field1 = new xmldb_field('liste_codes_competence');
$field1->set_attributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'nb_domaines');
/// Launch add field referentiel_referentiel
if (!$dbman->field_exists($table1, $field1)) {
$dbman->add_field($table1, $field1);
}
/// Define new field liste_empreintes_competence to be added to referentiel_referentiel
$field2 = new xmldb_field('liste_empreintes_competence');
$field2->set_attributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'liste_codes_competence');
/// Launch add field referentiel_referentiel
//.........这里部分代码省略.........
示例15: xmldb_facetoface_upgrade
function xmldb_facetoface_upgrade($oldversion = 0)
{
global $CFG, $USER, $DB;
$dbman = $DB->get_manager();
// Loads ddl manager and xmldb classes.
require_once $CFG->dirroot . '/mod/facetoface/lib.php';
$result = true;
if ($result && $oldversion < 2008050500) {
$table = new xmldb_table('facetoface');
$field = new xmldb_field('thirdpartywaitlist');
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'thirdparty');
$result = $result && $dbman->add_field($table, $field);
}
if ($result && $oldversion < 2008061000) {
$table = new xmldb_table('facetoface_submissions');
$field = new xmldb_field('notificationtype');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timemodified');
$result = $result && $dbman->add_field($table, $field);
}
if ($result && $oldversion < 2008080100) {
echo $OUTPUT->notification(get_string('upgradeprocessinggrades', 'facetoface'), 'notifysuccess');
require_once $CFG->dirroot . '/mod/facetoface/lib.php';
$transaction = $DB->start_delegated_transaction();
$DB->debug = false;
// Too much debug output.
// Migrate the grades to the gradebook.
$sql = "SELECT f.id, f.name, f.course, s.grade, s.timegraded, s.userid,\n cm.idnumber as cmidnumber\n FROM {facetoface_submissions} s\n JOIN {facetoface} f ON s.facetoface = f.id\n JOIN {course_modules} cm ON cm.instance = f.id\n JOIN {modules} m ON m.id = cm.module\n WHERE m.name='facetoface'";
if ($rs = $DB->get_recordset_sql($sql)) {
foreach ($rs as $facetoface) {
$grade = new stdclass();
$grade->userid = $facetoface->userid;
$grade->rawgrade = $facetoface->grade;
$grade->rawgrademin = 0;
$grade->rawgrademax = 100;
$grade->timecreated = $facetoface->timegraded;
$grade->timemodified = $facetoface->timegraded;
$result = $result && GRADE_UPDATE_OK == facetoface_grade_item_update($facetoface, $grade);
}
$rs->close();
}
$DB->debug = true;
// Remove the grade and timegraded fields from facetoface_submissions.
if ($result) {
$table = new xmldb_table('facetoface_submissions');
$field1 = new xmldb_field('grade');
$field2 = new xmldb_field('timegraded');
$result = $result && $dbman->drop_field($table, $field1, false, true);
$result = $result && $dbman->drop_field($table, $field2, false, true);
}
$transaction->allow_commit();
}
if ($result && $oldversion < 2008090800) {
// Define field timemodified to be added to facetoface_submissions.
$table = new xmldb_table('facetoface_submissions');
$field = new xmldb_field('timecancelled');
$field->set_attributes(XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'timemodified');
// Launch add field.
$result = $result && $dbman->add_field($table, $field);
}
if ($result && $oldversion < 2009111300) {
// New fields necessary for the training calendar.
$table = new xmldb_table('facetoface');
$field1 = new xmldb_field('shortname');
$field1->set_attributes(XMLDB_TYPE_CHAR, '32', null, null, null, null, 'timemodified');
$result = $result && $dbman->add_field($table, $field1);
$field2 = new xmldb_field('description');
$field2->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'shortname');
$result = $result && $dbman->add_field($table, $field2);
$field3 = new xmldb_field('showoncalendar');
$field3->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'description');
$result = $result && $dbman->add_field($table, $field3);
}
if ($result && $oldversion < 2009111600) {
$table1 = new xmldb_table('facetoface_session_field');
$table1->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table1->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table1->add_field('shortname', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table1->add_field('type', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table1->add_field('possiblevalues', XMLDB_TYPE_TEXT, 'medium', null, null, null, null);
$table1->add_field('required', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table1->add_field('defaultvalue', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table1->add_field('isfilter', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
$table1->add_field('showinsummary', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1');
$table1->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$result = $result && $dbman->create_table($table1);
$table2 = new xmldb_table('facetoface_session_data');
$table2->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table2->add_field('fieldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table2->add_field('sessionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table2->add_field('data', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table2->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$result = $result && $dbman->create_table($table2);
}
if ($result && $oldversion < 2009111900) {
// Remove unused field.
$table = new xmldb_table('facetoface_sessions');
$field = new xmldb_field('closed');
$result = $result && $dbman->drop_field($table, $field);
}
// Migration of old Location, Venue and Room fields.
//.........这里部分代码省略.........