This commit is contained in:
root 2019-06-14 15:07:54 +02:00
parent 612012d480
commit f85b6e848b
6 changed files with 144 additions and 111 deletions

View File

@ -8,8 +8,8 @@ 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}XzeVqnrNOqCyH0z7F5gEVxBKwivMttoy
', 'admin@transnum.cadol.es', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}xiNakN3H44Yrsb6ZrCP+/VGKob+TEyKy
', 'afornerot@cadoles.com', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');

View File

@ -172,6 +172,8 @@ class RegistrationController extends Controller
public function submitAction(Request $request)
{
$moderegistration = $this->getParameter('moderegistration');
$masteridentity = $this->getParameter('masteridentity');
if($moderegistration=="none"||$masteridentity!="SQL")
@ -282,6 +284,8 @@ class RegistrationController extends Controller
$message = $this->container->get('cadoles.core.service.mail');
$message->sendEmail($template, $mail_params, $to, $from, $fromName);
}
// si oui : Domaine de confiance : email de validation d'inscription directement à l'utilisateur
@ -319,24 +323,33 @@ class RegistrationController extends Controller
$em->flush();
// A voir retour sur un écran d'info indiquant si validation par admion ou s'il doit matter ses email
return $this->render($this->labelentity.':info.html.twig', [
$this->get('session')->set('registrationinfo', $info);
$this->get('session')->set('registrationmode', "info");
return $this->redirectToRoute('cadoles_core_registration_info');
}
else {
return $this->render($this->labelentity.':edit.html.twig', [
'useheader' => true,
'usemenu' => false,
'usesidebar' => false,
'info' => $info,
'mode' => "info"
$this->labeldata => $data,
'mode' => 'submit',
'form' => $form->createView()
]);
}
return $this->render($this->labelentity.':edit.html.twig', [
}
public function infoAction(Request $request)
{
$info = $this->get('session')->get('registrationinfo');
$mode = $this->get('session')->get('registrationmode');
return $this->render($this->labelentity.':info.html.twig', [
'useheader' => true,
'usemenu' => false,
'usesidebar' => false,
$this->labeldata => $data,
'mode' => 'submit',
'form' => $form->createView()
'info' => $info,
'mode' => $mode
]);
}
public function sendAction($id,Request $request)
@ -440,12 +453,18 @@ class RegistrationController extends Controller
if(!$data) {
$info="Clé de validation invalide";
$mode="danger";
$this->get('session')->set('registrationinfo', $info);
$this->get('session')->set('registrationmode', $mode);
}
else {
$url=$this->getParameter('eportail_login');
$url=$this->getUrlLogin();
$info="<p>Votre compte est à présent activé</p><p>Vous allez être redirigé vers la mire de connexion</p><p><a href='".$url."'>Connexion</a>";
$mode="success";
$this->get('session')->set('registrationinfo', $info);
$this->get('session')->set('registrationmode', $mode);
// Initialisation de l'enregistrement
$user = new User();
$user->setAvatar("noavatar.png");
@ -487,14 +506,7 @@ class RegistrationController extends Controller
$em->flush();
}
return $this->render($this->labelentity.':info.html.twig', [
'useheader' => true,
'usemenu' => false,
'usesidebar' => false,
'info' => $info,
'mode' => $mode
]);
return $this->redirectToRoute('cadoles_core_registration_info');
}
@ -612,14 +624,10 @@ class RegistrationController extends Controller
// Info
$info="Vous allez recevoir un mail avec lien qui vous permettra de réinitialiser votre mot de passe";
$mode="success";
return $this->render($this->labelentity.':info.html.twig', [
'useheader' => true,
'usemenu' => false,
'usesidebar' => false,
'info' => $info,
'mode' => $mode
]);
$mode="info";
$this->get('session')->set('registrationinfo', $info);
$this->get('session')->set('registrationmode', $mode);
return $this->redirectToRoute('cadoles_core_registration_info');
}
// Affichage du formulaire
@ -654,14 +662,9 @@ class RegistrationController extends Controller
if(!$user) {
$info="Clé de validation invalide";
$mode="danger";
return $this->render($this->labelentity.':info.html.twig', [
'useheader' => true,
'usemenu' => false,
'usesidebar' => false,
'info' => $info,
'mode' => $mode
]);
$this->get('session')->set('registrationinfo', $info);
$this->get('session')->set('registrationmode', $mode);
return $this->redirectToRoute('cadoles_core_registration_info');
}
else {
// Création du formulaire
@ -715,18 +718,12 @@ class RegistrationController extends Controller
$em->persist($user[0]);
$em->flush();
$info="Nouveau mot de passe prise en compte<br>Vous allez être rediriger vers la mire d'authentification";
$url=$this->getUrlLogin();
$info="<p>Nouveau mot de passe prise en compte</p><p>Vous allez être redirigé vers la mire de connexion</p><p><a href='".$url."'>Connexion</a>";
$mode="success";
return $this->render($this->labelentity.':info.html.twig', [
'useheader' => true,
'usemenu' => false,
'usesidebar' => false,
'info' => $info,
'mode' => $mode
]);
$this->get('session')->set('registrationinfo', $info);
$this->get('session')->set('registrationmode', $mode);
return $this->redirectToRoute('cadoles_core_registration_info');
}
// Affichage du formulaire
@ -739,6 +736,24 @@ class RegistrationController extends Controller
}
}
protected function getUrlLogin()
{
$mode_auth=$this->getParameter("mode_auth");
if($mode_auth == "SAML")
$url = $this->generateUrl('lightsaml_sp.login');
elseif($mode_auth == "CAS")
$url = $this->generateUrl('cas_sp.login');
elseif($mode_auth == "SQL")
$url = $this->generateUrl('cadoles_core_login');
elseif($mode_auth == "LDAP")
$url = $this->generateUrl('cadoles_core_ldap_login');
else
$url="";
return $url;
}
protected function getDatas()
{
$em = $this->getDoctrine()->getManager();

View File

@ -169,6 +169,10 @@ cadoles_core_registration:
path: /registration
defaults: { _controller: CadolesCoreBundle:Registration:submit }
cadoles_core_registration_info:
path: /registration/info
defaults: { _controller: CadolesCoreBundle:Registration:info }
cadoles_core_registration_validation:
path: /registration/validation/{key}
defaults: { _controller: CadolesCoreBundle:Registration:validation }

View File

@ -16,17 +16,20 @@
{% if mode=="success" %}
$(document).ready(function() {
{% if eportail_sync %}
// Redirection vers la mire de connexion d'ePortail
setTimeout(function(){
window.location.href="{{ eportail_login }}";
}, 6000);
{% else %}
// Redirection vers la mire d'authentification
setTimeout(function(){
window.location.href="{{ path("cadoles_core_login") }}";
}, 6000);
{% endif %}
// Redirection vers la mire d'authentification
setTimeout(function(){
{% if mode_auth == "SAML" %}
window.location.href="{{ path("lightsaml_sp.login") }}";
{% elseif mode_auth == "CAS" %}
window.location.href="{{ path("cas_sp.login") }}";
{% elseif mode_auth == "SQL" %}
window.location.href="{{ path("cadoles_core_login") }}";
{% elseif mode_auth == "LDAP" %}
window.location.href="{{ path("cadoles_core_ldap_login") }}";
{% endif %}
}, 6000);
});
{% endif %}

View File

@ -228,11 +228,15 @@ class jsonRPCClient
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (isset($this->httpErrors[$httpCode]))
{
echo 'Response Http Error - ' . $this->httpErrors[$httpCode];
return $false;
throw new \RuntimeException('Response Http Error - ' . $this->httpErrors[$httpCode]);
}
// check for curl error
if (0 < curl_errno($ch))
{
echo 'Unable to connect to '.$this->url . ' Error: ' . curl_error($ch);
return $response;
throw new \RuntimeException('Unable to connect to '.$this->url . ' Error: ' . curl_error($ch));
}
// close the connection
@ -253,6 +257,7 @@ class jsonRPCClient
{
if ($pFailed)
{
return false;
throw new \RuntimeException($pErrMsg);
}
}
@ -397,37 +402,39 @@ class GetLimesurveyCommand extends Command
// list de l'ensemble des sondages invité
$surveys= $myJSONRPCClient->list_surveys($sessionKey);
foreach($surveys as $survey) {
// Si le sondage est actif
if($survey["active"]=="Y") {
if(is_array($surveys)) {
foreach($surveys as $survey) {
// Si le sondage est actif
if($survey["active"]=="Y") {
// Liste des participants
$survey_id=$survey["sid"];
$users = $myJSONRPCClient->list_participants($sessionKey, $survey_id, 0, 10000);
$token="";
// Liste des participants
$survey_id=$survey["sid"];
$users = $myJSONRPCClient->list_participants($sessionKey, $survey_id, 0, 10000);
$token="";
foreach($users as $user) {
if(isset($user["participant_info"]["email"]) && $user["participant_info"]["email"]!="") {
$entity = $this->em->getRepository('CadolesCoreBundle:User')->findOneBy(["email"=>$user["participant_info"]["email"]]);
if($entity) {
$surveypropconf = $myJSONRPCClient->get_survey_properties($sessionKey,$survey["sid"],["datecreated"]);
$surveyproplang = $myJSONRPCClient->get_language_properties($sessionKey,$survey["sid"],["surveyls_welcometext"]);
$surveydescription = $surveyproplang["surveyls_welcometext"];
$surveydescription = json_encode(str_replace("\r","",str_replace("\n","",$surveydescription)));
foreach($users as $user) {
if(isset($user["participant_info"]["email"]) && $user["participant_info"]["email"]!="") {
$entity = $this->em->getRepository('CadolesCoreBundle:User')->findOneBy(["email"=>$user["participant_info"]["email"]]);
if($entity) {
$surveypropconf = $myJSONRPCClient->get_survey_properties($sessionKey,$survey["sid"],["datecreated"]);
$surveyproplang = $myJSONRPCClient->get_language_properties($sessionKey,$survey["sid"],["surveyls_welcometext"]);
$surveydescription = $surveyproplang["surveyls_welcometext"];
$surveydescription = json_encode(str_replace("\r","",str_replace("\n","",$surveydescription)));
$token=$user["token"];
$url=$widlimesurvey_url."/".$survey_id;
if($token!="")
$url.="?token=".$token;
$token=$user["token"];
$url=$widlimesurvey_url."/".$survey_id;
if($token!="")
$url.="?token=".$token;
$string ='"'.$survey["sid"].'": {';
$string.='"title": '.json_encode($survey["surveyls_title"]).',';
$string.='"url": "'.$url.'",';
$string.='"date": "'.$surveypropconf["datecreated"].'",';
$string.='"description": '.$surveydescription;
$string.='},';
$string ='"'.$survey["sid"].'": {';
$string.='"title": '.json_encode($survey["surveyls_title"]).',';
$string.='"url": "'.$url.'",';
$string.='"date": "'.$surveypropconf["datecreated"].'",';
$string.='"description": '.$surveydescription;
$string.='},';
$this->filesystem->appendToFile($this->limefile.'-new/'.$entity->getId().'/invitation.json', $string."\n");
$this->filesystem->appendToFile($this->limefile.'-new/'.$entity->getId().'/invitation.json', $string."\n");
}
}
}
}
@ -436,29 +443,31 @@ class GetLimesurveyCommand extends Command
// Pour chaque user on remonte les sondages dont ils sont propriétaires
$userlimesurveys=$myJSONRPCClient->list_users($sessionKey);
foreach($userlimesurveys as $userlimesurvey) {
$user = $this->em->getRepository('CadolesCoreBundle:User')->findOneBy(["username"=>$userlimesurvey["users_name"]]);
if($user) {
$surveys = $myJSONRPCClient->list_surveys($sessionKey, $user->getUserName());
foreach($surveys as $survey) {
if(is_array($survey)) {
if(is_array($userlimesurveys)) {
foreach($userlimesurveys as $userlimesurvey) {
$user = $this->em->getRepository('CadolesCoreBundle:User')->findOneBy(["username"=>$userlimesurvey["users_name"]]);
if($user) {
$surveys = $myJSONRPCClient->list_surveys($sessionKey, $user->getUserName());
foreach($surveys as $survey) {
if(is_array($survey)) {
if($survey["active"]=="Y") {
$surveypropconf = $myJSONRPCClient->get_survey_properties($sessionKey,$survey["sid"],["datecreated"]);
$surveyproplang = $myJSONRPCClient->get_language_properties($sessionKey,$survey["sid"],["surveyls_welcometext"]);
$surveydescription = $surveyproplang["surveyls_welcometext"];
$surveydescription = json_encode(str_replace("\r","",str_replace("\n","",$surveydescription)));
if($survey["active"]=="Y") {
$surveypropconf = $myJSONRPCClient->get_survey_properties($sessionKey,$survey["sid"],["datecreated"]);
$surveyproplang = $myJSONRPCClient->get_language_properties($sessionKey,$survey["sid"],["surveyls_welcometext"]);
$surveydescription = $surveyproplang["surveyls_welcometext"];
$surveydescription = json_encode(str_replace("\r","",str_replace("\n","",$surveydescription)));
$url=$widlimesurvey_url."/admin/survey/sa/view/surveyid/".$survey["sid"];
$url=$widlimesurvey_url."/admin/survey/sa/view/surveyid/".$survey["sid"];
$string ='"'.$survey["sid"].'": {';
$string.='"title": '.json_encode($survey["surveyls_title"]).',';
$string.='"url": "'.$url.'",';
$string.='"date": "'.$surveypropconf["datecreated"].'",';
$string.='"description": '.$surveydescription;
$string.='},';
$string ='"'.$survey["sid"].'": {';
$string.='"title": '.json_encode($survey["surveyls_title"]).',';
$string.='"url": "'.$url.'",';
$string.='"date": "'.$surveypropconf["datecreated"].'",';
$string.='"description": '.$surveydescription;
$string.='},';
$this->filesystem->appendToFile($this->limefile.'-new/'.$user->getId().'/survey.json', $string."\n");
$this->filesystem->appendToFile($this->limefile.'-new/'.$user->getId().'/survey.json', $string."\n");
}
}
}
}
@ -466,8 +475,10 @@ class GetLimesurveyCommand extends Command
}
// On supprime les encours pour le remplacer le new
$fs->remove($this->limefile);
$fs->rename($this->limefile.'-new',$this->limefile);
if($fs->exists($this->limefile.'-new')) {
$fs->remove($this->limefile);
$fs->rename($this->limefile.'-new',$this->limefile);
}
// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );

View File

@ -18,8 +18,8 @@
> Synchronisation posh-profil à revoir
> Séparateur milier sur datatable
> Donner des permissions d'écritures sur les calendriers comme sur le blog
> Que faire si lock sur cron depuis trop longtemps
> Couleur sur blog
> Import de compte