Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
 * Redis Cache Store - Add instance form
19
 *
20
 * @package   cachestore_redis
21
 * @copyright 2013 Adam Durana
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
require_once($CFG->dirroot . '/cache/forms.php');
28
 
29
/**
30
 * Form for adding instance of Redis Cache Store.
31
 *
32
 * @copyright   2013 Adam Durana
33
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 */
35
class cachestore_redis_addinstance_form extends cachestore_addinstance_form {
36
    /**
37
     * Builds the form for creating an instance.
38
     */
39
    protected function configuration_definition() {
40
        $form = $this->_form;
41
 
42
        $form->addElement('advcheckbox', 'clustermode', get_string('clustermode', 'cachestore_redis'), '',
43
            cache_helper::is_cluster_available() ? '' : 'disabled');
44
        $form->addHelpButton('clustermode', 'clustermode', 'cachestore_redis');
45
        $form->setType('clustermode', PARAM_BOOL);
46
 
47
        $form->addElement('textarea', 'server', get_string('server', 'cachestore_redis'), ['cols' => 6, 'rows' => 10]);
48
        $form->setType('server', PARAM_TEXT);
49
        $form->addHelpButton('server', 'server', 'cachestore_redis');
50
        $form->addRule('server', get_string('required'), 'required');
51
 
52
        $form->addElement('advcheckbox', 'encryption', get_string('encrypt_connection', 'cachestore_redis'));
53
        $form->setType('encryption', PARAM_BOOL);
54
        $form->addHelpButton('encryption', 'encrypt_connection', 'cachestore_redis');
55
 
56
        $form->addElement('text', 'cafile', get_string('ca_file', 'cachestore_redis'));
57
        $form->setType('cafile', PARAM_TEXT);
58
        $form->addHelpButton('cafile', 'ca_file', 'cachestore_redis');
59
 
60
        $form->addElement('passwordunmask', 'password', get_string('password', 'cachestore_redis'));
61
        $form->setType('password', PARAM_RAW);
62
        $form->addHelpButton('password', 'password', 'cachestore_redis');
63
 
64
        $form->addElement('text', 'prefix', get_string('prefix', 'cachestore_redis'), array('size' => 16));
65
        $form->setType('prefix', PARAM_TEXT); // We set to text but we have a rule to limit to alphanumext.
66
        $form->addHelpButton('prefix', 'prefix', 'cachestore_redis');
67
        $form->addRule('prefix', get_string('prefixinvalid', 'cachestore_redis'), 'regex', '#^[a-zA-Z0-9\-_]+$#');
68
 
69
        $serializeroptions = cachestore_redis::config_get_serializer_options();
70
        $form->addElement('select', 'serializer', get_string('useserializer', 'cachestore_redis'), $serializeroptions);
71
        $form->addHelpButton('serializer', 'useserializer', 'cachestore_redis');
72
        $form->setDefault('serializer', Redis::SERIALIZER_PHP);
73
        $form->setType('serializer', PARAM_INT);
74
 
75
        $compressoroptions = cachestore_redis::config_get_compressor_options();
76
        $form->addElement('select', 'compressor', get_string('usecompressor', 'cachestore_redis'), $compressoroptions);
77
        $form->addHelpButton('compressor', 'usecompressor', 'cachestore_redis');
78
        $form->setDefault('compressor', cachestore_redis::COMPRESSOR_NONE);
79
        $form->setType('compressor', PARAM_INT);
80
    }
81
}