-
Notifications
You must be signed in to change notification settings - Fork 514
Plugin: Add config-based control for global conference roles visibility in BBB - refs #3498 #6336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
00569a0
b131629
b49bfcb
ac885c3
5bec797
9448fca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
|
||
/* For licensing terms, see /license.txt */ | ||
|
||
use Chamilo\CoreBundle\Entity\AccessUrlRelPlugin; | ||
use Chamilo\CoreBundle\Entity\ConferenceMeeting; | ||
use Chamilo\CoreBundle\Entity\ConferenceRecording; | ||
use Chamilo\CoreBundle\Framework\Container; | ||
use Chamilo\CourseBundle\Entity\CCourseSetting; | ||
use Chamilo\CoreBundle\Entity\Course; | ||
|
||
|
@@ -63,6 +65,7 @@ protected function __construct() | |
'disable_course_settings' => 'boolean', | ||
'meeting_duration' => 'text', | ||
'delete_recordings_on_course_delete' => 'boolean', | ||
'hide_conference_link' => 'boolean', | ||
] | ||
); | ||
|
||
|
@@ -284,6 +287,115 @@ private function deleteRecording(string $recordId): void | |
@file_get_contents($url); | ||
} | ||
|
||
/** | ||
* Installs the plugin | ||
*/ | ||
public function install(): void | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Method |
||
{ | ||
$entityManager = Database::getManager(); | ||
|
||
$pluginRepo = Container::getPluginRepository(); | ||
$plugin = $pluginRepo->findOneByTitle($this->get_name()); | ||
|
||
if (!$plugin) { | ||
// Create the plugin only if it does not exist | ||
$plugin = new \Chamilo\CoreBundle\Entity\Plugin(); | ||
$plugin->setTitle($this->get_name()); | ||
$plugin->setInstalled(true); | ||
$plugin->setInstalledVersion($this->get_version()); | ||
$plugin->setSource(\Chamilo\CoreBundle\Entity\Plugin::SOURCE_OFFICIAL); | ||
|
||
$entityManager->persist($plugin); | ||
$entityManager->flush(); | ||
} else { | ||
// Ensure Doctrine manages it in the current UnitOfWork | ||
$plugin = $entityManager->merge($plugin); | ||
} | ||
|
||
// Check if the plugin has relations for access URLs | ||
$accessUrlRepo = Container::getAccessUrlRepository(); | ||
$accessUrlRelPluginRepo = Container::getAccessUrlRelPluginRepository(); | ||
|
||
$accessUrls = $accessUrlRepo->findAll(); | ||
|
||
foreach ($accessUrls as $accessUrl) { | ||
$rel = $accessUrlRelPluginRepo->findOneBy([ | ||
'plugin' => $plugin, | ||
'url' => $accessUrl, | ||
]); | ||
|
||
if (!$rel) { | ||
$rel = new AccessUrlRelPlugin(); | ||
$rel->setPlugin($plugin); | ||
$rel->setUrl($accessUrl); | ||
$rel->setActive(true); | ||
|
||
$configuration = []; | ||
foreach ($this->fields as $name => $type) { | ||
$defaultValue = ''; | ||
|
||
if (is_array($type)) { | ||
$defaultValue = $type['type'] === 'boolean' ? 'false' : ''; | ||
} else { | ||
switch ($type) { | ||
case 'boolean': | ||
case 'checkbox': | ||
$defaultValue = 'false'; | ||
break; | ||
default: | ||
$defaultValue = ''; | ||
break; | ||
} | ||
} | ||
|
||
$configuration[$name] = $defaultValue; | ||
} | ||
|
||
$rel->setConfiguration($configuration); | ||
|
||
$entityManager->persist($rel); | ||
} | ||
} | ||
|
||
$entityManager->flush(); | ||
} | ||
|
||
public function canCurrentUserSeeGlobalConferenceLink(): bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function |
||
{ | ||
$allowedStatuses = $this->get('global_conference_allow_roles') ?? []; | ||
|
||
if (empty($allowedStatuses)) { | ||
return api_is_platform_admin(); | ||
} | ||
|
||
foreach ($allowedStatuses as $status) { | ||
switch ((int) $status) { | ||
case PLATFORM_ADMIN: | ||
if (api_is_platform_admin()) { | ||
return true; | ||
} | ||
break; | ||
case COURSEMANAGER: | ||
if (api_is_teacher()) { | ||
return true; | ||
} | ||
break; | ||
case STUDENT: | ||
if (api_is_student()) { | ||
return true; | ||
} | ||
break; | ||
case STUDENT_BOSS: | ||
if (api_is_student_boss()) { | ||
return true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid too many |
||
} | ||
break; | ||
} | ||
} | ||
|
||
return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid too many |
||
} | ||
|
||
public function get_name(): string | ||
{ | ||
return 'Bbb'; | ||
|
Unchanged files with check annotations Beta
/** | ||
* @template-implements ProviderInterface<Session> | ||
*/ | ||
class UserSessionSubscriptionsStateProvider implements ProviderInterface | ||
Check failure on line 25 in src/CoreBundle/State/UserSessionSubscriptionsStateProvider.php
|
||
{ | ||
public function __construct( | ||
private readonly UserHelper $userHelper, |
return $courseItems; | ||
}, $results); | ||
$flatItems = array_merge(...$items); | ||
Check failure on line 174 in src/CoreBundle/Controller/Admin/SessionAdminController.php
|
||
return $this->json([ | ||
'items' => $flatItems, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
install
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.