Commit 86f6bb26 authored by Petr Skoda's avatar Petr Skoda
Browse files

fix navigation links

parent ad1c11bd
......@@ -76,7 +76,7 @@ if ($allowedit and !$chapters) {
/// check chapterid and read chapter data
if ($chapterid == '0') { // go to first chapter if no given
foreach($chapters as $ch) {
if ($allowedit) {
if ($allowedit and !empty($USER->editing)) {
$chapterid = $ch->id;
break;
}
......@@ -129,22 +129,21 @@ echo $OUTPUT->header();
/// prepare chapter navigation icons
$previd = null;
$nextid = null;
$found = 0;
$last = null;
foreach ($chapters as $ch) {
if ($found) {
$nextid= $ch->id;
break;
if ($allowedit and empty($USER->editing) and $ch->hidden) {
continue;
}
if ($ch->id == $chapter->id) {
$found = 1;
if ($last == $chapter->id) {
$nextid = $ch->id;
break;
}
if (!$found) {
if ($ch->id != $chapter->id) {
$previd = $ch->id;
}
$last = $ch->id;
}
if ($ch == current($chapters)) {
$nextid = $ch->id;
}
$chnavigation = '';
if ($previd) {
$chnavigation .= '<a title="'.get_string('navprev', 'book').'" href="view.php?id='.$cm->id.'&amp;chapterid='.$previd.'"><img src="'.$OUTPUT->pix_url('nav_prev', 'mod_book').'" class="bigicon" alt="'.get_string('navprev', 'book').'"/></a>';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment