Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-33121 Book Module: removing prev/next value from book_preload_cha…

…pters and more code cleaning
  • Loading branch information...
commit 0a5b9e79e38059ecb5a280a339fd680ae99418e8 1 parent fb90975
@rwijaya rwijaya authored
View
16 mod/book/edit_form.php
@@ -29,17 +29,15 @@
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 @@ function definition() {
$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 @@ function definition() {
// 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');
+ }
+ }
}
View
5 mod/book/lib.php
@@ -29,6 +29,7 @@
* @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");
View
10 mod/book/locallib.php
@@ -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;
View
1  mod/book/tool/exportimscp/lib.php
@@ -31,7 +31,6 @@
* @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)) {
View
1  mod/book/tool/importhtml/lib.php
@@ -31,7 +31,6 @@
* @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)) {
View
4 mod/book/tool/print/lib.php
@@ -31,11 +31,9 @@
* @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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.