Skip to content
Browse files

MDL-31014 Allow for selection of a different displayformat when appro…

…ving glossary entries
  • Loading branch information...
1 parent 60e9909 commit c042fc819dcc4877dd25bd3cc0ed7f94e557cf71 @andrewnicols andrewnicols committed Jan 4, 2012
View
9 mod/glossary/db/install.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/glossary/db" VERSION="20101115" COMMENT="XMLDB file for Moodle mod/glossary"
+<XMLDB PATH="mod/glossary/db" VERSION="20120104" COMMENT="XMLDB file for Moodle mod/glossary"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@@ -20,8 +20,9 @@
<FIELD NAME="allowcomments" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="showall" NEXT="allowprintview"/>
<FIELD NAME="allowprintview" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="allowcomments" NEXT="usedynalink"/>
<FIELD NAME="usedynalink" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="allowprintview" NEXT="defaultapproval"/>
- <FIELD NAME="defaultapproval" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="usedynalink" NEXT="globalglossary"/>
- <FIELD NAME="globalglossary" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="defaultapproval" NEXT="entbypage"/>
+ <FIELD NAME="defaultapproval" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="usedynalink" NEXT="approvaldisplayformat"/>
+ <FIELD NAME="approvaldisplayformat" TYPE="char" LENGTH="50" NOTNULL="true" DEFAULT="default" SEQUENCE="false" COMMENT="Display Format when approving entries" PREVIOUS="defaultapproval" NEXT="globalglossary"/>
+ <FIELD NAME="globalglossary" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="approvaldisplayformat" NEXT="entbypage"/>
<FIELD NAME="entbypage" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="10" SEQUENCE="false" PREVIOUS="globalglossary" NEXT="editalways"/>
<FIELD NAME="editalways" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="entbypage" NEXT="rsstype"/>
<FIELD NAME="rsstype" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="editalways" NEXT="rssarticles"/>
@@ -121,4 +122,4 @@
</KEYS>
</TABLE>
</TABLES>
-</XMLDB>
+</XMLDB>
View
22 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;
}
View
3 mod/glossary/lang/en/glossary.php
@@ -42,6 +42,8 @@
$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 @@
* 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';
View
6 mod/glossary/mod_form.php
@@ -79,6 +79,12 @@ function definition() {
$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');
View
2 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;
View
5 mod/glossary/view.php
@@ -173,6 +173,11 @@
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';
}

0 comments on commit c042fc8

Please sign in to comment.
Something went wrong with that request. Please try again.