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 |
* Database module preset forms.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_data
|
|
|
21 |
* @copyright 2010 Sam Hemelryk
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
if (!defined('MOODLE_INTERNAL')) {
|
|
|
26 |
die('Direct access to this script is forbidden!');
|
|
|
27 |
}
|
|
|
28 |
require_once($CFG->libdir . '/formslib.php');
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
class data_existing_preset_form extends moodleform {
|
|
|
32 |
public function definition() {
|
|
|
33 |
$this->_form->addElement('header', 'presets', get_string('usestandard', 'data'));
|
|
|
34 |
$this->_form->addHelpButton('presets', 'usestandard', 'data');
|
|
|
35 |
|
|
|
36 |
$this->_form->addElement('hidden', 'd');
|
|
|
37 |
$this->_form->setType('d', PARAM_INT);
|
|
|
38 |
$this->_form->addElement('hidden', 'action', 'confirmdelete');
|
|
|
39 |
$this->_form->setType('action', PARAM_ALPHANUM);
|
|
|
40 |
$delete = get_string('delete');
|
|
|
41 |
foreach ($this->_customdata['presets'] as $preset) {
|
|
|
42 |
$userid = $preset instanceof \mod_data\preset ? $preset->get_userid() : $preset->userid;
|
|
|
43 |
$this->_form->addElement('radio', 'fullname', null, ' '.$preset->description, $userid.'/'.$preset->shortname);
|
|
|
44 |
}
|
|
|
45 |
$this->_form->addElement('submit', 'importexisting', get_string('choose'));
|
|
|
46 |
}
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
class data_export_form extends moodleform {
|
|
|
50 |
public function definition() {
|
|
|
51 |
$this->_form->addElement('header', 'exportheading', get_string('exportaszip', 'data'));
|
|
|
52 |
$this->_form->addElement('hidden', 'd');
|
|
|
53 |
$this->_form->setType('d', PARAM_INT);
|
|
|
54 |
$this->_form->addElement('hidden', 'action', 'export');
|
|
|
55 |
$this->_form->setType('action', PARAM_ALPHANUM);
|
|
|
56 |
$this->_form->addElement('submit', 'export', get_string('export', 'data'));
|
|
|
57 |
}
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
class data_save_preset_form extends moodleform {
|
|
|
61 |
public function definition() {
|
|
|
62 |
$this->_form->addElement('header', 'exportheading', get_string('saveaspreset', 'data'));
|
|
|
63 |
$this->_form->addElement('hidden', 'd');
|
|
|
64 |
$this->_form->setType('d', PARAM_INT);
|
|
|
65 |
$this->_form->addElement('hidden', 'action', 'save2');
|
|
|
66 |
$this->_form->setType('action', PARAM_ALPHANUM);
|
|
|
67 |
$this->_form->addElement('text', 'name', get_string('name'));
|
|
|
68 |
$this->_form->setType('name', PARAM_FILE);
|
|
|
69 |
$this->_form->addRule('name', null, 'required');
|
|
|
70 |
$this->_form->addElement('checkbox', 'overwrite', get_string('overwrite', 'data'), get_string('overrwritedesc', 'data'));
|
|
|
71 |
$this->_form->addElement('submit', 'saveaspreset', get_string('continue'));
|
|
|
72 |
}
|
|
|
73 |
}
|