Update plugin with sedra changes

pull/2487/head
jmontoyaa 9 years ago
parent e1a3c19d84
commit 5562832a4c
  1. 8
      plugin/bbb/changelog.md
  2. 1
      plugin/bbb/lang/english.php
  3. 96
      plugin/bbb/lib/bbb.lib.php
  4. 4
      plugin/bbb/lib/bbb_plugin.class.php
  5. 6
      plugin/bbb/listing.php
  6. 2
      plugin/bbb/readme.txt
  7. 3
      plugin/bbb/start.php

@ -1,4 +1,10 @@
Version 2.4 2016-05 Version 2.5 - 2016-07
---------------------
* User global conference support
* Requires a database change: "ALTER TABLE plugin_bbb_meeting ADD COLUMN user_id INT DEFAULT 0"
* Requires a database change: "ALTER TABLE plugin_bbb_meeting ADD COLUMN access_url INT DEFAULT 0"
Version 2.4 - 2016-05
------------------------ ------------------------
Changes: Changes:

@ -46,6 +46,7 @@ $strings['tool_enable_help'] = "Choose whether you want to enable the BigBlueBut
$strings['big_blue_button_welcome_message'] = 'Welcome message'; $strings['big_blue_button_welcome_message'] = 'Welcome message';
$strings['enable_global_conference'] = 'Enable global conference'; $strings['enable_global_conference'] = 'Enable global conference';
$strings['enable_global_conference_per_user'] = 'Enable global conference per user';
$strings['enable_conference_in_course_groups'] = 'Enable conference in course groups'; $strings['enable_conference_in_course_groups'] = 'Enable conference in course groups';
$strings['enable_global_conference_link'] = 'Enable the link to the global conference in the homepage'; $strings['enable_global_conference_link'] = 'Enable the link to the global conference in the homepage';

@ -26,10 +26,12 @@ class bbb
public $logoutUrl = ''; public $logoutUrl = '';
public $pluginEnabled = false; public $pluginEnabled = false;
public $enableGlobalConference = false; public $enableGlobalConference = false;
public $enableGlobalConferencePerUser = false;
public $isGlobalConference = false; public $isGlobalConference = false;
public $groupSupport = false; public $groupSupport = false;
public $table; public $userSupport = false;
public $accessUrl = 1; public $accessUrl = 1;
public $userId = 0;
/** /**
* Constructor (generates a connection to the API and the Chamilo settings * Constructor (generates a connection to the API and the Chamilo settings
@ -37,8 +39,9 @@ class bbb
* @param string $host * @param string $host
* @param string $salt * @param string $salt
* @param bool $isGlobalConference * @param bool $isGlobalConference
* @param int $isGlobalPerUser
*/ */
public function __construct($host = '', $salt = '', $isGlobalConference = false) public function __construct($host = '', $salt = '', $isGlobalConference = false, $isGlobalPerUser = 0)
{ {
// Initialize video server settings from global settings // Initialize video server settings from global settings
$plugin = BBBPlugin::create(); $plugin = BBBPlugin::create();
@ -50,20 +53,24 @@ class bbb
$this->logoutUrl = $this->getListingUrl(); $this->logoutUrl = $this->getListingUrl();
$this->table = Database::get_main_table('plugin_bbb_meeting'); $this->table = Database::get_main_table('plugin_bbb_meeting');
$this->enableGlobalConference = (bool) $plugin->get('enable_global_conference');
$this->enableGlobalConference = $plugin->get('enable_global_conference');
$this->isGlobalConference = (bool) $isGlobalConference; $this->isGlobalConference = (bool) $isGlobalConference;
$columns = Database::listTableColumns($this->table); $columns = Database::listTableColumns($this->table);
$this->groupSupport = isset($columns['group_id']) ? true : false; $this->groupSupport = isset($columns['group_id']) ? true : false;
$this->userSupport = isset($columns['user_id']) ? true : false;
$this->accessUrl = api_get_current_access_url_id(); $this->accessUrl = api_get_current_access_url_id();
if ($this->userSupport && !empty($isGlobalPerUser)) {
$this->enableGlobalConferencePerUser = (bool) $plugin->get('enable_global_conference_per_user');
$this->userId = $isGlobalPerUser;
} else {
$this->enableGlobalConferencePerUser = false;
}
if ($this->groupSupport) { if ($this->groupSupport) {
// Plugin check // Plugin check
$this->groupSupport = (bool) $plugin->get('enable_conference_in_course_groups'); $this->groupSupport = (bool) $plugin->get('enable_conference_in_course_groups');
if ($this->groupSupport) { if ($this->groupSupport) {
// Platform check // Platform check
@ -105,7 +112,15 @@ class bbb
*/ */
public function isGlobalConferenceEnabled() public function isGlobalConferenceEnabled()
{ {
return (bool) $this->enableGlobalConference; return $this->enableGlobalConference;
}
/**
* @return bool
*/
public function isGlobalConferencePerUserEnabled()
{
return $this->enableGlobalConferencePerUser;
} }
/** /**
@ -181,8 +196,14 @@ class bbb
$params['group_id'] = api_get_group_id(); $params['group_id'] = api_get_group_id();
} }
$courseCode = is_null($courseCode) ? '' : $courseCode; if ($this->isGlobalConferencePerUserEnabled()) {
$params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $courseCode; $currentUserId = api_get_user_id();
if ($this->userId === $currentUserId) {
$params['user_id'] = $this->userId;
}
}
$params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getUserMeetingPassword();
$attendeePassword = $params['attendee_pw']; $attendeePassword = $params['attendee_pw'];
$params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword(); $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword();
$moderatorPassword = $params['moderator_pw']; $moderatorPassword = $params['moderator_pw'];
@ -485,6 +506,9 @@ class bbb
public function getMeetings() public function getMeetings()
{ {
$pass = $this->getUserMeetingPassword(); $pass = $this->getUserMeetingPassword();
$isGlobal = $this->isGlobalConference();
$isGlobalPerUser = $this->isGlobalConferencePerUserEnabled();
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$sessionId = api_get_session_id(); $sessionId = api_get_session_id();
@ -508,6 +532,15 @@ class bbb
); );
} }
if ($isGlobalPerUser) {
$conditions = array(
'where' => array(
'user_id = ? AND access_url = ?' =>
array($this->userId, $this->accessUrl)
)
);
}
$meetingList = Database::select( $meetingList = Database::select(
'*', '*',
$this->table, $this->table,
@ -804,6 +837,11 @@ class bbb
return $this->getModMeetingPassword(); return $this->getModMeetingPassword();
} else { } else {
if ($this->isGlobalConferencePerUserEnabled()) {
return 'url_'.$this->userId.'_'.api_get_current_access_url_id();
}
if ($this->isGlobalConference()) { if ($this->isGlobalConference()) {
return 'url_'.api_get_current_access_url_id(); return 'url_'.api_get_current_access_url_id();
@ -819,6 +857,11 @@ class bbb
*/ */
public function getModMeetingPassword() public function getModMeetingPassword()
{ {
if ($this->isGlobalConferencePerUserEnabled()) {
return 'url_'.$this->userId.'_'.api_get_current_access_url_id().'_mod';
}
if ($this->isGlobalConference()) { if ($this->isGlobalConference()) {
return 'url_'.api_get_current_access_url_id().'_mod'; return 'url_'.api_get_current_access_url_id().'_mod';
@ -860,6 +903,18 @@ class bbb
), ),
); );
} }
if ($this->isGlobalConferencePerUserEnabled()) {
$conditions = array(
'where' => array(
'user_id = ? AND status = 1 AND access_url = ?' => array(
$this->userId,
$this->accessUrl
),
),
);
}
$meetingData = Database::select( $meetingData = Database::select(
'*', '*',
$this->table, $this->table,
@ -893,7 +948,7 @@ class bbb
/** /**
* Deletes a previous recording of a meeting * Deletes a previous recording of a meeting
* @param int integral ID of the recording * @param int $id ID of the recording
* @return array ? * @return array ?
* @assert () === false * @assert () === false
* @todo Also delete links and agenda items created from this recording * @todo Also delete links and agenda items created from this recording
@ -901,6 +956,7 @@ class bbb
public function deleteRecord($id) public function deleteRecord($id)
{ {
if (empty($id)) { if (empty($id)) {
return false; return false;
} }
@ -925,7 +981,7 @@ class bbb
$result = $this->api->deleteRecordingsWithXmlResponseArray($recordingParams); $result = $this->api->deleteRecordingsWithXmlResponseArray($recordingParams);
if (!empty($result) && isset($result['deleted']) && $result['deleted'] == 'true') { if (!empty($result) && isset($result['deleted']) && $result['deleted'] === 'true') {
Database::delete( Database::delete(
$this->table, $this->table,
array('id = ?' => array($id)) array('id = ?' => array($id))
@ -937,7 +993,7 @@ class bbb
/** /**
* Creates a link in the links tool from the given videoconference recording * Creates a link in the links tool from the given videoconference recording
* @param int ID of the item in the plugin_bbb_meeting table * @param int $id ID of the item in the plugin_bbb_meeting table
* @param string Hash identifying the recording, as provided by the API * @param string Hash identifying the recording, as provided by the API
* @return mixed ID of the newly created link, or false on error * @return mixed ID of the newly created link, or false on error
* @assert (null, null) === false * @assert (null, null) === false
@ -970,6 +1026,7 @@ class bbb
$params['url'] = $url; $params['url'] = $url;
$params['title'] = $meetingData['meeting_name']; $params['title'] = $meetingData['meeting_name'];
$id = $link->save($params); $id = $link->save($params);
return $id; return $id;
} }
} }
@ -1030,7 +1087,14 @@ class bbb
if (empty($courseInfo)) { if (empty($courseInfo)) {
if ($this->isGlobalConferencePerUserEnabled()) {
return 'global=1&user_id='.$this->userId;
}
if ($this->isGlobalConference()) { if ($this->isGlobalConference()) {
return 'global=1'; return 'global=1';
} }
@ -1045,7 +1109,13 @@ class bbb
*/ */
public function getCurrentVideoConferenceName() public function getCurrentVideoConferenceName()
{ {
if ($this->isGlobalConferencePerUserEnabled()) {
return 'url_'.$this->userId.'_'.api_get_current_access_url_id();
}
if ($this->isGlobalConference()) { if ($this->isGlobalConference()) {
return 'url_'.api_get_current_access_url_id(); return 'url_'.api_get_current_access_url_id();
} }

@ -34,13 +34,14 @@ class BBBPlugin extends Plugin
protected function __construct() protected function __construct()
{ {
parent::__construct( parent::__construct(
'2.4', '2.5',
'Julio Montoya, Yannick Warnier', 'Julio Montoya, Yannick Warnier',
[ [
'tool_enable' => 'boolean', 'tool_enable' => 'boolean',
'host' => 'text', 'host' => 'text',
'salt' => 'text', 'salt' => 'text',
'enable_global_conference' => 'boolean', 'enable_global_conference' => 'boolean',
'enable_global_conference_per_user' => 'boolean',
'enable_conference_in_course_groups' => 'boolean', 'enable_conference_in_course_groups' => 'boolean',
'enable_global_conference_link' => 'boolean' 'enable_global_conference_link' => 'boolean'
] ]
@ -84,6 +85,7 @@ class BBBPlugin extends Plugin
id INT unsigned NOT NULL auto_increment PRIMARY KEY, id INT unsigned NOT NULL auto_increment PRIMARY KEY,
c_id INT unsigned NOT NULL DEFAULT 0, c_id INT unsigned NOT NULL DEFAULT 0,
group_id INT unsigned NOT NULL DEFAULT 0, group_id INT unsigned NOT NULL DEFAULT 0,
user_id INT unsigned NOT NULL DEFAULT 0,
meeting_name VARCHAR(255) NOT NULL DEFAULT '', meeting_name VARCHAR(255) NOT NULL DEFAULT '',
attendee_pw VARCHAR(255) NOT NULL DEFAULT '', attendee_pw VARCHAR(255) NOT NULL DEFAULT '',
moderator_pw VARCHAR(255) NOT NULL DEFAULT '', moderator_pw VARCHAR(255) NOT NULL DEFAULT '',

@ -11,9 +11,9 @@ $plugin = BBBPlugin::create();
$tool_name = $plugin->get_lang('Videoconference'); $tool_name = $plugin->get_lang('Videoconference');
$isGlobal = isset($_GET['global']) ? true : false; $isGlobal = isset($_GET['global']) ? true : false;
$isGlobalPerUser = isset($_GET['user_id']) ? (int) $_GET['user_id']: false;
$bbb = new bbb('', '', $isGlobal); $bbb = new bbb('', '', $isGlobal, $isGlobalPerUser);
$action = isset($_GET['action']) ? $_GET['action'] : null; $action = isset($_GET['action']) ? $_GET['action'] : null;
$conferenceManager = $bbb->isConferenceManager(); $conferenceManager = $bbb->isConferenceManager();
@ -105,6 +105,7 @@ if ($conferenceManager) {
break; break;
} }
} }
$meetings = $bbb->getMeetings(); $meetings = $bbb->getMeetings();
if (!empty($meetings)) { if (!empty($meetings)) {
$meetings = array_reverse($meetings); $meetings = array_reverse($meetings);
@ -163,6 +164,7 @@ if ($bbb->isGlobalConference() === false &&
$tpl = new Template($tool_name); $tpl = new Template($tool_name);
$tpl->assign('allow_to_edit', $conferenceManager); $tpl->assign('allow_to_edit', $conferenceManager);
$tpl->assign('meetings', $meetings); $tpl->assign('meetings', $meetings);
$tpl->assign('conference_url', $conferenceUrl); $tpl->assign('conference_url', $conferenceUrl);
$tpl->assign('users_online', $users_online); $tpl->assign('users_online', $users_online);
$tpl->assign('bbb_status', $status); $tpl->assign('bbb_status', $status);

@ -1,2 +0,0 @@
This plugin will create a link in existing and new courses for the teachers to start a videoconference room,
as well as the administration settings to configure this tool.

@ -16,7 +16,8 @@ $vmIsEnabled = false;
$host = ''; $host = '';
$salt = ''; $salt = '';
$isGlobal = isset($_GET['global']) ? true : false; $isGlobal = isset($_GET['global']) ? true : false;
$bbb = new bbb('', '', $isGlobal); $isGlobalPerUser = isset($_GET['user_id']) ? (int) $_GET['user_id']: false;
$bbb = new bbb('', '', $isGlobal, $isGlobalPerUser);
if ($bbb->pluginEnabled) { if ($bbb->pluginEnabled) {
if ($bbb->isServerRunning()) { if ($bbb->isServerRunning()) {

Loading…
Cancel
Save