2011-05-15 01:32:47 +02:00
|
|
|
<?php
|
2014-09-04 17:52:18 +02:00
|
|
|
/**
|
|
|
|
* This software is governed by the CeCILL-B license. If a copy of this license
|
|
|
|
* is not distributed with this file, you can obtain one at
|
|
|
|
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
|
|
|
|
*
|
|
|
|
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
|
|
|
|
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
|
|
|
|
*
|
|
|
|
* =============================
|
|
|
|
*
|
|
|
|
* Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
|
|
|
|
* ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
|
|
|
|
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
|
|
|
|
*
|
|
|
|
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
|
|
|
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
|
|
|
*/
|
2015-01-06 23:52:52 +01:00
|
|
|
|
|
|
|
use Framadate\Services\AdminPollService;
|
|
|
|
use Framadate\Services\LogService;
|
|
|
|
use Framadate\Services\PollService;
|
|
|
|
use Framadate\Services\SuperAdminService;
|
|
|
|
use Framadate\Utils;
|
2011-05-15 01:32:47 +02:00
|
|
|
|
2014-09-04 17:52:18 +02:00
|
|
|
include_once __DIR__ . '/../app/inc/init.php';
|
|
|
|
include_once __DIR__ . '/../bandeaux.php';
|
2011-05-15 01:32:47 +02:00
|
|
|
|
2015-01-06 23:52:52 +01:00
|
|
|
/* Services */
|
|
|
|
/*----------*/
|
|
|
|
$logService = new LogService();
|
|
|
|
$pollService = new PollService($connect, $logService);
|
|
|
|
$adminPollService = new AdminPollService($connect, $pollService, $logService);
|
|
|
|
$superAdminService = new SuperAdminService($connect);
|
|
|
|
|
2014-09-04 17:52:18 +02:00
|
|
|
// Ce fichier index.php se trouve dans le sous-repertoire ADMIN de Studs. Il sert à afficher l'intranet de studs
|
2011-05-15 01:32:47 +02:00
|
|
|
// pour modifier les sondages directement sans avoir reçu les mails. C'est l'interface d'aministration
|
|
|
|
// de l'application.
|
|
|
|
|
|
|
|
// Affichage des balises standards
|
2015-01-06 23:52:52 +01:00
|
|
|
Utils::print_header(_('Polls administrator'));
|
2014-11-27 00:52:47 +01:00
|
|
|
bandeau_titre(_('Polls administrator'));
|
2011-05-15 01:32:47 +02:00
|
|
|
|
2015-01-06 23:52:52 +01:00
|
|
|
$polls = $superAdminService->findAllPolls();
|
|
|
|
|
|
|
|
echo '<form action="' . Utils::get_server_name() . 'admin/index.php" method="POST">' . "\n";
|
2011-05-15 01:32:47 +02:00
|
|
|
|
|
|
|
// Test et affichage du bouton de confirmation en cas de suppression de sondage
|
2015-01-06 23:52:52 +01:00
|
|
|
foreach ($polls as $poll) {
|
|
|
|
if (!empty($_POST['supprimersondage' . $poll->id])) {
|
2014-09-04 17:52:18 +02:00
|
|
|
echo '
|
|
|
|
<div class="alert alert-warning text-center">
|
2015-01-06 23:52:52 +01:00
|
|
|
<h3>' . _("Confirm removal of the poll ") . '"' . $poll->id . '</h3>
|
|
|
|
<p><button class="btn btn-default" type="submit" value="1" name="annullesuppression">' . _('Keep this poll!') . '</button>
|
|
|
|
<button type="submit" name="confirmesuppression' . $poll->id . '" value="1" class="btn btn-danger">' . _('Remove this poll!') . '</button></p>
|
2014-09-04 17:52:18 +02:00
|
|
|
</div>';
|
2011-12-30 04:16:41 +01:00
|
|
|
}
|
|
|
|
|
2014-09-04 17:52:18 +02:00
|
|
|
// Traitement de la confirmation de suppression
|
2015-01-06 23:52:52 +01:00
|
|
|
if (!empty($_POST['confirmesuppression' . $poll->id])) {
|
2014-09-04 17:52:18 +02:00
|
|
|
// On inclut la routine de suppression
|
2014-11-27 00:52:47 +01:00
|
|
|
$date = date('H:i:s d/m/Y');
|
2011-12-30 04:16:41 +01:00
|
|
|
|
2015-01-06 23:52:52 +01:00
|
|
|
$adminPollService->deleteEntirePoll($poll->id);
|
2014-09-04 17:52:18 +02:00
|
|
|
}
|
2011-05-15 01:32:47 +02:00
|
|
|
}
|
|
|
|
|
2015-01-06 23:52:52 +01:00
|
|
|
$btn_logs = (is_readable('../' . LOG_FILE)) ? '<a role="button" class="btn btn-default btn-xs pull-right" href="' . Utils::get_server_name() . LOG_FILE . '">' . _("Logs") . '</a>' : '';
|
2014-10-21 01:31:26 +02:00
|
|
|
|
2015-01-06 23:52:52 +01:00
|
|
|
echo '<p>' . count($polls) . ' ' . _("polls in the database at this time") . $btn_logs . '</p>' . "\n";
|
2011-05-15 01:32:47 +02:00
|
|
|
|
|
|
|
// tableau qui affiche tous les sondages de la base
|
2014-09-04 17:52:18 +02:00
|
|
|
echo '<table class="table table-bordered">
|
|
|
|
<tr align="center">
|
2015-01-06 23:52:52 +01:00
|
|
|
<th scope="col">' . _('Poll ID') . '</th>
|
|
|
|
<th scope="col">' . _('Format') . '</th>
|
|
|
|
<th scope="col">' . _('Title') . '</th>
|
|
|
|
<th scope="col">' . _('Author') . '</th>
|
|
|
|
<th scope="col">' . _('Email') . '</th>
|
|
|
|
<th scope="col">' . _('Expiration\'s date') . '</th>
|
|
|
|
<th scope="col">' . _('Users') . '</th>
|
|
|
|
<th scope="col" colspan="3">' . _('Actions') . '</th>
|
|
|
|
</tr>' . "\n";
|
2011-05-15 01:32:47 +02:00
|
|
|
|
|
|
|
$i = 0;
|
2015-01-06 23:52:52 +01:00
|
|
|
foreach ($polls as $poll) {
|
|
|
|
$nb_users = $pollService->countVotesByPollId($poll->id);
|
2014-09-04 17:52:18 +02:00
|
|
|
|
2015-01-06 23:52:52 +01:00
|
|
|
if ($poll->format === 'D') {
|
|
|
|
$format_html = '<span class="glyphicon glyphicon-calendar" aria-hidden="true"></span><span class="sr-only">'. _('Date').'</span>';
|
|
|
|
} else {
|
|
|
|
$format_html = '<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span><span class="sr-only">'. _('Classic').'</span>';
|
|
|
|
}
|
2014-09-04 17:52:18 +02:00
|
|
|
echo '
|
|
|
|
<tr align="center">
|
2015-01-06 23:52:52 +01:00
|
|
|
<td>' . $poll->id . '</td>
|
|
|
|
<td>' . $format_html . '</td>
|
|
|
|
<td>' . htmlentities($poll->title) . '</td>
|
|
|
|
<td>' . htmlentities($poll->admin_name) . '</td>
|
|
|
|
<td>' . htmlentities($poll->admin_mail) . '</td>';
|
|
|
|
|
|
|
|
if (strtotime($poll->end_date) > time()) {
|
|
|
|
echo '<td>' . date('d/m/y', strtotime($poll->end_date)) . '</td>';
|
2014-09-04 17:52:18 +02:00
|
|
|
} else {
|
2015-01-06 23:52:52 +01:00
|
|
|
echo '<td><span class="text-danger">' . date('d/m/y', strtotime($poll->end_date)) . '</span></td>';
|
2014-09-04 17:52:18 +02:00
|
|
|
}
|
|
|
|
echo '
|
2015-01-06 23:52:52 +01:00
|
|
|
<td>' . $nb_users . '</td>
|
|
|
|
<td><a href="' . Utils::getUrlSondage($poll->id) . '" class="btn btn-link" title="' . _('See the poll') . '"><span class="glyphicon glyphicon-eye-open"></span><span class="sr-only">' . _('See the poll') . '</span></a></td>
|
|
|
|
<td><a href="' . Utils::getUrlSondage($poll->admin_id, true) . '" class="btn btn-link" title="' . _('Change the poll') . '"><span class="glyphicon glyphicon-pencil"></span><span class="sr-only">' . _("Change the poll") . '</span></a></td>
|
|
|
|
<td><button type="submit" name="supprimersondage' . $poll->id . '" value="' . _('Remove the poll') . '" class="btn btn-link" title="' . _("Remove the poll") . '"><span class="glyphicon glyphicon-trash text-danger"></span><span class="sr-only">' . _('Remove the poll') . '</span></td>
|
|
|
|
</tr>' . "\n";
|
2014-11-27 00:52:47 +01:00
|
|
|
++$i;
|
2011-05-15 01:32:47 +02:00
|
|
|
}
|
|
|
|
|
2015-01-06 23:52:52 +01:00
|
|
|
echo '</table></form>' . "\n";
|
2014-09-04 17:52:18 +02:00
|
|
|
|
|
|
|
bandeau_pied(true);
|