Subversion Repositories Applications.papyrus

Rev

Rev 308 | 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
// +------------------------------------------------------------------------------------------------------+
309 jpm 22
// CVS : $Id: identification.php,v 1.11 2005-03-17 15:52:17 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
309 jpm 41
*@version       $Revision: 1.11 $ $Date: 2005-03-17 15:52:17 $
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 {
308 jpm 158
        // L'utilisateur est identifié. Nous affichons ses informations.
304 jpm 159
        // Affichage du prénom et nom d'une personne ou du nom de la structure en fonction des paramêtres
160
        // de l'annuaire utilisé
308 jpm 161
        $retour = str_repeat(' ', 16).'<p id="identification_info"><span id="identification_message">'.IDEN_LANG_MESSAGE.'</span> ';
304 jpm 162
        if (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom) && isset($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom)) {
163
            $retour .=  '<span id="identification_prenom">'.
164
                        $objet_pear_auth->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom).
165
                        '</span> '.
166
                        '<span id="identification_nom">'.
167
                        $objet_pear_auth->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom).
168
                        '</span>';
169
        } elseif (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_structure_nom)) {
170
            $retour .=  '<span id="identification_structure">'.
171
                        $objet_pear_auth->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_structure_nom).
172
                        '</span>';
173
        }
174
        $retour .= '</p>'."\n";
175
 
176
        // Affichage du bouton de déconnexion
308 jpm 177
        $retour .= str_repeat(' ', 16).'<p id="deconnexion">'."\n";
309 jpm 178
        $retour .= str_repeat(' ', 20).'<a href="'.$url.'&amp;logout=1">'.'Déconnexion'.'</a>'."\n";
308 jpm 179
        $retour .= str_repeat(' ', 16).'</p>'."\n";
4 jpm 180
    }
304 jpm 181
    return $retour;
4 jpm 182
}
183
 
184
// +------------------------------------------------------------------------------------------------------+
185
// |                                            PIED du PROGRAMME                                         |
186
// +------------------------------------------------------------------------------------------------------+
187
 
188
 
189
 
190
/* +--Fin du code ----------------------------------------------------------------------------------------+
191
*
192
* $Log: not supported by cvs2svn $
309 jpm 193
* Revision 1.10  2005/03/15 14:47:14  jpm
194
* Utilisation d'un lien à la place d'un formulaire pour la déconnexion.
195
*
308 jpm 196
* Revision 1.9  2005/03/15 14:17:46  jpm
197
* Ajout d'un fichier de config et de traduction.
198
* Début gestion des constantes de langue.
199
*
304 jpm 200
* Revision 1.8  2005/03/10 12:50:44  alex
201
* remplacement de & par  &amp;
202
*
303 alex 203
* Revision 1.7  2005/01/07 12:43:03  alex
204
* réauction de la taille des champs texte à 12
205
*
246 alex 206
* Revision 1.6  2004/12/13 18:07:09  alex
207
* désauthentification spip presque parfaite
208
*
228 alex 209
* Revision 1.5  2004/09/23 14:31:12  jpm
210
* Correction bogue sur l'identification de l'annuaire_tela.
211
*
51 jpm 212
* Revision 1.4  2004/09/23 10:53:44  jpm
213
* Suppression de l'attribut size. Gestion via les css.
214
*
49 jpm 215
* Revision 1.3  2004/06/28 10:18:48  alex
216
* suppression de balises <p>
217
*
20 alex 218
* Revision 1.2  2004/06/21 07:37:30  alex
219
* Modification d'un label
220
*
17 alex 221
* Revision 1.1  2004/06/15 15:01:41  jpm
222
* Changement de nom et d'arborescence de Genesia en Papyrus.
223
*
4 jpm 224
* Revision 1.5  2004/05/05 06:44:15  jpm
225
* Complément des commentaires indiquant les paquetages nécessaire à l'applette.
226
*
227
* Revision 1.4  2004/05/03 11:18:55  jpm
228
* Intégration de la variable globale de Génésia dans les arguments de la fonction de l'applette.
229
*
230
* Revision 1.3  2004/05/01 17:21:16  jpm
231
* Ajout d'un fieldset et d'une légende au formulaire.
232
*
233
* Revision 1.2  2004/05/01 16:13:07  jpm
234
* Ajout du nom de la balise de l'applette dans le code de l'applette.
235
*
236
* Revision 1.1  2004/05/01 11:42:01  jpm
237
* Ajout de l'applette identification.
238
*
239
*
240
* +-- Fin du code ----------------------------------------------------------------------------------------+
241
*/
242
?>