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;
$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);
// 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');
+ }
+ }
}
* @return array
*/
function book_get_numbering_types() {
+ global $CFG; // required for the include
require_once(dirname(__FILE__).'/locallib.php');
* @return array
*/
function book_get_view_actions() {
+ global $CFG; // necessary for includes
$return = array('view', 'view all');
* @return array
*/
function book_get_post_actions() {
+ global $CFG; // necessary for includes
$return = array('update');
* @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");
defined('MOODLE_INTERNAL') || die;
-global $CFG;
-
require_once(dirname(__FILE__).'/lib.php');
require_once($CFG->libdir.'/filelib.php');
}
}
- // 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;
* @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)) {
* @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)) {
* @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;
}