Exemplo n.º 1
0
 /**
  * Send an email to warn the friend request.
  *
  * @param int $iId friend ID
  * @param object \PH7\UserCoreModel $oUserModel
  * @return void
  */
 protected function sendMail($iId, UserCoreModel $oUserModel)
 {
     $sFriendEmail = $oUserModel->getEmail($iId);
     $sFriendUsername = $oUserModel->getUsername($iId);
     /**
      * Note: The predefined variables as %site_name% does not work here,
      * because we are in an ajax script that is called before the definition of these variables.
      */
     /**
      * Get the site name, because we do not have access to predefined variables.
      */
     $sSiteName = Framework\Mvc\Model\DbConfig::getSetting('siteName');
     $this->view->content = t('Hello %0%!<br /><strong>%1%</strong> sent you a friendship request on %2%.<br /> <a href="%3%">Click here</a> to see your friend request.', $sFriendUsername, $this->session->get('member_username'), $sSiteName, Framework\Mvc\Router\Uri::get('user', 'friend', 'index'));
     /* Because we work in Ajax, the constant "PH7_TPL_NAME" is not yet defined.
      * So we use the constant "PH7_DEFAULT_THEME" is already defined.
      */
     $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_DEFAULT_THEME . '/mail/sys/mod/user/friend_request.tpl', $sFriendEmail);
     $aInfo = ['to' => $sFriendEmail, 'subject' => t('%0% wants to be friends with you on %1%', $this->session->get('member_first_name'), $sSiteName)];
     (new Framework\Mail\Mail())->send($aInfo, $sMessageHtml);
 }