public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true) { if ($stream->context != 'relationship') { return; } $params = $this->getParams(); if (!$params->get('stream_approve', true)) { return; } $my = FD::user(); $privacy = FD::privacy($my->id); if ($includePrivacy && !$privacy->validate('core.view', $stream->contextId, 'relationship', $stream->actor->id)) { return; } $stream->color = '#DC554F'; $stream->fonticon = 'ies-heart'; $stream->label = JText::_('APP_USER_RELATIONSHIP_STREAM_TOOLTIP'); $stream->display = SOCIAL_STREAM_DISPLAY_FULL; $registry = FD::registry($stream->params); $this->set('type', $registry->get('type')); $this->set('actor', $stream->actor); $this->set('target', $stream->targets[0]); $stream->title = parent::display('streams/' . $stream->verb . '.title'); if ($includePrivacy) { $stream->privacy = $privacy->form($stream->contextId, 'relationship', $stream->actor->id, 'core.view', false, $stream->uid); } return true; }
/** * Class constructor. * * @since 1.0 * @access public */ public function __construct() { // Load language file for plugin $lang = JFactory::getLanguage(); $lang->load('plg_app_user_q2c_boughtproducts', JPATH_ADMINISTRATOR); parent::__construct(); }
/** * Class constructor. * * @since 1.0 * @access public * @param array return all html code of layout. */ public function __construct($options = array()) { // Load language file for plugin $lang = JFactory::getLanguage(); $lang->load('plg_app_user_q2cMyProducts', JPATH_ADMINISTRATOR); require_once JPATH_SITE . '/components/com_quick2cart/helper.php'; parent::__construct($options); }
public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true) { // We only want to process related items if ($item->cluster_type !== SOCIAL_TYPE_EVENT || empty($item->cluster_id)) { return; } // Context are split into events and nodes // "events" context are stream items that are related to event item // "guests" context are stream items that are related to guests of the event // Only process "events" context here // "guests" context are processed in the app/event/guests app if ($item->context !== 'events') { return; } $event = FD::event($item->cluster_id); // Only show Social sharing in public group if (!$event->isOpen()) { $item->sharing = false; } if (!$event->canViewItem()) { return; } if (!$this->getParams()->get('stream_' . $item->verb, true)) { return; } $item->display = SOCIAL_STREAM_DISPLAY_FULL; $item->color = '#f06050'; $item->fonticon = 'ies-calendar'; $item->label = FD::_('APP_EVENT_EVENTS_STREAM_TOOLTIP', true); $actor = $item->actor; $this->set('event', $event); $this->set('actor', $actor); // streams/create.title // streams/feature.title // streams/update.title $item->title = parent::display('streams/' . $item->verb . '.title'); $item->content = ''; if ($event->isGroupEvent()) { $this->set('group', $event->getGroup()); $item->content = parent::display('streams/content'); } // APP_EVENT_EVENTS_STREAM_OPENGRAPH_UPDATE // APP_EVENT_EVENTS_STREAM_OPENGRAPH_CREATE // APP_EVENT_EVENTS_STREAM_OPENGRAPH_FEATURE $item->opengraph->addDescription(JText::sprintf('APP_EVENT_EVENTS_STREAM_OPENGRAPH_' . strtoupper($item->verb), $actor->getName(), $event->getName())); }
/** * Prepares the stream items for mosets tree * * @since 1.3 * @access public * @param string * @return */ public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true) { if (!$this->exists() || $stream->context != 'mtree') { return; } // Decorate the stream $stream->display = SOCIAL_STREAM_DISPLAY_FULL; $stream->color = '#6f90b5'; $stream->fonticon = 'ies-comments-2'; $stream->label = JText::_('APP_USER_MTREE_STREAM_LABEL'); // Get the link object $db = JFactory::getDbo(); $link = new mtLinks($db); $link->load($stream->contextId); $this->decorate($link); $this->set('actor', $stream->actor); $this->set('link', $link); $stream->title = parent::display('streams/title'); $stream->content = parent::display('streams/content'); }
public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true) { // We only want to process related items if ($item->cluster_type !== SOCIAL_TYPE_EVENT || empty($item->cluster_id)) { return; } // Context are split into events and nodes // "events" context are stream items that are related to event item // "guests" context are stream items that are related to guests of the event // Only process "guests" context here // "events" context are processed in the app/event/events app if ($item->context !== 'guests') { return; } $event = FD::event($item->cluster_id); if (!$event->canViewItem()) { return; } if (!$this->getParams()->get('stream_' . $item->verb, true)) { return; } $item->display = SOCIAL_STREAM_DISPLAY_FULL; $item->color = '#6bccb4'; $item->fonticon = 'ies-user'; $item->label = FD::_('APP_EVENT_GUESTS_STREAM_TOOLTIP', true); $actor = $item->actor; $this->set('event', $event); $this->set('actor', $actor); // streams/going.title // streams/makeadmin.title // streams/notgoing.title $item->title = parent::display('streams/' . $item->verb . '.title'); $item->content = ''; // APP_EVENT_GUESTS_STREAM_OPENGRAPH_GOING // APP_EVENT_GUESTS_STREAM_OPENGRAPH_NOTGOING // APP_EVENT_GUESTS_STREAM_OPENGRAPH_MAKEADMIN $item->opengraph->addDescription(JText::sprintf('APP_EVENT_GUESTS_STREAM_OPENGRAPH_' . strtoupper($item->verb), $actor->getName(), $event->getName())); }
/** * Responsible to generate the activity logs. * * @since 1.0 * @access public * @param object $params A standard object with key / value binding. * * @return none */ public function onPrepareActivityLog(SocialStreamItem &$item, $includePrivacy = true) { if ($item->context != 'links') { return; } //get story object, in this case, is the stream_item $tbl = FD::table('StreamItem'); $tbl->load($item->uid); // item->uid is now streamitem.id $uid = $tbl->uid; //get story object, in this case, is the stream_item $my = FD::user(); $privacy = FD::privacy($my->id); $actor = $item->actor; $target = count($item->targets) > 0 ? $item->targets[0] : ''; $assets = $item->getAssets($uid); if (empty($assets)) { return; } $assets = $assets[0]; $this->set('assets', $assets); $this->set('actor', $actor); $this->set('target', $target); $this->set('stream', $item); $item->display = SOCIAL_STREAM_DISPLAY_MINI; $item->title = parent::display('logs/' . $item->verb); return true; }
public function prepareCreateMilestoneStream(SocialStreamItem $streamItem, $includePrivacy = true) { $params = FD::registry($streamItem->params); $milestone = FD::table('Milestone'); $milestone->bind($params->get('milestone')); // Get the group data FD::load('event'); $event = new SocialEvent(); $event->bind($params->get('event')); // Get the actor $actor = $streamItem->actor; $app = $this->getApp(); $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id)); $this->set('permalink', $permalink); $this->set('milestone', $milestone); $this->set('actor', $actor); $this->set('event', $event); $streamItem->title = parent::display('streams/create.milestone.title'); $streamItem->content = parent::display('streams/create.milestone.content'); $streamItem->opengraph->addDescription(JText::sprintf('APP_EVENT_TASKS_STREAM_OPENGRAPH_CREATE_MILESTONE', $streamItem->actor->getName(), $event->getName())); }
/** * 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 !== 'feeds') { return; } // Get app params $params = $this->getParams(); if (!$params->get('stream_create', true)) { return; } // Get the feed table $obj = FD::makeObject($item->params); $feed = $this->getTable('Feed'); $feed->bind($obj); $actor = $item->actor; $app = $this->getApp(); $this->set('app', $app); $this->set('feed', $feed); $this->set('actor', $actor); $item->color = '#e67e22'; $item->display = SOCIAL_STREAM_DISPLAY_FULL; $item->fonticon = 'ies-feed'; $item->label = FD::_('APP_USER_FEED_STREAM_TOOLTIP', true); $item->title = parent::display('streams/' . $item->verb . '.title'); $item->content = parent::display('streams/' . $item->verb . '.content'); }
/** * 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; }
/** * 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) { if ($item->context != 'friends') { return; } // Determines if the stream should be generated $params = $this->getParams(); if (!$params->get('stream_friends', 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; } $my = FD::user(); $privacy = FD::privacy($my->id); if ($includePrivacy) { if (!$privacy->validate('core.view', $item->contextId, 'friends', $item->actor->id)) { return; } } // Get the context id. $id = $item->contextId; // no target. this could be data error. ignore this item. if (!$item->targets) { return; } // Receiving actor. $target = $item->targets[0]; // Get the current id. $id = JRequest::getInt('id'); // Decorate the stream $item->display = SOCIAL_STREAM_DISPLAY_MINI; $item->color = '#7AD7EE'; $item->fonticon = 'ies-user'; $item->label = FD::_('APP_USER_FRIENDS_STREAM_TOOLTIP', true); // 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; $this->set('actor', $actor); $this->set('target', $target); $item->title = parent::display('streams/' . $item->verb . '.title'); if ($includePrivacy) { $item->privacy = $privacy->form($item->contextId, 'friends', $item->actor->id, 'core.view', false, $item->uid); } return true; }
/** * Prepares the stream item when an article is being read * * @since 1.0 * @access public * @param SocialStreamItem The stream item. * @return */ private function prepareReadArticleStream(&$item) { // Load up the article dataset $article = JTable::getInstance('Content'); $article->load($item->contextId); // Load up the category dataset $category = JTable::getInstance('Category'); $category->load($article->catid); // Get the actor $actor = $item->actor; // Get the permalink $permalink = ContentHelperRoute::getArticleRoute($article->id . ':' . $article->alias, $article->catid . ':' . $category->alias); // Get the creation date $date = FD::date($article->created); // Get the category permalink $categoryPermalink = ContentHelperRoute::getCategoryRoute($category->id . ':' . $category->alias); // Get the content $content = $article->introtext; if (empty($content)) { $content = $article->fulltext; } $this->set('content', $content); $this->set('categoryPermalink', $categoryPermalink); $this->set('date', $date); $this->set('permalink', $permalink); $this->set('article', $article); $this->set('category', $category); $this->set('actor', $actor); // Load up the contents now. $item->title = parent::display('streams/read.title'); $item->content = parent::display('streams/read.content'); }
/** * 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 !== 'feeds') { return; } // Get app params $params = $this->getParams(); if (!$params->get('stream_create', true)) { return; } // Get the feed table $rss = FD::table('Rss'); $rss->load($item->contextId); if (!$rss->id || !$item->contextId) { return; } $group = FD::group($item->cluster_id); $actor = $item->actor; $app = $this->getApp(); $this->set('app', $app); $this->set('rss', $rss); $this->set('actor', $actor); $this->set('group', $group); $item->color = '#e67e22'; $item->display = SOCIAL_STREAM_DISPLAY_FULL; $item->fonticon = 'ies-feed'; $item->label = JText::_('APP_USER_FEED_STREAM_TOOLTIP'); $item->title = parent::display('streams/' . $item->verb . '.title'); $item->content = parent::display('streams/' . $item->verb . '.content'); }
/** * Prepares the activity log * * @since 1.0 * @access public * @param SocialStreamItem The stream object. * @param bool Determines if we should respect the privacy */ public function onPrepareActivityLog(SocialStreamItem &$item, $includePrivacy = true) { if ($item->context !== 'notes') { return; } // Load the note $note = $this->getTable('Note'); $note->load($item->contextId); $this->set('note', $note); $this->set('actor', $item->actor); $item->title = parent::display('streams/' . $item->verb . '.title'); }
public function prepareCreateMilestoneStream(SocialStreamItem $item, $includePrivacy = true) { $params = FD::registry($item->params); $milestone = FD::table('Milestone'); $milestone->bind($params->get('milestone')); // Get the group data FD::load('group'); $group = new SocialGroup(); $group->bind($params->get('group')); // Get the actor $actor = $item->actor; $app = $this->getApp(); $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id)); $this->set('permalink', $permalink); $this->set('milestone', $milestone); $this->set('actor', $actor); $this->set('group', $group); $item->title = parent::display('streams/create.milestone.title'); $item->content = parent::display('streams/create.milestone.content'); }
/** * 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; }
private function prepareCreateStream(SocialStreamItem &$item) { $groupId = $item->contextId; $params = FD::registry($item->params); $obj = $params->get('group'); $group = new SocialGroup(); $group->bind($obj); if (!$group) { return; } // We don't want to display groups that are invitation only. if ($group->type == SOCIAL_GROUPS_INVITE_TYPE) { return; } $actor = $item->actor; $this->set('group', $group); $this->set('actor', $actor); $item->title = parent::display('streams/create.title'); $item->content = parent::display('streams/create.content'); $item->opengraph->addDescription(JText::sprintf('APP_GROUP_GROUPS_STREAM_CREATED_GROUP', $actor->getName(), $group->getName())); }
private function prepareCreateStream(SocialStreamItem &$item, SocialGroup $group) { // We want a full display for group creation. $item->display = SOCIAL_STREAM_DISPLAY_FULL; // Get the actor. $actor = $item->actor; $this->set('group', $group); $this->set('actor', $actor); $item->title = parent::display('streams/create.title'); $item->content = parent::display('streams/content'); $item->opengraph->addDescription(JText::sprintf('APP_USER_GROUPS_STREAM_CREATED_GROUP', $actor->getName(), $group->getName())); }
/** * 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) { if ($item->context != SOCIAL_TYPE_FOLLOWERS) { return; } // Check if the app should be able to generate the stream. $params = $this->getParams(); if (!$params->get('stream_follow', true)) { return; } $my = FD::user(); $privacy = FD::privacy($my->id); if ($includePrivacy) { if (!$privacy->validate('followers.view', $item->contextId, SOCIAL_TYPE_FOLLOWERS, $item->actor->id)) { return; } } $item->display = SOCIAL_STREAM_DISPLAY_MINI; $item->color = '#415457'; $item->fonticon = 'ies-tree-view'; $item->label = JText::_('APP_USER_FOLLOWERS_STREAM_TOOLTIP'); // Get the context id. $id = $item->contextId; // Get the target. $table = FD::table('Subscription'); $table->load($id); // Get the actor $actor = $item->actor; // Receiving actor. $target = FD::user($table->uid); // Get the current id. $id = JRequest::getInt('id'); $this->set('actor', $actor); $this->set('target', $target); // User A following user B if ($item->verb == 'follow') { $item->title = parent::display('streams/' . $item->verb . '.title'); } $item->opengraph->addDescription($item->title); if ($includePrivacy) { $item->privacy = $privacy->form($id, SOCIAL_TYPE_FOLLOWERS, $item->actor->id, 'followers.view', false, $item->uid); } return true; }
private function processTaskStream(SocialStreamItem &$item, $includePrivacy) { $app = FD::table('App'); $app->load(array('group' => SOCIAL_TYPE_EVENT, 'type' => SOCIAL_TYPE_APPS, 'element' => 'tasks')); $event = FD::event($item->cluster_id); $params = FD::registry($item->params); // Get the milestone $milestone = FD::table('Milestone'); $milestone->bind($params->get('milestone')); $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id)); // Do not allow reposting on milestone items $item->repost = false; if ($item->verb == 'createTask') { $items = $params->get('tasks'); $tasks = array(); foreach ($items as $i) { $task = FD::table('Task'); // We don't do bind here because we need to latest state from the database // THe cached params might be an old data. $task->load($i->id); $tasks[] = $task; } $this->set('tasks', $tasks); $this->set('total', count($tasks)); } $this->set('event', $event); $this->set('stream', $item); $this->set('milestone', $milestone); $this->set('permalink', $permalink); $this->set('actor', $item->actor); // streams/tasks/createTask.title // streams/tasks/createTask.content // streams/tasks/createMilestone.title // streams/tasks/createMilestone.content $item->title = parent::display('streams/tasks/' . $item->verb . '.title'); $item->content = parent::display('streams/tasks/' . $item->verb . '.content'); if ($item->verb === 'createMilestone') { $item->opengraph->addDescription(JText::sprintf('APP_USER_EVENTS_TASKS_STREAM_OPENGRAPH_CREATED_MILESTONE', $item->actor->getName(), $milestone->title, $event->getName())); } if ($item->verb === 'createTask') { $item->opengraph->addDescription(JText::sprintf(FD::string()->computeNoun('APP_USER_EVENTS_TASKS_STREAM_OPENGRAPH_ADDED_TASK', count($tasks)), $item->actor->getName(), count($tasks), $milestone->title, $event->getName())); } }
private function prepareLoginStream(SocialStreamItem &$item) { $params = $this->getParams(); // Check if the settings is enabled. if (!$params->get('stream_login', false)) { $item->title = ''; return; } // Decorate the stream $item->color = '#EF9033'; $item->fonticon = 'ies-locked'; $item->label = FD::_('APP_USER_USERS_LOGIN_STREAM_TOOLTIP', true); $item->display = SOCIAL_STREAM_DISPLAY_MINI; // Set the actor $actor = $item->actor; // check if actor is an ESAD user, if yes, do not render the stream. if (!$actor->hasCommunityAccess()) { $item->title = ''; return; } $this->set('actor', $actor); $item->title = parent::display('streams/login.title'); if (isset($item->opengraph) && $item->opengraph instanceof SocialOpengraph) { $item->opengraph->addDescription($item->title); } }
/** * Prepares the stream item for new file uploads * * @since 1.0 * @access public * @param SocialStreamItem The stream item. * @return */ private function prepareUploadedStream(&$item) { $params = FD::registry($item->params); // Load up the event object $event = FD::event($params->get('event')->id); // Do not allow user to repost files $item->repost = false; // Get the file object $file = FD::table('File'); $file->load($params->get('file')->id); if (!$file->id) { return; } // Get the actor $actor = $item->actor; $this->set('actor', $actor); $this->set('file', $file); $this->set('event', $event); // Load up the contents now. $item->title = parent::display('streams/uploaded.title'); $item->content = parent::display('streams/uploaded.content'); }
/** * Prepares the upload avatar stream * * @since 1.0 * @access public * @param SocialStream */ public function prepareUpdateCoverStream(SocialStreamItem &$item) { $element = $item->context; $uid = $item->contextId; // Get the photo object $photo = $this->getPhotoFromParams($item); // Get the cover of the group $event = FD::event($item->cluster_id); $cover = $event->getCoverData(); $this->set('cover', $cover); $this->set('photo', $photo); $this->set('actor', $item->actor); $item->title = parent::display('streams/upload.cover.title'); $item->content = parent::display('streams/upload.cover.content'); }
/** * Prepares the activity log item * * @since 1.2 * @access public * @param SocialStreamItem The stream object. * @param bool Determines if we should respect the privacy */ public function onPrepareActivityLog(SocialStreamItem &$item, $includePrivacy = true) { if ($item->context != 'kunena') { return; } // Test if Kunena exists; if (!$this->exists()) { return; } // Get the context id. $actor = $item->actor; $topic = KunenaForumTopicHelper::get($item->contextId); if ($item->verb == 'thanked') { $message = KunenaForumMessageHelper::get($item->contextId); $topic = $message->getTopic(); $target = $item->targets[0]; $this->set('target', $target); $this->set('message', $message); } else { if ($item->verb == 'reply') { $message = KunenaForumMessageHelper::get($item->contextId); $topic = $message->getTopic(); $this->set('message', $message); } } $this->set('topic', $topic); $this->set('actor', $actor); // Load up the contents now. $item->title = parent::display('streams/' . $item->verb . '.title'); $item->content = ''; }
private function prepareCreateStream(SocialStreamItem &$item, SocialGroup $group) { if (!$group->canViewItem()) { return; } $params = FD::registry($item->params); $data = $params->get('news'); // Load the group $group = FD::group($data->cluster_id); $news = FD::table('GroupNews'); $news->load($data->id); // Get the permalink $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $this->getApp()->getAlias(), 'newsId' => $news->id), false); // Get the app params $appParams = $this->getApp()->getParams(); // Format the content $this->format($news, $appParams->get('stream_length')); // Attach actions to the stream $this->attachActions($item, $news, $permalink, $appParams); $this->set('group', $group); $this->set('appParams', $appParams); $this->set('permalink', $permalink); $this->set('news', $news); $this->set('actor', $item->actor); // Load up the contents now. $item->title = parent::display('streams/create.title'); $item->content = parent::display('streams/create.content'); }
/** * 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; }
/** * Prepares the stream item for new discussion creation * * @since 1.3 * @access public * @param SocialStreamItem $item The stream item. */ private function prepareLockedStream(&$item) { // Get the context params $params = FD::registry($item->params); $event = FD::event($params->get('event')->id); $discussion = FD::table('Discussion'); $discussion->bind($params->get('discussion')); $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $this->getApp()->getAlias(), 'discussionId' => $discussion->id), false); $item->display = SOCIAL_STREAM_DISPLAY_MINI; $this->set('permalink', $permalink); $this->set('actor', $item->actor); $this->set('discussion', $discussion); // Load up the contents now. $item->title = parent::display('streams/locked.title'); }
/** * Prepares the stream item for new file uploads * * @since 1.0 * @access public * @param SocialStreamItem The stream item. * @return */ private function prepareUploadedStream(&$item) { $params = FD::registry($item->params); // Get the group object $group = FD::group($params->get('group')); // Do not allow user to repost files $item->repost = false; // NOTE // We do not need to override the likes and comments to pass in the stream id // since the stream id is already passed to the likes and comments. // Get the file object $file = FD::table('File'); $exists = $file->load($params->get('file')->id); if (!$exists) { return; } // Get the actor $actor = $item->actor; $this->set('actor', $actor); $this->set('file', $file); $this->set('group', $group); // Load up the contents now. $item->title = parent::display('streams/uploaded.title'); $item->content = parent::display('streams/uploaded.content'); }
/** * 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; }
/** * Prepares the stream item when an article is being read * * @since 1.0 * @access public * @param SocialStreamItem The stream item. * @return */ private function prepareReadArticleStream(&$item) { // Retrieve initial data $article = $this->getArticle($item); $category = $this->getCategory($item, $article); $permalink = $this->getPermalink($item, $article, $category); $categoryPermalink = $this->getCategoryPermalink($item, $category); // Ensure that the user can really view this article if (!$this->canView($article)) { return; } // Get the actor $actor = $item->actor; // Get the creation date $date = FD::date($article->created); // Get the content $content = $article->introtext; if (empty($content)) { $content = $article->fulltext; } $content = preg_replace('/\\{.*\\}/i', '', $content); // Limit the content length $params = $this->getParams(); $contentLength = $params->get('stream_content_length'); if ($contentLength) { $content = JString::substr(strip_tags($content), 0, $contentLength) . JText::_('COM_EASYSOCIAL_ELLIPSES'); } $this->set('content', $content); $this->set('categoryPermalink', $categoryPermalink); $this->set('date', $date); $this->set('permalink', $permalink); $this->set('article', $article); $this->set('category', $category); $this->set('actor', $actor); // Load up the contents now. $item->title = parent::display('streams/read.title'); $item->content = parent::display('streams/read.content'); $item->opengraph->addDescription($content); }