/**
  * Returns the html body as a string
  *
  * @return  string
  */
 public function getHtmlBody()
 {
     $strHtmlBody = parent::getHtmlBody();
     if ($this->getMessage()->convertPtoBr) {
         $strHtmlBody = NotificationCenterPlus::convertPToBr($strHtmlBody);
     }
     if ($strHtmlBody && $this->getMessage()->addStylesheets) {
         $strHtmlBody = NotificationCenterPlus::addHeaderCss($strHtmlBody, $this->getMessage());
         $strHtmlBody = DOM::convertToInlineCss($strHtmlBody, implode(' ', NotificationCenterPlus::getStylesheetContents($this->getMessage(), NotificationCenterPlus::CSS_MODE_INLINE)));
     }
     return $strHtmlBody;
 }
 /**
  * Send a lost password e-mail
  *
  * @param \MemberModel $objMember
  */
 protected function sendPasswordLink($objMember)
 {
     $objNotification = \NotificationCenter\Model\Notification::findByPk($this->nc_notification);
     if ($objNotification === null) {
         $this->log('The notification was not found ID ' . $this->nc_notification, __METHOD__, TL_ERROR);
         return;
     }
     $confirmationId = md5(uniqid(mt_rand(), true));
     // Store the confirmation ID
     $objMember = \MemberModel::findByPk($objMember->id);
     $objMember->activation = $confirmationId;
     $objMember->save();
     $arrTokens = array();
     // Add member tokens
     foreach ($objMember->row() as $k => $v) {
         if (\Validator::isBinaryUuid($v)) {
             $v = \StringUtil::binToUuid($v);
         }
         $arrTokens['member_' . $k] = specialchars($v);
     }
     // FIX: Add salutation token
     $arrTokens['salutation_user'] = NotificationCenterPlus::createSalutation($GLOBALS['TL_LANGUAGE'], $objMember);
     // ENDFIX
     $arrTokens['recipient_email'] = $objMember->email;
     $arrTokens['domain'] = \Idna::decode(\Environment::get('host'));
     $arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId;
     // FIX: Add custom change password jump to
     if (($objJumpTo = $this->objModel->getRelated('changePasswordJumpTo')) !== null) {
         $arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Controller::generateFrontendUrl($objJumpTo->row(), '?token=' . $confirmationId);
     }
     // ENDFIX
     $objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
     $this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . $objMember->email . ')', __METHOD__, TL_ACCESS);
     // Check whether there is a jumpTo page
     if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) {
         $this->jumpToOrReload($objJumpTo->row());
     }
     StatusMessage::addSuccess(sprintf($GLOBALS['TL_LANG']['notification_center_plus']['sendPasswordLink']['messageSuccess'], $arrTokens['recipient_email']), $this->objModel->id);
     $this->reload();
 }
 public static function getConfirmationNotificationsAsOptions()
 {
     return NotificationCenterPlus::getNotificationsAsOptions(Submissions::NOTIFICATION_TYPE_CONFIRMATION);
 }
 public static function generateTokens($intSubmission, $arrFields = array())
 {
     $arrTokens = array();
     \Controller::loadDataContainer('tl_submission');
     \System::loadLanguageFile('tl_submission');
     $arrDca =& $GLOBALS['TL_DCA']['tl_submission'];
     if (($objSubmission = SubmissionModel::findByPk($intSubmission)) !== null) {
         $objDc = new DC_Hybrid('tl_submission');
         $objDc->activeRecord = $objSubmission;
         // fields
         if (($objSubmissionArchive = $objSubmission->getRelated('pid')) !== null) {
             \Controller::loadDataContainer('tl_submission');
             $arrFields = empty($arrFields) ? deserialize($objSubmissionArchive->submissionFields, true) : $arrFields;
             if (isset($GLOBALS['TL_HOOKS']['preGenerateSubmissionTokens']) && is_array($GLOBALS['TL_HOOKS']['preGenerateSubmissionTokens'])) {
                 foreach ($GLOBALS['TL_HOOKS']['preGenerateSubmissionTokens'] as $arrCallback) {
                     \System::importStatic($arrCallback[0])->{$arrCallback}[1]($objSubmission, $objSubmissionArchive, $arrFields);
                 }
             }
         }
         $arrSubmissionData = static::prepareData($objSubmission, 'tl_submission', $GLOBALS['TL_DCA']['tl_submission'], $objDc, $arrFields, Submissions::getSkipFields());
         $arrTokens = static::tokenizeData($arrSubmissionData);
         // salutation
         $arrTokens['salutation_submission'] = NotificationCenterPlus::createSalutation($GLOBALS['TL_LANGUAGE'], array('gender' => $arrTokens['form_value_gender'], 'title' => $arrTokens['form_value_title'], 'lastname' => $arrTokens['form_value_lastname']));
         $arrTokens['tl_submission'] = $objSubmission->id;
     }
     return $arrTokens;
 }
 public static function generateTokens($strTable, \Model $objEntity, \MemberModel $objFormerEditor)
 {
     // entity
     \Controller::loadDataContainer($strTable);
     \System::loadLanguageFile($strTable);
     $arrDca = $GLOBALS['TL_DCA'][$strTable];
     $objDc = new DC_Hybrid($strTable);
     $objDc->activeRecord = $objEntity;
     $arrSubmissionData = SubmissionModel::prepareData($objEntity, $strTable, $arrDca, $objDc);
     $arrTokens = SubmissionModel::tokenizeData($arrSubmissionData, 'entity');
     // former editor
     \Controller::loadDataContainer('tl_member');
     \System::loadLanguageFile('tl_member');
     $arrDca = $GLOBALS['TL_DCA']['tl_member'];
     $objDc = new DC_Hybrid('tl_member');
     $objDc->activeRecord = $objFormerEditor;
     $arrSubmissionData = SubmissionModel::prepareData($objFormerEditor, 'tl_member', $arrDca, $objDc);
     $arrTokens = array_merge(SubmissionModel::tokenizeData($arrSubmissionData, 'former_editor'), $arrTokens);
     $arrTokens['salutation_former_editor'] = NotificationCenterPlus::createSalutation($GLOBALS['TL_LANGUAGE'], $objFormerEditor);
     return $arrTokens;
 }