Amélioration exemple formulaire inscription publique

This commit is contained in:
Laurent Destailleur 2007-02-27 23:47:21 +00:00
parent 8503d24474
commit 5205372e54

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2001-2002 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -23,7 +23,7 @@
/** /**
\file htdocs/public/adherents/new.php \file htdocs/public/adherents/new.php
\ingroup adherent \ingroup adherent
\brief Page liste des nouveaux adherents \brief formulaire exemple pour inscription publique d'un nouveau membre
\version $Revision$ \version $Revision$
*/ */
@ -37,6 +37,11 @@ $errmsg='';
$num=0; $num=0;
$error=0; $error=0;
/*
* Actions
*/
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
// test si le login existe deja // test si le login existe deja
@ -77,7 +82,9 @@ if ($_POST["action"] == 'add')
}else{ }else{
$public=0; $public=0;
} }
if (!$error){
if (! $error)
{
// email a peu pres correct et le login n'existe pas // email a peu pres correct et le login n'existe pas
$adh = new Adherent($db); $adh = new Adherent($db);
$adh->statut = -1; $adh->statut = -1;
@ -104,21 +111,37 @@ if ($_POST["action"] == 'add')
$adh->array_options[$key]=$_POST[$key]; $adh->array_options[$key]=$_POST[$key];
} }
} }
if ($adh->create($user->id) )
$result=$adh->create($user->id);
if ($result > 0)
{ {
if ($cotisation > 0) if ($cotisation > 0)
{ {
$adh->cotisation(mktime(12, 0 , 0, $remonth, $reday, $reyear), $cotisation); $adh->cotisation(mktime(12, 0 , 0, $remonth, $reday, $reyear), $cotisation);
} }
// Envoi d'un Email de confirmation au nouvel adherent // Envoi d'un Email de confirmation au nouvel adherent
$adh->send_an_email($email,$conf->adherent->email_new,$conf->adherent->email_new_subject); $adh->send_an_email($email,$conf->adherent->email_new,$conf->adherent->email_new_subject);
Header("Location: new.php?action=added"); Header("Location: new.php?action=added");
exit;
} }
} }
} }
// On vient de s'inscrire avec succes
if (isset($_GET["action"]) && $_GET["action"] == 'added' && $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)
{
// Si conf->global->MEMBER_URL_REDIRECT_SBUSCRIPTION defini, faire redirect sur page.
Header("Location: ".$conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION);
exit;
}
llxHeaderVierge(); llxHeaderVierge();
$html = new Form($db);
print_titre("Nouvel adhérent");
/* ************************************************************************** */ /* ************************************************************************** */
@ -127,26 +150,32 @@ llxHeaderVierge();
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
$adht = new AdherentType($db);
// fetch optionals attributes and labels // fetch optionals attributes and labels
$adho->fetch_optionals(); $adho->fetch_optionals();
if (isset($action) && $action== 'added') if (isset($_GET["action"]) && $_GET["action"] == 'added')
{ {
// Si on a pas été redirigé
print '<br>';
print '<table cellspacing="0" border="1" width="100%" cellpadding="3">'; print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
print "<tr><td><FONT COLOR=\"blue\">Nouvel Adhérent ajouté. En attente de validation</FONT></td></tr>\n"; print "<tr><td><FONT COLOR=\"blue\">Nouvel Adhérent ajouté. En attente de validation</FONT></td></tr>\n";
print '</table>'; print '</table>';
} }
if ($errmsg != ''){
print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
if ($errmsg != '')
{
print '<br>';
print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
print '<th>Erreur dans le formulaire</th>'; print '<th>Erreur dans le formulaire</th>';
print "<tr><td class=\"delete\"><b>$errmsg</b></td></tr>\n"; print "<tr><td class=\"delete\"><b>$errmsg</b></td></tr>\n";
// print "<FONT COLOR=\"red\">$errmsg</FONT>\n"; // print "<FONT COLOR=\"red\">$errmsg</FONT>\n";
print '</table>'; print '</table>';
} }
print_titre("Nouvel adhérent"); if (defined("ADH_TEXT_NEW_ADH") && ADH_TEXT_NEW_ADH !='')
if (defined("ADH_TEXT_NEW_ADH") && ADH_TEXT_NEW_ADH !=''){ {
print ADH_TEXT_NEW_ADH; print ADH_TEXT_NEW_ADH;
print "<BR>\n"; print "<BR>\n";
} }
@ -160,11 +189,9 @@ print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
$htmls = new Form($db);
$adht = new AdherentType($db);
print '<tr><td width="15%">'.$langs->trans("Type").'</td><td width="35%">'; print '<tr><td width="15%">'.$langs->trans("Type").'</td><td width="35%">';
$htmls->select_array("type", $adht->liste_array()); $html->select_array("type", $adht->liste_array());
print "</td>\n"; print "</td>\n";
print '<td width="50%" valign="top">'.$langs->trans("Comments").' :</td></tr>'; print '<td width="50%" valign="top">'.$langs->trans("Comments").' :</td></tr>';
@ -173,7 +200,7 @@ $morphys["phy"] = "Physique";
$morphys["mor"] = "Morale"; $morphys["mor"] = "Morale";
print "<tr><td>Personne</td><td>\n"; print "<tr><td>Personne</td><td>\n";
$htmls->select_array("morphy", $morphys); $html->select_array("morphy", $morphys);
print "</td>\n"; print "</td>\n";
print '<td valign="top" rowspan="14"><textarea name="comment" wrap="soft" cols="40" rows="25">'.$comment.'</textarea></td></tr>'; print '<td valign="top" rowspan="14"><textarea name="comment" wrap="soft" cols="40" rows="25">'.$comment.'</textarea></td></tr>';