/**
  * Sanitise the identifier and populate the variables list
  */
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $slug = singleton('SiteTree')->generateURLSegment($this->Identifier);
     $original_slug = $slug;
     $i = 0;
     while ($t = PermamailTemplate::get()->filter(array("Identifier" => "{$slug}"))->exclude(array("ID" => $this->ID))->first()) {
         $i++;
         $slug = $original_slug . "-{$i}";
     }
     $this->Identifier = $slug;
     $reflector = EmailReflectionTemplate::create();
     $reflector->process($this->Content);
     $vars = array();
     foreach ($reflector->getTopLevelVars() as $var => $type) {
         $vars[$var] = false;
     }
     foreach ($reflector->getTopLevelBlocks() as $block) {
         $vars[$block->getName()] = $block->isLoop();
     }
     // Remove any variables that are no longer in the template
     if ($this->TestVariables()->exists()) {
         $this->TestVariables()->exclude(array('Variable' => array_keys($vars)))->removeAll();
     }
     $currentVars = $this->TestVariables()->column('Variable');
     foreach ($vars as $var => $isList) {
         if (!in_array($var, $currentVars)) {
             $v = PermamailTemplateVariable::create(array('Variable' => $var, 'PermamailTemplateID' => $this->ID, 'List' => $isList));
             $v->write();
         }
     }
 }
    function doUp()
    {
        global $database;
        if (intval(PermamailTemplate::get()->filter('Identifier', MEMBER_REGISTRATION_VERIFICATION_EMAIL_TEMPLATE_ID)->count()) === 0) {
            $email_tpl = PermamailTemplate::create();
            $email_tpl->Identifier = MEMBER_REGISTRATION_VERIFICATION_EMAIL_TEMPLATE_ID;
            $email_tpl->Subject = 'Thank you for becoming an OpenStack Foundation Member';
            $email_tpl->From = '*****@*****.**';
            $email_tpl->Content = '<p>Dear {$Member.FullName}, thank you for joining the OpenStack Foundation.</p><p>IMPORTANT! Please click <a href="{$VerificationLink}">here</a> to complete your registration.</p>';
            $email_tpl->write();
        }
        if (intval(PermamailTemplate::get()->filter('Identifier', MEMBER_REGISTRATION_VERIFIED_EMAIL_TEMPLATE_ID)->count()) === 0) {
            $email_tpl = PermamailTemplate::create();
            $email_tpl->Identifier = MEMBER_REGISTRATION_VERIFIED_EMAIL_TEMPLATE_ID;
            $email_tpl->Subject = 'Thank you for becoming an OpenStack Foundation Member';
            $email_tpl->From = '*****@*****.**';
            $email_tpl->Content = '<p>Dear {$Member.FullName}, thank you for registering with OpenStack.</p>
<div style="font-size: 10px;">
<ul><li>Meet the <a href="http://www.openstack.org/foundation/staff">OpenStack Foundation Staff</a>, the <a href="http://www.openstack.org/foundation/board-of-directors/">Board of Directors</a>, and the <a href="http://www.openstack.org/foundation/technical-committee/">Technical Committee</a>.</li>
<li>Using OpenStack?  <a href="http://openstack.org/user-survey" target="_blank">Take the User Survey</a>.</li>
<li>The latest Summit information is always <a href="http://openstack.org/Summit" target="_blank">available here</a>, including links to video of past sessions.</li>
<li>Ready to contribute to the future of OpenStack? <a href="https://wiki.openstack.org/wiki/How_To_Contribute" target="_blank">Check the how to contribute page </a>.</li>
</ul></div>';
            $email_tpl->write();
        }
    }
 /**
  * @param mixed $subject
  * @throws Exception
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Summit']) || !isset($subject['Name']) || !isset($subject['Email']) || !isset($subject['PromoCode'])) {
         return;
     }
     $summit = $subject['Summit'];
     $name = $subject['Name'];
     $email_address = $subject['Email'];
     $promo_code = $subject['PromoCode'];
     if (!$summit instanceof ISummit) {
         return;
     }
     if (!$promo_code instanceof SummitRegistrationPromoCode) {
         return;
     }
     $email = PermamailTemplate::get()->filter('Identifier', MEMBER_PROMO_CODE_EMAIL)->first();
     if (is_null($email)) {
         throw new Exception(sprintf('Email Template %s does not exists on DB!', MEMBER_PROMO_CODE_EMAIL));
     }
     $email = EmailFactory::getInstance()->buildEmail(MEMBER_NOTIFICATION_PROMO_CODE_EMAIL_FROM, $email_address);
     $schedule_page = SummitAppSchedPage::get()->filter('SummitID', $summit->ID)->first();
     if (is_null($schedule_page)) {
         throw new Exception('Summit Schedule page does not exists!');
     }
     $email->setUserTemplate(MEMBER_PROMO_CODE_EMAIL)->populateTemplate(array('Name' => $name, 'PromoCode' => $promo_code->getCode(), 'Summit' => $summit, 'ScheduleMainPageLink' => $schedule_page->getAbsoluteLiveLink(false)))->send();
 }
 /**
  * @param mixed $subject
  * @throws Exception
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Summit']) || !isset($subject['Speaker']) || !isset($subject['PromoCode'])) {
         return;
     }
     $summit = $subject['Summit'];
     $speaker = $subject['Speaker'];
     $role = $subject['Role'];
     $promo_code = $subject['PromoCode'];
     if (!$speaker instanceof IPresentationSpeaker) {
         return;
     }
     if (!$summit instanceof ISummit) {
         return;
     }
     if (!$promo_code instanceof SpeakerSummitRegistrationPromoCode) {
         return;
     }
     $email = PermamailTemplate::get()->filter('Identifier', PRESENTATION_SPEAKER_ALTERNATE_ONLY_EMAIL)->first();
     if (is_null($email)) {
         throw new Exception(sprintf('Email Template %s does not exists on DB!', PRESENTATION_SPEAKER_ALTERNATE_ONLY_EMAIL));
     }
     $speaker->registerAnnouncementEmailTypeSent(IPresentationSpeaker::AnnouncementEmailAlternate, $summit->ID);
     $email = EmailFactory::getInstance()->buildEmail(PRESENTATION_SPEAKER_NOTIFICATION_ACCEPTANCE_EMAIL_FROM, $speaker->getEmail());
     $schedule_page = SummitAppSchedPage::getBy($summit);
     if (is_null($schedule_page)) {
         throw new Exception('Summit Schedule page does not exists!');
     }
     $email->setUserTemplate(PRESENTATION_SPEAKER_ALTERNATE_ONLY_EMAIL)->populateTemplate(array('Speaker' => $speaker, 'Role' => $role, 'ConfirmationLink' => $speaker->getSpeakerConfirmationLink($summit->ID), 'PromoCode' => $promo_code->getCode(), 'Summit' => $summit, 'ScheduleMainPageLink' => $schedule_page->getAbsoluteLiveLink(false)))->send();
 }
 /**
  * @param mixed $subject
  * @throws Exception
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Summit']) || !isset($subject['Speaker'])) {
         return;
     }
     $summit = $subject['Summit'];
     $speaker = $subject['Speaker'];
     $role = $subject['Role'];
     if (!$speaker instanceof IPresentationSpeaker) {
         return;
     }
     if (!$summit instanceof ISummit) {
         return;
     }
     $email = PermamailTemplate::get()->filter('Identifier', PRESENTATION_SPEAKER_REJECTED_EMAIL)->first();
     if (is_null($email)) {
         throw new Exception(sprintf('Email Template %s does not exists on DB!', PRESENTATION_SPEAKER_REJECTED_EMAIL));
     }
     $speaker->registerAnnouncementEmailTypeSent(IPresentationSpeaker::AnnouncementEmailRejected, $summit->ID);
     $email = EmailFactory::getInstance()->buildEmail(PRESENTATION_SPEAKER_NOTIFICATION_ACCEPTANCE_SUMMIT_SUPPORT, $speaker->getEmail());
     $email->setUserTemplate(PRESENTATION_SPEAKER_REJECTED_EMAIL)->populateTemplate(array('Speaker' => $speaker, 'Role' => $role, 'Summit' => $summit))->send();
 }
 /**
  * @param mixed $subject
  * @throws EntityValidationException
  * @throws NotFoundEntityException
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Summit']) || !isset($subject['Speaker'])) {
         return;
     }
     $summit = $subject['Summit'];
     $speaker = $subject['Speaker'];
     if (!$speaker instanceof IPresentationSpeaker) {
         return;
     }
     if (!$summit instanceof ISummit) {
         return;
     }
     if ($speaker->breakoutEmailAlreadySent($summit->getIdentifier())) {
         throw new EntityValidationException('Speaker Email already Sent!');
     }
     $email = PermamailTemplate::get()->filter('Identifier', PRESENTATION_SPEAKER_SUMMIT_REMINDER_EMAIL)->first();
     if (is_null($email)) {
         throw new NotFoundEntityException(sprintf('Email Template %s does not exists on DB!', PRESENTATION_SPEAKER_SUMMIT_REMINDER_EMAIL));
     }
     $schedule_page = SummitAppSchedPage::get()->filter('SummitID', $summit->getIdentifier())->first();
     if (is_null($schedule_page)) {
         throw new NotFoundEntityException('Summit Schedule page does not exists!');
     }
     $speaker->registerBreakOutSent($summit->getIdentifier(), 'SECOND_BREAKOUT_REMAINDER');
     $email = EmailFactory::getInstance()->buildEmail(null, $speaker->getEmail());
     $email->setUserTemplate(PRESENTATION_SPEAKER_SUMMIT_REMINDER_EMAIL)->populateTemplate(array('Speaker' => $speaker, 'Summit' => $summit, 'ScheduleMainPageLink' => $schedule_page->getAbsoluteLiveLink(false)))->send();
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->add($ddl = new DropdownField('EmailTemplateID', 'Email Template', PermamailTemplate::get()->map('ID', 'Identifier')));
     $ddl->setEmptyString('-- Select an Email Template --');
     return $fields;
 }
 /**
  * @param $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send($subject)
 {
     $email_template = PermamailTemplate::get_by_identifier(SUMMIT_ATTENDEE_CREATE_MEMBERSHIP_INVITATION_EMAIL_TEMPLATE);
     if (is_null($email_template)) {
         return;
     }
     $email = EmailFactory::getInstance()->buildEmail(null, $subject);
     $email->setUserTemplate('summit-attendee-create-membership-invitation')->populateTemplate(array('Email' => $subject, 'Summit' => Summit::get_active()))->send();
 }
 /**
  * @param $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send($subject)
 {
     $email_template = PermamailTemplate::get_by_identifier('summit-attendee-create-membership-invitation');
     if (is_null($email_template)) {
         return;
     }
     $email = EmailFactory::getInstance()->buildEmail(null, $subject);
     $email->setUserTemplate('summit-attendee-create-membership-invitation')->populateTemplate(array('Email' => $subject))->send();
 }
 function doUp()
 {
     if (intval(PermamailTemplate::get()->filter('Identifier', SUMMIT_ATTENDEE_RSVP_EMAIL)->count()) === 0) {
         $email_tpl = PermamailTemplate::create();
         $email_tpl->Identifier = SUMMIT_ATTENDEE_RSVP_EMAIL;
         $email_tpl->Subject = 'OpenStack Summit - Thank you for your RSVP';
         $email_tpl->From = '*****@*****.**';
         $email_tpl->Content = '<p>Thank you for your RSVP to {$Event.Title} at {$Event.getDateNice} . For your convenience, we have added this to My Schedule within the Summit Management tool. Be sure to synch it to your calendar by going <a href="{$ScheduleURL}">here</a>.</p><p>Cheers,</p><p>OpenStack Summit Team</p>';
         $email_tpl->write();
     }
 }
 /**
  * @param $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send($subject)
 {
     if (!$subject instanceof ISummitAttendee) {
         return;
     }
     $email_template = PermamailTemplate::get_by_identifier(SUMMIT_ATTENDEE_CREATED_EMAIL_TEMPLATE);
     if (is_null($email_template)) {
         return;
     }
     $email = EmailFactory::getInstance()->buildEmail(null, $subject->getMember()->getEmail());
     $email->setUserTemplate('summit-attendee-created')->populateTemplate(array('Attendee' => $subject, 'Summit' => Summit::get_active()))->send();
 }
 /**
  * @param mixed $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send($subject)
 {
     if (!$subject instanceof Member) {
         return;
     }
     $email_template = PermamailTemplate::get_by_identifier(MEMBER_REGISTRATION_VERIFIED_EMAIL_TEMPLATE_ID);
     if (is_null($email_template)) {
         return;
     }
     $from = null;
     $email = EmailFactory::getInstance()->buildEmail($from, $subject->Email);
     $email->setUserTemplate(MEMBER_REGISTRATION_VERIFIED_EMAIL_TEMPLATE_ID)->populateTemplate(array('Member' => $subject))->send();
 }
 /**
  * @param mixed $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send($subject)
 {
     if (!$subject instanceof Member) {
         return;
     }
     $email_template = PermamailTemplate::get_by_identifier(MEMBER_REGISTRATION_VERIFICATION_EMAIL_TEMPLATE_ID);
     if (is_null($email_template)) {
         return;
     }
     $from = null;
     $email = EmailFactory::getInstance()->buildEmail($from, $subject->Email);
     $token = $subject->generateEmailVerificationToken();
     $email->setUserTemplate(MEMBER_REGISTRATION_VERIFICATION_EMAIL_TEMPLATE_ID)->populateTemplate(array('Member' => $subject, 'VerificationLink' => sprintf("%smembers/verification/%s", Director::absoluteBaseURL(), $token)))->send();
 }
 function doUp()
 {
     global $database;
     if (intval(PermamailTemplate::get()->filter('Identifier', SUMMIT_ATTENDEE_CREATED_EMAIL_TEMPLATE)->count()) === 0) {
         $email_tpl = PermamailTemplate::create();
         $email_tpl->Identifier = SUMMIT_ATTENDEE_CREATED_EMAIL_TEMPLATE;
         $email_tpl->Subject = 'Thank you for registering or the OpenStack Summit';
         $email_tpl->From = '*****@*****.**';
         $email_tpl->Content = '<p>{$Attendee.Member.FirstName} {$Attendee.Member.Surname},</p><p>Thank you for registering for the OpenStack Summit {$Summit.Title}. Your EventBrite registration has now been associated with your OpenStack Foundation Account. We look forward to seeing you in {$Summit.Month}.</p><p>Thank you,</p><p>OpenStack Summit Team</p>';
         $email_tpl->write();
     }
     if (intval(PermamailTemplate::get()->filter('Identifier', SUMMIT_ATTENDEE_CREATE_MEMBERSHIP_INVITATION_EMAIL_TEMPLATE)->count()) === 0) {
         $email_tpl = PermamailTemplate::create();
         $email_tpl->Identifier = SUMMIT_ATTENDEE_CREATE_MEMBERSHIP_INVITATION_EMAIL_TEMPLATE;
         $email_tpl->Subject = 'Thank you for registering or the OpenStack Summit';
         $email_tpl->From = '*****@*****.**';
         $email_tpl->Content = '<p>Hello,</p><p>Thank you for registering for the OpenStack Summit {$Summit.Title}! We see you do not currently have an OpenStack Community Account or OpenStack Foundation Membership. In order to make the most of your visit, please proceed to https://www.openstack.org/join/register/ to complete your registration on openstack.org. Without this information, you will not have access to the Summit mobile apps.</p><p>Thank you,</p><p>OpenStack Summit Team</p>';
         $email_tpl->write();
     }
 }
 /**
  * @param mixed $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Presentation'])) {
         return;
     }
     $presentation = $subject['Presentation'];
     // check if template exists
     $email_template = PermamailTemplate::get_by_identifier('presentation-moderator-notification');
     if (is_null($email_template)) {
         return;
     }
     $from = null;
     $subject = null;
     $email = EmailFactory::getInstance()->buildEmail($from, $presentation->Creator()->Email, $subject);
     $email->setUserTemplate('presentation-moderator-notification');
     $email->populateTemplate(array('Moderator' => $presentation->Moderator(), 'Summit' => $presentation->Summit(), 'Link' => Director::absoluteBaseURL() . Director::makeRelative($presentation->EditLink()), 'PasswordLink' => Director::absoluteBaseURL() . '/lostpassword'));
     $email->send();
 }
 /**
  * @param mixed $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Speaker'])) {
         return;
     }
     $speaker = $subject['Speaker'];
     // check if template exists
     $email_template = PermamailTemplate::get_by_identifier('presentation-speaker-creation');
     if (is_null($email_template)) {
         return;
     }
     $from = null;
     $subject = null;
     $email = EmailFactory::getInstance()->buildEmail($from, $speaker->getEmail(), $subject);
     $email->setUserTemplate('presentation-speaker-creation');
     $email->populateTemplate(array('Speaker' => $speaker, 'BioLink' => Director::makeRelative($speaker->BioLink())));
     $email->send();
 }
 /**
  * @param mixed $subject
  * @throws InvalidArgumentException
  * @return void
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Presentation']) || !isset($subject['Speaker'])) {
         return;
     }
     $presentation = $subject['Presentation'];
     $speaker = $subject['Speaker'];
     // check if template exists
     $email_template = PermamailTemplate::get_by_identifier('presentation-speaker-notification');
     if (is_null($email_template)) {
         return;
     }
     $from = null;
     $subject = null;
     $email = EmailFactory::getInstance()->buildEmail($from, $speaker->getEmail(), $subject);
     $email->setUserTemplate('presentation-speaker-notification');
     $email->populateTemplate(array('RecipientMember' => $speaker->Member(), 'Presentation' => $presentation, 'Speaker' => $speaker, 'Creator' => $presentation->Creator(), 'EditLink' => Director::makeRelative($speaker->EditLink($presentation->ID)), 'ReviewLink' => Director::makeRelative($speaker->ReviewLink($presentation->ID)), 'PasswordLink' => Director::absoluteBaseURL() . '/lostpassword', 'Link' => Director::absoluteBaseURL() . Director::makeRelative($presentation->EditLink())));
     $email->send();
 }
 /**
  * @param mixed $subject
  * @throws NotFoundEntityException
  * @throws EntityValidationException
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Summit']) || !isset($subject['Speaker'])) {
         return;
     }
     $summit = $subject['Summit'];
     $speaker = $subject['Speaker'];
     $promo_code = $subject['PromoCode'];
     if (!$speaker instanceof IPresentationSpeaker) {
         return;
     }
     if (!$summit instanceof ISummit) {
         return;
     }
     if (!$promo_code instanceof SpeakerSummitRegistrationPromoCode) {
         return;
     }
     if ($speaker->hasConfirmedAssistanceFor($summit->getIdentifier())) {
         throw new EntityValidationException('Speaker Already confirmed Assistance!');
     }
     if ($speaker->breakoutEmailAlreadySent($summit->getIdentifier())) {
         throw new EntityValidationException('Speaker Email already Sent!');
     }
     $email = PermamailTemplate::get()->filter('Identifier', PRESENTATION_SPEAKER_CONFIRM_SUMMIT_ASSISTANCE_EMAIL)->first();
     if (is_null($email)) {
         throw new NotFoundEntityException(sprintf('Email Template %s does not exists on DB!', PRESENTATION_SPEAKER_CONFIRM_SUMMIT_ASSISTANCE_EMAIL));
     }
     $schedule_page = SummitAppSchedPage::get()->filter('SummitID', $summit->getIdentifier())->first();
     if (is_null($schedule_page)) {
         throw new NotFoundEntityException('Summit Schedule page does not exists!');
     }
     $confirmation_link = $speaker->hasAssistanceFor($summit->getIdentifier()) ? $speaker->resetConfirmationLink($summit->getIdentifier()) : $speaker->getSpeakerConfirmationLink($summit->getIdentifier());
     $speaker->registerBreakOutSent($summit->getIdentifier(), 'SECOND_BREAKOUT_REGISTER');
     $email = EmailFactory::getInstance()->buildEmail(null, $speaker->getEmail());
     $email->setUserTemplate(PRESENTATION_SPEAKER_CONFIRM_SUMMIT_ASSISTANCE_EMAIL)->populateTemplate(array('Speaker' => $speaker, 'ConfirmationLink' => $confirmation_link, 'PromoCode' => $promo_code->getCode(), 'Summit' => $summit, 'ScheduleMainPageLink' => $schedule_page->getAbsoluteLiveLink(false)))->send();
 }
 /**
  * @param mixed $subject
  * @throws EntityValidationException
  * @throws NotFoundEntityException
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Summit']) || !isset($subject['Speaker'])) {
         return;
     }
     $summit = $subject['Summit'];
     $speaker = $subject['Speaker'];
     if (!$speaker instanceof IPresentationSpeaker) {
         return;
     }
     if (!$summit instanceof ISummit) {
         return;
     }
     if (!$speaker->hasPendingRegistrationRequest()) {
         throw new EntityValidationException('speaker not has a pending registration request!');
     }
     $email = PermamailTemplate::get()->filter('Identifier', PRESENTATION_SPEAKER_CREATE_MEMBERSHIP_EMAIL)->first();
     if (is_null($email)) {
         throw new NotFoundEntityException(sprintf('Email Template %s does not exists on DB!', PRESENTATION_SPEAKER_CREATE_MEMBERSHIP_EMAIL));
     }
     $schedule_page = SummitAppSchedPage::get()->filter('SummitID', $summit->getIdentifier())->first();
     if (is_null($schedule_page)) {
         throw new NotFoundEntityException('Summit Schedule page does not exists!');
     }
     // reset token ...
     $registration_request = $speaker->RegistrationRequest();
     $token = $registration_request->generateConfirmationToken();
     $registration_request->write();
     $registration_url = Controller::join_links(Director::baseURL(), 'summit-login', 'registration');
     $registration_url = HTTP::setGetVar(SpeakerRegistrationRequest::ConfirmationTokenParamName, $token, $registration_url);
     $speaker->registerCreateMembershipSent();
     $email = EmailFactory::getInstance()->buildEmail(null, $speaker->getEmail());
     $email->setUserTemplate(PRESENTATION_SPEAKER_CREATE_MEMBERSHIP_EMAIL)->populateTemplate(array('Speaker' => $speaker, 'Summit' => $summit, 'RegistrationUrl' => $registration_url))->send();
 }
 /**
  * @param mixed $subject
  * @throws Exception
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Event']) || !isset($subject['Attendee'])) {
         return;
     }
     $event = $subject['Event'];
     $attendee = $subject['Attendee'];
     if (!$attendee instanceof ISummitAttendee) {
         return;
     }
     $email = PermamailTemplate::get()->filter('Identifier', SUMMIT_ATTENDEE_RSVP_EMAIL)->first();
     if (is_null($email)) {
         throw new Exception(sprintf('Email Template %s does not exists on DB!', SUMMIT_ATTENDEE_RSVP_EMAIL));
     }
     $email = EmailFactory::getInstance()->buildEmail(SUMMIT_ATTENDEE_RSVP_EMAIL_FROM, $attendee->getMember()->getEmail());
     $schedule_page = SummitAppSchedPage::get()->filter('SummitID', $event->SummitID)->first();
     if (is_null($schedule_page)) {
         throw new NotFoundEntityException('Summit Schedule page does not exists!');
     }
     $email->setUserTemplate(SUMMIT_ATTENDEE_RSVP_EMAIL)->populateTemplate(array('Event' => $event, 'Attendee' => $attendee, 'ScheduleURL' => $schedule_page->getAbsoluteLiveLink(false)))->send();
 }
    function doUp()
    {
        global $database;
        if (intval(PermamailTemplate::get()->filter('Identifier', PRESENTATION_SPEAKER_CONFIRM_SUMMIT_ASSISTANCE_EMAIL)->count()) === 0) {
            $email_tpl = PermamailTemplate::create();
            $email_tpl->Identifier = PRESENTATION_SPEAKER_CONFIRM_SUMMIT_ASSISTANCE_EMAIL;
            $email_tpl->Subject = 'Register for the OpenStack Summit Austin 2016';
            $email_tpl->From = '*****@*****.**';
            $body = <<<HTML
<html>
<body>
<p>Hello \$Speaker.FirstName \$Speaker.LastName -- </p>
<p>We look forward to you joining us as a speaker for the OpenStack Summit in Austin! April 25th through April 29th.  Please respond to this email with your phone number where you can be reached while onsite.</p>
<p>This email includes important information, including your session details and presentation information so please review it carefully.  Going forward your main contacts (speaker managers) will be Beth Nowak (+1 415.994.8059) and Joe Schlick (+1 415.377.6370). They can be reached at speakersupport@openstack.org and will be able to help you with all of your conference needs. Beth and Joe will be on-site in Austin, Sunday, April 24th through Friday, April 29th to assist you.</p>
<p><b>REGISTRATION & SPEAKER CONFIRMATION</b></p>
<p>If you have not already completed both of these steps, please do so NOW!</p>
<p><b>STEP ONE: Register for the Summit.  Full Access FREE REGISTRATION CODE (IT'S UNIQUE & SINGLE-USE): {\$PromoCode}</b></p>
<p>In order to register for FREE you must use the code no later than April 19th, 2016.</p>
<p>
In Eventbrite there is a blue "Enter Promotional Code" option just above the “Order Now” button, where you may redeem the code for a free registration pass. Please reference this image for clarity:
<a href="https://www.eventbrite.com/e/openstack-summit-april-2016-austin-tickets-19805252042"><img src="https://dl.dropboxusercontent.com/s/m3jivcmfexctqeh/DiscountCodeImageAustin.jpg" alt="discount_code" title="discount code"/></a>
</p>
<p><b>STEP TWO: CONFIRM YOURSELF AS A SPEAKER</b></p>
<p>
Please click this link to confirm your attendance as a speaker: <a href="{\$ConfirmationLink}">\$ConfirmationLink</a>
</p>
<p><b>SESSION INFORMATION</b></p>
<p>Please review the Session Schedule for your Session Date, Time and Room Assignment:</p>
<ul>
<% loop \$Speaker.PublishedPresentations %>
<li><a href="{\$getLink}">\$Title ( \$getDateNice ) - \$getLocationNameNice </a></li>
<% end_loop %>
</ul>
<p><a href={\$ScheduleMainPageLink}">OpenStack Summit Schedule.</a></p>
<p>Also please take a moment to review your speaker information and verify that your name, title and Company are reflected accurately. If your headshot and/or biography do not appear on the schedule or the information is incorrect in any way, you can update your info by logging into your OpenStack Community Member account here: <a href="https://www.openstack.org/profile/speaker">https://www.openstack.org/profile/speaker</a>. We are also able to make the edits for you if needed.</p>
<p>Most sessions are 40 minutes long, with a 10-minute break between sessions. Please arrive to your session room at least 10 minutes prior to the start of your session and please be considerate of other speakers by ending your session on time.</p>
<p><b>PRESENTATION INFORMATION</b></p>
<p>We do not have a speaker ready room so please come prepared with your VGA or DVI compatible laptop with your 16:9 presentations loaded and ready to present. If your laptop needs an adapter to connect via VGA or DVI (i.e. Macs require a dongle), please bring that as well. If you require another type of connection, have a demo, or will use more than one connected device, please notify your speaker manager immediately.</p>
<p>If you have a presentation which requires attendees to download large files to participate in your session, please share your delivery system with the speaker managers so we are able to communicate that information with the attendees.  We suggest you provide a link to files several days prior to the conference.</p>
<p>We will be video recording sessions from a lockdown camera capturing the screen and presenter, and also a hard drive video recorder 1280x720 final resolution which will capture slides and camera in a two up format.  Recordings will be uploaded to OpenStack’s YouTube page and available on the OpenStack Foundation website post event. If you have not already done so, provide a 450 character abstract for YouTube by replying to this email.</p>
<p>Please include your name, title, company name, and title of your presentation in your introductory slide.</p>
<p><b>AV / ROOM SET UP</b></p>
<ul>
<li>**Sessions: small stage with presenter table (highboy), theater style seating for audience</li>
<li>**Workshops: small stage with presenter table (highboy), classroom style seating for audience</li>
<li>**Panels: chairs arranged in semi circle on stage with presenter table (highboy), theater style seating for audience</li>
</ul>
<p>A/V: each room is equipped with a projector (1280x720, 720p) and screen (16:9), DVI & VGA connections at 1920x1080 (capable of scaling if needed), 1 Seamless Switcher, 1 Wireless slide advancer, 3 wireless mics (handheld or lav), 1 Q&A mic set in aisle, 2 computer audio inputs on stage, Ethernet connections on stage, basic stage wash lighting and 1 standard power strip at the 30” cocktail round on stage. There will be an AV Tech in each room.</p>
<p>If you require additional equipment or need more information, please contact your speaker manager immediately.</p>
<p><b>PANEL INFORMATION</b></p>
<p>If you are moderating a panel and cannot meet with the panelists in person, please schedule a quick conference call with all participants to review expectations. A reminder for panels with 40 minutes: please introduce panelists first (we suggest no more than 30 sec. per person), follow with 15-20 minutes of prepared questions and discussions, and finish with 20 minutes of audience/interactive Q&A.</p>
<p>Thanks and see you soon!</p>
<p>OpenStack Summit Team</p>
</body>
</html>
HTML;
            $email_tpl->Content = $body;
            $email_tpl->write();
        }
        if (intval(PermamailTemplate::get()->filter('Identifier', PRESENTATION_SPEAKER_SUMMIT_REMINDER_EMAIL)->count()) === 0) {
            $email_tpl = PermamailTemplate::create();
            $email_tpl->Identifier = PRESENTATION_SPEAKER_SUMMIT_REMINDER_EMAIL;
            $email_tpl->Subject = 'Thank you for registering or the OpenStack Summit';
            $email_tpl->From = '*****@*****.**';
            $body = <<<HTML
<html>
<body>
<p>Hello \$Speaker.FirstName \$Speaker.LastName -- </p>
<p>We look forward to you joining us as a speaker for the OpenStack Summit in Austin! April 25th through April 29th.  Please respond to this email with your phone number where you can be reached while onsite.</p>
<p>This email includes important information, including your session details and presentation information so please review it carefully.  Going forward your main contacts (speaker managers) will be Beth Nowak (+1 415.994.8059) and Joe Schlick (+1 415.377.6370). They can be reached at speakersupport@openstack.org and will be able to help you with all of your conference needs. Beth and Joe will be on-site in Austin, Sunday, April 24th through Friday, April 29th to assist you.</p>


<p><b>SESSION INFORMATION</b></p>
<p>Please review the Session Schedule for your Session Date, Time and Room Assignment:</p>
<ul>
<% loop \$Speaker.PublishedPresentations %>
<li><a href="{\$getLink}">\$Title ( \$getDateNice ) - \$getLocationNameNice </a></li>
<% end_loop %>
</ul>
<p><a href="{\$ScheduleMainPageLink}">OpenStack Summit Schedule.</a></p>
<p>Also please take a moment to review your speaker information and verify that your name, title and Company are reflected accurately. If your headshot and/or biography do not appear on the schedule or the information is incorrect in any way, you can update your info by logging into your OpenStack Community Member account here: <a href="https://www.openstack.org/profile/speaker">https://www.openstack.org/profile/speaker</a>. We are also able to make the edits for you if needed.</p>
<p>Most sessions are 40 minutes long, with a 10-minute break between sessions. Please arrive to your session room at least 10 minutes prior to the start of your session and please be considerate of other speakers by ending your session on time.</p>
<p><b>PRESENTATION INFORMATION</b></p>
<p>We do not have a speaker ready room so please come prepared with your VGA or DVI compatible laptop with your 16:9 presentations loaded and ready to present. If your laptop needs an adapter to connect via VGA or DVI (i.e. Macs require a dongle), please bring that as well. If you require another type of connection, have a demo, or will use more than one connected device, please notify your speaker manager immediately.</p>
<p>If you have a presentation which requires attendees to download large files to participate in your session, please share your delivery system with the speaker managers so we are able to communicate that information with the attendees.  We suggest you provide a link to files several days prior to the conference.</p>
<p>We will be video recording sessions from a lockdown camera capturing the screen and presenter, and also a hard drive video recorder 1280x720 final resolution which will capture slides and camera in a two up format.  Recordings will be uploaded to OpenStack’s YouTube page and available on the OpenStack Foundation website post event. If you have not already done so, provide a 450 character abstract for YouTube by replying to this email.</p>
<p>Please include your name, title, company name, and title of your presentation in your introductory slide.</p>
<p><b>AV / ROOM SET UP</b></p>
<ul>
<li>**Sessions: small stage with presenter table (highboy), theater style seating for audience</li>
<li>**Workshops: small stage with presenter table (highboy), classroom style seating for audience</li>
<li>**Panels: chairs arranged in semi circle on stage with presenter table (highboy), theater style seating for audience</li>
</ul>
<p>A/V: each room is equipped with a projector (1280x720, 720p) and screen (16:9), DVI & VGA connections at 1920x1080 (capable of scaling if needed), 1 Seamless Switcher, 1 Wireless slide advancer, 3 wireless mics (handheld or lav), 1 Q&A mic set in aisle, 2 computer audio inputs on stage, Ethernet connections on stage, basic stage wash lighting and 1 standard power strip at the 30” cocktail round on stage. There will be an AV Tech in each room.</p>
<p>If you require additional equipment or need more information, please contact your speaker manager immediately.</p>
<p><b>PANEL INFORMATION</b></p>
<p>If you are moderating a panel and cannot meet with the panelists in person, please schedule a quick conference call with all participants to review expectations. A reminder for panels with 40 minutes: please introduce panelists first (we suggest no more than 30 sec. per person), follow with 15-20 minutes of prepared questions and discussions, and finish with 20 minutes of audience/interactive Q&A.</p>
<p>Thanks and see you soon!</p>
<p>OpenStack Summit Team</p>
</body>
</html>
HTML;
            $email_tpl->Content = $body;
            $email_tpl->write();
        }
    }
 /**
  * Gets the {@link PermamailTemplate} by its identifier
  * @return PermamailTemplate
  */
 public function getUserTemplate()
 {
     if ($this->userTemplate) {
         return PermamailTemplate::get_by_identifier($this->userTemplate);
     }
     return false;
 }