Merge branch 'master' into dist/envole/6/master

This commit is contained in:
Arnaud Fornerot 2020-01-06 09:21:19 +01:00
commit a97ba39dbd
10 changed files with 278 additions and 5 deletions

View File

@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES
(-100, 'Interne', 'SIREN');
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');

View File

@ -0,0 +1,79 @@
<?php
namespace Cadoles\CoreBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Form\FormError;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Cadoles\CoreBundle\Entity\Mail;
use Cadoles\CoreBundle\Form\MailType;
class MailController extends Controller
{
public function invitationgroupAction($id,Request $request)
{
// Recherche du groupe
$em = $this->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,<br><br>Vous êtes invité à participer au groupe de travail = <b>".$group->getLabel()."</b><br><br>";
$message.= "Pour cela vous devez vous inscrire sur <b>".$this->get('session')->get('appname')."</b> en suivant le lien suivant<br>";
$message.= "<a href='$url'>$url</a><br><br>";
$message.= "Une foi le processus d'inscription complété, vous serez automatiquement rattaché à notre groupe de travail<br><br>";
$message.= "Cordialement<br>";
$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()
]);
}
}

View File

@ -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<br>".$user->getLastname()." ".$user->getFirstname()."<br>Inscription via inviation";
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key->toString(),$userid,$groupid,$message);
}
}
$em->remove($data[0]);
$em->flush();
}

View File

@ -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;
}
}

View File

@ -0,0 +1,63 @@
<?php
namespace Cadoles\CoreBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Ivory\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\EntityManager;
class MailType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->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)
{
}
}

View File

@ -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

View File

@ -4,6 +4,9 @@
<h1 class="page-header">Gestion des Utilisateurs</h1>
<h2>Groupe = {{ group.label }}</h2>
<a class="btn btn-default" href={{ path('cadoles_core_'~access~'_group') }}>Fermer</a>
{% if moderegistration!="none" and masteridentity=="SQL"%}
<a class="btn btn-primary" style="cursor:pointer" onClick="showMail();">Inviter des personnes non inscrites</a>
{%endif%}
<br><br>
<div class="col-sm-6">
@ -148,5 +151,12 @@
"user": id,
}
});
}
}
function showMail() {
$("#mymodal").find(".modal-title").html("INVITATION");
var url="{{ path('cadoles_core_mail_invitationgroup',{id:group.id}) }}";
$("#mymodal").find("#framemodal").attr("src",url);
$("#mymodal").modal().show();
}
{% endblock %}

View File

@ -0,0 +1,54 @@
{% extends '@CadolesCore/base.html.twig' %}
{% block pagewrapper %}
{{ form_start(form) }}
{{ form_widget(form.submit) }} <a class="btn btn-default" onClick="closeModal()">Annuler</a>
<br><br>
{% if app.session.flashbag.has('error') %}
<div class='alert alert-danger' style='margin: 5px 0px'>
<strong>Erreur</strong><br>
{% for flashMessage in app.session.flashbag.get('error') %}
{{ flashMessage }}<br>
{% endfor %}
</div>
{% endif %}
{% if app.session.flashbag.has('notice') %}
<div class='alert alert-info' style='margin: 5px 0px'>
<strong>Information</strong><br>
{% for flashMessage in app.session.flashbag.get('notice') %}
{{ flashMessage }}<br>
{% endfor %}
</div>
{% endif %}
{{ form_row(form.destinataire) }}
<div class='alert alert-info' style='font-size: 80%;padding: 5px;margin-top: -10px;'>
Séparer les adresses mails par des ;
</div>
{{ form_row(form.subject) }}
{{ form_row(form.message) }}
{{ form_end(form) }}
{% endblock %}
{% block localjavascript %}
$(document).ready(function() {
{% if closed %}
closeModal();
{% else %}
$("#mail_subject").val("{{ subject }}");
$("#mail_message").val("{{ message | raw }}");
$("#mail_destinataire").focus();
{% endif %}
});
function closeModal() {
window.parent.$("#mymodal").modal('hide');;
}
{% endblock %}

View File

@ -133,7 +133,7 @@ class Widget
* @var ArrayCollection $pagewidgets
* @var Order
*
* @ORM\OneToMany(targetEntity="Pagewidget", mappedBy="widget", cascade={"persist"}, orphanRemoval=false)
* @ORM\OneToMany(targetEntity="Pagewidget", mappedBy="widget", cascade={"persist"}, orphanRemoval=true)
*/
private $pagewidgets;

View File

@ -219,7 +219,6 @@
{% block localjavascript %}
var idpage;
$('document').ready(function(){
{% for page in pagesadmin %}
{% if page.id==entity.id %}
@ -241,6 +240,7 @@
{% endfor %}
{% endfor %}
// Rendre les pages user déplacable
$("#pagesuser").sortable({
axis: "x",
@ -369,6 +369,8 @@
// Sauvegarder la page en cours
idpage=id;
// Cacher toutes les pages
$(".pageframereload").remove();
$(".pageframe").hide();
@ -382,6 +384,10 @@
url=url.replace('yy',usage);
url=url.replace('zz',groupid);
passurl="{{ path('cadoles_core_home',{id:'xx'}) }}";
passurl=passurl.replace('xx',id);
history.pushState('data to be passed', 'Title of the page', passurl);
// Si force le rechargement et frame existante on la détruit
if(forcereload&&$("#page-"+id).length)
$("#page-"+id).remove();