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 // First, try to see if there is an active room for this course and session
$roomId = null; $roomId = null;
$meetingData = \Database::select('*', $this->table, array('where' => array('c_id = ?' => $this->chamiloCourseId, ' AND session_id = ? ' => $this->chamiloSessionId)), 'first'); $meetingData = \Database::select('*', $this->table, array('where' => array('c_id = ?' => $this->chamiloCourseId, ' AND session_id = ? ' => $this->chamiloSessionId)), 'first');
if (count($meetingData) > 0) { if ($meetingData != false && count($meetingData) > 0) {
//error_log('Found previous room reference - reusing'); error_log('Found previous room reference - reusing');
// There has been a room in the past for this course. It should // 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) // still be on the server, so update (instead of creating a new one)
// This fills the following attributes: status, name, comment, chamiloCourseId, chamiloSessionId // This fills the following attributes: status, name, comment, chamiloCourseId, chamiloSessionId
@ -153,23 +153,16 @@ class OpenMeetings
} else { } else {
error_log('Found no previous room - creating'); error_log('Found no previous room - creating');
$room = new Room(); $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->SID = $this->sessionId;
$room->name = $this->roomName; $room->name = $this->roomName;
$room->roomtypes_id = $roomTypeId; $room->roomtypes_id = $room->roomtypes_id;
$room->comment = get_lang('Course').': ' . $params['meeting_name'] . ' Plugin for Chamilo'; $room->comment = urlencode(get_lang('Course').': ' . $params['meeting_name'] . ' Plugin for Chamilo');
$room->numberOfPartizipants = 40; $room->numberOfPartizipants = $room->numberOfPartizipants;
$room->ispublic = true; $room->ispublic = $room->getString('isPublic');
$room->appointment = false; $room->appointment = $room->getString('appointment');
$room->isDemoRoom = false; $room->isDemoRoom = $room->getString('isDemoRoom');
$room->demoTime = 0; $room->demoTime = $room->demoTime;
$room->isModeratedRoom = $isModerated; $room->isModeratedRoom = $room->getString('isModeratedRoom');
$room->externalRoomType = 'chamilolms';
$roomId = $this->gateway->createRoomWithModAndType($room); $roomId = $this->gateway->createRoomWithModAndType($room);
} }

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

@ -10,11 +10,21 @@ namespace Chamilo\Plugin\OpenMeetings;
class Room class Room
{ {
public $SID; 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 $rooms_id;
public $room_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; 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 $roomtypes_id = 1;
public $comment; public $comment;
public $numberOfPartizipants = 40; public $numberOfPartizipants = 40;
@ -31,6 +41,13 @@ class Room
public function __construct() public function __construct()
{ {
$this->table = \Database::get_main_table('plugin_openmeetings'); $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