get('tool_enable'); $om_host = $plugin->get('host'); $om_user = $plugin->get('user'); $om_pass = $plugin->get('pass'); $accessUrl = api_get_access_url($_configuration['access_url']); $this->externalType = substr($accessUrl['url'], strpos($accessUrl['url'], '://') + 3, -1); if (strcmp($this->externalType, 'localhost') == 0) { $this->externalType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://') + 3, -1); } $this->externalType = 'chamilolms.'.$this->externalType; $this->table = \Database::get_main_table('plugin_openmeetings'); if ($om_plugin) { $user_info = api_get_user_info(); $this->user_complete_name = $user_info['complete_name']; $this->user = $om_user; $this->pass = $om_pass; $this->url = $om_host; // Setting OM api define('CONFIG_OPENMEETINGS_USER', $this->user); define('CONFIG_OPENMEETINGS_PASS', $this->pass); define('CONFIG_OPENMEETINGS_SERVER_URL', $this->url); $this->gateway = new \OpenMeetingsGateway($this->url, $this->user, $this->pass); $this->plugin_enabled = $om_plugin; // The room has a name composed of C + course ID + '-' + session ID $this->chamiloCourseId = api_get_course_int_id(); $this->chamiloSessionId = api_get_session_id(); $this->roomName = 'C'.$this->chamiloCourseId.'-'.$this->chamiloSessionId; $return = $this->gateway->loginUser(); if ($return == 0) { $msg = 'Could not initiate session with server through OpenMeetingsGateway::loginUser()'; error_log(__FILE__.'+'.__LINE__.': '.$msg); die($msg); } $this->sessionId = $this->gateway->sessionId; } } /** * Checks whether a user is teacher in the current course. * * @return bool True if the user can be considered a teacher in this course, false otherwise */ public function isTeacher() { return api_is_course_admin() || api_is_coach() || api_is_platform_admin(); } /* * Creating a Room for the meeting * @return bool True if the user is correct and false when is incorrect */ public function createMeeting($params) { global $_configuration; // First, try to see if there is an active room for this course and session. $roomId = null; $meetingData = \Database::select( '*', $this->table, [ 'where' => [ 'c_id = ?' => $this->chamiloCourseId, ' AND session_id = ? ' => $this->chamiloSessionId, ' AND status <> ? ' => 2, ], ], 'first' ); if ($meetingData != false && count($meetingData) > 0) { // There has been a room in the past for this course. It should // still be on the server, so update (instead of creating a new one) // This fills the following attributes: status, name, comment, chamiloCourseId, chamiloSessionId $room = new Room(); $room->loadRoomId($meetingData['room_id']); $roomArray = (array) $room; $roomArray['SID'] = $this->sessionId; $roomId = $this->gateway->updateRoomWithModeration($room); if ($roomId != $meetingData['room_id']) { $msg = 'Something went wrong: the updated room ID ('.$roomId.') is not the same as the one we had ('.$meetingData['room_id'].')'; die($msg); } } else { $room = new Room(); $room->SID = $this->sessionId; $room->name = $this->roomName; //$room->roomtypes_id = $room->roomtypes_id; $room->comment = urlencode(get_lang('Course').': '.$params['meeting_name'].' - '.$_configuration['software_name']); //$room->numberOfPartizipants = $room->numberOfPartizipants; $room->ispublic = boolval($room->getString('isPublic', 'false')); //$room->appointment = $room->getString('appointment'); //$room->isDemoRoom = $room->getString('isDemoRoom'); //$room->demoTime = $room->demoTime; //$room->isModeratedRoom = $room->getString('isModeratedRoom'); $roomId = $this->gateway->createRoomWithModAndType($room); } if (!empty($roomId)) { /* // Find the biggest room_id so far, and create a new one if (empty($roomId)) { $roomData = \Database::select('MAX(room_id) as room_id', $this->table, array(), 'first'); $roomId = $roomData['room_id'] + 1; }*/ $params['status'] = '1'; $params['meeting_name'] = $room->name; $params['created_at'] = api_get_utc_datetime(); $params['room_id'] = $roomId; $params['c_id'] = api_get_course_int_id(); $params['session_id'] = api_get_session_id(); $params['record'] = ($room->allowRecording ? 1 : 0); $id = \Database::insert($this->table, $params); $this->joinMeeting($id); } else { return -1; } } /** * Returns a meeting "join" URL. * * @param string The name of the meeting (usually the course code) * * @return mixed The URL to join the meeting, or false on error * * @todo implement moderator pass * @assert ('') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false */ public function joinMeeting($meetingId) { if (empty($meetingId)) { return false; } $meetingData = \Database::select( '*', $this->table, ['where' => ['id = ? AND status = 1 ' => $meetingId]], 'first' ); if (empty($meetingData)) { if ($this->debug) { error_log("meeting does not exist: $meetingId "); } return false; } $params = ['room_id' => $meetingData['room_id']]; $returnVal = $this->setUserObjectAndGenerateRoomHashByURLAndRecFlag($params); $iframe = $this->url."/?"."secureHash=".$returnVal; printf("