#123 Renamed column to avoid breaking Oracle

The word 'size' is a reserved word in Oracle.
This commit is contained in:
Mark Nelson 2017-08-05 15:45:35 +08:00
parent 5299a83209
commit 87ee9f10ce
5 changed files with 24 additions and 10 deletions

View file

@ -129,7 +129,7 @@ abstract class element {
$element->name = $data->name;
$element->data = $this->save_unique_data($data);
$element->font = (isset($data->font)) ? $data->font : null;
$element->size = (isset($data->size)) ? $data->size : null;
$element->fontsize = (isset($data->fontsize)) ? $data->fontsize : null;
$element->colour = (isset($data->colour)) ? $data->colour : null;
if ($this->showposxy) {
$element->posx = (isset($data->posx)) ? $data->posx : null;

View file

@ -61,7 +61,7 @@ class element_helper {
*/
public static function render_content($pdf, $element, $content) {
list($font, $attr) = self::get_font($element);
$pdf->setFont($font, $attr, $element->size);
$pdf->setFont($font, $attr, $element->fontsize);
$fontcolour = \TCPDF_COLORS::convertHTMLColorToDec($element->colour, $fontcolour);
$pdf->SetTextColor($fontcolour['R'], $fontcolour['G'], $fontcolour['B']);
@ -120,7 +120,7 @@ class element_helper {
$fontstyle .= '; font-style: italic';
}
$style = $fontstyle . '; color: ' . $element->colour . '; font-size: ' . $element->size . 'pt;';
$style = $fontstyle . '; color: ' . $element->colour . '; font-size: ' . $element->fontsize . 'pt;';
if ($element->width) {
$style .= ' width: ' . $element->width . 'mm';
}
@ -137,10 +137,10 @@ class element_helper {
$mform->setType('font', PARAM_TEXT);
$mform->setDefault('font', 'times');
$mform->addHelpButton('font', 'font', 'customcert');
$mform->addElement('select', 'size', get_string('fontsize', 'customcert'), \mod_customcert\certificate::get_font_sizes());
$mform->setType('size', PARAM_INT);
$mform->setDefault('size', 12);
$mform->addHelpButton('size', 'fontsize', 'customcert');
$mform->addElement('select', 'fontsize', get_string('fontsize', 'customcert'), \mod_customcert\certificate::get_font_sizes());
$mform->setType('fontsize', PARAM_INT);
$mform->setDefault('fontsize', 12);
$mform->addHelpButton('fontsize', 'fontsize', 'customcert');
}
/**

View file

@ -78,7 +78,7 @@
<FIELD NAME="element" TYPE="text" LENGTH="big" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="data" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="font" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="size" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="fontsize" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="colour" TYPE="char" LENGTH="50" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="posx" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="posy" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>

View file

@ -121,5 +121,19 @@ function xmldb_customcert_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2017050502, 'customcert');
}
if ($oldversion < 2017050506) {
$table = new xmldb_table('customcert_elements');
$field = new xmldb_field('size');
// Rename column as it is a reserved word in Oracle.
if ($dbman->field_exists($table, $field)) {
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'font');
$dbman->rename_field($table, $field, 'fontsize');
}
// Savepoint reached.
upgrade_mod_savepoint(true, 2017050506, 'customcert');
}
return true;
}

View file

@ -24,10 +24,10 @@
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
$plugin->version = 2017050505; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2017050506; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2017050500; // Requires this Moodle version (3.3).
$plugin->cron = 0; // Period for cron to check this module (secs).
$plugin->component = 'mod_customcert';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = "3.3 release (Build: 2017050505)"; // User-friendly version number.
$plugin->release = "3.3 release (Build: 2017050506)"; // User-friendly version number.