MDL-29538 core_condition: initial commit to add support for making things conditional on user profile fields

This commit is contained in:
Mark Nelson 2011-09-26 21:20:17 +08:00
parent 6be7840ce6
commit 76af15bb4c
11 changed files with 399 additions and 10 deletions

View file

@ -586,6 +586,22 @@ function xmldb_main_upgrade($oldversion) {
$table->add_key('sourcecmid', XMLDB_KEY_FOREIGN, array('sourcecmid'), 'course_modules', array('id'));
$table->add_key('gradeitemid', XMLDB_KEY_FOREIGN, array('gradeitemid'), 'grade_items', array('id'));
// Define table course_modules_availability to be created
$table = new xmldb_table('course_modules_avail_fields');
// Adding fields to table course_modules_avail_fields
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('coursemoduleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('userfield', XMLDB_TYPE_CHAR, '50', null, null, null, null);
$table->add_field('customfieldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
$table->add_field('operator', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
$table->add_field('value', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
// Adding keys to table course_modules_avail_fields
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('coursemoduleid', XMLDB_KEY_FOREIGN, array('coursemoduleid'), 'course_modules', array('id'));
// Conditionally launch create table for course_modules_availability
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}