Rename a few classes, fix bugs, fix syntax

This commit is contained in:
osaajani 2019-11-06 20:34:26 +01:00
parent 7cb963b8cf
commit bda1c7ddfd
18 changed files with 106 additions and 37 deletions

View file

@ -108,6 +108,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Command', 'list'));
}
@ -118,16 +119,19 @@ namespace controllers\publics;
if (!$name || !$script)
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Renseignez au moins un nom et un script.');
return $this->redirect(\descartes\Router::url('Command', 'list'));
}
if (!$this->internal_command->create($name, $script, $admin))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible créer cette commande.');
return $this->redirect(\descartes\Router::url('commands', 'add'));
}
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'La commande a bien été crée.');
return $this->redirect(\descartes\Router::url('Command', 'list'));
}
@ -144,6 +148,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Command', 'list'));
}
@ -157,10 +162,12 @@ namespace controllers\publics;
if ($nb_commands_update !== \count($_POST['commands']))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Certaines commandes n\'ont pas pu êtres mises à jour.');
return $this->redirect(\descartes\Router::url('Command', 'list'));
}
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Toutes les commandes ont été modifiées avec succès.');
return $this->redirect(\descartes\Router::url('Command', 'list'));
}
}

View file

@ -87,6 +87,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Connect', 'forget_password'));
}
@ -96,6 +97,7 @@ namespace controllers\publics;
if (!$email || !$user)
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Aucun utilisateur n\'existe pour cette adresse mail.');
return $this->redirect(\descartes\Router::url('Connect', 'forget_password'));
}
@ -144,6 +146,7 @@ namespace controllers\publics;
{
session_unset();
session_destroy();
return $this->redirect(\descartes\Router::url('Connect', 'login'));
}
}

View file

@ -45,6 +45,7 @@ namespace controllers\publics;
{
$page = (int) $page;
$contacts = $this->internal_contact->list(25, $page);
return $this->render('contact/list', ['contacts' => $contacts]);
}
@ -61,6 +62,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Contact', 'list'));
}

View file

@ -60,12 +60,14 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Event', 'list'));
}
if (!\controllers\internals\Tool::is_admin())
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez être admin pour pouvoir supprimer des events.');
return $this->redirect(\descartes\Router::url('Event', 'list'));
}

View file

@ -70,6 +70,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Group', 'list'));
}
@ -120,6 +121,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Group', 'add'));
}
@ -129,6 +131,7 @@ namespace controllers\publics;
if (!$name || !$contacts_ids)
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Des champs sont manquants !');
return $this->redirect(\descartes\Router::url('Group', 'add'));
}
@ -136,10 +139,12 @@ namespace controllers\publics;
if (!$id_group)
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de créer ce groupe.');
return $this->redirect(\descartes\Router::url('Group', 'add'));
}
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Le groupe a bien été créé.');
return $this->redirect(\descartes\Router::url('Group', 'list'));
}
@ -156,6 +161,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Group', 'list'));
}
@ -170,10 +176,12 @@ namespace controllers\publics;
if ($nb_groups_update !== \count($groups))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Certains groupes n\'ont pas pu êtres mis à jour.');
return $this->redirect(\descartes\Router::url('Group', 'list'));
}
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Tous les groupes ont été modifiés avec succès.');
return $this->redirect(\descartes\Router::url('Group', 'list'));
}

View file

@ -108,12 +108,14 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Received', 'list'));
}
if (!\controllers\internals\Tool::is_admin())
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez être administrateur pour effectuer cette action.');
return $this->redirect(\descartes\Router::url('Received', 'list'));
}

View file

@ -58,6 +58,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}
@ -141,6 +142,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
@ -153,12 +155,14 @@ namespace controllers\publics;
if (!$content)
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous ne pouvez pas créer un Sms sans message.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (!\controllers\internals\Tool::validate_date($date, 'Y-m-d H:i:s') && !\controllers\internals\Tool::validate_date($date, 'Y-m-d H:i'))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez fournir une date valide.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
@ -179,6 +183,7 @@ namespace controllers\publics;
if (!$numbers && !$contacts && !$groups)
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez renseigner au moins un destinataire pour le Sms.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
@ -192,10 +197,12 @@ namespace controllers\publics;
if (!$scheduled_id = $this->internal_scheduled->create($scheduled, $numbers, $contacts, $groups))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de créer le Sms.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Le Sms a bien été créé pour le '.$date.'.');
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}
@ -212,6 +219,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}
@ -230,12 +238,14 @@ namespace controllers\publics;
if (!$content)
{
$all_update_ok = false;
continue;
}
if (!\controllers\internals\Tool::validate_date($date, 'Y-m-d H:i:s') && !\controllers\internals\Tool::validate_date($date, 'Y-m-d H:i'))
{
$all_update_ok = false;
continue;
}
@ -246,6 +256,7 @@ namespace controllers\publics;
if (!$number)
{
unset($numbers[$key]);
continue;
}
@ -255,13 +266,15 @@ namespace controllers\publics;
if (!$numbers && !$contacts && !$groups)
{
$all_update_ok = false;
continue;
}
$success = $this->internal_scheduled->update($id_scheduled, $content, $at, $numbers, $contacts, $groups);
$success = $this->internal_scheduled->update($id_scheduled, $content, $date, $numbers, $contacts, $groups);
if (!$success)
{
$all_update_ok = false;
continue;
}
}
@ -269,10 +282,12 @@ namespace controllers\publics;
if (!$all_update_ok)
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Certains SMS n\'ont pas pu êtres mis à jour.');
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Tous les SMS ont été mis à jour.');
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
}
}

View file

@ -59,6 +59,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Sent', 'list'));
}

View file

@ -59,12 +59,14 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf))
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('SmsStop', 'list'));
}
if (!\controllers\internals\Tool::is_admin())
{
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez être administrateur pour pouvoir supprimer un "STOP Sms" !');
return $this->redirect(\descartes\Router::url('SmsStop', 'list'));
}