Code conventions and URL update in OpenMeetings plugin - refs BT#7046 refs #5491

1.9.x
Yannick Warnier 12 years ago
parent bd392b59df
commit 527616544e
  1. 578
      plugin/openmeetings/lib/openmeetings_gateway.php

@ -29,305 +29,309 @@ require_once ('openmeetings_rest_service.php');
*/ */
class OpenMeetingsGateway class OpenMeetingsGateway
{ {
public $session_id = ""; public $session_id = "";
public $config; public $config;
function __construct($cfg) function __construct()
{ {
$this->config = $cfg; $this->_user = CONFIG_OPENMEETINGS_USER;
} $this->_pass = CONFIG_OPENMEETINGS_PASS;
$this->_url = CONFIG_OPENMEETINGS_SERVER_URL;
function getRestUrl($name) if (substr($this->_url, -1, 1) == '/') {
$this->_url = substr($this->_url, 0, -1);
}
}
function getRestUrl($name)
{ {
return $this->getUrl() . "/services/" . $name . "/"; return $this->getUrl() . "/services/" . $name . "/";
} }
function getUrl() function getUrl()
{ {
// FIXME protocol should be added // FIXME protocol should be added
$port = $this->config["port"] == 80 ? '' : ":" . $this->config["port"]; return $this->_url;
return $this->config["protocol"] . "://" . $this->config["host"] . $port . "/" . $this->config["webappname"]; }
}
function var_to_str($in)
function var_to_str($in)
{ {
if (is_bool($in)) { if (is_bool($in)) {
return $in ? "true" : "false"; return $in ? "true" : "false";
} else { } else {
return $in; return $in;
} }
} }
/** /**
* TODO: Get Error Service and show detailed Error Message * TODO: Get Error Service and show detailed Error Message
*/ */
function loginuser() function loginuser()
{ {
$restService = new OpenMeetingsRestService(); $restService = new OpenMeetingsRestService();
$response = $restService->call($this->getRestUrl("UserService") . "getSession", "session_id"); $response = $restService->call($this->getRestUrl("UserService") . "getSession", "session_id");
if ($restService->getError()) { if ($restService->getError()) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($response); print_r($response);
echo '</pre>'; echo '</pre>';
} else { } else {
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>'; echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else { } else {
$this->session_id = $response; $this->session_id = $response;
$result = $restService->call($this->getRestUrl("UserService") . "loginUser?SID=" . $this->session_id $result = $restService->call($this->getRestUrl("UserService") . "loginUser?SID=" . $this->session_id
. "&username=" . urlencode($this->config["adminUser"]) . "&username=" . urlencode($this->config["adminUser"])
. "&userpass=" . urlencode($this->config["adminPass"])); . "&userpass=" . urlencode($this->config["adminPass"]));
if ($restService->getError()) { if ($restService->getError()) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($result); print_r($result);
echo '</pre>'; echo '</pre>';
} else { } else {
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>'; echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else { } else {
$returnValue = $result; $returnValue = $result;
} }
} }
} }
} }
if ($returnValue > 0) { if ($returnValue > 0) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
function updateRoomWithModeration($openmeetings) function updateRoomWithModeration($openmeetings)
{ {
$restService = new OpenMeetingsRestService(); $restService = new OpenMeetingsRestService();
// echo $restService."<br/>"; // echo $restService."<br/>";
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($restService->getDebug(), ENT_QUOTES) . '</pre>'; echo '<h2>Debug</h2><pre>' . htmlspecialchars($restService->getDebug(), ENT_QUOTES) . '</pre>';
exit(); exit();
} }
$isModeratedRoom = false; $isModeratedRoom = false;
if ($openmeetings->is_moderated_room == 1) { if ($openmeetings->is_moderated_room == 1) {
$isModeratedRoom = true; $isModeratedRoom = true;
} }
$result = $restService->call($this->getRestUrl("RoomService") . "updateRoomWithModeration?SID=" . $this->session_id $result = $restService->call($this->getRestUrl("RoomService") . "updateRoomWithModeration?SID=" . $this->session_id
. "&room_id=" . $openmeetings->room_id . "&name=" . urlencode($openmeetings->roomname) . "&roomtypes_id=" . "&room_id=" . $openmeetings->room_id . "&name=" . urlencode($openmeetings->roomname) . "&roomtypes_id="
. urlencode($openmeetings->type) . "&comment=" . urlencode("Created by SOAP-Gateway") . urlencode($openmeetings->type) . "&comment=" . urlencode("Created by SOAP-Gateway")
. "&numberOfPartizipants=" . $openmeetings->max_user . "&ispublic=false" . "&appointment=false" . "&isDemoRoom=false" . "&numberOfPartizipants=" . $openmeetings->max_user . "&ispublic=false" . "&appointment=false" . "&isDemoRoom=false"
. "&demoTime=0" . "&isModeratedRoom=" . $this->var_to_str($isModeratedRoom)); . "&demoTime=0" . "&isModeratedRoom=" . $this->var_to_str($isModeratedRoom));
if ($restService->fault) { if ($restService->fault) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($result); print_r($result);
echo '</pre>'; echo '</pre>';
} else { } else {
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>'; echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else { } else {
// echo '<h2>Result</h2><pre>'; print_r($result["return"]); echo '</pre>'; // echo '<h2>Result</h2><pre>'; print_r($result["return"]); echo '</pre>';
return $result; return $result;
} }
} }
return - 1; return - 1;
} }
/* /*
* public String setUserObjectAndGenerateRecordingHashByURL(String SID, String username, String firstname, String lastname, Long externalUserId, String externalUserType, Long recording_id) * public String setUserObjectAndGenerateRecordingHashByURL(String SID, String username, String firstname, String lastname, Long externalUserId, String externalUserType, Long recording_id)
*/ */
function setUserObjectAndGenerateRecordingHashByURL($username, $firstname, $lastname, $userId, $systemType, $recording_id) function setUserObjectAndGenerateRecordingHashByURL($username, $firstname, $lastname, $userId, $systemType, $recording_id)
{ {
$restService = new OpenMeetingsRestService(); $restService = new OpenMeetingsRestService();
$result = $restService->call($this->getRestUrl("UserService") . 'setUserObjectAndGenerateRecordingHashByURL?SID=' . $this->session_id $result = $restService->call($this->getRestUrl("UserService") . 'setUserObjectAndGenerateRecordingHashByURL?SID=' . $this->session_id
. '&username=' . urlencode($username) . '&firstname=' . urlencode($firstname) . '&lastname=' . urlencode($lastname) . '&username=' . urlencode($username) . '&firstname=' . urlencode($firstname) . '&lastname=' . urlencode($lastname)
. '&externalUserId=' . $userId . '&externalUserType=' . urlencode($systemType) . '&recording_id=' . $recording_id, 'return'); . '&externalUserId=' . $userId . '&externalUserType=' . urlencode($systemType) . '&recording_id=' . $recording_id, 'return');
if ($restService->fault) { if ($restService->fault) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($result); print_r($result);
echo '</pre>'; echo '</pre>';
} else { } else {
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>'; echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else { } else {
return $result; return $result;
} }
} }
return - 1; return - 1;
} }
function setUserObjectAndGenerateRoomHashByURLAndRecFlag($username, $firstname, $lastname, $profilePictureUrl, $email, $userId, $systemType, $room_id, $becomeModerator, $allowRecording) function setUserObjectAndGenerateRoomHashByURLAndRecFlag($username, $firstname, $lastname, $profilePictureUrl, $email, $userId, $systemType, $room_id, $becomeModerator, $allowRecording)
{ {
$restService = new OpenMeetingsRestService(); $restService = new OpenMeetingsRestService();
// echo $restService."<br/>"; // echo $restService."<br/>";
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($restService->getDebug(), ENT_QUOTES) . '</pre>'; echo '<h2>Debug</h2><pre>' . htmlspecialchars($restService->getDebug(), ENT_QUOTES) . '</pre>';
exit(); exit();
} }
$result = $restService->call($this->getRestUrl("UserService") . "setUserObjectAndGenerateRoomHashByURLAndRecFlag?SID=" . $this->session_id $result = $restService->call($this->getRestUrl("UserService") . "setUserObjectAndGenerateRoomHashByURLAndRecFlag?SID=" . $this->session_id
. "&username=" . urlencode($username) . "&firstname=" . urlencode($firstname) . "&lastname=" . urlencode($lastname) . "&username=" . urlencode($username) . "&firstname=" . urlencode($firstname) . "&lastname=" . urlencode($lastname)
. "&profilePictureUrl=" . urlencode($profilePictureUrl) . "&email=" . urlencode($email) . "&externalUserId=" . urlencode($userId) . "&profilePictureUrl=" . urlencode($profilePictureUrl) . "&email=" . urlencode($email) . "&externalUserId=" . urlencode($userId)
. "&externalUserType=" . urlencode($systemType) . "&room_id=" . urlencode($room_id) . "&becomeModeratorAsInt=" . $becomeModerator . "&externalUserType=" . urlencode($systemType) . "&room_id=" . urlencode($room_id) . "&becomeModeratorAsInt=" . $becomeModerator
. "&showAudioVideoTestAsInt=1" . "&allowRecording=" . $this->var_to_str($allowRecording)); . "&showAudioVideoTestAsInt=1" . "&allowRecording=" . $this->var_to_str($allowRecording));
if ($restService->fault) { if ($restService->fault) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($result); print_r($result);
echo '</pre>'; echo '</pre>';
} else { } else {
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>'; echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else { } else {
// echo '<h2>Result</h2><pre>'; print_r($result["return"]); echo '</pre>'; // echo '<h2>Result</h2><pre>'; print_r($result["return"]); echo '</pre>';
return $result; return $result;
} }
} }
return - 1; return - 1;
} }
function deleteRoom($openmeetings) function deleteRoom($openmeetings)
{ {
// echo $client_roomService."<br/>"; // echo $client_roomService."<br/>";
$restService = new OpenMeetingsRestService(); $restService = new OpenMeetingsRestService();
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($restService->getDebug(), ENT_QUOTES) . '</pre>'; echo '<h2>Debug</h2><pre>' . htmlspecialchars($restService->getDebug(), ENT_QUOTES) . '</pre>';
exit(); exit();
} }
$result = $restService->call($this->getRestUrl("RoomService") . "deleteRoom?SID=" . $this->session_id $result = $restService->call($this->getRestUrl("RoomService") . "deleteRoom?SID=" . $this->session_id
. "&rooms_id=" . $openmeetings->room_id); . "&rooms_id=" . $openmeetings->room_id);
if ($restService->fault) { if ($restService->fault) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($result); print_r($result);
echo '</pre>'; echo '</pre>';
} else { } else {
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>'; echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else { } else {
// echo '<h2>Result</h2><pre>'; print_r($result["return"]); echo '</pre>'; // echo '<h2>Result</h2><pre>'; print_r($result["return"]); echo '</pre>';
// return $result["return"]; // return $result["return"];
return $result; return $result;
} }
} }
return - 1; return - 1;
} }
/** /**
* Generate a new room hash for entering a conference room * Generate a new room hash for entering a conference room
*/ */
function setUserObjectAndGenerateRoomHash($username, $firstname, $lastname, $profilePictureUrl, $email, $externalUserId, $externalUserType, $room_id, $becomeModeratorAsInt, $showAudioVideoTestAsInt) function setUserObjectAndGenerateRoomHash($username, $firstname, $lastname, $profilePictureUrl, $email, $externalUserId, $externalUserType, $room_id, $becomeModeratorAsInt, $showAudioVideoTestAsInt)
{ {
$restService = new OpenMeetingsRestService(); $restService = new OpenMeetingsRestService();
$result = $restService->call($this->getRestUrl("UserService") . "setUserObjectAndGenerateRoomHash?SID=" . $this->session_id $result = $restService->call($this->getRestUrl("UserService") . "setUserObjectAndGenerateRoomHash?SID=" . $this->session_id
. "&username=" . urlencode($username) . "&firstname=" . urlencode($firstname) . "&lastname=" . urlencode($lastname) . "&username=" . urlencode($username) . "&firstname=" . urlencode($firstname) . "&lastname=" . urlencode($lastname)
. "&profilePictureUrl=" . urlencode($profilePictureUrl) . "&email=" . urlencode($email) . "&externalUserId=" . "&profilePictureUrl=" . urlencode($profilePictureUrl) . "&email=" . urlencode($email) . "&externalUserId="
. urlencode($externalUserId) . "&externalUserType=" . urlencode($externalUserType) . "&room_id=" . $room_id . urlencode($externalUserId) . "&externalUserType=" . urlencode($externalUserType) . "&room_id=" . $room_id
. "&becomeModeratorAsInt=" . $becomeModeratorAsInt . "&showAudioVideoTestAsInt=" . $showAudioVideoTestAsInt); . "&becomeModeratorAsInt=" . $becomeModeratorAsInt . "&showAudioVideoTestAsInt=" . $showAudioVideoTestAsInt);
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($restService->getDebug(), ENT_QUOTES) . '</pre>'; echo '<h2>Debug</h2><pre>' . htmlspecialchars($restService->getDebug(), ENT_QUOTES) . '</pre>';
exit(); exit();
} }
if ($restService->getError()) { if ($restService->getError()) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($result); print_r($result);
echo '</pre>'; echo '</pre>';
} else { } else {
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>'; echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else { } else {
// echo '<h2>Result</h2><pre>'; print_r($result["return"]); echo '</pre>'; // echo '<h2>Result</h2><pre>'; print_r($result["return"]); echo '</pre>';
return $result; return $result;
} }
} }
return - 1; return - 1;
} }
/** /**
* Create a new conference room * Create a new conference room
*/ */
function createRoomWithModAndType($openmeetings) function createRoomWithModAndType($openmeetings)
{ {
global $USER; global $USER;
$restService = new OpenMeetingsRestService(); $restService = new OpenMeetingsRestService();
$isModeratedRoom = "false"; $isModeratedRoom = "false";
if ($openmeetings->is_moderated_room == 1) { if ($openmeetings->is_moderated_room == 1) {
$isModeratedRoom = "true"; $isModeratedRoom = "true";
} }
$url = $this->getRestUrl("RoomService") . 'addRoomWithModerationAndExternalType?SID=' . $this->session_id $url = $this->getRestUrl("RoomService") . 'addRoomWithModerationAndExternalType?SID=' . $this->session_id
. '&name=' . urlencode($openmeetings->roomname) . '&roomtypes_id=' . $openmeetings->type . '&comment=' . '&name=' . urlencode($openmeetings->roomname) . '&roomtypes_id=' . $openmeetings->type . '&comment='
. urlencode('Created by SOAP-Gateway') . '&numberOfPartizipants=' . $openmeetings->max_user . urlencode('Created by SOAP-Gateway') . '&numberOfPartizipants=' . $openmeetings->max_user
. '&ispublic=false' . '&appointment=false' . '&isDemoRoom=false' . '&demoTime=0' . '&isModeratedRoom=' . $isModeratedRoom . '&ispublic=false' . '&appointment=false' . '&isDemoRoom=false' . '&demoTime=0' . '&isModeratedRoom=' . $isModeratedRoom
. '&externalRoomType=' . urlencode($this->config["moduleKey"]); . '&externalRoomType=' . urlencode($this->config["moduleKey"]);
$result = $restService->call($url, "return"); $result = $restService->call($url, "return");
if ($restService->fault) { if ($restService->fault) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($result); print_r($result);
echo '</pre>'; echo '</pre>';
} else { } else {
$err = $restService->getError(); $err = $restService->getError();
if ($err) { if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>'; echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else { } else {
return $result; return $result;
} }
} }
return - 1; return - 1;
} }
/** /**
* Get list of available recordings made by this instance * Get list of available recordings made by this instance
*/ */
function getRecordingsByExternalRooms() function getRecordingsByExternalRooms()
{ {
$restService = new OpenMeetingsRestService(); $restService = new OpenMeetingsRestService();
$url = $this->getRestUrl("RoomService") . "getFlvRecordingByExternalRoomType?SID=" . $this->session_id $url = $this->getRestUrl("RoomService") . "getFlvRecordingByExternalRoomType?SID=" . $this->session_id
. "&externalRoomType=" . urlencode($this->config["moduleKey"]); . "&externalRoomType=" . urlencode($this->config["moduleKey"]);
$result = $restService->call($url, "return"); $result = $restService->call($url, "return");
return $result; return $result;
} }
/** /**
* Get list of available recordings made by user * Get list of available recordings made by user
*/ */
function getRecordingsByExternalUser($id) function getRecordingsByExternalUser($id)
{ {
$restService = new OpenMeetingsRestService(); $restService = new OpenMeetingsRestService();
$url = $this->getRestUrl("RoomService") . "getFlvRecordingByExternalUserId?SID=" . $this->session_id $url = $this->getRestUrl("RoomService") . "getFlvRecordingByExternalUserId?SID=" . $this->session_id
. "&externalUserId=" . $id; . "&externalUserId=" . $id;
$result = $restService->call($url, "return"); $result = $restService->call($url, "return");
return $result; return $result;
} }
} }

Loading…
Cancel
Save