Review code style in main code for OpenMeetings plugin - refs BT#7046 refs #5491

1.9.x
Yannick Warnier 11 years ago
parent 09560313ef
commit 4736488e0b
  1. 72
      plugin/om_integration/lib/om_integration.lib.php
  2. 15
      plugin/om_integration/lib/om_integration_api.php
  3. 12
      plugin/om_integration/lib/om_integration_plugin.class.php

@ -1,4 +1,12 @@
<?php
/**
* Chamilo-OpenMeetings integration plugin library, defining methods to connect
* to OpenMeetings from Chamilo by calling its web services
* @package chamilo.plugin.openmeetings
*/
/**
* Initialization
*/
include_once 'services/getSession/getSession.class.php';
include_once 'services/loginUser/loginUser.class.php';
include_once 'services/addRoomWithModerationAndExternalType/addRoomWithModerationAndExternalType.class.php';
@ -9,7 +17,8 @@ include_once 'services/getRoomById/getRoomById.class.php';
/**
* Open Meetings-Chamilo connector class
*/
class om_integration {
class om_integration
{
var $url;
var $salt;
@ -25,8 +34,8 @@ class om_integration {
* Constructor (generates a connection to the API and the Chamilo settings
* required for the connection to the videoconference server)
*/
function __construct() {
function __construct()
{
// initialize video server settings from global settings
$plugin = om_integrationPlugin::create();
@ -57,14 +66,16 @@ class om_integration {
* 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 is_teacher()
{
return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
}
/**
* Login the user with OM Server
* @return bool True if the user is correct and false when is incorrect
*/
function loginUser() {
function loginUser()
{
try {
$objGetSession = new getSession();
$objloginUser = new loginUser();
@ -79,10 +90,11 @@ class om_integration {
$luFn = $omServices->loginUser($objloginUser);
if ( $luFn->return > 0 )
if ($luFn->return > 0) {
return true;
else
} else {
return false;
}
} else {
$this->sessionId = $_SESSION['sessOpenMeeting'];
return true;
@ -98,7 +110,8 @@ class om_integration {
* Creating a Room for the meeting
* @return bool True if the user is correct and false when is incorrect
*/
function create_meeting( $params ) {
function create_meeting($params)
{
//$id = Database::insert($this->table, $params);
try {
$objAddRoom = new addRoomWithModerationAndExternalType();
@ -151,8 +164,8 @@ class om_integration {
* @assert ('') === false
* @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
*/
function join_meeting($meetingid) {
function join_meeting($meetingid)
{
if (empty($meetingid)) {
return false;
}
@ -183,7 +196,6 @@ class om_integration {
'&allowRecording=1'*/;
printf("<iframe src='%s' width='%s' height = '%s' />", $iframe, "100%", 640);
}
/**
* Checks if the videoconference server is running.
@ -191,14 +203,16 @@ class om_integration {
* @return bool True if server is running, false otherwise
* @assert () === false
*/
function is_server_running() {
function is_server_running()
{
return true;
}
/**
* 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 get_user_meeting_password()
{
if ($this->is_teacher()) {
return $this->get_mod_meeting_password();
} else {
@ -209,7 +223,8 @@ class om_integration {
* Generated a moderator password for the meeting
* @return string A password for the moderation of the videoconference
*/
function get_mod_meeting_password() {
function get_mod_meeting_password()
{
return api_get_course_id().'mod';
}
/**
@ -218,7 +233,8 @@ class om_integration {
* @return mixed Array of information on success, false on error
* @assert (array()) === false
*/
function get_meeting_info($params) {
function get_meeting_info($params)
{
try {
$result = $this->api->getMeetingInfoArray($params);
if ($result == null) {
@ -231,7 +247,8 @@ class om_integration {
}
return false;
}
function setUserObjectAndGenerateRecordingHashByURL( $params ) {
function setUserObjectAndGenerateRecordingHashByURL( $params )
{
$username = $_SESSION['_user']['username'];
$firstname = $_SESSION['_user']['firstname'];
$lastname = $_SESSION['_user']['lastname'];
@ -253,10 +270,10 @@ class om_integration {
$orFn = $omServices->setUserObjectAndGenerateRecordingHashByURL( $objRec );
return $orFn->return;
}
function setUserObjectAndGenerateRoomHashByURLAndRecFlag( $params ) {
function setUserObjectAndGenerateRoomHashByURLAndRecFlag( $params )
{
$username = $_SESSION['_user']['username'];
$firstname = $_SESSION['_user']['firstname'];
@ -295,7 +312,8 @@ class om_integration {
* Gets all the course meetings saved in the plugin_bbb_meeting table
* @return array Array of current open meeting rooms
*/
function get_course_meetings() {
function get_course_meetings()
{
$new_meeting_list = array();
$item = array();
$pass = $this->get_user_meeting_password();
@ -352,12 +370,13 @@ class om_integration {
$meeting_om = $current_room;
if (empty( $meeting_om ))
if ($meeting_db['status'] == 1 && $this->is_teacher())
if (empty( $meeting_om )) {
if ($meeting_db['status'] == 1 && $this->is_teacher()) {
$this->end_meeting($meeting_db['id']);
else
}
} else {
$meeting_om['add_to_calendar_url'] = api_get_self().'?action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['startTime']);
}
$meeting_om['end_url'] = api_get_self().'?action=end&id='.$meeting_db['id'];
$record_array = array();
@ -425,7 +444,8 @@ class om_integration {
}
return $new_meeting_list;
}
function end_meeting( $meetingId ){
function end_meeting($meetingId )
{
try {
$this->loginUser();
$urlWsdl = CONFIG_OMSERVER_BASE_URL . "/services/RoomService?wsdl";
@ -435,9 +455,9 @@ class om_integration {
$objClose->room_id = $meetingId;
$objClose->status = false;
$crFn = $omServices->closeRoom( $objClose );
if( $crFn > 0 )
if ($crFn > 0) {
Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $meetingId));
}
} catch (SoapFault $e) {
echo "<h1>Warning</h1>
<p>We have detected some problems </br>

@ -1,13 +1,16 @@
<?php
class OpenMeetings {
class OpenMeetings
{
private $_securitySalt;
private $_omServerBaseUrl;
function __construct() {
function __construct()
{
$this->_securitySalt = CONFIG_SECURITY_SALT;
$this->_omServerBaseUrl = CONFIG_SERVER_BASE_URL;
}
function getMeetingInfoArray($infoParams) {
function getMeetingInfoArray($infoParams)
{
$xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams));
if ($xml) {
@ -19,8 +22,7 @@ class OpenMeetings {
'message' => $xml->message
);
return $result;
}
else {
} else {
// In this case, we have success and meeting info:
$result = array(
'returncode' => $xml->returncode,
@ -49,8 +51,7 @@ class OpenMeetings {
}
return $result;
}
}
else {
} else {
return null;
}

@ -9,16 +9,19 @@ class om_integrationPlugin extends Plugin
array('name' => 'om_button_record_and_store', 'type' => 'checkbox')
);
static function create() {
static function create()
{
static $result = null;
return $result ? $result : $result = new self();
}
protected function __construct() {
protected function __construct()
{
parent::__construct('2.0', 'Francis Gonzales', array('tool_enable' => 'boolean', 'host' =>'text', 'user' => 'text', 'pass' => 'text'));
}
function install() {
function install()
{
$table = Database::get_main_table('plugin_om_meeting');
$sql = "CREATE TABLE IF NOT EXISTS $table (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
@ -38,7 +41,8 @@ class om_integrationPlugin extends Plugin
$this->install_course_fields_in_all_courses();
}
function uninstall() {
function uninstall()
{
$t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);

Loading…
Cancel
Save