mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-22 01:16:26 +02:00
fix a few things
This commit is contained in:
parent
be194a06a8
commit
8f9bf0a729
11 changed files with 53 additions and 103 deletions
|
@ -50,7 +50,7 @@ namespace controllers\publics;
|
|||
|
||||
foreach ($groups as $key => $group)
|
||||
{
|
||||
$contacts = $this->internal_group->get_contact($group['id']);
|
||||
$contacts = $this->internal_group->get_contacts($group['id']);
|
||||
$groups[$key]['nb_contacts'] = \count($contacts);
|
||||
}
|
||||
|
||||
|
@ -70,17 +70,13 @@ namespace controllers\publics;
|
|||
if (!$this->verify_csrf($csrf))
|
||||
{
|
||||
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
|
||||
$this->redirect(\descartes\Router::url('Group', 'list'));
|
||||
|
||||
return false;
|
||||
return $this->redirect(\descartes\Router::url('Group', 'list'));
|
||||
}
|
||||
|
||||
$ids = $_GET['ids'] ?? [];
|
||||
$this->internal_group->delete($ids);
|
||||
|
||||
$this->redirect(\descartes\Router::url('Group', 'list'));
|
||||
|
||||
return true;
|
||||
return $this->redirect(\descartes\Router::url('Group', 'list'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,7 +100,7 @@ namespace controllers\publics;
|
|||
|
||||
foreach ($groups as $key => $group)
|
||||
{
|
||||
$groups[$key]['contacts'] = $this->internal_group->get_contact($group['id']);
|
||||
$groups[$key]['contacts'] = $this->internal_group->get_contacts($group['id']);
|
||||
}
|
||||
|
||||
$this->render('group/edit', [
|
||||
|
@ -124,7 +120,6 @@ 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'));
|
||||
}
|
||||
|
||||
|
@ -134,20 +129,17 @@ 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'));
|
||||
}
|
||||
|
||||
$id_group = $this->internal_group->create($name, $contacts_ids);
|
||||
if (!$id_group)
|
||||
{
|
||||
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de créer ce 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 group a bien été créé.');
|
||||
|
||||
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Le groupe a bien été créé.');
|
||||
return $this->redirect(\descartes\Router::url('Group', 'list'));
|
||||
}
|
||||
|
||||
|
@ -164,9 +156,7 @@ namespace controllers\publics;
|
|||
if (!$this->verify_csrf($csrf))
|
||||
{
|
||||
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
|
||||
$this->redirect(\descartes\Router::url('Group', 'list'));
|
||||
|
||||
return false;
|
||||
return $this->redirect(\descartes\Router::url('Group', 'list'));
|
||||
}
|
||||
|
||||
$groups = $_POST['groups'] ?? [];
|
||||
|
@ -179,13 +169,11 @@ namespace controllers\publics;
|
|||
|
||||
if ($nb_groups_update !== \count($groups))
|
||||
{
|
||||
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Certains groups n\'ont pas pu êtres mis à jour.');
|
||||
|
||||
\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 groups ont été modifiés avec succès.');
|
||||
|
||||
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Tous les groupes ont été modifiés avec succès.');
|
||||
return $this->redirect(\descartes\Router::url('Group', 'list'));
|
||||
}
|
||||
|
||||
|
|
|
@ -108,14 +108,12 @@ 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'));
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ 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'));
|
||||
}
|
||||
|
||||
|
@ -142,7 +141,6 @@ 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'));
|
||||
}
|
||||
|
||||
|
@ -155,14 +153,12 @@ 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'));
|
||||
}
|
||||
|
||||
|
@ -183,7 +179,6 @@ 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'));
|
||||
}
|
||||
|
||||
|
@ -197,12 +192,10 @@ 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'));
|
||||
}
|
||||
|
||||
|
@ -219,7 +212,6 @@ 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'));
|
||||
}
|
||||
|
||||
|
@ -238,14 +230,12 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -256,7 +246,6 @@ namespace controllers\publics;
|
|||
if (!$number)
|
||||
{
|
||||
unset($numbers[$key]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -266,40 +255,24 @@ namespace controllers\publics;
|
|||
if (!$numbers && !$contacts && !$groups)
|
||||
{
|
||||
$all_update_ok = false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$scheduled = [
|
||||
'scheduled' => [
|
||||
'id' => $id_scheduled,
|
||||
'at' => $date,
|
||||
'content' => $content,
|
||||
'flash' => false,
|
||||
'progress' => false,
|
||||
],
|
||||
'numbers' => $numbers,
|
||||
'contacts_ids' => $contacts,
|
||||
'groups_ids' => $groups,
|
||||
];
|
||||
|
||||
if (!$this->internal_scheduled->update([$scheduled]))
|
||||
$success = $this->internal_scheduled->update($id_scheduled, $content, $at, $numbers, $contacts, $groups);
|
||||
if (!$success)
|
||||
{
|
||||
$all_update_ok = false;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$all_update_ok)
|
||||
{
|
||||
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Certains Sms n\'ont pas pu êtres mis à jour.');
|
||||
|
||||
\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.');
|
||||
|
||||
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Tous les SMS ont été mis à jour.');
|
||||
return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue