예제 #1
0
 /**
  * Renders the comment count for Komento
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function getCount(EasyBlogPost $post)
 {
     if (!$this->exists()) {
         return;
     }
     FD::language()->load('com_easysocial', JPATH_ROOT);
     $url = $post->getPermalink();
     $comments = FD::comments($post->id, 'blog', SOCIAL_APPS_GROUP_USER, $url);
     $count = $comments->getCount();
     return $count;
 }
예제 #2
0
 /**
  * Notify site subscribers whenever a new blog post is created
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function notifySubscribers(EasyBlogPost $blog, $action, $comment = null)
 {
     if (!$this->exists()) {
         return false;
     }
     // We don't want to notify via e-mail
     $emailOptions = false;
     $recipients = array();
     $rule = '';
     // Get the permalink of the post
     $permalink = $blog->getPermalink();
     // Get the blog image
     $image = $blog->getImage() ? $blog->getImage('frontpage') : '';
     // New post created on the site
     if ($action == 'new.post') {
         $rule = 'blog.create';
         $recipients = $blog->getRegisteredSubscribers('new', array($blog->created_by));
         $options = array('uid' => $blog->id, 'actor_id' => $blog->created_by, 'title' => JText::sprintf('COM_EASYBLOG_EASYSOCIAL_NOTIFICATION_NEW_BLOG_POST', $blog->title), 'type' => 'blog', 'url' => $permalink, 'image' => $image);
     }
     // New comment posted on the site
     if ($action == 'new.comment') {
         if (!$this->config->get('integrations_easysocial_notifications_newcomment')) {
             return false;
         }
         $rule = 'blog.comment';
         // Get a list of recipients that we should notify
         $recipients = $comment->getSubscribers($blog, array($comment->created_by));
         $recipients = array_merge($recipients, array($blog->created_by));
         // Format the comment's content
         $content = $comment->getContent(true);
         $options = array('uid' => $blog->id, 'actor_id' => $comment->created_by, 'title' => JText::sprintf('COM_EASYBLOG_EASYSOCIAL_NOTIFICATION_NEW_COMMENT_ON_THE_BLOG_POST', $content, $blog->title), 'type' => 'blog', 'url' => $permalink, 'image' => $image);
     }
     // New ratings added on the post
     if ($action == 'ratings.add' && $this->config->get('integrations_easysocial_notifications_ratings')) {
         $rule = 'blog.ratings';
         // @TODO: Perhaps notify everyone else that subscribed to this post?
         // Notify the blog author
         $recipients = array($blog->created_by);
         $options = array('uid' => $blog->id, 'actor_id' => $this->my->id, 'title' => JText::sprintf('COM_EASYBLOG_EASYSOCIAL_NOTIFICATION_NEW_RATINGS_FOR_YOUR_BLOG_POST', $blog->title), 'type' => 'blog', 'url' => $permalink, 'image' => $image);
     }
     if (!$rule) {
         return false;
     }
     // Send notifications to the receivers when they unlock the badge
     FD::notify($rule, $recipients, $emailOptions, $options);
 }