Added a 'leftmargin' field

Also renamed the 'margin' field to 'rightmargin'
to easily distinguish between the two.
This commit is contained in:
Mark Nelson 2015-12-08 17:41:38 +08:00
parent 9413d65ee0
commit 355de679e8
10 changed files with 118 additions and 32 deletions

View file

@ -39,7 +39,8 @@
<FIELD NAME="customcertid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="width" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="height" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="margin" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="leftmargin" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="rightmargin" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="pagenumber" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
@ -89,7 +90,8 @@
<FIELD NAME="templateid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="width" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="height" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="margin" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="leftmargin" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="rightmargin" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="pagenumber" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>

View file

@ -100,5 +100,34 @@ function xmldb_customcert_upgrade($oldversion=0) {
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;
}