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. 2
      plugin/bbb/course_index.php
  8. 3
      plugin/bbb/cron.php
  9. 1
      plugin/bbb/lang/english.php
  10. 1
      plugin/bbb/lang/french.php
  11. 93
      plugin/bbb/lib/bbb.lib.php
  12. 55
      plugin/bbb/lib/bbb_plugin.class.php

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

@ -150,7 +150,7 @@ if (!empty($_GET['category']) &&
}
}
}
//Reload settings
// Reload settings
$settings_array = getCategorySettings($my_category);
$settings = $settings_array['settings'];
$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);
if (isset($result[$plugin])) {
return $result[$plugin];
$value = $result[$plugin];
if (@unserialize($value) !== false) {
$value = unserialize($value);
}
return $value;
}
return null;
@ -5360,6 +5364,12 @@ function api_add_setting(
$settingRepo = $em->getRepository('ChamiloCoreBundle:SettingsCurrent');
$accessUrlId = (int) $accessUrlId ?: 1;
if (is_array($value)) {
$value = serialize($value);
} else {
$value = trim($value);
}
$criteria = ['variable' => $variable, 'accessUrl' => $accessUrlId];
if (!empty($subKey)) {

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

@ -419,19 +419,29 @@ class AppPlugin
$plugin_info = array();
if (file_exists($plugin_file)) {
require $plugin_file;
}
// @todo check if settings are already added
// Extra options
$plugin_settings = api_get_settings_params(
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();
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'];
}
$plugin_info['settings'] = $settings_filtered;

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

@ -7,4 +7,4 @@
/**
* Display course tool title
*/
echo "Videoconference";
echo "Videoconference";

@ -1,9 +1,8 @@
<?php
/* For license terms, see /license.txt */
require __DIR__.'/../../vendor/autoload.php';
require_once __DIR__.'/../../vendor/autoload.php';
if (file_exists(__DIR__.'/config.vm.php')) {
require_once __DIR__.'/config.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['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['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['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['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 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->courseId = api_get_course_int_id();
$this->sessionId = api_get_session_id();
@ -83,7 +87,6 @@ class bbb
// Plugin check
$this->groupSupport = (bool) $this->plugin->get('enable_conference_in_course_groups');
if ($this->groupSupport) {
// Platform check
$bbbSetting = api_get_setting('bbb_enable_conference_in_course_groups');
$bbbSetting = isset($bbbSetting['bbb']) ? $bbbSetting['bbb'] === 'true' : false;
@ -209,7 +212,8 @@ class bbb
* This value can be overridden by course-specific values
* @return int Maximum number of users set globally
*/
public function getMaxUsersLimit() {
public function getMaxUsersLimit()
{
$limit = $this->maxUsersLimit;
if ($limit <= 0) {
$limit = 0;
@ -248,11 +252,13 @@ class bbb
}
return $limit;
}
/**
* Sets the global limit of users in a video-conference room.
* @param int Maximum number of users (globally)
*/
public function setMaxUsersLimit($max) {
public function setMaxUsersLimit($max)
{
if ($max < 0) {
$max = 0;
}
@ -422,7 +428,6 @@ class bbb
public function meetingExists($meetingName)
{
if (empty($meetingName)) {
return false;
}
@ -440,7 +445,13 @@ class bbb
$conditions = array(
'where' => array(
'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)) {
return false;
} else {
return true;
@ -489,7 +499,14 @@ class bbb
$meetingData = Database::select(
'*',
$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'
);
@ -511,7 +528,6 @@ class bbb
$status = false;
$meetingInfoExists = false;
while ($status === false) {
$meetingIsRunningInfo = $this->getMeetingInfo($params);
if ($meetingIsRunningInfo === false) {
//checking with the remote_id didn't work, so just in case and
@ -561,7 +577,7 @@ class bbb
'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
//'createTime' => api_get_utc_datetime(), //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
'userID' => api_get_user_id(), //-- OPTIONAL - string
'webVoiceConf' => '' // -- OPTIONAL - string
'webVoiceConf' => '' // -- OPTIONAL - string
);
$url = $this->api->getJoinMeetingURL($joinParams);
$url = $this->protocol.$url;
@ -659,7 +675,11 @@ class bbb
if ($this->hasGroupSupport()) {
$conditions = 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
)
)
);
}
@ -802,7 +822,7 @@ class bbb
'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
'createTime' => '', //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
'userID' => '', // -- OPTIONAL - string
'webVoiceConf' => '' // -- OPTIONAL - string
'webVoiceConf' => '' // -- OPTIONAL - string
);
$item['go_url'] = $this->protocol.$this->api->getJoinMeetingURL($joinParams);
}
@ -823,7 +843,6 @@ class bbb
{
//return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt);
if (empty($id)) {
return false;
}
$id = intval($id);
@ -839,7 +858,6 @@ class bbb
{
//return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt);
if (empty($id)) {
return false;
}
$id = intval($id);
@ -1015,7 +1033,6 @@ class bbb
public function deleteRecording($id)
{
if (empty($id)) {
return false;
}
@ -1070,9 +1087,16 @@ class bbb
return false;
}
//$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 (isset($records['message']) && !empty($records['message'])) {
@ -1148,7 +1172,6 @@ class bbb
public function getUrlParams()
{
if (empty($this->courseCode)) {
if ($this->isGlobalConferencePerUserEnabled()) {
return 'global=1&user_id='.$this->userId;
}
@ -1173,17 +1196,14 @@ class bbb
public function getCurrentVideoConferenceName()
{
if ($this->isGlobalConferencePerUserEnabled()) {
return 'url_'.$this->userId.'_'.api_get_current_access_url_id();
}
if ($this->isGlobalConference()) {
return 'url_'.api_get_current_access_url_id();
}
if ($this->hasGroupSupport()) {
return api_get_course_id().'-'.api_get_session_id().'-'.api_get_group_id();
}
@ -1465,4 +1485,33 @@ class bbb
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()
{
parent::__construct(
'2.5',
'2.6',
'Julio Montoya, Yannick Warnier, Angel Fernando Quiroz Campos',
[
'tool_enable' => 'boolean',
@ -45,6 +45,15 @@ class BBBPlugin extends Plugin
'enable_conference_in_course_groups' => 'boolean',
'enable_global_conference_link' => 'boolean',
'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 ($this->get('enable_conference_in_course_groups') === 'true') {
return true;
} else {
return false;
@ -124,14 +132,40 @@ class BBBPlugin extends Plugin
$fieldTitle = 'MaxUsersInConferenceRoom';
$fieldDefault = '0';
$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->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';
$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->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
$this->install_course_fields_in_all_courses();
@ -157,6 +191,7 @@ class BBBPlugin extends Plugin
'bbb_plugin_host',
'bbb_plugin_salt',
'max_users_limit',
'global_conference_allow_roles'
];
foreach ($variables as $variable) {
@ -164,12 +199,16 @@ class BBBPlugin extends Plugin
Database::query($sql);
}
$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)) {
$extraField->delete($extraFieldInfo['id']);
}
$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)) {
$extraField->delete($extraFieldInfo['id']);
}

Loading…
Cancel
Save