Skip to content

Commit

Permalink
MDL-31014 Allow for selection of a different displayformat when appro…
Browse files Browse the repository at this point in the history
…ving glossary entries
  • Loading branch information
Andrew Robert Nicols committed Jan 19, 2012
1 parent 60e9909 commit c042fc8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
9 changes: 5 additions & 4 deletions mod/glossary/db/install.xml
Original file line number Diff line number Diff line change
@@ -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"
>
Expand All @@ -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"/>
Expand Down Expand Up @@ -121,4 +122,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
22 changes: 22 additions & 0 deletions mod/glossary/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions mod/glossary/lang/en/glossary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
6 changes: 6 additions & 0 deletions mod/glossary/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
5 changes: 5 additions & 0 deletions mod/glossary/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down

0 comments on commit c042fc8

Please sign in to comment.