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)
|
|
|
|
*
|
2014-07-04 11:21:31 +02:00
|
|
|
* =============================
|
2014-09-04 17:52:18 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
2014-07-04 11:21:31 +02:00
|
|
|
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
2014-09-04 17:52:18 +02:00
|
|
|
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
2014-07-04 11:21:31 +02:00
|
|
|
*/
|
2014-09-04 17:52:18 +02:00
|
|
|
namespace Framadate;
|
|
|
|
|
|
|
|
include_once __DIR__ . '/app/inc/init.php';
|
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
/* Functions */
|
|
|
|
/* --------- */
|
2014-09-29 16:33:15 +02:00
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
function split_slots($slots) {
|
|
|
|
$splitted = array();
|
|
|
|
foreach ($slots as $slot) {
|
|
|
|
$ex = explode('@', $slot->sujet);
|
|
|
|
$obj = new \stdClass();
|
|
|
|
$obj->day = $ex[0];
|
|
|
|
$obj->moments = explode(',', $ex[1]);
|
2014-09-04 17:52:18 +02:00
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
$splitted[] = $obj;
|
2011-05-15 03:56:54 +02:00
|
|
|
}
|
2014-12-12 13:43:43 +01:00
|
|
|
return $splitted;
|
2014-10-21 01:31:26 +02:00
|
|
|
}
|
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
function split_votes($votes) {
|
|
|
|
$splitted = array();
|
|
|
|
foreach ($votes as $vote) {
|
|
|
|
$obj = new \stdClass();
|
|
|
|
$obj->id = $vote->id_users;
|
|
|
|
$obj->name = $vote->nom;
|
|
|
|
$obj->choices = str_split($vote->reponses);
|
2014-09-04 17:52:18 +02:00
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
$splitted[] = $obj;
|
2011-05-15 03:56:54 +02:00
|
|
|
}
|
2014-12-12 13:43:43 +01:00
|
|
|
return $splitted;
|
2011-05-15 03:56:54 +02:00
|
|
|
}
|
2014-09-04 17:52:18 +02:00
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
/* PAGE */
|
|
|
|
/* ---- */
|
2011-05-15 03:56:54 +02:00
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
if(!empty($_GET['poll'])) {
|
|
|
|
$poll_id = $_GET['poll'];
|
2014-09-04 17:52:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
$poll = $connect->findPollById($poll_id);
|
2014-09-04 17:52:18 +02:00
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
if (!$poll) {
|
|
|
|
$smarty->assign('error', 'This poll doesn\'t exist');
|
|
|
|
$smarty->display('error.tpl');
|
|
|
|
exit;
|
2011-05-15 03:56:54 +02:00
|
|
|
}
|
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
// Retrieve data
|
|
|
|
$slots = $connect->allSlotsByPollId($poll_id);
|
|
|
|
$votes = $connect->allUserVotesByPollId($poll_id);
|
2014-10-21 01:31:26 +02:00
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
// Assign data to template
|
|
|
|
$smarty->assign('poll_id', $poll_id);
|
|
|
|
$smarty->assign('poll', $poll);
|
|
|
|
$smarty->assign('title', _('Poll') . ' - ' . $poll->title);
|
|
|
|
$smarty->assign('slots', split_slots($slots));
|
|
|
|
$smarty->assign('votes', split_votes($votes));
|
|
|
|
$smarty->assign('editingVoteId', 0); // TODO Replace by the right ID
|
2014-09-04 17:52:18 +02:00
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
//Utils::debug(split_votes($votes));exit;
|
2014-09-04 17:52:18 +02:00
|
|
|
|
2014-12-12 13:43:43 +01:00
|
|
|
$smarty->display('studs.tpl');
|