diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql
index 949a0a76..d1bff3f9 100644
--- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql
+++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql
@@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES
(-100, 'DRAAF', '130007107');
INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES
-(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}Kvz21GjhkryG4l7EKniMJzVfwDufa+eI
+(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}o85pP7Lzbqw8J8wr8jlgxl8NFvCcJlve
', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');
diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php
new file mode 100755
index 00000000..8ac3c859
--- /dev/null
+++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php
@@ -0,0 +1,79 @@
+getDoctrine()->getManager();
+ $group = $em->getRepository("CadolesCoreBundle:Group")->find($id);
+ if (!$group) {
+ throw $this->createNotFoundException('Unable to find '.$this->labeldata);
+ }
+
+ // Création du formulaire
+ $form = $this->createForm(MailType::class);
+
+ // Récupération des data du formulaire
+ $form->handleRequest($request);
+
+ // Sujet
+ $subject = $this->get('session')->get('appname')." : Invitation au groupe de travail ".$group->getLabel();
+
+ // Sujet
+ $url = $this->generateUrl('cadoles_core_registration',[], UrlGeneratorInterface::ABSOLUTE_URL)."?group=".$group->getId();
+ $message = "Bonjour,
Vous êtes invité à participer au groupe de travail = ".$group->getLabel()."
";
+ $message.= "Pour cela vous devez vous inscrire sur ".$this->get('session')->get('appname')." en suivant le lien suivant
";
+ $message.= "$url
";
+ $message.= "Une foi le processus d'inscription complété, vous serez automatiquement rattaché à notre groupe de travail
";
+ $message.= "Cordialement
";
+ $message.= $this->getUser()->getFirstname()." ".$this->getUser()->getLastname();
+
+ // To close ?
+ $closed = false;
+
+ // Sur validation
+ if ($form->get('submit')->isClicked() && $form->isValid()) {
+ $closed = true;
+
+
+ $destinataires=$form->get("destinataire")->getData();
+ $to=explode(";",$destinataires);
+ $text=$form->get("message")->getData();
+ $subject=$form->get("subject")->getData();
+ $template="template";
+ $mail_params=array(
+ "subject" => $subject,
+ "body_html"=>nl2br($text),
+ "body_text"=>$text
+ );
+ $from = $this->getUser()->getEmail();
+ $fromName = $this->getUser()->getFirstname()." ".$this->getUser()->getLastname();
+ $message = $this->container->get('cadoles.core.service.mail');
+ $message->sendEmail($template, $mail_params, $to, $from, $fromName);
+ }
+
+ return $this->render('CadolesCoreBundle:Mail:mail.html.twig',[
+ 'useheader' => false,
+ 'usemenu' => false,
+ 'usesidebar' => false,
+ 'closed' => $closed,
+ 'subject' => $subject,
+ 'message' => $message,
+ 'form' => $form->createView()
+ ]);
+ }
+
+}
diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php
index fcad3d7b..515ca626 100755
--- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php
+++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php
@@ -13,6 +13,7 @@ use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Cadoles\CoreBundle\Entity\User;
+use Cadoles\CoreBundle\Entity\Usergroup;
use Cadoles\CoreBundle\Entity\Registration;
use Cadoles\CoreBundle\Form\RegistrationType;
use Cadoles\CoreBundle\Form\UserType;
@@ -176,6 +177,8 @@ class RegistrationController extends Controller
$moderegistration = $this->getParameter('moderegistration');
$masteridentity = $this->getParameter('masteridentity');
+ $groupid = $request->query->get('group');
+
if($moderegistration=="none"||$masteridentity!="SQL")
throw $this->createNotFoundException('Permission denied');
@@ -200,6 +203,9 @@ class RegistrationController extends Controller
$data = $form->getData();
+ // On enregistre l'invitation à un groupe dans l'inscription
+ $data->setGroupid($groupid);
+
$appname = $this->get('session')->get('appname');
$noreply = $this->getParameter('noreply');
$keyterm = $this->getParameter('keyterm');
@@ -506,11 +512,31 @@ class RegistrationController extends Controller
$user->setAuthlevel("simple");
$user->setBelongingpopulation("agent");
-
// Sauvegarde
$em->persist($user);
$em->flush();
+ // Si invitation à un groupe : on le rattache directement à ce groupe
+ $groupid=$data[0]->getGroupid();
+ $userid=$user->getId();
+ if($groupid) {
+ $group=$em->getRepository("CadolesCoreBundle:Group")->find($groupid);
+ if($group) {
+ $key = Uuid::uuid4();
+ $usergroup=new Usergroup;
+ $user=$em->getRepository("CadolesCoreBundle:User")->find($userid);
+ $usergroup->setUser($user);
+ $usergroup->setGroup($group);
+ $usergroup->setKeyvalue($key);
+ $em->persist($usergroup);
+ $em->flush();
+
+ // Notification message
+ $message="Inscription de l'utilisateur
".$user->getLastname()." ".$user->getFirstname()."
Inscription via inviation";
+ $websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key->toString(),$userid,$groupid,$message);
+ }
+ }
+
$em->remove($data[0]);
$em->flush();
}
diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Registration.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Registration.php
index 71dae38c..585473b2 100644
--- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Registration.php
+++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Registration.php
@@ -123,6 +123,11 @@ class Registration implements UserInterface, \Serializable
*/
private $position;
+ /**
+ * @ORM\Column(type="integer", length=60, nullable=true)
+ */
+ private $groupid;
+
/**
* @ORM\ManyToOne(targetEntity="Country", inversedBy="registrations")
* @ORM\JoinColumn(nullable=true)
@@ -709,4 +714,28 @@ class Registration implements UserInterface, \Serializable
{
return $this->niveau02;
}
+
+ /**
+ * Set groupid
+ *
+ * @param integer $groupid
+ *
+ * @return Registration
+ */
+ public function setGroupid($groupid)
+ {
+ $this->groupid = $groupid;
+
+ return $this;
+ }
+
+ /**
+ * Get groupid
+ *
+ * @return integer
+ */
+ public function getGroupid()
+ {
+ return $this->groupid;
+ }
}
diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/MailType.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/MailType.php
new file mode 100644
index 00000000..2b29c948
--- /dev/null
+++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/MailType.php
@@ -0,0 +1,63 @@
+add('submit',
+ SubmitType::class, array(
+ "label" => "Envoyer l'inviation",
+ "attr" => array("class" => "btn btn-success")
+ )
+ );
+
+ $builder->add('destinataire',
+ TextType::class, array(
+ "label" =>"Destinataires",
+ "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
+ "mapped" => false
+ )
+ );
+
+ $builder->add('subject',
+ TextType::class, array(
+ "label" =>"Sujet",
+ "attr" => array("class" => "form-control", "style" => "margin-bottom:15px"),
+ "mapped" => false
+ )
+ );
+
+ $builder
+ ->add("message",CKEditorType::class,[
+ 'config_name' => 'small_config',
+ 'label' => "Message",
+ 'mapped'=> false,
+ 'required' => false,
+ 'attr' => array("class" => "form-control", "style" => "margin-bottom:15px"),
+ 'config' => ["height" => "150px",'filebrowserUploadRoute' => 'cadoles_portal_user_pagewidget_upload']
+ ]);
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+
+ }
+}
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 904d8405..f8db5ef1 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
@@ -132,6 +132,12 @@ cadoles_core_config:
defaults: { _controller: CadolesCoreBundle:Config:home }
+#== Mail =================================================================================================================
+cadoles_core_mail_invitationgroup:
+ path: /user/mail/invitationgroup/{id}
+ defaults: { _controller: CadolesCoreBundle:Mail:invitationgroup }
+
+
#== Commun Config Commun =================================================================================================
cadoles_core_config_commun:
path: /config/commun
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 544a4e29..c2ff3e51 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
@@ -4,6 +4,9 @@