Skip to content

Commit

Permalink
[smarcet] - #13179
Browse files Browse the repository at this point in the history
* tweaks on individual speaker announcement email task
  • Loading branch information
smarcet committed Aug 18, 2017
1 parent 1b86918 commit ddc2e70
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,31 @@ 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']))
{
$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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions summit/code/models/IPresentationSpeaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,4 +480,10 @@ public function hasRejectedPresentations
array $excluded_tracks = []
);

/**
* @param ISummit $summit
* @return bool
*/
public function isModeratorFor(ISummit $summit);

}

0 comments on commit ddc2e70

Please sign in to comment.