From e153e57a59576be2652bb4dd49d3668757a219ae Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Wed, 9 Apr 2014 22:56:16 +0200 Subject: [PATCH] admin/emails/broken: Sort lines of the produced CSV Sort these lines by (promo, sortname) instead of email address. --- modules/email.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/email.php b/modules/email.php index 360c462..f6ad6b2 100644 --- a/modules/email.php +++ b/modules/email.php @@ -907,6 +907,14 @@ class EmailModule extends PLModule WHERE flags = \'active\' AND broken_level = 1 AND DATE_ADD(last, INTERVAL 1 YEAR) < CURDATE()'); + // Sort $broken_user_list with (promo, sortname, pid) + $sortable_array = array(); + foreach ($broken_user_list as $pid => $mails) { + $profile = $broken_user_profiles[$pid]; + $sortable_array[$pid] = array($profile->promo(), $profile->sortName(), $pid); + } + asort($sortable_array); + // Output the list of users with recently broken addresses, // along with the count of valid redirections. pl_cached_content_headers('text/x-csv', 1); @@ -914,7 +922,8 @@ class EmailModule extends PLModule $csv = fopen('php://output', 'w'); fputcsv($csv, array('nom', 'promo', 'bounces', 'nbmails', 'url', 'corps', 'job', 'networking'), ';'); $corpsList = DirEnum::getOptions(DirEnum::CURRENTCORPS); - foreach ($broken_user_list as $pid => $mails) { + foreach (array_keys($sortable_array) as $pid) { + $mails = $broken_user_list[$pid]; $profile = $broken_user_profiles[$pid]; $current_corps = $profile->getCorpsName(); $jobs = $profile->getJobs(); -- 2.1.4