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 %}