From: Stéphane Jacob Date: Sun, 17 Oct 2010 20:22:31 +0000 (+0200) Subject: Finishes pages to fix merge related possible errors. X-Git-Tag: xorg/1.0.1~35 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=12419b5b97c1bc6a4fd06818b2e66fbefe5e5d00;p=platal.git Finishes pages to fix merge related possible errors. Signed-off-by: Stéphane Jacob --- diff --git a/modules/fusionax.php b/modules/fusionax.php index dfde915..848bc27 100644 --- a/modules/fusionax.php +++ b/modules/fusionax.php @@ -34,28 +34,23 @@ class FusionAxModule extends PLModule function handlers() { if (Platal::globals()->merge->state == 'pending') { - $auth = 'admin'; + return array( + 'fusionax' => $this->make_hook('index', AUTH_MDP, 'admin'), + 'fusionax/import' => $this->make_hook('import', AUTH_MDP, 'admin'), + 'fusionax/view' => $this->make_hook('view', AUTH_MDP, 'admin'), + 'fusionax/ids' => $this->make_hook('ids', AUTH_MDP, 'admin'), + 'fusionax/deceased' => $this->make_hook('deceased', AUTH_MDP, 'admin'), + 'fusionax/promo' => $this->make_hook('promo', AUTH_MDP, 'admin'), + 'fusionax/names' => $this->make_hook('names', AUTH_MDP, 'admin') + ); } elseif (Platal::globals()->merge->state == 'done') { - $auth = 'admin,edit_directory'; + return array( + 'fusionax' => $this->make_hook('index', AUTH_MDP, 'admin,edit_directory'), + 'fusionax/issues' => $this->make_hook('issues', AUTH_MDP, 'admin,edit_directory'), + 'fusionax/issues/deathdate' => $this->make_hook('issues_deathdate', AUTH_MDP, 'admin,edit_directory'), + 'fusionax/issues/promo' => $this->make_hook('issues_promo', AUTH_MDP, 'admin,edit_directory'), + ); } - - return array( - 'fusionax' => $this->make_hook('index', AUTH_MDP, $auth), - 'fusionax/import' => $this->make_hook('import', AUTH_MDP, 'admin'), - 'fusionax/view' => $this->make_hook('view', AUTH_MDP, 'admin'), - 'fusionax/ids' => $this->make_hook('ids', AUTH_MDP, 'admin'), - 'fusionax/deceased' => $this->make_hook('deceased', AUTH_MDP, 'admin'), - 'fusionax/promo' => $this->make_hook('promo', AUTH_MDP, 'admin'), - 'fusionax/names' => $this->make_hook('names', AUTH_MDP, 'admin'), - - 'fusionax/deathdate_issues' => $this->make_hook('deathdate_issue', AUTH_MDP, 'admin,edit_directory'), - 'fusionax/promo_issues' => $this->make_hook('promo_issue', AUTH_MDP, 'admin,edit_directory'), - 'fusionax/name_issues' => $this->make_hook('name_issue', AUTH_MDP, 'admin,edit_directory'), - 'fusionax/phone_issues' => $this->make_hook('phone_issue', AUTH_MDP, 'admin,edit_directory'), - 'fusionax/education_issues' => $this->make_hook('education_issue', AUTH_MDP, 'admin,edit_directory'), - 'fusionax/address_issues' => $this->make_hook('address_issue', AUTH_MDP, 'admin,edit_directory'), - 'fusionax/job_issues' => $this->make_hook('job_issue', AUTH_MDP, 'admin,edit_directory'), - ); } @@ -64,6 +59,15 @@ class FusionAxModule extends PLModule if (Platal::globals()->merge->state == 'pending') { $page->changeTpl('fusionax/index.tpl'); } elseif (Platal::globals()->merge->state == 'done') { + $issueList = array( + 'name' => 'noms', + 'job' => 'emplois', + 'address' => 'adresses', + 'promo' => 'promotions', + 'deathdate' => 'dates de décès', + 'phone' => 'téléphones', + 'education' => 'formations', + ); $issues = XDB::rawFetchOneAssoc("SELECT COUNT(*) AS total, SUM(FIND_IN_SET('name', issues)) DIV 1 AS name, SUM(FIND_IN_SET('job', issues)) DIV 2 AS job, @@ -74,8 +78,9 @@ class FusionAxModule extends PLModule SUM(FIND_IN_SET('education', issues)) DIV 7 AS education FROM profile_merge_issues WHERE issues IS NOT NULL OR issues != ''"); - $page->assign('issues', $issues); $page->changeTpl('fusionax/issues.tpl'); + $page->assign('issues', $issues); + $page->assign('issueList', $issueList); } } @@ -569,6 +574,130 @@ class FusionAxModule extends PLModule $page->assign('firstnameIssues', $res->fetchOneCell()); } + + function handler_issues_deathdate(&$page, $action = '') + { + $page->changeTpl('fusionax/deathdate_issues.tpl'); + if ($action == 'edit') { + S::assert_xsrf_token(); + + $issues = XDB::rawIterRow('SELECT p.pid, pd.directory_name, pd.promo, pm.deathdate_ax, p.deathdate + FROM profile_merge_issues AS pm + INNER JOIN profiles AS p ON (pm.pid = p.pid) + INNER JOIN profile_display AS pd ON (pd.pid = p.pid) + WHERE FIND_IN_SET(\'deathdate\', pm.issues) + ORDER BY pd.directory_name'); + while (list($pid, $name, $promo, $deathAX, $deathXorg) = $issues->next()) { + $choiceAX = Post::has('AX_' . $pid); + $choiceXorg = Post::has('XORG_' . $pid); + if (!($choiceAX || $choiceXorg)) { + continue; + } + + if ($choiceAX) { + XDB::execute('UPDATE profiles AS p + INNER JOIN profile_merge_issues AS pm ON (pm.pid = p.pid) + SET p.deathdate = pm.deathdate_ax, p.deathdate_rec = NOW() + WHERE p.pid = {?}', $pid); + } + XDB::execute("UPDATE profile_merge_issues + SET issues = REPLACE(issues, 'deathdate', '') + WHERE pid = {?}", $pid()); + $page->trigSuccess("La date de décès de $name ($promo) a bien été corrigée."); + } + } + + $issues = XDB::rawFetchAllAssoc('SELECT p.pid, p.hrpid, pd.directory_name, pd.promo, pm.deathdate_ax, p.deathdate + FROM profile_merge_issues AS pm + INNER JOIN profiles AS p ON (pm.pid = p.pid) + INNER JOIN profile_display AS pd ON (pd.pid = p.pid) + WHERE FIND_IN_SET(\'deathdate\', pm.issues) + ORDER BY pd.directory_name'); + $page->assign('issues', $issues); + $page->assign('total', count($issues)); + } + + function handler_issues_promo(&$page, $action = '') + { + $page->changeTpl('fusionax/promo_issues.tpl'); + if ($action == 'edit') { + S::assert_xsrf_token(); + + $issues = XDB::rawIterRow('SELECT p.pid, pd.directory_name, pd.promo, pm.entry_year_ax, pe.entry_year, pe.grad_year + FROM profile_merge_issues AS pm + INNER JOIN profiles AS p ON (pm.pid = p.pid) + INNER JOIN profile_display AS pd ON (pd.pid = p.pid) + INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET(\'primary\', pe.flags)) + WHERE FIND_IN_SET(\'promo\', pm.issues) + ORDER BY pd.directory_name'); + while (list($pid, $name, $promo, $deathAX, $deathXorgEntry, $deathXorgGrad) = $issues->next()) { + $choiceXorg = Post::has('XORG_' . $pid); + if (!(Post::has('display_' . $pid) && Post::has('entry_' . $pid) && Post::has('grad_' . $pid))) { + continue; + } + + $display = Post::i('display_' . $pid); + $entry = Post::i('entry_' . $pid); + $grad = Post::i('grad_' . $pid); + if (!(($grad <= $entry + 5 && $grad >= $entry + 3) && ($display >= $entry && $display <= $grad - 3))) { + $page->trigError("La promotion de $name n'a pas été corrigée."); + continue; + } + XDB::execute('UPDATE profile_display + SET promo = {?} + WHERE pid = {?}', 'X' . $display, $pid); + XDB::execute('UPDATE profile_education + SET entry_year = {?}, grad_year = {?} + WHERE pid = {?} AND FIND_IN_SET(\'primary\', flags)', $entry, $grad, $pid); + $page->trigSuccess("La promotion de $name a bien été corrigée."); + } + } + + $issues = XDB::rawFetchAllAssoc('SELECT p.pid, p.hrpid, pd.directory_name, pd.promo, pm.entry_year_ax, pe.entry_year, pe.grad_year + FROM profile_merge_issues AS pm + INNER JOIN profiles AS p ON (pm.pid = p.pid) + INNER JOIN profile_display AS pd ON (pd.pid = p.pid) + INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET(\'primary\', pe.flags)) + WHERE FIND_IN_SET(\'promo\', pm.issues) + ORDER BY pd.directory_name'); + $page->assign('issues', $issues); + $page->assign('total', count($issues)); + } + + function handler_issues(&$page, $action = '') + { + static $issueList = array( + 'name' => 'noms', + 'phone' => 'téléphones', + 'education' => 'formations', + 'address' => 'adresses', + 'job' => 'emplois' + ); + + if (!array_key_exists($action, $issueList)) { + pl_redirect('fusionax'); + } else { + $total = XDB::fetchOneCell('SELECT COUNT(*) + FROM profile_merge_issues + WHERE FIND_IN_SET({?}, issues)', $action); + if ($total == 0) { + pl_redirect('fusionax'); + } + + $issues = XDB::fetchAllAssoc('SELECT p.hrpid, pd.directory_name, pd.promo + FROM profile_merge_issues AS pm + INNER JOIN profiles AS p ON (pm.pid = p.pid) + INNER JOIN profile_display AS pd ON (pd.pid = p.pid) + WHERE FIND_IN_SET({?}, pm.issues) + ORDER BY pd.directory_name + LIMIT 100', $action); + + $page->changeTpl('fusionax/other_issues.tpl'); + $page->assign('issues', $issues); + $page->assign('issue', $issueList[$action]); + $page->assign('total', $total); + } + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/templates/fusionax/deathdate_issues.tpl b/templates/fusionax/deathdate_issues.tpl new file mode 100644 index 0000000..93f3229 --- /dev/null +++ b/templates/fusionax/deathdate_issues.tpl @@ -0,0 +1,59 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2010 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 *} +{* *} +{**************************************************************************} + +

Fusion des annuaires X.org - AX : dates de décès

+ +{if $total > 0} +

+ Il reste {$total} problème{if $total > 1}s{/if} du{if $issues.total > 1}s{/if} à la + fusion des annuaires lié{if $issues.total > 1}s{/if} aux dates de décès à corriger sur les profils : +

+
+ {xsrf_token_field} + + + + + + + + {foreach from=$issues item=profile} + + + + + + + {/foreach} + +
NomDécès XorgDécès AXChoix
+ {$profile.directory_name} ({$profile.promo}) + {$deathdate}{$deathdate_ax} + + - +
+
+{else} +

Il ne reste plus d'erreur liée à la fusion des annuaires concernant les dates de décès !

+{/if} + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/fusionax/issues.tpl b/templates/fusionax/issues.tpl index 54cc91f..fbb274b 100644 --- a/templates/fusionax/issues.tpl +++ b/templates/fusionax/issues.tpl @@ -24,19 +24,16 @@ {if $issues.total > 0}

- Il reste les problèmes suivants dus à la fusion des annuaires à corriger sur les profils : + Il reste {$issues.total} problème{if $issues.total > 1}s{/if} du{if $issues.total > 1}s{/if} à la fusion des annuaires à corriger sur les profils :

{else} -

Il ne reste plus d'erreurs liées à la fusion des annuaires !

+

Il ne reste plus d'erreur liée à la fusion des annuaires !

{/if} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/fusionax/other_issues.tpl b/templates/fusionax/other_issues.tpl new file mode 100644 index 0000000..2911688 --- /dev/null +++ b/templates/fusionax/other_issues.tpl @@ -0,0 +1,39 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2010 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 *} +{* *} +{**************************************************************************} + +

Fusion des annuaires X.org - AX : {$issue}

+ +{if $total > 0} +

+ Il reste {$total} problème{if $total > 1}s{/if} du{if $total > 1}s{/if} à la + fusion des annuaires lié{if $total > 1}s{/if} aux {$issue} à corriger sur les profils : +

+ +{else} +

Il ne reste plus d'erreur liée à la fusion des annuaires concernant les {$issue} !

+{/if} + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/fusionax/promo_issues.tpl b/templates/fusionax/promo_issues.tpl new file mode 100644 index 0000000..4ebc78c --- /dev/null +++ b/templates/fusionax/promo_issues.tpl @@ -0,0 +1,64 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2010 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 *} +{* *} +{**************************************************************************} + +

Fusion des annuaires X.org - AX : promotions

+ +{if $total > 0} +

+ Il reste {$total} problème{if $total > 1}s{/if} du{if $issues.total > 1}s{/if} à la + fusion des annuaires lié{if $issues.total > 1}s{/if} aux promotions à corriger sur les profils : +

+
+ {xsrf_token_field} + + + + + + + + + + + + {foreach from=$issues item=profile} + + + + + + + + + + + {/foreach} + +
NomPromo XorgPromo entrée XorgPromo sortie XorgPromo AXChoix promo affichéeChoix promo entréeChoix promo sortie
+ {$profile.directory_name} + {$profile.promo}{$profile.entry_year}{$profile.grad_year}{$profile.entry_year_ax}
+
+{else} +

Il ne reste plus d'erreur liée à la fusion des annuaires concernant les promotions !

+{/if} + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}