PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/cache/stores/mongodb/addinstanceform.php

https://bitbucket.org/synergylearning/campusconnect
PHP | 96 lines | 43 code | 13 blank | 40 comment | 1 complexity | 5396fec54b8eacd8e69ad54be7d7a8c4 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, LGPL-2.1, Apache-2.0, BSD-3-Clause, AGPL-3.0
  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. * The MongoDB plugin form for adding an instance.
  18. *
  19. * The following settings are provided:
  20. * - server
  21. * - username
  22. * - password
  23. * - database
  24. * - replicaset
  25. * - usesafe
  26. * - extendedmode
  27. *
  28. * @package cachestore_mongodb
  29. * @copyright 2012 Sam Hemelryk
  30. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  31. */
  32. defined('MOODLE_INTERNAL') || die();
  33. // Include the necessary evils.
  34. require_once($CFG->dirroot.'/cache/forms.php');
  35. /**
  36. * The form to add an instance of the MongoDB store to the system.
  37. *
  38. * @copyright 2012 Sam Hemelryk
  39. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  40. */
  41. class cachestore_mongodb_addinstance_form extends cachestore_addinstance_form {
  42. /**
  43. * The forms custom definitions.
  44. */
  45. protected function configuration_definition() {
  46. $form = $this->_form;
  47. $form->addElement('text', 'server', get_string('server', 'cachestore_mongodb'), array('size' => 72));
  48. $form->addHelpButton('server', 'server', 'cachestore_mongodb');
  49. $form->addRule('server', get_string('required'), 'required');
  50. $form->setDefault('server', 'mongodb://127.0.0.1:27017');
  51. $form->setType('server', PARAM_RAW);
  52. $form->addElement('text', 'database', get_string('database', 'cachestore_mongodb'));
  53. $form->addHelpButton('database', 'database', 'cachestore_mongodb');
  54. $form->addRule('database', get_string('required'), 'required');
  55. $form->setType('database', PARAM_ALPHANUMEXT);
  56. $form->setDefault('database', 'mcache');
  57. $form->addElement('text', 'username', get_string('username', 'cachestore_mongodb'));
  58. $form->addHelpButton('username', 'username', 'cachestore_mongodb');
  59. $form->setType('username', PARAM_ALPHANUMEXT);
  60. $form->addElement('text', 'password', get_string('password', 'cachestore_mongodb'));
  61. $form->addHelpButton('password', 'password', 'cachestore_mongodb');
  62. $form->setType('password', PARAM_TEXT);
  63. $form->addElement('text', 'replicaset', get_string('replicaset', 'cachestore_mongodb'));
  64. $form->addHelpButton('replicaset', 'replicaset', 'cachestore_mongodb');
  65. $form->setType('replicaset', PARAM_ALPHANUMEXT);
  66. $form->setAdvanced('replicaset');
  67. $form->addElement('checkbox', 'usesafe', get_string('usesafe', 'cachestore_mongodb'));
  68. $form->addHelpButton('usesafe', 'usesafe', 'cachestore_mongodb');
  69. $form->setDefault('usesafe', 1);
  70. $form->setAdvanced('usesafe');
  71. $form->setType('usesafe', PARAM_BOOL);
  72. $form->addElement('text', 'usesafevalue', get_string('usesafevalue', 'cachestore_mongodb'));
  73. $form->addHelpButton('usesafevalue', 'usesafevalue', 'cachestore_mongodb');
  74. $form->disabledIf('usesafevalue', 'usesafe', 'notchecked');
  75. $form->setType('usesafevalue', PARAM_INT);
  76. $form->setAdvanced('usesafevalue');
  77. $form->addElement('checkbox', 'extendedmode', get_string('extendedmode', 'cachestore_mongodb'));
  78. $form->addHelpButton('extendedmode', 'extendedmode', 'cachestore_mongodb');
  79. $form->setDefault('extendedmode', 0);
  80. $form->setAdvanced('extendedmode');
  81. $form->setType('extendedmode', PARAM_BOOL);
  82. }
  83. }