Subversion Repositories Applications.papyrus

Rev

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

Rev Author Line No. Line
4 jpm 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
// +------------------------------------------------------------------------------------------------------+
304 jpm 22
// CVS : $Id: identification.php,v 1.9 2005-03-15 14:17:46 jpm Exp $
4 jpm 23
/**
24
* Applette : identification
25
*
26
* Génère un formulaire les champs nécessaires pour s'identifier.
27
* Nécessite :
28
* - Variable globale de Génésia.
29
* - Pear Auth
30
* - Pear Net_URL
17 alex 31
*
32
* A faire : remplacer le formulaire par un QuickForm
4 jpm 33
*
34
*@package Applette
35
*@subpackage Identification
36
//Auteur original :
37
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
38
//Autres auteurs :
39
*@author        Aucun
40
*@copyright     Tela-Botanica 2000-2004
304 jpm 41
*@version       $Revision: 1.9 $ $Date: 2005-03-15 14:17:46 $
4 jpm 42
// +------------------------------------------------------------------------------------------------------+
43
*/
44
 
45
// +------------------------------------------------------------------------------------------------------+
46
// |                                            ENTÊTE du PROGRAMME                                       |
47
// +------------------------------------------------------------------------------------------------------+
48
$_GEN_commun['info_applette_nom_fonction'] = 'afficherFormIdentification';
49
$_GEN_commun['info_applette_balise'] = 'IDENTIFICATION';
304 jpm 50
 
51
/** Inclusion du fichier de configuration de cette applette.*/
52
require_once GEN_CHEMIN_APPLETTE.'identification/configuration/iden_config.inc.php';
53
 
54
// Inclusion des fichiers de traduction de l'applette.
55
if (file_exists(IDEN_CHEMIN_LANGUE.'iden_langue_'.$_GEN_commun['i18n'].'.inc.php')) {
56
    /** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
57
    require_once IDEN_CHEMIN_LANGUE.'iden_langue_'.$_GEN_commun['i18n'].'.inc.php';
58
} else {
59
    /** Inclusion du fichier de traduction par défaut.*/
60
    require_once IDEN_CHEMIN_LANGUE.'iden_langue_'.IDEN_I18N_DEFAUT.'.inc.php';
61
}
4 jpm 62
// +------------------------------------------------------------------------------------------------------+
63
// |                                            CORPS du PROGRAMME                                        |
64
// +------------------------------------------------------------------------------------------------------+
65
 
66
// Si le site utilise une authentification.
67
if ($_GEN_commun['info_auth']->gsa_ce_type_auth == 1) {
68
    // Si un formulaire nous renvoie en POST une variable "deconnexion", nous délogons l'utilisateur.
304 jpm 69
    if (isset($_REQUEST['deconnexion']) || isset($_REQUEST['logout'])) {
228 alex 70
        $_GEN_commun['pear_auth']->logout();
71
        // Le test suivant vérifie si une authentification SPIP est en cour, vois pap_initialise_auth.inc.php
72
        if (isset ($chemin_spip) && isset ($coauth) && $coauth == $auth_courante['gsab_id_auth_bdd']) {
73
            // On place un cookie avec une duré dépassée
74
            setcookie("spip_session", $id_session, time() - 3600*24, "/$chemin_cookie_spip/") ;
75
            setcookie("spip_admin", "@".$login, time() -3600*24, "/$chemin_cookie_spip/") ;
76
 
77
            $dirname = $GLOBALS['flag_ecrire'] ? "data/" : "ecrire/data/";
78
            $dirname = $chemin_spip."/".$dirname ;
79
             // ne pas se zapper soi-meme
80
            if ($s = $GLOBALS['spip_session'])
81
                   $fichier_session = fichier_session($s, lire_meta('alea_ephemere'));
82
                $fichier_session = $chemin_spip."/ecrire/".$fichier_session ;
83
            $dir = opendir($dirname);
84
            $t = time();
85
            while(($item = readdir($dir)) != '') {
86
                $chemin = "$dirname$item";
87
                if (ereg("^session_([0-9]+_)?([a-z0-9]+)\.php3$", $item, $regs)) {
88
                // Si c'est une vieille session, on jette
89
                    if (($t - filemtime($chemin)) > 48 * 3600) unlink($chemin);
90
                    // sinon voir si c'est une session du meme auteur
91
                        else if ($regs[1] == $id_auteur.'_') {
92
                            $zap_num ++;
93
                    if ($zap) unlink($chemin);
94
                    }
95
                }
96
            }
97
        }
4 jpm 98
        $_GEN_commun['pear_auth']->start();
99
    }
100
    // Si un formulaire nous renvoie en POST une variable "connexion", nous logons l'utilisateur.
304 jpm 101
    if (isset($_REQUEST['connexion'])) {
4 jpm 102
        $_GEN_commun['pear_auth']->login();
103
        $_SESSION['username'] = $username;
104
    }
105
}
106
 
107
// +------------------------------------------------------------------------------------------------------+
108
// |                                           LISTE de FONCTIONS                                         |
109
// +------------------------------------------------------------------------------------------------------+
110
 
111
/** Fonction afficherFormIdentification() - Retourne une formulaire pour s'identifier.
112
*
113
* Retourne un formulaire d'identificatin ou de déconnexion suivant que l'utilisateur est
114
* identifié ou pas.
115
*
116
* @param  array  tableau d'éventuel arguments présent dans la balise transmis à la fonction.
117
* @param  array  tableau global de Papyrus.
118
* @return string formulaire de connexion ou de déconnexion.
119
*/
304 jpm 120
function afficherFormIdentification($tab_arguments, &$_GEN_commun)
4 jpm 121
{
122
    // Initialisation de variable.
304 jpm 123
    $objet_pear_auth =& $GLOBALS['_GEN_commun']['pear_auth'];
124
    $objet_pear_db =& $GLOBALS['_GEN_commun']['pear_db'];
125
    $url = $GLOBALS['_GEN_commun']['url']->getURL();
4 jpm 126
    // Récupération des valeurs pour le login et le mot de passe
127
    $mot_de_passe = (! isset($_POST['password']))    ? '' : $_POST['password'];
128
    $login        = (! isset($_POST['username']))    ? '' : $_POST['username'];
129
 
130
    // ATTENTION : Partie à supprimer une fois les mise à jour effectué dans l'annuaire de Tela Botanica
131
    // Devrait être déplacer dans l'appli inscription de Tela.
304 jpm 132
    if (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_nom_table) && $GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_nom_table == 'annuaire_tela') {
51 jpm 133
        verification_mot_de_passe($objet_pear_db, $mot_de_passe, $login);
134
        if (isset($_POST['connexion'])) {
304 jpm 135
            $objet_pear_auth->login();
51 jpm 136
        }
4 jpm 137
    }
138
 
139
    if (! $objet_pear_auth->getAuth()) {
140
        // L'utilisateur n'est pas identifié:
304 jpm 141
        $retour  = str_repeat(' ', 16).'<form id="form_connexion" class="form_identification" action="'.$url.'" method="post">'."\n";
142
        $retour .= str_repeat(' ', 16).'<fieldset>'."\n";
143
        $retour .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";
144
        $retour .= str_repeat(' ', 20).''."\n";
145
        $retour .= str_repeat(' ', 24).'<label for="username">'.'Courriel :'.'</label>'."\n";
146
        $retour .= str_repeat(' ', 24).'<input type="text" size="12" id="username" name="username" maxlength="80" tabindex="1" value="'.'courriel'.'" />'."\n";
147
        $retour .= str_repeat(' ', 20).''."\n";
148
        $retour .= str_repeat(' ', 20).''."\n";
149
        $retour .= str_repeat(' ', 24).'<label for="password">'.'Mot de passe :'.'</label>'."\n";
150
        $retour .= str_repeat(' ', 24).'<input type="password" size="12" id="password" name="password" maxlength="80" tabindex="2" value="'.'mot de passe'.'" />'."\n";
151
        $retour .= str_repeat(' ', 20).''."\n";
152
        $retour .= str_repeat(' ', 20).''."\n";
153
        $retour .= str_repeat(' ', 24).'<input type="submit" id="connexion" name="connexion" tabindex="3" value="'.'ok'.'" />'."\n";
154
        $retour .= str_repeat(' ', 20).''."\n";
155
        $retour .= str_repeat(' ', 16).'</fieldset>'."\n";
156
        $retour .= str_repeat(' ', 16).'</form>';
4 jpm 157
    } else {
158
        // L'utilisateur est identifié. Nous affichons ses informations.
304 jpm 159
        $retour  = str_repeat(' ', 16).'<form id="form_deconnexion" class="form_identification" action="'.$url.'&amp;logout=1" method="post">'."\n";
160
        $retour .= str_repeat(' ', 16).'<fieldset>'."\n";
161
        $retour .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";
162
 
163
        // Affichage du prénom et nom d'une personne ou du nom de la structure en fonction des paramêtres
164
        // de l'annuaire utilisé
165
        $retour .= str_repeat(' ', 20).'<p><span id="identification_message">'.IDEN_LANG_MESSAGE.'</span> ';
166
        if (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom) && isset($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom)) {
167
            $retour .=  '<span id="identification_prenom">'.
168
                        $objet_pear_auth->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom).
169
                        '</span> '.
170
                        '<span id="identification_nom">'.
171
                        $objet_pear_auth->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom).
172
                        '</span>';
173
        } elseif (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_structure_nom)) {
174
            $retour .=  '<span id="identification_structure">'.
175
                        $objet_pear_auth->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_structure_nom).
176
                        '</span>';
177
        }
178
        $retour .= '</p>'."\n";
179
 
180
        // Affichage du bouton de déconnexion
181
        $retour .= str_repeat(' ', 20).'<p>'."\n";
182
        $retour .= str_repeat(' ', 24).'<input type="submit" id="deconnexion" name="deconnexion" tabindex="1" value="'.'d&eacute;connexion'.'" />'."\n";
183
        $retour .= str_repeat(' ', 20).'</p>'."\n";
184
        $retour .= str_repeat(' ', 16).'</fieldset>'."\n";
185
        $retour .= str_repeat(' ', 16).'</form>';
4 jpm 186
    }
304 jpm 187
    return $retour;
4 jpm 188
}
189
 
190
// +------------------------------------------------------------------------------------------------------+
191
// |                                            PIED du PROGRAMME                                         |
192
// +------------------------------------------------------------------------------------------------------+
193
 
194
 
195
 
196
/* +--Fin du code ----------------------------------------------------------------------------------------+
197
*
198
* $Log: not supported by cvs2svn $
304 jpm 199
* Revision 1.8  2005/03/10 12:50:44  alex
200
* remplacement de & par  &amp;
201
*
303 alex 202
* Revision 1.7  2005/01/07 12:43:03  alex
203
* réauction de la taille des champs texte à 12
204
*
246 alex 205
* Revision 1.6  2004/12/13 18:07:09  alex
206
* désauthentification spip presque parfaite
207
*
228 alex 208
* Revision 1.5  2004/09/23 14:31:12  jpm
209
* Correction bogue sur l'identification de l'annuaire_tela.
210
*
51 jpm 211
* Revision 1.4  2004/09/23 10:53:44  jpm
212
* Suppression de l'attribut size. Gestion via les css.
213
*
49 jpm 214
* Revision 1.3  2004/06/28 10:18:48  alex
215
* suppression de balises <p>
216
*
20 alex 217
* Revision 1.2  2004/06/21 07:37:30  alex
218
* Modification d'un label
219
*
17 alex 220
* Revision 1.1  2004/06/15 15:01:41  jpm
221
* Changement de nom et d'arborescence de Genesia en Papyrus.
222
*
4 jpm 223
* Revision 1.5  2004/05/05 06:44:15  jpm
224
* Complément des commentaires indiquant les paquetages nécessaire à l'applette.
225
*
226
* Revision 1.4  2004/05/03 11:18:55  jpm
227
* Intégration de la variable globale de Génésia dans les arguments de la fonction de l'applette.
228
*
229
* Revision 1.3  2004/05/01 17:21:16  jpm
230
* Ajout d'un fieldset et d'une légende au formulaire.
231
*
232
* Revision 1.2  2004/05/01 16:13:07  jpm
233
* Ajout du nom de la balise de l'applette dans le code de l'applette.
234
*
235
* Revision 1.1  2004/05/01 11:42:01  jpm
236
* Ajout de l'applette identification.
237
*
238
*
239
* +-- Fin du code ----------------------------------------------------------------------------------------+
240
*/
241
?>