Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
5219cc87
Commit
5219cc87
authored
Oct 04, 2012
by
Ankit Agarwal
Browse files
MDL-33646 book: Adding a notice instead of error when there is no content in the book
parent
5d6285c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
mod/book/lang/en/book.php
View file @
5219cc87
...
...
@@ -47,6 +47,7 @@ $string['editingchapter'] = 'Editing chapter';
$string
[
'chaptertitle'
]
=
'Chapter title'
;
$string
[
'content'
]
=
'Content'
;
$string
[
'subchapter'
]
=
'Subchapter'
;
$string
[
'nocontent'
]
=
'No content has been added to this book yet.'
;
$string
[
'numbering'
]
=
'Chapter formatting'
;
$string
[
'numbering_help'
]
=
'* None - Chapter and subchapter titles have no formatting
* Numbers - Chapters and subchapter titles are numbered 1, 1.1, 1.2, 2, ...
...
...
mod/book/view.php
View file @
5219cc87
...
...
@@ -87,13 +87,16 @@ if ($chapterid == '0') { // Go to first chapter if no given.
}
}
if
(
!
$chapterid
or
!
$chapter
=
$DB
->
get_record
(
'book_chapters'
,
array
(
'id'
=>
$chapterid
,
'bookid'
=>
$book
->
id
)))
{
print_error
(
'errorchapter'
,
'mod_book'
,
new
moodle_url
(
'/course/view.php'
,
array
(
'id'
=>
$course
->
id
)));
}
$courseurl
=
new
moodle_url
(
'/course/view.php'
,
array
(
'id'
=>
$course
->
id
));
// chapter is hidden for students
if
(
$chapter
->
hidden
and
!
$viewhidden
)
{
print_error
(
'errorchapter'
,
'mod_book'
,
new
moodle_url
(
'/course/view.php'
,
array
(
'id'
=>
$course
->
id
)));
// No content in the book.
if
(
!
$chapterid
)
{
$PAGE
->
set_url
(
'/mod/book/view.php'
,
array
(
'id'
=>
$id
));
notice
(
get_string
(
'nocontent'
,
'mod_book'
),
$courseurl
->
out
(
false
));
}
// Chapter doesnt exist or it is hidden for students
if
((
!
$chapter
=
$DB
->
get_record
(
'book_chapters'
,
array
(
'id'
=>
$chapterid
,
'bookid'
=>
$book
->
id
)))
or
(
$chapter
->
hidden
and
!
$viewhidden
))
{
print_error
(
'errorchapter'
,
'mod_book'
,
$courseurl
);
}
$PAGE
->
set_url
(
'/mod/book/view.php'
,
array
(
'id'
=>
$id
,
'chapterid'
=>
$chapterid
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment