diff --git a/mod/glossary/db/install.xml b/mod/glossary/db/install.xml index e0502e80937..757f028904e 100644 --- a/mod/glossary/db/install.xml +++ b/mod/glossary/db/install.xml @@ -1,5 +1,5 @@ - @@ -20,8 +20,9 @@ - - + + + @@ -121,4 +122,4 @@ - \ No newline at end of file + diff --git a/mod/glossary/db/upgrade.php b/mod/glossary/db/upgrade.php index 4eef079f3fd..72df2a33fef 100644 --- a/mod/glossary/db/upgrade.php +++ b/mod/glossary/db/upgrade.php @@ -29,6 +29,28 @@ function xmldb_glossary_upgrade($oldversion) { // Moodle v2.2.0 release upgrade line // Put any upgrade step following this + if ($oldversion < 2012010400) { + + // Define field approvaldisplayformat to be added to glossary + $table = new xmldb_table('glossary'); + $field = new xmldb_field('approvaldisplayformat', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, 'default', 'defaultapproval'); + + // Conditionally launch add field approvaldisplayformat + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Set the default approvaldisplayformat for existing entries to be + // the existing displayformat so as not to change existing + // functionality + $sql = "UPDATE {glossary} + SET approvaldisplayformat = 'default'"; + $DB->execute($sql); + + // glossary savepoint reached + upgrade_mod_savepoint(true, 2012010400, 'glossary'); + } + return true; } diff --git a/mod/glossary/lang/en/glossary.php b/mod/glossary/lang/en/glossary.php index 535f758dc77..1a4821e0167 100644 --- a/mod/glossary/lang/en/glossary.php +++ b/mod/glossary/lang/en/glossary.php @@ -42,6 +42,8 @@ $string['allowprintview_help'] = 'If enabled, students are provided with a link $string['andmorenewentries'] = 'and {$a} more new entries.'; $string['answer'] = 'Answer'; $string['approve'] = 'Approve'; +$string['approvaldisplayformat'] = 'Approval Display format'; +$string['approvaldisplayformat_help'] = 'When approving glossary items you may wish to use a different display format'; $string['areyousuredelete'] = 'Are you sure you want to delete this entry?'; $string['areyousuredeletecomment'] = 'Are you sure you want to delete this comment?'; $string['areyousureexport'] = 'Are you sure you want to export this entry to'; @@ -115,6 +117,7 @@ $string['displayformat_help'] = 'There are 7 display formats: * Entry list - Concepts are listed as links * FAQ - The words QUESTION and ANSWER are appended to the concept and definition respectively'; $string['displayformatcontinuous'] = 'Continuous without author'; +$string['displayformatdefault'] = 'Default to same as Display Format'; $string['displayformatdictionary'] = 'Simple, dictionary style'; $string['displayformatencyclopedia'] = 'Encyclopedia'; $string['displayformatentrylist'] = 'Entry list'; diff --git a/mod/glossary/mod_form.php b/mod/glossary/mod_form.php index f5c21bd4e6e..4db6c90e3e9 100644 --- a/mod/glossary/mod_form.php +++ b/mod/glossary/mod_form.php @@ -79,6 +79,12 @@ class mod_glossary_mod_form extends moodleform_mod { $mform->setDefault('displayformat', 'dictionary'); $mform->addHelpButton('displayformat', 'displayformat', 'glossary'); + $displayformats['default'] = get_string('displayformatdefault', 'glossary'); + $displayformats = array_merge($displayformats, $formats); + $mform->addElement('select', 'approvaldisplayformat', get_string('approvaldisplayformat', 'glossary'), $displayformats); + $mform->setDefault('approvaldisplayformat', 'default'); + $mform->addHelpButton('approvaldisplayformat', 'approvaldisplayformat', 'glossary'); + $mform->addElement('selectyesno', 'showspecial', get_string('showspecial', 'glossary')); $mform->setDefault('showspecial', 1); $mform->addHelpButton('showspecial', 'showspecial', 'glossary'); diff --git a/mod/glossary/version.php b/mod/glossary/version.php index 250d9373837..8c2241d386f 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$module->version = 2011112900; // The current module version (Date: YYYYMMDDXX) +$module->version = 2012010400; // The current module version (Date: YYYYMMDDXX) $module->requires = 2011112900; // Requires this Moodle version $module->component = 'mod_glossary'; // Full name of the plugin (used for diagnostics) $module->cron = 0; diff --git a/mod/glossary/view.php b/mod/glossary/view.php index fe16b5ec6ca..b57cec68464 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -173,6 +173,11 @@ break; case 'approval': /// Looking for entries waiting for approval $tab = GLOSSARY_APPROVAL_VIEW; + // Override the display format with the approvaldisplayformat + if ($glossary->approvaldisplayformat !== 'default' && ($df = $DB->get_record("glossary_formats", + array("name" => $glossary->approvaldisplayformat)))) { + $displayformat = $df->popupformatname; + } if ( !$hook and !$sortkey and !$sortorder) { $hook = 'ALL'; }