$this->make_hook('index', AUTH_COOKIE), 'survey/vote' => $this->make_hook('vote', AUTH_COOKIE), /* 'survey/result' => $this->make_hook('result', AUTH_COOKIE), 'survey/edit' => $this->make_hook('edit', AUTH_COOKIE), 'survey/ajax' => $this->make_hook('ajax', AUTH_COOKIE), 'survey/admin' => $this->make_hook('admin', AUTH_MDP, 'admin'), 'survey/admin/edit' => $this->make_hook('adminEdit', AUTH_MDP, 'admin'), 'survey/admin/valid' => $this->make_hook('adminValidate', AUTH_MDP, 'admin'), 'survey/admin/del' => $this->make_hook('adminDelete', AUTH_MDP, 'admin'), */ ); } function handler_index(&$page, $action = null) { $this->load('survey.inc.php'); XDB::execute("DELETE FROM surveys"); $survey = new Survey(); $survey->id = null; $survey->shortname = "blah"; $survey->title = "Blah"; $survey->description = "Blih blih blih blih"; $survey->uid = S::user()->id(); $survey->begin = "09/09/2010"; $survey->end = "30/12/2011"; $qpage = $survey->newQuestion("section"); $qpage->parameters = array('type' => 'page'); $qpage->label = 'Première page'; $question = $qpage->newQuestion("text"); $question->label = "Super question"; $question->flags = "mandatory"; $question->parameters = array("type" => "text", "limit" => 256); $question = $qpage->newQuestion("text"); $question->label = "Super question 2"; $qpage = $survey->newQuestion("section"); $qpage->parameters = array('type' => 'page'); $qpage->label = 'Deuxième page'; $survey->flags = 'validated'; $survey->insert(true); $page->changeTpl('survey/index.tpl'); $page->assign('active', Survey::iterActive()); } function handler_vote(PlPage $page, $name) { $this->load('survey.inc.php'); $page->changeTpl('survey/vote.tpl'); $survey = Survey::get($name); if (is_null($survey)) { return PL_NOT_FOUND; } 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); } } // vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8: ?>