Esempio n. 1
0
 /**
  * constructor
  *
  * @access  public
  * @param   array   $options    Associated options array
  * @return  void
  */
 public function __construct($options)
 {
     $this->object = Jaws_Mail::getInstance('notification');
     // fetch all registry keys related to site attributes
     $this->attributes = $GLOBALS['app']->Registry->fetchAll('Settings', false);
     Jaws_Translate::getInstance()->LoadTranslation('Global', JAWS_COMPONENT_OTHERS, $this->attributes['site_language']);
     $this->attributes['site_url'] = $GLOBALS['app']->GetSiteURL('/');
     $this->attributes['site_direction'] = _t_lang($this->attributes['site_language'], 'GLOBAL_LANG_DIRECTION');
 }
Esempio n. 2
0
 /**
  * Send contact reply
  *
  * @access  public
  * @param   int     $cid    Contact ID
  * @return  mixed   True on Success or Jaws_Error on Failure
  */
 function SendReply($cid)
 {
     $model = $this->gadget->model->loadAdmin('Contacts');
     $contact = $model->GetReply($cid);
     if (Jaws_Error::IsError($contact)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_QUERY_FAILED'), RESPONSE_ERROR);
         return new Jaws_Error(_t('GLOBAL_ERROR_QUERY_FAILED'));
     }
     if (!isset($contact['id'])) {
         $GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_ERROR_CONTACT_DOES_NOT_EXISTS'), RESPONSE_ERROR);
         return new Jaws_Error(_t('CONTACT_ERROR_CONTACT_DOES_NOT_EXISTS'));
     }
     $from_name = '';
     $from_email = '';
     $to = $contact['email'];
     $rid = $contact['recipient'];
     if ($rid != 0) {
         $rModel = $this->gadget->model->load('Recipients');
         $recipient = $rModel->GetRecipient($rid);
         if (Jaws_Error::IsError($recipient)) {
             $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_QUERY_FAILED'), RESPONSE_ERROR);
             return new Jaws_Error(_t('GLOBAL_ERROR_QUERY_FAILED'));
         }
         if (!isset($recipient['id'])) {
             $GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_ERROR_RECIPIENT_DOES_NOT_EXISTS'), RESPONSE_ERROR);
             return new Jaws_Error(_t('CONTACT_ERROR_RECIPIENT_DOES_NOT_EXISTS'));
         }
         $from_name = $recipient['name'];
         $from_email = $recipient['email'];
     }
     $format = $this->gadget->registry->fetch('email_format');
     if ($format == 'html') {
         $reply = $this->gadget->ParseText($contact['reply']);
     } else {
         $reply = $contact['reply'];
     }
     $jDate = Jaws_Date::getInstance();
     $site_url = $GLOBALS['app']->getSiteURL('/');
     $site_name = $this->gadget->registry->fetch('site_name', 'Settings');
     $site_language = $this->gadget->registry->fetch('site_language', 'Settings');
     $profile_url = $GLOBALS['app']->getSiteURL('/') . $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $GLOBALS['app']->Session->GetAttribute('username')));
     Jaws_Translate::getInstance()->LoadTranslation('Global', JAWS_COMPONENT_OTHERS, $site_language);
     Jaws_Translate::getInstance()->LoadTranslation('Contact', JAWS_COMPONENT_GADGET, $site_language);
     $tpl = $this->gadget->template->load('SendReplyTo.html', array('loadFromTheme' => true, 'loadRTLDirection' => _t_lang($site_language, 'GLOBAL_LANG_DIRECTION') == 'rtl'));
     $tpl->SetBlock($format);
     $tpl->SetVariable('lbl_name', _t_lang($site_language, 'GLOBAL_NAME'));
     $tpl->SetVariable('lbl_email', _t_lang($site_language, 'GLOBAL_EMAIL'));
     $tpl->SetVariable('lbl_message', _t_lang($site_language, 'CONTACT_MESSAGE'));
     $tpl->SetVariable('lbl_reply', _t_lang($site_language, 'CONTACT_REPLY'));
     $tpl->SetVariable('name', $contact['name']);
     $tpl->SetVariable('email', $contact['email']);
     $tpl->SetVariable('subject', $contact['subject']);
     $tpl->SetVariable('message', $contact['msg_txt']);
     $tpl->SetVariable('reply', $reply);
     $tpl->SetVariable('createtime', $jDate->Format($contact['createtime']));
     $tpl->SetVariable('nickname', $GLOBALS['app']->Session->GetAttribute('nickname'));
     $tpl->SetVariable('profile_url', $profile_url);
     $tpl->SetVariable('site-name', $site_name);
     $tpl->SetVariable('site-url', $site_url);
     $tpl->ParseBlock($format);
     $template = $tpl->Get();
     $subject = _t_lang($site_language, 'CONTACT_REPLY_TO', Jaws_XSS::defilter($contact['subject']));
     $mail = Jaws_Mail::getInstance();
     $mail->SetFrom($from_email, $from_name);
     $mail->AddRecipient($to);
     $mail->AddRecipient('', 'cc');
     $mail->SetSubject($subject);
     $mail->SetBody($template, $format);
     $result = $mail->send();
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_ERROR_REPLY_NOT_SENT'), RESPONSE_ERROR);
         return false;
     }
     $model->UpdateReplySent($cid, true);
     $GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_REPLY_SENT'), RESPONSE_NOTICE);
     return true;
 }
Esempio n. 3
0
 /**
  * Prepares the message body of the Email
  *
  * @access  public
  * @param   string  $message  Body part of the Email
  * @return  string  XHTML template content
  */
 function PrepareMessage($message)
 {
     $this->gadget->CheckPermission('AccessToMailer');
     $format = $this->gadget->registry->fetch('email_format');
     if ($format == 'html') {
         $message = $this->gadget->ParseText($message);
     } else {
         $message = strip_tags($message);
     }
     $site_language = $this->gadget->registry->fetch('site_language', 'Settings');
     Jaws_Translate::getInstance()->LoadTranslation('Global', JAWS_COMPONENT_OTHERS, $site_language);
     Jaws_Translate::getInstance()->LoadTranslation('Contact', JAWS_COMPONENT_GADGET, $site_language);
     $tpl = $this->gadget->template->load('SendEmail.html', array('loadFromTheme' => true, 'loadRTLDirection' => _t_lang($site_language, 'GLOBAL_LANG_DIRECTION') == 'rtl'));
     $tpl->SetBlock($format);
     $tpl->SetVariable('message', $message);
     $site_name = $this->gadget->registry->fetch('site_name', 'Settings');
     $site_url = $GLOBALS['app']->getSiteURL('/');
     $tpl->SetVariable('site-name', $site_name);
     $tpl->SetVariable('site-url', $site_url);
     $tpl->ParseBlock($format);
     return $tpl->Get();
 }
Esempio n. 4
0
 /**
  * Mails reply to the sender
  *
  * @access  public
  * @param   string  $email      Comment sender's email
  * @param   string  $message    Message
  * @param   string  $reply      Reply message
  * @param   int     $replier    Replier Id
  * @return  mixed   True on successfully or Jaws_Error on failure
  */
 function EmailReply($email, $message, $reply, $replier)
 {
     $site_url = $GLOBALS['app']->getSiteURL('/');
     $site_name = $this->gadget->registry->fetch('site_name', 'Settings');
     $site_language = $this->gadget->registry->fetch('site_language', 'Settings');
     Jaws_Translate::getInstance()->LoadTranslation('Global', JAWS_COMPONENT_OTHERS, $site_language);
     Jaws_Translate::getInstance()->LoadTranslation('Comments', JAWS_COMPONENT_GADGET, $site_language);
     $tpl = $this->gadget->template->load('EmailReply.html');
     $tpl->SetBlock('notification');
     $tpl->SetVariable('lbl_message', _t_lang($site_language, 'COMMENTS_MESSAGE'));
     $tpl->SetVariable('message', $message);
     $tpl->SetVariable('replier', _t_lang($site_language, 'COMMENTS_REPLY_BY', $replier));
     $tpl->SetVariable('lbl_reply', _t_lang($site_language, 'COMMENTS_REPLY'));
     $tpl->SetVariable('reply', $reply);
     $tpl->SetVariable('site_name', $site_name);
     $tpl->SetVariable('site_url', $site_url);
     $tpl->ParseBlock('notification');
     $template = $tpl->Get();
     $ObjMail = Jaws_Mail::getInstance();
     $ObjMail->SetFrom();
     if (empty($email)) {
         $ObjMail->AddRecipient('', 'to');
     } else {
         $ObjMail->AddRecipient($email);
         $ObjMail->AddRecipient('', 'cc');
     }
     $ObjMail->SetSubject(_t_lang('COMMENTS_YOU_GET_REPLY'));
     $ObjMail->SetBody($template, 'html');
     return $ObjMail->send();
 }