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

@ -16,28 +16,29 @@ class Console extends \descartes\InternalController
{ {
private $model_command; private $model_command;
private $model_database; private $model_database;
private $model_sended; private $model_sent;
private $model_smsstop; private $model_smsstop;
private $model_received; private $model_received;
private $model_scheduled;
private $model_user; private $model_user;
private $internal_scheduled;
private $internal_event; private $internal_event;
public function __construct() public function __construct()
{ {
$bdd = descartes\Model::connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD); $bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
$this->model_command = new \models\Command($bdd); $this->model_command = new \models\Command($bdd);
$this->model_database = new \models\DataBase($bdd); $this->model_database = new \models\DataBase($bdd);
$this->model_sended = new \models\Sent($bdd); $this->model_sent = new \models\Sent($bdd);
$this->model_smsstop = new \models\SmsStop($bdd); $this->model_smsstop = new \models\SmsStop($bdd);
$this->model_received = new \models\Received($bdd); $this->model_received = new \models\Received($bdd);
$this->model_user = new \models\User($bdd); $this->model_user = new \models\User($bdd);
$this->internal_event = new \controllers\internals\Event($bdd); $this->internal_event = new \controllers\internals\Event($bdd);
} }
/** /**
* Cette fonction envoie tous les Sms programmés qui doivent l'être. * Cette fonction envoie tous les Sms programmés qui doivent l'être.
*/ */
@ -131,7 +132,7 @@ class Console extends \descartes\InternalController
$now = $now->format('Y-m-d H:i:s'); $now = $now->format('Y-m-d H:i:s');
//On peut maintenant ajouter le Sms //On peut maintenant ajouter le Sms
if (!$id_sended = $this->model_sended->insert(['at' => $now, 'target' => $number, 'content' => $scheduled['content'], 'before_delivered' => ceil(mb_strlen($scheduled['content']) / 160)])) if (!$id_sended = $this->model_sent->insert(['at' => $now, 'target' => $number, 'content' => $scheduled['content'], 'before_delivered' => ceil(mb_strlen($scheduled['content']) / 160)]))
{ {
echo 'Impossible d\'inserer le sms pour le numero '.$number."\n"; echo 'Impossible d\'inserer le sms pour le numero '.$number."\n";
} }
@ -237,7 +238,7 @@ class Console extends \descartes\InternalController
$interval = new \DateInterval('PT12H'); $interval = new \DateInterval('PT12H');
$sinceDate = $now->sub($interval)->format('Y-m-d H:i:s'); $sinceDate = $now->sub($interval)->format('Y-m-d H:i:s');
if (!$sendeds = $this->model_sended->_select('sendeds', ['target' => $number, 'delivered' => false, 'failed' => false, '>at' => $sinceDate], 'at', false, 1)) if (!$sendeds = $this->model_sent->_select('sendeds', ['target' => $number, 'delivered' => false, 'failed' => false, '>at' => $sinceDate], 'at', false, 1))
{ {
continue; continue;
} }
@ -247,8 +248,8 @@ class Console extends \descartes\InternalController
//On gère les echecs //On gère les echecs
if ('Failed' === trim($text)) if ('Failed' === trim($text))
{ {
$this->model_sended->update($sended['id'], ['before_delivered' => 0, 'failed' => true]); $this->model_sent->update($sended['id'], ['before_delivered' => 0, 'failed' => true]);
echo 'Sent Sms id ' . $sended['id'] . " pass to failed status\n"; echo 'Sent Sms id '.$sended['id']." pass to failed status\n";
continue; continue;
} }
@ -257,14 +258,14 @@ class Console extends \descartes\InternalController
if ($sended['before_delivered'] > 1) if ($sended['before_delivered'] > 1)
{ {
$this->model_database->update($sended['id'], ['before_delivered' => $sended['before_delivered'] - 1]); $this->model_database->update($sended['id'], ['before_delivered' => $sended['before_delivered'] - 1]);
echo 'Sent Sms id ' . $sended['id'] . " before_delivered decrement\n"; echo 'Sent Sms id '.$sended['id']." before_delivered decrement\n";
continue; continue;
} }
//Si tout est bon, que nous avons assez d'accusés, nous validons ! //Si tout est bon, que nous avons assez d'accusés, nous validons !
$this->model_database->update($sended['id'], ['before_delivered' => 0, 'delivered' => true]); $this->model_database->update($sended['id'], ['before_delivered' => 0, 'delivered' => true]);
echo 'Sent Sms id ' . $sended['id'] . " to delivered status\n"; echo 'Sent Sms id '.$sended['id']." to delivered status\n";
continue; continue;
} }
@ -358,7 +359,6 @@ class Console extends \descartes\InternalController
return false; return false;
} }
global $this->model_database;
$transfers = $this->model_database->_select('transfers', ['progress' => false]); $transfers = $this->model_database->_select('transfers', ['progress' => false]);
$ids_transfers = []; $ids_transfers = [];

View File

@ -1,5 +1,15 @@
<?php <?php
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace controllers\internals; namespace controllers\internals;
/** /**

View File

@ -133,13 +133,19 @@ namespace controllers\internals;
* @param array $numbers : Les numéros auxquels envoyer le scheduled * @param array $numbers : Les numéros auxquels envoyer le scheduled
* @param array $contacts_ids : Les ids des contact auquels envoyer le scheduled * @param array $contacts_ids : Les ids des contact auquels envoyer le scheduled
* @param array $groups_ids : Les ids des group auxquels envoyer le scheduled * @param array $groups_ids : Les ids des group auxquels envoyer le scheduled
* @param mixed $id
* @param mixed $content
* @param mixed $at
* @param mixed $contact_ids
* @param mixed $flash
* @param mixed $progress
* *
* @return int : le nombre de ligne modifiées * @return int : le nombre de ligne modifiées
*/ */
public function update($id, $content, $at, $numbers = [], $contact_ids = [], $groups_ids = [], $flash = false, $progress = false) public function update($id, $content, $at, $numbers = [], $contact_ids = [], $groups_ids = [], $flash = false, $progress = false)
{ {
$scheduled = [ $scheduled = [
'at' => $date, 'at' => $at,
'content' => $content, 'content' => $content,
'flash' => $flash, 'flash' => $flash,
'progress' => $progress, 'progress' => $progress,
@ -209,11 +215,14 @@ namespace controllers\internals;
} }
/** /**
* This function update progress status of a scheduled sms * This function update progress status of a scheduled sms.
* @param bool $progress : Progress status *
* @param bool $progress : Progress status
* @param mixed $id_scheduled
*
* @return int : Number of update * @return int : Number of update
*/ */
public function update_progress ($id_scheduled, $progress) public function update_progress($id_scheduled, $progress)
{ {
return $this->model_scheduled->update($id_scheduled, ['progress' => $progress]); return $this->model_scheduled->update($id_scheduled, ['progress' => $progress]);
} }

View File

@ -17,11 +17,11 @@ namespace controllers\internals;
*/ */
class Sent extends \descartes\InternalController class Sent extends \descartes\InternalController
{ {
private $model_sended; private $model_sent;
public function __construct(\PDO $bdd) public function __construct(\PDO $bdd)
{ {
$this->model_sended = new \models\Sent($bdd); $this->model_sent = new \models\Sent($bdd);
} }
/** /**
@ -35,7 +35,7 @@ namespace controllers\internals;
public function list($nb_entry = false, $page = false) public function list($nb_entry = false, $page = false)
{ {
//Recupération des sendedes //Recupération des sendedes
return $this->model_sended->list($nb_entry, $nb_entry * $page); return $this->model_sent->list($nb_entry, $nb_entry * $page);
} }
/** /**
@ -48,7 +48,7 @@ namespace controllers\internals;
public function gets($ids) public function gets($ids)
{ {
//Recupération des sendedes //Recupération des sendedes
return $this->model_sended->gets($ids); return $this->model_sent->gets($ids);
} }
/** /**
@ -60,7 +60,7 @@ namespace controllers\internals;
*/ */
public function get_lasts_by_date($nb_entry = false) public function get_lasts_by_date($nb_entry = false)
{ {
return $this->model_sended->get_lasts_by_date($nb_entry); return $this->model_sent->get_lasts_by_date($nb_entry);
} }
/** /**
@ -73,7 +73,7 @@ namespace controllers\internals;
public function get_by_target($target) public function get_by_target($target)
{ {
//Recupération des sendeds //Recupération des sendeds
return $this->model_sended->get_by_target($target); return $this->model_sent->get_by_target($target);
} }
/** /**
@ -86,7 +86,7 @@ namespace controllers\internals;
*/ */
public function delete($id) public function delete($id)
{ {
return $this->model_sended->delete($id); return $this->model_sent->delete($id);
} }
/** /**
@ -98,7 +98,7 @@ namespace controllers\internals;
*/ */
public function create($sended) public function create($sended)
{ {
return $this->model_sended->create($sended); return $this->model_sent->create($sended);
} }
/** /**
@ -108,7 +108,7 @@ namespace controllers\internals;
*/ */
public function count() public function count()
{ {
return $this->model_sended->count(); return $this->model_sent->count();
} }
/** /**
@ -120,7 +120,7 @@ namespace controllers\internals;
*/ */
public function count_by_day_since($date) public function count_by_day_since($date)
{ {
$counts_by_day = $this->model_sended->count_by_day_since($date); $counts_by_day = $this->model_sent->count_by_day_since($date);
$return = []; $return = [];
foreach ($counts_by_day as $count_by_day) foreach ($counts_by_day as $count_by_day)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -58,6 +58,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf)) if (!$this->verify_csrf($csrf))
{ {
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !'); \modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Scheduled', 'list')); return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
} }
@ -141,6 +142,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf)) if (!$this->verify_csrf($csrf))
{ {
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !'); \modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Scheduled', 'add')); return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
} }
@ -153,12 +155,14 @@ namespace controllers\publics;
if (!$content) if (!$content)
{ {
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous ne pouvez pas créer un Sms sans message.'); \modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous ne pouvez pas créer un Sms sans message.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add')); 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')) 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.'); \modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez fournir une date valide.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add')); return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
} }
@ -179,6 +183,7 @@ namespace controllers\publics;
if (!$numbers && !$contacts && !$groups) if (!$numbers && !$contacts && !$groups)
{ {
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez renseigner au moins un destinataire pour le Sms.'); \modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Vous devez renseigner au moins un destinataire pour le Sms.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add')); 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)) if (!$scheduled_id = $this->internal_scheduled->create($scheduled, $numbers, $contacts, $groups))
{ {
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de créer le Sms.'); \modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Impossible de créer le Sms.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add')); return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
} }
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Le Sms a bien été créé pour le '.$date.'.'); \modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('success', 'Le Sms a bien été créé pour le '.$date.'.');
return $this->redirect(\descartes\Router::url('Scheduled', 'list')); return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
} }
@ -212,6 +219,7 @@ namespace controllers\publics;
if (!$this->verify_csrf($csrf)) if (!$this->verify_csrf($csrf))
{ {
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !'); \modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
return $this->redirect(\descartes\Router::url('Scheduled', 'list')); return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
} }
@ -230,12 +238,14 @@ namespace controllers\publics;
if (!$content) if (!$content)
{ {
$all_update_ok = false; $all_update_ok = false;
continue; 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')) 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; $all_update_ok = false;
continue; continue;
} }
@ -246,6 +256,7 @@ namespace controllers\publics;
if (!$number) if (!$number)
{ {
unset($numbers[$key]); unset($numbers[$key]);
continue; continue;
} }
@ -255,13 +266,15 @@ namespace controllers\publics;
if (!$numbers && !$contacts && !$groups) if (!$numbers && !$contacts && !$groups)
{ {
$all_update_ok = false; $all_update_ok = false;
continue; 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) if (!$success)
{ {
$all_update_ok = false; $all_update_ok = false;
continue; continue;
} }
} }
@ -269,10 +282,12 @@ namespace controllers\publics;
if (!$all_update_ok) 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')); 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')); return $this->redirect(\descartes\Router::url('Scheduled', 'list'));
} }
} }

View File

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

View File

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

View File

@ -58,18 +58,17 @@ namespace models;
return isset($contacts[0]) ? $contacts[0] : false; return isset($contacts[0]) ? $contacts[0] : false;
} }
/** /**
* Get contacts of a particular group * Get contacts of a particular group.
* *
* @param int $id_group : Id of the group we want contacts for * @param int $id_group : Id of the group we want contacts for
*
* @return array * @return array
*/ */
public function get_by_group($id_group) public function get_by_group($id_group)
{ {
$contacts = $this->_select('contact', ['id_group' => $id_group]); return $this->_select('contact', ['id_group' => $id_group]);
return $contacts;
} }
/** /**

View File

@ -14,7 +14,6 @@ namespace models;
class DataBase extends \descartes\Model class DataBase extends \descartes\Model
{ {
// //
// PARTIE DES REQUETES SCHEDULEDS_NUMBERS // PARTIE DES REQUETES SCHEDULEDS_NUMBERS
// //

View File

@ -1,5 +1,14 @@
<?php <?php
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace models; namespace models;

View File

@ -64,16 +64,17 @@ namespace models;
} }
/** /**
* Get scheduleds message not in progress and before a date * Get scheduleds message not in progress and before a date.
*
* @param string $date : Limit date * @param string $date : Limit date
*
* @return array * @return array
*/ */
public function get_scheduleds_not_in_progress_before ($date) public function get_scheduleds_not_in_progress_before($date)
{ {
return $this->_select('scheduleds', ['<=at' => $date, 'progress' => false]); return $this->_select('scheduleds', ['<=at' => $date, 'progress' => false]);
} }
/** /**
* Cette fonction retourne les messages programmés avant une date et pour un numéro. * Cette fonction retourne les messages programmés avant une date et pour un numéro.
* *

View File

@ -15,7 +15,7 @@ namespace models;
/** /**
* Cette classe gère les accès bdd pour les sendedes. * Cette classe gère les accès bdd pour les sendedes.
*/ */
class Sended extends \descartes\Model class Sent extends \descartes\Model
{ {
/** /**
* Retourne une entrée par son id. * Retourne une entrée par son id.