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
0a5b9e79
Commit
0a5b9e79
authored
Jun 18, 2012
by
Rossiani Wijaya
Browse files
MDL-33121 Book Module: removing prev/next value from book_preload_chapters and more code cleaning
parent
fb909757
Changes
6
Hide whitespace changes
Inline
Side-by-side
mod/book/edit_form.php
View file @
0a5b9e79
...
...
@@ -29,17 +29,15 @@ require_once($CFG->libdir.'/formslib.php');
class
book_chapter_edit_form
extends
moodleform
{
function
definition
()
{
global
$CFG
;
$chapter
=
$this
->
_customdata
[
'chapter'
];
$options
=
$this
->
_customdata
[
'options'
];
//Disabled subchapter option when editing first node
$disabledmsg
=
null
;
$disabledarr
=
null
;
if
(
!
$chapter
->
id
&&
$chapter
->
pagenum
==
1
||
$chapter
->
pagenum
==
1
)
{
if
(
$chapter
->
pagenum
==
1
)
{
$disabledmsg
=
get_string
(
'subchapternotice'
,
'book'
);
$disabledarr
=
array
(
'group'
=>
1
,
'disabled'
=>
'disabled'
);
}
$mform
=
$this
->
_form
;
...
...
@@ -50,7 +48,7 @@ class book_chapter_edit_form extends moodleform {
$mform
->
setType
(
'title'
,
PARAM_RAW
);
$mform
->
addRule
(
'title'
,
null
,
'required'
,
null
,
'client'
);
$mform
->
addElement
(
'advcheckbox'
,
'subchapter'
,
get_string
(
'subchapter'
,
'mod_book'
),
$disabledmsg
,
$disabledarr
);
$mform
->
addElement
(
'advcheckbox'
,
'subchapter'
,
get_string
(
'subchapter'
,
'mod_book'
),
$disabledmsg
);
$mform
->
addElement
(
'editor'
,
'content_editor'
,
get_string
(
'content'
,
'mod_book'
),
null
,
$options
);
$mform
->
setType
(
'content_editor'
,
PARAM_RAW
);
...
...
@@ -70,4 +68,12 @@ class book_chapter_edit_form extends moodleform {
// set the defaults
$this
->
set_data
(
$chapter
);
}
function
definition_after_data
(){
$mform
=
$this
->
_form
;
$pagenum
=
$mform
->
getElement
(
'pagenum'
);
if
(
$pagenum
->
getValue
()
==
1
)
{
$mform
->
hardFreeze
(
'subchapter'
);
}
}
}
mod/book/lib.php
View file @
0a5b9e79
...
...
@@ -29,6 +29,7 @@ defined('MOODLE_INTERNAL') || die;
* @return array
*/
function
book_get_numbering_types
()
{
global
$CFG
;
// required for the include
require_once
(
dirname
(
__FILE__
)
.
'/locallib.php'
);
...
...
@@ -215,6 +216,7 @@ function book_scale_used_anywhere($scaleid) {
* @return array
*/
function
book_get_view_actions
()
{
global
$CFG
;
// necessary for includes
$return
=
array
(
'view'
,
'view all'
);
...
...
@@ -239,6 +241,7 @@ function book_get_view_actions() {
* @return array
*/
function
book_get_post_actions
()
{
global
$CFG
;
// necessary for includes
$return
=
array
(
'update'
);
...
...
@@ -289,11 +292,9 @@ function book_supports($feature) {
* @return void
*/
function
book_extend_settings_navigation
(
settings_navigation
$settingsnav
,
navigation_node
$booknode
)
{
global
$USER
,
$PAGE
;
$plugins
=
get_plugin_list
(
'booktool'
);
foreach
(
$plugins
as
$plugin
=>
$dir
)
{
if
(
file_exists
(
"
$dir
/lib.php"
))
{
require_once
(
"
$dir
/lib.php"
);
...
...
mod/book/locallib.php
View file @
0a5b9e79
...
...
@@ -24,8 +24,6 @@
defined
(
'MOODLE_INTERNAL'
)
||
die
;
global
$CFG
;
require_once
(
dirname
(
__FILE__
)
.
'/lib.php'
);
require_once
(
$CFG
->
libdir
.
'/filelib.php'
);
...
...
@@ -113,19 +111,11 @@ function book_preload_chapters($book) {
}
}
// assigning previous and next page id
$ch
->
prev
=
$prev
;
$ch
->
next
=
null
;
if
(
$prev
)
{
$chapters
[
$prev
]
->
next
=
$ch
->
id
;
}
if
(
$oldch
->
subchapter
!=
$ch
->
subchapter
or
$oldch
->
pagenum
!=
$ch
->
pagenum
or
$oldch
->
hidden
!=
$ch
->
hidden
)
{
// update only if something changed
$DB
->
update_record
(
'book_chapters'
,
$ch
);
}
$chapters
[
$id
]
=
$ch
;
$prev
=
$ch
->
id
;
}
return
$chapters
;
...
...
mod/book/tool/exportimscp/lib.php
View file @
0a5b9e79
...
...
@@ -31,7 +31,6 @@ defined('MOODLE_INTERNAL') || die;
* @param navigation_node $node The node to add module settings to
*/
function
booktool_exportimscp_extend_settings_navigation
(
settings_navigation
$settings
,
navigation_node
$node
)
{
global
$PAGE
;
if
(
has_capability
(
'booktool/exportimscp:export'
,
$PAGE
->
cm
->
context
))
{
...
...
mod/book/tool/importhtml/lib.php
View file @
0a5b9e79
...
...
@@ -31,7 +31,6 @@ defined('MOODLE_INTERNAL') || die;
* @param navigation_node $node The node to add module settings to
*/
function
booktool_importhtml_extend_settings_navigation
(
settings_navigation
$settings
,
navigation_node
$node
)
{
global
$PAGE
;
if
(
has_capability
(
'booktool/importhtml:import'
,
$PAGE
->
cm
->
context
))
{
...
...
mod/book/tool/print/lib.php
View file @
0a5b9e79
...
...
@@ -31,11 +31,9 @@ defined('MOODLE_INTERNAL') || die;
* @param navigation_node $node The node to add module settings to
*/
function
booktool_print_extend_settings_navigation
(
settings_navigation
$settings
,
navigation_node
$node
)
{
global
$PAGE
;
global
$USER
,
$PAGE
,
$CFG
,
$DB
,
$OUTPUT
;
$params
=
$PAGE
->
url
->
params
();
if
(
empty
(
$params
[
'id'
])
or
empty
(
$params
[
'chapterid'
]))
{
return
;
}
...
...
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