Add STATUS.txt file
[framadate-sandstorm.git] / admin / index.php
blob61335d58f0b43bf47ff789f73bf3daeeae8b1e13
1 <?php
2 /**
3 * This software is governed by the CeCILL-B license. If a copy of this license
4 * is not distributed with this file, you can obtain one at
5 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
7 * Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
8 * Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
10 * =============================
12 * Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
13 * ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
14 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
16 * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
17 * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
19 namespace Framadate;
20 session_start();
22 include_once __DIR__ . '/../app/inc/init.php';
23 include_once __DIR__ . '/../bandeaux.php';
25 // Ce fichier index.php se trouve dans le sous-repertoire ADMIN de Studs. Il sert à afficher l'intranet de studs
26 // pour modifier les sondages directement sans avoir reçu les mails. C'est l'interface d'aministration
27 // de l'application.
29 // Affichage des balises standards
30 Utils::print_header( _("Polls administrator") );
31 bandeau_titre(_("Polls administrator"));
33 $sondage=$connect->Execute("select * from sondage");
35 echo'
36 <form action="' . Utils::get_server_name() . 'admin/index.php" method="POST">'."\n";
37 // Test et affichage du bouton de confirmation en cas de suppression de sondage
38 while($dsondage = $sondage->FetchNextObject(false)) {
39 if (Utils::issetAndNoEmpty('supprimersondage'.$dsondage->id_sondage) === true) {
40 echo '
41 <div class="alert alert-warning text-center">
42 <h3>'. _("Confirm removal of the poll ") .'"'.$dsondage->id_sondage.'</h3>
43 <p><button class="btn btn-default" type="submit" value="1" name="annullesuppression">'._("Keep this poll!").'</button>
44 <button type="submit" name="confirmesuppression'.$dsondage->id_sondage.'" value="1" class="btn btn-danger">'._("Remove this poll!").'</button></p>
45 </div>';
48 // Traitement de la confirmation de suppression
49 if (Utils::issetAndNoEmpty('confirmesuppression'.$dsondage->id_sondage) === true) {
50 // On inclut la routine de suppression
51 $date=date('H:i:s d/m/Y');
53 if (Utils::remove_sondage($connect, $dsondage->id_sondage)) {
54 // ecriture des traces dans le fichier de logs
55 error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, 'logs_studs.txt');
60 $sondage=$connect->Execute("select * from sondage WHERE date_fin > DATE_SUB(now(), INTERVAL 3 MONTH) ORDER BY date_fin ASC");
61 $nbsondages=$sondage->RecordCount();
63 $btn_logs = (is_readable('logs_studs.txt')) ? '<a role="button" class="btn btn-default btn-xs pull-right" href="'.str_replace('/admin','', Utils::get_server_name()).'admin/logs_studs.txt">'. _("Logs") .'</a>' : '';
65 echo '<p>' . $nbsondages. ' ' . _("polls in the database at this time") . $btn_logs .'</p>'."\n";
67 // tableau qui affiche tous les sondages de la base
68 echo '<table class="table table-bordered">
69 <tr align="center">
70 <th scope="col">'. _("Poll ID") .'</th>
71 <th scope="col">'. _("Format") .'</th>
72 <th scope="col">'. _("Title") .'</th>
73 <th scope="col">'. _("Author") .'</th>
74 <th scope="col">'. _("Email") .'</th>
75 <th scope="col">'. _("Expiration's date") .'</th>
76 <th scope="col">'. _("Users") .'</th>
77 <th scope="col" colspan="3">'. _("Actions") .'</th>
78 </tr>'."\n";
80 $i = 0;
81 while($dsondage = $sondage->FetchNextObject(false)) {
82 /* possible en 1 bonne requête dans $sondage */
83 $sujets=$connect->Execute( "select * from sujet_studs where id_sondage='$dsondage->id_sondage'");
84 $dsujets=$sujets->FetchObject(false);
86 $user_studs=$connect->Execute( "select * from user_studs where id_sondage='$dsondage->id_sondage'");
87 $nbuser=$user_studs->RecordCount();
89 echo '
90 <tr align="center">
91 <td>'.$dsondage->id_sondage.'</td>
92 <td>'.$dsondage->format.'</td>
93 <td>'. stripslashes($dsondage->titre).'</td>
94 <td>'.stripslashes($dsondage->nom_admin).'</td>
95 <td>'.stripslashes($dsondage->mail_admin).'</td>';
97 if (strtotime($dsondage->date_fin) > time()) {
98 echo '
99 <td>'.date("d/m/y",strtotime($dsondage->date_fin)).'</td>';
100 } else {
101 echo '
102 <td><span class="text-danger">'.date("d/m/y",strtotime($dsondage->date_fin)).'</span></td>';
104 echo '
105 <td>'.$nbuser.'</td>
106 <td><a href="' . Utils::getUrlSondage($dsondage->id_sondage) . '" 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>
107 <td><a href="' . Utils::getUrlSondage($dsondage->id_sondage_admin, 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>
108 <td><button type="submit" name="supprimersondage'.$dsondage->id_sondage.'" 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>
109 </tr>'."\n";
110 $i++;
113 echo '</table></form>'."\n";
115 bandeau_pied(true);