General cleanup in OpenMeetings plugin - refs BT#7046 refs #5491

1.9.x
Yannick Warnier 11 years ago
parent 13a67f4847
commit 48632d971a
  1. 55
      plugin/openmeetings/lib/openmeetings.lib.php
  2. 6
      plugin/openmeetings/listing.php
  3. 10
      plugin/openmeetings/start.php

@ -66,7 +66,7 @@ class OpenMeetings
* 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
*/
function is_teacher()
function isTeacher()
{
return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
}
@ -110,19 +110,19 @@ class OpenMeetings
* Creating a Room for the meeting
* @return bool True if the user is correct and false when is incorrect
*/
function create_meeting($params)
function createMeeting($params)
{
//$id = Database::insert($this->table, $params);
try {
$objAddRoom = new addRoomWithModerationAndExternalType();
$roomtypes_id = $isModerated = ( $this->is_teacher() ) ? 1 : 2 ;
$roomTypeId = $isModerated = ( $this->isTeacher() ) ? 1 : 2 ;
$params['c_id'] = api_get_course_int_id();
$course_name = 'COURSE_ID_' . $params['c_id'] .'_NAME_' . $params['meeting_name'];
$urlWsdl = CONFIG_OPENMEETINGS_SERVER_BASE_URL . "/services/RoomService?wsdl";
$objAddRoom->SID = $this->sessionId;
$objAddRoom->name = $course_name;
$objAddRoom->roomtypes_id = $roomtypes_id;
$objAddRoom->roomtypes_id = $roomTypeId;
$objAddRoom->comment = get_lang('Course').': ' . $params['meeting_name'] . ' Plugin for Chamilo';
$objAddRoom->numberOfPartizipants = 40;
$objAddRoom->ispublic = true;
@ -143,7 +143,7 @@ class OpenMeetings
Database::insert($this->table, $params);
$this->join_meeting($meetingId);
$this->joinMeeting($meetingId);
} else {
return -1;
}
@ -164,18 +164,18 @@ class OpenMeetings
* @assert ('') === false
* @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
*/
function join_meeting($meetingid)
function joinMeeting($meetingId)
{
if (empty($meetingid)) {
if (empty($meetingId)) {
return false;
}
$meeting_data = Database::select('*', $this->table, array('where' => array('id = ? AND status = 1 ' => $meetingid)), 'first');
$meetingData = Database::select('*', $this->table, array('where' => array('id = ? AND status = 1 ' => $meetingId)), 'first');
if (empty($meeting_data)) {
if ($this->debug) error_log("meeting does not exist: $meetingid ");
if (empty($meetingData)) {
if ($this->debug) error_log("meeting does not exist: $meetingId ");
return false;
}
$params = array( 'room_id' => $meetingid );
$params = array( 'room_id' => $meetingId );
$returnVal = $this->setUserObjectAndGenerateRoomHashByURLAndRecFlag( $params );
//$urlWithoutProtocol = str_replace("http://", CONFIG_OPENMEETINGS_SERVER_BASE_URL);
@ -203,7 +203,7 @@ class OpenMeetings
* @return bool True if server is running, false otherwise
* @assert () === false
*/
function is_server_running()
function isServerRunning()
{
return true;
}
@ -211,10 +211,10 @@ class OpenMeetings
* Gets the password for a specific meeting for the current user
* @return string A moderator password if user is teacher, or the course code otherwise
*/
function get_user_meeting_password()
function getMeetingUserPassword()
{
if ($this->is_teacher()) {
return $this->get_mod_meeting_password();
if ($this->isTeacher()) {
return $this->getMeetingModerationPassword();
} else {
return api_get_course_id();
}
@ -223,7 +223,7 @@ class OpenMeetings
* Generated a moderator password for the meeting
* @return string A password for the moderation of the video conference
*/
function get_mod_meeting_password()
function getMeetingModerationPassword()
{
return api_get_course_id().'mod';
}
@ -233,7 +233,7 @@ class OpenMeetings
* @return mixed Array of information on success, false on error
* @assert (array()) === false
*/
function get_meeting_info($params)
function getMeetingInfo($params)
{
try {
$result = $this->api->getMeetingInfoArray($params);
@ -247,6 +247,11 @@ class OpenMeetings
}
return false;
}
/**
* @param array $params Array of parameters
* @return mixed
*/
function setUserObjectAndGenerateRecordingHashByURL( $params )
{
$username = $_SESSION['_user']['username'];
@ -272,6 +277,10 @@ class OpenMeetings
return $orFn->return;
}
/**
* @param Array $params Array of parameters
* @return mixed
*/
function setUserObjectAndGenerateRoomHashByURLAndRecFlag( $params )
{
@ -283,7 +292,7 @@ class OpenMeetings
$userId = $_SESSION['_user']['user_id'];
$systemType = 'Chamilo';
$room_id = $params['room_id'];
$becomeModerator = ( $this->is_teacher() ? 1 : 0 );
$becomeModerator = ( $this->isTeacher() ? 1 : 0 );
$allowRecording = 1; //Provisional
$urlWsdl = CONFIG_OPENMEETINGS_SERVER_BASE_URL . "/services/UserService?wsdl";
@ -312,11 +321,11 @@ class OpenMeetings
* Gets all the course meetings saved in the plugin_openmeetings table
* @return array Array of current open meeting rooms
*/
function get_course_meetings()
function getCourseMeetings()
{
$new_meeting_list = array();
$item = array();
$pass = $this->get_user_meeting_password();
$pass = $this->getMeetingUserPassword();
$this->loginUser();
$meeting_list = Database::select('*', $this->table, array('where' => array('c_id = ? ' => api_get_course_int_id())));
@ -370,8 +379,8 @@ class OpenMeetings
$meeting_om = $current_room;
if (empty( $meeting_om )) {
if ($meeting_db['status'] == 1 && $this->is_teacher()) {
$this->end_meeting($meeting_db['id']);
if ($meeting_db['status'] == 1 && $this->isTeacher()) {
$this->endMeeting($meeting_db['id']);
}
} else {
$meeting_om['add_to_calendar_url'] = api_get_self().'?action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['startTime']);
@ -449,7 +458,7 @@ class OpenMeetings
* @param $meetingId
* @return int
*/
function end_meeting($meetingId)
function endMeeting($meetingId)
{
try {
$this->loginUser();

@ -16,7 +16,7 @@ $tpl = new Template($tool_name);
$om = new openmeetings();
$action = isset($_GET['action']) ? $_GET['action'] : null;
$teacher = $om->is_teacher();
$teacher = $om->isTeacher();
api_protect_course_script(true);
$message = null;
@ -56,7 +56,7 @@ if ($teacher) {
}
break;
case 'end':
$om->end_meeting($_GET['id']);
$om->endMeeting($_GET['id']);
$message = Display::return_message(get_lang('MeetingClosed').'<br />'.get_lang('MeetingClosedComment'), 'success', false);
break;
case 'publish':
@ -70,7 +70,7 @@ if ($teacher) {
}
}
$meetings = $om->get_course_meetings();
$meetings = $om->getCourseMeetings();
if (!empty($meetings)) {
$meetings = array_reverse($meetings);
}

@ -15,13 +15,13 @@ $om = new openmeetings();
if ($om->plugin_enabled) {
if ($om->is_server_running()) {
if ($om->isServerRunning()) {
if (isset($_GET['launch']) && $_GET['launch'] == 1) {
$meeting_params = array();
$meeting_params['meeting_name'] = api_get_course_id();
$meetings = $om->get_course_meetings();
$meetings = $om->getCourseMeetings();
// Select the meeting with more participantCount.
$selectedMeeting = array();
@ -37,17 +37,17 @@ if ($om->plugin_enabled) {
if ($om->loginUser() && !empty($selectedMeeting)) {
//if (false/*$om->meeting_exists($meeting_params['meeting_name'])*/) {
$url = $om->join_meeting($selectedMeeting['id']);
$url = $om->joinMeeting($selectedMeeting['id']);
if ($url) {
header('location: '.$url);
exit;
}
} else {
if ( $om->is_teacher() && $om->loginUser()) {
if ( $om->isTeacher() && $om->loginUser()) {
//$url =
$om->create_meeting($meeting_params);
$om->createMeeting($meeting_params);
//header('location: '.$url);
exit;
} else {

Loading…
Cancel
Save