Example #1
0
    protected function sendFixDateMail($user, $foodle)
    {
        if (!$this->user->notification('invite', TRUE)) {
            error_log('Foodle response was added, but mail notification was not sent because of users preferences');
            return;
        }
        error_log('Sending Foodle fixdate to ' . $user->email);
        $profileurl = FoodleUtils::getUrl() . 'profile/';
        $url = FoodleUtils::getUrl() . 'foodle/' . $foodle->identifier;
        $name = 'Date and time set for ' . $foodle->name;
        if (empty($user->email)) {
            error_log('Was not able to send e-mail notification to ' . $user->userid . ' because email address was missing');
            return;
        }
        $to = $user->email;
        //		$to = '*****@*****.**';
        $datetimetext = '';
        $extralinks = '';
        if (!empty($foodle->datetime)) {
            $tz = new TimeZone($this->db, NULL, $user);
            $icalurl = FoodleUtils::getUrl() . 'foodle/' . $foodle->identifier . '?output=ical';
            $datetimetext = "\n\n### Date and time\n\n" . $foodle->datetimeText($tz->getTimeZone());
            $extralinks = "\n* Import to your calendar using the attached calendar file";
        }
        $mail = $foodle->descr . '

### Confirm your participation

* [Please confirm your participation on this event](' . $url . ')
* [View confirmation of other participants](' . $url . '#responses)' . $extralinks . '

' . $datetimetext . '

### Did you know

You may also create new Foodles on your own, and invite others to respond.

* [Go to Foodl.org to create a new Foodle.](http://foodl.org)

		';
        $mailer = new Foodle_EMail($to, htmlspecialchars($name), 'Foodl.org <*****@*****.**>');
        $mailer->setBody($mail);
        if (!empty($foodle->datetime)) {
            $url = FoodleUtils::getUrl() . 'foodle/' . $foodle->identifier . '?output=ical';
            $ics = file_get_contents($url);
            $mailer->send(array(array('data' => $ics, 'file' => 'foodl-invitation.ics', 'type' => 'calendar/text')));
        } else {
            $mailer->send();
        }
    }