Ejemplo n.º 1
2
 /**
  * Sends notification to all watchers of this thread saying a new post has been made.
  *
  * @param quipComment $comment A reference to the actual comment
  * @return boolean True if successful
  */
 public function notify(quipComment &$comment)
 {
     if (!$this->_loadLexicon()) {
         return false;
     }
     $this->xpdo->lexicon->load('quip:emails');
     /* get the poster's email address */
     $posterEmail = false;
     $user = $comment->getOne('Author');
     if ($user) {
         $profile = $user->getOne('Profile');
         if ($profile) {
             $posterEmail = $profile->get('email');
         }
     }
     /* get email body/subject */
     $properties = $comment->toArray();
     $properties['url'] = $comment->makeUrl('', array(), array('scheme' => 'full'));
     $body = $this->xpdo->lexicon('quip.email_notify', $properties);
     $subject = $this->xpdo->lexicon('quip.email_notify_subject');
     /* send notifications */
     $success = true;
     $notifyEmails = $this->get('notify_emails');
     $emails = explode(',', $notifyEmails);
     /* send notifications to notify_emails subjects */
     if (!empty($emails)) {
         $this->sendEmail($subject, $body, $emails);
     }
     /* now send to notified users */
     $notifiees = $this->getMany('Notifications');
     /** @var quipCommentNotify $notification */
     foreach ($notifiees as $notification) {
         $email = $notification->get('email');
         /* remove invalid emails */
         if (empty($email) || strpos($email, '@') == false) {
             $notification->remove();
             continue;
         }
         /* don't notify the poster, since they posted the comment. */
         if ($posterEmail == $email) {
             continue;
         }
         $notification->send($comment, $properties);
     }
     return $success;
 }
Ejemplo n.º 2
0
 public function process()
 {
     if ($this->comment->approve() === false) {
         return $this->failure($this->modx->lexicon('quip.comment_err_save'));
     }
     return $this->success();
 }
 /**
  * Send the notification
  *
  * @param quipComment $comment
  * @param array $properties
  * @return boolean
  */
 public function send(quipComment $comment, array $properties = array())
 {
     $this->xpdo->getService('mail', 'mail.modPHPMailer');
     if (!$this->xpdo->mail) {
         return false;
     }
     $email = $this->get('email');
     /* set unsubscription link */
     $unsubscribeSecretHash = 'One sees great things from the valley, only small things from the peak.';
     $hash = md5('quip.' . $unsubscribeSecretHash . $email . $this->get('createdon'));
     $properties['unsubscribeUrl'] = $comment->makeUrl('', array('quip_unsub' => $email, 'quip_uhsh' => $hash), array('scheme' => 'full'), false) . '#quip-success-' . $comment->get('idprefix');
     $properties['unsubscribeText'] = $this->xpdo->lexicon('quip.unsubscribe_text', array('unsubscribeUrl' => $properties['unsubscribeUrl']));
     $body = $this->xpdo->lexicon('quip.email_notify', $properties);
     $subject = $this->xpdo->lexicon('quip.email_notify_subject');
     $emailFrom = $this->xpdo->context->getOption('quip.emailsFrom', $this->xpdo->context->getOption('emailsender'));
     $emailReplyTo = $this->xpdo->context->getOption('quip.emailsReplyTo', $this->xpdo->context->getOption('emailsender'));
     if (empty($email) || strpos($email, '@') == false) {
         return false;
     }
     if ($this->xpdo->parser) {
         $this->xpdo->parser->processElementTags('', $body, true, false);
         $this->xpdo->parser->processElementTags('', $subject, true, false);
         $this->xpdo->parser->processElementTags('', $emailFrom, true, false);
         $this->xpdo->parser->processElementTags('', $emailReplyTo, true, false);
     }
     $this->xpdo->mail->set(modMail::MAIL_BODY, $body);
     $this->xpdo->mail->set(modMail::MAIL_FROM, $emailFrom);
     $this->xpdo->mail->set(modMail::MAIL_FROM_NAME, $this->xpdo->context->getOption('quip.emails_from_name', 'Quip'));
     $this->xpdo->mail->set(modMail::MAIL_SENDER, $emailFrom);
     $this->xpdo->mail->set(modMail::MAIL_SUBJECT, $subject);
     $this->xpdo->mail->address('to', $email);
     $this->xpdo->mail->address('reply-to', $emailReplyTo);
     $this->xpdo->mail->setHTML(true);
     $success = $this->xpdo->mail->send();
     $this->xpdo->mail->reset();
     return $success;
 }
Ejemplo n.º 4
0
 /**
  * Get the comments for this Thread
  * @return array
  */
 public function getComments()
 {
     $parent = $this->getProperty('parent', 0);
     $sortBy = $this->getProperty('sortBy', 'rank');
     $sortByAlias = $this->getProperty('sortByAlias', 'quipComment');
     $sortDir = $this->getProperty('sortDir', 'ASC');
     $this->modx->loadClass('quipComment');
     $result = quipComment::getThread($this->modx, $this->thread, $parent, $this->ids, $sortBy, $sortByAlias, $sortDir);
     $this->comments = $result['results'];
     $this->setPlaceholder('total', $result['total']);
     return $this->comments;
 }