diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index 78e056efc68..437383a54f3 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -71,5 +71,23 @@ function xmldb_data_upgrade($oldversion) { // Automatically generated Moodle v3.6.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2018120301) { + + $columns = $DB->get_columns('data'); + + $oldclass = "mod-data-default-template ##approvalstatus##"; + $newclass = "mod-data-default-template ##approvalstatusclass##"; + + // Update existing classes. + $DB->replace_all_text('data', $columns['singletemplate'], $oldclass, $newclass); + $DB->replace_all_text('data', $columns['listtemplate'], $oldclass, $newclass); + $DB->replace_all_text('data', $columns['addtemplate'], $oldclass, $newclass); + $DB->replace_all_text('data', $columns['rsstemplate'], $oldclass, $newclass); + $DB->replace_all_text('data', $columns['asearchtemplate'], $oldclass, $newclass); + + // Data savepoint reached. + upgrade_mod_savepoint(true, 2018120301, 'data'); + } + return true; } diff --git a/mod/data/lib.php b/mod/data/lib.php index eace6e75fb8..8298d91283c 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -608,7 +608,7 @@ function data_generate_default_template(&$data, $template, $recordid=0, $form=fa if ($fields = $DB->get_records('data_fields', array('dataid'=>$data->id), 'id')) { $table = new html_table(); - $table->attributes['class'] = 'mod-data-default-template ##approvalstatus##'; + $table->attributes['class'] = 'mod-data-default-template ##approvalstatusclass##'; $table->colclasses = array('template-field', 'template-token'); $table->data = array(); foreach ($fields as $field) { @@ -1507,12 +1507,16 @@ function data_print_template($template, $records, $data, $search='', $page=0, $r } $patterns[] = '##approvalstatus##'; + $patterns[] = '##approvalstatusclass##'; if (!$data->approval) { $replacement[] = ''; + $replacement[] = ''; } else if ($record->approved) { $replacement[] = get_string('approved', 'data'); + $replacement[] = 'approved'; } else { $replacement[] = get_string('notapproved', 'data'); + $replacement[] = 'notapproved'; } $patterns[]='##comments##'; diff --git a/mod/data/version.php b/mod/data/version.php index bbf1a7aaefb..fcf968eaaee 100644 --- a/mod/data/version.php +++ b/mod/data/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2018120300; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2018120301; // The current module version (Date: YYYYMMDDXX) $plugin->requires = 2018112800; // Requires this Moodle version $plugin->component = 'mod_data'; // Full name of the plugin (used for diagnostics) $plugin->cron = 0;