1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Definition for the room class. |
4
|
|
|
* |
5
|
|
|
* @package chamilo.plugin.videoconference |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Chamilo\Plugin\OpenMeetings; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class room. |
12
|
|
|
*/ |
13
|
|
|
class Room |
14
|
|
|
{ |
15
|
|
|
public $SID; |
16
|
|
|
/** |
17
|
|
|
* Defining plural and non-plural because of inconsistency in OpenMeetings. |
18
|
|
|
*/ |
19
|
|
|
public $rooms_id; |
20
|
|
|
public $room_id; |
21
|
|
|
/** |
22
|
|
|
* Status is false for closed, true for open. |
23
|
|
|
*/ |
24
|
|
|
public $status = false; |
25
|
|
|
public $name; |
26
|
|
|
/** |
27
|
|
|
* Room types are described here http://openmeetings.apache.org/RoomService.html#addRoomWithModerationAndExternalType |
28
|
|
|
* 1 = Conference, 2 = Audience, 3 = Restricted, 4 = Interview |
29
|
|
|
* $roomTypeId = ( $this->isTeacher() ) ? 1 : 2 ;. |
30
|
|
|
*/ |
31
|
|
|
public $roomtypes_id = 1; |
32
|
|
|
public $comment; |
33
|
|
|
public $numberOfPartizipants = 40; |
34
|
|
|
public $ispublic = false; |
35
|
|
|
public $appointment = false; |
36
|
|
|
public $isDemoRoom = false; |
37
|
|
|
public $demoTime = 0; |
38
|
|
|
public $isModeratedRoom = true; |
39
|
|
|
public $externalRoomType = 'chamilolms'; |
40
|
|
|
public $allowUserQuestions = false; |
41
|
|
|
public $isAudioOnly = false; |
42
|
|
|
public $waitForRecording = true; |
43
|
|
|
public $allowRecording = true; |
44
|
|
|
public $chamiloCourseId; |
45
|
|
|
public $chamiloSessionId; |
46
|
|
|
private $table; |
47
|
|
|
|
48
|
|
|
public function __construct() |
49
|
|
|
{ |
50
|
|
|
$this->table = \Database::get_main_table('plugin_openmeetings'); |
51
|
|
|
global $_configuration; |
52
|
|
|
$this->name = 'C'.api_get_course_int_id().'-'.api_get_session_id(); |
53
|
|
|
$accessUrl = api_get_access_url($_configuration['access_url']); |
54
|
|
|
$this->externalRoomType = substr($accessUrl['url'], strpos($accessUrl['url'], '://') + 3, -1); |
55
|
|
|
if (strcmp($this->externalRoomType, 'localhost') == 0) { |
56
|
|
|
$this->externalRoomType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://') + 3, -1); |
57
|
|
|
} |
58
|
|
|
$this->externalRoomType = 'chamilolms.'.$this->externalRoomType; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get Room by id. |
63
|
|
|
* |
64
|
|
|
* @param int $id |
65
|
|
|
*/ |
66
|
|
|
public function getRoom($id) |
67
|
|
|
{ |
68
|
|
|
if (!empty($id)) { |
69
|
|
|
$roomData = \Database::select('*', $this->table, ['where' => ['id = ?' => $id]], 'first'); |
70
|
|
|
if (!empty($roomData)) { |
71
|
|
|
$this->rooms_id = $this->room_id = $roomData['room_id']; |
72
|
|
|
$this->status = $roomData['status']; |
73
|
|
|
$this->name = $roomData['meeting_name']; |
74
|
|
|
$this->comment = $roomData['welcome_msg']; |
75
|
|
|
$this->allowRecording = $roomData['record']; |
76
|
|
|
$this->chamiloCourseId = $roomData['c_id']; |
77
|
|
|
$this->chamiloSessionId = $roomData['session_id']; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Sets the room ID and loads as much info as possible from the local table. |
84
|
|
|
* |
85
|
|
|
* @param int $id The room ID (from table.room_id) |
86
|
|
|
*/ |
87
|
|
|
public function loadRoomId($id) |
88
|
|
|
{ |
89
|
|
|
if (!empty($id)) { |
90
|
|
|
$roomData = \Database::select('*', $this->table, ['where' => ['room_id = ?' => $id]], 'last'); |
91
|
|
|
if (!empty($roomData)) { |
92
|
|
|
$this->rooms_id = $this->room_id = $roomData['room_id']; |
93
|
|
|
$this->status = $roomData['status']; |
94
|
|
|
$this->name = $roomData['meeting_name']; |
95
|
|
|
$this->comment = $roomData['welcome_msg']; |
96
|
|
|
$this->allowRecording = $roomData['record']; |
97
|
|
|
$this->chamiloCourseId = $roomData['c_id']; |
98
|
|
|
$this->chamiloSessionId = $roomData['session_id']; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Gets a string from a boolean attribute. |
105
|
|
|
* |
106
|
|
|
* @param string $attribute Name of the attribute |
107
|
|
|
* @param mixed $voidReturn What to return if the value is not defined |
108
|
|
|
* |
109
|
|
|
* @return string The boolean value expressed as string ('true' or 'false') |
110
|
|
|
*/ |
111
|
|
|
public function getString($attribute, $voidReturn = false) |
112
|
|
|
{ |
113
|
|
|
if (empty($attribute)) { |
114
|
|
|
return false; |
115
|
|
|
} |
116
|
|
|
if (!isset($this->$attribute)) { |
117
|
|
|
return $voidReturn; |
|
|
|
|
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
return $this->$attribute ? 'true' : 'false'; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled.