Exemplo n.º 1
0
 /**
  * Retrieve the title of the stream
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function getTitle()
 {
     // Get the actors
     $actors = $this->item->actors;
     // Get the source id
     $sourceId = $this->share->uid;
     // Load the stream
     $stream = FD::table('Stream');
     $stream->load($sourceId);
     // If stream cannot be loaded, skip this altogether
     if (!$stream->id) {
         return;
     }
     // Build the permalink to the stream item
     $link = FRoute::stream(array('layout' => 'item', 'id' => $sourceId));
     // Get the target user.
     $target = FD::user($stream->actor_id);
     $actor = $actors[0];
     $theme = FD::get('Themes');
     $theme->set('actor', $actor);
     $theme->set('link', $link);
     $theme->set('target', $target);
     $title = $theme->output('apps/group/shares/streams/stream/title');
     return $title;
 }
Exemplo n.º 2
0
 public function display()
 {
     // Get the configuration objects
     $config = FD::config();
     $jConfig = FD::config('joomla');
     // Get the stream library
     $stream = FD::stream();
     $stream->get();
     // Get the result in an array form
     $result = $stream->toArray();
     // Set the document properties
     $doc = JFactory::getDocument();
     $doc->link = FRoute::dashboard();
     FD::page()->title(JText::_('COM_EASYSOCIAL_STREAM_FEED_TITLE'));
     $doc->setDescription(JText::sprintf('COM_EASYSOCIAL_STREAM_FEED_DESC', $jConfig->getValue('sitename')));
     if ($result) {
         $useEmail = $jConfig->getValue('feed_email');
         foreach ($result as $row) {
             $item = new JFeedItem();
             $item->title = $row->title;
             $item->link = FRoute::stream(array('id' => $row->uid));
             $item->description = $row->content;
             $item->date = $row->created->toMySQL();
             $item->author = $row->actor->getName();
             if ($useEmail != 'none') {
                 $item->authorEmail = $jConfig->getValue('mailfrom');
                 if ($useEmail == 'author') {
                     $item->authorEmail = $row->actor->email;
                 }
             }
             $doc->addItem($item);
         }
     }
 }
Exemplo n.º 3
0
 public function create_report()
 {
     $app = JFactory::getApplication();
     $msg = $app->input->get('message', '', 'STRING');
     $title = $app->input->get('user_title', '', 'STRING');
     $item_id = $app->input->get('itemId', 0, 'INT');
     $log_user = $this->plugin->get('user')->id;
     $data = array();
     $data['message'] = $msg;
     $data['uid'] = $item_id;
     $data['type'] = 'stream';
     $data['title'] = $title;
     $data['extension'] = 'com_easysocial';
     //build share url use for share post through app
     $sharing = FD::get('Sharing', array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item_id, 'external' => true, 'xhtml' => true)), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small'));
     $url = $sharing->url;
     $data['url'] = $url;
     // Get the reports model
     $model = FD::model('Reports');
     // Determine if this user has the permissions to submit reports.
     $access = FD::access();
     // Determine if this user has exceeded the number of reports that they can submit
     $total = $model->getCount(array('created_by' => $log_user));
     if ($access->exceeded('reports.limit', $total)) {
         $final_result['message'] = "Limit exceeds";
         $final_result['status'] = true;
         return $final_result;
     }
     // Create the report
     $report = FD::table('Report');
     $report->bind($data);
     // Set the creator id.
     $report->created_by = $log_user;
     // Set the default state of the report to new
     $report->state = 0;
     // Try to store the report.
     $state = $report->store();
     // If there's an error, throw it
     if (!$state) {
         $final_result['message'] = "Can't save report";
         $final_result['status'] = true;
         return $final_result;
     }
     // @badge: reports.create
     // Add badge for the author when a report is created.
     $badge = FD::badges();
     $badge->log('com_easysocial', 'reports.create', $log_user, JText::_('COM_EASYSOCIAL_REPORTS_BADGE_CREATED_REPORT'));
     // @points: reports.create
     // Add points for the author when a report is created.
     $points = FD::points();
     $points->assign('reports.create', 'com_easysocial', $log_user);
     // Determine if we should send an email
     $config = FD::config();
     if ($config->get('reports.notifications.moderators')) {
         $report->notify();
     }
     $final_result['message'] = "Report logged successfully!";
     $final_result['status'] = true;
     return $final_result;
 }
Exemplo n.º 4
0
 /**
  * Responsible to output a single stream item.
  *
  * @access	public
  * @return	null
  *
  */
 public function item()
 {
     // Check for user profile completeness
     FD::checkCompleteProfile();
     // Get the stream id from the request
     $id = JRequest::getInt('id');
     if (!$id) {
         return JError::raiseError(404, JText::_('COM_EASYSOCIAL_STREAM_INVALID_STREAM_ID'));
     }
     // Get the current logged in user.
     $user = FD::user();
     // Retrieve stream
     $streamLib = FD::stream();
     $stream = $streamLib->getItem($id);
     if ($stream === false) {
         return JError::raiseError(404, JText::_('COM_EASYSOCIAL_STREAM_CONTENT_NOT_AVAILABLE'));
     }
     // If the user is not allowed to view this stream, display the appropriate message
     if ($stream === true || count($stream) <= 0) {
         $streamTable = FD::table('Stream');
         $streamTable->load($id);
         $type = $streamTable->cluster_type ? $streamTable->cluster_type : SOCIAL_TYPE_USER;
         $template = 'site/stream/restricted.' . $type;
         $this->set('streamTable', $streamTable);
         parent::display($template);
         return;
     }
     // Get the first stream item
     $stream = $stream[0];
     // Strip off any html tags from the title
     $title = strip_tags($stream->title);
     // Set the page title
     FD::page()->title($title);
     // Append opengraph tags
     $image = $streamLib->getContentImage($stream);
     if ($image) {
         $stream->opengraph->addImage($image);
     }
     // Get the permalink of this stream
     $permalink = FRoute::stream(array('id' => $stream->uid, 'layout' => 'item', 'external' => 1));
     // Append additional opengraph details
     $stream->opengraph->addUrl($permalink);
     $stream->opengraph->addType('article');
     $stream->opengraph->addTitle(trim($title));
     // render the meta tags here.
     $stream->opengraph->render();
     // Get stream actions
     $actions = '';
     if ($stream->display == SOCIAL_STREAM_DISPLAY_FULL) {
         $actions = $streamLib->getActions($stream);
     }
     $this->set('actions', $actions);
     $this->set('user', $user);
     $this->set('stream', $stream);
     parent::display('site/stream/item');
     return;
 }
Exemplo n.º 5
0
 public function getTitle()
 {
     $actors = $this->item->actors;
     $names = FD::string()->namesToStream($actors, true, 3);
     // Get the source id
     $sourceId = $this->share->uid;
     // Load the stream
     $stream = FD::table('Stream');
     $stream->load($sourceId);
     if (!$stream->id) {
         return '';
     }
     $link = FRoute::stream(array('layout' => 'item', 'id' => $sourceId));
     // Get the target user.
     $target = FD::user($stream->actor_id);
     $actor = $actors[0];
     $theme = FD::get('Themes');
     $theme->set('actor', $actor);
     $theme->set('link', $link);
     $theme->set('target', $target);
     $title = $theme->output('apps/user/shares/streams/stream/title');
     return $title;
 }
Exemplo n.º 6
0
 public function onAfterCommentSave($comment)
 {
     $segments = explode('.', $comment->element);
     if (count($segments) !== 3 || $segments[1] !== SOCIAL_TYPE_EVENT) {
         return;
     }
     list($element, $group, $verb) = explode('.', $comment->element);
     // Get the actor
     $actor = FD::user($comment->created_by);
     if ($element === 'events') {
         $event = FD::event($comment->uid);
         $stream = FD::table('Stream');
         $stream->load($comment->stream_id);
         $owner = FD::user($stream->actor_id);
         // APP_USER_EVENTS_EMAILS_FEATURE_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_EMAILS_CREATE_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_EMAILS_UPDATE_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_EMAILS_FEATURE_COMMENT_INVOLVED_SUBJECT
         // APP_USER_EVENTS_EMAILS_CREATE_COMMENT_INVOLVED_SUBJECT
         // APP_USER_EVENTS_EMAILS_UPDATE_COMMENT_INVOLVED_SUBJECT
         // apps/user/events/feature.comment.item
         // apps/user/events/create.comment.item
         // apps/user/events/update.comment.item
         // apps/user/events/feature.comment.involved
         // apps/user/events/create.comment.involved
         // apps/user/events/update.comment.involved
         $emailOptions = array('title' => 'APP_USER_EVENTS_EMAILS_' . strtoupper($verb) . '_COMMENT_ITEM_SUBJECT', 'template' => 'apps/user/events/' . $verb . '.comment.item', 'permalink' => $stream->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment);
         $systemOptions = array('context_type' => $comment->element, 'content' => $comment->comment, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner first
         if ($comment->created_by != $owner->id) {
             FD::notify('comments.item', array($owner->id), $emailOptions, $systemOptions);
         }
         // Get a list of recipients to be notified for this stream item
         // We exclude the owner of the discussion and the actor of the comment here
         $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($owner->id, $comment->created_by));
         $emailOptions['title'] = 'APP_USER_EVENTS_EMAILS_' . strtoupper($verb) . '_COMMENT_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/user/events/' . $verb . '.comment.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
     }
     if ($element === 'guests') {
         $guest = FD::table('EventGuest');
         $guest->load($comment->uid);
         $event = FD::event($guest->cluster_id);
         $stream = FD::table('Stream');
         $stream->load($comment->stream_id);
         $owner = FD::user($stream->actor_id);
         // APP_USER_EVENTS_GUESTS_EMAILS_MAKEADMIN_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_GUESTS_EMAILS_GOING_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_GUESTS_EMAILS_NOTGOING_COMMENT_ITEM_SUBJECT
         // APP_USER_EVENTS_GUESTS_EMAILS_MAKEADMIN_COMMENT_INVOLVED_SUBJECT
         // APP_USER_EVENTS_GUESTS_EMAILS_GOING_COMMENT_INVOLVED_SUBJECT
         // APP_USER_EVENTS_GUESTS_EMAILS_NOTGOING_COMMENT_INVOLVED_SUBJECT
         // apps/user/events/guest.makeadmin.comment.item
         // apps/user/events/guest.going.comment.item
         // apps/user/events/guest.notgoing.comment.item
         // apps/user/events/guest.makeadmin.comment.involved
         // apps/user/events/guest.going.comment.involved
         // apps/user/events/guest.notgoing.comment.involved
         $emailOptions = array('title' => 'APP_USER_EVENTS_GUESTS_EMAILS_' . strtoupper($verb) . '_COMMENT_ITEM_SUBJECT', 'template' => 'apps/user/events/guest.' . $verb . '.comment.item', 'permalink' => $stream->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment);
         $systemOptions = array('context_type' => $comment->element, 'content' => $comment->comment, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner first
         if ($comment->created_by != $owner->id) {
             FD::notify('comments.item', array($owner->id), $emailOptions, $systemOptions);
         }
         // Get a list of recipients to be notified for this stream item
         // We exclude the owner of the discussion and the actor of the comment here
         $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($owner->id, $comment->created_by));
         $emailOptions['title'] = 'APP_USER_EVENTS_GUESTS_EMAILS_' . strtoupper($verb) . '_COMMENT_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/user/events/guest.' . $verb . '.comment.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
     }
     if ($element === 'discussions') {
         // Uses app/event/discussions onAfterCommentSave logic and language strings since it is the same
         $stream = FD::table('Stream');
         $stream->load($comment->stream_id);
         // Get the discussion object since it's tied to the stream
         $discussion = FD::table('Discussion');
         $discussion->load($comment->uid);
         // APP_EVENT_DISCUSSIONS_EMAILS_CREATE_COMMENT_ITEM_SUBJECT
         // APP_EVENT_DISCUSSIONS_EMAILS_CREATE_COMMENT_INVOLVED_SUBJECT
         // APP_EVENT_DISCUSSIONS_EMAILS_REPLY_COMMENT_ITEM_SUBJECT
         // APP_EVENT_DISCUSSIONS_EMAILS_REPLY_COMMENT_INVOLVED_SUBJECT
         // apps/event/discussions/create.comment.item
         // apps/event/discussions/create.comment.involved
         // apps/event/discussions/reply.comment.item
         // apps/event/discussions/reply.comment.involved
         $emailOptions = array('title' => 'APP_EVENT_DISCUSSIONS_EMAILS_' . strtoupper($verb) . '_COMMENT_ITEM_SUBJECT', 'template' => 'apps/event/discussions/' . $verb . '.comment.item', 'permalink' => $stream->getPermalink(true, true), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment);
         $systemOptions = array('context_type' => $comment->element, 'content' => $comment->comment, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner first
         if ($comment->created_by != $discussion->created_by) {
             FD::notify('comments.item', array($discussion->created_by), $emailOptions, $systemOptions);
         }
         // Get a list of recipients to be notified for this stream item
         // We exclude the owner of the discussion and the actor of the comment here
         $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($discussion->created_by, $comment->created_by));
         $emailOptions['title'] = 'APP_EVENT_DISCUSSIONS_EMAILS_' . strtoupper($verb) . '_COMMENT_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/event/discussions/' . $verb . '.comment.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
     }
     if ($element === 'tasks') {
         // Uses app/event/tasks onAfterCommentSave logic and language strings since it is the same
         $identifier = $verb == 'createMilestone' ? 'milestone' : 'task';
         // Get the milestone/task table
         $table = FD::table($identifier);
         $table->load($comment->uid);
         // Get the owner
         $owner = FD::user($table->owner_id);
         // Get the event
         $event = FD::event($table->uid);
         $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($owner->id, $comment->created_by));
         // APP_EVENT_TASKS_EMAILS_COMMENTED_ON_YOUR_MILESTONE_SUBJECT
         // APP_EVENT_TASKS_EMAILS_COMMENTED_ON_YOUR_TASK_SUBJECT
         // APP_EVENT_TASKS_EMAILS_COMMENTED_ON_A_MILESTONE_SUBJECT
         // APP_EVENT_TASKS_EMAILS_COMMENTED_ON_A_TASK_SUBJECT
         // apps/event/tasks/comment.milestone
         // apps/event/tasks/comment.task
         // apps/event/tasks/comment.milestone.involved
         // apps/event/tasks/comment.task.involved
         $emailOptions = array('title' => 'APP_EVENT_TASKS_EMAILS_COMMENTED_ON_YOUR_' . strtoupper($identifier) . '_SUBJECT', 'template' => 'apps/event/tasks/comment.' . $identifier, 'permalink' => FRoute::stream(array('layout' => 'item', 'id' => $comment->stream_id, 'external' => true)), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment);
         $systemOptions = array('context_type' => $comment->element, 'content' => $comment->element, 'url' => FRoute::stream(array('layout' => 'item', 'id' => $comment->stream_id, 'sef' => false)), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner first
         if ($comment->created_by != $owner->id) {
             FD::notify('comments.item', array($owner->id), $emailOptions, $systemOptions);
         }
         // Get a list of recipients to be notified for this stream item
         // We exclude the owner of the note and the actor of the like here
         $recipients = $this->getStreamNotificationTargets($comment->uid, $element, $group, $verb, array(), array($owner->id, $comment->created_by));
         $emailOptions['title'] = 'APP_EVENT_TASKS_EMAILS_COMMENTED_ON_A_' . strtoupper($identifier) . '_SUBJECT';
         $emailOptions['template'] = 'apps/event/tasks/comment.' . $identifier . '.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
     }
 }
Exemplo n.º 7
0
 /**
  * Triggered to prepare the stream item
  *
  * @since   1.0
  * @access  public
  * @param   string
  * @return
  */
 public function onPrepareStream(SocialStreamItem &$item)
 {
     // If this is not it's context, we don't want to do anything here.
     if ($item->context != 'story') {
         return;
     }
     // Get the event object
     $group = $item->getCluster();
     if (!$group) {
         return;
     }
     if (!$group->canViewItem()) {
         return;
     }
     // Allow editing of the stream item
     $item->editable = $this->my->isSiteAdmin() || $group->isAdmin() || $item->actor->id == $this->my->id;
     // Get the actor
     $actor = $item->getActor();
     // Decorate the stream
     $item->fonticon = 'ies-pencil-2';
     $item->color = '#6E9545';
     $item->label = FD::_('APP_GROUP_STORY_STREAM_TOOLTIP', true);
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $this->set('group', $group);
     $this->set('actor', $actor);
     $this->set('stream', $item);
     $item->title = parent::display('streams/title.' . $item->verb);
     $item->content = parent::display('streams/content.' . $item->verb);
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, $item->uid);
     $item->likes = $likes;
     // If this update is posted in a group, the comments should be linked to the group item
     $comments = FD::comments($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     return true;
 }
Exemplo n.º 8
0
 public function put_data()
 {
     $app = JFactory::getApplication();
     $recep = $app->input->get('recipient', '', 'STRING');
     $stream_id = $app->input->get('stream_uid', 0, 'INT');
     $msg = $app->input->get('message', '', 'STRING');
     $res = new stdClass();
     if (!$stream_id) {
         $res->success = 0;
         $res->message = "Empty stream id not allowed";
     }
     //create sharing url
     $sharing = FD::get('Sharing', array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream_id, 'external' => true, 'xhtml' => true)), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small'));
     $tok = base64_encode($sharing->url);
     if (is_string($recep)) {
         $recep = explode(',', FD::string()->escape($recep));
     }
     if (is_array($recep)) {
         foreach ($recep as &$recipient) {
             $recipient = FD::string()->escape($recipient);
             if (!JMailHelper::isEmailAddress($recipient)) {
                 return false;
             }
         }
     }
     $msg = FD::string()->escape($msg);
     // Check for valid data
     if (empty($recep)) {
         return false;
     }
     if (empty($tok)) {
         return false;
     }
     $session = JFactory::getSession();
     $config = FD::config();
     $limit = $config->get('sharing.email.limit', 0);
     $now = FD::date()->toUnix();
     $time = $session->get('easysocial.sharing.email.time');
     $count = $session->get('easysocial.sharing.email.count');
     if (is_null($time)) {
         $session->set('easysocial.sharing.email.time', $now);
         $time = $now;
     }
     if (is_null($count)) {
         $session->set('easysocial.sharing.email.count', 0);
     }
     $diff = $now - $time;
     if ($diff <= 3600) {
         if ($limit > 0 && $count >= $limit) {
             return false;
         }
         $count++;
         $session->set('easysocial.sharing.email.count', $count);
     } else {
         $session->set('easysocial.sharing.email.time', $now);
         $session->set('easysocial.sharing.email.count', 1);
     }
     $library = FD::get('Sharing');
     $result = $library->sendLink($recep, $tok, $msg);
     $res->success = 1;
     $res->message = "share successful";
     $res->result = $result;
     return $res;
 }
Exemplo n.º 9
0
 /**
  * Prepares the stream item
  *
  * @since	1.0
  * @access	public
  * @param	SocialStreamItem	The stream object.
  * @param	bool				Determines if we should respect the privacy
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != 'discussions') {
         return;
     }
     // group access checking
     $group = FD::group($item->cluster_id);
     if (!$group) {
         return;
     }
     if (!$group->canViewItem()) {
         return;
     }
     // Ensure that announcements are enabled for this group
     $registry = $group->getParams();
     if (!$registry->get('discussions', true)) {
         return;
     }
     // Define standard stream looks
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $item->color = '#69b598';
     $item->fonticon = 'ies-comments';
     $item->label = FD::_('COM_EASYSOCIAL_STREAM_CONTEXT_TITLE_DISCUSSIONS_TOOLTIP', true);
     $params = $this->getApp()->getParams();
     if ($params->get('stream_' . $item->verb, true) == false) {
         return;
     }
     // Do not allow user to repost discussions
     $item->repost = false;
     // Process likes and comments differently.
     $likes = FD::likes();
     $likes->get($item->contextId, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, $item->uid);
     $item->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($item->contextId, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     if ($item->verb == 'create') {
         $this->prepareCreateDiscussionStream($item);
     }
     if ($item->verb == 'reply') {
         $this->prepareReplyStream($item);
     }
     if ($item->verb == 'answered') {
         $this->prepareAnsweredStream($item);
     }
     if ($item->verb == 'lock') {
         $this->prepareLockedStream($item);
     }
 }
Exemplo n.º 10
0
 public function onAfterLikeSave($likes)
 {
     $segments = explode('.', $likes->type);
     if (count($segments) !== 3 || $segments[1] !== SOCIAL_TYPE_EVENT) {
         return;
     }
     list($element, $group, $verb) = explode('.', $likes->type);
     if ($element !== 'guests') {
         return;
     }
     // Get the actor
     $actor = FD::user($likes->created_by);
     // Verbs
     // makeadmin
     // going
     // notgoing
     $guest = FD::table('EventGuest');
     $guest->load($likes->uid);
     $event = FD::event($guest->cluster_id);
     $stream = FD::table('Stream');
     $stream->load($likes->stream_id);
     $owner = FD::user($stream->actor_id);
     // APP_USER_EVENTS_GUESTS_EMAILS_MAKEADMIN_LIKE_ITEM_SUBJECT
     // APP_USER_EVENTS_GUESTS_EMAILS_GOING_LIKE_ITEM_SUBJECT
     // APP_USER_EVENTS_GUESTS_EMAILS_NOTGOING_LIKE_ITEM_SUBJECT
     // APP_USER_EVENTS_GUESTS_EMAILS_MAKEADMIN_LIKE_INVOLVED_SUBJECT
     // APP_USER_EVENTS_GUESTS_EMAILS_GOING_LIKE_INVOLVED_SUBJECT
     // APP_USER_EVENTS_GUESTS_EMAILS_NOTGOING_LIKE_INVOLVED_SUBJECT
     // apps/user/events/guest.makeadmin.like.item
     // apps/user/events/guest.going.like.item
     // apps/user/events/guest.notgoing.like.item
     // apps/user/events/guest.makeadmin.like.involved
     // apps/user/events/guest.going.like.involved
     // apps/user/events/guest.notgoing.like.involved
     $emailOptions = array('title' => 'APP_USER_EVENTS_GUESTS_EMAILS_' . strtoupper($verb) . '_LIKE_ITEM_SUBJECT', 'template' => 'apps/user/events/guest.' . $verb . '.like.item', 'permalink' => FRoute::stream(array('layout' => 'item', 'id' => $likes->stream_id, 'external' => true)), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true));
     $systemOptions = array('context_type' => $likes->type, 'url' => FRoute::stream(array('layout' => 'item', 'id' => $likes->stream_id, 'sef' => false)), 'actor_id' => $likes->created_by, 'uid' => $likes->uid, 'aggregate' => true);
     // Notify the owner first
     if ($likes->created_by != $owner->id) {
         FD::notify('likes.item', array($owner->id), $emailOptions, $systemOptions);
     }
     // Get a list of recipients to be notified for this stream item
     // We exclude the guest and the actor of the like here
     $recipients = $this->getStreamNotificationTargets($likes->uid, $element, $group, $verb, array(), array($owner->id, $likes->created_by));
     $emailOptions['title'] = 'APP_USER_EVENTS_GUESTS_EMAILS_' . strtoupper($verb) . '_LIKE_INVOLVED_SUBJECT';
     $emailOptions['template'] = 'apps/user/events/guest.' . $verb . '.like.involved';
     // Notify other participating users
     FD::notify('likes.involved', $recipients, $emailOptions, $systemOptions);
 }
Exemplo n.º 11
0
 /**
  * Generates the stream title of event.
  *
  * @since    1.0
  * @access    public
  * @param    object    $params        A standard object with key / value binding.
  *
  * @return    none
  */
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     if ($stream->context != 'links') {
         return;
     }
     // event access checking
     $event = FD::event($stream->cluster_id);
     if (!$event || !$event->canViewItem()) {
         return;
     }
     //get links object, in this case, is the stream_item
     $uid = $stream->uid;
     $stream->color = '#5580BE';
     $stream->fonticon = 'ies-link';
     $stream->label = FD::_('APP_EVENT_LINKS_STREAM_TOOLTIP', true);
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_EVENT, $stream->uid);
     $stream->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_EVENT, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream->uid))), $stream->uid);
     $stream->comments = $comments;
     // Apply repost on the stream
     $stream->repost = FD::get('Repost', $stream->uid, SOCIAL_TYPE_STREAM, SOCIAL_APPS_GROUP_EVENT);
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_LINKS, $stream->actor->id)) {
         return;
     }
     $actor = $stream->actor;
     $target = count($stream->targets) > 0 ? $stream->targets[0] : '';
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $assets = $stream->getAssets();
     if (empty($assets)) {
         return;
     }
     $assets = $assets[0];
     $videoHtml = '';
     // Retrieve the link that is stored.
     $hash = md5($assets->get('link'));
     $link = FD::table('Link');
     $link->load(array('hash' => $hash));
     $linkObj = FD::json()->decode($link->data);
     // Determine if there's any embedded object
     $oembed = isset($linkObj->oembed) ? $linkObj->oembed : '';
     // Get app params
     $params = $this->getParams();
     $this->set('event', $event);
     $this->set('params', $params);
     $this->set('oembed', $oembed);
     $this->set('assets', $assets);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $stream);
     $stream->title = parent::display('streams/title.' . $stream->verb);
     $stream->preview = parent::display('streams/preview.' . $stream->verb);
     return true;
 }
Exemplo n.º 12
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;
     }
 }
Exemplo n.º 13
0
 /**
  * Returns the stream's permalink
  *
  * @since	1.0
  * @access	public
  * @param	bool	Determines if the output should be xhtml encoded.
  * @return	string	The url
  */
 public function getPermalink($xhtml = true, $external = false, $sef = true)
 {
     return FRoute::stream(array('id' => $this->uid, 'layout' => 'item', 'external' => $external, 'sef' => $sef), $xhtml);
 }
Exemplo n.º 14
0
 public function prepareCreatedTaskStream(SocialStreamItem $streamItem, $includePrivacy = true)
 {
     $params = FD::registry($streamItem->params);
     // Get the tasks available from the cached data
     $items = $params->get('tasks');
     $tasks = array();
     $taskId = '';
     foreach ($items as $item) {
         $task = FD::table('Task');
         $task->load($item->id);
         $tasks[] = $task;
         $taskId = $task->id;
     }
     // Get the milestone
     $milestone = FD::table('Milestone');
     $milestone->bind($params->get('milestone'));
     // Get the group data
     FD::load('group');
     $group = new SocialGroup();
     $group->bind($params->get('group'));
     // We need to get the task app for the group
     $app = Foundry::table('App');
     $app->load(array('element' => 'tasks', 'group' => 'group'));
     $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('stream', $streamItem);
     $this->set('milestone', $milestone);
     $this->set('total', count($tasks));
     $this->set('actor', $streamItem->actor);
     $this->set('group', $group);
     $this->set('tasks', $tasks);
     $streamItem->title = parent::display('streams/tasks/create.task.title');
     $streamItem->content = parent::display('streams/tasks/create.task.content');
     // Append the likes action on the stream
     if (!$streamItem->contextIds[0]) {
         $likes = Foundry::likes();
         $likes->get($taskId, $streamItem->context, $streamItem->verb, SOCIAL_TYPE_GROUP, $streamItem->uid);
         $streamItem->likes = $likes;
         // Append the comment action on the stream
         $comments = Foundry::comments($taskId, $streamItem->context, $streamItem->verb, SOCIAL_TYPE_GROUP, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $streamItem->uid))), $streamItem->uid);
         $streamItem->comments = $comments;
     }
 }
Exemplo n.º 15
0
 /**
  * Override parent's implementation as we need to generate the stream
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function addFile($title = null)
 {
     // Run the parent's logics first
     $result = parent::addFile($title);
     if ($result instanceof SocialException) {
         return $result;
     }
     // Create a stream item for the groups now
     $stream = FD::stream();
     $tpl = $stream->getTemplate();
     $actor = FD::user();
     // this is a cluster stream and it should be viewable in both cluster and user page.
     $tpl->setCluster($this->group->id, SOCIAL_TYPE_GROUP, $this->group->type);
     // Set the actor
     $tpl->setActor($actor->id, SOCIAL_TYPE_USER);
     // Set the context
     $tpl->setContext($result->id, SOCIAL_TYPE_FILES);
     // Set the verb
     $tpl->setVerb('uploaded');
     $file = FD::table('File');
     $file->load($result->id);
     // Set the params to cache the group data
     $registry = FD::registry();
     $registry->set('group', $this->group);
     $registry->set('file', $file);
     // Set the params to cache the group data
     $tpl->setParams($registry);
     // since this is a cluster and user stream, we need to call setPublicStream
     // so that this stream will display in unity page as well
     // This stream should be visible to the public
     $tpl->setAccess('core.view');
     $streamItem = $stream->add($tpl);
     // Prepare the stream permalink
     $permalink = FRoute::stream(array('layout' => 'item', 'id' => $streamItem->uid));
     // Notify group members when a new file is uploaded
     $this->group->notifyMembers('file.uploaded', array('fileId' => $file->id, 'fileName' => $file->name, 'fileSize' => $file->getSize(), 'permalink' => $permalink, 'userId' => $file->user_id));
     return $result;
 }
Exemplo n.º 16
0
if (count($items) > 0) {
    ?>
				<?php 
    foreach ($items as $item) {
        ?>
					<li class="<?php 
        echo $filter->id == $item->id ? 'active' : '';
        ?>
"
						data-sidebar-item
						data-id="<?php 
        echo $item->id;
        ?>
"
						data-url="<?php 
        echo FRoute::stream(array('layout' => 'form', 'id' => $item->id));
        ?>
"
						data-title="<?php 
        echo $this->html('string.escape', $item->title) . ' - ' . JText::_('Filter', true);
        ?>
"
					>
						<a href="javascript:void(0);">
							<i class="icon-es-aircon-document mr-5"></i> <?php 
        echo $this->html('string.escape', $item->title);
        ?>
						</a>
					</li>
				<?php 
    }
Exemplo n.º 17
0
 public function streamSchema($rows, $userid)
 {
     $result = array();
     foreach ($rows as $ky => $row) {
         if (isset($row->uid)) {
             $item = new streamSimpleSchema();
             //new code
             // Set the stream title
             $item->id = $row->uid;
             //$item->title = strip_tags($row->title);
             //code changed as request not right way
             $item->title = $row->title;
             if ($row->type != 'links') {
                 $item->title = str_replace('href="', 'href="' . JURI::root(), $item->title);
             }
             $item->type = $row->type;
             $item->group = $row->cluster_type;
             $item->element_id = $row->contextId;
             //
             $item->content = $row->content;
             //$item->preview = $row->preview;
             //hari - code for build video iframe
             //check code optimisation
             $frame_match = preg_match('/;iframe.*?>/', $row->preview);
             if ($frame_match) {
                 $dom = new DOMDocument();
                 $dom->loadHTML($row->preview);
                 foreach ($dom->getElementsByTagName('a') as $node) {
                     $first = $node->getAttribute('href');
                     break;
                 }
                 if (strstr($first, "youtu.be")) {
                     $first = preg_replace("/\\s+/", '', $first);
                     $first = preg_replace("/youtu.be/", "youtube.com/embed", $first);
                     $abc = $first . "?feature=oembed";
                     $item->preview = '<div class="video-container"><iframe src="' . $abc . '" frameborder="0" allowfullscreen=""></iframe></div>';
                 } else {
                     $df = preg_replace("/\\s+/", '', $first);
                     $df = preg_replace("/watch\\?v=([a-zA-Z0-9\\]+)([a-zA-Z0-9\\/\\\\?\\&\\;\\%\\=\\.])/i", "embed/\$1 ", $first);
                     $abc = $df . "?feature=oembed";
                     $df = preg_replace("/\\s+/", '', $abc);
                     $item->preview = '<div class="video-container"><iframe src="' . $df . '" frameborder="0" allowfullscreen=""></iframe></div>';
                 }
             } else {
                 $item->preview = $row->preview;
             }
             //end
             // Set the stream content
             if (!empty($item->preview)) {
                 $item->raw_content_url = $row->preview;
             } elseif (!empty($item->content)) {
                 $item->raw_content_url = $row->content;
             }
             //code for easyblog / easydisucss share , img path not proper
             if (strpos($item->raw_content_url, 'src="//')) {
                 $item->raw_content_url = str_replace('src="//', 'src="' . 'http://', $item->raw_content_url);
             }
             if (strpos($item->content, 'src="//')) {
                 $item->content = str_replace('src="//', 'src="' . 'http://', $item->content);
             }
             if ($row->type != 'links') {
                 $item->raw_content_url = str_replace('href="', 'href="' . JURI::root(), $item->raw_content_url);
             }
             // Set the publish date
             $item->published = $row->created->toMySQL();
             /*
             // Set the generator
             $item->generator = new stdClass();
             $item->generator->url = JURI::root();
             
             // Set the generator
             $item->provider = new stdClass();
             $item->provider->url = JURI::root();
             */
             // Set the verb
             $item->verb = $row->verb;
             //create users object
             $actors = array();
             $user_url = array();
             foreach ($row->actors as $actor) {
                 $user_url[$actor->id] = JURI::root() . FRoute::profile(array('id' => $actor->id, 'layout' => 'item', 'sef' => false));
                 $actors[] = $this->createUserObj($actor->id);
             }
             //with share obj users object
             //$with_usr = array();
             $with_user_url = array();
             foreach ($row->with as $actor) {
                 $withurl = JURI::root() . FRoute::profile(array('id' => $actor->id, 'layout' => 'item', 'sef' => false));
                 $with_user_url[] = "<a href='" . $withurl . "'>" . $actor->username . "</a>";
                 //$with_url = $with_url." and ".
                 //$with_user_url[] = $this->createUserObj($actor->id);
             }
             $item->with = null;
             //to maintain site view for with url
             if (!empty($with_user_url)) {
                 $cnt = sizeof($with_user_url);
                 $item->with = 'with ' . $with_user_url[0];
                 for ($i = 0; $i < $cnt - 2; $i++) {
                     $item->with = $item->with . ', ' . $with_user_url[$i + 1];
                 }
                 if ($cnt - 1 != 0) {
                     $item->with = $item->with . ' and ' . $with_user_url[$cnt - 1];
                 }
             }
             //
             $item->actor = $actors;
             //This node is for Report-flag for the posts.
             $item->isself = $actors[0]->id == $userid ? true : false;
             $item->likes = !empty($row->likes) ? $this->createlikeObj($row->likes, $userid) : null;
             if (!empty($row->comments->element)) {
                 $item->comment_element = $row->comments->element . "." . $row->comments->group . "." . $row->comments->verb;
                 $row->comments->stream_id = $row->comments->options['streamid'];
             } else {
                 $item->comment_element = null;
             }
             $item->comments = !empty($row->comments->uid) ? $this->createCommentsObj($row->comments) : null;
             // These properties onwards are not activity stream specs
             $item->icon = $row->fonticon;
             // Set the lapsed time
             $item->lapsed = $row->lapsed;
             // set the if this stream is mini mode or not.
             // mini mode should not have any actions such as - likes, comments, share and etc.
             $item->mini = $row->display == SOCIAL_STREAM_DISPLAY_MINI ? true : false;
             //build share url use for share post through app
             $sharing = FD::get('Sharing', array('url' => FRoute::stream(array('layout' => 'item', 'id' => $row->uid, 'external' => true, 'xhtml' => true)), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small'));
             $item->share_url = $sharing->url;
             // Check if this item has already been bookmarked
             $sticky = FD::table('StreamSticky');
             $item->isPinned = null;
             if ($sticky) {
                 $item->isPinned = $sticky->load(array('stream_id' => $row->uid));
             }
             //create urls for app side mapping
             //$log_usr = FRoute::profile( array('id' => $row->uid , 'layout' => 'item', 'sef' => false ));
             $strm_urls = array();
             $strm_urls['actors'] = $user_url;
             /*switch( $row->type )
             		{
             			case 'discussions': $strm_urls['discussions'] = JURI::root().FRoute::apps( array('id' => $row->uid , 'layout' => 'canvas', 'sef' => false ));
             			//FRoute::apps( array( 'layout' => 'canvas' , 'customView' => 'item' , 'uid' => $group->getAlias() , 'type' => SOCIAL_TYPE_GROUP , 'id' => $this->getApp()->getAlias() , 'discussionId' => $discussion->id ) , false );
             							break;
             			case 'apps':	$strm_urls['apps'] = JURI::root().FRoute::apps( array('id' => $row->element_id , 'layout' => 'item', 'sef' => false ));
             							break;
             			case 'dashboard':	$strm_urls['dashboard'] = JURI::root().FRoute::dashboard( array('id' => $row->element_id , 'layout' => 'item', 'sef' => false ));
             							break;
             			case 'albums':	$strm_urls['album'] = JURI::root().FRoute::albums( array('id' => $row->element_id , 'layout' => 'item', 'sef' => false ));
             							break;
             			case 'photos':	$strm_urls['photos'] = JURI::root().FRoute::photos( array('id' => $row->element_id , 'layout' => 'item', 'sef' => false ));
             							break;
             			case 'groups':	$strm_urls['groups'] = JURI::root().FRoute::groups( array('id' => $row->element_id , 'layout' => 'item', 'sef' => false ));
             							break;
             			case 'links':	$lnk_arr = explode('shared', $item->title);
             							
             							preg_match_all('/href=\"(.*?)\"/i', $lnk_arr[1], $matches);
             							$strm_urls['links'] = $matches[1][0];
             							break;
             		}
             		
             		$item->strm_urls = $strm_urls; */
             $result[] = $item;
             //$result[]	= $row;
             //end new
         }
     }
     return $result;
 }
Exemplo n.º 18
0
 /**
  * Prepares the stream item
  *
  * @since	1.0
  * @access	public
  * @param	SocialStreamItem	The stream object.
  * @param	bool				Determines if we should respect the privacy
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != SOCIAL_TYPE_FILES) {
         return;
     }
     // if this is a cluster stream, let check if user can view this stream or not.
     if ($item->cluster_id && $item->cluster_type) {
         $cluster = FD::cluster($item->cluster_type, $item->cluster_id);
         if (!$cluster) {
             return;
         }
         if (!$cluster->canViewItem()) {
             return;
         }
         $item->display = SOCIAL_STREAM_DISPLAY_FULL;
         if ($item->cluster_type == SOCIAL_TYPE_GROUP) {
             $item->color = '#303229';
             $item->fonticon = 'ies-users';
             $item->label = JText::_('APP_USER_FILES_GROUPS_STREAM_TOOLTIP');
         }
         if ($item->cluster_type == SOCIAL_TYPE_EVENT) {
             $item->color = '#f06050';
             $item->fonticon = 'ies-calendar';
             $item->label = JText::_('APP_USER_EVENTS_STREAM_TOOLTIP');
         }
         if ($item->verb == 'uploaded') {
             $this->prepareUploadedStream($item);
         }
         return;
     }
     // File uploads by user
     if (isset($item->contextParams[0])) {
         $params = FD::registry($item->contextParams[0]);
         $items = $params->get('files');
         $total = count($items);
         $files = array();
         if (!$items) {
             return;
         }
         foreach ($items as $id) {
             $file = FD::table('File');
             $file->load($id);
             $files[] = $file;
         }
         $plurality = $total > 1 ? '_PLURAL' : '_SINGULAR';
         $targets = $item->targets ? $item->targets[0] : false;
         $this->set('target', $targets);
         $this->set('content', $item->content);
         $this->set('plurality', $plurality);
         $this->set('total', $total);
         $this->set('files', $files);
         $this->set('actor', $item->actor);
         $item->display = SOCIAL_STREAM_DISPLAY_FULL;
         $item->color = '#00B6AD';
         $item->fonticon = 'ies-file';
         $item->label = JText::_('APP_USER_FILES_STREAM_TOOLTIP');
         // Apply likes on the stream
         $likes = FD::likes();
         $likes->get($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_USER, $item->uid);
         $item->likes = $likes;
         // Apply comments on the stream
         $comments = FD::comments($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
         $item->comments = $comments;
         $item->title = parent::display('streams/uploaded.title.user');
         $item->content = parent::display('streams/uploaded.content.user');
     }
 }
Exemplo n.º 19
0
 /**
  * Processes the stream actions
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 private function processActions(SocialStreamItem &$item, $privacy)
 {
     $group = $item->cluster_id ? $item->cluster_type : SOCIAL_APPS_GROUP_USER;
     // Whether the item is shared or uploaded via the photo albums, we need to bind the repost here
     $repost = Foundry::get('Repost', $item->uid, SOCIAL_TYPE_STREAM, $group);
     $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 = Foundry::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 = Foundry::likes();
         $likes->get($objectId, $objectType, 'upload', $group, $item->uid);
         $item->likes = $likes;
         // Append the comment action on the stream
         $comments = Foundry::comments($objectId, $objectType, 'upload', $group, array('url' => $commentUrl), $item->uid);
         $item->comments = $comments;
         return;
     }
     // If there is more than 1 photo uploaded, we need to link the likes and comments on the album
     if (count($item->contextIds) > 1) {
         $photo = false;
         $photos = $this->getPhotoFromParams($item, $privacy);
         if ($photos instanceof SocialTablePhoto) {
             $photo = $photos;
         }
         if (is_array($photos)) {
             $photo = $photos[0];
         }
         // If we can't get anything, skip this
         if (!$photo) {
             return;
         }
         // If we can't get anything, skip this
         if (!$photo) {
             return;
         }
         $element = SOCIAL_TYPE_ALBUM;
         $uid = $photo->album_id;
         // Get the album object
         $album = Foundry::table('Album');
         $album->load($photo->album_id);
         // Format the likes for the stream
         $likes = Foundry::likes();
         $likes->get($photo->album_id, 'albums', 'create', $group);
         $item->likes = $likes;
         // Apply comments on the stream
         $commentParams = array('url' => $album->getPermalink());
         $comments = Foundry::comments($photo->album_id, 'albums', 'create', $group, $commentParams);
         $item->comments = $comments;
         return;
     }
     // Here onwards we are assuming that the likes and comment should be applied on the single photo.
     // Since the stream library already handles this nicely, we leave it to the stream to handle.
     // $likes 				= Foundry::likes();
     // $likes->get($item->contextId , $item->context, $item->verb , SOCIAL_APPS_GROUP_USER );
     // $item->likes		= $likes;
     // // Apply comments on the stream
     // $comments			= Foundry::comments( $item->contextId , $item->context , $item->verb, SOCIAL_APPS_GROUP_USER , array( 'url' => FRoute::photos( array( 'layout' => 'item', 'id' => $item->contextId ) ) ) );
     // $item->comments 	= $comments;
 }
Exemplo n.º 20
0
 /**
  * Responsible to generate the stream contents.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$item)
 {
     // Load up the config object
     $config = FD::config();
     if ($item->context != 'badges' || !$config->get('badges.enabled')) {
         return;
     }
     // Check if the app should be able to generate the stream.
     $params = $this->getParams();
     if (!$params->get('stream_achieved', true)) {
         return;
     }
     // Test if stream item is allowed
     if (!$this->onStreamValidatePrivacy($item)) {
         return;
     }
     // Get the actor
     $actor = $item->actor;
     // Try to get the badge object from the params
     $raw = $item->params;
     $badge = FD::table('Badge');
     $badge->load($item->contextId);
     // Set the display mode to be full.
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $item->color = '#FEBC9D';
     $item->fonticon = 'ies-crown';
     $item->label = JText::_('APP_USER_BADGES_STREAM_TOOLTIP');
     // Format the likes for the stream
     $likes = FD::likes();
     $likes->get($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, $item->uid);
     $item->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     $this->set('badge', $badge);
     $this->set('actor', $actor);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     $item->content = parent::display('streams/' . $item->verb . '.content');
     return true;
 }
Exemplo n.º 21
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;
 }
Exemplo n.º 22
0
 /**
  * Notify the owner of the stream
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function onAfterStreamSave(SocialStreamTemplate &$streamTemplate)
 {
     // We only want to process shares
     if ($streamTemplate->context_type != SOCIAL_TYPE_SHARE || !$streamTemplate->cluster_type) {
         return;
     }
     $allowed = array('add.stream');
     if (!in_array($streamTemplate->verb, $allowed)) {
         return;
     }
     // Because the verb is segmented with a ., we need to split this up
     $namespace = explode('.', $streamTemplate->verb);
     $verb = $namespace[0];
     $type = $namespace[1];
     // Add a notification to the owner of the stream
     $stream = FD::table('Stream');
     $stream->load($streamTemplate->target_id);
     // If the person that is reposting this is the same as the actor of the stream, skip this altogether.
     if ($streamTemplate->actor_id == $stream->actor_id) {
         return;
     }
     // Get the group
     $group = FD::group($streamTemplate->cluster_id);
     // Get the actor
     $actor = FD::user($streamTemplate->actor_id);
     // Get the share object
     $share = FD::table('Share');
     $share->load($streamTemplate->context_id);
     // Prepare the email params
     $mailParams = array();
     $mailParams['actor'] = $actor->getName();
     $mailParams['actorLink'] = $actor->getPermalink(true, true);
     $mailParams['actorAvatar'] = $actor->getAvatar(SOCIAL_AVATAR_SQUARE);
     $mailParams['group'] = $group->getName();
     $mailParams['groupLink'] = $group->getPermalink(true, true);
     $mailParams['permalink'] = FRoute::stream(array('layout' => 'item', 'id' => $share->uid, 'external' => true), true);
     $mailParams['title'] = 'APP_GROUP_SHARES_EMAILS_USER_REPOSTED_YOUR_POST_SUBJECT';
     $mailParams['template'] = 'apps/group/shares/stream.repost';
     // Prepare the system notification params
     $systemParams = array();
     $systemParams['context_type'] = $streamTemplate->verb;
     $systemParams['url'] = FRoute::stream(array('layout' => 'item', 'id' => $share->uid, 'sef' => false));
     $systemParams['actor_id'] = $actor->id;
     $systemParams['uid'] = $group->id;
     $systemParams['context_ids'] = $share->id;
     FD::notify('repost.item', array($stream->actor_id), $mailParams, $systemParams);
 }
Exemplo n.º 23
0
 /**
  * Processes when someone likes the stream of a milestone
  *
  * @since    1.2
  * @access    public
  * @param    string
  * @return
  */
 public function onAfterLikeSave(&$likes)
 {
     $allowed = array('tasks.event.createMilestone', 'tasks.event.createTask');
     if (!in_array($likes->type, $allowed)) {
         return;
     }
     // Get the verb
     list($element, $group, $verb) = explode('.', $likes->type);
     $identifier = $verb == 'createMilestone' ? 'milestone' : 'task';
     // Get the milestone/task table
     $table = FD::table($identifier);
     $table->load($likes->uid);
     // Get the actor
     $actor = FD::user($likes->created_by);
     // Get the owner
     $owner = FD::user($table->owner_id);
     // Get the event
     $event = FD::event($table->uid);
     $recipients = $this->getStreamNotificationTargets($likes->uid, $element, $group, $verb, array(), array($owner->id, $likes->created_by));
     // APP_EVENT_TASKS_EMAILS_LIKE_YOUR_MILESTONE_SUBJECT
     // APP_EVENT_TASKS_EMAILS_LIKE_YOUR_TASK_SUBJECT
     // APP_EVENT_TASKS_EMAILS_LIKE_A_MILESTONE_SUBJECT
     // APP_EVENT_TASKS_EMAILS_LIKE_A_TASK_SUBJECT
     // apps/event/tasks/like.milestone
     // apps/event/tasks/like.task
     // apps/event/tasks/like.milestone.involved
     // apps/event/tasks/like.task.involved
     $emailOptions = array('title' => 'APP_EVENT_TASKS_EMAILS_LIKE_YOUR_' . strtoupper($identifier) . '_SUBJECT', 'template' => 'apps/event/tasks/like.' . $identifier, 'permalink' => FRoute::stream(array('layout' => 'item', 'id' => $likes->stream_id, 'external' => true)), 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true));
     $systemOptions = array('context_type' => $likes->type, 'url' => FRoute::stream(array('layout' => 'item', 'id' => $likes->stream_id, 'sef' => false)), 'actor_id' => $likes->created_by, 'uid' => $likes->uid, 'aggregate' => true);
     // Notify the owner first
     if ($likes->created_by != $owner->id) {
         FD::notify('likes.item', array($owner->id), $emailOptions, $systemOptions);
     }
     // Get a list of recipients to be notified for this stream item
     // We exclude the owner of the note and the actor of the like here
     $recipients = $this->getStreamNotificationTargets($likes->uid, $element, $group, $verb, array(), array($owner->id, $likes->created_by));
     $emailOptions['title'] = 'APP_EVENT_TASKS_EMAILS_LIKE_A_' . strtoupper($identifier) . '_SUBJECT';
     $emailOptions['template'] = 'apps/event/tasks/like.' . $identifier . '.involved';
     // Notify other participating users
     FD::notify('likes.involved', $recipients, $emailOptions, $systemOptions);
 }
Exemplo n.º 24
0
 /**
  * Generates the stream title of group.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     if ($stream->context != 'links') {
         return;
     }
     // Group access
     $group = FD::group($stream->cluster_id);
     if (!$group) {
         return;
     }
     if (!$group->canViewItem()) {
         return;
     }
     //get links object, in this case, is the stream_item
     $uid = $stream->uid;
     $stream->color = '#5580BE';
     $stream->fonticon = 'ies-link';
     $stream->label = FD::_('APP_GROUP_LINKS_STREAM_TOOLTIP', true);
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_GROUP, $stream->uid);
     $stream->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_GROUP, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream->uid))), $stream->uid);
     $stream->comments = $comments;
     // Apply repost on the stream
     $repost = FD::get('Repost', $stream->uid, SOCIAL_TYPE_STREAM, SOCIAL_APPS_GROUP_GROUP);
     $stream->repost = $repost;
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_LINKS, $stream->actor->id)) {
         return;
     }
     $actor = $stream->actor;
     $target = count($stream->targets) > 0 ? $stream->targets[0] : '';
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $assets = $stream->getAssets();
     if (empty($assets)) {
         return;
     }
     // Get the assets
     $assets = $assets[0];
     // Get app params
     $params = $this->getParams();
     // Retrieve the link that is stored.
     $hash = md5($assets->get('link'));
     // Load the link object
     $link = FD::table('Link');
     $link->load(array('hash' => $hash));
     // Get the link data
     $linkObj = json_decode($link->data);
     // Determine if there's any embedded object
     $oembed = isset($linkObj->oembed) ? $linkObj->oembed : '';
     $image = FD::links()->getImageLink($assets, $params);
     // Fix video issues with youtube when site is on https
     $oembed = FD::links()->fixOembedLinks($oembed);
     // Get the contents and truncate accordingly
     $content = $assets->get('content', '');
     if ($params->get('stream_link_truncate')) {
         $content = JString::substr(strip_tags($content), 0, $params->get('stream_link_truncate_length', 250)) . JText::_('COM_EASYSOCIAL_ELLIPSES');
     }
     $this->set('image', $image);
     $this->set('content', $content);
     $this->set('params', $params);
     $this->set('oembed', $oembed);
     $this->set('assets', $assets);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $stream);
     $this->set('group', $group);
     $stream->title = parent::display('streams/title.' . $stream->verb);
     $stream->preview = parent::display('streams/preview.' . $stream->verb);
     return true;
 }
Exemplo n.º 25
0
 public function streamSchema($rows, $userid)
 {
     $result = array();
     foreach ($rows as $ky => $row) {
         if (isset($row->uid)) {
             $item = new streamSimpleSchema();
             //new code
             // Set the stream title
             $item->id = $row->uid;
             //$item->title = strip_tags($row->title);
             //code changed as request not right way
             $item->title = $row->title;
             if ($row->type != 'links') {
                 $item->title = str_replace('href="', 'href="' . JURI::root(), $item->title);
             }
             $item->type = $row->type;
             $item->group = $row->cluster_type;
             $item->element_id = $row->contextId;
             //
             $item->content = $row->content;
             $item->preview = $row->preview;
             // Set the stream content
             if (!empty($item->preview)) {
                 $item->raw_content_url = $row->preview;
             } elseif (!empty($item->content)) {
                 $item->raw_content_url = $row->content;
             }
             if ($row->type != 'links') {
                 $item->raw_content_url = str_replace('href="', 'href="' . JURI::root(), $item->raw_content_url);
             }
             // Set the publish date
             $item->published = $row->created->toMySQL();
             /*
             // Set the generator
             $item->generator = new stdClass();
             $item->generator->url = JURI::root();
             
             // Set the generator
             $item->provider = new stdClass();
             $item->provider->url = JURI::root();
             */
             // Set the verb
             $item->verb = $row->verb;
             //create users object
             $actors = array();
             $user_url = array();
             foreach ($row->actors as $actor) {
                 $user_url[$actor->id] = JURI::root() . FRoute::profile(array('id' => $actor->id, 'layout' => 'item', 'sef' => false));
                 $actors[] = $this->createUserObj($actor->id);
             }
             //with share obj users object
             //$with_usr = array();
             $with_user_url = array();
             foreach ($row->with as $actor) {
                 $withurl = JURI::root() . FRoute::profile(array('id' => $actor->id, 'layout' => 'item', 'sef' => false));
                 $with_user_url[] = "<a href='" . $withurl . "'>" . $actor->username . "</a>";
                 //$with_url = $with_url." and ".
                 //$with_user_url[] = $this->createUserObj($actor->id);
             }
             $item->with = null;
             //to maintain site view for with url
             if (!empty($with_user_url)) {
                 $cnt = sizeof($with_user_url);
                 $item->with = 'with ' . $with_user_url[0];
                 for ($i = 0; $i < $cnt - 2; $i++) {
                     $item->with = $item->with . ', ' . $with_user_url[$i + 1];
                 }
                 if ($cnt - 1 != 0) {
                     $item->with = $item->with . ' and ' . $with_user_url[$cnt - 1];
                 }
             }
             //
             $item->actor = $actors;
             $item->likes = !empty($row->likes) ? $this->createlikeObj($row->likes, $userid) : null;
             if (!empty($row->comments->element)) {
                 $item->comment_element = $row->comments->element . "." . $row->comments->group . "." . $row->comments->verb;
             } else {
                 $item->comment_element = null;
             }
             $item->comments = !empty($row->comments->uid) ? $this->createCommentsObj($row->comments) : null;
             // These properties onwards are not activity stream specs
             $item->icon = $row->fonticon;
             // Set the lapsed time
             $item->lapsed = $row->lapsed;
             // set the if this stream is mini mode or not.
             // mini mode should not have any actions such as - likes, comments, share and etc.
             $item->mini = $row->display == SOCIAL_STREAM_DISPLAY_MINI ? true : false;
             //build share url use for share post through app
             $sharing = FD::get('Sharing', array('url' => FRoute::stream(array('layout' => 'item', 'id' => $row->uid, 'external' => true, 'xhtml' => true)), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small'));
             $item->share_url = $sharing->url;
             // Check if this item has already been bookmarked
             $sticky = FD::table('StreamSticky');
             $item->isPinned = $sticky->load(array('stream_id' => $row->uid));
             //create urls for app side mapping
             //$log_usr = FRoute::profile( array('id' => $row->uid , 'layout' => 'item', 'sef' => false ));
             $strm_urls = array();
             $strm_urls['actors'] = $user_url;
             /*switch( $row->type )
             		{
             			case 'discussions': $strm_urls['discussions'] = JURI::root().FRoute::apps( array('id' => $row->uid , 'layout' => 'canvas', 'sef' => false ));
             			//FRoute::apps( array( 'layout' => 'canvas' , 'customView' => 'item' , 'uid' => $group->getAlias() , 'type' => SOCIAL_TYPE_GROUP , 'id' => $this->getApp()->getAlias() , 'discussionId' => $discussion->id ) , false );
             							break;
             			case 'apps':	$strm_urls['apps'] = JURI::root().FRoute::apps( array('id' => $row->element_id , 'layout' => 'item', 'sef' => false ));
             							break;
             			case 'dashboard':	$strm_urls['dashboard'] = JURI::root().FRoute::dashboard( array('id' => $row->element_id , 'layout' => 'item', 'sef' => false ));
             							break;
             			case 'albums':	$strm_urls['album'] = JURI::root().FRoute::albums( array('id' => $row->element_id , 'layout' => 'item', 'sef' => false ));
             							break;
             			case 'photos':	$strm_urls['photos'] = JURI::root().FRoute::photos( array('id' => $row->element_id , 'layout' => 'item', 'sef' => false ));
             							break;
             			case 'groups':	$strm_urls['groups'] = JURI::root().FRoute::groups( array('id' => $row->element_id , 'layout' => 'item', 'sef' => false ));
             							break;
             			case 'links':	$lnk_arr = explode('shared', $item->title);
             							
             							preg_match_all('/href=\"(.*?)\"/i', $lnk_arr[1], $matches);
             							$strm_urls['links'] = $matches[1][0];
             							break;
             		}
             		
             		$item->strm_urls = $strm_urls; */
             $result[] = $item;
             //$result[]	= $row;
             //end new
         }
     }
     return $result;
 }
Exemplo n.º 26
0
 /**
  * Responsible to generate the stream content for profiles apps.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != 'profiles') {
         return;
     }
     // Get the application params
     $params = $this->getParams();
     if ($item->verb == 'update' && !$params->get('stream_update', true)) {
         return;
     }
     if ($item->verb == 'register' && !$params->get('stream_register', true)) {
         return;
     }
     $my = FD::user();
     // Decorate the stream
     $item->display = SOCIAL_STREAM_DISPLAY_MINI;
     if ($item->verb == 'register') {
         $item->color = '#FF7553';
         $item->fonticon = 'ies-user-add';
         $item->label = FD::_('APP_USER_PROFILES_REGISTER_STREAM_TOOLTIP', true);
     }
     // When user updates their profile.
     if ($item->verb == 'update') {
         $item->color = '#1FBCA7';
         $item->fonticon = 'ies-briefcase';
         $item->label = FD::_('APP_USER_PROFILES_UPDATE_PROFILE_STREAM_TOOLTIP', true);
     }
     $actor = $item->actor;
     if (!$actor->hasCommunityAccess()) {
         $item->title = '';
         return;
     }
     $genderValue = $actor->getFieldData('GENDER');
     $gender = 'THEIR';
     if ($genderValue == 1) {
         $gender = 'MALE';
     }
     if ($genderValue == 2) {
         $gender = 'FEMALE';
     }
     // Override the likes
     $item->likes = FD::likes($item->uid, 'userprofile', $item->verb, SOCIAL_APPS_GROUP_USER, $item->uid);
     // Override the comments
     $comments = FD::comments($item->uid, 'userprofile', $item->verb, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     $this->set('gender', $gender);
     $this->set('actor', $item->actor);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     return true;
 }
Exemplo n.º 27
0
 /**
  * Prepares the stream item.
  *
  * @since   1.3
  * @access  public
  * @param   SocialStreamItem    $item           The stream object.
  * @param   boolean             $includePrivacy True if privacy should be respected.
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != 'discussions') {
         return;
     }
     // Get the event object
     $event = FD::event($item->cluster_id);
     if (!$event) {
         return;
     }
     if (!$event->canViewItem()) {
         return;
     }
     // Define standard stream looks
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $item->color = '#69b598';
     $item->fonticon = 'ies-comments';
     $item->label = JText::_('COM_EASYSOCIAL_STREAM_CONTEXT_TITLE_DISCUSSIONS_TOOLTIP');
     $params = $this->getApp()->getParams();
     if ($params->get('stream_' . $item->verb, true) == false) {
         return;
     }
     // Do not allow user to repost discussions
     $item->repost = false;
     // Process likes and comments differently.
     $likes = FD::likes();
     $likes->get($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_EVENT, $item->uid);
     $item->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_EVENT, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     if ($item->verb == 'create') {
         $this->prepareCreateStream($item);
     }
     if ($item->verb == 'reply') {
         $this->prepareReplyStream($item);
     }
     if ($item->verb == 'answered') {
         $this->prepareAnsweredStream($item);
     }
     if ($item->verb == 'locked') {
         $this->prepareLockedStream($item);
     }
 }
Exemplo n.º 28
0
    }
    ?>

									<div class="es-stream-title">
										<?php 
    echo $stream->title;
    ?>
									</div>
									<div class="es-stream-meta-footer">

										<?php 
    if ($this->config->get('stream.timestamp.enabled')) {
        ?>
										<time>
											<a href="<?php 
        echo FRoute::stream(array('id' => $stream->uid, 'layout' => 'item'));
        ?>
"><?php 
        echo $stream->friendlyDate;
        ?>
</a>
										</time>
										<?php 
    }
    ?>
									</div>
								</div>
							</div>
						</div>

		 				<?php 
Exemplo n.º 29
0
 /**
  * Triggered to prepare the stream item
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     // If this is not it's context, we don't want to do anything here.
     if ($stream->context != 'story') {
         return;
     }
     $uid = $stream->uid;
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($stream->cluster_id) {
         // Group access checking
         $cluster = FD::cluster($stream->cluster_type, $stream->cluster_id);
         if (!$cluster) {
             return;
         }
         if (!$cluster->canViewItem()) {
             return;
         }
         // Allow editing of the stream item
         $stream->editable = $my->isSiteAdmin() || $cluster->isAdmin() || $stream->actor->id == $my->id;
     } else {
         // Allow editing of the stream item
         $stream->editable = $my->isSiteAdmin() || $stream->actor->id == $my->id;
     }
     // we stil need to check for the privacy because the context might come from the 'repost'
     if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_STORY, $stream->actor->id)) {
         return;
     }
     // Actor of this stream
     $actor = $stream->actor;
     $target = count($stream->targets) > 0 ? $stream->targets[0] : '';
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $stream->color = '#16a085';
     $stream->fonticon = 'ies-pencil-2';
     $stream->label = FD::_('APP_USER_STORY_UPDATES_STREAM_TOOLTIP', true);
     if ($stream->cluster_id) {
         if ($stream->cluster_type == SOCIAL_TYPE_GROUP) {
             $stream->color = '#303229';
             $stream->fonticon = 'ies-users';
             $stream->label = FD::_('APP_USER_STORY_GROUPS_STREAM_TOOLTIP', true);
         }
         if ($stream->cluster_type == SOCIAL_TYPE_EVENT) {
             $stream->color = '#f06050';
             $stream->fonticon = 'ies-calendar';
             $stream->label = FD::_('APP_USER_STORY_EVENTS_STREAM_TOOLTIP', true);
         }
     }
     $appGroup = SOCIAL_APPS_GROUP_USER;
     if ($stream->cluster_id) {
         if ($stream->cluster_type == SOCIAL_TYPE_EVENT) {
             $appGroup = SOCIAL_APPS_GROUP_EVENT;
         } else {
             $appGroup = SOCIAL_APPS_GROUP_GROUP;
         }
     }
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($stream->uid, $stream->context, $stream->verb, $appGroup, $stream->uid);
     $stream->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($stream->uid, $stream->context, $stream->verb, $appGroup, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream->uid))), $stream->uid);
     $stream->comments = $comments;
     // Apply repost on the stream
     $repost = FD::get('Repost', $stream->uid, SOCIAL_TYPE_STREAM, $appGroup);
     $stream->repost = $repost;
     // If this is a group type, and the viewer is not a member of the group, we need to hide these data
     if ($stream->cluster_id) {
         $cluster = FD::cluster($stream->cluster_type, $stream->cluster_id);
         if (!$cluster->isMember()) {
             $stream->commentLink = false;
             $stream->repost = false;
             $stream->commentForm = false;
         }
         // Sharing only show in public group
         if (!$cluster->isOpen()) {
             $stream->sharing = false;
         }
     }
     // Get application params
     $params = $this->getParams();
     $this->set('params', $params);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $stream);
     if ($stream->cluster_id) {
         $clusterReg = FD::registry($stream->params);
         $object = $clusterReg->get($stream->cluster_type);
         $cluster = FD::cluster($stream->cluster_type);
         if ($object) {
             // If have the object only bind
             $cluster->bind($object);
         } else {
             $cluster = $stream->getCluster();
         }
         $this->set('cluster', $cluster);
     }
     $titleFileName = $stream->cluster_type ? $stream->cluster_type . '.' . $stream->verb : $stream->verb;
     $stream->title = parent::display('streams/title.' . $titleFileName);
     $stream->content = parent::display('streams/content.' . $stream->verb);
     $stream->opengraph->addDescription($stream->content);
     if ($includePrivacy) {
         $stream->privacy = $privacy->form($uid, SOCIAL_TYPE_STORY, $stream->actor->id, 'story.view', false, $stream->uid);
     }
     return true;
 }
Exemplo n.º 30
0
 /**
  * Responsible to generate the stream contents.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$item)
 {
     // Load up the config object
     $config = FD::config();
     if ($item->context != 'badges' || !$config->get('badges.enabled')) {
         return;
     }
     // Check if the app should be able to generate the stream.
     $params = $this->getParams();
     if (!$params->get('stream_achieved', true)) {
         return;
     }
     // Get the actor
     $actor = $item->actor;
     // check if the actor is ESAD profile or not, if yes, we skip the rendering.
     if (!$actor->hasCommunityAccess()) {
         $item->title = '';
         return;
     }
     // Test if stream item is allowed
     if (!$this->onStreamValidatePrivacy($item)) {
         return;
     }
     // Try to get the badge object from the params
     $raw = $item->params;
     $badge = FD::table('Badge');
     $badge->load($item->contextId);
     // lets load 3rd party component's language file if this is not a core badge
     if ($badge->extension && $badge->extension != 'com_easysocial') {
         Foundry::language()->load($badge->extension, JPATH_ROOT);
     }
     // Set the display mode to be full.
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $item->color = '#FEBC9D';
     $item->fonticon = 'ies-crown';
     $item->label = FD::_('APP_USER_BADGES_STREAM_TOOLTIP', true);
     // Format the likes for the stream
     $likes = FD::likes();
     $likes->get($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, $item->uid);
     $item->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     $this->set('badge', $badge);
     $this->set('actor', $actor);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     $item->content = parent::display('streams/' . $item->verb . '.content');
     return true;
 }