// // This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. // // To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/1.0/ // // or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. // // Francais (brouillon): http://creativecommons.org/projects/international/fr/translated-license // ////////////////////////////////////////////////////////////////////////////////////////////////////// // Espace administrateur / Votes // v0.1.0 function print_liste($liste) { if(count($liste) < 1) return "

Aucun vote.

"; $out = ''; return $out; } $requiredFiles = array("votes",'fonctions'); include_once("head.php"); if(!$cfg['votes']) header("location: index?err=".urlencode("Vous devez activer les votes dans la configuration.")); if($_POST['nouveau']) { $debut = mktime($_POST['debut']['heure'],$_POST['debut']['minute'],0,$_POST['debut']['mois'],$_POST['debut']['jour'],$_POST['debut']['annee']); $fin = mktime($_POST['fin']['heure'],$_POST['fin']['minute'],0,$_POST['fin']['mois'],$_POST['fin']['jour'],$_POST['fin']['annee']); $votes->ajout($_POST['titre'],$_POST['texte'],$_POST['choix'],$debut,$fin); $err = "Vote ajouté."; } elseif($_POST['modifier']) { $debut = mktime($_POST['debut']['heure'],$_POST['debut']['minute'],0,$_POST['debut']['mois'],$_POST['debut']['jour'],$_POST['debut']['annee']); $fin = mktime($_POST['fin']['heure'],$_POST['fin']['minute'],0,$_POST['fin']['mois'],$_POST['fin']['jour'],$_POST['fin']['annee']); $votes->modifier($_POST['id'],$_POST['titre'],$_POST['texte'],$_POST['choix'],$debut,$fin); $err = "Vote modifié."; $act = "voir"; $id = $_POST['id']; } elseif($_GET['supprimer']) { $votes->supprimer($_GET['supprimer']); $err = "Vote supprimé."; } elseif($_GET['valider']) { $votes->valider($_GET['valider']); $err = "Vote validé."; } if($err) $page = '

'.$err.'

'; $page.= ' '; $act = $_GET['act']; if($_GET['voir']) { $act = "voir"; $id = $_GET['voir']; } elseif($_GET['modifier']) { $id = $_GET['modifier']; $act = "modifier"; } elseif($_GET['voir_votes']) { $id = $_GET['voir_votes']; $act = "voir_votes"; } if($act == "nouveau" || $act == "modifier") { if($act == "modifier") { $_POST = $votes->lire($id); for($i = 1; $i <= 8; $i++) $_POST['choix'][$i] = $_POST["choix".$i]; } else { $_POST['date_debut'] = time(); $_POST['date_fin'] = time(); } $page.= '
'.show_date("debut",$_POST['date_debut']).'
'.show_date("fin",$_POST['date_fin']).'
'; if($act == "modifier") $page.= '
'; else $page.= '
'; $page.= ''; } elseif($act == "attente") { $liste = $votes->liste("proposition"); $page.= '

Votes en attente

'; $page.= print_liste($liste); } elseif($act == "archives") { $liste = $votes->liste("archives"); $page.= '

Votes passés (archivés)

'; $page.= print_liste($liste,1); } elseif($act == "voir") { $rec = $votes->lire($id); $resultats = $votes->resultats($id); if($resultats['votants'] > 0) $resultats['taux_participation'] = floor(($resultats['votants'] / $resultats['nb_membres'])*100); else $resultats['taux_participation'] = 0; $page.= '

'.str2html($rec['titre']).'

Début du vote: '.strtolower(date_fr("l d F Y à H\hi",$rec['date_debut'])). '

Fin du vote: '.strtolower(date_fr("l d F Y à H\hi",$rec['date_fin'])).'

'. str2display($rec['texte'],"bbhtml").'

Participation: '.$resultats['votants'].' votants sur '.$resultats['nb_membres']. ' membres ('.$resultats['taux_participation'].'%)

Résultats:

Modifier ce vote - Voir les votes individuels

'; } elseif($act == "voir_votes") { $page.= '

Retour au vote

'; $votes_liste = $votes->voir_votes($id); if(count($votes_liste) < 1) $page.= '

Pas de votants.

'; else { $page.= '
    '; foreach($votes_liste as $vote) { $page.= '
  1. '.$vote['intitule'].': '; if(count($vote['votants']) < 1) $page.= 'Aucun votant.'; else { $page.= '
      '; foreach($vote['votants'] as $votant) $page.= '
    • '.$votant['pseudo'].' (a voté le '.date("d/m/Y H:i",$votant['date']).')
    • '; $page.= '
    '; } $page.= '
  2. '; } $page.= '
'; } } else { $liste = $votes->liste("valide"); $page.= '

Votes validés en cours et à venir

'; $page.= print_liste($liste,1); } page("Votes",$page); ?>