From a582da2c0560c5e68da6eb0c3a45751e117d6676 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 2 Jun 2014 11:56:47 +0200 Subject: [PATCH] Minor - format code. --- plugin/bbb/lib/bbb.lib.php | 105 +++++++++++++++++++--------- plugin/bbb/lib/bbb_plugin.class.php | 22 ++++-- 2 files changed, 87 insertions(+), 40 deletions(-) diff --git a/plugin/bbb/lib/bbb.lib.php b/plugin/bbb/lib/bbb.lib.php index e848193941..1c5706b7b0 100755 --- a/plugin/bbb/lib/bbb.lib.php +++ b/plugin/bbb/lib/bbb.lib.php @@ -1,29 +1,29 @@ plugin_enabled = true; } } + /** * 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() { + public function is_teacher() + { return api_is_course_admin() || api_is_coach() || api_is_platform_admin(); } @@ -94,7 +96,8 @@ class bbb { defaultMeetingCreateJoinDuration=5 * */ - function create_meeting($params) { + public function create_meeting($params) + { $params['c_id'] = api_get_course_int_id(); $course_code = api_get_course_id(); $params['session_id'] = api_get_session_id(); @@ -147,19 +150,31 @@ class bbb { return $this->logout; } } + /** - * Tells whether the given meeting exists and is running + * Tells whether the given meeting exists and is running * (using course code as name) * @param string Meeting name (usually the course code) * @return bool True if meeting exists, false otherwise * @assert ('') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false */ - function meeting_exists($meeting_name) { + public function meeting_exists($meeting_name) + { if (empty($meeting_name)) { return false; } $course_id = api_get_course_int_id(); $session_id = api_get_session_id(); - $meeting_data = Database::select('*', $this->table, array('where' => array('c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 ' => array($course_id, $session_id, $meeting_name))), 'first'); + $meeting_data = Database::select( + '*', + $this->table, + array( + 'where' => array( + 'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 ' => + array($course_id, $session_id, $meeting_name) + ) + ), + 'first' + ); if ($this->debug) error_log("meeting_exists ".print_r($meeting_data,1)); if (empty($meeting_data)) { return false; @@ -176,12 +191,14 @@ class bbb { * @assert ('') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false */ - function join_meeting($meeting_name) { + public function join_meeting($meeting_name) + { if (empty($meeting_name)) { return false; } $pass = $this->get_user_meeting_password(); $meeting_data = Database::select('*', $this->table, array('where' => array('meeting_name = ? AND status = 1 ' => $meeting_name)), 'first'); if (empty($meeting_data)) { if ($this->debug) error_log("meeting does not exist: $meeting_name "); + return false; } @@ -214,13 +231,15 @@ class bbb { if ($this->debug) error_log("return url :".$url); return $url; } + /** * Get information about the given meeting * @param array ...? * @return mixed Array of information on success, false on error * @assert (array()) === false */ - function get_meeting_info($params) { + public function get_meeting_info($params) + { try { $result = $this->api->getMeetingInfoWithXmlResponseArray($params); if ($result == null) { @@ -238,7 +257,8 @@ class bbb { * Gets all the course meetings saved in the plugin_bbb_meeting table * @return array Array of current open meeting rooms */ - function get_course_meetings() { + public function get_course_meetings() + { $pass = $this->get_user_meeting_password(); $meeting_list = Database::select('*', $this->table, array('where' => array('c_id = ? AND session_id = ? ' => array(api_get_course_int_id(), api_get_session_id())))); $new_meeting_list = array(); @@ -338,18 +358,23 @@ class bbb { } return $new_meeting_list; } + /** * Function disabled */ - function publish_meeting($id) { + public function publish_meeting($id) + { //return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt); } + /** * Function disabled */ - function unpublish_meeting($id) { + public function unpublish_meeting($id) + { //return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt); } + /** * Closes a meeting (usually when the user click on the close button from * the conferences listing. @@ -357,7 +382,8 @@ class bbb { * @return void * @assert (0) === false */ - function end_meeting($id) { + public function end_meeting($id) + { if (empty($id)) { return false; } $pass = $this->get_user_meeting_password(); $endParams = array( @@ -367,22 +393,26 @@ class bbb { $this->api->endMeetingWithXmlResponseArray($endParams); Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $id)); } + /** * 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() { + public function get_user_meeting_password() + { if ($this->is_teacher()) { return $this->get_mod_meeting_password(); } else { return api_get_course_id(); } } + /** * Generated a moderator password for the meeting * @return string A password for the moderation of the videoconference */ - function get_mod_meeting_password() { + public function get_mod_meeting_password() + { return api_get_course_id().'mod'; } @@ -391,7 +421,8 @@ class bbb { * @return int The number of users currently connected to the videoconference * @assert () > -1 */ - function get_users_online_in_current_room() { + public function get_users_online_in_current_room() + { $course_id = api_get_course_int_id(); $session_id = api_get_session_id(); $meeting_data = Database::select('*', $this->table, array('where' => array('c_id = ? AND session_id = ? AND status = 1 ' => array($course_id, $session_id))), 'first'); @@ -407,6 +438,7 @@ class bbb { } return 0; } + /** * Deletes a previous recording of a meeting * @param int integral ID of the recording @@ -414,12 +446,13 @@ class bbb { * @assert () === false * @todo Also delete links and agenda items created from this recording */ - function delete_record($ids) { + public function delete_record($ids) + { if (empty($ids) or (is_array($ids) && count($ids)==0)) { return false; } $recordingParams = array( /* - * NOTE: Set the recordId below to a valid id after you have - * created a recorded meeting, and received a real recordID + * NOTE: Set the recordId below to a valid id after you have + * created a recorded meeting, and received a real recordID * back from your BBB server using the * getRecordingsWithXmlResponseArray method. */ @@ -429,6 +462,7 @@ class bbb { ); return $this->api->deleteRecordingsWithXmlResponseArray($recordingParams); } + /** * Creates a link in the links tool from the given videoconference recording * @param int ID of the item in the plugin_bbb_meeting table @@ -438,7 +472,8 @@ class bbb { * @assert (1, null) === false * @assert (null, 'abcdefabcdefabcdefabcdef') === false */ - function copy_record_to_link_tool($id, $record_id) { + public function copy_record_to_link_tool($id, $record_id) + { if (empty($id) or empty($record_id)) { return false; } @@ -462,13 +497,15 @@ class bbb { } return false; } + /** * Checks if the videoconference server is running. * Function currently disabled (always returns 1) * @return bool True if server is running, false otherwise * @assert () === false */ - function is_server_running() { + public function is_server_running() + { return true; //return BigBlueButtonBN::isServerRunning($this->protocol.$this->url); } diff --git a/plugin/bbb/lib/bbb_plugin.class.php b/plugin/bbb/lib/bbb_plugin.class.php index 5e05b10803..9d0919ab5f 100755 --- a/plugin/bbb/lib/bbb_plugin.class.php +++ b/plugin/bbb/lib/bbb_plugin.class.php @@ -6,26 +6,35 @@ * main/img/icons/64/plugin_name.png * main/img/icons/64/plugin_name_na.png */ + +/** + * Class BBBPlugin + */ class BBBPlugin extends Plugin { public $isCoursePlugin = true; //When creating a new course this settings are added to the course public $course_settings = array( -// array('name' => 'big_blue_button_welcome_message', 'type' => 'text'), - array('name' => 'big_blue_button_record_and_store', 'type' => 'checkbox') + array( + 'name' => 'big_blue_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.1', 'Julio Montoya, Yannick Warnier', array('tool_enable' => 'boolean', 'host' =>'text', 'salt' => 'text')); } - function install() { + public function install() + { $table = Database::get_main_table('plugin_bbb_meeting'); $sql = "CREATE TABLE IF NOT EXISTS $table ( id INT unsigned NOT NULL auto_increment PRIMARY KEY, @@ -46,7 +55,8 @@ class BBBPlugin extends Plugin $this->install_course_fields_in_all_courses(); } - function uninstall() { + public 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);