Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1089 → Rev 1090

/trunk/papyrus/applettes/identification/identification.php
1,182 → 1,182
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: identification.php,v 1.25 2006-11-20 18:40:33 jp_milcent Exp $
/**
* Applette : identification
*
* Génère un formulaire les champs nécessaires pour s'identifier.
* Nécessite :
* - Variable globale de Génésia.
* - Pear Auth
* - Pear Net_URL
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: identification.php,v 1.26 2006-12-01 16:33:40 florian Exp $
/**
* Applette : identification
*
* Génère un formulaire les champs nécessaires pour s'identifier.
* Nécessite :
* - Variable globale de Génésia.
* - Pear Auth
* - Pear Net_URL
*
* A faire : remplacer le formulaire par un QuickForm
*
*@package Applette
*@subpackage Identification
//Auteur original :
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.25 $ $Date: 2006-11-20 18:40:33 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTÊTE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
$_GEN_commun['info_applette_nom_fonction'] = 'afficherFormIdentification';
$_GEN_commun['info_applette_balise'] = 'IDENTIFICATION';
*
*@package Applette
*@subpackage Identification
//Auteur original :
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.26 $ $Date: 2006-12-01 16:33:40 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTÊTE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
$GLOBALS['_GEN_commun']['info_applette_nom_fonction'] = 'afficherFormIdentification';
$GLOBALS['_GEN_commun']['info_applette_balise'] = '<!-- '.$GLOBALS['_GEN_commun']['balise_prefixe'].'(IDENTIFICATION) -->';
 
/** Inclusion du fichier de configuration de cette applette.*/
require_once GEN_CHEMIN_APPLETTE.'identification/configuration/iden_config.inc.php';
require_once GEN_CHEMIN_APPLETTE.'identification'.GEN_SEP.'configuration'.GEN_SEP.'iden_config.inc.php';
 
// Inclusion des fichiers de traduction de l'applette.
if (file_exists(IDEN_CHEMIN_LANGUE.'iden_langue_'.$_GEN_commun['i18n'].'.inc.php')) {
if (file_exists(IDEN_CHEMIN_LANGUE.'iden_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
/** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
require_once IDEN_CHEMIN_LANGUE.'iden_langue_'.$_GEN_commun['i18n'].'.inc.php';
require_once IDEN_CHEMIN_LANGUE.'iden_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
} else {
/** Inclusion du fichier de traduction par défaut.*/
require_once IDEN_CHEMIN_LANGUE.'iden_langue_'.IDEN_I18N_DEFAUT.'.inc.php';
}
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
// Si le site utilise une authentification.
if ($GLOBALS['_GEN_commun']['info_auth']->gsa_ce_type_auth == 1) {
// Si un formulaire nous renvoie en POST une variable "deconnexion", nous délogons l'utilisateur.
if (isset($_REQUEST['deconnexion']) || isset($_REQUEST['logout'])) {
$GLOBALS['_GEN_commun']['pear_auth']->logout();
// Destruction du cookie de Papyrus
setcookie(session_name(), session_id(), time()-3600, '/');
}
// Si un formulaire nous renvoie en POST une variable "connexion", nous logons l'utilisateur.
if (isset($_REQUEST['connexion'])) {
// Nous vérifions que l'utilisateur est coché "Mémoriser mon compte"
if (isset($_POST['persistant']) && $_POST['persistant'] == 'o' && IDEN_AUTH_SESSION_DUREE != 0) {
//echo '<pre>'.print_r($_POST, true).'</pre>';
// Expiration si l'utilisateur ne referme pas son navigateur
$GLOBALS['_GEN_commun']['pear_auth']->setExpire((int)IDEN_AUTH_SESSION_DUREE);
// Pour que la session dure même après avoir refermer son navigateur
setcookie(session_name(), session_id(), (int)IDEN_AUTH_SESSION_DUREE, '/');
}
$GLOBALS['_GEN_commun']['pear_auth']->login();
$_SESSION['username'] = $username;
}
}
 
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
// +------------------------------------------------------------------------------------------------------+
 
/** Fonction afficherFormIdentification() - Retourne une formulaire pour s'identifier.
*
* Retourne un formulaire d'identificatin ou de déconnexion suivant que l'utilisateur est
* identifié ou pas.
*
* @param array tableau d'éventuel arguments présent dans la balise transmis à la fonction.
* @param array tableau global de Papyrus.
* @return string formulaire de connexion ou de déconnexion.
*/
function afficherFormIdentification($tab_arguments, &$_GEN_commun)
{
}
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
// Si le site utilise une authentification.
if ($GLOBALS['_GEN_commun']['info_auth']->gsa_ce_type_auth == 1) {
// Si un formulaire nous renvoie en POST une variable "deconnexion", nous délogons l'utilisateur.
if (isset($_REQUEST['deconnexion']) || isset($_REQUEST['logout'])) {
$GLOBALS['_GEN_commun']['pear_auth']->logout();
// Destruction du cookie de Papyrus
setcookie(session_name(), session_id(), time()-3600, '/');
}
// Si un formulaire nous renvoie en POST une variable "connexion", nous logons l'utilisateur.
if (isset($_REQUEST['connexion'])) {
// Nous vérifions que l'utilisateur est coché "Mémoriser mon compte"
if (isset($_POST['persistant']) && $_POST['persistant'] == 'o' && IDEN_AUTH_SESSION_DUREE != 0) {
//echo '<pre>'.print_r($_POST, true).'</pre>';
// Expiration si l'utilisateur ne referme pas son navigateur
$GLOBALS['_GEN_commun']['pear_auth']->setExpire((int)IDEN_AUTH_SESSION_DUREE);
// Pour que la session dure même après avoir refermer son navigateur
setcookie(session_name(), session_id(), (int)IDEN_AUTH_SESSION_DUREE, '/');
}
$GLOBALS['_GEN_commun']['pear_auth']->login();
$_SESSION['username'] = $username;
}
}
 
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
// +------------------------------------------------------------------------------------------------------+
 
/** Fonction afficherFormIdentification() - Retourne une formulaire pour s'identifier.
*
* Retourne un formulaire d'identificatin ou de déconnexion suivant que l'utilisateur est
* identifié ou pas.
*
* @param array tableau d'éventuel arguments présent dans la balise transmis à la fonction.
* @param array tableau global de Papyrus.
* @return string formulaire de connexion ou de déconnexion.
*/
function afficherFormIdentification($tab_arguments, $_GEN_commun)
{
// Initialisation de variable.
$retour = '';
$objet_pear_auth =& $GLOBALS['_GEN_commun']['pear_auth'];
$objet_pear_db =& $GLOBALS['_GEN_commun']['pear_db'];
$InfoAuthBdd =& $GLOBALS['_GEN_commun']['info_auth_bdd'];
$objet_url =& $GLOBALS['_GEN_commun']['url'];
$url = $objet_url->getURL();
// Récupération des valeurs pour le login et le mot de passe
$mot_de_passe = (! isset($_POST['password'])) ? '' : $_POST['password'];
$login = (! isset($_POST['username'])) ? '' : $_POST['username'];
// ATTENTION : Partie à supprimer une fois les mise à jour effectué dans l'annuaire de Tela Botanica
// Devrait être déplacer dans l'appli inscription de Tela.
if (isset($InfoAuthBdd->gsab_nom_table) && $InfoAuthBdd->gsab_nom_table == 'annuaire_tela') {
$retour = '';
$objet_pear_auth =& $_GEN_commun['pear_auth'];
$objet_pear_db =& $_GEN_commun['pear_db'];
$InfoAuthBdd =& $_GEN_commun['info_auth_bdd'];
$objet_url =& $_GEN_commun['url'];
$url = $objet_url->getURL();
// Récupération des valeurs pour le login et le mot de passe
$mot_de_passe = (! isset($_POST['password'])) ? '' : $_POST['password'];
$login = (! isset($_POST['username'])) ? '' : $_POST['username'];
// ATTENTION : Partie à supprimer une fois les mise à jour effectué dans l'annuaire de Tela Botanica
// Devrait être déplacer dans l'appli inscription de Tela.
if (isset($InfoAuthBdd->gsab_nom_table) && $InfoAuthBdd->gsab_nom_table == 'annuaire_tela') {
verification_mot_de_passe($objet_pear_db, $mot_de_passe, $login);
if (isset($_POST['connexion'])) {
$objet_pear_auth->login();
}
}
if (! $objet_pear_auth->getAuth()) {
// L'utilisateur a essayé de s'identifier mais a échoué
if ($login != '') {
$retour .= '<span class="erreur">'.IDEN_ECHEC_AUTH ;
if (isset($InfoAuthBdd->url_inscription)) {
$retour .= '<a id="lien_inscription" href="'.$InfoAuthBdd->url_inscription.'">' ;
$retour .= IDEN_ICI.'</a>' ;
}
$retour .= '</span>'."\n";
}
// L'utilisateur n'est pas identifié:
$retour .= str_repeat(' ', 16).'<form id="form_connexion" class="form_identification" action="'.$url.'" method="post">'."\n";
$retour .= str_repeat(' ', 16).'<fieldset>'."\n";
$retour .= str_repeat(' ', 20).'<legend>'.IDEN_LG_FORM_LEGEND.'</legend>'."\n";
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 24).'<label for="username">'.IDEN_LG_FORM_LABEL_COURRIEL.'</label>'."\n";
$retour .= str_repeat(' ', 24).'<input type="text" id="username" name="username" maxlength="80" tabindex="1" value="'.IDEN_LG_FORM_VALUE_COURRIEL.'" />'."\n";
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 24).'<label for="password">'.IDEN_LG_FORM_LABEL_MDP.'</label>'."\n";
$retour .= str_repeat(' ', 24).'<input type="password" id="password" name="password" maxlength="80" tabindex="2" value="'.IDEN_LG_FORM_VALUE_MDP.'" />'."\n";
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 20).''."\n";
if (IDEN_AUTH_SESSION_DUREE != 0) {
$retour .= str_repeat(' ', 24).'<input type="checkbox" id="persistant" name="persistant" tabindex="3" value="o" />'."\n";
$retour .= str_repeat(' ', 24).'<label id="persistant_label" for="persistant">'.'Mémoriser mon compte'.'</label>'."\n";
}
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 24).'<input type="submit" id="connexion" name="connexion" tabindex="4" value="'.IDEN_LG_FORM_VALUE_SUBMIT.'" />'."\n";
}
}
if (! $objet_pear_auth->getAuth()) {
// L'utilisateur a essayé de s'identifier mais a échoué
if ($login != '') {
$retour .= '<span class="erreur">'.IDEN_ECHEC_AUTH ;
if (isset($InfoAuthBdd->url_inscription)) {
$retour .= '<a id="lien_inscription" href="'.$InfoAuthBdd->url_inscription.'">' ;
$retour .= IDEN_ICI.'</a>' ;
}
$retour .= '</span>'."\n";
}
// L'utilisateur n'est pas identifié:
$retour .= str_repeat(' ', 16).'<form id="form_connexion" class="form_identification" action="'.$url.'" method="post">'."\n";
$retour .= str_repeat(' ', 16).'<fieldset>'."\n";
$retour .= str_repeat(' ', 20).'<legend>'.IDEN_LG_FORM_LEGEND.'</legend>'."\n";
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 24).'<label for="username">'.IDEN_LG_FORM_LABEL_COURRIEL.'</label>'."\n";
$retour .= str_repeat(' ', 24).'<input type="text" id="username" name="username" maxlength="80" tabindex="1" value="'.IDEN_LG_FORM_VALUE_COURRIEL.'" />'."\n";
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 24).'<label for="password">'.IDEN_LG_FORM_LABEL_MDP.'</label>'."\n";
$retour .= str_repeat(' ', 24).'<input type="password" id="password" name="password" maxlength="80" tabindex="2" value="'.IDEN_LG_FORM_VALUE_MDP.'" />'."\n";
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 20).''."\n";
if (IDEN_AUTH_SESSION_DUREE != 0) {
$retour .= str_repeat(' ', 24).'<input type="checkbox" id="persistant" name="persistant" tabindex="3" value="o" />'."\n";
$retour .= str_repeat(' ', 24).'<label id="persistant_label" for="persistant">'.'Mémoriser mon compte'.'</label>'."\n";
}
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 20).''."\n";
$retour .= str_repeat(' ', 24).'<input type="submit" id="connexion" name="connexion" tabindex="4" value="'.IDEN_LG_FORM_VALUE_SUBMIT.'" />'."\n";
$retour .= str_repeat(' ', 20).''."\n";
// Si l'url de la page d'inscription est stockée dans les paramêtres, nous l'affichons
if (isset($InfoAuthBdd->url_inscription) || isset($InfoAuthBdd->url_inscription_aide)) {
$retour .= '<p id="inscription_info">';
if (isset($InfoAuthBdd->url_inscription) || isset($InfoAuthBdd->url_inscription_aide)) {
$retour .= '<p id="inscription_info">';
if (isset($InfoAuthBdd->url_inscription)) {
$retour .= '<a id="lien_inscription" href="'.$InfoAuthBdd->url_inscription.'">'.
IDEN_LG_INSCRIPTION_URL.
'</a>';
}
if (isset($InfoAuthBdd->url_inscription_aide)) {
$retour .= '<a id="inscription_aide" href="'.$InfoAuthBdd->url_inscription_aide.'">'.
IDEN_LG_INSCRIPTION_AIDE.
'</a>';
}
$retour .= '</p>'."\n";
}
$retour .= str_repeat(' ', 16).'</fieldset>'."\n";
$retour .= str_repeat(' ', 16).'</form>';
} else {
}
if (isset($InfoAuthBdd->url_inscription_aide)) {
$retour .= '<a id="inscription_aide" href="'.$InfoAuthBdd->url_inscription_aide.'">'.
IDEN_LG_INSCRIPTION_AIDE.
'</a>';
}
$retour .= '</p>'."\n";
}
$retour .= str_repeat(' ', 16).'</fieldset>'."\n";
$retour .= str_repeat(' ', 16).'</form>';
} else {
// L'utilisateur est identifié. Nous affichons ses informations.
// Affichage du prénom et nom d'une personne ou du nom de la structure en fonction des paramêtres
// de l'annuaire utilisé
$retour .= str_repeat(' ', 16).'<p id="identification_info"><span id="identification_message">'.IDEN_LG_MESSAGE.'</span> ';
// Si les intitulés des champs nom et prénoms d'une personne ou le nom d'une structure sont indiqués nous les affichons
// Si les intitulés des champs nom et prénoms d'une personne ou le nom d'une structure sont indiqués nous les affichons
if (isset($InfoAuthBdd->chp_personne_prenom) && isset($InfoAuthBdd->chp_personne_nom)) {
$retour .= '<span id="identification_prenom">'.
$objet_pear_auth->getAuthData($InfoAuthBdd->chp_personne_prenom).
198,24 → 198,28
IDEN_LG_INSCRIPTION_URL_MODIF.
'</a>'."\n";
}
// Affichage du bouton de déconnexion
$objet_url->addQueryString('logout', 1);
$retour .= str_repeat(' ', 20).'<a id="deconnexion" href="'.$objet_url->getURL().'">'.IDEN_LG_DECONNEXION.'</a>'."\n";
$objet_url->removeQueryString('logout');
$retour .= str_repeat(' ', 16).'</p>'."\n";
}
return $retour;
}
 
// +------------------------------------------------------------------------------------------------------+
// | PIED du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
 
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
// Affichage du bouton de déconnexion
$objet_url->addQueryString('logout', 1);
$retour .= str_repeat(' ', 20).'<a id="deconnexion" href="'.$objet_url->getURL().'">'.IDEN_LG_DECONNEXION.'</a>'."\n";
$objet_url->removeQueryString('logout');
$retour .= str_repeat(' ', 16).'</p>'."\n";
}
return $retour;
}
 
// +------------------------------------------------------------------------------------------------------+
// | PIED du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
 
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.25 2006/11/20 18:40:33 jp_milcent
* Amélioration de la gestion des infos sur l'inscription.
* Ajout du paramêtre url_inscription_aide permettant d'indiquer l'url vers une page d'aide sur l'inscription.
*
* Revision 1.24 2006/11/20 17:42:40 jp_milcent
* Ajout d'un test activant ou pas la mémorisation de l'identification.
*
299,20 → 303,20
*
* Revision 1.5 2004/05/05 06:44:15 jpm
* Complément des commentaires indiquant les paquetages nécessaire à l'applette.
*
* Revision 1.4 2004/05/03 11:18:55 jpm
* Intégration de la variable globale de Génésia dans les arguments de la fonction de l'applette.
*
* Revision 1.3 2004/05/01 17:21:16 jpm
* Ajout d'un fieldset et d'une légende au formulaire.
*
* Revision 1.2 2004/05/01 16:13:07 jpm
* Ajout du nom de la balise de l'applette dans le code de l'applette.
*
* Revision 1.1 2004/05/01 11:42:01 jpm
* Ajout de l'applette identification.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
*
* Revision 1.4 2004/05/03 11:18:55 jpm
* Intégration de la variable globale de Génésia dans les arguments de la fonction de l'applette.
*
* Revision 1.3 2004/05/01 17:21:16 jpm
* Ajout d'un fieldset et d'une légende au formulaire.
*
* Revision 1.2 2004/05/01 16:13:07 jpm
* Ajout du nom de la balise de l'applette dans le code de l'applette.
*
* Revision 1.1 2004/05/01 11:42:01 jpm
* Ajout de l'applette identification.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>