jfederico /
moodle-mod_bigbluebuttonbn
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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 | * The mod_bigbluebuttonbn settings/renderer. |
||
| 19 | * |
||
| 20 | * @package mod_bigbluebuttonbn |
||
| 21 | * @copyright 2010 onwards, Blindside Networks Inc |
||
| 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||
| 23 | * @author Jesus Federico (jesus [at] blindsidenetworks [dt] com) |
||
| 24 | */ |
||
| 25 | |||
| 26 | namespace mod_bigbluebuttonbn\settings; |
||
| 27 | |||
| 28 | defined('MOODLE_INTERNAL') || die(); |
||
| 29 | |||
| 30 | require_once($CFG->dirroot . '/mod/bigbluebuttonbn/locallib.php'); |
||
| 31 | require_once($CFG->libdir.'/adminlib.php'); |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Helper class for rendering HTML for settings.php. |
||
| 35 | * |
||
| 36 | * @copyright 2010 onwards, Blindside Networks Inc |
||
| 37 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||
| 38 | */ |
||
| 39 | class renderer { |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var $settings stores the settings as they come from settings.php |
||
| 43 | */ |
||
| 44 | private $settings; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Constructor. |
||
| 48 | * |
||
| 49 | * @param object $settings |
||
| 50 | */ |
||
| 51 | public function __construct(&$settings) { |
||
| 52 | $this->settings = $settings; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Render the header for a group. |
||
| 57 | * |
||
| 58 | * @param string $name |
||
| 59 | * @param string $itemname |
||
| 60 | * @param string $itemdescription |
||
| 61 | * |
||
| 62 | * @return void |
||
| 63 | */ |
||
| 64 | public function render_group_header($name, $itemname = null, $itemdescription = null) { |
||
| 65 | if ($itemname === null) { |
||
| 66 | $itemname = get_string('config_' . $name, 'bigbluebuttonbn'); |
||
| 67 | } |
||
| 68 | if ($itemdescription === null) { |
||
| 69 | $itemdescription = get_string('config_' .$name . '_description', 'bigbluebuttonbn'); |
||
| 70 | } |
||
| 71 | $item = new \admin_setting_heading('bigbluebuttonbn_config_' . $name, $itemname, $itemdescription); |
||
| 72 | $this->settings->add($item); |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Render an element in a group. |
||
| 77 | * |
||
| 78 | * @param string $name |
||
| 79 | * @param object $item |
||
| 80 | * |
||
| 81 | * @return void |
||
| 82 | */ |
||
| 83 | public function render_group_element($name, $item) { |
||
| 84 | global $CFG; |
||
| 85 | if (!isset($CFG->bigbluebuttonbn[$name])) { |
||
| 86 | $this->settings->add($item); |
||
| 87 | } |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Render a text element in a group. |
||
| 92 | * |
||
| 93 | * @param string $name |
||
| 94 | * @param object $default |
||
| 95 | * @param string $type |
||
| 96 | * |
||
| 97 | * @return Object |
||
| 98 | */ |
||
| 99 | View Code Duplication | public function render_group_element_text($name, $default = null, $type = PARAM_RAW) { |
|
|
0 ignored issues
–
show
|
|||
| 100 | $item = new \admin_setting_configtext('bigbluebuttonbn_' . $name, |
||
| 101 | get_string('config_' . $name, 'bigbluebuttonbn'), |
||
| 102 | get_string('config_' . $name . '_description', 'bigbluebuttonbn'), |
||
| 103 | $default, $type); |
||
| 104 | return $item; |
||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Render a checkbox element in a group. |
||
| 109 | * |
||
| 110 | * @param string $name |
||
| 111 | * @param object $default |
||
| 112 | * |
||
| 113 | * @return Object |
||
| 114 | */ |
||
| 115 | View Code Duplication | public function render_group_element_checkbox($name, $default = null) { |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 116 | $item = new \admin_setting_configcheckbox('bigbluebuttonbn_' . $name, |
||
| 117 | get_string('config_' . $name, 'bigbluebuttonbn'), |
||
| 118 | get_string('config_' . $name . '_description', 'bigbluebuttonbn'), |
||
| 119 | $default); |
||
| 120 | return $item; |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Render a multiselect element in a group. |
||
| 125 | * |
||
| 126 | * @param string $name |
||
| 127 | * @param object $defaultsetting |
||
| 128 | * @param object $choices |
||
| 129 | * |
||
| 130 | * @return Object |
||
| 131 | */ |
||
| 132 | View Code Duplication | public function render_group_element_configmultiselect($name, $defaultsetting, $choices) { |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 133 | $item = new \admin_setting_configmultiselect('bigbluebuttonbn_' . $name, |
||
| 134 | get_string('config_' . $name, 'bigbluebuttonbn'), |
||
| 135 | get_string('config_' . $name . '_description', 'bigbluebuttonbn'), |
||
| 136 | $defaultsetting, $choices); |
||
| 137 | return $item; |
||
| 138 | } |
||
| 139 | |||
| 140 | /** |
||
| 141 | * Render a select element in a group. |
||
| 142 | * |
||
| 143 | * @param string $name |
||
| 144 | * @param object $defaultsetting |
||
| 145 | * @param object $choices |
||
| 146 | * |
||
| 147 | * @return Object |
||
| 148 | */ |
||
| 149 | View Code Duplication | public function render_group_element_configselect($name, $defaultsetting, $choices) { |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 150 | $item = new \admin_setting_configselect('bigbluebuttonbn_' . $name, |
||
| 151 | get_string('config_' . $name, 'bigbluebuttonbn'), |
||
| 152 | get_string('config_' . $name . '_description', 'bigbluebuttonbn'), |
||
| 153 | $defaultsetting, $choices); |
||
| 154 | return $item; |
||
| 155 | } |
||
| 156 | |||
| 157 | /** |
||
| 158 | * Render a general warning message. |
||
| 159 | * |
||
| 160 | * @param string $name |
||
| 161 | * @param string $message |
||
| 162 | * @param string $type |
||
| 163 | * @param boolean $closable |
||
| 164 | * |
||
| 165 | * @return Object |
||
| 166 | */ |
||
| 167 | public function render_warning_message($name, $message, $type = 'warning', $closable = true) { |
||
| 168 | $output = $this->output->box_start('box boxalignleft adminerror alert alert-' . $type . ' alert-block fade in', |
||
|
0 ignored issues
–
show
The property
output does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
| 169 | 'bigbluebuttonbn_' . $name)."\n"; |
||
| 170 | if ($closable) { |
||
| 171 | $output .= ' <button type="button" class="close" data-dismiss="alert">×</button>' . "\n"; |
||
| 172 | } |
||
| 173 | $output .= ' ' . $message . "\n"; |
||
| 174 | $output .= $this->output->box_end() . "\n"; |
||
| 175 | $item = new \admin_setting_heading('bigbluebuttonbn_' . $name, '', $output); |
||
| 176 | $this->settings->add($item); |
||
| 177 | return $item; |
||
| 178 | } |
||
| 179 | |||
| 180 | /** |
||
| 181 | * Render a general manage file for use as default presentation. |
||
| 182 | * |
||
| 183 | * @param string $name |
||
| 184 | * |
||
| 185 | * @return Object |
||
| 186 | */ |
||
| 187 | public function render_filemanager_default_file_presentation($name) { |
||
| 188 | |||
| 189 | $filemanageroptions = array(); |
||
| 190 | $filemanageroptions['accepted_types'] = '*'; |
||
| 191 | $filemanageroptions['maxbytes'] = 0; |
||
| 192 | $filemanageroptions['subdirs'] = 0; |
||
| 193 | $filemanageroptions['maxfiles'] = 1; |
||
| 194 | $filemanageroptions['mainfile'] = true; |
||
| 195 | |||
| 196 | $filemanager = new \admin_setting_configstoredfile('mod_bigbluebuttonbn/presentationdefault', |
||
| 197 | get_string('config_' . $name, 'bigbluebuttonbn'), |
||
| 198 | get_string('config_' . $name . '_description', 'bigbluebuttonbn'), |
||
| 199 | 'presentationdefault', |
||
| 200 | 0, |
||
| 201 | $filemanageroptions); |
||
| 202 | |||
| 203 | $this->settings->add($filemanager); |
||
| 204 | return $filemanager; |
||
| 205 | } |
||
| 206 | } |
||
| 207 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.