Adding delete room see BT#7391

1.9.x
Julio Montoya 12 years ago
parent 90abac951a
commit c6850cc05b
  1. 97
      plugin/openmeetings/lib/openmeetings.class.php
  2. 18
      plugin/openmeetings/lib/openmeetings_gateway.php
  3. 33
      plugin/openmeetings/lib/room.class.php
  4. 12
      plugin/openmeetings/listing.php
  5. 3
      plugin/openmeetings/listing.tpl
  6. 20
      plugin/openmeetings/start.php

@ -54,7 +54,6 @@ class OpenMeetings
$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) {
@ -136,10 +135,24 @@ class OpenMeetings
public function createMeeting($params)
{
global $_configuration;
//$id = \Database::insert($this->table, $params);
// 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;
$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,
' AND status <> ? ' => 2,
)
),
'first'
);
if ($meetingData != false && count($meetingData) > 0) {
//error_log(print_r($meetingData,1));
//error_log('Found previous room reference - reusing');
@ -165,7 +178,7 @@ class OpenMeetings
//$room->roomtypes_id = $room->roomtypes_id;
$room->comment = urlencode(get_lang('Course').': ' . $params['meeting_name'] . ' - '.$_configuration['software_name']);
//$room->numberOfPartizipants = $room->numberOfPartizipants;
$room->ispublic = $room->getString('isPublic','false');
$room->ispublic = $room->getString('isPublic', 'false');
//$room->appointment = $room->getString('appointment');
//$room->isDemoRoom = $room->getString('isDemoRoom');
//$room->demoTime = $room->demoTime;
@ -210,21 +223,20 @@ class OpenMeetings
if (empty($meetingId)) {
return false;
}
$meetingData = \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($meetingData)) {
if ($this->debug) error_log("meeting does not exist: $meetingId ");
return false;
}
$params = array( 'room_id' => $meetingData['room_id'] );
$returnVal = $this->setUserObjectAndGenerateRoomHashByURLAndRecFlag( $params );
//$urlWithoutProtocol = str_replace("http://", CONFIG_OPENMEETINGS_SERVER_URL);
//$imgWithoutProtocol = str_replace("http://", $_SESSION['_user']['avatar'] );
$iframe = $this->url . "/?" .
"secureHash=" . $returnVal;
$params = array('room_id' => $meetingData['room_id']);
$returnVal = $this->setUserObjectAndGenerateRoomHashByURLAndRecFlag($params);
$iframe = $this->url . "/?" ."secureHash=" . $returnVal;
printf("<iframe src='%s' width='%s' height = '%s' />", $iframe, "100%", 640);
}
@ -302,7 +314,7 @@ class OpenMeetings
$systemType = 'chamilo';
$room_id = $params['room_id'];
$urlWsdl = $this->url . "/services/UserService?wsdl";
$urlWsdl = $this->url."/services/UserService?wsdl";
$omServices = new \SoapClient($urlWsdl);
$objRec = new User();
@ -324,7 +336,6 @@ class OpenMeetings
*/
public function setUserObjectAndGenerateRoomHashByURLAndRecFlag($params)
{
$username = $_SESSION['_user']['username'];
$firstname = $_SESSION['_user']['firstname'];
$lastname = $_SESSION['_user']['lastname'];
@ -336,7 +347,7 @@ class OpenMeetings
$becomeModerator = ( $this->isTeacher() ? 1 : 0 );
$allowRecording = 1; //Provisional
$urlWsdl = $this->url . "/services/UserService?wsdl";
$urlWsdl = $this->url."/services/UserService?wsdl";
$omServices = new \SoapClient($urlWsdl);
$objRec = new User();
@ -371,12 +382,13 @@ class OpenMeetings
array('where' =>
array(
'c_id = ? ' => api_get_course_int_id(),
' AND session_id = ? ' => api_get_session_id()
' AND session_id = ? ' => api_get_session_id(),
' AND status <> ? ' => 2 // status deleted
)
)
);
$urlWsdl = $this->url . "/services/RoomService?wsdl";
$omServices = new \SoapClient($urlWsdl);
/*$urlWsdl = $this->url."/services/RoomService?wsdl";
$omServices = new \SoapClient($urlWsdl);*/
$room = new Room();
/*
@ -489,6 +501,7 @@ class OpenMeetings
$remoteMeeting['add_to_calendar_url'] = api_get_self().'?action=add_to_calendar&id='.$meetingDb['id'].'&start='.api_strtotime($meetingDb['startTime']);
}
$remoteMeeting['end_url'] = api_get_self().'?action=end&id='.$meetingDb['id'];
$remoteMeeting['delete_url'] = api_get_self().'?action=delete&id='.$meetingDb['id'];
//$record_array = array();
@ -561,21 +574,30 @@ class OpenMeetings
/**
* Send a command to the OpenMeetings server to close the meeting
* @param $meetingId
* @param int $meetingId
* @return int
*/
public function endMeeting($meetingId)
{
try {
$urlWsdl = $this->url . "/services/RoomService?wsdl";
$ws = new \SoapClient( $urlWsdl );
$room = new Room($meetingId);
$room->SID = $this->sessionId;
$room->room_id = intval($meetingId);
$room->status = false;
$urlWsdl = $this->url."/services/RoomService?wsdl";
$ws = new \SoapClient($urlWsdl);
$roomClosed = $ws->closeRoom($room);
if ($roomClosed > 0) {
\Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $meetingId));
\Database::update(
$this->table,
array(
'status' => 0,
'closed_at' => api_get_utc_datetime()
),
array('id = ? ' => $meetingId)
);
}
//error_log(__FILE__.'+'.__LINE__.' Finished closing');
} catch (SoapFault $e) {
@ -584,4 +606,29 @@ class OpenMeetings
return -1;
}
}
/**
* @param int $id
*/
public function deleteMeeting($id)
{
try {
$room = new Room();
$room->loadRoomId($id);
$this->gateway->deleteRoom($room);
\Database::update(
$this->table,
array(
'status' => 2
),
array('id = ? ' => $id)
);
//error_log(__FILE__.'+'.__LINE__.' Finished closing');
} catch (SoapFault $e) {
error_log(__FILE__.'+'.__LINE__.' Warning: We have detected some problems: Fault: '.$e->faultstring);
exit;
return -1;
}
}
}

@ -51,7 +51,6 @@ class OpenMeetingsGateway
error_log('Debug: ' . $this->rest->getDebug());;
exit();
}
}
function getRestUrl($name)
@ -83,7 +82,6 @@ class OpenMeetingsGateway
if ($this->rest->getError()) {
error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($response,1));
} else {
$err = $this->rest->getError();
if ($err) {
@ -98,7 +96,6 @@ class OpenMeetingsGateway
. "&username=" . $this->_user
. "&userpass=" . $this->_pass;
$result = $this->rest->call($url);
//error_log(__FILE__.'+'.__LINE__.': '.$url);
if ($this->rest->getError()) {
error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result,1));
} else {
@ -118,6 +115,7 @@ class OpenMeetingsGateway
return false;
}
}
function updateRoomWithModeration($room)
{
$err = $this->rest->getError();
@ -189,6 +187,7 @@ class OpenMeetingsGateway
}
return - 1;
}
function setUserObjectAndGenerateRoomHashByURLAndRecFlag($username, $firstname, $lastname, $profilePictureUrl, $email, $userId, $systemType, $room_id, $becomeModerator, $allowRecording)
{
$err = $this->rest->getError();
@ -226,17 +225,21 @@ class OpenMeetingsGateway
}
return - 1;
}
/**
* @param Room $openmeetings
* @return array|bool|int|null
*/
function deleteRoom($openmeetings)
{
$err = $this->rest->getError();
if ($err) {
error_log('Constructor error: ' . $err);
error_log('Debug: ' . $this->rest->getDebug());;
error_log('Debug: ' . $this->rest->getDebug());
exit();
}
$result = $this->rest->call($this->getRestUrl("RoomService") . "deleteRoom?SID=" . $this->sessionId
. "&rooms_id=" . $openmeetings->room_id);
$url = $this->getRestUrl("RoomService")."deleteRoom?SID=".$this->sessionId."&rooms_id=".$openmeetings->room_id;
$result = $this->rest->call($url);
if ($result->fault) {
error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result,1));
@ -320,7 +323,6 @@ class OpenMeetingsGateway
} elseif ($room->isAudioOnly) {
$url .= '&isAudioOnly=' . $this->var_to_str($room->isAudioOnly);
}
error_log($url);
$result = $this->rest->call($url);
if ($this->rest->fault) {

@ -4,6 +4,7 @@
* @package chamilo.plugin.videoconference
*/
namespace Chamilo\Plugin\OpenMeetings;
/**
* Class room
*/
@ -48,13 +49,33 @@ class Room
global $_configuration;
$this->name = 'C'.api_get_real_course_id().'-'.api_get_session_id();
$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 = 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;
}
/**
* Get Room by id
* @param int $id
*/
public function getRoom($id)
{
if (!empty($id)) {
$roomData = \Database::select('*', $this->table, array('where' => array('id = ?' => $id)), 'first');
if (!empty($roomData)) {
$this->rooms_id = $this->room_id = $roomData['room_id'];
$this->status = $roomData['status'];
$this->name = $roomData['meeting_name'];
$this->comment = $roomData['welcome_msg'];
$this->allowRecording = $roomData['record'];
$this->chamiloCourseId = $roomData['c_id'];
$this->chamiloSessionId = $roomData['session_id'];
}
}
}
/**
* Sets the room ID and loads as much info as possible from the local table
* @param int $id The room ID (from table.room_id)
@ -74,13 +95,15 @@ class Room
}
}
}
/**
* Gets a string from a boolean attribute
* @param string $attribute Name of the attribute
* @param mixed $voidReturn What to return if the value is not defined
* @return string The boolean value expressed as string ('true' or 'false')
*/
public function getString($attribute, $voidReturn = false) {
public function getString($attribute, $voidReturn = false)
{
if (empty($attribute)) {
return false;
}
@ -89,4 +112,4 @@ class Room
}
return $this->$attribute?'true':'false';
}
}
}

@ -15,7 +15,6 @@ $tpl = new Template($tool_name);
$om = new Chamilo\Plugin\OpenMeetings\OpenMeetings();
$action = isset($_GET['action']) ? $_GET['action'] : null;
$teacher = $om->isTeacher();
api_protect_course_script(true);
@ -48,12 +47,19 @@ if ($teacher) {
}
break;
case 'delete_record':
$om->delete_record($_GET['id']);
/*$result = $om->delete_record($_GET['id']);
if ($result) {
$message = Display::return_message(get_lang('Deleted'), 'success');
} else {
$message = Display::return_message(get_lang('Error'), 'error');
}
}*/
break;
case 'delete':
$om->deleteMeeting($_GET['id']);
unset($om);
$message = Display::return_message(get_lang('MeetingDeleted').'<br />'.get_lang('MeetingDeletedComment'), 'success', false);
header('Location: '.api_get_self());
exit;
break;
case 'end':
$om->endMeeting($_GET['id']);

@ -48,8 +48,9 @@
{% if allow_to_edit %}
<td>
{% if meeting.status == 1 %}
<a class="btn" href="{{ meeting.end_url }} "> {{ 'CloseMeeting'|get_lang }}</a>
<a class="btn" href="{{ meeting.end_url }} "> {{ 'CloseMeeting' | get_lang }}</a>
{% endif %}
<a class="btn btn-danger" href="{{ meeting.delete_url }} "> {{ 'DeleteMeeting' | get_lang }}</a>
</td>
{% endif %}

@ -1,12 +1,10 @@
<?php
/**
* This script initiates a videoconference session, calling the BigBlueButton API
* @package chamilo.plugin.bigbluebutton
* This script initiates a video conference session
*/
/**
* Initialization
*/
$course_plugin = 'openmeetings'; //needed in order to load the plugin lang variables
require_once dirname(__FILE__).'/config.php';
$tool_name = get_lang('Videoconference');
@ -36,25 +34,23 @@ if ($om->isServerRunning()) {
*/
// Check for the first meeting available with status = 1
// (there should be only one at a time, as createMeeting checks for that first
foreach ($meetings as $meeting) {
if ($meeting['status'] == 1) {
$selectedMeeting = $meeting;
if (!empty($meetings)) {
foreach ($meetings as $meeting) {
if ($meeting['status'] == 1) {
$selectedMeeting = $meeting;
}
}
}
if (!empty($selectedMeeting)) {
//if (false/*$om->meeting_exists($meeting_params['meeting_name'])*/) {
$url = $om->joinMeeting($selectedMeeting['id']);
if ($url) {
header('location: '.$url);
exit;
}
} else {
if ( $om->isTeacher()) {
//$url =
if ($om->isTeacher()) {
$om->createMeeting($meeting_params);
//header('location: '.$url);
exit;
} else {
$url = 'listing.php';

Loading…
Cancel
Save