carrection de bug dans la gestion des users

passage des constante en text dans la base
modification du formulaires des constantes pour gerer le texte
support des mails de bienvenues dans les constante
et debut de gestion de mailing-list mailman (enfin un truc sommaire pour l'instant)
This commit is contained in:
jlb 2003-03-03 17:39:23 +00:00
parent 2753f6f7ea
commit 4a05560a21
9 changed files with 167 additions and 39 deletions

View File

@ -42,7 +42,7 @@ class Adherent
var $pass;
var $naiss;
var $photo;
var $public;
// var $public;
var $array_options;
var $errorstr;
@ -63,14 +63,59 @@ class Adherent
/*
* function envoyant un email au destinataire (recipient) avec le text fourni en parametre.
* La particularite de cette focntion est de remplacer certains champs par leur valeur pour l'adherent
* La particularite de cette fonction est de remplacer certains champs par leur valeur pour l'adherent
* en l'occurrence :
* %prenom% : est remplace par le prenom
* %nom% : est remplace par nom
* %PRENOM% : est remplace par le prenom
* %NOM% : est remplace par nom
* %INFOS% : l'ensemble des attributs de cet adherent
* %SERVEUR% : URL du serveur web
* ...
*/
Function send_an_email($recipients,$text)
Function send_an_email($recipients,$text,$subject="Vos coordonnees sur %SERVEUR%")
{
$patterns = array (
'/%PRENOM%/',
'/%NOM%/',
'/%INFOS%/',
'/%INFO%/',
'/%SERVEUR%/',
'/%SOCIETE%/',
'/%ADRESSE%/',
'/%CP%/',
'/%VILLE%/',
'/%PAYS%/',
'/%EMAIL%/',
'/%NAISS%/',
'/%PHOTO%/',
'/%LOGIN%/',
'/%PASS%/'
);
$infos = "Prenom : $this->prenom\nNom : $this->nom\nSociete : $this->societe\nAdresse : $this->adresse\nCP : $this->cp\nVille : $this->ville\nPays : $this->pays\nEmail : $this->email\nLogin : $this->login\nPassword : $this->pass\nDate de naissance : $this->naiss\nPhoto : $this->photo\n";
if ($this->public == 1){
$infos.="Fiche Publique : Oui\n";
}else{
$infos.="Fiche Publique : Non\n";
}
$replace = array (
$this->prenom,
$this->nom,
$infos,
$infos,
"http://".$_SERVER["SERVER_NAME"]."/",
$this->societe,
$this->adresse,
$this->cp,
$this->ville,
$this->pays,
$this->email,
$this->naiss,
$this->photo,
$this->login,
$this->pass
);
$texttosend = preg_replace ($patterns, $replace, $text);
$subjectosend = preg_replace ($patterns, $replace, $subject);
return mail($recipients,$subjectosend,$texttosend);
}
/*
*
@ -532,6 +577,49 @@ class Adherent
}
}
/*
* Ajoute le user aux mailing-list
*
*/
Function add_to_list($email,$list)
{
}
/*
*
*
*/
Function add_to_mailman($email,$list,$mailmandir)
{
if (!file_exists($mailmandir)) {
mkdir($mailmandir, 0777);
}
if (!file_exists("$mailmandir/$list")) {
mkdir("$mailmandir/$list", 0777);
}
if (!file_exists("$mailmandir/$list/subscribe")) {
mkdir("$mailmandir/$list/subscribe", 0777);
}
if (!file_exists("$mailmandir/$list/subscribe/$email")) {
touch("$mailmandir/$list/subscribe/$email");
}
}
Function del_to_mailman($email,$list,$mailmandir)
{
if (!file_exists($mailmandir)) {
mkdir($mailmandir, 0777);
}
if (!file_exists("$mailmandir/$list")) {
mkdir("$mailmandir/$list", 0777);
}
if (!file_exists("$mailmandir/$list/unsubscribe")) {
mkdir("$mailmandir/$list/unsubscribe", 0777);
}
if (!file_exists("$mailmandir/$list/unsubscribe/$email")) {
touch("$mailmandir/$list/unsubscribe/$email");
}
}
}
?>

View File

@ -92,8 +92,15 @@ if ($HTTP_POST_VARS["action"] == 'confirm_valid' && $HTTP_POST_VARS["confirm"] =
$adh = new Adherent($db, $rowid);
$adh->validate($user->id);
$adh->fetch($rowid);
$mesg=preg_replace("/%INFO%/","Prenom : $adh->prenom\nNom : $adh->nom\nSociete = $adh->societe\nAdresse = $adh->adresse\nCode Postal : $adh->cp\nVille : $adh->ville\nPays : $adh->pays\nEmail : $adh->email\nLogin : $adh->login\nPassword : $adh->pass\nNote : $adh->note\n\nServeur : http://$SERVER_NAME/public/adherents/",$conf->adherent->email_valid);
mail($adh->email,"Vos coordonnees sur http://$SERVER_NAME/",$mesg);
//$mesg=preg_replace("/%INFO%/","Prenom : $adh->prenom\nNom : $adh->nom\nSociete = $adh->societe\nAdresse = $adh->adresse\nCode Postal : $adh->cp\nVille : $adh->ville\nPays : $adh->pays\nEmail : $adh->email\nLogin : $adh->login\nPassword : $adh->pass\nNote : $adh->note\n\nServeur : http://$SERVER_NAME/public/adherents/",$conf->adherent->email_valid);
//mail($adh->email,"Vos coordonnees sur http://$SERVER_NAME/",$mesg);
$adh->send_an_email($adh->email,$conf->adherent->email_valid,'Vos coordonnees sur %SERVEUR%');
if ($conf->adherent->use_mailman == 1){
foreach ($conf->adherent->mailman_lists as $key){
$adh->add_to_mailman($adh->email,$key,$conf->adherent->mailman_dir);
}
}
}
if ($HTTP_POST_VARS["action"] == 'confirm_resign' && $HTTP_POST_VARS["confirm"] == yes)
@ -101,8 +108,14 @@ if ($HTTP_POST_VARS["action"] == 'confirm_resign' && $HTTP_POST_VARS["confirm"]
$adh = new Adherent($db, $rowid);
$adh->resiliate($user->id);
$adh->fetch($rowid);
$mesg=preg_replace("/%INFO%/","Prenom : $adh->prenom\nNom : $adh->nom\nSociete = $adh->societe\nAdresse = $adh->adresse\nCode Postal : $adh->cp\nVille : $adh->ville\nPays : $adh->pays\nEmail : $adh->email\nLogin : $adh->login\nPassword : $adh->pass\nNote : $adh->note\n\nServeur : http://$SERVER_NAME/public/adherents/",$conf->adherent->email_resil);
mail($adh->email,"Vos coordonnees sur http://$SERVER_NAME/",$mesg);
//$mesg=preg_replace("/%INFO%/","Prenom : $adh->prenom\nNom : $adh->nom\nSociete = $adh->societe\nAdresse = $adh->adresse\nCode Postal : $adh->cp\nVille : $adh->ville\nPays : $adh->pays\nEmail : $adh->email\nLogin : $adh->login\nPassword : $adh->pass\nNote : $adh->note\n\nServeur : http://$SERVER_NAME/public/adherents/",$conf->adherent->email_resil);
//mail($adh->email,"Vos coordonnees sur http://$SERVER_NAME/",$mesg);
$adh->send_an_email($adh->email,$conf->adherent->email_resil,'Vos coordonnees sur %SERVEUR%');
if ($conf->adherent->use_mailman == 1){
foreach ($conf->adherent->mailman_lists as $key){
$adh->del_to_mailman($adh->email,$key,$conf->adherent->mailman_dir);
}
}
}

View File

@ -37,14 +37,14 @@ print "</TR>\n";
$db = new Db();
$form = new Form($db);
$typeconst=array('yesno','texte','chaine');
if ($user->admin)
{
if ($HTTP_POST_VARS["action"] == 'update' || $HTTP_POST_VARS["action"] == 'add')
{
if ($HTTP_POST_VARS["consttype"] == 0){
$sql = "REPLACE INTO llx_const SET name='".$_POST["constname"]."', value = '".$HTTP_POST_VARS["constvalue"]."',note='".$HTTP_POST_VARS["constnote"]."', type='yesno'";
if (isset($HTTP_POST_VARS["consttype"]) && $HTTP_POST_VARS["consttype"] != ''){
$sql = "REPLACE INTO llx_const SET name='".$_POST["constname"]."', value = '".$HTTP_POST_VARS["constvalue"]."',note='".$HTTP_POST_VARS["constnote"]."', type='".$typeconst[$HTTP_POST_VARS["consttype"]]."'";
}else{
$sql = "REPLACE INTO llx_const SET name='".$_POST["constname"]."', value = '".$HTTP_POST_VARS["constvalue"]."',note='".$HTTP_POST_VARS["constnote"]."'";
}
@ -94,13 +94,21 @@ if ($result)
{
$form->selectyesnonum('constvalue',$obj->value);
print '</td><td>';
$form->select_array('consttype',array('yesno','texte'),0);
$form->select_array('consttype',array('yesno','texte','chaine'),0);
}
elseif ($obj->type == 'texte')
{
print '<textarea name="constvalue" cols="35" rows="5"wrap="soft">';
print $obj->value;
print "</textarea>\n";
print '</td><td>';
$form->select_array('consttype',array('yesno','texte','chaine'),1);
}
else
{
print '<input type="text" size="15" name="constvalue" value="'.stripslashes($obj->value).'">';
print '<input type="text" size="30" name="constvalue" value="'.stripslashes($obj->value).'">';
print '</td><td>';
$form->select_array('consttype',array('yesno','texte'),1);
$form->select_array('consttype',array('yesno','texte','chaine'),2);
}
print '</td><td>';
@ -122,10 +130,10 @@ print '<input type="hidden" name="action" value="add">';
print "<tr $bc[$var] class=value><td><input type=\"text\" size=\"15\" name=\"constname\" value=\"\"></td>\n";
print '<td>';
print '<input type="text" size="15" name="constvalue" value="">';
print '<input type="text" size="30" name="constvalue" value="">';
print '</td><td>';
$form->select_array('consttype',array('yesno','texte'),1);
$form->select_array('consttype',array('yesno','texte','chaine'),1);
print '</td><td>';
print '<input type="text" size="15" name="constnote" value="">';

View File

@ -192,6 +192,9 @@ class ServiceConf {
class AdherentConf {
Function AdherentConf() {
$this->enabled = 0;
$this->use_mailman = 1;
$this->mailman_dir = "/home/httpd/adherents.j1b.org/htdocs/adherents/ml/mailman";
$this->mailman_lists = array('lists1','list2');
$this->email_new = "Merci de votre inscription. Votre adhesion devrait etre rapidement validee.\nVoici le rappel des coordonnees que vous avez rentrees (toute information erronee entrainera la non validation de votre inscription) :\n\n%INFO%\n\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l'adresse suivante :\nhttp://$SERVER_NAME/public/adherents/priv_edit.php\n\n";
$this->email_edit = "Voici le rappel des coordonnees que vous avez modifiees (toute information erronee entrainera la non validation de votre inscription) :\n\n%INFO%\n\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l'adresse suivante :\nhttp://$SERVER_NAME/public/adherents/priv_edit.php\n\n";
$this->email_valid = "Votre adhesion vient d'etre validee. Voici le rappel de vos coordonnees (toute information erronee entrainera la non validation de votre inscription) :\n\n%INFO%\n\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l'adresse suivante :\nhttp://$SERVER_NAME/public/adherents/priv_edit.php\n\n";

View File

@ -176,9 +176,9 @@ class Form {
Function checkbox($name,$checked=0,$value=1)
{
if ($checked==1){
print "<input type=\"checkbox\" name=\"$name\" value=\"fixe\" checked />\n";
print "<input type=\"checkbox\" name=\"$name\" value=\"$value\" checked />\n";
}else{
print "<input type=\"checkbox\" name=\"$name\" value=\"fixe\" />\n";
print "<input type=\"checkbox\" name=\"$name\" value=\"$value\" />\n";
}
}
}

View File

@ -80,7 +80,22 @@ if (defined("MAIN_THEME"))
$conf->theme=MAIN_THEME;
$conf->css = "theme/".$conf->theme."/".$conf->theme.".css";
}
if (defined("MAIN_MAIL_RESIL"))
{
$conf->adherent->email_resil=MAIN_MAIL_RESIL;
}
if (defined("MAIN_MAIL_VALID"))
{
$conf->adherent->email_valid=MAIN_MAIL_VALID;
}
if (defined("MAIN_MAIL_EDIT"))
{
$conf->adherent->email_edit=MAIN_MAIL_EDIT;
}
if (defined("MAIN_MAIL_NEW"))
{
$conf->adherent->email_new=MAIN_MAIL_NEW;
}
/*
*/
if(!isset($application_lang))

View File

@ -102,9 +102,9 @@ if ($HTTP_POST_VARS["action"] == 'add')
$adh->cotisation(mktime(12, 0 , 0, $remonth, $reday, $reyear), $cotisation);
}
// Envoi d'un Email de confirmation au nouvel adherent
$mesg=preg_replace("/%INFO%/","Prenom : $prenom\nNom : $nom\nSociete = $societe\nAdresse = $adresse\nCode Postal : $cp\nVille : $ville\nPays : $pays\nEmail : $email\nLogin : $login\nPassword : $pass1\nNote : $note\n\nServeur : http://$SERVER_NAME/public/adherents/",$conf->adherent->email_new);
//$mesg="Merci de votre inscription. Votre adhesion devrait etre rapidement validee.\nVoici le rappel des coordonnees que vous avez rentrees (toute information erronee entrainera la non validation de votre inscription) :\n\nPrenom : $prenom\nNom : $nom\nSociete = $societe\nAdresse = $adresse\nCode Postal : $cp\nVille : $ville\nPays : $pays\nEmail : $email\nLogin : $login\nPassword : $pass\nNote : $note\n\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l'adresse suivante :\nhttp://$SERVER_NAME/adherents/private/edit.php\n\n";
mail($email,"Votre adhesion sur http://$SERVER_NAME/",$mesg);
//$mesg=preg_replace("/%INFO%/","Prenom : $prenom\nNom : $nom\nSociete = $societe\nAdresse = $adresse\nCode Postal : $cp\nVille : $ville\nPays : $pays\nEmail : $email\nLogin : $login\nPassword : $pass1\nNote : $note\n\nServeur : http://$SERVER_NAME/public/adherents/",$conf->adherent->email_new);
//mail($email,"Votre adhesion sur http://$SERVER_NAME/",$mesg);
$adh->send_an_email($email,$conf->adherent->email_new,'Vos coordonnees sur %SERVEUR%');
Header("Location: new.php?action=added");
}
}

View File

@ -109,9 +109,9 @@ if ($action == 'update')
}
if ($adh->update($user->id) )
{
$mesg=preg_replace("/%INFO%/","Prenom : $prenom\nNom : $nom\nSociete = $societe\nAdresse = $adresse\nCode Postal : $cp\nVille : $ville\nPays : $pays\nEmail : $email\nLogin : $login\nPassword : $pass\nNote : $note\n\nServeur : http://$SERVER_NAME/public/adherents/",$conf->adherent->email_edit);
mail($email,"Vos coordonnees sur http://$SERVER_NAME/",$mesg);
//$mesg=preg_replace("/%INFO%/","Prenom : $prenom\nNom : $nom\nSociete = $societe\nAdresse = $adresse\nCode Postal : $cp\nVille : $ville\nPays : $pays\nEmail : $email\nLogin : $login\nPassword : $pass\nNote : $note\n\nServeur : http://$SERVER_NAME/public/adherents/",$conf->adherent->email_edit);
//mail($email,"Vos coordonnees sur http://$SERVER_NAME/",$mesg);
$adh->send_an_email($email,$conf->adherent->email_edit,'Vos coordonnees sur %SERVEUR%');
//Header("Location: fiche.php?rowid=$adh->id&action=edit");
Header("Location: $PHP_SELF");
}

View File

@ -57,30 +57,31 @@ if ($HTTP_POST_VARS["action"] == 'add' && $user->admin)
}
}
if ($action == 'update' && $user->admin)
if ($_POST["action"] == 'update' && $user->admin)
{
$edituser = new User($db, $id);
$edituser->fetch();
$edituser->nom = $nom;
$edituser->note = $HTTP_POST_VARS["note"];
$edituser->prenom = $prenom;
$edituser->login = $login;
$edituser->email = $email;
$edituser->admin = $HTTP_POST_VARS["admin"];
$edituser->webcal_login = $HTTP_POST_VARS["webcal_login"];
if (isset($HTTP_POST_VARS["module_compta"]) && $HTTP_POST_VARS["module_compta"] ==1){
$edituser->nom = $_POST["nom"];
$edituser->note = $_POST["note"];
$edituser->prenom = $_POST["prenom"];
$edituser->login = $_POST["login"];
$edituser->email = $_POST["email"];
$edituser->admin = $_POST["admin"];
$edituser->webcal_login = $_POST["webcal_login"];
if (isset($_POST["module_compta"]) && $_POST["module_compta"] ==1){
$edituser->compta = 1;
}else{
$edituser->compta = 0;
}
if (isset($HTTP_POST_VARS["module_comm"]) && $HTTP_POST_VARS["module_comm"] ==1){
if (isset($_POST["module_comm"]) && $_POST["module_comm"] ==1){
$edituser->comm = 1;
}else{
$edituser->comm = 0;
}
if (! $edituser->update($id, $user))
// if (! $edituser->update($id, $user))
if (! $edituser->update())
{
print $edituser->error();
}