Mise en route du suivi.
[aidenligne_francais_universite.git] / plugins / forms_1_9_1 / balise / forms.php
1 <?php
2
3 if (!defined("_ECRIRE_INC_VERSION")) return; #securite
4
5 // Pas besoin de contexte de compilation
6 global $balise_FORMS_collecte;
7 $balise_FORMS_collecte = array('id_form','id_article');
8
9 function balise_FORMS ($p) {
10 return calculer_balise_dynamique($p,'FORMS', array('id_form', 'id_article', 'class'));
11 }
12
13 function balise_FORMS_stat($args, $filtres) {
14 return $args;
15 }
16
17 function balise_FORMS_dyn($id_form = 0, $id_article = 0, $class='', $script_validation = 'valide_form', $message_confirm='forms:avis_message_confirmation',$reponse_enregistree="forms:reponse_enregistree") {
18 $url = self();
19 // nettoyer l'url qui est passee par htmlentities pour raison de securités
20 $url = str_replace("&amp;","&",$url);
21 if ($retour=='') $retour = $url;
22
23 $res = spip_query("SELECT * FROM spip_forms WHERE id_form=".spip_abstract_quote($id_form));
24 if (!$row = spip_fetch_array($res)) return;
25
26 $erreur = array();
27 $valide_sondage = '';
28 $reponse = '';
29 $formok = '';
30 $valeurs = array('0'=>'0');
31 $affiche_sondage = '';
32 $formactif = (_DIR_RESTREINT==_DIR_RESTREINT_ABS)?' ':'';
33
34 $flag_reponse = (_request('ajout_reponse') == 'oui' && _request('id_form') == $id_form) && _request('nobotnobot')=='';
35 if ($flag_reponse) {
36 include_spip('inc/forms');
37 $url_validation = Forms_enregistrer_reponse_formulaire($id_form, $erreur, $reponse, $script_validation, $id_article?"id_article=$id_article":"");
38 if (!$erreur) {
39 $formok = _T($reponse_enregistree);
40 if ($reponse)
41 $reponse = _T($message_confirm,array('mail'=>$reponse));
42 }
43 else {
44 // on reinjecte get et post dans $valeurs
45 foreach($_GET as $key => $val)
46 $valeurs[$key] = interdire_scripts($val);
47 foreach($_POST as $key => $val)
48 $valeurs[$key] = interdire_scripts($val);
49 }
50 }
51 if ($row['sondage'] == 'public'){
52 include_spip('inc/forms');
53 if ((Forms_verif_cookie_sondage_utilise($id_form)==true)&&(_DIR_RESTREINT!=""))
54 $affiche_sondage=' ';
55 }
56 return array('formulaires/forms', 0,
57 array(
58 'erreur_message'=>isset($erreur['@'])?$erreur['@']:'',
59 'erreur'=>serialize($erreur),
60 'reponse'=>filtrer_entites($reponse),
61 'id_article' => $id_article,
62 'id_form' => $id_form,
63 'self' => $url,
64 'valeurs' => serialize($valeurs),
65 'url_validation' => str_replace("&amp;","&",$url_validation),
66 'affiche_sondage' => $affiche_sondage,
67 'formok' => filtrer_entites($formok),
68 'formactif' => $formactif,
69 'class' => 'formulaires/'.($class?$class:'forms_structure')
70 ));
71 }
72
73 ?>