Completed
Push — master ( 12ecea...43b232 )
by Jesus
03:32
created

mod_bigbluebuttonbn_mod_form   B

Complexity

Total Complexity 36

Size/Duplication

Total Lines 306
Duplicated Lines 9.48 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 19
Bugs 2 Features 2
Metric Value
c 19
b 2
f 2
dl 29
loc 306
rs 8.8
wmc 36
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
F definition() 29 271 25
A data_preprocessing() 0 13 3
B validation() 0 17 8

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Config all BigBlueButtonBN instances in this course.
4
 * 
5
 * @package   mod_bigbluebuttonbn
6
 * @author    Fred Dixon  (ffdixon [at] blindsidenetworks [dt] com)
7
 * @author    Jesus Federico  (jesus [at] blindsidenetworks [dt] com)
8
 * @copyright 2010-2015 Blindside Networks Inc.
9
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later
10
 */
11
12
defined('MOODLE_INTERNAL') || die();
13
14
require_once(dirname(__FILE__).'/locallib.php');
15
require_once($CFG->dirroot.'/course/moodleform_mod.php');
16
17
class mod_bigbluebuttonbn_mod_form extends moodleform_mod {
18
19
    function definition() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
20
        global $CFG, $DB, $USER, $BIGBLUEBUTTONBN_CFG;
21
22
        $course_id = optional_param('course', 0, PARAM_INT); // course ID, or
23
        $course_module_id = optional_param('update', 0, PARAM_INT); // course_module ID, or
24
        if ($course_id) {
25
            $course = $DB->get_record('course', array('id' => $course_id), '*', MUST_EXIST);
26
            $bigbluebuttonbn = null;
27
        } else if ($course_module_id) {
28
            $cm = get_coursemodule_from_id('bigbluebuttonbn', $course_module_id, 0, false, MUST_EXIST);
29
            $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
30
            $bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $cm->instance), '*', MUST_EXIST);
31
        }
32
33
        $context = bigbluebuttonbn_get_context_course($course->id);
0 ignored issues
show
Bug introduced by
The variable $course does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
34
35
        //BigBlueButton server data
36
        $endpoint = bigbluebuttonbn_get_cfg_server_url();
37
38
        //UI configuration options
39
        $voicebridge_editable = bigbluebuttonbn_get_cfg_voicebridge_editable();
40
        $recording_default = bigbluebuttonbn_get_cfg_recording_default();
41
        $recording_editable = bigbluebuttonbn_get_cfg_recording_editable();
42
        $recording_tagging_default = bigbluebuttonbn_get_cfg_recording_tagging_default();
43
        $recording_tagging_editable = bigbluebuttonbn_get_cfg_recording_tagging_editable();
44
        $waitformoderator_default = bigbluebuttonbn_get_cfg_waitformoderator_default();
45
        $waitformoderator_editable = bigbluebuttonbn_get_cfg_waitformoderator_editable();
46
        $userlimit_default = bigbluebuttonbn_get_cfg_userlimit_default();
47
        $userlimit_editable = bigbluebuttonbn_get_cfg_userlimit_editable();
48
        $preuploadpresentation_enabled = bigbluebuttonbn_get_cfg_preuploadpresentation_enabled();
49
        $sendnotifications_enabled = bigbluebuttonbn_get_cfg_sendnotifications_enabled(); 
50
51
        //Validates if the BigBlueButton server is running 
52
        $serverVersion = bigbluebuttonbn_getServerVersion($endpoint);
53
        if ( !isset($serverVersion) ) {
54
            print_error( 'general_error_unable_connect', 'bigbluebuttonbn', $CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn' );
55
        }
56
57
        $mform =& $this->_form;
58
        $current_activity =& $this->current;
59
60
        //-------------------------------------------------------------------------------
61
        // First block starts here
62
        //-------------------------------------------------------------------------------
63
        $mform->addElement('header', 'general', get_string('mod_form_block_general', 'bigbluebuttonbn'));
64
65
        $mform->addElement('text', 'name', get_string('mod_form_field_name','bigbluebuttonbn'), 'maxlength="64" size="32"');
66
        $mform->setType('name', PARAM_TEXT);
67
        $mform->addRule('name', null, 'required', null, 'client');
68
69
        $version_major = bigbluebuttonbn_get_moodle_version_major();
70
        if ( $version_major < '2015051100' ) {
71
            //This is valid before v2.9
72
            $this->add_intro_editor(false, get_string('mod_form_field_intro', 'bigbluebuttonbn'));
73
        } else {
74
            //This is valid after v2.9
75
            $this->standard_intro_elements(get_string('mod_form_field_intro', 'bigbluebuttonbn'));
76
        }
77
        $mform->setAdvanced('introeditor');
78
        $mform->setAdvanced('showdescription');
79
80
        $mform->addElement('textarea', 'welcome', get_string('mod_form_field_welcome','bigbluebuttonbn'), 'wrap="virtual" rows="5" cols="60"');
81
        $mform->addHelpButton('welcome', 'mod_form_field_welcome', 'bigbluebuttonbn');
82
        $mform->setType('welcome', PARAM_TEXT);
83
        $mform->setAdvanced('welcome');
84
85
        if ( $voicebridge_editable ) {
86
            $mform->addElement('text', 'voicebridge', get_string('mod_form_field_voicebridge','bigbluebuttonbn'), array('maxlength'=>4, 'size'=>6));
87
            $mform->addRule('voicebridge', get_string('mod_form_field_voicebridge_format_error', 'bigbluebuttonbn'), 'numeric', '####', 'server');
88
            $mform->setDefault( 'voicebridge', 0 );
89
            $mform->addHelpButton('voicebridge', 'mod_form_field_voicebridge', 'bigbluebuttonbn');
90
            $mform->setAdvanced('voicebridge');
91
        }
92
        $mform->setType('voicebridge', PARAM_INT);
93
94 View Code Duplication
        if ( $waitformoderator_editable ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
95
            $mform->addElement('checkbox', 'wait', get_string('mod_form_field_wait', 'bigbluebuttonbn'));
96
            $mform->addHelpButton('wait', 'mod_form_field_wait', 'bigbluebuttonbn');
97
            $mform->setDefault( 'wait', $waitformoderator_default );
98
            $mform->setAdvanced('wait');
99
        } else {
100
            $mform->addElement('hidden', 'wait', $waitformoderator_default );
101
        }
102
        $mform->setType('wait', PARAM_INT);
103
104 View Code Duplication
        if ( $userlimit_editable ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
105
            $mform->addElement('text', 'userlimit', get_string('mod_form_field_userlimit','bigbluebuttonbn'), 'maxlength="3" size="5"' );
106
            $mform->addHelpButton('userlimit', 'mod_form_field_userlimit', 'bigbluebuttonbn');
107
            $mform->setDefault( 'userlimit', $userlimit_default );
108
        } else {
109
            $mform->addElement('hidden', 'userlimit', $userlimit_default );
110
        }
111
        $mform->setType('userlimit', PARAM_TEXT);
112
113
        if ( floatval($serverVersion) >= 0.8 ) {
114 View Code Duplication
            if ( $recording_editable ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
115
                $mform->addElement('checkbox', 'record', get_string('mod_form_field_record', 'bigbluebuttonbn'));
116
                $mform->setDefault( 'record', $recording_default );
117
                $mform->setAdvanced('record');
118
            } else {
119
                $mform->addElement('hidden', 'record', $recording_default);
120
            }
121
            $mform->setType('record', PARAM_INT);
122
123 View Code Duplication
            if ( $recording_tagging_editable ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
124
                $mform->addElement('checkbox', 'tagging', get_string('mod_form_field_recordingtagging', 'bigbluebuttonbn'));
125
                $mform->setDefault('tagging', $recording_tagging_default);
126
                $mform->setAdvanced('tagging');
127
            } else {
128
                $mform->addElement('hidden', 'tagging', $recording_tagging_default );
129
            }
130
            $mform->setType('tagging', PARAM_INT);
131
        }
132
133
        if ( $sendnotifications_enabled ) {
134
            $mform->addElement('checkbox', 'notification', get_string('mod_form_field_notification', 'bigbluebuttonbn'));
135
            if ($this->current->instance) {
136
                $mform->addHelpButton('notification', 'mod_form_field_notification', 'bigbluebuttonbn');
137
            } else {
138
                $mform->addHelpButton('notification', 'mod_form_field_notification', 'bigbluebuttonbn');
139
            }
140
            $mform->setDefault('notification', 0);
141
        }
142
        $mform->setType('notification', PARAM_INT);
143
        //-------------------------------------------------------------------------------
144
        // First block ends here
145
        //-------------------------------------------------------------------------------
146
147
148
        //-------------------------------------------------------------------------------
149
        // Second block starts here
150
        //-------------------------------------------------------------------------------
151
        if ( $preuploadpresentation_enabled ) {
152
            $mform->addElement('header', 'preupload', get_string('mod_form_block_presentation', 'bigbluebuttonbn'));
153
            $mform->setExpanded('preupload');
154
155
            $filemanager_options = array();
156
            $filemanager_options['accepted_types'] = '*';
157
            $filemanager_options['maxbytes'] = 0; //$this->course->maxbytes;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
158
            $filemanager_options['subdirs'] = 0;
159
            $filemanager_options['maxfiles'] = 1;
160
            $filemanager_options['mainfile'] = true;
161
162
            $mform->addElement('filemanager', 'presentation', get_string('selectfiles'), null, $filemanager_options);
163
            //$mform->addHelpButton('presentation', 'mod_form_field_presentation', 'bigbluebuttonbn');
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
164
        }
165
        //-------------------------------------------------------------------------------
166
        // Second block ends here
167
        //-------------------------------------------------------------------------------
168
169
170
        //-------------------------------------------------------------------------------
171
        // Third block starts here
172
        //-------------------------------------------------------------------------------
173
        $mform->addElement('header', 'permission', get_string('mod_form_block_participants', 'bigbluebuttonbn'));
174
175
        // Data required for "Add participant" and initial "Participant list" setup
176
        $roles = bigbluebuttonbn_get_roles();
177
        $users = bigbluebuttonbn_get_users($context);
178
179
        $participant_list = bigbluebuttonbn_get_participant_list($bigbluebuttonbn, $context);
0 ignored issues
show
Bug introduced by
The variable $bigbluebuttonbn does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
180
        $mform->addElement('hidden', 'participants', json_encode($participant_list));
181
        $mform->setType('participants', PARAM_TEXT);
182
183
        $html_participant_selection = ''.
184
             '<div id="fitem_bigbluebuttonbn_participant_selection" class="fitem fitem_fselect">'."\n".
185
             '  <div class="fitemtitle">'."\n".
186
             '    <label for="bigbluebuttonbn_participant_selectiontype">'.get_string('mod_form_field_participant_add', 'bigbluebuttonbn').' </label>'."\n".
187
             '  </div>'."\n".
188
             '  <div class="felement fselect">'."\n".
189
             '    <select id="bigbluebuttonbn_participant_selection_type" onchange="bigbluebuttonbn_participant_selection_set(); return 0;">'."\n".
190
             '      <option value="all" selected="selected">'.get_string('mod_form_field_participant_list_type_all', 'bigbluebuttonbn').'</option>'."\n".
191
             '      <option value="role">'.get_string('mod_form_field_participant_list_type_role', 'bigbluebuttonbn').'</option>'."\n".
192
             '      <option value="user">'.get_string('mod_form_field_participant_list_type_user', 'bigbluebuttonbn').'</option>'."\n".
193
             '    </select>'."\n".
194
             '    &nbsp;&nbsp;'."\n".
195
             '    <select id="bigbluebuttonbn_participant_selection" disabled="disabled">'."\n".
196
             '      <option value="all" selected="selected">---------------</option>'."\n".
197
             '    </select>'."\n".
198
             '    &nbsp;&nbsp;'."\n".
199
             '    <input value="'.get_string('mod_form_field_participant_list_action_add', 'bigbluebuttonbn').'" type="button" id="id_addselectionid" onclick="bigbluebuttonbn_participant_add(); return 0;" />'."\n".
200
             '  </div>'."\n".
201
             '</div>'."\n".
202
             '<div id="fitem_bigbluebuttonbn_participant_list" class="fitem">'."\n".
203
             '  <div class="fitemtitle">'."\n".
204
             '    <label for="bigbluebuttonbn_participant_list">'.get_string('mod_form_field_participant_list', 'bigbluebuttonbn').' </label>'."\n".
205
             '  </div>'."\n".
206
             '  <div class="felement fselect">'."\n".
207
             '    <table id="participant_list_table">'."\n";
208
209
        // Add participant list
210
        foreach($participant_list as $participant){
211
            $participant_selectionid = '';
212
            $participant_selectiontype = $participant['selectiontype'];
213
            if( $participant_selectiontype == 'all') {
214
                $participant_selectiontype = '<b><i>'.get_string('mod_form_field_participant_list_type_'.$participant_selectiontype, 'bigbluebuttonbn').'</i></b>';
215
            } else {
216
                if ( $participant_selectiontype == 'role') {
217
                    $participant_selectionid = bigbluebuttonbn_get_role_name($participant['selectionid']);
218
                } else {
219
                    foreach($users as $user){
220
                        if( $user->id == $participant['selectionid']) {
221
                            $participant_selectionid = $user->firstname.' '.$user->lastname;
222
                            break;
223
                        }
224
                    }
225
                }
226
                $participant_selectiontype = '<b><i>'.get_string('mod_form_field_participant_list_type_'.$participant_selectiontype, 'bigbluebuttonbn').':</i></b>&nbsp;';
227
            }
228
            $participant_role = get_string('mod_form_field_participant_bbb_role_'.$participant['role'], 'bigbluebuttonbn');
0 ignored issues
show
Unused Code introduced by
$participant_role is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
229
230
            $html_participant_selection .= ''.
231
                '      <tr id="participant_list_tr_'.$participant['selectiontype'].'-'.$participant['selectionid'].'">'."\n".
232
                '        <td width="20px"><a onclick="bigbluebuttonbn_participant_remove(\''.$participant['selectiontype'].'\', \''.$participant['selectionid'].'\'); return 0;" title="'.get_string('mod_form_field_participant_list_action_remove', 'bigbluebuttonbn').'">x</a></td>'."\n".
233
                '        <td width="125px">'.$participant_selectiontype.'</td>'."\n".
234
                '        <td>'.$participant_selectionid.'</td>'."\n".
235
                '        <td><i>&nbsp;'.get_string('mod_form_field_participant_list_text_as', 'bigbluebuttonbn').'&nbsp;</i>'."\n".
236
                '          <select id="participant_list_role_'.$participant['selectiontype'].'-'.$participant['selectionid'].'" onchange="bigbluebuttonbn_participant_list_role_update(\''.$participant['selectiontype'].'\', \''.$participant['selectionid'].'\'); return 0;">'."\n".
237
                '            <option value="'.BIGBLUEBUTTONBN_ROLE_VIEWER.'" '.($participant['role'] == BIGBLUEBUTTONBN_ROLE_VIEWER? 'selected="selected" ': '').'>'.get_string('mod_form_field_participant_bbb_role_'.BIGBLUEBUTTONBN_ROLE_VIEWER, 'bigbluebuttonbn').'</option>'."\n".
238
                '            <option value="'.BIGBLUEBUTTONBN_ROLE_MODERATOR.'" '.($participant['role'] == BIGBLUEBUTTONBN_ROLE_MODERATOR? 'selected="selected" ': '').'>'.get_string('mod_form_field_participant_bbb_role_'.BIGBLUEBUTTONBN_ROLE_MODERATOR, 'bigbluebuttonbn').'</option><select>'."\n".
239
                '        </td>'."\n".
240
                '      </tr>'."\n";
241
        }
242
243
        $html_participant_selection .= ''.
244
             '    </table>'."\n".
245
             '  </div>'."\n".
246
             '</div>'."\n".
247
             '<script type="text/javascript" src="'.$CFG->wwwroot.'/mod/bigbluebuttonbn/mod_form.js">'."\n".
248
             '</script>'."\n";
249
250
        $mform->addElement('html', $html_participant_selection);
251
252
        // Add data
253
        $mform->addElement('html', '<script type="text/javascript">var bigbluebuttonbn_participant_selection = {"all": [], "role": '.json_encode($roles).', "user": '.bigbluebuttonbn_get_users_json($users).'}; </script>');
254
        $mform->addElement('html', '<script type="text/javascript">var bigbluebuttonbn_participant_list = '.json_encode($participant_list).'; </script>');
255
        $bigbluebuttonbn_strings = Array( "as" => get_string('mod_form_field_participant_list_text_as', 'bigbluebuttonbn'),
256
                                          "viewer" => get_string('mod_form_field_participant_bbb_role_viewer', 'bigbluebuttonbn'),
257
                                          "moderator" => get_string('mod_form_field_participant_bbb_role_moderator', 'bigbluebuttonbn'),
258
                                          "remove" => get_string('mod_form_field_participant_list_action_remove', 'bigbluebuttonbn'),
259
                                    );
260
        $mform->addElement('html', '<script type="text/javascript">var bigbluebuttonbn_strings = '.json_encode($bigbluebuttonbn_strings).'; </script>');
261
        //-------------------------------------------------------------------------------
262
        // Third block ends here
263
        //-------------------------------------------------------------------------------
264
265
266
        //-------------------------------------------------------------------------------
267
        // Fourth block starts here
268
        //-------------------------------------------------------------------------------
269
        $mform->addElement('header', 'schedule', get_string('mod_form_block_schedule', 'bigbluebuttonbn'));
270
        if( isset($current_activity->openingtime) && $current_activity->openingtime != 0 || isset($current_activity->closingtime) && $current_activity->closingtime != 0 )
271
            $mform->setExpanded('schedule');
272
273
        $mform->addElement('date_time_selector', 'openingtime', get_string('mod_form_field_openingtime', 'bigbluebuttonbn'), array('optional' => true));
274
        $mform->setDefault('openingtime', 0);
275
        $mform->addElement('date_time_selector', 'closingtime', get_string('mod_form_field_closingtime', 'bigbluebuttonbn'), array('optional' => true));
276
        $mform->setDefault('closingtime', 0);
277
        //-------------------------------------------------------------------------------
278
        // Fourth block ends here
279
        //-------------------------------------------------------------------------------
280
281
282
        //-------------------------------------------------------------------------------
283
        // add standard elements, common to all modules
284
        $this->standard_coursemodule_elements();
285
286
        //-------------------------------------------------------------------------------
287
        // add standard buttons, common to all modules
288
        $this->add_action_buttons();
289
    }
290
291
    function data_preprocessing(&$default_values) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
292
        if ($this->current->instance) {
293
            // Editing existing instance - copy existing files into draft area.
294
            try {
295
                $draftitemid = file_get_submitted_draft_itemid('presentation');
296
                file_prepare_draft_area($draftitemid, $this->context->id, 'mod_bigbluebuttonbn', 'presentation', 0, array('subdirs'=>0, 'maxbytes' => 0, 'maxfiles' => 1, 'mainfile' => true));
297
                $default_values['presentation'] = $draftitemid;
298
            } catch (Exception $e){
299
                error_log("Presentation could not be loaded: ".$e->getMessage());
300
                return NULL;
301
            }
302
        }
303
    }
304
305
    function validation($data, $files) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
306
        $errors = parent::validation($data, $files);
307
308
        if ( isset($data['openingtime']) && isset($data['closingtime']) ) {
309
            if ( $data['openingtime'] != 0 && $data['closingtime'] != 0 && $data['closingtime'] < $data['openingtime']) {
310
                $errors['closingtime'] = get_string('bbbduetimeoverstartingtime', 'bigbluebuttonbn');
311
            }
312
        }
313
        
314
        if ( isset($data['voicebridge']) ) {
315
            if ( !bigbluebuttonbn_voicebridge_unique($data['voicebridge'], $data['instance'])) {
316
                $errors['voicebridge'] = get_string('mod_form_field_voicebridge_notunique_error', 'bigbluebuttonbn');
317
            }
318
        }
319
320
        return $errors;
321
    }
322
}