diff --git a/assets/styles/app.scss b/assets/styles/app.scss index f1349795614fa1f72aa9dded9d17d5c9946574c1..4cb6082d77715d3584394c8b10648ae2f40f4776 100644 --- a/assets/styles/app.scss +++ b/assets/styles/app.scss @@ -131,6 +131,7 @@ button[type=submit]{ .button-cancel { border: none; border-radius: 3px; + background-color: #5c636a; } .button-cancel:hover { diff --git a/migrations/Version20220125084520.php b/migrations/Version20220208141756.php similarity index 93% rename from migrations/Version20220125084520.php rename to migrations/Version20220208141756.php index 6adb95ef2255e6f1db38b11d4f1b5a18be3c9a37..253a647f6f5052d322b0581f39ee9f99f63f89b0 100644 --- a/migrations/Version20220125084520.php +++ b/migrations/Version20220208141756.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20220125084520 extends AbstractMigration +final class Version20220208141756 extends AbstractMigration { public function getDescription(): string { diff --git a/migrations/Version20220208145209.php b/migrations/Version20220208145209.php new file mode 100644 index 0000000000000000000000000000000000000000..e99fc5d43b23e6ac877eafa57e40568f1fb654c2 --- /dev/null +++ b/migrations/Version20220208145209.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +namespace DoctrineMigrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20220208145209 extends AbstractMigration +{ + public function getDescription(): string + { + return ''; + } + + public function up(Schema $schema): void + { + // this up() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE TABLE `group` (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE group_capsule (group_id INT NOT NULL, capsule_id INT NOT NULL, INDEX IDX_4468F58FFE54D947 (group_id), INDEX IDX_4468F58F714704E9 (capsule_id), PRIMARY KEY(group_id, capsule_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE group_capsule ADD CONSTRAINT FK_4468F58FFE54D947 FOREIGN KEY (group_id) REFERENCES `group` (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE group_capsule ADD CONSTRAINT FK_4468F58F714704E9 FOREIGN KEY (capsule_id) REFERENCES capsule (id) ON DELETE CASCADE'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE group_capsule DROP FOREIGN KEY FK_4468F58FFE54D947'); + $this->addSql('DROP TABLE `group`'); + $this->addSql('DROP TABLE group_capsule'); + } +} diff --git a/src/Builder/CapsuleBuilder.php b/src/Builder/CapsuleBuilder.php old mode 100644 new mode 100755 diff --git a/src/Builder/UserBuilder.php b/src/Builder/UserBuilder.php old mode 100644 new mode 100755 diff --git a/src/Controller/.gitignore b/src/Controller/.gitignore old mode 100644 new mode 100755 diff --git a/src/Controller/CapsuleController.php b/src/Controller/CapsuleController.php old mode 100644 new mode 100755 diff --git a/src/Controller/CapsuleEditorController.php b/src/Controller/CapsuleEditorController.php old mode 100644 new mode 100755 diff --git a/src/Controller/CapsuleGroupController.php b/src/Controller/CapsuleGroupController.php new file mode 100755 index 0000000000000000000000000000000000000000..17a92c6d56d080375cf43a84b8595a2e14c8d1d1 --- /dev/null +++ b/src/Controller/CapsuleGroupController.php @@ -0,0 +1,269 @@ +<?php + +namespace App\Controller; + +use App\Entity\Capsule; +use App\Entity\Group; +use App\Entity\User; +use App\Form\CreateCapsuleGroupsFormType; +use App\Form\RemoveGroupFormType; +use App\Form\SelectCapsuleGroupsFormType; +use App\Repository\CapsuleRepository; +use App\Repository\GroupRepository; +use Doctrine\Common\Collections\Collection; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\Form\FormInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Contracts\Translation\TranslatorInterface; +use Symfony\Component\Routing\Annotation\Route; + +class CapsuleGroupController extends AbstractController +{ + private TranslatorInterface $translator; + private CapsuleRepository $capsule_repository; + private EntityManagerInterface $entity_manager; + private GroupRepository $group_repository; + + public function __construct( + TranslatorInterface $translator, + CapsuleRepository $capsule_repository, + EntityManagerInterface $entity_manager, + GroupRepository $group_repository + ) { + $this->translator = $translator; + $this->capsule_repository = $capsule_repository; + $this->entity_manager = $entity_manager; + $this->group_repository = $group_repository; + } + + /** + * @Route("/capsule/{capsule_id}/groups/edit", name="edit_capsule_groups") + */ + public function edit(int $capsule_id, Request $request): Response + { + $current_user = $this->getUser(); + + if (! $current_user instanceof User) { + return $this->redirectToRoute('app_logout'); + } + + $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); + + if (! $capsule instanceof Capsule) { + throw new \Exception("Capsule does not exist"); + } + + $groups = $capsule->getGroups(); + $editor_groups_not_added = $this->getEditorGroupsNotAdded($current_user, $groups); + + $form = $this->createForm(SelectCapsuleGroupsFormType::class, ['groups' => $editor_groups_not_added]); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $groups = $this->addGroups($form, $capsule); + + $groups_names = []; + + foreach ($groups as $group) { + $groups_names[] = $group->getName(); + } + + $this->addFlash( + 'success', + $this->translator->trans( + 'groups.add.success', + [ + 'groups_names' => implode(",", $groups_names), + 'capsule_name' => $capsule->getName() + ] + ) + ); + + return $this->redirectToRoute('edit_capsule_groups', [ + 'capsule_id' => $capsule_id + ]); + } + + return $this->render('capsule/groups/edit.html.twig', [ + 'selectCapsuleGroupsForm' => $form->createView(), + 'capsule' => $capsule, + 'groups' => $groups, + 'existing_groups' => $editor_groups_not_added + ]); + } + + /** + * @Route("capsule/{capsule_id}/groups/create", name="create_group") + */ + public function create(int $capsule_id, Request $request): Response + { + $current_user = $this->getUser(); + + if (! $current_user instanceof User) { + return $this->redirectToRoute('app_logout'); + } + + $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); + + if (! $capsule instanceof Capsule) { + throw new \Exception("Capsule does not exist"); + } + + $form = $this->createForm(CreateCapsuleGroupsFormType::class); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $group = $this->createAGroup($form, $capsule); + + $this->addFlash( + 'success', + $this->translator->trans( + 'groups.create.success', + [ + 'group_name' => $group->getName() + ] + ) + ); + + return $this->redirectToRoute('edit_capsule_groups', [ + 'capsule_id' => $capsule_id + ]); + } + + return $this->render('capsule/groups/create.html.twig', [ + 'createCapsuleGroupsForm' => $form->createView(), + 'capsule' => $capsule + ]); + } + + /** + * @Route("/capsule/{capsule_id}/groups/{group_id}/remove", name="remove_group") + */ + public function remove( + int $capsule_id, + int $group_id, + Request $request + ): Response { + $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); + if (! $capsule instanceof Capsule) { + throw new \Exception('Capsule not found'); + } + + $group = $this->group_repository->findOneBy(['id' => $group_id]); + if (! $group instanceof Group) { + throw new \Exception('Group not found'); + } + + $current_user = $this->getUser(); + if (! $current_user instanceof User) { + return $this->redirectToRoute('app_logout'); + } + + $form = $this->createForm(RemoveGroupFormType::class); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $capsule->removeGroup($group); + $this->entity_manager->persist($capsule); + $this->entity_manager->flush(); + + $this->addFlash( + 'success', + $this->translator->trans( + 'groups.remove.success', + [ + 'group_name' => $group->getName(), + 'capsule_name' => $capsule->getName() + ] + ) + ); + + return $this->redirectToRoute('edit_capsule_groups', [ + 'capsule_id' => $capsule->getId() + ]); + } + + return $this->render('capsule/groups/remove.html.twig', [ + 'removeGroupForm' => $form->createView(), + 'group_name' => $group->getName(), + 'capsule_id' => $capsule_id + ]); + } + + /** + * @return array<Group> + */ + private function addGroups(FormInterface $form, Capsule $capsule): array + { + $groups_data = $form->getData()['name']; + $groups = []; + + foreach ($groups_data as $group_data) { + $group_db = $this->group_repository->findOneBy(['id' => $group_data->getId()]); + + if (! $group_db instanceof Group) { + throw new \Exception('Group not found'); + } + + $groups[] = $group_db; + $capsule->addGroup($group_db); + $this->entity_manager->persist($capsule); + } + + $this->entity_manager->flush(); + + return $groups; + } + + private function createAGroup(FormInterface $form, Capsule $capsule): Group + { + $group_name = $form->get('name')->getData(); + + $group = new Group(); + $group->setName($group_name); + $this->entity_manager->persist($group); + + $capsule->addGroup($group); + $this->entity_manager->persist($capsule); + + $this->entity_manager->flush(); + + return $group; + } + + /** + * @return array<Group> + */ + private function getExistingGroupsForCurrentEditor(User $current_user): array + { + $editor_capsules = $current_user->getCapsules(); + $existing_groups_for_current_editor = []; + foreach ($editor_capsules as $editor_capsule) { + $existing_groups_for_current_editor = array_merge( + $existing_groups_for_current_editor, + $editor_capsule->getGroups()->toArray() + ); + } + + return $existing_groups_for_current_editor; + } + + /** + * @param Collection<Group> $groups + * @return array<Group> + */ + private function getEditorGroupsNotAdded(User $current_user, Collection $groups): array + { + $editor_existing_groups = $this->getExistingGroupsForCurrentEditor($current_user); + + return array_udiff( + $editor_existing_groups, + $groups->toArray(), + function ($obj_a, $obj_b) { + return $obj_a->getId() - $obj_b->getId(); + } + ); + } +} diff --git a/src/Controller/FallbackController.php b/src/Controller/FallbackController.php old mode 100644 new mode 100755 diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php old mode 100644 new mode 100755 diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php old mode 100644 new mode 100755 diff --git a/src/Controller/ResetPasswordController.php b/src/Controller/ResetPasswordController.php old mode 100644 new mode 100755 diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php old mode 100644 new mode 100755 diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php old mode 100644 new mode 100755 diff --git a/src/Curl/CurlHandle.php b/src/Curl/CurlHandle.php old mode 100644 new mode 100755 diff --git a/src/DataFixtures/CapsuleFixtures.php b/src/DataFixtures/CapsuleFixtures.php old mode 100644 new mode 100755 diff --git a/src/DataFixtures/UserFixtures.php b/src/DataFixtures/UserFixtures.php old mode 100644 new mode 100755 diff --git a/src/Entity/.gitignore b/src/Entity/.gitignore old mode 100644 new mode 100755 diff --git a/src/Entity/Capsule.php b/src/Entity/Capsule.php old mode 100644 new mode 100755 index 08ff123ce5e6625d0200dfc0cfdd0a2760e4d94f..f3e6f715c893e385361331ebfdc6b072d19fb9ac --- a/src/Entity/Capsule.php +++ b/src/Entity/Capsule.php @@ -90,9 +90,16 @@ class Capsule */ private Collection $editors; + /** + * @var Collection<Group> + * @ORM\ManyToMany(targetEntity=Group::class, mappedBy="capsules") + */ + private Collection $groups; + public function __construct() { $this->editors = new ArrayCollection(); + $this->groups = new ArrayCollection(); } public function getId(): int @@ -205,14 +212,13 @@ class Capsule } /** - * @return Collection<User> $editors + * @return Collection<User> */ public function getEditors(): Collection { return $this->editors; } - public function getVideoPreviewImageLink(): ?string { $file_system = new Filesystem(); @@ -231,4 +237,31 @@ class Capsule return 'https://vumbnail.com/' . $video_id . '.jpg'; } + + /** + * @return Collection|Group[] + */ + public function getGroups(): Collection + { + return $this->groups; + } + + public function addGroup(Group $group): self + { + if (!$this->groups->contains($group)) { + $this->groups[] = $group; + $group->addCapsule($this); + } + + return $this; + } + + public function removeGroup(Group $group): self + { + if ($this->groups->removeElement($group)) { + $group->removeCapsule($this); + } + + return $this; + } } diff --git a/src/Entity/Group.php b/src/Entity/Group.php new file mode 100755 index 0000000000000000000000000000000000000000..dae2d533ec24b6a139b42ab7cf018ddde2aafdfe --- /dev/null +++ b/src/Entity/Group.php @@ -0,0 +1,81 @@ +<?php + +namespace App\Entity; + +use App\Repository\GroupRepository; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; +use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; + +/** + * @ORM\Entity(repositoryClass=GroupRepository::class) + * @ORM\Table(name="`group`") + * @UniqueEntity(fields={"name"}, message="group.name.unique") + */ +class Group +{ + /** + * @ORM\Id + * @ORM\GeneratedValue + * @ORM\Column(type="integer") + */ + private int $id; + + /** + * @ORM\Column(type="string", length=255) + */ + private string $name; + + /** + * @var Collection<Capsule> + * @ORM\ManyToMany(targetEntity=Capsule::class, inversedBy="groups") + */ + private Collection $capsules; + + public function __construct() + { + $this->capsules = new ArrayCollection(); + } + + public function getId(): int + { + return $this->id; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + + /** + * @return Collection|Capsule[] + */ + public function getCapsules(): Collection + { + return $this->capsules; + } + + public function addCapsule(Capsule $capsule): self + { + if (!$this->capsules->contains($capsule)) { + $this->capsules[] = $capsule; + } + + return $this; + } + + public function removeCapsule(Capsule $capsule): self + { + $this->capsules->removeElement($capsule); + + return $this; + } +} diff --git a/src/Entity/PendingEditorInvitation.php b/src/Entity/PendingEditorInvitation.php old mode 100644 new mode 100755 diff --git a/src/Entity/ResetPasswordRequest.php b/src/Entity/ResetPasswordRequest.php old mode 100644 new mode 100755 diff --git a/src/Entity/User.php b/src/Entity/User.php old mode 100644 new mode 100755 diff --git a/src/Exception/CapsuleNotFoundException.php b/src/Exception/CapsuleNotFoundException.php old mode 100644 new mode 100755 diff --git a/src/Exception/CurlInitFailedException.php b/src/Exception/CurlInitFailedException.php old mode 100644 new mode 100755 diff --git a/src/Exception/ZipArchiveNotOpeningException.php b/src/Exception/ZipArchiveNotOpeningException.php old mode 100644 new mode 100755 diff --git a/src/Form/CapsuleEditorsFormType.php b/src/Form/CapsuleEditorsFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/ChangePasswordFormType.php b/src/Form/ChangePasswordFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/CreateCapsuleFormType.php b/src/Form/CreateCapsuleFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/CreateCapsuleGroupsFormType.php b/src/Form/CreateCapsuleGroupsFormType.php new file mode 100755 index 0000000000000000000000000000000000000000..452885873246bc9cdeab9327a298b26e6b6ebb62 --- /dev/null +++ b/src/Form/CreateCapsuleGroupsFormType.php @@ -0,0 +1,47 @@ +<?php + +namespace App\Form; + +use App\Entity\Group; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ButtonType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\NotBlank; + +class CreateCapsuleGroupsFormType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add( + 'name', + TextType::class, + [ + 'constraints' => [new NotBlank(['message' => 'group.name.not_blank'])], + 'label' => 'groups.create.name' + ] + ) + ->add( + 'validate', + SubmitType::class, + ['label' => 'groups.create.validate'] + ) + ->add( + 'go_back', + ButtonType::class, + ['label' => 'groups.create.go_back', + 'attr' => ['class' => 'button-cancel'] + ] + ); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Group::class, + ]); + } +} diff --git a/src/Form/DeleteCapsuleFormType.php b/src/Form/DeleteCapsuleFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/DuplicateCapsuleFormType.php b/src/Form/DuplicateCapsuleFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/EditPasswordFormType.php b/src/Form/EditPasswordFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/EditUserProfileFormType.php b/src/Form/EditUserProfileFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/EditVideoUrlFormType.php b/src/Form/EditVideoUrlFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/RemoveEditorFormType.php b/src/Form/RemoveEditorFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/RemoveGroupFormType.php b/src/Form/RemoveGroupFormType.php new file mode 100755 index 0000000000000000000000000000000000000000..436405a7f769127a5f751001054b6c3b929c5e7b --- /dev/null +++ b/src/Form/RemoveGroupFormType.php @@ -0,0 +1,37 @@ +<?php + +namespace App\Form; + +use App\Entity\Group; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ButtonType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +class RemoveGroupFormType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add( + 'cancel', + ButtonType::class, + ['label' => 'general.cancel_button', + 'attr' => ['class' => 'button-cancel'] + ] + ) + ->add( + 'remove', + SubmitType::class, + ['label' => 'groups.remove.button'] + ); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Group::class, + ]); + } +} diff --git a/src/Form/ResetPasswordRequestFormType.php b/src/Form/ResetPasswordRequestFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/SelectCapsuleGroupsFormType.php b/src/Form/SelectCapsuleGroupsFormType.php new file mode 100755 index 0000000000000000000000000000000000000000..91ef852542c1fb7b68ba71aafdb36d1da90d9d85 --- /dev/null +++ b/src/Form/SelectCapsuleGroupsFormType.php @@ -0,0 +1,34 @@ +<?php + +namespace App\Form; + +use App\Entity\Group; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\FormBuilderInterface; + +class SelectCapsuleGroupsFormType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $groups = $options['data']['groups']; + + $builder + ->add('name', EntityType::class, [ + 'class' => Group::class, + 'choice_label' => 'name', + 'choices' => $groups, + 'multiple' => true, + 'label' => 'groups.choose', + 'choice_value' => function (?Group $entity) { + return $entity ? $entity->getId() : ''; + } + ]) + ->add( + 'validate', + SubmitType::class, + ['label' => 'groups.add.validate'] + ); + } +} diff --git a/src/Helper/ContractHelper.php b/src/Helper/ContractHelper.php old mode 100644 new mode 100755 diff --git a/src/Helper/LegacyHelper.php b/src/Helper/LegacyHelper.php old mode 100644 new mode 100755 diff --git a/src/Helper/StringHelper.php b/src/Helper/StringHelper.php old mode 100644 new mode 100755 diff --git a/src/Kernel.php b/src/Kernel.php old mode 100644 new mode 100755 diff --git a/src/Repository/.gitignore b/src/Repository/.gitignore old mode 100644 new mode 100755 diff --git a/src/Repository/CapsuleRepository.php b/src/Repository/CapsuleRepository.php old mode 100644 new mode 100755 diff --git a/src/Repository/GroupRepository.php b/src/Repository/GroupRepository.php new file mode 100755 index 0000000000000000000000000000000000000000..8f1d8f459c3677cf8b962a7b62b3a1f4bfbc446c --- /dev/null +++ b/src/Repository/GroupRepository.php @@ -0,0 +1,21 @@ +<?php + +namespace App\Repository; + +use App\Entity\Group; +use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\Persistence\ManagerRegistry; + +/** + * @method Group|null find($id, $lockMode = null, $lockVersion = null) + * @method Group|null findOneBy(array $criteria, array $orderBy = null) + * @method Group[] findAll() + * @method Group[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class GroupRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Group::class); + } +} diff --git a/src/Repository/PendingEditorInvitationRepository.php b/src/Repository/PendingEditorInvitationRepository.php old mode 100644 new mode 100755 diff --git a/src/Repository/ResetPasswordRequestRepository.php b/src/Repository/ResetPasswordRequestRepository.php old mode 100644 new mode 100755 diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php old mode 100644 new mode 100755 diff --git a/src/Retriever/ProjectRetriever.php b/src/Retriever/ProjectRetriever.php old mode 100644 new mode 100755 diff --git a/src/Security/AppCustomAuthenticator.php b/src/Security/AppCustomAuthenticator.php old mode 100644 new mode 100755 diff --git a/src/Security/EmailVerifier.php b/src/Security/EmailVerifier.php old mode 100644 new mode 100755 diff --git a/src/Security/UserChecker.php b/src/Security/UserChecker.php old mode 100644 new mode 100755 diff --git a/templates/capsule/groups/create.html.twig b/templates/capsule/groups/create.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..c590d3a25987673defbb2b59eae384c421d504d9 --- /dev/null +++ b/templates/capsule/groups/create.html.twig @@ -0,0 +1,36 @@ +{% extends 'layout.html.twig' %} + +{% block title %} + {{ 'groups.create.title'|trans }} + - + {{ parent() }} +{% endblock %} + +{% block body %} + + <div> + <div class="row w-100 gx-0"> + <div class="row-title-box"> + <h3 class="row-title"> + {{ 'groups.create.title'|trans }} + </h3> + </div> + </div> + + <div class="d-flex flex-column justify-content-center align-items-center"> + {{ form_start(createCapsuleGroupsForm, {'attr': {novalidate: 'novalidate'}}) }} + {{ form_row(createCapsuleGroupsForm.name, {'row_attr': {'class' : 'm-auto mb-4 me-3'}}) }} + + <div class="d-flex flex-column flex-sm-row justify-content-center align-items-center align-items-sm-start"> + {{ form_row(createCapsuleGroupsForm.validate, {'row_attr': {'class' : 'me-sm-3 mb-3'}}) }} + <a href="/capsule/{{ capsule.getId() }}/groups/edit"> + {{ form_row(createCapsuleGroupsForm.go_back) }} + </a> + </div> + + {{ form_end(createCapsuleGroupsForm) }} + </div> + + </div> + +{% endblock %} \ No newline at end of file diff --git a/templates/capsule/groups/edit.html.twig b/templates/capsule/groups/edit.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..35070f4628cbfe50b1d83abf81983d8c7424ab7b --- /dev/null +++ b/templates/capsule/groups/edit.html.twig @@ -0,0 +1,73 @@ +{% extends 'layout.html.twig' %} + +{% block title %} + {{ 'groups.edit.title'|trans }} + - + {{ parent() }} +{% endblock %} + +{% block body %} + + <div> + <div class="row w-100 gx-0"> + <div class="row-title-box"> + <h3 class="row-title"> + {{ 'groups.edit.title_with_capsule_name'|trans({'%capsule_name%': capsule.getName()}) }} + </h3> + </div> + </div> + + {% for flashWarning in app.flashes('warning') %} + <div class="text-center alert alert-warning col-5 mx-auto my-5 mt-2" role="alert"> + {{ flashWarning }} + </div> + {% endfor %} + + {% for flashSuccess in app.flashes('success') %} + <div class="text-center alert alert-success col-5 mx-auto my-5 mt-2" role="alert"> + {{ flashSuccess }} + </div> + {% endfor %} + + <div class="d-flex flex-md-row flex-column justify-content-center"> + + <div class="d-flex flex-row pe-md-5 pb-3 fw-normal me-0 me-md-5"> + <div class="pe-3 pe-md-4 text-nowrap"> + <h5> + {{ 'groups.list.title'|trans }} + </h5> + <ul class="ps-0"> + {% for group in groups %} + <li class="text-capitalize text-secondary list-unstyled p-1"> + {{ group.getName() }} + - + <a href="/capsule/{{ capsule.getId() }}/groups/{{ group.getId() }}/remove" class="remove-link"> + {{ 'groups.remove.link'|trans }} + </a> + </li> + {% endfor %} + </ul> + </div> + </div> + + <div class="d-flex flex-column justify-content-center order-md-2 mb-4 col-sm-8 col-md-6 col-lg-5 col-xl-4"> + <h5 class="mb-5"> + <a href="/capsule/{{ capsule.getId() }}/groups/create" class="list-unstyled"> + {{ 'groups.create.title'|trans }} + </a> + </h5> + + {% if existing_groups is not empty %} + <div class="d-flex flex-column justify-content-center mb-4"> + {{ form_start(selectCapsuleGroupsForm, {'attr': {novalidate: 'novalidate'}}) }} + {{ form_row(selectCapsuleGroupsForm.name, {'row_attr': {'class' : 'm-auto mb-4'}}) }} + {{ form_row(selectCapsuleGroupsForm.validate) }} + {{ form_end(selectCapsuleGroupsForm) }} + </div> + {% endif %} + </div> + + </div> + </div> + +{% endblock %} \ No newline at end of file diff --git a/templates/capsule/groups/remove.html.twig b/templates/capsule/groups/remove.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..9894b62642153b5b19f1e7aaec4e74452ca56f09 --- /dev/null +++ b/templates/capsule/groups/remove.html.twig @@ -0,0 +1,34 @@ +{% extends 'layout.html.twig' %} + +{% block title %} + {{ 'groups.remove.title'|trans }} +{% endblock %} + +{% block body %} + + <div> + <div class="row w-100 gx-0"> + <div class="row-title-box"> + <h3 class="row-title"> + {{ 'groups.remove.title'|trans }} + </h3> + </div> + </div> + + <div class="d-flex flex-column justify-content-center align-items-center"> + + <p class="text-secondary fs-5 mb-5"> + {{ 'groups.remove.text'|trans({'%group_name%': group_name}) }} + </p> + + {{ form_start(removeGroupForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} + {{ form_row(removeGroupForm.remove, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} + <a href="/capsule/{{ capsule_id }}/editors"> + {{ form_row(removeGroupForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} + </a> + {{ form_end(removeGroupForm) }} + </div> + + </div> + +{% endblock %} \ No newline at end of file diff --git a/templates/capsule/index.html.twig b/templates/capsule/index.html.twig index 24c3d22ac50d87f75ee65a19e0f80327b8b69087..48b0b61155c14a5198f403ade3930cb9c8d268b4 100644 --- a/templates/capsule/index.html.twig +++ b/templates/capsule/index.html.twig @@ -38,12 +38,10 @@ </div> {% endfor %} -</div> - <div class="d-flex flex-column align-items-center mt-4 mb-4"> {% for capsule in capsules %} - <div class="capsule-item pb-4 col-12 col-lg-10 col-xl-8"> - <div class="d-flex flex-column flex-md-row justify-content-center align-items-center mt-sm-4"> + <div class="capsule-item pb-4 col-12 col-sm-11 col-md-10 col-xxl-8"> + <div class="d-flex flex-column justify-content-center align-items-center mt-sm-4"> <div class="list-item"> <a href="/capsule/preview/{{ capsule.getLinkPath() }}" class="capsule-title"> {{ capsule.getName() }} @@ -54,7 +52,7 @@ </div> </div> - <div class="d-flex flex-column flex-md-row justify-content-center align-items-center"> + <div class="d-flex flex-column flex-xl-row justify-content-center align-items-center"> <div class="m-4 ratio ratio-16x9"> {% if capsule.getVideoPreviewImageLink() is null %} <img src="{{ asset('build/images/project_not_found.jpg') }}" alt="video preview"> @@ -80,6 +78,14 @@ </a> </div> + + <div class="list-item text-nowrap"> + <a href="{{ path('edit_capsule_groups', { 'capsule_id' : capsule.getId()}) }}" class="links text-decoration-none"> + <i class="fas fa-layer-group m-2"></i> + {{ 'groups.edit.title'|trans({'%capsule_name%': capsule.getName()}) }} + </a> + </div> + <div class="list-item text-nowrap"> <a href="/capsule/duplicate/{{ capsule.getId() }}" class="links text-decoration-none"> <i class="far fa-clone m-2"></i> diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index ad0f150076247179414da7228ca4caec93ae8a1b..a6d1235d8b0411704a0bbf75c2d865e8db040e07 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -113,4 +113,70 @@ user: change_password: Change password updated_success: The password has been updated edit_profile: Edit my profile - edit_password: Edit my password \ No newline at end of file + edit_password: Edit my password + +editors: + title: Editors + title_name: Editors of capsule %capsule_name% + add_email_address: Add new editor with email address + current_editors_title: Current editors + pending_editors_title: Pending editors + user_not_editor_error: You are not editor of the capsule + add: + pending_editor: + success: The user user_email has been added to pending editor list. + He will receive an email to invite him register on MemoRekall and to inform him he has been added as an editor of this capsule. + already_added: The user user_email has already been added to pending editor list + email: + title: Invitation to edit a MemoRekall capsule + text: You have been added by %user_name% as editor of the capsule "%capsule_name%". + In order to access and edit it, you first need to register on MemoRekall. Please follow this link to + link: https://project.memorekall.com/register/ + link_name: register + user: + success: The user user_email is now an editor of the capsule capsule_name. + He will receive an email to inform him he has been added as an editor of this capsule. + already_added: The user user_email is already an editor of this capsule + email: + title: New capsule on your list + text: You have been add by %user_name% as editor of the capsule "%capsule_name%". + You can now access and edit it. You will find the capsule in your capsule list. + link: Go to capsule edition page + remove: + button: Delete + pending_editor: + title: Remove pending editor + text: Do you really want to remove pending editor %editor_email% ? + link: Remove pending editor + error: Email address pending_editor_email has already been removed from the pending editors list of the capsule capsule_name + success: Email address pending_editor_email has been successfully removed from the pending editor list of the capsule capsule_name + editor: + title: Remove editor + text: Do you really want to remove editor %editor_email% ? + link: Remove editor + success: User editor_email cannot edit anymore the capsule capsule_name + error: You can't remove yourself as editor of your own capsule. + If you want to remove the capsule from your list, go to the capsule list page and click on "delete capsule" + +groups: + list: + title: Capsule groups + edit: + title: Edit capsule groups + title_with_capsule_name: Groups for capsule %capsule_name% + create: + title: Create a new group + success: Group group_name has been created and added to the capsule successfully + name: Choose a new group name + validate: Create a new group + go_back: Go back to capsule groups + add: + success: Group(s) groups_names has/have been added successfully to capsule capsule_name + validate: Add theses groups to the capsule + choose: Please choose one or more groups + remove: + button: Remove group + link: Remove group + text: Do you really want to remove group %group_name% ? + title: Remove group + success: Group group_name removed successfully \ No newline at end of file diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index 010c565af4ca1105a9d1dc3c38673ad9be6febf9..81fa761aef9b7f120627c6ddf343dd1038212eab 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -154,5 +154,28 @@ editors: text: Souhaitez-vous vraiment supprimer l'éditeur %editor_email% ? link: Supprimer l'éditeur success: L'utilisateur editor_email ne peut plus éditer la capsule capsule_name - error: You can't remove yourself as editor of your own capsule. - If you want to remove the capsule from your list, go to the capsule list page and click on "delete capsule" \ No newline at end of file + error: Vous ne pouvez pas vous enlever de la liste des éditeurs de votre propre capsule. + Si vous voulez enlever la capsule de votre liste, allez sur la page qui affiche la liste de vos capsules et cliquer sur "supprimer la capsule" + +groups: + list: + title: Groupes de la capsule + edit: + title: Modifier les groupes + title_with_capsule_name: Groupes de la capsule %capsule_name% + create: + title: Créer un nouveau groupe + success: Le groupe group_name a bien été créé et ajouté à la capsule + name: Choisir un nom de groupe + validate: Créer un nouveau groupe + go_back: Retourner à la liste des groupes + add: + success: Le(s) groupe(s) groups_names a/ont bien été ajouté(s) à la capsule capsule_name + validate: Ajouter ces groupes à la capsule + choose: Veuillez choisir un ou plusieurs groupes + remove: + button: Supprimer le groupe + link: Supprimer le groupe + text: Souhaitez-vous vraiment supprimer le groupe %group_name% ? + title: Supprimer le groupe + success: Le groupe group_name a bien été supprimé \ No newline at end of file diff --git a/translations/validators.en.yaml b/translations/validators.en.yaml index 2a4c7e79c671ce31e50ed4099f7d3074a7fafabb..3c257dc61aff7460b5b068087352bdaa2c4c599d 100644 --- a/translations/validators.en.yaml +++ b/translations/validators.en.yaml @@ -21,4 +21,9 @@ capsule: not_blank: Please enter a capsule name unique: There is already a capsule with this name video_url: - not_blank: Please enter a video URL \ No newline at end of file + not_blank: Please enter a video URL + +group: + name: + not_blank: Please enter a group name + unique: There is already a group with this name \ No newline at end of file diff --git a/translations/validators.fr.yaml b/translations/validators.fr.yaml index e6aa6050801f11f164ce603c6e01fd58177644a6..3c494abcece23ecd86f7b97c522d46bac1bf9f28 100644 --- a/translations/validators.fr.yaml +++ b/translations/validators.fr.yaml @@ -21,4 +21,9 @@ capsule: not_blank: Veuillez saisir le nom de la capsule unique: Il existe déjà une capsule avec ce nom video_url: - not_blank: Veuillez saisir l'URL de votre vidéo \ No newline at end of file + not_blank: Veuillez saisir l'URL de votre vidéo + +group: + name: + not_blank: Veuillez saisir le nom du groupe + unique: Il existe déjà un groupe avec ce nom \ No newline at end of file