Subversion Repositories Applications.papyrus

Rev

Rev 1400 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
// +------------------------------------------------------------------------------------------------------+
37
 
38
 
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                                 CLASSE                                               |
41
// +------------------------------------------------------------------------------------------------------+
1400 alexandre_ 42
 
43
include_once 'configuration/bottin.config.inc.php';
44
include_once INS_CHEMIN_APPLI.'langues/bottin.admin.langue_fr.php';
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'])) {
105
        	$req = 'update inscription_configuration set '.
106
        			'ic_formulaire_structure="'.$_POST['ic_formulaire_structure'].'", '.
107
        			'ic_url_bazar="'.$_POST['ic_url_bazar'].'", '.
108
        			(isset ($_POST['ic_inscription_modere']) ? 'ic_inscription_modere="'.$_POST['ic_inscription_modere'].'", ':'').
109
        			'ic_mail_moderateur="'.$_POST['ic_mail_moderateur'].'", '.
110
        			'ic_sujet_mail="'.$_POST['ic_sujet_mail'].'", '.
111
        			'ic_utilise_nom_wiki="'.$_POST['ic_utilise_nom_wiki'].'", '.
112
        			(isset ($_POST['ic_genere_nom_wiki']) ? 'ic_genere_nom_wiki="'.$_POST['ic_genere_nom_wiki'].'", ':'').
113
        			(isset ($_POST['ic_utilise_reecriture_url']) ? 'ic_utilise_reecriture_url="'.$_POST['ic_utilise_reecriture_url'].'", ':'').
114
        			'ic_url_prefixe="'.$_POST['ic_url_prefixe'].'", '.
115
        			(isset ($_POST['ic_mail_valide_inscription']) ? 'ic_mail_valide_inscription="'.$_POST['ic_mail_valide_inscription'].'", ':'').
116
        			'ic_google_key="'.$_POST['ic_google_key'].'", '.
117
        			'ic_mail_admin_apres_inscription="'.$_POST['ic_mail_admin_apres_inscription'].'"';
118
 
119
        	//$this->objet_pear_db->query($req);
120
 
121
        	// On place la configuration dans gm_application_arguments de la table gen_menu
122
        	$requete = 'update gen_menu set gm_application_arguments = \''.serialize($_POST).'" where gm_id_menu="'.
123
        				$_REQUEST['adme_menu_id'].'\'';
124
        	$resultat = $this->objet_pear_db->query($requete);
125
 
126
        	if (DB::isError($resultat)) {
127
        		return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
128
        	}
129
 
130
        }
131
 
132
 
1400 alexandre_ 133
        // Requete pour recuperer les valeurs de la table inscription_config
134
        $requete = 'select * from inscription_configuration';
1421 alexandre_ 135
        $resultat = $this->objet_pear_db->query($requete) ;
1400 alexandre_ 136
        if (DB::isError($resultat)) {
137
        	return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
138
        }
1421 alexandre_ 139
        if ($resultat->numRows() == 0) {
1400 alexandre_ 140
        	return 'La table inscription_configuration est vide. Il faut qu\'elle contienne au moins une ligne';
141
        }
1421 alexandre_ 142
        $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
143
 
1400 alexandre_ 144
        //-------------------------------------------------------------------------------------------------------------
1107 florian 145
        // Gestion du formulaire
146
        $this->objet_pear_url->addQueryString('adme_site_id', $_GET['adme_site_id']);
147
        $this->objet_pear_url->addQueryString('adme_menu_id', $_GET['adme_menu_id']);
148
        $this->objet_pear_url->addQueryString('adme_action', 'administrer');
149
        $form =& new HTML_QuickForm('form_param_inscription', 'post', str_replace('&amp;', '&', $this->objet_pear_url->getUrl()));
150
        $squelette =& $form->defaultRenderer();
151
        $squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
152
        $squelette->setElementTemplate( '<p>'."\n".
153
                                        '<label style="width:100px;padding:5px;text-align:right;">{label}'.
154
                                        '<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
155
                                        '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
156
										' : </label>'."\n".'{element}'."\n".
157
										'</p>'."\n" );
158
        $option_tables[0] = INS_ANNUAIRE_BOTTIN;
159
        $option_tables[1] = INS_ANNUAIRE_ADMIN_PAPYRUS;
160
        $form->addElement('select', 'type_annuaire', INS_TYPE_ANNUAIRE, $option_tables);
1400 alexandre_ 161
        //$liste_bouton_debut = '<ul class="liste_bouton">'."\n";
162
        //$form->addElement('html', $liste_bouton_debut);
163
        // checkbox pour la presence ou non d un formulaire structure
164
        $form->addElement('checkbox', 'ic_formulaire_structure', INS_FORMULAIRE_STRUCTURE);
165
        $form->addElement('text', 'ic_url_bazar', INS_URL_BAZAR);
166
        $form->addElement('checkbox', 'ic_inscription_modere', INS_INSCRIPTION_MODERE_OUI_NON);
167
        $form->addElement('textarea', 'ic_mail_moderateur', INS_MAILS_MODERATEURS, array('cols' => 30, 'rows' => 4));
168
        $form->addElement('checkbox', 'ic_mail_valide_inscription', INS_INSCRIPTION_VERIFICATION_EMAIL);
169
        $form->addElement('textarea', 'ic_mail_admin_apres_inscription', INS_MAILS_ADMIN, array('cols' => 30, 'rows' => 4));
1421 alexandre_ 170
        $form->addElement('text', 'ic_sujet_mail', INS_SUJET_MAIL_CONFIRMATION, array('size' => '60'));
1400 alexandre_ 171
        $form->addElement('checkbox', 'ic_utilise_nom_wiki', INS_CHAMPS_WIKI);
172
        $form->addElement('checkbox', 'ic_genere_nom_wiki', INS_GENERE_NOM_WIKI);
173
        $form->addElement('checkbox', 'ic_utilise_reecriture_url', INS_REECRITURE_URL);
174
        $form->addElement('text', 'ic_url_prefixe', INS_PREFIXE_URL);
1421 alexandre_ 175
        $form->addElement('text', 'ic_google_key', INS_GOOGLE_KEY, array('size' => '60'));
176
        $form->addElement('submit', 'enregistrer_quitter', INS_ENREGISTRER_ET_QUITTER);
1400 alexandre_ 177
        $form->addElement('button', 'afficheur_annuler', INS_ANNULER);
1421 alexandre_ 178
 
179
        $form->setDefaults($ligne);
1107 florian 180
        $this->sortie_xhtml .= $form->toHTML()."\n";
181
        return $this->sortie_xhtml;
182
    }
183
 
184
}// Fin de la classe
185
 
186
// +------------------------------------------------------------------------------------------------------+
187
// |                                            PIED du PROGRAMME                                         |
188
// +------------------------------------------------------------------------------------------------------+
189
?>