From 9e570fe0de461eec909a72655e4ba6429378bdec Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Thu, 27 Jul 2006 14:13:10 +0000 Subject: [PATCH] Close #429: tools to store informations about duplicated adresses git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@678 839d8a87-29fc-0310-9880-83ba4fa771e5 --- ChangeLog | 1 + bin/cron/emails.check.php | 2 +- htdocs/images/icons/page_edit.gif | Bin 0 -> 1352 bytes modules/email.php | 93 ++++++++++++++++++++++++++++ templates/admin/index.tpl | 2 + templates/admin/wiki.tpl | 2 +- templates/emails/duplicated.tpl | 127 ++++++++++++++++++++++++++++++++++++++ templates/table-editor.tpl | 2 +- 8 files changed, 226 insertions(+), 3 deletions(-) create mode 100644 htdocs/images/icons/page_edit.gif create mode 100644 templates/emails/duplicated.tpl diff --git a/ChangeLog b/ChangeLog index a5f7e32..22a5acd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -76,6 +76,7 @@ Bug/Wish: * Admin: - #430: Specify date format on downtime admin page. -Car - #397: Can edit death date in user admin page -FRU + - #429: Tools to administrate duplicated adresses -FRU * Carnet: - #435: Calendar contains yearly events for all the contacts. -FRU diff --git a/bin/cron/emails.check.php b/bin/cron/emails.check.php index fc9322c..3762c7b 100755 --- a/bin/cron/emails.check.php +++ b/bin/cron/emails.check.php @@ -46,7 +46,7 @@ while (list($alias1, $alias2, $mail) = $it->next()) { if (count($conflits) > 0) { echo "Nouvelles adresses en doublon détectées :\n" . join("\n", $conflits) . "\n\nVous pouvez entrer les informations collectées à ce sujet sur la page :\n" - . "http://www.polytechnique.org/admin/doublons"; + . "http://www.polytechnique.org/admin/emails/duplicated"; echo "\n\n"; $sql = "INSERT IGNORE INTO emails_watch (email, state, detection, last) diff --git a/htdocs/images/icons/page_edit.gif b/htdocs/images/icons/page_edit.gif new file mode 100644 index 0000000000000000000000000000000000000000..9f6eb3b84768bf1b06bffce691c43e93f840bcb9 GIT binary patch literal 1352 zcmcJPe`p(39KgSc-2!P>Gdo?JZeI4IO*NZo%es`!?Y6MyvJSn}!O|+>(lj=OEbV$?VM7ZP@>zoZ0QwZ$hK7|AZl9@BD9GsO`Do#gPrC&uH9YmB>RT&_Dj<+ASZ>D-Jn7cq_&Thp^eX4uS# zP3KEF)&QrNnv)flHD5Rg@bpOlV`$Cy zFx75~=b4q#TSKhTOgvpj0M^}awI22Y_|5@5sl2!B5oO5B~^K?k%=$A+>-+m(T0FaXBK1LSqHC!4Y^Fc` zn(sn9zJKz?9mhP2+J);MKR>oH@y5R8w2yC$i^A(~ZrQ5yw>}MQ>pVXA%HFG~uXxls z+>zYry)!y`blp=c-*Ov*i^0^<@1vcs9!PTCsnyJV{$S(<|M0d$-M;j*KbU=qLp^); zJvqFPdT{&e54l}8#L#!%_udZ&9=fu_AKBh`dT1 c=U-fYIh6hRavp8p7%RPNeR22NG7tOz0F6+9BLDyZ literal 0 HcmV?d00001 diff --git a/modules/email.php b/modules/email.php index 1113aa4..0e7a1b4 100644 --- a/modules/email.php +++ b/modules/email.php @@ -30,6 +30,8 @@ class EmailModule extends PLModule 'emails/broken' => $this->make_hook('broken', AUTH_COOKIE), 'emails/redirect' => $this->make_hook('redirect', AUTH_MDP), 'emails/send' => $this->make_hook('send', AUTH_MDP), + + 'admin/emails/duplicated' => $this->make_hook('duplicated', AUTH_MDP, 'admin') ); } @@ -375,6 +377,97 @@ L' } } } + + function handler_duplicated(&$page, $action = 'list', $email = null) + { + $page->changeTpl('emails/duplicated.tpl'); + + $states = array('pending' => 'En attente...', + 'safe' => 'Pas d\'inquiétude', + 'unsafe' => 'Recherches en cours', + 'dangerous' => 'Usurpations par cette adresse'); + $page->assign('states', $states); + + switch (Post::v('action')) { + case 'create': + if (trim(Post::v('emailN')) != '') { + Xdb::execute('INSERT IGNORE INTO emails_watch (email, state, detection, last, uid, description) + VALUES ({?}, {?}, CURDATE(), NOW(), {?}, {?})', + trim(Post::v('emailN')), Post::v('stateN'), S::i('uid'), Post::v('descriptionN')); + }; + break; + + case 'edit': + Xdb::execute('UPDATE emails_watch + SET state = {?}, last = NOW(), uid = {?}, description = {?} + WHERE email = {?}', Post::v('stateN'), S::i('uid'), Post::v('descriptionN'), Post::v('emailN')); + break; + + default: + if ($action == 'delete' && !is_null($email)) { + Xdb::execute('DELETE FROM emails_watch WHERE email = {?}', $email); + } + } + if ($action != 'create' && $action != 'edit') { + $action = 'list'; + } + $page->assign('action', $action); + + if ($action == 'list') { + $sql = "SELECT w.email, w.detection, w.state, a.alias AS forlife + FROM emails_watch AS w + INNER JOIN emails AS e USING(email) + INNER JOIN aliases AS a ON (a.id = e.uid AND a.type = 'a_vie') + ORDER BY w.state, w.email, a.alias"; + $it = Xdb::iterRow($sql); + + $table = array(); + $props = array(); + while (list($email, $date, $state, $forlife) = $it->next()) { + if (count($props) == 0 || $props['mail'] != $email) { + if (count($props) > 0) { + $table[] = $props; + } + $props = array('mail' => $email, + 'detection' => $date, + 'state' => $state, + 'users' => array($forlife)); + } else { + $props['users'][] = $forlife; + } + } + if (count($props) > 0) { + $table[] = $props; + } + $page->assign('table', $table); + } elseif ($action == 'edit') { + $sql = "SELECT w.detection, w.state, w.last, w.description, + a1.alias AS edit, a2.alias AS forlife + FROM emails_watch AS w + INNER JOIN emails AS e USING(email) + LEFT JOIN aliases AS a1 ON (a1.id = w.uid AND a1.type = 'a_vie') + INNER JOIN aliases AS a2 ON (a2.id = e.uid AND a2.type = 'a_vie') + WHERE w.email = {?} + ORDER BY a2.alias"; + $it = Xdb::iterRow($sql, $email); + + $props = array(); + while (list($detection, $state, $last, $description, $edit, $forlife) = $it->next()) { + if (count($props) == 0) { + $props = array('mail' => $email, + 'detection' => $detection, + 'state' => $state, + 'last' => $last, + 'description' => $description, + 'edit' => $edit, + 'users' => array($forlife)); + } else { + $props['users'][] = $forlife; + } + } + $page->assign('doublon', $props); + } + } } ?> diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index 6515294..5abbc8a 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -42,6 +42,8 @@ Logs des sessions   |   Actions +   |   + Doublons diff --git a/templates/admin/wiki.tpl b/templates/admin/wiki.tpl index 5548d4d..84204d0 100644 --- a/templates/admin/wiki.tpl +++ b/templates/admin/wiki.tpl @@ -57,7 +57,7 @@ {foreach from=$wiki_pages item=perm key=page} - {$page} {icon name=date_edit title='éditer'} + {$page} {icon name=page_edit title='éditer'} {$perm.read} diff --git a/templates/emails/duplicated.tpl b/templates/emails/duplicated.tpl new file mode 100644 index 0000000..4091cf9 --- /dev/null +++ b/templates/emails/duplicated.tpl @@ -0,0 +1,127 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2006 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* 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 *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +

Gestion des adresses en doublon

+ +{if $action eq "list"} + + + + + + + + + + + + + {foreach from=$table item=doublon} + + + + + + + {/foreach} +
AdresseEtatUtilisateurs
+ Ajouter une entrée manuellement + + créer{icon name=add} +
+ {$doublon.mail}
+ Détecté le {$doublon.detection|date_format} +
+ {$doublon.state} + + {foreach from=$doublon.users item=user name=all} + {$user}{icon name=user_suit title="Fiche"} + {icon name=wrench title="Administrer}{if !$smarty.foreach.all.last}
{/if} + {/foreach} +
+ {icon name=page_edit title="Editer"} + {icon name=delete title="Supprimer"} +
+{elseif $action eq "create" || $action eq "edit"} +[Retour à la liste des doublons]

+
+ + + + + + + {if $action eq "create"} + + {else} + + {foreach from=$doublon.users key=i name=all item=user} + {if $i is even}{/if} + + {if $i is even && $smarty.foreach.all.last}{/if} + {if $id is odd || $smarty.foreach.all.last}{/if} + {/foreach} + + + + + {/if} + + + + + + + + + + + + + + +
Commenter le doublon
Adresse mail + {icon name=email title="Envoyer un mail"} +  {$doublon.mail} + +
+ {$user}{icon name=user_suit title="Fiche"} + {icon name=wrench title="Administrer}{if !$smarty.foreach.all.last}
{/if} +
Date de détection{$doublon.detection|date_format}
Danger + +
+ Description
+ {if $doublon.edit}Dernière édition par {$doublon.edit} le {$doublon.last|date_format}{/if} +
+ +
+ + +
+
+{/if} + +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/table-editor.tpl b/templates/table-editor.tpl index 6601c7d..392c55a 100644 --- a/templates/table-editor.tpl +++ b/templates/table-editor.tpl @@ -61,7 +61,7 @@ {if !$hideactions} {if !$readonly} - {icon name=date_edit title='éditer'} + {icon name=page_edit title='éditer'} {icon name=delete title='supprimer'} {/if} -- 2.1.4