Subversion Repositories Applications.papyrus

Rev

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