1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of 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 |
* Form for editing tours.
|
|
|
19 |
*
|
|
|
20 |
* @package tool_usertours
|
|
|
21 |
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace tool_usertours\local\forms;
|
|
|
26 |
|
|
|
27 |
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
|
|
28 |
|
|
|
29 |
require_once($CFG->libdir . '/formslib.php');
|
|
|
30 |
|
|
|
31 |
use tool_usertours\helper;
|
|
|
32 |
use tool_usertours\tour;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Form for editing tours.
|
|
|
36 |
*
|
|
|
37 |
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
|
|
|
38 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
39 |
*/
|
|
|
40 |
class edittour extends \moodleform {
|
|
|
41 |
/**
|
|
|
42 |
* @var tool_usertours\tour $tour
|
|
|
43 |
*/
|
|
|
44 |
protected $tour;
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Create the edit tour form.
|
|
|
48 |
*
|
|
|
49 |
* @param tour $tour The tour being editted.
|
|
|
50 |
*/
|
|
|
51 |
public function __construct(\tool_usertours\tour $tour) {
|
|
|
52 |
$this->tour = $tour;
|
|
|
53 |
|
|
|
54 |
parent::__construct($tour->get_edit_link());
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
* Form definition.
|
|
|
59 |
*/
|
|
|
60 |
public function definition() {
|
|
|
61 |
$mform = $this->_form;
|
|
|
62 |
|
|
|
63 |
// ID of existing tour.
|
|
|
64 |
$mform->addElement('hidden', 'id');
|
|
|
65 |
$mform->setType('id', PARAM_INT);
|
|
|
66 |
|
|
|
67 |
// Name of the tour.
|
|
|
68 |
$mform->addElement('text', 'name', get_string('name', 'tool_usertours'));
|
|
|
69 |
$mform->addRule('name', get_string('required'), 'required', null, 'client');
|
|
|
70 |
$mform->setType('name', PARAM_TEXT);
|
|
|
71 |
$mform->addHelpButton('name', 'name', 'tool_usertours');
|
|
|
72 |
|
|
|
73 |
// Admin-only descriptions.
|
|
|
74 |
$mform->addElement('textarea', 'description', get_string('description', 'tool_usertours'));
|
|
|
75 |
$mform->setType('description', PARAM_RAW);
|
|
|
76 |
$mform->addHelpButton('description', 'description', 'tool_usertours');
|
|
|
77 |
|
|
|
78 |
// Application.
|
|
|
79 |
$mform->addElement('text', 'pathmatch', get_string('pathmatch', 'tool_usertours'));
|
|
|
80 |
$mform->setType('pathmatch', PARAM_RAW);
|
|
|
81 |
$mform->addHelpButton('pathmatch', 'pathmatch', 'tool_usertours');
|
|
|
82 |
|
|
|
83 |
$mform->addElement('checkbox', 'enabled', get_string('tourisenabled', 'tool_usertours'));
|
|
|
84 |
|
|
|
85 |
$mform->addElement('text', 'endtourlabel', get_string('endtourlabel', 'tool_usertours'));
|
|
|
86 |
$mform->setType('endtourlabel', PARAM_TEXT);
|
|
|
87 |
$mform->addHelpButton('endtourlabel', 'endtourlabel', 'tool_usertours');
|
|
|
88 |
|
|
|
89 |
$mform->addElement('checkbox', 'displaystepnumbers', get_string('displaystepnumbers', 'tool_usertours'));
|
|
|
90 |
$mform->addHelpButton('displaystepnumbers', 'displaystepnumbers', 'tool_usertours');
|
|
|
91 |
|
|
|
92 |
$mform->addElement(
|
|
|
93 |
'select',
|
|
|
94 |
'showtourwhen',
|
|
|
95 |
get_string('showtourwhen', 'tool_usertours'),
|
|
|
96 |
[
|
|
|
97 |
tour::SHOW_TOUR_UNTIL_COMPLETE => get_string('showtouruntilcomplete', 'tool_usertours'),
|
|
|
98 |
tour::SHOW_TOUR_ON_EACH_PAGE_VISIT => get_string('showtoureachtime', 'tool_usertours'),
|
|
|
99 |
]
|
|
|
100 |
);
|
|
|
101 |
$mform->setDefault('showtourwhen', tour::SHOW_TOUR_UNTIL_COMPLETE);
|
|
|
102 |
|
|
|
103 |
// Configuration.
|
|
|
104 |
$this->tour->add_config_to_form($mform);
|
|
|
105 |
|
|
|
106 |
// Filters.
|
|
|
107 |
$mform->addElement('header', 'filters', get_string('filter_header', 'tool_usertours'));
|
|
|
108 |
$mform->addElement('static', 'filterhelp', '', get_string('filter_help', 'tool_usertours'));
|
|
|
109 |
|
|
|
110 |
foreach (helper::get_all_filters() as $filterclass) {
|
|
|
111 |
$filterclass::add_filter_to_form($mform);
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
$this->add_action_buttons();
|
|
|
115 |
}
|
|
|
116 |
}
|