Subversion Repositories Sites.gentiana.org

Compare Revisions

Ignore whitespace Rev 84 → Rev 83

/trunk/client/annuaire/classes/inscription.class.php
New file
0,0 → 1,229
<?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: inscription.class.php,v 1.1.1.1 2005/01/03 17:27:49 alex Exp $
/**
* Inscription
*
* Un module d'inscription, en général ce code est spécifique à
* un site web
*
*@package inscription
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.1.1.1 $ $Date: 2005/01/03 17:27:49 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
require_once 'HTML/QuickForm.php' ;
 
class HTML_formulaireInscription extends HTML_Quickform {
 
/**
* Constructeur
*
* @param string formName Le nom du formulaire
* @param string method Méthode post ou get
* @param string action L'action du formulaire.
* @param int target La cible.
* @param Array attributes Les attributs HTML en plus.
* @param bool trackSubmit ??
* @return void
* @access public
*/
function HTML_forumlaireInscription ( $formName, $method = "post", $action, $target = "_self", $attributes, $trackSubmit = false ) {
HTML_Quickform::HTML_Quickform($formName, $method, $action, $target, $attributes, $trackSubmit) ;
}
 
/**
*
*
* @return void
* @access public
*/
function construitFormulaire($url, $liste_pays)
{
$squelette =& $this->defaultRenderer();
$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<li class="liste_inscription">'."\n".'{label}'."\n".'{element}'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
'</li>'."\n");
$squelette->setGroupElementTemplate ('<span class="groupe_formulaire">{label}{element}</span>', 'groupe_mot_de_passe') ;
$squelette->setGroupElementTemplate ('<span class="groupe_formulaire">{label}{element}</span>', 'groupe_cp_ville') ;
$squelette->setGroupElementTemplate ('<span class="groupe_formulaire">{label}{element}</span>', 'groupe_nom') ;
$squelette->setRequiredNoteTemplate("\n".'<p>'."\n".'<span class="symbole_obligatoire">*</span> {requiredNote}'."\n".'</p>'."\n");
$fieldset_debut = '<fieldset>'."\n".
'<legend>'.INS_AJOUT_MEMBRE.'</legend>'."\n".
'<ul>'."\n";
$this->addElement('html', $fieldset_debut);
$this->addElement ('text', 'email', INS_EMAIL) ;
$this->addRule ('email', INS_EMAIL_REQUIS, 'required','', 'client') ;
$this->addRule ('email', INS_MAIL_INCORRECT, 'email', '', 'client') ;
$this->registerRule('doublonmail', 'callback', 'verif_doublonMail');
$this->addRule('email', INS_MAIL_DOUBLE, 'doublonmail', true);
// A faire, grouper les mots de passe
$this->addElement ('password', 'mot_de_passe', INS_MOT_DE_PASSE) ;
$this->addElement ('password', 'mot_de_passe_repete', INS_REPETE_MOT_DE_PASSE) ;
$this->addRule ('mot_de_passe', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
$this->addRule ('mot_de_passe_repete', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
$this->addRule (array ('mot_de_passe', 'mot_de_passe_repete'), INS_MOTS_DE_PASSE_DIFFERENTS, 'compare', '', 'client') ;
$nom_prenom[] = & HTML_QuickForm::createElement ('text', 'nom', INS_NOM) ;
$nom_prenom[] = & HTML_QuickForm::createElement ('text', 'prenom', INS_PRENOM) ;
$this->addGroup ($nom_prenom, 'groupe_nom', '', '', false) ;
if (INS_UTILISE_WIKINI) {
$this->addElement ('text', 'nom_wikini', INS_NOM_WIKI) ;
$this->addRule ('nom_wikini', INS_MAUVAIS_NOM_WIKI, 'regex', '/(!?[A-Z][A-Za-z0-9]*[a-z0-9]+[A-Z][A-Za-z0-9]*)/', 'client') ;
$this->registerRule('doublonwikini', 'callback', 'verif_doublonNomWiki');
$this->addRule('nom_wikini', INS_NOMWIKI_DOUBLE, 'doublonwikini', true);
}
$this->addElement ('text', 'adresse_1', INS_ADRESSE) ;
$this->addElement ('text', 'adresse_2', INS_ADRESSE) ;
$this->addElement ('text', 'region', INS_REGION) ;
$cp_ville[] = & HTML_QuickForm::createElement ('text', 'cp', INS_CODE_POSTAL) ;
$cp_ville[] = & HTML_QuickForm::createElement ('text', 'ville', INS_VILLE) ;
$this->addGroup ($cp_ville, 'groupe_cp_ville', '', '', false) ;
$this->addGroupRule ('groupe_cp_ville', INS_CODE_POSTAL_REQUIS, 'required', '', 1, 'client') ;
// L'élément pays est construit à partir du tableau liste_pays
 
$this->addElement ('select', 'pays', INS_PAYS, $liste_pays) ;
$this->addElement ('text', 'site', INS_SITE_INTERNET) ;
// on fait un groupe avec les boutons pour les mettres sur la même ligne
$buttons[] = &HTML_QuickForm::createElement('button', 'annuler', INS_ANNULER, array ("onclick" => "javascript:document.location.href='".$url."'"));
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', INS_VALIDER);
$this->addGroup($buttons, null, null, '&nbsp;');
$fieldset_fin = '</ul>'."\n".
'</fieldset>'."\n";
$this->addElement('html', $fieldset_fin);
 
$this->setRequiredNote(INS_CHAMPS_REQUIS) ;
} // end of member function construitFormulaire
/** Modifie le formulaire pour l'adapter au cas des structures
*
*
* @return void
* @access public
*/
function formulaireStructure()
{
$this->removeElement('groupe_nom') ;
$this->removeElement('email', false) ;
$mail = & HTML_QuickForm::createElement ('text', 'email', INS_MAIL_STRUCTURE) ;
$this->insertElementBefore ($mail, 'mot_de_passe') ;
$nom_structure = & HTML_QuickForm::createElement ('text', 'nom', INS_NOM_STRUCTURE) ;
$this->insertElementBefore ($nom_structure, 'email') ;
$this->removeElement ('site', false) ;
$site_structure = & HTML_QuickForm::createElement ('text', 'site', INS_SITE_STRUCTURE) ;
$this->insertElementBefore ($site_structure, 'pays') ;
$this->addElement ('hidden', 'est_structure', 1) ;
$sigle_structure = & HTML_QuickForm::createElement ('text', 'sigle_structure', INS_SIGLE_STRUCTURE) ;
$this->insertElementBefore ($sigle_structure, 'nom') ;
$this->addRule ('sigle_structure', INS_SIGLE_REQUIS, 'required', '', 'client') ;
}
/**
*
*
* @return string
* @access public
*/
function toHTML( )
{
$res = HTML_QuickForm::toHTML() ;
return $res ;
} // end of member function toHTML
 
 
 
}
 
class ListeDePays extends PEAR{
 
var $_db ;
/** Constructeur
* Vérifie l'existance de la table gen_pays_traduction
*
* @param DB Un objet PEAR::DB
* @return
*/
function ListeDePays (&$objetDB) {
$this->_db = $objetDB ;
$requete = "show tables" ;
$resultat = $objetDB->query ($requete) ;
if (DB::isError ($resultat)) {
die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
}
while ($ligne = $resultat->fetchRow()) {
if ($ligne[0] == 'gen_pays_traduction') {
return ;
}
}
return $this->raiseError ('La table gen_pays_traduction n\'est pas présente dans la base de donnée !') ;
}
/** Renvoie la liste des pays traduite
*
* @param string une chaine de type i18n ou une chaine code iso langue (fr_FR ou fr ou FR)
* @return un tableau contenant en clé, le code iso du pays, en majuscule et en valeur le nom du pays traduit
*/
function getListePays ($i18n) {
if (strlen($i18n) == 2) {
$i18n = strtolower($i18n)."-".strtoupper($i18n) ;
}
$requete = "select gpt_id_pays, gpt_nom_pays_traduit from gen_pays_traduction where gpt_id_i18n='".$i18n."'" ;
$resultat = $this->_db->query ($requete) ;
if (DB::isError ($resultat)) {
die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
}
if ($resultat->numRows() == 0) {
return $this->raiseError('Le code fourni ne correspond à aucun pays ou n\'est pas dans la table!') ;
}
$retour = array() ;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$retour[$ligne->gpt_id_pays] = $ligne->gpt_nom_pays_traduit ;
}
return $retour ;
}
}
 
?>