MDL-40112 badges: Drop unused image field from badge table

This commit is contained in:
Yuliya Bozhko 2013-06-14 16:09:52 +12:00
parent f8e6e5bc30
commit e50220f840
7 changed files with 15 additions and 12 deletions

View file

@ -108,7 +108,6 @@ class badge {
public $timemodified;
public $usercreated;
public $usermodified;
public $image;
public $issuername;
public $issuerurl;
public $issuercontact;
@ -241,7 +240,6 @@ class badge {
$fordb->name = get_string('copyof', 'badges', $this->name);
$fordb->status = BADGE_STATUS_INACTIVE;
$fordb->image = 0;
$fordb->usercreated = $USER->id;
$fordb->usermodified = $USER->id;
$fordb->timecreated = time();
@ -1081,10 +1079,7 @@ function badges_process_badge_image(badge $badge, $iconfile) {
require_once($CFG->libdir. '/gdlib.php');
if (!empty($CFG->gdversion)) {
if ($fileid = (int)process_new_icon($badge->get_context(), 'badges', 'badgeimage', $badge->id, $iconfile)) {
$badge->image = $fileid;
$badge->save();
}
process_new_icon($badge->get_context(), 'badges', 'badgeimage', $badge->id, $iconfile);
@unlink($iconfile);
// Clean up file draft area after badge image has been saved.

View file

@ -2868,7 +2868,6 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="image" TYPE="int" LENGTH="10" NOTNULL="true" 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"/>
<FIELD NAME="usercreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>

View file

@ -2190,5 +2190,18 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013061700.00);
}
if ($oldversion < 2013070400.01) {
// Define field attachment to be dropped from badge.
$table = new xmldb_table('badge');
$field = new xmldb_field('image');
// Conditionally launch drop field eventtype.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
upgrade_main_savepoint(true, 2013070400.01);
}
return true;
}