2019-10-29 14:57:13 +01:00
|
|
|
<?php
|
|
|
|
namespace controllers\publics;
|
2019-10-29 18:36:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Page des sendeds
|
|
|
|
*/
|
|
|
|
class Sended extends \descartes\Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Cette fonction est appelée avant toute les autres :
|
|
|
|
* Elle vérifie que l'utilisateur est bien connecté
|
|
|
|
* @return void;
|
|
|
|
*/
|
|
|
|
public function _before()
|
2019-10-29 14:57:13 +01:00
|
|
|
{
|
|
|
|
global $bdd;
|
|
|
|
$this->bdd = $bdd;
|
|
|
|
|
|
|
|
$this->internalSended = new \controllers\internals\Sended($this->bdd);
|
|
|
|
|
2019-10-29 18:36:25 +01:00
|
|
|
\controllers\internals\Tool::verify_connect();
|
2019-10-29 14:57:13 +01:00
|
|
|
}
|
|
|
|
|
2019-10-29 18:36:25 +01:00
|
|
|
/**
|
|
|
|
* Cette fonction retourne tous les sendeds, sous forme d'un tableau permettant l'administration de ces sendeds
|
|
|
|
*/
|
|
|
|
public function list($page = 0)
|
2019-10-29 14:57:13 +01:00
|
|
|
{
|
|
|
|
$page = (int) $page;
|
|
|
|
$limit = 25;
|
|
|
|
$sendeds = $this->internalSended->get_list($limit, $page);
|
|
|
|
$this->render('sended/list', ['sendeds' => $sendeds, 'page' => $page, 'limit' => $limit, 'nb_results' => count($sendeds)]);
|
2019-10-29 18:36:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-29 14:57:13 +01:00
|
|
|
* Cette fonction va supprimer une liste de sendeds
|
|
|
|
* @param array int $_GET['ids'] : Les id des sendedes à supprimer
|
|
|
|
* @return boolean;
|
|
|
|
*/
|
|
|
|
public function delete($csrf)
|
|
|
|
{
|
2019-10-29 18:36:25 +01:00
|
|
|
if (!$this->verifyCSRF($csrf)) {
|
2019-10-29 14:57:13 +01:00
|
|
|
\modules\DescartesSessionMessages\internals\DescartesSessionMessages::push('danger', 'Jeton CSRF invalid !');
|
2019-10-29 18:36:25 +01:00
|
|
|
return header('Location: ' . \descartes\Router::url('Sended', 'list'));
|
2019-10-29 14:57:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$ids = $_GET['ids'] ?? [];
|
2019-10-29 18:36:25 +01:00
|
|
|
foreach ($ids as $id) {
|
2019-10-29 14:57:13 +01:00
|
|
|
$this->internalSended->delete($id);
|
|
|
|
}
|
|
|
|
|
2019-10-29 18:36:25 +01:00
|
|
|
return header('Location: ' . \descartes\Router::url('Sended', 'list'));
|
2019-10-29 14:57:13 +01:00
|
|
|
}
|
2019-10-29 18:36:25 +01:00
|
|
|
}
|