1107 |
florian |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | Lesser General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
|
|
19 |
// | License along with this library; if not, write to the Free Software |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
22 |
// CVS : $Id$
|
|
|
23 |
/**
|
|
|
24 |
*
|
|
|
25 |
*@package bottin
|
|
|
26 |
//Auteur original :
|
|
|
27 |
*@author Florian Schmitt <florian@ecole-et-nature.org>
|
1421 |
alexandre_ |
28 |
*@author Alexandre Granier <alexandre@tela-botanica.org>
|
1107 |
florian |
29 |
//Autres auteurs :
|
1421 |
alexandre_ |
30 |
*@copyright Tela-Botanica 2000-2007
|
1107 |
florian |
31 |
*@version $Revision$ $Date$
|
|
|
32 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
33 |
*/
|
|
|
34 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
35 |
// | ENTETE du PROGRAMME |
|
|
|
36 |
// +------------------------------------------------------------------------------------------------------+
|
1467 |
alexandre_ |
37 |
include_once 'configuration/bottin.config.inc.php';
|
|
|
38 |
include_once INS_CHEMIN_APPLI.'langues/bottin.admin.langue_fr.php';
|
1107 |
florian |
39 |
|
|
|
40 |
|
|
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
42 |
// | CLASSE |
|
|
|
43 |
// +------------------------------------------------------------------------------------------------------+
|
1400 |
alexandre_ |
44 |
|
|
|
45 |
|
1107 |
florian |
46 |
class Inscription_Admin {
|
|
|
47 |
var $objet_pear_auth;
|
|
|
48 |
var $objet_pear_db;
|
|
|
49 |
var $objet_pear_url;
|
|
|
50 |
var $sortie_xhtml;
|
|
|
51 |
|
|
|
52 |
/** Fonction redigerContenu() - Affiche le formulaire de r?action
|
|
|
53 |
*
|
|
|
54 |
*
|
|
|
55 |
* @return string Le HTML
|
|
|
56 |
*/
|
|
|
57 |
function afficherContenuCorps()
|
|
|
58 |
{
|
|
|
59 |
/** Inclusion du fichier de configuration de cette application.*/
|
|
|
60 |
require_once PAP_CHEMIN_RACINE.'client/bottin/configuration/bottin.config.inc.php';
|
|
|
61 |
//require_once INS_CHEMIN_APPLI.'configuration/cartographie.config.inc.php';
|
|
|
62 |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ;
|
|
|
63 |
|
|
|
64 |
//-------------------------------------------------------------------------------------------------------------------
|
|
|
65 |
// Initialisation des attributs
|
|
|
66 |
$this->objet_pear_auth = $GLOBALS['_GEN_commun']['pear_auth'];
|
|
|
67 |
$this->objet_pear_db = $GLOBALS['ins_db'];
|
|
|
68 |
$this->objet_pear_url = $GLOBALS['_GEN_commun']['url'];
|
|
|
69 |
$this->sortie_xhtml = '<h1>'.INS_CONFIG_INSCRIPTION.'</h1><br />'."\n";
|
|
|
70 |
|
|
|
71 |
//-------------------------------------------------------------------------------------------------------------------
|
|
|
72 |
// Gestion des boutons de l'interface
|
|
|
73 |
if (isset($_POST['afficheur_annuler'])) {
|
|
|
74 |
return false;
|
1421 |
alexandre_ |
75 |
}
|
1107 |
florian |
76 |
|
1421 |
alexandre_ |
77 |
|
1107 |
florian |
78 |
$requete = 'SELECT gm_application_arguments FROM gen_menu WHERE gm_id_menu='.$_GET['adme_menu_id'];
|
|
|
79 |
$resultat = $this->objet_pear_db->query($requete) ;
|
|
|
80 |
if (DB::isError($resultat)) {
|
1400 |
alexandre_ |
81 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
1107 |
florian |
82 |
}
|
|
|
83 |
$valeurs_par_defaut = array();
|
1400 |
alexandre_ |
84 |
if ($resultat->numRows()>0) {
|
1107 |
florian |
85 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
|
|
|
86 |
$arguments = explode(' ', $ligne->gm_application_arguments);
|
|
|
87 |
for ($i = 0; $i < count($arguments); $i++) {
|
|
|
88 |
$attr = explode('=', $arguments[$i]);
|
|
|
89 |
if ($attr[0] != '') {
|
|
|
90 |
$info_application->$attr[0] = (isset($attr[1]) ? $attr[1] : '');
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
}
|
|
|
94 |
//valeurs par defaut enregistrees dans la table
|
1400 |
alexandre_ |
95 |
if (isset ($info_application->type_annuaire))$valeurs_par_defaut['type_annuaire']=$info_application->type_annuaire;
|
1107 |
florian |
96 |
} else {
|
|
|
97 |
//valeurs par defaut pour afficher une carto des structures
|
1400 |
alexandre_ |
98 |
$valeurs_par_defaut['type_annuaire']=0;
|
1107 |
florian |
99 |
}
|
|
|
100 |
|
1421 |
alexandre_ |
101 |
//-------------------------------------------------------------------------------------------------------------
|
|
|
102 |
// Si le formulaire vient d etre poste, on met a jour la table inscription_configuration
|
|
|
103 |
|
|
|
104 |
if (isset($_POST['enregistrer_quitter'])) {
|
1467 |
alexandre_ |
105 |
if (isset ($_POST['id_inscription'])) {
|
|
|
106 |
$req = 'update inscription_configuration set '.
|
|
|
107 |
'ic_nom_inscription="'.$_POST['ic_nom_inscription'].'", '.
|
|
|
108 |
'ic_url_bazar="'.$_POST['ic_url_bazar'].'", '.
|
|
|
109 |
(isset ($_POST['ic_inscription_modere']) ? 'ic_inscription_modere="'.$_POST['ic_inscription_modere'].'", ':'ic_inscription_modere=0, ').
|
|
|
110 |
'ic_mail_moderateur="'.$_POST['ic_mail_moderateur'].'", '.
|
|
|
111 |
'ic_from_mail_confirmation="'.$_POST['ic_from_mail_confirmation'].'", '.
|
|
|
112 |
'ic_utilise_nom_wiki="'.$_POST['ic_utilise_nom_wiki'].'", '.
|
|
|
113 |
(isset ($_POST['ic_genere_nom_wiki']) ? 'ic_genere_nom_wiki="'.$_POST['ic_genere_nom_wiki'].'", ':'').
|
|
|
114 |
(isset ($_POST['ic_utilise_reecriture_url']) ? 'ic_utilise_reecriture_url="'.$_POST['ic_utilise_reecriture_url'].'", ':'').
|
|
|
115 |
'ic_url_prefixe="'.$_POST['ic_url_prefixe'].'", '.
|
|
|
116 |
(isset ($_POST['ic_mail_valide_inscription']) ? 'ic_mail_valide_inscription="'.$_POST['ic_mail_valide_inscription'].'", ':'').
|
|
|
117 |
'ic_mail_inscription_news="'.$_POST['ic_mail_inscription_news'].'", '.
|
|
|
118 |
'ic_mail_admin_apres_inscription="'.$_POST['ic_mail_admin_apres_inscription'].'"'.
|
|
|
119 |
' where ic_id_inscription="'.$_GET['id_inscription'].'"';
|
|
|
120 |
|
1486 |
alexandre_ |
121 |
$res = $GLOBALS['ins_db']->query($req);$this->sortie_xhtml .= $req;
|
|
|
122 |
if (DB::isError($res)) $this->sortie_xhtml .= $res->getMessage().'<br />'.$res->getDebugInfo();
|
1421 |
alexandre_ |
123 |
}
|
1467 |
alexandre_ |
124 |
if (isset($_POST['id_template'])) {
|
|
|
125 |
$req = 'update inscription_template set ' .
|
|
|
126 |
'it_nom_template="'.$_POST['it_nom_template'].'",' .
|
|
|
127 |
'it_template="'.$_POST['it_template'].'" ' .
|
|
|
128 |
'where it_id_template="'.$_POST['id_template'].'"';
|
|
|
129 |
$GLOBALS['ins_db']->query($req);
|
|
|
130 |
}
|
1421 |
alexandre_ |
131 |
}
|
|
|
132 |
|
|
|
133 |
|
1400 |
alexandre_ |
134 |
// Requete pour recuperer les valeurs de la table inscription_config
|
1426 |
alexandre_ |
135 |
$requete = 'select * from inscription_configuration order by ic_id_inscription';
|
1467 |
alexandre_ |
136 |
$resultat = $GLOBALS['ins_db']->query($requete) ;
|
1400 |
alexandre_ |
137 |
if (DB::isError($resultat)) {
|
|
|
138 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
|
|
139 |
}
|
1421 |
alexandre_ |
140 |
if ($resultat->numRows() == 0) {
|
1400 |
alexandre_ |
141 |
return 'La table inscription_configuration est vide. Il faut qu\'elle contienne au moins une ligne';
|
|
|
142 |
}
|
1467 |
alexandre_ |
143 |
|
|
|
144 |
$GLOBALS['ins_url']->addQueryString('adme_site_id', $_GET['adme_site_id']);
|
|
|
145 |
$GLOBALS['ins_url']->addQueryString('adme_menu_id', $_GET['adme_menu_id']);
|
|
|
146 |
$GLOBALS['ins_url']->addQueryString('adme_action', 'administrer');
|
|
|
147 |
|
|
|
148 |
// Affichage des inscriptions disponible
|
|
|
149 |
$this->sortie_xhtml .= '<ul>';
|
1426 |
alexandre_ |
150 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
1467 |
alexandre_ |
151 |
$GLOBALS['ins_url']->addQueryString('id_inscription', $ligne['ic_id_inscription']);
|
|
|
152 |
$this->sortie_xhtml .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'">'.$ligne['ic_nom_inscription'];
|
|
|
153 |
$this->sortie_xhtml .= '</a></li>';
|
|
|
154 |
}
|
|
|
155 |
$this->sortie_xhtml .= '</ul>';
|
|
|
156 |
|
|
|
157 |
if (isset ($_GET['id_inscription'])) {
|
|
|
158 |
$requete = 'select * from inscription_configuration where ic_id_inscription="'.$_GET['id_inscription'].'"';
|
|
|
159 |
$resultat = $GLOBALS['ins_db']->query($requete) ;
|
|
|
160 |
if (DB::isError($resultat)) {
|
|
|
161 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
|
|
162 |
}
|
|
|
163 |
if ($resultat->numRows() == 0) {
|
|
|
164 |
return 'La table inscription_configuration est vide. Il faut qu\'elle contienne au moins une ligne';
|
|
|
165 |
}
|
|
|
166 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
|
|
167 |
$this->sortie_xhtml .= '<h2>'.$ligne['ic_nom_inscription'].'</h2>';
|
|
|
168 |
|
1426 |
alexandre_ |
169 |
//-------------------------------------------------------------------------------------------------------------
|
|
|
170 |
// Gestion du formulaire
|
1467 |
alexandre_ |
171 |
|
1426 |
alexandre_ |
172 |
$GLOBALS['ins_url']->addQueryString('id_inscription', $ligne['ic_id_inscription']);
|
1467 |
alexandre_ |
173 |
$form = &new HTML_QuickForm('form_param_inscription', 'post', str_replace('&', '&', $GLOBALS['ins_url']->getUrl()));
|
|
|
174 |
$squelette =& $form->defaultRenderer();
|
1426 |
alexandre_ |
175 |
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
|
|
|
176 |
$squelette->setElementTemplate( '<p>'."\n".
|
|
|
177 |
'<label style="width:100px;padding:5px;text-align:right;">{label}'.
|
|
|
178 |
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
|
|
|
179 |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
|
|
|
180 |
' : </label>'."\n".'{element}'."\n".
|
|
|
181 |
'</p>'."\n" );
|
1467 |
alexandre_ |
182 |
|
|
|
183 |
$form->addElement('text', 'ic_nom_inscription', INS_NOM_INSCRIPTION);
|
|
|
184 |
$form->addElement('checkbox', 'ic_inscription_modere', INS_INSCRIPTION_MODERE);
|
|
|
185 |
$form->addElement('textarea', 'ic_mail_moderateur', INS_MAILS_MODERATEURS, array('cols' => 30, 'rows' => 4));
|
|
|
186 |
$form->addElement('checkbox', 'ic_mail_valide_inscription', INS_INSCRIPTION_VERIFICATION_EMAIL);
|
|
|
187 |
$form->addElement('textarea', 'ic_mail_admin_apres_inscription', INS_MAILS_ADMIN, array('cols' => 30, 'rows' => 4));
|
|
|
188 |
$form->addElement('text', 'ic_from_mail_confirmation', INS_FROM_MAIL_CONFIRMATION, array('size' => '50'));
|
|
|
189 |
|
|
|
190 |
$form->addElement('checkbox', 'ic_utilise_nom_wiki', INS_CHAMPS_WIKI);
|
|
|
191 |
$form->addElement('checkbox', 'ic_genere_nom_wiki', INS_GENERE_NOM_WIKI);
|
|
|
192 |
$form->addElement('checkbox', 'ic_utilise_reecriture_url', INS_REECRITURE_URL);
|
|
|
193 |
$form->addElement('text', 'ic_url_prefixe', INS_PREFIXE_URL);
|
|
|
194 |
$form->addElement('text', 'ic_mail_inscription_news', INS_MAIL_INSCRIPTION_NEWS, array('size' => '50'));
|
1426 |
alexandre_ |
195 |
|
1467 |
alexandre_ |
196 |
$form->addElement('text', 'ic_url_bazar', INS_URL_BAZAR);
|
|
|
197 |
$form->addElement('hidden', 'id_inscription', $_GET['id_inscription']);
|
|
|
198 |
$form->addElement('submit', 'enregistrer_quitter', INS_ENREGISTRER_ET_QUITTER);
|
|
|
199 |
$form->addElement('button', 'afficheur_annuler', INS_ANNULER);
|
1426 |
alexandre_ |
200 |
|
1467 |
alexandre_ |
201 |
$form->setDefaults($ligne);
|
|
|
202 |
$this->sortie_xhtml .= $form->toHTML()."\n";
|
|
|
203 |
$this->sortie_xhtml .= '<hr /><br />';
|
|
|
204 |
|
|
|
205 |
// recuperation des templates
|
|
|
206 |
$requete = 'select * from inscription_template where it_ce_inscription="'.$_GET['id_inscription'].'"';
|
|
|
207 |
$resultat = $GLOBALS['ins_db']->query($requete) ;
|
|
|
208 |
if (DB::isError($resultat)) {
|
|
|
209 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
|
|
210 |
}
|
|
|
211 |
if ($resultat->numRows() == 0) {
|
|
|
212 |
$this->sortie_xhtml .= 'La table inscription_template est vide. Ca n\'est pas normal';
|
|
|
213 |
}
|
|
|
214 |
$this->sortie_xhtml .= '<ul>';
|
|
|
215 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
|
|
216 |
$GLOBALS['ins_url']->addQueryString('id_template', $ligne['it_id_template']);
|
|
|
217 |
$this->sortie_xhtml .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'">'.$ligne['it_nom_template'].'</a></li>'."\n";
|
|
|
218 |
}
|
|
|
219 |
$this->sortie_xhtml .= '</ul>';
|
|
|
220 |
// Si un template a ete clique, on affiche le formulaire
|
|
|
221 |
if (isset ($_GET['id_template'])) {
|
|
|
222 |
$requete = 'select * from inscription_template where it_id_template="'.$_GET['id_template'].'"';
|
|
|
223 |
if (isset ($GLOBALS['langue'])) $requete .= ' and it_i18n="'.$GLOBALS['langue'].'"';
|
|
|
224 |
$requete .= ' and it_ce_inscription="'.$_GET['id_inscription'].'"';
|
|
|
225 |
$resultat = $GLOBALS['ins_db']->query($requete) ;
|
|
|
226 |
if (DB::isError($resultat)) {
|
|
|
227 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
|
|
228 |
}
|
|
|
229 |
if ($resultat->numRows() == 0) {
|
|
|
230 |
return 'Pas de template avec ce numero.';
|
|
|
231 |
}
|
|
|
232 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
|
|
233 |
$this->sortie_xhtml .= '<h2>'.$ligne['it_nom_template'].'</h2>';
|
|
|
234 |
|
|
|
235 |
//-------------------------------------------------------------------------------------------------------------
|
|
|
236 |
// Gestion du formulaire
|
|
|
237 |
|
|
|
238 |
$GLOBALS['ins_url']->addQueryString('id_template', $ligne['it_id_template']);
|
|
|
239 |
$form = &new HTML_QuickForm('form_inscription_template', 'post', str_replace('&', '&', $GLOBALS['ins_url']->getUrl()));
|
|
|
240 |
$form->addElement('text', 'it_nom_template', INS_NOM_MODELE, array ('size' => 40));
|
|
|
241 |
|
|
|
242 |
// Recherche des langues
|
|
|
243 |
|
|
|
244 |
$form->addElement('textarea', 'it_template', INS_CONTENU_MODELE, array('cols' => 80, 'rows' => 12));
|
|
|
245 |
|
|
|
246 |
require_once PAP_CHEMIN_API_PEAR.'I18Nv2/Language.php';
|
|
|
247 |
$lang = & new I18Nv2_Language('fr', 'iso-8859-1');
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
// Les langues utilisees dans le site sont gen_i18n_langue
|
|
|
251 |
$requete_langue = 'select * from gen_i18n_langue';
|
|
|
252 |
$resultat_langue = $GLOBALS ['ins_db']->query($requete_langue);
|
|
|
253 |
while ($ligne_langue = $resultat_langue->fetchRow(DB_FETCHMODE_OBJECT)) {
|
|
|
254 |
$langues[$ligne_langue->gil_id_langue] = $ligne_langue->gil_nom;
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
$form->addElement('html', '<tr><td>'.INS_LANGUE.' : '.$lang->getName($ligne_langue->it_i18n).'</td></tr>');
|
|
|
258 |
$form->addElement('hidden', 'id_template', $ligne['it_id_template']);
|
|
|
259 |
$form->addElement('submit', 'enregistrer_quitter', INS_ENREGISTRER_ET_QUITTER);
|
|
|
260 |
$form->addElement('button', 'afficheur_annuler', INS_ANNULER);
|
|
|
261 |
$form->setDefaults($ligne);
|
|
|
262 |
$this->sortie_xhtml .= $form->toHTML()."\n";
|
|
|
263 |
$this->sortie_xhtml .= '<hr /><br />';
|
|
|
264 |
}
|
|
|
265 |
|
1426 |
alexandre_ |
266 |
}
|
1107 |
florian |
267 |
return $this->sortie_xhtml;
|
|
|
268 |
}
|
|
|
269 |
|
|
|
270 |
}// Fin de la classe
|
|
|
271 |
|
|
|
272 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
273 |
// | PIED du PROGRAMME |
|
|
|
274 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
275 |
?>
|