From 0102239e09c17a0df6591ee72be8be1dfa22d5a0 Mon Sep 17 00:00:00 2001 From: afornerot Date: Fri, 19 Mar 2021 13:29:03 +0100 Subject: [PATCH] =?UTF-8?q?syst=C3=A8me=20de=20suivi=20des=20invitations?= =?UTF-8?q?=20=C3=A0=20un=20groupe=20(ref=20#221)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoreBundle/Controller/GroupController.php | 40 ++++++++++++++ .../CoreBundle/Controller/MailController.php | 24 ++++++++- .../src/Cadoles/CoreBundle/Entity/Group.php | 29 +++++++++++ .../CoreBundle/Resources/config/routing.yml | 8 +++ .../views/Group/invitations.html.twig | 52 +++++++++++++++++++ .../Resources/views/Group/users.html.twig | 8 +++ 6 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/invitations.html.twig diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php index 8f05e4ad..183384a7 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php @@ -1198,6 +1198,46 @@ class GroupController extends Controller ]); } + public function invitationAction($id,Request $request, $access="config") + { + // Récupération de l'enregistrement courant + $em = $this->getDoctrine()->getManager(); + $group=$this->getData($id); + $this->canManager($group,$access); + + $invitations=$group->getInvitations(); + if(!is_array($invitations)) $invitations=[]; + + foreach($invitations as $key => $mail) { + $user=$em->getRepository("CadolesCoreBundle:User")->findOneBy(["email"=>$mail]); + // Si l'utilisateur est inscript plus la peine de le suivre + if($user) { + $listinvitations[$key]=["email"=>$mail,"statut"=>"","relance"=>false]; + $usergroup=$em->getRepository("CadolesCoreBundle:UserGroup")->findOneBy(["user"=>$user,"group"=>$group]); + if($usergroup) + $listinvitations[$key]["statut"]="Inscrit dans le groupe"; + else + $listinvitations[$key]["statut"]="Inscrit sur ".$this->get('session')->get('appname')." mais pas dans le groupe"; + } + else { + $listinvitations[$key]=["email"=>$mail,"statut"=>"Non inscrit sur ".$this->get('session')->get('appname'),"relance"=>true]; + $user=$em->getRepository("CadolesCoreBundle:Registration")->findOneBy(["email"=>$mail]); + if($user) { + $listinvitations[$key]["statut"]=$user->getStatut()->getLabel(); + $listinvitations[$key]["relance"]=false; + } + } + } + + return $this->render('CadolesCoreBundle:Group:invitations.html.twig',[ + 'useheader' => false, + 'usemenu' => false, + 'usesidebar' => false, + 'id' => $id, + 'invitations' => $listinvitations, + ]); + } + protected function canManager($group,$access) { if($access!="config") { $em = $this->getDoctrine()->getManager(); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php index 4935e014..6e9e06a9 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php @@ -23,6 +23,10 @@ class MailController extends Controller throw $this->createNotFoundException('Unable to find '.$this->labeldata); } + // On récupère la liste des email invités + $invitations=$group->getInvitations(); + if(!is_array($invitations)) $invitations=[]; + // Création du formulaire $form = $this->createForm(MailType::class); @@ -64,8 +68,15 @@ class MailController extends Controller if($usergroup) array_push($usersin,$user); else array_push($usersnotin,$user); } + else { + // On enregistre l'invitation si elle n'existe pas déjà + if(!in_array($mail,$invitations)) { + array_push($invitations,$mail); + } + } } - + + $text=$form->get("message")->getData(); $subject=$form->get("subject")->getData(); $template="template"; @@ -78,6 +89,17 @@ class MailController extends Controller $fromName = $this->getUser()->getFirstname()." ".$this->getUser()->getLastname(); $message = $this->container->get('cadoles.core.service.mail'); $message->sendEmail($template, $mail_params, $to, $from, $fromName); + + // Sauvegarde des invitation + $group->setInvitations($invitations); + $em->persist($group); + $em->flush(); + } + else { + $email=$request->get("email"); + if($email) { + $form->get('destinataire')->setData($email); + } } if($closed && (!empty($usersin)||!empty($usersnotin))) { diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Group.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Group.php index b241701c..2a8e02fc 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Group.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Group.php @@ -103,6 +103,11 @@ class Group */ private $idonlyoffice; + /** + * @ORM\Column(name="invitations", type="array", nullable=true) + */ + private $invitations; + /** * @ORM\ManyToOne(targetEntity="Cadoles\PortalBundle\Entity\Icon", inversedBy="groups") * @ORM\JoinColumn(nullable=true, onDelete="SET NULL") @@ -1085,4 +1090,28 @@ class Group { return $this->email; } + + /** + * Set invitations + * + * @param array $invitations + * + * @return Group + */ + public function setInvitations($invitations) + { + $this->invitations = $invitations; + + return $this; + } + + /** + * Get invitations + * + * @return array + */ + public function getInvitations() + { + return $this->invitations; + } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml index 78a13514..2bc28289 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml @@ -506,6 +506,10 @@ cadoles_core_config_group_usergroup_export: path: /config/group/users/export/{id} defaults: { _controller: CadolesCoreBundle:Group:usergroupexport, access: config } +cadoles_core_config_group_invitation: + path: /config/group/invitation/{id} + defaults: { _controller: CadolesCoreBundle:Group:invitation, access: config } + #-- Access user cadoles_core_user_group: path: /user/group @@ -563,6 +567,10 @@ cadoles_core_user_group_usergroup_export: path: /user/group/users/export/{id} defaults: { _controller: CadolesCoreBundle:Group:usergroupexport, access: user } +cadoles_core_user_group_invitation: + path: /user/group/invitation/{id} + defaults: { _controller: CadolesCoreBundle:Group:invitation, access: user } + #== Whitelist ============================================================================================================ cadoles_core_config_whitelist: diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/invitations.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/invitations.html.twig new file mode 100644 index 00000000..63aecc73 --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/invitations.html.twig @@ -0,0 +1,52 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} + Fermer + +

+ + + + + + + + + + + {% for invitation in invitations %} + + + + + + {% endfor %} + +
ActionEmailStatut
+ {% if invitation.relance %} + + {% endif %} + {{invitation.email}}{{invitation.statut}}
+ +{% endblock %} + +{% block localjavascript %} + $(document).ready(function() { + }); + + function showMail(email) { + window.parent.$("#mymodal").hide(); + + $("#mymodal").find(".modal-title").html("INVITATION"); + var url="{{ path('cadoles_core_mail_invitationgroup',{id:id,email:'xxx'}) }}"; + url=url.replace('xxx',email); + window.parent.$("#mymodal").find("#framemodal").attr("src",url); + window.parent.$("#mymodal").modal().show(); + } + + function closeModal() { + url=window.parent.location; + window.parent.location=url; + } + +{% endblock %} \ No newline at end of file diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/users.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/users.html.twig index a76e132d..3cc5e48b 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/users.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/users.html.twig @@ -11,6 +11,7 @@ {% if moderegistration!="none" and masteridentity=="SQL"%} Inviter des personnes non listées ci-dessous + Suivi des Invitations {%endif%} Exporter CSV

@@ -168,4 +169,11 @@ $("#mymodal").find("#framemodal").attr("src",url); $("#mymodal").modal().show(); } + + function showInvitations() { + $("#mymodal").find(".modal-title").html("SUVI DES INVITATIONS"); + var url="{{ path('cadoles_core_'~access~'_group_invitation',{id:group.id}) }}"; + $("#mymodal").find("#framemodal").attr("src",url); + $("#mymodal").modal().show(); + } {% endblock %}