Add option "global_conference_allow_roles" see BT#12620

- Global conference link only visible for this user roles.
pull/2487/head
jmontoyaa 8 years ago
parent 6dd4e05860
commit 28a1ab4349
  1. 8
      main/admin/configure_plugin.php
  2. 2
      main/admin/settings.php
  3. 12
      main/inc/lib/api.lib.php
  4. 47
      main/inc/lib/plugin.class.php
  5. 14
      main/inc/lib/plugin.lib.php
  6. 33
      main/inc/lib/userportal.lib.php
  7. 3
      plugin/bbb/cron.php
  8. 1
      plugin/bbb/lang/english.php
  9. 1
      plugin/bbb/lang/french.php
  10. 89
      plugin/bbb/lib/bbb.lib.php
  11. 55
      plugin/bbb/lib/bbb_plugin.class.php

@ -22,7 +22,6 @@ if (!in_array($pluginName, $installedPlugins) || empty($pluginInfo)) {
api_not_allowed(true); api_not_allowed(true);
} }
global $_configuration;
$content = ''; $content = '';
$currentUrl = api_get_self()."?name=$pluginName"; $currentUrl = api_get_self()."?name=$pluginName";
@ -33,7 +32,6 @@ if (isset($pluginInfo['settings_form'])) {
// We override the form attributes // We override the form attributes
$attributes = array('action' => $currentUrl, 'method' => 'POST'); $attributes = array('action' => $currentUrl, 'method' => 'POST');
$form->updateAttributes($attributes); $form->updateAttributes($attributes);
if (isset($pluginInfo['settings'])) { if (isset($pluginInfo['settings'])) {
$form->setDefaults($pluginInfo['settings']); $form->setDefaults($pluginInfo['settings']);
} }
@ -58,13 +56,12 @@ if (isset($form)) {
$accessUrlId, $accessUrlId,
$pluginName, $pluginName,
'setting', 'setting',
"status" 'status'
) )
) )
); );
foreach ($values as $key => $value) { foreach ($values as $key => $value) {
$value = trim($value);
api_add_setting( api_add_setting(
$value, $value,
Database::escape_string($pluginName.'_'.$key), Database::escape_string($pluginName.'_'.$key),
@ -75,7 +72,7 @@ if (isset($form)) {
'', '',
'', '',
'', '',
$_configuration['access_url'], api_get_current_access_url_id(),
1 1
); );
} }
@ -112,4 +109,3 @@ $interbreadcrumb[] = array(
$tpl = new Template($pluginName, true, true, false, true, false); $tpl = new Template($pluginName, true, true, false, true, false);
$tpl->assign('content', $content); $tpl->assign('content', $content);
$tpl->display_one_col_template(); $tpl->display_one_col_template();

@ -150,7 +150,7 @@ if (!empty($_GET['category']) &&
} }
} }
} }
//Reload settings // Reload settings
$settings_array = getCategorySettings($my_category); $settings_array = getCategorySettings($my_category);
$settings = $settings_array['settings']; $settings = $settings_array['settings'];
$settings_by_access_list = $settings_array['settings_by_access_list']; $settings_by_access_list = $settings_array['settings_by_access_list'];

@ -2443,7 +2443,11 @@ function api_get_plugin_setting($plugin, $variable)
$result = api_get_setting($variableName); $result = api_get_setting($variableName);
if (isset($result[$plugin])) { if (isset($result[$plugin])) {
return $result[$plugin]; $value = $result[$plugin];
if (@unserialize($value) !== false) {
$value = unserialize($value);
}
return $value;
} }
return null; return null;
@ -5360,6 +5364,12 @@ function api_add_setting(
$settingRepo = $em->getRepository('ChamiloCoreBundle:SettingsCurrent'); $settingRepo = $em->getRepository('ChamiloCoreBundle:SettingsCurrent');
$accessUrlId = (int) $accessUrlId ?: 1; $accessUrlId = (int) $accessUrlId ?: 1;
if (is_array($value)) {
$value = serialize($value);
} else {
$value = trim($value);
}
$criteria = ['variable' => $variable, 'accessUrl' => $accessUrlId]; $criteria = ['variable' => $variable, 'accessUrl' => $accessUrlId];
if (!empty($subKey)) { if (!empty($subKey)) {

@ -19,6 +19,9 @@ use Chamilo\CourseBundle\Entity\CTool;
*/ */
class Plugin class Plugin
{ {
const TAB_FILTER_NO_STUDENT = '::no-student';
const TAB_FILTER_ONLY_STUDENT = '::only-student';
protected $version = ''; protected $version = '';
protected $author = ''; protected $author = '';
protected $fields = []; protected $fields = [];
@ -51,9 +54,6 @@ class Plugin
*/ */
public $course_settings_callback = false; public $course_settings_callback = false;
const TAB_FILTER_NO_STUDENT = '::no-student';
const TAB_FILTER_ONLY_STUDENT = '::only-student';
/** /**
* Default constructor for the plugin class. By default, it only sets * Default constructor for the plugin class. By default, it only sets
* a few attributes of the object * a few attributes of the object
@ -204,6 +204,7 @@ class Plugin
foreach ($this->fields as $name => $type) { foreach ($this->fields as $name => $type) {
$options = null; $options = null;
if (is_array($type) && isset($type['type']) && $type['type'] === 'select') { if (is_array($type) && isset($type['type']) && $type['type'] === 'select') {
$attributes = isset($type['attributes']) ? $type['attributes'] : [];
$options = $type['options']; $options = $type['options'];
$type = $type['type']; $type = $type['type'];
} }
@ -235,8 +236,20 @@ class Plugin
break; break;
case 'boolean': case 'boolean':
$group = array(); $group = array();
$group[] = $result->createElement('radio', $name, '', get_lang('Yes'), 'true'); $group[] = $result->createElement(
$group[] = $result->createElement('radio', $name, '', get_lang('No'), 'false'); 'radio',
$name,
'',
get_lang('Yes'),
'true'
);
$group[] = $result->createElement(
'radio',
$name,
'',
get_lang('No'),
'false'
);
$result->addGroup($group, null, array($this->get_lang($name), $help)); $result->addGroup($group, null, array($this->get_lang($name), $help));
break; break;
case 'checkbox': case 'checkbox':
@ -261,14 +274,19 @@ class Plugin
$type, $type,
$name, $name,
array($this->get_lang($name), $help), array($this->get_lang($name), $help),
$options $options,
$attributes
); );
break; break;
} }
} }
if (!empty($checkboxGroup)) { if (!empty($checkboxGroup)) {
$result->addGroup($checkboxGroup, null, array($this->get_lang('sms_types'), $help)); $result->addGroup(
$checkboxGroup,
null,
array($this->get_lang('sms_types'), $help)
);
} }
$result->setDefaults($defaults); $result->setDefaults($defaults);
$result->addButtonSave($this->get_lang('Save'), 'submit_button'); $result->addButtonSave($this->get_lang('Save'), 'submit_button');
@ -287,6 +305,12 @@ class Plugin
$settings = $this->get_settings(); $settings = $this->get_settings();
foreach ($settings as $setting) { foreach ($settings as $setting) {
if ($setting['variable'] == $this->get_name().'_'.$name) { if ($setting['variable'] == $this->get_name().'_'.$name) {
if (!empty($setting['selected_value']) &&
@unserialize($setting['selected_value']) !== false
) {
$setting['selected_value'] = unserialize($setting['selected_value']);
}
return $setting['selected_value']; return $setting['selected_value'];
} }
} }
@ -304,7 +328,12 @@ class Plugin
if (empty($this->settings) || $forceFromDB) { if (empty($this->settings) || $forceFromDB) {
$settings = api_get_settings_params( $settings = api_get_settings_params(
array( array(
"subkey = ? AND category = ? AND type = ? " => array($this->get_name(), 'Plugins', 'setting') "subkey = ? AND category = ? AND type = ? AND access_url = ?" => array(
$this->get_name(),
'Plugins',
'setting',
api_get_current_access_url_id()
)
) )
); );
$this->settings = $settings; $this->settings = $settings;
@ -334,7 +363,6 @@ class Plugin
{ {
// Check whether the language strings for the plugin have already been // Check whether the language strings for the plugin have already been
// loaded. If so, no need to load them again. // loaded. If so, no need to load them again.
if (is_null($this->strings)) { if (is_null($this->strings)) {
global $language_interface; global $language_interface;
$root = api_get_path(SYS_PLUGIN_PATH); $root = api_get_path(SYS_PLUGIN_PATH);
@ -369,7 +397,6 @@ class Plugin
$parentPath = "{$root}{$plugin_name}/lang/{$languageParentFolder}.php"; $parentPath = "{$root}{$plugin_name}/lang/{$languageParentFolder}.php";
if (is_readable($parentPath)) { if (is_readable($parentPath)) {
include $parentPath; include $parentPath;
if (!empty($strings)) { if (!empty($strings)) {
foreach ($strings as $key => $string) { foreach ($strings as $key => $string) {
$this->strings[$key] = $string; $this->strings[$key] = $string;

@ -419,19 +419,29 @@ class AppPlugin
$plugin_info = array(); $plugin_info = array();
if (file_exists($plugin_file)) { if (file_exists($plugin_file)) {
require $plugin_file; require $plugin_file;
} }
// @todo check if settings are already added
// Extra options // Extra options
$plugin_settings = api_get_settings_params( $plugin_settings = api_get_settings_params(
array( array(
"subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins', 'setting') "subkey = ? AND category = ? AND type = ? AND access_url = ?" => array(
$plugin_name,
'Plugins',
'setting',
api_get_current_access_url_id()
)
) )
); );
$settings_filtered = array(); $settings_filtered = array();
foreach ($plugin_settings as $item) { foreach ($plugin_settings as $item) {
if (!empty($item['selected_value'])) {
if (@unserialize($item['selected_value']) !== false) {
$item['selected_value'] = unserialize($item['selected_value']);
}
}
$settings_filtered[$item['variable']] = $item['selected_value']; $settings_filtered[$item['variable']] = $item['selected_value'];
} }
$plugin_info['settings'] = $settings_filtered; $plugin_info['settings'] = $settings_filtered;

@ -883,28 +883,26 @@ class IndexManager
*/ */
public function return_profile_block() public function return_profile_block()
{ {
global $_configuration; $userInfo = api_get_user_info();
$user_id = api_get_user_id(); $userId = api_get_user_id();
if (empty($userId)) {
if (empty($user_id)) {
return; return;
} }
$items = []; $items = [];
$userGroup = new UserGroup(); $userGroup = new UserGroup();
// @todo Add a platform setting to add the user image. // @todo Add a platform setting to add the user image.
if (api_get_setting('allow_message_tool') == 'true') { if (api_get_setting('allow_message_tool') == 'true') {
// New messages. // New messages.
$number_of_new_messages = MessageManager::getCountNewMessages(); $number_of_new_messages = MessageManager::getCountNewMessages();
// New contact invitations. // New contact invitations.
$number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id( $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(
api_get_user_id() $userId
); );
// New group invitations sent by a moderator. // New group invitations sent by a moderator.
$group_pending_invitations = $userGroup->get_groups_by_user( $group_pending_invitations = $userGroup->get_groups_by_user(
api_get_user_id(), $userId,
GROUP_USER_PERMISSION_PENDING_INVITATION, GROUP_USER_PERMISSION_PENDING_INVITATION,
false false
); );
@ -939,7 +937,7 @@ class IndexManager
]; ];
} }
if (isset($_configuration['allow_my_files_link_in_homepage']) && $_configuration['allow_my_files_link_in_homepage']) { if (api_get_configuration_value('allow_my_files_link_in_homepage')) {
if (api_get_setting('allow_my_files') !== 'false') { if (api_get_setting('allow_my_files') !== 'false') {
$items[] = [ $items[] = [
'class' => 'myfiles-social', 'class' => 'myfiles-social',
@ -954,11 +952,13 @@ class IndexManager
$items[] = [ $items[] = [
'class' => 'profile-social', 'class' => 'profile-social',
'icon' => Display::return_icon('edit-profile.png', get_lang('EditProfile')), 'icon' => Display::return_icon('edit-profile.png', get_lang('EditProfile')),
'link' => Display::getProfileEditionLink($user_id), 'link' => Display::getProfileEditionLink($userId),
'title' => get_lang('EditProfile') 'title' => get_lang('EditProfile')
]; ];
if (api_get_configuration_value('show_link_request_hrm_user') && api_is_drh()) { if (api_get_configuration_value('show_link_request_hrm_user') &&
api_is_drh()
) {
$label = get_lang('RequestLinkingToUser'); $label = get_lang('RequestLinkingToUser');
$items[] = [ $items[] = [
'icon' => Display::return_icon('new_group.png', $label), 'icon' => Display::return_icon('new_group.png', $label),
@ -967,14 +967,14 @@ class IndexManager
]; ];
} }
$setting = api_get_plugin_setting('bbb', 'enable_global_conference'); if (bbb::showGlobalConferenceLink($userInfo)) {
$settingLink = api_get_plugin_setting('bbb', 'enable_global_conference_link');
if ($setting === 'true' && $settingLink === 'true') {
$url = api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?global=1'; $url = api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?global=1';
//$content = Display::url(get_lang('LaunchVideoConferenceRoom'), $url);
$items[] = [ $items[] = [
'class' => 'video-conference', 'class' => 'video-conference',
'icon' => Display::return_icon('bbb.png', get_lang('VideoConference')), 'icon' => Display::return_icon(
'bbb.png',
get_lang('VideoConference')
),
'link' => $url, 'link' => $url,
'title' => get_lang('VideoConference') 'title' => get_lang('VideoConference')
]; ];
@ -1121,7 +1121,6 @@ class IndexManager
private static function returnRightBlockItems(array $items) private static function returnRightBlockItems(array $items)
{ {
$my_account_content = ''; $my_account_content = '';
foreach ($items as $item) { foreach ($items as $item) {
if (empty($item['link']) && empty($item['title'])) { if (empty($item['link']) && empty($item['title'])) {
continue; continue;
@ -1139,6 +1138,8 @@ class IndexManager
/** /**
* Prints the session and course list (user_portal.php) * Prints the session and course list (user_portal.php)
* @param int $user_id * @param int $user_id
* @param bool $showSessions
* @param string $categoryCodeFilter
* @return string * @return string
*/ */
public function returnCoursesAndSessions($user_id, $showSessions = true, $categoryCodeFilter = '') public function returnCoursesAndSessions($user_id, $showSessions = true, $categoryCodeFilter = '')

@ -1,9 +1,8 @@
<?php <?php
/* For license terms, see /license.txt */ /* For license terms, see /license.txt */
require __DIR__.'/../../vendor/autoload.php'; require_once __DIR__.'/../../vendor/autoload.php';
if (file_exists(__DIR__.'/config.vm.php')) { if (file_exists(__DIR__.'/config.vm.php')) {
require_once __DIR__.'/config.php'; require_once __DIR__.'/config.php';
require __DIR__.'/lib/vm/AbstractVM.php'; require __DIR__.'/lib/vm/AbstractVM.php';

@ -66,3 +66,4 @@ $strings['MaxXUsersWarning'] = 'This conference room has a maximum number of %s
$strings['MaxXUsersReached'] = 'The limit of %s simultaneous users has been reached for this conference room. Please wait for one seat to be freed or for another conference to start in order to join.'; $strings['MaxXUsersReached'] = 'The limit of %s simultaneous users has been reached for this conference room. Please wait for one seat to be freed or for another conference to start in order to join.';
$strings['MaxXUsersReachedManager'] = 'The limit of %s simultaneous users has been reached for this conference room. To increase this limit, please contact the platform administrator.'; $strings['MaxXUsersReachedManager'] = 'The limit of %s simultaneous users has been reached for this conference room. To increase this limit, please contact the platform administrator.';
$strings['MaxUsersInConferenceRoom'] = 'Max simultaneous users in a conference room'; $strings['MaxUsersInConferenceRoom'] = 'Max simultaneous users in a conference room';
$strings['global_conference_allow_roles'] = "Global conference link only visible for this user roles";

@ -48,3 +48,4 @@ $strings['MaxXUsersWarning'] = 'Cette salle de conférence est limitée à %s ut
$strings['MaxXUsersReached'] = 'La limite de %s utilisateurs simultanés a été atteinte dans cette salle de conférence. Veuillez rafraîchir dans quelque minutes pour voir si un siège s\'est libéré, ou attendre l\'ouverture d\'une nouvelle salle de conférence pour participer.'; $strings['MaxXUsersReached'] = 'La limite de %s utilisateurs simultanés a été atteinte dans cette salle de conférence. Veuillez rafraîchir dans quelque minutes pour voir si un siège s\'est libéré, ou attendre l\'ouverture d\'une nouvelle salle de conférence pour participer.';
$strings['MaxXUsersReachedManager'] = 'La limite de %s utilisateurs simultanés a été atteinte dans cette salle de conférence. Pour augmenter la limite, prenez contact avec l\'administrateur du portail.'; $strings['MaxXUsersReachedManager'] = 'La limite de %s utilisateurs simultanés a été atteinte dans cette salle de conférence. Pour augmenter la limite, prenez contact avec l\'administrateur du portail.';
$strings['MaxUsersInConferenceRoom'] = 'Nombre max d\'utilisateurs simultanés dans une salle de conférence'; $strings['MaxUsersInConferenceRoom'] = 'Nombre max d\'utilisateurs simultanés dans une salle de conférence';
$strings['global_conference_allow_roles'] = "Visibilité du lien de vidéo conférence global pour les profils suivant";

@ -47,8 +47,12 @@ class bbb
* @param bool $isGlobalConference * @param bool $isGlobalConference
* @param int $isGlobalPerUser * @param int $isGlobalPerUser
*/ */
public function __construct($host = '', $salt = '', $isGlobalConference = false, $isGlobalPerUser = 0) public function __construct(
{ $host = '',
$salt = '',
$isGlobalConference = false,
$isGlobalPerUser = 0
) {
$this->courseCode = api_get_course_id(); $this->courseCode = api_get_course_id();
$this->courseId = api_get_course_int_id(); $this->courseId = api_get_course_int_id();
$this->sessionId = api_get_session_id(); $this->sessionId = api_get_session_id();
@ -83,7 +87,6 @@ class bbb
// Plugin check // Plugin check
$this->groupSupport = (bool) $this->plugin->get('enable_conference_in_course_groups'); $this->groupSupport = (bool) $this->plugin->get('enable_conference_in_course_groups');
if ($this->groupSupport) { if ($this->groupSupport) {
// Platform check // Platform check
$bbbSetting = api_get_setting('bbb_enable_conference_in_course_groups'); $bbbSetting = api_get_setting('bbb_enable_conference_in_course_groups');
$bbbSetting = isset($bbbSetting['bbb']) ? $bbbSetting['bbb'] === 'true' : false; $bbbSetting = isset($bbbSetting['bbb']) ? $bbbSetting['bbb'] === 'true' : false;
@ -209,7 +212,8 @@ class bbb
* This value can be overridden by course-specific values * This value can be overridden by course-specific values
* @return int Maximum number of users set globally * @return int Maximum number of users set globally
*/ */
public function getMaxUsersLimit() { public function getMaxUsersLimit()
{
$limit = $this->maxUsersLimit; $limit = $this->maxUsersLimit;
if ($limit <= 0) { if ($limit <= 0) {
$limit = 0; $limit = 0;
@ -248,11 +252,13 @@ class bbb
} }
return $limit; return $limit;
} }
/** /**
* Sets the global limit of users in a video-conference room. * Sets the global limit of users in a video-conference room.
* @param int Maximum number of users (globally) * @param int Maximum number of users (globally)
*/ */
public function setMaxUsersLimit($max) { public function setMaxUsersLimit($max)
{
if ($max < 0) { if ($max < 0) {
$max = 0; $max = 0;
} }
@ -422,7 +428,6 @@ class bbb
public function meetingExists($meetingName) public function meetingExists($meetingName)
{ {
if (empty($meetingName)) { if (empty($meetingName)) {
return false; return false;
} }
@ -440,7 +445,13 @@ class bbb
$conditions = array( $conditions = array(
'where' => array( 'where' => array(
'c_id = ? AND session_id = ? AND meeting_name = ? AND group_id = ? AND status = 1 AND access_url = ?' => 'c_id = ? AND session_id = ? AND meeting_name = ? AND group_id = ? AND status = 1 AND access_url = ?' =>
array($courseId, $sessionId, $meetingName, $groupId, $this->accessUrl) array(
$courseId,
$sessionId,
$meetingName,
$groupId,
$this->accessUrl
)
) )
); );
} }
@ -458,7 +469,6 @@ class bbb
} }
if (empty($meetingData)) { if (empty($meetingData)) {
return false; return false;
} else { } else {
return true; return true;
@ -489,7 +499,14 @@ class bbb
$meetingData = Database::select( $meetingData = Database::select(
'*', '*',
$this->table, $this->table,
array('where' => array('meeting_name = ? AND status = 1 AND access_url = ?' => array($meetingName, $this->accessUrl))), array(
'where' => array(
'meeting_name = ? AND status = 1 AND access_url = ?' => array(
$meetingName,
$this->accessUrl
)
)
),
'first' 'first'
); );
@ -511,7 +528,6 @@ class bbb
$status = false; $status = false;
$meetingInfoExists = false; $meetingInfoExists = false;
while ($status === false) { while ($status === false) {
$meetingIsRunningInfo = $this->getMeetingInfo($params); $meetingIsRunningInfo = $this->getMeetingInfo($params);
if ($meetingIsRunningInfo === false) { if ($meetingIsRunningInfo === false) {
//checking with the remote_id didn't work, so just in case and //checking with the remote_id didn't work, so just in case and
@ -659,7 +675,11 @@ class bbb
if ($this->hasGroupSupport()) { if ($this->hasGroupSupport()) {
$conditions = array( $conditions = array(
'where' => array( 'where' => array(
'c_id = ? AND session_id = ? AND group_id = ? ' => array($courseId, $sessionId, $groupId) 'c_id = ? AND session_id = ? AND group_id = ? ' => array(
$courseId,
$sessionId,
$groupId
)
) )
); );
} }
@ -823,7 +843,6 @@ class bbb
{ {
//return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt); //return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt);
if (empty($id)) { if (empty($id)) {
return false; return false;
} }
$id = intval($id); $id = intval($id);
@ -839,7 +858,6 @@ class bbb
{ {
//return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt); //return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt);
if (empty($id)) { if (empty($id)) {
return false; return false;
} }
$id = intval($id); $id = intval($id);
@ -1015,7 +1033,6 @@ class bbb
public function deleteRecording($id) public function deleteRecording($id)
{ {
if (empty($id)) { if (empty($id)) {
return false; return false;
} }
@ -1070,9 +1087,16 @@ class bbb
return false; return false;
} }
//$records = BigBlueButtonBN::getRecordingsUrl($id); //$records = BigBlueButtonBN::getRecordingsUrl($id);
$meetingData = Database::select('*', $this->table, array('where' => array('id = ?' => array($id))), 'first'); $meetingData = Database::select(
'*',
$this->table,
array('where' => array('id = ?' => array($id))),
'first'
);
$records = $this->api->getRecordingsWithXmlResponseArray(array('meetingId' => $meetingData['remote_id'])); $records = $this->api->getRecordingsWithXmlResponseArray(
array('meetingId' => $meetingData['remote_id'])
);
if (!empty($records)) { if (!empty($records)) {
if (isset($records['message']) && !empty($records['message'])) { if (isset($records['message']) && !empty($records['message'])) {
@ -1148,7 +1172,6 @@ class bbb
public function getUrlParams() public function getUrlParams()
{ {
if (empty($this->courseCode)) { if (empty($this->courseCode)) {
if ($this->isGlobalConferencePerUserEnabled()) { if ($this->isGlobalConferencePerUserEnabled()) {
return 'global=1&user_id='.$this->userId; return 'global=1&user_id='.$this->userId;
} }
@ -1173,17 +1196,14 @@ class bbb
public function getCurrentVideoConferenceName() public function getCurrentVideoConferenceName()
{ {
if ($this->isGlobalConferencePerUserEnabled()) { if ($this->isGlobalConferencePerUserEnabled()) {
return 'url_'.$this->userId.'_'.api_get_current_access_url_id(); 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();
} }
if ($this->hasGroupSupport()) { if ($this->hasGroupSupport()) {
return api_get_course_id().'-'.api_get_session_id().'-'.api_get_group_id(); return api_get_course_id().'-'.api_get_session_id().'-'.api_get_group_id();
} }
@ -1465,4 +1485,33 @@ class bbb
return $hasCapture; return $hasCapture;
} }
/**
* @param array $userInfo
* @return bool
*/
public static function showGlobalConferenceLink($userInfo)
{
if (empty($userInfo)) {
return false;
}
$setting = api_get_plugin_setting('bbb', 'enable_global_conference');
$settingLink = api_get_plugin_setting('bbb', 'enable_global_conference_link');
if ($setting === 'true' && $settingLink === 'true') {
//$content = Display::url(get_lang('LaunchVideoConferenceRoom'), $url);
$allowedRoles = api_get_plugin_setting(
'bbb',
'global_conference_allow_roles'
);
$showGlobalLink = true;
if (!empty($allowedRoles)) {
if (!in_array($userInfo['status'], $allowedRoles)) {
$showGlobalLink = false;
}
}
return $showGlobalLink;
}
}
} }

@ -34,7 +34,7 @@ class BBBPlugin extends Plugin
protected function __construct() protected function __construct()
{ {
parent::__construct( parent::__construct(
'2.5', '2.6',
'Julio Montoya, Yannick Warnier, Angel Fernando Quiroz Campos', 'Julio Montoya, Yannick Warnier, Angel Fernando Quiroz Campos',
[ [
'tool_enable' => 'boolean', 'tool_enable' => 'boolean',
@ -45,6 +45,15 @@ class BBBPlugin extends Plugin
'enable_conference_in_course_groups' => 'boolean', 'enable_conference_in_course_groups' => 'boolean',
'enable_global_conference_link' => 'boolean', 'enable_global_conference_link' => 'boolean',
'max_users_limit' => 'text', 'max_users_limit' => 'text',
'global_conference_allow_roles' => [
'type' => 'select',
'options' => [
COURSEMANAGER => get_lang('Teacher'),
STUDENT => get_lang('Student'),
STUDENT_BOSS => get_lang('StudentBoss')
],
'attributes' => ['multiple' => 'multiple']
]
] ]
); );
@ -59,7 +68,6 @@ class BBBPlugin extends Plugin
{ {
if ($variable === 'bbb_enable_conference_in_groups') { if ($variable === 'bbb_enable_conference_in_groups') {
if ($this->get('enable_conference_in_course_groups') === 'true') { if ($this->get('enable_conference_in_course_groups') === 'true') {
return true; return true;
} else { } else {
return false; return false;
@ -124,14 +132,40 @@ class BBBPlugin extends Plugin
$fieldTitle = 'MaxUsersInConferenceRoom'; $fieldTitle = 'MaxUsersInConferenceRoom';
$fieldDefault = '0'; $fieldDefault = '0';
$extraField = new ExtraField('course'); $extraField = new ExtraField('course');
$fieldId = CourseManager::create_course_extra_field($fieldLabel, $fieldType, $fieldTitle, $fieldDefault); $fieldId = CourseManager::create_course_extra_field(
$fieldLabel,
$fieldType,
$fieldTitle,
$fieldDefault
);
$extraField->find($fieldId); $extraField->find($fieldId);
$extraField->update(['id' => $fieldId, 'variable' => 'plugin_bbb_course_users_limit', 'changeable' => 1, 'visible_to_self' => 1, 'visible_to_others' => 0]); $extraField->update(
[
'id' => $fieldId,
'variable' => 'plugin_bbb_course_users_limit',
'changeable' => 1,
'visible_to_self' => 1,
'visible_to_others' => 0
]
);
$fieldLabel = 'plugin_bbb_session_users_limit'; $fieldLabel = 'plugin_bbb_session_users_limit';
$extraField = new ExtraField('session'); $extraField = new ExtraField('session');
$fieldId = SessionManager::create_session_extra_field($fieldLabel, $fieldType, $fieldTitle, $fieldDefault); $fieldId = SessionManager::create_session_extra_field(
$fieldLabel,
$fieldType,
$fieldTitle,
$fieldDefault
);
$extraField->find($fieldId); $extraField->find($fieldId);
$extraField->update(['id' => $fieldId, 'variable' => 'plugin_bbb_session_users_limit', 'changeable' => 1, 'visible_to_self' => 1, 'visible_to_others' => 0]); $extraField->update(
[
'id' => $fieldId,
'variable' => 'plugin_bbb_session_users_limit',
'changeable' => 1,
'visible_to_self' => 1,
'visible_to_others' => 0
]
);
// Installing course settings // Installing course settings
$this->install_course_fields_in_all_courses(); $this->install_course_fields_in_all_courses();
@ -157,6 +191,7 @@ class BBBPlugin extends Plugin
'bbb_plugin_host', 'bbb_plugin_host',
'bbb_plugin_salt', 'bbb_plugin_salt',
'max_users_limit', 'max_users_limit',
'global_conference_allow_roles'
]; ];
foreach ($variables as $variable) { foreach ($variables as $variable) {
@ -164,12 +199,16 @@ class BBBPlugin extends Plugin
Database::query($sql); Database::query($sql);
} }
$extraField = new ExtraField('course'); $extraField = new ExtraField('course');
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable('plugin_bbb_course_users_limit'); $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable(
'plugin_bbb_course_users_limit'
);
if (!empty($extraFieldInfo)) { if (!empty($extraFieldInfo)) {
$extraField->delete($extraFieldInfo['id']); $extraField->delete($extraFieldInfo['id']);
} }
$extraField = new ExtraField('session'); $extraField = new ExtraField('session');
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable('plugin_bbb_session_users_limit'); $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable(
'plugin_bbb_session_users_limit'
);
if (!empty($extraFieldInfo)) { if (!empty($extraFieldInfo)) {
$extraField->delete($extraFieldInfo['id']); $extraField->delete($extraFieldInfo['id']);
} }

Loading…
Cancel
Save