diff --git a/adminstuds.php b/adminstuds.php index 53a0122..ec82d51 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -16,1199 +16,56 @@ * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft) */ -namespace Framadate; +use Framadate\Services\PollService; +use Framadate\Services\InputService; +use Framadate\Message; +use Framadate\Utils; -session_start(); - -//setlocale(LC_TIME, "fr_FR"); include_once __DIR__ . '/app/inc/init.php'; -if (file_exists('bandeaux_local.php')) { - include_once('bandeaux_local.php'); -} else { - include_once('bandeaux.php'); -} +/* Variables */ +/* --------- */ +$admin_poll_id = null; +$poll_id = null; +$poll = null; +$message = null; -// recuperation du numero de sondage admin (24 car.) dans l'URL -if (!empty($_GET['sondage']) && is_string($_GET['sondage']) && strlen($_GET['sondage']) === 24) { - $admin_poll_id = $_GET["sondage"]; - // on découpe le résultat pour avoir le numéro de sondage (16 car.) +/* Services */ +/*----------*/ + +$pollService = new PollService($connect); +$inputService = new InputService(); + +/* PAGE */ +/* ---- */ + +if(!empty($_GET['poll']) && strlen($_GET['poll']) === 24) { + $admin_poll_id = filter_input(INPUT_GET, 'poll', FILTER_VALIDATE_REGEXP, ['options'=>['regexp'=>'/^[a-z0-9]+$/']]); $poll_id = substr($admin_poll_id, 0, 16); + $poll = $pollService->findById($poll_id); } -if (preg_match(";[\w\d]{24};i", $admin_poll_id)) { - $prepared = $connect->prepare('SELECT * FROM sondage WHERE admin_poll_id = ?'); - $prepared->execute(array($admin_poll_id)); - $poll = $prepared->fetch(); - $prepared->closeCursor(); - - $prepared = $connect->prepare('SELECT * FROM sujet_studs WHERE id_sondage = ?'); - $prepared->execute(array($poll_id)); - $sujets = $prepared->fetchAll(); - - $prepared = $connect->prepare('SELECT * FROM user_studs WHERE id_sondage = ? order by id_users'); - $prepared->execute(array($poll_id)); - $users = $prepared->fetchAll(); +if (!$poll) { + $smarty->assign('error', 'This poll doesn\'t exist'); + $smarty->display('error.tpl'); + exit; } -//verification de l'existence du sondage, s'il n'existe pas on met une page d'erreur -if (!$poll || !$sujets) { - Utils::print_header( _('Error!')); - - bandeau_titre(_('Error!')); - - echo ' -
' . _('Back to the homepage of ') . ' ' . NOMAPPLICATION . '
-' . _('Back to the homepage of ') . ' ' . NOMAPPLICATION . '
-' . _('Back to the homepage of ') . ' ' . NOMAPPLICATION . '
-' . _('Back to the homepage of ') . ' ' . NOMAPPLICATION . '
+' . _('Back to the homepage of ') . ' ' . NOMAPPLICATION . '
+' . _('Back to the homepage of ') . ' ' . NOMAPPLICATION . '
+