. /** * This file keeps track of upgrades to the customcert module * * @package mod_customcert * @copyright 2015 Shamim Rezaie * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ function xmldb_customcert_upgrade($oldversion=0) { global $CFG, $DB; $dbman = $DB->get_manager(); if ($oldversion < 2015073000) { // Add the margin fields to customcert_pages table $table = new xmldb_table('customcert_pages'); $field = new xmldb_field('margin', XMLDB_TYPE_INTEGER, 10, null, null, null, 0, 'height'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Add the margin fields to customcert_template_pages table $table = new xmldb_table('customcert_template_pages'); $field = new xmldb_field('margin', XMLDB_TYPE_INTEGER, 10, null, null, null, 0, 'height'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Retrieve the customcert_elements table to add some elements to it $table = new xmldb_table('customcert_elements'); // Add the width fields to customcert_elements table $field = new xmldb_field('width', XMLDB_TYPE_INTEGER, 10, null, null, null, 0, 'posy'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Add the refpoint fields to customcert_elements table. $field = new xmldb_field('refpoint', XMLDB_TYPE_INTEGER, 4, null, null, null, 0, 'width'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Add the align fields to customcert_elements table. $field = new xmldb_field('align', XMLDB_TYPE_CHAR, 1, null, null, null, 0, 'refpoint'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Retrieve the customcert_template_elements table to add some elements to it $table = new xmldb_table('customcert_template_elements'); // Add the width fields to customcert_template_elements table $field = new xmldb_field('width', XMLDB_TYPE_INTEGER, 10, null, null, null, 0, 'posy'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Add the refpoint fields to customcert_template_elements table. $field = new xmldb_field('refpoint', XMLDB_TYPE_INTEGER, 4, null, null, null, 0, 'width'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Add the align fields to customcert_template_elements table. $field = new xmldb_field('align', XMLDB_TYPE_CHAR, 1, null, null, null, 0, 'refpoint'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Customcert savepoint reached. upgrade_mod_savepoint(true, 2015073000, 'customcert'); } if ($oldversion < 2015120800) { // Remove the align column from both the 'customcert_elements' and 'customcert_template_elements' table. $table = new xmldb_table('customcert_elements'); $field = new xmldb_field('align'); if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field); } $table = new xmldb_table('customcert_template_elements'); if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field); } // Customcert savepoint reached. upgrade_mod_savepoint(true, 2015120800, 'customcert'); } if ($oldversion < 2015120801) { // Rename the 'margin' field to 'rightmargin' in the 'customcert_pages' and 'customcert_template_pages' tables. $table = new xmldb_table('customcert_pages'); $field = new xmldb_field('margin', XMLDB_TYPE_INTEGER, 10, null, null, null, 0, 'height'); if ($dbman->field_exists($table, $field)) { $dbman->rename_field($table, $field, 'rightmargin'); } $table = new xmldb_table('customcert_template_pages'); if ($dbman->field_exists($table, $field)) { $dbman->rename_field($table, $field, 'rightmargin'); } // Add 'leftmargin' fields to the 'customcert_pages' and 'customcert_template_pages' tables. $table = new xmldb_table('customcert_pages'); $field = new xmldb_field('leftmargin', XMLDB_TYPE_INTEGER, 10, null, null, null, 0, 'height'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } $table = new xmldb_table('customcert_template_pages'); if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Customcert savepoint reached. upgrade_mod_savepoint(true, 2015120801, 'customcert'); } return true; }