|
|
@ -335,28 +335,6 @@ function xmldb_attendance_upgrade($oldversion=0) { |
|
|
|
// Add new warning table. |
|
|
|
if ($oldversion < 2016121315) { |
|
|
|
|
|
|
|
// Define table attendance_warning to be created. |
|
|
|
$table = new xmldb_table('attendance_warning'); |
|
|
|
|
|
|
|
// Adding fields to table attendance_warning. |
|
|
|
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); |
|
|
|
$table->add_field('idnumber', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('warningpercent', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('warnafter', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('emailuser', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('emailsubject', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('emailcontent', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('emailcontentformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('thirdpartyemails', XMLDB_TYPE_TEXT, null, null, null, null, null); |
|
|
|
|
|
|
|
// Adding keys to table attendance_warning. |
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); |
|
|
|
|
|
|
|
// Conditionally launch create table for attendance_warning. |
|
|
|
if (!$dbman->table_exists($table)) { |
|
|
|
$dbman->create_table($table); |
|
|
|
} |
|
|
|
|
|
|
|
// Define table attendance_warning_done to be created. |
|
|
|
$table = new xmldb_table('attendance_warning_done'); |
|
|
|
|
|
|
@ -381,17 +359,44 @@ function xmldb_attendance_upgrade($oldversion=0) { |
|
|
|
upgrade_mod_savepoint(true, 2016121315, 'attendance'); |
|
|
|
} |
|
|
|
|
|
|
|
if ($oldversion < 2016121317) { |
|
|
|
if ($oldversion < 2016121318) { |
|
|
|
// Fix key. |
|
|
|
$table = new xmldb_table('attendance_warning'); |
|
|
|
if ($table->getkey('level_id')) { |
|
|
|
$table->deleteKey('level_id'); |
|
|
|
} |
|
|
|
$key = new xmldb_key('level_id', XMLDB_KEY_UNIQUE, array('idnumber, warningpercent, warnafter')); |
|
|
|
$dbman->add_key($table, $key); |
|
|
|
|
|
|
|
if (!$dbman->table_exists($table)) { |
|
|
|
// Adding fields to table attendance_warning. |
|
|
|
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); |
|
|
|
$table->add_field('idnumber', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('warningpercent', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('warnafter', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('emailuser', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('emailsubject', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('emailcontent', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('emailcontentformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, null); |
|
|
|
$table->add_field('thirdpartyemails', XMLDB_TYPE_TEXT, null, null, null, null, null); |
|
|
|
|
|
|
|
// Adding keys to table attendance_warning. |
|
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); |
|
|
|
$table->add_key('level_id', XMLDB_KEY_UNIQUE, array('idnumber, warningpercent, warnafter')); |
|
|
|
|
|
|
|
// Conditionally launch create table for attendance_warning. |
|
|
|
$dbman->create_table($table); |
|
|
|
|
|
|
|
} else { |
|
|
|
// Key definition is probably incorrect so fix it - drop_key dml function doesn't seem to work. |
|
|
|
$indexes = $DB->get_indexes('attendance_warning'); |
|
|
|
foreach ($indexes as $name => $index) { |
|
|
|
if ($DB->get_dbfamily() === 'mysql') { |
|
|
|
$DB->execute("ALTER TABLE {attendance_warning} DROP INDEX ". $name); |
|
|
|
} else { |
|
|
|
$DB->execute("DROP INDEX ". $name); |
|
|
|
} |
|
|
|
} |
|
|
|
$index = new xmldb_key('level_id', XMLDB_KEY_UNIQUE, array('idnumber, warningpercent', 'warnafter')); |
|
|
|
$dbman->add_key($table, $index); |
|
|
|
} |
|
|
|
// Attendance savepoint reached. |
|
|
|
upgrade_mod_savepoint(true, 2016121317, 'attendance'); |
|
|
|
upgrade_mod_savepoint(true, 2016121318, 'attendance'); |
|
|
|
} |
|
|
|
|
|
|
|
return $result; |
|
|
|