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_google_key="'.$_POST['ic_google_key'].'", '.
|
|
|
118 |
'ic_mail_inscription_news="'.$_POST['ic_mail_inscription_news'].'", '.
|
|
|
119 |
'ic_inscription_template="'.$_POST['ic_inscription_template'].'", '.
|
|
|
120 |
'ic_mail_admin_apres_inscription="'.$_POST['ic_mail_admin_apres_inscription'].'"'.
|
|
|
121 |
' where ic_id_inscription="'.$_GET['id_inscription'].'"';
|
|
|
122 |
|
|
|
123 |
$GLOBALS['ins_db']->query($req);
|
1421 |
alexandre_ |
124 |
}
|
1467 |
alexandre_ |
125 |
if (isset($_POST['id_template'])) {
|
|
|
126 |
$req = 'update inscription_template set ' .
|
|
|
127 |
'it_nom_template="'.$_POST['it_nom_template'].'",' .
|
|
|
128 |
'it_template="'.$_POST['it_template'].'" ' .
|
|
|
129 |
'where it_id_template="'.$_POST['id_template'].'"';
|
|
|
130 |
$GLOBALS['ins_db']->query($req);
|
|
|
131 |
}
|
1421 |
alexandre_ |
132 |
}
|
|
|
133 |
|
|
|
134 |
|
1400 |
alexandre_ |
135 |
// Requete pour recuperer les valeurs de la table inscription_config
|
1426 |
alexandre_ |
136 |
$requete = 'select * from inscription_configuration order by ic_id_inscription';
|
1467 |
alexandre_ |
137 |
$resultat = $GLOBALS['ins_db']->query($requete) ;
|
1400 |
alexandre_ |
138 |
if (DB::isError($resultat)) {
|
|
|
139 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
|
|
140 |
}
|
1421 |
alexandre_ |
141 |
if ($resultat->numRows() == 0) {
|
1400 |
alexandre_ |
142 |
return 'La table inscription_configuration est vide. Il faut qu\'elle contienne au moins une ligne';
|
|
|
143 |
}
|
1467 |
alexandre_ |
144 |
|
|
|
145 |
$GLOBALS['ins_url']->addQueryString('adme_site_id', $_GET['adme_site_id']);
|
|
|
146 |
$GLOBALS['ins_url']->addQueryString('adme_menu_id', $_GET['adme_menu_id']);
|
|
|
147 |
$GLOBALS['ins_url']->addQueryString('adme_action', 'administrer');
|
|
|
148 |
|
|
|
149 |
// Affichage des inscriptions disponible
|
|
|
150 |
$this->sortie_xhtml .= '<ul>';
|
1426 |
alexandre_ |
151 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
1467 |
alexandre_ |
152 |
$GLOBALS['ins_url']->addQueryString('id_inscription', $ligne['ic_id_inscription']);
|
|
|
153 |
$this->sortie_xhtml .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'">'.$ligne['ic_nom_inscription'];
|
|
|
154 |
$this->sortie_xhtml .= '</a></li>';
|
|
|
155 |
}
|
|
|
156 |
$this->sortie_xhtml .= '</ul>';
|
|
|
157 |
|
|
|
158 |
if (isset ($_GET['id_inscription'])) {
|
|
|
159 |
$requete = 'select * from inscription_configuration where ic_id_inscription="'.$_GET['id_inscription'].'"';
|
|
|
160 |
$resultat = $GLOBALS['ins_db']->query($requete) ;
|
|
|
161 |
if (DB::isError($resultat)) {
|
|
|
162 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
|
|
163 |
}
|
|
|
164 |
if ($resultat->numRows() == 0) {
|
|
|
165 |
return 'La table inscription_configuration est vide. Il faut qu\'elle contienne au moins une ligne';
|
|
|
166 |
}
|
|
|
167 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
|
|
168 |
$this->sortie_xhtml .= '<h2>'.$ligne['ic_nom_inscription'].'</h2>';
|
|
|
169 |
|
1426 |
alexandre_ |
170 |
//-------------------------------------------------------------------------------------------------------------
|
|
|
171 |
// Gestion du formulaire
|
1467 |
alexandre_ |
172 |
|
1426 |
alexandre_ |
173 |
$GLOBALS['ins_url']->addQueryString('id_inscription', $ligne['ic_id_inscription']);
|
1467 |
alexandre_ |
174 |
$form = &new HTML_QuickForm('form_param_inscription', 'post', str_replace('&', '&', $GLOBALS['ins_url']->getUrl()));
|
|
|
175 |
$squelette =& $form->defaultRenderer();
|
1426 |
alexandre_ |
176 |
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
|
|
|
177 |
$squelette->setElementTemplate( '<p>'."\n".
|
|
|
178 |
'<label style="width:100px;padding:5px;text-align:right;">{label}'.
|
|
|
179 |
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
|
|
|
180 |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
|
|
|
181 |
' : </label>'."\n".'{element}'."\n".
|
|
|
182 |
'</p>'."\n" );
|
1467 |
alexandre_ |
183 |
|
|
|
184 |
$form->addElement('text', 'ic_nom_inscription', INS_NOM_INSCRIPTION);
|
|
|
185 |
$form->addElement('checkbox', 'ic_inscription_modere', INS_INSCRIPTION_MODERE);
|
|
|
186 |
$form->addElement('textarea', 'ic_mail_moderateur', INS_MAILS_MODERATEURS, array('cols' => 30, 'rows' => 4));
|
|
|
187 |
$form->addElement('checkbox', 'ic_mail_valide_inscription', INS_INSCRIPTION_VERIFICATION_EMAIL);
|
|
|
188 |
$form->addElement('textarea', 'ic_mail_admin_apres_inscription', INS_MAILS_ADMIN, array('cols' => 30, 'rows' => 4));
|
|
|
189 |
$form->addElement('text', 'ic_from_mail_confirmation', INS_FROM_MAIL_CONFIRMATION, array('size' => '50'));
|
|
|
190 |
|
|
|
191 |
$form->addElement('checkbox', 'ic_utilise_nom_wiki', INS_CHAMPS_WIKI);
|
|
|
192 |
$form->addElement('checkbox', 'ic_genere_nom_wiki', INS_GENERE_NOM_WIKI);
|
|
|
193 |
$form->addElement('checkbox', 'ic_utilise_reecriture_url', INS_REECRITURE_URL);
|
|
|
194 |
$form->addElement('text', 'ic_url_prefixe', INS_PREFIXE_URL);
|
|
|
195 |
$form->addElement('text', 'ic_mail_inscription_news', INS_MAIL_INSCRIPTION_NEWS, array('size' => '50'));
|
1426 |
alexandre_ |
196 |
|
1467 |
alexandre_ |
197 |
$form->addElement('text', 'ic_url_bazar', INS_URL_BAZAR);
|
|
|
198 |
$form->addElement('hidden', 'id_inscription', $_GET['id_inscription']);
|
|
|
199 |
$form->addElement('submit', 'enregistrer_quitter', INS_ENREGISTRER_ET_QUITTER);
|
|
|
200 |
$form->addElement('button', 'afficheur_annuler', INS_ANNULER);
|
1426 |
alexandre_ |
201 |
|
1467 |
alexandre_ |
202 |
$form->setDefaults($ligne);
|
|
|
203 |
$this->sortie_xhtml .= $form->toHTML()."\n";
|
|
|
204 |
$this->sortie_xhtml .= '<hr /><br />';
|
|
|
205 |
|
|
|
206 |
// recuperation des templates
|
|
|
207 |
$requete = 'select * from inscription_template where it_ce_inscription="'.$_GET['id_inscription'].'"';
|
|
|
208 |
$resultat = $GLOBALS['ins_db']->query($requete) ;
|
|
|
209 |
if (DB::isError($resultat)) {
|
|
|
210 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
|
|
211 |
}
|
|
|
212 |
if ($resultat->numRows() == 0) {
|
|
|
213 |
$this->sortie_xhtml .= 'La table inscription_template est vide. Ca n\'est pas normal';
|
|
|
214 |
}
|
|
|
215 |
$this->sortie_xhtml .= '<ul>';
|
|
|
216 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
|
|
217 |
$GLOBALS['ins_url']->addQueryString('id_template', $ligne['it_id_template']);
|
|
|
218 |
$this->sortie_xhtml .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'">'.$ligne['it_nom_template'].'</a></li>'."\n";
|
|
|
219 |
}
|
|
|
220 |
$this->sortie_xhtml .= '</ul>';
|
|
|
221 |
// Si un template a ete clique, on affiche le formulaire
|
|
|
222 |
if (isset ($_GET['id_template'])) {
|
|
|
223 |
$requete = 'select * from inscription_template where it_id_template="'.$_GET['id_template'].'"';
|
|
|
224 |
if (isset ($GLOBALS['langue'])) $requete .= ' and it_i18n="'.$GLOBALS['langue'].'"';
|
|
|
225 |
$requete .= ' and it_ce_inscription="'.$_GET['id_inscription'].'"';
|
|
|
226 |
$resultat = $GLOBALS['ins_db']->query($requete) ;
|
|
|
227 |
if (DB::isError($resultat)) {
|
|
|
228 |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
|
|
229 |
}
|
|
|
230 |
if ($resultat->numRows() == 0) {
|
|
|
231 |
return 'Pas de template avec ce numero.';
|
|
|
232 |
}
|
|
|
233 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
|
|
234 |
$this->sortie_xhtml .= '<h2>'.$ligne['it_nom_template'].'</h2>';
|
|
|
235 |
|
|
|
236 |
//-------------------------------------------------------------------------------------------------------------
|
|
|
237 |
// Gestion du formulaire
|
|
|
238 |
|
|
|
239 |
$GLOBALS['ins_url']->addQueryString('id_template', $ligne['it_id_template']);
|
|
|
240 |
$form = &new HTML_QuickForm('form_inscription_template', 'post', str_replace('&', '&', $GLOBALS['ins_url']->getUrl()));
|
|
|
241 |
$form->addElement('text', 'it_nom_template', INS_NOM_MODELE, array ('size' => 40));
|
|
|
242 |
|
|
|
243 |
// Recherche des langues
|
|
|
244 |
|
|
|
245 |
$form->addElement('textarea', 'it_template', INS_CONTENU_MODELE, array('cols' => 80, 'rows' => 12));
|
|
|
246 |
|
|
|
247 |
require_once PAP_CHEMIN_API_PEAR.'I18Nv2/Language.php';
|
|
|
248 |
$lang = & new I18Nv2_Language('fr', 'iso-8859-1');
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
// Les langues utilisees dans le site sont gen_i18n_langue
|
|
|
252 |
$requete_langue = 'select * from gen_i18n_langue';
|
|
|
253 |
$resultat_langue = $GLOBALS ['ins_db']->query($requete_langue);
|
|
|
254 |
while ($ligne_langue = $resultat_langue->fetchRow(DB_FETCHMODE_OBJECT)) {
|
|
|
255 |
$langues[$ligne_langue->gil_id_langue] = $ligne_langue->gil_nom;
|
|
|
256 |
}
|
|
|
257 |
|
|
|
258 |
$form->addElement('html', '<tr><td>'.INS_LANGUE.' : '.$lang->getName($ligne_langue->it_i18n).'</td></tr>');
|
|
|
259 |
$form->addElement('hidden', 'id_template', $ligne['it_id_template']);
|
|
|
260 |
$form->addElement('submit', 'enregistrer_quitter', INS_ENREGISTRER_ET_QUITTER);
|
|
|
261 |
$form->addElement('button', 'afficheur_annuler', INS_ANNULER);
|
|
|
262 |
$form->setDefaults($ligne);
|
|
|
263 |
$this->sortie_xhtml .= $form->toHTML()."\n";
|
|
|
264 |
$this->sortie_xhtml .= '<hr /><br />';
|
|
|
265 |
}
|
|
|
266 |
|
1426 |
alexandre_ |
267 |
}
|
1107 |
florian |
268 |
return $this->sortie_xhtml;
|
|
|
269 |
}
|
|
|
270 |
|
|
|
271 |
}// Fin de la classe
|
|
|
272 |
|
|
|
273 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
274 |
// | PIED du PROGRAMME |
|
|
|
275 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
276 |
?>
|