/** * Send a real live email reminder * * @todo This would probably be better as two or more sep functions * * @param string $type type of reminder * @param mixed $object Confirm_address or Invitation object * @param string $subject subjct of the email reminder * @param string $title title of the email reminder * @return boolean true if the email subsystem doesn't explode */ static function sendReminderEmail($type, $object, $subject, $title = null) { $sitename = common_config('site', 'name'); $recipients = array($object->address); $inviter = null; $inviterurl = null; if ($type == UserInviteReminderHandler::INVITE_REMINDER) { $user = User::getKV($object->user_id); if (!empty($user)) { $profile = $user->getProfile(); $inviter = $profile->getBestName(); $inviterUrl = $profile->profileurl; } } $headers['From'] = mail_notify_from(); $headers['To'] = trim($object->address); // TRANS: Subject for confirmation e-mail. // TRANS: %s is the StatusNet sitename. $headers['Subject'] = $subject; $headers['Content-Type'] = 'text/html; charset=UTF-8'; $confirmUrl = common_local_url('register', array('code' => $object->code)); $template = DocFile::forTitle($title, DocFile::mailPaths()); $blankfillers = array('confirmurl' => $confirmUrl); if ($type == UserInviteReminderHandler::INVITE_REMINDER) { $blankfillers['inviter'] = $inviter; $blankfillers['inviterurl'] = $inviterUrl; // @todo private invitation message? } $body = $template->toHTML($blankfillers); return mail_send($recipients, $headers, $body); }
function sendInvitation($email, $user, $personal) { $profile = $user->getProfile(); $bestname = $profile->getBestName(); $sitename = common_config('site', 'name'); $invite = new Invitation(); $invite->address = $email; $invite->address_type = 'email'; $invite->code = common_confirmation_code(128); $invite->user_id = $user->id; $invite->created = common_sql_now(); if (!$invite->insert()) { common_log_db_error($invite, 'INSERT', __FILE__); return false; } $confirmUrl = common_local_url('register', array('code' => $invite->code)); $recipients = array($email); $headers['From'] = mail_notify_from(); $headers['To'] = trim($email); $headers['Content-Type'] = 'text/html; charset=UTF-8'; // TRANS: Subject for invitation email. Note that 'them' is correct as a gender-neutral // TRANS: singular 3rd-person pronoun in English. %1$s is the inviting user, $2$s is // TRANS: the StatusNet sitename. $headers['Subject'] = sprintf(_('%1$s has invited you to join them on %2$s'), $bestname, $sitename); $title = empty($personal) ? 'invite' : 'invitepersonal'; // @todo FIXME: i18n issue. $inviteTemplate = DocFile::forTitle($title, DocFile::mailPaths()); $body = $inviteTemplate->toHTML(array('inviter' => $bestname, 'inviterurl' => $profile->profileurl, 'confirmurl' => $confirmUrl, 'personal' => $personal)); common_debug('Confirm URL is ' . common_local_url('register', array('code' => $invite->code))); mail_send($recipients, $headers, $body); }
function loadDoc() { if (Event::handle('StartLoadDoc', array(&$this->title, &$this->output))) { $paths = DocFile::defaultPaths(); $docfile = DocFile::forTitle($this->title, $paths); if (empty($docfile)) { // TRANS: Client exception thrown when requesting a document from the documentation that does not exist. // TRANS: %s is the non-existing document. throw new ClientException(sprintf(_('No such document "%s".'), $this->title), 404); } $this->output = $docfile->toHTML(); Event::handle('EndLoadDoc', array($this->title, &$this->output)); } }
static function sendConfirmEmail($confirm, $title = null) { $sitename = common_config('site', 'name'); $recipients = array($confirm->address); $headers['From'] = mail_notify_from(); $headers['To'] = trim($confirm->address); // TRANS: Subject for confirmation e-mail. // TRANS: %s is the StatusNet sitename. $headers['Subject'] = sprintf(_m('Welcome to %s'), $sitename); $headers['Content-Type'] = 'text/html; charset=UTF-8'; $confirmUrl = common_local_url('register', array('code' => $confirm->code)); if (empty($title)) { $title = 'confirmemailreg'; } $confirmTemplate = DocFile::forTitle($title, DocFile::mailPaths()); $body = $confirmTemplate->toHTML(array('confirmurl' => $confirmUrl)); mail_send($recipients, $headers, $body); }