Example #1
1
 /**
  * Prepare the comments object for the photo item
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function comments()
 {
     // Get the verb to use.
     $verb = $this->getPhotoVerb();
     // The context should always be photos
     $context = SOCIAL_TYPE_PHOTO;
     // The object id should always be the photo id
     $id = $this->data->id;
     $streamId = $this->getPhotoStreamId($id, $verb, false);
     if ($verb == 'upload') {
         // we now this photo is uploaded via stream's story form.
         $model = FD::model('Stream');
         $aggregated = $model->isAggregated($this->data->id, 'photos');
         if ($aggregated) {
             $streamId = '0';
         }
     }
     // Get the permalink to the photo
     $permalink = $this->data->getPermalink(false, true);
     return FD::comments($id, $context, $verb, $this->type, array('url' => $permalink), $streamId);
 }
Example #2
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($userId = null, $docType = null)
 {
     // Require user to be logged in
     FD::requireLogin();
     $id = JRequest::getVar('schedule_id');
     // Get the user that's being accessed.
     $user = FD::user($userId);
     $calendar = FD::table('Calendar');
     $calendar->load($id);
     if (!$calendar->id || !$id) {
         FD::info()->set(false, JText::_('APP_CALENDAR_CANVAS_INVALID_SCHEDULE_ID'), SOCIAL_MSG_ERROR);
         return $this->redirect(FD::profile(array('id' => $user->getAlias()), false));
     }
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     $result = $privacy->validate('apps.calendar', $calendar->id, 'view', $user->id);
     if (!$result) {
         FD::info()->set(false, JText::_('APP_CALENDAR_NO_ACCESS'), SOCIAL_MSG_ERROR);
         JFactory::getApplication()->redirect(FRoute::dashboard());
     }
     FD::page()->title($calendar->title);
     // Render the comments and likes
     $likes = FD::likes();
     $likes->get($id, 'calendar', 'create', SOCIAL_APPS_GROUP_USER);
     // Apply comments on the stream
     $comments = FD::comments($id, 'calendar', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::albums(array('layout' => 'item', 'id' => $id))));
     $params = $this->app->getParams();
     $this->set('params', $params);
     $this->set('likes', $likes);
     $this->set('comments', $comments);
     $this->set('calendar', $calendar);
     $this->set('user', $user);
     echo parent::display('canvas/item/default');
 }
Example #3
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.0
  * @access    public
  * @param    int        The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $event = FD::event($uid);
     // Get the article item
     $news = FD::table('EventNews');
     $news->load($this->input->get('newsId', 0, 'int'));
     // Check if the user is really allowed to view this item
     if (!$event->canViewItem()) {
         return $this->redirect($event->getPermalink(false));
     }
     // Get the author of the article
     $author = FD::user($news->created_by);
     // Get the url for the article
     $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $this->app->getAlias(), 'articleId' => $news->id), false);
     // Apply comments for the article
     $comments = FD::comments($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT, array('url' => $url));
     // Apply likes for the article
     $likes = FD::likes()->get($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT);
     // Set the page title
     FD::page()->title($news->get('title'));
     // Retrieve the params
     $params = $this->app->getParams();
     $this->set('app', $this->app);
     $this->set('params', $params);
     $this->set('event', $event);
     $this->set('likes', $likes);
     $this->set('comments', $comments);
     $this->set('author', $author);
     $this->set('news', $news);
     echo parent::display('canvas/item');
 }
Example #4
0
 /**
  * Returns the contents of this action.
  *
  * @since	1.0
  * @access	public
  * @return	string	The html codes for the comments.
  */
 public function getContents()
 {
     $config = FD::config();
     if (!$config->get('stream.comments.enabled')) {
         return false;
     }
     $obj = $this->getElementSource();
     $output = FD::comments($obj->uid, $obj->element, $this->item->verb, SOCIAL_APPS_GROUP_USER, array('url' => ''))->getHtml(array('hideEmpty' => true));
     return $output;
 }
Example #5
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;
 }
Example #6
0
 public function format(&$notes)
 {
     if (!$notes) {
         return;
     }
     // Since this is the dashboard view, we may freely use the current user.
     $my = FD::user();
     $stream = FD::stream();
     foreach ($notes as &$note) {
         $comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::apps(array('layout' => 'canvas', 'userid' => $my->getAlias(), 'cid' => $note->id))));
         $likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER);
         $options = array('comments' => $comments, 'likes' => $likes);
         $note->actions = $stream->getActions($options);
     }
 }
Example #7
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($userId = null, $docType = null)
 {
     // Get Notes model library
     $model = $this->getModel('Notes');
     // Retrieve list of notes created by user
     $result = $model->getItems($userId);
     $notes = array();
     if ($result) {
         foreach ($result as $row) {
             $note = $this->getTable('Note');
             $note->bind($row);
             $note->likes = FD::likes($row->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER);
             $note->comments = FD::comments($row->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER);
             $notes[] = $note;
         }
     }
     // Get the profile
     $user = FD::user($userId);
     $this->set('user', $user);
     $this->set('notes', $notes);
     echo parent::display('profile/default');
 }
Example #8
0
 /**
  * Displays the single note item
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($userId = null, $docType = null)
 {
     $id = JRequest::getInt('cid');
     $appid = JRequest::getInt('id');
     // Get the current owner of this app canvas
     $user = FD::user($userId);
     $note = $this->getTable('Note');
     $note->load($id);
     if (!$id || !$note) {
         FD::info()->set(false, JText::_('APP_USER_NOTES_INVALID_NOTE_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $this->redirect(FD::profile(array('id' => $user->getAlias()), false));
     }
     // Load up likes library for this note.
     $likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER);
     // Load up comments library for this note.
     $comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => ''));
     $this->set('likes', $likes);
     $this->set('comments', $comments);
     $this->set('note', $note);
     $this->set('user', $user);
     $this->set('appId', $appid);
     echo parent::display('canvas/default');
 }
Example #9
0
 /**
  * Prepares the stream item
  *
  * @since	1.0
  * @access	public
  * @param	SocialStreamItem	The stream object.
  * @param	bool				Determines if we should respect the privacy
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != 'discussions') {
         return;
     }
     // group access checking
     $group = FD::group($item->cluster_id);
     if (!$group) {
         return;
     }
     if (!$group->canViewItem()) {
         return;
     }
     // Ensure that announcements are enabled for this group
     $registry = $group->getParams();
     if (!$registry->get('discussions', true)) {
         return;
     }
     // Define standard stream looks
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $item->color = '#69b598';
     $item->fonticon = 'ies-comments';
     $item->label = FD::_('COM_EASYSOCIAL_STREAM_CONTEXT_TITLE_DISCUSSIONS_TOOLTIP', true);
     $params = $this->getApp()->getParams();
     if ($params->get('stream_' . $item->verb, true) == false) {
         return;
     }
     // Do not allow user to repost discussions
     $item->repost = false;
     // Process likes and comments differently.
     $likes = FD::likes();
     $likes->get($item->contextId, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, $item->uid);
     $item->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($item->contextId, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     if ($item->verb == 'create') {
         $this->prepareCreateDiscussionStream($item);
     }
     if ($item->verb == 'reply') {
         $this->prepareReplyStream($item);
     }
     if ($item->verb == 'answered') {
         $this->prepareAnsweredStream($item);
     }
     if ($item->verb == 'lock') {
         $this->prepareLockedStream($item);
     }
 }
Example #10
0
 /**
  * Triggered when preparing an article for display
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function onContentPrepare($context, &$article, &$params)
 {
     if ($context != 'com_content.article') {
         return;
     }
     if (!$this->exists()) {
         return;
     }
     // Get the current viewer
     $my = FD::user();
     // Get app and plugin params
     $pluginParams = $this->getPluginParams();
     $appParams = $this->getAppParams();
     // Only assign points to viewer when they are not a guest and not the owner of the article
     if ($my->id && $my->id != $article->created_by && JRequest::getVar('view') == 'article' && !$this->sessionExists()) {
         // Assign points to viewer
         $this->assignPoints('read.article', $my->id);
         // Assign badge to the viewer
         $this->assignBadge('read.article', JText::_('PLG_CONTENT_EASYSOCIAL_UPDATED_EXISTING_ARTICLE'));
         // Assign points to author when their article is being read
         $this->assignPoints('author.read.article', $article->created_by);
         // Create a new stream item when an article is being read
         if ($appParams->get('stream_read', true)) {
             $this->createStream($article, 'read', $my->id);
         }
     }
     $comments = '';
     // Load css files
     $this->loadAssets();
     FD::language()->loadSite();
     // If configured to display comemnts
     if ($my->id && $pluginParams->get('load_comments', false)) {
         $url = ContentHelperRoute::getArticleRoute($article->id . ':' . $article->alias, $article->catid);
         $comments = FD::comments($article->id, 'article', 'create', SOCIAL_APPS_GROUP_USER, array('url' => $url));
         $comments = $comments->getHtml();
     }
     // Get the author of the article
     if (isset($article->created_by)) {
         $author = FD::user($article->created_by);
         $displayAuthor = $pluginParams->get('display_author', true);
         $displayInfo = $pluginParams->get('display_info', true);
         // Get a list of badges the author has
         $badges = $author->getBadges();
         ob_start();
         require_once dirname(__FILE__) . '/tmpl/article.php';
         $contents = ob_get_contents();
         ob_end_clean();
         $article->text .= $contents;
     }
 }
Example #11
0
 /**
  * Generates the stream title of event.
  *
  * @since    1.0
  * @access    public
  * @param    object    $params        A standard object with key / value binding.
  *
  * @return    none
  */
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     if ($stream->context != 'links') {
         return;
     }
     // event access checking
     $event = FD::event($stream->cluster_id);
     if (!$event || !$event->canViewItem()) {
         return;
     }
     //get links object, in this case, is the stream_item
     $uid = $stream->uid;
     $stream->color = '#5580BE';
     $stream->fonticon = 'ies-link';
     $stream->label = FD::_('APP_EVENT_LINKS_STREAM_TOOLTIP', true);
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_EVENT, $stream->uid);
     $stream->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_EVENT, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream->uid))), $stream->uid);
     $stream->comments = $comments;
     // Apply repost on the stream
     $stream->repost = FD::get('Repost', $stream->uid, SOCIAL_TYPE_STREAM, SOCIAL_APPS_GROUP_EVENT);
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_LINKS, $stream->actor->id)) {
         return;
     }
     $actor = $stream->actor;
     $target = count($stream->targets) > 0 ? $stream->targets[0] : '';
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $assets = $stream->getAssets();
     if (empty($assets)) {
         return;
     }
     $assets = $assets[0];
     $videoHtml = '';
     // Retrieve the link that is stored.
     $hash = md5($assets->get('link'));
     $link = FD::table('Link');
     $link->load(array('hash' => $hash));
     $linkObj = FD::json()->decode($link->data);
     // Determine if there's any embedded object
     $oembed = isset($linkObj->oembed) ? $linkObj->oembed : '';
     // Get app params
     $params = $this->getParams();
     $this->set('event', $event);
     $this->set('params', $params);
     $this->set('oembed', $oembed);
     $this->set('assets', $assets);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $stream);
     $stream->title = parent::display('streams/title.' . $stream->verb);
     $stream->preview = parent::display('streams/preview.' . $stream->verb);
     return true;
 }
Example #12
0
 private function attachActions(&$item, &$news, $permalink, $appParams)
 {
     // We need to link the comments to the news
     $item->comments = FD::comments($news->id, 'news', 'create', SOCIAL_APPS_GROUP_GROUP, array('url' => $permalink), $item->uid);
     // The comments for the stream item should link to the news itself.
     if (!$appParams->get('allow_comments') || !$news->comments) {
         $item->comments = false;
     }
     // The likes needs to be linked to the news itself
     $likes = FD::likes();
     $likes->get($news->id, 'news', 'create', SOCIAL_APPS_GROUP_GROUP, $item->uid);
     $item->likes = $likes;
 }
Example #13
0
 /**
  * Responsible to generate the stream contents.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$item)
 {
     // Load up the config object
     $config = FD::config();
     if ($item->context != 'badges' || !$config->get('badges.enabled')) {
         return;
     }
     // Check if the app should be able to generate the stream.
     $params = $this->getParams();
     if (!$params->get('stream_achieved', true)) {
         return;
     }
     // Test if stream item is allowed
     if (!$this->onStreamValidatePrivacy($item)) {
         return;
     }
     // Get the actor
     $actor = $item->actor;
     // Try to get the badge object from the params
     $raw = $item->params;
     $badge = FD::table('Badge');
     $badge->load($item->contextId);
     // Set the display mode to be full.
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $item->color = '#FEBC9D';
     $item->fonticon = 'ies-crown';
     $item->label = JText::_('APP_USER_BADGES_STREAM_TOOLTIP');
     // Format the likes for the stream
     $likes = FD::likes();
     $likes->get($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, $item->uid);
     $item->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     $this->set('badge', $badge);
     $this->set('actor', $actor);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     $item->content = parent::display('streams/' . $item->verb . '.content');
     return true;
 }
Example #14
0
<?php

/**
* @package		EasySocial
* @copyright	Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* EasySocial is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Unauthorized Access');
?>
<div data-photo-likes-holder class="es-item-likes">
	<?php 
echo FD::likes($photo->id, SOCIAL_TYPE_PHOTO, 'upload', SOCIAL_APPS_GROUP_USER)->toString();
?>
</div>
<div data-photo-comments-holder class="es-item-comments">
	<?php 
echo FD::comments($photo->id, SOCIAL_TYPE_PHOTO, 'upload', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::photos(array('layout' => 'item', 'id' => $photo->id))))->getHTML();
?>
</div>
Example #15
0
 /**
  * Formats a stream item with the necessary data.
  *
  * Example:
  * <code>
  * </code>
  *
  * @since	1.0
  * @access	public
  * @param	Array
  *
  */
 public function format($items, $context = 'all', $viewer = null, $loadCoreAction = true, $defaultEvent = 'onPrepareStream', $options = array())
 {
     // Get the current user
     $my = is_null($viewer) ? FD::user() : FD::user($viewer);
     // Basic display options
     $commentLink = isset($options['commentLink']) && $options['commentLink'] || !isset($options['commentLink']) ? true : false;
     $commentForm = isset($options['commentForm']) && $options['commentForm'] || !isset($options['commentForm']) ? true : false;
     // Default the event to onPrepareStream
     if (!$defaultEvent) {
         $defaultEvent = 'onPrepareStream';
     }
     // Determines if this is a stream
     $isStream = false;
     if ($defaultEvent == 'onPrepareStream') {
         $isStream = true;
     }
     // If there's no items, skip formatting this because it's pointless to run after this.
     if (!$items) {
         return $items;
     }
     // Prepare default data
     $data = array();
     $activeUser = FD::user();
     // Get stream model
     $model = FD::model('Stream');
     //current user being view.
     $targetUser = JRequest::getInt('id', '');
     if (empty($targetUser)) {
         $targetUser = $my->id;
     }
     if ($targetUser && strpos($targetUser, ':')) {
         $tmp = explode(':', $targetUser);
         $targetUser = $tmp[0];
     }
     // Get template configuration
     $templateConfig = FD::themes()->getConfig();
     // Get the site configuration
     $config = FD::config();
     // Link options
     // We only have to do this once instead of putting inside the loop.
     $linkOptions = array('target' => '_blank');
     if ($config->get('stream.content.nofollow')) {
         $linkOptions['rel'] = 'nofollow';
     }
     // Format items with appropriate objects.
     foreach ($items as &$row) {
         // Get the uid
         $uid = $row->id;
         // Get the last updated time
         $lastupdate = $row->modified;
         // Determines if this is a cluster
         $isCluster = $row->cluster_id ? true : false;
         // Obtain related activities for aggregation.
         $relatedActivities = null;
         if ($isStream) {
             $relatedActivities = $model->getRelatedActivities($uid, $row->context_type, $viewer);
         } else {
             $relatedActivities = $model->getActivityItem($uid);
         }
         $aggregatedData = $this->buildAggregatedData($relatedActivities);
         // Get the stream item.
         $streamItem = new SocialStreamItem();
         if (isset($row->isNew)) {
             $streamItem->isNew = $row->isNew;
         }
         // Set the state
         $streamItem->state = $row->state;
         // Set the actors (Aggregated actors )
         $streamItem->actors = $aggregatedData->actors;
         // Set the edited value
         $streamItem->edited = isset($row->edited) ? $row->edited : false;
         // Set the content
         $streamItem->content = $row->content;
         $streamItem->content_raw = $row->content;
         // Set the title of the stream item.
         $streamItem->title = $row->title;
         // Set the targets (Aggregated targets )
         $streamItem->targets = $aggregatedData->targets;
         // Set the aggregated items here so 3rd party can manipulate the data.
         $streamItem->aggregatedItems = $relatedActivities;
         $streamItem->contextIds = $aggregatedData->contextIds;
         // Set the context params. ( Aggregated params )
         $streamItem->contextParams = $aggregatedData->params;
         // main stream params
         $streamItem->params = $row->params;
         // Set the stream uid / activity id.
         $streamItem->uid = $uid;
         // Set stream lapsed time
         $streamItem->lapsed = FD::date($row->created)->toLapsed();
         $streamItem->created = FD::date($row->created);
         // Set the actor with the user object.
         $streamItem->actor = FD::user($row->actor_id);
         // Set the context id.
         $streamItem->contextId = $aggregatedData->contextIds[0];
         // Set the verb for this item.
         $streamItem->verb = $aggregatedData->verbs[0];
         // Set the context type.
         $streamItem->context = $row->context_type;
         // stream display type
         $streamItem->display = $row->stream_type;
         // stream cluster_id
         $streamItem->cluster_id = $row->cluster_id;
         // stream cluster_type
         $streamItem->cluster_type = $row->cluster_type;
         // stream cluster_type
         $streamItem->cluster_access = $row->cluster_access;
         // stream privacy access
         $streamItem->access = $row->access;
         // stream privacy access
         $streamItem->custom_access = $row->custom_access;
         // Define an empty color
         $streamItem->color = '';
         // Define an empty favicon
         $streamItem->icon = '';
         // Always enable labels
         $streamItem->label = true;
         $streamItem->custom_label = '';
         $streamItem->opengraph = FD::opengraph();
         // Determines if this stream item has been bookmarked by the viewer
         $streamItem->bookmarked = false;
         if ($row->bookmarked) {
             $streamItem->bookmarked = true;
         }
         // Determines if this stream item has been bookmarked by the viewer
         $streamItem->sticky = false;
         if ($row->sticky) {
             $streamItem->sticky = true;
         }
         // @TODO: Since our stream has a unique favi on for each item. We need to get it here.
         // Each application is responsible to override this favicon, or stream wil use the context type.
         $streamItem->favicon = $row->context_type;
         $streamItem->type = $row->context_type;
         $streamDateDisplay = $templateConfig->get('stream_datestyle');
         $streamItem->friendlyDate = $streamItem->lapsed;
         if ($streamDateDisplay == 'datetime') {
             $streamItem->friendlyDate = $streamItem->created->toFormat($templateConfig->get('stream_dateformat_format', 'Y-m-d H:i'));
         }
         // getting the the with and mention tagging for the stream, only if the item is a stream.
         $streamItem->with = array();
         $streamItem->mention = array();
         if ($isStream) {
             $streamItem->with = $this->getStreamTagWith($uid);
             $streamItem->tags = $this->getTags($uid);
         }
         // Format the mood
         if (!empty($row->mood_id)) {
             $mood = FD::table('Mood');
             $mood->id = $row->md_id;
             $mood->namespace = $row->md_namespace;
             $mood->namespace_uid = $row->md_namespace_uid;
             $mood->icon = $row->md_icon;
             $mood->verb = $row->md_verb;
             $mood->subject = $row->md_subject;
             $mood->custom = $row->md_custom;
             $mood->text = $row->md_text;
             $mood->user_id = $row->md_user_id;
             $mood->created = $row->md_created;
             $streamItem->mood = $mood;
         }
         // Format the users that are tagged in this stream.
         if (!empty($row->location_id)) {
             $location = FD::table('Location');
             //$location->load( $row->location_id );
             // lets  assign the values into location jtable.
             $location->id = $row->loc_id;
             $location->uid = $row->loc_uid;
             $location->type = $row->loc_type;
             $location->user_id = $row->loc_user_id;
             $location->created = $row->loc_created;
             $location->short_address = $row->loc_short_address;
             $location->address = $row->loc_address;
             $location->latitude = $row->loc_latitude;
             $location->longitude = $row->loc_longitude;
             $location->params = $row->loc_params;
             $streamItem->location = $location;
         }
         // target user. this target user is different from the targets. this is the user who are being viewed currently.
         $streamItem->targetUser = $targetUser;
         // privacy
         $streamItem->privacy = null;
         // Check if the content is not empty. We need to perform some formatings
         if (isset($streamItem->content) && !empty($streamItem->content)) {
             $content = $streamItem->content;
             // Format mentions
             $content = $this->formatMentions($streamItem);
             // Apply e-mail replacements
             $content = FD::string()->replaceEmails($content);
             // Apply bbcode
             $content = FD::string()->parseBBCode($content, array('escape' => false, 'links' => true, 'code' => true));
             // Some app might want the raw contents
             $streamItem->content_raw = $streamItem->content;
             $streamItem->content = $content;
         }
         // Stream meta
         $streamItem->meta = '';
         if (!empty($streamItem->with) || !empty($streamItem->location) || !empty($streamItem->mood)) {
             $theme = FD::themes();
             $theme->set('stream', $streamItem);
             $streamItem->meta = $theme->output('site/stream/meta');
         }
         // Determines if the stream item is deleteable
         $streamItem->deleteable = false;
         // Determines if the stream item is editable
         $streamItem->editable = false;
         // Group stream should allow cluster admins to delete
         if ($streamItem->cluster_id) {
             $cluster = FD::cluster($streamItem->cluster_type, $streamItem->cluster_id);
             if ($cluster->isAdmin() || FD::user()->isSiteAdmin() || FD::user()->getAccess()->allowed('stream.delete', false) && FD::user()->id == $streamItem->actor->id) {
                 $streamItem->deleteable = true;
             }
         } else {
             if (FD::user()->getAccess()->allowed('stream.delete', false) && FD::user()->id == $streamItem->actor->id) {
                 $streamItem->deleteable = true;
             }
         }
         if (FD::user()->isSiteAdmin()) {
             $streamItem->deleteable = true;
         }
         // streams actions.
         $streamItem->comments = $defaultEvent == 'onPrepareStream' ? true : false;
         $streamItem->likes = $defaultEvent == 'onPrepareStream' ? true : false;
         $streamItem->repost = $defaultEvent == 'onPrepareStream' ? true : false;
         // @trigger onPrepareStream / onPrepareActivity
         $includePrivacy = $isCluster ? false : true;
         $result = $this->{$defaultEvent}($streamItem, $includePrivacy);
         // Allow app to stop loading / generating the stream and
         // if there is still no title, we need to skip this stream altogether.
         if ($result === false || !$streamItem->title) {
             continue;
         }
         // Set the plain content here.
         if (empty($streamItem->opengraph->properties['description'])) {
             $streamItem->opengraph->addDescription(strip_tags($streamItem->content));
         }
         // This mean the plugin did not set any privacy. lets use the stream / activity.
         if (is_null($streamItem->privacy) && !$isCluster) {
             $privacyObj = FD::privacy($activeUser->id);
             $privacy = isset($row->privacy) ? $row->privacy : null;
             $pUid = $uid;
             $tmpStreamId = $defaultEvent == 'onPrepareActivityLog' ? $row->uid : $row->id;
             $sModel = FD::model('Stream');
             $aItem = $sModel->getActivityItem($tmpStreamId, 'uid');
             if (count($streamItem->contextIds) == 1 && is_null($privacy)) {
                 if ($aItem) {
                     $pUid = $aItem[0]->id;
                 }
             }
             if (!$privacyObj->validate('core.view', $pUid, SOCIAL_TYPE_ACTIVITY, $streamItem->actor->id)) {
                 continue;
             }
             $tmpStreamId = $streamItem->aggregatedItems[0]->uid;
             if ($defaultEvent == 'onPrepareActivityLog') {
                 $tmpStreamId = count($aItem) > 1 ? '' : $tmpStreamId;
             }
             $streamItem->privacy = $privacyObj->form($pUid, SOCIAL_TYPE_ACTIVITY, $streamItem->actor->id, null, false, $tmpStreamId);
         }
         $itemGroup = $streamItem->cluster_id ? $streamItem->cluster_type : SOCIAL_APPS_GROUP_USER;
         if ($streamItem->display != SOCIAL_STREAM_DISPLAY_MINI) {
             $canComment = true;
             // comments
             if (isset($streamItem->comments) && $streamItem->comments) {
                 if (!$streamItem->comments instanceof SocialCommentBlock) {
                     $streamItem->comments = FD::comments($streamItem->contextId, $streamItem->context, $streamItem->verb, $itemGroup, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $streamItem->uid))), $streamItem->uid);
                 }
                 // for comments, we need to check against the actor privacy and see if the current viewer allow to
                 // post comments on their stream items or not.
                 if (!$isCluster) {
                     $privacyObj = FD::privacy($activeUser->id);
                     if (!$privacyObj->validate('story.post.comment', $streamItem->actor->id, SOCIAL_TYPE_USER)) {
                         $canComment = false;
                     }
                 }
             }
             // Set comment option the streamid
             if ($streamItem->comments) {
                 $streamItem->comments->setOption('streamid', $streamItem->uid);
             }
             // If comments link is meant to be disabled, hide it
             if (!$commentLink) {
                 $streamItem->commentLink = false;
             }
             // If comments is meant to be disabled, hide it.
             if ($streamItem->comments && (isset($streamItem->commentForm) && !$streamItem->commentForm || !$commentForm || !$canComment)) {
                 $streamItem->comments->setOption('hideForm', true);
             }
             //likes
             if (isset($streamItem->likes) && $streamItem->likes) {
                 if (!$streamItem->likes instanceof SocialLikes) {
                     $likes = FD::likes();
                     $likes->get($streamItem->contextId, $streamItem->context, $streamItem->verb, $itemGroup, $streamItem->uid);
                     $streamItem->likes = $likes;
                 }
             }
             //set likes option the streamid
             if ($streamItem->likes) {
                 $streamItem->likes->setOption('streamid', $streamItem->uid);
             }
             // Build repost links
             if (isset($streamItem->repost) && $streamItem->repost) {
                 if (!$streamItem->repost instanceof SocialRepost) {
                     $repost = FD::get('Repost', $streamItem->uid, SOCIAL_TYPE_STREAM, $itemGroup);
                     $streamItem->repost = $repost;
                 }
             }
             // set cluseter into repost
             if ($isCluster && $streamItem->repost) {
                 $streamItem->repost->setCluster($streamItem->cluster_id, $streamItem->cluster_type);
             }
             // Enable sharing on the stream
             if ($config->get('stream.sharing.enabled')) {
                 if (!isset($streamItem->sharing) || isset($streamItem->sharing) && $streamItem->sharing !== false && !$streamItem->sharing instanceof SocialSharing) {
                     $sharing = FD::get('Sharing', array('url' => FRoute::stream(array('layout' => 'item', 'id' => $streamItem->uid, 'external' => true), true), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small'));
                     $streamItem->sharing = $sharing;
                 }
             }
             // Now we have all the appropriate data, populate the actions
             $streamItem->actions = $this->getActions($streamItem);
         } else {
             $streamItem->comments = false;
             $streamItem->likes = false;
             $streamItem->repost = false;
             $streamItem->actions = '';
         }
         // Re-assign stream item to the result list.
         $data[] = $streamItem;
     }
     // here we know, the result from queries contain some records but it might return empty data due to privacy.
     // if that is the case, then we return TRUE so that the library will go retrieve the next set of data.
     if (count($data) <= 0) {
         return true;
     }
     return $data;
 }
Example #16
0
 /**
  * Prepares the stream item
  *
  * @since	1.0
  * @access	public
  * @param	SocialStreamItem	The stream object.
  * @param	bool				Determines if we should respect the privacy
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != SOCIAL_TYPE_FILES) {
         return;
     }
     // if this is a cluster stream, let check if user can view this stream or not.
     if ($item->cluster_id && $item->cluster_type) {
         $cluster = FD::cluster($item->cluster_type, $item->cluster_id);
         if (!$cluster) {
             return;
         }
         if (!$cluster->canViewItem()) {
             return;
         }
         $item->display = SOCIAL_STREAM_DISPLAY_FULL;
         if ($item->cluster_type == SOCIAL_TYPE_GROUP) {
             $item->color = '#303229';
             $item->fonticon = 'ies-users';
             $item->label = JText::_('APP_USER_FILES_GROUPS_STREAM_TOOLTIP');
         }
         if ($item->cluster_type == SOCIAL_TYPE_EVENT) {
             $item->color = '#f06050';
             $item->fonticon = 'ies-calendar';
             $item->label = JText::_('APP_USER_EVENTS_STREAM_TOOLTIP');
         }
         if ($item->verb == 'uploaded') {
             $this->prepareUploadedStream($item);
         }
         return;
     }
     // File uploads by user
     if (isset($item->contextParams[0])) {
         $params = FD::registry($item->contextParams[0]);
         $items = $params->get('files');
         $total = count($items);
         $files = array();
         if (!$items) {
             return;
         }
         foreach ($items as $id) {
             $file = FD::table('File');
             $file->load($id);
             $files[] = $file;
         }
         $plurality = $total > 1 ? '_PLURAL' : '_SINGULAR';
         $targets = $item->targets ? $item->targets[0] : false;
         $this->set('target', $targets);
         $this->set('content', $item->content);
         $this->set('plurality', $plurality);
         $this->set('total', $total);
         $this->set('files', $files);
         $this->set('actor', $item->actor);
         $item->display = SOCIAL_STREAM_DISPLAY_FULL;
         $item->color = '#00B6AD';
         $item->fonticon = 'ies-file';
         $item->label = JText::_('APP_USER_FILES_STREAM_TOOLTIP');
         // Apply likes on the stream
         $likes = FD::likes();
         $likes->get($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_USER, $item->uid);
         $item->likes = $likes;
         // Apply comments on the stream
         $comments = FD::comments($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
         $item->comments = $comments;
         $item->title = parent::display('streams/uploaded.title.user');
         $item->content = parent::display('streams/uploaded.content.user');
     }
 }
Example #17
0
 /**
  * Retrieves the comments count for this photo
  *
  * @since   1.0
  * @access  public
  * @param   string
  * @return
  */
 public function getCommentsCount()
 {
     static $comments = array();
     if (!isset($comments[$this->id])) {
         // Default context
         $context = SOCIAL_TYPE_PHOTO;
         $verb = 'add';
         $group = $this->type;
         $id = $this->id;
         // We need to determine if the album is a core one
         $album = $this->getAlbum();
         if ($album->core == SOCIAL_ALBUM_PROFILE_PHOTOS) {
             $verb = 'uploadAvatar';
         }
         if ($album->core == SOCIAL_ALBUM_PROFILE_COVERS) {
             $verb = 'updateCover';
         }
         if ($album->core == SOCIAL_ALBUM_STORY_ALBUM) {
             $verb = 'upload';
             $context = SOCIAL_TYPE_STREAM;
             // We need to test if this photo contains single stream item or aggregated
             $model = FD::model('Stream');
             $aggregated = $model->isAggregated($this->id, 'photos');
             if (!$aggregated) {
                 $context = SOCIAL_TYPE_PHOTO;
                 $verb = 'upload';
             }
         }
         $count = FD::comments($id, $context, $verb, $group)->getCount();
         $comments[$this->id] = $count;
     }
     return $comments[$this->id];
 }
Example #18
0
 /**
  * Prepares the stream item
  *
  * @since	1.0
  * @access	public
  * @param	SocialStreamItem	The stream object.
  * @param	bool				Determines if we should respect the privacy
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context !== 'notes') {
         return;
     }
     // Determine if we should display the stream items
     $params = $this->getParams();
     if ($item->verb == 'create' && !$params->get('stream_create', true)) {
         return;
     }
     if ($item->verb == 'update' && !$params->get('stream_update', true)) {
         return;
     }
     // Decorate the stream
     $item->color = '#552E54';
     $item->fonticon = 'ies-notebook';
     $item->label = FD::_('APP_USER_NOTES_STREAM_TOOLTIP', true);
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     // Apply comments on the stream
     $app = $this->getApp();
     $permalink = $app->getPermalink('canvas', array('userId' => $item->actor->id, 'cid' => $item->contextId));
     $comments = FD::comments($item->contextId, $item->context, $item->verb, SOCIAL_APPS_GROUP_USER, array('url' => $permalink), $item->uid);
     $item->comments = $comments;
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($item->contextId, $item->context, $item->verb, SOCIAL_APPS_GROUP_USER, $item->uid);
     $item->likes = $likes;
     // Apply repost on the stream
     $repost = FD::get('Repost', $item->uid, SOCIAL_TYPE_STREAM);
     $item->repost = $repost;
     // Load the note
     $note = $this->getTable('Note');
     $note->load($item->contextId);
     // Get params
     $params = $this->getParams();
     $this->set('params', $params);
     $this->set('note', $note);
     $this->set('actor', $item->actor);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     $item->content = parent::display('streams/' . $item->verb . '.content');
     $item->opengraph->addDescription($note->getContent());
 }
Example #19
0
 /**
  * Triggered to prepare the stream item
  *
  * @since   1.0
  * @access  public
  * @param   string
  * @return
  */
 public function onPrepareStream(SocialStreamItem &$item)
 {
     // If this is not it's context, we don't want to do anything here.
     if ($item->context != 'story') {
         return;
     }
     // Get the event object
     $group = $item->getCluster();
     if (!$group) {
         return;
     }
     if (!$group->canViewItem()) {
         return;
     }
     // Allow editing of the stream item
     $item->editable = $this->my->isSiteAdmin() || $group->isAdmin() || $item->actor->id == $this->my->id;
     // Get the actor
     $actor = $item->getActor();
     // Decorate the stream
     $item->fonticon = 'ies-pencil-2';
     $item->color = '#6E9545';
     $item->label = FD::_('APP_GROUP_STORY_STREAM_TOOLTIP', true);
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $this->set('group', $group);
     $this->set('actor', $actor);
     $this->set('stream', $item);
     $item->title = parent::display('streams/title.' . $item->verb);
     $item->content = parent::display('streams/content.' . $item->verb);
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, $item->uid);
     $item->likes = $likes;
     // If this update is posted in a group, the comments should be linked to the group item
     $comments = FD::comments($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     return true;
 }
Example #20
0
 /**
  * Retrieves a list of notification targets
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function getStreamNotificationTargets($uid, $element, $group, $verb, $targets = array(), $exclusion = array())
 {
     // Get a list of people that also likes this
     $likes = FD::likes($uid, $element, $verb, $group);
     $targets = array_merge($targets, $likes->getParticipants(false));
     // Get people who are part of the comments
     $comments = FD::comments($uid, $element, $verb, $group);
     $targets = array_merge($targets, $comments->getParticipants(array(), false));
     // Remove exclustion
     $targets = array_diff($targets, $exclusion);
     // Ensure that recipients are unique now.
     $targets = array_unique($targets);
     // Reset all indexes
     $targets = array_values($targets);
     return $targets;
 }
Example #21
0
 /**
  * Creates a new note.
  *
  * @since	1.0
  * @access	public
  */
 public function store()
 {
     // Check for request forgeriess
     FD::checkToken();
     // Ensure that the user is logged in.
     FD::requireLogin();
     // Get ajax lib
     $ajax = FD::ajax();
     // Get the current user.
     $my = FD::user();
     // Get the app id.
     $appId = JRequest::getInt('appId');
     // Get the title from request
     $title = JRequest::getVar('title');
     // Get the note content from request
     $content = JRequest::getVar('content');
     $stream = JRequest::getBool('stream');
     // Check if this is an edited entry
     $id = JRequest::getInt('id');
     // Create the note
     $note = $this->getTable('Note');
     $state = $note->load($id);
     if ($id && $state) {
         if ($note->user_id != $my->id) {
             return $ajax->reject();
         }
     }
     $note->title = $title;
     $note->content = $content;
     $note->user_id = $my->id;
     $state = $note->store();
     $note->link = FRoute::_('index.php?option=com_easysocial&view=apps&layout=canvas&id=' . $appId . '&cid=' . $note->id . '&userId=' . $my->id);
     if (!$state) {
         return $ajax->reject($note->getError());
     }
     // Format the note comments
     // Get the comments count
     $comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::apps(array('layout' => 'canvas', 'userid' => $my->getAlias(), 'cid' => $note->id))));
     $note->comments = $comments->getCount();
     // Get the likes count
     $likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER);
     $note->likes = $likes->getCount();
     // Create a stream record
     if ($stream) {
         $verb = $id ? 'update' : 'create';
         $note->createStream($verb);
     }
     // Format the note.
     $comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::apps(array('layout' => 'canvas', 'userid' => $my->getAlias(), 'cid' => $note->id))));
     $likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER);
     $stream = FD::stream();
     $options = array('comments' => $comments, 'likes' => $likes);
     $note->actions = $stream->getActions($options);
     $app = $this->getApp();
     $theme = FD::themes();
     $theme->set('app', $app);
     $theme->set('user', $my);
     $theme->set('appId', $appId);
     $theme->set('note', $note);
     $content = $theme->output('apps/user/notes/dashboard/item');
     return $ajax->resolve($content);
 }
Example #22
0
 /**
  * Responsible to generate the stream contents.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     // Only process this if the stream type is shares
     if ($item->context != 'shares' || !$item->cluster_type) {
         return;
     }
     // Get the single context id
     $id = $item->contextId;
     // We only need the single actor.
     // Load the profiles table.
     $share = FD::table('Share');
     $share->load($id);
     // If shared item no longer exist, exit here.
     if (!$share->id) {
         return;
     }
     // Get the current logged in user
     $my = FD::user();
     // Break down the shared element
     $segments = explode('.', $share->element);
     $element = $segments[0];
     $group = $segments[1];
     // We only want to process items from albums, photos and stream
     $allowed = array('albums', 'photos', 'stream');
     if (!in_array($element, $allowed)) {
         return;
     }
     // Get the repost helper
     $helper = $this->getHelper($item, $share);
     // We want the likes and comments to be associated with the "stream" rather than the shared item
     $uid = $item->uid;
     $element = 'story';
     $verb = 'create';
     // Load up custom likes
     $likes = FD::likes();
     $likes->get($uid, $element, $verb, SOCIAL_APPS_GROUP_GROUP, $item->uid);
     $item->likes = $likes;
     // Attach comments to the stream
     $comments = FD::comments($uid, $element, $verb, SOCIAL_APPS_GROUP_GROUP, array('url' => $helper->getLink()), $item->uid);
     $item->comments = $comments;
     // Share app does not allow reposting itself.
     $item->repost = false;
     // Get the content of the repost
     $item->content = $helper->getContent();
     // If the content is a false, there could be privacy restrictions.
     if ($item->content === false) {
         return;
     }
     // Decorate the stream item
     $item->fonticon = 'ies-refresh';
     $item->color = '#e74c3c';
     $item->label = JText::_('APP_GROUP_REPOST_STREAM_TITLE');
     $item->title = $helper->getTitle();
     // Set stream display mode.
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
 }
Example #23
0
 /**
  * Processes the stream actions
  *
  * @since   1.2
  * @access  public
  */
 private function processActions(SocialStreamItem &$item)
 {
     // Whether the item is shared or uploaded via the photo albums, we need to bind the repost here
     $repost = FD::get('Repost', $item->uid, SOCIAL_TYPE_STREAM, SOCIAL_APPS_GROUP_EVENT);
     $item->repost = $repost;
     // For photo items that are shared on the stream
     if ($item->verb == 'share') {
         // By default, we'll use the stream id as the object id
         $objectId = $item->uid;
         $objectType = SOCIAL_TYPE_STREAM;
         $commentUrl = FRoute::stream(array('layout' => 'item', 'id' => $item->uid));
         // When there is only 1 photo that is shared on the stream, we need to link to the photo item
         // We will only alter the id
         if (count($item->contextIds) == 1) {
             $photo = FD::table('Photo');
             $photo->load($item->contextIds[0]);
             $objectId = $photo->id;
             $objectType = SOCIAL_TYPE_PHOTO;
             $commentUrl = $photo->getPermalink();
         }
         // Append the likes action on the stream
         $likes = FD::likes();
         $likes->get($objectId, $objectType, 'upload', SOCIAL_APPS_GROUP_EVENT, $item->uid);
         $item->likes = $likes;
         // Append the comment action on the stream
         $comments = FD::comments($objectId, $objectType, 'upload', SOCIAL_APPS_GROUP_EVENT, array('url' => $commentUrl), $item->uid);
         $item->comments = $comments;
         return;
     }
     // Here onwards, we are assuming the user is uploading the photos via the albums area.
     // If there is more than 1 photo uploaded, we need to link the likes and comments on the album
     if (count($item->contextIds) > 1) {
         $photos = $this->getPhotoObject($item);
         $photo = false;
         if ($photos instanceof SocialTablePhoto) {
             $photo = $photos;
         }
         if (is_array($photos)) {
             $photo = $photos[0];
         }
         // If we can't get anything, skip this
         if (!$photo) {
             return;
         }
         $element = SOCIAL_TYPE_ALBUM;
         $uid = $photo->album_id;
         // Get the album object
         $album = FD::table('Album');
         $album->load($photo->album_id);
         // Format the likes for the stream
         $likes = FD::likes();
         $likes->get($photo->album_id, 'albums', 'create', SOCIAL_APPS_GROUP_GROUP, $item->uid);
         $item->likes = $likes;
         // Apply comments on the stream
         $commentParams = array('url' => $album->getPermalink());
         $comments = FD::comments($photo->album_id, 'albums', 'create', SOCIAL_APPS_GROUP_GROUP, $commentParams, $item->uid);
         $item->comments = $comments;
         return;
     }
 }
Example #24
0
 /**
  * Generates the stream title of group.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     if ($stream->context != 'links') {
         return;
     }
     // Group access
     $group = FD::group($stream->cluster_id);
     if (!$group) {
         return;
     }
     if (!$group->canViewItem()) {
         return;
     }
     //get links object, in this case, is the stream_item
     $uid = $stream->uid;
     $stream->color = '#5580BE';
     $stream->fonticon = 'ies-link';
     $stream->label = FD::_('APP_GROUP_LINKS_STREAM_TOOLTIP', true);
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_GROUP, $stream->uid);
     $stream->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_GROUP, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream->uid))), $stream->uid);
     $stream->comments = $comments;
     // Apply repost on the stream
     $repost = FD::get('Repost', $stream->uid, SOCIAL_TYPE_STREAM, SOCIAL_APPS_GROUP_GROUP);
     $stream->repost = $repost;
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_LINKS, $stream->actor->id)) {
         return;
     }
     $actor = $stream->actor;
     $target = count($stream->targets) > 0 ? $stream->targets[0] : '';
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $assets = $stream->getAssets();
     if (empty($assets)) {
         return;
     }
     // Get the assets
     $assets = $assets[0];
     // Get app params
     $params = $this->getParams();
     // Retrieve the link that is stored.
     $hash = md5($assets->get('link'));
     // Load the link object
     $link = FD::table('Link');
     $link->load(array('hash' => $hash));
     // Get the link data
     $linkObj = json_decode($link->data);
     // Determine if there's any embedded object
     $oembed = isset($linkObj->oembed) ? $linkObj->oembed : '';
     $image = FD::links()->getImageLink($assets, $params);
     // Fix video issues with youtube when site is on https
     $oembed = FD::links()->fixOembedLinks($oembed);
     // Get the contents and truncate accordingly
     $content = $assets->get('content', '');
     if ($params->get('stream_link_truncate')) {
         $content = JString::substr(strip_tags($content), 0, $params->get('stream_link_truncate_length', 250)) . JText::_('COM_EASYSOCIAL_ELLIPSES');
     }
     $this->set('image', $image);
     $this->set('content', $content);
     $this->set('params', $params);
     $this->set('oembed', $oembed);
     $this->set('assets', $assets);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $stream);
     $this->set('group', $group);
     $stream->title = parent::display('streams/title.' . $stream->verb);
     $stream->preview = parent::display('streams/preview.' . $stream->verb);
     return true;
 }
 public function albumsSchema($rows, $userid)
 {
     //To load easysocial language constant
     $lang = JFactory::getLanguage();
     $lang->load('com_easysocial', JPATH_ADMINISTRATOR, 'en-GB', true);
     $result = array();
     foreach ($rows as $ky => $row) {
         if (isset($row->id)) {
             $item = new GetalbumsSimpleSchema();
             $item->id = $row->id;
             $item->cover_id = $row->cover_id;
             $item->type = $row->type;
             $item->uid = $row->uid;
             $item->title = JText::_($row->title);
             $item->caption = JText::_($row->caption);
             $item->created = $row->created;
             $item->assigned_date = $row->assigned_date;
             $item->cover_featured = $row->cover_featured;
             $item->cover_large = $row->cover_large;
             $item->cover_square = $row->cover_square;
             $item->cover_thumbnail = $row->cover_thumbnail;
             $item->count = $row->count;
             $likes = FD::likes($row->id, SOCIAL_TYPE_ALBUM, 'create', SOCIAL_APPS_GROUP_USER);
             $item->likes = $this->createlikeObj($likes, $userid);
             //$item->total=$item->likes->total;
             // Get album comments
             $comments = FD::comments($row->id, SOCIAL_TYPE_ALBUM, 'create', SOCIAL_APPS_GROUP_USER, array('url' => $row->getPermalink()));
             $item->comment_element = $comments->element . "." . $comments->group . "." . $comments->verb;
             $comments->stream_id = 1;
             //$comments->element=$item->comment_element;
             $item->comments = $this->createCommentsObj($comments);
             $options = array('uid' => $comments->uid, 'element' => $item->comment_element, 'stream_id' => $comments->stream_id);
             $model = FD::model('Comments');
             $comcount = $model->getCommentCount($options);
             $item->commentcount = $comcount;
             $item->isowner = $row->uid == $userid ? true : false;
             $result[] = $item;
         }
     }
     return $result;
 }
Example #26
0
 /**
  * Responsible to generate the stream content for profiles apps.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != 'profiles') {
         return;
     }
     // Get the application params
     $params = $this->getParams();
     if ($item->verb == 'update' && !$params->get('stream_update', true)) {
         return;
     }
     if ($item->verb == 'register' && !$params->get('stream_register', true)) {
         return;
     }
     $my = FD::user();
     // Decorate the stream
     $item->display = SOCIAL_STREAM_DISPLAY_MINI;
     if ($item->verb == 'register') {
         $item->color = '#FF7553';
         $item->fonticon = 'ies-user-add';
         $item->label = FD::_('APP_USER_PROFILES_REGISTER_STREAM_TOOLTIP', true);
     }
     // When user updates their profile.
     if ($item->verb == 'update') {
         $item->color = '#1FBCA7';
         $item->fonticon = 'ies-briefcase';
         $item->label = FD::_('APP_USER_PROFILES_UPDATE_PROFILE_STREAM_TOOLTIP', true);
     }
     $actor = $item->actor;
     if (!$actor->hasCommunityAccess()) {
         $item->title = '';
         return;
     }
     $genderValue = $actor->getFieldData('GENDER');
     $gender = 'THEIR';
     if ($genderValue == 1) {
         $gender = 'MALE';
     }
     if ($genderValue == 2) {
         $gender = 'FEMALE';
     }
     // Override the likes
     $item->likes = FD::likes($item->uid, 'userprofile', $item->verb, SOCIAL_APPS_GROUP_USER, $item->uid);
     // Override the comments
     $comments = FD::comments($item->uid, 'userprofile', $item->verb, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     $this->set('gender', $gender);
     $this->set('actor', $item->actor);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     return true;
 }
Example #27
0
 /**
  * Prepares the stream item.
  *
  * @since   1.3
  * @access  public
  * @param   SocialStreamItem    $item           The stream object.
  * @param   boolean             $includePrivacy True if privacy should be respected.
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != 'discussions') {
         return;
     }
     // Get the event object
     $event = FD::event($item->cluster_id);
     if (!$event) {
         return;
     }
     if (!$event->canViewItem()) {
         return;
     }
     // Define standard stream looks
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $item->color = '#69b598';
     $item->fonticon = 'ies-comments';
     $item->label = JText::_('COM_EASYSOCIAL_STREAM_CONTEXT_TITLE_DISCUSSIONS_TOOLTIP');
     $params = $this->getApp()->getParams();
     if ($params->get('stream_' . $item->verb, true) == false) {
         return;
     }
     // Do not allow user to repost discussions
     $item->repost = false;
     // Process likes and comments differently.
     $likes = FD::likes();
     $likes->get($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_EVENT, $item->uid);
     $item->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_EVENT, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     if ($item->verb == 'create') {
         $this->prepareCreateStream($item);
     }
     if ($item->verb == 'reply') {
         $this->prepareReplyStream($item);
     }
     if ($item->verb == 'answered') {
         $this->prepareAnsweredStream($item);
     }
     if ($item->verb == 'locked') {
         $this->prepareLockedStream($item);
     }
 }
Example #28
0
<?php

/**
* @package		EasySocial
* @copyright	Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* EasySocial is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Unauthorized Access');
?>
<div data-album-likes-holder class="es-item-likes">
	<?php 
echo FD::likes($album->id, SOCIAL_TYPE_ALBUM, 'create', SOCIAL_APPS_GROUP_USER)->toString();
?>
</div>
<div data-album-comments-holder class="es-item-comments">
	<?php 
echo FD::comments($album->id, SOCIAL_TYPE_ALBUM, 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::albums(array('layout' => 'item', 'id' => $album->id))))->getHTML();
?>
</div>
Example #29
0
 /**
  * Triggered to prepare the stream item
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     // If this is not it's context, we don't want to do anything here.
     if ($stream->context != 'story') {
         return;
     }
     $uid = $stream->uid;
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($stream->cluster_id) {
         // Group access checking
         $cluster = FD::cluster($stream->cluster_type, $stream->cluster_id);
         if (!$cluster) {
             return;
         }
         if (!$cluster->canViewItem()) {
             return;
         }
         // Allow editing of the stream item
         $stream->editable = $my->isSiteAdmin() || $cluster->isAdmin() || $stream->actor->id == $my->id;
     } else {
         // Allow editing of the stream item
         $stream->editable = $my->isSiteAdmin() || $stream->actor->id == $my->id;
     }
     // we stil need to check for the privacy because the context might come from the 'repost'
     if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_STORY, $stream->actor->id)) {
         return;
     }
     // Actor of this stream
     $actor = $stream->actor;
     $target = count($stream->targets) > 0 ? $stream->targets[0] : '';
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $stream->color = '#16a085';
     $stream->fonticon = 'ies-pencil-2';
     $stream->label = FD::_('APP_USER_STORY_UPDATES_STREAM_TOOLTIP', true);
     if ($stream->cluster_id) {
         if ($stream->cluster_type == SOCIAL_TYPE_GROUP) {
             $stream->color = '#303229';
             $stream->fonticon = 'ies-users';
             $stream->label = FD::_('APP_USER_STORY_GROUPS_STREAM_TOOLTIP', true);
         }
         if ($stream->cluster_type == SOCIAL_TYPE_EVENT) {
             $stream->color = '#f06050';
             $stream->fonticon = 'ies-calendar';
             $stream->label = FD::_('APP_USER_STORY_EVENTS_STREAM_TOOLTIP', true);
         }
     }
     $appGroup = SOCIAL_APPS_GROUP_USER;
     if ($stream->cluster_id) {
         if ($stream->cluster_type == SOCIAL_TYPE_EVENT) {
             $appGroup = SOCIAL_APPS_GROUP_EVENT;
         } else {
             $appGroup = SOCIAL_APPS_GROUP_GROUP;
         }
     }
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($stream->uid, $stream->context, $stream->verb, $appGroup, $stream->uid);
     $stream->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($stream->uid, $stream->context, $stream->verb, $appGroup, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream->uid))), $stream->uid);
     $stream->comments = $comments;
     // Apply repost on the stream
     $repost = FD::get('Repost', $stream->uid, SOCIAL_TYPE_STREAM, $appGroup);
     $stream->repost = $repost;
     // If this is a group type, and the viewer is not a member of the group, we need to hide these data
     if ($stream->cluster_id) {
         $cluster = FD::cluster($stream->cluster_type, $stream->cluster_id);
         if (!$cluster->isMember()) {
             $stream->commentLink = false;
             $stream->repost = false;
             $stream->commentForm = false;
         }
         // Sharing only show in public group
         if (!$cluster->isOpen()) {
             $stream->sharing = false;
         }
     }
     // Get application params
     $params = $this->getParams();
     $this->set('params', $params);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $stream);
     if ($stream->cluster_id) {
         $clusterReg = FD::registry($stream->params);
         $object = $clusterReg->get($stream->cluster_type);
         $cluster = FD::cluster($stream->cluster_type);
         if ($object) {
             // If have the object only bind
             $cluster->bind($object);
         } else {
             $cluster = $stream->getCluster();
         }
         $this->set('cluster', $cluster);
     }
     $titleFileName = $stream->cluster_type ? $stream->cluster_type . '.' . $stream->verb : $stream->verb;
     $stream->title = parent::display('streams/title.' . $titleFileName);
     $stream->content = parent::display('streams/content.' . $stream->verb);
     $stream->opengraph->addDescription($stream->content);
     if ($includePrivacy) {
         $stream->privacy = $privacy->form($uid, SOCIAL_TYPE_STORY, $stream->actor->id, 'story.view', false, $stream->uid);
     }
     return true;
 }
Example #30
0
 /**
  * Responsible to generate the stream contents.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$item)
 {
     // Load up the config object
     $config = FD::config();
     if ($item->context != 'badges' || !$config->get('badges.enabled')) {
         return;
     }
     // Check if the app should be able to generate the stream.
     $params = $this->getParams();
     if (!$params->get('stream_achieved', true)) {
         return;
     }
     // Get the actor
     $actor = $item->actor;
     // check if the actor is ESAD profile or not, if yes, we skip the rendering.
     if (!$actor->hasCommunityAccess()) {
         $item->title = '';
         return;
     }
     // Test if stream item is allowed
     if (!$this->onStreamValidatePrivacy($item)) {
         return;
     }
     // Try to get the badge object from the params
     $raw = $item->params;
     $badge = FD::table('Badge');
     $badge->load($item->contextId);
     // lets load 3rd party component's language file if this is not a core badge
     if ($badge->extension && $badge->extension != 'com_easysocial') {
         Foundry::language()->load($badge->extension, JPATH_ROOT);
     }
     // Set the display mode to be full.
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $item->color = '#FEBC9D';
     $item->fonticon = 'ies-crown';
     $item->label = FD::_('APP_USER_BADGES_STREAM_TOOLTIP', true);
     // Format the likes for the stream
     $likes = FD::likes();
     $likes->get($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, $item->uid);
     $item->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     $this->set('badge', $badge);
     $this->set('actor', $actor);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     $item->content = parent::display('streams/' . $item->verb . '.content');
     return true;
 }