本文整理汇总了PHP中upgrade_group_members_only函数的典型用法代码示例。如果您正苦于以下问题:PHP upgrade_group_members_only函数的具体用法?PHP upgrade_group_members_only怎么用?PHP upgrade_group_members_only使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了upgrade_group_members_only函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: xmldb_main_upgrade
//.........这里部分代码省略.........
// Define index behaviour (not unique) to be added to question_attempts.
$table = new xmldb_table('question_attempts');
$index = new xmldb_index('behaviour', XMLDB_INDEX_NOTUNIQUE, array('behaviour'));
// Conditionally launch add index behaviour.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2014080801.0);
}
if ($oldversion < 2014082900.01) {
// Fixing possible wrong MIME type for 7-zip and Rar files.
$filetypes = array('%.7z' => 'application/x-7z-compressed', '%.rar' => 'application/x-rar-compressed');
upgrade_mimetypes($filetypes);
upgrade_main_savepoint(true, 2014082900.01);
}
if ($oldversion < 2014082900.02) {
// Replace groupmembersonly usage with new availability system.
$transaction = $DB->start_delegated_transaction();
if ($CFG->enablegroupmembersonly) {
// If it isn't already enabled, we need to enable availability.
if (!$CFG->enableavailability) {
set_config('enableavailability', 1);
}
// Count all course-modules with groupmembersonly set (for progress
// bar).
$total = $DB->count_records('course_modules', array('groupmembersonly' => 1));
$pbar = new progress_bar('upgradegroupmembersonly', 500, true);
// Get all these course-modules, one at a time.
$rs = $DB->get_recordset('course_modules', array('groupmembersonly' => 1), 'course, id');
$i = 0;
foreach ($rs as $cm) {
// Calculate and set new availability value.
$availability = upgrade_group_members_only($cm->groupingid, $cm->availability);
$DB->set_field('course_modules', 'availability', $availability, array('id' => $cm->id));
// Update progress.
$i++;
$pbar->update($i, $total, "Upgrading groupmembersonly settings - {$i}/{$total}.");
}
$rs->close();
}
// Define field groupmembersonly to be dropped from course_modules.
$table = new xmldb_table('course_modules');
$field = new xmldb_field('groupmembersonly');
// Conditionally launch drop field groupmembersonly.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Unset old config variable.
unset_config('enablegroupmembersonly');
$transaction->allow_commit();
upgrade_main_savepoint(true, 2014082900.02);
}
if ($oldversion < 2014100100.0) {
// Define table messageinbound_handlers to be created.
$table = new xmldb_table('messageinbound_handlers');
// Adding fields to table messageinbound_handlers.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('component', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
$table->add_field('classname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('defaultexpiration', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '86400');
$table->add_field('validateaddress', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1');
$table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
// Adding keys to table messageinbound_handlers.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('classname', XMLDB_KEY_UNIQUE, array('classname'));
开发者ID:isuruAb,项目名称:moodle,代码行数:67,代码来源:upgrade.php
示例2: process_module
protected function process_module($data)
{
global $CFG, $DB;
$data = (object) $data;
$oldid = $data->id;
$this->task->set_old_moduleversion($data->version);
$data->course = $this->task->get_courseid();
$data->module = $DB->get_field('modules', 'id', array('name' => $data->modulename));
// Map section (first try by course_section mapping match. Useful in course and section restores)
$data->section = $this->get_mappingid('course_section', $data->sectionid);
if (!$data->section) {
// mapping failed, try to get section by sectionnumber matching
$params = array('course' => $this->get_courseid(), 'section' => $data->sectionnumber);
$data->section = $DB->get_field('course_sections', 'id', $params);
}
if (!$data->section) {
// sectionnumber failed, try to get first section in course
$params = array('course' => $this->get_courseid());
$data->section = $DB->get_field('course_sections', 'MIN(id)', $params);
}
if (!$data->section) {
// no sections in course, create section 0 and 1 and assign module to 1
$sectionrec = array('course' => $this->get_courseid(), 'section' => 0);
$DB->insert_record('course_sections', $sectionrec);
// section 0
$sectionrec = array('course' => $this->get_courseid(), 'section' => 1);
$data->section = $DB->insert_record('course_sections', $sectionrec);
// section 1
}
$data->groupingid = $this->get_mappingid('grouping', $data->groupingid);
// grouping
if (!grade_verify_idnumber($data->idnumber, $this->get_courseid())) {
// idnumber uniqueness
$data->idnumber = '';
}
if (empty($CFG->enablecompletion)) {
// completion
$data->completion = 0;
$data->completiongradeitemnumber = null;
$data->completionview = 0;
$data->completionexpected = 0;
} else {
$data->completionexpected = $this->apply_date_offset($data->completionexpected);
}
if (empty($CFG->enableavailability)) {
$data->availability = null;
}
// Backups that did not include showdescription, set it to default 0
// (this is not totally necessary as it has a db default, but just to
// be explicit).
if (!isset($data->showdescription)) {
$data->showdescription = 0;
}
$data->instance = 0;
// Set to 0 for now, going to create it soon (next step)
if (empty($data->availability)) {
// If there are legacy availablility data fields (and no new format data),
// convert the old fields.
$data->availability = \core_availability\info::convert_legacy_fields($data, false);
} else {
if (!empty($data->groupmembersonly)) {
// There is current availability data, but it still has groupmembersonly
// as well (2.7 backups), convert just that part.
require_once $CFG->dirroot . '/lib/db/upgradelib.php';
$data->availability = upgrade_group_members_only($data->groupingid, $data->availability);
}
}
// course_module record ready, insert it
$newitemid = $DB->insert_record('course_modules', $data);
// save mapping
$this->set_mapping('course_module', $oldid, $newitemid);
// set the new course_module id in the task
$this->task->set_moduleid($newitemid);
// we can now create the context safely
$ctxid = context_module::instance($newitemid)->id;
// set the new context id in the task
$this->task->set_contextid($ctxid);
// update sequence field in course_section
if ($sequence = $DB->get_field('course_sections', 'sequence', array('id' => $data->section))) {
$sequence .= ',' . $newitemid;
} else {
$sequence = $newitemid;
}
$DB->set_field('course_sections', 'sequence', $sequence, array('id' => $data->section));
// If there is the legacy showavailability data, store this for later use.
// (This data is not present when restoring 'new' backups.)
if (isset($data->showavailability)) {
// Cache the showavailability flag using the backup_ids data field.
restore_dbops::set_backup_ids_record($this->get_restoreid(), 'module_showavailability', $newitemid, 0, null, (object) array('showavailability' => $data->showavailability));
}
}
开发者ID:Jinelle,项目名称:moodle,代码行数:91,代码来源:restore_stepslib.php
示例3: xmldb_main_upgrade
//.........这里部分代码省略.........
// Define index behaviour (not unique) to be added to question_attempts.
$table = new xmldb_table('question_attempts');
$index = new xmldb_index('behaviour', XMLDB_INDEX_NOTUNIQUE, array('behaviour'));
// Conditionally launch add index behaviour.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2014080801.0);
}
if ($oldversion < 2014082900.01) {
// Fixing possible wrong MIME type for 7-zip and Rar files.
$filetypes = array('%.7z' => 'application/x-7z-compressed', '%.rar' => 'application/x-rar-compressed');
upgrade_mimetypes($filetypes);
upgrade_main_savepoint(true, 2014082900.01);
}
if ($oldversion < 2014082900.02) {
// Replace groupmembersonly usage with new availability system.
$transaction = $DB->start_delegated_transaction();
if ($CFG->enablegroupmembersonly) {
// If it isn't already enabled, we need to enable availability.
if (!$CFG->enableavailability) {
set_config('enableavailability', 1);
}
// Count all course-modules with groupmembersonly set (for progress
// bar).
$total = $DB->count_records('course_modules', array('groupmembersonly' => 1));
$pbar = new progress_bar('upgradegroupmembersonly', 500, true);
// Get all these course-modules, one at a time.
$rs = $DB->get_recordset('course_modules', array('groupmembersonly' => 1), 'course, id');
$i = 0;
foreach ($rs as $cm) {
// Calculate and set new availability value.
$availability = upgrade_group_members_only($cm->groupingid, $cm->availability);
$DB->set_field('course_modules', 'availability', $availability, array('id' => $cm->id));
// Update progress.
$i++;
$pbar->update($i, $total, "Upgrading groupmembersonly settings - {$i}/{$total}.");
}
$rs->close();
}
// Define field groupmembersonly to be dropped from course_modules.
$table = new xmldb_table('course_modules');
$field = new xmldb_field('groupmembersonly');
// Conditionally launch drop field groupmembersonly.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Unset old config variable.
unset_config('enablegroupmembersonly');
$transaction->allow_commit();
upgrade_main_savepoint(true, 2014082900.02);
}
if ($oldversion < 2014100100.0) {
// Define table messageinbound_handlers to be created.
$table = new xmldb_table('messageinbound_handlers');
// Adding fields to table messageinbound_handlers.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('component', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
$table->add_field('classname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('defaultexpiration', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '86400');
$table->add_field('validateaddress', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1');
$table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
// Adding keys to table messageinbound_handlers.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('classname', XMLDB_KEY_UNIQUE, array('classname'));
开发者ID:lucaboesch,项目名称:moodle,代码行数:67,代码来源:upgrade.php
示例4: xmldb_main_upgrade
//.........这里部分代码省略.........
// Define index behaviour (not unique) to be added to question_attempts.
$table = new xmldb_table('question_attempts');
$index = new xmldb_index('behaviour', XMLDB_INDEX_NOTUNIQUE, array('behaviour'));
// Conditionally launch add index behaviour.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2014080801.0);
}
if ($oldversion < 2014082900.01) {
// Fixing possible wrong MIME type for 7-zip and Rar files.
$filetypes = array('%.7z' => 'application/x-7z-compressed', '%.rar' => 'application/x-rar-compressed');
upgrade_mimetypes($filetypes);
upgrade_main_savepoint(true, 2014082900.01);
}
if ($oldversion < 2014082900.02) {
// Replace groupmembersonly usage with new availability system.
$transaction = $DB->start_delegated_transaction();
if ($CFG->enablegroupmembersonly) {
// If it isn't already enabled, we need to enable availability.
if (!$CFG->enableavailability) {
set_config('enableavailability', 1);
}
// Count all course-modules with groupmembersonly set (for progress
// bar).
$total = $DB->count_records('course_modules', array('groupmembersonly' => 1));
$pbar = new progress_bar('upgradegroupmembersonly', 500, true);
// Get all these course-modules, one at a time.
$rs = $DB->get_recordset('course_modules', array('groupmembersonly' => 1), 'course, id');
$i = 0;
foreach ($rs as $cm) {
// Calculate and set new availability value.
$availability = upgrade_group_members_only($cm->groupingid, $cm->availability);
$DB->set_field('course_modules', 'availability', $availability, array('id' => $cm->id));
// Update progress.
$i++;
$pbar->update($i, $total, "Upgrading groupmembersonly settings - {$i}/{$total}.");
}
$rs->close();
}
// Define field groupmembersonly to be dropped from course_modules.
$table = new xmldb_table('course_modules');
$field = new xmldb_field('groupmembersonly');
// Conditionally launch drop field groupmembersonly.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Unset old config variable.
unset_config('enablegroupmembersonly');
$transaction->allow_commit();
upgrade_main_savepoint(true, 2014082900.02);
}
if ($oldversion < 2014100100.0) {
// Define table messageinbound_handlers to be created.
$table = new xmldb_table('messageinbound_handlers');
// Adding fields to table messageinbound_handlers.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('component', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
$table->add_field('classname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('defaultexpiration', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '86400');
$table->add_field('validateaddress', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1');
$table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
// Adding keys to table messageinbound_handlers.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('classname', XMLDB_KEY_UNIQUE, array('classname'));
开发者ID:HuiChangZhai,项目名称:moodle,代码行数:67,代码来源:upgrade.php
示例5: process_module
protected function process_module($data)
{
global $CFG, $DB;
$data = (object) $data;
$oldid = $data->id;
$this->task->set_old_moduleversion($data->version);
// Get the current course module data.
$newitemid = $this->task->get_moduleid();
$params = array('id' => $newitemid);
$cmdata = $DB->get_record('course_modules', $params, '*', MUST_EXIST);
// Group mode and Grouping.
$cmdata->groupmode = $data->groupmode;
$cmdata->groupingid = $this->get_mappingid('grouping', $data->groupingid);
// Idnumber uniqueness.
if (!grade_verify_idnumber($data->idnumber, $this->get_courseid())) {
$data->idnumber = '';
}
$cmdata->idnumber = $data->idnumber;
// Completion.
if (!empty($CFG->enablecompletion)) {
$cmdata->completion = $data->completion;
$cmdata->completiongradeitemnumber = $data->completiongradeitemnumber;
$cmdata->completionview = $data->completionview;
$cmdata->completionexpected = $this->apply_date_offset($data->completionexpected);
}
// Availability.
if (empty($CFG->enableavailability)) {
$data->availability = null;
}
if (empty($data->availability)) {
// If there are legacy availablility data fields (and no new format data),
// convert the old fields.
$data->availability = \core_availability\info::convert_legacy_fields($data, false);
} else {
if (!empty($data->groupmembersonly)) {
// There is current availability data, but it still has groupmembersonly
// as well (2.7 backups), convert just that part.
require_once $CFG->dirroot . '/lib/db/upgradelib.php';
$data->availability = upgrade_group_members_only($data->groupingid, $data->availability);
}
}
$cmdata->availability = $data->availability;
// Backups that did not include showdescription, set it to default 0
// (this is not totally necessary as it has a db default, but just to
// be explicit).
if (!isset($data->showdescription)) {
$data->showdescription = 0;
}
$cmdata->showdescription = $data->showdescription;
// Course_module record ready, update it.
$DB->update_record('course_modules', $cmdata);
// Save mapping.
$this->set_mapping('course_module', $oldid, $newitemid);
// Set the new course_module id in the task.
$this->task->set_moduleid($newitemid);
// We can now create the context safely.
$ctxid = context_module::instance($newitemid)->id;
// Set the new context id in the task.
$this->task->set_contextid($ctxid);
// If there is the legacy showavailability data, store this for later use.
// (This data is not present when restoring 'new' backups.)
if (isset($cmdata->showavailability)) {
// Cache the showavailability flag using the backup_ids data field.
restore_dbops::set_backup_ids_record($this->get_restoreid(), 'module_showavailability', $newitemid, 0, null, (object) array('showavailability' => $cmdata->showavailability));
}
}
开发者ID:parksandwildlife,项目名称:learning,代码行数:66,代码来源:restore_dataform_activity_task.class.php
注:本文中的upgrade_group_members_only函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论