[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_www.git] / www / plugins-dist / forum / balise / formulaire_forum_prive.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2016 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined("_ECRIRE_INC_VERSION")) return; #securite
14
15 include_spip('inc/acces');
16 include_spip('inc/texte');
17 include_spip('inc/forum');
18
19 /*******************************/
20 /* GESTION DU FORMULAIRE FORUM */
21 /*******************************/
22
23 /**
24 * Contexte du formulaire
25 * Mots-cles dans les forums :
26 * Si la variable de personnalisation $afficher_groupe[] est definie
27 * dans le fichier d'appel, et si la table de reference est OK, proposer
28 * la liste des mots-cles
29 * #FORMULAIRE_FORUM_PRIVE seul calcule (objet, id_objet) depuis la boucle parente
30 * #FORMULAIRE_FORUM_PRIVE{#SELF} pour forcer l'url de retour
31 * #FORMULAIRE_FORUM_PRIVE{#SELF, article, 3} pour forcer l'objet et son identifiant
32 * http://code.spip.net/@balise_FORMULAIRE_FORUM_PRIVE
33 *
34 * @param Object $p
35 * @return Object
36 */
37 function balise_FORMULAIRE_FORUM_PRIVE ($p) {
38
39 /**
40 * On recupere $objet et $id_objet depuis une boucle englobante si possible
41 * Sinon, on essaie aussi de recuperer des id_xx dans l'URL qui pourraient indiquer
42 * sur quoi le formulaire porte.
43 * Enfin, on pourra aussi forcer objet et id_objet depuis l'appel du formulaire
44 */
45 $i_boucle = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
46 if (isset($p->boucles[$i_boucle])) {
47 $_id_objet = $p->boucles[$i_boucle]->primary;
48 $_type = $p->boucles[$i_boucle]->id_table;
49 } else {
50 $_id_objet = $_type = '';
51 }
52
53 /**
54 * On essaye de trouver les forums en fonction de l'environnement
55 * pour cela, on recupere l'ensemble des id_xxx possibles dans l'env
56 */
57 $ids = forum_get_objets_depuis_env();
58 $ids = array_values($ids);
59
60 $obtenir = array(
61 $_id_objet,
62 'id_forum',
63 'afficher_texte',
64 'statut',
65 );
66
67
68 if ($ids) {
69 $obtenir = array_merge($obtenir, $ids);
70 }
71
72 $p = calculer_balise_dynamique($p,'FORMULAIRE_FORUM_PRIVE', $obtenir,
73 array("'$_type'", count($ids))
74 );
75
76 return $p;
77 }
78
79 /**
80 * Chercher l'objet/id_objet et la configuration du forum
81 *
82 * http://code.spip.net/@balise_FORMULAIRE_FORUM_PRIVE_stat
83 *
84 * @param array $args
85 * @param array $context_compil
86 * @return array|bool
87 */
88 function balise_FORMULAIRE_FORUM_PRIVE_stat($args, $context_compil) {
89 // un arg peut contenir l'url sur lequel faire le retour
90 // exemple dans un squelette article.html : [(#FORMULAIRE_FORUM_PRIVE{#SELF})]
91 // recuperer les donnees du forum auquel on repond.
92 // deux autres a la suite pour forcer objet et id_objet
93 // [(#FORMULAIRE_FORUM_PRIVE{#SELF, article, 8})]
94 //
95
96 // $args = (obtenir) + (ids) + (url, objet, id_objet)
97 $ido = array_shift($args);
98 $id_forum = intval(array_shift($args));
99 $afficher_texte = array_shift($args);
100 $statut = array_shift($args);
101
102 include_spip('balise/formulaire_forum');
103 // si statut privrac ou privadm, pas besoin d'objet !
104 $r = balise_forum_retrouve_objet($ido,$id_forum,$args,$context_compil,!in_array($statut,array('privrac','privadm')));
105 if (!$r)
106 return false;
107
108 list($objet, $id_objet, $retour) = $r;
109
110 return
111 array($objet, $id_objet, $id_forum, $afficher_texte, $statut, $retour);
112 }
113
114 ?>