From: Nicolas Iooss Date: Wed, 9 Apr 2014 20:56:16 +0000 (+0200) Subject: admin/emails/broken: Sort lines of the produced CSV X-Git-Tag: xorg/1.1.13~35 X-Git-Url: http://git.polytechnique.org/?p=platal.git;a=commitdiff_plain;h=e153e57a59576be2652bb4dd49d3668757a219ae admin/emails/broken: Sort lines of the produced CSV Sort these lines by (promo, sortname) instead of email address. --- 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();