disable import for now
[moodle.git] / edit_form.php
... / ...
CommitLineData
1<?php
2// This file is part of Book module for Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Chapter edit form
19 *
20 * @package mod
21 * @subpackage book
22 * @copyright 2004-2010 Petr Skoda {@link http://skodak.org}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26defined('MOODLE_INTERNAL') || die;
27
28require_once($CFG->libdir.'/formslib.php');
29
30class book_chapter_edit_form extends moodleform {
31
32 function definition() {
33 global $CFG;
34 $mform = $this->_form;
35 $cm = $this->_customdata;
36
37 $mform->addElement('header', 'general', get_string('edit'));
38
39 $mform->addElement('text', 'title', get_string('chaptertitle', 'book'), array('size'=>'30'));
40 $mform->setType('title', PARAM_RAW);
41 $mform->addRule('title', null, 'required', null, 'client');
42
43 $mform->addElement('advcheckbox', 'subchapter', get_string('subchapter', 'book'));
44
45 $mform->addElement('htmleditor', 'content', get_string('content', 'book'), array('cols'=>50, 'rows'=>30));
46 $mform->setType('content', PARAM_RAW);
47
48 $mform->addElement('hidden', 'id');
49 $mform->setType('id', PARAM_INT);
50
51 $mform->addElement('hidden', 'cmid');
52 $mform->setType('cmid', PARAM_INT);
53
54 $mform->addElement('hidden', 'pagenum');
55 $mform->setType('pagenum', PARAM_INT);
56
57 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
58 if (false and has_capability('mod/book:import', $context)) { //TODO: after files
59 $mform->addElement('static', 'doimport', get_string('importingchapters', 'book').':', '<a href="import.php?id='.$cm->id.'">'.get_string('doimport', 'book').'</a>');
60 }
61
62 $this->add_action_buttons(true);
63 }
64
65 function definition_after_data() {
66 global $CFG;
67 $mform = $this->_form;
68
69 if ($mform->getElementValue('id')) {
70 if ($mform->elementExists('doimport')) {
71 $mform->removeElement('doimport');
72 }
73 }
74 }
75}