Minor: Format code

pull/5031/head
Angel Fernando Quiroz Campos 2 years 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; 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\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
use const JSON_PRETTY_PRINT;
class UpdateVueTranslations extends Command class UpdateVueTranslations extends Command
{ {
/** /**
@ -70,7 +72,7 @@ class UpdateVueTranslations extends Command
$newLanguage = []; $newLanguage = [];
foreach ($translations as $variable => $translation) { foreach ($translations as $variable => $translation) {
//$translated = $this->translator->trans($variable, [], null, $iso); // $translated = $this->translator->trans($variable, [], null, $iso);
$translated = $this->getTranslationWithFallback($variable, $language); $translated = $this->getTranslationWithFallback($variable, $language);
$newLanguage[$variable] = $this->replaceMarkers($translated); $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. * Gets the translation for a given variable with fallbacks to parent language and base language.
* *
* @param string $variable The variable to be translated. * @param string $variable the variable to be translated
* @param Language $language The Language entity for the current language. * @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 // Get the ISO code of the current language
$iso = $language->getIsocode(); $iso = $language->getIsocode();
// Try to translate the variable in the current language // Try to translate the variable in the current language

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

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

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

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

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

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

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

@ -6,6 +6,4 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar; 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['fullPage'] = true;
//$config['height'] = '200'; // $config['height'] = '200';
return $config; return $config;
} }

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

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

@ -6,6 +6,4 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Component\Utils; 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', 'format' => 'title first_name last_name',
'sort_by' => 'first_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' => [ 'bg' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_name', 'sort_by' => 'first_name',
@ -111,7 +111,7 @@ class NameConvention
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_name', 'sort_by' => 'first_name',
], ],
//basque // basque
'fi' => [ 'fi' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_name', 'sort_by' => 'first_name',
@ -120,7 +120,7 @@ class NameConvention
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_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' => [ 'fur_IT' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_name', 'sort_by' => 'first_name',
@ -141,7 +141,7 @@ class NameConvention
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_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' => [ 'he' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_name', 'sort_by' => 'first_name',
@ -155,12 +155,12 @@ class NameConvention
'sort_by' => 'last_name', 'sort_by' => 'last_name',
], ],
// Eastern order // 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' => [ 'id' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_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' => [ 'it' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_name', 'sort_by' => 'first_name',
@ -175,7 +175,7 @@ class NameConvention
'sort_by' => 'last_name', 'sort_by' => 'last_name',
], ],
// Eastern order // 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' => [ 'lv' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_name', 'sort_by' => 'first_name',
@ -193,11 +193,11 @@ class NameConvention
'sort_by' => 'last_name', 'sort_by' => 'last_name',
], ],
// Eastern order // Eastern order
//'manx' => ['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'], // 'marathi' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
//'middle_frisian' => ['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'], // 'mingo' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
//'nepali' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'], // 'nepali' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'nn' => [ 'nn' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_name', 'sort_by' => 'first_name',
@ -230,17 +230,17 @@ class NameConvention
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_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' => [ 'ru' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_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' => [ 'sr' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_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' => [ 'zh_CN' => [
'format' => 'title last_name first_name', 'format' => 'title last_name first_name',
'sort_by' => 'last_name', 'sort_by' => 'last_name',
@ -270,7 +270,7 @@ class NameConvention
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_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' => [ 'th' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_name', 'sort_by' => 'first_name',
@ -293,8 +293,8 @@ class NameConvention
'sort_by' => 'last_name', 'sort_by' => 'last_name',
], ],
// Eastern order // Eastern order
//'welsh' => ['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'], // 'yiddish' => ['format' => 'title first_name last_name', 'sort_by' => 'first_name'],
'yo' => [ 'yo' => [
'format' => 'title first_name last_name', 'format' => 'title first_name last_name',
'sort_by' => 'first_name', 'sort_by' => 'first_name',

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

@ -26,7 +26,7 @@ class AccountController extends BaseController
{ {
use ControllerTrait; 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 public function editAction(Request $request, UserRepository $userRepository, IllustrationRepository $illustrationRepo, SettingsManager $settingsManager): Response
{ {
$user = $this->getUser(); $user = $this->getUser();

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

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

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

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

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

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

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

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

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

@ -30,7 +30,7 @@ class UpdateCCalendarEventAction extends BaseResourceFileAction
->setColor($result['color'] ?? '') ->setColor($result['color'] ?? '')
->setStartDate(new DateTime($result['startDate'] ?? '')) ->setStartDate(new DateTime($result['startDate'] ?? ''))
->setEndDate(new DateTime($result['endDate'] ?? '')) ->setEndDate(new DateTime($result['endDate'] ?? ''))
//->setAllDay($result['allDay'] ?? false) // ->setAllDay($result['allDay'] ?? false)
->setCollective($result['collective'] ?? 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, // The image was cropped manually by the user, so we force to render this version,
// no matter other crop parameters. // no matter other crop parameters.
//$crop = $resourceFile->getCrop(); // $crop = $resourceFile->getCrop();
/*if (!empty($crop)) { /*if (!empty($crop)) {
$params['crop'] = $crop; $params['crop'] = $crop;
}*/ }*/

@ -10,9 +10,5 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
/** /**
* Each entity controller must extend this class. * 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 class ChatController extends AbstractResourceController implements CourseControllerInterface
{ {
use ControllerTrait; use ControllerTrait;
use ResourceControllerTrait;
use CourseControllerTrait; use CourseControllerTrait;
use ResourceControllerTrait;
/** /**
* @Route("/resources/chat/", name="chat_home", options={"expose"=true}) * @Route("/resources/chat/", name="chat_home", options={"expose"=true})
@ -90,21 +90,22 @@ class ChatController extends AbstractResourceController implements CourseControl
Event::registerLog($logInfo); Event::registerLog($logInfo);
break; break;
case 'track': case 'track':
$courseChatUtils->keepUserAsConnected(); $courseChatUtils->keepUserAsConnected();
$courseChatUtils->disconnectInactiveUsers(); $courseChatUtils->disconnectInactiveUsers();
$friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0; $friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0;
//$filePath = $courseChatUtils->getFileName(true, $friend); // $filePath = $courseChatUtils->getFileName(true, $friend);
//$newFileSize = file_exists($filePath) ? filesize($filePath) : 0; // $newFileSize = file_exists($filePath) ? filesize($filePath) : 0;
//$oldFileSize = isset($_GET['size']) ? (int) $_GET['size'] : -1; // $oldFileSize = isset($_GET['size']) ? (int) $_GET['size'] : -1;
$newUsersOnline = $courseChatUtils->countUsersOnline(); $newUsersOnline = $courseChatUtils->countUsersOnline();
$oldUsersOnline = isset($_GET['users_online']) ? (int) $_GET['users_online'] : 0; $oldUsersOnline = isset($_GET['users_online']) ? (int) $_GET['users_online'] : 0;
$json = [ $json = [
'status' => true, 'status' => true,
'data' => [ 'data' => [
//'oldFileSize' => file_exists($filePath) ? filesize($filePath) : 0, // 'oldFileSize' => file_exists($filePath) ? filesize($filePath) : 0,
'oldFileSize' => false, 'oldFileSize' => false,
'history' => $courseChatUtils->readMessages(false, $friend), 'history' => $courseChatUtils->readMessages(false, $friend),
'usersOnline' => $newUsersOnline, 'usersOnline' => $newUsersOnline,
@ -114,6 +115,7 @@ class ChatController extends AbstractResourceController implements CourseControl
]; ];
break; break;
case 'preview': case 'preview':
$json = [ $json = [
'status' => true, 'status' => true,
@ -123,6 +125,7 @@ class ChatController extends AbstractResourceController implements CourseControl
]; ];
break; break;
case 'reset': case 'reset':
$friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0; $friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0;
@ -132,6 +135,7 @@ class ChatController extends AbstractResourceController implements CourseControl
]; ];
break; break;
case 'write': case 'write':
$friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0; $friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0;
$status = $courseChatUtils->saveMessage($_REQUEST['message'], $friend); $status = $courseChatUtils->saveMessage($_REQUEST['message'], $friend);

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

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

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

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

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

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

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

@ -56,6 +56,7 @@ class SessionController extends AbstractController
/** @var EntityRepository $fieldsRepo */ /** @var EntityRepository $fieldsRepo */
$fieldsRepo = $em->getRepository(ExtraField::class); $fieldsRepo = $em->getRepository(ExtraField::class);
/** @var TagRepository $tagRepo */ /** @var TagRepository $tagRepo */
$tagRepo = $em->getRepository(Tag::class); $tagRepo = $em->getRepository(Tag::class);
@ -83,6 +84,7 @@ class SessionController extends AbstractController
$courseCoaches = $userRepo->getCoachesForSessionCourse($session, $sessionCourse); $courseCoaches = $userRepo->getCoachesForSessionCourse($session, $sessionCourse);
$coachesData = []; $coachesData = [];
/** @var User $courseCoach */ /** @var User $courseCoach */
foreach ($courseCoaches as $courseCoach) { foreach ($courseCoaches as $courseCoach) {
$coachData = [ $coachData = [
@ -117,35 +119,43 @@ class SessionController extends AbstractController
if (!empty($descriptionsData)) { if (!empty($descriptionsData)) {
foreach ($descriptionsData as $descriptionInfo) { foreach ($descriptionsData as $descriptionInfo) {
$type = $descriptionInfo->getDescriptionType(); $type = $descriptionInfo->getDescriptionType();
switch ($type) { switch ($type) {
case CCourseDescription::TYPE_DESCRIPTION: case CCourseDescription::TYPE_DESCRIPTION:
$courseDescription[] = $descriptionInfo; $courseDescription[] = $descriptionInfo;
break; break;
case CCourseDescription::TYPE_OBJECTIVES: case CCourseDescription::TYPE_OBJECTIVES:
$courseObjectives[] = $descriptionInfo; $courseObjectives[] = $descriptionInfo;
break; break;
case CCourseDescription::TYPE_TOPICS: case CCourseDescription::TYPE_TOPICS:
$courseTopics[] = $descriptionInfo; $courseTopics[] = $descriptionInfo;
break; break;
case CCourseDescription::TYPE_METHODOLOGY: case CCourseDescription::TYPE_METHODOLOGY:
$courseMethodology[] = $descriptionInfo; $courseMethodology[] = $descriptionInfo;
break; break;
case CCourseDescription::TYPE_COURSE_MATERIAL: case CCourseDescription::TYPE_COURSE_MATERIAL:
$courseMaterial[] = $descriptionInfo; $courseMaterial[] = $descriptionInfo;
break; break;
case CCourseDescription::TYPE_RESOURCES: case CCourseDescription::TYPE_RESOURCES:
$courseResources[] = $descriptionInfo; $courseResources[] = $descriptionInfo;
break; break;
case CCourseDescription::TYPE_ASSESSMENT: case CCourseDescription::TYPE_ASSESSMENT:
$courseAssessment[] = $descriptionInfo; $courseAssessment[] = $descriptionInfo;
break; break;
case CCourseDescription::TYPE_CUSTOM: case CCourseDescription::TYPE_CUSTOM:
$courseCustom[] = $descriptionInfo; $courseCustom[] = $descriptionInfo;
@ -223,7 +233,7 @@ class SessionController extends AbstractController
'essence' => $essence, 'essence' => $essence,
'session_extra_fields' => $sessionValues->getAllValuesForAnItem($session->getId(), null, true), 'session_extra_fields' => $sessionValues->getAllValuesForAnItem($session->getId(), null, true),
'has_requirements' => $hasRequirements, 'has_requirements' => $hasRequirements,
//'sequences' => $sessionRequirements, // 'sequences' => $sessionRequirements,
'is_premium' => $sessionIsPremium, 'is_premium' => $sessionIsPremium,
'show_tutor' => 'true' === api_get_setting('show_session_coach'), 'show_tutor' => 'true' === api_get_setting('show_session_coach'),
'page_url' => api_get_path(WEB_PATH).sprintf('sessions/%s/about/', $session->getId()), '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. * Updates the table tool and resource_type with the content of tools.yml.
* *
* @Security("is_granted('ROLE_ADMIN')") * @Security("is_granted('ROLE_ADMIN')")
*
* @Route("/update", methods={"GET"}) * @Route("/update", methods={"GET"})
*/ */
public function profileAction(ToolChain $toolChain): Response public function profileAction(ToolChain $toolChain): Response

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

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

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

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

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

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

@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security; 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 final class CToolIntroExtension implements QueryCollectionExtensionInterface
{ {
@ -24,8 +24,7 @@ final class CToolIntroExtension implements QueryCollectionExtensionInterface
public function __construct( public function __construct(
private readonly Security $security, private readonly Security $security,
private readonly RequestStack $requestStack private readonly RequestStack $requestStack
) { ) {}
}
public function applyToCollection( public function applyToCollection(
QueryBuilder $queryBuilder, QueryBuilder $queryBuilder,

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

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

@ -15,14 +15,13 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security; 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( public function __construct(
private readonly Security $security private readonly Security $security
) { ) {}
}
public function applyToCollection( public function applyToCollection(
QueryBuilder $queryBuilder, QueryBuilder $queryBuilder,

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

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

@ -13,14 +13,13 @@ use Chamilo\CoreBundle\Entity\MessageTag;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Core\Security; 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( public function __construct(
private readonly Security $security private readonly Security $security
) { ) {}
}
public function applyToCollection( public function applyToCollection(
QueryBuilder $queryBuilder, QueryBuilder $queryBuilder,

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

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

@ -18,15 +18,14 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security; 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( public function __construct(
private readonly Security $security, private readonly Security $security,
private readonly RequestStack $requestStack private readonly RequestStack $requestStack
) { ) {}
}
public function applyToCollection( public function applyToCollection(
QueryBuilder $queryBuilder, QueryBuilder $queryBuilder,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -14,8 +14,7 @@ class MessageListener
{ {
public function __construct( public function __construct(
private MessageBusInterface $bus private MessageBusInterface $bus
) { ) {}
}
public function postPersist(Message $message, PostPersistEventArgs $args): void 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\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use const JSON_THROW_ON_ERROR;
use const PATHINFO_EXTENSION;
class ResourceListener class ResourceListener
{ {
use AccessUrlListenerTrait; use AccessUrlListenerTrait;
@ -40,8 +43,7 @@ class ResourceListener
protected ToolChain $toolChain, protected ToolChain $toolChain,
protected RequestStack $request, protected RequestStack $request,
protected Security $security protected Security $security
) { ) {}
}
/** /**
* Only in creation. * Only in creation.
@ -132,7 +134,7 @@ class ResourceListener
} }
if (null === $parentUrl) { 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; $parentNode = $parentUrl;
} }
@ -184,8 +186,8 @@ class ResourceListener
if (null === $currentUser) { if (null === $currentUser) {
$currentUser = $parentNode->getCreator(); $currentUser = $parentNode->getCreator();
} }
$valid = $parentNode->getCreator()->getUsername() === $currentUser->getUsername() || $valid = $parentNode->getCreator()->getUsername() === $currentUser->getUsername()
$parentNode->getId() === $currentUser->getResourceNode()->getId(); || $parentNode->getId() === $currentUser->getResourceNode()->getId();
if (!$valid) { if (!$valid) {
$msg = sprintf('User %s cannot add a file to another user', $currentUser->getUsername()); $msg = sprintf('User %s cannot add a file to another user', $currentUser->getUsername());
@ -269,15 +271,15 @@ class ResourceListener
$resourceNode->setParent($parentResourceNode); $resourceNode->setParent($parentResourceNode);
} }
//error_log('Resource listener preUpdate'); // error_log('Resource listener preUpdate');
//$this->setLinks($resource, $eventArgs->getEntityManager()); // $this->setLinks($resource, $eventArgs->getEntityManager());
} }
public function postUpdate(AbstractResource $resource, PostUpdateEventArgs $eventArgs): void public function postUpdate(AbstractResource $resource, PostUpdateEventArgs $eventArgs): void
{ {
//error_log('resource listener postUpdate'); // error_log('resource listener postUpdate');
//$em = $eventArgs->getEntityManager(); // $em = $eventArgs->getEntityManager();
//$this->updateResourceName($resource, $resource->getResourceName(), $em); // $this->updateResourceName($resource, $resource->getResourceName(), $em);
} }
public function updateResourceName(AbstractResource $resource): void public function updateResourceName(AbstractResource $resource): void
@ -290,7 +292,7 @@ class ResourceListener
$extension = $this->slugify->slugify(pathinfo($resourceName, PATHINFO_EXTENSION)); $extension = $this->slugify->slugify(pathinfo($resourceName, PATHINFO_EXTENSION));
if (empty($extension)) { if (empty($extension)) {
//$slug = $this->slugify->slugify($resourceName); // $slug = $this->slugify->slugify($resourceName);
} }
/*$originalExtension = pathinfo($resourceName, PATHINFO_EXTENSION); /*$originalExtension = pathinfo($resourceName, PATHINFO_EXTENSION);
$originalBasename = \basename($resourceName, $originalExtension); $originalBasename = \basename($resourceName, $originalExtension);

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

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

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

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

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

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

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

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

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

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

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

@ -9,6 +9,4 @@ namespace Chamilo\CoreBundle\Entity;
/** /**
* Show base course resources inside a session. * 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). * 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)] #[ORM\Column(name: 'c_id', type: 'integer', nullable: true)]
protected ?int $cId = null; protected ?int $cId = null;
public function __construct() public function __construct() {}
{
}
public function getId(): int public function getId(): int
{ {

@ -578,7 +578,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
return false; 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)); $criteria = Criteria::create()->where(Criteria::expr()->eq('user', $user));
if (null !== $status) { if (null !== $status) {
@ -1124,7 +1124,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
return $relation->count() > 0; 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() $criteria = Criteria::create()
->where( ->where(
@ -1161,7 +1161,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
return $this->hasUserInCourse($user, $course, self::STUDENT); 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'); $now = new Datetime('now');

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

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

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

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

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

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

@ -41,8 +41,7 @@ class CourseListener
private readonly AuthorizationCheckerInterface $authorizationChecker, private readonly AuthorizationCheckerInterface $authorizationChecker,
private readonly TranslatorInterface $translator, private readonly TranslatorInterface $translator,
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
) { ) {}
}
/** /**
* Get request from the URL cidReq, c_id or the "ABC" in the courses url (courses/ABC/index.php). * 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('sid');
$sessionHandler->remove('session'); $sessionHandler->remove('session');
} else { } else {
//dump("Load chamilo session from DB"); // dump("Load chamilo session from DB");
$session = $this->entityManager->find(Session::class, $sessionId); $session = $this->entityManager->find(Session::class, $sessionId);
if (null !== $session) { if (null !== $session) {
//$course->setCurrentSession($session); // $course->setCurrentSession($session);
$session->setCurrentCourse($course); $session->setCurrentCourse($course);
// Check if user is allowed to this course-session // Check if user is allowed to this course-session
// See SessionVoter.php // See SessionVoter.php
@ -155,7 +154,7 @@ class CourseListener
if (empty($groupId)) { if (empty($groupId)) {
$sessionHandler->remove('gid'); $sessionHandler->remove('gid');
} else { } else {
//dump('Load chamilo group from DB'); // dump('Load chamilo group from DB');
$group = $this->entityManager->getRepository(CGroup::class)->find($groupId); $group = $this->entityManager->getRepository(CGroup::class)->find($groupId);
if (null === $group) { 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. * 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(); $request = $event->getRequest();
$sessionHandler = $request->getSession(); $sessionHandler = $request->getSession();
//$container = $this->container; // $container = $this->container;
/*if ($course) { /*if ($course) {
$courseLanguage = $course->getCourseLanguage(); $courseLanguage = $course->getCourseLanguage();
@ -223,20 +220,20 @@ class CourseListener
}*/ }*/
$courseId = (int) $request->get('cid'); $courseId = (int) $request->get('cid');
//$groupId = (int) $request->get('gid'); // $groupId = (int) $request->get('gid');
//$sessionId = (int) $request->get('sid'); // $sessionId = (int) $request->get('sid');
// cidReset is set in the global.inc.php files // cidReset is set in the global.inc.php files
//global $cidReset; // global $cidReset;
//$cidReset = $sessionHandler->get('cid_reset', false); // $cidReset = $sessionHandler->get('cid_reset', false);
// This controller implements ToolInterface? Then set the course/session // This controller implements ToolInterface? Then set the course/session
if (\is_array($controllerList) && if (\is_array($controllerList)
( && (
$controllerList[0] instanceof CourseControllerInterface || $controllerList[0] instanceof CourseControllerInterface
$controllerList[0] instanceof EditorController || $controllerList[0] instanceof EditorController
//$controllerList[0] instanceof ResourceController // $controllerList[0] instanceof ResourceController
//|| $controllerList[0] instanceof LegacyController // || $controllerList[0] instanceof LegacyController
) )
) { ) {
if (!empty($courseId)) { if (!empty($courseId)) {
@ -249,12 +246,12 @@ class CourseListener
if ($course) { if ($course) {
$controller->setCourse($course); $controller->setCourse($course);
// Legacy code // Legacy code
//$courseCode = $course->getCode(); // $courseCode = $course->getCode();
//$courseInfo = api_get_course_info($courseCode); // $courseInfo = api_get_course_info($courseCode);
//$container->get('twig')->addGlobal('course', $course); // $container->get('twig')->addGlobal('course', $course);
//$sessionHandler->set('_real_cid', $course->getId()); // $sessionHandler->set('_real_cid', $course->getId());
//$sessionHandler->set('_cid', $course->getCode()); // $sessionHandler->set('_cid', $course->getCode());
//$sessionHandler->set('_course', $courseInfo); // $sessionHandler->set('_course', $courseInfo);
} }
if ($session) { if ($session) {
@ -263,10 +260,10 @@ class CourseListener
} }
// Example 'chamilo_notebook.controller.notebook:indexAction' // Example 'chamilo_notebook.controller.notebook:indexAction'
//$controllerAction = $request->get('_controller'); // $controllerAction = $request->get('_controller');
//$controllerActionParts = explode(':', $controllerAction); // $controllerActionParts = explode(':', $controllerAction);
//$controllerNameParts = explode('.', $controllerActionParts[0]); // $controllerNameParts = explode('.', $controllerActionParts[0]);
//$controllerName = $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 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 public function onKernelException(ExceptionEvent $event): void
{ {
$exception = $event->getThrowable(); $exception = $event->getThrowable();
if (!($exception instanceof HttpException) || if (!($exception instanceof HttpException)
false === strpos($event->getRequest()->getRequestUri(), '/api/') || !str_contains($event->getRequest()->getRequestUri(), '/api/')
) { ) {
return; return;
} }

@ -37,8 +37,7 @@ class LegacyListener
private readonly RouterInterface $router, private readonly RouterInterface $router,
private readonly ParameterBagInterface $parameterBag, private readonly ParameterBagInterface $parameterBag,
private readonly SettingsManager $settingsManager private readonly SettingsManager $settingsManager
) { ) {}
}
public function onKernelRequest(RequestEvent $event): void 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 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(); /*$languages = api_get_languages();
$languageList = []; $languageList = [];
foreach ($languages as $isoCode => $language) { foreach ($languages as $isoCode => $language) {
@ -131,9 +130,9 @@ class LegacyListener
'text' => $languageList[$isoFixed] ?? 'English', 'text' => $languageList[$isoFixed] ?? 'English',
] ]
);*/ );*/
//$twig->addGlobal('current_locale', $request->getLocale()); // $twig->addGlobal('current_locale', $request->getLocale());
//$twig->addGlobal('available_locales', $languages); // $twig->addGlobal('available_locales', $languages);
//$twig->addGlobal('show_toolbar', \Template::isToolBarDisplayedForUser() ? 1 : 0); // $twig->addGlobal('show_toolbar', \Template::isToolBarDisplayedForUser() ? 1 : 0);
// Extra content // Extra content
$extraHeader = ''; $extraHeader = '';
@ -163,11 +162,7 @@ class LegacyListener
$session->set('access_url_id', $urlId); $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 Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use UserManager; use UserManager;
//class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface // class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface
class LoginSuccessHandler class LoginSuccessHandler
{ {
protected UrlGeneratorInterface $router; protected UrlGeneratorInterface $router;
@ -37,19 +37,20 @@ class LoginSuccessHandler
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event) public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{ {
$request = $event->getRequest(); $request = $event->getRequest();
/** @var User $user */ /** @var User $user */
$user = $event->getAuthenticationToken()->getUser(); $user = $event->getAuthenticationToken()->getUser();
$userId = $user->getId(); $userId = $user->getId();
$session = $request->getSession(); $session = $request->getSession();
//$userInfo = api_get_user_info($user->getId()); // $userInfo = api_get_user_info($user->getId());
//$userInfo['is_anonymous'] = false; // $userInfo['is_anonymous'] = false;
// Backward compatibility. // Backward compatibility.
//$ip = $request->getClientIp(); // $ip = $request->getClientIp();
// Setting user info. // Setting user info.
//$session->set('_user', $user); // $session->set('_user', $user);
// Setting admin permissions for. // Setting admin permissions for.
if ($this->checker->isGranted('ROLE_ADMIN')) { if ($this->checker->isGranted('ROLE_ADMIN')) {
@ -79,10 +80,12 @@ class LoginSuccessHandler
$url = $legacyIndex; $url = $legacyIndex;
break; break;
case 'user_portal.php': case 'user_portal.php':
$url = $legacyIndex.'user_portal.php'; $url = $legacyIndex.'user_portal.php';
break; break;
case 'main/auth/courses.php': case 'main/auth/courses.php':
$url = $legacyIndex.'/'.$pageAfterLogin; $url = $legacyIndex.'/'.$pageAfterLogin;
@ -93,9 +96,9 @@ class LoginSuccessHandler
$goToCourse = $this->settingsManager->getSetting('course.go_to_course_after_login'); $goToCourse = $this->settingsManager->getSetting('course.go_to_course_after_login');
$session->set('_uid', $user->getId()); $session->set('_uid', $user->getId());
//$session->set('_user', $userInfo); // $session->set('_user', $userInfo);
//$session->set('is_platformAdmin', \UserManager::is_admin($userId)); // $session->set('is_platformAdmin', \UserManager::is_admin($userId));
//$session->set('is_allowedCreateCourse', $userInfo['status'] === 1); // $session->set('is_allowedCreateCourse', $userInfo['status'] === 1);
// Redirecting to a course or a session. // Redirecting to a course or a session.
if ('true' === $goToCourse) { if ('true' === $goToCourse) {
// Get the courses list // Get the courses list

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

Loading…
Cancel
Save