MDL-62388 tool_dataprivacy: Default value if no sensitive data provided
[moodle.git] / cache / stores / mongodb / addinstanceform.php
blobc7d310487044ac12035e26640adbfbd29feb64fa
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.
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/>.
17 /**
18 * The MongoDB plugin form for adding an instance.
20 * The following settings are provided:
21 * - server
22 * - username
23 * - password
24 * - database
25 * - replicaset
26 * - usesafe
27 * - extendedmode
29 * @package cachestore_mongodb
30 * @copyright 2012 Sam Hemelryk
31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 defined('MOODLE_INTERNAL') || die();
36 // Include the necessary evils.
37 require_once($CFG->dirroot.'/cache/forms.php');
39 /**
40 * The form to add an instance of the MongoDB store to the system.
42 * @copyright 2012 Sam Hemelryk
43 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
45 class cachestore_mongodb_addinstance_form extends cachestore_addinstance_form {
47 /**
48 * The forms custom definitions.
50 protected function configuration_definition() {
51 global $OUTPUT;
52 $form = $this->_form;
54 if (!class_exists('MongoClient')) {
55 $form->addElement('html', $OUTPUT->notification(get_string('pleaseupgrademongo', 'cachestore_mongodb')));
58 $form->addElement('text', 'server', get_string('server', 'cachestore_mongodb'), array('size' => 72));
59 $form->addHelpButton('server', 'server', 'cachestore_mongodb');
60 $form->addRule('server', get_string('required'), 'required');
61 $form->setDefault('server', 'mongodb://127.0.0.1:27017');
62 $form->setType('server', PARAM_RAW);
64 $form->addElement('text', 'database', get_string('database', 'cachestore_mongodb'));
65 $form->addHelpButton('database', 'database', 'cachestore_mongodb');
66 $form->addRule('database', get_string('required'), 'required');
67 $form->setType('database', PARAM_ALPHANUMEXT);
68 $form->setDefault('database', 'mcache');
70 $form->addElement('text', 'username', get_string('username', 'cachestore_mongodb'));
71 $form->addHelpButton('username', 'username', 'cachestore_mongodb');
72 $form->setType('username', PARAM_ALPHANUMEXT);
74 $form->addElement('text', 'password', get_string('password', 'cachestore_mongodb'));
75 $form->addHelpButton('password', 'password', 'cachestore_mongodb');
76 $form->setType('password', PARAM_TEXT);
78 $form->addElement('text', 'replicaset', get_string('replicaset', 'cachestore_mongodb'));
79 $form->addHelpButton('replicaset', 'replicaset', 'cachestore_mongodb');
80 $form->setType('replicaset', PARAM_ALPHANUMEXT);
81 $form->setAdvanced('replicaset');
83 $form->addElement('checkbox', 'usesafe', get_string('usesafe', 'cachestore_mongodb'));
84 $form->addHelpButton('usesafe', 'usesafe', 'cachestore_mongodb');
85 $form->setDefault('usesafe', 1);
86 $form->setAdvanced('usesafe');
87 $form->setType('usesafe', PARAM_BOOL);
89 $form->addElement('text', 'usesafevalue', get_string('usesafevalue', 'cachestore_mongodb'));
90 $form->addHelpButton('usesafevalue', 'usesafevalue', 'cachestore_mongodb');
91 $form->disabledIf('usesafevalue', 'usesafe', 'notchecked');
92 $form->setType('usesafevalue', PARAM_INT);
93 $form->setAdvanced('usesafevalue');
95 $form->addElement('checkbox', 'extendedmode', get_string('extendedmode', 'cachestore_mongodb'));
96 $form->addHelpButton('extendedmode', 'extendedmode', 'cachestore_mongodb');
97 $form->setDefault('extendedmode', 0);
98 $form->setAdvanced('extendedmode');
99 $form->setType('extendedmode', PARAM_BOOL);