From e5397dfaa260bbbd59b8cf30b8fc3c496dcdb582 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 15 May 2023 11:27:56 -0500 Subject: [PATCH] Minor: Format code --- public/main/announcements/announcements.php | 2 +- .../main/gradebook/lib/be/category.class.php | 2 +- public/main/inc/lib/document.lib.php | 2 +- public/main/inc/lib/tracking.lib.php | 2 +- public/main/my_space/myStudents.php | 2 +- public/main/my_space/student.php | 2 +- public/main/my_space/teachers.php | 2 +- public/main/my_space/users.php | 2 +- public/main/tracking/messages.php | 2 +- src/CoreBundle/Component/Utils/ChamiloApi.php | 3 +- .../Admin/IndexBlocksController.php | 19 +- .../Controller/SecurityController.php | 3 +- .../Extension/CCalendarEventExtension.php | 48 +- .../Extension/CDocumentExtension.php | 26 +- .../Extension/CToolIntroExtension.php | 25 +- .../Extension/CourseExtension.php | 12 +- .../Extension/CourseRelUserExtension.php | 6 +- .../Extension/MessageExtension.php | 30 +- .../Extension/MessageTagExtension.php | 6 +- .../DataProvider/Extension/PageExtension.php | 32 +- .../Extension/PersonalFileExtension.php | 16 +- .../Extension/SessionRelUserExtension.php | 7 +- .../Extension/SocialPostExtension.php | 5 +- .../Extension/TrackEExerciseExtension.php | 5 +- .../Extension/UserRelUserExtension.php | 25 +- src/CoreBundle/Entity/AbstractResource.php | 12 +- src/CoreBundle/Entity/AccessUrl.php | 10 +- src/CoreBundle/Entity/AccessUrlRelCourse.php | 3 - .../Entity/AgendaEventInvitation.php | 139 ++++ src/CoreBundle/Entity/AgendaEventInvitee.php | 72 +++ .../Entity/AgendaEventSubscriber.php | 14 + .../Entity/AgendaEventSubscription.php | 34 + src/CoreBundle/Entity/AgendaReminder.php | 103 +++ src/CoreBundle/Entity/Asset.php | 8 +- src/CoreBundle/Entity/BranchSync.php | 7 +- src/CoreBundle/Entity/Course.php | 34 +- src/CoreBundle/Entity/CourseCategory.php | 8 +- src/CoreBundle/Entity/CourseRelUser.php | 2 +- .../Entity/CourseRelUserCatalogue.php | 3 +- src/CoreBundle/Entity/ExtraField.php | 82 ++- src/CoreBundle/Entity/ExtraFieldValues.php | 39 +- src/CoreBundle/Entity/GradebookCategory.php | 45 +- src/CoreBundle/Entity/Group.php | 18 +- src/CoreBundle/Entity/Illustration.php | 29 +- src/CoreBundle/Entity/Language.php | 4 +- src/CoreBundle/Entity/Level.php | 3 +- .../Entity/Listener/CourseListener.php | 6 +- .../Entity/Listener/MessageListener.php | 5 +- .../Entity/Listener/ResourceListener.php | 8 +- .../Entity/Listener/ResourceNodeListener.php | 9 +- .../Entity/Listener/SessionListener.php | 6 +- .../Entity/Listener/SkillRelUserListener.php | 8 +- .../Entity/Listener/UserListener.php | 6 +- .../Entity/Listener/UserRelUserListener.php | 5 +- src/CoreBundle/Entity/Message.php | 159 ++--- src/CoreBundle/Entity/MessageAttachment.php | 43 +- src/CoreBundle/Entity/MessageFeedback.php | 172 +++++ src/CoreBundle/Entity/MessageRelUser.php | 50 +- src/CoreBundle/Entity/MessageTag.php | 46 +- src/CoreBundle/Entity/Page.php | 65 +- src/CoreBundle/Entity/PageCategory.php | 51 +- src/CoreBundle/Entity/PersonalFile.php | 36 +- src/CoreBundle/Entity/Portfolio.php | 119 +++- src/CoreBundle/Entity/PortfolioAttachment.php | 135 ++++ src/CoreBundle/Entity/PortfolioCategory.php | 11 +- src/CoreBundle/Entity/PortfolioComment.php | 275 ++++++++ src/CoreBundle/Entity/Profile.php | 18 +- src/CoreBundle/Entity/Promotion.php | 6 +- .../Entity/ResetPasswordRequest.php | 13 +- src/CoreBundle/Entity/ResourceComment.php | 22 +- src/CoreBundle/Entity/ResourceFile.php | 151 +++-- src/CoreBundle/Entity/ResourceLink.php | 108 ++-- src/CoreBundle/Entity/ResourceNode.php | 141 +++-- src/CoreBundle/Entity/ResourceRight.php | 3 +- src/CoreBundle/Entity/ResourceType.php | 7 +- src/CoreBundle/Entity/Sequence.php | 3 +- src/CoreBundle/Entity/SequenceCondition.php | 3 - src/CoreBundle/Entity/SequenceFormula.php | 3 - src/CoreBundle/Entity/SequenceMethod.php | 3 - src/CoreBundle/Entity/SequenceResource.php | 3 - src/CoreBundle/Entity/SequenceRowEntity.php | 3 - src/CoreBundle/Entity/SequenceRule.php | 3 - .../Entity/SequenceRuleCondition.php | 3 - src/CoreBundle/Entity/SequenceRuleMethod.php | 3 - src/CoreBundle/Entity/SequenceTypeEntity.php | 3 - src/CoreBundle/Entity/SequenceValue.php | 3 - src/CoreBundle/Entity/SequenceVariable.php | 3 - src/CoreBundle/Entity/Session.php | 278 ++++---- src/CoreBundle/Entity/SessionCategory.php | 34 +- src/CoreBundle/Entity/SessionRelCourse.php | 30 +- .../Entity/SessionRelCourseRelUser.php | 44 +- src/CoreBundle/Entity/SessionRelUser.php | 46 +- src/CoreBundle/Entity/Skill.php | 83 ++- src/CoreBundle/Entity/SocialPost.php | 99 +-- src/CoreBundle/Entity/SysAnnouncement.php | 1 - src/CoreBundle/Entity/SystemTemplate.php | 21 + .../Entity/TicketMessageAttachment.php | 3 +- src/CoreBundle/Entity/Tool.php | 3 +- src/CoreBundle/Entity/ToolResourceRight.php | 6 +- src/CoreBundle/Entity/TrackCourseRanking.php | 2 +- src/CoreBundle/Entity/TrackEAttempt.php | 60 +- src/CoreBundle/Entity/TrackECourseAccess.php | 5 +- src/CoreBundle/Entity/TrackEExercise.php | 89 ++- src/CoreBundle/Entity/TrackELogin.php | 5 +- src/CoreBundle/Entity/User.php | 599 ++++++++++-------- src/CoreBundle/Entity/UserRelUser.php | 31 +- src/CoreBundle/Entity/Usergroup.php | 93 +-- src/CoreBundle/EventListener/TwigListener.php | 1 - .../Filter/UserExtraFieldFilter.php | 6 +- .../Schema/V200/Version20230216122900.php | 520 ++++++++++++++- .../Schema/V200/Version20230216122950.php | 268 ++++++++ .../Repository/Node/UserRepository.php | 18 +- src/CoreBundle/Resources/config/settings.yml | 5 + .../Serializer/ResourceNormalizer.php | 3 +- .../Settings/AdminSettingsSchema.php | 47 ++ .../Settings/AgendaSettingsSchema.php | 34 + .../Settings/AnnouncementSettingsSchema.php | 6 + .../Settings/AttendanceSettingsSchema.php | 6 + .../Settings/CertificateSettingsSchema.php | 2 + .../Settings/CourseSettingsSchema.php | 101 +++ .../Settings/DocumentSettingsSchema.php | 19 + .../Settings/EditorSettingsSchema.php | 59 ++ .../Settings/ExerciseSettingsSchema.php | 64 ++ .../Settings/ForumSettingsSchema.php | 4 + .../Settings/GradebookSettingsSchema.php | 23 + .../Settings/LanguageSettingsSchema.php | 4 + .../Settings/LearningPathSettingsSchema.php | 53 ++ .../Settings/MailSettingsSchema.php | 20 +- .../Settings/MessageSettingsSchema.php | 12 + .../Settings/PlatformSettingsSchema.php | 170 +++++ .../Settings/ProfileSettingsSchema.php | 8 + .../Settings/SecuritySettingsSchema.php | 2 + .../Settings/SessionSettingsSchema.php | 52 ++ .../Settings/SurveySettingsSchema.php | 4 + .../Settings/WikiSettingsSchema.php | 37 ++ .../Settings/WorkSettingsSchema.php | 3 + src/CourseBundle/Entity/CAnnouncement.php | 3 +- .../Entity/CAnnouncementAttachment.php | 3 +- src/CourseBundle/Entity/CAttendance.php | 9 +- .../Entity/CAttendanceCalendar.php | 19 +- .../Entity/CAttendanceResultComment.php | 199 ++++++ src/CourseBundle/Entity/CAttendanceSheet.php | 25 + src/CourseBundle/Entity/CCalendarEvent.php | 6 +- .../Entity/CCalendarEventAttachment.php | 3 +- src/CourseBundle/Entity/CChatConversation.php | 3 +- .../Entity/CCourseDescription.php | 3 +- src/CourseBundle/Entity/CDocument.php | 61 +- src/CourseBundle/Entity/CExerciseCategory.php | 3 +- src/CourseBundle/Entity/CForum.php | 12 +- src/CourseBundle/Entity/CForumAttachment.php | 3 +- src/CourseBundle/Entity/CForumCategory.php | 5 +- src/CourseBundle/Entity/CForumPost.php | 11 +- src/CourseBundle/Entity/CForumThread.php | 9 +- src/CourseBundle/Entity/CGlossary.php | 3 +- src/CourseBundle/Entity/CGroup.php | 108 ++-- src/CourseBundle/Entity/CGroupCategory.php | 3 +- src/CourseBundle/Entity/CLink.php | 3 +- src/CourseBundle/Entity/CLinkCategory.php | 5 +- src/CourseBundle/Entity/CLp.php | 35 +- src/CourseBundle/Entity/CLpCategory.php | 5 +- src/CourseBundle/Entity/CLpCategoryUser.php | 3 +- src/CourseBundle/Entity/CLpItem.php | 13 +- src/CourseBundle/Entity/CNotebook.php | 3 +- src/CourseBundle/Entity/CQuiz.php | 28 +- src/CourseBundle/Entity/CQuizQuestion.php | 13 +- .../Entity/CQuizQuestionCategory.php | 7 +- src/CourseBundle/Entity/CShortcut.php | 3 +- .../Entity/CStudentPublication.php | 13 +- .../Entity/CStudentPublicationAssignment.php | 3 +- .../Entity/CStudentPublicationComment.php | 3 +- .../Entity/CStudentPublicationCorrection.php | 3 +- src/CourseBundle/Entity/CSurvey.php | 19 +- src/CourseBundle/Entity/CSurveyAnswer.php | 52 ++ src/CourseBundle/Entity/CSurveyInvitation.php | 27 + src/CourseBundle/Entity/CSurveyQuestion.php | 14 +- src/CourseBundle/Entity/CThematic.php | 9 +- src/CourseBundle/Entity/CThematicAdvance.php | 3 +- src/CourseBundle/Entity/CThematicPlan.php | 3 +- src/CourseBundle/Entity/CTool.php | 56 +- src/CourseBundle/Entity/CToolIntro.php | 39 +- src/CourseBundle/Entity/CWiki.php | 27 +- src/CourseBundle/Entity/CWikiCategory.php | 190 ++++++ src/LtiBundle/Controller/CourseController.php | 4 +- src/LtiBundle/Entity/ExternalTool.php | 10 +- src/LtiBundle/Entity/LineItem.php | 3 - src/LtiBundle/Entity/Platform.php | 3 - src/LtiBundle/Entity/Token.php | 3 - src/LtiBundle/Util/Utils.php | 4 +- 188 files changed, 5239 insertions(+), 1616 deletions(-) create mode 100644 src/CoreBundle/Entity/AgendaEventInvitation.php create mode 100644 src/CoreBundle/Entity/AgendaEventInvitee.php create mode 100644 src/CoreBundle/Entity/AgendaEventSubscriber.php create mode 100644 src/CoreBundle/Entity/AgendaEventSubscription.php create mode 100644 src/CoreBundle/Entity/AgendaReminder.php create mode 100644 src/CoreBundle/Entity/MessageFeedback.php create mode 100644 src/CoreBundle/Entity/PortfolioAttachment.php create mode 100644 src/CoreBundle/Entity/PortfolioComment.php create mode 100644 src/CoreBundle/Settings/WikiSettingsSchema.php create mode 100644 src/CourseBundle/Entity/CAttendanceResultComment.php create mode 100644 src/CourseBundle/Entity/CWikiCategory.php diff --git a/public/main/announcements/announcements.php b/public/main/announcements/announcements.php index 876a822508..a1a52649c5 100644 --- a/public/main/announcements/announcements.php +++ b/public/main/announcements/announcements.php @@ -36,7 +36,7 @@ $repo = Container::getAnnouncementRepository(); $allowToEdit = ( api_is_allowed_to_edit(false, true) || (1 === (int) api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) || - ($sessionId && api_is_coach() && api_get_configuration_value('allow_coach_to_edit_announcements')) + ($sessionId && api_is_coach() && ('true' === api_get_setting('announcement.allow_coach_to_edit_announcements'))) ); $allowStudentInGroupToSend = false; diff --git a/public/main/gradebook/lib/be/category.class.php b/public/main/gradebook/lib/be/category.class.php index 2da82ab095..85af8c026c 100644 --- a/public/main/gradebook/lib/be/category.class.php +++ b/public/main/gradebook/lib/be/category.class.php @@ -2196,7 +2196,7 @@ class Category implements GradebookItem $params['bottom'] = 0; $page_format = 'landscape' == $params['orientation'] ? 'A4-L' : 'A4'; $pdf = new PDF($page_format, $params['orientation'], $params); - if (api_get_configuration_value('add_certificate_pdf_footer')) { + if ('true' === api_get_setting('certificate.add_certificate_pdf_footer')) { $pdf->setCertificateFooter(); } $certificate_list = GradebookUtils::get_list_users_certificates($catId, $userList); diff --git a/public/main/inc/lib/document.lib.php b/public/main/inc/lib/document.lib.php index 0e173de901..1285047a82 100644 --- a/public/main/inc/lib/document.lib.php +++ b/public/main/inc/lib/document.lib.php @@ -367,7 +367,7 @@ class DocumentManager $len = filesize($full_file_name); // Fixing error when file name contains a "," $filename = str_replace(',', '', $filename); - $sendFileHeaders = api_get_configuration_value('enable_x_sendfile_headers'); + $sendFileHeaders = ('true' === api_get_setting('document.enable_x_sendfile_headers')); // Allows chrome to make videos and audios seekable header('Accept-Ranges: bytes'); diff --git a/public/main/inc/lib/tracking.lib.php b/public/main/inc/lib/tracking.lib.php index 6175154d2a..8c471e40ab 100644 --- a/public/main/inc/lib/tracking.lib.php +++ b/public/main/inc/lib/tracking.lib.php @@ -7740,7 +7740,7 @@ class Tracking $columnHeaders['student_follow_page_add_LP_subscription_info'] = get_lang('Unlock'); } - if (true === api_get_configuration_value('student_follow_page_add_LP_acquisition_info')) { + if ('true' === api_get_setting('lp.student_follow_page_add_LP_acquisition_info')) { $columnHeaders['student_follow_page_add_LP_acquisition_info'] = get_lang('Acquisition'); } diff --git a/public/main/my_space/myStudents.php b/public/main/my_space/myStudents.php index c54062b7e9..5ad672d2d9 100644 --- a/public/main/my_space/myStudents.php +++ b/public/main/my_space/myStudents.php @@ -2276,7 +2276,7 @@ if ($allowMessages) { $form->display(); } -$allow = ('true' === api_get_setting('mail.allow_user_message_tracking')); +$allow = ('true' === api_get_setting('message.allow_user_message_tracking')); if ($allow && (api_is_drh() || api_is_platform_admin())) { $users = MessageManager::getUsersThatHadConversationWithUser($studentId); echo Display::page_subheader2(get_lang('MessageReporting')); diff --git a/public/main/my_space/student.php b/public/main/my_space/student.php index b01d5cdf4c..d4ea8f8407 100644 --- a/public/main/my_space/student.php +++ b/public/main/my_space/student.php @@ -106,7 +106,7 @@ function get_users($from, $limit, $column, $direction) } } - $checkSessionVisibility = api_get_configuration_value('show_users_in_active_sessions_in_tracking'); + $checkSessionVisibility = ('true' === api_get_setting('session.show_users_in_active_sessions_in_tracking')); if (false === $drhLoaded) { $students = UserManager::getUsersFollowedByUser( api_get_user_id(), diff --git a/public/main/my_space/teachers.php b/public/main/my_space/teachers.php index 166122fb76..d482b279e4 100644 --- a/public/main/my_space/teachers.php +++ b/public/main/my_space/teachers.php @@ -92,7 +92,7 @@ function get_users($from, $limit, $column, $direction) $drhLoaded = true; } - $checkSessionVisibility = api_get_configuration_value('show_users_in_active_sessions_in_tracking'); + $checkSessionVisibility = ('true' === api_get_setting('session.show_users_in_active_sessions_in_tracking')); if (false == $drhLoaded) { $students = UserManager::getUsersFollowedByUser( api_get_user_id(), diff --git a/public/main/my_space/users.php b/public/main/my_space/users.php index 8e4773251d..0b353eecfa 100644 --- a/public/main/my_space/users.php +++ b/public/main/my_space/users.php @@ -105,7 +105,7 @@ function get_users($from, $limit, $column, $direction) } if (false === $drhLoaded) { - $checkSessionVisibility = api_get_configuration_value('show_users_in_active_sessions_in_tracking'); + $checkSessionVisibility = ('true' === api_get_setting('session.show_users_in_active_sessions_in_tracking')); $students = UserManager::getUsersFollowedByUser( api_get_user_id(), $status, diff --git a/public/main/tracking/messages.php b/public/main/tracking/messages.php index caa5b2fc46..2642bd2129 100644 --- a/public/main/tracking/messages.php +++ b/public/main/tracking/messages.php @@ -3,7 +3,7 @@ require_once __DIR__.'/../inc/global.inc.php'; -$allow = ('true' === api_get_setting('mail.allow_user_message_tracking')); +$allow = ('true' === api_get_setting('message.allow_user_message_tracking')); if (!$allow) { api_not_allowed(true); diff --git a/src/CoreBundle/Component/Utils/ChamiloApi.php b/src/CoreBundle/Component/Utils/ChamiloApi.php index f9e99b4c63..d6da34b96f 100644 --- a/src/CoreBundle/Component/Utils/ChamiloApi.php +++ b/src/CoreBundle/Component/Utils/ChamiloApi.php @@ -13,9 +13,8 @@ use DateTime; use DateTimeZone; use Display; use Exception; -use Template; - use const PHP_SAPI; +use Template; class ChamiloApi { diff --git a/src/CoreBundle/Controller/Admin/IndexBlocksController.php b/src/CoreBundle/Controller/Admin/IndexBlocksController.php index a2540e5717..a3c81ec666 100644 --- a/src/CoreBundle/Controller/Admin/IndexBlocksController.php +++ b/src/CoreBundle/Controller/Admin/IndexBlocksController.php @@ -1,4 +1,5 @@ $this->translator->trans('Anonymise users list'), ]; - if (isset($extAuthSource, $extAuthSource['extldap']) && count($extAuthSource['extldap']) > 0) { + if (isset($extAuthSource, $extAuthSource['extldap']) && \count($extAuthSource['extldap']) > 0) { $items[] = [ 'class' => 'item-user-ldap-list', 'url' => $this->generateUrl('legacy_main', ['name' => 'admin/ldap_users_list.php']), @@ -172,7 +175,7 @@ class IndexBlocksController extends BaseController $items = array_filter($items, function (array $item) { $urls = ['user_list.php', 'user_add.php']; - return in_array($item['url'], $urls); + return \in_array($item['url'], $urls, true); }); } @@ -180,7 +183,7 @@ class IndexBlocksController extends BaseController $items = array_filter($items, function (array $item) { $urls = ['user_list.php']; - return !in_array($item['url'], $urls); + return !\in_array($item['url'], $urls, true); }); } @@ -271,7 +274,7 @@ class IndexBlocksController extends BaseController ]; } - if (isset($extAuthSource, $extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) { + if (isset($extAuthSource, $extAuthSource['ldap']) && \count($extAuthSource['ldap']) > 0) { $items[] = [ 'class' => 'item-course-subscription-ldap', 'url' => $this->generateUrl('legacy_main', ['name' => 'admin/ldap_import_students.php']), @@ -422,7 +425,7 @@ class IndexBlocksController extends BaseController ]; } - $allowJustification = api_get_plugin_setting('justification', 'tool_enable') === 'true'; + $allowJustification = 'true' === api_get_plugin_setting('justification', 'tool_enable'); if ($allowJustification) { $items[] = [ @@ -469,7 +472,7 @@ class IndexBlocksController extends BaseController 'url' => $this->generateUrl('legacy_main', ['name' => 'session/session_import_drh.php']), 'label' => $this->translator->trans('Import list of HR directors into sessions'), ]; - if (isset($extAuthSource, $extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) { + if (isset($extAuthSource, $extAuthSource['ldap']) && \count($extAuthSource['ldap']) > 0) { $items[] = [ 'class' => 'item-session-subscription-ldap-import', 'url' => $this->generateUrl('legacy_main', ['name' => 'admin/ldap_import_students_to_session.php']), diff --git a/src/CoreBundle/Controller/SecurityController.php b/src/CoreBundle/Controller/SecurityController.php index c58306dec7..0586a9b677 100644 --- a/src/CoreBundle/Controller/SecurityController.php +++ b/src/CoreBundle/Controller/SecurityController.php @@ -50,7 +50,8 @@ class SecurityController extends AbstractController ->setUsername($user->getUsername()) ->setLoginDate(new DateTime()) ->setUserIp(api_get_real_ip()) - ->setSuccess(true); + ->setSuccess(true) + ; $this->trackELoginRecordRepository->create($trackELoginRecord); diff --git a/src/CoreBundle/DataProvider/Extension/CCalendarEventExtension.php b/src/CoreBundle/DataProvider/Extension/CCalendarEventExtension.php index 7c78dc8f8e..2109ef6ab3 100644 --- a/src/CoreBundle/DataProvider/Extension/CCalendarEventExtension.php +++ b/src/CoreBundle/DataProvider/Extension/CCalendarEventExtension.php @@ -7,7 +7,6 @@ declare(strict_types=1); namespace Chamilo\CoreBundle\DataProvider\Extension; use ApiPlatform\Doctrine\Orm\Extension\QueryCollectionExtensionInterface; - //use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface; //use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface; use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface; @@ -20,9 +19,10 @@ use Symfony\Component\Security\Core\Security; final class CCalendarEventExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface { - - public function __construct(private readonly Security $security, private readonly RequestStack $requestStack) - { + public function __construct( + private readonly Security $security, + private readonly RequestStack $requestStack + ) { } public function applyToCollection( @@ -49,6 +49,17 @@ final class CCalendarEventExtension implements QueryCollectionExtensionInterface $this->addWhere($queryBuilder, $resourceClass); } + public function applyToItem( + QueryBuilder $queryBuilder, + QueryNameGeneratorInterface $queryNameGenerator, + string $resourceClass, + array $identifiers, + string $operationName = null, + array $context = [] + ): void { + //$this->addWhere($queryBuilder, $resourceClass); + } + private function addWhere(QueryBuilder $qb, string $resourceClass): void { if (CCalendarEvent::class !== $resourceClass) { @@ -65,7 +76,8 @@ final class CCalendarEventExtension implements QueryCollectionExtensionInterface $qb ->innerJoin("$alias.resourceNode", 'node') - ->leftJoin('node.resourceLinks', 'links'); + ->leftJoin('node.resourceLinks', 'links') + ; $request = $this->requestStack->getCurrentRequest(); $courseId = $request->query->get('cid'); @@ -84,24 +96,28 @@ final class CCalendarEventExtension implements QueryCollectionExtensionInterface ); $qb ->setParameter('start', $startDate) - ->setParameter('end', $endDate); + ->setParameter('end', $endDate) + ; } if (empty($courseId)) { $qb ->andWhere('links.user = :user OR node.creator = :user') - ->setParameter('user', $user); + ->setParameter('user', $user) + ; } else { $qb ->andWhere('links.course = :course') - ->setParameter('course', $courseId); + ->setParameter('course', $courseId) + ; if (empty($sessionId)) { $qb->andWhere('links.session IS NULL'); } else { $qb ->andWhere('links.session = :session') - ->setParameter('session', $sessionId); + ->setParameter('session', $sessionId) + ; } if (empty($groupId)) { @@ -109,7 +125,8 @@ final class CCalendarEventExtension implements QueryCollectionExtensionInterface } else { $qb ->andWhere('links.group = :group') - ->setParameter('group', $groupId); + ->setParameter('group', $groupId) + ; } } @@ -130,17 +147,6 @@ final class CCalendarEventExtension implements QueryCollectionExtensionInterface );*/ } - public function applyToItem( - QueryBuilder $queryBuilder, - QueryNameGeneratorInterface $queryNameGenerator, - string $resourceClass, - array $identifiers, - string $operationName = null, - array $context = [] - ): void { - //$this->addWhere($queryBuilder, $resourceClass); - } - /*public function generateBetweenRange($qb, $alias, $field, $range) { $value = $range['between']; diff --git a/src/CoreBundle/DataProvider/Extension/CDocumentExtension.php b/src/CoreBundle/DataProvider/Extension/CDocumentExtension.php index e1963ae10a..e6070061cd 100644 --- a/src/CoreBundle/DataProvider/Extension/CDocumentExtension.php +++ b/src/CoreBundle/DataProvider/Extension/CDocumentExtension.php @@ -7,7 +7,6 @@ declare(strict_types=1); namespace Chamilo\CoreBundle\DataProvider\Extension; use ApiPlatform\Doctrine\Orm\Extension\QueryCollectionExtensionInterface; - //use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryItemExtensionInterface; use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface; use ApiPlatform\Metadata\Operation; @@ -23,9 +22,10 @@ use Symfony\Component\Security\Core\Security; */ final class CDocumentExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface { - - public function __construct(private readonly Security $security, private readonly RequestStack $requestStack) - { + public function __construct( + private readonly Security $security, + private readonly RequestStack $requestStack + ) { } public function applyToCollection( @@ -78,12 +78,14 @@ final class CDocumentExtension implements QueryCollectionExtensionInterface //, $queryBuilder ->innerJoin("$rootAlias.resourceNode", 'node') - ->innerJoin('node.resourceLinks', 'links'); + ->innerJoin('node.resourceLinks', 'links') + ; // Do not show deleted resources. $queryBuilder ->andWhere('links.visibility != :visibilityDeleted') - ->setParameter('visibilityDeleted', ResourceLink::VISIBILITY_DELETED); + ->setParameter('visibilityDeleted', ResourceLink::VISIBILITY_DELETED) + ; $allowDraft = $this->security->isGranted('ROLE_ADMIN') || @@ -92,19 +94,22 @@ final class CDocumentExtension implements QueryCollectionExtensionInterface //, if (!$allowDraft) { $queryBuilder ->andWhere('links.visibility != :visibilityDraft') - ->setParameter('visibilityDraft', ResourceLink::VISIBILITY_DRAFT); + ->setParameter('visibilityDraft', ResourceLink::VISIBILITY_DRAFT) + ; } $queryBuilder ->andWhere('links.course = :course') - ->setParameter('course', $courseId); + ->setParameter('course', $courseId) + ; if (empty($sessionId)) { $queryBuilder->andWhere('links.session IS NULL'); } else { $queryBuilder ->andWhere('links.session = :session') - ->setParameter('session', $sessionId); + ->setParameter('session', $sessionId) + ; } if (empty($groupId)) { @@ -112,7 +117,8 @@ final class CDocumentExtension implements QueryCollectionExtensionInterface //, } else { $queryBuilder ->andWhere('links.group = :group') - ->setParameter('group', $groupId); + ->setParameter('group', $groupId) + ; } /*$queryBuilder-> diff --git a/src/CoreBundle/DataProvider/Extension/CToolIntroExtension.php b/src/CoreBundle/DataProvider/Extension/CToolIntroExtension.php index 38c83b15c4..0619119d6e 100644 --- a/src/CoreBundle/DataProvider/Extension/CToolIntroExtension.php +++ b/src/CoreBundle/DataProvider/Extension/CToolIntroExtension.php @@ -20,9 +20,10 @@ use Symfony\Component\Security\Core\Security; final class CToolIntroExtension implements QueryCollectionExtensionInterface { - - public function __construct(private readonly Security $security, private readonly RequestStack $requestStack) - { + public function __construct( + private readonly Security $security, + private readonly RequestStack $requestStack + ) { } public function applyToCollection( @@ -59,12 +60,14 @@ final class CToolIntroExtension implements QueryCollectionExtensionInterface $queryBuilder ->innerJoin("$rootAlias.resourceNode", 'node') - ->innerJoin('node.resourceLinks', 'links'); + ->innerJoin('node.resourceLinks', 'links') + ; // Do not show deleted resources. $queryBuilder ->andWhere('links.visibility != :visibilityDeleted') - ->setParameter('visibilityDeleted', ResourceLink::VISIBILITY_DELETED); + ->setParameter('visibilityDeleted', ResourceLink::VISIBILITY_DELETED) + ; $allowDraft = $this->security->isGranted('ROLE_ADMIN') || @@ -73,19 +76,22 @@ final class CToolIntroExtension implements QueryCollectionExtensionInterface if (!$allowDraft) { $queryBuilder ->andWhere('links.visibility != :visibilityDraft') - ->setParameter('visibilityDraft', ResourceLink::VISIBILITY_DRAFT); + ->setParameter('visibilityDraft', ResourceLink::VISIBILITY_DRAFT) + ; } $queryBuilder ->andWhere('links.course = :course') - ->setParameter('course', $courseId); + ->setParameter('course', $courseId) + ; if (empty($sessionId)) { $queryBuilder->andWhere('links.session IS NULL'); } else { $queryBuilder ->andWhere('links.session = :session') - ->setParameter('session', $sessionId); + ->setParameter('session', $sessionId) + ; } if (empty($groupId)) { @@ -93,7 +99,8 @@ final class CToolIntroExtension implements QueryCollectionExtensionInterface } else { $queryBuilder ->andWhere('links.group = :group') - ->setParameter('group', $groupId); + ->setParameter('group', $groupId) + ; } } } diff --git a/src/CoreBundle/DataProvider/Extension/CourseExtension.php b/src/CoreBundle/DataProvider/Extension/CourseExtension.php index 2055a99aca..f96aa38b43 100644 --- a/src/CoreBundle/DataProvider/Extension/CourseExtension.php +++ b/src/CoreBundle/DataProvider/Extension/CourseExtension.php @@ -21,9 +21,9 @@ use Symfony\Component\Security\Core\Security; */ final class CourseExtension implements QueryCollectionExtensionInterface { - - public function __construct(private readonly Security $security) - { + public function __construct( + private readonly Security $security + ) { } public function applyToCollection( @@ -60,9 +60,11 @@ final class CourseExtension implements QueryCollectionExtensionInterface $queryBuilder ->andWhere(sprintf('%s.visibility <> :visibility_hidden', $rootAlias)) - ->setParameter('visibility_hidden', Course::HIDDEN); + ->setParameter('visibility_hidden', Course::HIDDEN) + ; $queryBuilder ->andWhere(sprintf('%s.visibility <> :visibility_closed', $rootAlias)) - ->setParameter('visibility_closed', Course::CLOSED); + ->setParameter('visibility_closed', Course::CLOSED) + ; } } diff --git a/src/CoreBundle/DataProvider/Extension/CourseRelUserExtension.php b/src/CoreBundle/DataProvider/Extension/CourseRelUserExtension.php index add3128d86..f1f04fe24a 100644 --- a/src/CoreBundle/DataProvider/Extension/CourseRelUserExtension.php +++ b/src/CoreBundle/DataProvider/Extension/CourseRelUserExtension.php @@ -18,9 +18,9 @@ use Symfony\Component\Security\Core\Security; final class CourseRelUserExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface { - - public function __construct(private readonly Security $security) - { + public function __construct( + private readonly Security $security + ) { } public function applyToCollection( diff --git a/src/CoreBundle/DataProvider/Extension/MessageExtension.php b/src/CoreBundle/DataProvider/Extension/MessageExtension.php index 56ec5938ae..294ba82f13 100644 --- a/src/CoreBundle/DataProvider/Extension/MessageExtension.php +++ b/src/CoreBundle/DataProvider/Extension/MessageExtension.php @@ -20,9 +20,9 @@ use Symfony\Component\Security\Core\Security; final class MessageExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface { - - public function __construct(private readonly Security $security) - { + public function __construct( + private readonly Security $security + ) { } public function applyToCollection( @@ -49,6 +49,18 @@ final class MessageExtension implements QueryCollectionExtensionInterface //, Qu $this->addWhere($queryBuilder, $resourceClass); } + public function applyToItem( + QueryBuilder $queryBuilder, + QueryNameGeneratorInterface $queryNameGenerator, + string $resourceClass, + array $identifiers, + string $operationName = null, + array $context = [] + ): void { + //error_log('applyToItem1'); + //$this->addWhere($queryBuilder, $resourceClass); + } + private function addWhere(QueryBuilder $qb, string $resourceClass): void { if (Message::class !== $resourceClass) { @@ -102,16 +114,4 @@ final class MessageExtension implements QueryCollectionExtensionInterface //, Qu 'conversation' => Message::MESSAGE_TYPE_CONVERSATION, ]); } - - public function applyToItem( - QueryBuilder $queryBuilder, - QueryNameGeneratorInterface $queryNameGenerator, - string $resourceClass, - array $identifiers, - string $operationName = null, - array $context = [] - ): void { - //error_log('applyToItem1'); - //$this->addWhere($queryBuilder, $resourceClass); - } } diff --git a/src/CoreBundle/DataProvider/Extension/MessageTagExtension.php b/src/CoreBundle/DataProvider/Extension/MessageTagExtension.php index dd6339bf00..0dbfa83003 100644 --- a/src/CoreBundle/DataProvider/Extension/MessageTagExtension.php +++ b/src/CoreBundle/DataProvider/Extension/MessageTagExtension.php @@ -17,9 +17,9 @@ use Symfony\Component\Security\Core\Security; final class MessageTagExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface { - - public function __construct(private readonly Security $security) - { + public function __construct( + private readonly Security $security + ) { } public function applyToCollection( diff --git a/src/CoreBundle/DataProvider/Extension/PageExtension.php b/src/CoreBundle/DataProvider/Extension/PageExtension.php index 7e9875bac4..dfee6f79be 100644 --- a/src/CoreBundle/DataProvider/Extension/PageExtension.php +++ b/src/CoreBundle/DataProvider/Extension/PageExtension.php @@ -19,9 +19,10 @@ use Symfony\Component\Security\Core\Security; final class PageExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface { - - public function __construct(private readonly Security $security, private readonly RequestStack $requestStack) - { + public function __construct( + private readonly Security $security, + private readonly RequestStack $requestStack + ) { } public function applyToCollection( @@ -34,6 +35,17 @@ final class PageExtension implements QueryCollectionExtensionInterface //, Query $this->addWhere($queryBuilder, $resourceClass); } + public function applyToItem( + QueryBuilder $queryBuilder, + QueryNameGeneratorInterface $queryNameGenerator, + string $resourceClass, + array $identifiers, + string $operationName = null, + array $context = [] + ): void { + //$this->addWhere($queryBuilder, $resourceClass); + } + private function addWhere(QueryBuilder $qb, string $resourceClass): void { if (Page::class !== $resourceClass) { @@ -48,21 +60,11 @@ final class PageExtension implements QueryCollectionExtensionInterface //, Query // Url filter by default. $qb ->andWhere("$alias.url = :url") - ->setParameter('url', $urlId); + ->setParameter('url', $urlId) + ; if (!$this->security->isGranted('ROLE_ADMIN')) { $qb->andWhere("$alias.enabled = 1"); } } - - public function applyToItem( - QueryBuilder $queryBuilder, - QueryNameGeneratorInterface $queryNameGenerator, - string $resourceClass, - array $identifiers, - string $operationName = null, - array $context = [] - ): void { - //$this->addWhere($queryBuilder, $resourceClass); - } } diff --git a/src/CoreBundle/DataProvider/Extension/PersonalFileExtension.php b/src/CoreBundle/DataProvider/Extension/PersonalFileExtension.php index 014f0097a3..8ac9352ac9 100644 --- a/src/CoreBundle/DataProvider/Extension/PersonalFileExtension.php +++ b/src/CoreBundle/DataProvider/Extension/PersonalFileExtension.php @@ -22,9 +22,10 @@ use Symfony\Component\Security\Core\Security; */ final class PersonalFileExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface { - - public function __construct(private readonly Security $security, private readonly RequestStack $requestStack) - { + public function __construct( + private readonly Security $security, + private readonly RequestStack $requestStack + ) { } public function applyToCollection( @@ -63,7 +64,8 @@ final class PersonalFileExtension implements QueryCollectionExtensionInterface / $rootAlias = $queryBuilder->getRootAliases()[0]; $queryBuilder - ->innerJoin("$rootAlias.resourceNode", 'node'); + ->innerJoin("$rootAlias.resourceNode", 'node') + ; if ($isShared) { $queryBuilder->leftJoin('node.resourceLinks', 'links'); @@ -75,11 +77,13 @@ final class PersonalFileExtension implements QueryCollectionExtensionInterface / $queryBuilder ->andWhere('links.visibility = :visibility') - ->setParameter('visibility', ResourceLink::VISIBILITY_PUBLISHED); + ->setParameter('visibility', ResourceLink::VISIBILITY_PUBLISHED) + ; $queryBuilder ->andWhere('links.user = :userLink') - ->setParameter('userLink', $user); + ->setParameter('userLink', $user) + ; } else { $queryBuilder->orWhere('node.creator = :current'); $queryBuilder->setParameter('current', $user); diff --git a/src/CoreBundle/DataProvider/Extension/SessionRelUserExtension.php b/src/CoreBundle/DataProvider/Extension/SessionRelUserExtension.php index 1ce3fb8423..441188131d 100644 --- a/src/CoreBundle/DataProvider/Extension/SessionRelUserExtension.php +++ b/src/CoreBundle/DataProvider/Extension/SessionRelUserExtension.php @@ -21,9 +21,10 @@ use Symfony\Component\Security\Core\Security; final class SessionRelUserExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface { - - public function __construct(private readonly Security $security, private readonly RequestStack $requestStack) - { + public function __construct( + private readonly Security $security, + private readonly RequestStack $requestStack + ) { } public function applyToCollection( diff --git a/src/CoreBundle/DataProvider/Extension/SocialPostExtension.php b/src/CoreBundle/DataProvider/Extension/SocialPostExtension.php index a436827651..ffab148dbc 100644 --- a/src/CoreBundle/DataProvider/Extension/SocialPostExtension.php +++ b/src/CoreBundle/DataProvider/Extension/SocialPostExtension.php @@ -15,8 +15,9 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException; class SocialPostExtension implements QueryCollectionExtensionInterface { - public function __construct(private readonly SettingsManager $settingsManager) - { + public function __construct( + private readonly SettingsManager $settingsManager + ) { } public function applyToCollection( diff --git a/src/CoreBundle/DataProvider/Extension/TrackEExerciseExtension.php b/src/CoreBundle/DataProvider/Extension/TrackEExerciseExtension.php index 37c1c8d969..36da8b0ea2 100644 --- a/src/CoreBundle/DataProvider/Extension/TrackEExerciseExtension.php +++ b/src/CoreBundle/DataProvider/Extension/TrackEExerciseExtension.php @@ -17,8 +17,9 @@ use Symfony\Component\Security\Core\Security; final class TrackEExerciseExtension implements QueryCollectionExtensionInterface { - public function __construct(private readonly Security $security) - { + public function __construct( + private readonly Security $security + ) { } public function applyToCollection( diff --git a/src/CoreBundle/DataProvider/Extension/UserRelUserExtension.php b/src/CoreBundle/DataProvider/Extension/UserRelUserExtension.php index a273301745..713191045d 100644 --- a/src/CoreBundle/DataProvider/Extension/UserRelUserExtension.php +++ b/src/CoreBundle/DataProvider/Extension/UserRelUserExtension.php @@ -16,7 +16,6 @@ use Doctrine\ORM\QueryBuilder; final class UserRelUserExtension implements QueryCollectionExtensionInterface //, QueryItemExtensionInterface { - public function __construct() { } @@ -31,6 +30,18 @@ final class UserRelUserExtension implements QueryCollectionExtensionInterface // $this->addWhere($queryBuilder, $resourceClass); } + public function applyToItem( + QueryBuilder $queryBuilder, + QueryNameGeneratorInterface $queryNameGenerator, + string $resourceClass, + array $identifiers, + string $operationName = null, + array $context = [] + ): void { + //error_log('applyToItem'); + //$this->addWhere($queryBuilder, $resourceClass); + } + private function addWhere(QueryBuilder $queryBuilder, string $resourceClass): void { if (Message::class !== $resourceClass) { @@ -61,16 +72,4 @@ final class UserRelUserExtension implements QueryCollectionExtensionInterface // 'conversation' => Message::MESSAGE_TYPE_CONVERSATION, ]);*/ } - - public function applyToItem( - QueryBuilder $queryBuilder, - QueryNameGeneratorInterface $queryNameGenerator, - string $resourceClass, - array $identifiers, - string $operationName = null, - array $context = [] - ): void { - //error_log('applyToItem'); - //$this->addWhere($queryBuilder, $resourceClass); - } } diff --git a/src/CoreBundle/Entity/AbstractResource.php b/src/CoreBundle/Entity/AbstractResource.php index 1fb477c1a4..8dd232e609 100644 --- a/src/CoreBundle/Entity/AbstractResource.php +++ b/src/CoreBundle/Entity/AbstractResource.php @@ -167,7 +167,8 @@ abstract class AbstractResource ->setVisibility($visibility) ->setCourse($course) ->setSession($session) - ->setGroup($group); + ->setGroup($group) + ; $rights = []; switch ($visibility) { @@ -176,7 +177,8 @@ abstract class AbstractResource $editorMask = ResourceNodeVoter::getEditorMask(); $resourceRight = (new ResourceRight()) ->setMask($editorMask) - ->setRole(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER); + ->setRole(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER) + ; $rights[] = $resourceRight; break; @@ -268,7 +270,8 @@ abstract class AbstractResource ->setUser($user) ->setCourse($course) ->setSession($session) - ->setGroup($group); + ->setGroup($group) + ; if ($this->hasResourceNode()) { $resourceNode = $this->getResourceNode(); @@ -312,7 +315,8 @@ abstract class AbstractResource ->setCourse($course) ->setSession($session) ->setGroup($group) - ->setVisibility(ResourceLink::VISIBILITY_PUBLISHED); + ->setVisibility(ResourceLink::VISIBILITY_PUBLISHED) + ; if ($this->hasResourceNode()) { $resourceNode = $this->getResourceNode(); diff --git a/src/CoreBundle/Entity/AccessUrl.php b/src/CoreBundle/Entity/AccessUrl.php index d8b67b57f4..a6977d2794 100644 --- a/src/CoreBundle/Entity/AccessUrl.php +++ b/src/CoreBundle/Entity/AccessUrl.php @@ -1,6 +1,6 @@ ['access_url:read'], @@ -73,12 +71,12 @@ class AccessUrl extends AbstractResource implements ResourceInterface, Stringabl protected Collection $courseCategory; #[ORM\JoinColumn(onDelete: 'CASCADE')] #[Gedmo\TreeParent] - #[ORM\ManyToOne(targetEntity: AccessUrl::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] protected ?AccessUrl $parent = null; /** * @var AccessUrl[]|Collection */ - #[ORM\OneToMany(targetEntity: AccessUrl::class, mappedBy: 'parent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] #[ORM\OrderBy(['id' => 'ASC'])] protected Collection $children; #[Gedmo\TreeLeft] @@ -91,7 +89,7 @@ class AccessUrl extends AbstractResource implements ResourceInterface, Stringabl #[ORM\Column(name: 'rgt', type: 'integer')] protected int $rgt; #[Gedmo\TreeRoot] - #[ORM\ManyToOne(targetEntity: AccessUrl::class)] + #[ORM\ManyToOne(targetEntity: self::class)] #[ORM\JoinColumn(name: 'tree_root', onDelete: 'CASCADE')] protected ?AccessUrl $root = null; #[Assert\NotBlank] diff --git a/src/CoreBundle/Entity/AccessUrlRelCourse.php b/src/CoreBundle/Entity/AccessUrlRelCourse.php index e44cb3f626..637ed5f961 100644 --- a/src/CoreBundle/Entity/AccessUrlRelCourse.php +++ b/src/CoreBundle/Entity/AccessUrlRelCourse.php @@ -37,9 +37,6 @@ class AccessUrlRelCourse implements EntityAccessUrlInterface, Stringable return '-'; } - /** - * Get id. - */ public function getId(): ?int { return $this->id; diff --git a/src/CoreBundle/Entity/AgendaEventInvitation.php b/src/CoreBundle/Entity/AgendaEventInvitation.php new file mode 100644 index 0000000000..1682cd40f0 --- /dev/null +++ b/src/CoreBundle/Entity/AgendaEventInvitation.php @@ -0,0 +1,139 @@ +invitees = new ArrayCollection(); + } + + public function getId(): int + { + return $this->id; + } + + public function getInvitees(): Collection + { + return $this->invitees; + } + + public function setInvitees(Collection $invitees): AgendaEventInvitation + { + $this->invitees = $invitees; + + return $this; + } + + public function addInvitee(AgendaEventInvitee $invitee): AgendaEventInvitation + { + $invitee->setInvitation($this); + $this->invitees->add($invitee); + + return $this; + } + + public function removeInviteeUser(User $user): AgendaEventInvitation + { + /** @var AgendaEventInvitee $invitee */ + $invitee = $this + ->invitees + ->filter(function (AgendaEventInvitee $invitee) use ($user) { + return $invitee->getUser() === $user; + }) + ->first(); + + if ($invitee) { + $this->invitees->removeElement($invitee); + $invitee->setInvitation(null); + } + + return $this; + } + + public function removeInvitees(): self + { + $this->invitees = new ArrayCollection(); + + return $this; + } + + public function getCreator(): User + { + return $this->creator; + } + + public function setCreator(User $creator): self + { + $this->creator = $creator; + + return $this; + } + + public function hasUserAsInvitee(User $user): bool + { + return $this->invitees->exists( + function (int $key, AgendaEventInvitee $invitee) use ($user) { + return $invitee->getUser() === $user; + } + ); + } + + public function removeInviteesNotInIdList(array $idList): self + { + $toRemove = []; + + /** @var AgendaEventInvitee $invitee */ + foreach ($this->invitees as $key => $invitee) { + if (!in_array($invitee->getUser()->getId(), $idList)) { + $toRemove[] = $key; + } + } + + foreach ($toRemove as $key) { + $this->invitees->remove($key); + } + + return $this; + } +} diff --git a/src/CoreBundle/Entity/AgendaEventInvitee.php b/src/CoreBundle/Entity/AgendaEventInvitee.php new file mode 100644 index 0000000000..95d08de6cc --- /dev/null +++ b/src/CoreBundle/Entity/AgendaEventInvitee.php @@ -0,0 +1,72 @@ +id; + } + + public function getInvitation(): ?AgendaEventInvitation + { + return $this->invitation; + } + + public function setInvitation(?AgendaEventInvitation $invitation): AgendaEventInvitee + { + $this->invitation = $invitation; + + return $this; + } + + public function getUser(): ?User + { + return $this->user; + } + + public function setUser(?User $user): AgendaEventInvitee + { + $this->user = $user; + + return $this; + } +} diff --git a/src/CoreBundle/Entity/AgendaEventSubscriber.php b/src/CoreBundle/Entity/AgendaEventSubscriber.php new file mode 100644 index 0000000000..73477c3cae --- /dev/null +++ b/src/CoreBundle/Entity/AgendaEventSubscriber.php @@ -0,0 +1,14 @@ +maxAttendees; + } + + public function setMaxAttendees(int $maxAttendees): self + { + $this->maxAttendees = $maxAttendees; + + return $this; + } +} diff --git a/src/CoreBundle/Entity/AgendaReminder.php b/src/CoreBundle/Entity/AgendaReminder.php new file mode 100644 index 0000000000..b86e6a18d5 --- /dev/null +++ b/src/CoreBundle/Entity/AgendaReminder.php @@ -0,0 +1,103 @@ +sent = false; + } + + public function getId(): int + { + return $this->id; + } + + public function getType(): string + { + return $this->type; + } + + public function setType(string $type): AgendaReminder + { + $this->type = $type; + + return $this; + } + + public function getEventId(): int + { + return $this->eventId; + } + + public function setEventId(int $eventId): AgendaReminder + { + $this->eventId = $eventId; + + return $this; + } + + public function getDateInterval(): \DateInterval + { + return $this->dateInterval; + } + + public function setDateInterval(\DateInterval $dateInterval): AgendaReminder + { + $this->dateInterval = $dateInterval; + + return $this; + } + + public function isSent(): bool + { + return $this->sent; + } + + public function setSent(bool $sent): AgendaReminder + { + $this->sent = $sent; + + return $this; + } +} diff --git a/src/CoreBundle/Entity/Asset.php b/src/CoreBundle/Entity/Asset.php index 2165968782..5f7d6000da 100644 --- a/src/CoreBundle/Entity/Asset.php +++ b/src/CoreBundle/Entity/Asset.php @@ -11,6 +11,7 @@ use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Timestampable\Traits\TimestampableEntity; +use Stringable; use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\Serializer\Annotation\Groups; @@ -23,7 +24,7 @@ use Vich\UploaderBundle\Mapping\Annotation as Vich; */ #[ORM\Table(name: 'asset')] #[ORM\Entity] -class Asset implements \Stringable +class Asset implements Stringable { use TimestampableEntity; @@ -45,7 +46,7 @@ class Asset implements \Stringable protected ?string $title = null; #[Assert\NotBlank] - #[Assert\Choice([Asset::SCORM, Asset::WATERMARK, Asset::EXTRA_FIELD, Asset::COURSE_CATEGORY, Asset::SKILL], message: 'Choose a valid category.')] + #[Assert\Choice([self::SCORM, self::WATERMARK, self::EXTRA_FIELD, self::COURSE_CATEGORY, self::SKILL], message: 'Choose a valid category.')] #[ORM\Column(type: 'string', length: 255)] protected ?string $category = null; @@ -261,9 +262,6 @@ class Asset implements \Stringable return $this->file; } - /** - * @param File|UploadedFile $file - */ public function setFile(File|UploadedFile $file = null): self { $this->file = $file; diff --git a/src/CoreBundle/Entity/BranchSync.php b/src/CoreBundle/Entity/BranchSync.php index 2193e15aca..54ee79804b 100644 --- a/src/CoreBundle/Entity/BranchSync.php +++ b/src/CoreBundle/Entity/BranchSync.php @@ -98,15 +98,14 @@ class BranchSync protected ?int $root = null; #[Gedmo\TreeParent] - #[ORM\ManyToOne(targetEntity: BranchSync::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', onDelete: 'SET NULL')] protected ?BranchSync $parent = null; /** - * * @var BranchSync[]|Collection */ - #[ORM\OneToMany(targetEntity: BranchSync::class, mappedBy: 'parent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] #[ORM\OrderBy(['lft' => 'ASC'])] protected Collection $children; @@ -578,7 +577,7 @@ class BranchSync /** * @return BranchSync[]|Collection */ - public function getChildren(): array|\Doctrine\Common\Collections\Collection + public function getChildren(): array|Collection { return $this->children; } diff --git a/src/CoreBundle/Entity/Course.php b/src/CoreBundle/Entity/Course.php index 19e2b3dbc6..21f35e0a06 100644 --- a/src/CoreBundle/Entity/Course.php +++ b/src/CoreBundle/Entity/Course.php @@ -1,6 +1,6 @@ new Link( - fromClass: TrackCourseRanking::class, identifiers: ['id'] + fromClass: TrackCourseRanking::class, + identifiers: ['id'] ), - ], status: 200, + ], + status: 200, normalizationContext: [ - 'groups' => ['course:read'] + 'groups' => ['course:read'], ], filters: [ 'course.sticky_boolean_filter', @@ -79,8 +79,7 @@ use function in_array; 'annotated_chamilo_core_bundle_entity_course_api_platform_core_bridge_doctrine_orm_filter_order_filter', ] )] -class Course extends AbstractResource implements ResourceInterface, ResourceWithAccessUrlInterface, - ResourceIllustrationInterface, ExtraFieldItemInterface, Stringable +class Course extends AbstractResource implements ResourceInterface, ResourceWithAccessUrlInterface, ResourceIllustrationInterface, ExtraFieldItemInterface, Stringable { public const CLOSED = 0; public const REGISTERED = 1; @@ -119,7 +118,6 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith protected ?string $title = null; /** * The course code. - * */ #[ApiProperty(iris: ['http://schema.org/courseCode'])] #[Groups(['course:read', 'user:write', 'course_rel_user:read'])] @@ -233,11 +231,11 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith #[ORM\OneToMany(targetEntity: Templates::class, mappedBy: 'course', cascade: ['persist', 'remove'])] protected Collection $templates; /** - * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SpecificFieldValues", mappedBy="course") + * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SpecificFieldValues", mappedBy="course"). */ //protected $specificFieldValues; /** - * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SharedSurvey", mappedBy="course") + * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SharedSurvey", mappedBy="course"). */ //protected $sharedSurveys; #[ORM\Column(name: 'directory', type: 'string', length: 40, nullable: true, unique: false)] @@ -359,6 +357,11 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith //$this->sharedSurveys = new ArrayCollection(); } + public function __toString(): string + { + return $this->getTitle(); + } + public static function getStatusList(): array { return [ @@ -370,11 +373,6 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith ]; } - public function __toString(): string - { - return $this->getTitle(); - } - public function getTitle(): string { return $this->title; @@ -964,7 +962,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith { $activeVisibilityList = [self::REGISTERED, self::OPEN_PLATFORM, self::OPEN_WORLD]; - return in_array($this->visibility, $activeVisibilityList, true); + return \in_array($this->visibility, $activeVisibilityList, true); } /** @@ -999,6 +997,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith foreach ($list as $item) { if ($item->getSession()->getId() === $session->getId()) { $this->currentSession = $session; + break; } } @@ -1029,6 +1028,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith foreach ($urlList as $item) { if ($item->getUrl()->getId() === $url->getId()) { $this->currentUrl = $url; + break; } } diff --git a/src/CoreBundle/Entity/CourseCategory.php b/src/CoreBundle/Entity/CourseCategory.php index f6671a6e68..446bcc59b1 100644 --- a/src/CoreBundle/Entity/CourseCategory.php +++ b/src/CoreBundle/Entity/CourseCategory.php @@ -1,6 +1,6 @@ ['course_category:read', 'course:read'], @@ -99,7 +97,7 @@ class CourseCategory implements Stringable /** * @var Collection|CourseCategory[] */ - #[ORM\OneToMany(mappedBy: 'parent', targetEntity: CourseCategory::class)] + #[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)] protected Collection $children; #[Assert\NotBlank] #[Groups(['course_category:read', 'course_category:write', 'course:read', 'session:read'])] @@ -109,7 +107,7 @@ class CourseCategory implements Stringable #[Groups(['course_category:read', 'course_category:write', 'course:read'])] #[ORM\Column(name: 'code', type: 'string', length: 40, nullable: false)] protected string $code; - #[ORM\ManyToOne(targetEntity: CourseCategory::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', onDelete: 'CASCADE')] protected ?CourseCategory $parent = null; #[ORM\Column(name: 'tree_pos', type: 'integer', nullable: true)] diff --git a/src/CoreBundle/Entity/CourseRelUser.php b/src/CoreBundle/Entity/CourseRelUser.php index c18c9a8ff5..2bb723f354 100644 --- a/src/CoreBundle/Entity/CourseRelUser.php +++ b/src/CoreBundle/Entity/CourseRelUser.php @@ -1,6 +1,6 @@ ['extra_field:write']], normalizationContext: ['groups' => ['extra_field:read']])] #[ORM\Table(name: 'extra_field')] #[ORM\Entity] @@ -120,22 +120,24 @@ class ExtraField { return $this->id; } - public function getItemType() : int + public function getItemType(): int { return $this->itemType; } - public function setItemType(int $itemType) : self + public function setItemType(int $itemType): self { $this->itemType = $itemType; + return $this; } - public function getValueType() : int + public function getValueType(): int { return $this->valueType; } - public function setValueType(int $valueType) : self + public function setValueType(int $valueType): self { $this->valueType = $valueType; + return $this; } /** @@ -145,9 +147,10 @@ class ExtraField { return $this->variable; } - public function setVariable(string $variable) : self + public function setVariable(string $variable): self { $this->variable = $variable; + return $this; } /** @@ -157,9 +160,10 @@ class ExtraField { return $this->displayText; } - public function setDisplayText(string $displayText) : self + public function setDisplayText(string $displayText): self { $this->displayText = $displayText; + return $this; } /** @@ -169,9 +173,10 @@ class ExtraField { return $this->defaultValue; } - public function setDefaultValue(string $defaultValue) : self + public function setDefaultValue(string $defaultValue): self { $this->defaultValue = $defaultValue; + return $this; } /** @@ -181,9 +186,10 @@ class ExtraField { return $this->fieldOrder; } - public function setFieldOrder(int $fieldOrder) : self + public function setFieldOrder(int $fieldOrder): self { $this->fieldOrder = $fieldOrder; + return $this; } /** @@ -193,97 +199,107 @@ class ExtraField { return $this->changeable; } - public function setChangeable(bool $changeable) : self + public function setChangeable(bool $changeable): self { $this->changeable = $changeable; + return $this; } - public function isFilter() : bool + public function isFilter(): bool { return $this->filter; } - public function setFilter(bool $filter) : self + public function setFilter(bool $filter): self { $this->filter = $filter; + return $this; } - public function isVisibleToSelf() : bool + public function isVisibleToSelf(): bool { return $this->visibleToSelf; } - public function setVisibleToSelf(bool $visibleToSelf) : self + public function setVisibleToSelf(bool $visibleToSelf): self { $this->visibleToSelf = $visibleToSelf; + return $this; } - public function isVisibleToOthers() : bool + public function isVisibleToOthers(): bool { return $this->visibleToOthers; } - public function setVisibleToOthers(bool $visibleToOthers) : self + public function setVisibleToOthers(bool $visibleToOthers): self { $this->visibleToOthers = $visibleToOthers; + return $this; } - public function getDescription() : ?string + public function getDescription(): ?string { return $this->description; } - public function setDescription(string $description) : self + public function setDescription(string $description): self { $this->description = $description; + return $this; } /** * @return Collection */ - public function getOptions() : Collection + public function getOptions(): Collection { return $this->options; } - public function setOptions(Collection $options) : self + public function setOptions(Collection $options): self { $this->options = $options; + return $this; } /** * @return Tag[]|Collection */ - public function getTags() : array|\Doctrine\Common\Collections\Collection + public function getTags(): array|Collection { return $this->tags; } - public function setTags(Collection $tags) : self + public function setTags(Collection $tags): self { $this->tags = $tags; + return $this; } - public function hasTag(string $tagName) : bool + public function hasTag(string $tagName): bool { if (0 === $this->tags->count()) { return false; } - return $this->tags->exists(fn($key, Tag $tag) => $tagName === $tag->getTag()); + + return $this->tags->exists(fn ($key, Tag $tag) => $tagName === $tag->getTag()); } - public function getTypeToString() : string + public function getTypeToString(): string { return match ($this->getItemType()) { \ExtraField::FIELD_TYPE_RADIO, \ExtraField::FIELD_TYPE_SELECT => 'choice', default => 'text', }; } - public function getHelperText() : string + public function getHelperText(): string { return $this->helperText; } - public function setHelperText(string $helperText) : self + public function setHelperText(string $helperText): self { $this->helperText = $helperText; + return $this; } public function setTranslatableLocale($locale) { $this->locale = $locale; + return $this; } public function getTranslatableLocale() diff --git a/src/CoreBundle/Entity/ExtraFieldValues.php b/src/CoreBundle/Entity/ExtraFieldValues.php index 966479b312..066196ed14 100644 --- a/src/CoreBundle/Entity/ExtraFieldValues.php +++ b/src/CoreBundle/Entity/ExtraFieldValues.php @@ -1,24 +1,24 @@ ['extra_field_values:write']], normalizationContext: ['groups' => ['extra_field_values:read']])] #[ORM\Table(name: 'extra_field_values')] #[ORM\Index(name: 'idx_efv_fiii', columns: ['field_id', 'item_id'])] @@ -59,30 +59,33 @@ class ExtraFieldValues { $this->comment = ''; } - public function getField() : ExtraField + public function getField(): ExtraField { return $this->field; } - public function setField(ExtraField $field) : self + public function setField(ExtraField $field): self { $this->field = $field; + return $this; } - public function getItemId() : int + public function getItemId(): int { return $this->itemId; } - public function setItemId(int $itemId) : self + public function setItemId(int $itemId): self { $this->itemId = $itemId; + return $this; } - public function setComment(string $comment) : self + public function setComment(string $comment): self { $this->comment = $comment; + return $this; } - public function getComment() : ?string + public function getComment(): ?string { return $this->comment; } @@ -95,22 +98,24 @@ class ExtraFieldValues { return $this->id; } - public function getFieldValue() : ?string + public function getFieldValue(): ?string { return $this->fieldValue; } - public function setFieldValue(?string $fieldValue) : self + public function setFieldValue(?string $fieldValue): self { $this->fieldValue = $fieldValue; + return $this; } - public function getAsset() : ?Asset + public function getAsset(): ?Asset { return $this->asset; } - public function setAsset(?Asset $asset) : self + public function setAsset(?Asset $asset): self { $this->asset = $asset; + return $this; } } diff --git a/src/CoreBundle/Entity/GradebookCategory.php b/src/CoreBundle/Entity/GradebookCategory.php index 58f2053f03..7e6285039b 100644 --- a/src/CoreBundle/Entity/GradebookCategory.php +++ b/src/CoreBundle/Entity/GradebookCategory.php @@ -40,14 +40,14 @@ class GradebookCategory #[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id', onDelete: 'CASCADE')] protected Course $course; - #[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\GradebookCategory::class, inversedBy: 'subCategories')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'subCategories')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', onDelete: 'CASCADE')] protected ?GradebookCategory $parent = null; /** * @var GradebookCategory[]|Collection */ - #[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\GradebookCategory::class, mappedBy: 'parent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] protected Collection $subCategories; #[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\Session::class)] @@ -119,6 +119,9 @@ class GradebookCategory #[ORM\Column(name: 'gradebooks_to_validate_in_dependence', type: 'integer', nullable: true)] protected ?int $gradeBooksToValidateInDependence = null; + #[ORM\Column(name: 'allow_skills_by_subcategory', type: 'integer', nullable: true, options: ['default' => 1])] + protected $allowSkillsBySubcategory; + public function __construct() { $this->comments = new ArrayCollection(); @@ -359,7 +362,7 @@ class GradebookCategory /** * @return GradebookComment[]|Collection */ - public function getComments(): array|\Doctrine\Common\Collections\Collection + public function getComments(): array|Collection { return $this->comments; } @@ -367,7 +370,7 @@ class GradebookCategory /** * @param GradebookComment[]|Collection $comments */ - public function setComments(array|\Doctrine\Common\Collections\Collection $comments): self + public function setComments(array|Collection $comments): self { $this->comments = $comments; @@ -401,7 +404,7 @@ class GradebookCategory /** * @return GradebookEvaluation[]|Collection */ - public function getEvaluations(): array|\Doctrine\Common\Collections\Collection + public function getEvaluations(): array|Collection { return $this->evaluations; } @@ -409,7 +412,7 @@ class GradebookCategory /** * @param GradebookEvaluation[]|Collection $evaluations */ - public function setEvaluations(array|\Doctrine\Common\Collections\Collection $evaluations): self + public function setEvaluations(array|Collection $evaluations): self { $this->evaluations = $evaluations; @@ -419,7 +422,7 @@ class GradebookCategory /** * @return GradebookLink[]|Collection */ - public function getLinks(): array|\Doctrine\Common\Collections\Collection + public function getLinks(): array|Collection { return $this->links; } @@ -427,7 +430,7 @@ class GradebookCategory /** * @param GradebookLink[]|Collection $links */ - public function setLinks(array|\Doctrine\Common\Collections\Collection $links): self + public function setLinks(array|Collection $links): self { $this->links = $links; @@ -437,7 +440,7 @@ class GradebookCategory /** * @return GradebookCategory[]|Collection */ - public function getSubCategories(): array|\Doctrine\Common\Collections\Collection + public function getSubCategories(): array|Collection { return $this->subCategories; } @@ -481,7 +484,7 @@ class GradebookCategory /** * @return SkillRelGradebook[]|Collection */ - public function getSkills(): array|\Doctrine\Common\Collections\Collection + public function getSkills(): array|Collection { return $this->skills; } @@ -489,10 +492,30 @@ class GradebookCategory /** * @param SkillRelGradebook[]|Collection $skills */ - public function setSkills(array|\Doctrine\Common\Collections\Collection $skills): self + public function setSkills(array|Collection $skills): self { $this->skills = $skills; return $this; } + + /** + * @return int + */ + public function getAllowSkillsBySubcategory() + { + return $this->allowSkillsBySubcategory; + } + + /** + * @param int $allowSkillsBySubcategory + * + * @return GradebookCategory + */ + public function setAllowSkillsBySubcategory($allowSkillsBySubcategory) + { + $this->allowSkillsBySubcategory = $allowSkillsBySubcategory; + + return $this; + } } diff --git a/src/CoreBundle/Entity/Group.php b/src/CoreBundle/Entity/Group.php index 17a8b2b50e..0bc3c43506 100644 --- a/src/CoreBundle/Entity/Group.php +++ b/src/CoreBundle/Entity/Group.php @@ -9,6 +9,7 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -16,7 +17,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'fos_group')] #[ORM\Entity] -class Group implements \Stringable +class Group implements Stringable { #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] @@ -33,11 +34,14 @@ class Group implements \Stringable #[ORM\ManyToMany(targetEntity: \Chamilo\CoreBundle\Entity\User::class, mappedBy: 'groups')] protected Collection $users; - public function __construct(#[Assert\NotBlank] - #[ORM\Column(name: 'name', type: 'string', length: 255, nullable: false, unique: true)] - protected string $name, #[ORM\Column(name: 'roles', type: 'array')] - protected array $roles = []) - { + public function __construct( + #[Assert\NotBlank] + #[ORM\Column(name: 'name', type: 'string', length: 255, unique: true, nullable: false)] + protected string $name, + #[ORM\Column(name: 'roles', type: 'array')] + protected array $roles = [ + ] + ) { $this->users = new ArrayCollection(); } @@ -107,7 +111,7 @@ class Group implements \Stringable /** * @return User[]|Collection */ - public function getUsers(): array|\Doctrine\Common\Collections\Collection + public function getUsers(): array|Collection { return $this->users; } diff --git a/src/CoreBundle/Entity/Illustration.php b/src/CoreBundle/Entity/Illustration.php index bea6498615..54fdec677a 100644 --- a/src/CoreBundle/Entity/Illustration.php +++ b/src/CoreBundle/Entity/Illustration.php @@ -1,29 +1,23 @@ ['illustration:read']])] #[ORM\Table(name: 'illustration')] #[ORM\Entity(repositoryClass: \Chamilo\CoreBundle\Repository\Node\IllustrationRepository::class)] -class Illustration extends AbstractResource implements ResourceInterface, \Stringable +class Illustration extends AbstractResource implements ResourceInterface, Stringable { use PersonalResourceTrait; use TimestampableEntity; @@ -38,32 +32,33 @@ class Illustration extends AbstractResource implements ResourceInterface, \Strin $this->id = Uuid::v4(); $this->name = 'illustration'; } - public function __toString() : string + public function __toString(): string { return $this->getName(); } - public function getId() : Uuid + public function getId(): Uuid { return $this->id; } - public function getName() : string + public function getName(): string { return $this->name; } - public function setName(string $name) : self + public function setName(string $name): self { $this->name = $name; + return $this; } - public function getResourceIdentifier() : Uuid + public function getResourceIdentifier(): Uuid { return $this->getId(); } - public function getResourceName() : string + public function getResourceName(): string { return $this->getName(); } - public function setResourceName(string $name) : self + public function setResourceName(string $name): self { return $this->setName($name); } diff --git a/src/CoreBundle/Entity/Language.php b/src/CoreBundle/Entity/Language.php index 895edf51a1..10ccecba81 100644 --- a/src/CoreBundle/Entity/Language.php +++ b/src/CoreBundle/Entity/Language.php @@ -39,11 +39,11 @@ class Language #[ORM\Column(name: 'available', type: 'boolean', nullable: false)] protected bool $available; - #[ORM\ManyToOne(targetEntity: Language::class, inversedBy: 'subLanguages')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'subLanguages')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', nullable: true)] protected ?Language $parent = null; - #[ORM\OneToMany(targetEntity: Language::class, mappedBy: 'parent')] + #[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)] protected Collection $subLanguages; public function __construct() diff --git a/src/CoreBundle/Entity/Level.php b/src/CoreBundle/Entity/Level.php index 6d7ed86e75..b9f613c59e 100644 --- a/src/CoreBundle/Entity/Level.php +++ b/src/CoreBundle/Entity/Level.php @@ -8,13 +8,14 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; +use Stringable; /** * Skill level. */ #[ORM\Table(name: 'skill_level')] #[ORM\Entity] -class Level implements \Stringable +class Level implements Stringable { #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] diff --git a/src/CoreBundle/Entity/Listener/CourseListener.php b/src/CoreBundle/Entity/Listener/CourseListener.php index 784570c2e3..c3297d795f 100644 --- a/src/CoreBundle/Entity/Listener/CourseListener.php +++ b/src/CoreBundle/Entity/Listener/CourseListener.php @@ -22,8 +22,10 @@ use Exception; */ class CourseListener { - public function __construct(protected ToolChain $toolChain, protected SettingsManager $settingsManager) - { + public function __construct( + protected ToolChain $toolChain, + protected SettingsManager $settingsManager + ) { } /** diff --git a/src/CoreBundle/Entity/Listener/MessageListener.php b/src/CoreBundle/Entity/Listener/MessageListener.php index 26225787b1..bdafe3b6a8 100644 --- a/src/CoreBundle/Entity/Listener/MessageListener.php +++ b/src/CoreBundle/Entity/Listener/MessageListener.php @@ -12,8 +12,9 @@ use Symfony\Component\Messenger\MessageBusInterface; class MessageListener { - public function __construct(private MessageBusInterface $bus) - { + public function __construct( + private MessageBusInterface $bus + ) { } public function postPersist(Message $message, LifecycleEventArgs $args): void diff --git a/src/CoreBundle/Entity/Listener/ResourceListener.php b/src/CoreBundle/Entity/Listener/ResourceListener.php index db1dc6254d..0fbd288136 100644 --- a/src/CoreBundle/Entity/Listener/ResourceListener.php +++ b/src/CoreBundle/Entity/Listener/ResourceListener.php @@ -36,8 +36,12 @@ class ResourceListener { use AccessUrlListenerTrait; - public function __construct(protected SlugifyInterface $slugify, protected ToolChain $toolChain, protected RequestStack $request, protected Security $security) - { + public function __construct( + protected SlugifyInterface $slugify, + protected ToolChain $toolChain, + protected RequestStack $request, + protected Security $security + ) { } /** diff --git a/src/CoreBundle/Entity/Listener/ResourceNodeListener.php b/src/CoreBundle/Entity/Listener/ResourceNodeListener.php index 2788dd0562..23c137a540 100644 --- a/src/CoreBundle/Entity/Listener/ResourceNodeListener.php +++ b/src/CoreBundle/Entity/Listener/ResourceNodeListener.php @@ -19,8 +19,13 @@ class ResourceNodeListener { //protected $accessUrl; - public function __construct(protected SlugifyInterface $slugify, protected ToolChain $toolChain, protected RequestStack $request, protected Security $security, protected ResourceNodeRepository $resourceNodeRepository) - { + public function __construct( + protected SlugifyInterface $slugify, + protected ToolChain $toolChain, + protected RequestStack $request, + protected Security $security, + protected ResourceNodeRepository $resourceNodeRepository + ) { } /*public function prePersist(ResourceNode $resourceNode, LifecycleEventArgs $event) diff --git a/src/CoreBundle/Entity/Listener/SessionListener.php b/src/CoreBundle/Entity/Listener/SessionListener.php index 2389e2d9c4..4ff3d2318f 100644 --- a/src/CoreBundle/Entity/Listener/SessionListener.php +++ b/src/CoreBundle/Entity/Listener/SessionListener.php @@ -23,8 +23,10 @@ class SessionListener { use AccessUrlListenerTrait; - public function __construct(protected RequestStack $request, protected Security $security) - { + public function __construct( + protected RequestStack $request, + protected Security $security + ) { } /** diff --git a/src/CoreBundle/Entity/Listener/SkillRelUserListener.php b/src/CoreBundle/Entity/Listener/SkillRelUserListener.php index 9cafce8fc0..70d2b76ac9 100644 --- a/src/CoreBundle/Entity/Listener/SkillRelUserListener.php +++ b/src/CoreBundle/Entity/Listener/SkillRelUserListener.php @@ -18,8 +18,12 @@ use Symfony\Contracts\Translation\TranslatorInterface; class SkillRelUserListener { - public function __construct(private SettingsManager $settingsManager, private RouterInterface $router, private TranslatorInterface $translator, protected Security $security) - { + public function __construct( + private SettingsManager $settingsManager, + private RouterInterface $router, + private TranslatorInterface $translator, + protected Security $security + ) { } public function postPersist(SkillRelUser $skillRelUser, LifecycleEventArgs $event): void diff --git a/src/CoreBundle/Entity/Listener/UserListener.php b/src/CoreBundle/Entity/Listener/UserListener.php index b9f328430e..c1f327cbda 100644 --- a/src/CoreBundle/Entity/Listener/UserListener.php +++ b/src/CoreBundle/Entity/Listener/UserListener.php @@ -15,8 +15,10 @@ use Symfony\Component\Security\Core\Security; class UserListener { - public function __construct(private UserRepository $userRepository, private Security $security) - { + public function __construct( + private UserRepository $userRepository, + private Security $security + ) { } /** diff --git a/src/CoreBundle/Entity/Listener/UserRelUserListener.php b/src/CoreBundle/Entity/Listener/UserRelUserListener.php index 45b211f309..e1831eba9e 100644 --- a/src/CoreBundle/Entity/Listener/UserRelUserListener.php +++ b/src/CoreBundle/Entity/Listener/UserRelUserListener.php @@ -14,8 +14,9 @@ use Symfony\Component\Security\Core\Security; class UserRelUserListener { - public function __construct(private Security $security) - { + public function __construct( + private Security $security + ) { } public function prePersist(UserRelUser $userRelUser, LifecycleEventArgs $args): void diff --git a/src/CoreBundle/Entity/Message.php b/src/CoreBundle/Entity/Message.php index e83f235a59..251b0b6b48 100644 --- a/src/CoreBundle/Entity/Message.php +++ b/src/CoreBundle/Entity/Message.php @@ -1,21 +1,23 @@ ['message:write']], normalizationContext: ['groups' => ['message:read']])] + +#[ApiResource(operations: [new Get(security: 'is_granted(\'VIEW\', object)'), new Put(security: 'is_granted(\'EDIT\', object)'), new Delete(security: 'is_granted(\'DELETE\', object)'), new GetCollection(security: 'is_granted(\'ROLE_USER\')'), new Post(securityPostDenormalize: 'is_granted(\'CREATE\', object)')], normalizationContext: ['groups' => ['message:read']], denormalizationContext: ['groups' => ['message:write']], security: 'is_granted(\'ROLE_USER\')')] #[ORM\Table(name: 'message')] -#[ORM\Index(name: 'idx_message_user_sender', columns: ['user_sender_id'])] -#[ORM\Index(name: 'idx_message_group', columns: ['group_id'])] -#[ORM\Index(name: 'idx_message_type', columns: ['msg_type'])] -#[ORM\Entity(repositoryClass: \Chamilo\CoreBundle\Repository\MessageRepository::class)] -#[ORM\EntityListeners([\Chamilo\CoreBundle\Entity\Listener\MessageListener::class])] +#[ORM\Index(columns: ['user_sender_id'], name: 'idx_message_user_sender')] +#[ORM\Index(columns: ['group_id'], name: 'idx_message_group')] +#[ORM\Index(columns: ['msg_type'], name: 'idx_message_type')] +#[ORM\Entity(repositoryClass: MessageRepository::class)] +#[ORM\EntityListeners([MessageListener::class])] #[ApiFilter(filterClass: OrderFilter::class, properties: ['title', 'sendDate'])] #[ApiFilter(filterClass: SearchFilter::class, properties: ['msgType' => 'exact', 'status' => 'exact', 'sender' => 'exact', 'receivers.receiver' => 'exact', 'receivers.tags.tag' => 'exact', 'parent' => 'exact'])] class Message @@ -53,7 +56,7 @@ class Message protected ?int $id = null; #[Assert\NotBlank] #[Groups(['message:read', 'message:write'])] - #[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\User::class, inversedBy: 'sentMessages')] + #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'sentMessages')] #[ORM\JoinColumn(name: 'user_sender_id', referencedColumnName: 'id', nullable: false)] protected User $sender; /** @@ -61,7 +64,7 @@ class Message */ #[Assert\Valid] #[Groups(['message:read', 'message:write'])] - #[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\MessageRelUser::class, mappedBy: 'message', cascade: ['persist', 'remove'])] + #[ORM\OneToMany(mappedBy: 'message', targetEntity: MessageRelUser::class, cascade: ['persist', 'remove'])] protected array|null|Collection $receivers; /** * @var Collection|MessageRelUser[] @@ -94,16 +97,16 @@ class Message protected string $content; #[Groups(['message:read', 'message:write'])] protected ?MessageRelUser $firstReceiver = null; - #[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\Usergroup::class)] + #[ORM\ManyToOne(targetEntity: Usergroup::class)] #[ORM\JoinColumn(name: 'group_id', referencedColumnName: 'id', onDelete: 'CASCADE')] protected ?Usergroup $group = null; /** - * @var Collection|Message[] + * @var Collection */ - #[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\Message::class, mappedBy: 'parent')] + #[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)] protected Collection $children; #[Groups(['message:write'])] - #[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\Message::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id')] protected ?Message $parent = null; #[Gedmo\Timestampable(on: 'update')] @@ -112,11 +115,15 @@ class Message #[ORM\Column(name: 'votes', type: 'integer', nullable: true)] protected ?int $votes; /** - * @var Collection|MessageAttachment[] + * @var Collection */ #[Groups(['message:read'])] - #[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\MessageAttachment::class, mappedBy: 'message', cascade: ['remove', 'persist'])] + #[ORM\OneToMany(mappedBy: 'message', targetEntity: MessageAttachment::class, cascade: ['remove', 'persist'])] protected Collection $attachments; + + #[ORM\OneToMany(mappedBy: 'message', targetEntity: MessageFeedback::class, orphanRemoval: true)] + protected Collection $likes; + public function __construct() { $this->sendDate = new DateTime('now'); @@ -128,20 +135,21 @@ class Message $this->receivers = new ArrayCollection(); $this->receiversCc = new ArrayCollection(); $this->receiversTo = new ArrayCollection(); + $this->likes = new ArrayCollection(); $this->votes = 0; $this->status = 0; } /** * @return null|Collection|MessageRelUser[] */ - public function getReceivers() : null|\Doctrine\Common\Collections\Collection|array + public function getReceivers(): null|Collection|array { return $this->receivers; } /** * @return MessageRelUser[] */ - public function getReceiversTo() + public function getReceiversTo(): array { /*return $this->getReceivers()->filter(function (MessageRelUser $messageRelUser) { return MessageRelUser::TYPE_TO === $messageRelUser->getReceiverType(); @@ -152,12 +160,13 @@ class Message $list[] = $receiver; } } + return $list; } /** - * @return MessageRelUser[] + * @return array */ - public function getReceiversCc() + public function getReceiversCc(): array { $list = []; foreach ($this->receivers as $receiver) { @@ -174,174 +183,174 @@ class Message */ return $list; } - public function getFirstReceiver() : ?MessageRelUser + public function getFirstReceiver(): ?MessageRelUser { if ($this->receivers->count() > 0) { return $this->receivers->first(); } + return null; } - public function hasReceiver(User $receiver) + public function hasReceiver(User $receiver): bool { if ($this->receivers->count()) { $criteria = Criteria::create()->where(Criteria::expr()->eq('receiver', $receiver))->andWhere(Criteria::expr()->eq('message', $this)); + return $this->receivers->matching($criteria)->count() > 0; } + return false; } - public function addReceiver(User $receiver, int $receiverType = MessageRelUser::TYPE_TO) : self + public function addReceiver(User $receiver, int $receiverType = MessageRelUser::TYPE_TO): self { $messageRelUser = (new MessageRelUser())->setReceiver($receiver)->setReceiverType($receiverType)->setMessage($this); if (!$this->receivers->contains($messageRelUser)) { $this->receivers->add($messageRelUser); } + return $this; } - public function setReceivers(\Doctrine\Common\Collections\Collection|\Chamilo\CoreBundle\Entity\MessageRelUser $receivers) : self + public function setReceivers(Collection|MessageRelUser $receivers): self { /** @var MessageRelUser $receiver */ foreach ($receivers as $receiver) { $receiver->setMessage($this); } $this->receivers = $receivers; + return $this; } - public function setSender(User $sender) : self + public function setSender(User $sender): self { $this->sender = $sender; + return $this; } - public function getSender() : User + public function getSender(): User { return $this->sender; } - public function setMsgType(int $msgType) : self + public function setMsgType(int $msgType): self { $this->msgType = $msgType; + return $this; } - public function getMsgType() : int + public function getMsgType(): int { return $this->msgType; } - public function setSendDate(DateTime $sendDate) : self + public function setSendDate(DateTime $sendDate): self { $this->sendDate = $sendDate; + return $this; } - /** - * Get sendDate. - * - * @return DateTime - */ - public function getSendDate() + public function getSendDate(): DateTime { return $this->sendDate; } - public function setTitle(string $title) : self + public function setTitle(string $title): self { $this->title = $title; + return $this; } - public function getTitle() : string + public function getTitle(): string { return $this->title; } - public function setContent(string $content) : self + public function setContent(string $content): self { $this->content = $content; + return $this; } - public function getContent() : string + public function getContent(): string { return $this->content; } - public function setUpdateDate(DateTime $updateDate) : self + public function setUpdateDate(DateTime $updateDate): self { $this->updateDate = $updateDate; + return $this; } - /** - * Get updateDate. - * - * @return DateTime - */ - public function getUpdateDate() + public function getUpdateDate(): ?DateTime { return $this->updateDate; } - /** - * Get id. - * - * @return int - */ - public function getId() + public function getId(): ?int { return $this->id; } - public function setVotes(int $votes) : self + public function setVotes(int $votes): self { $this->votes = $votes; + return $this; } - public function getVotes() : int + public function getVotes(): int { return $this->votes; } /** - * Get attachments. - * - * @return Collection|MessageAttachment[] + * @return Collection */ - public function getAttachments() : \Doctrine\Common\Collections\Collection|array + public function getAttachments(): Collection { return $this->attachments; } - public function addAttachment(MessageAttachment $attachment) : self + public function addAttachment(MessageAttachment $attachment): self { $this->attachments->add($attachment); $attachment->setMessage($this); + return $this; } - public function getParent() : ?self + public function getParent(): ?self { return $this->parent; } /** - * @return Collection|Message[] + * @return Collection */ - public function getChildren() : \Doctrine\Common\Collections\Collection|array + public function getChildren(): Collection { return $this->children; } - public function addChild(self $child) : self + public function addChild(self $child): self { $this->children[] = $child; $child->setParent($this); + return $this; } - public function setParent(self $parent = null) : self + public function setParent(self $parent = null): self { $this->parent = $parent; + return $this; } - public function getGroup() : ?Usergroup + public function getGroup(): ?Usergroup { return $this->group; } - public function setGroup(?Usergroup $group) : self + public function setGroup(?Usergroup $group): self { // $this->msgType = self::MESSAGE_TYPE_GROUP; $this->group = $group; + return $this; } - public function getStatus() : int + public function getStatus(): int { return $this->status; } - public function setStatus(int $status) : self + public function setStatus(int $status): self { $this->status = $status; + return $this; } } diff --git a/src/CoreBundle/Entity/MessageAttachment.php b/src/CoreBundle/Entity/MessageAttachment.php index 9d804d058d..5844eebcf4 100644 --- a/src/CoreBundle/Entity/MessageAttachment.php +++ b/src/CoreBundle/Entity/MessageAttachment.php @@ -1,24 +1,24 @@ ['Default', 'message_attachment:create']], openapiContext: ['requestBody' => ['content' => ['multipart/form-data' => ['schema' => ['type' => 'object', 'properties' => ['file' => ['type' => 'string', 'format' => 'binary'], 'messageId' => ['type' => 'integer']]]]]]])], types: ['http://schema.org/MediaObject'], normalizationContext: ['groups' => 'message:read'])] #[ORM\Table(name: 'message_attachment')] #[ORM\Entity(repositoryClass: \Chamilo\CoreBundle\Repository\Node\MessageAttachmentRepository::class)] -class MessageAttachment extends AbstractResource implements ResourceInterface, \Stringable +class MessageAttachment extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] @@ -42,17 +42,18 @@ class MessageAttachment extends AbstractResource implements ResourceInterface, \ $this->comment = ''; $this->path = ''; } - public function __toString() : string + public function __toString(): string { return $this->getFilename(); } - public function getFilename() : string + public function getFilename(): string { return $this->filename; } - public function setFilename(string $filename) : self + public function setFilename(string $filename): self { $this->filename = $filename; + return $this; } /** @@ -64,9 +65,10 @@ class MessageAttachment extends AbstractResource implements ResourceInterface, \ { return $this->path; } - public function setPath(string $path) : self + public function setPath(string $path): self { $this->path = $path; + return $this; } /** @@ -78,30 +80,33 @@ class MessageAttachment extends AbstractResource implements ResourceInterface, \ { return $this->comment; } - public function setComment(string $comment) : self + public function setComment(string $comment): self { $this->comment = $comment; + return $this; } - public function getSize() : int + public function getSize(): int { return $this->size; } - public function setSize(int $size) : self + public function setSize(int $size): self { $this->size = $size; + return $this; } - public function getMessage() : Message + public function getMessage(): Message { return $this->message; } - public function setMessage(Message $message) : self + public function setMessage(Message $message): self { $this->message = $message; + return $this; } - public function getResourceIdentifier() : int + public function getResourceIdentifier(): int { return $this->getId(); } @@ -114,11 +119,11 @@ class MessageAttachment extends AbstractResource implements ResourceInterface, \ { return $this->id; } - public function getResourceName() : string + public function getResourceName(): string { return $this->getFilename(); } - public function setResourceName(string $name) : self + public function setResourceName(string $name): self { return $this->setFilename($name); } diff --git a/src/CoreBundle/Entity/MessageFeedback.php b/src/CoreBundle/Entity/MessageFeedback.php new file mode 100644 index 0000000000..c3e968ed39 --- /dev/null +++ b/src/CoreBundle/Entity/MessageFeedback.php @@ -0,0 +1,172 @@ +id; + } + + /** + * @param int $id + * + * @return MessageFeedback + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * @return Message + */ + public function getMessage() + { + return $this->message; + } + + /** + * @return MessageFeedback + */ + public function setMessage(Message $message) + { + $this->message = $message; + + return $this; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } + + /** + * @return MessageFeedback + */ + public function setUser(User $user) + { + $this->user = $user; + + return $this; + } + + /** + * @return bool + */ + public function isLiked() + { + return $this->liked; + } + + /** + * @param bool $liked + * + * @return MessageFeedback + */ + public function setLiked($liked) + { + $this->liked = $liked; + + return $this; + } + + /** + * @return bool + */ + public function isDisliked() + { + return $this->disliked; + } + + /** + * @param bool $disliked + * + * @return MessageFeedback + */ + public function setDisliked($disliked) + { + $this->disliked = $disliked; + + return $this; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * @return MessageFeedback + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + + return $this; + } +} diff --git a/src/CoreBundle/Entity/MessageRelUser.php b/src/CoreBundle/Entity/MessageRelUser.php index b15c755aa6..f84c0afd0a 100644 --- a/src/CoreBundle/Entity/MessageRelUser.php +++ b/src/CoreBundle/Entity/MessageRelUser.php @@ -1,28 +1,23 @@ starred = false; $this->receiverType = self::TYPE_TO; } - public function getId() : ?int + public function getId(): ?int { return $this->id; } /** * @return Collection|MessageTag[] */ - public function getTags() : \Doctrine\Common\Collections\Collection|array + public function getTags(): Collection|array { return $this->tags; } - public function addTag(MessageTag $tag) : self + public function addTag(MessageTag $tag): self { if (!$this->tags->contains($tag)) { $this->tags->add($tag); } + return $this; } - public function removeTag(MessageTag $tag) : self + public function removeTag(MessageTag $tag): self { if ($this->tags->contains($tag)) { $this->tags->removeElement($tag); } + return $this; } - public function isRead() : bool + public function isRead(): bool { return $this->read; } - public function setRead(bool $read) : self + public function setRead(bool $read): self { $this->read = $read; + return $this; } - public function isStarred() : bool + public function isStarred(): bool { return $this->starred; } - public function setStarred(bool $starred) : self + public function setStarred(bool $starred): self { $this->starred = $starred; + return $this; } - public function getMessage() : Message + public function getMessage(): Message { return $this->message; } - public function setMessage(Message $message) : self + public function setMessage(Message $message): self { $this->message = $message; + return $this; } - public function getReceiver() : User + public function getReceiver(): User { return $this->receiver; } - public function setReceiver(User $receiver) : self + public function setReceiver(User $receiver): self { $this->receiver = $receiver; + return $this; } - public function getReceiverType() : int + public function getReceiverType(): int { return $this->receiverType; } - public function setReceiverType(int $receiverType) : self + public function setReceiverType(int $receiverType): self { $this->receiverType = $receiverType; + return $this; } } diff --git a/src/CoreBundle/Entity/MessageTag.php b/src/CoreBundle/Entity/MessageTag.php index 68c1609bce..e0c3d9dcca 100644 --- a/src/CoreBundle/Entity/MessageTag.php +++ b/src/CoreBundle/Entity/MessageTag.php @@ -1,20 +1,19 @@ ['message_tag:write']], normalizationContext: ['groups' => ['message_tag:read']])] #[UniqueEntity(fields: ['user', 'tag'], errorPath: 'tag', message: 'This user-tag relation is already used.')] #[ORM\Table(name: 'message_tag')] @@ -64,64 +64,70 @@ class MessageTag $this->color = 'blue'; $this->messageRelUsers = new ArrayCollection(); } - public function getId() : ?int + public function getId(): ?int { return $this->id; } - public function getUser() : User + public function getUser(): User { return $this->user; } - public function setUser(User $user) : self + public function setUser(User $user): self { $this->user = $user; + return $this; } - public function getTag() : string + public function getTag(): string { return $this->tag; } - public function setTag(string $tag) : self + public function setTag(string $tag): self { $this->tag = $tag; + return $this; } - public function getColor() : string + public function getColor(): string { return $this->color; } - public function setColor(string $color) : self + public function setColor(string $color): self { $this->color = $color; + return $this; } - public function setPosition(int $position) : self + public function setPosition(int $position): self { $this->position = $position; + return $this; } - public function getPosition() : int + public function getPosition(): int { return $this->position; } - public function getMessages() : Collection + public function getMessages(): Collection { return $this->messageRelUsers; } - public function addMessage(MessageRelUser $message) : self + public function addMessage(MessageRelUser $message): self { if (!$this->messageRelUsers->contains($message)) { $this->messageRelUsers->add($message); $message->addTag($this); } + return $this; } - public function removeMessage(MessageRelUser $message) : self + public function removeMessage(MessageRelUser $message): self { if ($this->messageRelUsers->contains($message)) { $this->messageRelUsers->removeElement($message); $message->removeTag($this); } + return $this; } } diff --git a/src/CoreBundle/Entity/Page.php b/src/CoreBundle/Entity/Page.php index b7f82461a0..3375a5fc40 100644 --- a/src/CoreBundle/Entity/Page.php +++ b/src/CoreBundle/Entity/Page.php @@ -1,27 +1,27 @@ ['page:read', 'timestampable_created:read', 'timestampable_updated:read'], ], denormalizationContext: [ - 'groups' => ['page:write'] + 'groups' => ['page:write'], ] )] #[ORM\Table(name: 'page')] @@ -97,89 +97,98 @@ class Page { $this->enabled = false; } - public function getId() : ?int + public function getId(): ?int { return $this->id; } - public function getTitle() : string + public function getTitle(): string { return $this->title; } - public function setTitle(string $title) : self + public function setTitle(string $title): self { $this->title = $title; + return $this; } - public function getContent() : string + public function getContent(): string { return $this->content; } - public function setContent(string $content) : self + public function setContent(string $content): self { $this->content = $content; + return $this; } - public function getSlug() : string + public function getSlug(): string { return $this->slug; } - public function setSlug(string $slug) : self + public function setSlug(string $slug): self { $this->slug = $slug; + return $this; } - public function isEnabled() : bool + public function isEnabled(): bool { return $this->enabled; } - public function setEnabled(bool $enabled) : self + public function setEnabled(bool $enabled): self { $this->enabled = $enabled; + return $this; } - public function getLocale() : string + public function getLocale(): string { return $this->locale; } - public function setLocale(string $locale) : self + public function setLocale(string $locale): self { $this->locale = $locale; + return $this; } - public function getUrl() : AccessUrl + public function getUrl(): AccessUrl { return $this->url; } - public function setUrl(AccessUrl $url) : self + public function setUrl(AccessUrl $url): self { $this->url = $url; + return $this; } - public function getCreator() : User + public function getCreator(): User { return $this->creator; } - public function setCreator(User $creator) : self + public function setCreator(User $creator): self { $this->creator = $creator; + return $this; } - public function getPosition() : int + public function getPosition(): int { return $this->position; } - public function setPosition(int $position) : self + public function setPosition(int $position): self { $this->position = $position; + return $this; } - public function getCategory() : ?PageCategory + public function getCategory(): ?PageCategory { return $this->category; } - public function setCategory(PageCategory $category) : self + public function setCategory(PageCategory $category): self { $this->category = $category; + return $this; } } diff --git a/src/CoreBundle/Entity/PageCategory.php b/src/CoreBundle/Entity/PageCategory.php index 7b02d8486a..f9d33274af 100644 --- a/src/CoreBundle/Entity/PageCategory.php +++ b/src/CoreBundle/Entity/PageCategory.php @@ -1,26 +1,39 @@ ['page_category:write']], normalizationContext: ['groups' => ['page_category:read']])] + +#[ApiResource( + operations: [ + new Get(security: 'is_granted(\'ROLE_USER\')'), + new Put(security: 'is_granted(\'ROLE_ADMIN\')'), + new Delete(security: 'is_granted(\'ROLE_ADMIN\')'), + new GetCollection(security: 'is_granted(\'ROLE_USER\')'), + new Post(security: 'is_granted(\'ROLE_ADMIN\')'), + ], + normalizationContext: [ + 'groups' => ['page_category:read'], + ], + denormalizationContext: [ + 'groups' => ['page_category:write'], + ] +)] #[ORM\Table(name: 'page_category')] #[ORM\Entity] class PageCategory @@ -46,50 +59,54 @@ class PageCategory /** * @var Collection|Page[] */ - #[ORM\OneToMany(targetEntity: Page::class, mappedBy: 'category', cascade: ['persist'])] + #[ORM\OneToMany(mappedBy: 'category', targetEntity: Page::class, cascade: ['persist'])] protected Collection $pages; public function __construct() { $this->pages = new ArrayCollection(); } - public function getId() : ?int + public function getId(): ?int { return $this->id; } - public function getTitle() : string + public function getTitle(): string { return $this->title; } - public function setTitle(string $title) : self + public function setTitle(string $title): self { $this->title = $title; + return $this; } - public function getCreator() : User + public function getCreator(): User { return $this->creator; } - public function setCreator(User $creator) : self + public function setCreator(User $creator): self { $this->creator = $creator; + return $this; } - public function getType() : string + public function getType(): string { return $this->type; } - public function setType(string $type) : self + public function setType(string $type): self { $this->type = $type; + return $this; } public function getPages() { return $this->pages; } - public function setPages(Collection $pages) : self + public function setPages(Collection $pages): self { $this->pages = $pages; + return $this; } } diff --git a/src/CoreBundle/Entity/PersonalFile.php b/src/CoreBundle/Entity/PersonalFile.php index a2bb4661bd..87044550e8 100644 --- a/src/CoreBundle/Entity/PersonalFile.php +++ b/src/CoreBundle/Entity/PersonalFile.php @@ -1,32 +1,31 @@ ['Default', 'media_object_create', 'personal_file:write']], openapiContext: ['requestBody' => ['content' => ['multipart/form-data' => ['schema' => ['type' => 'object', 'properties' => ['title' => ['type' => 'string'], 'comment' => ['type' => 'string'], 'contentFile' => ['type' => 'string'], 'uploadFile' => ['type' => 'string', 'format' => 'binary'], 'parentResourceNodeId' => ['type' => 'integer'], 'resourceLinkList' => ['type' => 'array', 'items' => ['type' => 'object', 'properties' => ['visibility' => ['type' => 'integer'], 'c_id' => ['type' => 'integer'], 'session_id' => ['type' => 'integer']]]]]]]]]]), new GetCollection(security: 'is_granted(\'ROLE_USER\')')], normalizationContext: ['groups' => ['personal_file:read', 'resource_node:read']], denormalizationContext: ['groups' => ['personal_file:write']])] #[ORM\Table(name: 'personal_file')] #[ORM\EntityListeners([ResourceListener::class])] @@ -34,7 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert; #[ApiFilter(filterClass: SearchFilter::class, properties: ['title' => 'partial', 'resourceNode.parent' => 'exact'])] #[ApiFilter(filterClass: PropertyFilter::class)] #[ApiFilter(filterClass: OrderFilter::class, properties: ['id', 'resourceNode.title', 'resourceNode.createdAt', 'resourceNode.resourceFile.size', 'resourceNode.updatedAt'])] -class PersonalFile extends AbstractResource implements ResourceInterface, \Stringable +class PersonalFile extends AbstractResource implements ResourceInterface, Stringable { use TimestampableEntity; #[Groups(['personal_file:read'])] @@ -49,32 +48,33 @@ class PersonalFile extends AbstractResource implements ResourceInterface, \Strin public function __construct() { } - public function __toString() : string + public function __toString(): string { return $this->getTitle(); } - public function getId() : int + public function getId(): int { return $this->id; } - public function getTitle() : string + public function getTitle(): string { return $this->title; } - public function setTitle(string $title) : self + public function setTitle(string $title): self { $this->title = $title; + return $this; } - public function getResourceIdentifier() : int + public function getResourceIdentifier(): int { return $this->getId(); } - public function getResourceName() : string + public function getResourceName(): string { return $this->getTitle(); } - public function setResourceName(string $name) : self + public function setResourceName(string $name): self { return $this->setTitle($name); } diff --git a/src/CoreBundle/Entity/Portfolio.php b/src/CoreBundle/Entity/Portfolio.php index c1c9344eb4..aa5cdfaa65 100644 --- a/src/CoreBundle/Entity/Portfolio.php +++ b/src/CoreBundle/Entity/Portfolio.php @@ -10,14 +10,11 @@ use Chamilo\CoreBundle\Traits\UserTrait; use DateTime; use Doctrine\ORM\Mapping as ORM; -/** - * Class Portfolio. - */ #[ORM\Table(name: 'portfolio')] -#[ORM\Index(name: 'user', columns: ['user_id'])] -#[ORM\Index(name: 'course', columns: ['c_id'])] -#[ORM\Index(name: 'session', columns: ['session_id'])] -#[ORM\Index(name: 'category', columns: ['category_id'])] +#[ORM\Index(columns: ['user_id'], name: 'user')] +#[ORM\Index(columns: ['c_id'], name: 'course')] +#[ORM\Index(columns: ['session_id'], name: 'session')] +#[ORM\Index(columns: ['category_id'], name: 'category')] #[ORM\Entity] class Portfolio { @@ -59,6 +56,24 @@ class Portfolio #[ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')] protected PortfolioCategory $category; + #[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\PortfolioComment::class)] + private $comments; + + #[ORM\Column(name: 'origin', type: 'integer', nullable: true)] + private int $origin; + + #[ORM\Column(name: 'origin_type', type: 'integer', nullable: true)] + private int $originType; + + #[ORM\Column(name: 'score', type: 'float', nullable: true)] + private float $score; + + #[ORM\Column(name: 'is_highlighted', type: 'boolean', options: ['default' => false])] + private bool $isHighlighted = false; + + #[ORM\Column(name: 'is_template', type: 'boolean', options: ['default' => false])] + private bool $isTemplate = false; + public function __construct() { $this->category = new PortfolioCategory(); @@ -244,4 +259,94 @@ class Portfolio return $this; } + + public function getComments(): Collection + { + return $this->comments; + } + + public function getLastComments(int $number = 3, bool $avoidPerUserVisibility = false): Collection + { + $criteria = Criteria::create(); + $criteria + ->orderBy(['date' => 'DESC']) + ->setMaxResults($number); + + if ($avoidPerUserVisibility) { + $criteria->where( + Criteria::expr()->neq('visibility', PortfolioComment::VISIBILITY_PER_USER) + ); + } + + return $this->comments->matching($criteria); + } + + public function getOrigin(): ?int + { + return $this->origin; + } + + /** + * @return \Chamilo\CoreBundle\Entity\Portfolio + */ + public function setOrigin(?int $origin): Portfolio + { + $this->origin = $origin; + + return $this; + } + + public function getOriginType(): ?int + { + return $this->originType; + } + + /** + * @return \Chamilo\CoreBundle\Entity\Portfolio + */ + public function setOriginType(?int $originType): Portfolio + { + $this->originType = $originType; + + return $this; + } + + public function getExcerpt(int $count = 380): string + { + return api_get_short_text_from_html($this->content, $count); + } + + public function getScore(): ?float + { + return $this->score; + } + + public function setScore(?float $score): void + { + $this->score = $score; + } + + public function isHighlighted(): bool + { + return $this->isHighlighted; + } + + public function setIsHighlighted(bool $isHighlighted): Portfolio + { + $this->isHighlighted = $isHighlighted; + + return $this; + } + + public function isTemplate(): bool + { + return $this->isTemplate; + } + + public function setIsTemplate(bool $isTemplate): Portfolio + { + $this->isTemplate = $isTemplate; + + return $this; + } } diff --git a/src/CoreBundle/Entity/PortfolioAttachment.php b/src/CoreBundle/Entity/PortfolioAttachment.php new file mode 100644 index 0000000000..9120c737ab --- /dev/null +++ b/src/CoreBundle/Entity/PortfolioAttachment.php @@ -0,0 +1,135 @@ +id; + } + + public function getPath(): string + { + return $this->path; + } + + public function setPath(string $path): PortfolioAttachment + { + $this->path = $path; + + return $this; + } + + public function getComment(): ?string + { + return $this->comment; + } + + public function setComment(?string $comment): PortfolioAttachment + { + $this->comment = $comment; + + return $this; + } + + public function getSize(): int + { + return $this->size; + } + + public function setSize(int $size): PortfolioAttachment + { + $this->size = $size; + + return $this; + } + + public function getFilename(): string + { + return $this->filename; + } + + public function setFilename(string $filename): PortfolioAttachment + { + $this->filename = $filename; + + return $this; + } + + public function getOrigin(): int + { + return $this->origin; + } + + public function setOrigin(int $origin): PortfolioAttachment + { + $this->origin = $origin; + + return $this; + } + + public function getOriginType(): int + { + return $this->originType; + } + + public function setOriginType(int $originType): PortfolioAttachment + { + $this->originType = $originType; + + return $this; + } +} diff --git a/src/CoreBundle/Entity/PortfolioCategory.php b/src/CoreBundle/Entity/PortfolioCategory.php index 411b7fa587..f7cf765d07 100644 --- a/src/CoreBundle/Entity/PortfolioCategory.php +++ b/src/CoreBundle/Entity/PortfolioCategory.php @@ -10,14 +10,12 @@ use Chamilo\CoreBundle\Traits\UserTrait; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; +use Stringable; -/** - * Class PortfolioCategory. - */ #[ORM\Table(name: 'portfolio_category')] -#[ORM\Index(name: 'user', columns: ['user_id'])] +#[ORM\Index(columns: ['user_id'], name: 'user')] #[ORM\Entity] -class PortfolioCategory implements \Stringable +class PortfolioCategory implements Stringable { use UserTrait; @@ -84,9 +82,6 @@ class PortfolioCategory implements \Stringable return $this; } - /** - * Get description. - */ public function getDescription(): ?string { return $this->description; diff --git a/src/CoreBundle/Entity/PortfolioComment.php b/src/CoreBundle/Entity/PortfolioComment.php new file mode 100644 index 0000000000..0f19ab20ef --- /dev/null +++ b/src/CoreBundle/Entity/PortfolioComment.php @@ -0,0 +1,275 @@ +isImportant = false; + $this->children = new ArrayCollection(); + $this->visibility = 1; + } + + public function getId(): int + { + return $this->id; + } + + public function getAuthor(): User + { + return $this->author; + } + + public function setAuthor(User $author): PortfolioComment + { + $this->author = $author; + + return $this; + } + + /** + * @return \Chamilo\CoreBundle\Entity\Portfolio + */ + public function getItem(): Portfolio + { + return $this->item; + } + + /** + * @param \Chamilo\CoreBundle\Entity\Portfolio $item + */ + public function setItem(Portfolio $item): PortfolioComment + { + $this->item = $item; + + return $this; + } + + public function getContent(): string + { + return $this->content; + } + + public function setContent(string $content): PortfolioComment + { + $this->content = $content; + + return $this; + } + + public function getDate(): DateTime + { + return $this->date; + } + + public function setDate(DateTime $date): PortfolioComment + { + $this->date = $date; + + return $this; + } + + /** + * @return \Chamilo\CoreBundle\Entity\PortfolioComment|null + */ + public function getParent(): ?PortfolioComment + { + return $this->parent; + } + + /** + * @param \Chamilo\CoreBundle\Entity\PortfolioComment|null $parent + */ + public function setParent(?PortfolioComment $parent): PortfolioComment + { + $this->parent = $parent; + + return $this; + } + + public function getChildren(): ArrayCollection + { + return $this->children; + } + + public function setChildren(ArrayCollection $children): PortfolioComment + { + $this->children = $children; + + return $this; + } + + public function isImportant(): bool + { + return $this->isImportant; + } + + public function setIsImportant(bool $isImportant): void + { + $this->isImportant = $isImportant; + } + + public function getExcerpt(int $count = 190): string + { + return api_get_short_text_from_html($this->content, $count); + } + + public function getScore(): ?float + { + return $this->score; + } + + public function setScore(?float $score): void + { + $this->score = $score; + } + + /** + * @return \Chamilo\CoreBundle\Entity\PortfolioComment + */ + public function getRoot(): PortfolioComment + { + return $this->root; + } + + public function getLvl(): int + { + return $this->lvl; + } + + public function isTemplate(): bool + { + return $this->isTemplate; + } + + public function setIsTemplate(bool $isTemplate): PortfolioComment + { + $this->isTemplate = $isTemplate; + + return $this; + } + + public function getVisibility(): int + { + return $this->visibility; + } + + public function setVisibility(int $visibility): PortfolioComment + { + $this->visibility = $visibility; + + return $this; + } +} diff --git a/src/CoreBundle/Entity/Profile.php b/src/CoreBundle/Entity/Profile.php index 96f53c2e0e..5f378c8ae5 100644 --- a/src/CoreBundle/Entity/Profile.php +++ b/src/CoreBundle/Entity/Profile.php @@ -9,10 +9,11 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; #[ORM\Table(name: 'skill_level_profile')] #[ORM\Entity] -class Profile implements \Stringable +class Profile implements Stringable { #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] @@ -23,16 +24,15 @@ class Profile implements \Stringable protected string $name; /** - * @var Skill[]|Collection + * @var Collection */ - #[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\Skill::class, mappedBy: 'profile', cascade: ['persist'])] + #[ORM\OneToMany(mappedBy: 'profile', targetEntity: Skill::class, cascade: ['persist'])] protected Collection $skills; /** - * - * @var Level[]|Collection + * @var Collection */ - #[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\Level::class, mappedBy: 'profile', cascade: ['persist'])] + #[ORM\OneToMany(mappedBy: 'profile', targetEntity: Level::class, cascade: ['persist'])] #[ORM\OrderBy(['position' => 'ASC'])] protected Collection $levels; @@ -70,7 +70,7 @@ class Profile implements \Stringable /** * @return Skill[]|Collection */ - public function getSkills(): array|\Doctrine\Common\Collections\Collection + public function getSkills(): array|Collection { return $this->skills; } @@ -78,7 +78,7 @@ class Profile implements \Stringable /** * @param Skill[]|Collection $skills */ - public function setSkills(array|\Doctrine\Common\Collections\Collection $skills): self + public function setSkills(array|Collection $skills): self { $this->skills = $skills; @@ -88,7 +88,7 @@ class Profile implements \Stringable /** * @return Level[]|Collection */ - public function getLevels(): array|\Doctrine\Common\Collections\Collection + public function getLevels(): array|Collection { return $this->levels; } diff --git a/src/CoreBundle/Entity/Promotion.php b/src/CoreBundle/Entity/Promotion.php index 6772777822..a30e830e4e 100644 --- a/src/CoreBundle/Entity/Promotion.php +++ b/src/CoreBundle/Entity/Promotion.php @@ -130,7 +130,7 @@ class Promotion /** * @return Session[]|Collection */ - public function getSessions(): array|\Doctrine\Common\Collections\Collection + public function getSessions(): array|Collection { return $this->sessions; } @@ -145,7 +145,7 @@ class Promotion /** * @return SysAnnouncement[]|Collection */ - public function getAnnouncements(): array|\Doctrine\Common\Collections\Collection + public function getAnnouncements(): array|Collection { return $this->announcements; } @@ -153,7 +153,7 @@ class Promotion /** * @param SysAnnouncement[]|Collection $announcements */ - public function setAnnouncements(array|\Doctrine\Common\Collections\Collection $announcements): self + public function setAnnouncements(array|Collection $announcements): self { $this->announcements = $announcements; diff --git a/src/CoreBundle/Entity/ResetPasswordRequest.php b/src/CoreBundle/Entity/ResetPasswordRequest.php index f00b271c1a..d8273b2b8f 100644 --- a/src/CoreBundle/Entity/ResetPasswordRequest.php +++ b/src/CoreBundle/Entity/ResetPasswordRequest.php @@ -4,12 +4,13 @@ declare(strict_types=1); namespace Chamilo\CoreBundle\Entity; +use Chamilo\CoreBundle\Repository\ResetPasswordRequestRepository; use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordRequestInterface; use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordRequestTrait; -#[ORM\Entity(repositoryClass: \Chamilo\CoreBundle\Repository\ResetPasswordRequestRepository::class)] +#[ORM\Entity(repositoryClass: ResetPasswordRequestRepository::class)] class ResetPasswordRequest implements ResetPasswordRequestInterface { use ResetPasswordRequestTrait; @@ -19,9 +20,13 @@ class ResetPasswordRequest implements ResetPasswordRequestInterface #[ORM\Column(type: 'integer')] private ?int $id = null; - public function __construct(#[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\User::class)] - private ?object $user, DateTimeInterface $expiresAt, string $selector, string $hashedToken) - { + public function __construct( + #[ORM\ManyToOne(targetEntity: User::class)] + private ?object $user, + DateTimeInterface $expiresAt, + string $selector, + string $hashedToken + ) { $this->initialize($expiresAt, $selector, $hashedToken); } diff --git a/src/CoreBundle/Entity/ResourceComment.php b/src/CoreBundle/Entity/ResourceComment.php index d1fa0d479c..92ba72978e 100644 --- a/src/CoreBundle/Entity/ResourceComment.php +++ b/src/CoreBundle/Entity/ResourceComment.php @@ -14,6 +14,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; +use Gedmo\Tree\Entity\Repository\NestedTreeRepository; use Gedmo\Tree\Traits\NestedSetEntity; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; @@ -26,7 +27,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'resource_comment')] #[Gedmo\Tree(type: 'nested')] -#[ORM\Entity(repositoryClass: \Gedmo\Tree\Entity\Repository\NestedTreeRepository::class)] +#[ORM\Entity(repositoryClass: NestedTreeRepository::class)] class ResourceComment { use TimestampableTypedEntity; @@ -39,12 +40,12 @@ class ResourceComment #[Groups(['comment:read'])] protected ?int $id = null; - #[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\ResourceNode::class, inversedBy: 'comments')] + #[ORM\ManyToOne(targetEntity: ResourceNode::class, inversedBy: 'comments')] #[ORM\JoinColumn(name: 'resource_node_id', referencedColumnName: 'id', onDelete: 'CASCADE')] protected ResourceNode $resourceNode; #[Groups(['comment:read'])] - #[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\User::class)] + #[ORM\ManyToOne(targetEntity: User::class)] #[ORM\JoinColumn(name: 'author_id', referencedColumnName: 'id', onDelete: 'CASCADE')] protected User $author; @@ -55,7 +56,7 @@ class ResourceComment #[ORM\JoinColumn(onDelete: 'CASCADE')] #[Gedmo\TreeParent] - #[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\ResourceComment::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] protected ?ResourceComment $parent = null; #[Groups(['comment:read'])] @@ -69,9 +70,9 @@ class ResourceComment protected DateTime $updatedAt; /** - * @var Collection|ResourceComment[] + * @var Collection */ - #[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\ResourceComment::class, mappedBy: 'parent')] + #[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)] #[ORM\OrderBy(['id' => 'ASC'])] protected Collection $children; @@ -136,17 +137,14 @@ class ResourceComment } /** - * @return ResourceComment[]|Collection + * @return Collection */ - public function getChildren(): array|\Doctrine\Common\Collections\Collection + public function getChildren(): Collection { return $this->children; } - /** - * @param ResourceComment[]|Collection $children - */ - public function setChildren(array|\Doctrine\Common\Collections\Collection $children): self + public function setChildren(Collection $children): self { $this->children = $children; diff --git a/src/CoreBundle/Entity/ResourceFile.php b/src/CoreBundle/Entity/ResourceFile.php index fbd09833ed..2865838fdc 100644 --- a/src/CoreBundle/Entity/ResourceFile.php +++ b/src/CoreBundle/Entity/ResourceFile.php @@ -1,43 +1,84 @@ ['Default', 'media_object_create', 'document:write']], openapiContext: ['requestBody' => ['content' => ['multipart/form-data' => ['schema' => ['type' => 'object', 'properties' => ['file' => ['type' => 'string', 'format' => 'binary']]]]]]]), new GetCollection()], types: ['http://schema.org/MediaObject'], normalizationContext: ['groups' => ['resource_file:read', 'resource_node:read', 'document:read', 'media_object_read', 'message:read']])] +#[ApiResource( + types: ['http://schema.org/MediaObject'], + operations: [ + new Get(), + new Post( + controller: CreateResourceFileAction::class, + openapiContext: [ + 'requestBody' => [ + 'content' => [ + 'multipart/form-data' => [ + 'schema' => [ + 'type' => 'object', + 'properties' => [ + 'file' => [ + 'type' => 'string', + 'format' => 'binary', + ], + ], + ], + ], + ], + ], + ], + security: 'is_granted(\'ROLE_USER\')', + validationContext: [ + 'groups' => ['Default', 'media_object_create', 'document:write'], + ], + deserialize: false + ), + new GetCollection(), + ], + normalizationContext: [ + 'groups' => [ + 'resource_file:read', + 'resource_node:read', + 'document:read', + 'media_object_read', + 'message:read', + ], + ] +)] #[ORM\Table(name: 'resource_file')] #[ORM\Entity] #[ApiFilter(filterClass: PropertyFilter::class)] #[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'partial'])] #[ApiFilter(filterClass: OrderFilter::class, properties: ['id', 'name', 'size', 'updatedAt'])] -class ResourceFile implements \Stringable +class ResourceFile implements Stringable { use TimestampableEntity; #[Groups(['resource_file:read', 'resource_node:read', 'document:read', 'message:read'])] @@ -82,7 +123,7 @@ class ResourceFile implements \Stringable protected ?File $file = null; #[ORM\Column(name: 'crop', type: 'string', length: 255, nullable: true)] protected ?string $crop = null; - #[ORM\OneToOne(targetEntity: \Chamilo\CoreBundle\Entity\ResourceNode::class, mappedBy: 'resourceFile')] + #[ORM\OneToOne(mappedBy: 'resourceFile', targetEntity: ResourceNode::class)] protected ResourceNode $resourceNode; /** * @var string[] @@ -111,87 +152,89 @@ class ResourceFile implements \Stringable $this->metadata = []; $this->dimensions = []; } - public function __toString() : string + public function __toString(): string { return $this->getOriginalName(); } - public function isText() : bool + public function isText(): bool { $mimeType = $this->getMimeType(); + return str_contains($mimeType, 'text'); } - public function isImage() : bool + public function isImage(): bool { $mimeType = $this->getMimeType(); + return str_contains($mimeType, 'image'); } - public function isVideo() : bool + public function isVideo(): bool { $mimeType = $this->getMimeType(); + return str_contains($mimeType, 'video'); } - public function isAudio() : bool + public function isAudio(): bool { $mimeType = $this->getMimeType(); + return str_contains($mimeType, 'audio'); } - public function getName() : ?string + public function getName(): ?string { return $this->name; } - public function setName(?string $name) : self + public function setName(?string $name): self { $this->name = $name; + return $this; } - /** - * @return string - */ - public function getCrop() + public function getCrop(): ?string { return $this->crop; } /** * $crop example: 100,100,100,100 = width,height,x,y. */ - public function setCrop(string $crop) : self + public function setCrop(string $crop): self { $this->crop = $crop; + return $this; } - public function getSize() : ?int + public function getSize(): ?int { return $this->size; } - public function setSize(?int $size) : self + public function setSize(?int $size): self { $this->size = $size; + return $this; } - public function getResourceNode() : ResourceNode + public function getResourceNode(): ResourceNode { return $this->resourceNode; } - public function setResourceNode(ResourceNode $resourceNode) : self + public function setResourceNode(ResourceNode $resourceNode): self { $this->resourceNode = $resourceNode; + return $this; } /*public function isEnabled(): bool { return $this->enabled; } - + public function setEnabled(bool $enabled): self { $this->enabled = $enabled; - + return $this; }*/ - /** - * @return int - */ - public function getId() + public function getId(): ?int { return $this->id; } @@ -199,84 +242,89 @@ class ResourceFile implements \Stringable { return $this->description; } - + public function setDescription(string $description): self { $this->description = $description; - + return $this; }*/ - public function getMimeType() : ?string + public function getMimeType(): ?string { return $this->mimeType; } - public function setMimeType(?string $mimeType) : self + public function setMimeType(?string $mimeType): self { $this->mimeType = $mimeType; + return $this; } - public function getOriginalName() : string + public function getOriginalName(): string { return $this->originalName; } - public function setOriginalName(?string $originalName) : self + public function setOriginalName(?string $originalName): self { $this->originalName = $originalName; + return $this; } - public function getDimensions() : array + public function getDimensions(): array { return $this->dimensions; } - public function setDimensions(?array $dimensions) : self + public function setDimensions(?array $dimensions): self { $this->dimensions = $dimensions; + return $this; } - public function getWidth() : int + public function getWidth(): int { $data = $this->getDimensions(); if ([] !== $data) { //$data = explode(',', $data); return (int) $data[0]; } + return 0; } - public function getHeight() : int + public function getHeight(): int { $data = $this->getDimensions(); if ([] !== $data) { //$data = explode(',', $data); return (int) $data[1]; } + return 0; } - public function getMetadata() : array + public function getMetadata(): array { return $this->metadata; } - public function setMetadata(array $metadata) : self + public function setMetadata(array $metadata): self { $this->metadata = $metadata; + return $this; } - public function getDescription() : string + public function getDescription(): string { return $this->description; } - public function setDescription(string $description) : self + public function setDescription(string $description): self { $this->description = $description; + return $this; } - public function getFile() : ?File + public function getFile(): ?File { return $this->file; } - /** - * @param File|UploadedFile|null $file - */ - public function setFile(\Symfony\Component\HttpFoundation\File\File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $file = null) : self + + public function setFile(File|UploadedFile|null $file = null): self { $this->file = $file; if (null !== $file) { @@ -284,6 +332,7 @@ class ResourceFile implements \Stringable // otherwise the event listeners won't be called and the file is lost $this->updatedAt = new DateTimeImmutable(); } + return $this; } } diff --git a/src/CoreBundle/Entity/ResourceLink.php b/src/CoreBundle/Entity/ResourceLink.php index b4be83ad86..01d5a95a06 100644 --- a/src/CoreBundle/Entity/ResourceLink.php +++ b/src/CoreBundle/Entity/ResourceLink.php @@ -1,28 +1,26 @@ resourceRights = new ArrayCollection(); $this->visibility = self::VISIBILITY_DRAFT; } - public function __toString() : string + public function __toString(): string { return (string) $this->getId(); } - public function getStartVisibilityAt() : ?DateTimeInterface + public function getStartVisibilityAt(): ?DateTimeInterface { return $this->startVisibilityAt; } - public function setStartVisibilityAt(?DateTimeInterface $startVisibilityAt) : self + public function setStartVisibilityAt(?DateTimeInterface $startVisibilityAt): self { $this->startVisibilityAt = $startVisibilityAt; + return $this; } - public function getEndVisibilityAt() : ?DateTimeInterface + public function getEndVisibilityAt(): ?DateTimeInterface { return $this->endVisibilityAt; } - public function setEndVisibilityAt(?DateTimeInterface $endVisibilityAt) : self + public function setEndVisibilityAt(?DateTimeInterface $endVisibilityAt): self { $this->endVisibilityAt = $endVisibilityAt; + return $this; } + /** - * @param ResourceRight[]|Collection $rights + * @param Collection $rights + * + * @return ResourceLink */ - public function setResourceRights(array|\Doctrine\Common\Collections\Collection $rights) : self + public function setResourceRights(Collection $rights): self { $this->resourceRights = $rights; /*foreach ($rights as $right) { @@ -135,18 +138,19 @@ class ResourceLink implements \Stringable }*/ return $this; } - public function addResourceRight(ResourceRight $right) : self + public function addResourceRight(ResourceRight $right): self { if (!$this->resourceRights->contains($right)) { $right->setResourceLink($this); $this->resourceRights->add($right); } + return $this; } /** * @return Collection|ResourceRight[] */ - public function getResourceRights() : \Doctrine\Common\Collections\Collection|array + public function getResourceRights(): Collection|array { return $this->resourceRights; } @@ -157,106 +161,122 @@ class ResourceLink implements \Stringable { return $this->id; } - public function setUser(User $user = null) : self + public function setUser(User $user = null): self { $this->user = $user; + return $this; } - public function getCourse() : ?Course + public function getCourse(): ?Course { return $this->course; } - public function setCourse(Course $course = null) : self + public function setCourse(Course $course = null): self { $this->course = $course; + return $this; } - public function getSession() : ?Session + public function getSession(): ?Session { return $this->session; } - public function setSession(Session $session = null) : self + public function setSession(Session $session = null): self { $this->session = $session; + return $this; } - public function hasSession() : bool + public function hasSession(): bool { return null !== $this->session; } - public function hasCourse() : bool + public function hasCourse(): bool { return null !== $this->course; } - public function hasGroup() : bool + public function hasGroup(): bool { return null !== $this->group; } - public function getGroup() : ?CGroup + public function getGroup(): ?CGroup { return $this->group; } - public function setGroup(CGroup $group = null) : self + public function setGroup(CGroup $group = null): self { $this->group = $group; + return $this; } - public function getUserGroup() : ?Usergroup + public function getUserGroup(): ?Usergroup { return $this->userGroup; } - public function setUserGroup(Usergroup $group = null) : self + public function setUserGroup(Usergroup $group = null): self { $this->userGroup = $group; + return $this; } - public function getUser() : ?User + public function getUser(): ?User { return $this->user; } - public function hasUser() : bool + public function hasUser(): bool { return null !== $this->user; } - public function setResourceNode(ResourceNode $resourceNode) : self + public function setResourceNode(ResourceNode $resourceNode): self { $this->resourceNode = $resourceNode; + return $this; } - public function getResourceNode() : ResourceNode + public function getResourceNode(): ResourceNode { return $this->resourceNode; } - public function getVisibility() : int + public function getVisibility(): int { return $this->visibility; } - public function setVisibility(int $visibility) : self + public function setVisibility(int $visibility): self { if (!\in_array($visibility, self::getVisibilityList(), true)) { - $message = sprintf('The visibility is not valid. Valid options: %s', print_r(self::getVisibilityList(), true)); + $message = sprintf( + 'The visibility is not valid. Valid options: %s', + print_r(self::getVisibilityList(), true) + ); + throw new LogicException($message); } $this->visibility = $visibility; + return $this; } - public function isPublished() : bool + public function isPublished(): bool { return self::VISIBILITY_PUBLISHED === $this->getVisibility(); } - public function isPending() : bool + public function isPending(): bool { return self::VISIBILITY_PENDING === $this->getVisibility(); } - public function isDraft() : bool + public function isDraft(): bool { return self::VISIBILITY_DRAFT === $this->getVisibility(); } - public static function getVisibilityList() : array + public static function getVisibilityList(): array { - return ['Draft' => self::VISIBILITY_DRAFT, 'Pending' => self::VISIBILITY_PENDING, 'Published' => self::VISIBILITY_PUBLISHED, 'Deleted' => self::VISIBILITY_DELETED]; + return [ + 'Draft' => self::VISIBILITY_DRAFT, + 'Pending' => self::VISIBILITY_PENDING, + 'Published' => self::VISIBILITY_PUBLISHED, + 'Deleted' => self::VISIBILITY_DELETED, + ]; } - public function getVisibilityName() : string + public function getVisibilityName(): string { return array_flip(static::getVisibilityList())[$this->getVisibility()]; } diff --git a/src/CoreBundle/Entity/ResourceNode.php b/src/CoreBundle/Entity/ResourceNode.php index 1b854a6677..dc7af2ef26 100644 --- a/src/CoreBundle/Entity/ResourceNode.php +++ b/src/CoreBundle/Entity/ResourceNode.php @@ -1,23 +1,22 @@ ['resource_node:write', 'document:write']], normalizationContext: ['groups' => ['resource_node:read', 'document:read']])] #[ORM\Table(name: 'resource_node')] @@ -73,7 +71,7 @@ use Symfony\Component\Validator\Constraints as Assert; #[ApiResource(uriTemplate: '/c_tools/{iid}/resource_node/parent.{_format}', uriVariables: ['iid' => new Link(fromClass: \Chamilo\CourseBundle\Entity\CTool::class, identifiers: ['iid']), 'resourceNode' => new Link(fromClass: self::class, identifiers: [], expandedValue: 'resource_node')], status: 200, filters: ['annotated_chamilo_core_bundle_entity_resource_node_api_platform_core_bridge_doctrine_orm_filter_order_filter', 'annotated_chamilo_core_bundle_entity_resource_node_api_platform_serializer_filter_property_filter', 'annotated_chamilo_core_bundle_entity_resource_node_api_platform_core_bridge_doctrine_orm_filter_search_filter'], normalizationContext: ['groups' => ['resource_node:read', 'document:read']], operations: [new Get()])] #[ApiResource(uriTemplate: '/c_tool_intros/{iid}/resource_node.{_format}', uriVariables: ['iid' => new Link(fromClass: \Chamilo\CourseBundle\Entity\CToolIntro::class, identifiers: ['iid'])], status: 200, filters: ['annotated_chamilo_core_bundle_entity_resource_node_api_platform_core_bridge_doctrine_orm_filter_order_filter', 'annotated_chamilo_core_bundle_entity_resource_node_api_platform_serializer_filter_property_filter', 'annotated_chamilo_core_bundle_entity_resource_node_api_platform_core_bridge_doctrine_orm_filter_search_filter'], normalizationContext: ['groups' => ['resource_node:read', 'document:read']], operations: [new Get()])] #[ApiResource(uriTemplate: '/c_tool_intros/{iid}/resource_node/parent.{_format}', uriVariables: ['iid' => new Link(fromClass: \Chamilo\CourseBundle\Entity\CToolIntro::class, identifiers: ['iid']), 'resourceNode' => new Link(fromClass: self::class, identifiers: [], expandedValue: 'resource_node')], status: 200, filters: ['annotated_chamilo_core_bundle_entity_resource_node_api_platform_core_bridge_doctrine_orm_filter_order_filter', 'annotated_chamilo_core_bundle_entity_resource_node_api_platform_serializer_filter_property_filter', 'annotated_chamilo_core_bundle_entity_resource_node_api_platform_core_bridge_doctrine_orm_filter_search_filter'], normalizationContext: ['groups' => ['resource_node:read', 'document:read']], operations: [new Get()])] -class ResourceNode implements \Stringable +class ResourceNode implements Stringable { use TimestampableTypedEntity; use TimestampableAgoTrait; @@ -116,12 +114,12 @@ class ResourceNode implements \Stringable protected User $creator; #[ORM\JoinColumn(name: 'parent_id', onDelete: 'CASCADE')] #[Gedmo\TreeParent] - #[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\ResourceNode::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] protected ?ResourceNode $parent = null; /** * @var Collection|ResourceNode[] */ - #[ORM\OneToMany(targetEntity: \Chamilo\CoreBundle\Entity\ResourceNode::class, mappedBy: 'parent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] #[ORM\OrderBy(['id' => 'ASC'])] protected Collection $children; #[Gedmo\TreeLevel] @@ -172,11 +170,11 @@ class ResourceNode implements \Stringable $this->createdAt = new DateTime(); $this->fileEditableText = false; } - public function __toString() : string + public function __toString(): string { return $this->getPathForDisplay(); } - public function getUuid() : ?UuidV4 + public function getUuid(): ?UuidV4 { return $this->uuid; } @@ -189,17 +187,18 @@ class ResourceNode implements \Stringable { return $this->id; } - public function hasCreator() : bool + public function hasCreator(): bool { return null !== $this->creator; } - public function getCreator() : ?User + public function getCreator(): ?User { return $this->creator; } - public function setCreator(User $creator) : self + public function setCreator(User $creator): self { $this->creator = $creator; + return $this; } /** @@ -207,29 +206,30 @@ class ResourceNode implements \Stringable * * @return Collection|ResourceNode[] */ - public function getChildren() : \Doctrine\Common\Collections\Collection|array + public function getChildren(): Collection|array { return $this->children; } /** * Sets the parent resource. */ - public function setParent(self $parent = null) : self + public function setParent(self $parent = null): self { $this->parent = $parent; + return $this; } /** * Returns the parent resource. */ - public function getParent() : ?\Chamilo\CoreBundle\Entity\ResourceNode + public function getParent(): ?self { return $this->parent; } /** * Return the lvl value of the resource in the tree. */ - public function getLevel() : int + public function getLevel(): int { return $this->level; } @@ -247,26 +247,27 @@ class ResourceNode implements \Stringable /** * @return Collection|ResourceComment[] */ - public function getComments() : \Doctrine\Common\Collections\Collection|array + public function getComments(): Collection|array { return $this->comments; } - public function addComment(ResourceComment $comment) : self + public function addComment(ResourceComment $comment): self { $comment->setResourceNode($this); $this->comments->add($comment); + return $this; } /** * Returns the path cleaned from its ids. * Eg.: "Root/subdir/file.txt". */ - public function getPathForDisplay() : string + public function getPathForDisplay(): string { return $this->path; //return $this->convertPathForDisplay($this->path); } - public function getPathForDisplayToArray(?int $baseRoot = null) : array + public function getPathForDisplayToArray(?int $baseRoot = null): array { $parts = explode(self::PATH_SEPARATOR, $this->path); $list = []; @@ -282,40 +283,45 @@ class ResourceNode implements \Stringable } $list[$id] = $value; } + return $list; } - public function getPathForDisplayRemoveBase(string $base) : string + public function getPathForDisplayRemoveBase(string $base): string { $path = str_replace($base, '', $this->path); + return $this->convertPathForDisplay($path); } - public function getSlug() : string + public function getSlug(): string { return $this->slug; } - public function getTitle() : string + public function getTitle(): string { return $this->title; } - public function setTitle(string $title) : self + public function setTitle(string $title): self { $title = str_replace('/', '-', $title); $this->title = $title; + return $this; } - public function setSlug(string $slug) : self + public function setSlug(string $slug): self { if (str_contains(self::PATH_SEPARATOR, $slug)) { - $message = 'Invalid character "' . self::PATH_SEPARATOR . '" in resource name'; + $message = 'Invalid character "'.self::PATH_SEPARATOR.'" in resource name'; + throw new InvalidArgumentException($message); } $this->slug = $slug; + return $this; } /** * Convert a path for display: remove ids. */ - public function convertPathForDisplay(string $path) : string + public function convertPathForDisplay(string $path): string { /*$pathForDisplay = preg_replace( '/-\d+'.self::PATH_SEPARATOR.'/', @@ -326,45 +332,49 @@ class ResourceNode implements \Stringable $pathForDisplay = substr_replace($pathForDisplay, '', -3); } */ - $pathForDisplay = preg_replace('/-\\d+\\' . self::PATH_SEPARATOR . '/', '/', $path); + $pathForDisplay = preg_replace('/-\\d+\\'.self::PATH_SEPARATOR.'/', '/', $path); if (null !== $pathForDisplay && '' !== $pathForDisplay) { $pathForDisplay = substr_replace($pathForDisplay, '', -1); } + return $pathForDisplay; } - public function getResourceType() : ResourceType + public function getResourceType(): ResourceType { return $this->resourceType; } - public function setResourceType(ResourceType $resourceType) : self + public function setResourceType(ResourceType $resourceType): self { $this->resourceType = $resourceType; + return $this; } - public function getResourceLinks() : Collection + public function getResourceLinks(): Collection { return $this->resourceLinks; } - public function addResourceLink(ResourceLink $link) : self + public function addResourceLink(ResourceLink $link): self { $link->setResourceNode($this); $this->resourceLinks->add($link); + return $this; } - public function setResourceLinks(Collection $resourceLinks) : self + public function setResourceLinks(Collection $resourceLinks): self { $this->resourceLinks = $resourceLinks; + return $this; } - public function hasResourceFile() : bool + public function hasResourceFile(): bool { return null !== $this->resourceFile; } - public function getResourceFile() : ?ResourceFile + public function getResourceFile(): ?ResourceFile { return $this->resourceFile; } - public function hasEditableTextContent() : bool + public function hasEditableTextContent(): bool { if ($this->hasResourceFile()) { $mimeType = $this->getResourceFile()->getMimeType(); @@ -372,9 +382,10 @@ class ResourceNode implements \Stringable return true; } } + return false; } - public function isResourceFileAnImage() : bool + public function isResourceFileAnImage(): bool { if ($this->hasResourceFile()) { $mimeType = $this->getResourceFile()->getMimeType(); @@ -382,9 +393,10 @@ class ResourceNode implements \Stringable return true; } } + return false; } - public function isResourceFileAVideo() : bool + public function isResourceFileAVideo(): bool { if ($this->hasResourceFile()) { $mimeType = $this->getResourceFile()->getMimeType(); @@ -392,17 +404,19 @@ class ResourceNode implements \Stringable return true; } } + return false; } - public function setResourceFile(?ResourceFile $resourceFile = null) : self + public function setResourceFile(?ResourceFile $resourceFile = null): self { $this->resourceFile = $resourceFile; if (null !== $resourceFile) { $resourceFile->setResourceNode($this); } + return $this; } - public function getIcon() : string + public function getIcon(): string { $class = 'fa fa-folder'; if ($this->hasResourceFile()) { @@ -414,9 +428,10 @@ class ResourceNode implements \Stringable $class = 'far fa-file-video'; } } - return ''; + + return ''; } - public function getThumbnail(RouterInterface $router) : string + public function getThumbnail(RouterInterface $router): string { $size = 'fa-3x'; $class = sprintf('fa fa-folder %s', $size); @@ -424,41 +439,51 @@ class ResourceNode implements \Stringable $class = sprintf('far fa-file %s', $size); if ($this->isResourceFileAnImage()) { $class = sprintf('far fa-file-image %s', $size); - $params = ['id' => $this->getId(), 'tool' => $this->getResourceType()->getTool(), 'type' => $this->getResourceType()->getName(), 'filter' => 'editor_thumbnail']; + $params = [ + 'id' => $this->getId(), + 'tool' => $this->getResourceType()->getTool(), + 'type' => $this->getResourceType()->getName(), + 'filter' => 'editor_thumbnail', + ]; $url = $router->generate('chamilo_core_resource_view', $params); + return sprintf("", $url); } if ($this->isResourceFileAVideo()) { $class = sprintf('far fa-file-video %s', $size); } } - return ''; + + return ''; } - public function getContent() : ?string + public function getContent(): ?string { return $this->content; } - public function setContent(string $content) : self + public function setContent(string $content): self { $this->content = $content; + return $this; } - public function getShortCut() : ?CShortcut + public function getShortCut(): ?CShortcut { return $this->shortCut; } - public function setShortCut(?CShortcut $shortCut) : self + public function setShortCut(?CShortcut $shortCut): self { $this->shortCut = $shortCut; + return $this; } - public function isPublic() : bool + public function isPublic(): bool { return $this->public; } - public function setPublic(bool $public) : self + public function setPublic(bool $public): self { $this->public = $public; + return $this; } } diff --git a/src/CoreBundle/Entity/ResourceRight.php b/src/CoreBundle/Entity/ResourceRight.php index 9cc65d6f10..dd9dc851f6 100644 --- a/src/CoreBundle/Entity/ResourceRight.php +++ b/src/CoreBundle/Entity/ResourceRight.php @@ -7,10 +7,11 @@ declare(strict_types=1); namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Stringable; #[ORM\Table(name: 'resource_right')] #[ORM\Entity] -class ResourceRight implements \Stringable +class ResourceRight implements Stringable { #[ORM\Id] #[ORM\Column(type: 'bigint')] diff --git a/src/CoreBundle/Entity/ResourceType.php b/src/CoreBundle/Entity/ResourceType.php index 447f96bb4e..2be5981b56 100644 --- a/src/CoreBundle/Entity/ResourceType.php +++ b/src/CoreBundle/Entity/ResourceType.php @@ -10,11 +10,12 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Timestampable\Traits\TimestampableEntity; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'resource_type')] #[ORM\Entity] -class ResourceType implements \Stringable +class ResourceType implements Stringable { use TimestampableEntity; @@ -79,7 +80,7 @@ class ResourceType implements \Stringable /** * @return ResourceNode[]|Collection */ - public function getResourceNodes(): array|\Doctrine\Common\Collections\Collection + public function getResourceNodes(): array|Collection { return $this->resourceNodes; } @@ -87,7 +88,7 @@ class ResourceType implements \Stringable /** * @param ResourceNode[]|Collection $resourceNodes */ - public function setResourceNodes(array|\Doctrine\Common\Collections\Collection $resourceNodes): self + public function setResourceNodes(array|Collection $resourceNodes): self { $this->resourceNodes = $resourceNodes; diff --git a/src/CoreBundle/Entity/Sequence.php b/src/CoreBundle/Entity/Sequence.php index 3c3fe286d6..75d444801f 100644 --- a/src/CoreBundle/Entity/Sequence.php +++ b/src/CoreBundle/Entity/Sequence.php @@ -9,10 +9,11 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Fhaculty\Graph\Graph; use Gedmo\Timestampable\Traits\TimestampableEntity; +use Stringable; #[ORM\Table(name: 'sequence')] #[ORM\Entity(repositoryClass: \Chamilo\CoreBundle\Repository\SequenceRepository::class)] -class Sequence implements \Stringable +class Sequence implements Stringable { use TimestampableEntity; diff --git a/src/CoreBundle/Entity/SequenceCondition.php b/src/CoreBundle/Entity/SequenceCondition.php index 0330597e7a..832fc88ae6 100644 --- a/src/CoreBundle/Entity/SequenceCondition.php +++ b/src/CoreBundle/Entity/SequenceCondition.php @@ -8,9 +8,6 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class SequenceCondition. - */ #[ORM\Table(name: 'sequence_condition')] #[ORM\Entity] class SequenceCondition diff --git a/src/CoreBundle/Entity/SequenceFormula.php b/src/CoreBundle/Entity/SequenceFormula.php index eac7bae0f4..a6f080aa32 100644 --- a/src/CoreBundle/Entity/SequenceFormula.php +++ b/src/CoreBundle/Entity/SequenceFormula.php @@ -8,9 +8,6 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class SequenceFormula. - */ #[ORM\Table(name: 'sequence_formula')] #[ORM\Entity] class SequenceFormula diff --git a/src/CoreBundle/Entity/SequenceMethod.php b/src/CoreBundle/Entity/SequenceMethod.php index 5a9c55ab78..1e22bb54f0 100644 --- a/src/CoreBundle/Entity/SequenceMethod.php +++ b/src/CoreBundle/Entity/SequenceMethod.php @@ -8,9 +8,6 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class SequenceMethod. - */ #[ORM\Table(name: 'sequence_method')] #[ORM\Entity] class SequenceMethod diff --git a/src/CoreBundle/Entity/SequenceResource.php b/src/CoreBundle/Entity/SequenceResource.php index 3ad07d5417..29dab110cb 100644 --- a/src/CoreBundle/Entity/SequenceResource.php +++ b/src/CoreBundle/Entity/SequenceResource.php @@ -8,9 +8,6 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class SequenceResource. - */ #[ORM\Table(name: 'sequence_resource')] #[ORM\Entity(repositoryClass: \Chamilo\CoreBundle\Repository\SequenceResourceRepository::class)] class SequenceResource diff --git a/src/CoreBundle/Entity/SequenceRowEntity.php b/src/CoreBundle/Entity/SequenceRowEntity.php index 3c3a3f030a..7647d1a8c5 100644 --- a/src/CoreBundle/Entity/SequenceRowEntity.php +++ b/src/CoreBundle/Entity/SequenceRowEntity.php @@ -8,9 +8,6 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class SequenceRowEntity. - */ #[ORM\Table(name: 'sequence_row_entity')] #[ORM\Entity] class SequenceRowEntity diff --git a/src/CoreBundle/Entity/SequenceRule.php b/src/CoreBundle/Entity/SequenceRule.php index 57956710ec..612834640f 100644 --- a/src/CoreBundle/Entity/SequenceRule.php +++ b/src/CoreBundle/Entity/SequenceRule.php @@ -8,9 +8,6 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class SequenceRule. - */ #[ORM\Table(name: 'sequence_rule')] #[ORM\Entity] class SequenceRule diff --git a/src/CoreBundle/Entity/SequenceRuleCondition.php b/src/CoreBundle/Entity/SequenceRuleCondition.php index f0911abc58..9c38a32aea 100644 --- a/src/CoreBundle/Entity/SequenceRuleCondition.php +++ b/src/CoreBundle/Entity/SequenceRuleCondition.php @@ -8,9 +8,6 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class SequenceRuleCondition. - */ #[ORM\Table(name: 'sequence_rule_condition')] #[ORM\Entity] class SequenceRuleCondition diff --git a/src/CoreBundle/Entity/SequenceRuleMethod.php b/src/CoreBundle/Entity/SequenceRuleMethod.php index e99a3a270c..150b22b3e3 100644 --- a/src/CoreBundle/Entity/SequenceRuleMethod.php +++ b/src/CoreBundle/Entity/SequenceRuleMethod.php @@ -8,9 +8,6 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class SequenceRuleMethod. - */ #[ORM\Table(name: 'sequence_rule_method')] #[ORM\Entity] class SequenceRuleMethod diff --git a/src/CoreBundle/Entity/SequenceTypeEntity.php b/src/CoreBundle/Entity/SequenceTypeEntity.php index e879a5c834..d7d0ce806e 100644 --- a/src/CoreBundle/Entity/SequenceTypeEntity.php +++ b/src/CoreBundle/Entity/SequenceTypeEntity.php @@ -8,9 +8,6 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class SequenceTypeEntity. - */ #[ORM\Table(name: 'sequence_type_entity')] #[ORM\Entity] class SequenceTypeEntity diff --git a/src/CoreBundle/Entity/SequenceValue.php b/src/CoreBundle/Entity/SequenceValue.php index 65099b0f2d..2aaa51862b 100644 --- a/src/CoreBundle/Entity/SequenceValue.php +++ b/src/CoreBundle/Entity/SequenceValue.php @@ -10,9 +10,6 @@ use Chamilo\CoreBundle\Traits\UserTrait; use DateTime; use Doctrine\ORM\Mapping as ORM; -/** - * Class Sequence. - */ #[ORM\Table(name: 'sequence_value')] #[ORM\Entity] class SequenceValue diff --git a/src/CoreBundle/Entity/SequenceVariable.php b/src/CoreBundle/Entity/SequenceVariable.php index 608d17951e..131162692f 100644 --- a/src/CoreBundle/Entity/SequenceVariable.php +++ b/src/CoreBundle/Entity/SequenceVariable.php @@ -9,9 +9,6 @@ namespace Chamilo\CoreBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; -/** - * Class SequenceVariable. - */ #[ORM\Table(name: 'sequence_variable')] #[ORM\Entity] class SequenceVariable diff --git a/src/CoreBundle/Entity/Session.php b/src/CoreBundle/Entity/Session.php index 53a22bfea7..5fffdd14a2 100644 --- a/src/CoreBundle/Entity/Session.php +++ b/src/CoreBundle/Entity/Session.php @@ -1,21 +1,20 @@ ['session:read']], denormalizationContext: ['groups' => ['session:write']], @@ -45,7 +46,7 @@ use Symfony\Component\Validator\Constraints as Assert; #[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'partial'])] #[ApiFilter(filterClass: PropertyFilter::class)] #[ApiFilter(filterClass: OrderFilter::class, properties: ['id', 'name'])] -class Session implements ResourceWithAccessUrlInterface, \Stringable +class Session implements ResourceWithAccessUrlInterface, Stringable { public const VISIBLE = 1; public const READ_ONLY = 2; @@ -187,30 +188,32 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable $this->status = 0; $this->position = 0; } - public function __toString() : string + public function __toString(): string { return $this->getName(); } - public static function getRelationTypeList() : array + public static function getRelationTypeList(): array { return [self::STUDENT, self::DRH, self::COURSE_COACH, self::GENERAL_COACH, self::SESSION_ADMIN]; } - public function getDuration() : ?int + public function getDuration(): ?int { return $this->duration; } - public function setDuration(int $duration) : self + public function setDuration(int $duration): self { $this->duration = $duration; + return $this; } - public function getShowDescription() : bool + public function getShowDescription(): bool { return $this->showDescription; } - public function setShowDescription(bool $showDescription) : self + public function setShowDescription(bool $showDescription): self { $this->showDescription = $showDescription; + return $this; } /** @@ -225,19 +228,20 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable /** * @return Collection */ - public function getUsers() : Collection + public function getUsers(): Collection { return $this->users; } - public function setUsers(Collection $users) : self + public function setUsers(Collection $users): self { $this->users = new ArrayCollection(); foreach ($users as $user) { $this->addUserSubscription($user); } + return $this; } - public function addUserSubscription(SessionRelUser $subscription) : void + public function addUserSubscription(SessionRelUser $subscription): void { $subscription->setSession($this); if (!$this->hasUser($subscription)) { @@ -245,37 +249,42 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable $this->nbrUsers++; } } - public function addUserInSession(int $relationType, User $user) : self + public function addUserInSession(int $relationType, User $user): self { $sessionRelUser = (new SessionRelUser())->setUser($user)->setRelationType($relationType); $this->addUserSubscription($sessionRelUser); + return $this; } - public function removeUserInSession(int $relationType, User $user) : self + public function removeUserInSession(int $relationType, User $user): self { $criteria = Criteria::create()->where(Criteria::expr()->eq('relationType', $relationType))->andWhere(Criteria::expr()->eq('user', $user)); $subscriptions = $this->users->matching($criteria); foreach ($subscriptions as $subscription) { $this->removeUserSubscription($subscription); } + return $this; } - public function removeUserSubscription(SessionRelUser $subscription) : self + public function removeUserSubscription(SessionRelUser $subscription): self { if ($this->hasUser($subscription)) { $subscription->setSession(null); $this->users->removeElement($subscription); $this->nbrUsers--; } + return $this; } - public function hasUser(SessionRelUser $subscription) : bool + public function hasUser(SessionRelUser $subscription): bool { if (0 !== $this->getUsers()->count()) { $criteria = Criteria::create()->where(Criteria::expr()->eq('user', $subscription->getUser()))->andWhere(Criteria::expr()->eq('session', $subscription->getSession()))->andWhere(Criteria::expr()->eq('relationType', $subscription->getRelationType())); $relation = $this->getUsers()->matching($criteria); + return $relation->count() > 0; } + return false; } /** @@ -285,31 +294,33 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable { return $this->courses; } - public function setCourses(ArrayCollection $courses) : void + public function setCourses(ArrayCollection $courses): void { $this->courses = new ArrayCollection(); foreach ($courses as $course) { $this->addCourses($course); } } - public function addCourses(SessionRelCourse $course) : void + public function addCourses(SessionRelCourse $course): void { $course->setSession($this); $this->courses->add($course); } - public function hasCourse(Course $course) : bool + public function hasCourse(Course $course): bool { if (0 !== $this->getCourses()->count()) { $criteria = Criteria::create()->where(Criteria::expr()->eq('course', $course)); $relation = $this->getCourses()->matching($criteria); + return $relation->count() > 0; } + return false; } /** * Remove $course. */ - public function removeCourses(SessionRelCourse $course) : void + public function removeCourses(SessionRelCourse $course): void { foreach ($this->courses as $key => $value) { if ($value->getId() === $course->getId()) { @@ -321,7 +332,7 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable * Remove course subscription for a user. * If user status in session is student, then decrease number of course users. */ - public function removeUserCourseSubscription(User $user, Course $course) : void + public function removeUserCourseSubscription(User $user, Course $course): void { foreach ($this->sessionRelCourseRelUsers as $i => $sessionRelUser) { if ($sessionRelUser->getCourse()->getId() === $course->getId() && $sessionRelUser->getUser()->getId() === $user->getId()) { @@ -337,214 +348,239 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable * @param int $status if not set it will check if the user is registered * with any status */ - public function hasUserInCourse(User $user, Course $course, int $status = null) : bool + public function hasUserInCourse(User $user, Course $course, int $status = null): bool { $relation = $this->getUserInCourse($user, $course, $status); + return $relation->count() > 0; } - public function hasStudentInCourse(User $user, Course $course) : bool + public function hasStudentInCourse(User $user, Course $course): bool { return $this->hasUserInCourse($user, $course, self::STUDENT); } - public function hasCourseCoachInCourse(User $user, Course $course = null) : bool + public function hasCourseCoachInCourse(User $user, Course $course = null): bool { if (null === $course) { return false; } + return $this->hasUserInCourse($user, $course, self::COURSE_COACH); } - public function getUserInCourse(User $user, Course $course, ?int $status = null) : Collection + public function getUserInCourse(User $user, Course $course, ?int $status = null): Collection { $criteria = Criteria::create()->where(Criteria::expr()->eq('course', $course))->andWhere(Criteria::expr()->eq('user', $user)); if (null !== $status) { $criteria->andWhere(Criteria::expr()->eq('status', $status)); } + return $this->getSessionRelCourseRelUsers()->matching($criteria); } - public function getAllUsersFromCourse(int $status) : Collection + public function getAllUsersFromCourse(int $status): Collection { $criteria = Criteria::create()->where(Criteria::expr()->eq('status', $status)); + return $this->getSessionRelCourseRelUsers()->matching($criteria); } - public function getSessionRelCourseByUser(User $user, ?int $status = null) : Collection + public function getSessionRelCourseByUser(User $user, ?int $status = null): Collection { $criteria = Criteria::create()->where(Criteria::expr()->eq('user', $user)); if (null !== $status) { $criteria->andWhere(Criteria::expr()->eq('status', $status)); } + return $this->sessionRelCourseRelUsers->matching($criteria); } - public function setName(string $name) : self + public function setName(string $name): self { $this->name = $name; + return $this; } - public function getName() : string + public function getName(): string { return $this->name; } - public function setDescription(string $description) : self + public function setDescription(string $description): self { $this->description = $description; + return $this; } - public function getDescription() : ?string + public function getDescription(): ?string { return $this->description; } - public function setNbrCourses(int $nbrCourses) : self + public function setNbrCourses(int $nbrCourses): self { $this->nbrCourses = $nbrCourses; + return $this; } - public function getNbrCourses() : int + public function getNbrCourses(): int { return $this->nbrCourses; } - public function setNbrUsers(int $nbrUsers) : self + public function setNbrUsers(int $nbrUsers): self { $this->nbrUsers = $nbrUsers; + return $this; } - public function getNbrUsers() : int + public function getNbrUsers(): int { return $this->nbrUsers; } - public function setNbrClasses(int $nbrClasses) : self + public function setNbrClasses(int $nbrClasses): self { $this->nbrClasses = $nbrClasses; + return $this; } - public function getNbrClasses() : int + public function getNbrClasses(): int { return $this->nbrClasses; } - public function setVisibility(int $visibility) : self + public function setVisibility(int $visibility): self { $this->visibility = $visibility; + return $this; } - public function getVisibility() : int + public function getVisibility(): int { return $this->visibility; } - public function getPromotion() : ?Promotion + public function getPromotion(): ?Promotion { return $this->promotion; } - public function setPromotion(?Promotion $promotion) : self + public function setPromotion(?Promotion $promotion): self { $this->promotion = $promotion; + return $this; } - public function setDisplayStartDate(?DateTime $displayStartDate) : self + public function setDisplayStartDate(?DateTime $displayStartDate): self { $this->displayStartDate = $displayStartDate; + return $this; } - public function getDisplayStartDate() : ?DateTime + public function getDisplayStartDate(): ?DateTime { return $this->displayStartDate; } - public function setDisplayEndDate(?DateTime $displayEndDate) : self + public function setDisplayEndDate(?DateTime $displayEndDate): self { $this->displayEndDate = $displayEndDate; + return $this; } - public function getDisplayEndDate() : ?DateTime + public function getDisplayEndDate(): ?DateTime { return $this->displayEndDate; } - public function setAccessStartDate(?DateTime $accessStartDate) : self + public function setAccessStartDate(?DateTime $accessStartDate): self { $this->accessStartDate = $accessStartDate; + return $this; } - public function getAccessStartDate() : ?DateTime + public function getAccessStartDate(): ?DateTime { return $this->accessStartDate; } - public function setAccessEndDate(?DateTime $accessEndDate) : self + public function setAccessEndDate(?DateTime $accessEndDate): self { $this->accessEndDate = $accessEndDate; + return $this; } - public function getAccessEndDate() : ?DateTime + public function getAccessEndDate(): ?DateTime { return $this->accessEndDate; } - public function setCoachAccessStartDate(?DateTime $coachAccessStartDate) : self + public function setCoachAccessStartDate(?DateTime $coachAccessStartDate): self { $this->coachAccessStartDate = $coachAccessStartDate; + return $this; } - public function getCoachAccessStartDate() : ?DateTime + public function getCoachAccessStartDate(): ?DateTime { return $this->coachAccessStartDate; } - public function setCoachAccessEndDate(?DateTime $coachAccessEndDate) : self + public function setCoachAccessEndDate(?DateTime $coachAccessEndDate): self { $this->coachAccessEndDate = $coachAccessEndDate; + return $this; } - public function getCoachAccessEndDate() : ?DateTime + public function getCoachAccessEndDate(): ?DateTime { return $this->coachAccessEndDate; } - public function getGeneralCoaches() : Collection + public function getGeneralCoaches(): Collection { - return $this->getGeneralCoachesSubscriptions()->map(fn(SessionRelUser $subscription) => $subscription->getUser()); + return $this->getGeneralCoachesSubscriptions()->map(fn (SessionRelUser $subscription) => $subscription->getUser()); } - public function getGeneralCoachesSubscriptions() : Collection + public function getGeneralCoachesSubscriptions(): Collection { $criteria = Criteria::create()->where(Criteria::expr()->eq('relationType', self::GENERAL_COACH)); + return $this->users->matching($criteria); } - public function hasUserAsGeneralCoach(User $user) : bool + public function hasUserAsGeneralCoach(User $user): bool { $criteria = Criteria::create()->where(Criteria::expr()->eq('relationType', self::GENERAL_COACH))->andWhere(Criteria::expr()->eq('user', $user)); + return $this->users->matching($criteria)->count() > 0; } - public function addGeneralCoach(User $coach) : self + public function addGeneralCoach(User $coach): self { return $this->addUserInSession(self::GENERAL_COACH, $coach); } - public function removeGeneralCoach(User $user) : self + public function removeGeneralCoach(User $user): self { $this->removeUserInSession(self::GENERAL_COACH, $user); + return $this; } - public function getCategory() : ?SessionCategory + public function getCategory(): ?SessionCategory { return $this->category; } - public function setCategory(?SessionCategory $category) : self + public function setCategory(?SessionCategory $category): self { $this->category = $category; + return $this; } - public static function getStatusList() : array + public static function getStatusList(): array { return [self::VISIBLE => 'status_visible', self::READ_ONLY => 'status_read_only', self::INVISIBLE => 'status_invisible', self::AVAILABLE => 'status_available']; } /** * Check if session is visible. */ - public function isActive() : bool + public function isActive(): bool { $now = new Datetime('now'); + return $now > $this->getAccessStartDate(); } - public function isActiveForStudent() : bool + public function isActiveForStudent(): bool { $start = $this->getAccessStartDate(); $end = $this->getAccessEndDate(); + return $this->compareDates($start, $end); } - public function isActiveForCoach() : bool + public function isActiveForCoach(): bool { $start = $this->getCoachAccessStartDate(); $end = $this->getCoachAccessEndDate(); + return $this->compareDates($start, $end); } /** @@ -553,15 +589,17 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable * * @return bool whether now is between the session access start and end dates */ - public function isCurrentlyAccessible() : bool + public function isCurrentlyAccessible(): bool { $now = new Datetime(); + return (null === $this->accessStartDate || $this->accessStartDate < $now) && (null === $this->accessEndDate || $now < $this->accessEndDate); } - public function addCourse(Course $course) : self + public function addCourse(Course $course): self { $sessionRelCourse = (new SessionRelCourse())->setCourse($course); $this->addCourses($sessionRelCourse); + return $this; } /** @@ -571,41 +609,45 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable * * @return bool whether the course was actually found in this session and removed from it */ - public function removeCourse(Course $course) : bool + public function removeCourse(Course $course): bool { $relCourse = $this->getCourseSubscription($course); if (null !== $relCourse) { $this->courses->removeElement($relCourse); $this->setNbrCourses(\count($this->courses)); + return true; } + return false; } /** * @return SessionRelCourseRelUser[]|ArrayCollection|Collection */ - public function getSessionRelCourseRelUsers() : array|\Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection + public function getSessionRelCourseRelUsers(): array|ArrayCollection|Collection { return $this->sessionRelCourseRelUsers; } - public function setSessionRelCourseRelUsers(Collection $sessionRelCourseRelUsers) : self + public function setSessionRelCourseRelUsers(Collection $sessionRelCourseRelUsers): self { $this->sessionRelCourseRelUsers = new ArrayCollection(); foreach ($sessionRelCourseRelUsers as $item) { $this->addSessionRelCourseRelUser($item); } + return $this; } - public function addSessionRelCourseRelUser(SessionRelCourseRelUser $sessionRelCourseRelUser) : void + public function addSessionRelCourseRelUser(SessionRelCourseRelUser $sessionRelCourseRelUser): void { $sessionRelCourseRelUser->setSession($this); if (!$this->hasUserCourseSubscription($sessionRelCourseRelUser)) { $this->sessionRelCourseRelUsers->add($sessionRelCourseRelUser); } } - public function getCourseSubscription(Course $course) : ?SessionRelCourse + public function getCourseSubscription(Course $course): ?SessionRelCourse { $criteria = Criteria::create()->where(Criteria::expr()->eq('course', $course)); + return $this->courses->matching($criteria)->current(); } /** @@ -613,7 +655,7 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable * If user status in session is student, then increase number of course users. * Status example: Session::STUDENT. */ - public function addUserInCourse(int $status, User $user, Course $course) : SessionRelCourseRelUser + public function addUserInCourse(int $status, User $user, Course $course): SessionRelCourseRelUser { $userRelCourseRelSession = (new SessionRelCourseRelUser())->setCourse($course)->setUser($user)->setSession($this)->setStatus($status); $this->addSessionRelCourseRelUser($userRelCourseRelSession); @@ -621,42 +663,47 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable $sessionCourse = $this->getCourseSubscription($course); $sessionCourse->setNbrUsers($sessionCourse->getNbrUsers() + 1); } + return $userRelCourseRelSession; } - public function hasUserCourseSubscription(SessionRelCourseRelUser $subscription) : bool + public function hasUserCourseSubscription(SessionRelCourseRelUser $subscription): bool { if (0 !== $this->getSessionRelCourseRelUsers()->count()) { $criteria = Criteria::create()->where(Criteria::expr()->eq('user', $subscription->getUser()))->andWhere(Criteria::expr()->eq('course', $subscription->getCourse()))->andWhere(Criteria::expr()->eq('session', $subscription->getSession())); $relation = $this->getSessionRelCourseRelUsers()->matching($criteria); + return $relation->count() > 0; } + return false; } /** * currentCourse is set in CourseListener. */ - public function getCurrentCourse() : ?Course + public function getCurrentCourse(): ?Course { return $this->currentCourse; } /** * currentCourse is set in CourseListener. */ - public function setCurrentCourse(Course $course) : self + public function setCurrentCourse(Course $course): self { // If the session is registered in the course session list. - $exists = $this->getCourses()->exists(fn($key, $element) => $course->getId() === $element->getCourse()->getId()); + $exists = $this->getCourses()->exists(fn ($key, $element) => $course->getId() === $element->getCourse()->getId()); if ($exists) { $this->currentCourse = $course; } + return $this; } - public function setSendSubscriptionNotification(bool $sendNotification) : self + public function setSendSubscriptionNotification(bool $sendNotification): self { $this->sendSubscriptionNotification = $sendNotification; + return $this; } - public function getSendSubscriptionNotification() : bool + public function getSendSubscriptionNotification(): bool { return $this->sendSubscriptionNotification; } @@ -665,24 +712,27 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable * * @return ArrayCollection|Collection */ - public function getSessionRelCourseRelUsersByStatus(Course $course, int $status) : \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection + public function getSessionRelCourseRelUsersByStatus(Course $course, int $status): ArrayCollection|Collection { $criteria = Criteria::create()->where(Criteria::expr()->eq('course', $course))->andWhere(Criteria::expr()->eq('status', $status)); + return $this->sessionRelCourseRelUsers->matching($criteria); } - public function getIssuedSkills() : Collection + public function getIssuedSkills(): Collection { return $this->issuedSkills; } - public function setCurrentUrl(AccessUrl $url) : self + public function setCurrentUrl(AccessUrl $url): self { $urlList = $this->getUrls(); foreach ($urlList as $item) { if ($item->getUrl()->getId() === $url->getId()) { $this->currentUrl = $url; + break; } } + return $this; } /** @@ -692,30 +742,33 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable { return $this->currentUrl; } - public function getUrls() : Collection + public function getUrls(): Collection { return $this->urls; } - public function setUrls(Collection $urls) : self + public function setUrls(Collection $urls): self { $this->urls = new ArrayCollection(); foreach ($urls as $url) { $this->addUrls($url); } + return $this; } - public function addAccessUrl(?AccessUrl $url) : self + public function addAccessUrl(?AccessUrl $url): self { $accessUrlRelSession = new AccessUrlRelSession(); $accessUrlRelSession->setUrl($url); $accessUrlRelSession->setSession($this); $this->addUrls($accessUrlRelSession); + return $this; } - public function addUrls(AccessUrlRelSession $url) : self + public function addUrls(AccessUrlRelSession $url): self { $url->setSession($this); $this->urls->add($url); + return $this; } /** @@ -725,77 +778,83 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable { return $this->position; } - public function setPosition(int $position) : self + public function setPosition(int $position): self { $this->position = $position; + return $this; } - public function getStatus() : int + public function getStatus(): int { return $this->status; } - public function setStatus(int $status) : self + public function setStatus(int $status): self { $this->status = $status; + return $this; } - public function getSessionAdmins() : Collection + public function getSessionAdmins(): Collection { - return $this->getGeneralAdminsSubscriptions()->map(fn(SessionRelUser $subscription) => $subscription->getUser()); + return $this->getGeneralAdminsSubscriptions()->map(fn (SessionRelUser $subscription) => $subscription->getUser()); } - public function getGeneralAdminsSubscriptions() : Collection + public function getGeneralAdminsSubscriptions(): Collection { $criteria = Criteria::create()->where(Criteria::expr()->eq('relationType', self::SESSION_ADMIN)); + return $this->users->matching($criteria); } - public function hasUserAsSessionAdmin(User $user) : bool + public function hasUserAsSessionAdmin(User $user): bool { $criteria = Criteria::create()->where(Criteria::expr()->eq('relationType', self::SESSION_ADMIN))->andWhere(Criteria::expr()->eq('user', $user)); + return $this->users->matching($criteria)->count() > 0; } - public function addSessionAdmin(User $sessionAdmin) : self + public function addSessionAdmin(User $sessionAdmin): self { return $this->addUserInSession(self::SESSION_ADMIN, $sessionAdmin); } /** * @return SkillRelCourse[]|Collection */ - public function getSkills() : array|\Doctrine\Common\Collections\Collection + public function getSkills(): array|Collection { return $this->skills; } /** * @return ResourceLink[]|Collection */ - public function getResourceLinks() : array|\Doctrine\Common\Collections\Collection + public function getResourceLinks(): array|Collection { return $this->resourceLinks; } /** * Check if $user is course coach in any course. */ - public function hasCoachInCourseList(User $user) : bool + public function hasCoachInCourseList(User $user): bool { foreach ($this->courses as $sessionCourse) { if ($this->hasCourseCoachInCourse($user, $sessionCourse->getCourse())) { return true; } } + return false; } /** * Check if $user is student in any course. */ - public function hasStudentInCourseList(User $user) : bool + public function hasStudentInCourseList(User $user): bool { foreach ($this->courses as $sessionCourse) { if ($this->hasStudentInCourse($user, $sessionCourse->getCourse())) { return true; } } + return false; } - protected function compareDates(DateTime $start, DateTime $end = null) : bool + protected function compareDates(DateTime $start, DateTime $end = null): bool { $now = new Datetime('now'); if (!empty($start) && !empty($end) && ($now >= $start && $now <= $end)) { @@ -804,6 +863,7 @@ class Session implements ResourceWithAccessUrlInterface, \Stringable if (!empty($start) && $now >= $start) { return true; } + return !empty($end) && $now <= $end; } } diff --git a/src/CoreBundle/Entity/SessionCategory.php b/src/CoreBundle/Entity/SessionCategory.php index aba317695f..81bbcd74fb 100644 --- a/src/CoreBundle/Entity/SessionCategory.php +++ b/src/CoreBundle/Entity/SessionCategory.php @@ -1,30 +1,30 @@ ['session_category:write']], normalizationContext: ['groups' => ['session_category:read']])] #[ORM\Table(name: 'session_category')] #[ORM\Entity] -class SessionCategory implements \Stringable +class SessionCategory implements Stringable { #[Groups(['session_category:read', 'session_rel_user:read'])] #[ORM\Column(name: 'id', type: 'integer', nullable: false)] @@ -48,16 +48,17 @@ class SessionCategory implements \Stringable { $this->sessions = new ArrayCollection(); } - public function __toString() : string + public function __toString(): string { return $this->name; } - public function setUrl(AccessUrl $url) : self + public function setUrl(AccessUrl $url): self { $this->url = $url; + return $this; } - public function getUrl() : AccessUrl + public function getUrl(): AccessUrl { return $this->url; } @@ -70,18 +71,20 @@ class SessionCategory implements \Stringable { return $this->id; } - public function setName(string $name) : self + public function setName(string $name): self { $this->name = $name; + return $this; } - public function getName() : string + public function getName(): string { return $this->name; } - public function setDateStart(DateTime $dateStart) : self + public function setDateStart(DateTime $dateStart): self { $this->dateStart = $dateStart; + return $this; } /** @@ -93,9 +96,10 @@ class SessionCategory implements \Stringable { return $this->dateStart; } - public function setDateEnd(DateTime $dateEnd) : self + public function setDateEnd(DateTime $dateEnd): self { $this->dateEnd = $dateEnd; + return $this; } /** diff --git a/src/CoreBundle/Entity/SessionRelCourse.php b/src/CoreBundle/Entity/SessionRelCourse.php index e63feee321..e4a11187d2 100644 --- a/src/CoreBundle/Entity/SessionRelCourse.php +++ b/src/CoreBundle/Entity/SessionRelCourse.php @@ -1,21 +1,20 @@ id; } - public function setSession(Session $session) : self + public function setSession(Session $session): self { $this->session = $session; + return $this; } - public function getCourse() : Course + public function getCourse(): Course { return $this->course; } - public function setCourse(Course $course) : self + public function setCourse(Course $course): self { $this->course = $course; + return $this; } - public function getSession() : Session + public function getSession(): Session { return $this->session; } - public function setNbrUsers(int $nbrUsers) : self + public function setNbrUsers(int $nbrUsers): self { $this->nbrUsers = $nbrUsers; + return $this; } - public function getNbrUsers() : int + public function getNbrUsers(): int { return $this->nbrUsers; } - public function getPosition() : int + public function getPosition(): int { return $this->position; } - public function setPosition(int $position) : void + public function setPosition(int $position): void { $this->position = $position; } diff --git a/src/CoreBundle/Entity/SessionRelCourseRelUser.php b/src/CoreBundle/Entity/SessionRelCourseRelUser.php index 6a7b11ab5f..b1b5dcd566 100644 --- a/src/CoreBundle/Entity/SessionRelCourseRelUser.php +++ b/src/CoreBundle/Entity/SessionRelCourseRelUser.php @@ -1,27 +1,21 @@ legalAgreement = 0; $this->status = Session::STUDENT; } - public function getSession() : Session + public function getSession(): Session { return $this->session; } - public function setSession(Session $session) : self + public function setSession(Session $session): self { $this->session = $session; + return $this; } - public function getCourse() : Course + public function getCourse(): Course { return $this->course; } - public function setCourse(Course $course) : self + public function setCourse(Course $course): self { $this->course = $course; + return $this; } - public function getId() : ?int + public function getId(): ?int { return $this->id; } - public function setVisibility(int $visibility) : self + public function setVisibility(int $visibility): self { $this->visibility = $visibility; + return $this; } - public function getVisibility() : int + public function getVisibility(): int { return $this->visibility; } - public function setStatus(int $status) : self + public function setStatus(int $status): self { $this->status = $status; + return $this; } - public function getStatus() : int + public function getStatus(): int { return $this->status; } - public function setLegalAgreement(int $legalAgreement) : self + public function setLegalAgreement(int $legalAgreement): self { $this->legalAgreement = $legalAgreement; + return $this; } - public function getLegalAgreement() : int + public function getLegalAgreement(): int { return $this->legalAgreement; } - public function getProgress() : int + public function getProgress(): int { return $this->progress; } - public function setProgress(int $progress) : self + public function setProgress(int $progress): self { $this->progress = $progress; + return $this; } } diff --git a/src/CoreBundle/Entity/SessionRelUser.php b/src/CoreBundle/Entity/SessionRelUser.php index 4ab4f86b80..67564a2c0c 100644 --- a/src/CoreBundle/Entity/SessionRelUser.php +++ b/src/CoreBundle/Entity/SessionRelUser.php @@ -1,19 +1,18 @@ movedStatus = null; $this->registeredAt = new DateTime('now', new DateTimeZone('UTC')); } - public function getCourses() : Collection + public function getCourses(): Collection { return $this->session->getSessionRelCourseByUser($this->getUser()); } - public function getId() : ?int + public function getId(): ?int { return $this->id; } - public function setSession(?Session $session) : self + public function setSession(?Session $session): self { $this->session = $session; + return $this; } - public function getSession() : ?Session + public function getSession(): ?Session { return $this->session; } - public function setRelationType(int $relationType) : self + public function setRelationType(int $relationType): self { $this->relationType = $relationType; + return $this; } - public function getRelationType() : int + public function getRelationType(): int { return $this->relationType; } - public function setMovedTo(int $movedTo) : self + public function setMovedTo(int $movedTo): self { $this->movedTo = $movedTo; + return $this; } /** @@ -113,9 +116,10 @@ class SessionRelUser { return $this->movedTo; } - public function setMovedStatus(int $movedStatus) : self + public function setMovedStatus(int $movedStatus): self { $this->movedStatus = $movedStatus; + return $this; } /** @@ -127,9 +131,10 @@ class SessionRelUser { return $this->movedStatus; } - public function setMovedAt(DateTime $movedAt) : self + public function setMovedAt(DateTime $movedAt): self { $this->movedAt = $movedAt; + return $this; } /** @@ -141,9 +146,10 @@ class SessionRelUser { return $this->movedAt; } - public function setRegisteredAt(DateTime $registeredAt) : self + public function setRegisteredAt(DateTime $registeredAt): self { $this->registeredAt = $registeredAt; + return $this; } /** @@ -162,19 +168,21 @@ class SessionRelUser { return $this->duration; } - public function setDuration(int $duration) : self + public function setDuration(int $duration): self { $this->duration = $duration; + return $this; } - public function getUser() : User + public function getUser(): User { return $this->user; } - public function setUser(User $user) : self + public function setUser(User $user): self { $user->addSessionRelUser($this); $this->user = $user; + return $this; } } diff --git a/src/CoreBundle/Entity/Skill.php b/src/CoreBundle/Entity/Skill.php index df07fd67b6..81c7d29083 100644 --- a/src/CoreBundle/Entity/Skill.php +++ b/src/CoreBundle/Entity/Skill.php @@ -1,31 +1,26 @@ ['skill:read']])] #[ORM\Table(name: 'skill')] #[ORM\Entity(repositoryClass: \Chamilo\CoreBundle\Repository\SkillRepository::class)] -class Skill implements \Stringable +class Skill implements Stringable { public const STATUS_DISABLED = 0; public const STATUS_ENABLED = 1; @@ -99,34 +94,37 @@ class Skill implements \Stringable $this->description = ''; $this->status = self::STATUS_ENABLED; } - public function __toString() : string + public function __toString(): string { return $this->getName(); } - public function setName(string $name) : self + public function setName(string $name): self { $this->name = $name; + return $this; } - public function getName() : string + public function getName(): string { return $this->name; } - public function getShortCode() : string + public function getShortCode(): string { return $this->shortCode; } - public function setShortCode(string $shortCode) : self + public function setShortCode(string $shortCode): self { $this->shortCode = $shortCode; + return $this; } - public function setDescription(string $description) : self + public function setDescription(string $description): self { $this->description = $description; + return $this; } - public function getDescription() : string + public function getDescription(): string { return $this->description; } @@ -138,6 +136,7 @@ class Skill implements \Stringable public function setAccessUrlId(int $accessUrlId) { $this->accessUrlId = $accessUrlId; + return $this; } /** @@ -149,9 +148,10 @@ class Skill implements \Stringable { return $this->accessUrlId; } - public function setIcon(string $icon) : self + public function setIcon(string $icon): self { $this->icon = $icon; + return $this; } /** @@ -163,9 +163,10 @@ class Skill implements \Stringable { return $this->icon; } - public function setCriteria(string $criteria) : self + public function setCriteria(string $criteria): self { $this->criteria = $criteria; + return $this; } /** @@ -177,9 +178,10 @@ class Skill implements \Stringable { return $this->criteria; } - public function setStatus(int $status) : self + public function setStatus(int $status): self { $this->status = $status; + return $this; } /** @@ -201,6 +203,7 @@ class Skill implements \Stringable public function setUpdatedAt(DateTime $updatedAt) { $this->updatedAt = $updatedAt; + return $this; } /** @@ -228,9 +231,10 @@ class Skill implements \Stringable { return $this->profile; } - public function setProfile(Profile $profile) : self + public function setProfile(Profile $profile): self { $this->profile = $profile; + return $this; } /** @@ -249,12 +253,13 @@ class Skill implements \Stringable { return $this->items; } - public function setItems(ArrayCollection $items) : self + public function setItems(ArrayCollection $items): self { $this->items = $items; + return $this; } - public function hasItem(int $typeId, int $itemId) : bool + public function hasItem(int $typeId, int $itemId): bool { if (0 !== $this->getItems()->count()) { $found = false; @@ -262,14 +267,17 @@ class Skill implements \Stringable foreach ($this->getItems() as $item) { if ($item->getItemId() === $itemId && $item->getItemType() === $typeId) { $found = true; + break; } } + return $found; } + return false; } - public function addItem(SkillRelItem $skillRelItem) : void + public function addItem(SkillRelItem $skillRelItem): void { $skillRelItem->setSkill($this); $this->items[] = $skillRelItem; @@ -281,55 +289,59 @@ class Skill implements \Stringable { return $this->courses; } - public function setCourses(ArrayCollection $courses) : self + public function setCourses(ArrayCollection $courses): self { $this->courses = $courses; + return $this; } /** * @return SkillRelSkill[]|Collection */ - public function getSkills() : array|\Doctrine\Common\Collections\Collection + public function getSkills(): array|Collection { return $this->skills; } /** * @param SkillRelSkill[]|Collection $skills */ - public function setSkills(array|\Doctrine\Common\Collections\Collection $skills) : self + public function setSkills(array|Collection $skills): self { $this->skills = $skills; + return $this; } /** * @return SkillRelGradebook[]|Collection */ - public function getGradeBookCategories() : array|\Doctrine\Common\Collections\Collection + public function getGradeBookCategories(): array|Collection { return $this->gradeBookCategories; } /** * @param SkillRelGradebook[]|Collection $gradeBookCategories */ - public function setGradeBookCategories(array|\Doctrine\Common\Collections\Collection $gradeBookCategories) : self + public function setGradeBookCategories(array|Collection $gradeBookCategories): self { $this->gradeBookCategories = $gradeBookCategories; + return $this; } - public function hasAsset() : bool + public function hasAsset(): bool { return null !== $this->asset; } - public function getAsset() : ?Asset + public function getAsset(): ?Asset { return $this->asset; } - public function setAsset(?Asset $asset) : self + public function setAsset(?Asset $asset): self { $this->asset = $asset; + return $this; } - public function hasCourseAndSession(SkillRelCourse $searchItem) : bool + public function hasCourseAndSession(SkillRelCourse $searchItem): bool { if (0 !== $this->getCourses()->count()) { $found = false; @@ -344,14 +356,17 @@ class Skill implements \Stringable } if ($item->getCourse()->getId() === $searchItem->getCourse()->getId() && $sessionPassFilter) { $found = true; + break; } } + return $found; } + return false; } - public function addToCourse(SkillRelCourse $item) : void + public function addToCourse(SkillRelCourse $item): void { $item->setSkill($this); $this->courses[] = $item; diff --git a/src/CoreBundle/Entity/SocialPost.php b/src/CoreBundle/Entity/SocialPost.php index 9b8a61a8cd..6287869498 100644 --- a/src/CoreBundle/Entity/SocialPost.php +++ b/src/CoreBundle/Entity/SocialPost.php @@ -2,21 +2,19 @@ /* For licensing terms, see /license.txt */ -declare (strict_types=1); +declare(strict_types=1); namespace Chamilo\CoreBundle\Entity; -use ApiPlatform\Metadata\GetCollection; -use ApiPlatform\Metadata\Post; -use ApiPlatform\Metadata\Delete; -use ApiPlatform\Metadata\Put; -use ApiPlatform\Metadata\Get; -use ApiPlatform\Metadata\ApiResource; -use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Metadata\ApiFilter; -use ApiPlatform\Core\Bridge\Doctrine\Common\Filter\SearchFilterInterface; +use ApiPlatform\Metadata\ApiResource; +use ApiPlatform\Metadata\Delete; +use ApiPlatform\Metadata\Get; +use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\Post; +use ApiPlatform\Metadata\Put; use Chamilo\CoreBundle\Controller\Api\DislikeSocialPostController; use Chamilo\CoreBundle\Controller\Api\LikeSocialPostController; use Chamilo\CoreBundle\Filter\SocialWallFilter; @@ -29,6 +27,7 @@ use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; + #[ApiResource(operations: [new Get(security: 'is_granted(\'VIEW\', object)'), new Put(security: 'is_granted(\'EDIT\', object)'), new Delete(security: 'is_granted(\'DELETE\', object)'), new Post(uriTemplate: '/social_posts/{id}/like', controller: LikeSocialPostController::class, denormalizationContext: ['groups' => []], normalizationContext: ['groups' => ['social_post_feedback']], security: 'is_granted(\'ROLE_USER\')'), new Post(uriTemplate: '/social_posts/{id}/dislike', controller: DislikeSocialPostController::class, denormalizationContext: ['groups' => []], normalizationContext: ['groups' => ['social_post_feedback']], security: 'is_granted(\'ROLE_USER\')'), new GetCollection(security: 'is_granted(\'ROLE_USER\')'), new Post(securityPostDenormalize: 'is_granted(\'CREATE\', object)')], security: 'is_granted(\'ROLE_USER\')', denormalizationContext: ['groups' => ['social_post:write']], normalizationContext: ['groups' => ['social_post:read']])] #[ORM\Table(name: 'social_post')] #[ORM\Index(name: 'idx_social_post_sender', columns: ['sender_id'])] @@ -64,10 +63,10 @@ class SocialPost #[ORM\Column(type: 'text')] protected string $content; #[Groups(['social_post:write', 'social_post:read'])] - #[Assert\Choice([SocialPost::TYPE_WALL_POST, SocialPost::TYPE_WALL_COMMENT, SocialPost::TYPE_GROUP_MESSAGE, SocialPost::TYPE_PROMOTED_MESSAGE], message: 'Choose a valid type.')] + #[Assert\Choice([self::TYPE_WALL_POST, self::TYPE_WALL_COMMENT, self::TYPE_GROUP_MESSAGE, self::TYPE_PROMOTED_MESSAGE], message: 'Choose a valid type.')] #[ORM\Column(type: 'smallint')] protected int $type; - #[Assert\Choice([SocialPost::STATUS_SENT, SocialPost::STATUS_DELETED], message: 'Choose a status.')] + #[Assert\Choice([self::STATUS_SENT, self::STATUS_DELETED], message: 'Choose a status.')] #[ORM\Column(type: 'smallint')] protected int $status; #[Groups(['social_post:read'])] @@ -82,10 +81,10 @@ class SocialPost #[ORM\ManyToOne(targetEntity: Usergroup::class)] #[ORM\JoinColumn(onDelete: 'CASCADE')] protected ?Usergroup $groupReceiver = null; - #[ORM\OneToMany(targetEntity: SocialPost::class, mappedBy: 'parent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] protected Collection $children; #[Groups(['social_post:write'])] - #[ORM\ManyToOne(targetEntity: SocialPost::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', onDelete: 'CASCADE')] protected ?SocialPost $parent; #[Groups(['social_post:read', 'social_post_feedback'])] @@ -107,145 +106,161 @@ class SocialPost $this->countFeedbackLikes = 0; $this->countFeedbackDislikes = 0; } - public function getId() : int + public function getId(): int { return $this->id; } - public function setId(int $id) : self + public function setId(int $id): self { $this->id = $id; + return $this; } - public function getSender() : User + public function getSender(): User { return $this->sender; } - public function setSender(User $sender) : self + public function setSender(User $sender): self { $this->sender = $sender; + return $this; } - public function getUserReceiver() : ?User + public function getUserReceiver(): ?User { return $this->userReceiver; } - public function setUserReceiver(?User $userReceiver) : self + public function setUserReceiver(?User $userReceiver): self { $this->userReceiver = $userReceiver; + return $this; } - public function getStatus() : int + public function getStatus(): int { return $this->status; } - public function setStatus(int $status) : self + public function setStatus(int $status): self { $this->status = $status; + return $this; } - public function getSendDate() : DateTime + public function getSendDate(): DateTime { return $this->sendDate; } - public function setSendDate(DateTime $sendDate) : self + public function setSendDate(DateTime $sendDate): self { $this->sendDate = $sendDate; + return $this; } - public function getSubject() : ?string + public function getSubject(): ?string { return $this->subject; } - public function setSubject(?string $subject) : self + public function setSubject(?string $subject): self { $this->subject = $subject; + return $this; } - public function getContent() : string + public function getContent(): string { return $this->content; } - public function setContent(string $content) : self + public function setContent(string $content): self { $this->content = $content; + return $this; } - public function getUpdatedAt() : DateTime + public function getUpdatedAt(): DateTime { return $this->updatedAt; } - public function setUpdatedAt(DateTime $updatedAt) : self + public function setUpdatedAt(DateTime $updatedAt): self { $this->updatedAt = $updatedAt; + return $this; } - public function getFeedbacks() : Collection + public function getFeedbacks(): Collection { return $this->feedbacks; } - public function setFeedbacks(Collection $feedbacks) : self + public function setFeedbacks(Collection $feedbacks): self { $this->feedbacks = $feedbacks; + return $this; } - public function addFeedback(SocialPostFeedback $feedback) : self + public function addFeedback(SocialPostFeedback $feedback): self { if (!$this->feedbacks->contains($feedback)) { $this->feedbacks[] = $feedback; $feedback->setSocialPost($this); } + return $this; } - public function getCountFeedbackLikes() : int + public function getCountFeedbackLikes(): int { $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('liked', true)); + return $this->feedbacks->matching($criteria)->count(); } - public function getCountFeedbackDislikes() : int + public function getCountFeedbackDislikes(): int { $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('disliked', true)); + return $this->feedbacks->matching($criteria)->count(); } - public function getParent() : ?self + public function getParent(): ?self { return $this->parent; } - public function setParent(self $parent = null) : self + public function setParent(self $parent = null): self { $this->parent = $parent; + return $this; } /** * @return Collection */ - public function getChildren() : Collection + public function getChildren(): Collection { return $this->children; } - public function addChild(self $child) : self + public function addChild(self $child): self { $this->children[] = $child; $child->setParent($this); + return $this; } - public function getGroupReceiver() : ?Usergroup + public function getGroupReceiver(): ?Usergroup { return $this->groupReceiver; } - public function setGroupReceiver(?Usergroup $groupReceiver) : self + public function setGroupReceiver(?Usergroup $groupReceiver): self { $this->groupReceiver = $groupReceiver; + return $this; } - public function getType() : int + public function getType(): int { return $this->type; } - public function setType(int $type) : self + public function setType(int $type): self { $this->type = $type; + return $this; } } diff --git a/src/CoreBundle/Entity/SysAnnouncement.php b/src/CoreBundle/Entity/SysAnnouncement.php index f800828212..10f8bfd89f 100644 --- a/src/CoreBundle/Entity/SysAnnouncement.php +++ b/src/CoreBundle/Entity/SysAnnouncement.php @@ -46,7 +46,6 @@ class SysAnnouncement /** * An array of roles. Example: ROLE_USER, ROLE_TEACHER, ROLE_ADMIN. * - * * @var string[] */ #[ORM\Column(type: 'array')] diff --git a/src/CoreBundle/Entity/SystemTemplate.php b/src/CoreBundle/Entity/SystemTemplate.php index 32ac71cf02..eecb404bf3 100644 --- a/src/CoreBundle/Entity/SystemTemplate.php +++ b/src/CoreBundle/Entity/SystemTemplate.php @@ -32,6 +32,9 @@ class SystemTemplate #[ORM\Column(name: 'content', type: 'text', nullable: false)] protected string $content; + #[ORM\Column(name: 'language', type: 'string', length: 40, nullable: true)] + protected string $language; + public function __construct() { $this->comment = ''; @@ -114,4 +117,22 @@ class SystemTemplate { return $this->id; } + + /** + * @return string + */ + public function getLanguage(): string + { + return $this->language; + } + + /** + * @param string $language + */ + public function setLanguage(string $language): self + { + $this->language = $language; + + return $this; + } } diff --git a/src/CoreBundle/Entity/TicketMessageAttachment.php b/src/CoreBundle/Entity/TicketMessageAttachment.php index c8c72c87a7..85c850440c 100644 --- a/src/CoreBundle/Entity/TicketMessageAttachment.php +++ b/src/CoreBundle/Entity/TicketMessageAttachment.php @@ -8,10 +8,11 @@ namespace Chamilo\CoreBundle\Entity; use DateTime; use Doctrine\ORM\Mapping as ORM; +use Stringable; #[ORM\Table(name: 'ticket_message_attachments')] #[ORM\Entity] -class TicketMessageAttachment extends AbstractResource implements ResourceInterface, \Stringable +class TicketMessageAttachment extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] diff --git a/src/CoreBundle/Entity/Tool.php b/src/CoreBundle/Entity/Tool.php index 4a20a5e37c..ca6ed03d34 100644 --- a/src/CoreBundle/Entity/Tool.php +++ b/src/CoreBundle/Entity/Tool.php @@ -10,6 +10,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; @@ -18,7 +19,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'tool')] #[ORM\Entity] -class Tool implements \Stringable +class Tool implements Stringable { #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] diff --git a/src/CoreBundle/Entity/ToolResourceRight.php b/src/CoreBundle/Entity/ToolResourceRight.php index ea322a787c..97b5426d38 100644 --- a/src/CoreBundle/Entity/ToolResourceRight.php +++ b/src/CoreBundle/Entity/ToolResourceRight.php @@ -8,13 +8,14 @@ namespace Chamilo\CoreBundle\Entity; use Chamilo\CoreBundle\Security\Authorization\Voter\ResourceNodeVoter; use Doctrine\ORM\Mapping as ORM; +use Stringable; /** * ToolResourceRight. */ #[ORM\Table(name: 'tool_resource_right')] #[ORM\Entity] -class ToolResourceRight implements \Stringable +class ToolResourceRight implements Stringable { #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] @@ -31,9 +32,6 @@ class ToolResourceRight implements \Stringable #[ORM\JoinColumn(name: 'tool_id', referencedColumnName: 'id')] protected ?Tool $tool = null; - /** - * @return string - */ public function __toString(): string { return (string) $this->getMask(); diff --git a/src/CoreBundle/Entity/TrackCourseRanking.php b/src/CoreBundle/Entity/TrackCourseRanking.php index 39865a693c..b4c95bbfbf 100644 --- a/src/CoreBundle/Entity/TrackCourseRanking.php +++ b/src/CoreBundle/Entity/TrackCourseRanking.php @@ -1,6 +1,6 @@ teacherComment = ''; $this->secondsSpent = 0; } - public function setQuestionId(int $questionId) : self + public function setQuestionId(int $questionId): self { $this->questionId = $questionId; + return $this; } /** @@ -98,9 +99,10 @@ class TrackEAttempt { return $this->questionId; } - public function setAnswer(string $answer) : self + public function setAnswer(string $answer): self { $this->answer = $answer; + return $this; } /** @@ -112,9 +114,10 @@ class TrackEAttempt { return $this->answer; } - public function setTeacherComment(string $teacherComment) : self + public function setTeacherComment(string $teacherComment): self { $this->teacherComment = $teacherComment; + return $this; } /** @@ -126,9 +129,10 @@ class TrackEAttempt { return $this->teacherComment; } - public function setMarks(float $marks) : self + public function setMarks(float $marks): self { $this->marks = $marks; + return $this; } /** @@ -140,9 +144,10 @@ class TrackEAttempt { return $this->marks; } - public function setPosition(int $position) : self + public function setPosition(int $position): self { $this->position = $position; + return $this; } /** @@ -154,9 +159,10 @@ class TrackEAttempt { return $this->position; } - public function setTms(DateTime $tms) : self + public function setTms(DateTime $tms): self { $this->tms = $tms; + return $this; } /** @@ -176,6 +182,7 @@ class TrackEAttempt public function setFilename(string $filename) { $this->filename = $filename; + return $this; } /** @@ -196,77 +203,84 @@ class TrackEAttempt { return $this->id; } - public function getUser() : User + public function getUser(): User { return $this->user; } - public function setUser(User $user) : self + public function setUser(User $user): self { $this->user = $user; + return $this; } - public function getTrackEExercise() : TrackEExercise + public function getTrackEExercise(): TrackEExercise { return $this->trackExercise; } - public function setTrackEExercise(TrackEExercise $trackExercise) : self + public function setTrackEExercise(TrackEExercise $trackExercise): self { $this->trackExercise = $trackExercise; + return $this; } - public function getSecondsSpent() : int + public function getSecondsSpent(): int { return $this->secondsSpent; } - public function setSecondsSpent(int $secondsSpent) : self + public function setSecondsSpent(int $secondsSpent): self { $this->secondsSpent = $secondsSpent; + return $this; } /** * @return AttemptFile[]|Collection */ - public function getAttemptFiles() : array|\Doctrine\Common\Collections\Collection + public function getAttemptFiles(): array|Collection { return $this->attemptFiles; } /** * @param AttemptFile[]|Collection $attemptFiles */ - public function setAttemptFiles(array|\Doctrine\Common\Collections\Collection $attemptFiles) : self + public function setAttemptFiles(array|Collection $attemptFiles): self { $this->attemptFiles = $attemptFiles; + return $this; } /** * @return AttemptFeedback[]|Collection */ - public function getAttemptFeedbacks() : array|\Doctrine\Common\Collections\Collection + public function getAttemptFeedbacks(): array|Collection { return $this->attemptFeedbacks; } /** * @param AttemptFeedback[]|Collection $attemptFeedbacks */ - public function setAttemptFeedbacks(array|\Doctrine\Common\Collections\Collection $attemptFeedbacks) : self + public function setAttemptFeedbacks(array|Collection $attemptFeedbacks): self { $this->attemptFeedbacks = $attemptFeedbacks; + return $this; } - public function addAttemptFeedback(AttemptFeedback $attemptFeedback) : self + public function addAttemptFeedback(AttemptFeedback $attemptFeedback): self { if (!$this->attemptFeedbacks->contains($attemptFeedback)) { $this->attemptFeedbacks[] = $attemptFeedback; $attemptFeedback->setAttempt($this); } + return $this; } - public function addAttemptFile(AttemptFile $attemptFile) : self + public function addAttemptFile(AttemptFile $attemptFile): self { if (!$this->attemptFiles->contains($attemptFile)) { $this->attemptFiles[] = $attemptFile; $attemptFile->setAttempt($this); } + return $this; } } diff --git a/src/CoreBundle/Entity/TrackECourseAccess.php b/src/CoreBundle/Entity/TrackECourseAccess.php index 33150d9996..61ecf8c6f4 100644 --- a/src/CoreBundle/Entity/TrackECourseAccess.php +++ b/src/CoreBundle/Entity/TrackECourseAccess.php @@ -107,10 +107,7 @@ class TrackECourseAccess return $this; } - /** - * Get logoutCourseDate. - */ - public function getLogoutCourseDate(): ?\DateTime + public function getLogoutCourseDate(): ?DateTime { return $this->logoutCourseDate; } diff --git a/src/CoreBundle/Entity/TrackEExercise.php b/src/CoreBundle/Entity/TrackEExercise.php index a3c872e61e..85f9671a73 100644 --- a/src/CoreBundle/Entity/TrackEExercise.php +++ b/src/CoreBundle/Entity/TrackEExercise.php @@ -1,18 +1,17 @@ exeDate = new DateTime(); $this->startDate = new DateTime(); } - public function setExeDate(DateTime $exeDate) : self + public function setExeDate(DateTime $exeDate): self { $this->exeDate = $exeDate; + return $this; } /** @@ -145,18 +146,20 @@ class TrackEExercise { return $this->exeDate; } - public function setQuiz(CQuiz $cQuiz) : self + public function setQuiz(CQuiz $cQuiz): self { $this->quiz = $cQuiz; + return $this; } - public function getQuiz() : ?CQuiz + public function getQuiz(): ?CQuiz { return $this->quiz; } - public function setUserIp(string $userIp) : self + public function setUserIp(string $userIp): self { $this->userIp = $userIp; + return $this; } /** @@ -168,9 +171,10 @@ class TrackEExercise { return $this->userIp; } - public function setStatus(string $status) : self + public function setStatus(string $status): self { $this->status = $status; + return $this; } /** @@ -182,9 +186,10 @@ class TrackEExercise { return $this->status; } - public function setDataTracking(string $dataTracking) : self + public function setDataTracking(string $dataTracking): self { $this->dataTracking = $dataTracking; + return $this; } /** @@ -196,9 +201,10 @@ class TrackEExercise { return $this->dataTracking; } - public function setStartDate(DateTime $startDate) : self + public function setStartDate(DateTime $startDate): self { $this->startDate = $startDate; + return $this; } /** @@ -210,9 +216,10 @@ class TrackEExercise { return $this->startDate; } - public function setStepsCounter(int $stepsCounter) : self + public function setStepsCounter(int $stepsCounter): self { $this->stepsCounter = $stepsCounter; + return $this; } /** @@ -224,9 +231,10 @@ class TrackEExercise { return $this->stepsCounter; } - public function setOrigLpId(int $origLpId) : self + public function setOrigLpId(int $origLpId): self { $this->origLpId = $origLpId; + return $this; } /** @@ -238,9 +246,10 @@ class TrackEExercise { return $this->origLpId; } - public function setOrigLpItemId(int $origLpItemId) : self + public function setOrigLpItemId(int $origLpItemId): self { $this->origLpItemId = $origLpItemId; + return $this; } /** @@ -252,9 +261,10 @@ class TrackEExercise { return $this->origLpItemId; } - public function setExeDuration(int $exeDuration) : self + public function setExeDuration(int $exeDuration): self { $this->exeDuration = $exeDuration; + return $this; } /** @@ -266,18 +276,20 @@ class TrackEExercise { return $this->exeDuration; } - public function setExpiredTimeControl(?DateTime $expiredTimeControl) : self + public function setExpiredTimeControl(?DateTime $expiredTimeControl): self { $this->expiredTimeControl = $expiredTimeControl; + return $this; } - public function getExpiredTimeControl() : ?DateTime + public function getExpiredTimeControl(): ?DateTime { return $this->expiredTimeControl; } - public function setOrigLpItemViewId(int $origLpItemViewId) : self + public function setOrigLpItemViewId(int $origLpItemViewId): self { $this->origLpItemViewId = $origLpItemViewId; + return $this; } /** @@ -289,9 +301,10 @@ class TrackEExercise { return $this->origLpItemViewId; } - public function setQuestionsToCheck(string $questionsToCheck) : self + public function setQuestionsToCheck(string $questionsToCheck): self { $this->questionsToCheck = $questionsToCheck; + return $this; } /** @@ -312,75 +325,82 @@ class TrackEExercise { return $this->exeId; } - public function getScore() : float + public function getScore(): float { return $this->score; } - public function setScore(float $score) : self + public function setScore(float $score): self { $this->score = $score; + return $this; } - public function getMaxScore() : float + public function getMaxScore(): float { return $this->maxScore; } - public function setMaxScore(float $maxScore) : self + public function setMaxScore(float $maxScore): self { $this->maxScore = $maxScore; + return $this; } - public function getUser() : User + public function getUser(): User { return $this->user; } - public function setUser(User $user) : self + public function setUser(User $user): self { $this->user = $user; + return $this; } - public function getCourse() : Course + public function getCourse(): Course { return $this->course; } - public function setCourse(Course $course) : self + public function setCourse(Course $course): self { $this->course = $course; + return $this; } /** * @return TrackEAttempt[]|Collection */ - public function getAttempts() : array|\Doctrine\Common\Collections\Collection + public function getAttempts(): array|Collection { return $this->attempts; } /** * @param TrackEAttempt[]|Collection $attempts */ - public function setAttempts(array|\Doctrine\Common\Collections\Collection $attempts) : self + public function setAttempts(array|Collection $attempts): self { $this->attempts = $attempts; + return $this; } - public function addAttempt(TrackEAttempt $attempt) : self + public function addAttempt(TrackEAttempt $attempt): self { if (!$this->attempts->contains($attempt)) { $this->attempts[] = $attempt; $attempt->setTrackEExercise($this); } + return $this; } - public function getSession() : ?Session + public function getSession(): ?Session { return $this->session; } - public function setSession(?Session $session) : self + public function setSession(?Session $session): self { $this->session = $session; + return $this; } - public function getAttemptByQuestionId(int $questionId) : ?TrackEAttempt + public function getAttemptByQuestionId(int $questionId): ?TrackEAttempt { $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('questionId', $questionId))->setMaxResults(1); @@ -389,6 +409,7 @@ class TrackEExercise if (!empty($attempt)) { return $attempt; } + return null; } } diff --git a/src/CoreBundle/Entity/TrackELogin.php b/src/CoreBundle/Entity/TrackELogin.php index 46372e7a86..128ae8f4fd 100644 --- a/src/CoreBundle/Entity/TrackELogin.php +++ b/src/CoreBundle/Entity/TrackELogin.php @@ -89,10 +89,7 @@ class TrackELogin return $this; } - /** - * Get logoutDate. - */ - public function getLogoutDate(): ?\DateTime + public function getLogoutDate(): ?DateTime { return $this->logoutDate; } diff --git a/src/CoreBundle/Entity/User.php b/src/CoreBundle/Entity/User.php index fffb819127..707c69ef5c 100644 --- a/src/CoreBundle/Entity/User.php +++ b/src/CoreBundle/Entity/User.php @@ -1,21 +1,21 @@ ['user:read']], denormalizationContext: ['groups' => ['user:write']], @@ -64,7 +65,7 @@ use UserManager; #[ORM\EntityListeners([UserListener::class])] #[ApiFilter(filterClass: SearchFilter::class, properties: ['username' => 'partial', 'firstname' => 'partial', 'lastname' => 'partial'])] #[ApiFilter(filterClass: BooleanFilter::class, properties: ['isActive'])] -class User implements UserInterface, EquatableInterface, ResourceInterface, ResourceIllustrationInterface, PasswordAuthenticatedUserInterface, LegacyPasswordAuthenticatedUserInterface, ExtraFieldItemInterface, \Stringable +class User implements UserInterface, EquatableInterface, ResourceInterface, ResourceIllustrationInterface, PasswordAuthenticatedUserInterface, LegacyPasswordAuthenticatedUserInterface, ExtraFieldItemInterface, Stringable { use TimestampableEntity; use UserCreatorTrait; @@ -83,7 +84,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso public ?ResourceNode $resourceNode = null; /** * Resource illustration URL - Property set by ResourceNormalizer.php. - * */ #[ApiProperty(iris: ['http://schema.org/contentUrl'])] #[Groups(['user_export', 'user:read', 'resource_node:read', 'document:read', 'media_object_read', 'course:read', 'course_rel_user:read', 'user_json:read', 'message:read', 'user_rel_user:read', 'social_post:read'])] @@ -99,8 +99,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso protected string $username; #[ORM\Column(name: 'api_token', type: 'string', unique: true, nullable: true)] protected ?string $apiToken = null; - /** - */ + #[ApiProperty(iris: ['http://schema.org/name'])] #[Assert\NotBlank] #[Groups(['user:read', 'user:write', 'resource_node:read', 'user_json:read'])] @@ -193,7 +192,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso /** * An array of roles. Example: ROLE_USER, ROLE_TEACHER, ROLE_ADMIN. * - * * @var mixed[]|string[] */ #[Groups(['user:read', 'user:write', 'user_json:read'])] @@ -202,7 +200,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso #[ORM\Column(name: 'profile_completed', type: 'boolean', nullable: true)] protected ?bool $profileCompleted = null; /** - * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\JuryMembers", mappedBy="user") + * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\JuryMembers", mappedBy="user"). */ //protected $jurySubscriptions; /** @@ -510,11 +508,11 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso $this->receivedSocialPosts = new ArrayCollection(); $this->socialPostsFeedbacks = new ArrayCollection(); } - public function __toString() : string + public function __toString(): string { return $this->username; } - public static function getPasswordConstraints() : array + public static function getPasswordConstraints(): array { return [ new Assert\Length(['min' => 5]), @@ -529,7 +527,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso new Assert\Regex(['pattern' => '/[0-9]{2}/', 'htmlPattern' => '/[0-9]{2}/']), ]; } - public static function loadValidatorMetadata(ClassMetadata $metadata) : void + public static function loadValidatorMetadata(ClassMetadata $metadata): void { //$metadata->addPropertyConstraint('firstname', new Assert\NotBlank()); //$metadata->addPropertyConstraint('lastname', new Assert\NotBlank()); @@ -552,47 +550,51 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso )) );*/ } - public function getUuid() : UuidV4 + public function getUuid(): UuidV4 { return $this->uuid; } - public function setUuid(UuidV4 $uuid) : self + public function setUuid(UuidV4 $uuid): self { $this->uuid = $uuid; + return $this; } - public function getResourceNode() : ?ResourceNode + public function getResourceNode(): ?ResourceNode { return $this->resourceNode; } - public function setResourceNode(ResourceNode $resourceNode) : self + public function setResourceNode(ResourceNode $resourceNode): self { $this->resourceNode = $resourceNode; + return $this; } - public function hasResourceNode() : bool + public function hasResourceNode(): bool { return $this->resourceNode instanceof ResourceNode; } - public function getResourceNodes() : Collection + public function getResourceNodes(): Collection { return $this->resourceNodes; } /** * @param Collection|ResourceNode[] $resourceNodes */ - public function setResourceNodes(\Doctrine\Common\Collections\Collection|array $resourceNodes) : self + public function setResourceNodes(Collection|array $resourceNodes): self { $this->resourceNodes = $resourceNodes; + return $this; } - public function getDropBoxSentFiles() : Collection + public function getDropBoxSentFiles(): Collection { return $this->dropBoxSentFiles; } - public function setDropBoxSentFiles(Collection $value) : self + public function setDropBoxSentFiles(Collection $value): self { $this->dropBoxSentFiles = $value; + return $this; } /*public function getDropBoxReceivedFiles() @@ -604,21 +606,23 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso { $this->dropBoxReceivedFiles = $value; }*/ - public function getCourses() : Collection + public function getCourses(): Collection { return $this->courses; } /** * @param Collection|CourseRelUser[] $courses */ - public function setCourses(\Doctrine\Common\Collections\Collection|array $courses) : self + public function setCourses(Collection|array $courses): self { $this->courses = $courses; + return $this; } - public function setPortal(AccessUrlRelUser $portal) : self + public function setPortal(AccessUrlRelUser $portal): self { $this->portals->add($portal); + return $this; } /*public function getCurriculumItems(): Collection @@ -632,32 +636,34 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso return $this; }*/ - public function getIsActive() : bool + public function getIsActive(): bool { return $this->active; } - public function isEnabled() : bool + public function isEnabled(): bool { return $this->isActive(); } - public function setEnabled(bool $boolean) : self + public function setEnabled(bool $boolean): self { $this->enabled = $boolean; + return $this; } - public function getSalt() : ?string + public function getSalt(): ?string { return $this->salt; } - public function setSalt(string $salt) : self + public function setSalt(string $salt): self { $this->salt = $salt; + return $this; } /** * Returns the list of classes for the user. */ - public function getCompleteNameWithClasses() : string + public function getCompleteNameWithClasses(): string { $classSubscription = $this->getClasses(); $classList = []; @@ -666,367 +672,402 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso $class = $subscription->getUsergroup(); $classList[] = $class->getName(); } - $classString = empty($classList) ? null : ' [' . implode(', ', $classList) . ']'; - return UserManager::formatUserFullName($this) . $classString; + $classString = empty($classList) ? null : ' ['.implode(', ', $classList).']'; + + return UserManager::formatUserFullName($this).$classString; } - public function getClasses() : Collection + public function getClasses(): Collection { return $this->classes; } /** * @param Collection|UsergroupRelUser[] $classes */ - public function setClasses(\Doctrine\Common\Collections\Collection|array $classes) : self + public function setClasses(Collection|array $classes): self { $this->classes = $classes; + return $this; } - public function getPassword() : ?string + public function getPassword(): ?string { return $this->password; } - public function setPassword(string $password) : self + public function setPassword(string $password): self { $this->password = $password; + return $this; } - public function getAuthSource() : ?string + public function getAuthSource(): ?string { return $this->authSource; } - public function setAuthSource(string $authSource) : self + public function setAuthSource(string $authSource): self { $this->authSource = $authSource; + return $this; } - public function getEmail() : string + public function getEmail(): string { return $this->email; } - public function setEmail(string $email) : self + public function setEmail(string $email): self { $this->email = $email; + return $this; } - public function getOfficialCode() : ?string + public function getOfficialCode(): ?string { return $this->officialCode; } - public function setOfficialCode(?string $officialCode) : self + public function setOfficialCode(?string $officialCode): self { $this->officialCode = $officialCode; + return $this; } - public function getPhone() : ?string + public function getPhone(): ?string { return $this->phone; } - public function setPhone(?string $phone) : self + public function setPhone(?string $phone): self { $this->phone = $phone; + return $this; } - public function getAddress() : ?string + public function getAddress(): ?string { return $this->address; } - public function setAddress(?string $address) : self + public function setAddress(?string $address): self { $this->address = $address; + return $this; } - public function getCreatorId() : ?int + public function getCreatorId(): ?int { return $this->creatorId; } - public function setCreatorId(int $creatorId) : self + public function setCreatorId(int $creatorId): self { $this->creatorId = $creatorId; + return $this; } - public function getCompetences() : ?string + public function getCompetences(): ?string { return $this->competences; } - public function setCompetences(?string $competences) : self + public function setCompetences(?string $competences): self { $this->competences = $competences; + return $this; } - public function getDiplomas() : ?string + public function getDiplomas(): ?string { return $this->diplomas; } - public function setDiplomas(?string $diplomas) : self + public function setDiplomas(?string $diplomas): self { $this->diplomas = $diplomas; + return $this; } - public function getOpenarea() : ?string + public function getOpenarea(): ?string { return $this->openarea; } - public function setOpenarea(?string $openarea) : self + public function setOpenarea(?string $openarea): self { $this->openarea = $openarea; + return $this; } - public function getTeach() : ?string + public function getTeach(): ?string { return $this->teach; } - public function setTeach(?string $teach) : self + public function setTeach(?string $teach): self { $this->teach = $teach; + return $this; } - public function getProductions() : ?string + public function getProductions(): ?string { return $this->productions; } - public function setProductions(?string $productions) : self + public function setProductions(?string $productions): self { $this->productions = $productions; + return $this; } - public function getRegistrationDate() : DateTime + public function getRegistrationDate(): DateTime { return $this->registrationDate; } - public function setRegistrationDate(DateTime $registrationDate) : self + public function setRegistrationDate(DateTime $registrationDate): self { $this->registrationDate = $registrationDate; + return $this; } - public function getExpirationDate() : ?DateTime + public function getExpirationDate(): ?DateTime { return $this->expirationDate; } - public function setExpirationDate(?DateTime $expirationDate) : self + public function setExpirationDate(?DateTime $expirationDate): self { $this->expirationDate = $expirationDate; + return $this; } - public function getActive() : bool + public function getActive(): bool { return $this->active; } - public function isActive() : bool + public function isActive(): bool { return $this->getIsActive(); } - public function setActive(bool $active) : self + public function setActive(bool $active): self { $this->active = $active; + return $this; } - public function getOpenid() : ?string + public function getOpenid(): ?string { return $this->openid; } - public function setOpenid(string $openid) : self + public function setOpenid(string $openid): self { $this->openid = $openid; + return $this; } - public function getTheme() : ?string + public function getTheme(): ?string { return $this->theme; } - public function setTheme(string $theme) : self + public function setTheme(string $theme): self { $this->theme = $theme; + return $this; } - public function getHrDeptId() : ?int + public function getHrDeptId(): ?int { return $this->hrDeptId; } - public function setHrDeptId(int $hrDeptId) : self + public function setHrDeptId(int $hrDeptId): self { $this->hrDeptId = $hrDeptId; + return $this; } - public function getMemberSince() : DateTime + public function getMemberSince(): DateTime { return $this->registrationDate; } - public function isOnline() : bool + public function isOnline(): bool { return false; } - public function getIdentifier() : int + public function getIdentifier(): int { return $this->getId(); } - public function getId() : ?int + public function getId(): ?int { return $this->id; } - public function getIri() : ?string + public function getIri(): ?string { if (null === $this->id) { return null; } - return '/api/users/' . $this->getId(); + + return '/api/users/'.$this->getId(); } - public function getSlug() : string + public function getSlug(): string { return $this->getUsername(); } - public function getUsername() : string + public function getUsername(): string { return $this->username; } - public function getUserIdentifier() : string + public function getUserIdentifier(): string { return $this->username; } - public function setUsername(string $username) : self + public function setUsername(string $username): self { $this->username = $username; + return $this; } - public function setSlug(string $slug) : self + public function setSlug(string $slug): self { return $this->setUsername($slug); } - public function getLastLogin() : ?DateTime + public function getLastLogin(): ?DateTime { return $this->lastLogin; } - public function setLastLogin(DateTime $lastLogin = null) : self + public function setLastLogin(DateTime $lastLogin = null): self { $this->lastLogin = $lastLogin; + return $this; } - public function getConfirmationToken() : ?string + public function getConfirmationToken(): ?string { return $this->confirmationToken; } - public function setConfirmationToken(string $confirmationToken) : self + public function setConfirmationToken(string $confirmationToken): self { $this->confirmationToken = $confirmationToken; + return $this; } - public function isPasswordRequestNonExpired(int $ttl) : bool + public function isPasswordRequestNonExpired(int $ttl): bool { return $this->getPasswordRequestedAt() instanceof DateTime && $this->getPasswordRequestedAt()->getTimestamp() + $ttl > time(); } - public function getPasswordRequestedAt() : ?DateTime + public function getPasswordRequestedAt(): ?DateTime { return $this->passwordRequestedAt; } - public function setPasswordRequestedAt(DateTime $date = null) : self + public function setPasswordRequestedAt(DateTime $date = null): self { $this->passwordRequestedAt = $date; + return $this; } - public function getPlainPassword() : ?string + public function getPlainPassword(): ?string { return $this->plainPassword; } - public function setPlainPassword(string $password) : self + public function setPlainPassword(string $password): self { $this->plainPassword = $password; // forces the object to look "dirty" to Doctrine. Avoids // Doctrine *not* saving this entity, if only plainPassword changes $this->password = ''; + return $this; } /** * Returns the expiration date. */ - public function getExpiresAt() : ?DateTime + public function getExpiresAt(): ?DateTime { return $this->expiresAt; } - public function setExpiresAt(DateTime $date) : self + public function setExpiresAt(DateTime $date): self { $this->expiresAt = $date; + return $this; } /** * Returns the credentials expiration date. */ - public function getCredentialsExpireAt() : ?DateTime + public function getCredentialsExpireAt(): ?DateTime { return $this->credentialsExpireAt; } /** * Sets the credentials expiration date. */ - public function setCredentialsExpireAt(DateTime $date = null) : self + public function setCredentialsExpireAt(DateTime $date = null): self { $this->credentialsExpireAt = $date; + return $this; } - public function getFullname() : string + public function getFullname(): string { if (empty($this->fullName)) { return sprintf('%s %s', $this->getFirstname(), $this->getLastname()); } + return $this->fullName; } - public function getFirstname() : ?string + public function getFirstname(): ?string { return $this->firstname; } - public function setFirstname(string $firstname) : self + public function setFirstname(string $firstname): self { $this->firstname = $firstname; + return $this; } - public function getLastname() : ?string + public function getLastname(): ?string { return $this->lastname; } - public function setLastname(string $lastname) : self + public function setLastname(string $lastname): self { $this->lastname = $lastname; + return $this; } - public function hasGroup(string $name) : bool + public function hasGroup(string $name): bool { return \in_array($name, $this->getGroupNames(), true); } - public function getGroupNames() : array + public function getGroupNames(): array { $names = []; foreach ($this->getGroups() as $group) { $names[] = $group->getName(); } + return $names; } - public function getGroups() : Collection + public function getGroups(): Collection { return $this->groups; } /** * Sets the user groups. */ - public function setGroups(Collection $groups) : self + public function setGroups(Collection $groups): self { foreach ($groups as $group) { $this->addGroup($group); } + return $this; } - public function addGroup(Group $group) : self + public function addGroup(Group $group): self { if (!$this->getGroups()->contains($group)) { $this->getGroups()->add($group); } + return $this; } - public function removeGroup(Group $group) : self + public function removeGroup(Group $group): self { if ($this->getGroups()->contains($group)) { $this->getGroups()->removeElement($group); } + return $this; } - public function isAccountNonExpired() : bool + public function isAccountNonExpired(): bool { /*if (true === $this->expired) { return false; @@ -1037,12 +1078,12 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso }*/ return true; } - public function isAccountNonLocked() : bool + public function isAccountNonLocked(): bool { return true; //return !$this->locked; } - public function isCredentialsNonExpired() : bool + public function isCredentialsNonExpired(): bool { /*if (true === $this->credentialsExpired) { return false; @@ -1053,34 +1094,37 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso }*/ return true; } - public function getCredentialsExpired() : bool + public function getCredentialsExpired(): bool { return $this->credentialsExpired; } - public function setCredentialsExpired(bool $boolean) : self + public function setCredentialsExpired(bool $boolean): self { $this->credentialsExpired = $boolean; + return $this; } - public function getExpired() : bool + public function getExpired(): bool { return $this->expired; } /** * Sets this user to expired. */ - public function setExpired(bool $boolean) : self + public function setExpired(bool $boolean): self { $this->expired = $boolean; + return $this; } - public function getLocked() : bool + public function getLocked(): bool { return $this->locked; } - public function setLocked(bool $boolean) : self + public function setLocked(bool $boolean): self { $this->locked = $boolean; + return $this; } /** @@ -1088,80 +1132,86 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso * * @param Skill $skill The skill */ - public function hasSkill(Skill $skill) : bool + public function hasSkill(Skill $skill): bool { $achievedSkills = $this->getAchievedSkills(); foreach ($achievedSkills as $userSkill) { if ($userSkill->getSkill()->getId() !== $skill->getId()) { continue; } + return true; } + return false; } - public function getAchievedSkills() : Collection + public function getAchievedSkills(): Collection { return $this->achievedSkills; } /** * @param Collection|SkillRelUser[] $value */ - public function setAchievedSkills(\Doctrine\Common\Collections\Collection|array $value) : self + public function setAchievedSkills(Collection|array $value): self { $this->achievedSkills = $value; + return $this; } - public function isProfileCompleted() : ?bool + public function isProfileCompleted(): ?bool { return $this->profileCompleted; } - public function setProfileCompleted(?bool $profileCompleted) : self + public function setProfileCompleted(?bool $profileCompleted): self { $this->profileCompleted = $profileCompleted; + return $this; } - public function getCurrentUrl() : ?AccessUrl + public function getCurrentUrl(): ?AccessUrl { return $this->currentUrl; } - public function setCurrentUrl(AccessUrl $url) : self + public function setCurrentUrl(AccessUrl $url): self { $accessUrlRelUser = (new AccessUrlRelUser())->setUrl($url)->setUser($this); $this->getPortals()->add($accessUrlRelUser); + return $this; } - public function getPortals() : Collection + public function getPortals(): Collection { return $this->portals; } /** * @param AccessUrlRelUser[]|Collection $value */ - public function setPortals(array|\Doctrine\Common\Collections\Collection $value) : void + public function setPortals(array|Collection $value): void { $this->portals = $value; } - public function getSessionsAsGeneralCoach() : array + public function getSessionsAsGeneralCoach(): array { return $this->getSessions(Session::GENERAL_COACH); } - public function getSessionsAsAdmin() : array + public function getSessionsAsAdmin(): array { return $this->getSessions(Session::SESSION_ADMIN); } - public function getCommentedUserSkills() : Collection + public function getCommentedUserSkills(): Collection { return $this->commentedUserSkills; } /** * @param Collection|SkillRelUserComment[] $commentedUserSkills */ - public function setCommentedUserSkills(\Doctrine\Common\Collections\Collection|array $commentedUserSkills) : self + public function setCommentedUserSkills(Collection|array $commentedUserSkills): self { $this->commentedUserSkills = $commentedUserSkills; + return $this; } - public function isEqualTo(UserInterface $user) : bool + public function isEqualTo(UserInterface $user): bool { if ($this->password !== $user->getPassword()) { return false; @@ -1172,39 +1222,41 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso if ($this->username !== $user->getUserIdentifier()) { return false; } + return true; } - public function getSentMessages() : Collection + public function getSentMessages(): Collection { return $this->sentMessages; } - public function getReceivedMessages() : Collection + public function getReceivedMessages(): Collection { return $this->receivedMessages; } - public function getCourseGroupsAsMember() : Collection + public function getCourseGroupsAsMember(): Collection { return $this->courseGroupsAsMember; } - public function getCourseGroupsAsTutor() : Collection + public function getCourseGroupsAsTutor(): Collection { return $this->courseGroupsAsTutor; } - public function getCourseGroupsAsMemberFromCourse(Course $course) : Collection + public function getCourseGroupsAsMemberFromCourse(Course $course): Collection { $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('cId', $course)); + return $this->courseGroupsAsMember->matching($criteria); } - public function eraseCredentials() : void + public function eraseCredentials(): void { $this->plainPassword = null; } - public function isSuperAdmin() : bool + public function isSuperAdmin(): bool { return $this->hasRole('ROLE_SUPER_ADMIN'); } - public static function getRoleFromStatus(int $status) : string + public static function getRoleFromStatus(int $status): string { return match ($status) { COURSEMANAGER => 'ROLE_TEACHER', @@ -1216,19 +1268,19 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso default => 'ROLE_USER', }; } - public function setRoleFromStatus(int $status) : void + public function setRoleFromStatus(int $status): void { $role = self::getRoleFromStatus($status); $this->addRole($role); } - public function hasRole(string $role) : bool + public function hasRole(string $role): bool { return \in_array(strtoupper($role), $this->getRoles(), true); } /** * Returns the user roles. */ - public function getRoles() : array + public function getRoles(): array { $roles = $this->roles; foreach ($this->getGroups() as $group) { @@ -1236,17 +1288,19 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso } // we need to make sure to have at least one role $roles[] = 'ROLE_USER'; + return array_unique($roles); } - public function setRoles(array $roles) : self + public function setRoles(array $roles): self { $this->roles = []; foreach ($roles as $role) { $this->addRole($role); } + return $this; } - public function addRole(string $role) : self + public function addRole(string $role): self { $role = strtoupper($role); if ($role === static::ROLE_DEFAULT || empty($role)) { @@ -1255,244 +1309,259 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso if (!\in_array($role, $this->roles, true)) { $this->roles[] = $role; } + return $this; } - public function removeRole(string $role) : self + public function removeRole(string $role): self { if (false !== ($key = array_search(strtoupper($role), $this->roles, true))) { unset($this->roles[$key]); $this->roles = array_values($this->roles); } + return $this; } - public function getUsernameCanonical() : string + public function getUsernameCanonical(): string { return $this->usernameCanonical; } - public function setUsernameCanonical(string $usernameCanonical) : self + public function setUsernameCanonical(string $usernameCanonical): self { $this->usernameCanonical = $usernameCanonical; + return $this; } - public function getEmailCanonical() : string + public function getEmailCanonical(): string { return $this->emailCanonical; } - public function setEmailCanonical(string $emailCanonical) : self + public function setEmailCanonical(string $emailCanonical): self { $this->emailCanonical = $emailCanonical; + return $this; } - public function getTimezone() : string + public function getTimezone(): string { return $this->timezone; } - public function setTimezone(string $timezone) : self + public function setTimezone(string $timezone): self { $this->timezone = $timezone; + return $this; } - public function getLocale() : string + public function getLocale(): string { return $this->locale; } - public function setLocale(string $locale) : self + public function setLocale(string $locale): self { $this->locale = $locale; + return $this; } - public function getApiToken() : ?string + public function getApiToken(): ?string { return $this->apiToken; } - public function setApiToken(string $apiToken) : self + public function setApiToken(string $apiToken): self { $this->apiToken = $apiToken; + return $this; } - public function getWebsite() : ?string + public function getWebsite(): ?string { return $this->website; } - public function setWebsite(string $website) : self + public function setWebsite(string $website): self { $this->website = $website; + return $this; } - public function getBiography() : ?string + public function getBiography(): ?string { return $this->biography; } - public function setBiography(string $biography) : self + public function setBiography(string $biography): self { $this->biography = $biography; + return $this; } - public function getDateOfBirth() : ?DateTime + public function getDateOfBirth(): ?DateTime { return $this->dateOfBirth; } - public function setDateOfBirth(DateTime $dateOfBirth = null) : self + public function setDateOfBirth(DateTime $dateOfBirth = null): self { $this->dateOfBirth = $dateOfBirth; + return $this; } - public function getProfileUrl() : string + public function getProfileUrl(): string { - return '/main/social/profile.php?u=' . $this->id; + return '/main/social/profile.php?u='.$this->id; } - public function getIconStatus() : string + public function getIconStatus(): string { $hasCertificates = $this->getGradeBookCertificates()->count() > 0; $urlImg = '/img/'; if ($this->isStudent()) { - $iconStatus = $urlImg . 'icons/svg/identifier_student.svg'; + $iconStatus = $urlImg.'icons/svg/identifier_student.svg'; if ($hasCertificates) { - $iconStatus = $urlImg . 'icons/svg/identifier_graduated.svg'; + $iconStatus = $urlImg.'icons/svg/identifier_graduated.svg'; } + return $iconStatus; } if ($this->isTeacher()) { - $iconStatus = $urlImg . 'icons/svg/identifier_teacher.svg'; + $iconStatus = $urlImg.'icons/svg/identifier_teacher.svg'; if ($this->isAdmin()) { - $iconStatus = $urlImg . 'icons/svg/identifier_admin.svg'; + $iconStatus = $urlImg.'icons/svg/identifier_admin.svg'; } + return $iconStatus; } if ($this->isStudentBoss()) { - return $urlImg . 'icons/svg/identifier_teacher.svg'; + return $urlImg.'icons/svg/identifier_teacher.svg'; } + return ''; } - public function getStatus() : int + public function getStatus(): int { return $this->status; } - public function setStatus(int $status) : self + public function setStatus(int $status): self { $this->status = $status; + return $this; } - public function getPictureUri() : ?string + public function getPictureUri(): ?string { return $this->pictureUri; } - public function getGradeBookCertificates() : Collection + public function getGradeBookCertificates(): Collection { return $this->gradeBookCertificates; } /** * @param Collection|GradebookCertificate[] $gradeBookCertificates */ - public function setGradeBookCertificates(\Doctrine\Common\Collections\Collection|array $gradeBookCertificates) : self + public function setGradeBookCertificates(Collection|array $gradeBookCertificates): self { $this->gradeBookCertificates = $gradeBookCertificates; + return $this; } - public function isStudent() : bool + public function isStudent(): bool { return $this->hasRole('ROLE_STUDENT'); } - public function isStudentBoss() : bool + public function isStudentBoss(): bool { return $this->hasRole('ROLE_STUDENT_BOSS'); } - public function isTeacher() : bool + public function isTeacher(): bool { return $this->hasRole('ROLE_TEACHER'); } - public function isAdmin() : bool + public function isAdmin(): bool { return $this->hasRole('ROLE_ADMIN'); } /** * @return GradebookCategory[]|Collection */ - public function getGradeBookCategories() : array|\Doctrine\Common\Collections\Collection + public function getGradeBookCategories(): array|Collection { return $this->gradeBookCategories; } /** * @return GradebookComment[]|Collection */ - public function getGradeBookComments() : array|\Doctrine\Common\Collections\Collection + public function getGradeBookComments(): array|Collection { return $this->gradeBookComments; } /** * @return GradebookEvaluation[]|Collection */ - public function getGradeBookEvaluations() : array|\Doctrine\Common\Collections\Collection + public function getGradeBookEvaluations(): array|Collection { return $this->gradeBookEvaluations; } /** * @return GradebookLink[]|Collection */ - public function getGradeBookLinks() : array|\Doctrine\Common\Collections\Collection + public function getGradeBookLinks(): array|Collection { return $this->gradeBookLinks; } /** * @return GradebookResult[]|Collection */ - public function getGradeBookResults() : array|\Doctrine\Common\Collections\Collection + public function getGradeBookResults(): array|Collection { return $this->gradeBookResults; } /** * @return GradebookResultLog[]|Collection */ - public function getGradeBookResultLogs() : array|\Doctrine\Common\Collections\Collection + public function getGradeBookResultLogs(): array|Collection { return $this->gradeBookResultLogs; } /** * @return GradebookScoreLog[]|Collection */ - public function getGradeBookScoreLogs() : array|\Doctrine\Common\Collections\Collection + public function getGradeBookScoreLogs(): array|Collection { return $this->gradeBookScoreLogs; } /** * @return GradebookLinkevalLog[]|Collection */ - public function getGradeBookLinkEvalLogs() : array|\Doctrine\Common\Collections\Collection + public function getGradeBookLinkEvalLogs(): array|Collection { return $this->gradeBookLinkEvalLogs; } /** * @return UserRelCourseVote[]|Collection */ - public function getUserRelCourseVotes() : array|\Doctrine\Common\Collections\Collection + public function getUserRelCourseVotes(): array|Collection { return $this->userRelCourseVotes; } /** * @return UserRelTag[]|Collection */ - public function getUserRelTags() : array|\Doctrine\Common\Collections\Collection + public function getUserRelTags(): array|Collection { return $this->userRelTags; } /** * @return PersonalAgenda[]|Collection */ - public function getPersonalAgendas() : array|\Doctrine\Common\Collections\Collection + public function getPersonalAgendas(): array|Collection { return $this->personalAgendas; } /** * @return Collection|mixed[] */ - public function getCurriculumItems() : \Doctrine\Common\Collections\Collection|array + public function getCurriculumItems(): Collection|array { return $this->curriculumItems; } /** * @return UserRelUser[]|Collection */ - public function getFriends() : array|\Doctrine\Common\Collections\Collection + public function getFriends(): array|Collection { return $this->friends; } @@ -1501,89 +1570,89 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso * * @return Collection */ - public function getFriendsByRelationType(int $relationType) : Collection + public function getFriendsByRelationType(int $relationType): Collection { $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('relationType', $relationType)); + return $this->friends->matching($criteria); } /** * @return UserRelUser[]|Collection */ - public function getFriendsWithMe() : array|\Doctrine\Common\Collections\Collection + public function getFriendsWithMe(): array|Collection { return $this->friendsWithMe; } - public function addFriend(self $friend) : self + public function addFriend(self $friend): self { return $this->addUserRelUser($friend, UserRelUser::USER_RELATION_TYPE_FRIEND); } - public function addUserRelUser(self $friend, int $relationType) : self + public function addUserRelUser(self $friend, int $relationType): self { $userRelUser = (new UserRelUser())->setUser($this)->setFriend($friend)->setRelationType($relationType); $this->friends->add($userRelUser); + return $this; } /** * @return Templates[]|Collection */ - public function getTemplates() : array|\Doctrine\Common\Collections\Collection + public function getTemplates(): array|Collection { return $this->templates; } - /** - * @return ArrayCollection|Collection - */ - public function getDropBoxReceivedFiles() : \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection + public function getDropBoxReceivedFiles(): ArrayCollection|Collection { return $this->dropBoxReceivedFiles; } /** * @return SequenceValue[]|Collection */ - public function getSequenceValues() : array|\Doctrine\Common\Collections\Collection + public function getSequenceValues(): array|Collection { return $this->sequenceValues; } /** * @return TrackEExerciseConfirmation[]|Collection */ - public function getTrackEExerciseConfirmations() : array|\Doctrine\Common\Collections\Collection + public function getTrackEExerciseConfirmations(): array|Collection { return $this->trackEExerciseConfirmations; } /** * @return TrackEAttempt[]|Collection */ - public function getTrackEAccessCompleteList() : array|\Doctrine\Common\Collections\Collection + public function getTrackEAccessCompleteList(): array|Collection { return $this->trackEAccessCompleteList; } /** * @return TrackEAttempt[]|Collection */ - public function getTrackEAttempts() : array|\Doctrine\Common\Collections\Collection + public function getTrackEAttempts(): array|Collection { return $this->trackEAttempts; } /** * @return TrackECourseAccess[]|Collection */ - public function getTrackECourseAccess() : array|\Doctrine\Common\Collections\Collection + public function getTrackECourseAccess(): array|Collection { return $this->trackECourseAccess; } /** * @return UserCourseCategory[]|Collection */ - public function getUserCourseCategories() : array|\Doctrine\Common\Collections\Collection + public function getUserCourseCategories(): array|Collection { return $this->userCourseCategories; } - public function getCourseGroupsAsTutorFromCourse(Course $course) : Collection + public function getCourseGroupsAsTutorFromCourse(Course $course): Collection { $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('cId', $course->getId())); + return $this->courseGroupsAsTutor->matching($criteria); } /** @@ -1591,29 +1660,31 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso * * @return Session[] */ - public function getSessionsAsStudent() : array + public function getSessionsAsStudent(): array { return $this->getSessions(Session::STUDENT); } /** * @return SessionRelUser[]|Collection */ - public function getSessionsRelUser() : array|\Doctrine\Common\Collections\Collection + public function getSessionsRelUser(): array|Collection { return $this->sessionsRelUser; } - public function addSessionRelUser(SessionRelUser $sessionSubscription) : static + public function addSessionRelUser(SessionRelUser $sessionSubscription): static { $this->sessionsRelUser->add($sessionSubscription); + return $this; } - public function isSkipResourceNode() : bool + public function isSkipResourceNode(): bool { return $this->skipResourceNode; } - public function setSkipResourceNode(bool $skipResourceNode) : self + public function setSkipResourceNode(bool $skipResourceNode): self { $this->skipResourceNode = $skipResourceNode; + return $this; } /** @@ -1621,7 +1692,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso * * @return Session[] */ - public function getSessions(int $relationType) : array + public function getSessions(int $relationType): array { $sessions = []; foreach ($this->getSessionsRelUser() as $sessionRelUser) { @@ -1629,6 +1700,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso $sessions[] = $sessionRelUser->getSession(); } } + return $sessions; } /** @@ -1636,7 +1708,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso * * @return Session[] */ - public function getDRHSessions() : array + public function getDRHSessions(): array { return $this->getSessions(Session::DRH); } @@ -1645,7 +1717,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso * * @return Session[] */ - public function getCurrentlyAccessibleSessions(int $relationType = Session::STUDENT) : array + public function getCurrentlyAccessibleSessions(int $relationType = Session::STUDENT): array { $sessions = []; foreach ($this->getSessions($relationType) as $session) { @@ -1653,38 +1725,41 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso $sessions[] = $session; } } + return $sessions; } - public function getResourceIdentifier() : int + public function getResourceIdentifier(): int { return $this->id; } - public function getResourceName() : string + public function getResourceName(): string { return $this->getUsername(); } - public function setResourceName(string $name) : void + public function setResourceName(string $name): void { $this->setUsername($name); } - public function setParent(AbstractResource $parent) : void + public function setParent(AbstractResource $parent): void { } - public function getDefaultIllustration(int $size) : string + public function getDefaultIllustration(int $size): string { $size = empty($size) ? 32 : $size; + return sprintf('/img/icons/%s/unknown.png', $size); } - public function getAdmin() : ?Admin + public function getAdmin(): ?Admin { return $this->admin; } - public function setAdmin(?Admin $admin) : self + public function setAdmin(?Admin $admin): self { $this->admin = $admin; + return $this; } - public function addUserAsAdmin() : self + public function addUserAsAdmin(): self { if (null === $this->admin) { $admin = new Admin(); @@ -1692,74 +1767,81 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso $this->setAdmin($admin); $this->addRole('ROLE_ADMIN'); } + return $this; } - public function getSessionsByStatusInCourseSubscription(int $status) : Collection + public function getSessionsByStatusInCourseSubscription(int $status): Collection { $criteria = Criteria::create()->where(Criteria::expr()->eq('status', $status)); - return $this->getSessionRelCourseRelUsers()->matching($criteria)->map(fn(SessionRelCourseRelUser $sessionRelCourseRelUser) => $sessionRelCourseRelUser->getSession()); + + return $this->getSessionRelCourseRelUsers()->matching($criteria)->map(fn (SessionRelCourseRelUser $sessionRelCourseRelUser) => $sessionRelCourseRelUser->getSession()); } /** * @return SessionRelCourseRelUser[]|Collection */ - public function getSessionRelCourseRelUsers() : array|\Doctrine\Common\Collections\Collection + public function getSessionRelCourseRelUsers(): array|Collection { return $this->sessionRelCourseRelUsers; } /** * @param SessionRelCourseRelUser[]|Collection $sessionRelCourseRelUsers */ - public function setSessionRelCourseRelUsers(array|\Doctrine\Common\Collections\Collection $sessionRelCourseRelUsers) : self + public function setSessionRelCourseRelUsers(array|Collection $sessionRelCourseRelUsers): self { $this->sessionRelCourseRelUsers = $sessionRelCourseRelUsers; + return $this; } - public function getGender() : ?string + public function getGender(): ?string { return $this->gender; } - public function setGender(?string $gender) : self + public function setGender(?string $gender): self { $this->gender = $gender; + return $this; } /** * @return CSurveyInvitation[]|Collection */ - public function getSurveyInvitations() : array|\Doctrine\Common\Collections\Collection + public function getSurveyInvitations(): array|Collection { return $this->surveyInvitations; } - public function setSurveyInvitations(Collection $surveyInvitations) : self + public function setSurveyInvitations(Collection $surveyInvitations): self { $this->surveyInvitations = $surveyInvitations; + return $this; } /** * @return TrackELogin[]|Collection */ - public function getLogins() : array|\Doctrine\Common\Collections\Collection + public function getLogins(): array|Collection { return $this->logins; } - public function setLogins(Collection $logins) : self + public function setLogins(Collection $logins): self { $this->logins = $logins; + return $this; } /** * @return MessageTag[]|Collection */ - public function getMessageTags() : array|\Doctrine\Common\Collections\Collection + public function getMessageTags(): array|Collection { return $this->messageTags; } /** * @param MessageTag[]|Collection $messageTags */ - public function setMessageTags(array|\Doctrine\Common\Collections\Collection $messageTags) : self + public function setMessageTags(array|Collection $messageTags): self { $this->messageTags = $messageTags; + return $this; } /** @@ -1773,72 +1855,79 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso * * @param null|UserCourseCategory $userCourseCategory the user_course_category */ - public function getMaxSortValue(?UserCourseCategory $userCourseCategory = null) : int + public function getMaxSortValue(?UserCourseCategory $userCourseCategory = null): int { $categoryCourses = $this->courses->matching(Criteria::create()->where(Criteria::expr()->neq('relationType', COURSE_RELATION_TYPE_RRHH))->andWhere(Criteria::expr()->eq('userCourseCat', $userCourseCategory))); - return $categoryCourses->isEmpty() ? 0 : max($categoryCourses->map(fn($courseRelUser) => $courseRelUser->getSort())->toArray()); + + return $categoryCourses->isEmpty() ? 0 : max($categoryCourses->map(fn ($courseRelUser) => $courseRelUser->getSort())->toArray()); } - public function setFullName(string $fullName) : self + public function setFullName(string $fullName): self { $this->fullName = $fullName; + return $this; } - public function hasFriendWithRelationType(self $friend, int $relationType) : bool + public function hasFriendWithRelationType(self $friend, int $relationType): bool { $friends = $this->getFriendsByRelationType($relationType); - return $friends->exists(fn(int $index, UserRelUser $userRelUser) => $userRelUser->getFriend() === $friend); + + return $friends->exists(fn (int $index, UserRelUser $userRelUser) => $userRelUser->getFriend() === $friend); } /** * @return Collection */ - public function getSentSocialPosts() : Collection + public function getSentSocialPosts(): Collection { return $this->sentSocialPosts; } - public function addSentSocialPost(SocialPost $sentSocialPost) : self + public function addSentSocialPost(SocialPost $sentSocialPost): self { if (!$this->sentSocialPosts->contains($sentSocialPost)) { $this->sentSocialPosts[] = $sentSocialPost; $sentSocialPost->setSender($this); } + return $this; } /** * @return Collection */ - public function getReceivedSocialPosts() : Collection + public function getReceivedSocialPosts(): Collection { return $this->receivedSocialPosts; } - public function addReceivedSocialPost(SocialPost $receivedSocialPost) : self + public function addReceivedSocialPost(SocialPost $receivedSocialPost): self { if (!$this->receivedSocialPosts->contains($receivedSocialPost)) { $this->receivedSocialPosts[] = $receivedSocialPost; $receivedSocialPost->setUserReceiver($this); } + return $this; } /** * @return Collection */ - public function getSocialPostsFeedbacks() : Collection + public function getSocialPostsFeedbacks(): Collection { return $this->socialPostsFeedbacks; } - public function getSocialPostFeedbackBySocialPost(SocialPost $post) : ?SocialPostFeedback + public function getSocialPostFeedbackBySocialPost(SocialPost $post): ?SocialPostFeedback { - $filtered = $this->getSocialPostsFeedbacks()->filter(fn(SocialPostFeedback $postFeedback) => $postFeedback->getSocialPost() === $post); + $filtered = $this->getSocialPostsFeedbacks()->filter(fn (SocialPostFeedback $postFeedback) => $postFeedback->getSocialPost() === $post); if ($filtered->count() > 0) { return $filtered->first(); } + return null; } - public function addSocialPostFeedback(SocialPostFeedback $socialPostFeedback) : self + public function addSocialPostFeedback(SocialPostFeedback $socialPostFeedback): self { if (!$this->socialPostsFeedbacks->contains($socialPostFeedback)) { $this->socialPostsFeedbacks[] = $socialPostFeedback; $socialPostFeedback->setUser($this); } + return $this; } } diff --git a/src/CoreBundle/Entity/UserRelUser.php b/src/CoreBundle/Entity/UserRelUser.php index bdf91085cb..ff4079439b 100644 --- a/src/CoreBundle/Entity/UserRelUser.php +++ b/src/CoreBundle/Entity/UserRelUser.php @@ -1,26 +1,26 @@ relationType = self::USER_RELATION_TYPE_FRIEND; } - public function getUser() : User + public function getUser(): User { return $this->user; } - public function setUser(User $user) : self + public function setUser(User $user): self { $this->user = $user; + return $this; } - public function getFriend() : User + public function getFriend(): User { return $this->friend; } - public function setFriend(User $friend) : self + public function setFriend(User $friend): self { $this->friend = $friend; + return $this; } - public function setRelationType(int $relationType) : self + public function setRelationType(int $relationType): self { $this->relationType = $relationType; + return $this; } - public function getRelationType() : ?int + public function getRelationType(): ?int { return $this->relationType; } diff --git a/src/CoreBundle/Entity/Usergroup.php b/src/CoreBundle/Entity/Usergroup.php index 007216110f..abe5842a1b 100644 --- a/src/CoreBundle/Entity/Usergroup.php +++ b/src/CoreBundle/Entity/Usergroup.php @@ -1,32 +1,27 @@ ['usergroup:read']])] #[ORM\Table(name: 'usergroup')] #[ORM\Entity(repositoryClass: \Chamilo\CoreBundle\Repository\Node\UsergroupRepository::class)] -class Usergroup extends AbstractResource implements ResourceInterface, ResourceIllustrationInterface, ResourceWithAccessUrlInterface, \Stringable +class Usergroup extends AbstractResource implements ResourceInterface, ResourceIllustrationInterface, ResourceWithAccessUrlInterface, Stringable { use TimestampableEntity; public const SOCIAL_CLASS = 1; @@ -91,49 +86,52 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI $this->sessions = new ArrayCollection(); $this->questions = new ArrayCollection(); } - public function __toString() : string + public function __toString(): string { return $this->getName(); } /** * @return UsergroupRelUser[]|Collection */ - public function getUsers() : array|Collection + public function getUsers(): array|Collection { return $this->users; } - public function getUrls() : Collection + public function getUrls(): Collection { return $this->urls; } - public function addAccessUrl(?AccessUrl $url) : self + public function addAccessUrl(?AccessUrl $url): self { $urlRelUsergroup = new AccessUrlRelUserGroup(); $urlRelUsergroup->setUserGroup($this); $urlRelUsergroup->setUrl($url); $this->addUrlRelUsergroup($urlRelUsergroup); + return $this; } - public function addUrlRelUsergroup(AccessUrlRelUserGroup $urlRelUsergroup) : self + public function addUrlRelUsergroup(AccessUrlRelUserGroup $urlRelUsergroup): self { $urlRelUsergroup->setUserGroup($this); $this->urls[] = $urlRelUsergroup; + return $this; } - public function setUsers(Collection $users) : void + public function setUsers(Collection $users): void { $this->users = new ArrayCollection(); foreach ($users as $user) { $this->addUsers($user); } } - public function addUsers(UsergroupRelUser $user) : self + public function addUsers(UsergroupRelUser $user): self { $user->setUsergroup($this); $this->users[] = $user; + return $this; } - public function removeUsers(UsergroupRelUser $user) : void + public function removeUsers(UsergroupRelUser $user): void { foreach ($this->users as $key => $value) { if ($value->getId() === $user->getId()) { @@ -150,21 +148,23 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI { return $this->id; } - public function setName(string $name) : self + public function setName(string $name): self { $this->name = $name; + return $this; } - public function getName() : string + public function getName(): string { return $this->name; } - public function setDescription(string $description) : self + public function setDescription(string $description): self { $this->description = $description; + return $this; } - public function getDescription() : ?string + public function getDescription(): ?string { return $this->description; } @@ -175,101 +175,110 @@ class Usergroup extends AbstractResource implements ResourceInterface, ResourceI { return $this->groupType; } - public function setGroupType(int $groupType) : self + public function setGroupType(int $groupType): self { $this->groupType = $groupType; + return $this; } - public function getVisibility() : string + public function getVisibility(): string { return $this->visibility; } - public function setVisibility(string $visibility) : self + public function setVisibility(string $visibility): self { $this->visibility = $visibility; + return $this; } - public function getUrl() : ?string + public function getUrl(): ?string { return $this->url; } - public function setUrl(?string $url) : self + public function setUrl(?string $url): self { $this->url = $url; + return $this; } - public function getAuthorId() : string + public function getAuthorId(): string { return $this->authorId; } - public function setAuthorId(string $authorId) : self + public function setAuthorId(string $authorId): self { $this->authorId = $authorId; + return $this; } - public function getAllowMembersToLeaveGroup() : int + public function getAllowMembersToLeaveGroup(): int { return $this->allowMembersToLeaveGroup; } - public function setAllowMembersToLeaveGroup(int $allowMembersToLeaveGroup) : self + public function setAllowMembersToLeaveGroup(int $allowMembersToLeaveGroup): self { $this->allowMembersToLeaveGroup = $allowMembersToLeaveGroup; + return $this; } /** * @return UsergroupRelCourse[]|Collection */ - public function getCourses() : array|Collection + public function getCourses(): array|Collection { return $this->courses; } - public function setCourses(Collection $courses) : self + public function setCourses(Collection $courses): self { $this->courses = $courses; + return $this; } /** * @return UsergroupRelSession[]|Collection */ - public function getSessions() : array|Collection + public function getSessions(): array|Collection { return $this->sessions; } - public function setSessions(Collection $sessions) : self + public function setSessions(Collection $sessions): self { $this->sessions = $sessions; + return $this; } /** * @return UsergroupRelQuestion[]|Collection */ - public function getQuestions() : array|Collection + public function getQuestions(): array|Collection { return $this->questions; } - public function setQuestions(Collection $questions) : self + public function setQuestions(Collection $questions): self { $this->questions = $questions; + return $this; } - public function getPicture() : ?string + public function getPicture(): ?string { return $this->picture; } - public function getDefaultIllustration(int $size) : string + public function getDefaultIllustration(int $size): string { $size = empty($size) ? 32 : $size; + return sprintf('/img/icons/%s/group_na.png', $size); } - public function getResourceIdentifier() : int + public function getResourceIdentifier(): int { return $this->getId(); } - public function getResourceName() : string + public function getResourceName(): string { return $this->getName(); } - public function setResourceName(string $name) : self + public function setResourceName(string $name): self { return $this->setName($name); } diff --git a/src/CoreBundle/EventListener/TwigListener.php b/src/CoreBundle/EventListener/TwigListener.php index a13550bc38..f49800e241 100644 --- a/src/CoreBundle/EventListener/TwigListener.php +++ b/src/CoreBundle/EventListener/TwigListener.php @@ -6,7 +6,6 @@ declare(strict_types=1); namespace Chamilo\CoreBundle\EventListener; -use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Repository\LanguageRepository; use Chamilo\CoreBundle\Settings\SettingsManager; use Symfony\Component\HttpKernel\Event\RequestEvent; diff --git a/src/CoreBundle/Filter/UserExtraFieldFilter.php b/src/CoreBundle/Filter/UserExtraFieldFilter.php index d95b68505f..884fa192b4 100644 --- a/src/CoreBundle/Filter/UserExtraFieldFilter.php +++ b/src/CoreBundle/Filter/UserExtraFieldFilter.php @@ -67,11 +67,13 @@ class UserExtraFieldFilter extends AbstractFilter ) ->innerJoin(ExtraField::class, 'ef', Join::WITH, 'efv.field = ef.id') ->andWhere('ef.itemType = :itemType') - ->andWhere('ef.variable = :variable'); + ->andWhere('ef.variable = :variable') + ; $queryBuilder ->setParameter('itemType', ExtraField::USER_FIELD_TYPE) - ->setParameter('variable', $value); + ->setParameter('variable', $value) + ; break; case 'userExtraFieldValue': diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20230216122900.php b/src/CoreBundle/Migrations/Schema/V200/Version20230216122900.php index eccc745761..4909f2ef23 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20230216122900.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20230216122900.php @@ -46,6 +46,18 @@ class Version20230216122900 extends AbstractMigrationChamilo 'catalog_settings', 'allow_session_status', 'tracking_columns', + 'my_progress_session_show_all_courses', + 'assignment_base_course_teacher_access_to_all_session', + 'allow_session_admin_extra_access', + 'hide_session_graph_in_my_progress', + 'show_users_in_active_sessions_in_tracking', + 'session_coach_access_after_duration_end', + 'session_course_users_subscription_limited_to_session_users', + 'session_classes_tab_disable', + 'email_template_subscription_to_session_confirmation_username', + 'email_template_subscription_to_session_confirmation_lost_password', + 'session_creation_user_course_extra_field_relation_to_prefill', + 'session_creation_form_set_extra_fields_mandatory', ], 'Security' => [ 'allow_online_users_by_status', @@ -60,6 +72,7 @@ class Version20230216122900 extends AbstractMigrationChamilo 'security_x_content_type_options', 'security_referrer_policy', 'security_block_inactive_users_immediately', + 'security_session_cookie_samesite_none', ], 'Course' => [ 'view_grid_courses', @@ -81,10 +94,27 @@ class Version20230216122900 extends AbstractMigrationChamilo 'course_log_hide_columns', 'course_student_info', 'course_catalog_settings', + 'resource_sequence_show_dependency_in_course_intro', + 'block_registered_users_access_to_open_course_contents', + 'course_catalog_display_in_home', + 'course_creation_form_set_course_category_mandatory', + 'course_creation_form_hide_course_code', + 'course_about_teacher_name_hide', + 'course_visibility_change_only_admin', + 'catalog_hide_public_link', + 'course_log_default_extra_fields', + 'show_courses_in_catalogue', + 'courses_catalogue_show_only_category', + 'course_creation_by_teacher_extra_fields_to_show', + 'course_creation_form_set_extra_fields_mandatory', + 'course_configuration_tool_extra_fields_to_show_and_edit', + 'course_creation_user_course_extra_field_relation_to_prefill', ], 'Language' => [ 'show_language_selector_in_menu', 'language_flags_by_country', + 'allow_course_multiple_languages', + 'template_activate_language_filter', ], 'Platform' => [ 'table_row_list', @@ -104,8 +134,39 @@ class Version20230216122900 extends AbstractMigrationChamilo 'generate_random_login', 'timepicker_increment', 'allow_portfolio_tool', + 'session_stored_in_db_as_backup', + 'memcache_server', + 'session_stored_after_n_times', + 'default_template', + 'aspell_bin', + 'aspell_opts', + 'aspell_temp_dir', + 'webservice_return_user_field', + 'multiple_url_hide_disabled_settings', + 'login_max_attempt_before_blocking_account', + 'force_renew_password_at_first_login', + 'hide_breadcrumb_if_not_allowed', + 'extldap_config', + 'update_student_expiration_x_date', + 'user_status_show_options_enabled', + 'user_status_show_option', + 'user_number_of_days_for_default_expiration_date_per_role', + 'user_edition_extra_field_to_check', + 'user_hide_never_expire_option', + 'platform_logo_url', + 'use_career_external_id_as_identifier_in_diagrams', + 'disable_webservices', + 'webservice_enable_adminonly_api', + 'plugin_settings', + 'allow_working_time_edition', + 'ticket_project_user_roles', + 'disable_user_conditions_sender_id', + 'portfolio_advanced_sharing', ], 'Profile' => [ + 'linkedin_organization_id', + 'career_diagram_disclaimer', + 'career_diagram_legend', 'allow_career_diagram', 'hide_username_with_complete_name', 'disable_change_user_visibility_for_public_courses', @@ -131,10 +192,15 @@ class Version20230216122900 extends AbstractMigrationChamilo 'allow_social_map_fields', ], 'Admin' => [ + 'user_status_option_only_for_admin_enabled', 'show_link_request_hrm_user', 'max_anonymous_users', 'send_inscription_notification_to_general_admin_only', 'plugin_redirection_enabled', + 'usergroup_do_not_unsubscribe_users_from_course_nor_session_on_user_unsubscribe', + 'usergroup_do_not_unsubscribe_users_from_course_on_course_unsubscribe', + 'usergroup_do_not_unsubscribe_users_from_session_on_session_unsubscribe', + 'drh_allow_access_to_all_students', ], 'Agenda' => [ 'personal_agenda_show_all_session_events', @@ -142,6 +208,12 @@ class Version20230216122900 extends AbstractMigrationChamilo 'agenda_legend', 'agenda_colors', 'agenda_on_hover_info', + 'personal_calendar_show_sessions_occupation', + 'agenda_collective_invitations', + 'agenda_event_subscriptions', + 'agenda_reminders', + 'agenda_reminders_sender_id', + 'fullcalendar_settings', ], 'Lp' => [ 'add_all_files_in_lp_export', @@ -170,6 +242,26 @@ class Version20230216122900 extends AbstractMigrationChamilo 'lp_view_settings', 'download_files_after_all_lp_finished', 'allow_lp_subscription_to_usergroups', + 'lp_fixed_encoding', + 'lp_prerequisite_use_last_attempt_only', + 'show_invisible_exercise_in_lp_list', + 'force_edit_exercise_in_lp', + 'student_follow_page_add_LP_subscription_info', + 'lp_show_max_progress_instead_of_average', + 'lp_show_max_progress_or_average_enable_course_level_redefinition', + 'lp_allow_export_to_students', + 'show_invisible_lp_in_course_home', + 'lp_start_and_end_date_visible_in_student_view', + 'scorm_lms_update_sco_status_all_time', + 'scorm_upload_from_cache', + 'lp_prerequisit_on_quiz_unblock_if_max_attempt_reached', + 'student_follow_page_hide_lp_tests_average', + 'student_follow_page_add_LP_acquisition_info', + 'student_follow_page_add_LP_invisible_checkbox', + 'student_follow_page_include_not_subscribed_lp_students', + 'my_progress_course_tools_order', + 'lp_enable_flow', + 'lp_item_prerequisite_dates', ], 'Gradebook' => [ 'gradebook_enable_best_score', @@ -189,6 +281,10 @@ class Version20230216122900 extends AbstractMigrationChamilo 'gradebook_flatview_extrafields_columns', 'gradebook_pdf_export_settings', 'allow_gradebook_comments', + 'gradebook_display_extra_stats', + 'gradebook_hide_table', + 'gradebook_hide_link_to_item_for_student', + 'gradebook_enable_subcategory_skills_independant_assignement', ], 'Exercise' => [ 'block_quiz_mail_notification_general_coach', @@ -230,6 +326,21 @@ class Version20230216122900 extends AbstractMigrationChamilo 'exercise_category_report_user_extra_fields', 'score_grade_model', 'allow_time_per_question', + 'my_courses_show_pending_exercise_attempts', + 'allow_quick_question_description_popup', + 'exercise_hide_ip', + 'tracking_my_progress_show_deleted_exercises', + 'show_exercise_attempts_in_all_user_sessions', + 'show_exercise_session_attempts_in_base_course', + 'quiz_check_all_answers_before_end_test', + 'quiz_discard_orphan_in_course_export', + 'exercise_result_end_text_html_strict_filtering', + 'question_exercise_html_strict_filtering', + 'quiz_question_delete_automatically_when_deleting_exercise', + 'quiz_question_allow_inter_course_linking', + 'quiz_hide_attempts_table_on_start_page', + 'quiz_hide_question_number', + 'quiz_keep_alive_ping_interval', ], 'Glossary' => [ 'default_glossary_view', @@ -240,10 +351,17 @@ class Version20230216122900 extends AbstractMigrationChamilo 'hide_forum_post_revision_language', 'allow_forum_post_revisions', 'forum_fold_categories', + 'allow_forum_category_language_filter', + 'subscribe_users_to_forum_notifications_also_in_base_course', ], 'Message' => [ 'private_messages_about_user', 'private_messages_about_user_visible_to_user', + 'social_enable_messages_feedback', + 'disable_dislike_option', + 'enable_message_tags', + 'allow_user_message_tracking', + 'filter_interactivity_messages', ], 'Display' => [ 'hide_social_media_links', @@ -257,6 +375,11 @@ class Version20230216122900 extends AbstractMigrationChamilo 'full_ckeditor_toolbar_set', 'ck_editor_block_image_copy_paste', 'translate_html', + 'editor_driver_list', + 'enable_uploadimage_editor', + 'editor_settings', + 'video_context_menu_hidden', + 'video_player_renderers', ], 'Chat' => [ 'hide_username_in_course_chat', @@ -276,6 +399,8 @@ class Version20230216122900 extends AbstractMigrationChamilo 'allow_mandatory_survey', 'hide_survey_edition', 'survey_additional_teacher_modify_actions', + 'allow_survey_tool_in_lp', + 'show_surveys_base_in_sessions', ], 'Document' => [ 'send_notification_when_document_added', @@ -286,15 +411,21 @@ class Version20230216122900 extends AbstractMigrationChamilo 'group_category_document_access', 'allow_compilatio_tool', 'compilatio_tool', + 'documents_hide_download_icon', + 'enable_x_sendfile_headers', + 'documents_custom_cloud_link_list', ], 'Announcement' => [ - 'disable_announcement_attachment', + 'disable_delete_all_announcements', 'admin_chamilo_announcements_disable', + 'disable_announcement_attachment', 'allow_scheduled_announcements', - 'disable_delete_all_announcements', 'hide_announcement_sent_to_users_info', 'send_all_emails_to', 'allow_careers_in_global_announcements', + 'announcements_hide_send_to_hrm_users', + 'allow_coach_to_edit_announcements', + 'course_announcement_scheduled_by_date', ], 'Skill' => [ 'allow_private_skills', @@ -313,13 +444,13 @@ class Version20230216122900 extends AbstractMigrationChamilo 'allow_email_editor_for_anonymous', 'messages_hide_mail_content', 'send_inscription_msg_to_inbox', - 'allow_user_message_tracking', 'send_two_inscription_confirmation_mail', 'show_user_email_in_notification', 'send_notification_score_in_percentage', 'mail_template_system', 'cron_notification_mails', 'cron_notification_help_desk', + 'notifications_extended_footer_message', ], 'Work' => [ 'block_student_publication_edition', @@ -331,6 +462,20 @@ class Version20230216122900 extends AbstractMigrationChamilo 'considered_working_time', 'force_download_doc_before_upload_work', 'allow_redirect_to_main_page_after_work_upload', + 'my_courses_show_pending_work', + ], + 'Wiki' => [ + 'wiki_categories_enabled', + 'wiki_html_strict_filtering', + ], + 'Certificate' => [ + 'hide_my_certificate_link', + 'add_certificate_pdf_footer', + ], + 'Attendance' => [ + 'enable_sign_attendance_sheet', + 'attendance_calendar_set_duration', + 'attendance_allow_comments', ], ]; foreach ($configurationValues as $category => $variables) { @@ -375,14 +520,160 @@ class Version20230216122900 extends AbstractMigrationChamilo "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (12, 13, 'is_mandatory', 'IsMandatory', 1, 1, 1, NOW())" ); } - // Alter tables required. + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'show_in_catalogue' AND item_type = 2 AND value_type = 3" + ) + ; + $count = $result->fetchNumeric()[0]; + if (empty($count)) { + $this->addSql( + "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (2, 3, 'show_in_catalogue', 'Show in catalogue', 1, 1, 0, NOW())" + ); + $this->addSql( + "SET @ef_id = LAST_INSERT_ID()" + ); + $this->addSql( + "INSERT INTO extra_field_options (field_id, option_value, display_text, priority, priority_message, option_order) VALUES (@ef_id, '1', 'Yes', NULL, NULL, 1), (@ef_id, '0', 'No', NULL, NULL, 2)" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'multiple_language' AND item_type = 2 AND value_type = 5" + ) + ; + $count = $result->fetchNumeric()[0]; + if (empty($count)) { + $this->addSql( + "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (2, 5, 'multiple_language', 'Multiple Language', 1, 1, 1, NOW())" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'send_notification_at_a_specific_date' AND item_type = 21 AND value_type = 13" + ) + ; + $count = $result->fetchNumeric()[0]; + if (empty($count)) { + $this->addSql( + "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (21, 13, 'send_notification_at_a_specific_date', 'Send notification at a specific date', 1, 1, 1, NOW())" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'date_to_send_notification' AND item_type = 21 AND value_type = 6" + ) + ; + $count = $result->fetchNumeric()[0]; + if (empty($count)) { + $this->addSql( + "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (21, 6, 'date_to_send_notification', 'Date to send notification', 1, 1, 1, NOW())" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'send_to_users_in_session' AND item_type = 21 AND value_type = 13" + ) + ; + $count = $result->fetchNumeric()[0]; + if (empty($count)) { + $this->addSql( + "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (21, 13, 'send_to_users_in_session', 'Send to users in session', 1, 1, 1, NOW())" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'tags' AND item_type = 22 AND value_type = 10" + ) + ; + $count = $result->fetchNumeric()[0]; + if (empty($count)) { + $this->addSql( + "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (22, 10, 'tags', 'Tags', 1, 1, 1, NOW())" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'acquisition' AND item_type = 20 AND value_type = 3" + ) + ; + $count = $result->fetchNumeric()[0]; + if (empty($count)) { + $this->addSql( + "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (20, 3, 'acquisition', 'Acquisition', 1, 1, 0, NOW())" + ); + $this->addSql( + "SET @ef_id = LAST_INSERT_ID()" + ); + $this->addSql( + "INSERT INTO extra_field_options (field_id, option_value, display_text, priority, priority_message, option_order) VALUES (@ef_id, '1', 'Acquired', NULL, NULL, 1), (@ef_id, '2', 'In the process of acquisition', NULL, NULL, 2), (@ef_id, '3', 'Not acquired', NULL, NULL, 3)" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'invisible' AND item_type = 20 AND value_type = 13" + ) + ; + $count = $result->fetchNumeric()[0]; + if (empty($count)) { + $this->addSql( + "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (20, 13, 'invisible', 'Invisible', 1, 1, 1, NOW())" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'start_date' AND item_type = 7 AND value_type = 7" + ) + ; + $count = $result->fetchNumeric()[0]; + if (empty($count)) { + $this->addSql( + "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (7, 7, 'start_date', 'StartDate', 1, 1, 1, NOW())" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'end_date' AND item_type = 7 AND value_type = 7" + ) + ; + $count = $result->fetchNumeric()[0]; + if (empty($count)) { + $this->addSql( + "INSERT INTO extra_field (item_type, value_type, variable, display_text, visible_to_self, changeable, filter, created_at) VALUES (7, 7, 'end_date', 'EndDate', 1, 1, 1, NOW())" + ); + } + } public function down(Schema $schema): void { $connection = $this->getEntityManager()->getConnection(); $configurationValues = [ + 'Attendance' => [ + 'attendance_allow_comments', + 'attendance_calendar_set_duration', + 'enable_sign_attendance_sheet', + ], + 'Certificate' => [ + 'add_certificate_pdf_footer', + 'hide_my_certificate_link', + ], + 'Wiki' => [ + 'wiki_html_strict_filtering', + 'wiki_categories_enabled', + ], 'Work' => [ + 'my_courses_show_pending_work', 'allow_redirect_to_main_page_after_work_upload', 'force_download_doc_before_upload_work', 'considered_working_time', @@ -394,13 +685,13 @@ class Version20230216122900 extends AbstractMigrationChamilo 'block_student_publication_edition', ], 'Mail' => [ + 'notifications_extended_footer_message', 'cron_notification_help_desk', 'cron_notification_mails', 'mail_template_system', 'send_notification_score_in_percentage', 'show_user_email_in_notification', 'send_two_inscription_confirmation_mail', - 'allow_user_message_tracking', 'send_inscription_msg_to_inbox', 'messages_hide_mail_content', 'allow_email_editor_for_anonymous', @@ -419,15 +710,21 @@ class Version20230216122900 extends AbstractMigrationChamilo 'allow_private_skills', ], 'Announcement' => [ + 'course_announcement_scheduled_by_date', + 'allow_coach_to_edit_announcements', + 'announcements_hide_send_to_hrm_users', 'allow_careers_in_global_announcements', 'send_all_emails_to', 'hide_announcement_sent_to_users_info', 'allow_scheduled_announcements', - 'admin_chamilo_announcements_disable', 'disable_announcement_attachment', + 'admin_chamilo_announcements_disable', 'disable_delete_all_announcements', ], 'Document' => [ + 'documents_custom_cloud_link_list', + 'enable_x_sendfile_headers', + 'documents_hide_download_icon', 'compilatio_tool', 'allow_compilatio_tool', 'group_category_document_access', @@ -438,6 +735,8 @@ class Version20230216122900 extends AbstractMigrationChamilo 'send_notification_when_document_added', ], 'Survey' => [ + 'show_surveys_base_in_sessions', + 'allow_survey_tool_in_lp', 'survey_additional_teacher_modify_actions', 'hide_survey_edition', 'allow_mandatory_survey', @@ -457,6 +756,11 @@ class Version20230216122900 extends AbstractMigrationChamilo 'hide_username_in_course_chat', ], 'Editor' => [ + 'video_player_renderers', + 'video_context_menu_hidden', + 'editor_settings', + 'enable_uploadimage_editor', + 'editor_driver_list', 'translate_html', 'ck_editor_block_image_copy_paste', 'full_ckeditor_toolbar_set', @@ -470,10 +774,17 @@ class Version20230216122900 extends AbstractMigrationChamilo 'hide_social_media_links', ], 'Message' => [ + 'filter_interactivity_messages', + 'allow_user_message_tracking', + 'enable_message_tags', + 'disable_dislike_option', + 'social_enable_messages_feedback', 'private_messages_about_user_visible_to_user', 'private_messages_about_user', ], 'Forum' => [ + 'subscribe_users_to_forum_notifications_also_in_base_course', + 'allow_forum_category_language_filter', 'forum_fold_categories', 'allow_forum_post_revisions', 'hide_forum_post_revision_language', @@ -484,6 +795,21 @@ class Version20230216122900 extends AbstractMigrationChamilo 'default_glossary_view', ], 'Exercise' => [ + 'quiz_keep_alive_ping_interval', + 'quiz_hide_question_number', + 'quiz_hide_attempts_table_on_start_page', + 'quiz_question_allow_inter_course_linking', + 'quiz_question_delete_automatically_when_deleting_exercise', + 'question_exercise_html_strict_filtering', + 'exercise_result_end_text_html_strict_filtering', + 'quiz_discard_orphan_in_course_export', + 'quiz_check_all_answers_before_end_test', + 'show_exercise_session_attempts_in_base_course', + 'show_exercise_attempts_in_all_user_sessions', + 'tracking_my_progress_show_deleted_exercises', + 'exercise_hide_ip', + 'allow_quick_question_description_popup', + 'my_courses_show_pending_exercise_attempts', 'allow_time_per_question', 'score_grade_model', 'exercise_category_report_user_extra_fields', @@ -525,6 +851,10 @@ class Version20230216122900 extends AbstractMigrationChamilo 'block_quiz_mail_notification_general_coach', ], 'Gradebook' => [ + 'gradebook_enable_subcategory_skills_independant_assignement', + 'gradebook_hide_link_to_item_for_student', + 'gradebook_hide_table', + 'gradebook_display_extra_stats', 'allow_gradebook_comments', 'gradebook_pdf_export_settings', 'gradebook_flatview_extrafields_columns', @@ -544,6 +874,26 @@ class Version20230216122900 extends AbstractMigrationChamilo 'gradebook_enable_best_score', ], 'Lp' => [ + 'lp_item_prerequisite_dates', + 'lp_enable_flow', + 'my_progress_course_tools_order', + 'student_follow_page_include_not_subscribed_lp_students', + 'student_follow_page_add_LP_invisible_checkbox', + 'student_follow_page_add_LP_acquisition_info', + 'student_follow_page_hide_lp_tests_average', + 'lp_prerequisit_on_quiz_unblock_if_max_attempt_reached', + 'scorm_upload_from_cache', + 'scorm_lms_update_sco_status_all_time', + 'lp_start_and_end_date_visible_in_student_view', + 'show_invisible_lp_in_course_home', + 'lp_allow_export_to_students', + 'lp_show_max_progress_or_average_enable_course_level_redefinition', + 'lp_show_max_progress_instead_of_average', + 'student_follow_page_add_LP_subscription_info', + 'force_edit_exercise_in_lp', + 'show_invisible_exercise_in_lp_list', + 'lp_prerequisite_use_last_attempt_only', + 'lp_fixed_encoding', 'allow_lp_subscription_to_usergroups', 'download_files_after_all_lp_finished', 'lp_view_settings', @@ -572,6 +922,12 @@ class Version20230216122900 extends AbstractMigrationChamilo 'add_all_files_in_lp_export', ], 'Agenda' => [ + 'fullcalendar_settings', + 'agenda_reminders_sender_id', + 'agenda_reminders', + 'agenda_event_subscriptions', + 'agenda_collective_invitations', + 'personal_calendar_show_sessions_occupation', 'agenda_on_hover_info', 'agenda_colors', 'agenda_legend', @@ -579,10 +935,15 @@ class Version20230216122900 extends AbstractMigrationChamilo 'personal_agenda_show_all_session_events', ], 'Admin' => [ + 'drh_allow_access_to_all_students', + 'usergroup_do_not_unsubscribe_users_from_session_on_session_unsubscribe', + 'usergroup_do_not_unsubscribe_users_from_course_on_course_unsubscribe', + 'usergroup_do_not_unsubscribe_users_from_course_nor_session_on_user_unsubscribe', 'plugin_redirection_enabled', 'send_inscription_notification_to_general_admin_only', 'max_anonymous_users', 'show_link_request_hrm_user', + 'user_status_option_only_for_admin_enabled', ], 'Profile' => [ 'allow_social_map_fields', @@ -608,8 +969,39 @@ class Version20230216122900 extends AbstractMigrationChamilo 'disable_change_user_visibility_for_public_courses', 'hide_username_with_complete_name', 'allow_career_diagram', + 'career_diagram_legend', + 'career_diagram_disclaimer', + 'linkedin_organization_id', ], 'Platform' => [ + 'portfolio_advanced_sharing', + 'disable_user_conditions_sender_id', + 'ticket_project_user_roles', + 'allow_working_time_edition', + 'plugin_settings', + 'webservice_enable_adminonly_api', + 'disable_webservices', + 'use_career_external_id_as_identifier_in_diagrams', + 'platform_logo_url', + 'user_hide_never_expire_option', + 'user_edition_extra_field_to_check', + 'user_number_of_days_for_default_expiration_date_per_role', + 'user_status_show_option', + 'user_status_show_options_enabled', + 'update_student_expiration_x_date', + 'extldap_config', + 'hide_breadcrumb_if_not_allowed', + 'force_renew_password_at_first_login', + 'login_max_attempt_before_blocking_account', + 'multiple_url_hide_disabled_settings', + 'webservice_return_user_field', + 'aspell_temp_dir', + 'aspell_opts', + 'aspell_bin', + 'default_template', + 'session_stored_after_n_times', + 'memcache_server', + 'session_stored_in_db_as_backup', 'allow_portfolio_tool', 'timepicker_increment', 'generate_random_login', @@ -629,10 +1021,27 @@ class Version20230216122900 extends AbstractMigrationChamilo 'table_row_list', ], 'Language' => [ + 'template_activate_language_filter', + 'allow_course_multiple_languages', 'language_flags_by_country', 'show_language_selector_in_menu', ], 'Course' => [ + 'course_creation_user_course_extra_field_relation_to_prefill', + 'course_configuration_tool_extra_fields_to_show_and_edit', + 'course_creation_form_set_extra_fields_mandatory', + 'course_creation_by_teacher_extra_fields_to_show', + 'courses_catalogue_show_only_category', + 'show_courses_in_catalogue', + 'course_log_default_extra_fields', + 'catalog_hide_public_link', + 'course_visibility_change_only_admin', + 'course_about_teacher_name_hide', + 'course_creation_form_hide_course_code', + 'course_creation_form_set_course_category_mandatory', + 'course_catalog_display_in_home', + 'block_registered_users_access_to_open_course_contents', + 'resource_sequence_show_dependency_in_course_intro', 'course_catalog_settings', 'course_student_info', 'course_log_hide_columns', @@ -654,6 +1063,7 @@ class Version20230216122900 extends AbstractMigrationChamilo 'view_grid_courses', ], 'Security' => [ + 'security_session_cookie_samesite_none', 'security_block_inactive_users_immediately', 'security_referrer_policy', 'security_x_content_type_options', @@ -668,6 +1078,18 @@ class Version20230216122900 extends AbstractMigrationChamilo 'allow_online_users_by_status', ], 'Session' => [ + 'session_creation_form_set_extra_fields_mandatory', + 'session_creation_user_course_extra_field_relation_to_prefill', + 'email_template_subscription_to_session_confirmation_lost_password', + 'email_template_subscription_to_session_confirmation_username', + 'session_classes_tab_disable', + 'session_course_users_subscription_limited_to_session_users', + 'session_coach_access_after_duration_end', + 'show_users_in_active_sessions_in_tracking', + 'hide_session_graph_in_my_progress', + 'allow_session_admin_extra_access', + 'assignment_base_course_teacher_access_to_all_session', + 'my_progress_session_show_all_courses', 'tracking_columns', 'allow_session_status', 'catalog_settings', @@ -712,6 +1134,91 @@ class Version20230216122900 extends AbstractMigrationChamilo } // Delete extra fields required. + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'end_date' AND item_type = 7 AND value_type = 7" + ) + ; + $count = $result->fetchNumeric()[0]; + if (!empty($count)) { + $this->addSql( + "DELETE FROM extra_field WHERE variable = 'end_date' AND item_type = 7 AND value_type = 7" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'start_date' AND item_type = 7 AND value_type = 7" + ) + ; + $count = $result->fetchNumeric()[0]; + if (!empty($count)) { + $this->addSql( + "DELETE FROM extra_field WHERE variable = 'start_date' AND item_type = 7 AND value_type = 7" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'invisible' AND item_type = 20 AND value_type = 13" + ) + ; + $count = $result->fetchNumeric()[0]; + if (!empty($count)) { + $this->addSql( + "DELETE FROM extra_field WHERE variable = 'invisible' AND item_type = 20 AND value_type = 13" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'acquisition' AND item_type = 20 AND value_type = 3" + ) + ; + $count = $result->fetchNumeric()[0]; + if (!empty($count)) { + $this->addSql( + "DELETE FROM extra_field WHERE variable = 'acquisition' AND item_type = 20 AND value_type = 3" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'tags' AND item_type = 22 AND value_type = 10" + ) + ; + $count = $result->fetchNumeric()[0]; + if (!empty($count)) { + $this->addSql( + "DELETE FROM extra_field WHERE variable = 'tags' AND item_type = 22 AND value_type = 10" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'multiple_language' AND item_type = 2 AND value_type = 5" + ) + ; + $count = $result->fetchNumeric()[0]; + if (!empty($count)) { + $this->addSql( + "DELETE FROM extra_field WHERE variable = 'multiple_language' AND item_type = 2 AND value_type = 5" + ); + } + + $result = $connection + ->executeQuery( + "SELECT COUNT(1) FROM extra_field WHERE variable = 'show_in_catalogue' AND item_type = 2 AND value_type = 3" + ) + ; + $count = $result->fetchNumeric()[0]; + if (!empty($count)) { + $this->addSql( + "DELETE FROM extra_field WHERE variable = 'show_in_catalogue' AND item_type = 2 AND value_type = 3" + ); + } + $result = $connection ->executeQuery( "SELECT COUNT(1) FROM extra_field WHERE variable = 'session_courses_read_only_mode' AND item_type = 2 AND value_type = 13" @@ -735,6 +1242,7 @@ class Version20230216122900 extends AbstractMigrationChamilo "DELETE FROM extra_field WHERE variable = 'is_mandatory' AND item_type = 12 AND value_type = 13" ); } + } public function getConfigurationSelectedValue(string $variable): string diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20230216122950.php b/src/CoreBundle/Migrations/Schema/V200/Version20230216122950.php index 578a745187..49a82098e3 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20230216122950.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20230216122950.php @@ -39,10 +39,278 @@ final class Version20230216122950 extends AbstractMigrationChamilo 'CREATE TABLE notification_event (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, content LONGTEXT DEFAULT NULL, link LONGTEXT DEFAULT NULL, persistent INT DEFAULT NULL, day_diff INT DEFAULT NULL, event_type VARCHAR(255) NOT NULL, event_id INT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' ); } + + if ($schema->hasTable('system_template')) { + $this->addSql( + 'ALTER TABLE system_template ADD language VARCHAR(40) NOT NULL DEFAULT "english"' + ); + } + + if (!$schema->hasTable('agenda_event_invitee')) { + $this->addSql( + 'CREATE TABLE agenda_event_invitee (id BIGINT AUTO_INCREMENT NOT NULL, invitation_id BIGINT DEFAULT NULL, user_id INT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", type VARCHAR(255) NOT NULL, INDEX IDX_4F5757FEA35D7AF0 (invitation_id), INDEX IDX_4F5757FEA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' + ); + $this->addSql( + 'ALTER TABLE agenda_event_invitee ADD CONSTRAINT FK_4F5757FEA35D7AF0 FOREIGN KEY (invitation_id) REFERENCES agenda_event_invitation (id) ON DELETE CASCADE' + ); + $this->addSql( + 'ALTER TABLE agenda_event_invitee ADD CONSTRAINT FK_4F5757FEA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE SET NULL' + ); + } + + if (!$schema->hasTable('agenda_event_invitation')) { + $this->addSql( + 'CREATE TABLE agenda_event_invitation (id BIGINT AUTO_INCREMENT NOT NULL, creator_id INT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", type VARCHAR(255) NOT NULL, max_attendees INT DEFAULT 0, INDEX IDX_52A2D5E161220EA6 (creator_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' + ); + $this->addSql( + 'ALTER TABLE agenda_event_invitation ADD CONSTRAINT FK_52A2D5E161220EA6 FOREIGN KEY (creator_id) REFERENCES user (id) ON DELETE CASCADE' + ); + } + + if (!$schema->hasTable('agenda_reminder')) { + $this->addSql( + 'CREATE TABLE agenda_reminder (id BIGINT AUTO_INCREMENT NOT NULL, type VARCHAR(255) 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)", PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;' + ); + } + + if (!$schema->hasTable('c_wiki_category')) { + $this->addSql( + 'CREATE TABLE c_wiki_category (id INT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, session_id INT DEFAULT NULL, tree_root INT DEFAULT NULL, parent_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, lft INT NOT NULL, lvl INT NOT NULL, rgt INT NOT NULL, INDEX IDX_17F1099A91D79BD3 (c_id), INDEX IDX_17F1099A613FECDF (session_id), INDEX IDX_17F1099AA977936C (tree_root), INDEX IDX_17F1099A727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' + ); + $this->addSql( + 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE' + ); + $this->addSql( + 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE CASCADE' + ); + $this->addSql( + 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099AA977936C FOREIGN KEY (tree_root) REFERENCES c_wiki_category (id) ON DELETE CASCADE' + ); + $this->addSql( + 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A727ACA70 FOREIGN KEY (parent_id) REFERENCES c_wiki_category (id) ON DELETE CASCADE' + ); + } + + if (!$schema->hasTable('c_wiki_rel_category')) { + $this->addSql( + 'CREATE TABLE c_wiki_rel_category (wiki_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_AC88945BAA948DBE (wiki_id), INDEX IDX_AC88945B12469DE2 (category_id), PRIMARY KEY(wiki_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' + ); + $this->addSql( + 'ALTER TABLE c_wiki_rel_category ADD CONSTRAINT FK_AC88945BAA948DBE FOREIGN KEY (wiki_id) REFERENCES c_wiki (iid) ON DELETE CASCADE' + ); + $this->addSql( + 'ALTER TABLE c_wiki_rel_category ADD CONSTRAINT FK_AC88945B12469DE2 FOREIGN KEY (category_id) REFERENCES c_wiki_category (id) ON DELETE CASCADE' + ); + } + + if (!$schema->hasTable('notification_event_rel_user')) { + $this->addSql( + 'CREATE TABLE notification_event_rel_user (id INT UNSIGNED AUTO_INCREMENT NOT NULL, event_id INT unsigned, user_id INT, INDEX FK_EVENT (event_id), INDEX FK_USER (user_id), PRIMARY KEY (id))' + ); + $this->addSql( + 'ALTER TABLE notification_event_rel_user ADD CONSTRAINT FK_EVENT FOREIGN KEY (event_id) REFERENCES notification_event (id) ON DELETE CASCADE' + ); + $this->addSql( + 'ALTER TABLE notification_event_rel_user ADD CONSTRAINT FK_USER FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE' + ); + } + + if ($schema->hasTable('c_survey_answer')) { + $this->addSql( + 'ALTER TABLE c_survey_answer ADD session_id INT NOT NULL, ADD c_lp_item_id INT NOT NULL' + ); + } + + if ($schema->hasTable('c_survey_invitation')) { + $this->addSql( + 'ALTER TABLE c_survey_invitation ADD c_lp_item_id INT NOT NULL' + ); + } + + if (!$schema->hasTable('message_feedback')) { + $this->addSql( + 'CREATE TABLE message_feedback (id BIGINT AUTO_INCREMENT NOT NULL, message_id BIGINT NOT NULL, user_id INT NOT NULL, liked TINYINT(1) DEFAULT 0 NOT NULL, disliked TINYINT(1) DEFAULT 0 NOT NULL, updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", INDEX IDX_DB0F8049537A1329 (message_id), INDEX IDX_DB0F8049A76ED395 (user_id), INDEX idx_message_feedback_uid_mid (message_id, user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' + ); + $this->addSql( + 'ALTER TABLE message_feedback ADD CONSTRAINT FK_DB0F8049537A1329 FOREIGN KEY (message_id) REFERENCES message (id) ON DELETE CASCADE' + ); + $this->addSql( + 'ALTER TABLE message_feedback ADD CONSTRAINT FK_DB0F8049A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE' + ); + } + + if (!$schema->hasTable('portfolio_attachment')) { + $this->addSql( + 'CREATE TABLE portfolio_attachment (id INT AUTO_INCREMENT NOT NULL, path VARCHAR(255) NOT NULL, comment LONGTEXT DEFAULT NULL, size INT NOT NULL, filename VARCHAR(255) NOT NULL, origin_id INT NOT NULL, origin_type INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' + ); + } + + if (!$schema->hasTable('portfolio_comment')) { + $this->addSql( + 'CREATE TABLE portfolio_comment (id INT AUTO_INCREMENT NOT NULL, author_id INT NOT NULL, item_id INT NOT NULL, tree_root INT DEFAULT NULL, parent_id INT DEFAULT NULL, visibility SMALLINT DEFAULT 1 NOT NULL, content LONGTEXT NOT NULL, date DATETIME NOT NULL COMMENT "(DC2Type:datetime)", is_important TINYINT(1) DEFAULT 0 NOT NULL, lft INT NOT NULL, lvl INT NOT NULL, rgt INT NOT NULL, score DOUBLE PRECISION DEFAULT NULL, is_template TINYINT(1) DEFAULT 0 NOT NULL, INDEX IDX_C2C17DA2F675F31B (author_id), INDEX IDX_C2C17DA2126F525E (item_id), INDEX IDX_C2C17DA2A977936C (tree_root), INDEX IDX_C2C17DA2727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' + ); + $this->addSql( + 'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2F675F31B FOREIGN KEY (author_id) REFERENCES user (id) ON DELETE CASCADE' + ); + $this->addSql( + 'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2126F525E FOREIGN KEY (item_id) REFERENCES portfolio (id) ON DELETE CASCADE' + ); + $this->addSql( + 'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2A977936C FOREIGN KEY (tree_root) REFERENCES portfolio_comment (id) ON DELETE CASCADE' + ); + $this->addSql( + 'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2727ACA70 FOREIGN KEY (parent_id) REFERENCES portfolio_comment (id) ON DELETE CASCADE' + ); + } + + if ($schema->hasTable('portfolio')) { + $this->addSql( + 'ALTER TABLE portfolio ADD origin INT DEFAULT NULL, ADD origin_type INT DEFAULT NULL, ADD score DOUBLE PRECISION DEFAULT NULL, ADD is_highlighted TINYINT(1) DEFAULT 0 NOT NULL, ADD is_template TINYINT(1) DEFAULT 0 NOT NULL' + ); + } + + if (!$schema->hasTable('c_attendance_result_comment')) { + $this->addSql( + 'CREATE TABLE c_attendance_result_comment (iid INT AUTO_INCREMENT NOT NULL, attendance_sheet_id INT NOT NULL, user_id INT NOT NULL, comment LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", author_user_id INT NOT NULL, INDEX attendance_sheet_id (attendance_sheet_id), INDEX user_id (user_id), PRIMARY KEY(iid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' + ); + } + + if ($schema->hasTable('c_attendance_calendar')) { + $this->addSql( + 'ALTER TABLE c_attendance_calendar ADD blocked TINYINT(1) DEFAULT NULL' + ); + } + + if ($schema->hasTable('c_attendance_sheet')) { + $this->addSql( + 'ALTER TABLE c_attendance_sheet ADD signature VARCHAR(255) DEFAULT NULL' + ); + } + + if ($schema->hasTable('gradebook_category')) { + $this->addSql( + 'ALTER TABLE gradebook_category ADD allow_skills_by_subcategory INT DEFAULT 1' + ); + } + + if ($schema->hasTable('c_quiz')) { + $this->addSql( + 'ALTER TABLE c_quiz ADD hide_attempts_table TINYINT(1) NOT NULL' + ); + } + + if ($schema->hasTable('c_lp')) { + $this->addSql( + 'ALTER TABLE c_lp ADD next_lp_id INT DEFAULT 0 NOT NULL' + ); + } + } public function down(Schema $schema): void { + $table = $schema->getTable('c_lp'); + if ($table->hasColumn('next_lp_id')) { + $this->addSql('ALTER TABLE c_lp DROP next_lp_id'); + } + + $table = $schema->getTable('c_quiz'); + if ($table->hasColumn('hide_attempts_table')) { + $this->addSql('ALTER TABLE c_quiz DROP hide_attempts_table'); + } + + $table = $schema->getTable('gradebook_category'); + if ($table->hasColumn('allow_skills_by_subcategory')) { + $this->addSql('ALTER TABLE c_attendance_sheet DROP allow_skills_by_subcategory'); + } + + $table = $schema->getTable('c_attendance_sheet'); + if ($table->hasColumn('signature')) { + $this->addSql('ALTER TABLE c_attendance_sheet DROP signature'); + } + + $table = $schema->getTable('c_attendance_calendar'); + if ($table->hasColumn('blocked')) { + $this->addSql('ALTER TABLE c_attendance_calendar DROP blocked'); + } + + if ($schema->hasTable('c_attendance_result_comment')) { + $this->addSql( + 'DROP TABLE c_attendance_result_comment' + ); + } + + $table = $schema->getTable('portfolio'); + if ($table->hasColumn('origin')) { + $this->addSql('ALTER TABLE portfolio DROP origin'); + } + if ($table->hasColumn('origin_type')) { + $this->addSql('ALTER TABLE portfolio DROP origin_type'); + } + if ($table->hasColumn('score')) { + $this->addSql('ALTER TABLE portfolio DROP score'); + } + if ($table->hasColumn('is_highlighted')) { + $this->addSql('ALTER TABLE portfolio DROP is_highlighted'); + } + if ($table->hasColumn('is_template')) { + $this->addSql('ALTER TABLE portfolio DROP is_template'); + } + + if ($schema->hasTable('portfolio_attachment')) { + $this->addSql( + 'DROP TABLE portfolio_attachment' + ); + } + + if ($schema->hasTable('portfolio_comment')) { + $this->addSql( + 'DROP TABLE portfolio_comment' + ); + } + + if ($schema->hasTable('message_feedback')) { + $this->addSql( + 'DROP TABLE message_feedback' + ); + } + + $table = $schema->getTable('c_survey_answer'); + if ($table->hasColumn('session_id')) { + $this->addSql('ALTER TABLE c_survey_answer DROP session_id'); + } + if ($table->hasColumn('c_lp_item_id')) { + $this->addSql('ALTER TABLE c_survey_answer DROP c_lp_item_id'); + } + + $table = $schema->getTable('c_survey_invitation'); + if ($table->hasColumn('c_lp_item_id')) { + $this->addSql('ALTER TABLE c_survey_invitation DROP c_lp_item_id'); + } + + if ($schema->hasTable('notification_event_rel_user')) { + $this->addSql( + 'DROP TABLE notification_event_rel_user' + ); + } + + if ($schema->hasTable('c_wiki_category')) { + $this->addSql( + 'DROP TABLE c_wiki_category' + ); + } + + if ($schema->hasTable('c_wiki_rel_category')) { + $this->addSql( + 'DROP TABLE c_wiki_rel_category' + ); + } + + $table = $schema->getTable('system_template'); + if ($table->hasColumn('language')) { + $this->addSql('ALTER TABLE system_template DROP language'); + } + if ($schema->hasTable('notification_event')) { $this->addSql( 'DROP TABLE notification_event' diff --git a/src/CoreBundle/Repository/Node/UserRepository.php b/src/CoreBundle/Repository/Node/UserRepository.php index a6d19d5044..c57a211932 100644 --- a/src/CoreBundle/Repository/Node/UserRepository.php +++ b/src/CoreBundle/Repository/Node/UserRepository.php @@ -494,15 +494,15 @@ class UserRepository extends ResourceRepository implements PasswordUpgraderInter // All users if ('true' === $allowSendMessageToAllUsers || api_is_platform_admin()) { $this->addNotCurrentUserQueryBuilder($currentUserId, $qb); - /*$dql = "SELECT DISTINCT U - FROM ChamiloCoreBundle:User U - LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R - WITH U = R.user - WHERE - U.active = 1 AND - U.status != 6 AND - U.id != {$currentUserId} AND - R.url = {$accessUrlId}";*/ + /*$dql = "SELECT DISTINCT U + FROM ChamiloCoreBundle:User U + LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R + WITH U = R.user + WHERE + U.active = 1 AND + U.status != 6 AND + U.id != {$currentUserId} AND + R.url = {$accessUrlId}";*/ } else { $this->addOnlyMyFriendsQueryBuilder($currentUserId, $qb); /*$dql = 'SELECT DISTINCT U diff --git a/src/CoreBundle/Resources/config/settings.yml b/src/CoreBundle/Resources/config/settings.yml index 703efdde6f..e72c3c1432 100644 --- a/src/CoreBundle/Resources/config/settings.yml +++ b/src/CoreBundle/Resources/config/settings.yml @@ -185,3 +185,8 @@ services: class: Chamilo\CoreBundle\Settings\WebServiceSettingsSchema tags: - {name: sylius.settings_schema, alias: chamilo_core.settings.webservice, namespace: webservice} + + chamilo_core.settings.wiki: + class: Chamilo\CoreBundle\Settings\WikiSettingsSchema + tags: + - { name: sylius.settings_schema, alias: chamilo_core.settings.wiki, namespace: wiki } diff --git a/src/CoreBundle/Serializer/ResourceNormalizer.php b/src/CoreBundle/Serializer/ResourceNormalizer.php index c14d352ace..08b413634d 100644 --- a/src/CoreBundle/Serializer/ResourceNormalizer.php +++ b/src/CoreBundle/Serializer/ResourceNormalizer.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Chamilo\CoreBundle\Serializer; +use ArrayObject; use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceIllustrationInterface; use Chamilo\CoreBundle\Entity\User; @@ -34,7 +35,7 @@ final class ResourceNormalizer implements ContextAwareNormalizerInterface, Norma $this->illustrationRepository = $illustrationRepository; } - public function normalize($object, ?string $format = null, array $context = []): float|int|bool|\ArrayObject|array|string|null + public function normalize($object, ?string $format = null, array $context = []): float|int|bool|ArrayObject|array|string|null { $context[self::ALREADY_CALLED] = true; diff --git a/src/CoreBundle/Settings/AdminSettingsSchema.php b/src/CoreBundle/Settings/AdminSettingsSchema.php index 687c75abc4..1a3e4592b5 100644 --- a/src/CoreBundle/Settings/AdminSettingsSchema.php +++ b/src/CoreBundle/Settings/AdminSettingsSchema.php @@ -9,6 +9,7 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; use Sylius\Bundle\SettingsBundle\Schema\AbstractSettingsBuilder; use Symfony\Component\Form\Extension\Core\Type\EmailType; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; @@ -28,6 +29,12 @@ class AdminSettingsSchema extends AbstractSettingsSchema 'max_anonymous_users' => '0', 'send_inscription_notification_to_general_admin_only' => 'false', 'plugin_redirection_enabled' => 'false', + 'usergroup_do_not_unsubscribe_users_from_course_nor_session_on_user_unsubscribe' => 'false', + 'usergroup_do_not_unsubscribe_users_from_course_on_course_unsubscribe' => 'false', + 'usergroup_do_not_unsubscribe_users_from_session_on_session_unsubscribe' => 'false', + 'drh_allow_access_to_all_students' => 'false', + 'user_status_option_only_for_admin_enabled' => 'false', + 'user_status_option_show_only_for_admin' => '', ] ) ; @@ -59,6 +66,46 @@ class AdminSettingsSchema extends AbstractSettingsSchema ->add('max_anonymous_users', TextType::class) ->add('send_inscription_notification_to_general_admin_only', YesNoType::class) ->add('plugin_redirection_enabled', YesNoType::class) + ->add('usergroup_do_not_unsubscribe_users_from_course_nor_session_on_user_unsubscribe', YesNoType::class) + ->add('usergroup_do_not_unsubscribe_users_from_course_on_course_unsubscribe', YesNoType::class) + ->add('usergroup_do_not_unsubscribe_users_from_session_on_session_unsubscribe', YesNoType::class) + ->add('drh_allow_access_to_all_students', YesNoType::class) + ->add('user_status_option_only_for_admin_enabled', YesNoType::class) + ->add( + 'user_status_option_show_only_for_admin', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('The user status is hidden when is false, it requires user_status_option_only_for_admin_enabled = true'). + $this->settingArrayHelpValue('user_status_option_show_only_for_admin'), + ] + ) + + + ; } + + private function settingArrayHelpValue(string $variable): string + { + $values = [ + 'user_status_option_show_only_for_admin' => "
+                [
+                    'COURSEMANAGER' => false,
+                    'STUDENT' => false,
+                    'DRH' => false,
+                    'SESSIONADMIN' => true,
+                    'STUDENT_BOSS' => false,
+                    'INVITEE' => false,
+                ]
+                
", + ]; + + $returnValue = []; + if (isset($values[$variable])) { + $returnValue = $values[$variable]; + } + + return $returnValue; + } } diff --git a/src/CoreBundle/Settings/AgendaSettingsSchema.php b/src/CoreBundle/Settings/AgendaSettingsSchema.php index e9bcd6ea96..11f35756ea 100644 --- a/src/CoreBundle/Settings/AgendaSettingsSchema.php +++ b/src/CoreBundle/Settings/AgendaSettingsSchema.php @@ -10,6 +10,7 @@ use Chamilo\CoreBundle\Form\Type\YesNoType; use Sylius\Bundle\SettingsBundle\Schema\AbstractSettingsBuilder; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; class AgendaSettingsSchema extends AbstractSettingsSchema @@ -31,6 +32,11 @@ class AgendaSettingsSchema extends AbstractSettingsSchema 'agenda_legend' => '', 'agenda_colors' => '', 'agenda_on_hover_info' => '', + 'agenda_collective_invitations' => 'false', + 'agenda_event_subscriptions' => 'false', + 'agenda_reminders' => 'false', + 'agenda_reminders_sender_id' => '0', + 'fullcalendar_settings' => '', ] ) ; @@ -92,6 +98,21 @@ class AgendaSettingsSchema extends AbstractSettingsSchema $this->settingArrayHelpValue('agenda_on_hover_info'), ] ) + ->add('agenda_collective_invitations', YesNoType::class) + ->add('agenda_event_subscriptions', YesNoType::class) + ->add('agenda_reminders', YesNoType::class) + ->add('agenda_reminders_sender_id', TextType::class) + ->add( + 'fullcalendar_settings', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Extra settings for the agenda (FullCalendar v3)'). + $this->settingArrayHelpValue('fullcalendar_settings'), + ] + ) + + ; } @@ -123,6 +144,19 @@ class AgendaSettingsSchema extends AbstractSettingsSchema ] ] ", + 'fullcalendar_settings' => "
+                [
+                    'settings' => [
+                        'businessHours' => [
+                            // days of week. an array of zero-based day of week integers (0=Sunday)
+                            'dow' => [0, 1, 2, 3, 4], // Sunday - Thursday
+                            'start'  => '10:00',
+                            'end' => '18:00',
+                        ],
+                        'firstDay' => 0, // 0 = Sunday, 1 = Monday
+                    ]
+                ]
+                
", ]; $returnValue = []; diff --git a/src/CoreBundle/Settings/AnnouncementSettingsSchema.php b/src/CoreBundle/Settings/AnnouncementSettingsSchema.php index 6295617ee1..627b572081 100644 --- a/src/CoreBundle/Settings/AnnouncementSettingsSchema.php +++ b/src/CoreBundle/Settings/AnnouncementSettingsSchema.php @@ -27,6 +27,9 @@ class AnnouncementSettingsSchema extends AbstractSettingsSchema 'hide_announcement_sent_to_users_info' => 'false', 'send_all_emails_to' => '', 'allow_careers_in_global_announcements' => 'false', + 'announcements_hide_send_to_hrm_users' => 'false', + 'allow_coach_to_edit_announcements' => 'false', + 'course_announcement_scheduled_by_date' => 'false', ] ) ; @@ -59,6 +62,9 @@ class AnnouncementSettingsSchema extends AbstractSettingsSchema ] ) ->add('allow_careers_in_global_announcements', YesNoType::class) + ->add('announcements_hide_send_to_hrm_users', YesNoType::class) + ->add('allow_coach_to_edit_announcements', YesNoType::class) + ->add('course_announcement_scheduled_by_date', YesNoType::class) ; } diff --git a/src/CoreBundle/Settings/AttendanceSettingsSchema.php b/src/CoreBundle/Settings/AttendanceSettingsSchema.php index 7838f7d847..5ebc07ead3 100644 --- a/src/CoreBundle/Settings/AttendanceSettingsSchema.php +++ b/src/CoreBundle/Settings/AttendanceSettingsSchema.php @@ -18,6 +18,9 @@ class AttendanceSettingsSchema extends AbstractSettingsSchema ->setDefaults( [ 'allow_delete_attendance' => 'true', + 'enable_sign_attendance_sheet' => 'false', + 'attendance_calendar_set_duration' => 'false', + 'attendance_allow_comments' => 'false', ] ) // ->setAllowedTypes( @@ -37,6 +40,9 @@ class AttendanceSettingsSchema extends AbstractSettingsSchema 'help' => 'AttendanceDeletionEnableComment', ] ) + ->add('enable_sign_attendance_sheet', YesNoType::class) + ->add('attendance_calendar_set_duration', YesNoType::class) + ->add('attendance_allow_comments', YesNoType::class) ; } } diff --git a/src/CoreBundle/Settings/CertificateSettingsSchema.php b/src/CoreBundle/Settings/CertificateSettingsSchema.php index 6f357b3093..a995174c8b 100644 --- a/src/CoreBundle/Settings/CertificateSettingsSchema.php +++ b/src/CoreBundle/Settings/CertificateSettingsSchema.php @@ -19,6 +19,7 @@ class CertificateSettingsSchema extends AbstractSettingsSchema [ 'hide_my_certificate_link' => 'false', 'hide_header_footer' => 'false', + 'add_certificate_pdf_footer' => 'false', ] ) ; @@ -34,6 +35,7 @@ class CertificateSettingsSchema extends AbstractSettingsSchema $builder ->add('hide_my_certificate_link', YesNoType::class) ->add('hide_header_footer', YesNoType::class) + ->add('add_certificate_pdf_footer', YesNoType::class) ; } } diff --git a/src/CoreBundle/Settings/CourseSettingsSchema.php b/src/CoreBundle/Settings/CourseSettingsSchema.php index 68a5d328d6..f37b77f078 100644 --- a/src/CoreBundle/Settings/CourseSettingsSchema.php +++ b/src/CoreBundle/Settings/CourseSettingsSchema.php @@ -105,6 +105,20 @@ class CourseSettingsSchema extends AbstractSettingsSchema 'course_log_hide_columns' => '', 'course_student_info' => '', 'course_catalog_settings' => '', + 'resource_sequence_show_dependency_in_course_intro' => 'false', + 'course_catalog_display_in_home' => 'false', + 'course_creation_form_set_course_category_mandatory' => 'false', + 'course_creation_form_hide_course_code' => 'false', + 'course_about_teacher_name_hide' => 'false', + 'course_visibility_change_only_admin' => 'false', + 'catalog_hide_public_link' => 'false', + 'course_log_default_extra_fields' => '', + 'show_courses_in_catalogue' => 'false', + 'courses_catalogue_show_only_category' => '', + 'course_creation_by_teacher_extra_fields_to_show' => '', + 'course_creation_form_set_extra_fields_mandatory' => '', + 'course_configuration_tool_extra_fields_to_show_and_edit' => '', + 'course_creation_user_course_extra_field_relation_to_prefill' => '', ] ) ->setTransformer( @@ -312,6 +326,70 @@ class CourseSettingsSchema extends AbstractSettingsSchema $this->settingArrayHelpValue('course_catalog_settings'), ] ) + ->add('resource_sequence_show_dependency_in_course_intro', YesNoType::class) + ->add('course_catalog_display_in_home', YesNoType::class) + ->add('course_creation_form_set_course_category_mandatory', YesNoType::class) + ->add('course_creation_form_hide_course_code', YesNoType::class) + ->add('course_about_teacher_name_hide', YesNoType::class) + ->add('course_visibility_change_only_admin', YesNoType::class) + ->add('catalog_hide_public_link', YesNoType::class) + ->add( + 'course_log_default_extra_fields', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Course log - User extra fields to show as columns for default'). + $this->settingArrayHelpValue('course_log_default_extra_fields'), + ] + ) + ->add('show_courses_in_catalogue', YesNoType::class) + ->add( + 'courses_catalogue_show_only_category', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Allows defining one or several categories of courses that will be visible in the course catalog'). + $this->settingArrayHelpValue('courses_catalogue_show_only_category'), + ] + ) + ->add( + 'course_creation_by_teacher_extra_fields_to_show', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Course extra fields to be presented on main/create_course/add_course.php'). + $this->settingArrayHelpValue('course_creation_by_teacher_extra_fields_to_show'), + ] + ) + ->add( + 'course_creation_form_set_extra_fields_mandatory', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Configuration setting to make some extra field required in course creation form'). + $this->settingArrayHelpValue('course_creation_form_set_extra_fields_mandatory'), + ] + ) + ->add( + 'course_configuration_tool_extra_fields_to_show_and_edit', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Course extra fields to be presented on course settings'). + $this->settingArrayHelpValue('course_configuration_tool_extra_fields_to_show_and_edit'), + ] + ) + ->add( + 'course_creation_user_course_extra_field_relation_to_prefill', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Relation to prefill course extra field with user extra field on course creacion on main/create_course/add_course.php and main/admin/course_add.php'). + $this->settingArrayHelpValue('course_creation_user_course_extra_field_relation_to_prefill'), + ] + ) + + ; } @@ -355,6 +433,29 @@ class CourseSettingsSchema extends AbstractSettingsSchema ], ] ", + 'course_log_default_extra_fields' => "
+                ['extra_fields' => ['office_address', 'office_phone_extension']]
+                
", + 'courses_catalogue_show_only_category' => "
+                ['Cat1','Cat2']
+                
", + 'course_creation_by_teacher_extra_fields_to_show' => "
+                ['fields' => ['ExtrafieldLabel1', 'ExtrafieldLabel2']]
+                
", + 'course_creation_form_set_extra_fields_mandatory' => "
+                ['fields' => ['fieldLabel1','fieldLabel2']]
+                
", + 'course_configuration_tool_extra_fields_to_show_and_edit' => "
+                ['fields' => ['ExtrafieldLabel1', 'ExtrafieldLabel2']]
+                
", + 'course_creation_user_course_extra_field_relation_to_prefill' => "
+                [
+                    'fields' => [
+                        'CourseExtrafieldLabel1' => 'UserExtrafieldLabel1',
+                        'CourseExtrafieldLabel2' => 'UserExtrafieldLabel2',
+                    ]
+                ]
+                
", ]; $returnValue = []; diff --git a/src/CoreBundle/Settings/DocumentSettingsSchema.php b/src/CoreBundle/Settings/DocumentSettingsSchema.php index b7ac9cf224..0179ad9798 100644 --- a/src/CoreBundle/Settings/DocumentSettingsSchema.php +++ b/src/CoreBundle/Settings/DocumentSettingsSchema.php @@ -66,6 +66,9 @@ class DocumentSettingsSchema extends AbstractSettingsSchema 'group_category_document_access' => 'false', 'allow_compilatio_tool' => 'false', 'compilatio_tool' => '', + 'documents_hide_download_icon' => 'false', + 'enable_x_sendfile_headers' => 'false', + 'documents_custom_cloud_link_list' => '', ] ) ->setTransformer( @@ -189,6 +192,19 @@ class DocumentSettingsSchema extends AbstractSettingsSchema $this->settingArrayHelpValue('compilatio_tool'), ] ) + ->add('documents_hide_download_icon', YesNoType::class) + ->add('enable_x_sendfile_headers', YesNoType::class) + ->add( + 'documents_custom_cloud_link_list', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Custom cloud link URLS, this requires enable_add_file_link = true'). + $this->settingArrayHelpValue('documents_custom_cloud_link_list'), + ] + ) + + ; } @@ -210,6 +226,9 @@ class DocumentSettingsSchema extends AbstractSettingsSchema ] ] ", + 'documents_custom_cloud_link_list' => "
+                ['links' => ['example.com', 'example2.com']]
+                
", ]; $returnValue = []; diff --git a/src/CoreBundle/Settings/EditorSettingsSchema.php b/src/CoreBundle/Settings/EditorSettingsSchema.php index 88b539e1b4..98f77034d9 100644 --- a/src/CoreBundle/Settings/EditorSettingsSchema.php +++ b/src/CoreBundle/Settings/EditorSettingsSchema.php @@ -8,6 +8,7 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; use Sylius\Bundle\SettingsBundle\Schema\AbstractSettingsBuilder; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; class EditorSettingsSchema extends AbstractSettingsSchema @@ -40,6 +41,11 @@ class EditorSettingsSchema extends AbstractSettingsSchema 'save_titles_as_html' => 'false', 'full_ckeditor_toolbar_set' => 'false', 'ck_editor_block_image_copy_paste' => 'false', + 'editor_driver_list' => '', + 'enable_uploadimage_editor' => 'false', + 'editor_settings' => '', + 'video_context_menu_hidden' => 'false', + 'video_player_renderers' => '', ] ) /*->setAllowedTypes( @@ -75,6 +81,59 @@ class EditorSettingsSchema extends AbstractSettingsSchema ->add('save_titles_as_html', YesNoType::class) ->add('full_ckeditor_toolbar_set', YesNoType::class) ->add('ck_editor_block_image_copy_paste', YesNoType::class) + ->add( + 'editor_driver_list', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('List of driver to plugin in ckeditor'). + $this->settingArrayHelpValue('editor_driver_list'), + ] + ) + ->add('enable_uploadimage_editor', YesNoType::class) + ->add( + 'editor_settings', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Ckeditor settings'). + $this->settingArrayHelpValue('editor_settings'), + ] + ) + ->add('video_context_menu_hidden', YesNoType::class) + ->add( + 'video_player_renderers', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Enable player renderers for YouTube, Vimeo, Facebook, DailyMotion, Twitch medias'). + $this->settingArrayHelpValue('video_player_renderers'), + ] + ) + + ; } + + private function settingArrayHelpValue(string $variable): string + { + $values = [ + 'editor_driver_list' => "
+                ['PersonalDriver', 'CourseDriver']
+                
", + 'editor_settings' => "
+                ['config' => ['youtube_responsive' => true, 'image_responsive' => true]]
+                
", + 'video_player_renderers' => "
+                ['renderers' => ['dailymotion', 'facebook', 'twitch', 'vimeo', 'youtube']]
+                
", + ]; + + $returnValue = []; + if (isset($values[$variable])) { + $returnValue = $values[$variable]; + } + + return $returnValue; + } } diff --git a/src/CoreBundle/Settings/ExerciseSettingsSchema.php b/src/CoreBundle/Settings/ExerciseSettingsSchema.php index ccb99a31e5..8e983d8f92 100644 --- a/src/CoreBundle/Settings/ExerciseSettingsSchema.php +++ b/src/CoreBundle/Settings/ExerciseSettingsSchema.php @@ -69,6 +69,22 @@ class ExerciseSettingsSchema extends AbstractSettingsSchema 'exercise_category_report_user_extra_fields' => '', 'score_grade_model' => '', 'allow_time_per_question' => 'false', + 'my_courses_show_pending_exercise_attempts' => 'false', + 'allow_quick_question_description_popup' => 'false', + 'exercise_hide_ip' => 'false', + 'tracking_my_progress_show_deleted_exercises' => 'false', + 'show_exercise_attempts_in_all_user_sessions' => 'false', + 'show_exercise_session_attempts_in_base_course' => 'false', + 'quiz_check_all_answers_before_end_test' => 'false', + 'quiz_discard_orphan_in_course_export' => 'false', + 'exercise_result_end_text_html_strict_filtering' => 'false', + 'question_exercise_html_strict_filtering' => 'false', + 'quiz_question_delete_automatically_when_deleting_exercise' => 'false', + 'quiz_question_allow_inter_course_linking' => 'false', + 'quiz_hide_attempts_table_on_start_page' => 'false', + 'quiz_hide_question_number' => 'false', + 'quiz_keep_alive_ping_interval' => '0', + 'exercise_embeddable_extra_types' => '', ] ) ; @@ -182,6 +198,31 @@ class ExerciseSettingsSchema extends AbstractSettingsSchema ] ) ->add('allow_time_per_question', YesNoType::class) + ->add('my_courses_show_pending_exercise_attempts', YesNoType::class) + ->add('allow_quick_question_description_popup', YesNoType::class) + ->add('exercise_hide_ip', YesNoType::class) + ->add('tracking_my_progress_show_deleted_exercises', YesNoType::class) + ->add('show_exercise_attempts_in_all_user_sessions', YesNoType::class) + ->add('show_exercise_session_attempts_in_base_course', YesNoType::class) + ->add('quiz_check_all_answers_before_end_test', YesNoType::class) + ->add('quiz_discard_orphan_in_course_export', YesNoType::class) + ->add('exercise_result_end_text_html_strict_filtering', YesNoType::class) + ->add('question_exercise_html_strict_filtering', YesNoType::class) + ->add('quiz_question_delete_automatically_when_deleting_exercise', YesNoType::class) + ->add('quiz_question_allow_inter_course_linking', YesNoType::class) + ->add('quiz_hide_attempts_table_on_start_page', YesNoType::class) + ->add('quiz_hide_question_number', YesNoType::class) + ->add('quiz_keep_alive_ping_interval', TextType::class) + ->add( + 'exercise_embeddable_extra_types', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Allow extends allowed question types for embeddable exercises. By default, only the following question types are allowed: 1, 2, 17'). + $this->settingArrayHelpValue('exercise_embeddable_extra_types'), + ] + ) + ; } @@ -250,6 +291,29 @@ class ExerciseSettingsSchema extends AbstractSettingsSchema ] ] ", + 'exercise_embeddable_extra_types' => "
+                Add this types to allow them in embeddable exercises:
+                 1 = Multiple choice
+                 2 = Multiple answers
+                 3 = Fill blanks or form
+                 4 = Matching
+                 5 = Open question
+                 9 = Exact Selection
+                10 = Unique answer with unknown
+                11 = Multiple answer true/false/don't know
+                12 = Combination true/false/don't know
+                13 = Oral expression
+                14 = Global multiple answer
+                16 = Calculated question
+                17 = Unique answer image
+                21 = Reading comprehension
+                22 = Multiple answer true/false/degree of certainty
+                23 = Upload answer
+
+                [
+                    'types' => [],
+                ]
+                
", ]; $returnValue = []; diff --git a/src/CoreBundle/Settings/ForumSettingsSchema.php b/src/CoreBundle/Settings/ForumSettingsSchema.php index 76532f0844..f64feb33de 100644 --- a/src/CoreBundle/Settings/ForumSettingsSchema.php +++ b/src/CoreBundle/Settings/ForumSettingsSchema.php @@ -25,6 +25,8 @@ class ForumSettingsSchema extends AbstractSettingsSchema 'hide_forum_post_revision_language' => 'false', 'allow_forum_post_revisions' => 'false', 'forum_fold_categories' => 'false', + 'allow_forum_category_language_filter' => 'false', + 'subscribe_users_to_forum_notifications_also_in_base_course' => 'false', ] ) ; @@ -54,6 +56,8 @@ class ForumSettingsSchema extends AbstractSettingsSchema ->add('hide_forum_post_revision_language', YesNoType::class) ->add('allow_forum_post_revisions', YesNoType::class) ->add('forum_fold_categories', YesNoType::class) + ->add('allow_forum_category_language_filter', YesNoType::class) + ->add('subscribe_users_to_forum_notifications_also_in_base_course', YesNoType::class) ; } } diff --git a/src/CoreBundle/Settings/GradebookSettingsSchema.php b/src/CoreBundle/Settings/GradebookSettingsSchema.php index 25c1c8af24..2445f2be73 100644 --- a/src/CoreBundle/Settings/GradebookSettingsSchema.php +++ b/src/CoreBundle/Settings/GradebookSettingsSchema.php @@ -57,6 +57,10 @@ class GradebookSettingsSchema extends AbstractSettingsSchema 'gradebook_flatview_extrafields_columns' => '', 'gradebook_pdf_export_settings' => '', 'allow_gradebook_comments' => 'false', + 'gradebook_display_extra_stats' => '', + 'gradebook_hide_table' => 'false', + 'gradebook_hide_link_to_item_for_student' => 'false', + 'gradebook_enable_subcategory_skills_independant_assignement' => 'false', ] ) ; @@ -159,6 +163,19 @@ class GradebookSettingsSchema extends AbstractSettingsSchema ] ) ->add('allow_gradebook_comments', YesNoType::class) + ->add( + 'gradebook_display_extra_stats', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Enable specific columns in gradebook table'). + $this->settingArrayHelpValue('gradebook_display_extra_stats'), + ] + ) + ->add('gradebook_hide_table', YesNoType::class) + ->add('gradebook_hide_link_to_item_for_student', YesNoType::class) + ->add('gradebook_enable_subcategory_skills_independant_assignement', YesNoType::class) + ; } @@ -184,6 +201,12 @@ class GradebookSettingsSchema extends AbstractSettingsSchema 'hide_feedback_textarea' => true, ] ", + 'gradebook_display_extra_stats' => "
+                [1] = Ranking
+                [2] = Best Score
+                [3] = Average
+                ['columns' => [1, 2, 3]]
+                
", ]; $returnValue = []; diff --git a/src/CoreBundle/Settings/LanguageSettingsSchema.php b/src/CoreBundle/Settings/LanguageSettingsSchema.php index 5598975e6b..b62574279c 100644 --- a/src/CoreBundle/Settings/LanguageSettingsSchema.php +++ b/src/CoreBundle/Settings/LanguageSettingsSchema.php @@ -32,6 +32,8 @@ class LanguageSettingsSchema extends AbstractSettingsSchema 'user_name_order' => '', 'user_name_sort' => '', 'language_flags_by_country' => 'false', + 'allow_course_multiple_languages' => 'false', + 'template_activate_language_filter' => 'false', ] ) ; @@ -92,6 +94,8 @@ class LanguageSettingsSchema extends AbstractSettingsSchema ->add('hide_dltt_markup') ->add('show_language_selector_in_menu', YesNoType::class) ->add('language_flags_by_country', YesNoType::class) + ->add('allow_course_multiple_languages', YesNoType::class) + ->add('template_activate_language_filter', YesNoType::class) ; $choices = [ diff --git a/src/CoreBundle/Settings/LearningPathSettingsSchema.php b/src/CoreBundle/Settings/LearningPathSettingsSchema.php index 544f61a635..a9c1c70440 100644 --- a/src/CoreBundle/Settings/LearningPathSettingsSchema.php +++ b/src/CoreBundle/Settings/LearningPathSettingsSchema.php @@ -48,6 +48,26 @@ class LearningPathSettingsSchema extends AbstractSettingsSchema 'lp_view_settings' => '', 'download_files_after_all_lp_finished' => '', 'allow_lp_subscription_to_usergroups' => 'false', + 'lp_fixed_encoding' => 'false', + 'lp_prerequisite_use_last_attempt_only' => 'false', + 'show_invisible_exercise_in_lp_list' => 'false', + 'force_edit_exercise_in_lp' => 'false', + 'student_follow_page_add_LP_subscription_info' => 'false', + 'lp_show_max_progress_instead_of_average' => 'false', + 'lp_show_max_progress_or_average_enable_course_level_redefinition' => 'false', + 'lp_allow_export_to_students' => 'false', + 'show_invisible_lp_in_course_home' => 'false', + 'lp_start_and_end_date_visible_in_student_view' => 'false', + 'scorm_lms_update_sco_status_all_time' => 'false', + 'scorm_upload_from_cache' => 'false', + 'lp_prerequisit_on_quiz_unblock_if_max_attempt_reached' => 'false', + 'student_follow_page_hide_lp_tests_average' => 'false', + 'student_follow_page_add_LP_acquisition_info' => 'false', + 'student_follow_page_add_LP_invisible_checkbox' => 'false', + 'student_follow_page_include_not_subscribed_lp_students' => 'false', + 'my_progress_course_tools_order' => '', + 'lp_enable_flow' => 'false', + 'lp_item_prerequisite_dates' => 'false', ] ) ; @@ -129,6 +149,34 @@ class LearningPathSettingsSchema extends AbstractSettingsSchema ] ) ->add('allow_lp_subscription_to_usergroups', YesNoType::class) + ->add('lp_fixed_encoding', YesNoType::class) + ->add('lp_prerequisite_use_last_attempt_only', YesNoType::class) + ->add('show_invisible_exercise_in_lp_list', YesNoType::class) + ->add('force_edit_exercise_in_lp', YesNoType::class) + ->add('student_follow_page_add_LP_subscription_info', YesNoType::class) + ->add('lp_show_max_progress_instead_of_average', YesNoType::class) + ->add('lp_show_max_progress_or_average_enable_course_level_redefinition', YesNoType::class) + ->add('lp_allow_export_to_students', YesNoType::class) + ->add('show_invisible_lp_in_course_home', YesNoType::class) + ->add('lp_start_and_end_date_visible_in_student_view', YesNoType::class) + ->add('scorm_lms_update_sco_status_all_time', YesNoType::class) + ->add('scorm_upload_from_cache', YesNoType::class) + ->add('lp_prerequisit_on_quiz_unblock_if_max_attempt_reached', YesNoType::class) + ->add('student_follow_page_hide_lp_tests_average', YesNoType::class) + ->add('student_follow_page_add_LP_acquisition_info', YesNoType::class) + ->add('student_follow_page_add_LP_invisible_checkbox', YesNoType::class) + ->add('student_follow_page_include_not_subscribed_lp_students', YesNoType::class) + ->add( + 'my_progress_course_tools_order', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Allow change the order to show the tools in "My progress" page'). + $this->settingArrayHelpValue('my_progress_course_tools_order'), + ] + ) + ->add('lp_enable_flow', YesNoType::class) + ->add('lp_item_prerequisite_dates', YesNoType::class) ; } @@ -156,6 +204,11 @@ class LearningPathSettingsSchema extends AbstractSettingsSchema 'download_files_after_all_lp_finished' => "
                 ['courses' => ['ABC' => [1, 100]]]
                 
", + 'my_progress_course_tools_order' => "
+                [
+                    'order' => ['quizzes', 'learning_paths', 'skills'],
+                ]
+                
", ]; $returnValue = []; diff --git a/src/CoreBundle/Settings/MailSettingsSchema.php b/src/CoreBundle/Settings/MailSettingsSchema.php index 9fd89be98d..0f9fb5ecc7 100644 --- a/src/CoreBundle/Settings/MailSettingsSchema.php +++ b/src/CoreBundle/Settings/MailSettingsSchema.php @@ -28,13 +28,13 @@ class MailSettingsSchema extends AbstractSettingsSchema 'allow_email_editor_for_anonymous' => 'true', 'messages_hide_mail_content' => 'false', 'send_inscription_msg_to_inbox' => 'false', - 'allow_user_message_tracking' => 'false', 'send_two_inscription_confirmation_mail' => 'false', 'show_user_email_in_notification' => 'false', 'send_notification_score_in_percentage' => 'false', 'mail_template_system' => 'false', 'cron_notification_mails' => '', 'cron_notification_help_desk' => '', + 'notifications_extended_footer_message' => '', ] ) ; @@ -52,7 +52,6 @@ class MailSettingsSchema extends AbstractSettingsSchema ->add('allow_email_editor_for_anonymous', YesNoType::class) ->add('messages_hide_mail_content', YesNoType::class) ->add('send_inscription_msg_to_inbox', YesNoType::class) - ->add('allow_user_message_tracking', YesNoType::class) ->add('send_two_inscription_confirmation_mail', YesNoType::class) ->add('show_user_email_in_notification', YesNoType::class) ->add('send_notification_score_in_percentage', YesNoType::class) @@ -75,6 +74,16 @@ class MailSettingsSchema extends AbstractSettingsSchema $this->settingArrayHelpValue('cron_notification_help_desk'), ] ) + ->add( + 'notifications_extended_footer_message', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Add a custom extra footer for notificacions emails for a specific language, for example for privacy policy notices. Multiple languages and paragraphs can be added'). + $this->settingArrayHelpValue('notifications_extended_footer_message'), + ] + ) + ; } @@ -86,7 +95,12 @@ class MailSettingsSchema extends AbstractSettingsSchema ['email@example.com', 'email2@example.com'] ", 'cron_notification_help_desk' => "
-                    ['email@example.com', 'email2@example.com']
+                ['email@example.com', 'email2@example.com']
+                
", + 'notifications_extended_footer_message' => "
+                ['english' => ['paragraphs' => [
+                    'Change or delete this paragraph or add another one'
+                ]]]
                 
", ]; diff --git a/src/CoreBundle/Settings/MessageSettingsSchema.php b/src/CoreBundle/Settings/MessageSettingsSchema.php index 0263df69a1..a254c957cb 100644 --- a/src/CoreBundle/Settings/MessageSettingsSchema.php +++ b/src/CoreBundle/Settings/MessageSettingsSchema.php @@ -22,6 +22,11 @@ class MessageSettingsSchema extends AbstractSettingsSchema 'message_max_upload_filesize' => '20971520', 'private_messages_about_user' => 'false', 'private_messages_about_user_visible_to_user' => 'false', + 'social_enable_messages_feedback' => 'false', + 'disable_dislike_option' => 'false', + 'enable_message_tags' => 'false', + 'allow_user_message_tracking' => 'false', + 'filter_interactivity_messages' => 'false', ] ) ; @@ -40,6 +45,13 @@ class MessageSettingsSchema extends AbstractSettingsSchema ->add('message_max_upload_filesize') ->add('private_messages_about_user', YesNoType::class) ->add('private_messages_about_user_visible_to_user', YesNoType::class) + ->add('social_enable_messages_feedback', YesNoType::class) + ->add('disable_dislike_option', YesNoType::class) + ->add('enable_message_tags', YesNoType::class) + ->add('allow_user_message_tracking', YesNoType::class) + ->add('filter_interactivity_messages', YesNoType::class) + + ; } } diff --git a/src/CoreBundle/Settings/PlatformSettingsSchema.php b/src/CoreBundle/Settings/PlatformSettingsSchema.php index aab0a92c1b..6f0d9441fe 100644 --- a/src/CoreBundle/Settings/PlatformSettingsSchema.php +++ b/src/CoreBundle/Settings/PlatformSettingsSchema.php @@ -72,6 +72,34 @@ class PlatformSettingsSchema extends AbstractSettingsSchema 'video_features' => '', 'table_row_list' => '', 'allow_portfolio_tool' => 'false', + 'session_stored_in_db_as_backup' => 'false', + 'memcache_server' => '', + 'session_stored_after_n_times' => '10', + 'default_template' => 'default', + 'aspell_bin' => '/usr/bin/hunspell', + 'aspell_opts' => '-a -d en_GB -H -i utf-8', + 'aspell_temp_dir' => './', + 'webservice_return_user_field' => 'oauth2_id', + 'multiple_url_hide_disabled_settings' => 'false', + 'login_max_attempt_before_blocking_account' => '0', + 'force_renew_password_at_first_login' => 'false', + 'hide_breadcrumb_if_not_allowed' => 'false', + 'extldap_config' => '', + 'update_student_expiration_x_date' => '', + 'user_status_show_options_enabled' => 'false', + 'user_status_show_option' => '', + 'user_number_of_days_for_default_expiration_date_per_role' => '', + 'user_edition_extra_field_to_check' => 'ExtrafieldLabel', + 'user_hide_never_expire_option' => 'false', + 'platform_logo_url' => 'https://chamilo.org', + 'use_career_external_id_as_identifier_in_diagrams' => 'false', + 'disable_webservices' => 'false', + 'webservice_enable_adminonly_api' => 'false', + 'plugin_settings' => '', + 'allow_working_time_edition' => 'false', + 'ticket_project_user_roles' => '', + 'disable_user_conditions_sender_id' => '0', + 'portfolio_advanced_sharing' => 'false', ] ) ->setTransformer( @@ -247,6 +275,91 @@ class PlatformSettingsSchema extends AbstractSettingsSchema ] ) ->add('allow_portfolio_tool', YesNoType::class) + ->add('session_stored_in_db_as_backup', YesNoType::class) + ->add( + 'memcache_server', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Define the different memcache servers available'). + $this->settingArrayHelpValue('memcache_server'), + ] + ) + ->add('session_stored_after_n_times', TextType::class) + ->add('default_template', TextType::class) + ->add('aspell_bin', TextType::class) + ->add('aspell_opts', TextType::class) + ->add('aspell_temp_dir', TextType::class) + ->add('webservice_return_user_field', TextType::class) + ->add('multiple_url_hide_disabled_settings', YesNoType::class) + ->add('login_max_attempt_before_blocking_account', TextType::class) + ->add('force_renew_password_at_first_login', YesNoType::class) + ->add('hide_breadcrumb_if_not_allowed', YesNoType::class) + ->add( + 'extldap_config', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Overwrites the app/config/auth.conf.php settings'). + $this->settingArrayHelpValue('extldap_config'), + ] + ) + ->add( + 'update_student_expiration_x_date', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Update user expiration in x days or months when login the first time'). + $this->settingArrayHelpValue('update_student_expiration_x_date'), + ] + ) + ->add('user_status_show_options_enabled', YesNoType::class) + ->add( + 'user_status_show_option', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('The user status is hidden when is false, it requires user_status_show_options_enabled = true'). + $this->settingArrayHelpValue('user_status_show_option'), + ] + ) + ->add( + 'user_number_of_days_for_default_expiration_date_per_role', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Set the default expiration date when a user is created by role and days'). + $this->settingArrayHelpValue('user_number_of_days_for_default_expiration_date_per_role'), + ] + ) + ->add('user_edition_extra_field_to_check', TextType::class) + ->add('user_hide_never_expire_option', YesNoType::class) + ->add('platform_logo_url', TextType::class) + ->add('use_career_external_id_as_identifier_in_diagrams', YesNoType::class) + ->add('disable_webservices', YesNoType::class) + ->add('webservice_enable_adminonly_api', YesNoType::class) + ->add( + 'plugin_settings', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Disables the following BBB plugin settings in the plugin form and use them in priority'). + $this->settingArrayHelpValue('plugin_settings'), + ] + ) + ->add('allow_working_time_edition', YesNoType::class) + ->add( + 'ticket_project_user_roles', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Allow ticket projects to be access by specific chamilo roles'). + $this->settingArrayHelpValue('ticket_project_user_roles'), + ] + ) + ->add('disable_user_conditions_sender_id', TextType::class) + ->add('portfolio_advanced_sharing', TextType::class) + ; } @@ -273,6 +386,63 @@ class PlatformSettingsSchema extends AbstractSettingsSchema 'table_row_list' => "
                 ['options' => [50, 100, 200, 500]]
                 
", + 'memcache_server' => "
+                [
+                    0 => [
+                        'host' => 'chamilo8',
+                        'port' => '11211',
+                    ],
+                    1 => [
+                        'host' => 'chamilo9',
+                        'port' => '11211',
+                    ],
+                ]
+                
", + 'extldap_config' => "
+                ['host' => '', 'port' => '']
+                
", + 'update_student_expiration_x_date' => "
+                [
+                    'days' => 0,
+                    'months' => 0,
+                ]
+                
", + 'user_status_show_option' => "
+                [
+                    'COURSEMANAGER' => true,
+                    'STUDENT' => true,
+                    'DRH' => false,
+                    'SESSIONADMIN' => false,
+                    'STUDENT_BOSS' => false,
+                    'INVITEE' => false
+                ]
+                
", + 'user_number_of_days_for_default_expiration_date_per_role' => "
+                [
+                    'COURSEMANAGER' => 365,
+                    'STUDENT' => 31,
+                    'DRH' => 31,
+                    'SESSIONADMIN' => 60,
+                    'STUDENT_BOSS' => 60,
+                    'INVITEE' => 31
+                ]
+                
", + 'plugin_settings' => "
+                [
+                    'bbb' => [
+                        'tool_enable' => 'true', // string value
+                        'host' => 'https://www.example.com',
+                        'salt' => 'abc123'
+                    ]
+                ]
+                
", + 'ticket_project_user_roles' => "
+                [
+                    'permissions' => [
+                        1 => [17] // project_id = 1, STUDENT_BOSS = 17
+                    ]
+                ]
+                
", ]; $returnValue = []; diff --git a/src/CoreBundle/Settings/ProfileSettingsSchema.php b/src/CoreBundle/Settings/ProfileSettingsSchema.php index 6faf2b7cbd..dac4c04e71 100644 --- a/src/CoreBundle/Settings/ProfileSettingsSchema.php +++ b/src/CoreBundle/Settings/ProfileSettingsSchema.php @@ -59,6 +59,9 @@ class ProfileSettingsSchema extends AbstractSettingsSchema 'required_extra_fields_in_inscription' => '', 'community_managers_user_list' => '', 'allow_social_map_fields' => '', + 'career_diagram_legend' => 'false', + 'career_diagram_disclaimer' => 'false', + 'linkedin_organization_id' => 'false', ] ) ->setTransformer( @@ -229,6 +232,11 @@ class ProfileSettingsSchema extends AbstractSettingsSchema $this->settingArrayHelpValue('allow_social_map_fields'), ] ) + ->add('career_diagram_legend', YesNoType::class) + ->add('career_diagram_disclaimer', YesNoType::class) + ->add('linkedin_organization_id', YesNoType::class) + + ; } diff --git a/src/CoreBundle/Settings/SecuritySettingsSchema.php b/src/CoreBundle/Settings/SecuritySettingsSchema.php index e2b5ad0670..b31adf3da8 100644 --- a/src/CoreBundle/Settings/SecuritySettingsSchema.php +++ b/src/CoreBundle/Settings/SecuritySettingsSchema.php @@ -41,6 +41,7 @@ class SecuritySettingsSchema extends AbstractSettingsSchema 'security_block_inactive_users_immediately' => 'false', 'password_requirements' => '', 'allow_online_users_by_status' => '', + 'security_session_cookie_samesite_none' => 'false', ] ); $allowedTypes = [ @@ -156,6 +157,7 @@ class SecuritySettingsSchema extends AbstractSettingsSchema $this->settingArrayHelpValue('allow_online_users_by_status'), ] ) + ->add('security_session_cookie_samesite_none', YesNoType::class) ; } diff --git a/src/CoreBundle/Settings/SessionSettingsSchema.php b/src/CoreBundle/Settings/SessionSettingsSchema.php index a74c97dd02..5538836903 100644 --- a/src/CoreBundle/Settings/SessionSettingsSchema.php +++ b/src/CoreBundle/Settings/SessionSettingsSchema.php @@ -69,6 +69,18 @@ class SessionSettingsSchema extends AbstractSettingsSchema 'catalog_settings' => '', 'allow_session_status' => 'false', 'tracking_columns' => '', + 'my_progress_session_show_all_courses' => 'false', + 'assignment_base_course_teacher_access_to_all_session' => 'false', + 'allow_session_admin_extra_access' => 'false', + 'hide_session_graph_in_my_progress' => 'false', + 'show_users_in_active_sessions_in_tracking' => 'false', + 'session_coach_access_after_duration_end' => 'false', + 'session_course_users_subscription_limited_to_session_users' => 'false', + 'session_classes_tab_disable' => 'false', + 'email_template_subscription_to_session_confirmation_username' => 'false', + 'email_template_subscription_to_session_confirmation_lost_password' => 'false', + 'session_creation_user_course_extra_field_relation_to_prefill' => '', + 'session_creation_form_set_extra_fields_mandatory' => '', ] ) ; @@ -188,6 +200,35 @@ class SessionSettingsSchema extends AbstractSettingsSchema $this->settingArrayHelpValue('tracking_columns'), ] ) + ->add('my_progress_session_show_all_courses', YesNoType::class) + ->add('assignment_base_course_teacher_access_to_all_session', YesNoType::class) + ->add('allow_session_admin_extra_access', YesNoType::class) + ->add('hide_session_graph_in_my_progress', YesNoType::class) + ->add('show_users_in_active_sessions_in_tracking', YesNoType::class) + ->add('session_coach_access_after_duration_end', YesNoType::class) + ->add('session_course_users_subscription_limited_to_session_users', YesNoType::class) + ->add('email_template_subscription_to_session_confirmation_username', YesNoType::class) + ->add('email_template_subscription_to_session_confirmation_lost_password', YesNoType::class) + ->add( + 'session_creation_user_course_extra_field_relation_to_prefill', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Relation to prefill session extra field with user extra field on session creation on main/session/session_add.php'). + $this->settingArrayHelpValue('session_creation_user_course_extra_field_relation_to_prefill'), + ] + ) + ->add( + 'session_creation_form_set_extra_fields_mandatory', + TextareaType::class, + [ + 'help_html' => true, + 'help' => get_lang('Configuration setting to make some extra field required in session creation form on main/session/session_add.php'). + $this->settingArrayHelpValue('session_creation_form_set_extra_fields_mandatory'), + ] + ) + + ; } @@ -261,6 +302,17 @@ class SessionSettingsSchema extends AbstractSettingsSchema ] ] ", + 'session_creation_user_course_extra_field_relation_to_prefill' => "
+                [
+                    'fields' => [
+                        'client' => 'client',
+                        'region' => 'region',
+                    ]
+                ]
+                
", + 'session_creation_form_set_extra_fields_mandatory' => "
+                ['fields' => ['client','region']]
+                
", ]; $returnValue = []; diff --git a/src/CoreBundle/Settings/SurveySettingsSchema.php b/src/CoreBundle/Settings/SurveySettingsSchema.php index 0fb407df97..ba38d49103 100644 --- a/src/CoreBundle/Settings/SurveySettingsSchema.php +++ b/src/CoreBundle/Settings/SurveySettingsSchema.php @@ -33,6 +33,8 @@ class SurveySettingsSchema extends AbstractSettingsSchema 'allow_mandatory_survey' => 'false', 'hide_survey_edition' => '', 'survey_additional_teacher_modify_actions' => '', + 'allow_survey_tool_in_lp' => 'false', + 'show_surveys_base_in_sessions' => 'false', ] ) ; @@ -85,6 +87,8 @@ class SurveySettingsSchema extends AbstractSettingsSchema $this->settingArrayHelpValue('survey_additional_teacher_modify_actions'), ] ) + ->add('allow_survey_tool_in_lp', YesNoType::class) + ->add('show_surveys_base_in_sessions', YesNoType::class) ; } diff --git a/src/CoreBundle/Settings/WikiSettingsSchema.php b/src/CoreBundle/Settings/WikiSettingsSchema.php new file mode 100644 index 0000000000..9d48b1bd94 --- /dev/null +++ b/src/CoreBundle/Settings/WikiSettingsSchema.php @@ -0,0 +1,37 @@ +setDefaults( + [ + 'wiki_categories_enabled' => 'false', + 'wiki_html_strict_filtering' => 'false', + + ] + ) + ; + } + + public function buildForm(FormBuilderInterface $builder): void + { + $builder + ->add('wiki_categories_enabled', YesNoType::class) + ->add('wiki_html_strict_filtering', YesNoType::class) + + ; + } +} diff --git a/src/CoreBundle/Settings/WorkSettingsSchema.php b/src/CoreBundle/Settings/WorkSettingsSchema.php index 720ef26985..26ee947163 100644 --- a/src/CoreBundle/Settings/WorkSettingsSchema.php +++ b/src/CoreBundle/Settings/WorkSettingsSchema.php @@ -27,6 +27,7 @@ class WorkSettingsSchema extends AbstractSettingsSchema 'considered_working_time' => 'work_time', 'force_download_doc_before_upload_work' => 'true', 'allow_redirect_to_main_page_after_work_upload' => 'false', + 'my_courses_show_pending_work' => 'false', ] ) ; @@ -45,6 +46,8 @@ class WorkSettingsSchema extends AbstractSettingsSchema ->add('considered_working_time', TextType::class) ->add('force_download_doc_before_upload_work', YesNoType::class) ->add('allow_redirect_to_main_page_after_work_upload', YesNoType::class) + ->add('my_courses_show_pending_work', YesNoType::class) + ; } } diff --git a/src/CourseBundle/Entity/CAnnouncement.php b/src/CourseBundle/Entity/CAnnouncement.php index 2a5afe4bf4..0dcde9f7cb 100644 --- a/src/CourseBundle/Entity/CAnnouncement.php +++ b/src/CourseBundle/Entity/CAnnouncement.php @@ -13,11 +13,12 @@ use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_announcement')] #[ORM\Entity(repositoryClass: CAnnouncementRepository::class)] -class CAnnouncement extends AbstractResource implements ResourceInterface, \Stringable +class CAnnouncement extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CAnnouncementAttachment.php b/src/CourseBundle/Entity/CAnnouncementAttachment.php index ea903770fb..8001fdc421 100644 --- a/src/CourseBundle/Entity/CAnnouncementAttachment.php +++ b/src/CourseBundle/Entity/CAnnouncementAttachment.php @@ -9,13 +9,14 @@ namespace Chamilo\CourseBundle\Entity; use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; use Doctrine\ORM\Mapping as ORM; +use Stringable; /** * CAnnouncementAttachment. */ #[ORM\Table(name: 'c_announcement_attachment')] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CAnnouncementAttachmentRepository::class)] -class CAnnouncementAttachment extends AbstractResource implements ResourceInterface, \Stringable +class CAnnouncementAttachment extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CAttendance.php b/src/CourseBundle/Entity/CAttendance.php index 66764b25ca..1c323a2a74 100644 --- a/src/CourseBundle/Entity/CAttendance.php +++ b/src/CourseBundle/Entity/CAttendance.php @@ -11,12 +11,13 @@ use Chamilo\CoreBundle\Entity\ResourceInterface; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_attendance')] #[ORM\Index(name: 'active', columns: ['active'])] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CAttendanceRepository::class)] -class CAttendance extends AbstractResource implements ResourceInterface, \Stringable +class CAttendance extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -202,7 +203,7 @@ class CAttendance extends AbstractResource implements ResourceInterface, \String /** * @return CAttendanceSheetLog[]|Collection */ - public function getLogs(): array|\Doctrine\Common\Collections\Collection + public function getLogs(): array|Collection { return $this->logs; } @@ -210,7 +211,7 @@ class CAttendance extends AbstractResource implements ResourceInterface, \String /** * @param CAttendanceSheetLog[]|Collection $logs */ - public function setLogs(array|\Doctrine\Common\Collections\Collection $logs): self + public function setLogs(array|Collection $logs): self { $this->logs = $logs; @@ -220,7 +221,7 @@ class CAttendance extends AbstractResource implements ResourceInterface, \String /** * @return CAttendanceResult[]|Collection */ - public function getResults(): array|\Doctrine\Common\Collections\Collection + public function getResults(): array|Collection { return $this->results; } diff --git a/src/CourseBundle/Entity/CAttendanceCalendar.php b/src/CourseBundle/Entity/CAttendanceCalendar.php index e8497f583e..d0c2afd0bb 100644 --- a/src/CourseBundle/Entity/CAttendanceCalendar.php +++ b/src/CourseBundle/Entity/CAttendanceCalendar.php @@ -30,6 +30,9 @@ class CAttendanceCalendar #[ORM\Column(name: 'done_attendance', type: 'boolean', nullable: false)] protected bool $doneAttendance; + #[ORM\Column(name: 'blocked', type: 'boolean', nullable: false)] + protected bool $blocked; + /** * @var Collection|CAttendanceSheet[] */ @@ -82,10 +85,22 @@ class CAttendanceCalendar return $this->doneAttendance; } + public function setBlocked($blocked): self + { + $this->blocked = $blocked; + + return $this; + } + + public function getBlocked(): bool + { + return $this->blocked; + } + /** * @return CAttendanceSheet[]|Collection */ - public function getSheets(): array|\Doctrine\Common\Collections\Collection + public function getSheets(): array|Collection { return $this->sheets; } @@ -93,7 +108,7 @@ class CAttendanceCalendar /** * @param CAttendanceSheet[]|Collection $sheets */ - public function setSheets(array|\Doctrine\Common\Collections\Collection $sheets): self + public function setSheets(array|Collection $sheets): self { $this->sheets = $sheets; diff --git a/src/CourseBundle/Entity/CAttendanceResultComment.php b/src/CourseBundle/Entity/CAttendanceResultComment.php new file mode 100644 index 0000000000..de34234ebf --- /dev/null +++ b/src/CourseBundle/Entity/CAttendanceResultComment.php @@ -0,0 +1,199 @@ +createdAt = new \DateTime(); + $this->updatedAt = new \DateTime(); + } + + /** + * Get attendanceSheetId. + */ + public function getAttendanceSheetId(): int + { + return $this->attendanceSheetId; + } + + /** + * Set attendanceSheetId. + * + * @return CAttendanceResultComment + */ + public function setAttendanceSheetId(int $attendanceSheetId) + { + $this->attendanceSheetId = $attendanceSheetId; + + return $this; + } + + /** + * Set userId. + * + * @param int $userId + * + * @return CAttendanceResultComment + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId. + * + * @return int + */ + public function getUserId() + { + return $this->userId; + } + + /** + * @param \DateTime $createdAt + * + * @return CAttendanceResultComment + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * @param \DateTime $updatedAt + * + * @return CAttendanceResultComment + */ + public function setUpdatedAt($updatedAt) + { + $this->updatedAt = $updatedAt; + + return $this; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * Set comment. + * + * @param string $comment + * + * @return CAttendanceResultComment + */ + public function setComment($comment) + { + $this->comment = $comment; + + return $this; + } + + /** + * Get comment. + * + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * Set authorUserId. + * + * @param int $authorUserId + * + * @return CAttendanceResultComment + */ + public function setAuthorUserId($authorUserId) + { + $this->authorUserId = $authorUserId; + + return $this; + } + + /** + * Get authorUserId. + * + * @return int + */ + public function getAuthorUserId() + { + return $this->authorUserId; + } +} diff --git a/src/CourseBundle/Entity/CAttendanceSheet.php b/src/CourseBundle/Entity/CAttendanceSheet.php index 18b7974caa..95b2a89fd9 100644 --- a/src/CourseBundle/Entity/CAttendanceSheet.php +++ b/src/CourseBundle/Entity/CAttendanceSheet.php @@ -32,6 +32,9 @@ class CAttendanceSheet #[ORM\JoinColumn(name: 'attendance_calendar_id', referencedColumnName: 'iid', onDelete: 'CASCADE')] protected CAttendanceCalendar $attendanceCalendar; + #[ORM\Column(name: 'signature', type: 'string', nullable: false)] + protected $signature; + public function setPresence(bool $presence): self { $this->presence = $presence; @@ -44,6 +47,28 @@ class CAttendanceSheet return $this->presence; } + /** + * Set signature. + * + * @return CAttendanceSheet + */ + public function setSignature(string $signature) + { + $this->signature = $signature; + + return $this; + } + + /** + * Get signature. + * + * @return string + */ + public function getSignature() + { + return $this->signature; + } + public function getUser(): User { return $this->user; diff --git a/src/CourseBundle/Entity/CCalendarEvent.php b/src/CourseBundle/Entity/CCalendarEvent.php index 0a28f7cf7d..6faf87ec1f 100644 --- a/src/CourseBundle/Entity/CCalendarEvent.php +++ b/src/CourseBundle/Entity/CCalendarEvent.php @@ -1,6 +1,6 @@ ['media_object_create', 'document:write']]), new Put(deserialize: false, security: 'is_granted(\'EDIT\', object.resourceNode)', uriTemplate: '/documents/{iid}/toggle_visibility', controller: UpdateVisibilityDocument::class), new Get(security: 'is_granted(\'VIEW\', object.resourceNode)'), new Delete(security: 'is_granted(\'DELETE\', object.resourceNode)'), new Post(controller: CreateDocumentFileAction::class, deserialize: false, security: 'is_granted(\'ROLE_CURRENT_COURSE_TEACHER\') or is_granted(\'ROLE_CURRENT_COURSE_SESSION_TEACHER\')', validationContext: ['groups' => ['Default', 'media_object_create', 'document:write']], openapiContext: ['requestBody' => ['content' => ['multipart/form-data' => ['schema' => ['type' => 'object', 'properties' => ['title' => ['type' => 'string'], 'filetype' => ['type' => 'string', 'enum' => ['folder', 'file']], 'comment' => ['type' => 'string'], 'contentFile' => ['type' => 'string'], 'uploadFile' => ['type' => 'string', 'format' => 'binary'], 'parentResourceNodeId' => ['type' => 'integer'], 'resourceLinkList' => ['type' => 'array', 'items' => ['type' => 'object', 'properties' => ['visibility' => ['type' => 'integer'], 'cid' => ['type' => 'integer'], 'gid' => ['type' => 'integer'], 'sid' => ['type' => 'integer']]]]]]]]]]), new GetCollection(openapiContext: ['parameters' => [['name' => 'resourceNode.parent', 'in' => 'query', 'required' => true, 'description' => 'Resource node Parent', 'schema' => ['type' => 'integer']], ['name' => 'cid', 'in' => 'query', 'required' => true, 'description' => 'Course id', 'schema' => ['type' => 'integer']], ['name' => 'sid', 'in' => 'query', 'required' => false, 'description' => 'Session id', 'schema' => ['type' => 'integer']]]])], shortName: 'Documents', normalizationContext: ['groups' => ['document:read', 'resource_node:read']], denormalizationContext: ['groups' => ['document:write']])] -#[ORM\Table(name: "c_document")] -#[ORM\Index(name: "idx_cdoc_type", columns: ["filetype"])] + +#[ApiResource(shortName: 'Documents', operations: [new Put(controller: UpdateDocumentFileAction::class, deserialize: false, security: 'is_granted(\'EDIT\', object.resourceNode)', validationContext: ['groups' => ['media_object_create', 'document:write']]), new Put(deserialize: false, security: 'is_granted(\'EDIT\', object.resourceNode)', uriTemplate: '/documents/{iid}/toggle_visibility', controller: UpdateVisibilityDocument::class), new Get(security: 'is_granted(\'VIEW\', object.resourceNode)'), new Delete(security: 'is_granted(\'DELETE\', object.resourceNode)'), new Post(controller: CreateDocumentFileAction::class, deserialize: false, security: 'is_granted(\'ROLE_CURRENT_COURSE_TEACHER\') or is_granted(\'ROLE_CURRENT_COURSE_SESSION_TEACHER\')', validationContext: ['groups' => ['Default', 'media_object_create', 'document:write']], openapiContext: ['requestBody' => ['content' => ['multipart/form-data' => ['schema' => ['type' => 'object', 'properties' => ['title' => ['type' => 'string'], 'filetype' => ['type' => 'string', 'enum' => ['folder', 'file']], 'comment' => ['type' => 'string'], 'contentFile' => ['type' => 'string'], 'uploadFile' => ['type' => 'string', 'format' => 'binary'], 'parentResourceNodeId' => ['type' => 'integer'], 'resourceLinkList' => ['type' => 'array', 'items' => ['type' => 'object', 'properties' => ['visibility' => ['type' => 'integer'], 'cid' => ['type' => 'integer'], 'gid' => ['type' => 'integer'], 'sid' => ['type' => 'integer']]]]]]]]]]), new GetCollection(openapiContext: ['parameters' => [['name' => 'resourceNode.parent', 'in' => 'query', 'required' => true, 'description' => 'Resource node Parent', 'schema' => ['type' => 'integer']], ['name' => 'cid', 'in' => 'query', 'required' => true, 'description' => 'Course id', 'schema' => ['type' => 'integer']], ['name' => 'sid', 'in' => 'query', 'required' => false, 'description' => 'Session id', 'schema' => ['type' => 'integer']]]])], normalizationContext: ['groups' => ['document:read', 'resource_node:read']], denormalizationContext: ['groups' => ['document:write']])] +#[ORM\Table(name: 'c_document')] +#[ORM\Index(columns: ['filetype'], name: 'idx_cdoc_type')] #[ORM\Entity(repositoryClass: CDocumentRepository::class)] #[ORM\EntityListeners([ResourceListener::class])] #[ApiFilter(filterClass: PropertyFilter::class)] #[ApiFilter(filterClass: SearchFilter::class, properties: ['title' => 'partial', 'resourceNode.parent' => 'exact'])] #[ApiFilter(filterClass: OrderFilter::class, properties: ['iid', 'filetype', 'resourceNode.title', 'resourceNode.createdAt', 'resourceNode.resourceFile.size', 'resourceNode.updatedAt'])] -class CDocument extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, \Stringable +class CDocument extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, Stringable { #[ApiProperty(identifier: true)] #[Groups(['document:read'])] @@ -68,52 +68,57 @@ class CDocument extends AbstractResource implements ResourceInterface, ResourceS $this->readonly = false; $this->template = false; } - public function __toString() : string + public function __toString(): string { return $this->getTitle(); } - public function isTemplate() : bool + public function isTemplate(): bool { return $this->template; } - public function setTemplate(bool $template) : self + public function setTemplate(bool $template): self { $this->template = $template; + return $this; } - public function setComment(?string $comment) : self + public function setComment(?string $comment): self { $this->comment = $comment; + return $this; } - public function getComment() : ?string + public function getComment(): ?string { return $this->comment; } - public function setTitle(string $title) : self + public function setTitle(string $title): self { $this->title = $title; + return $this; } - public function getTitle() : string + public function getTitle(): string { return $this->title; } - public function setFiletype(string $filetype) : self + public function setFiletype(string $filetype): self { $this->filetype = $filetype; + return $this; } - public function getFiletype() : string + public function getFiletype(): string { return $this->filetype; } - public function setReadonly(bool $readonly) : self + public function setReadonly(bool $readonly): self { $this->readonly = $readonly; + return $this; } - public function getReadonly() : bool + public function getReadonly(): bool { return $this->readonly; } @@ -124,15 +129,15 @@ class CDocument extends AbstractResource implements ResourceInterface, ResourceS { return $this->iid; } - public function getResourceIdentifier() : int + public function getResourceIdentifier(): int { return $this->getIid(); } - public function getResourceName() : string + public function getResourceName(): string { return $this->getTitle(); } - public function setResourceName(string $name) : self + public function setResourceName(string $name): self { return $this->setTitle($name); } diff --git a/src/CourseBundle/Entity/CExerciseCategory.php b/src/CourseBundle/Entity/CExerciseCategory.php index 01c3120026..2c935808f5 100644 --- a/src/CourseBundle/Entity/CExerciseCategory.php +++ b/src/CourseBundle/Entity/CExerciseCategory.php @@ -12,11 +12,12 @@ use Chamilo\CoreBundle\Entity\ResourceInterface; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Timestampable\Traits\TimestampableEntity; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_exercise_category')] #[ORM\Entity(repositoryClass: \Gedmo\Sortable\Entity\Repository\SortableRepository::class)] -class CExerciseCategory extends AbstractResource implements ResourceInterface, \Stringable +class CExerciseCategory extends AbstractResource implements ResourceInterface, Stringable { use TimestampableEntity; diff --git a/src/CourseBundle/Entity/CForum.php b/src/CourseBundle/Entity/CForum.php index 80d52573d7..dac6eb7b8a 100644 --- a/src/CourseBundle/Entity/CForum.php +++ b/src/CourseBundle/Entity/CForum.php @@ -13,6 +13,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -20,7 +21,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'c_forum_forum')] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CForumRepository::class)] -class CForum extends AbstractResource implements ResourceInterface, \Stringable +class CForum extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -193,10 +194,7 @@ class CForum extends AbstractResource implements ResourceInterface, \Stringable return $this; } - /** - * Get forumCategory. - */ - public function getForumCategory(): ?\Chamilo\CourseBundle\Entity\CForumCategory + public function getForumCategory(): ?CForumCategory { return $this->forumCategory; } @@ -447,7 +445,7 @@ class CForum extends AbstractResource implements ResourceInterface, \Stringable * * @return Collection|CForumThread[] */ - public function getThreads(): \Doctrine\Common\Collections\Collection|array + public function getThreads(): Collection|array { return $this->threads; } @@ -479,7 +477,7 @@ class CForum extends AbstractResource implements ResourceInterface, \Stringable /** * @return Collection|CForumPost[] */ - public function getPosts(): \Doctrine\Common\Collections\Collection|array + public function getPosts(): Collection|array { return $this->posts; } diff --git a/src/CourseBundle/Entity/CForumAttachment.php b/src/CourseBundle/Entity/CForumAttachment.php index 1cf97e27a0..2f76fc6552 100644 --- a/src/CourseBundle/Entity/CForumAttachment.php +++ b/src/CourseBundle/Entity/CForumAttachment.php @@ -10,11 +10,12 @@ use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CourseBundle\Repository\CForumAttachmentRepository; use Doctrine\ORM\Mapping as ORM; +use Stringable; #[ORM\Table(name: 'c_forum_attachment')] #[ORM\Index(name: 'course', columns: ['c_id'])] #[ORM\Entity(repositoryClass: CForumAttachmentRepository::class)] -class CForumAttachment extends AbstractResource implements ResourceInterface, \Stringable +class CForumAttachment extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CForumCategory.php b/src/CourseBundle/Entity/CForumCategory.php index 55b80657f8..6b8a258b5c 100644 --- a/src/CourseBundle/Entity/CForumCategory.php +++ b/src/CourseBundle/Entity/CForumCategory.php @@ -12,11 +12,12 @@ use Chamilo\CourseBundle\Repository\CForumCategoryRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_forum_category')] #[ORM\Entity(repositoryClass: CForumCategoryRepository::class)] -class CForumCategory extends AbstractResource implements ResourceInterface, \Stringable +class CForumCategory extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -133,7 +134,7 @@ class CForumCategory extends AbstractResource implements ResourceInterface, \Str * * @return Collection|CForum[] */ - public function getForums(): \Doctrine\Common\Collections\Collection|array + public function getForums(): Collection|array { return $this->forums; } diff --git a/src/CourseBundle/Entity/CForumPost.php b/src/CourseBundle/Entity/CForumPost.php index ae1a677879..2b663aa828 100644 --- a/src/CourseBundle/Entity/CForumPost.php +++ b/src/CourseBundle/Entity/CForumPost.php @@ -14,6 +14,7 @@ use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -24,7 +25,7 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Index(name: 'idx_forum_post_thread_id', columns: ['thread_id'])] #[ORM\Index(name: 'idx_forum_post_visible', columns: ['visible'])] #[ORM\Entity(repositoryClass: CForumPostRepository::class)] -class CForumPost extends AbstractResource implements ResourceInterface, \Stringable +class CForumPost extends AbstractResource implements ResourceInterface, Stringable { public const STATUS_VALIDATED = 1; public const STATUS_WAITING_MODERATION = 2; @@ -69,14 +70,14 @@ class CForumPost extends AbstractResource implements ResourceInterface, \Stringa #[ORM\JoinColumn(name: 'poster_id', referencedColumnName: 'id')] protected ?User $user = null; - #[ORM\ManyToOne(targetEntity: CForumPost::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] #[ORM\JoinColumn(name: 'post_parent_id', referencedColumnName: 'iid', onDelete: 'SET NULL')] protected ?CForumPost $postParent = null; /** * @var Collection|CForumPost[] */ - #[ORM\OneToMany(targetEntity: CForumPost::class, mappedBy: 'postParent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'postParent')] protected Collection $children; /** @@ -264,7 +265,7 @@ class CForumPost extends AbstractResource implements ResourceInterface, \Stringa /** * @return CForumPost[]|Collection */ - public function getChildren(): array|\Doctrine\Common\Collections\Collection + public function getChildren(): array|Collection { return $this->children; } @@ -272,7 +273,7 @@ class CForumPost extends AbstractResource implements ResourceInterface, \Stringa /** * @param CForumPost[]|Collection $children */ - public function setChildren(array|\Doctrine\Common\Collections\Collection $children): self + public function setChildren(array|Collection $children): self { $this->children = $children; diff --git a/src/CourseBundle/Entity/CForumThread.php b/src/CourseBundle/Entity/CForumThread.php index 27422ef4d9..7066a184b9 100644 --- a/src/CourseBundle/Entity/CForumThread.php +++ b/src/CourseBundle/Entity/CForumThread.php @@ -14,6 +14,7 @@ use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -21,7 +22,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'c_forum_thread')] #[ORM\Entity(repositoryClass: CForumThreadRepository::class)] -class CForumThread extends AbstractResource implements ResourceInterface, \Stringable +class CForumThread extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -321,7 +322,7 @@ class CForumThread extends AbstractResource implements ResourceInterface, \Strin /** * @return Collection|CForumPost[] */ - public function getPosts(): \Doctrine\Common\Collections\Collection|array + public function getPosts(): Collection|array { return $this->posts; } @@ -341,7 +342,7 @@ class CForumThread extends AbstractResource implements ResourceInterface, \Strin /** * @return CForumThreadQualify[]|Collection */ - public function getQualifications(): array|\Doctrine\Common\Collections\Collection + public function getQualifications(): array|Collection { return $this->qualifications; } @@ -349,7 +350,7 @@ class CForumThread extends AbstractResource implements ResourceInterface, \Strin /** * @param CForumThreadQualify[]|Collection $qualifications */ - public function setQualifications(array|\Doctrine\Common\Collections\Collection $qualifications): self + public function setQualifications(array|Collection $qualifications): self { $this->qualifications = $qualifications; diff --git a/src/CourseBundle/Entity/CGlossary.php b/src/CourseBundle/Entity/CGlossary.php index 88d0a79b04..68634eadd8 100644 --- a/src/CourseBundle/Entity/CGlossary.php +++ b/src/CourseBundle/Entity/CGlossary.php @@ -9,6 +9,7 @@ namespace Chamilo\CourseBundle\Entity; use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -16,7 +17,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'c_glossary')] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CGlossaryRepository::class)] -class CGlossary extends AbstractResource implements ResourceInterface, \Stringable +class CGlossary extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CGroup.php b/src/CourseBundle/Entity/CGroup.php index 55b5b6aee5..16ae4a836e 100644 --- a/src/CourseBundle/Entity/CGroup.php +++ b/src/CourseBundle/Entity/CGroup.php @@ -1,20 +1,13 @@ ['group:read']])] #[ORM\Table(name: 'c_group_info')] #[ORM\Entity(repositoryClass: CGroupRepository::class)] -class CGroup extends AbstractResource implements ResourceInterface, \Stringable +class CGroup extends AbstractResource implements ResourceInterface, Stringable { public const TOOL_NOT_AVAILABLE = 0; public const TOOL_PUBLIC = 1; @@ -106,7 +99,7 @@ class CGroup extends AbstractResource implements ResourceInterface, \Stringable $this->selfRegistrationAllowed = false; $this->selfUnregistrationAllowed = false; } - public function __toString() : string + public function __toString(): string { return $this->getName(); } @@ -119,45 +112,50 @@ class CGroup extends AbstractResource implements ResourceInterface, \Stringable { return $this->iid; } - public function setName(string $name) : self + public function setName(string $name): self { $this->name = $name; + return $this; } - public function getName() : string + public function getName(): string { return $this->name; } - public function setStatus(bool $status) : self + public function setStatus(bool $status): self { $this->status = $status; + return $this; } - public function getStatus() : bool + public function getStatus(): bool { return $this->status; } - public function setDescription(string $description) : self + public function setDescription(string $description): self { $this->description = $description; + return $this; } - public function getDescription() : ?string + public function getDescription(): ?string { return $this->description; } - public function setMaxStudent(int $maxStudent) : self + public function setMaxStudent(int $maxStudent): self { $this->maxStudent = $maxStudent; + return $this; } - public function getMaxStudent() : int + public function getMaxStudent(): int { return $this->maxStudent; } - public function setDocState(int $docState) : self + public function setDocState(int $docState): self { $this->docState = $docState; + return $this; } /** @@ -169,9 +167,10 @@ class CGroup extends AbstractResource implements ResourceInterface, \Stringable { return $this->docState; } - public function setCalendarState(int $calendarState) : self + public function setCalendarState(int $calendarState): self { $this->calendarState = $calendarState; + return $this; } /** @@ -183,9 +182,10 @@ class CGroup extends AbstractResource implements ResourceInterface, \Stringable { return $this->calendarState; } - public function setWorkState(int $workState) : self + public function setWorkState(int $workState): self { $this->workState = $workState; + return $this; } /** @@ -197,9 +197,10 @@ class CGroup extends AbstractResource implements ResourceInterface, \Stringable { return $this->workState; } - public function setAnnouncementsState(int $announcementsState) : self + public function setAnnouncementsState(int $announcementsState): self { $this->announcementsState = $announcementsState; + return $this; } /** @@ -211,18 +212,20 @@ class CGroup extends AbstractResource implements ResourceInterface, \Stringable { return $this->announcementsState; } - public function setForumState(int $forumState) : self + public function setForumState(int $forumState): self { $this->forumState = $forumState; + return $this; } - public function getForumState() : int + public function getForumState(): int { return $this->forumState; } - public function setWikiState(int $wikiState) : self + public function setWikiState(int $wikiState): self { $this->wikiState = $wikiState; + return $this; } /** @@ -234,9 +237,10 @@ class CGroup extends AbstractResource implements ResourceInterface, \Stringable { return $this->wikiState; } - public function setChatState(int $chatState) : self + public function setChatState(int $chatState): self { $this->chatState = $chatState; + return $this; } /** @@ -248,9 +252,10 @@ class CGroup extends AbstractResource implements ResourceInterface, \Stringable { return $this->chatState; } - public function setSelfRegistrationAllowed(bool $selfRegistrationAllowed) : self + public function setSelfRegistrationAllowed(bool $selfRegistrationAllowed): self { $this->selfRegistrationAllowed = $selfRegistrationAllowed; + return $this; } /** @@ -262,9 +267,10 @@ class CGroup extends AbstractResource implements ResourceInterface, \Stringable { return $this->selfRegistrationAllowed; } - public function setSelfUnregistrationAllowed(bool $selfUnregistrationAllowed) : self + public function setSelfUnregistrationAllowed(bool $selfUnregistrationAllowed): self { $this->selfUnregistrationAllowed = $selfUnregistrationAllowed; + return $this; } /** @@ -276,87 +282,93 @@ class CGroup extends AbstractResource implements ResourceInterface, \Stringable { return $this->selfUnregistrationAllowed; } - public function getDocumentAccess() : int + public function getDocumentAccess(): int { return $this->documentAccess; } - public function setDocumentAccess(int $documentAccess) : self + public function setDocumentAccess(int $documentAccess): self { $this->documentAccess = $documentAccess; + return $this; } /** * @return CGroupRelUser[]|Collection */ - public function getMembers() : array|\Doctrine\Common\Collections\Collection + public function getMembers(): array|Collection { return $this->members; } /** * @param CGroupRelUser[]|Collection $members */ - public function setMembers(array|\Doctrine\Common\Collections\Collection $members) : self + public function setMembers(array|Collection $members): self { $this->members = $members; + return $this; } - public function hasMembers() : bool + public function hasMembers(): bool { return $this->members->count() > 0; } - public function hasMember(User $user) : bool + public function hasMember(User $user): bool { if (!$this->hasMembers()) { return false; } - $list = $this->members->filter(fn(CGroupRelUser $member) => $member->getUser()->getId() === $user->getId()); + $list = $this->members->filter(fn (CGroupRelUser $member) => $member->getUser()->getId() === $user->getId()); + return $list->count() > 0; } - public function hasTutor(User $user) : bool + public function hasTutor(User $user): bool { if (!$this->hasTutors()) { return false; } - $list = $this->tutors->filter(fn(CGroupRelTutor $tutor) => $tutor->getUser()->getId() === $user->getId()); + $list = $this->tutors->filter(fn (CGroupRelTutor $tutor) => $tutor->getUser()->getId() === $user->getId()); + return $list->count() > 0; } /** * @return CGroupRelTutor[]|Collection */ - public function getTutors() : array|\Doctrine\Common\Collections\Collection + public function getTutors(): array|Collection { return $this->tutors; } /** * @param CGroupRelTutor[]|Collection $tutors */ - public function setTutors(array|\Doctrine\Common\Collections\Collection $tutors) : self + public function setTutors(array|Collection $tutors): self { $this->tutors = $tutors; + return $this; } - public function hasTutors() : bool + public function hasTutors(): bool { return $this->tutors->count() > 0; } - public function getCategory() : ?CGroupCategory + public function getCategory(): ?CGroupCategory { return $this->category; } - public function setCategory(CGroupCategory $category = null) : self + public function setCategory(CGroupCategory $category = null): self { $this->category = $category; + return $this; } - public function getResourceIdentifier() : int + public function getResourceIdentifier(): int { return $this->iid; } - public function getResourceName() : string + public function getResourceName(): string { return $this->getName(); } - public function setResourceName(string $name) : self + public function setResourceName(string $name): self { return $this->setName($name); } diff --git a/src/CourseBundle/Entity/CGroupCategory.php b/src/CourseBundle/Entity/CGroupCategory.php index dceed340dc..52582fc214 100644 --- a/src/CourseBundle/Entity/CGroupCategory.php +++ b/src/CourseBundle/Entity/CGroupCategory.php @@ -10,6 +10,7 @@ use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CourseBundle\Repository\CGroupCategoryRepository; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -17,7 +18,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'c_group_category')] #[ORM\Entity(repositoryClass: CGroupCategoryRepository::class)] -class CGroupCategory extends AbstractResource implements ResourceInterface, \Stringable +class CGroupCategory extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CLink.php b/src/CourseBundle/Entity/CLink.php index a2754bc6ed..f89b1b20c2 100644 --- a/src/CourseBundle/Entity/CLink.php +++ b/src/CourseBundle/Entity/CLink.php @@ -10,11 +10,12 @@ use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CourseBundle\Repository\CLinkRepository; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_link')] #[ORM\Entity(repositoryClass: CLinkRepository::class)] -class CLink extends AbstractResource implements ResourceInterface, \Stringable +class CLink extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CLinkCategory.php b/src/CourseBundle/Entity/CLinkCategory.php index d69f8ef469..6673696d18 100644 --- a/src/CourseBundle/Entity/CLinkCategory.php +++ b/src/CourseBundle/Entity/CLinkCategory.php @@ -11,6 +11,7 @@ use Chamilo\CoreBundle\Entity\ResourceInterface; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -18,7 +19,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'c_link_category')] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CLinkCategoryRepository::class)] -class CLinkCategory extends AbstractResource implements ResourceInterface, \Stringable +class CLinkCategory extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -97,7 +98,7 @@ class CLinkCategory extends AbstractResource implements ResourceInterface, \Stri /** * @return CLink[]|Collection */ - public function getLinks(): array|\Doctrine\Common\Collections\Collection + public function getLinks(): array|Collection { return $this->links; } diff --git a/src/CourseBundle/Entity/CLp.php b/src/CourseBundle/Entity/CLp.php index 222ce83e62..156aa13acf 100644 --- a/src/CourseBundle/Entity/CLp.php +++ b/src/CourseBundle/Entity/CLp.php @@ -16,6 +16,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -23,7 +24,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'c_lp')] #[ORM\Entity(repositoryClass: CLpRepository::class)] -class CLp extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, \Stringable +class CLp extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, Stringable { public const LP_TYPE = 1; public const SCORM_TYPE = 2; @@ -134,6 +135,9 @@ class CLp extends AbstractResource implements ResourceInterface, ResourceShowCou #[ORM\Column(name: 'accumulate_work_time', type: 'integer', nullable: false, options: ['default' => 0])] protected int $accumulateWorkTime; + #[ORM\Column(name: 'next_lp_id', type: 'integer', nullable: false, options: ['default' => 0])] + protected int $nextLpId; + #[ORM\OneToMany(targetEntity: CLpItem::class, mappedBy: 'lp', cascade: ['persist', 'remove'], orphanRemoval: true)] protected Collection $items; @@ -638,10 +642,30 @@ class CLp extends AbstractResource implements ResourceInterface, ResourceShowCou return $this->maxAttempts; } + /** + * @return int + */ + public function getNextLpId(): int + { + return $this->nextLpId; + } + + /** + * @param int $nextLpId + */ + public function setNextLpId(int $nextLpId): self + { + $this->nextLpId = $nextLpId; + + return $this; + } + + + /** * @return CLpItem[]|Collection */ - public function getItems(): array|\Doctrine\Common\Collections\Collection + public function getItems(): array|Collection { return $this->items; } @@ -676,15 +700,12 @@ class CLp extends AbstractResource implements ResourceInterface, ResourceShowCou /** * @return ArrayCollection|Collection|CForum[] */ - public function getForums(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection|array + public function getForums(): ArrayCollection|Collection|array { return $this->forums; } - /** - * @param ArrayCollection|Collection $forums - */ - public function setForums(\Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection $forums): self + public function setForums(ArrayCollection|Collection $forums): self { $this->forums = $forums; diff --git a/src/CourseBundle/Entity/CLpCategory.php b/src/CourseBundle/Entity/CLpCategory.php index 4cbbe31102..15b2ed8a0e 100644 --- a/src/CourseBundle/Entity/CLpCategory.php +++ b/src/CourseBundle/Entity/CLpCategory.php @@ -14,6 +14,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -21,7 +22,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'c_lp_category')] #[ORM\Entity(repositoryClass: \Gedmo\Sortable\Entity\Repository\SortableRepository::class)] -class CLpCategory extends AbstractResource implements ResourceInterface, \Stringable +class CLpCategory extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -97,7 +98,7 @@ class CLpCategory extends AbstractResource implements ResourceInterface, \String /** * @return Collection|CLp[] */ - public function getLps(): \Doctrine\Common\Collections\Collection|array + public function getLps(): Collection|array { return $this->lps; } diff --git a/src/CourseBundle/Entity/CLpCategoryUser.php b/src/CourseBundle/Entity/CLpCategoryUser.php index ba428f57b5..a420574157 100644 --- a/src/CourseBundle/Entity/CLpCategoryUser.php +++ b/src/CourseBundle/Entity/CLpCategoryUser.php @@ -9,13 +9,14 @@ namespace Chamilo\CourseBundle\Entity; use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Traits\UserTrait; use Doctrine\ORM\Mapping as ORM; +use Stringable; /** * CLpCategoryUser. */ #[ORM\Table(name: 'c_lp_category_user')] #[ORM\Entity] -class CLpCategoryUser implements \Stringable +class CLpCategoryUser implements Stringable { use UserTrait; diff --git a/src/CourseBundle/Entity/CLpItem.php b/src/CourseBundle/Entity/CLpItem.php index 48f64c4b8f..d850f5db98 100644 --- a/src/CourseBundle/Entity/CLpItem.php +++ b/src/CourseBundle/Entity/CLpItem.php @@ -10,6 +10,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -19,7 +20,7 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Index(name: 'lp_id', columns: ['lp_id'])] #[Gedmo\Tree(type: 'nested')] #[ORM\Entity] -class CLpItem implements \Stringable +class CLpItem implements Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -88,16 +89,16 @@ class CLpItem implements \Stringable protected CLp $lp; #[Gedmo\TreeRoot] - #[ORM\ManyToOne(targetEntity: \Chamilo\CourseBundle\Entity\CLpItem::class)] + #[ORM\ManyToOne(targetEntity: self::class)] #[ORM\JoinColumn(name: 'item_root', referencedColumnName: 'iid', onDelete: 'CASCADE')] protected ?CLpItem $root = null; #[Gedmo\TreeParent] - #[ORM\ManyToOne(targetEntity: \Chamilo\CourseBundle\Entity\CLpItem::class, inversedBy: 'children', cascade: ['persist'])] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children', cascade: ['persist'])] #[ORM\JoinColumn(name: 'parent_item_id', referencedColumnName: 'iid', onDelete: 'SET NULL')] protected ?CLpItem $parent = null; - #[ORM\OneToMany(targetEntity: \Chamilo\CourseBundle\Entity\CLpItem::class, mappedBy: 'parent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] protected Collection $children; #[Gedmo\TreeLeft] @@ -491,7 +492,7 @@ class CLpItem implements \Stringable /** * @return CLpItem[]|Collection */ - public function getChildren(): array|\Doctrine\Common\Collections\Collection + public function getChildren(): array|Collection { return $this->children; } @@ -499,7 +500,7 @@ class CLpItem implements \Stringable /** * @param CLpItem[]|Collection $children */ - public function setChildren(array|\Doctrine\Common\Collections\Collection $children): self + public function setChildren(array|Collection $children): self { $this->children = $children; diff --git a/src/CourseBundle/Entity/CNotebook.php b/src/CourseBundle/Entity/CNotebook.php index 927d0e71ef..a13cec4e9b 100644 --- a/src/CourseBundle/Entity/CNotebook.php +++ b/src/CourseBundle/Entity/CNotebook.php @@ -13,6 +13,7 @@ use Chamilo\CourseBundle\Repository\CNotebookRepository; use DateTime; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -20,7 +21,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'c_notebook')] #[ORM\Entity(repositoryClass: CNotebookRepository::class)] -class CNotebook extends AbstractResource implements ResourceInterface, \Stringable +class CNotebook extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CQuiz.php b/src/CourseBundle/Entity/CQuiz.php index bb70d915d6..be634f7156 100644 --- a/src/CourseBundle/Entity/CQuiz.php +++ b/src/CourseBundle/Entity/CQuiz.php @@ -15,6 +15,7 @@ use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; @@ -23,7 +24,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'c_quiz')] #[ORM\Entity(repositoryClass: CQuizRepository::class)] -class CQuiz extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, \Stringable +class CQuiz extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, Stringable { public const ALL_ON_ONE_PAGE = 1; public const ONE_PER_PAGE = 2; @@ -123,6 +124,9 @@ class CQuiz extends AbstractResource implements ResourceInterface, ResourceShowC #[ORM\Column(name: 'autolaunch', type: 'boolean', nullable: true, options: ['default' => 0])] protected ?bool $autoLaunch; + #[ORM\Column(name: 'hide_attempts_table', type: 'boolean', nullable: false, options: ['default' => 0])] + protected bool $hideAttemptsTable; + #[ORM\Column(name: 'page_result_configuration', type: 'array')] protected array $pageResultConfiguration = []; @@ -179,7 +183,7 @@ class CQuiz extends AbstractResource implements ResourceInterface, ResourceShowC /** * @return Collection|CQuizRelQuestion[] */ - public function getQuestions(): \Doctrine\Common\Collections\Collection|array + public function getQuestions(): Collection|array { return $this->questions; } @@ -658,10 +662,28 @@ class CQuiz extends AbstractResource implements ResourceInterface, ResourceShowC return $this; } + /** + * @return bool + */ + public function isHideAttemptsTable(): bool + { + return $this->hideAttemptsTable; + } + + /** + * @param bool $hideAttemptsTable + */ + public function setHideAttemptsTable(bool $hideAttemptsTable): self + { + $this->hideAttemptsTable = $hideAttemptsTable; + + return $this; + } + /** * @return CQuizRelQuestionCategory[]|Collection */ - public function getQuestionsCategories(): array|\Doctrine\Common\Collections\Collection + public function getQuestionsCategories(): array|Collection { return $this->questionsCategories; } diff --git a/src/CourseBundle/Entity/CQuizQuestion.php b/src/CourseBundle/Entity/CQuizQuestion.php index 33d5d479e9..1a543c7c57 100644 --- a/src/CourseBundle/Entity/CQuizQuestion.php +++ b/src/CourseBundle/Entity/CQuizQuestion.php @@ -12,6 +12,7 @@ use Chamilo\CourseBundle\Repository\CQuizQuestionRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -20,7 +21,7 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_quiz_question')] #[ORM\Index(name: 'position', columns: ['position'])] #[ORM\Entity(repositoryClass: CQuizQuestionRepository::class)] -class CQuizQuestion extends AbstractResource implements ResourceInterface, \Stringable +class CQuizQuestion extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -298,7 +299,7 @@ class CQuizQuestion extends AbstractResource implements ResourceInterface, \Stri /** * @return CQuizQuestionCategory[]|Collection */ - public function getCategories(): array|\Doctrine\Common\Collections\Collection + public function getCategories(): array|Collection { return $this->categories; } @@ -306,7 +307,7 @@ class CQuizQuestion extends AbstractResource implements ResourceInterface, \Stri /** * @return CQuizRelQuestion[]|Collection */ - public function getRelQuizzes(): array|\Doctrine\Common\Collections\Collection + public function getRelQuizzes(): array|Collection { return $this->relQuizzes; } @@ -314,7 +315,7 @@ class CQuizQuestion extends AbstractResource implements ResourceInterface, \Stri /** * @return CQuizAnswer[]|Collection */ - public function getAnswers(): array|\Doctrine\Common\Collections\Collection + public function getAnswers(): array|Collection { return $this->answers; } @@ -327,7 +328,7 @@ class CQuizQuestion extends AbstractResource implements ResourceInterface, \Stri /** * @return CQuizQuestionOption[]|Collection */ - public function getOptions(): array|\Doctrine\Common\Collections\Collection + public function getOptions(): array|Collection { return $this->options; } @@ -335,7 +336,7 @@ class CQuizQuestion extends AbstractResource implements ResourceInterface, \Stri /** * @param CQuizQuestionOption[]|Collection $options */ - public function setOptions(array|\Doctrine\Common\Collections\Collection $options): self + public function setOptions(array|Collection $options): self { $this->options = $options; diff --git a/src/CourseBundle/Entity/CQuizQuestionCategory.php b/src/CourseBundle/Entity/CQuizQuestionCategory.php index ba6c2b5488..1f076ee915 100644 --- a/src/CourseBundle/Entity/CQuizQuestionCategory.php +++ b/src/CourseBundle/Entity/CQuizQuestionCategory.php @@ -12,11 +12,12 @@ use Chamilo\CoreBundle\Entity\ResourceShowCourseResourcesInSessionInterface; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_quiz_question_category')] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CQuizQuestionCategoryRepository::class)] -class CQuizQuestionCategory extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, \Stringable +class CQuizQuestionCategory extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -103,7 +104,7 @@ class CQuizQuestionCategory extends AbstractResource implements ResourceInterfac /** * @return Collection|CQuizQuestion[] */ - public function getQuestions(): \Doctrine\Common\Collections\Collection|array + public function getQuestions(): Collection|array { return $this->questions; } @@ -111,7 +112,7 @@ class CQuizQuestionCategory extends AbstractResource implements ResourceInterfac /** * @param Collection|CQuizQuestion[] $questions */ - public function setQuestions(\Doctrine\Common\Collections\Collection|array $questions): self + public function setQuestions(Collection|array $questions): self { $this->questions = $questions; diff --git a/src/CourseBundle/Entity/CShortcut.php b/src/CourseBundle/Entity/CShortcut.php index 23d9ae8a52..95c0ba7f1c 100644 --- a/src/CourseBundle/Entity/CShortcut.php +++ b/src/CourseBundle/Entity/CShortcut.php @@ -10,12 +10,13 @@ use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CoreBundle\Entity\ResourceNode; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_shortcut')] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CShortcutRepository::class)] -class CShortcut extends AbstractResource implements ResourceInterface, \Stringable +class CShortcut extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CStudentPublication.php b/src/CourseBundle/Entity/CStudentPublication.php index 398a548b10..0d7275a563 100644 --- a/src/CourseBundle/Entity/CStudentPublication.php +++ b/src/CourseBundle/Entity/CStudentPublication.php @@ -14,6 +14,7 @@ use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -21,7 +22,7 @@ use Symfony\Component\Validator\Constraints as Assert; */ #[ORM\Table(name: 'c_student_publication')] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CStudentPublicationRepository::class)] -class CStudentPublication extends AbstractResource implements ResourceInterface, \Stringable +class CStudentPublication extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -70,7 +71,7 @@ class CStudentPublication extends AbstractResource implements ResourceInterface, /** * @var Collection|CStudentPublication[] */ - #[ORM\OneToMany(targetEntity: \Chamilo\CourseBundle\Entity\CStudentPublication::class, mappedBy: 'publicationParent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'publicationParent')] protected Collection $children; /** @@ -79,7 +80,7 @@ class CStudentPublication extends AbstractResource implements ResourceInterface, #[ORM\OneToMany(targetEntity: \Chamilo\CourseBundle\Entity\CStudentPublicationComment::class, mappedBy: 'publication')] protected Collection $comments; - #[ORM\ManyToOne(targetEntity: \Chamilo\CourseBundle\Entity\CStudentPublication::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'iid')] protected ?CStudentPublication $publicationParent; @@ -477,7 +478,7 @@ class CStudentPublication extends AbstractResource implements ResourceInterface, /** * @return CStudentPublication[]|Collection */ - public function getChildren(): array|\Doctrine\Common\Collections\Collection + public function getChildren(): array|Collection { return $this->children; } @@ -516,7 +517,7 @@ class CStudentPublication extends AbstractResource implements ResourceInterface, /** * @return CStudentPublicationComment[]|Collection */ - public function getComments(): array|\Doctrine\Common\Collections\Collection + public function getComments(): array|Collection { return $this->comments; } @@ -524,7 +525,7 @@ class CStudentPublication extends AbstractResource implements ResourceInterface, /** * @param CStudentPublicationComment[]|Collection $comments */ - public function setComments(array|\Doctrine\Common\Collections\Collection $comments): self + public function setComments(array|Collection $comments): self { $this->comments = $comments; diff --git a/src/CourseBundle/Entity/CStudentPublicationAssignment.php b/src/CourseBundle/Entity/CStudentPublicationAssignment.php index 19bf2dac78..779fb5ed46 100644 --- a/src/CourseBundle/Entity/CStudentPublicationAssignment.php +++ b/src/CourseBundle/Entity/CStudentPublicationAssignment.php @@ -8,13 +8,14 @@ namespace Chamilo\CourseBundle\Entity; use DateTime; use Doctrine\ORM\Mapping as ORM; +use Stringable; /** * CStudentPublicationAssignment. */ #[ORM\Table(name: 'c_student_publication_assignment')] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CStudentPublicationAssignmentRepository::class)] -class CStudentPublicationAssignment implements \Stringable +class CStudentPublicationAssignment implements Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CStudentPublicationComment.php b/src/CourseBundle/Entity/CStudentPublicationComment.php index 806ecf31a7..7700ec30c9 100644 --- a/src/CourseBundle/Entity/CStudentPublicationComment.php +++ b/src/CourseBundle/Entity/CStudentPublicationComment.php @@ -13,13 +13,14 @@ use Chamilo\CourseBundle\Repository\CStudentPublicationCommentRepository; use Cocur\Slugify\Slugify; use DateTime; use Doctrine\ORM\Mapping as ORM; +use Stringable; /** * CStudentPublicationComment. */ #[ORM\Table(name: 'c_student_publication_comment')] #[ORM\Entity(repositoryClass: CStudentPublicationCommentRepository::class)] -class CStudentPublicationComment extends AbstractResource implements ResourceInterface, \Stringable +class CStudentPublicationComment extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CStudentPublicationCorrection.php b/src/CourseBundle/Entity/CStudentPublicationCorrection.php index d556d1b22d..8a9f5941b6 100644 --- a/src/CourseBundle/Entity/CStudentPublicationCorrection.php +++ b/src/CourseBundle/Entity/CStudentPublicationCorrection.php @@ -10,11 +10,12 @@ use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CourseBundle\Repository\CStudentPublicationCorrectionRepository; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_student_publication_correction')] #[ORM\Entity(repositoryClass: CStudentPublicationCorrectionRepository::class)] -class CStudentPublicationCorrection extends AbstractResource implements ResourceInterface, \Stringable +class CStudentPublicationCorrection extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CSurvey.php b/src/CourseBundle/Entity/CSurvey.php index 2275440d4d..c435621136 100644 --- a/src/CourseBundle/Entity/CSurvey.php +++ b/src/CourseBundle/Entity/CSurvey.php @@ -13,13 +13,14 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_survey')] #[ORM\Index(name: 'idx_survey_code', columns: ['code'])] #[Gedmo\Tree(type: 'nested')] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CSurveyRepository::class)] -class CSurvey extends AbstractResource implements ResourceInterface, \Stringable +class CSurvey extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -117,14 +118,14 @@ class CSurvey extends AbstractResource implements ResourceInterface, \Stringable protected Collection $invitations; #[Gedmo\TreeParent] - #[ORM\ManyToOne(targetEntity: \Chamilo\CourseBundle\Entity\CSurvey::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'iid', onDelete: 'CASCADE')] protected ?CSurvey $surveyParent = null; /** * @var Collection|CSurvey[] */ - #[ORM\OneToMany(targetEntity: \Chamilo\CourseBundle\Entity\CSurvey::class, mappedBy: 'surveyParent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'surveyParent')] protected Collection $children; /** @@ -602,7 +603,7 @@ class CSurvey extends AbstractResource implements ResourceInterface, \Stringable /** * @return CSurveyQuestion[]|Collection */ - public function getQuestions(): array|\Doctrine\Common\Collections\Collection + public function getQuestions(): array|Collection { return $this->questions; } @@ -665,7 +666,7 @@ class CSurvey extends AbstractResource implements ResourceInterface, \Stringable /** * @return CSurvey[]|Collection */ - public function getChildren(): array|\Doctrine\Common\Collections\Collection + public function getChildren(): array|Collection { return $this->children; } @@ -673,7 +674,7 @@ class CSurvey extends AbstractResource implements ResourceInterface, \Stringable /** * @param CSurvey[]|Collection $children */ - public function setChildren(array|\Doctrine\Common\Collections\Collection $children): self + public function setChildren(array|Collection $children): self { $this->children = $children; @@ -683,7 +684,7 @@ class CSurvey extends AbstractResource implements ResourceInterface, \Stringable /** * @return CSurveyQuestionOption[]|Collection */ - public function getOptions(): array|\Doctrine\Common\Collections\Collection + public function getOptions(): array|Collection { return $this->options; } @@ -698,7 +699,7 @@ class CSurvey extends AbstractResource implements ResourceInterface, \Stringable /** * @return CSurveyInvitation[]|Collection */ - public function getInvitations(): array|\Doctrine\Common\Collections\Collection + public function getInvitations(): array|Collection { return $this->invitations; } @@ -706,7 +707,7 @@ class CSurvey extends AbstractResource implements ResourceInterface, \Stringable /** * @param CSurveyInvitation[]|Collection $invitations */ - public function setInvitations(array|\Doctrine\Common\Collections\Collection $invitations): self + public function setInvitations(array|Collection $invitations): self { $this->invitations = $invitations; diff --git a/src/CourseBundle/Entity/CSurveyAnswer.php b/src/CourseBundle/Entity/CSurveyAnswer.php index 7bcea52216..be2497cf98 100644 --- a/src/CourseBundle/Entity/CSurveyAnswer.php +++ b/src/CourseBundle/Entity/CSurveyAnswer.php @@ -34,6 +34,12 @@ class CSurveyAnswer #[ORM\Column(name: 'user', type: 'string', length: 250, nullable: false)] protected string $user; + #[ORM\Column(name: 'session_id', type: 'integer', nullable: false)] + protected $sessionId; + + #[ORM\Column(name: 'c_lp_item_id', type: 'integer', nullable: false)] + protected $lpItemId; + public function __construct() { } @@ -112,4 +118,50 @@ class CSurveyAnswer return $this; } + + /** + * Get session Id. + * + * @return int + */ + public function getSessionId() + { + return $this->sessionId; + } + + /** + * Set session Id. + * + * @param int $sessionId + * + * @return CSurveyAnswer + */ + public function setSessionId($sessionId) + { + $this->sessionId = $sessionId; + + return $this; + } + + /** + * Get the lp item Id. + * + * @return int + */ + public function getLpItemId() + { + return $this->lpItemId; + } + + /** + * Set lp item Id. + * + * @return CSurveyAnswer + */ + public function setLpItemId(int $lpItemId) + { + $this->lpItemId = $lpItemId; + + return $this; + } } diff --git a/src/CourseBundle/Entity/CSurveyInvitation.php b/src/CourseBundle/Entity/CSurveyInvitation.php index cb28fea217..0ab97a91ca 100644 --- a/src/CourseBundle/Entity/CSurveyInvitation.php +++ b/src/CourseBundle/Entity/CSurveyInvitation.php @@ -59,6 +59,9 @@ class CSurveyInvitation #[ORM\Column(name: 'answered_at', type: 'datetime', nullable: true)] protected ?DateTime $answeredAt = null; + #[ORM\Column(name: 'c_lp_item_id', type: 'integer', nullable: false)] + protected $lpItemId; + public function __construct() { $this->answered = 0; @@ -204,4 +207,28 @@ class CSurveyInvitation return $this; } + + /** + * Set LpItemId. + * + * @param int $lpItemId + * + * @return CSurveyInvitation + */ + public function setLpItemId($lpItemId) + { + $this->lpItemId = $lpItemId; + + return $this; + } + + /** + * Get LpItemId. + * + * @return int + */ + public function getLpItemId() + { + return $this->lpItemId; + } } diff --git a/src/CourseBundle/Entity/CSurveyQuestion.php b/src/CourseBundle/Entity/CSurveyQuestion.php index 417fdb40ba..e3c6d158cf 100644 --- a/src/CourseBundle/Entity/CSurveyQuestion.php +++ b/src/CourseBundle/Entity/CSurveyQuestion.php @@ -21,14 +21,14 @@ class CSurveyQuestion #[ORM\GeneratedValue] protected int $iid; - #[ORM\ManyToOne(targetEntity: CSurveyQuestion::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'iid', onDelete: 'SET NULL')] protected ?CSurveyQuestion $parent = null; /** * @var Collection|CSurveyQuestion[] */ - #[ORM\OneToMany(targetEntity: CSurveyQuestion::class, mappedBy: 'parent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] protected Collection $children; /** @@ -307,7 +307,7 @@ class CSurveyQuestion /** * @return Collection|CSurveyQuestion[] */ - public function getChildren(): \Doctrine\Common\Collections\Collection|array + public function getChildren(): Collection|array { return $this->children; } @@ -315,7 +315,7 @@ class CSurveyQuestion /** * @param Collection|CSurveyQuestion[] $children */ - public function setChildren(\Doctrine\Common\Collections\Collection|array $children): self + public function setChildren(Collection|array $children): self { $this->children = $children; @@ -349,7 +349,7 @@ class CSurveyQuestion /** * @return CSurveyAnswer[]|Collection */ - public function getAnswers(): array|\Doctrine\Common\Collections\Collection + public function getAnswers(): array|Collection { return $this->answers; } @@ -357,7 +357,7 @@ class CSurveyQuestion /** * @return CSurveyQuestionOption[]|Collection */ - public function getOptions(): array|\Doctrine\Common\Collections\Collection + public function getOptions(): array|Collection { return $this->options; } @@ -365,7 +365,7 @@ class CSurveyQuestion /** * @param CSurveyQuestionOption[]|Collection $options */ - public function setOptions(array|\Doctrine\Common\Collections\Collection $options): self + public function setOptions(array|Collection $options): self { $this->options = $options; diff --git a/src/CourseBundle/Entity/CThematic.php b/src/CourseBundle/Entity/CThematic.php index 7a01ca4e5e..60cbb97989 100644 --- a/src/CourseBundle/Entity/CThematic.php +++ b/src/CourseBundle/Entity/CThematic.php @@ -11,12 +11,13 @@ use Chamilo\CoreBundle\Entity\ResourceInterface; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_thematic')] #[ORM\Index(name: 'active', columns: ['active'])] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CThematicRepository::class)] -class CThematic extends AbstractResource implements ResourceInterface, \Stringable +class CThematic extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -44,8 +45,6 @@ class CThematic extends AbstractResource implements ResourceInterface, \Stringab /** * @var Collection|CThematicAdvance[] - * - * */ #[ORM\OrderBy(['startDate' => 'ASC'])] #[ORM\OneToMany(targetEntity: \Chamilo\CourseBundle\Entity\CThematicAdvance::class, mappedBy: 'thematic', cascade: ['persist', 'remove'], orphanRemoval: true)] @@ -135,7 +134,7 @@ class CThematic extends AbstractResource implements ResourceInterface, \Stringab /** * @return Collection|CThematicPlan[] */ - public function getPlans(): \Doctrine\Common\Collections\Collection|array + public function getPlans(): Collection|array { return $this->plans; } @@ -143,7 +142,7 @@ class CThematic extends AbstractResource implements ResourceInterface, \Stringab /** * @return Collection|CThematicAdvance[] */ - public function getAdvances(): \Doctrine\Common\Collections\Collection|array + public function getAdvances(): Collection|array { return $this->advances; } diff --git a/src/CourseBundle/Entity/CThematicAdvance.php b/src/CourseBundle/Entity/CThematicAdvance.php index e67f8d63bf..1938425072 100644 --- a/src/CourseBundle/Entity/CThematicAdvance.php +++ b/src/CourseBundle/Entity/CThematicAdvance.php @@ -11,10 +11,11 @@ use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CoreBundle\Entity\Room; use DateTime; use Doctrine\ORM\Mapping as ORM; +use Stringable; #[ORM\Table(name: 'c_thematic_advance')] #[ORM\Entity] -class CThematicAdvance implements \Stringable //extends AbstractResource implements ResourceInterface +class CThematicAdvance implements Stringable //extends AbstractResource implements ResourceInterface { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CThematicPlan.php b/src/CourseBundle/Entity/CThematicPlan.php index 90d9dc322f..893be8bd6f 100644 --- a/src/CourseBundle/Entity/CThematicPlan.php +++ b/src/CourseBundle/Entity/CThematicPlan.php @@ -9,12 +9,13 @@ namespace Chamilo\CourseBundle\Entity; use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'c_thematic_plan')] #[ORM\Index(name: 'thematic_id', columns: ['thematic_id', 'description_type'])] #[ORM\Entity] -class CThematicPlan implements \Stringable //extends AbstractResource implements ResourceInterface +class CThematicPlan implements Stringable //extends AbstractResource implements ResourceInterface { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] diff --git a/src/CourseBundle/Entity/CTool.php b/src/CourseBundle/Entity/CTool.php index c41da77827..73995d1c9f 100644 --- a/src/CourseBundle/Entity/CTool.php +++ b/src/CourseBundle/Entity/CTool.php @@ -1,20 +1,12 @@ ['ctool:write']], normalizationContext: ['groups' => ['ctool:read']])] #[ORM\Table(name: 'c_tool')] #[ORM\Index(name: 'course', columns: ['c_id'])] #[ORM\Index(name: 'session_id', columns: ['session_id'])] #[ORM\HasLifecycleCallbacks] #[ORM\Entity(repositoryClass: CToolRepository::class)] -class CTool extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, \Stringable +class CTool extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, Stringable { #[Groups(['ctool:read'])] #[ORM\Column(name: 'iid', type: 'integer')] @@ -65,81 +59,87 @@ class CTool extends AbstractResource implements ResourceInterface, ResourceShowC $this->visibility = true; $this->position = 0; } - public function __toString() : string + public function __toString(): string { return $this->getName(); } - public function getNameToTranslate() : string + public function getNameToTranslate(): string { return ucfirst(str_replace('_', ' ', $this->name)); } - public function getName() : string + public function getName(): string { return $this->name; } - public function setName(string $name) : self + public function setName(string $name): self { $this->name = $name; + return $this; } - public function getIid() : ?int + public function getIid(): ?int { return $this->iid; } - public function setCourse(Course $course) : self + public function setCourse(Course $course): self { $this->course = $course; + return $this; } - public function getCourse() : Course + public function getCourse(): Course { return $this->course; } - public function getSession() : ?Session + public function getSession(): ?Session { return $this->session; } - public function setSession(Session $session = null) : self + public function setSession(Session $session = null): self { $this->session = $session; + return $this; } - public function setVisibility(bool $visibility) : self + public function setVisibility(bool $visibility): self { $this->visibility = $visibility; + return $this; } - public function getVisibility() : ?bool + public function getVisibility(): ?bool { return $this->visibility; } - public function getTool() : Tool + public function getTool(): Tool { return $this->tool; } - public function setTool(Tool $tool) : self + public function setTool(Tool $tool): self { $this->tool = $tool; + return $this; } - public function getPosition() : int + public function getPosition(): int { return $this->position; } - public function setPosition(int $position) : self + public function setPosition(int $position): self { $this->position = $position; + return $this; } - public function getResourceIdentifier() : int + public function getResourceIdentifier(): int { return $this->iid; } - public function getResourceName() : string + public function getResourceName(): string { return $this->getName(); } - public function setResourceName(string $name) : self + public function setResourceName(string $name): self { return $this->setName($name); } diff --git a/src/CourseBundle/Entity/CToolIntro.php b/src/CourseBundle/Entity/CToolIntro.php index c892c70c4c..30ab980637 100644 --- a/src/CourseBundle/Entity/CToolIntro.php +++ b/src/CourseBundle/Entity/CToolIntro.php @@ -1,31 +1,32 @@ ['c_tool_intro:write']], normalizationContext: ['groups' => ['c_tool_intro:read']])] #[ORM\Table(name: 'c_tool_intro')] #[ORM\Entity] #[ApiFilter(filterClass: SearchFilter::class, properties: ['courseTool' => 'exact'])] -class CToolIntro extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, \Stringable +class CToolIntro extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, Stringable { #[Groups(['c_tool_intro:read'])] #[ORM\Column(name: 'iid', type: 'integer')] @@ -41,41 +42,43 @@ class CToolIntro extends AbstractResource implements ResourceInterface, Resource #[ORM\ManyToOne(targetEntity: CTool::class)] #[ORM\JoinColumn(name: 'c_tool_id', referencedColumnName: 'iid', nullable: false, onDelete: 'CASCADE')] protected CTool $courseTool; - public function __toString() : string + public function __toString(): string { return $this->getIntroText(); } - public function getIid() : ?int + public function getIid(): ?int { return $this->iid; } - public function getCourseTool() : CTool + public function getCourseTool(): CTool { return $this->courseTool; } - public function setCourseTool(CTool $courseTool) : self + public function setCourseTool(CTool $courseTool): self { $this->courseTool = $courseTool; + return $this; } - public function setIntroText(string $introText) : self + public function setIntroText(string $introText): self { $this->introText = $introText; + return $this; } - public function getIntroText() : string + public function getIntroText(): string { return $this->introText; } - public function getResourceIdentifier() : int + public function getResourceIdentifier(): int { return $this->getIid(); } - public function getResourceName() : string + public function getResourceName(): string { return $this->getCourseTool()->getName(); } - public function setResourceName(string $name) : self + public function setResourceName(string $name): self { return $this; } diff --git a/src/CourseBundle/Entity/CWiki.php b/src/CourseBundle/Entity/CWiki.php index 87f7ab42e4..7ce35c9535 100644 --- a/src/CourseBundle/Entity/CWiki.php +++ b/src/CourseBundle/Entity/CWiki.php @@ -9,7 +9,9 @@ namespace Chamilo\CourseBundle\Entity; use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; use DateTime; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Stringable; use Symfony\Component\Validator\Constraints as Assert; /** @@ -22,7 +24,7 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Index(name: 'page_id', columns: ['page_id'])] #[ORM\Index(name: 'session_id', columns: ['session_id'])] #[ORM\Entity(repositoryClass: \Chamilo\CourseBundle\Repository\CWikiRepository::class)] -class CWiki extends AbstractResource implements ResourceInterface, \Stringable +class CWiki extends AbstractResource implements ResourceInterface, Stringable { #[ORM\Column(name: 'iid', type: 'integer')] #[ORM\Id] @@ -109,6 +111,16 @@ class CWiki extends AbstractResource implements ResourceInterface, \Stringable #[ORM\Column(name: 'session_id', type: 'integer', nullable: true)] protected ?int $sessionId = null; + /** + * @ORM\ManyToMany(targetEntity="Chamilo\CourseBundle\Entity\CWikiCategory", inversedBy="wikiPages") + * @ORM\JoinTable( + * name="c_wiki_rel_category", + * joinColumns={@ORM\JoinColumn(name="wiki_id", referencedColumnName="iid", onDelete="CASCADE")}, + * inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="CASCADE")} + * ) + */ + private $categories; + public function __toString(): string { return $this->getTitle(); @@ -701,6 +713,19 @@ class CWiki extends AbstractResource implements ResourceInterface, \Stringable return $this->getTitle(); } + public function getCategories() + { + return $this->categories; + } + + public function addCategory(CWikiCategory $category): CWiki + { + $category->addWikiPage($this); + $this->categories->add($category); + + return $this; + } + public function setResourceName(string $name): self { return $this->setTitle($name); diff --git a/src/CourseBundle/Entity/CWikiCategory.php b/src/CourseBundle/Entity/CWikiCategory.php new file mode 100644 index 0000000000..3c3cf32929 --- /dev/null +++ b/src/CourseBundle/Entity/CWikiCategory.php @@ -0,0 +1,190 @@ +parent = null; + $this->children = new ArrayCollection(); + $this->wikiPages = new ArrayCollection(); + } + + public function __toString() + { + return $this->name; + } + + public function getId(): int + { + return $this->id; + } + + public function getName(): string + { + return $this->name; + } + + public function getNodeName(): string + { + return str_repeat('    ', $this->lvl).$this->name; + } + + public function setName(string $name): CWikiCategory + { + $this->name = $name; + + return $this; + } + + public function getCourse(): Course + { + return $this->course; + } + + public function setCourse(Course $course): CWikiCategory + { + $this->course = $course; + + return $this; + } + + public function getSession(): ?Session + { + return $this->session; + } + + public function setSession(?Session $session): CWikiCategory + { + $this->session = $session; + + return $this; + } + + public function getRoot(): ?CWikiCategory + { + return $this->root; + } + + public function getParent(): ?CWikiCategory + { + return $this->parent; + } + + public function setParent(?CWikiCategory $parent): CWikiCategory + { + $this->parent = $parent; + + return $this; + } + + public function getChildren(): Collection + { + return $this->children; + } + + public function setChildren(Collection $children): CWikiCategory + { + $this->children = $children; + + return $this; + } + + public function addWikiPage(CWiki $page): CWikiCategory + { + $this->wikiPages->add($page); + + return $this; + } + + public function getWikiPages(): Collection + { + return $this->wikiPages; + } + + public function getLvl(): ?int + { + return $this->lvl; + } +} diff --git a/src/LtiBundle/Controller/CourseController.php b/src/LtiBundle/Controller/CourseController.php index 6288144601..b330a8842a 100644 --- a/src/LtiBundle/Controller/CourseController.php +++ b/src/LtiBundle/Controller/CourseController.php @@ -603,7 +603,7 @@ class CourseController extends ToolBaseController private function variableSubstitution( array $params, - array &$customParams, + array & $customParams, User $user, Course $course, Session $session = null @@ -757,7 +757,7 @@ class CourseController extends ToolBaseController ]; } - private function createLtiLink(array &$contentItem, ExternalTool $baseTool): ExternalTool + private function createLtiLink(array & $contentItem, ExternalTool $baseTool): ExternalTool { $newTool = clone $baseTool; $newTool->setToolParent($baseTool); diff --git a/src/LtiBundle/Entity/ExternalTool.php b/src/LtiBundle/Entity/ExternalTool.php index 818678df6f..99b37acbf5 100644 --- a/src/LtiBundle/Entity/ExternalTool.php +++ b/src/LtiBundle/Entity/ExternalTool.php @@ -15,14 +15,12 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; +use Stringable; use UnserializeApi; -/** - * Class ExternalTool. - */ #[ORM\Table(name: 'lti_external_tool')] #[ORM\Entity] -class ExternalTool extends AbstractResource implements ResourceInterface, ResourceToRootInterface, \Stringable +class ExternalTool extends AbstractResource implements ResourceInterface, ResourceToRootInterface, Stringable { public const V_1P1 = 'lti1p1'; public const V_1P3 = 'lti1p3'; @@ -64,11 +62,11 @@ class ExternalTool extends AbstractResource implements ResourceInterface, Resour #[ORM\JoinColumn(name: 'gradebook_eval_id', referencedColumnName: 'id', onDelete: 'SET NULL')] protected ?GradebookEvaluation $gradebookEval; - #[ORM\ManyToOne(targetEntity: ExternalTool::class, inversedBy: 'children')] + #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id')] protected ?ExternalTool $parent; - #[ORM\OneToMany(targetEntity: ExternalTool::class, mappedBy: 'parent')] + #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] protected Collection $children; #[ORM\Column(name: 'client_id', type: 'string', nullable: true)] diff --git a/src/LtiBundle/Entity/LineItem.php b/src/LtiBundle/Entity/LineItem.php index 95e399efa5..1d02d563b4 100644 --- a/src/LtiBundle/Entity/LineItem.php +++ b/src/LtiBundle/Entity/LineItem.php @@ -11,9 +11,6 @@ use DateTime; use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; -/** - * Class LineItem. - */ #[ORM\Table(name: 'lti_lineitem')] #[ORM\Entity] class LineItem diff --git a/src/LtiBundle/Entity/Platform.php b/src/LtiBundle/Entity/Platform.php index af024b5688..510b68752d 100644 --- a/src/LtiBundle/Entity/Platform.php +++ b/src/LtiBundle/Entity/Platform.php @@ -8,9 +8,6 @@ namespace Chamilo\LtiBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class Platform. - */ #[ORM\Table(name: 'lti_platform')] #[ORM\Entity] class Platform diff --git a/src/LtiBundle/Entity/Token.php b/src/LtiBundle/Entity/Token.php index 98195bd221..4c45edd246 100644 --- a/src/LtiBundle/Entity/Token.php +++ b/src/LtiBundle/Entity/Token.php @@ -8,9 +8,6 @@ namespace Chamilo\LtiBundle\Entity; use Doctrine\ORM\Mapping as ORM; -/** - * Class Token. - */ #[ORM\Table(name: 'lti_token')] #[ORM\Entity] class Token diff --git a/src/LtiBundle/Util/Utils.php b/src/LtiBundle/Util/Utils.php index 4ad922258a..5fa6fa36c9 100644 --- a/src/LtiBundle/Util/Utils.php +++ b/src/LtiBundle/Util/Utils.php @@ -96,7 +96,7 @@ class Utils return implode(',', $scope); } - public static function trimParams(array &$params): void + public static function trimParams(array & $params): void { foreach ($params as $key => $value) { $newValue = preg_replace('/\s+/', ' ', (string) $value); @@ -108,7 +108,7 @@ class Utils /** * @return array */ - public static function removeQueryParamsFromLaunchUrl(ExternalTool $tool, array &$params) + public static function removeQueryParamsFromLaunchUrl(ExternalTool $tool, array & $params) { $urlQuery = parse_url($tool->getLaunchUrl(), PHP_URL_QUERY);