* 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
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)
'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')
);
}
}
}
}
+
+ 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);
+ }
+ }
}
?>
<a href="admin/logger">Logs des sessions</a>
|
<a href="admin/logger/actions">Actions</a>
+ |
+ <a href="admin/emails/duplicated">Doublons</a>
</td>
</tr>
</table>
{foreach from=$wiki_pages item=perm key=page}
<tr class="{cycle values="impair,pair"}">
<td>
- <a href="{$page|replace:'.':'/'}">{$page}</a> <a href="{$page|replace:'.':'/'}?action=edit" class="indice">{icon name=date_edit title='éditer'}</a>
+ <a href="{$page|replace:'.':'/'}">{$page}</a> <a href="{$page|replace:'.':'/'}?action=edit" class="indice">{icon name=page_edit title='éditer'}</a>
</td>
<td class="center">
{$perm.read}
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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 *}
+{* *}
+{**************************************************************************}
+
+<h1>Gestion des adresses en doublon</h1>
+
+{if $action eq "list"}
+<table class="bicol">
+ <tr>
+ <th>Adresse</th>
+ <th>Etat</th>
+ <th>Utilisateurs</th>
+ <th></th>
+ </tr>
+ <tr>
+ <tr class="impair">
+ <td colspan="2">
+ <strong>Ajouter une entrée manuellement</strong>
+ </td>
+ <td colspan="2" class="right">
+ <strong><a href="admin/emails/duplicated/create">créer{icon name=add}</a></strong>
+ </td>
+ </tr>
+ {foreach from=$table item=doublon}
+ <tr class="{cycle values="pair,impair"}">
+ <td>
+ <strong>{$doublon.mail}</strong><br />
+ Détecté le {$doublon.detection|date_format}
+ </td>
+ <td>
+ {$doublon.state}
+ </td>
+ <td class="right">
+ {foreach from=$doublon.users item=user name=all}
+ <a href="profile/{$user}">{$user}{icon name=user_suit title="Fiche"}</a>
+ <a href="admin/user/{$user}">{icon name=wrench title="Administrer}</a>{if !$smarty.foreach.all.last}<br />{/if}
+ {/foreach}
+ </td>
+ <td class="right">
+ <a href="admin/emails/duplicated/edit/{$doublon.mail}">{icon name=page_edit title="Editer"}</a>
+ <a href="admin/emails/duplicated/delete/{$doublon.mail}">{icon name=delete title="Supprimer"}</a>
+ </td>
+ </tr>
+ {/foreach}
+</table>
+{elseif $action eq "create" || $action eq "edit"}
+[<a href="admin/emails/duplicated">Retour à la liste des doublons</a>]<br /><br />
+<form method="post" action="admin/emails/duplicated">
+<table class="tinybicol">
+ <tr>
+ <th colspan="2"><strong>Commenter le doublon</strong></th>
+ </tr>
+ <tr class="impair">
+ <td class="title"><strong>Adresse mail</strong></td>
+ {if $action eq "create"}
+ <td><input type="text" name="emailN" /></td>
+ {else}
+ <td>
+ <a href="mailto:{$doublon.mail}">{icon name=email title="Envoyer un mail"}</a>
+ {$doublon.mail}
+ <input type="hidden" name="emailN" value="{$doublon.mail}" />
+ </td>
+ {foreach from=$doublon.users key=i name=all item=user}
+ {if $i is even}<tr class="impair">{/if}
+ <td>
+ <a href="profile/{$user}">{$user}{icon name=user_suit title="Fiche"}</a>
+ <a href="admin/user/{$user}">{icon name=wrench title="Administrer}</a>{if !$smarty.foreach.all.last}<br />{/if}
+ </td>
+ {if $i is even && $smarty.foreach.all.last}<td></td>{/if}
+ {if $id is odd || $smarty.foreach.all.last}</tr>{/if}
+ {/foreach}
+ </tr>
+ <tr class="pair">
+ <td class="title"><strong>Date de détection</strong></td>
+ <td>{$doublon.detection|date_format}</td>
+ {/if}
+ </tr>
+ <tr class="pair">
+ <td class="title"><strong>Danger</strong></td>
+ <td>
+ <select name="stateN">
+ {foreach from=$states key=state item=text}
+ <option value="{$state}"{if $doublon.state eq $state} selected="selected"{/if}>{$text}</option>
+ {/foreach}
+ </select>
+ </td>
+ </tr>
+ <tr class="impair">
+ <td colspan="2" class="title">
+ <strong>Description</strong><br/>
+ {if $doublon.edit}<small>Dernière édition par {$doublon.edit} le {$doublon.last|date_format}</small>{/if}
+ </td>
+ </tr>
+ <tr class="impair">
+ <td colspan="2" class="center">
+ <textarea cols="50" rows="10" name="descriptionN">{$doublon.description}</textarea>
+ </td>
+ </tr>
+ <tr>
+ <th colspan="2">
+ <input type="hidden" name="action" value="{$action}" />
+ <input type="submit" name="valid" value="Valider" />
+ </th>
+ </tr>
+</table>
+</form>
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2: *}
{if !$hideactions}
<td class="action">
{if !$readonly}
- <a href="{$t->pl}/edit/{$idval}">{icon name=date_edit title='éditer'}</a>
+ <a href="{$t->pl}/edit/{$idval}">{icon name=page_edit title='éditer'}</a>
<a href="{$t->pl}/delete/{$idval}">{icon name=delete title='supprimer'}</a>
{/if}
</td>