Minor: Format code

pull/5031/head
Angel Fernando Quiroz Campos 11 months ago
parent f197e33a7f
commit 61d458379b
  1. 4
      src/CoreBundle/ChamiloCoreBundle.php
  2. 13
      src/CoreBundle/Command/UpdateVueTranslations.php
  3. 2
      src/CoreBundle/Component/Editor/CkEditor/CkEditor.php
  4. 26
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php
  5. 2
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/Messages.php
  6. 4
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/TestAnswerFeedback.php
  7. 2
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/TestFreeAnswer.php
  8. 3
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/TestFreeAnswerStrict.php
  9. 2
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/TestMatching.php
  10. 2
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/TestQuestionDescription.php
  11. 4
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/ToolbarStartExpanded.php
  12. 2
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/UniqueAnswerImage.php
  13. 15
      src/CoreBundle/Component/Editor/Editor.php
  14. 11
      src/CoreBundle/Component/Utils/ChamiloApi.php
  15. 4
      src/CoreBundle/Component/Utils/GlideAsset.php
  16. 36
      src/CoreBundle/Component/Utils/NameConvention.php
  17. 4
      src/CoreBundle/Controller/AbstractResourceController.php
  18. 2
      src/CoreBundle/Controller/AccountController.php
  19. 6
      src/CoreBundle/Controller/Admin/IndexBlocksController.php
  20. 4
      src/CoreBundle/Controller/Admin/PluginsController.php
  21. 2
      src/CoreBundle/Controller/Admin/SettingsController.php
  22. 17
      src/CoreBundle/Controller/Api/BaseResourceFileAction.php
  23. 2
      src/CoreBundle/Controller/Api/CreateCCalendarEventAction.php
  24. 6
      src/CoreBundle/Controller/Api/ExportCGlossaryAction.php
  25. 1
      src/CoreBundle/Controller/Api/ExportGlossaryToDocumentsAction.php
  26. 1
      src/CoreBundle/Controller/Api/GetLinksCollectionController.php
  27. 2
      src/CoreBundle/Controller/Api/ImportCGlossaryAction.php
  28. 2
      src/CoreBundle/Controller/Api/UpdateCCalendarEventAction.php
  29. 2
      src/CoreBundle/Controller/AssetController.php
  30. 6
      src/CoreBundle/Controller/BaseController.php
  31. 14
      src/CoreBundle/Controller/ChatController.php
  32. 48
      src/CoreBundle/Controller/CourseController.php
  33. 2
      src/CoreBundle/Controller/EditorController.php
  34. 14
      src/CoreBundle/Controller/ExceptionController.php
  35. 7
      src/CoreBundle/Controller/IndexController.php
  36. 4
      src/CoreBundle/Controller/PlatformConfigurationController.php
  37. 17
      src/CoreBundle/Controller/ResourceController.php
  38. 13
      src/CoreBundle/Controller/SecurityController.php
  39. 12
      src/CoreBundle/Controller/SessionController.php
  40. 1
      src/CoreBundle/Controller/ToolController.php
  41. 4
      src/CoreBundle/DataFixtures/AccessUserFixtures.php
  42. 1
      src/CoreBundle/DataFixtures/AccessUserUrlFixtures.php
  43. 6
      src/CoreBundle/DataPersister/UserRelUserDataPersister.php
  44. 17
      src/CoreBundle/DataProvider/Extension/CCalendarEventExtension.php
  45. 11
      src/CoreBundle/DataProvider/Extension/CDocumentExtension.php
  46. 3
      src/CoreBundle/DataProvider/Extension/CStudentPublicationExtension.php
  47. 5
      src/CoreBundle/DataProvider/Extension/CToolIntroExtension.php
  48. 5
      src/CoreBundle/DataProvider/Extension/CourseExtension.php
  49. 7
      src/CoreBundle/DataProvider/Extension/CourseLinkExtensionTrait.php
  50. 7
      src/CoreBundle/DataProvider/Extension/CourseRelUserExtension.php
  51. 21
      src/CoreBundle/DataProvider/Extension/MessageExtension.php
  52. 3
      src/CoreBundle/DataProvider/Extension/MessageRelUserExtension.php
  53. 7
      src/CoreBundle/DataProvider/Extension/MessageTagExtension.php
  54. 11
      src/CoreBundle/DataProvider/Extension/PageExtension.php
  55. 7
      src/CoreBundle/DataProvider/Extension/PersonalFileExtension.php
  56. 7
      src/CoreBundle/DataProvider/Extension/SessionRelUserExtension.php
  57. 3
      src/CoreBundle/DataProvider/Extension/SocialPostExtension.php
  58. 3
      src/CoreBundle/DataProvider/Extension/TrackEExerciseExtension.php
  59. 3
      src/CoreBundle/DataProvider/UserItemDataProvider.php
  60. 8
      src/CoreBundle/Entity/AbstractResource.php
  61. 4
      src/CoreBundle/Entity/AgendaEventSubscriber.php
  62. 6
      src/CoreBundle/Entity/Asset.php
  63. 2
      src/CoreBundle/Entity/Career.php
  64. 16
      src/CoreBundle/Entity/Course.php
  65. 3
      src/CoreBundle/Entity/CourseCategory.php
  66. 4
      src/CoreBundle/Entity/CourseRelUser.php
  67. 4
      src/CoreBundle/Entity/CourseRelUserCatalogue.php
  68. 10
      src/CoreBundle/Entity/ExtraField.php
  69. 2
      src/CoreBundle/Entity/ExtraFieldValues.php
  70. 2
      src/CoreBundle/Entity/GradebookCategory.php
  71. 2
      src/CoreBundle/Entity/GradebookComment.php
  72. 5
      src/CoreBundle/Entity/Listener/CourseListener.php
  73. 3
      src/CoreBundle/Entity/Listener/MessageListener.php
  74. 24
      src/CoreBundle/Entity/Listener/ResourceListener.php
  75. 5
      src/CoreBundle/Entity/Listener/ResourceNodeListener.php
  76. 9
      src/CoreBundle/Entity/Listener/SessionListener.php
  77. 3
      src/CoreBundle/Entity/Listener/SkillRelUserListener.php
  78. 3
      src/CoreBundle/Entity/Listener/UserListener.php
  79. 3
      src/CoreBundle/Entity/Listener/UserRelUserListener.php
  80. 3
      src/CoreBundle/Entity/Message.php
  81. 19
      src/CoreBundle/Entity/PageCategory.php
  82. 4
      src/CoreBundle/Entity/PersonalFile.php
  83. 4
      src/CoreBundle/Entity/ResourceComment.php
  84. 12
      src/CoreBundle/Entity/ResourceFile.php
  85. 15
      src/CoreBundle/Entity/ResourceNode.php
  86. 4
      src/CoreBundle/Entity/ResourceShowCourseResourcesInSessionInterface.php
  87. 4
      src/CoreBundle/Entity/ResourceToRootInterface.php
  88. 4
      src/CoreBundle/Entity/ScheduledAnnouncement.php
  89. 6
      src/CoreBundle/Entity/Session.php
  90. 3
      src/CoreBundle/Entity/SessionCategory.php
  91. 23
      src/CoreBundle/Entity/Skill.php
  92. 10
      src/CoreBundle/Entity/SkillRelItem.php
  93. 4
      src/CoreBundle/Entity/SkillRelItemRelUser.php
  94. 19
      src/CoreBundle/Entity/User.php
  95. 8
      src/CoreBundle/Entity/UserRelUser.php
  96. 59
      src/CoreBundle/Entity/Usergroup.php
  97. 57
      src/CoreBundle/EventListener/CourseListener.php
  98. 4
      src/CoreBundle/EventListener/HTTPExceptionListener.php
  99. 19
      src/CoreBundle/EventListener/LegacyListener.php
  100. 19
      src/CoreBundle/EventListener/LoginSuccessHandler.php
  101. Some files were not shown because too many files have changed in this diff Show More

@ -8,6 +8,4 @@ namespace Chamilo\CoreBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class ChamiloCoreBundle extends Bundle
{
}
class ChamiloCoreBundle extends Bundle {}

@ -14,6 +14,8 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use const JSON_PRETTY_PRINT;
class UpdateVueTranslations extends Command
{
/**
@ -70,7 +72,7 @@ class UpdateVueTranslations extends Command
$newLanguage = [];
foreach ($translations as $variable => $translation) {
//$translated = $this->translator->trans($variable, [], null, $iso);
// $translated = $this->translator->trans($variable, [], null, $iso);
$translated = $this->getTranslationWithFallback($variable, $language);
$newLanguage[$variable] = $this->replaceMarkers($translated);
}
@ -88,12 +90,13 @@ class UpdateVueTranslations extends Command
/**
* Gets the translation for a given variable with fallbacks to parent language and base language.
*
* @param string $variable The variable to be translated.
* @param Language $language The Language entity for the current language.
* @param string $variable the variable to be translated
* @param Language $language the Language entity for the current language
*
* @return string The translated string.
* @return string the translated string
*/
private function getTranslationWithFallback(string $variable, Language $language): string {
private function getTranslationWithFallback(string $variable, Language $language): string
{
// Get the ISO code of the current language
$iso = $language->getIsocode();
// Try to translate the variable in the current language

@ -92,7 +92,7 @@ class CkEditor extends Editor
$cssTheme,
api_get_path(REL_CODE_PATH).'img/',
api_get_path(REL_PATH),
//api_get_path(REL_DEFAULT_COURSE_DOCUMENT_PATH),
// api_get_path(REL_DEFAULT_COURSE_DOCUMENT_PATH),
'',
];

@ -15,8 +15,8 @@ class Basic extends Toolbar
* In order to add a new plugin you have to load it in default/layout/head.tpl.
*/
public array $defaultPlugins = [
//'adobeair',
//'ajax',
// 'adobeair',
// 'ajax',
'audio',
'image2_chamilo',
'bidi',
@ -25,14 +25,14 @@ class Basic extends Toolbar
'dialogui',
'dialogadvtab',
'div',
//if you activate this plugin the html, head tags will not be saved
//'divarea',
//'docprops',
// if you activate this plugin the html, head tags will not be saved
// 'divarea',
// 'docprops',
'find',
'flash',
'font',
'iframe',
//'iframedialog',
// 'iframedialog',
'indentblock',
'justify',
'language',
@ -45,20 +45,20 @@ class Basic extends Toolbar
'print',
'save',
'selectall',
//'sharedspace',
// 'sharedspace',
'showblocks',
'smiley',
//'sourcedialog',
//'stylesheetparser',
//'tableresize',
// 'sourcedialog',
// 'stylesheetparser',
// 'tableresize',
'templates',
//'uicolor',
// 'uicolor',
'video',
'widget',
'wikilink',
'wordcount',
'inserthtml',
//'xml',
// 'xml',
'qmarkersrolls',
];
@ -207,7 +207,7 @@ class Basic extends Toolbar
$this->config = $config;
//$config['width'] = '100';
// $config['width'] = '100';
$this->config['height'] = '300';
return $this->config;

@ -26,7 +26,7 @@ class Messages extends Basic
}
$config['fullPage'] = true;
//$config['height'] = '200';
// $config['height'] = '200';
return $config;
}

@ -54,8 +54,8 @@ class TestAnswerFeedback extends Basic
$config['toolbarCanCollapse'] = true;
$config['toolbarStartupExpanded'] = false;
//$config['width'] = '100';
//$config['height'] = '200';
// $config['width'] = '100';
// $config['height'] = '200';
if ('true' !== api_get_setting('more_buttons_maximized_mode')) {
$config['toolbar'] = $this->getNormalToolbar();

@ -40,7 +40,7 @@ class TestFreeAnswer extends Basic
'wordLimit' => 'unlimited',
];
//$config['height'] = '200';
// $config['height'] = '200';
return $config;
}

@ -39,7 +39,8 @@ class TestFreeAnswerStrict extends Basic
];
$config['removePlugins'] = 'elementspath';
//$config['height'] = '200';
// $config['height'] = '200';
return $config;
}

@ -38,7 +38,7 @@ class TestMatching extends Basic
'wordLimit' => 'unlimited',
];
//$config['height'] = '200';
// $config['height'] = '200';
return $config;
}

@ -31,7 +31,7 @@ class TestQuestionDescription extends Basic
'name' => 'editing',
'groups' => ['clipboard', 'undo'],
],
//array('name' => 'forms', 'groups' =>array('clipboard', 'undo', )),
// array('name' => 'forms', 'groups' =>array('clipboard', 'undo', )),
'/',
[
'name' => 'basicstyles',

@ -6,6 +6,4 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar;
class ToolbarStartExpanded extends Basic
{
}
class ToolbarStartExpanded extends Basic {}

@ -53,7 +53,7 @@ class UniqueAnswerImage extends Basic
];
$config['fullPage'] = true;
//$config['height'] = '200';
// $config['height'] = '200';
return $config;
}

@ -46,7 +46,7 @@ class Editor
$this->setConfigAttribute('fullPage', false);
$this->translator = $translator;
$this->urlGenerator = $urlGenerator;
//$this->course = $course;
// $this->course = $course;
}
/**
@ -87,6 +87,7 @@ class Editor
/**
* @param string $key
* @param mixed $value
*/
public function setConfigAttribute($key, $value): void
{
@ -113,25 +114,30 @@ class Editor
$this->toolbarSet = $value;
break;
case 'Config':
$this->processConfig($value);
break;
case 'width':
case 'Width':
$this->setConfigAttribute('width', $value);
break;
case 'height':
case 'Height':
$this->setConfigAttribute('height', $value);
break;
case 'FullPage':
case 'fullPage':
$this->setConfigAttribute('fullPage', $value);
break;
default:
$this->setConfigAttribute($key, $value);
@ -158,9 +164,11 @@ class Editor
switch (\gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false'; // Lowercase necessary!
case 'integer':
case 'double':
return (string) $var;
case 'resource':
case 'string':
return '"'.str_replace(
@ -170,6 +178,7 @@ class Editor
).'"';
break;
case 'array':
// Arrays in JSON can't be associative. If the array is empty or if it
// has sequential whole number keys starting with 0, it's not associative
@ -182,7 +191,8 @@ class Editor
return '[ '.implode(', ', $output).' ]';
}
//no break
// no break
case 'object':
// Otherwise, fall through to convert the array as an object.
$output = [];
@ -193,6 +203,7 @@ class Editor
return '{ '.implode(', '."\n", $output).' } '."\n";
break;
default:
return 'null';
}

@ -13,9 +13,10 @@ use DateTime;
use DateTimeZone;
use Display;
use Exception;
use const PHP_SAPI;
use Template;
use const PHP_SAPI;
class ChamiloApi
{
public const COURSE_MANAGER = 1;
@ -245,7 +246,7 @@ class ChamiloApi
*
* @throws Exception
*/
public static function getCourseIdByDirectory(?string $directory = null): int
public static function getCourseIdByDirectory(string $directory = null): int
{
if (!empty($directory)) {
$directory = Database::escape_string($directory);
@ -288,7 +289,7 @@ class ChamiloApi
$text = api_replace_dangerous_char($text);
$text = str_replace(['-', ' ', '.'], '_', $text);
$text = preg_replace('/_+/', '_', $text);
//$text = str_replace('_', '', $text);
// $text = str_replace('_', '', $text);
$text = api_underscore_to_camel_case($text);
return $prefix.$text;
@ -339,7 +340,7 @@ class ChamiloApi
public static function getColorPalette(
bool $decimalOpacity = false,
bool $wrapInRGBA = false,
?int $fillUpTo = null
int $fillUpTo = null
): array {
// Get the common colors from the palette used for pchart
$paletteFile = api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color';
@ -379,7 +380,7 @@ class ChamiloApi
*
* @throws Exception
*/
public static function getServerMidnightTime(?string $utcTime = null): DateTime
public static function getServerMidnightTime(string $utcTime = null): DateTime
{
$localTime = api_get_local_time($utcTime);
$localTimeZone = api_get_timezone();

@ -6,6 +6,4 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Component\Utils;
class GlideAsset extends Glide
{
}
class GlideAsset extends Glide {}

@ -66,7 +66,7 @@ class NameConvention
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
//'breton' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'breton' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'bg' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
@ -111,7 +111,7 @@ class NameConvention
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
//basque
// basque
'fi' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
@ -120,7 +120,7 @@ class NameConvention
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
//'frisian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'frisian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'fur_IT' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
@ -141,7 +141,7 @@ class NameConvention
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
//'hawaiian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'hawaiian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'he' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
@ -155,12 +155,12 @@ class NameConvention
'sort_by' => 'last_name',
],
// Eastern order
//'icelandic' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'icelandic' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'id' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
//'irish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'irish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'it' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
@ -175,7 +175,7 @@ class NameConvention
'sort_by' => 'last_name',
],
// Eastern order
//'latin' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'latin' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'lv' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
@ -193,11 +193,11 @@ class NameConvention
'sort_by' => 'last_name',
],
// Eastern order
//'manx' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
//'marathi' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
//'middle_frisian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
//'mingo' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
//'nepali' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'manx' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'marathi' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'middle_frisian' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'mingo' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'nepali' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'nn' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
@ -230,17 +230,17 @@ class NameConvention
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
//'rumantsch' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'rumantsch' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'ru' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
//'sanskrit' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'sanskrit' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'sr' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
//'serbian_cyrillic' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'serbian_cyrillic' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'zh_CN' => [
'format' => 'title last_name first_name',
'sort_by' => 'last_name',
@ -270,7 +270,7 @@ class NameConvention
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
],
//'tamil' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'tamil' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'th' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',
@ -293,8 +293,8 @@ class NameConvention
'sort_by' => 'last_name',
],
// Eastern order
//'welsh' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
//'yiddish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'welsh' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
// 'yiddish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'yo' => [
'format' => 'title first_name last_name',
'sort_by' => 'first_name',

@ -6,6 +6,4 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Controller;
abstract class AbstractResourceController extends BaseController
{
}
abstract class AbstractResourceController extends BaseController {}

@ -26,7 +26,7 @@ class AccountController extends BaseController
{
use ControllerTrait;
#[Route('/edit', name: 'chamilo_core_account_edit', methods:['GET', 'POST'])]
#[Route('/edit', name: 'chamilo_core_account_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, UserRepository $userRepository, IllustrationRepository $illustrationRepo, SettingsManager $settingsManager): Response
{
$user = $this->getUser();

@ -19,7 +19,7 @@ class IndexBlocksController extends BaseController
{
private bool $isAdmin = false;
private bool $isSessionAdmin = false;
private $extAuthSource = [];
private array $extAuthSource = [];
public function __construct(
private readonly TranslatorInterface $translator,
@ -271,10 +271,10 @@ class IndexBlocksController extends BaseController
'url' => $this->generateUrl('legacy_main', ['name' => 'admin/course_user_import.php']),
'label' => $this->translator->trans('Import users list'),
];
//$items[] = [
// $items[] = [
// 'url'=>'course_intro_pdf_import.php',
// 'label' => $this->translator->$this->trans('ImportPDFIntroToCourses'),
//];
// ];
if ('true' === $this->settingsManager->getSetting('gradebook.gradebook_enable_grade_model')) {
$items[] = [

@ -16,7 +16,7 @@ use Symfony\Component\Routing\Annotation\Route;
class PluginsController extends BaseController
{
#[IsGranted('ROLE_ADMIN')]
#[Route('/', name: 'chamilo_core_plugins', methods:['GET', 'POST'])]
#[Route('/', name: 'chamilo_core_plugins', methods: ['GET', 'POST'])]
public function index(): Response
{
$appPlugin = new AppPlugin();
@ -31,7 +31,7 @@ class PluginsController extends BaseController
}
#[IsGranted('ROLE_ADMIN')]
#[Route('/add', name: 'chamilo_core_plugins', methods:['GET', 'POST'])]
#[Route('/add', name: 'chamilo_core_plugins', methods: ['GET', 'POST'])]
public function pluginsAddAction(): Response
{
$appPlugin = new AppPlugin();

@ -147,7 +147,7 @@ class SettingsController extends BaseController
$manager->save($form->getData());
$message = $this->trans('Settings have been successfully updated');
} catch (ValidatorException $validatorException) {
//$message = $this->trans($exception->getMessage(), [], 'validators');
// $message = $this->trans($exception->getMessage(), [], 'validators');
$message = $this->trans($validatorException->getMessage());
$messageType = 'error';
}

@ -89,8 +89,8 @@ class BaseResourceFileAction
if ($linkSet) {
$em->persist($resourceLink);
$resourceNode->addResourceLink($resourceLink);
//$em->persist($resourceNode);
//$em->persist($resource->getResourceNode());
// $em->persist($resourceNode);
// $em->persist($resource->getResourceNode());
}
}
}
@ -98,7 +98,7 @@ class BaseResourceFileAction
// Use by Chamilo not api platform.
$links = $resource->getResourceLinkEntityList();
if ($links) {
//error_log('$resource->getResourceLinkEntityList()');
// error_log('$resource->getResourceLinkEntityList()');
foreach ($links as $link) {
/*$rights = [];
switch ($link->getVisibility()) {
@ -120,8 +120,8 @@ class BaseResourceFileAction
$link->addResourceRight($right);
}
}*/
//error_log('link adding to node: '.$resource->getResourceNode()->getId());
//error_log('link with user : '.$link->getUser()->getUsername());
// error_log('link adding to node: '.$resource->getResourceNode()->getId());
// error_log('link with user : '.$link->getUser()->getUsername());
$resource->getResourceNode()->addResourceLink($link);
$em->persist($link);
@ -150,7 +150,7 @@ class BaseResourceFileAction
$parentResourceNodeId = (int) $request->get('parentResourceNodeId');
$resourceLinkList = $request->get('resourceLinkList', []);
if (!empty($resourceLinkList)) {
$resourceLinkList = false === strpos($resourceLinkList, '[') ? json_decode('['.$resourceLinkList.']', true) : json_decode($resourceLinkList, true);
$resourceLinkList = !str_contains($resourceLinkList, '[') ? json_decode('['.$resourceLinkList.']', true) : json_decode($resourceLinkList, true);
if (empty($resourceLinkList)) {
$message = 'resourceLinkList is not a valid json. Use for example: [{"cid":1, "visibility":1}]';
@ -200,7 +200,7 @@ class BaseResourceFileAction
$fileType = $request->get('filetype');
$resourceLinkList = $request->get('resourceLinkList', []);
if (!empty($resourceLinkList)) {
$resourceLinkList = false === strpos($resourceLinkList, '[') ? json_decode('['.$resourceLinkList.']', true) : json_decode($resourceLinkList, true);
$resourceLinkList = !str_contains($resourceLinkList, '[') ? json_decode('['.$resourceLinkList.']', true) : json_decode($resourceLinkList, true);
if (empty($resourceLinkList)) {
$message = 'resourceLinkList is not a valid json. Use for example: [{"cid":1, "visibility":1}]';
@ -251,6 +251,7 @@ class BaseResourceFileAction
}
break;
case 'folder':
break;
}
@ -284,7 +285,7 @@ class BaseResourceFileAction
} else {
$title = $request->get('title');
$content = $request->request->get('contentFile');
//$comment = $request->request->get('comment');
// $comment = $request->request->get('comment');
}
$repo->setResourceName($resource, $title);

@ -30,7 +30,7 @@ class CreateCCalendarEventAction extends BaseResourceFileAction
->setColor($result['color'] ?? '')
->setStartDate(new DateTime($result['startDate'] ?? ''))
->setEndDate(new DateTime($result['endDate'] ?? ''))
//->setAllDay($result['allDay'] ?? false)
// ->setAllDay($result['allDay'] ?? false)
->setCollective($result['collective'] ?? false)
->setCreator($currentUser)
;

@ -62,10 +62,13 @@ class ExportCGlossaryAction
switch ($format) {
case 'csv':
return $this->generateCsvFile($glossaryItems, $exportPath);
case 'xls':
return $this->generateExcelFile($glossaryItems, $exportPath);
case 'pdf':
return $this->generatePdfFile($glossaryItems, $exportPath, $translator);
default:
throw new NotSupported('Export format not supported');
}
@ -75,6 +78,7 @@ class ExportCGlossaryAction
{
$csvFilePath = $exportPath.'/glossary.csv';
$csvContent = '';
/** @var CGlossary $item */
foreach ($glossaryItems as $item) {
$csvContent .= $item->getName().','.$item->getDescription()."\n";
@ -89,6 +93,7 @@ class ExportCGlossaryAction
$excelFilePath = $exportPath.'/glossary.xlsx';
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
/** @var CGlossary $item */
foreach ($glossaryItems as $index => $item) {
$row = $index + 1;
@ -111,6 +116,7 @@ class ExportCGlossaryAction
$html = '<h1>'.$translator->trans('Glossary').'</h1>';
$html .= '<table>';
$html .= '<tr><th>'.$translator->trans('Term').'</th><th>'.$translator->trans('Definition').'</th></tr>';
/** @var CGlossary $item */
foreach ($glossaryItems as $item) {
$html .= '<tr>';

@ -68,6 +68,7 @@ class ExportGlossaryToDocumentsAction
$html = '<h1>'.$translator->trans('Glossary').'</h1>';
$html .= '<table>';
$html .= '<tr><th>'.$translator->trans('Term').'</th><th>'.$translator->trans('Definition').'</th></tr>';
/** @var CGlossary $item */
foreach ($glossaryItems as $item) {
$html .= '<tr>';

@ -75,6 +75,7 @@ class GetLinksCollectionController extends BaseResourceFileAction
$dataResponse['categories'][$categoryId]['info'] = $categoryInfo;
if ($links) {
$items = [];
/** @var CLink $link */
foreach ($links as $link) {
$items[] = [

@ -107,6 +107,7 @@ class ImportCGlossaryAction
->andWhere('resource.name = :name')
->setParameter('name', $termToUpdate)
;
/** @var CGlossary $existingGlossaryTerm */
$existingGlossaryTerm = $qb->getQuery()->getOneOrNullResult();
if (null !== $existingGlossaryTerm) {
@ -122,6 +123,7 @@ class ImportCGlossaryAction
->andWhere('resource.name = :name')
->setParameter('name', $term)
;
/** @var CGlossary $existingNewGlossaryTerm */
$existingNewGlossaryTerm = $qb->getQuery()->getOneOrNullResult();
if (!$existingNewGlossaryTerm) {

@ -30,7 +30,7 @@ class UpdateCCalendarEventAction extends BaseResourceFileAction
->setColor($result['color'] ?? '')
->setStartDate(new DateTime($result['startDate'] ?? ''))
->setEndDate(new DateTime($result['endDate'] ?? ''))
//->setAllDay($result['allDay'] ?? false)
// ->setAllDay($result['allDay'] ?? false)
->setCollective($result['collective'] ?? false)
;

@ -52,7 +52,7 @@ class AssetController
// The image was cropped manually by the user, so we force to render this version,
// no matter other crop parameters.
//$crop = $resourceFile->getCrop();
// $crop = $resourceFile->getCrop();
/*if (!empty($crop)) {
$params['crop'] = $crop;
}*/

@ -10,9 +10,5 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
/**
* Each entity controller must extend this class.
*
* @abstract
*/
abstract class BaseController extends AbstractController
{
}
abstract class BaseController extends AbstractController {}

@ -22,8 +22,8 @@ use Symfony\Component\Routing\Annotation\Route;
class ChatController extends AbstractResourceController implements CourseControllerInterface
{
use ControllerTrait;
use ResourceControllerTrait;
use CourseControllerTrait;
use ResourceControllerTrait;
/**
* @Route("/resources/chat/", name="chat_home", options={"expose"=true})
@ -90,21 +90,22 @@ class ChatController extends AbstractResourceController implements CourseControl
Event::registerLog($logInfo);
break;
case 'track':
$courseChatUtils->keepUserAsConnected();
$courseChatUtils->disconnectInactiveUsers();
$friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0;
//$filePath = $courseChatUtils->getFileName(true, $friend);
//$newFileSize = file_exists($filePath) ? filesize($filePath) : 0;
//$oldFileSize = isset($_GET['size']) ? (int) $_GET['size'] : -1;
// $filePath = $courseChatUtils->getFileName(true, $friend);
// $newFileSize = file_exists($filePath) ? filesize($filePath) : 0;
// $oldFileSize = isset($_GET['size']) ? (int) $_GET['size'] : -1;
$newUsersOnline = $courseChatUtils->countUsersOnline();
$oldUsersOnline = isset($_GET['users_online']) ? (int) $_GET['users_online'] : 0;
$json = [
'status' => true,
'data' => [
//'oldFileSize' => file_exists($filePath) ? filesize($filePath) : 0,
// 'oldFileSize' => file_exists($filePath) ? filesize($filePath) : 0,
'oldFileSize' => false,
'history' => $courseChatUtils->readMessages(false, $friend),
'usersOnline' => $newUsersOnline,
@ -114,6 +115,7 @@ class ChatController extends AbstractResourceController implements CourseControl
];
break;
case 'preview':
$json = [
'status' => true,
@ -123,6 +125,7 @@ class ChatController extends AbstractResourceController implements CourseControl
];
break;
case 'reset':
$friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0;
@ -132,6 +135,7 @@ class ChatController extends AbstractResourceController implements CourseControl
];
break;
case 'write':
$friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0;
$status = $courseChatUtils->saveMessage($_REQUEST['message'], $friend);

@ -59,8 +59,7 @@ class CourseController extends ToolBaseController
{
public function __construct(
private readonly SerializerInterface $serializer
) {
}
) {}
#[Route('/{cid}/checkLegal.json', name: 'chamilo_core_course_check_legal_json')]
public function checkTermsAndConditionJson(
@ -78,9 +77,9 @@ class CourseController extends ToolBaseController
'url' => '#',
];
if ($user && $user->hasRole('ROLE_STUDENT') &&
'true' === $settingsManager->getSetting('allow_terms_conditions') &&
'course' === $settingsManager->getSetting('load_term_conditions_section')
if ($user && $user->hasRole('ROLE_STUDENT')
&& 'true' === $settingsManager->getSetting('allow_terms_conditions')
&& 'course' === $settingsManager->getSetting('load_term_conditions_section')
) {
$termAndConditionStatus = false;
$extraValue = $extraFieldValuesRepository->findLegalAcceptByItemId($user->getId());
@ -106,9 +105,9 @@ class CourseController extends ToolBaseController
->getSetting('course.allow_public_course_with_no_terms_conditions')
;
if (true === $allow &&
null !== $course->getVisibility() &&
Course::OPEN_WORLD === $course->getVisibility()
if (true === $allow
&& null !== $course->getVisibility()
&& Course::OPEN_WORLD === $course->getVisibility()
) {
$redirect = false;
}
@ -179,6 +178,7 @@ class CourseController extends ToolBaseController
$session = $request->getSession();
$userId = 0;
/** @var ?User $user */
$user = $this->getUser();
if (null !== $user) {
@ -206,8 +206,8 @@ class CourseController extends ToolBaseController
$isSpecialCourse = CourseManager::isSpecialCourse($courseId);
if ($user && $isSpecialCourse && (isset($_GET['autoreg']) && 1 === (int) $_GET['autoreg']) &&
CourseManager::subscribeUser($userId, $courseId, STUDENT)
if ($user && $isSpecialCourse && (isset($_GET['autoreg']) && 1 === (int) $_GET['autoreg'])
&& CourseManager::subscribeUser($userId, $courseId, STUDENT)
) {
$session->set('is_allowed_in_course', true);
}
@ -404,10 +404,12 @@ class CourseController extends ToolBaseController
EntityManagerInterface $em
): Response {
$courseId = $course->getId();
/** @var ?User $user */
$user = $this->getUser();
$fieldsRepo = $em->getRepository(ExtraField::class);
/** @var TagRepository $tagRepo */
$tagRepo = $em->getRepository(Tag::class);
@ -430,6 +432,7 @@ class CourseController extends ToolBaseController
$teachersData[] = $userData;
}
/** @var ExtraField $tagField */
$tagField = $fieldsRepo->findOneBy([
'itemType' => ExtraField::COURSE_FIELD_TYPE,
@ -450,30 +453,37 @@ class CourseController extends ToolBaseController
$courseDescription = $descriptionTool->getContent();
break;
case CCourseDescription::TYPE_OBJECTIVES:
$courseObjectives = $descriptionTool;
break;
case CCourseDescription::TYPE_TOPICS:
$courseTopics = $descriptionTool;
break;
case CCourseDescription::TYPE_METHODOLOGY:
$courseMethodology = $descriptionTool;
break;
case CCourseDescription::TYPE_COURSE_MATERIAL:
$courseMaterial = $descriptionTool;
break;
case CCourseDescription::TYPE_RESOURCES:
$courseResources = $descriptionTool;
break;
case CCourseDescription::TYPE_ASSESSMENT:
$courseAssessment = $descriptionTool;
break;
case CCourseDescription::TYPE_CUSTOM:
$courseCustom[] = $descriptionTool;
@ -556,7 +566,7 @@ class CourseController extends ToolBaseController
{
$sessionId = (int) $request->get('sid');
//$session = $this->getSession();
// $session = $this->getSession();
$responseData = [];
$ctoolRepo = $em->getRepository(CTool::class);
$sessionRepo = $em->getRepository(Session::class);
@ -600,6 +610,7 @@ class CourseController extends ToolBaseController
if ($ctool) {
$ctoolintroRepo = $em->getRepository(CToolIntro::class);
/** @var CToolIntro $ctoolintro */
$ctoolintro = $ctoolintroRepo->findOneBy(['courseTool' => $ctool]);
if ($ctoolintro) {
@ -654,6 +665,7 @@ class CourseController extends ToolBaseController
$em->flush();
if ($courseTool && !empty($ctoolintroId)) {
$ctoolintroRepo = Container::getToolIntroRepository();
/** @var CToolIntro $ctoolintro */
$ctoolintro = $ctoolintroRepo->find($ctoolintroId);
$ctoolintro->setCourseTool($courseTool);
@ -705,9 +717,9 @@ class CourseController extends ToolBaseController
$lpAutoLaunch = api_get_course_setting('enable_lp_auto_launch');
$session_id = api_get_session_id();
$allowAutoLaunchForCourseAdmins =
api_is_platform_admin() ||
api_is_allowed_to_edit(true, true) ||
api_is_coach();
api_is_platform_admin()
|| api_is_allowed_to_edit(true, true)
|| api_is_coach();
if (!empty($lpAutoLaunch)) {
if (2 === $lpAutoLaunch) {
@ -721,6 +733,7 @@ class CourseController extends ToolBaseController
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq();
$_SESSION[$session_key] = true;
header(sprintf('Location: %s', $url));
exit;
}
}
@ -757,6 +770,7 @@ class CourseController extends ToolBaseController
$_SESSION[$session_key] = true;
header(sprintf('Location: %s', $url));
exit;
}
}
@ -782,11 +796,12 @@ class CourseController extends ToolBaseController
} else {
$url = api_get_path(WEB_CODE_PATH).'forum/index.php?'.api_get_cidreq();
header(sprintf('Location: %s', $url));
exit;
}
}
if (('true' === api_get_setting('exercise.allow_exercise_auto_launch'))) {
if ('true' === api_get_setting('exercise.allow_exercise_auto_launch')) {
$exerciseAutoLaunch = (int) api_get_course_setting('enable_exercise_auto_launch');
if (2 === $exerciseAutoLaunch) {
if ($allowAutoLaunchForCourseAdmins) {
@ -799,6 +814,7 @@ class CourseController extends ToolBaseController
// Redirecting to the document
$url = api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq();
header(sprintf('Location: %s', $url));
exit;
}
} elseif (1 === $exerciseAutoLaunch) {
@ -834,6 +850,7 @@ class CourseController extends ToolBaseController
$url = api_get_path(WEB_CODE_PATH).
'exercise/overview.php?exerciseId='.$exerciseId.'&'.api_get_cidreq();
header(sprintf('Location: %s', $url));
exit;
}
}
@ -852,6 +869,7 @@ class CourseController extends ToolBaseController
// Redirecting to the document
$url = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq();
header("Location: $url");
exit;
}
}

@ -19,8 +19,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class EditorController extends BaseController
{
use ControllerTrait;
use ResourceControllerTrait;
use CourseControllerTrait;
use ResourceControllerTrait;
/**
* Get templates (left column when creating a document).

@ -23,7 +23,7 @@ class ExceptionController extends AbstractController
}
$showException = true;
//$name = $showException ? 'exception' : 'error';
// $name = $showException ? 'exception' : 'error';
$name = 'exception';
$code = $exception->getCode();
$format = 'html';
@ -44,8 +44,8 @@ class ExceptionController extends AbstractController
}
// default to a generic HTML exception
//$request->setRequestFormat('html');
//$template = sprintf('@ChamiloCore/Exception/%s.html.twig', $showException ? 'exception_full' : $name);
// $request->setRequestFormat('html');
// $template = sprintf('@ChamiloCore/Exception/%s.html.twig', $showException ? 'exception_full' : $name);
return $this->render($templateToLoad, [
'exception' => $exception,
@ -64,7 +64,7 @@ class ExceptionController extends AbstractController
$exception->setMessage($message);
$showException = true;
//$name = $showException ? 'exception' : 'error';
// $name = $showException ? 'exception' : 'error';
$name = 'exception';
$code = $exception->getCode();
$format = 'html';
@ -73,12 +73,12 @@ class ExceptionController extends AbstractController
$templateToLoad = sprintf('@ChamiloCore/Exception/%s.html.twig', 'exception_full');
// when not in debug, try to find a template for the specific HTTP status code and format
//if (!$showException) {
// if (!$showException) {
$template = sprintf('@ChamiloCore/Exception/%s%s.%s.twig', $name, $code, $format);
if ($loader->exists($template)) {
$templateToLoad = $template;
}
//}
// }
// try to find a template for the given format
$template = sprintf('@ChamiloCore/Exception/%s.%s.twig', $name, $format);
@ -87,7 +87,7 @@ class ExceptionController extends AbstractController
}
// default to a generic HTML exception
//$request->setRequestFormat('html');
// $request->setRequestFormat('html');
return $this->render($templateToLoad, [
'exception' => $exception,

@ -20,16 +20,12 @@ class IndexController extends BaseController
* @Route("/login", name="login", methods={"GET", "POST"}, options={"expose"=true})
* @Route("/faq", name="faq", methods={"GET", "POST"}, options={"expose"=true})
* @Route("/demo", name="demo", methods={"GET", "POST"}, options={"expose"=true})
*
* @Route("/course/{cid}/home", name="chamilo_core_course_home")
* @Route("/courses", name="courses", methods={"GET", "POST"}, options={"expose"=true})
*
* @Route("/catalog/{slug}", name="catalog", methods={"GET", "POST"}, options={"expose"=true})
* @Route("/resources/document/{nodeId}/manager", methods={"GET"}, name="resources_filemanager")
* @Route("/account/home", name="account", options={"expose"=true}, name="chamilo_core_account_home")
*
* @Route("/social", name="social", options={"expose"=true}, name="chamilo_core_socialnetwork")
*
* @Route("/admin", name="admin", options={"expose"=true})
*/
#[Route('/sessions', name: 'sessions')]
@ -41,6 +37,8 @@ class IndexController extends BaseController
/**
* Use only in PHPUnit tests.
*
* @param mixed $name
*/
public function classic($name): Response
{
@ -54,6 +52,7 @@ class IndexController extends BaseController
$fileToLoad = $mainPath.$name;
ob_start();
require_once $fileToLoad;
$content = ob_get_contents();
ob_end_clean();

@ -44,7 +44,7 @@ class PlatformConfigurationController extends AbstractController
'platform.cookie_warning',
'platform.show_tabs',
//'admin.admin_chamilo_announcements_disable',
// 'admin.admin_chamilo_announcements_disable',
'admin.administrator_name',
'admin.administrator_surname',
@ -56,7 +56,7 @@ class PlatformConfigurationController extends AbstractController
'registration.allow_terms_conditions',
'agenda.personal_calendar_show_sessions_occupation',
//'agenda.agenda_reminders',
// 'agenda.agenda_reminders',
'agenda.agenda_collective_invitations',
'social.social_enable_messages_feedback',

@ -42,9 +42,9 @@ use ZipStream\ZipStream;
#[Route('/r')]
class ResourceController extends AbstractResourceController implements CourseControllerInterface
{
use ControllerTrait;
use CourseControllerTrait;
use ResourceControllerTrait;
use ControllerTrait;
/**
* @Route("/{tool}/{type}/{id}/disk_space", methods={"GET", "POST"}, name="chamilo_core_resource_disk_space")
@ -192,7 +192,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
}
$zipName = $resourceNode->getSlug().'.zip';
//$rootNodePath = $resourceNode->getPathForDisplay();
// $rootNodePath = $resourceNode->getPathForDisplay();
$resourceNodeRepo = $repo->getResourceNodeRepository();
$type = $repo->getResourceType();
@ -221,16 +221,16 @@ class ResourceController extends AbstractResourceController implements CourseCon
// Define suitable options for ZipStream Archive.
$options = new Archive();
$options->setContentType('application/octet-stream');
//initialise zipstream with output zip filename and options.
// initialise zipstream with output zip filename and options.
$zip = new ZipStream($zipName, $options);
/** @var ResourceNode $node */
foreach ($children as $node) {
$stream = $repo->getResourceNodeFileStream($node);
$fileName = $node->getResourceFile()->getOriginalName();
//$fileToDisplay = basename($node->getPathForDisplay());
//$fileToDisplay = str_replace($rootNodePath, '', $node->getPathForDisplay());
//error_log($fileToDisplay);
// $fileToDisplay = basename($node->getPathForDisplay());
// $fileToDisplay = str_replace($rootNodePath, '', $node->getPathForDisplay());
// error_log($fileToDisplay);
$zip->addFileFromStream($fileName, $stream);
}
$zip->finish();
@ -239,7 +239,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
$disposition = $response->headers->makeDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
$zipName //Transliterator::transliterate($zipName)
$zipName // Transliterator::transliterate($zipName)
);
$response->headers->set('Content-Disposition', $disposition);
$response->headers->set('Content-Type', 'application/octet-stream');
@ -372,6 +372,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
$forceDownload = true;
break;
case 'show':
default:
$forceDownload = false;
@ -458,7 +459,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
}
);
//Transliterator::transliterate($fileName)
// Transliterator::transliterate($fileName)
$disposition = $response->headers->makeDisposition(
$forceDownload ? ResponseHeaderBag::DISPOSITION_ATTACHMENT : ResponseHeaderBag::DISPOSITION_INLINE,
$fileName

@ -27,8 +27,7 @@ class SecurityController extends AbstractController
public function __construct(
private readonly SerializerInterface $serializer,
private readonly TrackELoginRecordRepository $trackELoginRecordRepository
) {
}
) {}
#[Route('/login_json', name: 'login_json', methods: ['POST'])]
public function loginJson(Request $request, EntityManager $entityManager, SettingsManager $settingsManager, TokenStorageInterface $tokenStorage): Response
@ -46,9 +45,9 @@ class SecurityController extends AbstractController
$user = $this->getUser();
$extraFieldValuesRepository = $entityManager->getRepository(ExtraFieldValues::class);
$legalTermsRepo = $entityManager->getRepository(Legal::class);
if ($user->hasRole('ROLE_STUDENT') &&
'true' === $settingsManager->getSetting('allow_terms_conditions') &&
'login' === $settingsManager->getSetting('load_term_conditions_section')
if ($user->hasRole('ROLE_STUDENT')
&& 'true' === $settingsManager->getSetting('allow_terms_conditions')
&& 'login' === $settingsManager->getSetting('load_term_conditions_section')
) {
$termAndConditionStatus = false;
$extraValue = $extraFieldValuesRepository->findLegalAcceptByItemId($user->getId());
@ -78,8 +77,8 @@ class SecurityController extends AbstractController
return new JsonResponse($responseData, Response::HTTP_OK);
}
}
//$error = $authenticationUtils->getLastAuthenticationError();
//$lastUsername = $authenticationUtils->getLastUsername();
// $error = $authenticationUtils->getLastAuthenticationError();
// $lastUsername = $authenticationUtils->getLastUsername();
$data = null;
if ($user) {

@ -56,6 +56,7 @@ class SessionController extends AbstractController
/** @var EntityRepository $fieldsRepo */
$fieldsRepo = $em->getRepository(ExtraField::class);
/** @var TagRepository $tagRepo */
$tagRepo = $em->getRepository(Tag::class);
@ -83,6 +84,7 @@ class SessionController extends AbstractController
$courseCoaches = $userRepo->getCoachesForSessionCourse($session, $sessionCourse);
$coachesData = [];
/** @var User $courseCoach */
foreach ($courseCoaches as $courseCoach) {
$coachData = [
@ -117,35 +119,43 @@ class SessionController extends AbstractController
if (!empty($descriptionsData)) {
foreach ($descriptionsData as $descriptionInfo) {
$type = $descriptionInfo->getDescriptionType();
switch ($type) {
case CCourseDescription::TYPE_DESCRIPTION:
$courseDescription[] = $descriptionInfo;
break;
case CCourseDescription::TYPE_OBJECTIVES:
$courseObjectives[] = $descriptionInfo;
break;
case CCourseDescription::TYPE_TOPICS:
$courseTopics[] = $descriptionInfo;
break;
case CCourseDescription::TYPE_METHODOLOGY:
$courseMethodology[] = $descriptionInfo;
break;
case CCourseDescription::TYPE_COURSE_MATERIAL:
$courseMaterial[] = $descriptionInfo;
break;
case CCourseDescription::TYPE_RESOURCES:
$courseResources[] = $descriptionInfo;
break;
case CCourseDescription::TYPE_ASSESSMENT:
$courseAssessment[] = $descriptionInfo;
break;
case CCourseDescription::TYPE_CUSTOM:
$courseCustom[] = $descriptionInfo;
@ -223,7 +233,7 @@ class SessionController extends AbstractController
'essence' => $essence,
'session_extra_fields' => $sessionValues->getAllValuesForAnItem($session->getId(), null, true),
'has_requirements' => $hasRequirements,
//'sequences' => $sessionRequirements,
// 'sequences' => $sessionRequirements,
'is_premium' => $sessionIsPremium,
'show_tutor' => 'true' === api_get_setting('show_session_coach'),
'page_url' => api_get_path(WEB_PATH).sprintf('sessions/%s/about/', $session->getId()),

@ -19,6 +19,7 @@ class ToolController extends AbstractController
* Updates the table tool and resource_type with the content of tools.yml.
*
* @Security("is_granted('ROLE_ADMIN')")
*
* @Route("/update", methods={"GET"})
*/
public function profileAction(ToolChain $toolChain): Response

@ -35,7 +35,7 @@ class AccessUserFixtures extends Fixture implements ContainerAwareInterface
$toolChain->createTools();
// Defined in AccessGroupFixtures.php.
//$group = $this->getReference('GROUP_ADMIN');
// $group = $this->getReference('GROUP_ADMIN');
$admin = (new User())
->setSkipResourceNode(true)
@ -50,7 +50,7 @@ class AccessUserFixtures extends Fixture implements ContainerAwareInterface
->setTimezone($timezone)
->addUserAsAdmin()
->addRole('ROLE_GLOBAL_ADMIN') // Only for the first user
//->addGroup($group)
// ->addGroup($group)
;
$manager->persist($admin);

@ -27,6 +27,7 @@ class AccessUserUrlFixtures extends Fixture implements ContainerAwareInterface
public function load(ObjectManager $manager): void
{
$container = $this->container;
/** @var User $admin */
$admin = $this->getReference(AccessUserFixtures::ADMIN_USER_REFERENCE);
$anon = $this->getReference(AccessUserFixtures::ANON_USER_REFERENCE);

@ -30,13 +30,13 @@ class UserRelUserDataPersister implements ContextAwareDataPersisterInterface
{
$result = $this->decorated->persist($data, $context);
if ($data instanceof UserRelUser && (
//($context['collection_operation_name'] ?? null) === 'post' ||
//($context['graphql_operation_name'] ?? null) === 'create'
// ($context['collection_operation_name'] ?? null) === 'post' ||
// ($context['graphql_operation_name'] ?? null) === 'create'
($context['item_operation_name'] ?? null) === 'put' // on update
)
) {
if (UserRelUser::USER_RELATION_TYPE_FRIEND === $data->getRelationType()) {
//error_log((string)$data->getRelationType());
// error_log((string)$data->getRelationType());
$repo = $this->entityManager->getRepository(UserRelUser::class);
// Check if the inverse connection is a friend request.
$connection = $repo->findOneBy(

@ -7,8 +7,8 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\DataProvider\Extension;
use ApiPlatform\Doctrine\Orm\Extension\QueryCollectionExtensionInterface;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Metadata\Operation;
use Chamilo\CoreBundle\Entity\User;
@ -17,15 +17,14 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Security;
final class CCalendarEventExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface
final class CCalendarEventExtension implements QueryCollectionExtensionInterface // , QueryItemExtensionInterface
{
use CourseLinkExtensionTrait;
public function __construct(
private readonly Security $security,
private readonly RequestStack $requestStack
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,
@ -59,7 +58,7 @@ final class CCalendarEventExtension implements QueryCollectionExtensionInterface
string $operationName = null,
array $context = []
): void {
//$this->addWhere($queryBuilder, $resourceClass);
// $this->addWhere($queryBuilder, $resourceClass);
}
private function addWhere(QueryBuilder $qb, string $resourceClass): void
@ -111,9 +110,9 @@ final class CCalendarEventExtension implements QueryCollectionExtensionInterface
$this->addCourseLinkCondition($qb, $courseId, $sessionId, $groupId);
}
//$qb->leftJoin("$alias.receivers", 'r');
//$qb->leftJoin("$alias.receivers", 'r', Join::WITH, "r.receiver = :current OR $alias.sender = :current ");
//$qb->leftJoin("$alias.receivers", 'r');
// $qb->leftJoin("$alias.receivers", 'r');
// $qb->leftJoin("$alias.receivers", 'r', Join::WITH, "r.receiver = :current OR $alias.sender = :current ");
// $qb->leftJoin("$alias.receivers", 'r');
/*$qb->andWhere(
$qb->expr()->orX(
$qb->andWhere(

@ -7,7 +7,7 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\DataProvider\Extension;
use ApiPlatform\Doctrine\Orm\Extension\QueryCollectionExtensionInterface;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Metadata\Operation;
use Chamilo\CourseBundle\Entity\CDocument;
@ -19,15 +19,14 @@ use Symfony\Component\Security\Core\Security;
/**
* Extension is called when loading api/documents.json.
*/
final class CDocumentExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface
final class CDocumentExtension implements QueryCollectionExtensionInterface // , QueryItemExtensionInterface
{
use CourseLinkExtensionTrait;
public function __construct(
private readonly Security $security,
private readonly RequestStack $requestStack
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,
@ -80,7 +79,7 @@ final class CDocumentExtension implements QueryCollectionExtensionInterface //,
/*$queryBuilder->
andWhere('node.creator = :current_user')
;*/
//$queryBuilder->andWhere(sprintf('%s.node.creator = :current_user', $rootAlias));
//$queryBuilder->setParameter('current_user', $user->getId());
// $queryBuilder->andWhere(sprintf('%s.node.creator = :current_user', $rootAlias));
// $queryBuilder->setParameter('current_user', $user->getId());
}
}

@ -22,8 +22,7 @@ class CStudentPublicationExtension implements QueryCollectionExtensionInterface
public function __construct(
private readonly Security $security,
private readonly RequestStack $requestStack
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,

@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
final class CToolIntroExtension implements QueryCollectionExtensionInterface
{
@ -24,8 +24,7 @@ final class CToolIntroExtension implements QueryCollectionExtensionInterface
public function __construct(
private readonly Security $security,
private readonly RequestStack $requestStack
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,

@ -14,7 +14,7 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
/**
* Extension is called when loading api/courses.json.
@ -23,8 +23,7 @@ final class CourseExtension implements QueryCollectionExtensionInterface
{
public function __construct(
private readonly Security $security
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,

@ -12,8 +12,7 @@ trait CourseLinkExtensionTrait
{
public function __construct(
private readonly Security $security
) {
}
) {}
protected function addCourseLinkWithVisibilityConditions(
QueryBuilder $queryBuilder,
@ -45,8 +44,8 @@ trait CourseLinkExtensionTrait
;
$allowDraft =
$this->security->isGranted('ROLE_ADMIN') ||
$this->security->isGranted('ROLE_CURRENT_COURSE_TEACHER');
$this->security->isGranted('ROLE_ADMIN')
|| $this->security->isGranted('ROLE_CURRENT_COURSE_TEACHER');
if (!$allowDraft) {
$queryBuilder

@ -15,14 +15,13 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
final class CourseRelUserExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface
final class CourseRelUserExtension implements QueryCollectionExtensionInterface // , QueryItemExtensionInterface
{
public function __construct(
private readonly Security $security
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,

@ -15,15 +15,14 @@ use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Core\Security;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
final class MessageExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface
final class MessageExtension implements QueryCollectionExtensionInterface // , QueryItemExtensionInterface
{
public function __construct(
private readonly Security $security
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,
@ -57,8 +56,8 @@ final class MessageExtension implements QueryCollectionExtensionInterface //, Qu
string $operationName = null,
array $context = []
): void {
//error_log('applyToItem1');
//$this->addWhere($queryBuilder, $resourceClass);
// error_log('applyToItem1');
// $this->addWhere($queryBuilder, $resourceClass);
}
private function addWhere(QueryBuilder $qb, string $resourceClass): void
@ -75,10 +74,10 @@ final class MessageExtension implements QueryCollectionExtensionInterface //, Qu
$user = $this->security->getUser();
$alias = $qb->getRootAliases()[0];
//$qb->leftJoin("$alias.receivers", 'r');
// $qb->leftJoin("$alias.receivers", 'r');
$qb->leftJoin("$alias.receivers", 'r', Join::WITH, "r.receiver = :current OR $alias.sender = :current ");
//$qb->leftJoin("$alias.receivers", 'r');
// $qb->leftJoin("$alias.receivers", 'r');
/*$qb->andWhere(
$qb->expr()->orX(
$qb->andWhere(
@ -107,9 +106,9 @@ final class MessageExtension implements QueryCollectionExtensionInterface //, Qu
$qb->setParameters([
'current' => $user,
'deleted' => Message::MESSAGE_STATUS_DELETED,
//'currentList' => [$user->getId()],
// 'currentList' => [$user->getId()],
'inbox' => Message::MESSAGE_TYPE_INBOX,
//'outbox' => Message::MESSAGE_TYPE_OUTBOX,
// 'outbox' => Message::MESSAGE_TYPE_OUTBOX,
'invitation' => Message::MESSAGE_TYPE_INVITATION,
'conversation' => Message::MESSAGE_TYPE_CONVERSATION,
]);

@ -18,8 +18,7 @@ class MessageRelUserExtension implements QueryCollectionExtensionInterface
{
public function __construct(
private readonly Security $security
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,

@ -13,14 +13,13 @@ use Chamilo\CoreBundle\Entity\MessageTag;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Core\Security;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
final class MessageTagExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface
final class MessageTagExtension implements QueryCollectionExtensionInterface // , QueryItemExtensionInterface
{
public function __construct(
private readonly Security $security
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,

@ -14,16 +14,15 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Security;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
final class PageExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface
final class PageExtension implements QueryCollectionExtensionInterface // , QueryItemExtensionInterface
{
public function __construct(
private readonly Security $security,
private readonly RequestStack $requestStack
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,
@ -43,7 +42,7 @@ final class PageExtension implements QueryCollectionExtensionInterface //, Query
string $operationName = null,
array $context = []
): void {
//$this->addWhere($queryBuilder, $resourceClass);
// $this->addWhere($queryBuilder, $resourceClass);
}
private function addWhere(QueryBuilder $qb, string $resourceClass): void

@ -16,18 +16,17 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Security;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
/**
* Extension is called when loading api/personal_files.json.
*/
final class PersonalFileExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface
final class PersonalFileExtension implements QueryCollectionExtensionInterface // , QueryItemExtensionInterface
{
public function __construct(
private readonly Security $security,
private readonly RequestStack $requestStack
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,

@ -18,15 +18,14 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security;
//use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface;
final class SessionRelUserExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface
final class SessionRelUserExtension implements QueryCollectionExtensionInterface // , QueryItemExtensionInterface
{
public function __construct(
private readonly Security $security,
private readonly RequestStack $requestStack
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,

@ -17,8 +17,7 @@ class SocialPostExtension implements QueryCollectionExtensionInterface
{
public function __construct(
private readonly SettingsManager $settingsManager
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,

@ -19,8 +19,7 @@ final class TrackEExerciseExtension implements QueryCollectionExtensionInterface
{
public function __construct(
private readonly Security $security
) {
}
) {}
public function applyToCollection(
QueryBuilder $queryBuilder,

@ -17,8 +17,7 @@ class UserItemDataProvider implements ItemDataProviderInterface, RestrictedDataP
public function __construct(
private readonly UserRepository $repository,
private readonly NameConvention $nameConvention
) {
}
) {}
public function getItem(string $resourceClass, $id, string $operationName = null, array $context = [])
{

@ -136,6 +136,7 @@ abstract class AbstractResource
$sendTo['groups'][] = (int) $id;
break;
case 'USER':
$sendTo['users'][] = (int) $id;
@ -176,6 +177,7 @@ abstract class AbstractResource
;
$rights = [];
switch ($visibility) {
case ResourceLink::VISIBILITY_PENDING:
case ResourceLink::VISIBILITY_DRAFT:
@ -198,9 +200,9 @@ abstract class AbstractResource
if ($this->hasResourceNode()) {
$resourceNode = $this->getResourceNode();
$exists = $resourceNode->getResourceLinks()->exists(
fn ($key, $element) => $course === $element->getCourse() &&
$session === $element->getSession() &&
$group === $element->getGroup()
fn ($key, $element) => $course === $element->getCourse()
&& $session === $element->getSession()
&& $group === $element->getGroup()
);
if ($exists) {

@ -9,6 +9,4 @@ namespace Chamilo\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class AgendaEventSubscriber extends AgendaEventInvitee
{
}
class AgendaEventSubscriber extends AgendaEventInvitee {}

@ -30,7 +30,7 @@ class Asset implements Stringable
public const SCORM = 'scorm';
public const WATERMARK = 'watermark';
//public const CSS = 'css';
// public const CSS = 'css';
public const EXTRA_FIELD = 'ef';
public const COURSE_CATEGORY = 'course_category';
public const SKILL = 'skill';
@ -201,7 +201,7 @@ class Asset implements Stringable
{
$data = $this->getDimensions();
if ([] !== $data) {
//$data = explode(',', $data);
// $data = explode(',', $data);
return (int) $data[0];
}
@ -226,7 +226,7 @@ class Asset implements Stringable
$data = $this->getDimensions();
if ([] !== $data) {
//$data = explode(',', $data);
// $data = explode(',', $data);
return (int) $data[1];
}

@ -98,7 +98,7 @@ class Career
return $this->status;
}
public function getPromotions(): array | ArrayCollection | Collection
public function getPromotions(): array|ArrayCollection|Collection
{
return $this->promotions;
}

@ -230,12 +230,12 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
/**
* ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SpecificFieldValues", mappedBy="course").
*/
//protected $specificFieldValues;
// protected $specificFieldValues;
/**
* ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SharedSurvey", mappedBy="course").
*/
//protected $sharedSurveys;
// protected $sharedSurveys;
#[ORM\Column(name: 'directory', type: 'string', length: 40, unique: false, nullable: true)]
protected ?string $directory = null;
@ -334,7 +334,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
/**
* ORM\OneToMany(targetEntity="CurriculumCategory", mappedBy="course").
*/
//protected $curriculumCategories;
// protected $curriculumCategories;
#[ORM\ManyToOne(targetEntity: Room::class)]
#[ORM\JoinColumn(name: 'room_id', referencedColumnName: 'id')]
@ -374,8 +374,8 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
$this->subscribe = true;
$this->unsubscribe = false;
$this->sticky = false;
//$this->specificFieldValues = new ArrayCollection();
//$this->sharedSurveys = new ArrayCollection();
// $this->specificFieldValues = new ArrayCollection();
// $this->sharedSurveys = new ArrayCollection();
}
public function __toString(): string
@ -553,7 +553,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
$teacherSubscriptions = new ArrayCollection();
foreach ($this->users as $subscription) {
if ($subscription->getStatus() === CourseRelUser::TEACHER) {
if (CourseRelUser::TEACHER === $subscription->getStatus()) {
$teacherSubscriptions->add($subscription);
}
}
@ -573,7 +573,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
/*$criteria = Criteria::create()->where(
Criteria::expr()->eq('groups', $group)
);*/
//return $this->getGroups()->contains($group);
// return $this->getGroups()->contains($group);
}
public function getId(): ?int
@ -923,6 +923,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
$this->currentSession = $session;
}*/
$list = $this->getSessions();
/** @var SessionRelCourse $item */
foreach ($list as $item) {
if ($item->getSession()->getId() === $session->getId()) {
@ -951,6 +952,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
public function setCurrentUrl(AccessUrl $url): self
{
$urlList = $this->getUrls();
/** @var AccessUrlRelCourse $item */
foreach ($urlList as $item) {
if ($item->getUrl()->getId() === $url->getId()) {

@ -63,6 +63,7 @@ class CourseCategory implements Stringable
#[ORM\Id]
#[ORM\GeneratedValue]
protected ?int $id = null;
/**
* @var Collection|CourseCategory[]
*/
@ -93,6 +94,7 @@ class CourseCategory implements Stringable
#[Groups(['course_category:read', 'course_category:write'])]
#[ORM\Column(name: 'description', type: 'text', nullable: true)]
protected ?string $description = null;
/**
* @var Collection<int, AccessUrlRelCourseCategory>
*/
@ -103,6 +105,7 @@ class CourseCategory implements Stringable
orphanRemoval: true
)]
protected Collection $urls;
/**
* @var Collection<int, Course>
*/

@ -50,8 +50,8 @@ class CourseRelUser implements Stringable
use UserTrait;
public const TEACHER = 1;
//public const SESSION_ADMIN = 3;
//public const DRH = 4;
// public const SESSION_ADMIN = 3;
// public const DRH = 4;
public const STUDENT = 5;
#[ORM\Column(name: 'id', type: 'integer')]

@ -34,9 +34,7 @@ class CourseRelUserCatalogue implements Stringable
#[ORM\Column(name: 'visible', type: 'integer')]
protected int $visible;
public function __construct()
{
}
public function __construct() {}
public function __toString(): string
{

@ -87,12 +87,14 @@ class ExtraField
protected ?bool $changeable = null;
#[ORM\Column(name: 'filter', type: 'boolean', nullable: true, unique: false)]
protected ?bool $filter = null;
/**
* @var Collection<int, ExtraFieldOptions>
*/
#[Groups(['extra_field:read'])]
#[ORM\OneToMany(targetEntity: ExtraFieldOptions::class, mappedBy: 'field')]
protected Collection $options;
/**
* @var Tag[]|Collection
*/
@ -111,6 +113,7 @@ class ExtraField
$this->changeable = false;
$this->filter = false;
}
/**
* Get id.
*
@ -140,6 +143,7 @@ class ExtraField
return $this;
}
/**
* @return string
*/
@ -153,6 +157,7 @@ class ExtraField
return $this;
}
/**
* @return string
*/
@ -166,6 +171,7 @@ class ExtraField
return $this;
}
/**
* @return string
*/
@ -179,6 +185,7 @@ class ExtraField
return $this;
}
/**
* @return int
*/
@ -192,6 +199,7 @@ class ExtraField
return $this;
}
/**
* @return bool
*/
@ -245,6 +253,7 @@ class ExtraField
return $this;
}
/**
* @return Collection<int, ExtraFieldOptions>
*/
@ -258,6 +267,7 @@ class ExtraField
return $this;
}
/**
* @return Tag[]|Collection
*/

@ -45,6 +45,7 @@ class ExtraFieldValues
#[ORM\ManyToOne(targetEntity: Asset::class)]
#[ORM\JoinColumn(name: 'asset_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
protected ?Asset $asset = null;
/**
* Item id can be: userId, courseId, sessionId, etc.
*/
@ -89,6 +90,7 @@ class ExtraFieldValues
{
return $this->comment;
}
/**
* Get id.
*

@ -17,8 +17,8 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity]
class GradebookCategory
{
use UserTrait;
use CourseTrait;
use UserTrait;
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]

@ -14,8 +14,8 @@ use Gedmo\Timestampable\Traits\TimestampableEntity;
#[ORM\Entity]
class GradebookComment
{
use UserTrait;
use TimestampableEntity;
use UserTrait;
#[ORM\Column(name: 'id', type: 'bigint')]
#[ORM\Id]

@ -22,12 +22,11 @@ class CourseListener
public function __construct(
protected ToolChain $toolChain,
protected SettingsManager $settingsManager
) {
}
) {}
public function prePersist(Course $course, PrePersistEventArgs $args): void
{
///$this->checkLimit($repo, $course, $url);
// /$this->checkLimit($repo, $course, $url);
$this->toolChain->addToolsInCourse($course);
}

@ -14,8 +14,7 @@ class MessageListener
{
public function __construct(
private MessageBusInterface $bus
) {
}
) {}
public function postPersist(Message $message, PostPersistEventArgs $args): void
{

@ -31,6 +31,9 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\Security;
use const JSON_THROW_ON_ERROR;
use const PATHINFO_EXTENSION;
class ResourceListener
{
use AccessUrlListenerTrait;
@ -40,8 +43,7 @@ class ResourceListener
protected ToolChain $toolChain,
protected RequestStack $request,
protected Security $security
) {
}
) {}
/**
* Only in creation.
@ -132,7 +134,7 @@ class ResourceListener
}
if (null === $parentUrl) {
throw new InvalidArgumentException(('The resource needs an AccessUrl: use $resource->addAccessUrl()'));
throw new InvalidArgumentException('The resource needs an AccessUrl: use $resource->addAccessUrl()');
}
$parentNode = $parentUrl;
}
@ -184,8 +186,8 @@ class ResourceListener
if (null === $currentUser) {
$currentUser = $parentNode->getCreator();
}
$valid = $parentNode->getCreator()->getUsername() === $currentUser->getUsername() ||
$parentNode->getId() === $currentUser->getResourceNode()->getId();
$valid = $parentNode->getCreator()->getUsername() === $currentUser->getUsername()
|| $parentNode->getId() === $currentUser->getResourceNode()->getId();
if (!$valid) {
$msg = sprintf('User %s cannot add a file to another user', $currentUser->getUsername());
@ -269,15 +271,15 @@ class ResourceListener
$resourceNode->setParent($parentResourceNode);
}
//error_log('Resource listener preUpdate');
//$this->setLinks($resource, $eventArgs->getEntityManager());
// error_log('Resource listener preUpdate');
// $this->setLinks($resource, $eventArgs->getEntityManager());
}
public function postUpdate(AbstractResource $resource, PostUpdateEventArgs $eventArgs): void
{
//error_log('resource listener postUpdate');
//$em = $eventArgs->getEntityManager();
//$this->updateResourceName($resource, $resource->getResourceName(), $em);
// error_log('resource listener postUpdate');
// $em = $eventArgs->getEntityManager();
// $this->updateResourceName($resource, $resource->getResourceName(), $em);
}
public function updateResourceName(AbstractResource $resource): void
@ -290,7 +292,7 @@ class ResourceListener
$extension = $this->slugify->slugify(pathinfo($resourceName, PATHINFO_EXTENSION));
if (empty($extension)) {
//$slug = $this->slugify->slugify($resourceName);
// $slug = $this->slugify->slugify($resourceName);
}
/*$originalExtension = pathinfo($resourceName, PATHINFO_EXTENSION);
$originalBasename = \basename($resourceName, $originalExtension);

@ -16,7 +16,7 @@ use Symfony\Component\Security\Core\Security;
class ResourceNodeListener
{
//protected $accessUrl;
// protected $accessUrl;
public function __construct(
protected SlugifyInterface $slugify,
@ -24,8 +24,7 @@ class ResourceNodeListener
protected RequestStack $request,
protected Security $security,
protected ResourceNodeRepository $resourceNodeRepository
) {
}
) {}
/*public function prePersist(ResourceNode $resourceNode, LifecycleEventArgs $event)
{

@ -25,8 +25,7 @@ class SessionListener
public function __construct(
protected RequestStack $request,
protected Security $security
) {
}
) {}
/**
* This code is executed when a new session is created.
@ -45,15 +44,13 @@ class SessionListener
}
$session->addAccessUrl($accessUrl);
}
//$this->checkLimit($repo, $url);
// $this->checkLimit($repo, $url);
}
/**
* This code is executed when a session is updated.
*/
public function preUpdate(Session $session, PreUpdateEventArgs $args): void
{
}
public function preUpdate(Session $session, PreUpdateEventArgs $args): void {}
/*protected function checkLimit(SessionRepository $repo, AccessUrl $url): void
{

@ -23,8 +23,7 @@ class SkillRelUserListener
private readonly RouterInterface $router,
private readonly TranslatorInterface $translator,
protected Security $security
) {
}
) {}
public function postPersist(SkillRelUser $skillRelUser, PostPersistEventArgs $event): void
{

@ -22,8 +22,7 @@ class UserListener
private UserRepository $userRepository,
private Security $security,
private readonly TranslatorInterface $translator
) {
}
) {}
/**
* This code is executed when a new user is created.

@ -15,8 +15,7 @@ use Exception;
class UserRelUserListener
{
public function __construct(
) {
}
) {}
public function prePersist(UserRelUser $userRelUser, PrePersistEventArgs $args): void
{

@ -180,7 +180,8 @@ class Message
return $this->receivers
->filter(
fn (MessageRelUser $messageRelUser) => MessageRelUser::TYPE_TO === $messageRelUser->getReceiverType()
)->getValues();
)->getValues()
;
}
#[Groups(['message:read'])]

@ -21,11 +21,11 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource(
operations: [
new Get(security: 'is_granted(\'ROLE_USER\')'),
new Put(security: 'is_granted(\'ROLE_ADMIN\')'),
new Delete(security: 'is_granted(\'ROLE_ADMIN\')'),
new GetCollection(security: 'is_granted(\'ROLE_USER\')'),
new Post(security: 'is_granted(\'ROLE_ADMIN\')'),
new Get(security: "is_granted('ROLE_USER')"),
new Put(security: "is_granted('ROLE_ADMIN')"),
new Delete(security: "is_granted('ROLE_ADMIN')"),
new GetCollection(security: "is_granted('ROLE_USER')"),
new Post(security: "is_granted('ROLE_ADMIN')"),
],
normalizationContext: [
'groups' => ['page_category:read'],
@ -56,8 +56,9 @@ class PageCategory
#[Assert\NotBlank]
#[ORM\Column(name: 'type', type: 'string')]
protected string $type;
/**
* @var Collection|Page[]
* @var Collection<int, Page>
*/
#[ORM\OneToMany(mappedBy: 'category', targetEntity: Page::class, cascade: ['persist'])]
protected Collection $pages;
@ -99,7 +100,11 @@ class PageCategory
return $this;
}
public function getPages()
/**
* @return ArrayCollection<int, Page>
*/
public function getPages(): ArrayCollection
{
return $this->pages;
}

@ -45,9 +45,7 @@ class PersonalFile extends AbstractResource implements ResourceInterface, String
#[Groups(['personal_file:read'])]
#[ORM\Column(name: 'title', type: 'string', length: 255, nullable: false)]
protected string $title;
public function __construct()
{
}
public function __construct() {}
public function __toString(): string
{
return $this->getTitle();

@ -30,9 +30,9 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: NestedTreeRepository::class)]
class ResourceComment
{
use TimestampableTypedEntity;
use TimestampableAgoTrait;
use NestedSetEntity;
use TimestampableAgoTrait;
use TimestampableTypedEntity;
#[ORM\Id]
#[ORM\Column(type: 'bigint')]

@ -28,7 +28,7 @@ use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
//
//* attributes={"security"="is_granted('ROLE_ADMIN')"},
// * attributes={"security"="is_granted('ROLE_ADMIN')"},
/**
* @Vich\Uploadable
*/
@ -102,6 +102,7 @@ class ResourceFile implements Stringable
#[Groups(['resource_file:read', 'resource_node:read', 'document:read', 'message:read'])]
#[ORM\Column(type: 'integer')]
protected ?int $size = 0;
/**
* @Vich\UploadableField(
* mapping="resources",
@ -125,6 +126,7 @@ class ResourceFile implements Stringable
protected ?string $crop = null;
#[ORM\OneToOne(mappedBy: 'resourceFile', targetEntity: ResourceNode::class)]
protected ResourceNode $resourceNode;
/**
* @var string[]
*/
@ -140,6 +142,7 @@ class ResourceFile implements Stringable
protected ?bool $text = null;
#[ORM\Column(name: 'description', type: 'text', nullable: true)]
protected ?string $description = null;
/**
* @var DateTime|DateTimeImmutable
*/
@ -194,6 +197,7 @@ class ResourceFile implements Stringable
{
return $this->crop;
}
/**
* $crop example: 100,100,100,100 = width,height,x,y.
*/
@ -283,7 +287,7 @@ class ResourceFile implements Stringable
{
$data = $this->getDimensions();
if ([] !== $data) {
//$data = explode(',', $data);
// $data = explode(',', $data);
return (int) $data[0];
}
@ -293,7 +297,7 @@ class ResourceFile implements Stringable
{
$data = $this->getDimensions();
if ([] !== $data) {
//$data = explode(',', $data);
// $data = explode(',', $data);
return (int) $data[1];
}
@ -324,7 +328,7 @@ class ResourceFile implements Stringable
return $this->file;
}
public function setFile(File|UploadedFile|null $file = null): self
public function setFile(File|UploadedFile $file = null): self
{
$this->file = $file;
if (null !== $file) {

@ -35,7 +35,7 @@ use Symfony\Component\Uid\Uuid;
use Symfony\Component\Uid\UuidV4;
use Symfony\Component\Validator\Constraints as Assert;
//* attributes={"security"="is_granted('ROLE_ADMIN')"},
// * attributes={"security"="is_granted('ROLE_ADMIN')"},
/**
* Base entity for all resources.
@ -71,8 +71,8 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiFilter(filterClass: SearchFilter::class, properties: ['title' => 'partial'])]
class ResourceNode implements Stringable
{
use TimestampableTypedEntity;
use TimestampableAgoTrait;
use TimestampableTypedEntity;
public const PATH_SEPARATOR = '/';
@ -110,6 +110,7 @@ class ResourceNode implements Stringable
#[Groups(['ctool:read', 'c_tool_intro:read'])]
#[ORM\OneToMany(mappedBy: 'resourceNode', targetEntity: ResourceLink::class, cascade: ['persist', 'remove'])]
protected Collection $resourceLinks;
/**
* ResourceFile available file for this node.
*/
@ -154,7 +155,7 @@ class ResourceNode implements Stringable
*
* ORM\OneToOne(targetEntity="Chamilo\CoreBundle\Entity\Illustration", mappedBy="resourceNode")
*/
//protected $illustration;
// protected $illustration;
/**
* @var Collection<int, ResourceComment>
@ -216,7 +217,7 @@ class ResourceNode implements Stringable
public function getPathForDisplay(): string
{
return $this->path;
//return $this->convertPathForDisplay($this->path);
// return $this->convertPathForDisplay($this->path);
}
public function getUuid(): ?UuidV4
@ -290,7 +291,7 @@ class ResourceNode implements Stringable
/**
* @return Collection|ResourceComment[]
*/
public function getComments(): Collection|array
public function getComments(): array|Collection
{
return $this->comments;
}
@ -303,7 +304,7 @@ class ResourceNode implements Stringable
return $this;
}
public function getPathForDisplayToArray(?int $baseRoot = null): array
public function getPathForDisplayToArray(int $baseRoot = null): array
{
$parts = explode(self::PATH_SEPARATOR, $this->path);
$list = [];
@ -440,7 +441,7 @@ class ResourceNode implements Stringable
return $this->resourceFile;
}
public function setResourceFile(?ResourceFile $resourceFile = null): self
public function setResourceFile(ResourceFile $resourceFile = null): self
{
$this->resourceFile = $resourceFile;

@ -9,6 +9,4 @@ namespace Chamilo\CoreBundle\Entity;
/**
* Show base course resources inside a session.
*/
interface ResourceShowCourseResourcesInSessionInterface
{
}
interface ResourceShowCourseResourcesInSessionInterface {}

@ -9,6 +9,4 @@ namespace Chamilo\CoreBundle\Entity;
/**
* This will attach the resource to the main resource node root (For example a Course).
*/
interface ResourceToRootInterface
{
}
interface ResourceToRootInterface {}

@ -39,9 +39,7 @@ class ScheduledAnnouncement
#[ORM\Column(name: 'c_id', type: 'integer', nullable: true)]
protected ?int $cId = null;
public function __construct()
{
}
public function __construct() {}
public function getId(): int
{

@ -578,7 +578,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
return false;
}
public function getSessionRelCourseByUser(User $user, ?int $status = null): Collection
public function getSessionRelCourseByUser(User $user, int $status = null): Collection
{
$criteria = Criteria::create()->where(Criteria::expr()->eq('user', $user));
if (null !== $status) {
@ -1124,7 +1124,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
return $relation->count() > 0;
}
public function getUserInCourse(User $user, Course $course, ?int $status = null): Collection
public function getUserInCourse(User $user, Course $course, int $status = null): Collection
{
$criteria = Criteria::create()
->where(
@ -1161,7 +1161,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
return $this->hasUserInCourse($user, $course, self::STUDENT);
}
protected function compareDates(?DateTime $start, ?DateTime $end = null): bool
protected function compareDates(?DateTime $start, DateTime $end = null): bool
{
$now = new Datetime('now');

@ -62,6 +62,7 @@ class SessionCategory implements Stringable
{
return $this->url;
}
/**
* Get id.
*
@ -87,6 +88,7 @@ class SessionCategory implements Stringable
return $this;
}
/**
* Get dateStart.
*
@ -102,6 +104,7 @@ class SessionCategory implements Stringable
return $this;
}
/**
* Get dateEnd.
*

@ -32,26 +32,31 @@ class Skill implements Stringable
#[ORM\ManyToOne(targetEntity: Profile::class, inversedBy: 'skills')]
#[ORM\JoinColumn(name: 'profile_id', referencedColumnName: 'id')]
protected ?Profile $profile = null;
/**
* @var SkillRelUser[]|Collection
*/
#[ORM\OneToMany(targetEntity: SkillRelUser::class, mappedBy: 'skill', cascade: ['persist'])]
protected Collection $issuedSkills;
/**
* @var Collection|SkillRelItem[]
*/
#[ORM\OneToMany(targetEntity: SkillRelItem::class, mappedBy: 'skill', cascade: ['persist'])]
protected Collection $items;
/**
* @var Collection|SkillRelSkill[]
*/
#[ORM\OneToMany(targetEntity: SkillRelSkill::class, mappedBy: 'skill', cascade: ['persist'])]
protected Collection $skills;
/**
* @var Collection|SkillRelCourse[]
*/
#[ORM\OneToMany(targetEntity: SkillRelCourse::class, mappedBy: 'skill', cascade: ['persist'])]
protected Collection $courses;
/**
* @var Collection|SkillRelGradebook[]
*/
@ -128,6 +133,7 @@ class Skill implements Stringable
{
return $this->description;
}
/**
* Set accessUrlId.
*
@ -139,6 +145,7 @@ class Skill implements Stringable
return $this;
}
/**
* Get accessUrlId.
*
@ -154,6 +161,7 @@ class Skill implements Stringable
return $this;
}
/**
* Get icon.
*
@ -169,6 +177,7 @@ class Skill implements Stringable
return $this;
}
/**
* Get criteria.
*
@ -184,6 +193,7 @@ class Skill implements Stringable
return $this;
}
/**
* Get status.
*
@ -193,6 +203,7 @@ class Skill implements Stringable
{
return $this->status;
}
/**
* Set updatedAt.
*
@ -206,6 +217,7 @@ class Skill implements Stringable
return $this;
}
/**
* Get updatedAt.
*
@ -215,6 +227,7 @@ class Skill implements Stringable
{
return $this->updatedAt;
}
/**
* Get id.
*
@ -224,6 +237,7 @@ class Skill implements Stringable
{
return $this->id;
}
/**
* @return Profile
*/
@ -237,6 +251,7 @@ class Skill implements Stringable
return $this;
}
/**
* Get issuedSkills.
*
@ -246,6 +261,7 @@ class Skill implements Stringable
{
return $this->issuedSkills;
}
/**
* @return Collection
*/
@ -263,6 +279,7 @@ class Skill implements Stringable
{
if (0 !== $this->getItems()->count()) {
$found = false;
/** @var SkillRelItem $item */
foreach ($this->getItems() as $item) {
if ($item->getItemId() === $itemId && $item->getItemType() === $typeId) {
@ -282,6 +299,7 @@ class Skill implements Stringable
$skillRelItem->setSkill($this);
$this->items[] = $skillRelItem;
}
/**
* @return Collection
*/
@ -295,6 +313,7 @@ class Skill implements Stringable
return $this;
}
/**
* @return SkillRelSkill[]|Collection
*/
@ -302,6 +321,7 @@ class Skill implements Stringable
{
return $this->skills;
}
/**
* @param SkillRelSkill[]|Collection $skills
*/
@ -311,6 +331,7 @@ class Skill implements Stringable
return $this;
}
/**
* @return SkillRelGradebook[]|Collection
*/
@ -318,6 +339,7 @@ class Skill implements Stringable
{
return $this->gradeBookCategories;
}
/**
* @param SkillRelGradebook[]|Collection $gradeBookCategories
*/
@ -345,6 +367,7 @@ class Skill implements Stringable
{
if (0 !== $this->getCourses()->count()) {
$found = false;
/** @var SkillRelCourse $item */
foreach ($this->getCourses() as $item) {
$sessionPassFilter = false;

@ -268,24 +268,22 @@ class SkillRelItem
public function getItemResultUrl(string $cidReq): string
{
$url = '';
$url = match ($this->getItemType()) {
return match ($this->getItemType()) {
ITEM_TYPE_EXERCISE => 'exercise/exercise_show.php?action=qualify&'.$cidReq,
ITEM_TYPE_STUDENT_PUBLICATION => 'work/view.php?'.$cidReq,
default => $url,
};
return $url;
}
public function getItemResultList(string $cidReq): string
{
$url = '';
$url = match ($this->getItemType()) {
return match ($this->getItemType()) {
ITEM_TYPE_EXERCISE => 'exercise/exercise_report.php?'.$cidReq.'&id='.$this->getItemId(),
ITEM_TYPE_STUDENT_PUBLICATION => 'work/work_list_all.php?'.$cidReq.'&id='.$this->getItemId(),
default => $url,
};
return $url;
}
}

@ -42,9 +42,7 @@ class SkillRelItemRelUser
#[ORM\Column(name: 'updated_by', type: 'integer', nullable: false)]
protected int $updatedBy;
public function __construct()
{
}
public function __construct() {}
/**
* @return int

@ -275,7 +275,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
/**
* ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\JuryMembers", mappedBy="user").
*/
//protected $jurySubscriptions;
// protected $jurySubscriptions;
/**
* @var Collection<int, Group>
@ -768,7 +768,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
$this->receivedMessages = new ArrayCollection();
$this->surveyInvitations = new ArrayCollection();
$this->logins = new ArrayCollection();
//$this->extraFields = new ArrayCollection();
// $this->extraFields = new ArrayCollection();
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
$this->registrationDate = new DateTime();
@ -806,9 +806,9 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
//$metadata->addPropertyConstraint('firstname', new Assert\NotBlank());
//$metadata->addPropertyConstraint('lastname', new Assert\NotBlank());
//$metadata->addPropertyConstraint('email', new Assert\Email());
// $metadata->addPropertyConstraint('firstname', new Assert\NotBlank());
// $metadata->addPropertyConstraint('lastname', new Assert\NotBlank());
// $metadata->addPropertyConstraint('email', new Assert\Email());
/*
$metadata->addPropertyConstraint('password',
new Assert\Collection(self::getPasswordConstraints())
@ -950,6 +950,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
{
$classSubscription = $this->getClasses();
$classList = [];
/** @var UsergroupRelUser $subscription */
foreach ($classSubscription as $subscription) {
$class = $subscription->getUsergroup();
@ -1430,7 +1431,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
public function isAccountNonLocked(): bool
{
return true;
//return !$this->locked;
// return !$this->locked;
}
public function isCredentialsNonExpired(): bool
@ -2203,9 +2204,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
$this->setUsername($name);
}
public function setParent(AbstractResource $parent): void
{
}
public function setParent(AbstractResource $parent): void {}
public function getDefaultIllustration(int $size): string
{
@ -2339,7 +2338,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
* Used to be implemented in global function \api_max_sort_value.
* Reimplemented using the ORM cache.
*/
public function getMaxSortValue(?UserCourseCategory $userCourseCategory = null): int
public function getMaxSortValue(UserCourseCategory $userCourseCategory = null): int
{
$categoryCourses = $this->courses->matching(
Criteria::create()->where(Criteria::expr()->neq('relationType', COURSE_RELATION_TYPE_RRHH))->andWhere(

@ -67,16 +67,16 @@ use Symfony\Component\Validator\Constraints as Assert;
)]
class UserRelUser
{
use UserTrait;
use TimestampableTypedEntity;
use UserTrait;
public const USER_UNKNOWN = 0;
//public const USER_RELATION_TYPE_UNKNOWN = 1;
//public const USER_RELATION_TYPE_PARENT = 2;
// public const USER_RELATION_TYPE_UNKNOWN = 1;
// public const USER_RELATION_TYPE_PARENT = 2;
public const USER_RELATION_TYPE_FRIEND = 3;
public const USER_RELATION_TYPE_GOODFRIEND = 4;
// should be deprecated is useless
//public const USER_RELATION_TYPE_ENEMY = 5; // should be deprecated is useless
// public const USER_RELATION_TYPE_ENEMY = 5; // should be deprecated is useless
public const USER_RELATION_TYPE_DELETED = 6;
public const USER_RELATION_TYPE_RRHH = 7;
public const USER_RELATION_TYPE_BOSS = 8;

@ -8,6 +8,7 @@ namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use Chamilo\CoreBundle\Repository\Node\UsergroupRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -20,7 +21,7 @@ use Symfony\Component\Validator\Constraints as Assert;
*/
#[ApiResource(security: 'is_granted(\'ROLE_ADMIN\')', normalizationContext: ['groups' => ['usergroup:read']])]
#[ORM\Table(name: 'usergroup')]
#[ORM\Entity(repositoryClass: \Chamilo\CoreBundle\Repository\Node\UsergroupRepository::class)]
#[ORM\Entity(repositoryClass: UsergroupRepository::class)]
class Usergroup extends AbstractResource implements ResourceInterface, ResourceIllustrationInterface, ResourceWithAccessUrlInterface, Stringable
{
use TimestampableEntity;
@ -50,30 +51,35 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
#[Assert\NotBlank]
#[ORM\Column(name: 'allow_members_leave_group', type: 'integer')]
protected int $allowMembersToLeaveGroup;
/**
* @var Collection|UsergroupRelUser[]
* @var Collection<int, UsergroupRelUser>
*/
#[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\UsergroupRelUser::class, mappedBy: 'usergroup', cascade: ['persist'])]
#[ORM\OneToMany(mappedBy: 'usergroup', targetEntity: UsergroupRelUser::class, cascade: ['persist'])]
protected Collection $users;
/**
* @var Collection|UsergroupRelCourse[]
* @var Collection<int, UsergroupRelCourse>
*/
#[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\UsergroupRelCourse::class, mappedBy: 'usergroup', cascade: ['persist'])]
#[ORM\OneToMany(mappedBy: 'usergroup', targetEntity: UsergroupRelCourse::class, cascade: ['persist'])]
protected Collection $courses;
/**
* @var Collection|UsergroupRelSession[]
* @var Collection<int, UsergroupRelSession>
*/
#[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\UsergroupRelSession::class, mappedBy: 'usergroup', cascade: ['persist'])]
#[ORM\OneToMany(mappedBy: 'usergroup', targetEntity: UsergroupRelSession::class, cascade: ['persist'])]
protected Collection $sessions;
/**
* @var Collection|UsergroupRelQuestion[]
* @var Collection<int, UsergroupRelQuestion>
*/
#[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\UsergroupRelQuestion::class, mappedBy: 'usergroup', cascade: ['persist'])]
#[ORM\OneToMany(mappedBy: 'usergroup', targetEntity: UsergroupRelQuestion::class, cascade: ['persist'])]
protected Collection $questions;
/**
* @var AccessUrlRelUserGroup[]|Collection
* @var Collection<int, AccessUrlRelUserGroup>
*/
#[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\AccessUrlRelUserGroup::class, mappedBy: 'userGroup', cascade: ['persist', 'remove'], orphanRemoval: true)]
#[ORM\OneToMany(mappedBy: 'userGroup', targetEntity: AccessUrlRelUserGroup::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
protected Collection $urls;
public function __construct()
{
@ -90,10 +96,11 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
{
return $this->getName();
}
/**
* @return UsergroupRelUser[]|Collection
* @return ArrayCollection<int, UsergroupRelUser>
*/
public function getUsers(): array|Collection
public function getUsers(): ArrayCollection
{
return $this->users;
}
@ -139,12 +146,11 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
}
}
}
/**
* Get id.
*
* @return int
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
@ -168,10 +174,8 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
{
return $this->description;
}
/**
* @return int
*/
public function getGroupType()
public function getGroupType(): int
{
return $this->groupType;
}
@ -221,10 +225,11 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
return $this;
}
/**
* @return UsergroupRelCourse[]|Collection
* @return ArrayCollection<int, UsergroupRelCourse>
*/
public function getCourses(): array|Collection
public function getCourses(): ArrayCollection
{
return $this->courses;
}
@ -234,10 +239,11 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
return $this;
}
/**
* @return UsergroupRelSession[]|Collection
* @return ArrayCollection<int, UsergroupRelSession>
*/
public function getSessions(): array|Collection
public function getSessions(): ArrayCollection
{
return $this->sessions;
}
@ -247,10 +253,11 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
return $this;
}
/**
* @return UsergroupRelQuestion[]|Collection
* @return ArrayCollection<int, UsergroupRelQuestion>
*/
public function getQuestions(): array|Collection
public function getQuestions(): ArrayCollection
{
return $this->questions;
}

@ -41,8 +41,7 @@ class CourseListener
private readonly AuthorizationCheckerInterface $authorizationChecker,
private readonly TranslatorInterface $translator,
private readonly EntityManagerInterface $entityManager,
) {
}
) {}
/**
* Get request from the URL cidReq, c_id or the "ABC" in the courses url (courses/ABC/index.php).
@ -129,10 +128,10 @@ class CourseListener
$sessionHandler->remove('sid');
$sessionHandler->remove('session');
} else {
//dump("Load chamilo session from DB");
// dump("Load chamilo session from DB");
$session = $this->entityManager->find(Session::class, $sessionId);
if (null !== $session) {
//$course->setCurrentSession($session);
// $course->setCurrentSession($session);
$session->setCurrentCourse($course);
// Check if user is allowed to this course-session
// See SessionVoter.php
@ -155,7 +154,7 @@ class CourseListener
if (empty($groupId)) {
$sessionHandler->remove('gid');
} else {
//dump('Load chamilo group from DB');
// dump('Load chamilo group from DB');
$group = $this->entityManager->getRepository(CGroup::class)->find($groupId);
if (null === $group) {
@ -193,9 +192,7 @@ class CourseListener
}
}
public function onKernelResponse(ResponseEvent $event): void
{
}
public function onKernelResponse(ResponseEvent $event): void {}
/**
* Once the onKernelRequest was fired, we check if the course/session object were set and we inject them in the controller.
@ -210,7 +207,7 @@ class CourseListener
$request = $event->getRequest();
$sessionHandler = $request->getSession();
//$container = $this->container;
// $container = $this->container;
/*if ($course) {
$courseLanguage = $course->getCourseLanguage();
@ -223,20 +220,20 @@ class CourseListener
}*/
$courseId = (int) $request->get('cid');
//$groupId = (int) $request->get('gid');
//$sessionId = (int) $request->get('sid');
// $groupId = (int) $request->get('gid');
// $sessionId = (int) $request->get('sid');
// cidReset is set in the global.inc.php files
//global $cidReset;
//$cidReset = $sessionHandler->get('cid_reset', false);
// global $cidReset;
// $cidReset = $sessionHandler->get('cid_reset', false);
// This controller implements ToolInterface? Then set the course/session
if (\is_array($controllerList) &&
(
$controllerList[0] instanceof CourseControllerInterface ||
$controllerList[0] instanceof EditorController
//$controllerList[0] instanceof ResourceController
//|| $controllerList[0] instanceof LegacyController
if (\is_array($controllerList)
&& (
$controllerList[0] instanceof CourseControllerInterface
|| $controllerList[0] instanceof EditorController
// $controllerList[0] instanceof ResourceController
// || $controllerList[0] instanceof LegacyController
)
) {
if (!empty($courseId)) {
@ -249,12 +246,12 @@ class CourseListener
if ($course) {
$controller->setCourse($course);
// Legacy code
//$courseCode = $course->getCode();
//$courseInfo = api_get_course_info($courseCode);
//$container->get('twig')->addGlobal('course', $course);
//$sessionHandler->set('_real_cid', $course->getId());
//$sessionHandler->set('_cid', $course->getCode());
//$sessionHandler->set('_course', $courseInfo);
// $courseCode = $course->getCode();
// $courseInfo = api_get_course_info($courseCode);
// $container->get('twig')->addGlobal('course', $course);
// $sessionHandler->set('_real_cid', $course->getId());
// $sessionHandler->set('_cid', $course->getCode());
// $sessionHandler->set('_course', $courseInfo);
}
if ($session) {
@ -263,10 +260,10 @@ class CourseListener
}
// Example 'chamilo_notebook.controller.notebook:indexAction'
//$controllerAction = $request->get('_controller');
//$controllerActionParts = explode(':', $controllerAction);
//$controllerNameParts = explode('.', $controllerActionParts[0]);
//$controllerName = $controllerActionParts[0];
// $controllerAction = $request->get('_controller');
// $controllerActionParts = explode(':', $controllerAction);
// $controllerNameParts = explode('.', $controllerActionParts[0]);
// $controllerName = $controllerActionParts[0];
}
}
@ -308,7 +305,7 @@ class CourseListener
}
}
//$request->setLocale($request->getPreferredLanguage());
// $request->setLocale($request->getPreferredLanguage());
}
private function generateCourseUrl(?Course $course, int $sessionId, int $groupId, ?string $origin): string

@ -15,8 +15,8 @@ final class HTTPExceptionListener
public function onKernelException(ExceptionEvent $event): void
{
$exception = $event->getThrowable();
if (!($exception instanceof HttpException) ||
false === strpos($event->getRequest()->getRequestUri(), '/api/')
if (!($exception instanceof HttpException)
|| !str_contains($event->getRequest()->getRequestUri(), '/api/')
) {
return;
}

@ -37,8 +37,7 @@ class LegacyListener
private readonly RouterInterface $router,
private readonly ParameterBagInterface $parameterBag,
private readonly SettingsManager $settingsManager
) {
}
) {}
public function onKernelRequest(RequestEvent $event): void
{
@ -111,7 +110,7 @@ class LegacyListener
}
// Theme icon is loaded in the TwigListener src/ThemeBundle/EventListener/TwigListener.php
//$theme = api_get_visual_theme();
// $theme = api_get_visual_theme();
/*$languages = api_get_languages();
$languageList = [];
foreach ($languages as $isoCode => $language) {
@ -131,9 +130,9 @@ class LegacyListener
'text' => $languageList[$isoFixed] ?? 'English',
]
);*/
//$twig->addGlobal('current_locale', $request->getLocale());
//$twig->addGlobal('available_locales', $languages);
//$twig->addGlobal('show_toolbar', \Template::isToolBarDisplayedForUser() ? 1 : 0);
// $twig->addGlobal('current_locale', $request->getLocale());
// $twig->addGlobal('available_locales', $languages);
// $twig->addGlobal('show_toolbar', \Template::isToolBarDisplayedForUser() ? 1 : 0);
// Extra content
$extraHeader = '';
@ -163,11 +162,7 @@ class LegacyListener
$session->set('access_url_id', $urlId);
}
public function onKernelResponse(ResponseEvent $event): void
{
}
public function onKernelResponse(ResponseEvent $event): void {}
public function onKernelController(ControllerEvent $event): void
{
}
public function onKernelController(ControllerEvent $event): void {}
}

@ -14,7 +14,7 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use UserManager;
//class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface
// class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface
class LoginSuccessHandler
{
protected UrlGeneratorInterface $router;
@ -37,19 +37,20 @@ class LoginSuccessHandler
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
$request = $event->getRequest();
/** @var User $user */
$user = $event->getAuthenticationToken()->getUser();
$userId = $user->getId();
$session = $request->getSession();
//$userInfo = api_get_user_info($user->getId());
//$userInfo['is_anonymous'] = false;
// $userInfo = api_get_user_info($user->getId());
// $userInfo['is_anonymous'] = false;
// Backward compatibility.
//$ip = $request->getClientIp();
// $ip = $request->getClientIp();
// Setting user info.
//$session->set('_user', $user);
// $session->set('_user', $user);
// Setting admin permissions for.
if ($this->checker->isGranted('ROLE_ADMIN')) {
@ -79,10 +80,12 @@ class LoginSuccessHandler
$url = $legacyIndex;
break;
case 'user_portal.php':
$url = $legacyIndex.'user_portal.php';
break;
case 'main/auth/courses.php':
$url = $legacyIndex.'/'.$pageAfterLogin;
@ -93,9 +96,9 @@ class LoginSuccessHandler
$goToCourse = $this->settingsManager->getSetting('course.go_to_course_after_login');
$session->set('_uid', $user->getId());
//$session->set('_user', $userInfo);
//$session->set('is_platformAdmin', \UserManager::is_admin($userId));
//$session->set('is_allowedCreateCourse', $userInfo['status'] === 1);
// $session->set('_user', $userInfo);
// $session->set('is_platformAdmin', \UserManager::is_admin($userId));
// $session->set('is_allowedCreateCourse', $userInfo['status'] === 1);
// Redirecting to a course or a session.
if ('true' === $goToCourse) {
// Get the courses list

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save