示例#1
0
 /**
  * Retrieves the body of the email.
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getBody()
 {
     // if this object is not valid, do not futher process this item.
     if (!$this->id) {
         return false;
     }
     $body = $this->body;
     // If the body is not empty, we should just use this
     if (!empty($this->body) && !$this->template) {
         return $body;
     }
     // this is new way of handling mailq content.
     $notti = EB::notification();
     // data and params need to be in array form.
     $data = json_decode($this->data);
     $param = json_decode($this->param);
     if ($data && !is_array($data)) {
         $data = get_object_vars($data);
     }
     if ($param && !is_array($param)) {
         $param = get_object_vars($param);
     }
     if ($data) {
         $unsubscribe = 1;
         if ($param && isset($param['unsubscribe'])) {
             $unsubscribe = $param['unsubscribe'];
         }
         // we need to generate the unsubscribe links for this email.
         if ($unsubscribe) {
             $data['unsubscribeLink'] = $notti->getUnsubscribeLinks($this->recipient);
         }
         $body = $notti->getTemplateContents($this->template, $data);
     }
     return $body;
 }
示例#2
0
 /**
  * Retrieves the html codes for the ratings.
  *
  * @param	int	$uid	The unique id for the item that is being rated
  * @param	string	$type	The unique type for the item that is being rated
  * @param	string	$command	A textual representation to request user to vote for this item.
  * @param	string	$element	A dom element id.
  **/
 public function addMailQueue(EasyBlogSubscriptionItem $item)
 {
     // Build the variables for the template
     $data = array();
     $data['fullname'] = $item->ufullname;
     $data['target'] = $item->targetname;
     $data['targetlink'] = $item->targetlink;
     $data['type'] = $item->utype;
     $recipient = new stdClass();
     $recipient->email = $item->uemail;
     $recipient->unsubscribe = $this->getUnsubscribeLink($item, true);
     $title = JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_CONFIRMATION');
     $notification = EB::notification();
     return $notification->send(array($recipient), $title, 'subscription.confirmation', $data);
 }
示例#3
0
 /**
  * Retrieves the html codes for the ratings.
  *
  * @param	int	$uid	The unique id for the item that is being rated
  * @param	string	$type	The unique type for the item that is being rated
  * @param	string	$command	A textual representation to request user to vote for this item.
  * @param	string	$element	A dom element id.
  **/
 public function addMailQueue(EasyBlogSubscriptionItem $item)
 {
     // Build the variables for the template
     $data = array();
     $data['fullname'] = $item->ufullname;
     $data['target'] = $item->targetname;
     // To append joomla url inside the link.
     $domain = rtrim(JURI::root(), '/');
     if (stripos($item->targetLink, $domain) === false) {
         $item->targetlink = rtrim(JURI::root(), '/') . '/' . ltrim($item->targetlink, '/');
     }
     $data['targetlink'] = $item->targetlink;
     $data['type'] = $item->utype;
     $recipient = new stdClass();
     $recipient->email = $item->uemail;
     $recipient->unsubscribe = $this->getUnsubscribeLink($item, true);
     $title = JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_CONFIRMATION');
     $notification = EB::notification();
     return $notification->send(array($recipient), $title, 'subscription.confirmation', $data);
 }
示例#4
0
 /**
  * Notifies the author when a post is rejected
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function notify()
 {
     // $post = EB::table('Post');
     $post = EB::post();
     $post->load($this->post_id);
     // Get the author
     $author = $this->getAuthor();
     $data = array();
     $data['blogTitle'] = $post->title;
     $data['blogAuthor'] = $author->getName();
     $data['blogAuthorAvatar'] = $author->getAvatar();
     $data['blogEditLink'] = $post->getEditLink(false);
     $data['blogAuthorEmail'] = $author->user->email;
     $data['rejectMessage'] = $this->message;
     $subject = JText::_('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_REJECTED');
     $obj = new stdClass();
     $obj->unsubscribe = false;
     $obj->email = $author->user->email;
     $emails = array($obj);
     $notification = EB::notification();
     return $notification->send($emails, $subject, 'post.rejected', $data);
 }
示例#5
0
 /**
  * Process email notifications
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function processEmails($isModerated = false, $blog)
 {
     $config = EB::config();
     // Fix contents of comments.
     $content = $this->comment;
     // Initialize what we need
     $commentAuthor = $this->name;
     $commentAuthorEmail = $this->email;
     $commentAuthorAvatar = JURI::root() . 'components/com_easyblog/assets/images/default_blogger.png';
     // Get the date object
     $date = EB::date();
     // Format the date
     $commentDate = $date->format(JText::_('DATE_FORMAT_LC3'));
     $teamLink = '';
     if (isset($blog->team)) {
         $teamLink = '&team=' . $blog->team;
     }
     // Get the author data
     if ($this->created_by != 0) {
         $user = $this->getAuthor();
         $commentAuthor = $user->getName();
         $commentAuthorEmail = $user->user->email;
         $commentAuthorAvatar = $user->getAvatar();
     }
     $blogAuthor = EB::user($blog->created_by);
     $data = array('blogTitle' => $blog->title, 'blogIntro' => $blog->intro, 'blogContent' => $blog->content, 'blogLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry' . $teamLink . '&id=' . $blog->id, false, true), 'commentTitle' => empty($comment->title) ? '-' : $comment->title, 'commentContent' => $content, 'commentAuthor' => $commentAuthor, 'commentAuthorAvatar' => $commentAuthorAvatar, 'commentDate' => $commentDate, 'commentLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry' . $teamLink . '&id=' . $blog->id, false, true) . '#comment-' . $this->id);
     // Get a list of emails
     $emails = array();
     // Get the notification library
     $notification = EB::notification();
     if ($isModerated) {
         $hashkey = EB::table('HashKeys');
         $hashkey->uid = $this->id;
         $hashkey->type = 'comments';
         $hashkey->store();
         // Generate the approval and reject links
         $data['approveLink'] = EBR::getRoutedURL('index.php?option=com_easyblog&task=comments.approve&key=' . $hashkey->key, false, true);
         $data['rejectLink'] = EBR::getRoutedURL('index.php?option=com_easyblog&task=comments.reject&key=' . $hashkey->key, false, true);
         // Send email notification to admin.
         if ($config->get('custom_email_as_admin')) {
             $notification->getCustomEmails($emails);
         } else {
             $notification->getAdminEmails($emails);
         }
         // @rule: Send email notification to blog authors.
         if ($config->get('notification_commentmoderationauthor')) {
             $obj = new stdClass();
             $obj->unsubscribe = false;
             $obj->email = $blogAuthor->user->email;
             $emails[$blogAuthor->user->email] = $obj;
         }
         $notification->send($emails, JText::_('COM_EASYBLOG_NEW_COMMENT_ADDED_MODERATED_TITLE'), 'comment.moderate', $data);
         return true;
     }
     if (!$isModerated) {
         // Get a list of admin emails
         $notification->getAdminNotificationEmails($emails);
         // Send notification to blog authors.
         if ($config->get('notification_commentauthor')) {
             $obj = new stdClass();
             $obj->unsubscribe = false;
             $obj->email = $blogAuthor->user->email;
             $emails[$blogAuthor->user->email] = $obj;
         }
         // Send notifications to blog subscribers
         if ($config->get('main_subscription') && $blog->subscription == '1' && $config->get('notification_commentsubscriber')) {
             $notification->getBlogSubscriberEmails($emails, $blog->id);
         }
         // Do not send to the person that commented on the blog post.
         unset($emails[$commentAuthorEmail]);
         if (!$emails) {
             return false;
         }
         // Send the emails now.
         $subject = JText::sprintf('COM_EASYBLOG_NEW_COMMENT_ADDED_IN_POST', $blog->title);
         $notification->send($emails, $subject, 'comment.new', $data);
         return true;
     }
 }
示例#6
0
 /**
  * Notifies the site owners when a new report is made on the site
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function notify(EasyBlogPost &$post)
 {
     $config = EB::config();
     // Send notification to site admins when a new blog post is reported
     $data = array();
     $data['blogTitle'] = $post->title;
     $data['blogLink'] = $post->getExternalPermalink();
     // Get the author of this reporter
     $author = $this->getAuthor();
     $data['reporterAvatar'] = $author->getAvatar();
     $data['reporterName'] = $author->getName();
     $data['reporterLink'] = $author->getProfileLink();
     $data['reason'] = $this->reason;
     $data['reportDate'] = EB::date()->format(JText::_('DATE_FORMAT_LC2'));
     // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls.
     $app = JFactory::getApplication();
     if ($app->isAdmin() && EBR::isSh404Enabled()) {
         $data['blogLink'] = JURI::root() . 'index.php?option=com_easyblog&view=entry&id=' . $post->id;
     }
     // Set the title of the email
     $subject = JString::substr($post->title, 0, $config->get('main_mailtitle_length'));
     $subject = JText::sprintf('COM_EASYBLOG_EMAIL_TITLE_NEW_REPORT', $subject) . ' ...';
     // Get the notification library
     $notification = EB::notification();
     $recipients = array();
     // Fetch custom emails defined at the back end.
     if ($config->get('notification_blogadmin')) {
         if ($config->get('custom_email_as_admin')) {
             $notification->getCustomEmails($recipients);
         } else {
             $notification->getAdminEmails($recipients);
         }
     }
     if (!empty($recipients)) {
         $notification->send($recipients, $subject, 'post.reported', $data);
     }
 }
示例#7
0
 /**
  * Notifies site admin when a new user subscribes
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function notifyAdmin()
 {
     $data = array('subscriber' => $this->fullname, 'subscriberDate' => EB::date()->format(JText::_('DATE_FORMAT_LC1')), 'type' => $this->utype);
     if ($this->utype == 'entry') {
         $data['reviewLink'] = EBR::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $this->uid, false, true);
     }
     if ($this->utype == 'category') {
         $data['reviewLink'] = EBR::getRoutedURL('index.php?option=com_easyblog&view=categories&layout=listings&id=' . $this->uid, false, true);
     }
     $title = JText::_('COM_EASYBLOG_SUBSCRIPTION_NEW_' . strtoupper($this->utype));
     $emails = array();
     $lib = EB::notification();
     // If custom email addresses is specified, use that instead
     $config = EB::config();
     if ($config->get('custom_email_as_admin')) {
         $lib->getCustomEmails($emails);
     } else {
         $lib->getAdminEmails($emails);
     }
     $lib->send($emails, $title, 'subscription.notification', $data);
 }
示例#8
0
 /**
  * Sends notifications out
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function notify($reject = false)
 {
     $notification = EB::notification();
     // Load up the team blog
     $team = EB::table('TeamBlog');
     $team->load($this->team_id);
     // Send email notifications to the requester
     $requester = JFactory::getUser($this->user_id);
     $data = array('teamName' => $team->title, 'teamDescription' => $team->getDescription(), 'teamAvatar' => $team->getAvatar(), 'teamLink' => EBR::getRoutedURL('index.php?option=com_easyblog&view=teamblog&layout=listings&id=' . $this->team_id, false, true));
     $template = $reject ? 'team.rejected' : 'team.approved';
     // Load site language file
     EB::loadLanguages();
     $subject = $reject ? JText::sprintf('COM_EASYBLOG_TEAMBLOGS_REQUEST_REJECTED', $team->title) : JText::sprintf('COM_EASYBLOG_TEAMBLOGS_REQUEST_APPROVED', $team->title);
     $obj = new stdClass();
     $obj->unsubscribe = false;
     $obj->email = $requester->email;
     $emails = array($obj);
     $notification->send($emails, $subject, $template, $data);
 }
示例#9
0
 /**
  * Notify subscribers when a new blog post is published
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function notify($underApproval = false, $published = '1', $featured = false, $approved = false)
 {
     // Load site's language file
     JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
     if ($this->blogpassword) {
         return false;
     }
     $author = $this->getAuthor();
     // Export the data for email
     $data = $this->toEmailData();
     // Prepare the post title
     $title = JString::substr($this->title, 0, $this->config->get('main_mailtitle_length'));
     $subject = JText::sprintf('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_ADDED_WITH_TITLE', $title) . JText::_('COM_EASYBLOG_ELLIPSES');
     // Prepare ignored emails. We do not want to send notifications to the author
     $ignored = array($author->user->email);
     // Prepare emails
     $emails = array();
     // Load up notification library
     $notification = EB::notification();
     // If configured to notify custom emails, use that instead
     if ($this->config->get('notification_blogadmin')) {
         $notification->getAdminNotificationEmails($emails);
     }
     // If the blog post has been approved, we need to notify the author.
     if ($approved && $published) {
         $authorEmail = array();
         $obj = new stdClass();
         $obj->unsubscribe = false;
         $obj->email = $author->user->email;
         $authorEmail[$author->user->email] = $obj;
         $subject = JText::sprintf('COM_EASYBLOG_NOTIFICATION_NEW_BLOG_APPROVED', $title) . JText::_('COM_EASYBLOG_ELLIPSES');
         $notification->send($authorEmail, $subject, 'post.approved', $data);
         return true;
     }
     // Mailchimp integrations
     if (!$underApproval && $published && $this->config->get('mailchimp_campaign')) {
         EB::mailchimp()->notify($subject, $data, $this);
         return true;
     }
     if ($published) {
         $notification->sendSubscribers($subject, 'post.new', $data, $this, $ignored);
         // Send custom emails
         if ($emails) {
             $notification->send($emails, $subject, 'post.new', $data);
         }
     }
     // If the blog post is featured, send notification to the author
     if ($featured) {
         $subject = JText::_('COM_EASYBLOG_EMAIL_TITLE_NEW_BLOG_FEATURED');
         $email = new stdClass();
         $email->unsubscribe = false;
         $email->email = $author->user->email;
         $notification->send(array($email), 'COM_EASYBLOG_EMAIL_TITLE_POST_FEATURED', 'post.featured', $data);
     }
     // Logics for email notifications if this post is being submitted for approval
     if ($underApproval) {
         // If this blog post is submitted for approval, send the author an email letting them know that it is being moderated.
         $email = new stdClass();
         $email->unsubscribe = false;
         $email->email = $author->user->email;
         $notification->send(array($author->user->email => $email), 'COM_EASYBLOG_EMAIL_TITLE_POST_REQUIRES_APPROVAL', 'post.moderated', $data);
         // Send a notification to the site admin that a new post is made on the site and requires moderation.
         $emails = array();
         $notification->getAdminNotificationEmails($emails);
         $notification->send($emails, 'COM_EASYBLOG_EMAIL_TITLE_POST_REQUIRES_MODERATION', 'post.moderation', $data);
     }
 }