diff --git a/src/CoreBundle/Controller/SecurityController.php b/src/CoreBundle/Controller/SecurityController.php index 420fbc0504..4366da88ce 100644 --- a/src/CoreBundle/Controller/SecurityController.php +++ b/src/CoreBundle/Controller/SecurityController.php @@ -122,6 +122,7 @@ class SecurityController extends AbstractController if ($this->authorizationChecker->isGranted('IS_AUTHENTICATED_FULLY')) { $user = $this->userHelper->getCurrent(); $data = $this->serializer->serialize($user, 'jsonld', ['groups' => ['user_json:read']]); + return new JsonResponse(['isAuthenticated' => true, 'user' => json_decode($data)], Response::HTTP_OK); } diff --git a/src/CoreBundle/Controller/ThemeController.php b/src/CoreBundle/Controller/ThemeController.php index 703b9fbfa5..350941a611 100644 --- a/src/CoreBundle/Controller/ThemeController.php +++ b/src/CoreBundle/Controller/ThemeController.php @@ -15,6 +15,8 @@ use Symfony\Component\HttpFoundation\ResponseHeaderBag; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\Routing\Attribute\Route; +use const DIRECTORY_SEPARATOR; + #[Route('/themes')] class ThemeController extends AbstractController { @@ -25,21 +27,22 @@ class ThemeController extends AbstractController public function index( string $name, string $path, - #[Autowire(service: 'oneup_flysystem.themes_filesystem')] FilesystemOperator $filesystem + #[Autowire(service: 'oneup_flysystem.themes_filesystem')] + FilesystemOperator $filesystem ): Response { $themeDir = basename($name); if (!$filesystem->directoryExists($themeDir)) { - throw $this->createNotFoundException("The folder name does not exist."); + throw $this->createNotFoundException('The folder name does not exist.'); } $filePath = $themeDir.DIRECTORY_SEPARATOR.$path; if (!$filesystem->fileExists($filePath)) { - throw $this->createNotFoundException("The requested file does not exist."); + throw $this->createNotFoundException('The requested file does not exist.'); } - $response = new StreamedResponse(function () use ($filesystem, $filePath) { + $response = new StreamedResponse(function () use ($filesystem, $filePath): void { $outputStream = fopen('php://output', 'wb'); $fileStream = $filesystem->readStream($filePath); diff --git a/src/CoreBundle/Entity/AccessUrl.php b/src/CoreBundle/Entity/AccessUrl.php index 293ff09865..e008306f8c 100644 --- a/src/CoreBundle/Entity/AccessUrl.php +++ b/src/CoreBundle/Entity/AccessUrl.php @@ -545,6 +545,6 @@ class AccessUrl extends AbstractResource implements ResourceInterface, Stringabl Criteria::expr()->eq('colorTheme', $theme) ); - return $this->colorThemes->matching($criteria)->first() ?: null; + return $this->colorThemes->matching($criteria)->first() ?: null; } } diff --git a/src/CoreBundle/Entity/XApiSharedStatement.php b/src/CoreBundle/Entity/XApiSharedStatement.php index 8138c9a8a3..9afa772599 100644 --- a/src/CoreBundle/Entity/XApiSharedStatement.php +++ b/src/CoreBundle/Entity/XApiSharedStatement.php @@ -28,7 +28,7 @@ class XApiSharedStatement #[ORM\Column] private ?bool $sent = null; - public function __construct(array $statement, string $uuid = null, bool $sent = false) + public function __construct(array $statement, ?string $uuid = null, bool $sent = false) { $this->statement = $statement; $this->uuid = Uuid::fromString($uuid); diff --git a/src/CoreBundle/Migrations/AbstractMigrationChamilo.php b/src/CoreBundle/Migrations/AbstractMigrationChamilo.php index 32377df988..6f07baf5e7 100644 --- a/src/CoreBundle/Migrations/AbstractMigrationChamilo.php +++ b/src/CoreBundle/Migrations/AbstractMigrationChamilo.php @@ -40,7 +40,7 @@ abstract class AbstractMigrationChamilo extends AbstractMigration private LoggerInterface $logger; /** - * Constructor + * Constructor. */ public function __construct(Connection $connection, LoggerInterface $logger) { diff --git a/src/CoreBundle/Migrations/Schema/V200/PriorityMigrationHelper.php b/src/CoreBundle/Migrations/Schema/V200/PriorityMigrationHelper.php index a3254428bd..86e2c96d15 100644 --- a/src/CoreBundle/Migrations/Schema/V200/PriorityMigrationHelper.php +++ b/src/CoreBundle/Migrations/Schema/V200/PriorityMigrationHelper.php @@ -6,8 +6,8 @@ declare(strict_types=1); namespace Chamilo\CoreBundle\Migrations\Schema\V200; -use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Schema\Schema; use Psr\Log\LoggerInterface; /** @@ -22,7 +22,7 @@ class PriorityMigrationHelper private LoggerInterface $logger; /** - * Constructor + * Constructor. */ public function __construct(Connection $connection, LoggerInterface $logger) { @@ -56,12 +56,12 @@ class PriorityMigrationHelper 'c_lp', 'c_lp_item', 'c_student_publication', - 'c_attendance_calendar' + 'c_attendance_calendar', ]; foreach ($tables as $tableName) { $columns = $schemaManager->listTableColumns($tableName); - if (!array_key_exists('duration', $columns)) { + if (!\array_key_exists('duration', $columns)) { $this->connection->executeQuery("ALTER TABLE $tableName ADD duration INT DEFAULT NULL"); } } @@ -79,12 +79,12 @@ class PriorityMigrationHelper 'c_lp', 'c_lp_item', 'c_student_publication', - 'c_attendance_calendar' + 'c_attendance_calendar', ]; foreach ($tables as $tableName) { $columns = $schemaManager->listTableColumns($tableName); - if (array_key_exists('duration', $columns)) { + if (\array_key_exists('duration', $columns)) { $this->connection->executeQuery("ALTER TABLE $tableName DROP COLUMN duration"); } } diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20.php b/src/CoreBundle/Migrations/Schema/V200/Version20.php index ccf30fece2..0d6993dd42 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20.php @@ -8,8 +8,8 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200; use Chamilo\CoreBundle\DataFixtures\LanguageFixtures; use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; -use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Schema\Schema; use Psr\Log\LoggerInterface; /** diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20170523110000.php b/src/CoreBundle/Migrations/Schema/V200/Version20170523110000.php index e29f5b9b26..9f2b8316c8 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20170523110000.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20170523110000.php @@ -20,7 +20,7 @@ final class Version20170523110000 extends AbstractMigrationChamilo { $this->addSql("CREATE TABLE color_theme (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, variables LONGTEXT NOT NULL COMMENT '(DC2Type:json)', slug VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); $this->addSql("CREATE TABLE access_url_rel_color_theme (id INT AUTO_INCREMENT NOT NULL, url_id INT NOT NULL, color_theme_id INT NOT NULL, active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_D2A2E1C981CFDAE7 (url_id), INDEX IDX_D2A2E1C98587EFC5 (color_theme_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); - $this->addSql("ALTER TABLE access_url_rel_color_theme ADD CONSTRAINT FK_D2A2E1C981CFDAE7 FOREIGN KEY (url_id) REFERENCES access_url (id)"); - $this->addSql("ALTER TABLE access_url_rel_color_theme ADD CONSTRAINT FK_D2A2E1C98587EFC5 FOREIGN KEY (color_theme_id) REFERENCES color_theme (id)"); + $this->addSql('ALTER TABLE access_url_rel_color_theme ADD CONSTRAINT FK_D2A2E1C981CFDAE7 FOREIGN KEY (url_id) REFERENCES access_url (id)'); + $this->addSql('ALTER TABLE access_url_rel_color_theme ADD CONSTRAINT FK_D2A2E1C98587EFC5 FOREIGN KEY (color_theme_id) REFERENCES color_theme (id)'); } } diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20170625153000.php b/src/CoreBundle/Migrations/Schema/V200/Version20170625153000.php index f9280149ee..7e4e5b208e 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20170625153000.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20170625153000.php @@ -107,7 +107,7 @@ class Version20170625153000 extends AbstractMigrationChamilo } $this->addSql('UPDATE c_forum_thread SET thread_date = NOW() WHERE thread_date is NULL OR thread_date = 0'); - $this->addSql('UPDATE c_forum_thread SET forum_id = NULL WHERE forum_id IS NOT NULL AND forum_id NOT IN (SELECT iid FROM c_forum_forum) '); + $this->addSql('UPDATE c_forum_thread SET forum_id = NULL WHERE forum_id IS NOT NULL AND forum_id NOT IN (SELECT iid FROM c_forum_forum) '); $this->addSql('ALTER TABLE c_forum_thread CHANGE thread_date thread_date DATETIME NOT NULL'); if (false === $table->hasColumn('resource_node_id')) { diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201205102020.php b/src/CoreBundle/Migrations/Schema/V200/Version20201205102020.php index 1bf0ec1404..9eed182f13 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20201205102020.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20201205102020.php @@ -106,7 +106,7 @@ final class Version20201205102020 extends AbstractMigrationChamilo } if (!$table->hasForeignKey('FK_79D3D95A613FECDF')) { - $this->addSql('UPDATE skill_rel_user SET session_id = NULL WHERE session_id NOT IN (SELECT id FROM session)'); + $this->addSql('UPDATE skill_rel_user SET session_id = NULL WHERE session_id NOT IN (SELECT id FROM session)'); $this->addSql( 'ALTER TABLE skill_rel_user ADD CONSTRAINT FK_79D3D95A613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE SET NULL' ); diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201215072919.php b/src/CoreBundle/Migrations/Schema/V200/Version20201215072919.php index 36f2dc9a62..04c0d8ddc5 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20201215072919.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20201215072919.php @@ -16,16 +16,13 @@ class Version20201215072919 extends AbstractMigrationChamilo return 'Create agenda_reminder table as fallback to allow to use CCalendarEvent entities'; } - /** - * @inheritDoc - */ public function up(Schema $schema): void { if (!$schema->hasTable('agenda_reminder')) { $this->addSql( "CREATE TABLE agenda_reminder (id INT AUTO_INCREMENT NOT NULL, event_id INT NOT NULL, date_interval VARCHAR(255) NOT NULL COMMENT '(DC2Type:dateinterval)', sent TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_416FFA2471F7E88B (event_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC" ); - $this->addSql("ALTER TABLE agenda_reminder ADD CONSTRAINT FK_416FFA2471F7E88B FOREIGN KEY (event_id) REFERENCES c_calendar_event (iid)"); + $this->addSql('ALTER TABLE agenda_reminder ADD CONSTRAINT FK_416FFA2471F7E88B FOREIGN KEY (event_id) REFERENCES c_calendar_event (iid)'); } } -} \ No newline at end of file +} diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20231110194300.php b/src/CoreBundle/Migrations/Schema/V200/Version20231110194300.php index a23e8e71aa..edfd08714c 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20231110194300.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20231110194300.php @@ -10,6 +10,8 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; use Doctrine\DBAL\Schema\Schema; use Symfony\Component\Finder\Finder; +use const DIRECTORY_SEPARATOR; + final class Version20231110194300 extends AbstractMigrationChamilo { public function getDescription(): string diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20240425192900.php b/src/CoreBundle/Migrations/Schema/V200/Version20240425192900.php index da83d6316c..a86669b78c 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20240425192900.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20240425192900.php @@ -22,19 +22,19 @@ class Version20240425192900 extends AbstractMigration $tblAgendaReminder = $schema->getTable('agenda_reminder'); if ($tblAgendaReminder->hasColumn('type')) { - $this->addSql("ALTER TABLE agenda_reminder DROP type"); + $this->addSql('ALTER TABLE agenda_reminder DROP type'); } - $this->addSql("ALTER TABLE agenda_reminder CHANGE id id INT AUTO_INCREMENT NOT NULL"); + $this->addSql('ALTER TABLE agenda_reminder CHANGE id id INT AUTO_INCREMENT NOT NULL'); if (!$tblAgendaReminder->hasForeignKey('FK_416FFA2471F7E88B')) { $this->addSql('DELETE FROM agenda_reminder WHERE event_id IS NULL OR event_id NOT IN (SELECT iid FROM c_calendar_event)'); - $this->addSql("ALTER TABLE agenda_reminder ADD CONSTRAINT FK_416FFA2471F7E88B FOREIGN KEY (event_id) REFERENCES c_calendar_event (iid)"); + $this->addSql('ALTER TABLE agenda_reminder ADD CONSTRAINT FK_416FFA2471F7E88B FOREIGN KEY (event_id) REFERENCES c_calendar_event (iid)'); } if (!$tblAgendaReminder->hasIndex('IDX_416FFA2471F7E88B')) { - $this->addSql("CREATE INDEX IDX_416FFA2471F7E88B ON agenda_reminder (event_id)"); + $this->addSql('CREATE INDEX IDX_416FFA2471F7E88B ON agenda_reminder (event_id)'); } } } diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20240702222600.php b/src/CoreBundle/Migrations/Schema/V200/Version20240702222600.php index 9f3f5be6b2..d5eb172a97 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20240702222600.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20240702222600.php @@ -24,13 +24,13 @@ final class Version20240702222600 extends AbstractMigrationChamilo if (!$tblResourceFile->hasColumn('resource_node_id')) { $this->addSql('ALTER TABLE resource_file ADD resource_node_id INT DEFAULT NULL'); - $result = $this->connection->executeQuery("SELECT id, resource_file_id FROM resource_node"); + $result = $this->connection->executeQuery('SELECT id, resource_file_id FROM resource_node'); $resourceNodeRows = $result->fetchAllAssociative(); foreach ($resourceNodeRows as $resourceNodeRow) { $this->addSql( sprintf( - "UPDATE resource_file SET resource_node_id = %d WHERE id = %d", + 'UPDATE resource_file SET resource_node_id = %d WHERE id = %d', $resourceNodeRow['id'], $resourceNodeRow['resource_file_id'] ) diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20240704120500.php b/src/CoreBundle/Migrations/Schema/V200/Version20240704120500.php index 97db74b54f..787f2e7e0e 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20240704120500.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20240704120500.php @@ -51,7 +51,7 @@ final class Version20240704120500 extends AbstractMigrationChamilo $durationInSeconds = $workTime * 60; - $this->addSql("UPDATE c_student_publication SET duration = ? WHERE iid = ?", [$durationInSeconds, $id]); + $this->addSql('UPDATE c_student_publication SET duration = ? WHERE iid = ?', [$durationInSeconds, $id]); } } } @@ -75,15 +75,15 @@ final class Version20240704120500 extends AbstractMigrationChamilo $newDuration = null; if (preg_match('/(\d+)([h:](\d+)?)?/', $duration, $matches)) { - $hours = (int)$matches[1]; + $hours = (int) $matches[1]; $minutes = 0; if (!empty($matches[3])) { - $minutes = (int)$matches[3]; + $minutes = (int) $matches[3]; } $newDuration = ($hours * 3600) + ($minutes * 60); } - if ($newDuration !== null) { + if (null !== $newDuration) { $this->addSql('UPDATE c_attendance_calendar SET duration = ? WHERE iid = ?', [$newDuration, $id]); } } diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php b/src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php index be333fbd78..97b9820e60 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php @@ -1,5 +1,7 @@ addSql("DELETE FROM settings WHERE variable IN ('stylesheets', 'theme')"); @@ -40,7 +41,7 @@ class Version20240704185300 extends AbstractMigrationChamilo if ($entry->isDir()) { $this->write( sprintf( - "Moving theme directory: %s to %s", + 'Moving theme directory: %s to %s', $entry->getRealPath(), $themesDirectory.DIRECTORY_SEPARATOR ) diff --git a/src/CoreBundle/ServiceHelper/ThemeHelper.php b/src/CoreBundle/ServiceHelper/ThemeHelper.php index eed0a51e0f..a33572af51 100644 --- a/src/CoreBundle/ServiceHelper/ThemeHelper.php +++ b/src/CoreBundle/ServiceHelper/ThemeHelper.php @@ -16,6 +16,8 @@ use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\RouterInterface; +use const DIRECTORY_SEPARATOR; + final class ThemeHelper { public const DEFAULT_THEME = 'chamilo'; @@ -27,7 +29,8 @@ final class ThemeHelper private readonly CidReqHelper $cidReqHelper, private readonly SettingsCourseManager $settingsCourseManager, private readonly RouterInterface $router, - #[Autowire(service: 'oneup_flysystem.themes_filesystem')] private readonly FilesystemOperator $filesystem, + #[Autowire(service: 'oneup_flysystem.themes_filesystem')] + private readonly FilesystemOperator $filesystem, ) {} /** diff --git a/src/CoreBundle/State/AccessUrlRelColorThemeStateProcessor.php b/src/CoreBundle/State/AccessUrlRelColorThemeStateProcessor.php index 4be89c4527..204ca15a39 100644 --- a/src/CoreBundle/State/AccessUrlRelColorThemeStateProcessor.php +++ b/src/CoreBundle/State/AccessUrlRelColorThemeStateProcessor.php @@ -21,7 +21,7 @@ final class AccessUrlRelColorThemeStateProcessor implements ProcessorInterface public function process($data, Operation $operation, array $uriVariables = [], array $context = []): AccessUrlRelColorTheme { - assert($data instanceof AccessUrlRelColorTheme); + \assert($data instanceof AccessUrlRelColorTheme); $accessUrl = $this->accessUrlHelper->getCurrent(); $accessUrl->getActiveColorTheme()?->setActive(false); diff --git a/src/CoreBundle/State/AccessUrlRelColorThemeStateProvider.php b/src/CoreBundle/State/AccessUrlRelColorThemeStateProvider.php index c1d3cbab77..a0b1a57a1b 100644 --- a/src/CoreBundle/State/AccessUrlRelColorThemeStateProvider.php +++ b/src/CoreBundle/State/AccessUrlRelColorThemeStateProvider.php @@ -1,5 +1,7 @@ accessUrlHelper->getCurrent()->getColorThemes(); diff --git a/src/CoreBundle/State/ColorThemeStateProcessor.php b/src/CoreBundle/State/ColorThemeStateProcessor.php index d70e38f7d6..0501de726d 100644 --- a/src/CoreBundle/State/ColorThemeStateProcessor.php +++ b/src/CoreBundle/State/ColorThemeStateProcessor.php @@ -16,6 +16,7 @@ use League\Flysystem\FilesystemException; use League\Flysystem\FilesystemOperator; use Symfony\Component\DependencyInjection\Attribute\Autowire; +use const DIRECTORY_SEPARATOR; use const PHP_EOL; final class ColorThemeStateProcessor implements ProcessorInterface @@ -24,10 +25,13 @@ final class ColorThemeStateProcessor implements ProcessorInterface private readonly ProcessorInterface $persistProcessor, private readonly AccessUrlHelper $accessUrlHelper, private readonly EntityManagerInterface $entityManager, - #[Autowire(service: 'oneup_flysystem.themes_filesystem')] private readonly FilesystemOperator $filesystem, + #[Autowire(service: 'oneup_flysystem.themes_filesystem')] + private readonly FilesystemOperator $filesystem, ) {} /** + * @param mixed $data + * * @throws FilesystemException */ public function process($data, Operation $operation, array $uriVariables = [], array $context = []) diff --git a/tests/CoreBundle/Controller/ThemeControllerTest.php b/tests/CoreBundle/Controller/ThemeControllerTest.php index 09b6db3039..21a9147613 100644 --- a/tests/CoreBundle/Controller/ThemeControllerTest.php +++ b/tests/CoreBundle/Controller/ThemeControllerTest.php @@ -11,7 +11,6 @@ use Symfony\Component\HttpFoundation\Response; class ThemeControllerTest extends WebTestCase { - public function testValidAccess(): void { $client = static::createClient(); @@ -37,7 +36,6 @@ class ThemeControllerTest extends WebTestCase $this->assertResponseStatusCodeSame(Response::HTTP_INTERNAL_SERVER_ERROR); - $client->request('GET', 'themes/chamilo/../../../.env'); $this->assertResponseStatusCodeSame(Response::HTTP_INTERNAL_SERVER_ERROR);