From e441b7051b16020ca9e2f98718e37514548105a6 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Sun, 6 Dec 2015 20:54:18 +0800 Subject: [PATCH] Removed the 'align' property --- backup/moodle2/backup_customcert_stepslib.php | 4 ++-- db/install.xml | 2 -- db/upgrade.php | 17 +++++++++++++++++ element/element.class.php | 15 +-------------- lang/en/customcert.php | 6 ------ version.php | 2 +- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/backup/moodle2/backup_customcert_stepslib.php b/backup/moodle2/backup_customcert_stepslib.php index 6705284..772c323 100644 --- a/backup/moodle2/backup_customcert_stepslib.php +++ b/backup/moodle2/backup_customcert_stepslib.php @@ -55,8 +55,8 @@ class backup_customcert_activity_structure_step extends backup_activity_structur // The elements. $element = new backup_nested_element('element', array('id'), array( 'pageid', 'name', 'element', 'data', 'font', 'size', - 'colour', 'width', 'refpoint', 'align', 'posx', - 'posy', 'sequence', 'timecreated', 'timemodified')); + 'colour', 'width', 'refpoint', 'posx', 'posy', 'sequence', + 'timecreated', 'timemodified')); // Build the tree. $customcert->add_child($issues); diff --git a/db/install.xml b/db/install.xml index 700032f..265472e 100644 --- a/db/install.xml +++ b/db/install.xml @@ -63,7 +63,6 @@ - @@ -114,7 +113,6 @@ - diff --git a/db/upgrade.php b/db/upgrade.php index 8cc8b5c..5d18b3a 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -83,5 +83,22 @@ function xmldb_customcert_upgrade($oldversion=0) { 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'); + } + return true; } diff --git a/element/element.class.php b/element/element.class.php index d39dd63..8435e8f 100644 --- a/element/element.class.php +++ b/element/element.class.php @@ -115,7 +115,6 @@ abstract class customcert_element_base { $element->posy = (isset($data->posy)) ? $data->posy : null; $element->width = (isset($data->width)) ? $data->width : null; $element->refpoint = (isset($data->refpoint)) ? $data->refpoint : null; - $element->align = (isset($data->align)) ? $data->align : null; $element->timemodified = time(); // Check if we are updating, or inserting a new element. @@ -191,7 +190,6 @@ abstract class customcert_element_base { $x = $this->element->posx; $y = $this->element->posy; $w = $this->element->width; - $align = $this->element->align; $refpoint = $this->element->refpoint; $actualwidth = $pdf->GetStringWidth($content); @@ -224,7 +222,7 @@ abstract class customcert_element_base { $w += 0.0001; } $pdf->setCellPaddings(0, 0, 0, 0); - $pdf->writeHTMLCell($w, 0, $x, $y, $content, 0, 0, false, true, $align); + $pdf->writeHTMLCell($w, 0, $x, $y, $content, 0, 0, false, true); } /** @@ -351,17 +349,6 @@ abstract class customcert_element_base { $mform->setType('refpoint', PARAM_INT); $mform->setDefault('refpoint', ''); $mform->addHelpButton('refpoint', 'refpoint', 'customcert'); - - $alignoptions = array(); - $alignoptions[''] = get_string('alignnone', 'customcert'); - $alignoptions['L'] = get_string('alignleft', 'customcert'); - $alignoptions['C'] = get_string('aligncenter', 'customcert'); - $alignoptions['R'] = get_string('alignright', 'customcert'); - - $mform->addElement('select', 'align', get_string('align', 'customcert'), $alignoptions); - $mform->setType('align', PARAM_ALPHA); - $mform->setDefault('align', ''); - $mform->addHelpButton('align', 'align', 'customcert'); } /** diff --git a/lang/en/customcert.php b/lang/en/customcert.php index 0469ab5..2bb1fa7 100644 --- a/lang/en/customcert.php +++ b/lang/en/customcert.php @@ -24,12 +24,6 @@ $string['addcertpage'] = 'Add another certificate page'; $string['addelement'] = 'Add element'; -$string['align'] = 'Alignment'; -$string['align_help'] = 'Alignment Help'; -$string['aligncenter'] = 'Center'; -$string['alignleft'] = 'Left align'; -$string['alignnone'] = 'No alignment'; -$string['alignright'] = 'Right align'; $string['applypositions'] = 'Save positions & continue'; $string['awardedto'] = 'Awarded to'; $string['code'] = 'Code'; diff --git a/version.php b/version.php index 2b59746..17e8634 100644 --- a/version.php +++ b/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); -$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2015120800; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2015051100; // Requires this Moodle version (2.9). $plugin->cron = 0; // Period for cron to check this module (secs). $plugin->component = 'mod_customcert';