コード例 #1
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 /**
  * 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');
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 /**
  * 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');
 }
コード例 #3
0
ファイル: dependencies.php プロジェクト: ppantilla/bbninja
 /**
  * Sets the likes on the stream
  *
  * @since	1.3.8
  * @access	public
  * @param	string
  * @return	
  */
 public function setLikes($group, $useStreamId, $uid = null, $context = null, $verb = null)
 {
     $uid = is_null($uid) ? $this->uid : $uid;
     $context = is_null($context) ? $this->context : $context;
     $verb = is_null($verb) ? $this->verb : $verb;
     $likes = FD::likes();
     $likes->get($uid, $context, $verb, $group, $useStreamId);
     $this->likes = $likes;
 }
コード例 #4
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 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);
     }
 }
コード例 #5
0
ファイル: view.ajax.php プロジェクト: ppantilla/bbninja
 /**
  * Returns an ajax chain.
  *
  * @since	1.0
  * @access	public
  * @param	string	The verb that we have performed.
  */
 public function toggle($verb = '', $id = null, $type = null, $group = SOCIAL_APPS_GROUP_USER, $itemVerb = '')
 {
     // Load ajax lib
     $ajax = FD::ajax();
     // Determine if there's any errors on the form.
     $error = $this->getError();
     if ($error) {
         return $ajax->reject($error);
     }
     // Set the label
     $label = $verb == 'like' ? JText::_('COM_EASYSOCIAL_LIKES_UNLIKE') : JText::_('COM_EASYSOCIAL_LIKES_LIKE');
     // Set the message
     $likes = FD::likes($id, $type, $itemVerb, $group);
     $likes->get($id, $type, $itemVerb, $group);
     $likeCnt = count($likes->data);
     $isHidden = $likeCnt > 0 ? false : true;
     $contents = $likes->toString();
     return $ajax->resolve($contents, $label, $isHidden, $verb, $likeCnt);
 }
コード例 #6
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');
 }
コード例 #7
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 /**
  * 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');
 }
コード例 #8
0
ファイル: links.php プロジェクト: BetterBetterBetter/B3App
 /**
  * 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;
 }
コード例 #9
0
ファイル: news.php プロジェクト: ppantilla/bbninja
 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;
 }
コード例 #10
0
 /**
  * Prepare the likes object for the photo item
  *
  * @since	1.2
  * @access	public
  * @return	SocialLikes	The likes library
  */
 public function likes()
 {
     $verb = $this->getPhotoVerb();
     $context = SOCIAL_TYPE_PHOTO;
     $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';
         }
     }
     // NOTE:
     // We do not need to do any checking or fix any relations here since liking a photo should always be liking a photo
     // Nothing needs to be done here.
     return FD::likes($id, $context, $verb, $this->type, $streamId);
 }
コード例 #11
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>
コード例 #12
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;
 }
コード例 #13
0
ファイル: story.php プロジェクト: knigherrant/decopatio
 /**
  * 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;
 }
コード例 #14
0
ファイル: kunena.php プロジェクト: knigherrant/decopatio
 /**
  * Processes the stream item for new thanks
  *
  * @since	1.0
  * @access	public
  * @param	SocialStreamItem	The stream item object
  * @param	bool				Determine if we should include the privacy or not.
  * @return
  */
 private function processThanked(&$item, $includePrivacy = true)
 {
     $message = KunenaForumMessageHelper::get($item->contextId);
     $topic = $message->getTopic();
     $category = $topic->getCategory();
     if (!$category->authorise('read') || !$topic->authorise('read')) {
         // user not allow to view the content.
         return;
     }
     // Apply likes on the stream
     $likes = FD::likes()->get($item->contextId, 'kunena', 'thank', SOCIAL_APPS_GROUP_USER, $item->uid);
     $item->likes = $likes;
     // disable comments on the stream
     $item->comments = false;
     // Define standard stream looks
     $item->display = SOCIAL_STREAM_DISPLAY_MINI;
     $item->color = '#6f90b5';
     // Set the actor
     $actor = $item->actor;
     $target = $item->targets[0];
     $parent = $this->createParent($message->id);
     $message->message = KunenaHtmlParser::parseBBCode($message->message, $parent, 250);
     $message->message = $this->filterContent($message->message);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('topic', $topic);
     $this->set('message', $message);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     $item->opengraph->addDescription($item->title);
 }
コード例 #15
0
ファイル: groups.php プロジェクト: knigherrant/decopatio
 /**
  * Trigger for onPrepareStream
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     // We only want to process related items
     if ($item->cluster_type !== SOCIAL_TYPE_GROUP || empty($item->cluster_id)) {
         return;
     }
     $allowed = array('groups', 'tasks', 'discussions', 'news');
     if (!in_array($item->context, $allowed)) {
         return;
     }
     // Get the group object
     $group = FD::group($item->cluster_id);
     // If we can't find the group, skip this.
     if (!$group) {
         return;
     }
     // Determines if the user can view this group item.
     if (!$group->canViewItem()) {
         return;
     }
     // Get the app params so that we determine which stream should be appearing
     $app = $this->getApp();
     $params = $app->getParams();
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $item->color = '#303229';
     $item->fonticon = 'ies-users';
     $item->label = FD::_('APP_USER_GROUPS_STREAM_TOOLTIP', true);
     if ($item->context == 'news') {
         $this->prepareGroupNewsStream($item, $group, $includePrivacy);
     } else {
         if ($item->context == 'tasks') {
             $this->prepareGroupTask($item, $group, $includePrivacy);
         } else {
             if ($item->context == 'discussions') {
                 $this->prepareGroupDiscussion($item, $group, $includePrivacy);
             } else {
                 // Prepare the likes
                 $likes = FD::likes($item->uid, 'groups', $item->verb, SOCIAL_TYPE_USER, $item->uid);
                 $item->likes = $likes;
                 $item->display = SOCIAL_STREAM_DISPLAY_MINI;
                 // Display stream item for new member join
                 if ($item->verb == 'join' && $params->get('stream_join', true)) {
                     $this->prepareJoinStream($item, $group);
                 }
                 // Display stream item if member leaves a group
                 if ($item->verb == 'leave' && $params->get('stream_leave', true)) {
                     $this->prepareLeaveStream($item, $group);
                 }
                 // Display stream item for new group creation
                 if ($item->verb == 'create' && $params->get('stream_create', true)) {
                     $this->prepareCreateStream($item, $group);
                 }
                 // Display stream item when a member is promoted to be a group admin
                 if ($item->verb == 'makeadmin' && $params->get('stream_admin', true)) {
                     $this->prepareMakeAdminStream($item, $group);
                 }
                 if ($item->verb == 'update' && $params->get('stream_update', true)) {
                     $this->prepareUpdateStream($item, $group);
                 }
             }
         }
     }
     // Hide these items if the user is not a member of the group.
     if (!$group->isMember()) {
         $item->commentLink = false;
         $item->repost = false;
         $item->commentForm = false;
     }
     // Only show Social sharing in public group
     if ($group->type != SOCIAL_GROUPS_PUBLIC_TYPE) {
         $item->sharing = false;
     }
 }
コード例 #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 !== '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());
 }
コード例 #17
0
ファイル: friends.php プロジェクト: knigherrant/decopatio
 /**
  * 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;
 }
コード例 #18
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;
 }
コード例 #19
0
ファイル: view.ajax.php プロジェクト: ppantilla/bbninja
 /**
  * Post processing after a photo is liked
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function like($photoId)
 {
     $ajax = FD::ajax();
     if ($this->hasErrors()) {
         return $ajax->reject($this->getMessage());
     }
     $like = FD::likes($photoId, SOCIAL_TYPE_PHOTO, 'upload', SOCIAL_APPS_GROUP_USER);
     $obj = new stdClass();
     $obj->state = true;
     $obj->count = $like->getCount();
     $obj->html = $like->toString();
     return $ajax->resolve($obj);
 }
コード例 #20
0
ファイル: shares.php プロジェクト: BetterBetterBetter/B3App
 /**
  * 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;
 }
コード例 #21
0
ファイル: notes.php プロジェクト: knigherrant/decopatio
 /**
  * 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);
 }
コード例 #22
0
ファイル: links.php プロジェクト: BetterBetterBetter/B3App
 /**
  * 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;
 }
コード例 #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;
     }
 }
コード例 #24
0
ファイル: profiles.php プロジェクト: knigherrant/decopatio
 /**
  * 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;
 }
コード例 #25
0
 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;
 }
コード例 #26
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>
コード例 #27
0
ファイル: discussions.php プロジェクト: ppantilla/bbninja
 /**
  * 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);
     }
 }
コード例 #28
0
ファイル: badges.php プロジェクト: knigherrant/decopatio
 /**
  * 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;
 }
コード例 #29
0
ファイル: story.php プロジェクト: knigherrant/decopatio
 /**
  * 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;
 }
コード例 #30
0
ファイル: discussions.php プロジェクト: knigherrant/decopatio
 /**
  * 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);
     }
 }