From bc0276a2d79d88a56656514fe24bd427c0ef3b88 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Mon, 14 Oct 2013 19:19:36 +0200 Subject: [PATCH] Find corps field in profile educations when processing broken emails. The process of the borken emails produces a CSV file with a "corps" field to help finding a working email address. As $profile->getCorps() is often empty, this field can be field with the corps education found in $profile->getExtraEducations(), if it exists. Signed-off-by: Nicolas Iooss --- classes/profile.php | 28 ++++++++++++++++++++++++++++ modules/email.php | 3 +-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index bb4d2bf..0f5eb73 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -731,6 +731,34 @@ class Profile implements PlExportable return $this->corps; } + /** + * Retrieve the name of the corps which has been done. + * + * Note: this function first tries getCorps(), and if this field is blank + * tries to find an education which degree is "Corps". + * + * Returns an empty string if nothing has been found. + */ + public function getCorpsName() + { + $corps = $this->getCorps(); + if ($corps && $corps->current) { + $corpsList = DirEnum::getOptions(DirEnum::CURRENTCORPS); + return $corpsList[$corps->current]; + } + + foreach ($this->getExtraEducations() as $edu) { + if (!strcasecmp($edu->degree, 'Corps')) { + if ($edu->school_short) { + return $edu->school_short; + } elseif ($edu->school) { + return $edu->school; + } + } + } + return ''; + } + /** Networking */ private $networks = null; diff --git a/modules/email.php b/modules/email.php index 6402337..e7f1e28 100644 --- a/modules/email.php +++ b/modules/email.php @@ -891,8 +891,7 @@ class EmailModule extends PLModule $corpsList = DirEnum::getOptions(DirEnum::CURRENTCORPS); foreach ($broken_user_list as $uid => $mails) { $profile = Profile::get($uid); - $corps = $profile->getCorps(); - $current_corps = ($corps && $corps->current) ? $corpsList[$corps->current] : ''; + $current_corps = $profile->getCorpsName(); $jobs = $profile->getJobs(); $companies = array(); foreach ($jobs as $job) { -- 2.1.4