<?php
/***************************************************************************
- * Copyright (C) 2003-2010 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
function handler_vote(PlPage $page, $name)
{
$this->load('survey.inc.php');
+ $page->addJsLink('jquery.tmpl.js');
$page->changeTpl('survey/vote.tpl');
$survey = Survey::get($name);
if (is_null($survey)) {
if (!$survey->canSee(S::user())) {
return PL_FORBIDDEN;
}
+ if (Post::has('vote')) {
+ $answers = Post::v('qid');
+ $vote = $survey->vote(S::user(), $answers);
+ if (is_null($vote)) {
+ $page->kill("Tu n'as pas le droit de voter à ce sondage.");
+ } else if ($vote->inError()) {
+ $page->trigError("Certaines réponses sont invalides et doivent être corrigées");
+ } else {
+ $vote->insert(true);
+ $page->trigSuccess("Ton vote a été enregistré");
+ }
+ }
$page->assign('survey', $survey);
}
}