Proyectos de Subversion Moodle

Rev

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