From: Florent Bruneau Date: Wed, 16 Feb 2011 21:26:28 +0000 (+0100) Subject: Merge remote branch 'origin/xorg/maint' into xorg/master X-Git-Tag: xorg/1.1.0~151 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=82af3fc3b6e003b0cbbcf4faf4ed4f0ea5c07570;p=platal.git Merge remote branch 'origin/xorg/maint' into xorg/master Conflicts: core modules/admin.php modules/carnet.php modules/events.php modules/payment.php modules/survey.php modules/xnetgrp.php plugins/function.poison.php Signed-off-by: Florent Bruneau --- 82af3fc3b6e003b0cbbcf4faf4ed4f0ea5c07570 diff --cc classes/address.php index 6634f47,a834a1d..289cfb1 --- a/classes/address.php +++ b/classes/address.php @@@ -364,9 -364,9 +364,9 @@@ class Addres return $this->phones; } - public function addPhone(Phone &$phone) + public function addPhone(Phone $phone) { - if ($phone->linkType() == Phone::LINK_ADDRESS && $phone->pid() == $this->pid) { + if ($phone->link_type == Phone::LINK_ADDRESS && $phone->pid == $this->pid) { $this->phones[$phone->uniqueId()] = $phone; } } diff --cc core index 9007d49,ed4f7de..96dd0b0 --- a/core +++ b/core @@@ -1,1 -1,1 +1,1 @@@ - Subproject commit 9007d4955f2487e82c0f9f4059e1f6b450bdb528 -Subproject commit ed4f7de016bb136fae9f72256c827ef09d4ea863 ++Subproject commit 96dd0b0fbaaedf7d274cc919268fd717275d605f diff --cc include/profilefields.inc.php index f34e3b8,08e831d..6192575 --- a/include/profilefields.inc.php +++ b/include/profilefields.inc.php @@@ -148,9 -148,9 +148,9 @@@ class Compan } } - public function setPhone(Phone &$phone) + public function setPhone(Phone $phone) { - if ($phone->linkType() == Phone::LINK_COMPANY && $phone->linkId() == $this->id) { + if ($phone->link_type == Phone::LINK_COMPANY && $phone->link_id == $this->id) { $this->phone = $phone; } } @@@ -221,9 -221,9 +221,9 @@@ class Jo return $this->address; } - public function addPhone(Phone &$phone) + public function addPhone(Phone $phone) { - if ($phone->linkType() == Phone::LINK_JOB && $phone->linkId() == $this->id && $phone->pid() == $this->pid) { + if ($phone->link_type == Phone::LINK_JOB && $phone->link_id == $this->id && $phone->pid == $this->pid) { $this->phones[$phone->uniqueId()] = $phone; } } diff --cc modules/bandeau.php index f5008c0,77b4fcb..50fb51c --- a/modules/bandeau.php +++ b/modules/bandeau.php @@@ -43,10 -43,9 +43,10 @@@ class BandeauModule extends PLModul $page->changeTpl('skin/common.bandeau.tpl', NO_SKIN); $page->assign('login', $login == 'login'); $page->assign('seed', $login); + $page->assign('external', true); } - function handler_css(&$page) + function handler_css($page) { pl_cached_content_headers("text/css"); readfile('../htdocs/css/bandeau.css'); diff --cc modules/carnet.php index 82d0609,944b8a8..4f80b49 --- a/modules/carnet.php +++ b/modules/carnet.php @@@ -358,7 -358,7 +358,7 @@@ class CarnetModule extends PLModul exit; } - function handler_rss(PlPage& $page, PlUser& $user) - function handler_rss($page, $user = null, $hash = null) ++ function handler_rss(PlPage $page, PlUser $user) { $this->load('feed.inc.php'); $feed = new CarnetFeed(); @@@ -378,8 -378,17 +378,8 @@@ ); } - function handler_csv_birthday(PlPage& $page, PlUser& $user) - function handler_csv_birthday($page, $alias = null, $hash = null) ++ function handler_csv_birthday(PlPage $page, PlUser $user) { - $user = Platal::session()->tokenAuth($alias, $hash); - if (is_null($user)) { - if (S::logged()) { - $user = S::user(); - } else { - return PL_FORBIDDEN; - } - } - $page->changeTpl('carnet/calendar.outlook.tpl', NO_SKIN); $filter = new UserFilter(new UFC_Contact($user)); $profiles = $filter->iterProfiles(); @@@ -402,8 -411,17 +402,8 @@@ pl_content_headers("text/comma-separated-values;charset=".$encoding); } - function handler_ical(PlPage& $page, PlUser& $user) - function handler_ical($page, $alias = null, $hash = null) ++ function handler_ical(PlPage $page, PlUser $user) { - $user = Platal::session()->tokenAuth($alias, $hash); - if (is_null($user)) { - if (S::logged()) { - $user = S::user(); - } else { - return PL_FORBIDDEN; - } - } - require_once 'ical.inc.php'; $page->changeTpl('carnet/calendar.tpl', NO_SKIN); $page->register_function('display_ical', 'display_ical'); @@@ -423,8 -441,17 +423,8 @@@ $vcard->show(); } - function handler_csv(PlPage& $page, PlUser& $user) - function handler_csv($page, $alias = null, $hash = null) ++ function handler_csv(PlPage $page, PlUser $user) { - $user = Platal::session()->tokenAuth($alias, $hash); - if (is_null($user)) { - if (S::logged()) { - $user = S::user(); - } else { - return PL_FORBIDDEN; - } - } - $page->changeTpl('carnet/mescontacts.outlook.tpl', NO_SKIN); $pf = new ProfileFilter(new UFC_Contact($user)); require_once 'carnet/outlook.inc.php'; diff --cc modules/events.php index b9cca56,989377d..4064783 --- a/modules/events.php +++ b/modules/events.php @@@ -228,14 -228,14 +228,14 @@@ class EventsModule extends PLModul exit; } - function handler_rss(PlPage& $page, PlPage& $user) - function handler_rss($page, $user = null, $hash = null) ++ function handler_rss(PlPage $page, PlPage $user) { $this->load('feed.inc.php'); $feed = new EventFeed(); - return $feed->run($page, $user, $hash); + return $feed->run($page, $user); } - function handler_preview(&$page) + function handler_preview($page) { $page->changeTpl('events/preview.tpl', NO_SKIN); $texte = Get::v('texte'); diff --cc modules/payment.php index 6f8896d,ef19de2..52dd453 --- a/modules/payment.php +++ b/modules/payment.php @@@ -611,8 -580,8 +611,8 @@@ class PaymentModule extends PLModul $table_editor->apply($page, $action, $id); } - + - function handler_adm_transactions(&$page, $payment_id = null, $action = "list", $id = null) { + function handler_adm_transactions($page, $payment_id = null, $action = "list", $id = null) { // show transactions. FIXME: should not be modifiable $page->setTitle('Administration - Paiements - Transactions'); $page->assign('title', "Liste des transactions pour le paiement {$payment_id}"); @@@ -623,35 -592,35 +623,35 @@@ $table_editor = new PLTableEditor("admin/transactions/{$payment_id}",'payment_transactions','id'); $table_editor->set_where_clause(XDB::format('ref = {?}', $payment_id)); $table_editor->apply($page, 'list', $id); // only the 'list' action is allowed - $page->assign("readonly","readonly"); // don't show modification features + $page->assign('readonly', 'readonly'); // don't show modification features } - + - function handler_adm_bankaccounts(&$page, $action = 'list', $id = null) { + function handler_adm_bankaccounts($page, $action = "list", $id = null) { // managment of bank account used for money transfert $page->setTitle('Administration - Paiements - RIBs'); $page->assign('title', "Liste des RIBs"); - - $table_editor = new PLTableEditor("admin/payments/bankaccounts",'payment_bankaccounts','id'); - $table_editor->describe('asso_id','ID du groupe',false); - $table_editor->describe('owner','titulaire',true); - $table_editor->add_option_table('groups','groups.id = t.asso_id'); + + $table_editor = new PLTableEditor('admin/payments/bankaccounts', 'payment_bankaccounts', 'id'); + $table_editor->describe('asso_id', 'ID du groupe', false); + $table_editor->describe('owner', 'titulaire', true); + $table_editor->add_option_table('groups', 'groups.id = t.asso_id'); $table_editor->add_option_field('groups.diminutif', 'group_name', 'groupe', 'varchar','account'); - + // check RIB key - if ($action == "update" && Post::has("account") && !check_rib(Post::v("account"))) { + if ($action == 'update' && Post::has('account') && !check_rib(Post::v('account'))) { $page->trigError("Le RIB n'est pas valide"); - $table_editor->apply($page, "edit", $id); + $table_editor->apply($page, 'edit', $id); return; } - + $table_editor->apply($page, $action, $id); } - + - function handler_adm_methods(&$page, $action = 'list', $id = null) { + function handler_adm_methods($page, $action = "list", $id = null) { // show and edit payment methods $page->setTitle('Administration - Paiements - Méthodes'); - $page->assign('title', "Méthodes de paiement"); - $table_editor = new PLTableEditor("admin/payments/methods",'payment_methods','id'); + $page->assign('title', 'Méthodes de paiement'); + $table_editor = new PLTableEditor('admin/payments/methods', 'payment_methods', 'id'); $table_editor->apply($page, $action, $id); } @@@ -721,8 -690,8 +721,8 @@@ $page->assign_by_ref('recongps', $recongps); } } - + - function handler_adm_importlogs(&$page, $step, $param = null) { + function handler_adm_importlogs($page, $step, $param = null) { $page->setTitle('Administration - Paiements - Réconciliations'); $page->changeTpl('payment/reconcile.tpl'); $page->assign('step', $step); @@@ -893,13 -861,13 +893,13 @@@ $page->assign('onlydb_count', count($only_database)); } } - + - function handler_adm_transfers(&$page, $action = null, $id = null) { + function handler_adm_transfers($page, $action = null, $id = null) { // list/log all bank transfers and link them to individual transactions - + if (Post::has('generate')) { $recon_ids = array_keys(Post::v('recon_id')); - + // generate a new reconcilation group ID $res = XDB::query("SELECT MAX(recongroup_id)+1 FROM payment_reconcilations"); $recongp_id = $res->fetchOneCell(); diff --cc modules/profile.php index 0ac4d0b,3ba8612..c680c25 --- a/modules/profile.php +++ b/modules/profile.php @@@ -522,9 -524,11 +522,9 @@@ class ProfileModule extends PLModul LEFT JOIN geoloc_countries AS gc ON (m.country = gc.iso_3166_1_a2) WHERE pid = {?}", $pf->id()); $page->assign('pays', $res->fetchColumn()); - - $page->addJsLink('close_on_esc.js'); } - function handler_ref_country(&$page) + function handler_ref_country($page) { pl_content_headers("text/html"); $page->changeTpl('include/field.select.tpl', NO_SKIN); diff --cc modules/profile/skills.inc.php index 2ad367e,8a495cc..3145811 --- a/modules/profile/skills.inc.php +++ b/modules/profile/skills.inc.php @@@ -108,14 -106,14 +108,14 @@@ class ProfilePageSkills extends Profile { protected $pg_template = 'profile/skill.tpl'; - public function __construct(PlWizard &$wiz) + public function __construct(PlWizard $wiz) { parent::__construct($wiz); - $this->settings['competences'] = new ProfileSettingSkill('skill', 'cid', 'text_fr'); - $this->settings['langues'] = new ProfileSettingSkill('langskill', 'lid', 'langue_fr'); + $this->settings['competences'] = new ProfileSettingSkill('skill', 'id', 'cid', 'text_fr'); + $this->settings['langues'] = new ProfileSettingSkill('langskill', 'iso_639_2b', 'lid', 'language'); } - public function _prepare(PlPage &$page, $id) + public function _prepare(PlPage $page, $id) { $page->assign('comp_list', XDB::iterator("SELECT id, text_fr, FIND_IN_SET('titre',flags) AS title FROM profile_skill_enum")); diff --cc modules/survey.php index 66b65c4,8ea5817..6c76e54 --- a/modules/survey.php +++ b/modules/survey.php @@@ -34,95 -34,470 +34,95 @@@ class SurveyModule extends PLModul '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() : lists all available surveys - function handler_index($page, $action = null) + private function setup_page(PlPage $page) { $this->load('survey.inc.php'); - $page->changeTpl('survey/index.tpl'); - $page->assign('survey_current', Survey::retrieveList('c')); - $page->assign('survey_old', Survey::retrieveList('o')); - $page->assign('survey_modes', Survey::getModes(false)); - } - // }}} - - // {{{ function handler_vote() : handles the vote to a survey - function handler_vote($page, $id = -1) - { - if (Post::has('survey_cancel')) { // if the user cancels, returns to index - return $this->handler_index($page); - } - $id = intval($id); - if ($id == -1) { - return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey'); - } - $this->load('survey.inc.php'); - $survey = Survey::retrieveSurvey($id); // retrieves the survey object structure - if ($survey == null || !$survey->isValid()) { - return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey'); - } elseif ($survey->isEnded()) { - return $this->show_error($page, "Le sondage ".$survey->getTitle()." est terminé.", 'survey'); - } - if (!$this->check_surveyPerms($page, $survey)) { - return PL_DO_AUTH; - } - if (Post::has('survey_submit')) { // checks if the survey has already been filled in - // admins can see the survey but not vote - if (!$this->check_surveyPerms($page, $survey, false, false)) { - return PL_DO_AUTH; - } - $uid = 0; - if (!$survey->isMode(Survey::MODE_ALL)) { // if survey is restriced to alumni - $uid = S::v('uid'); - if ($survey->hasVoted($uid)) { // checks whether the user has already voted - return $this->show_error($page, "Tu as déjà voté à ce sondage.", 'survey'); - } - } - $survey->vote($uid, Post::v('survey'.$id)); // performs vote - $this->show_success($page, "Ta réponse a bien été prise en compte. Merci d'avoir participé à ce sondage.", 'survey'); - } else { // offers to fill in the survey - if ($survey->isMode(Survey::MODE_ALL) || !$survey->hasVoted(S::v('uid'))) { - $page->assign('survey_votemode', true); - } else { - $page->assign('survey_warning', "Tu as déjà voté à ce sondage."); - } - //$page->assign('survey_id', $id); - $this->show_survey($page, $survey); - } + $page->addJsLink('jquery.ui.xorg.js'); + $page->addJsLink('survey.js'); } - // }}} - function handler_index(&$page, $action = null) - // {{{ function handler_result() : show the results of the votes to a survey - function handler_result($page, $id = -1, $show = 'all') ++ function handler_index($page, $action = null) { - $id = intval($id); - if ($id == -1) { - return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey'); - } - $this->load('survey.inc.php'); - $survey = Survey::retrieveSurvey($id); // retrieves the survey object structure - if ($survey == null || !$survey->isValid()) { - return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey'); - } elseif (!$survey->isEnded() && !$survey->canSeeEarlyResults(S::user())) { - return $this->show_error($page, "Le sondage ".$survey->getTitle()." n'est pas encore terminé.", 'survey'); - } - if (!$survey->canSeeEarlyResults(S::user()) && !$this->check_surveyPerms($page, $survey)) { - return PL_DO_AUTH; - } - if ($show == 'csv') { - pl_content_headers("text/csv"); - header('Content-Disposition: attachment; filename="'.addslashes($survey->getTitle()).'.csv"'); - echo $survey->toCSV(); - exit; - } else { - $page->assign('survey_resultmode', true); - $this->show_survey($page, $survey); - } - } - // }}} + $this->setup_page($page); - // {{{ function handler_admin() : index of admin mode - function handler_admin($page, $id = -1) - { - $this->load('survey.inc.php'); - $this->clear_session(); - if ($id == -1) { - $page->changeTpl('survey/admin.tpl'); - $page->assign('survey_waiting', Survey::retrieveList('w')); - $page->assign('survey_current', Survey::retrieveList('c')); - $page->assign('survey_old', Survey::retrieveList('o')); - $page->assign('survey_modes', Survey::getModes(false)); - } else { - $id = intval($id); - $survey = Survey::retrieveSurvey($id); // retrieves all survey object structure - if ($survey == null) { - $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin'); - } - $page->assign('survey_adminmode', true); - $this->show_survey($page, $survey); - } + $page->changeTpl('survey/index.tpl'); + $page->assign('active', Survey::iterActive()); } - // }}} - // {{{ function handler_adminEdit() : edits a survey in admin mode - function handler_adminEdit($page, $id = -1, $req = -1) + function handler_vote(PlPage $page, $name) { - if ($id == -1 || ($id == 'req' && $req == -1)) { - return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin'); - } - $this->load('survey.inc.php'); - $this->clear_session(); // cleans session (in case there would have been a problem before) - if ($id == 'req') { - $survey = Survey::retrieveSurveyReq($req); - if ($survey == null) { - return $this->show_error($page, "Sondage introuvable.", 'survey/admin'); - } - $this->store_session($survey, $req, true); - } else { - $id = intval($id); - $survey = Survey::retrieveSurvey($id); // retrieves the survey in database - if ($survey == null) { - return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin'); - } - $this->store_session($survey, $id); - } - $this->handler_edit($page, 'show'); // calls handler_edit, but in admin mode since 'survey_id' is in session - } - // }}} + $this->setup_page($page); + $page->changeTpl('survey/vote.tpl'); - // {{{ function handler_adminValidate() : validates a survey (admin mode) - function handler_adminValidate($page, $id = -1) - { - $id = Post::i('survey_id', $id); - if (Post::has('survey_cancel')) { // if the admin cancels the validation, returns to the admin index - $this->clear_session(); - return $this->handler_admin($page, $id); + XDB::execute('delete from survey_votes'); + XDB::execute('delete from survey_voters'); + $survey = Survey::get($name); + if (is_null($survey)) { + return PL_NOT_FOUND; } - if ($id == -1) { - return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin'); + if (!$survey->canSee(S::user())) { + return PL_FORBIDDEN; } - $id = intval($id); - $this->load('survey.inc.php'); - $surveyInfo = Survey::retrieveSurveyInfo($id); // retrieves information about the survey (does not retrieve and unserialize the object structure) - if ($surveyInfo == null) { - return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin'); - } - if (Post::has('survey_submit')) { // needs a confirmation before validation - if (Survey::validateSurvey($id)) { // validates the survey (in the database) - $this->show_success($page, "Le sondage \"".$surveyInfo['title']."\" a bien été validé, les votes sont maintenant ouverts.", 'survey/admin'); + 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 { - $this->show_error($page, '', 'survey/admin'); + $vote->insert(true); + $page->trigSuccess("Ton vote a été enregistré"); } - } else { // asks for a confirmation - $this->show_confirm($page, "Êtes-vous certain de vouloir valider le sondage \"".$surveyInfo['title']."\" ? " - ."Les votes seront immédiatement ouverts.", 'admin/valid', array('id' => $id)); } + $page->assign('survey', $survey); } - // }}} - // {{{ function handler_adminDelete() : deletes a survey (admin mode) - function handler_adminDelete($page, $id = -1) + function handler_edit(PlPage $page, $name = null) { - $id = Post::i('survey_id', $id); - if (Post::has('survey_cancel')) { // if the admin cancels the suppression, returns to the admin index - return $this->handler_admin($page, $id); - } - if ($id == -1) { - return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin'); - } - $id = intval($id); - $this->load('survey.inc.php'); - $surveyInfo = Survey::retrieveSurveyInfo($id); // retrieves information about the survey (does not retrieve and unserialize the object structure) - if ($surveyInfo == null) { - return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin'); - } - if (Post::has('survey_submit')) { // needs a confirmation before suppression - if (Survey::deleteSurvey($id)) { // deletes survey in database - $this->show_success($page, "Le sondage \"".$surveyInfo['title']."\" a bien été supprimé, ainsi que tous les votes le concernant.", 'survey/admin'); - } else { - $this->show_error($page, '', 'survey/admin'); - } - } else { // asks for a confirmation - $this->show_confirm($page, "Êtes-vous certain de vouloir supprimer le sondage \"".$surveyInfo['title']."\" ?", 'admin/del', array('id' => $id)); - } - } - // }}} + $this->setup_page($page); + $page->changeTpl('survey/edit.tpl'); - // {{{ function handler_edit() : edits a survey (in normal mode unless called by handler_adminEdit() ) - function handler_edit($page, $action = 'show', $qid = 'root') - { - $this->load('survey.inc.php'); - $action = Post::v('survey_action', $action); - $qid = Post::v('survey_qid', $qid); - if (Post::has('survey_cancel')) { // after cancelling changes, shows the survey - if (S::has('survey')) { - $action = 'show'; - } else { // unless no editing has been done at all (shows to the surveys index page) - return $this->handler_index($page); - } - } - $page->assign('survey_editmode', true); - if (S::has('survey_id')) { // if 'survey_id' is in session, it means we are modifying a survey in admin mode - $page->assign('survey_updatemode', true); - } - if ($action == 'show' && !S::has('survey')) { - $action = 'new'; - } - if ($action == 'question') { // {{{ modifies an existing question - if (Post::has('survey_submit')) { // if the form has been submitted, makes the modifications - $survey = unserialize(S::v('survey')); - $args = Post::v('survey_question'); - if (!$survey->editQuestion($qid, $args)) { // update the survey object structure - return $this->show_error($page, '', 'survey/edit'); - } - $this->show_survey($page, $survey); - $this->store_session($survey); - } else { // if a form has not been submitted, shows modification form - $survey = unserialize(S::v('survey')); - $current = $survey->toArray($qid); // gets the current parameters of the question - if ($current == null) { - return $this->show_error($page, '', 'survey/edit'); - } - $this->show_form($page, $action, $qid, $current['type'], $current); - } // }}} - } elseif ($action == 'new') { // {{{ create a new survey : actually store the root question - if (Post::has('survey_submit')) { // if the form has been submitted, creates the survey - $this->clear_session(); - $survey = new Survey(Post::v('survey_question')); // creates the object structure - $this->show_survey($page, $survey); - $this->store_session($survey); - } else { - $this->clear_session(); - $this->show_form($page, $action, 'root', 'newsurvey'); - } // }}} - } elseif ($action == 'add') { // {{{ adds a new question - if (Post::has('survey_submit')) { // if the form has been submitted, adds the question - $survey = unserialize(S::v('survey')); - if (!$survey->addQuestion($qid, $survey->factory(Post::v('survey_type'), Post::v('survey_question')))) { - return $this->show_error($page, '', 'survey/edit'); - } - $this->show_survey($page, $survey); - $this->store_session($survey); - } else { - $this->show_form($page, $action, $qid); - } // }}} - } elseif ($action == 'del') { // {{{ deletes a question - if (Post::has('survey_submit')) { // if a confirmation has been sent, deletes the question - $survey = unserialize(S::v('survey')); - if (!$survey->delQuestion(Post::v('survey_qid'))) { // deletes the node in the survey object structure - return $this->show_error($page, '', 'survey/edit'); - } - $this->show_survey($page, $survey); - $this->store_session($survey); - } else { // if user has not confirmed, shows a confirmation form - $survey = unserialize(S::v('survey')); - $current = $survey->toArray($qid); // needed to get the title of the question to delete (more user-friendly than an id) - if ($current == null) { - return $this->show_error($page, '', 'survey/edit'); - } - $this->show_confirm($page, 'Êtes-vous certain de vouloir supprimer la question intitulé "'.$current['question'].'" ? ' - .'Attention, cela supprimera en même temps toutes les questions qui dépendent de celle-ci.', - 'edit', array('action' => 'del', 'qid' => $qid)); - } // }}} - } elseif ($action == 'show') { // {{{ simply shows the survey in its current state - $this->show_survey($page, unserialize(S::v('survey'))); // }}} - } elseif ($action == 'valid') { // {{{ validates the proposition, i.e stores the proposition in the database - // but an admin will still need to validate the survey before it is activated - if (Post::has('survey_submit')) { // needs a confirmation before storing the proposition - $survey = unserialize(S::v('survey')); - if (S::has('survey_id')) { // if 'survey_id' is in session, we are modifying an existing survey (in admin mode) instead of proposing a new one - $link = (S::has('survey_validate'))? 'admin/validate' : 'survey/admin'; - if ($survey->updateSurvey()) { // updates the database according the new survey object structure - $this->show_success($page, "Les modifications sur le sondage ont bien été enregistrées.", $link); - } else { - $this->show_error($page, '', $link); - } - } else { // if no 'survey_id' is in session, we are indeed proposing a new survey - if ($survey->proposeSurvey()) { // stores the survey object structure in database - $this->show_success($page, "Votre proposition de sondage a bien été enregistrée, - elle est en attente de validation par un administrateur du site.", 'survey'); - } else { - $this->show_error($page, '', 'survey'); - } - } - $this->clear_session(); - } else { // asks for a confirmation if it has not been sent - $survey = unserialize(S::v('survey')); - $errors = $survey->checkSyntax(); - if (!is_null($errors)) { - $this->show_error($page, "", 'survey/edit', $errors); - } else { - if (S::has('survey_id')) { - $this->show_confirm($page, "Veuillez confirmer l'enregistrement des modifications apportées à ce sondage.", 'edit', array('action' => 'valid')); - } else { - $this->show_confirm($page, "Veuillez confirmer l'envoi de cette proposition de sondage.", 'edit', array('action' => 'valid')); - } - } - } // }}} - } elseif ($action == 'cancel') { // {{{ cancels the creation/modification of a survey - if (Post::has('survey_submit')) { // needs a confirmation - if (S::has('survey_id')) { // only possible when modifying a survey in admin mode - if (S::has('survey_validate')) { // if a link has been supplied, uses it - $this->clear_session(); - return $this->show_success($page, "Les modifications effectuées ont été annulées", 'admin/validate'); - } else { // else shows the admin index - $this->clear_session(); - return $this->handler_admin($page); - } + if (!is_null($name)) { + $survey = Survey::get($name); + } else { + $survey = new Survey(); + $survey->id = null; + $survey->uid = S::user()->id(); + } + if (Post::has('valid')) { + $survey->title = Post::t('title'); + $survey->shortname = Post::t('shortname'); + $survey->description = Post::t('description'); + $survey->begin = Post::t('begin'); + $survey->end = Post::t('end'); + $survey->flags = 'validated'; + $survey->flags->addFlag('anonymous', Post::b('anonymous')); + + $q_edit = Post::v('q_edit'); + $qs = array(); + $survey->clearQuestions(); + foreach ($q_edit as $qid => $q_desc) { + if (isset($q_desc['parent'])) { + $parent = $qs[$q_desc['parent']]; } else { - $this->clear_session(); - return $this->handler_index($page); // else shows the 'normal' index + $parent = $survey; } - } else { // asks for a confirmation if it has not been sent - $this->show_confirm($page, "Êtes-vous certain de vouloir annuler totalement l'édition de ce sondage ? Attention, " - ."toutes les données éditées jusque là seront définitivement perdues.", - 'edit', array('action' => $action)); - } - } // }}} - } - // }}} - - // {{{ function handler_ajax() : some ajax in editing a new question (for now, there may be a little more later) - function handler_ajax($page, $type) - { - $this->load('survey.inc.php'); - pl_content_headers("text/html"); - if (Survey::isType($type)) { // when type has been chosen, the form is updated to fit exactly the type of question chosen - $page->changeTpl('survey/edit_new.tpl', NO_SKIN); - $page->assign('survey_types', Survey::getTypes()); - $page->assign('survey_type', $type); - } - } - // }}} - - // {{{ function clear_session() : clears the data stored in session - function clear_session() - { - S::kill('survey'); - S::kill('survey_id'); - S::kill('survey_validate'); - } - // }}} - - // {{{ function store_session() : serializes and stores survey (and survey_id) in session - function store_session($survey, $survey_id = -1, $survey_validate = false) - { - $_SESSION['survey'] = serialize($survey); - if ($survey_id != -1) { - $_SESSION['survey_id'] = $survey_id; - } - if ($survey_validate) { - $_SESSION['survey_validate'] = true; - } - } - // }}} - - // {{{ function check_surveyPerms() : checks the particular surveys access permissions - function check_surveyPerms($page, $survey, $silent = false, $admin_allowed = true) - { - $this->load('survey.inc.php'); - if ($survey->isMode(Survey::MODE_ALL)) { // if the survey is not reserved to alumni - return true; - } - if (!S::logged()) { - return false; - } - $profile = S::user()->profile(); - if (!$profile) { - return false; - } - // checks promotion - $allowed = false; - foreach ($profile->yearspromo() as $p) { - if ($survey->checkPromo($p)) { - $allowed = true; - break; - } - } - if ($allowed) { - return true; - } - if (S::admin() && $admin_allowed) { - if (!$silent) { - $page->trigWarning('Tu as accès à ce sondage car tu es administrateur du site.'); + $question = $parent->newQuestion($q_desc['type']); + $question->label = $q_desc['label']; + unset($q_desc['type']); + unset($q_desc['parent']); + unset($q_desc['label']); + $question->parameters = $q_desc; + $qs[$qid] = $question; } - return true; + $survey->insert('true'); } - if (!$silent) { - $page->kill("Tu n'as pas accès à ce sondage car il est réservé à d'autres promotions."); - } - return false; - } - // }}} - - // {{{ function show_survey() : calls the template to display a survey, for editing, voting, or consulting the results - function show_survey($page, $survey) - { - $page->changeTpl('survey/show_root.tpl'); - $page->assign('survey', $survey->toArray()); - $page->assign('survey_modes', Survey::getModes()); - } - // }}} - - // {{{ function show_form() : calls the template to display the editing form - function show_form($page, $action, $qid, $type = 'new', $current = null) - { - $page->changeTpl('survey/edit_survey.tpl'); - $page->assign('survey_action', $action); - $page->assign('survey_qid', $qid); - $page->assign('survey_formaction', './survey/edit'); - $page->assign('survey_type', $type); - if (!is_null($current) && is_array($current)) { - $page->assign('survey_current', $current); - } elseif ($type == 'new') { - $page->addJsLink('ajax.js'); - $page->assign('survey_types', Survey::getTypes()); - } - if ($type == 'root' || $type == 'newsurvey') { - $page->assign('survey_modes', Survey::getModes()); - } - } - // }}} - - // {{{ function show_confirm() : calls the template to display a confirm form - function show_confirm($page, $message, $formaction, $formhidden = null) - { - $page->changeTpl('survey/confirm.tpl'); - $page->assign('survey_message', $message); - $page->assign('survey_formaction', './survey/'.$formaction); - $page->assign('survey_formhidden', $formhidden); - } - // }}} - - // {{{ function show_error() : calls the template to display an error message - function show_error($page, $message, $link = "", $errArray = null) - { - $page->changeTpl('survey/error.tpl'); - $page->assign('survey_message', $message); - $page->assign('survey_link', $link); // 'return' link to let the user leave the page - if (!is_null($errArray)) { - $page->assign('survey_errors', $errArray); - } - - } - // }}} - - // {{{ function show_success() : calls the template to display a success message - function show_success($page, $message = "", $link = "") - { - $page->changeTpl('survey/success.tpl'); - $page->assign('survey_message', $message); - $page->assign('survey_link', $link); // 'return' link to let the user leave the page + $page->assign('survey', $survey); } - // }}} } // vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8: diff --cc modules/xnetgrp.php index d64b076,711ece0..55d98e1 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@@ -1005,20 -989,19 +1005,20 @@@ class XnetGrpModule extends PLModul $page->assign('user', $user); $page->assign('listes', $mmlist->get_lists($user->forlifeEmail())); $page->assign('alias', $user->emailAliases($globals->asso('mail_domain'), 'user', true)); + $page->assign('positions', explode(',', $positions)); } - function handler_rss(PlPage& $page, PlUser& $user) - function handler_rss($page, $user = null, $hash = null) ++ function handler_rss(PlPage $page, PlUser $user) { global $globals; $page->assign('asso', $globals->asso()); $this->load('feed.inc.php'); $feed = new XnetGrpEventFeed(); - return $feed->run($page, $user, $hash, false); + return $feed->run($page, $user, false); } - private function upload_image(PlPage &$page, PlUpload &$upload) + private function upload_image(PlPage $page, PlUpload $upload) { if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) { return true; diff --cc plugins/function.poison.php index 2a4beaa,7d45dc8..8443820 --- a/plugins/function.poison.php +++ b/plugins/function.poison.php @@@ -19,10 -19,7 +19,10 @@@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ - function smarty_function_poison($params, &$smarty) { + function smarty_function_poison($params, $smarty) { + if (S::logged()) { + return ''; + } $count = isset($params['count']) ? $params['count'] : 20; $seed = isset($params['seed']) ? $params['seed'] : date('r'); Platal::load('poison', 'poison.inc.php');