Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | 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
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: identification.php,v 1.1 2004-06-15 15:01:41 jpm Exp $
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
31
*
32
*@package Applette
33
*@subpackage Identification
34
//Auteur original :
35
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
36
//Autres auteurs :
37
*@author        Aucun
38
*@copyright     Tela-Botanica 2000-2004
39
*@version       $Revision: 1.1 $ $Date: 2004-06-15 15:01:41 $
40
// +------------------------------------------------------------------------------------------------------+
41
*/
42
 
43
// +------------------------------------------------------------------------------------------------------+
44
// |                                            ENTÊTE du PROGRAMME                                       |
45
// +------------------------------------------------------------------------------------------------------+
46
$_GEN_commun['info_applette_nom_fonction'] = 'afficherFormIdentification';
47
$_GEN_commun['info_applette_balise'] = 'IDENTIFICATION';
48
 
49
// +------------------------------------------------------------------------------------------------------+
50
// |                                            CORPS du PROGRAMME                                        |
51
// +------------------------------------------------------------------------------------------------------+
52
 
53
// Si le site utilise une authentification.
54
if ($_GEN_commun['info_auth']->gsa_ce_type_auth == 1) {
55
    // Si un formulaire nous renvoie en POST une variable "deconnexion", nous délogons l'utilisateur.
56
    if (isset($_POST['deconnexion'])) {
57
        $_GEN_commun['pear_auth']->logout();
58
        $_GEN_commun['pear_auth']->start();
59
    }
60
    // Si un formulaire nous renvoie en POST une variable "connexion", nous logons l'utilisateur.
61
    if (isset($_POST['connexion'])) {
62
        $_GEN_commun['pear_auth']->login();
63
        $_SESSION['username'] = $username;
64
    }
65
}
66
 
67
// +------------------------------------------------------------------------------------------------------+
68
// |                                           LISTE de FONCTIONS                                         |
69
// +------------------------------------------------------------------------------------------------------+
70
 
71
/** Fonction afficherFormIdentification() - Retourne une formulaire pour s'identifier.
72
*
73
* Retourne un formulaire d'identificatin ou de déconnexion suivant que l'utilisateur est
74
* identifié ou pas.
75
*
76
* @param  array  tableau d'éventuel arguments présent dans la balise transmis à la fonction.
77
* @param  array  tableau global de Papyrus.
78
* @return string formulaire de connexion ou de déconnexion.
79
*/
80
function afficherFormIdentification($tab_arguments, $_GEN_commun)
81
{
82
    // Initialisation de variable.
83
    $objet_pear_auth = $_GEN_commun['pear_auth'];
84
    $url = $_GEN_commun['url']->getUrl();
85
    // Récupération des valeurs pour le login et le mot de passe
86
    $mot_de_passe = (! isset($_POST['password']))    ? '' : $_POST['password'];
87
    $login        = (! isset($_POST['username']))    ? '' : $_POST['username'];
88
 
89
    // ATTENTION : Partie à supprimer une fois les mise à jour effectué dans l'annuaire de Tela Botanica
90
    // Devrait être déplacer dans l'appli inscription de Tela.
91
    if (isset($_GEN_commun['auth_info']->gsab_nom_table) && $_GEN_commun['auth_info']->gsab_nom_table == 'annuaire_tela') {
92
        verification_mot_de_passe($db, $mot_de_passe, $login);
93
    }
94
 
95
    if (! $objet_pear_auth->getAuth()) {
96
        // L'utilisateur n'est pas identifié:
97
        $res  = str_repeat(' ', 16).'<form id="form_connexion" action="'.$url.'" method="post">'."\n";
98
        $res .= str_repeat(' ', 16).'<fieldset>'."\n";
99
        $res .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";
100
        $res .= str_repeat(' ', 20).'<p>'."\n";
101
        $res .= str_repeat(' ', 24).'<label for="username">'.'Courriel :'.'</label>'."\n";
102
        $res .= str_repeat(' ', 24).'<input type="text" id="username" name="username" size="15" tabindex="1" value="'.'courriel'.'" />'."\n";
103
        $res .= str_repeat(' ', 20).'</p>'."\n";
104
        $res .= str_repeat(' ', 20).'<p>'."\n";
105
        $res .= str_repeat(' ', 24).'<label for="password">'.'Mot de passe :'.'</label>'."\n";
106
        $res .= str_repeat(' ', 24).'<input type="password" id="password" name="password" size="15" tabindex="2" value="'.'mot de passe'.'" />'."\n";
107
        $res .= str_repeat(' ', 20).'</p>'."\n";
108
        $res .= str_repeat(' ', 20).'<p>'."\n";
109
        $res .= str_repeat(' ', 24).'<input type="submit" id="connexion" name="connexion" tabindex="3" value="'.'s\'identifier'.'" />'."\n";
110
        $res .= str_repeat(' ', 20).'</p>'."\n";
111
        $res .= str_repeat(' ', 16).'</fieldset>'."\n";
112
        $res .= str_repeat(' ', 16).'</form>';
113
    } else {
114
        // L'utilisateur est identifié. Nous affichons ses informations.
115
        // Amélioré la récupération des informations sur l'utilisateur.
116
        //$nom_utilisateur = $objet_pear_auth->getAuthData($champ_nom);
117
 
118
        $res  = str_repeat(' ', 16).'<form id="form_deconnexion" action="'.$url.'" method="post">'."\n";
119
        $res .= str_repeat(' ', 16).'<fieldset>'."\n";
120
        $res .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";
121
        // Il faudrait mettre dans la base de données le prénom et le nom ou chercher comment définir ces champs en fonction
122
        // de l'annuaire utilisé, si on veut les afficher après le message de bienvenue.
123
        $res .= str_repeat(' ', 20).'<p>'.'Bienvenue!'.'</p>'."\n";
124
        $res .= str_repeat(' ', 20).'<p>'."\n";
125
        $res .= str_repeat(' ', 24).'<input type="submit" id="deconnexion" name="deconnexion" tabindex="1" value="'.'se déconnecter'.'" />'."\n";
126
        $res .= str_repeat(' ', 20).'</p>'."\n";
127
        $res .= str_repeat(' ', 16).'</fieldset>'."\n";
128
        $res .= str_repeat(' ', 16).'</form>';
129
    }
130
    return $res ;
131
}
132
 
133
// +------------------------------------------------------------------------------------------------------+
134
// |                                            PIED du PROGRAMME                                         |
135
// +------------------------------------------------------------------------------------------------------+
136
 
137
 
138
 
139
/* +--Fin du code ----------------------------------------------------------------------------------------+
140
*
141
* $Log: not supported by cvs2svn $
142
* Revision 1.5  2004/05/05 06:44:15  jpm
143
* Complément des commentaires indiquant les paquetages nécessaire à l'applette.
144
*
145
* Revision 1.4  2004/05/03 11:18:55  jpm
146
* Intégration de la variable globale de Génésia dans les arguments de la fonction de l'applette.
147
*
148
* Revision 1.3  2004/05/01 17:21:16  jpm
149
* Ajout d'un fieldset et d'une légende au formulaire.
150
*
151
* Revision 1.2  2004/05/01 16:13:07  jpm
152
* Ajout du nom de la balise de l'applette dans le code de l'applette.
153
*
154
* Revision 1.1  2004/05/01 11:42:01  jpm
155
* Ajout de l'applette identification.
156
*
157
*
158
* +-- Fin du code ----------------------------------------------------------------------------------------+
159
*/
160
?>