From 7cbf5d4bde73e077c71205281bbd83bc5687d557 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Fri, 25 May 2007 17:13:19 +0000 Subject: [PATCH] A better admin-action notification email classes/plmailer.php | 5 ++++- modules/admin.php | 18 ++++++++++++++---- templates/admin/mail_intervention.tpl | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1834 839d8a87-29fc-0310-9880-83ba4fa771e5 --- classes/plmailer.php | 5 ++++- modules/admin.php | 18 ++++++++++++++---- templates/admin/mail_intervention.tpl | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/classes/plmailer.php b/classes/plmailer.php index b65d257..15b9705 100644 --- a/classes/plmailer.php +++ b/classes/plmailer.php @@ -63,13 +63,16 @@ class PlMail extends Smarty { $this->assign('mail_part', $version); $text = $this->fetch($this->tpl); + if ($version == 'text') { + return wordwrap($text, 78); + } return $text; } /** used to remove the empty lines due to {from ...}, {to ...} ... functions */ static public function mail_format($output, &$smarty) { - return wordwrap("\n".trim($output)."\n",75); + return "\n".trim($output)."\n"; } static protected function format_addr(&$params) diff --git a/modules/admin.php b/modules/admin.php index 22e6190..d9a7857 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -357,7 +357,7 @@ class AdminModule extends PLModule require_once("user.func.inc.php"); if (S::has('suid')) { - $page->kill("déjà en SUID !!!"); + $page->kill("Déjà en SUID !!!"); } if (Env::has('user_id')) { @@ -505,6 +505,12 @@ class AdminModule extends PLModule break; } + $watch = 'SELECT naissance, deces, password, perms, + prenom, nom, flags, promo, comment + FROM auth_user_md5 + WHERE user_id = ' . $mr['user_id']; + $res = XDB::query($watch); + $old_fields = $res->fetchOneAssoc(); $query = "UPDATE auth_user_md5 SET naissance = '$naiss', deces = '$deces', @@ -519,9 +525,13 @@ class AdminModule extends PLModule if (XDB::execute($query)) { user_reindex($mr['user_id']); + $res = XDB::query($watch); + $new_fields = $res->fetchOneAssoc(); + $mailer = new PlMailer("admin/mail_intervention.tpl"); $mailer->assign("user", S::v('forlife')); - $mailer->assign("query", $query); + $mailer->assign('old', $old_fields); + $mailer->assign('new', $new_fields); $mailer->send(); $page->trig("updaté correctement."); @@ -703,7 +713,7 @@ class AdminModule extends PLModule ORDER BY u.promo,u.nom,u.prenom'); $page->assign('diffs', $res->fetchAllAssoc()); - // gens à l'ax mais pas chez nous + // gens à l'ax mais pas chez nous $res = XDB::query( 'SELECT ia.promo,ia.nom,ia.nom_patro,ia.prenom FROM identification_ax as ia @@ -711,7 +721,7 @@ class AdminModule extends PLModule WHERE u.nom IS NULL'); $page->assign('mank', $res->fetchAllAssoc()); - // gens chez nous et pas à l'ax + // gens chez nous et pas à l'ax $res = XDB::query('SELECT promo,nom,prenom FROM auth_user_md5 WHERE matricule_ax IS NULL'); $page->assign('plus', $res->fetchAllAssoc()); } diff --git a/templates/admin/mail_intervention.tpl b/templates/admin/mail_intervention.tpl index c1526bf..5344930 100644 --- a/templates/admin/mail_intervention.tpl +++ b/templates/admin/mail_intervention.tpl @@ -25,7 +25,18 @@ {from full=#from#} {to addr=#to#} {subject text="INTERVENTION de $user"} -{elseif $mail_part eq 'text'} -{$query|regex_replace:"/[ \t]+/":" "} +{elseif $mail_part eq 'wiki'} +Le profil du camarade {$old.prenom} {$old.nom} ({$old.promo}) a été édité.\\ +Les champs suivants ont été changés : +{foreach from=$old item=value key=field} +{if $value neq $new[$field]} +* '''{$field}''' : {$value} -> {$new[$field]}{/if} +{/foreach} + +Valeur des différents champs : +{foreach from=$old item=value key=field} +* '''{$field}''' : {$value} -> {$new[$field]} +{/foreach} {/if} + {* vim:set et sw=2 sts=2 sws=2: *} -- 2.1.4