/** * 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; }
/** * 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; } $streamGroup = SOCIAL_APPS_GROUP_USER; // group access checking if ($stream->cluster_id) { $streamGroup = $stream->cluster_type; if ($stream->cluster_type == SOCIAL_APPS_GROUP_GROUP) { $cluster = FD::group($stream->cluster_id); } if ($stream->cluster_type == SOCIAL_APPS_GROUP_EVENT) { $cluster = FD::event($stream->cluster_id); } if (!$cluster) { return; } if (!$cluster->canViewItem()) { return; } } //get links object, in this case, is the stream_item $uid = $stream->uid; $stream->color = '#5580BE'; $stream->fonticon = 'ies-link'; $stream->label = JText::_('APP_USER_LINKS_STREAM_TOOLTIP'); // Apply likes on the stream $stream->setLikes($streamGroup, $stream->uid); // Apply comments on the stream $permalink = FRoute::stream(array('layout' => 'item', 'id' => $stream->uid)); $stream->setComments($streamGroup, $stream->uid, array('url' => $permalink)); // Apply repost on the stream $stream->setRepost($streamGroup, SOCIAL_TYPE_STREAM); $my = FD::user(); $privacy = FD::privacy($my->id); if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_LINKS, $stream->actor->id)) { return; } // Get the person that created this stream item $actor = $stream->getActor(); // Get the targets if this stream was posted on another target $target = $stream->getTargets(); // Get the assets associated with this stream $assets = $stream->getAssets(); if (empty($assets)) { return; } $assets = $assets[0]; // Retrieve the link that is stored. $hash = md5($assets->get('link')); // Load the link object $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 : ''; $uri = JURI::getInstance(); // Get app params $params = $this->getParams(); // Get the image file $image = $assets->get('image'); $cachePath = ltrim($this->config->get('links.cache.location'), '/'); // @since 1.3.8 // This block of code should be removed later. // FIX Older images where 'cached' state is not stored. // Check if the image string contains the cached storage path if (!$assets->get('cached') && stristr($image, '/media/com_easysocial/cache') !== false) { $assets->set('cached', true); } // Dirty way of checking // If the image is cached, we need to get the correct path if ($assets->get('cached')) { $fileName = basename($image); $image = rtrim(JURI::root(), '/') . '/' . $cachePath . '/' . $fileName; } // If necessary, feed in our own proxy to avoid http over https issues. if ($params->get('stream_link_proxy', false) && ($oembed || $assets->get('image')) && $uri->getScheme() == 'https') { // Check if there are any http links if (isset($oembed->thumbnail) && $oembed->thumbnail && stristr($oembed->thumbnail, 'http://') !== false) { $oembed->thumbnail = FD::proxy($oembed->thumbnail); } if ($image && stristr($image, 'http://') !== false) { $image = FD::proxy($image); } } // Fix video issues with youtube when site is on https if (isset($oembed->provider_url) && $oembed->provider_url == 'http://www.youtube.com/') { $oembed->html = JString::str_ireplace('http://', 'https://', $oembed->html); } // 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); if ($stream->cluster_id) { if ($stream->cluster_type == SOCIAL_APPS_GROUP_GROUP) { $stream->label = JText::_('APP_USER_LINKS_GROUPS_STREAM_TOOLTIP'); $stream->color = '#303229'; $stream->fonticon = 'ies-users'; } if ($stream->cluster_type == SOCIAL_APPS_GROUP_EVENT) { $stream->color = '#f06050'; $stream->fonticon = 'ies-calendar'; $stream->label = JText::_('APP_USER_EVENTS_STREAM_TOOLTIP'); } $this->set('cluster', $cluster); $stream->title = parent::display('streams/title.' . $stream->verb . '.' . $stream->cluster_type); } else { $stream->title = parent::display('streams/title.' . $stream->verb); } // Set the stream display mode $stream->display = SOCIAL_STREAM_DISPLAY_FULL; // Set the preview $stream->preview = parent::display('streams/preview.' . $stream->verb); // Apply opengraph tags for this stream item when there is an image if ($image) { $stream->opengraph->addImage($image); } if ($content) { $stream->opengraph->addDescription($content); } else { $stream->opengraph->addDescription($stream->title); } // Include privacy checking or not if ($includePrivacy) { $stream->privacy = $privacy->form($uid, SOCIAL_TYPE_LINKS, $stream->actor->id, 'story.view', false, $stream->uid); } return true; }