Issues (2126)

plugin/openmeetings/start.php (1 issue)

Severity
1
<?php
2
/**
3
 * This script initiates a video conference session.
4
 */
5
/**
6
 * Initialization.
7
 */
8
$course_plugin = 'openmeetings'; //needed in order to load the plugin lang variables
9
require_once __DIR__.'/config.php';
10
$tool_name = get_lang('Videoconference');
11
$tpl = new Template($tool_name);
12
$om = new \Chamilo\Plugin\OpenMeetings\OpenMeetings();
13
14
if ($om->isServerRunning()) {
15
    if (isset($_GET['launch']) && $_GET['launch'] == 1) {
16
        $meeting_params = [];
17
        $meeting_params['meeting_name'] = 'C'.api_get_course_id().'-'.api_get_session_id();
18
        $meetings = $om->getCourseMeetings();
19
20
        $selectedMeeting = [];
21
        /*
22
        // Select the meeting with more participantCount.
23
        if (!empty($meetings)) {
24
            $max = 0;
25
            foreach ($meetings as $meeting) {
26
                if ($meeting['participantCount'] > $max) {
27
                    $selectedMeeting = $meeting;
28
                    $max = $meeting['participantCount'];
29
                }
30
            }
31
        }
32
        */
33
        // Check for the first meeting available with status = 1
34
        // (there should be only one at a time, as createMeeting checks for that first
35
        if (!empty($meetings)) {
36
            foreach ($meetings as $meeting) {
37
                if ($meeting['status'] == 1) {
38
                    $selectedMeeting = $meeting;
39
                }
40
            }
41
        }
42
43
        if (!empty($selectedMeeting)) {
44
            $url = $om->joinMeeting($selectedMeeting['id']);
45
            if ($url) {
0 ignored issues
show
$url is of type false|null, thus it always evaluated to false.
Loading history...
46
                header('location: '.$url);
47
                exit;
48
            }
49
        } else {
50
            if ($om->isTeacher()) {
51
                $om->createMeeting($meeting_params);
52
                exit;
53
            } else {
54
                $url = 'listing.php';
55
                header('location: '.$url);
56
                exit;
57
            }
58
        }
59
    } else {
60
        $url = 'listing.php';
61
        header('location: '.$url);
62
        exit;
63
    }
64
} else {
65
    $message = Display::return_message(get_lang('ServerIsNotRunning'), 'warning');
66
}
67
$tpl->assign('message', $message);
68
$tpl->display_one_col_template();
69