Minor: Format code

pull/5759/head
Angel Fernando Quiroz Campos 1 year ago
parent 08696ff7e6
commit 34d7e66fb3
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 2
      src/CoreBundle/Component/Editor/Toolbar.php
  2. 2
      src/CoreBundle/Component/Utils/AssetFileNameNamer.php
  3. 14
      src/CoreBundle/Component/Utils/ChamiloApi.php
  4. 11
      src/CoreBundle/Controller/Admin/PluginsController.php
  5. 44
      src/CoreBundle/Controller/Api/BaseResourceFileAction.php
  6. 2
      src/CoreBundle/Controller/AssetController.php
  7. 49
      src/CoreBundle/Controller/CourseController.php
  8. 12
      src/CoreBundle/Controller/ExceptionController.php
  9. 2
      src/CoreBundle/Controller/ResetPasswordController.php
  10. 2
      src/CoreBundle/Controller/ResourceController.php
  11. 24
      src/CoreBundle/Controller/SessionController.php
  12. 8
      src/CoreBundle/Controller/SocialController.php
  13. 4
      src/CoreBundle/DataProvider/Extension/CourseExtension.php
  14. 2
      src/CoreBundle/DataProvider/Extension/CourseRelUserExtension.php
  15. 17
      src/CoreBundle/DataProvider/Extension/MessageExtension.php
  16. 2
      src/CoreBundle/DataProvider/Extension/SessionRelUserExtension.php
  17. 6
      src/CoreBundle/Entity/Block.php
  18. 2
      src/CoreBundle/Entity/CourseCategory.php
  19. 7
      src/CoreBundle/Entity/JustificationDocumentRelUsers.php
  20. 45
      src/CoreBundle/Entity/Listener/CourseListener.php
  21. 8
      src/CoreBundle/Entity/Listener/ResourceListener.php
  22. 23
      src/CoreBundle/Entity/Listener/SessionListener.php
  23. 2
      src/CoreBundle/Entity/Listener/SkillRelUserListener.php
  24. 2
      src/CoreBundle/Entity/Listener/UserListener.php
  25. 34
      src/CoreBundle/Entity/Listener/UserRelUserListener.php
  26. 39
      src/CoreBundle/Entity/ResourceFile.php
  27. 2
      src/CoreBundle/Entity/ResourceLink.php
  28. 6
      src/CoreBundle/Entity/ResourceNode.php
  29. 2
      src/CoreBundle/Entity/Session.php
  30. 6
      src/CoreBundle/Entity/SkillRelUser.php
  31. 43
      src/CoreBundle/Entity/Tool.php
  32. 2
      src/CoreBundle/Entity/TrackEAttemptQualify.php
  33. 4
      src/CoreBundle/Entity/User.php
  34. 2
      src/CoreBundle/Entity/Usergroup.php
  35. 33
      src/CoreBundle/EventListener/LegacyListener.php
  36. 2
      src/CoreBundle/EventSubscriber/LocaleSubscriber.php
  37. 2
      src/CoreBundle/Form/CurriculumItemRelUserCollectionType.php
  38. 2
      src/CoreBundle/Form/CurriculumItemRelUserType.php
  39. 2
      src/CoreBundle/Form/DataTransformer/ResourceToIdentifierTransformer.php
  40. 2
      src/CoreBundle/Framework/Exporter.php
  41. 3
      src/CoreBundle/Migrations/AbstractMigrationChamilo.php
  42. 3
      src/CoreBundle/Migrations/Schema/V200/PriorityMigrationHelper.php
  43. 64
      src/CoreBundle/Migrations/Schema/V200/Version20.php
  44. 23
      src/CoreBundle/Migrations/Schema/V200/Version20170625143000.php
  45. 3
      src/CoreBundle/Migrations/Schema/V200/Version20181126174500.php
  46. 4
      src/CoreBundle/Migrations/Schema/V200/Version20191208160020.php
  47. 31
      src/CoreBundle/Migrations/Schema/V200/Version20200821224242.php
  48. 18
      src/CoreBundle/Migrations/Schema/V200/Version20200821224244.php
  49. 2
      src/CoreBundle/Migrations/Schema/V200/Version20201215072920.php
  50. 2
      src/CoreBundle/Migrations/Schema/V200/Version20201215160445.php
  51. 112
      src/CoreBundle/Migrations/Schema/V200/Version20201216105331.php
  52. 2
      src/CoreBundle/Migrations/Schema/V200/Version20230904173400.php
  53. 2
      src/CoreBundle/Migrations/Schema/V200/Version20240313111800.php
  54. 2
      src/CoreBundle/Migrations/Schema/V200/Version20240323181500.php
  55. 2
      src/CoreBundle/Migrations/Schema/V200/Version20240702222600.php
  56. 2
      src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php
  57. 33
      src/CoreBundle/Migrations/Schema/V200/Version20240806120000.php
  58. 6
      src/CoreBundle/Migrations/Schema/V200/Version20240811221400.php
  59. 3
      src/CoreBundle/Migrations/Schema/V200/Version20240811221500.php
  60. 5
      src/CoreBundle/Migrations/Schema/V200/Version20240811221600.php
  61. 2
      src/CoreBundle/Migrations/Schema/V200/Version20240811221700.php
  62. 2
      src/CoreBundle/Migrations/Schema/V200/Version20240811221800.php
  63. 2
      src/CoreBundle/Migrations/Schema/V200/Version20240811221900.php
  64. 46
      src/CoreBundle/Migrations/Schema/V200/Version20240811221950.php
  65. 3
      src/CoreBundle/Migrations/Schema/V200/Version20240819120200.php
  66. 6
      src/CoreBundle/Migrations/Schema/V200/Version20240826220000.php
  67. 26
      src/CoreBundle/Repository/Node/IllustrationRepository.php
  68. 2
      src/CoreBundle/Repository/Node/UserRepository.php
  69. 4
      src/CoreBundle/Repository/ResourceFactory.php
  70. 26
      src/CoreBundle/Repository/ResourceNodeRepository.php
  71. 4
      src/CoreBundle/Repository/ResourceRepository.php
  72. 1
      src/CoreBundle/Repository/ResourceWithLinkInterface.php
  73. 5
      src/CoreBundle/Repository/SessionRepository.php
  74. 9
      src/CoreBundle/Security/AuthenticationEntryPoint.php
  75. 6
      src/CoreBundle/Security/Authenticator/OAuth2/GenericAuthenticator.php
  76. 7
      src/CoreBundle/Security/Authorization/Voter/ResourceNodeVoter.php
  77. 2
      src/CoreBundle/ServiceHelper/LoginAttemptLogger.php
  78. 3
      src/CoreBundle/ServiceHelper/ThemeHelper.php
  79. 39
      src/CoreBundle/Settings/SettingsManager.php
  80. 25
      src/CoreBundle/Settings/SettingsResolver.php
  81. 4
      src/CoreBundle/State/CStudentPublicationPostStateProcessor.php
  82. 2
      src/CoreBundle/Tool/HandlerCollection.php
  83. 45
      src/CoreBundle/Traits/CourseControllerTrait.php
  84. 10
      src/CoreBundle/Twig/Extension/ChamiloExtension.php
  85. 2
      src/CourseBundle/DependencyInjection/Compiler/RegisterSchemasPass.php
  86. 10
      src/CourseBundle/Entity/CBlog.php
  87. 7
      src/CourseBundle/Entity/CBlogComment.php
  88. 7
      src/CourseBundle/Entity/CBlogPost.php
  89. 7
      src/CourseBundle/Entity/CBlogTaskRelUser.php
  90. 1
      src/CourseBundle/Entity/CStudentPublication.php
  91. 26
      src/CourseBundle/Entity/CStudentPublicationAssignment.php
  92. 26
      src/CourseBundle/Entity/CThematicAdvance.php
  93. 26
      src/CourseBundle/Entity/CThematicPlan.php
  94. 96
      src/CourseBundle/Repository/CForumPostRepository.php
  95. 2
      src/LtiBundle/Component/OutcomeDeleteResponse.php
  96. 2
      src/LtiBundle/Component/OutcomeReadRequest.php
  97. 2
      src/LtiBundle/Component/OutcomeReadResponse.php
  98. 2
      src/LtiBundle/Component/OutcomeReplaceRequest.php
  99. 2
      src/LtiBundle/Component/OutcomeReplaceResponse.php
  100. 2
      src/LtiBundle/Component/OutcomeResponse.php
  101. Some files were not shown because too many files have changed in this diff Show More

@ -16,8 +16,6 @@ class Toolbar
public array $defaultPlugins = [];
/**
* Toolbar constructor.
*
* @param RouterInterface $urlGenerator
* @param null $toolbar
* @param array $config

@ -45,7 +45,7 @@ class AssetFileNameNamer implements NamerInterface
$titleSlug = $this->slugify($templateTitle);
$extension = pathinfo($mapping->getFileName($object), PATHINFO_EXTENSION);
return sprintf('%s-%s.%s', $templateId, $titleSlug, $extension);
return \sprintf('%s-%s.%s', $templateId, $titleSlug, $extension);
}
}

@ -96,22 +96,22 @@ class ChamiloApi
}
}
$themeDir = Template::getThemeDir($theme);
$customLogoPath = $themeDir.sprintf('images/header-logo-custom%s.png', $accessUrlId);
$customLogoPath = $themeDir.\sprintf('images/header-logo-custom%s.png', $accessUrlId);
$svgIcons = api_get_setting('icons_mode_svg');
if ('true' === $svgIcons) {
$customLogoPathSVG = substr($customLogoPath, 0, -3).'svg';
if (file_exists(api_get_path(SYS_PUBLIC_PATH).sprintf('css/%s', $customLogoPathSVG))) {
if (file_exists(api_get_path(SYS_PUBLIC_PATH).\sprintf('css/%s', $customLogoPathSVG))) {
if ($getSysPath) {
return api_get_path(SYS_PUBLIC_PATH).sprintf('css/%s', $customLogoPathSVG);
return api_get_path(SYS_PUBLIC_PATH).\sprintf('css/%s', $customLogoPathSVG);
}
return api_get_path(WEB_CSS_PATH).$customLogoPathSVG;
}
}
if (file_exists(api_get_path(SYS_PUBLIC_PATH).sprintf('css/%s', $customLogoPath))) {
if (file_exists(api_get_path(SYS_PUBLIC_PATH).\sprintf('css/%s', $customLogoPath))) {
if ($getSysPath) {
return api_get_path(SYS_PUBLIC_PATH).sprintf('css/%s', $customLogoPath);
return api_get_path(SYS_PUBLIC_PATH).\sprintf('css/%s', $customLogoPath);
}
return api_get_path(WEB_CSS_PATH).$customLogoPath;
@ -310,10 +310,10 @@ class ChamiloApi
{
$visualTheme = api_get_visual_theme();
$cssFile = api_get_path(SYS_CSS_PATH).sprintf('themes/%s/editor_content.css', $visualTheme);
$cssFile = api_get_path(SYS_CSS_PATH).\sprintf('themes/%s/editor_content.css', $visualTheme);
if (is_file($cssFile)) {
return api_get_path(WEB_CSS_PATH).sprintf('themes/%s/editor_content.css', $visualTheme);
return api_get_path(WEB_CSS_PATH).\sprintf('themes/%s/editor_content.css', $visualTheme);
}
return api_get_path(WEB_CSS_PATH).'editor_content.css';

@ -39,12 +39,11 @@ class PluginsController extends BaseController
$allPluginsList = [];
foreach ($allPlugins as $pluginName) {
/*$file = api_get_path(SYS_PLUGIN_PATH).$pluginName.'/plugin.php';
if (is_file($file)) {
$pluginInfo = require $file;
var_dump($pluginInfo);exit;
$allPluginsList[] = $pluginInfo;
}*/
* if (is_file($file)) {
* $pluginInfo = require $file;
* var_dump($pluginInfo);exit;
* $allPluginsList[] = $pluginInfo;
* }*/
}
$installedPlugins = $appPlugin->getInstalledPlugins();

@ -49,7 +49,7 @@ class BaseResourceFileAction
$linkSet = true;
$resourceLink->setCourse($course);
} else {
throw new InvalidArgumentException(sprintf('Course #%s does not exists', $link['cid']));
throw new InvalidArgumentException(\sprintf('Course #%s does not exists', $link['cid']));
}
}
@ -59,7 +59,7 @@ class BaseResourceFileAction
$linkSet = true;
$resourceLink->setSession($session);
} else {
throw new InvalidArgumentException(sprintf('Session #%s does not exists', $link['sid']));
throw new InvalidArgumentException(\sprintf('Session #%s does not exists', $link['sid']));
}
}
@ -69,7 +69,7 @@ class BaseResourceFileAction
$linkSet = true;
$resourceLink->setGroup($group);
} else {
throw new InvalidArgumentException(sprintf('Group #%s does not exists', $link['gid']));
throw new InvalidArgumentException(\sprintf('Group #%s does not exists', $link['gid']));
}
}
@ -79,7 +79,7 @@ class BaseResourceFileAction
$linkSet = true;
$resourceLink->setUser($user);
} else {
throw new InvalidArgumentException(sprintf('User #%s does not exists', $link['uid']));
throw new InvalidArgumentException(\sprintf('User #%s does not exists', $link['uid']));
}
}
@ -104,25 +104,23 @@ class BaseResourceFileAction
// error_log('$resource->getResourceLinkEntityList()');
foreach ($links as $link) {
/*$rights = [];
switch ($link->getVisibility()) {
case ResourceLink::VISIBILITY_PENDING:
case ResourceLink::VISIBILITY_DRAFT:
$editorMask = ResourceNodeVoter::getEditorMask();
$resourceRight = new ResourceRight();
$resourceRight
->setMask($editorMask)
->setRole(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)
;
$rights[] = $resourceRight;
break;
}
if (!empty($rights)) {
foreach ($rights as $right) {
$link->addResourceRight($right);
}
}*/
* switch ($link->getVisibility()) {
* case ResourceLink::VISIBILITY_PENDING:
* case ResourceLink::VISIBILITY_DRAFT:
* $editorMask = ResourceNodeVoter::getEditorMask();
* $resourceRight = new ResourceRight();
* $resourceRight
* ->setMask($editorMask)
* ->setRole(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)
* ;
* $rights[] = $resourceRight;
* break;
* }
* if (!empty($rights)) {
* foreach ($rights as $right) {
* $link->addResourceRight($right);
* }
* }*/
// error_log('link adding to node: '.$resource->getResourceNode()->getId());
// error_log('link with user : '.$link->getUser()->getUsername());
$resource->getResourceNode()->addResourceLink($link);

@ -75,6 +75,6 @@ class AssetController
return $response;
}
throw new FileNotFoundException(sprintf('File not found: %s', $path));
throw new FileNotFoundException(\sprintf('File not found: %s', $path));
}
}

@ -280,27 +280,22 @@ class CourseController extends ToolBaseController
}
/*public function redirectToShortCut(string $toolName, CToolRepository $repo, ToolChain $toolChain): RedirectResponse
{
$tool = $repo->findOneBy([
'name' => $toolName,
]);
if (null === $tool) {
throw new NotFoundHttpException($this->trans('Tool not found'));
}
$tool = $toolChain->getToolFromName($tool->getTool()->getTitle());
$link = $tool->getLink();
if (strpos($link, 'nodeId')) {
$nodeId = (string) $this->getCourse()->getResourceNode()->getId();
$link = str_replace(':nodeId', $nodeId, $link);
}
$url = $link.'?'.$this->getCourseUrlQuery();
return $this->redirect($url);
}*/
* {
* $tool = $repo->findOneBy([
* 'name' => $toolName,
* ]);
* if (null === $tool) {
* throw new NotFoundHttpException($this->trans('Tool not found'));
* }
* $tool = $toolChain->getToolFromName($tool->getTool()->getTitle());
* $link = $tool->getLink();
* if (strpos($link, 'nodeId')) {
* $nodeId = (string) $this->getCourse()->getResourceNode()->getId();
* $link = str_replace(':nodeId', $nodeId, $link);
* }
* $url = $link.'?'.$this->getCourseUrlQuery();
* return $this->redirect($url);
* }*/
/**
* Edit configuration with given namespace.
@ -376,7 +371,7 @@ class CourseController extends ToolBaseController
$courseValues = new ExtraFieldValue('course');
$urlCourse = api_get_path(WEB_PATH).sprintf('course/%s/about', $courseId);
$urlCourse = api_get_path(WEB_PATH).\sprintf('course/%s/about', $courseId);
$courseTeachers = $course->getTeachersSubscriptions();
$teachersData = [];
@ -789,7 +784,7 @@ class CourseController extends ToolBaseController
// Redirecting to the LP
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq();
$_SESSION[$session_key] = true;
header(sprintf('Location: %s', $url));
header(\sprintf('Location: %s', $url));
exit;
}
@ -826,7 +821,7 @@ class CourseController extends ToolBaseController
'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp_data['iid'];
$_SESSION[$session_key] = true;
header(sprintf('Location: %s', $url));
header(\sprintf('Location: %s', $url));
exit;
}
@ -852,7 +847,7 @@ class CourseController extends ToolBaseController
}
} else {
$url = api_get_path(WEB_CODE_PATH).'forum/index.php?'.api_get_cidreq();
header(sprintf('Location: %s', $url));
header(\sprintf('Location: %s', $url));
exit;
}
@ -870,7 +865,7 @@ class CourseController extends ToolBaseController
} else {
// Redirecting to the document
$url = api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq();
header(sprintf('Location: %s', $url));
header(\sprintf('Location: %s', $url));
exit;
}
@ -906,7 +901,7 @@ class CourseController extends ToolBaseController
$exerciseId = $row['iid'];
$url = api_get_path(WEB_CODE_PATH).
'exercise/overview.php?exerciseId='.$exerciseId.'&'.api_get_cidreq();
header(sprintf('Location: %s', $url));
header(\sprintf('Location: %s', $url));
exit;
}

@ -29,16 +29,16 @@ class ExceptionController extends AbstractController
$format = 'html';
$loader = $this->container->get('twig')->getLoader();
$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
$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)) {
$templateToLoad = $template;
}
// 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);
if ($loader->exists($template)) {
$templateToLoad = $template;
}
@ -68,18 +68,18 @@ class ExceptionController extends AbstractController
$format = 'html';
$loader = $this->container->get('twig')->getLoader();
$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
// 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)) {
$templateToLoad = $template;
}
// }
// 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);
if ($loader->exists($template)) {
$templateToLoad = $template;
}

@ -97,7 +97,7 @@ class ResetPasswordController extends AbstractController
try {
$user = $this->resetPasswordHelper->validateTokenAndFetchUser($token);
} catch (ResetPasswordExceptionInterface $e) {
$this->addFlash('reset_password_error', sprintf(
$this->addFlash('reset_password_error', \sprintf(
'There was a problem validating your reset request - %s',
$e->getReason()
));

@ -256,7 +256,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
$qbAlias = $qb->getRootAliases()[0];
$qb
->leftJoin(sprintf('%s.resourceFiles', $qbAlias), 'resourceFiles') // must have a file
->leftJoin(\sprintf('%s.resourceFiles', $qbAlias), 'resourceFiles') // must have a file
->addCriteria($criteria)
;

@ -187,19 +187,17 @@ class SessionController extends AbstractController
$sessionDates = SessionManager::parseSessionDates($session, true);
$hasRequirements = false;
/*$sessionRequirements = $sequenceResourceRepo->getRequirements(
$session->getId(),
SequenceResource::SESSION_TYPE
);
foreach ($sessionRequirements as $sequence) {
if (!empty($sequence['requirements'])) {
$hasRequirements = true;
break;
}
}*/
/*$sessionRequirements = $sequenceResourceRepo->getRequirements(
* $session->getId(),
* SequenceResource::SESSION_TYPE
* );
* foreach ($sessionRequirements as $sequence) {
* if (!empty($sequence['requirements'])) {
* $hasRequirements = true;
* break;
* }
* }*/
$plugin = BuyCoursesPlugin::create();
$checker = $plugin->isEnabled();
$sessionIsPremium = null;
@ -235,7 +233,7 @@ class SessionController extends AbstractController
// 'sequences' => $sessionRequirements,
'is_premium' => $sessionIsPremium,
'show_tutor' => 'true' === api_get_setting('show_session_coach'),
'page_url' => api_get_path(WEB_PATH).sprintf('sessions/%s/about/', $session->getId()),
'page_url' => api_get_path(WEB_PATH).\sprintf('sessions/%s/about/', $session->getId()),
'session_date' => $sessionDates,
'is_subscribed' => SessionManager::isUserSubscribedAsStudent(
$session->getId(),

@ -212,11 +212,11 @@ class SocialController extends AbstractController
if (!empty($bossList)) {
$bossList = array_column($bossList, 'boss_id');
foreach ($bossList as $bossId) {
$subjectEmail = sprintf(
$subjectEmail = \sprintf(
$translator->trans('User %s signed the agreement'),
$user->getFullname()
);
$contentEmail = sprintf(
$contentEmail = \sprintf(
$translator->trans('User %s signed the agreement.TheDateY'),
$user->getFullname(),
api_get_local_time()
@ -286,12 +286,12 @@ class SocialController extends AbstractController
$fieldToUpdate = 'request_for_delete_account';
$justificationFieldToUpdate = 'request_for_delete_account_justification';
$emailSubject = $translator->trans('Request for account deletion');
$emailContent = sprintf($translator->trans('User %s asked for the deletion of his/her account, explaining that : ').$explanation, $user->getFullName());
$emailContent = \sprintf($translator->trans('User %s asked for the deletion of his/her account, explaining that : ').$explanation, $user->getFullName());
} elseif ('delete_legal' === $requestType) {
$fieldToUpdate = 'request_for_legal_agreement_consent_removal';
$justificationFieldToUpdate = 'request_for_legal_agreement_consent_removal_justification';
$emailSubject = $translator->trans('Request for consent withdrawal on legal terms');
$emailContent = sprintf($translator->trans('User %s asked for the removal of his/her consent to our legal terms, explaining that: ').$explanation, $user->getFullName());
$emailContent = \sprintf($translator->trans('User %s asked for the removal of his/her consent to our legal terms, explaining that: ').$explanation, $user->getFullName());
} else {
return $this->json(['success' => false, 'message' => 'Invalid action type']);
}

@ -58,11 +58,11 @@ final class CourseExtension implements QueryCollectionExtensionInterface
$rootAlias = $queryBuilder->getRootAliases()[0];
$queryBuilder
->andWhere(sprintf('%s.visibility <> :visibility_hidden', $rootAlias))
->andWhere(\sprintf('%s.visibility <> :visibility_hidden', $rootAlias))
->setParameter('visibility_hidden', Course::HIDDEN)
;
$queryBuilder
->andWhere(sprintf('%s.visibility <> :visibility_closed', $rootAlias))
->andWhere(\sprintf('%s.visibility <> :visibility_closed', $rootAlias))
->setParameter('visibility_closed', Course::CLOSED)
;
}

@ -72,7 +72,7 @@ final class CourseRelUserExtension implements QueryCollectionExtensionInterface
}
$rootAlias = $queryBuilder->getRootAliases()[0];
$queryBuilder->andWhere(sprintf('%s.user = :current_user', $rootAlias));
$queryBuilder->andWhere(\sprintf('%s.user = :current_user', $rootAlias));
$queryBuilder->setParameter('current_user', $user->getId());
}
}

@ -35,15 +35,14 @@ final class MessageExtension implements QueryCollectionExtensionInterface // , Q
return;
}*/
/*
if ('collection_query' === $operationName) {
if (null === $user = $this->security->getUser()) {
throw new AccessDeniedException('Access Denied.');
}
$rootAlias = $queryBuilder->getRootAliases()[0];
$queryBuilder->andWhere(sprintf('%s.user = :current_user', $rootAlias));
$queryBuilder->setParameter('current_user', $user);
}*/
* if ('collection_query' === $operationName) {
* if (null === $user = $this->security->getUser()) {
* throw new AccessDeniedException('Access Denied.');
* }
* $rootAlias = $queryBuilder->getRootAliases()[0];
* $queryBuilder->andWhere(sprintf('%s.user = :current_user', $rootAlias));
* $queryBuilder->setParameter('current_user', $user);
* }*/
$this->addWhere($queryBuilder, $resourceClass);
}

@ -58,7 +58,7 @@ final class SessionRelUserExtension implements QueryCollectionExtensionInterface
throw new AccessDeniedException('Access Denied SessionRelUser');
}
$qb->andWhere(sprintf('%s.user = :current_user', $alias));
$qb->andWhere(\sprintf('%s.user = :current_user', $alias));
$qb->setParameter('current_user', $user->getId());
}
}

@ -58,6 +58,7 @@ class Block
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
@ -69,6 +70,7 @@ class Block
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
@ -80,6 +82,7 @@ class Block
public function setPath(string $path): self
{
$this->path = $path;
return $this;
}
@ -91,6 +94,7 @@ class Block
public function setController(string $controller): self
{
$this->controller = $controller;
return $this;
}
@ -102,6 +106,7 @@ class Block
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
@ -113,6 +118,7 @@ class Block
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
}

@ -126,7 +126,7 @@ class CourseCategory implements Stringable
{
$name = strip_tags($this->title);
return sprintf('%s (%s)', $name, $this->code);
return \sprintf('%s (%s)', $name, $this->code);
}
/**

@ -6,6 +6,7 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Entity;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
@ -29,7 +30,7 @@ class JustificationDocumentRelUsers
private ?User $user = null;
#[ORM\Column(type: 'date', nullable: true)]
private ?\DateTime $dateValidity = null;
private ?DateTime $dateValidity = null;
public function getId(): ?int
{
@ -72,12 +73,12 @@ class JustificationDocumentRelUsers
return $this;
}
public function getDateValidity(): ?\DateTime
public function getDateValidity(): ?DateTime
{
return $this->dateValidity;
}
public function setDateValidity(?\DateTime $dateValidity): self
public function setDateValidity(?DateTime $dateValidity): self
{
$this->dateValidity = $dateValidity;

@ -31,29 +31,24 @@ class CourseListener
}
/*protected function checkLimit(CourseRepository $repo, Course $course, AccessUrl $url): void
{
$limit = $url->getLimitCourses();
if (!empty($limit)) {
$count = $repo->getCountCoursesByUrl($url);
if ($count >= $limit) {
api_warn_hosting_contact('hosting_limit_courses', $limit);
throw new \Exception('PortalCoursesLimitReached');
}
}
if (COURSE_VISIBILITY_HIDDEN != $course->getVisibility()) {
$limit = $url->getLimitActiveCourses();
if (!empty($limit)) {
$count = $repo->getCountActiveCoursesByUrl($url);
if ($count >= $limit) {
api_warn_hosting_contact('hosting_limit_active_courses', $limit);
throw new \Exception('PortalActiveCoursesLimitReached');
}
}
}
}*/
* {
* $limit = $url->getLimitCourses();
* if (!empty($limit)) {
* $count = $repo->getCountCoursesByUrl($url);
* if ($count >= $limit) {
* api_warn_hosting_contact('hosting_limit_courses', $limit);
* throw new \Exception('PortalCoursesLimitReached');
* }
* }
* if (COURSE_VISIBILITY_HIDDEN != $course->getVisibility()) {
* $limit = $url->getLimitActiveCourses();
* if (!empty($limit)) {
* $count = $repo->getCountActiveCoursesByUrl($url);
* if ($count >= $limit) {
* api_warn_hosting_contact('hosting_limit_active_courses', $limit);
* throw new \Exception('PortalActiveCoursesLimitReached');
* }
* }
* }
* }*/
}

@ -112,7 +112,7 @@ class ResourceListener
]);
if (null === $resourceType) {
throw new InvalidArgumentException(sprintf('ResourceType: "%s" not found for entity "%s"', $name, $entityClass));
throw new InvalidArgumentException(\sprintf('ResourceType: "%s" not found for entity "%s"', $name, $entityClass));
}
// 4. Set ResourceNode parent.
@ -179,7 +179,7 @@ class ResourceListener
}
if (null === $parentNode && !$resource instanceof AccessUrl) {
$msg = sprintf('Resource %s needs a parent', $resource->getResourceName());
$msg = \sprintf('Resource %s needs a parent', $resource->getResourceName());
throw new InvalidArgumentException($msg);
}
@ -192,7 +192,7 @@ class ResourceListener
|| $parentNode->getId() === $currentUser->getResourceNode()->getId();
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());
throw new InvalidArgumentException($msg);
}
@ -252,7 +252,7 @@ class ResourceListener
// All resources should have a parent, except AccessUrl.
if (!($resource instanceof AccessUrl) && null === $resourceNode->getParent()) {
$message = sprintf(
$message = \sprintf(
'ResourceListener: Resource %s, has a resource node, but this resource node must have a parent',
$resource->getResourceName()
);

@ -11,7 +11,6 @@ use Chamilo\CoreBundle\Repository\AssetRepository;
use Chamilo\CoreBundle\Traits\AccessUrlListenerTrait;
use Doctrine\ORM\Event\PrePersistEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\Persistence\Event\LifecycleEventArgs;
use Exception;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\RequestStack;
@ -55,16 +54,14 @@ class SessionListener
public function preUpdate(Session $session, PreUpdateEventArgs $args): void {}
/*protected function checkLimit(SessionRepository $repo, AccessUrl $url): void
{
$limit = $url->getLimitSessions();
if (!empty($limit)) {
$count = $repo->getCountSessionByUrl($url);
if ($count >= $limit) {
api_warn_hosting_contact('hosting_limit_sessions', $limit);
throw new \Exception('PortalSessionsLimitReached');
}
}
}*/
* {
* $limit = $url->getLimitSessions();
* if (!empty($limit)) {
* $count = $repo->getCountSessionByUrl($url);
* if ($count >= $limit) {
* api_warn_hosting_contact('hosting_limit_sessions', $limit);
* throw new \Exception('PortalSessionsLimitReached');
* }
* }
* }*/
}

@ -38,7 +38,7 @@ class SkillRelUserListener
UrlGeneratorInterface::ABSOLUTE_URL
);
$message = sprintf(
$message = \sprintf(
$this->translator->trans('Hi, %s. You have achieved the skill "%s". To see the details go here: %s.'),
$user->getFirstname(),
$skill->getTitle(),

@ -87,7 +87,7 @@ class UserListener
$now = api_get_utc_datetime();
$messages = $user->getSentMessages();
$newContent = sprintf(
$newContent = \sprintf(
$this->translator->trans('This message was deleted when the user was removed from the platform on %s'),
api_get_local_time($now)
);

@ -29,24 +29,22 @@ class UserRelUserListener
{
// If user accepts the relationship
/*if (UserRelUser::USER_RELATION_TYPE_FRIEND === $userRelUser->getRelationType()) {
$em = $args->getEntityManager();
$repo = $em->getRepository(UserRelUser::class);
$connection = $repo->findOneBy(
[
'user' => $userRelUser->getFriend(),
'friend' => $userRelUser->getUser(),
'relationType' => UserRelUser::USER_RELATION_TYPE_FRIEND_REQUEST,
]
);
if (null === $connection) {
$connection = new UserRelUser();
$connection->setRelationType(UserRelUser::USER_RELATION_TYPE_FRIEND);
$args->getEntityManager()->persist($connection);
$args->getEntityManager()->flush();
}
}*/
* $em = $args->getEntityManager();
* $repo = $em->getRepository(UserRelUser::class);
* $connection = $repo->findOneBy(
* [
* 'user' => $userRelUser->getFriend(),
* 'friend' => $userRelUser->getUser(),
* 'relationType' => UserRelUser::USER_RELATION_TYPE_FRIEND_REQUEST,
* ]
* );
* if (null === $connection) {
* $connection = new UserRelUser();
* $connection->setRelationType(UserRelUser::USER_RELATION_TYPE_FRIEND);
* $args->getEntityManager()->persist($connection);
* $args->getEntityManager()->flush();
* }
* }*/
}
public function postRemove(UserRelUser $userRelUser, PostRemoveEventArgs $args): void

@ -71,7 +71,7 @@ use Vich\UploaderBundle\Mapping\Annotation as Vich;
'document:read',
'media_object_read',
'message:read',
'personal_file:read'
'personal_file:read',
],
]
)]
@ -223,31 +223,28 @@ class ResourceFile implements Stringable
}
/*public function isEnabled(): bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): self
{
$this->enabled = $enabled;
return $this;
}*/
* {
* return $this->enabled;
* }
* public function setEnabled(bool $enabled): self
* {
* $this->enabled = $enabled;
* return $this;
* }*/
public function getId(): ?int
{
return $this->id;
}
/*public function getDescription(): string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}*/
/*public function getDescription(): string
* {
* return $this->description;
* }
* public function setDescription(string $description): self
* {
* $this->description = $description;
* return $this;
* }*/
public function getMimeType(): ?string
{
return $this->mimeType;

@ -278,7 +278,7 @@ class ResourceLink implements Stringable
public function setVisibility(int $visibility): self
{
if (!\in_array($visibility, self::getVisibilityList(), true)) {
$message = sprintf(
$message = \sprintf(
'The visibility is not valid. Valid options: %s',
print_r(self::getVisibilityList(), true)
);

@ -59,14 +59,14 @@ use Symfony\Component\Validator\Constraints as Assert;
'groups' => [
'resource_node:read',
'document:read',
'personal_file:read'
'personal_file:read',
],
],
denormalizationContext: [
'groups' => [
'resource_node:write',
'document:write',
'personal_file:write'
'personal_file:write',
],
]
)]
@ -553,7 +553,7 @@ class ResourceNode implements Stringable
];
$url = $router->generate('chamilo_core_resource_view', $params);
return sprintf("<img src='%s'/>", $url);
return \sprintf("<img src='%s'/>", $url);
}
return $this->getIcon('fa-3x');

@ -1203,7 +1203,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
$category = $image->getCategory();
$filename = $image->getTitle();
return sprintf('/assets/%s/%s/%s', $category, $filename, $filename);
return \sprintf('/assets/%s/%s/%s', $category, $filename, $filename);
}
return null;

@ -261,7 +261,7 @@ class SkillRelUser
{
$source = '';
if (null !== $this->session) {
$source .= sprintf('[%s] ', $this->session->getTitle());
$source .= \sprintf('[%s] ', $this->session->getTitle());
}
if (null !== $this->course) {
@ -278,7 +278,7 @@ class SkillRelUser
*/
public function getIssueUrl()
{
return api_get_path(WEB_PATH).sprintf('badge/%s', $this->id);
return api_get_path(WEB_PATH).\sprintf('badge/%s', $this->id);
}
/**
@ -288,7 +288,7 @@ class SkillRelUser
*/
public function getIssueUrlAll()
{
return api_get_path(WEB_PATH).sprintf('skill/%s/user/%s', $this->skill->getId(), $this->user->getId());
return api_get_path(WEB_PATH).\sprintf('skill/%s/user/%s', $this->skill->getId(), $this->user->getId());
}
/**

@ -53,21 +53,19 @@ class Tool implements Stringable
}*/
/*public function setToolResourceRight($toolResourceRight)
{
$this->toolResourceRight = new ArrayCollection();
foreach ($toolResourceRight as $item) {
$this->addToolResourceRight($item);
}
}*/
* {
* $this->toolResourceRight = new ArrayCollection();
* foreach ($toolResourceRight as $item) {
* $this->addToolResourceRight($item);
* }
* }*/
/*public function addToolResourceRight(ToolResourceRight $toolResourceRight)
{
$toolResourceRight->setTool($this);
$this->toolResourceRight[] = $toolResourceRight;
return $this;
}*/
* {
* $toolResourceRight->setTool($this);
* $this->toolResourceRight[] = $toolResourceRight;
* return $this;
* }*/
/*public function getResourceNodes()
{
@ -75,12 +73,10 @@ class Tool implements Stringable
}*/
/*public function setResourceNodes($resourceNodes)
{
$this->resourceNodes = $resourceNodes;
return $this;
}*/
* {
* $this->resourceNodes = $resourceNodes;
* return $this;
* }*/
public function getId(): int
{
return $this->id;
@ -128,9 +124,8 @@ class Tool implements Stringable
}
/*public function getResourceTypeByName(string $title): ?ResourceType
{
$criteria = Criteria::create()->where(Criteria::expr()->eq('title', $title));
return $this->getResourceTypes()->matching($criteria)->first();
}*/
* {
* $criteria = Criteria::create()->where(Criteria::expr()->eq('title', $title));
* return $this->getResourceTypes()->matching($criteria)->first();
* }*/
}

@ -72,8 +72,6 @@ class TrackEAttemptQualify
/**
* Set exeId.
*
* @param ?TrackEExercise $trackExercise
*
* @return TrackEAttemptQualify
*/
public function setTrackExercise(?TrackEExercise $trackExercise): static

@ -1266,7 +1266,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
public function getFullname(): string
{
if (empty($this->fullName)) {
return sprintf('%s %s', $this->getFirstname(), $this->getLastname());
return \sprintf('%s %s', $this->getFirstname(), $this->getLastname());
}
return $this->fullName;
@ -2123,7 +2123,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
{
$size = empty($size) ? 32 : $size;
return sprintf('/img/icons/%s/unknown.png', $size);
return \sprintf('/img/icons/%s/unknown.png', $size);
}
public function getAdmin(): ?Admin

@ -401,7 +401,7 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI
{
$size = empty($size) ? 32 : $size;
return sprintf('/img/icons/%s/group_na.png', $size);
return \sprintf('/img/icons/%s/group_na.png', $size);
}
public function getResourceIdentifier(): int
{

@ -111,24 +111,21 @@ class LegacyListener
// Theme icon is loaded in the TwigListener src/ThemeBundle/EventListener/TwigListener.php
// $theme = api_get_visual_theme();
/*$languages = api_get_languages();
$languageList = [];
foreach ($languages as $isoCode => $language) {
$languageList[languageToCountryIsoCode($isoCode)] = $language;
}
$isoFixed = languageToCountryIsoCode($request->getLocale());
if (!isset($languageList[$isoFixed])) {
$isoFixed = 'en';
}
$twig->addGlobal(
'current_locale_info',
[
'flag' => $isoFixed,
'text' => $languageList[$isoFixed] ?? 'English',
]
);*/
* $languageList = [];
* foreach ($languages as $isoCode => $language) {
* $languageList[languageToCountryIsoCode($isoCode)] = $language;
* }
* $isoFixed = languageToCountryIsoCode($request->getLocale());
* if (!isset($languageList[$isoFixed])) {
* $isoFixed = 'en';
* }
* $twig->addGlobal(
* 'current_locale_info',
* [
* 'flag' => $isoFixed,
* 'text' => $languageList[$isoFixed] ?? 'English',
* ]
* );*/
// $twig->addGlobal('current_locale', $request->getLocale());
// $twig->addGlobal('available_locales', $languages);
// $twig->addGlobal('show_toolbar', \Template::isToolBarDisplayedForUser() ? 1 : 0);

@ -107,7 +107,7 @@ class LocaleSubscriber implements EventSubscriberInterface
$locale = '';
foreach ($priorityList as $setting) {
$priority = $this->settingsManager->getSetting(sprintf('language.%s', $setting));
$priority = $this->settingsManager->getSetting(\sprintf('language.%s', $setting));
if (!empty($priority) && !empty($localeList[$priority])) {
$locale = $localeList[$priority];

@ -21,8 +21,6 @@ class CurriculumItemRelUserCollectionType extends AbstractType
public $itemId;
/**
* CurriculumItemRelUserCollectionType constructor.
*
* @param null $itemId
*/
public function __construct($itemId = null)

@ -21,8 +21,6 @@ class CurriculumItemRelUserType extends AbstractType
public $itemId;
/**
* CurriculumItemRelUserType constructor.
*
* @param null $itemId
*/
public function __construct($itemId = null)

@ -47,7 +47,7 @@ final class ResourceToIdentifierTransformer implements DataTransformerInterface
$this->identifier => $value,
]);
if (null === $resource) {
throw new TransformationFailedException(sprintf('Object "%s" with identifier "%s"="%s" does not exist.', $this->repository->getClassName(), $this->identifier, $value));
throw new TransformationFailedException(\sprintf('Object "%s" with identifier "%s"="%s" does not exist.', $this->repository->getClassName(), $this->identifier, $value));
}
return $resource;

@ -61,7 +61,7 @@ class Exporter
return new StreamedResponse($callback, Response::HTTP_OK, [
'Content-Type' => $contentType,
'Content-Disposition' => sprintf('attachment; filename=%s', $filename),
'Content-Disposition' => \sprintf('attachment; filename=%s', $filename),
]);
}
}

@ -39,9 +39,6 @@ abstract class AbstractMigrationChamilo extends AbstractMigration
private LoggerInterface $logger;
/**
* Constructor.
*/
public function __construct(Connection $connection, LoggerInterface $logger)
{
parent::__construct($connection, $logger);

@ -21,9 +21,6 @@ class PriorityMigrationHelper
private Connection $connection;
private LoggerInterface $logger;
/**
* Constructor.
*/
public function __construct(Connection $connection, LoggerInterface $logger)
{
$this->connection = $connection;

@ -315,22 +315,20 @@ class Version20 extends AbstractMigrationChamilo
// $this->addSql('ALTER TABLE c_tool_intro CHANGE id tool VARCHAR(255) NOT NULL');
/*$table = $schema->getTable('course_rel_class');
if (!$table->hasColumn('c_id')) {
$this->addSql("ALTER TABLE course_rel_class ADD c_id int NOT NULL");
}
if ($table->hasColumn('course_code')) {
$this->addSql("
UPDATE course_rel_class cc
SET cc.c_id = (SELECT id FROM course WHERE code = cc.course_code)
");
$this->addSql("ALTER TABLE course_rel_class DROP course_code");
$this->addSql("ALTER TABLE course_rel_class DROP PRIMARY KEY");
$this->addSql("ALTER TABLE course_rel_class MODIFY COLUMN class_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE course_rel_class ADD PRIMARY KEY (class_id, c_id)");
$this->addSql("ALTER TABLE course_rel_class ADD FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE RESTRICT");
}*/
* if (!$table->hasColumn('c_id')) {
* $this->addSql("ALTER TABLE course_rel_class ADD c_id int NOT NULL");
* }
* if ($table->hasColumn('course_code')) {
* $this->addSql("
* UPDATE course_rel_class cc
* SET cc.c_id = (SELECT id FROM course WHERE code = cc.course_code)
* ");
* $this->addSql("ALTER TABLE course_rel_class DROP course_code");
* $this->addSql("ALTER TABLE course_rel_class DROP PRIMARY KEY");
* $this->addSql("ALTER TABLE course_rel_class MODIFY COLUMN class_id INT DEFAULT NULL");
* $this->addSql("ALTER TABLE course_rel_class ADD PRIMARY KEY (class_id, c_id)");
* $this->addSql("ALTER TABLE course_rel_class ADD FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE RESTRICT");
* }*/
$tables = [
'shared_survey',
'specific_field_values',
@ -340,29 +338,27 @@ class Version20 extends AbstractMigrationChamilo
foreach ($tables as $table) {
// $tableObj = $schema->getTable($table);
/*if (!$tableObj->hasColumn('c_id')) {
$this->addSql("ALTER TABLE $table ADD c_id int NOT NULL");
if ($tableObj->hasColumn('course_code')) {
$this->addSql("
UPDATE $table t
SET t.c_id = (SELECT id FROM course WHERE code = t.course_code)
");
$this->addSql("ALTER TABLE $table DROP course_code");
}
}*/
* $this->addSql("ALTER TABLE $table ADD c_id int NOT NULL");
* if ($tableObj->hasColumn('course_code')) {
* $this->addSql("
* UPDATE $table t
* SET t.c_id = (SELECT id FROM course WHERE code = t.course_code)
* ");
* $this->addSql("ALTER TABLE $table DROP course_code");
* }
* }*/
/*$this->addSql("
ALTER TABLE $table ADD FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE RESTRICT
");*/
}
/*
$this->addSql("ALTER TABLE personal_agenda DROP course");
$this->addSql("
ALTER TABLE specific_field_values
ADD c_id int(11) NOT NULL,
ADD FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE RESTRICT;
");
*/
* $this->addSql("ALTER TABLE personal_agenda DROP course");
* $this->addSql("
* ALTER TABLE specific_field_values
* ADD c_id int(11) NOT NULL,
* ADD FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE RESTRICT;
* ");
*/
// Create tables.
$this->addSql(

@ -82,13 +82,11 @@ class Version20170625143000 extends AbstractMigrationChamilo
}
/*
if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_thematic_advance ADD resource_node_id INT DEFAULT NULL');
//$this->addSql('ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E971BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_62798E971BAD783F ON c_thematic_advance (resource_node_id)');
}*/
* if (false === $table->hasColumn('resource_node_id')) {
* $this->addSql('ALTER TABLE c_thematic_advance ADD resource_node_id INT DEFAULT NULL');
* //$this->addSql('ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E971BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE');
* $this->addSql('CREATE UNIQUE INDEX UNIQ_62798E971BAD783F ON c_thematic_advance (resource_node_id)');
* }*/
$table = $schema->getTable('c_thematic_plan');
$this->addSql('ALTER TABLE c_thematic_plan CHANGE thematic_id thematic_id INT DEFAULT NULL');
@ -110,12 +108,11 @@ class Version20170625143000 extends AbstractMigrationChamilo
}
/*
if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_thematic_plan ADD resource_node_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_thematic_plan ADD CONSTRAINT FK_1197487C1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_1197487C1BAD783F ON c_thematic_plan (resource_node_id)');
}*/
* if (false === $table->hasColumn('resource_node_id')) {
* $this->addSql('ALTER TABLE c_thematic_plan ADD resource_node_id INT DEFAULT NULL');
* $this->addSql('ALTER TABLE c_thematic_plan ADD CONSTRAINT FK_1197487C1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE');
* $this->addSql('CREATE UNIQUE INDEX UNIQ_1197487C1BAD783F ON c_thematic_plan (resource_node_id)');
* }*/
// CLink
$table = $schema->getTable('c_link');

@ -47,7 +47,8 @@ class Version20181126174500 extends AbstractMigrationChamilo
}
}
public function down(Schema $schema): void {
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS lti_external_tool;');
}
}

@ -19,7 +19,7 @@ class Version20191208160020 extends AbstractMigrationChamilo
public function up(Schema $schema): void
{
// Delete empty values.
$this->addSql(sprintf("UPDATE extra_field_saved_search SET value = NULL WHERE value = '%s'", 's:0:"";'));
$this->addSql(\sprintf("UPDATE extra_field_saved_search SET value = NULL WHERE value = '%s'", 's:0:"";'));
$sql = "SELECT id, value FROM extra_field_saved_search WHERE value LIKE 's:%'";
$result = $this->connection->executeQuery($sql);
@ -28,7 +28,7 @@ class Version20191208160020 extends AbstractMigrationChamilo
foreach ($items as $item) {
$id = $item['id'];
$value = 'a:1:{i:0;'.$item['value'].'}';
$sql = sprintf("UPDATE extra_field_saved_search SET value = '%s' WHERE id = %s", $value, $id);
$sql = \sprintf("UPDATE extra_field_saved_search SET value = '%s' WHERE id = %s", $value, $id);
$this->connection->executeQuery($sql);
}
}

@ -112,23 +112,20 @@ final class Version20200821224242 extends AbstractMigrationChamilo
$this->addSql('UPDATE message SET user_receiver_id = NULL WHERE user_receiver_id = 0');
/*
$result = $this->connection->executeQuery('SELECT * FROM message WHERE user_receiver_id IS NOT NULL');
$messages = $result->fetchAllAssociative();
if ($messages) {
foreach ($messages as $message) {
$messageId = $message['id'];
$receiverId = $message['user_receiver_id'];
$result = $this->connection->executeQuery(" SELECT * FROM message_rel_user WHERE message_id = $messageId AND user_id = $receiverId");
$exists = $result->fetchAllAssociative();
if (empty($exists)) {
$this->addSql("INSERT INTO message_rel_user (message_id, user_id, msg_read, starred) VALUES('$messageId', '$receiverId', 1, 0) ");
}
//$this->addSql("UPDATE message SET user_receiver_id = NULL WHERE id = $messageId");
}
}*/
* $result = $this->connection->executeQuery('SELECT * FROM message WHERE user_receiver_id IS NOT NULL');
* $messages = $result->fetchAllAssociative();
* if ($messages) {
* foreach ($messages as $message) {
* $messageId = $message['id'];
* $receiverId = $message['user_receiver_id'];
* $result = $this->connection->executeQuery(" SELECT * FROM message_rel_user WHERE message_id = $messageId AND user_id = $receiverId");
* $exists = $result->fetchAllAssociative();
* if (empty($exists)) {
* $this->addSql("INSERT INTO message_rel_user (message_id, user_id, msg_read, starred) VALUES('$messageId', '$receiverId', 1, 0) ");
* }
* //$this->addSql("UPDATE message SET user_receiver_id = NULL WHERE id = $messageId");
* }
* }*/
if (!$table->hasForeignKey('FK_B6BD307FF6C43E79')) {
$this->addSql(

@ -64,38 +64,38 @@ final class Version20200821224244 extends AbstractMigrationChamilo
$newTypeQueries = [];
$newTypeQueries[] = sprintf(
$newTypeQueries[] = \sprintf(
'UPDATE message SET status = %d WHERE msg_type = %d',
Message::MESSAGE_STATUS_DELETED,
self::OLD_MESSAGE_STATUS_DELETED
);
$newTypeQueries[] = sprintf(
$newTypeQueries[] = \sprintf(
'UPDATE message SET msg_type = %d WHERE msg_type = %d',
Message::MESSAGE_TYPE_INBOX,
self::OLD_MESSAGE_STATUS_OUTBOX
);
$newTypeQueries[] = sprintf(
$newTypeQueries[] = \sprintf(
'UPDATE message SET msg_type = %d WHERE msg_type = %d',
Message::MESSAGE_TYPE_CONVERSATION,
self::OLD_MESSAGE_STATUS_CONVERSATION
);
$newTypeQueries[] = sprintf(
$newTypeQueries[] = \sprintf(
'UPDATE message SET status = %d WHERE msg_type = %d',
Message::MESSAGE_STATUS_INVITATION_PENDING,
self::OLD_MESSAGE_STATUS_INVITATION_PENDING
);
$newTypeQueries[] = sprintf(
$newTypeQueries[] = \sprintf(
'UPDATE message SET status = %d WHERE msg_type = %d',
Message::MESSAGE_STATUS_INVITATION_ACCEPTED,
self::OLD_MESSAGE_STATUS_INVITATION_ACCEPTED
);
$newTypeQueries[] = sprintf(
$newTypeQueries[] = \sprintf(
'UPDATE message SET status = %d WHERE msg_type = %d',
Message::MESSAGE_STATUS_INVITATION_DENIED,
self::OLD_MESSAGE_STATUS_INVITATION_DENIED
);
$newTypeQueries[] = sprintf(
$newTypeQueries[] = \sprintf(
'UPDATE message SET msg_type = %d WHERE status IN (%d, %d, %d)',
Message::MESSAGE_TYPE_INVITATION,
Message::MESSAGE_STATUS_INVITATION_PENDING,
@ -103,13 +103,13 @@ final class Version20200821224244 extends AbstractMigrationChamilo
Message::MESSAGE_STATUS_INVITATION_DENIED
);
$newTypeQueries[] = sprintf(
$newTypeQueries[] = \sprintf(
'UPDATE message SET msg_type = %d WHERE msg_type = %d',
Message::MESSAGE_TYPE_INBOX,
self::OLD_MESSAGE_STATUS_NEW
);
$newTypeQueries[] = sprintf(
$newTypeQueries[] = \sprintf(
'UPDATE message SET msg_type = %d WHERE group_id IS NOT NULL',
Message::MESSAGE_TYPE_GROUP
);

@ -153,7 +153,7 @@ final class Version20201215072920 extends AbstractMigrationChamilo
if (\array_key_exists($oldEventId, $oldNewEventMap)) {
$newEvent = $oldNewEventMap[$oldEventId];
$this->addSql(
sprintf(
\sprintf(
'UPDATE agenda_reminder SET event_id = %d WHERE id = %d',
$newEvent->getIid(),
$reminder['id']

@ -207,7 +207,7 @@ final class Version20201215160445 extends AbstractMigrationChamilo
}
if (empty(trim($resource->getTitle()))) {
$resource->setTitle(sprintf('Post #%s', $resource->getIid()));
$resource->setTitle(\sprintf('Post #%s', $resource->getIid()));
}
$threadId = (int) $itemData['thread_id'];

@ -73,68 +73,62 @@ final class Version20201216105331 extends AbstractMigrationChamilo
// c_thematic_advance.
/*$sql = "SELECT * FROM c_thematic_advance WHERE c_id = $courseId
ORDER BY iid";
$result = $this->connection->executeQuery($sql);
$items = $result->fetchAllAssociative();
foreach ($items as $itemData) {
$id = $itemData['iid'];
// @var CThematicAdvance $resource
$resource = $thematicAdvanceRepo->find($id);
if ($resource->hasResourceNode()) {
continue;
}
$course = $courseRepo->find($courseId);
$result = $this->fixItemProperty(
'thematic_advance',
$thematicAdvanceRepo,
$course,
$admin,
$resource,
$course
);
if (false === $result) {
continue;
}
$this->entityManager->persist($resource);
$this->entityManager->flush();
}
$this->entityManager->flush();
$this->entityManager->clear();*/
* ORDER BY iid";
* $result = $this->connection->executeQuery($sql);
* $items = $result->fetchAllAssociative();
* foreach ($items as $itemData) {
* $id = $itemData['iid'];
* // @var CThematicAdvance $resource
* $resource = $thematicAdvanceRepo->find($id);
* if ($resource->hasResourceNode()) {
* continue;
* }
* $course = $courseRepo->find($courseId);
* $result = $this->fixItemProperty(
* 'thematic_advance',
* $thematicAdvanceRepo,
* $course,
* $admin,
* $resource,
* $course
* );
* if (false === $result) {
* continue;
* }
* $this->entityManager->persist($resource);
* $this->entityManager->flush();
* }
* $this->entityManager->flush();
* $this->entityManager->clear();*/
// c_thematic_plan.
/*$sql = "SELECT * FROM c_thematic_plan WHERE c_id = $courseId
ORDER BY iid";
$result = $this->connection->executeQuery($sql);
$items = $result->fetchAllAssociative();
foreach ($items as $itemData) {
$id = $itemData['iid'];
// @var CThematicPlan $resource
$resource = $thematicPlanRepo->find($id);
if ($resource->hasResourceNode()) {
continue;
}
$result = $this->fixItemProperty(
'thematic_plan',
$thematicPlanRepo,
$course,
$admin,
$resource,
$course
);
if (false === $result) {
continue;
}
$this->entityManager->persist($resource);
$this->entityManager->flush();
}
$this->entityManager->flush();
$this->entityManager->clear();*/
* ORDER BY iid";
* $result = $this->connection->executeQuery($sql);
* $items = $result->fetchAllAssociative();
* foreach ($items as $itemData) {
* $id = $itemData['iid'];
* // @var CThematicPlan $resource
* $resource = $thematicPlanRepo->find($id);
* if ($resource->hasResourceNode()) {
* continue;
* }
* $result = $this->fixItemProperty(
* 'thematic_plan',
* $thematicPlanRepo,
* $course,
* $admin,
* $resource,
* $course
* );
* if (false === $result) {
* continue;
* }
* $this->entityManager->persist($resource);
* $this->entityManager->flush();
* }
* $this->entityManager->flush();
* $this->entityManager->clear();*/
}
}
}

@ -240,7 +240,7 @@ class Version20230904173400 extends AbstractMigrationChamilo
if (\array_key_exists($oldEventId, $oldNewEventIdMap)) {
$newEvent = $oldNewEventIdMap[$oldEventId];
$this->addSql(
sprintf(
\sprintf(
'UPDATE agenda_reminder SET event_id = %d WHERE id = %d',
$newEvent->getIid(),
$reminder['id']

@ -26,7 +26,7 @@ class Version20240313111800 extends AbstractMigrationChamilo
$tables = array_keys($this->changes);
$columns = array_values($this->changes);
return sprintf(
return \sprintf(
'Removing %s columns from %s tables',
implode(', ', $columns),
implode(', ', $tables)

@ -121,7 +121,7 @@ class Version20240323181500 extends AbstractMigrationChamilo
if (\array_key_exists($oldEventId, $oldNewEventIdMap)) {
$newEvent = $oldNewEventIdMap[$oldEventId];
$this->addSql(
sprintf(
\sprintf(
'UPDATE agenda_reminder SET event_id = %d WHERE id = %d',
$newEvent->getIid(),
$reminder['id']

@ -29,7 +29,7 @@ final class Version20240702222600 extends AbstractMigrationChamilo
foreach ($resourceNodeRows as $resourceNodeRow) {
$this->addSql(
sprintf(
\sprintf(
'UPDATE resource_file SET resource_node_id = %d WHERE id = %d',
$resourceNodeRow['id'],
$resourceNodeRow['resource_file_id']

@ -40,7 +40,7 @@ class Version20240704185300 extends AbstractMigrationChamilo
foreach ($finder as $entry) {
if ($entry->isDir()) {
$this->write(
sprintf(
\sprintf(
'Moving theme directory: %s to %s',
$entry->getRealPath(),
$themesDirectory.DIRECTORY_SEPARATOR

@ -9,6 +9,9 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use const FILE_IGNORE_NEW_LINES;
use const PHP_EOL;
final class Version20240806120000 extends AbstractMigrationChamilo
{
public function getDescription(): string
@ -21,27 +24,27 @@ final class Version20240806120000 extends AbstractMigrationChamilo
global $_configuration;
$rootPath = $this->getRootPath();
$oldConfigPath = $rootPath . '/app/config/configuration.php';
$oldConfigPath = $rootPath.'/app/config/configuration.php';
if (!\in_array($oldConfigPath, get_included_files(), true)) {
include_once $oldConfigPath;
}
// Update .env and .env.local files
$this->updateEnvFiles($rootPath, [
"DB_MANAGER_ENABLED" => $_configuration['db_manager_enabled'] ? '1' : '0',
"SOFTWARE_NAME" => $_configuration['software_name'],
"SOFTWARE_URL" => $_configuration['software_url'],
"DENY_DELETE_USERS" => $_configuration['deny_delete_users'] ? '1' : '0',
"HOSTING_TOTAL_SIZE_LIMIT" => $_configuration['hosting_total_size_limit'] ?? 0
'DB_MANAGER_ENABLED' => $_configuration['db_manager_enabled'] ? '1' : '0',
'SOFTWARE_NAME' => $_configuration['software_name'],
'SOFTWARE_URL' => $_configuration['software_url'],
'DENY_DELETE_USERS' => $_configuration['deny_delete_users'] ? '1' : '0',
'HOSTING_TOTAL_SIZE_LIMIT' => $_configuration['hosting_total_size_limit'] ?? 0,
]);
// Ensure the hosting_limits.yml file exists
$hostingLimitsFile = $rootPath . '/config/hosting_limits.yml';
$hostingLimitsFile = $rootPath.'/config/hosting_limits.yml';
$hostingLimits = ['hosting_limits' => ['urls' => []]];
// Prepare hosting limits
foreach ($_configuration as $key => $config) {
if (is_numeric($key) && is_array($config)) {
if (is_numeric($key) && \is_array($config)) {
// Handle configurations specific to URL IDs
$hostingLimits['hosting_limits']['urls'][$key] = [
['hosting_limit_users' => $config['hosting_limit_users'] ?? 0],
@ -50,7 +53,7 @@ final class Version20240806120000 extends AbstractMigrationChamilo
['hosting_limit_sessions' => $config['hosting_limit_sessions'] ?? 0],
['hosting_limit_disk_space' => $config['hosting_limit_disk_space'] ?? 0],
['hosting_limit_active_courses' => $config['hosting_limit_active_courses'] ?? 0],
['hosting_total_size_limit' => $_configuration['hosting_total_size_limit'] ?? 0]
['hosting_total_size_limit' => $_configuration['hosting_total_size_limit'] ?? 0],
];
}
}
@ -79,7 +82,7 @@ final class Version20240806120000 extends AbstractMigrationChamilo
private function updateEnvFiles(string $rootPath, array $envSettings): void
{
$envFiles = [$rootPath . '/.env', $rootPath . '/.env.local'];
$envFiles = [$rootPath.'/.env', $rootPath.'/.env.local'];
foreach ($envFiles as $envFile) {
if (file_exists($envFile)) {
@ -88,10 +91,10 @@ final class Version20240806120000 extends AbstractMigrationChamilo
$existingKeys = [];
foreach ($lines as $line) {
if (strpos($line, '=') !== false) {
if (str_contains($line, '=')) {
[$key, $value] = explode('=', $line, 2);
$key = trim($key);
if (array_key_exists($key, $envSettings)) {
if (\array_key_exists($key, $envSettings)) {
$value = $envSettings[$key];
unset($envSettings[$key]);
}
@ -104,19 +107,19 @@ final class Version20240806120000 extends AbstractMigrationChamilo
// Add remaining new settings
foreach ($envSettings as $key => $value) {
if (!in_array($key, $existingKeys)) {
if (!\in_array($key, $existingKeys)) {
$updatedLines[] = "{$key}={$value}";
}
}
file_put_contents($envFile, implode(PHP_EOL, $updatedLines) . PHP_EOL);
file_put_contents($envFile, implode(PHP_EOL, $updatedLines).PHP_EOL);
} else {
// If the file does not exist, create it with the settings
$newContent = [];
foreach ($envSettings as $key => $value) {
$newContent[] = "{$key}={$value}";
}
file_put_contents($envFile, implode(PHP_EOL, $newContent) . PHP_EOL);
file_put_contents($envFile, implode(PHP_EOL, $newContent).PHP_EOL);
}
}
}

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
@ -8,7 +9,6 @@ use Doctrine\DBAL\Schema\Schema;
final class Version20240811221400 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Migration to update foreign key constraints, drop and create indexes, and alter table structures to ensure data consistency and prevent errors during execution.';
@ -16,7 +16,6 @@ final class Version20240811221400 extends AbstractMigrationChamilo
public function up(Schema $schema): void
{
$this->addSql('SET FOREIGN_KEY_CHECKS = 0;');
// resource_node
@ -599,6 +598,5 @@ final class Version20240811221400 extends AbstractMigrationChamilo
$this->addSql('SET FOREIGN_KEY_CHECKS = 1;');
}
public function down(Schema $schema): void
{}
public function down(Schema $schema): void {}
}

@ -1,12 +1,13 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Doctrine\DBAL\Schema\Schema;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
final class Version20240811221500 extends AbstractMigrationChamilo
{

@ -1,12 +1,13 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Doctrine\DBAL\Schema\Schema;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
final class Version20240811221600 extends AbstractMigrationChamilo
{
@ -61,7 +62,7 @@ final class Version20240811221600 extends AbstractMigrationChamilo
'c_survey_group',
'c_permission_group',
'c_role_group',
'track_e_open'
'track_e_open',
];
foreach ($tablesToDrop as $table) {

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Doctrine\DBAL\Schema\Schema;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
final class Version20240811221700 extends AbstractMigrationChamilo
{

@ -6,8 +6,8 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Doctrine\DBAL\Schema\Schema;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
final class Version20240811221800 extends AbstractMigrationChamilo
{

@ -6,8 +6,8 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Doctrine\DBAL\Schema\Schema;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
final class Version20240811221900 extends AbstractMigrationChamilo
{

@ -6,8 +6,8 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Doctrine\DBAL\Schema\Schema;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
final class Version20240811221950 extends AbstractMigrationChamilo
{
@ -30,10 +30,10 @@ final class Version20240811221950 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE gradebook_category DROP INDEX FK_96A4C705C33F7837, ADD UNIQUE INDEX UNIQ_96A4C705C33F7837 (document_id);');
}
if ($this->columnExists($schema, 'notification_event', 'title') &&
$this->columnExists($schema, 'notification_event', 'content') &&
$this->columnExists($schema, 'notification_event', 'link') &&
$this->columnExists($schema, 'notification_event', 'event_type')) {
if ($this->columnExists($schema, 'notification_event', 'title')
&& $this->columnExists($schema, 'notification_event', 'content')
&& $this->columnExists($schema, 'notification_event', 'link')
&& $this->columnExists($schema, 'notification_event', 'event_type')) {
$this->addSql('ALTER TABLE notification_event CHANGE title title VARCHAR(255) NOT NULL, CHANGE content content LONGTEXT DEFAULT NULL, CHANGE link link LONGTEXT DEFAULT NULL, CHANGE event_type event_type VARCHAR(255) NOT NULL;');
}
@ -48,49 +48,49 @@ final class Version20240811221950 extends AbstractMigrationChamilo
private function dropColumnIfExists(Schema $schema, string $tableName, string $columnName): void
{
if ($this->columnExists($schema, $tableName, $columnName)) {
$this->addSql(sprintf('ALTER TABLE %s DROP COLUMN %s;', $tableName, $columnName));
$this->addSql(\sprintf('ALTER TABLE %s DROP COLUMN %s;', $tableName, $columnName));
}
}
private function dropIndexIfExists(Schema $schema, string $tableName, string $indexName): void
{
if ($this->indexExists($schema, $tableName, $indexName)) {
$this->addSql(sprintf('DROP INDEX %s ON %s;', $indexName, $tableName));
$this->addSql(\sprintf('DROP INDEX %s ON %s;', $indexName, $tableName));
}
}
private function dropForeignKeyIfExists(Schema $schema, string $tableName, string $foreignKeyName): void
{
if ($this->foreignKeyExists($schema, $tableName, $foreignKeyName)) {
$this->addSql(sprintf('ALTER TABLE %s DROP FOREIGN KEY %s;', $tableName, $foreignKeyName));
$this->addSql(\sprintf('ALTER TABLE %s DROP FOREIGN KEY %s;', $tableName, $foreignKeyName));
}
}
private function columnExists(Schema $schema, string $tableName, string $columnName): bool
{
return $this->connection->fetchOne(sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name='%s' AND column_name='%s';",
$tableName,
$columnName
)) > 0;
return $this->connection->fetchOne(\sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name='%s' AND column_name='%s';",
$tableName,
$columnName
)) > 0;
}
private function indexExists(Schema $schema, string $tableName, string $indexName): bool
{
return $this->connection->fetchOne(sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema = DATABASE() AND table_name='%s' AND index_name='%s';",
$tableName,
$indexName
)) > 0;
return $this->connection->fetchOne(\sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema = DATABASE() AND table_name='%s' AND index_name='%s';",
$tableName,
$indexName
)) > 0;
}
private function foreignKeyExists(Schema $schema, string $tableName, string $foreignKeyName): bool
{
return $this->connection->fetchOne(sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_schema = DATABASE() AND table_name='%s' AND constraint_name='%s';",
$tableName,
$foreignKeyName
)) > 0;
return $this->connection->fetchOne(\sprintf(
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_schema = DATABASE() AND table_name='%s' AND constraint_name='%s';",
$tableName,
$foreignKeyName
)) > 0;
}
public function down(Schema $schema): void {}

@ -24,13 +24,12 @@ class Version20240819120200 extends AbstractMigrationChamilo
}
$this->addSql('ALTER TABLE message_rel_user ADD UNIQUE INDEX message_receiver (message_id, user_id, receiver_type)');
}
public function down(Schema $schema): void
public function down(Schema $schema): void
{
$table = $schema->getTable('message_rel_user');
if ($table->hasIndex('message_receiver')) {
$this->addSql('ALTER TABLE message_rel_user DROP INDEX message_receiver');
}
$this->addSql('ALTER TABLE message_rel_user ADD UNIQUE INDEX message_receiver (message_id, user_id)');
}
}

@ -91,16 +91,16 @@ final class Version20240826220000 extends AbstractMigrationChamilo
// Drop foreign key constraints
if ($schemaManager->tablesExist(['justification_document_rel_users'])) {
$foreignKeys = $schemaManager->listTableForeignKeys('justification_document_rel_users');
$foreignKeyNames = array_map(fn($fk) => $fk->getName(), $foreignKeys);
$foreignKeyNames = array_map(fn ($fk) => $fk->getName(), $foreignKeys);
if (in_array('FK_D1BB19421F2B6144', $foreignKeyNames, true)) {
if (\in_array('FK_D1BB19421F2B6144', $foreignKeyNames, true)) {
$this->addSql('
ALTER TABLE justification_document_rel_users
DROP FOREIGN KEY FK_D1BB19421F2B6144;
');
}
if (in_array('FK_D1BB1942A76ED395', $foreignKeyNames, true)) {
if (\in_array('FK_D1BB1942A76ED395', $foreignKeyNames, true)) {
$this->addSql('
ALTER TABLE justification_document_rel_users
DROP FOREIGN KEY FK_D1BB1942A76ED395;

@ -28,20 +28,18 @@ final class IllustrationRepository extends ResourceRepository
}
/*public function getResources(User $user, ResourceNode $parentNode, Course $course = null, Session $session = null, CGroup $group = null): QueryBuilder
{
$qb = $this->createQueryBuilder('resource')
->select('resource')
->innerJoin(
'resource.resourceNode',
'node'
)
;
$qb->andWhere('node.creator = :creator');
$qb->setParameter('creator', $user);
return $qb;
}*/
* {
* $qb = $this->createQueryBuilder('resource')
* ->select('resource')
* ->innerJoin(
* 'resource.resourceNode',
* 'node'
* )
* ;
* $qb->andWhere('node.creator = :creator');
* $qb->setParameter('creator', $user);
* return $qb;
* }*/
/**
* @param ResourceInterface|User $resource

@ -369,7 +369,7 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter
]);
if (null === $user) {
throw new UserNotFoundException(sprintf("User with id '%s' not found.", $username));
throw new UserNotFoundException(\sprintf("User with id '%s' not found.", $username));
}
return $user;

@ -28,13 +28,13 @@ class ResourceFactory
$tool = $this->toolChain->getToolFromName($toolName);
if (!$tool instanceof AbstractTool) {
throw new InvalidArgumentException(sprintf('Tool %s not found', $toolName));
throw new InvalidArgumentException(\sprintf('Tool %s not found', $toolName));
}
$entityClass = $tool->getEntityByResourceType($type);
if (null === $entityClass) {
throw new InvalidArgumentException(sprintf('Entity not found for tool "%s" and type "%s" ', $toolName, $type));
throw new InvalidArgumentException(\sprintf('Entity not found for tool "%s" and type "%s" ', $toolName, $type));
}
return $this->entityManager->getRepository($entityClass);

@ -44,20 +44,18 @@ class ResourceNodeRepository extends MaterializedPathRepository
}
/*public function create(ResourceNode $node): void
{
$this->getEntityManager()->persist($node);
$this->getEntityManager()->flush();
}
public function update(ResourceNode $node, bool $andFlush = true): void
{
//$node->setUpdatedAt(new \DateTime());
$this->getEntityManager()->persist($node);
if ($andFlush) {
$this->getEntityManager()->flush();
}
}*/
* {
* $this->getEntityManager()->persist($node);
* $this->getEntityManager()->flush();
* }
* public function update(ResourceNode $node, bool $andFlush = true): void
* {
* //$node->setUpdatedAt(new \DateTime());
* $this->getEntityManager()->persist($node);
* if ($andFlush) {
* $this->getEntityManager()->flush();
* }
* }*/
public function getFileSystem(): FilesystemOperator
{
return $this->filesystem;

@ -107,7 +107,7 @@ abstract class ResourceRepository extends ServiceEntityRepository
$this->slugify->slugify($originalExtension)
);*/
$newOriginalName = sprintf('%s.%s', $resourceName, $originalExtension);
$newOriginalName = \sprintf('%s.%s', $resourceName, $originalExtension);
$resourceFile->setOriginalName($newOriginalName);
$em->persist($resourceFile);
@ -638,7 +638,7 @@ abstract class ResourceRepository extends ServiceEntityRepository
} else {
$originalExtension = pathinfo($resourceName, PATHINFO_EXTENSION);
$originalBasename = basename($resourceName, $originalExtension);
$slug = sprintf('%s.%s', $this->slugify->slugify($originalBasename), $originalExtension);
$slug = \sprintf('%s.%s', $this->slugify->slugify($originalBasename), $originalExtension);
}
$resourceNode = new ResourceNode();

@ -10,7 +10,6 @@ use Chamilo\CoreBundle\Entity\ResourceInterface;
use Symfony\Component\Routing\RouterInterface;
/**
* Interface ResourceWithLinkInterface
* Allows resources to connect with a custom URL.
*/
interface ResourceWithLinkInterface

@ -132,7 +132,6 @@ class SessionRepository extends ServiceEntityRepository
$sessions = $this->getSubscribedSessionsOfUserInUrl($user, $url);
$filterCurrentSessions = function (Session $session) use ($user, $url) {
$userIsGeneralCoach = $session->hasUserAsGeneralCoach($user);
if (!$userIsGeneralCoach) {
$coursesAsCoach = $this->getSessionCoursesByStatusInCourseSubscription($user, $session, Session::COURSE_COACH, $url);
@ -223,13 +222,13 @@ class SessionRepository extends ServiceEntityRepository
}
if (!$session->hasCourse($course)) {
$msg = sprintf('Course %s is not subscribed to the session %s', $course->getTitle(), $session->getTitle());
$msg = \sprintf('Course %s is not subscribed to the session %s', $course->getTitle(), $session->getTitle());
throw new Exception($msg);
}
if (!\in_array($relationType, Session::getRelationTypeList(), true)) {
throw new Exception(sprintf('Cannot handle relationType %s', $relationType));
throw new Exception(\sprintf('Cannot handle relationType %s', $relationType));
}
$entityManager = $this->getEntityManager();

@ -30,11 +30,10 @@ class AuthenticationEntryPoint implements AuthenticationEntryPointInterface
// $session->getFlashBag()->add('warning', $message);
/*$data = [
// you might translate this message
'message' => 'Authentication Required',
];
return new JsonResponse($data, Response::HTTP_UNAUTHORIZED);*/
* // you might translate this message
* 'message' => 'Authentication Required',
* ];
* return new JsonResponse($data, Response::HTTP_UNAUTHORIZED);*/
return new RedirectResponse($this->urlGenerator->generate('login'));
}

@ -236,12 +236,12 @@ class GenericAuthenticator extends AbstractAuthenticator
$allowedUrlIds = [];
foreach ($this->getValueByKey($resourceOwnerData, $urlsField) as $value) {
if (array_key_exists($value, $availableUrls)) {
if (\array_key_exists($value, $availableUrls)) {
$allowedUrlIds[] = $availableUrls[$value];
} else {
$newValue = ($value[-1] === '/') ? substr($value, 0, -1) : $value.'/';
$newValue = ('/' === $value[-1]) ? substr($value, 0, -1) : $value.'/';
if (array_key_exists($newValue, $availableUrls)) {
if (\array_key_exists($newValue, $availableUrls)) {
$allowedUrlIds[] = $availableUrls[$newValue];
}
}

@ -250,10 +250,9 @@ class ResourceNodeVoter extends Voter
}
/*if (ResourceLink::VISIBILITY_PUBLISHED === $link->getVisibility()) {
$linkFound = true;
break;
}*/
* $linkFound = true;
* break;
* }*/
}
// No link was found.

@ -57,7 +57,7 @@ class LoginAttemptLogger
$clientText = $this->translator->trans('client');
$loginMessage = $this->translator->trans('Login %status% for username %username%', ['%status%' => $statusText, '%username%' => $username]);
$logMessage = sprintf(
$logMessage = \sprintf(
"[%s] [%s] [%s %s] %s\n",
$date->format('Y-m-d H:i:s'),
$infoText,

@ -17,6 +17,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use const DIRECTORY_SEPARATOR;
use const PHP_SAPI;
final class ThemeHelper
{
@ -107,7 +108,7 @@ final class ThemeHelper
return '';
}
return sprintf('<link rel="stylesheet" href="%s">', $url);
return \sprintf('<link rel="stylesheet" href="%s">', $url);
}
public function getAssetContents(string $path): string

@ -126,7 +126,7 @@ class SettingsManager implements SettingsManagerInterface
$settings = $this->load($category);
if (!$settings->has($name)) {
$message = sprintf("Parameter %s doesn't exists.", $name);
$message = \sprintf("Parameter %s doesn't exists.", $name);
throw new InvalidArgumentException($message);
}
@ -169,7 +169,7 @@ class SettingsManager implements SettingsManagerInterface
return null;
}
throw new InvalidArgumentException(sprintf('Category %s not found', $category));
throw new InvalidArgumentException(\sprintf('Category %s not found', $category));
}
public function loadAll(): void
@ -463,14 +463,11 @@ class SettingsManager implements SettingsManagerInterface
// }
// }
/*$parameters = $settingsBuilder->resolve($settings->getParameters());
$settings->setParameters($parameters);
$this->eventDispatcher->dispatch(SettingsEvent::PRE_SAVE, new SettingsEvent($settings));
$this->manager->persist($settings);
$this->manager->flush();
$this->eventDispatcher->dispatch(SettingsEvent::POST_SAVE, new SettingsEvent($settings));*/
* $settings->setParameters($parameters);
* $this->eventDispatcher->dispatch(SettingsEvent::PRE_SAVE, new SettingsEvent($settings));
* $this->manager->persist($settings);
* $this->manager->flush();
* $this->eventDispatcher->dispatch(SettingsEvent::POST_SAVE, new SettingsEvent($settings));*/
}
/**
@ -547,7 +544,7 @@ class SettingsManager implements SettingsManagerInterface
);
$name = $category.'.'.$name;
} else {
$message = sprintf('Parameter must be in format "category.name", "%s" given.', $name);
$message = \sprintf('Parameter must be in format "category.name", "%s" given.', $name);
throw new InvalidArgumentException($message);
}
@ -590,17 +587,15 @@ class SettingsManager implements SettingsManagerInterface
}
/*private function transformParameters(SettingsBuilder $settingsBuilder, array $parameters)
{
$transformedParameters = $parameters;
foreach ($settingsBuilder->getTransformers() as $parameter => $transformer) {
if (array_key_exists($parameter, $parameters)) {
$transformedParameters[$parameter] = $transformer->reverseTransform($parameters[$parameter]);
}
}
return $transformedParameters;
}*/
* {
* $transformedParameters = $parameters;
* foreach ($settingsBuilder->getTransformers() as $parameter => $transformer) {
* if (array_key_exists($parameter, $parameters)) {
* $transformedParameters[$parameter] = $transformer->reverseTransform($parameters[$parameter]);
* }
* }
* return $transformedParameters;
* }*/
/**
* Get variables and categories as in 1.11.x.

@ -14,18 +14,17 @@ class SettingsResolver implements SettingsResolverInterface
public function resolve($schemaAlias, $namespace = null): void
{
/*try {
$criteria = [];
if (null !== $namespace) {
$criteria['category'] = $namespace;
}
return $this->settingsRepository->findBy($criteria);
} catch (NonUniqueResultException $e) {
$message = sprintf(
'Multiple schemas found for "%s". You should probably define a custom settings resolver for this schema.',
$schemaAlias
);
throw new \LogicException($message);
}*/
* $criteria = [];
* if (null !== $namespace) {
* $criteria['category'] = $namespace;
* }
* return $this->settingsRepository->findBy($criteria);
* } catch (NonUniqueResultException $e) {
* $message = sprintf(
* 'Multiple schemas found for "%s". You should probably define a custom settings resolver for this schema.',
* $schemaAlias
* );
* throw new \LogicException($message);
* }*/
}
}

@ -86,7 +86,7 @@ final class CStudentPublicationPostStateProcessor implements ProcessorInterface
?Session $session,
?CGroup $group,
): CCalendarEvent {
$eventTitle = sprintf(
$eventTitle = \sprintf(
$this->translator->trans('Handing over of task %s'),
$publication->getTitle()
);
@ -102,7 +102,7 @@ final class CStudentPublicationPostStateProcessor implements ProcessorInterface
]
);
$content = sprintf(
$content = \sprintf(
'<div><a href="%s">%s</a></div> %s',
$publicationUrl,
$publication->getTitle(),

@ -28,7 +28,7 @@ class HandlerCollection
}
}
throw new InvalidArgumentException(sprintf('Cannot handle tool "%s"', $title));
throw new InvalidArgumentException(\sprintf('Cannot handle tool "%s"', $title));
}
/**

@ -29,32 +29,29 @@ trait CourseControllerTrait
* Gets the current Chamilo course based in the "_real_cid" session variable.
*/
/*public function getCourse()
{
$request = $this->getRequest();
if ($request) {
$courseId = $request->getSession()->get('cid', 0);
}
if (empty($courseId)) {
return null;
}
return $this->getDoctrine()->getManager()->find('ChamiloCoreBundle:Course', $courseId);
}
*/
* {
* $request = $this->getRequest();
* if ($request) {
* $courseId = $request->getSession()->get('cid', 0);
* }
* if (empty($courseId)) {
* return null;
* }
* return $this->getDoctrine()->getManager()->find('ChamiloCoreBundle:Course', $courseId);
* }.
*/
/*public function hasCourse()
{
$request = $this->getRequest();
if ($request) {
$courseId = $request->getSession()->get('cid', 0);
if (!empty($courseId)) {
return true;
}
}
return false;
}*/
* {
* $request = $this->getRequest();
* if ($request) {
* $courseId = $request->getSession()->get('cid', 0);
* if (!empty($courseId)) {
* return true;
* }
* }
* return false;
* }*/
/**
* Gets the current Chamilo session based in the "sid" $_SESSION variable.

@ -129,7 +129,7 @@ class ChamiloExtension extends AbstractExtension
$options['rules'][] = [
'minChar' => $minRequirements['length'],
'pattern' => '.',
'helpText' => sprintf(
'helpText' => \sprintf(
get_lang('Minimum %s characters in total'),
$minRequirements['length']
),
@ -140,7 +140,7 @@ class ChamiloExtension extends AbstractExtension
$options['rules'][] = [
'minChar' => $minRequirements['lowercase'],
'pattern' => '[a-z]',
'helpText' => sprintf(
'helpText' => \sprintf(
get_lang('Minimum %s lowercase characters'),
$minRequirements['lowercase']
),
@ -151,7 +151,7 @@ class ChamiloExtension extends AbstractExtension
$options['rules'][] = [
'minChar' => $minRequirements['uppercase'],
'pattern' => '[A-Z]',
'helpText' => sprintf(
'helpText' => \sprintf(
get_lang('Minimum %s uppercase characters'),
$minRequirements['uppercase']
),
@ -162,7 +162,7 @@ class ChamiloExtension extends AbstractExtension
$options['rules'][] = [
'minChar' => $minRequirements['numeric'],
'pattern' => '[0-9]',
'helpText' => sprintf(
'helpText' => \sprintf(
get_lang('Minimum %s numerical (0-9) characters'),
$minRequirements['numeric']
),
@ -173,7 +173,7 @@ class ChamiloExtension extends AbstractExtension
$options['rules'][] = [
'minChar' => $minRequirements['specials'],
'pattern' => '[!"#$%&\'()*+,\-./\\\:;<=>?@[\]^_`{|}~]',
'helpText' => sprintf(
'helpText' => \sprintf(
get_lang('Minimum %s special characters'),
$minRequirements['specials']
),

@ -28,7 +28,7 @@ class RegisterSchemasPass implements CompilerPassInterface
foreach ($taggedServicesIds as $id => $tags) {
foreach ($tags as $attributes) {
if (!isset($attributes['alias'])) {
throw new InvalidArgumentException(sprintf('Service "%s" must define the "alias" attribute on "sylius.settings_schema" tags.', $id));
throw new InvalidArgumentException(\sprintf('Service "%s" must define the "alias" attribute on "sylius.settings_schema" tags.', $id));
}
$schemaRegistry->addMethodCall('register', [$attributes['alias'], new Reference($id)]);

@ -8,6 +8,7 @@ namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -31,7 +32,7 @@ class CBlog extends AbstractResource implements ResourceInterface, Stringable
protected ?string $blogSubtitle = null;
#[ORM\Column(name: 'date_creation', type: 'datetime', nullable: false)]
protected \DateTime $dateCreation;
protected DateTime $dateCreation;
#[ORM\OneToMany(mappedBy: 'blog', targetEntity: CBlogAttachment::class, cascade: ['persist', 'remove'])]
private Collection $attachments;
@ -54,6 +55,7 @@ class CBlog extends AbstractResource implements ResourceInterface, Stringable
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
@ -65,17 +67,19 @@ class CBlog extends AbstractResource implements ResourceInterface, Stringable
public function setBlogSubtitle(?string $blogSubtitle): self
{
$this->blogSubtitle = $blogSubtitle;
return $this;
}
public function getDateCreation(): \DateTime
public function getDateCreation(): DateTime
{
return $this->dateCreation;
}
public function setDateCreation(\DateTime $dateCreation): self
public function setDateCreation(DateTime $dateCreation): self
{
$this->dateCreation = $dateCreation;
return $this;
}

@ -7,6 +7,7 @@ declare(strict_types=1);
namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\User;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'c_blog_comment')]
@ -32,7 +33,7 @@ class CBlogComment
protected User $author;
#[ORM\Column(name: 'date_creation', type: 'datetime', nullable: false)]
protected \DateTime $dateCreation;
protected DateTime $dateCreation;
#[ORM\ManyToOne(targetEntity: CBlog::class)]
#[ORM\JoinColumn(name: 'blog_id', referencedColumnName: 'iid', onDelete: 'CASCADE')]
@ -91,12 +92,12 @@ class CBlogComment
return $this;
}
public function getDateCreation(): \DateTime
public function getDateCreation(): DateTime
{
return $this->dateCreation;
}
public function setDateCreation(\DateTime $dateCreation): self
public function setDateCreation(DateTime $dateCreation): self
{
$this->dateCreation = $dateCreation;

@ -7,6 +7,7 @@ declare(strict_types=1);
namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\User;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'c_blog_post')]
@ -25,7 +26,7 @@ class CBlogPost
protected string $fullText;
#[ORM\Column(name: 'date_creation', type: 'datetime', nullable: false)]
protected \DateTime $dateCreation;
protected DateTime $dateCreation;
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'author_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
@ -64,12 +65,12 @@ class CBlogPost
return $this;
}
public function getDateCreation(): \DateTime
public function getDateCreation(): DateTime
{
return $this->dateCreation;
}
public function setDateCreation(\DateTime $dateCreation): self
public function setDateCreation(DateTime $dateCreation): self
{
$this->dateCreation = $dateCreation;

@ -8,6 +8,7 @@ namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Traits\UserTrait;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'c_blog_task_rel_user')]
@ -22,7 +23,7 @@ class CBlogTaskRelUser
protected ?int $iid = null;
#[ORM\Column(name: 'target_date', type: 'date', nullable: false)]
protected \DateTime $targetDate;
protected DateTime $targetDate;
#[ORM\ManyToOne(targetEntity: CBlogTask::class)]
#[ORM\JoinColumn(name: 'task_id', referencedColumnName: 'iid', onDelete: 'CASCADE')]
@ -41,12 +42,12 @@ class CBlogTaskRelUser
return $this->iid;
}
public function getTargetDate(): \DateTime
public function getTargetDate(): DateTime
{
return $this->targetDate;
}
public function setTargetDate(\DateTime $targetDate): self
public function setTargetDate(DateTime $targetDate): self
{
$this->targetDate = $targetDate;

@ -18,7 +18,6 @@ use ApiPlatform\Metadata\Put;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Entity\ResourceShowCourseResourcesInSessionInterface;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Filter\CidFilter;

@ -129,18 +129,16 @@ class CStudentPublicationAssignment implements Stringable
}
/*
public function getResourceIdentifier(): int
{
return $this->getIid();
}
public function getResourceName(): string
{
return (string) $this->getIid();
}
public function setResourceName(string $name): self
{
//return $this->setTitle($name);
}*/
* public function getResourceIdentifier(): int
* {
* return $this->getIid();
* }
* public function getResourceName(): string
* {
* return (string) $this->getIid();
* }
* public function setResourceName(string $name): self
* {
* //return $this->setTitle($name);
* }*/
}

@ -167,18 +167,16 @@ class CThematicAdvance implements Stringable // extends AbstractResource impleme
}
/*
public function getResourceIdentifier(): int
{
return $this->getIid();
}
public function getResourceName(): string
{
return (string) $this->getContent();
}
public function setResourceName(string $name): self
{
return $this->setContent($name);
}*/
* public function getResourceIdentifier(): int
* {
* return $this->getIid();
* }
* public function getResourceName(): string
* {
* return (string) $this->getContent();
* }
* public function setResourceName(string $name): self
* {
* return $this->setContent($name);
* }*/
}

@ -100,18 +100,16 @@ class CThematicPlan implements Stringable // extends AbstractResource implements
}
/*
public function getResourceIdentifier(): int
{
return $this->getIid();
}
public function getResourceName(): string
{
return $this->getTitle();
}
public function setResourceName(string $name): self
{
return $this->setTitle($name);
}*/
* public function getResourceIdentifier(): int
* {
* return $this->getIid();
* }
* public function getResourceName(): string
* {
* return $this->getTitle();
* }
* public function setResourceName(string $name): self
* {
* return $this->setTitle($name);
* }*/
}

@ -38,57 +38,51 @@ class CForumPostRepository extends ResourceRepository
}
/*public function findAllInCourseByThread(
bool $onlyVisible,
bool $isAllowedToEdit,
CForumThread $thread,
Course $course,
User $currentUser = null,
CGroup $group = null,
string $orderDirection = 'ASC'
): array {
$conditionVisibility = $onlyVisible ? 'p.visible = 1' : 'p.visible != 2';
$conditionModerated = '';
$filterModerated = true;
if (
(empty($group) && $isAllowedToEdit) ||
(
(null !== $group ? $group->hasTutor($currentUser) : false) ||
!$onlyVisible
)
) {
$filterModerated = false;
}
if ($filterModerated && $onlyVisible && $thread->getForum()->isModerated()) {
$userId = null !== $currentUser ? $currentUser->getId() : 0;
$conditionModerated = 'AND p.status = 1 OR
(p.status = '.CForumPost::STATUS_WAITING_MODERATION." AND p.posterId = {$userId}) OR
(p.status = ".CForumPost::STATUS_REJECTED." AND p.poster = {$userId}) OR
(p.status IS NULL AND p.posterId = {$userId})";
}
$dql = "SELECT p
FROM ChamiloCourseBundle:CForumPost p
WHERE
p.thread = :thread AND
p.cId = :course AND
{$conditionVisibility}
{$conditionModerated}
ORDER BY p.iid {$orderDirection}";
return $this
->getEntityManager()
->createQuery($dql)
->setParameters([
'thread' => $thread,
'course' => $course,
])
->getResult()
;
}*/
* bool $onlyVisible,
* bool $isAllowedToEdit,
* CForumThread $thread,
* Course $course,
* User $currentUser = null,
* CGroup $group = null,
* string $orderDirection = 'ASC'
* ): array {
* $conditionVisibility = $onlyVisible ? 'p.visible = 1' : 'p.visible != 2';
* $conditionModerated = '';
* $filterModerated = true;
* if (
* (empty($group) && $isAllowedToEdit) ||
* (
* (null !== $group ? $group->hasTutor($currentUser) : false) ||
* !$onlyVisible
* )
* ) {
* $filterModerated = false;
* }
* if ($filterModerated && $onlyVisible && $thread->getForum()->isModerated()) {
* $userId = null !== $currentUser ? $currentUser->getId() : 0;
* $conditionModerated = 'AND p.status = 1 OR
* (p.status = '.CForumPost::STATUS_WAITING_MODERATION." AND p.posterId = {$userId}) OR
* (p.status = ".CForumPost::STATUS_REJECTED." AND p.poster = {$userId}) OR
* (p.status IS NULL AND p.posterId = {$userId})";
* }
* $dql = "SELECT p
* FROM ChamiloCourseBundle:CForumPost p
* WHERE
* p.thread = :thread AND
* p.cId = :course AND
* {$conditionVisibility}
* {$conditionModerated}
* ORDER BY p.iid {$orderDirection}";
* return $this
* ->getEntityManager()
* ->createQuery($dql)
* ->setParameters([
* 'thread' => $thread,
* 'course' => $course,
* ])
* ->getResult()
* ;
* }*/
public function delete(ResourceInterface $resource): void
{
/** @var CForumPost $resource */

@ -11,8 +11,6 @@ use SimpleXMLElement;
class OutcomeDeleteResponse extends OutcomeResponse
{
/**
* OutcomeDeleteResponse constructor.
*
* @param mixed|null $bodyParam
*/
public function __construct(OutcomeResponseStatus $statusInfo, $bodyParam = null)

@ -67,7 +67,7 @@ class OutcomeReadRequest extends OutcomeRequest
$ltiScore = $result->get_score() / $evaluation->getMax();
}
$responseDescription = sprintf(
$responseDescription = \sprintf(
$this->translator->trans('Score for user %d is %s'),
$user->getId(),
$ltiScore

@ -11,8 +11,6 @@ use SimpleXMLElement;
class OutcomeReadResponse extends OutcomeResponse
{
/**
* OutcomeReadResponse constructor.
*
* @param mixed|null $bodyParam
*/
public function __construct(OutcomeResponseStatus $statusInfo, $bodyParam = null)

@ -96,7 +96,7 @@ class OutcomeReplaceRequest extends OutcomeRequest
->setSeverity(OutcomeResponseStatus::SEVERITY_STATUS)
->setCodeMajor(OutcomeResponseStatus::CODEMAJOR_SUCCESS)
->setDescription(
sprintf(
\sprintf(
$this->translator->trans('Score for user %d is %s'),
$user->getId(),
$resultScore

@ -11,8 +11,6 @@ use SimpleXMLElement;
class OutcomeReplaceResponse extends OutcomeResponse
{
/**
* OutcomeReplaceResponse constructor.
*
* @param mixed|null $bodyParam
*/
public function __construct(OutcomeResponseStatus $statusInfo, $bodyParam = null)

@ -18,8 +18,6 @@ abstract class OutcomeResponse
private OutcomeResponseStatus $statusInfo;
/**
* OutcomeResponse constructor.
*
* @param null|mixed $bodyParam
*/
public function __construct(OutcomeResponseStatus $statusInfo, $bodyParam = null)

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

Loading…
Cancel
Save