From 4a05560a213aaf6c4fe6e52046e9c731e5c8f852 Mon Sep 17 00:00:00 2001 From: jlb Date: Mon, 3 Mar 2003 17:39:23 +0000 Subject: [PATCH] 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) --- htdocs/adherent.class.php | 100 ++++++++++++++++++++++++-- htdocs/adherents/fiche.php | 21 ++++-- htdocs/admin/const.php | 26 ++++--- htdocs/conf/conf.class.php3.sample | 3 + htdocs/html.form.class.php | 4 +- htdocs/main.inc.php3 | 17 ++++- htdocs/public/adherents/new.php | 6 +- htdocs/public/adherents/priv_edit.php | 6 +- htdocs/user/fiche.php3 | 23 +++--- 9 files changed, 167 insertions(+), 39 deletions(-) diff --git a/htdocs/adherent.class.php b/htdocs/adherent.class.php index 6815aa25160..416b9a9ea2e 100644 --- a/htdocs/adherent.class.php +++ b/htdocs/adherent.class.php @@ -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"); + } + } } ?> diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index edcbb0afb59..ea88b97585e 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -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); + } + } } diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index bf3ebf2cc22..b333f7c141b 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -37,14 +37,14 @@ print "\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 ''; - $form->select_array('consttype',array('yesno','texte'),0); + $form->select_array('consttype',array('yesno','texte','chaine'),0); + } + elseif ($obj->type == 'texte') + { + print '\n"; + print ''; + $form->select_array('consttype',array('yesno','texte','chaine'),1); } else { - print ''; + print ''; print ''; - $form->select_array('consttype',array('yesno','texte'),1); + $form->select_array('consttype',array('yesno','texte','chaine'),2); } print ''; @@ -122,10 +130,10 @@ print ''; print "\n"; print ''; -print ''; +print ''; print ''; -$form->select_array('consttype',array('yesno','texte'),1); +$form->select_array('consttype',array('yesno','texte','chaine'),1); print ''; print ''; diff --git a/htdocs/conf/conf.class.php3.sample b/htdocs/conf/conf.class.php3.sample index ee03ea578c4..61ff840dbcd 100644 --- a/htdocs/conf/conf.class.php3.sample +++ b/htdocs/conf/conf.class.php3.sample @@ -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"; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 26aaa7ab2f1..c49b73da06f 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -176,9 +176,9 @@ class Form { Function checkbox($name,$checked=0,$value=1) { if ($checked==1){ - print "\n"; + print "\n"; }else{ - print "\n"; + print "\n"; } } } diff --git a/htdocs/main.inc.php3 b/htdocs/main.inc.php3 index 5a4857b7e63..106145d4ffe 100644 --- a/htdocs/main.inc.php3 +++ b/htdocs/main.inc.php3 @@ -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)) diff --git a/htdocs/public/adherents/new.php b/htdocs/public/adherents/new.php index 57f6d3e1e8f..8032ef1f0b0 100644 --- a/htdocs/public/adherents/new.php +++ b/htdocs/public/adherents/new.php @@ -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"); } } diff --git a/htdocs/public/adherents/priv_edit.php b/htdocs/public/adherents/priv_edit.php index feadab5c0cc..4938092b9db 100644 --- a/htdocs/public/adherents/priv_edit.php +++ b/htdocs/public/adherents/priv_edit.php @@ -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"); } diff --git a/htdocs/user/fiche.php3 b/htdocs/user/fiche.php3 index 9522d97325a..e18504f60bf 100644 --- a/htdocs/user/fiche.php3 +++ b/htdocs/user/fiche.php3 @@ -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(); }