Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions 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="blocks/navbuttons/db" VERSION="20140706" COMMENT="XMLDB file for Moodle blocks/navbuttons"
<XMLDB PATH="blocks/navbuttons/db" VERSION="20160801" COMMENT="XMLDB file for Moodle blocks/navbuttons"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
Expand All @@ -11,8 +11,9 @@
<FIELD NAME="enabled" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="course" NEXT="buttonstype"/>
<FIELD NAME="buttonstype" TYPE="char" LENGTH="6" NOTNULL="true" DEFAULT="icon" SEQUENCE="false" COMMENT="Buttons should be text or icons" PREVIOUS="enabled" NEXT="backgroundcolour"/>
<FIELD NAME="backgroundcolour" TYPE="char" LENGTH="20" NOTNULL="false" DEFAULT="#6666cc" SEQUENCE="false" PREVIOUS="buttonstype" NEXT="customusebackground"/>
<FIELD NAME="customusebackground" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="backgroundcolour" NEXT="homebuttonshow"/>
<FIELD NAME="homebuttonshow" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="customusebackground" NEXT="homebuttontype"/>
<FIELD NAME="customusebackground" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="backgroundcolour" NEXT="crosssectionmode"/>
<FIELD NAME="crosssectionmode" TYPE="char" LENGTH="4" NOTNULL="true" DEFAULT="show" SEQUENCE="false" PREVIOUS="customusebackground" NEXT="homebuttonshow"/>
<FIELD NAME="homebuttonshow" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="crosssectionmode" NEXT="homebuttontype"/>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not time to do a full review now - but why have you removed the homebuttontype field?

<FIELD NAME="homebuttontype" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="homebuttonshow" NEXT="firstbuttonshow"/>
<FIELD NAME="firstbuttonshow" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="homebuttontype" NEXT="firstbuttontype"/>
<FIELD NAME="firstbuttontype" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="2" SEQUENCE="false" PREVIOUS="firstbuttonshow" NEXT="prevbuttonshow"/>
Expand All @@ -34,4 +35,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
15 changes: 15 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,20 @@ function xmldb_block_navbuttons_upgrade($oldversion) {
upgrade_block_savepoint(true, 2014070601, 'navbuttons');
}

if ($oldversion < 2016080116) {

// Define field crosssectionmode to be added to navbuttons.
$table = new xmldb_table('navbuttons');
$field = new xmldb_field('crosssectionmode', XMLDB_TYPE_CHAR, '4', null, XMLDB_NOTNULL, null, 'show', 'enabled');

// Conditionally launch add field buttonstype.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

// Navbuttons savepoint reached.
upgrade_block_savepoint(true, 2016080116, 'navbuttons');
}

return true;
}
6 changes: 5 additions & 1 deletion definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@
define("BLOCK_NAVBUTTONS_EXTRA2ICON", 6);

define("BLOCK_NAVBUTTONS_TYPE_ICON", 'icon');
define("BLOCK_NAVBUTTONS_TYPE_TEXT", 'text');
define("BLOCK_NAVBUTTONS_TYPE_TEXT", 'text');

define("BLOCK_NAVBUTTONS_XSEC_SHOW", 'show');
define("BLOCK_NAVBUTTONS_XSEC_HIDE", 'hide');
define("BLOCK_NAVBUTTONS_XSEC_SECPAGE", 'sect');
10 changes: 10 additions & 0 deletions edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ function definition() {
$mform->addElement('selectyesno', 'customusebackground', get_string('customusebackground', 'block_navbuttons'));
$mform->disabledIf('customusebackground', 'buttonstype', 'neq', BLOCK_NAVBUTTONS_TYPE_ICON);

$crosssectionopts = array(
BLOCK_NAVBUTTONS_XSEC_SHOW => get_string('xsecshowbutton', 'block_navbuttons'),
BLOCK_NAVBUTTONS_XSEC_SECPAGE => get_string('xsecshowsectionpage', 'block_navbuttons'),
BLOCK_NAVBUTTONS_XSEC_HIDE => get_string('xsechidebutton', 'block_navbuttons'),
);
$mform->addElement('select', 'crosssectionmode', get_string('crosssectionmode', 'block_navbuttons'), $crosssectionopts);
$mform->setDefault('crosssectionmode', BLOCK_NAVBUTTONS_XSEC_SHOW);

$hometypes = array(
BLOCK_NAVBUTTONS_HOME_FRONTPAGE => get_string('frontpage', 'block_navbuttons'),
BLOCK_NAVBUTTONS_HOME_COURSE => get_string('coursepage', 'block_navbuttons')
Expand Down Expand Up @@ -156,6 +164,7 @@ function definition() {
$defaults->buttonstype = $settings->buttonstype;
$defaults->backgroundcolour = $settings->backgroundcolour;
$defaults->customusebackground = $settings->customusebackground;
$defaults->crosssectionmode = $settings->crosssectionmode;
$defaults->homebuttonshow = $settings->homebuttonshow;
$defaults->homebuttontype = $settings->homebuttontype;
$defaults->firstbuttonshow = $settings->firstbuttonshow;
Expand Down Expand Up @@ -223,6 +232,7 @@ function definition() {
$update->buttonstype = $data->buttonstype;
$update->backgroundcolour = $data->backgroundcolour;
$update->customusebackground = $data->customusebackground;
$update->crosssectionmode = $data->crosssectionmode;
$update->homebuttonshow = $data->homebuttonshow;
$update->homebuttontype = $data->homebuttontype;
$update->firstbuttonshow = $data->firstbuttonshow;
Expand Down
35 changes: 29 additions & 6 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ function draw_navbuttons() {
}

$cmid = $PAGE->cm->id;
$csnum = $PAGE->cm->sectionnum;
$xsecmode = $settings->crosssectionmode;

$modinfo = get_fast_modinfo($COURSE);
if ($CFG->version < 2011120100) {
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
} else {
$context = context_course::instance($COURSE->id);
}
$sections = $DB->get_records('course_sections', array('course' => $COURSE->id), 'section', 'section,visible,summary');
$sections = $DB->get_records('course_sections', array('course' => $COURSE->id), 'section', 'section,visible,summary,name');

/** @var object|null $next */
$next = null;
Expand Down Expand Up @@ -125,7 +127,8 @@ function draw_navbuttons() {

$thismod = (object)[
'link' => new moodle_url('/mod/'.$mod->modname.'/view.php', array('id' => $mod->id)),
'name' => strip_tags(format_string($mod->name, true))
'name' => strip_tags(format_string($mod->name, true)),
'sectionnum' => $mod->sectionnum
];

if ($flag) { // Current mod is the 'next' mod.
Expand Down Expand Up @@ -208,15 +211,35 @@ function draw_navbuttons() {
if ($settings->prevbuttonshow && $prev) {
list($icon, $bgcolour) = navbutton_get_icon($settings->buttonstype, 'prev', $context, BLOCK_NAVBUTTONS_PREVICON,
$settings->backgroundcolour, $settings->customusebackground);
$output .= make_navbutton($icon, $bgcolour, get_string('prevactivity', 'block_navbuttons').': '.$prev->name,
$prev->link, "prev");
if ($prev->sectionnum != $csnum) {
if ($xsecmode == BLOCK_NAVBUTTONS_XSEC_SECPAGE) {
$cursec = $sections[$csnum];
$cursecurl = new moodle_url('/course/view.php', array('id' => $COURSE->id, 'section' => $cursec->section));
$output .= make_navbutton($icon, $bgcolour,
get_string('sectionhome', 'block_navbuttons').': '.$cursec->name,
$cursecurl, "prev");
} // Else hide button.
} else {
$output .= make_navbutton($icon, $bgcolour, get_string('prevactivity', 'block_navbuttons').': '.$prev->name,
$prev->link, "prev");
}
}

if ($settings->nextbuttonshow && $next) {
list($icon, $bgcolour) = navbutton_get_icon($settings->buttonstype, 'next', $context, BLOCK_NAVBUTTONS_NEXTICON,
$settings->backgroundcolour, $settings->customusebackground);
$output .= make_navbutton($icon, $bgcolour, get_string('nextactivity', 'block_navbuttons').': '.$next->name,
$next->link, "next");
if ($next->sectionnum != $csnum) {
if ($xsecmode == BLOCK_NAVBUTTONS_XSEC_SECPAGE) {
$nextsec = $sections[$next->sectionnum];
$nextsecurl = new moodle_url('/course/view.php',array('id' => $COURSE->id, 'section' => $nextsec->section));
$output .= make_navbutton($icon, $bgcolour,
get_string('nextsection', 'block_navbuttons').': '.$nextsec->name,
$nextsecurl, "next");
} // Else hide button.
} else {
$output .= make_navbutton($icon, $bgcolour, get_string('nextactivity', 'block_navbuttons').': '.$next->name,
$next->link, "next");
}
}

if ($settings->lastbuttonshow) {
Expand Down
6 changes: 6 additions & 0 deletions lang/en/block_navbuttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
$string['buttonsenabled'] = 'Navigation buttons enabled for this course';
$string['coursepage'] = 'Course page';
$string['customusebackground'] = 'Use colour for custom icons';
$string['crosssectionmode'] = 'Behavior when changing section';
$string['xsecshowbutton'] = 'Go to previous / next activity';
$string['xsecshowsectionpage'] = 'Go to previous / next section home page';
$string['xsechidebutton'] = 'Hide button';
$string['displaybutton'] = 'Show this button';
$string['editsettings'] = 'Edit the Navigation Button settings';
$string['extra1'] = 'Extra button 1';
Expand All @@ -53,9 +57,11 @@
$string['navbuttons:addinstance'] = 'Add Navbuttons block to My Moodle page';
$string['navbuttons:myaddinstance'] = 'Add new Navbuttons block';
$string['nextactivity'] = 'Next activity';
$string['nextsection'] = 'Next section';
$string['nextbutton'] = 'Next button';
$string['pluginname'] = 'Navigation Buttons';
$string['prevactivity'] = 'Previous activity';
$string['sectionhome'] = 'Section home';
$string['prevbutton'] = 'Previous button';
$string['selftest_nofooter'] = 'Navbutton self-test: The line "$output = draw_navbuttons().$this->container_end_all(true);" has not been correctly added to outputrenderers.php - see README.txt for further instructions';
$string['selftest_ok'] = 'Navbuttons self-test: required core modifications have been completed successfully';
Expand Down
6 changes: 6 additions & 0 deletions lang/fr/block_navbuttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
$string['buttonsenabled'] = 'Boutons de navigation activés pour ce cours';
$string['coursepage'] = 'Accueil';
$string['customusebackground'] = 'Utiliser cette couleur pour les icônes personnalisées';
$string['crosssectionmode'] = 'Comportement lors du changement de section';
$string['xsecshowbutton'] = 'Aller à l\'activité précédente / suivante';
$string['xsecshowsectionpage'] = 'Aller à la page d\'accueil de la section précédente / suivante';
$string['xsechidebutton'] = 'Masquer le bouton';
$string['displaybutton'] = 'Afficher ce bouton';
$string['editsettings'] = 'Modifier les réglages des Boutons de Navigation';
$string['extra1'] = 'Bouton extra 1';
Expand All @@ -54,9 +58,11 @@
$string['navbuttons:addinstance'] = 'Ajouter un bloc Boutons de Navigation à la page Mon Moodle';
$string['navbuttons:myaddinstance'] = 'Ajouter un bloc Boutons de Navigation';
$string['nextactivity'] = 'Suivant';
$string['nextsection'] = 'Section suivante';
$string['nextbutton'] = 'Bouton "suivant"';
$string['pluginname'] = 'Boutons de Navigation';
$string['prevactivity'] = 'Précédent';
$string['sectionhome'] = 'Accueil de la section';
$string['prevbutton'] = 'Bouton "précédent"';
$string['selftest_nofooter'] = 'Auto-test des Boutons de Navigation: La ligne "$output = draw_navbuttons().$this->container_end_all(true);" n\'a pas été ajoutée correctement à outputrenderers.php - lire README.txt pour voir les instructions';
$string['selftest_ok'] = 'Auto-test des Boutons de Navigation: les modifications du cœur requises ont été effectuées avec succès';
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2016052000;
$plugin->version = 2016080116;
$plugin->release = '2.2+ (Build: 2016052000)';
$plugin->requires = 2011120100; // Moodle 2.2
$plugin->requires = 2011120116; // Moodle 2.2
$plugin->cron = 0;
$plugin->component = 'block_navbuttons';
$plugin->maturity = MATURITY_STABLE;