Fix creation of new rooms - OpenMeetings plugin - refs BT#7046 refs #5491

1.9.x
Yannick Warnier 12 years ago
parent ccbbda832a
commit 503d6c4445
  1. 27
      plugin/openmeetings/lib/openmeetings.class.php
  2. 35
      plugin/openmeetings/lib/openmeetings_gateway.php
  3. 32
      plugin/openmeetings/lib/room.class.php

@ -134,8 +134,8 @@ class OpenMeetings
// First, try to see if there is an active room for this course and session
$roomId = null;
$meetingData = \Database::select('*', $this->table, array('where' => array('c_id = ?' => $this->chamiloCourseId, ' AND session_id = ? ' => $this->chamiloSessionId)), 'first');
if (count($meetingData) > 0) {
//error_log('Found previous room reference - reusing');
if ($meetingData != false && count($meetingData) > 0) {
error_log('Found previous room reference - reusing');
// 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
@ -153,23 +153,16 @@ class OpenMeetings
} else {
error_log('Found no previous room - creating');
$room = new Room();
// Room types are described here http://openmeetings.apache.org/RoomService.html#addRoomWithModerationAndExternalType
// 1 = Conference, 2 = Audience, 3 = Restricted, 4 = Interview
$roomTypeId = ( $this->isTeacher() ) ? 1 : 2 ;
$isModerated = ($roomTypeId > 0); //bool
$urlWsdl = $this->url . "/services/RoomService?wsdl";
$room->SID = $this->sessionId;
$room->name = $this->roomName;
$room->roomtypes_id = $roomTypeId;
$room->comment = get_lang('Course').': ' . $params['meeting_name'] . ' Plugin for Chamilo';
$room->numberOfPartizipants = 40;
$room->ispublic = true;
$room->appointment = false;
$room->isDemoRoom = false;
$room->demoTime = 0;
$room->isModeratedRoom = $isModerated;
$room->externalRoomType = 'chamilolms';
$room->roomtypes_id = $room->roomtypes_id;
$room->comment = urlencode(get_lang('Course').': ' . $params['meeting_name'] . ' Plugin for Chamilo');
$room->numberOfPartizipants = $room->numberOfPartizipants;
$room->ispublic = $room->getString('isPublic');
$room->appointment = $room->getString('appointment');
$room->isDemoRoom = $room->getString('isDemoRoom');
$room->demoTime = $room->demoTime;
$room->isModeratedRoom = $room->getString('isModeratedRoom');
$roomId = $this->gateway->createRoomWithModAndType($room);
}

@ -287,28 +287,23 @@ class OpenMeetingsGateway
/**
* Create a new conference room
*/
function createRoomWithModAndType($openmeetings)
function createRoomWithModAndType($room)
{
$isModeratedRoom = "false";
if ($openmeetings->is_moderated_room == 1) {
$isModeratedRoom = "true";
}
$url = $this->getRestUrl("RoomService")
. 'addRoomWithModerationAndExternalType?'
. 'SID=' . $this->sessionId
. '&name=' . urlencode($openmeetings->roomname)
. '&roomtypes_id=' . $openmeetings->type
. '&comment='. urlencode('Created by SOAP-Gateway')
. '&numberOfPartizipants=' . $openmeetings->max_user
. '&ispublic=false'
. '&appointment=false'
. '&isDemoRoom=false'
. '&demoTime=0'
. '&isModeratedRoom=' . $isModeratedRoom
. '&externalRoomType=' . urlencode($this->config["moduleKey"]);
$result = $this->rest->call($url, "return");
. 'SID=' . $room->SID
. '&name=' . $room->roomname
. '&roomtypes_id=' . $room->roomtypes_id
. '&comment='. $room->comment
. '&numberOfPartizipants=' . $room->numberOfPartizipants
. '&ispublic=' . $room->ispublic
. '&appointment=' . $room->appointment
. '&isDemoRoom=' . $room->isDemoRoom
. '&demoTime=' . $room->demoTime
. '&isModeratedRoom=' . $room->isModeratedRoom
. '&externalRoomType=' . $room->externalRoomType;
error_log($url);
$result = $this->rest->call($url);
if ($this->rest->fault) {
error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result,1));
@ -317,7 +312,7 @@ class OpenMeetingsGateway
if ($err) {
error_log('Error: '.$err);
} else {
//error_log('Creation of a new room succeeded: ID '.$result);
error_log('Creation of a new room succeeded: ID '.print_r($result,1));
return $result;
}
}

@ -10,11 +10,21 @@ namespace Chamilo\Plugin\OpenMeetings;
class Room
{
public $SID;
// Defining plural and non-plural because of inconsistency in OpenMeetings
/**
* Defining plural and non-plural because of inconsistency in OpenMeetings
*/
public $rooms_id;
public $room_id;
public $status = false; //false for closed, true for open
/**
* Status is false for closed, true for open
*/
public $status = false;
public $name;
/**
* Room types are described here http://openmeetings.apache.org/RoomService.html#addRoomWithModerationAndExternalType
* 1 = Conference, 2 = Audience, 3 = Restricted, 4 = Interview
* $roomTypeId = ( $this->isTeacher() ) ? 1 : 2 ;
*/
public $roomtypes_id = 1;
public $comment;
public $numberOfPartizipants = 40;
@ -31,6 +41,13 @@ class Room
public function __construct()
{
$this->table = \Database::get_main_table('plugin_openmeetings');
global $_configuration;
$accessUrl = api_get_access_url($_configuration['access_url']);
$this->externalRoomType = substr($accessUrl['url'],strpos($accessUrl['url'],'://')+3,-1);
if (strcmp($this->externalRoomType,'localhost') == 0) {
$this->externalRoomType = substr(api_get_path(WEB_PATH),strpos(api_get_path(WEB_PATH),'://')+3,-1);
}
$this->externalRoomType = 'chamilolms.'.$this->externalRoomType;
}
/**
@ -51,4 +68,15 @@ class Room
}
}
}
/**
* Gets a string from a boolean attribute
* @param string $attribute Name of the attribute
* @return string The boolean value expressed as string ('true' or 'false')
*/
public function getString($attribute) {
if (empty($attribute)) {
return false;
}
return $this->$attribute?'true':'false';
}
}
Loading…
Cancel
Save