From ddc2e70057072df5d5e1a867e4ed50ef9ac8be69 Mon Sep 17 00:00:00 2001 From: Sebastian Marcet Date: Fri, 18 Aug 2017 10:58:54 -0300 Subject: [PATCH] [smarcet] - #13179 * tweaks on individual speaker announcement email task --- ...erSelectionAnnouncementEmailSenderTask.php | 26 ++++++++++++------- .../presentations/PresentationSpeaker.php | 12 +++++++++ summit/code/models/IPresentationSpeaker.php | 6 +++++ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/summit/code/cron_tasks/IndividualSpeakerSelectionAnnouncementEmailSenderTask.php b/summit/code/cron_tasks/IndividualSpeakerSelectionAnnouncementEmailSenderTask.php index b272dd2dd..e6be31326 100644 --- a/summit/code/cron_tasks/IndividualSpeakerSelectionAnnouncementEmailSenderTask.php +++ b/summit/code/cron_tasks/IndividualSpeakerSelectionAnnouncementEmailSenderTask.php @@ -39,10 +39,20 @@ public function run() $init_time = time(); $summit = null; $speaker = null; - $role = IPresentationSpeaker::RoleSpeaker; - if (isset($_GET['member_id'])) + + if (isset($_GET['email'])) { - $speaker = PresentationSpeaker::get()->filter("MemberID", $_GET['member_id'])->first(); + $email = $_GET['email']; + $speaker = PresentationSpeaker::get() + ->innerJoin("Member", "Member.ID = PresentationSpeaker.MemberID" ) + ->where("Member.Email = '{$email}' ") + ->first(); + if(is_null($speaker)){ + $speaker = PresentationSpeaker::get() + ->innerJoin("SpeakerRegistrationRequest", "SpeakerRegistrationRequest.ID = PresentationSpeaker.RegistrationRequestID" ) + ->where("SpeakerRegistrationRequest.Email = '{$email}' ") + ->first(); + } } if (isset($_GET['summit_id'])) @@ -50,14 +60,10 @@ public function run() $summit = Summit::get()->byID(intval($_GET['summit_id'])); } - if (isset($_GET['role'])) - { - if($_GET['role'] == 2) - $role = IPresentationSpeaker::RoleModerator; - } - if(is_null($summit)) throw new Exception('summit_id is not valid!'); - if(is_null($speaker)) throw new Exception('member_id is not valid!'); + if(is_null($speaker)) throw new Exception('speaker is not valid!'); + + $role = $speaker->isModeratorFor($summit) ? IPresentationSpeaker::RoleModerator : IPresentationSpeaker::RoleSpeaker; echo sprintf("sending individual mail for %s speaker as role %s", $speaker->getEmail(), $role).PHP_EOL; diff --git a/summit/code/infrastructure/active_records/events/presentations/PresentationSpeaker.php b/summit/code/infrastructure/active_records/events/presentations/PresentationSpeaker.php index a9dc94cdc..e984003c3 100644 --- a/summit/code/infrastructure/active_records/events/presentations/PresentationSpeaker.php +++ b/summit/code/infrastructure/active_records/events/presentations/PresentationSpeaker.php @@ -916,6 +916,18 @@ public function AlternatePresentations return $alternatePresentations; } + /** + * @param ISummit $summit + * @return bool + */ + public function isModeratorFor(ISummit $summit){ + $filters = [ + 'SummitEvent.SummitID' => $summit->ID, + 'ModeratorID' => $this->ID + ]; + return Presentation::get()->filter($filters)->count() > 0; + } + /** * @param int $summit_id * @return string diff --git a/summit/code/models/IPresentationSpeaker.php b/summit/code/models/IPresentationSpeaker.php index 05da1f9cb..9747a6f47 100644 --- a/summit/code/models/IPresentationSpeaker.php +++ b/summit/code/models/IPresentationSpeaker.php @@ -480,4 +480,10 @@ public function hasRejectedPresentations array $excluded_tracks = [] ); + /** + * @param ISummit $summit + * @return bool + */ + public function isModeratorFor(ISummit $summit); + } \ No newline at end of file