/** * 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; }