From 2708b09db30ad88154efc2eef8f508306b800117 Mon Sep 17 00:00:00 2001 From: x2000bedo Date: Tue, 24 Aug 2004 00:14:11 +0000 Subject: [PATCH] Migration utilisateurs_identification.php admin -> marketing --- etat_migration | 2 +- htdocs/marketing/utilisateurs_identification.php | 87 ++++++++++++++++++++++++ htdocs/marketing/utilisateurs_marketing.php | 59 +--------------- include/select_user.inc.php | 58 ++++++++++++++++ templates/marketing/utilisateurs_edit.tpl | 70 +++++++++++++++++++ templates/marketing/utilisateurs_inscrire.tpl | 69 +++++++++++++++++++ 6 files changed, 287 insertions(+), 58 deletions(-) create mode 100644 htdocs/marketing/utilisateurs_identification.php create mode 100644 include/select_user.inc.php create mode 100644 templates/marketing/utilisateurs_edit.tpl create mode 100644 templates/marketing/utilisateurs_inscrire.tpl diff --git a/etat_migration b/etat_migration index cc223b6..6cb81cd 100644 --- a/etat_migration +++ b/etat_migration @@ -16,7 +16,7 @@ ------+-------------------------------------------+---------------- Etat | Ancien nom | Nouveau nom ------+-[ marketing ]-----------------------------+---------------- -; | admin/utilisateurs_identification.php | marketing/ +x | admin/utilisateurs_identification.php | marketing/ ------+-[ inscription + mdp ]---------------------+---------------- xx | tmpPWD.php | ------+-[ listes ]--------------------------------+---------------- diff --git a/htdocs/marketing/utilisateurs_identification.php b/htdocs/marketing/utilisateurs_identification.php new file mode 100644 index 0000000..e3304cb --- /dev/null +++ b/htdocs/marketing/utilisateurs_identification.php @@ -0,0 +1,87 @@ +db->query("SELECT user_id FROM auth_user_md5 where matricule=".$_REQUEST["xmat"]); + if ($myrow = mysql_fetch_array($result)) + exit_error(">Le matricule existe déjà dans la table auth_user_md5, refus d'édition."); + $result = $globals->db->query("select * from identification where matricule=".$_REQUEST["xmat"]); + $myrow = mysql_fetch_array($result); + new_admin_page('marketing/utilisateurs_edit.tpl'); + $page->assign('row', $myrow); + $page->run(); + break; + +case "Modifier la base": + // gestion des flags + $flags = (empty($_REQUEST['flag_femmeN']))?"":"femme"; + // on fait la requete + $sql="update identification set prenom='".$_REQUEST["prenomN"]."',nom='".$_REQUEST["nomN"]."',promo=".$_REQUEST["promoN"].",deces='".$_REQUEST["decesN"]."',flags='".$flags."' where matricule=".$_REQUEST["xmat"]; + $globals->db->query($sql); + new_admin_page('marketing/utilisateurs_edit.tpl'); + $page->assign('success',1); + $page->run(); + break; + +case "Inscrire": + $result=$globals->db->query("SELECT user_id FROM auth_user_md5 where matricule=".$_REQUEST["xmat"]); + if ($myrow = mysql_fetch_array($result)) + exit_error("Le matricule existe déjà dans la table auth_user_md5."); + + $result = $globals->db->query("select * from identification where matricule=".$_REQUEST["xmat"]); + $myrow = mysql_fetch_array($result); + new_admin_page('marketing/utilisateurs_inscrire.tpl'); + $page->assign('row', $myrow); + //calcul du login de l'inscrit + $page->assign('mailorg',make_username($myrow['prenom'],$myrow['nom'])); + $page->run(); + break; + +case "Creer le login": + //on commence par vérifier: + // - que le matricule n'existe pas parmi les inscrits + // - que le login n'existe pas déjà + // - que la date de naissance est bien remplie + + $result=mysql_query("SELECT user_id FROM auth_user_md5 where matricule='".$_REQUEST["xmat"]."'"); + if ($myrow = mysql_fetch_array($result)) + exit_error("Le matricule existe déjà dans la table auth_user_md5."); + + $result=mysql_query("SELECT user_id FROM auth_user_md5 where username='".$_REQUEST["mailorg"]."'"); + if ($myrow = mysql_fetch_array($result)) + exit_error("Le login existe déjà dans la table auth_user_md5."); + + $naissance=(isset($_REQUEST['naissance']))?$naissance:0; + + // tirage aléatoire de UID et mot de passe + $pass_clair=rand_pass(); + $password=md5($pass_clair); + $date=date("Y-m-j"); + + $sql = "INSERT INTO auth_user_md5 SET username='".$_REQUEST['mailorg']."',matricule='".$_REQUEST['xmat']."',promo='".$_REQUEST['promoN']."',password='$password',nom='".$_REQUEST['nomN']."',prenom='".$_REQUEST['prenomN']."',date='$date',naissance='$naissance', date_ins = NULL"; + $result=$globals->db->query($sql); + + if (!$globals->db->err()) { + $newuid = mysql_insert_id(); + /** inscription à la liste promo ****************/ + $inspromo = inscription_liste_promo($newuid,$_REQUEST['promoN']); + /** inscription à la newsletter ***************/ + $insnewsletter = inscription_newsletter($newuid); + + // pas d'erreur pour l'insert + new_admin_page('marketing/utilisateurs_inscrire.tpl'); + $page->assign('mailorg',$_REQUEST['mailorg']); + $page->assign('pass_clair',$pass_clair); + $page->assign('success',1); + $page->run(); + } else { + exit_error("Une erreur s'est produite lors de la tentative d'insertion."); + } + break; +} +?> diff --git a/htdocs/marketing/utilisateurs_marketing.php b/htdocs/marketing/utilisateurs_marketing.php index a990bf5..73cb9b9 100644 --- a/htdocs/marketing/utilisateurs_marketing.php +++ b/htdocs/marketing/utilisateurs_marketing.php @@ -1,62 +1,7 @@ run(); - } - - if (!empty($_REQUEST["xmat"])) { - // on a un matricule, on affiche juste l'entrée correspondante - $where = "id.matricule={$_REQUEST['xmat']}"; - } else { - // on n'a pas le matricule, essayer de le trouver moi-meme, de le proposer - // et de reafficher le formulaire avec les propositions de matricules - - // suppression accents et passage en majuscules des champs entrés - $nomUS=replace_accent($_REQUEST["nomR"]); - $nomup=strtoupper($nomUS); - $nomup=str_replace("\'","'",$nomup); - $prenomUS=replace_accent($_REQUEST["prenomR"]); - $prenomup=strtoupper($prenomUS); - $prenomup=str_replace("\'","'",$prenomup); - - // calcul de la plus longue chaine servant à l'identification - $chaine1=strtok($nomup," -'"); - $chaine2=strtok(" -'"); - if ( strlen($chaine2) > strlen($chaine1) ) { - $chaine = $chaine2; - } else { - $chaine = $chaine1; - } - - if(strlen($_REQUEST["promoR"])==4) { - $rq="AND id.promo=".$_REQUEST["promoR"]; - } else { - $rq=""; - } - - $where = "id.prenom LIKE '%{$_REQUEST['prenomR']}%' AND id.nom LIKE '%$chaine%' $rq ORDER BY id.promo,id.nom"; - } // a-t-on xmat - - $sql = "SELECT id.*,user_id - FROM identification AS id - LEFT JOIN auth_user_md5 USING(matricule) - WHERE user_id IS NULL AND $where"; - - new_admin_page('marketing/utilisateurs_select.tpl'); - $page->mysql_assign($sql, 'nonins'); - $page->assign('id_actions', array('Mailer')); - $page->run(); -} - -function exit_error($err) { - global $page; - new_admin_page('marketing/utilisateurs_recherche.tpl'); - $page->assign('err', $err); - $page->run(); -} +$id_actions = array('Mailer'); +require("select_user.inc.php"); //actions possible une fois un X désigné par son matricule switch ($_REQUEST["submit"]) { diff --git a/include/select_user.inc.php b/include/select_user.inc.php new file mode 100644 index 0000000..506dadb --- /dev/null +++ b/include/select_user.inc.php @@ -0,0 +1,58 @@ +run(); + } + + if (!empty($_REQUEST["xmat"])) { + // on a un matricule, on affiche juste l'entrée correspondante + $where = "id.matricule={$_REQUEST['xmat']}"; + } else { + // on n'a pas le matricule, essayer de le trouver moi-meme, de le proposer + // et de reafficher le formulaire avec les propositions de matricules + + // suppression accents et passage en majuscules des champs entrés + $nomUS=replace_accent($_REQUEST["nomR"]); + $nomup=strtoupper($nomUS); + $nomup=str_replace("\'","'",$nomup); + $prenomUS=replace_accent($_REQUEST["prenomR"]); + $prenomup=strtoupper($prenomUS); + $prenomup=str_replace("\'","'",$prenomup); + + // calcul de la plus longue chaine servant à l'identification + $chaine1=strtok($nomup," -'"); + $chaine2=strtok(" -'"); + if ( strlen($chaine2) > strlen($chaine1) ) { + $chaine = $chaine2; + } else { + $chaine = $chaine1; + } + + if(strlen($_REQUEST["promoR"])==4) { + $rq="AND id.promo=".$_REQUEST["promoR"]; + } else { + $rq=""; + } + + $where = "id.prenom LIKE '%{$_REQUEST['prenomR']}%' AND id.nom LIKE '%$chaine%' $rq ORDER BY id.promo,id.nom"; + } // a-t-on xmat + + $sql = "SELECT id.*,user_id + FROM identification AS id + LEFT JOIN auth_user_md5 USING(matricule) + WHERE user_id IS NULL AND $where"; + + new_admin_page('marketing/utilisateurs_select.tpl'); + $page->mysql_assign($sql, 'nonins'); + $page->assign('id_actions', $id_actions); + $page->run(); +} + +function exit_error($err) { + global $page; + new_admin_page('marketing/utilisateurs_recherche.tpl'); + $page->assign('err', $err); + $page->run(); +} +?> diff --git a/templates/marketing/utilisateurs_edit.tpl b/templates/marketing/utilisateurs_edit.tpl new file mode 100644 index 0000000..fbeb74d --- /dev/null +++ b/templates/marketing/utilisateurs_edit.tpl @@ -0,0 +1,70 @@ +
+ Editer la base de tous les X +
+{dynamic} +{if $success eq "1"} +

+ La modification de la table identification a été effectuée. +

+

+ Retour +

+{else} +

+ Attention la table d'identification contenant la liste des polytechniciens sera +modifiée !! (aucune vérification n'est faite) +

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Editer +
Prénom : + +
Nom : + +
Femme : + +
Promo : + +
Décés : + +
+ Voir sa fiche sur le site de l'AX +
+ + +
+
+
+{/if} +{/dynamic} diff --git a/templates/marketing/utilisateurs_inscrire.tpl b/templates/marketing/utilisateurs_inscrire.tpl new file mode 100644 index 0000000..94e3022 --- /dev/null +++ b/templates/marketing/utilisateurs_inscrire.tpl @@ -0,0 +1,69 @@ +
+ Inscrire manuellement un X +
+{dynamic} +{if $success eq "1"} +

+ Paramètres à transmettre:
+ Login={$mailorg}
+ Password={$pass_clair} +

+

+ Pour éditer le profil, + clique sur ce lien. +

+{else} +

+ Les prénom, nom, promo sont pré-remplis suivant la table d'identification. + Modifie-les comme tu le souhaites. Une autre solution consiste à éditer + d'abord la table d'identification (écran précédent) avant d'inscrire cet X. +

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Créer un login +
Prénom d'inscription + +
Nom d'inscription + +
Promotion + +
Login + +
Date de naissance + +
+ + +
+
+
+{/if} +{/dynamic} -- 2.1.4