public function createStream($verb) { // Create a new stream item for this discussion $stream = FD::stream(); // Get the stream template $tpl = $stream->getTemplate(); // Someone just joined the event $tpl->setActor($this->created_by, SOCIAL_TYPE_USER); // Set the params to cache the event data $registry = FD::registry(); $registry->set('news', $this); // Set the context $tpl->setContext($this->id, 'news'); $event = FD::event($this->cluster_id); // Set the cluster $tpl->setCluster($this->cluster_id, SOCIAL_TYPE_EVENT, $event->type); // Set the verb $tpl->setVerb($verb); // Set the params $tpl->setParams($registry); if ($this->_stream_date) { $tpl->setDate($this->_stream_date); } $tpl->setAccess('core.view'); // Add the stream $stream->add($tpl); }
public function getContent() { $source = explode('.', $this->share->element); $element = $source[0]; $group = $source[1]; $message = $this->formatContent($this->share->content); $preview = ""; $content = ""; $title = ""; $stream = FD::stream(); $data = $stream->getItem($this->share->uid); if ($data !== true && !empty($data)) { $title = $data[0]->title; $content = $data[0]->content; if (isset($data[0]->preview) && $data[0]->preview) { $preview = $data[0]->preview; } } $theme = FD::themes(); $theme->set('message', $message); $theme->set('content', $content); $theme->set('preview', $preview); $theme->set('title', $title); $html = $theme->output('apps/user/shares/streams/stream/content'); return $html; }
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); } } }
/** * 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; }
public function __construct($uid, $group, $element) { $stream = FD::stream(); $data = $stream->getItem($uid); $item = $data[0]; $this->title = $item->title; $this->content = $item->content; if (isset($item->preview) && $item->preview) { $this->content = $item->preview; } }
/** * Post processes after a user submits a story. * * @since 1.0 * @access public * @param string * @return */ public function update($streamTable = '') { // Only logged in users allowed here FD::requireLogin(); $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } $stream = FD::stream(); $stream->getItem($streamTable->uid); $output = $stream->html(false, '', array('contentOnly' => true)); return $ajax->resolve($output, $streamTable->uid); }
function toggleLike() { //init variable $app = JFactory::getApplication(); $log_user = JFactory::getUser($this->plugin->get('user')->id); $result = new stdClass(); $id = $app->input->get('id', 0, 'INT'); $type = $app->input->get('type', null, 'STRING'); $group = $app->input->get('group', 'user', 'STRING'); $itemVerb = $app->input->get('verb', null, 'STRING'); $streamid = $app->input->get('stream_id', 0, 'INT'); $my = FD::user($log_user->id); // Load likes library. $model = FD::model('Likes'); // Build the key for likes $key = $type . '.' . $group; if ($itemVerb) { $key = $key . '.' . $itemVerb; } // Determine if user has liked this item previously. $hasLiked = $model->hasLiked($id, $key, $my->id); $useStreamId = $type == 'albums' ? '' : $streamid; // If user had already liked this item, we need to unlike it. if ($hasLiked) { $state = $model->unlike($id, $key, $my->id, $useStreamId); } else { $state = $model->like($id, $key, $my->id, $useStreamId); //now we need to update the associated stream id from the liked object if ($streamid) { $doUpdate = true; if ($type == 'photos') { $sModel = FD::model('Stream'); $totalItem = $sModel->getStreamItemsCount($streamid); if ($totalItem > 1) { $doUpdate = false; } } if ($doUpdate) { $stream = FD::stream(); $stream->updateModified($streamid); } } } // The current action $verb = $hasLiked ? 'Unlike' : 'Like'; $result->status = $state; $result->data = $state && $verb == 'like' ? $model->getLikesCount($id, $type) : 0; $result->message = $state ? $verb . " successful" : $verb . " unsuccessful"; return $result; }
public function format(&$notes) { if (!$notes) { return; } // Since this is the dashboard view, we may freely use the current user. $my = FD::user(); $stream = FD::stream(); foreach ($notes as &$note) { $comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::apps(array('layout' => 'canvas', 'userid' => $my->getAlias(), 'cid' => $note->id)))); $likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER); $options = array('comments' => $comments, 'likes' => $likes); $note->actions = $stream->getActions($options); } }
/** * Toggle the likes on an object. * * @since 1.0 * @access public * @param * @return string */ public function toggle() { // Validate the current request $userId = $this->validateAuth(); // Get the item properties $id = $this->input->get('uid', 0, 'int'); $type = $this->input->get('element', '', 'cmd'); $group = $this->input->get('group', SOCIAL_APPS_GROUP_USER, 'cmd'); $itemVerb = $this->input->get('verb', '', 'string'); // Get the stream id. $streamid = $this->input->get('stream_id', 0, 'int'); // If id is invalid, throw an error. if (!$id || !$type) { $this->set('status', 0); return parent::display(); } // Get current logged in user. $my = FD::user(); // Load likes library. $model = FD::model('Likes'); // Build the key for likes $key = $type . '.' . $group; if ($itemVerb) { $key = $key . '.' . $itemVerb; } // Determine if user has liked this item previously. $hasLiked = $model->hasLiked($id, $key, $my->id); // If user had already liked this item, we need to unlike it. if ($hasLiked) { $state = $model->unlike($id, $key, $my->id, $streamid); } else { $state = $model->like($id, $key, $my->id, $streamid); //now we need to update the associated stream id from the liked object if ($streamid) { $stream = FD::stream(); $stream->updateModified($streamid); } } // The current action $verb = $hasLiked ? 'unlike' : 'like'; $this->set('status', $state ? 1 : 0); parent::display(); }
/** * Displays a single profile item layout * * @since 4.0 * @access public * @param string * @return */ public function item() { $id = $this->input->get('id', 0, 'int'); // Get the profile object $profile = FD::table('Profile'); $profile->load($id); if (!$id || !$profile->id) { return JError::raiseError(404, JText::_('COM_EASYSOCIAL_404_PROFILE_NOT_FOUND')); } $model = FD::model('Profiles'); $randomMembers = array(); // if this profile is a ESAD profile, we do not show the random members if ($profile->community_access) { $randomMembers = $model->getMembers($profile->id, array('randomize' => true, 'limit' => 20)); } $totalUsers = $profile->getMembersCount(); // Get statistics of user registration for this profile type $stats = $model->getRegistrationStats($profile->id); $stats = $stats->profiles[0]->items; // Get the stream for this profile $startlimit = JRequest::getInt('limitstart', 0); $stream = FD::stream(); $options = array('profileId' => $profile->id); if ($startlimit) { $options['startlimit'] = $startlimit; } $stream->get($options); // Set the page title to this category FD::page()->title($profile->get('title')); // Set the breadcrumbs FD::page()->breadcrumb($profile->get('title')); // Get a list of random albums from this profile $albums = $model->getRandomAlbums(array('core' => false, 'withCovers' => true)); $this->set('albums', $albums); $this->set('stream', $stream); $this->set('stats', $stats); $this->set('randomMembers', $randomMembers); $this->set('totalUsers', $totalUsers); $this->set('profile', $profile); echo parent::display('site/profiles/item'); }
/** * to update privacy on an object by current logged in user * * @since 1.0 * @access public * @param * @return string */ public function update() { FD::checkToken(); FD::requireLogin(); $my = FD::user(); // get data from form post. $uid = JRequest::getInt('uid'); $utype = JRequest::getVar('utype'); $value = JRequest::getVar('value'); $pid = JRequest::getVar('pid'); $customIds = JRequest::getVar('custom', ''); $streamid = JRequest::getVar('streamid', ''); $view = FD::view('Privacy', false); // If id is invalid, throw an error. if (!$uid) { //Internal error logging. FD::logError(__FILE__, __LINE__, 'Privacy Log: Unable to update privacy on item because id provided is invalid.'); $view->setError(JText::_('COM_EASYSOCIAL_ERROR_UNABLE_TO_LOCATE_ID')); return $view->call(__FUNCTION__); } $model = FD::model('Privacy'); $state = $model->update($my->id, $pid, $uid, $utype, $value, $customIds); // If there's an error, log this down. if (!$state) { //Internal error logging. FD::logError(__FILE__, __LINE__, 'Privacy Log: Unable to update privacy on item because model returned the error, ' . $model->getError()); $view->setError($model->getError()); return $view->call(__FUNCTION__); } // lets check if there is stream id presented or not. if yes, means we need to update // privacy access in stream too. if ($streamid) { $access = FD::privacy()->toValue($value); $stream = FD::stream(); $stream->updateAccess($streamid, $access, $customIds); } return $view->call(__FUNCTION__); }
/** * Returns an ajax chain. * * @since 1.0 * @access public * @param string The verb that we have performed. */ public function share($uid = null, $element = null, $group = SOCIAL_APPS_GROUP_USER, $streamId = 0) { // Load ajax lib $ajax = FD::ajax(); // Determine if there's any errors on the form. $error = $this->getError(); if ($error) { return $ajax->reject($error); } // Set the message $share = FD::get('Repost', $uid, $element, $group); $cnt = $share->getCount(); $cntPluralize = FD::language()->pluralize($cnt, true)->getString(); $text = JText::sprintf('COM_EASYSOCIAL_REPOST' . $cntPluralize, $cnt); //$text = $share->getHTML(); $isHidden = $cnt > 0 ? false : true; $streamHTML = ''; if ($streamId) { $stream = FD::stream(); $stream->getItem($streamId); $streamHTML = $stream->html(); } return $ajax->resolve($text, $isHidden, $cnt, $streamHTML); }
/** * Allows a user to follow another user. * * @since 1.0 * @access public */ public function follow() { // Check for request forgeries. FD::checkToken(); // Ensure that the user needs to be logged in. FD::requireLogin(); // Get the current view. $view = $this->getCurrentView(); // Get the object identifier. $id = JRequest::getInt('id'); // Get the user that is being followed $user = FD::user($id); $type = JRequest::getVar('type'); $group = JRequest::getVar('group', SOCIAL_APPS_GROUP_USER); // Get the current logged in user. $my = FD::user(); // Load subscription table. $subscription = FD::table('Subscription'); // Get subscription library $subscriptionLib = FD::get('Subscriptions'); // User should never be allowed to follow themselves. if ($my->id == $id) { $view->setMessage(JText::_('COM_EASYSOCIAL_FOLLOWERS_NOT_ALLOWED_TO_FOLLOW_SELF'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__, $subscription); } // Determine if the current user is already a follower $isFollowing = $subscriptionLib->isFollowing($id, $type, $group, $my->id); // If it's already following, throw proper message if ($isFollowing) { $view->setMessage(JText::_('COM_EASYSOCIAL_SUBSCRIPTIONS_ERROR_ALREADY_FOLLOWING_USER'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__, $subscription); } // If the user isn't alreayd following, create a new subscription record. $subscription->uid = $id; $subscription->type = $type . '.' . $group; $subscription->user_id = $my->id; $state = $subscription->store(); if (!$state) { $view->setMessage($subscription->getError(), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__, $subscription); } // @badge: followers.follow $badge = FD::badges(); $badge->log('com_easysocial', 'followers.follow', $my->id, JText::_('COM_EASYSOCIAL_FOLLOWERS_BADGE_FOLLOWING_USER')); // @badge: followers.followed $badge->log('com_easysocial', 'followers.followed', $user->id, JText::_('COM_EASYSOCIAL_FOLLOWERS_BADGE_FOLLOWED')); // @points: profile.follow // Assign points when user follows another person $points = FD::points(); $points->assign('profile.follow', 'com_easysocial', $my->id); // @points: profile.followed // Assign points when user is being followed by another person $points->assign('profile.followed', 'com_easysocial', $user->id); // check if admin want to add stream on following a user or not. $config = FD::config(); if ($config->get('users.stream.following')) { // Share this on the stream. $stream = FD::stream(); $streamTemplate = $stream->getTemplate(); // Set the actor. $streamTemplate->setActor($my->id, SOCIAL_TYPE_USER); // Set the context. $streamTemplate->setContext($subscription->id, SOCIAL_TYPE_FOLLOWERS); // Set the verb. $streamTemplate->setVerb('follow'); $streamTemplate->setAccess('followers.view'); // Create the stream data. $stream->add($streamTemplate); } // Set the email options $emailOptions = array('title' => 'COM_EASYSOCIAL_EMAILS_NEW_FOLLOWER_SUBJECT', 'template' => 'site/followers/new.followers', 'actor' => $my->getName(), 'actorAvatar' => $my->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $my->getPermalink(true, true), 'target' => $user->getName(), 'targetLink' => $user->getPermalink(true, true), 'totalFriends' => $my->getTotalFriends(), 'totalFollowing' => $my->getTotalFollowing(), 'totalFollowers' => $my->getTotalFollowers()); $state = FD::notify('profile.followed', array($user->id), $emailOptions, array('url' => $my->getPermalink(false, false, false), 'actor_id' => $my->id, 'uid' => $id)); return $view->call(__FUNCTION__, $subscription); }
/** * Creates a new note. * * @since 1.0 * @access public */ public function store() { // Check for request forgeriess FD::checkToken(); // Ensure that the user is logged in. FD::requireLogin(); // Get ajax lib $ajax = FD::ajax(); // Get the current user. $my = FD::user(); // Get the app id. $appId = JRequest::getInt('appId'); // Get the title from request $title = JRequest::getVar('title'); // Get the note content from request $content = JRequest::getVar('content'); $stream = JRequest::getBool('stream'); // Check if this is an edited entry $id = JRequest::getInt('id'); // Create the note $note = $this->getTable('Note'); $state = $note->load($id); if ($id && $state) { if ($note->user_id != $my->id) { return $ajax->reject(); } } $note->title = $title; $note->content = $content; $note->user_id = $my->id; $state = $note->store(); $note->link = FRoute::_('index.php?option=com_easysocial&view=apps&layout=canvas&id=' . $appId . '&cid=' . $note->id . '&userId=' . $my->id); if (!$state) { return $ajax->reject($note->getError()); } // Format the note comments // Get the comments count $comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::apps(array('layout' => 'canvas', 'userid' => $my->getAlias(), 'cid' => $note->id)))); $note->comments = $comments->getCount(); // Get the likes count $likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER); $note->likes = $likes->getCount(); // Create a stream record if ($stream) { $verb = $id ? 'update' : 'create'; $note->createStream($verb); } // Format the note. $comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::apps(array('layout' => 'canvas', 'userid' => $my->getAlias(), 'cid' => $note->id)))); $likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER); $stream = FD::stream(); $options = array('comments' => $comments, 'likes' => $likes); $note->actions = $stream->getActions($options); $app = $this->getApp(); $theme = FD::themes(); $theme->set('app', $app); $theme->set('user', $my); $theme->set('appId', $appId); $theme->set('note', $note); $content = $theme->output('apps/user/notes/dashboard/item'); return $ajax->resolve($content); }
/** * 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; }
/** * Publishes into the stream * * @since 1.0 * @access public * @param string The verb to be used on the stream * @return */ public function createStream($verb = 'create') { // Add activity logging when a new schedule is created // Activity logging. $stream = FD::stream(); $streamTemplate = $stream->getTemplate(); // Set the actor. $streamTemplate->setActor($this->user_id, SOCIAL_TYPE_USER); // Set the context. $streamTemplate->setContext($this->id, 'calendar'); // Set the verb. $streamTemplate->setVerb($verb); $streamTemplate->setPublicStream('core.view'); // Create the stream data. $stream->add($streamTemplate); }
/** * Override parent's behavior to delete this discussion * * @since 1.2 * @access public * @param int * @return */ public function delete($pk = null) { $state = parent::delete($pk); if ($state) { // Delete all the replies $model = FD::model('Discussions'); $model->deleteReplies($this->id); // Delete all stream items related to this discussion. FD::stream()->delete($this->id, 'discussions'); // Delete any files associated in #__social_discussions_files $model->deleteFiles($this->id); } return $state; }
/** * Retrieves the stream contents. * * @since 1.0 * @access public */ public function getStream() { // Check for request forgeries. FD::checkToken(); // In order to access the dashboard apps, user must be logged in. FD::requireLogin(); // set jrequest view JRequest::set(array('view' => 'dashboard')); $hashtags = array(); // Get the type of the stream to load. $type = $this->input->get('type', '', 'word'); // Get the stream $stream = FD::stream(); if (!$type) { $this->view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_INVALID_FEED_TYPE'), SOCIAL_MSG_ERROR); return $this->view->call(__FUNCTION__, $stream, $type); } // Get feeds from user's friend list. if ($type == 'list') { // The id of the friend list. $id = $this->input->get('id', 0, 'int'); $list = FD::table('List'); $list->load($id); if (!$id || !$list->id) { $this->view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_INVALID_LIST_ID_PROVIDED'), SOCIAL_MSG_ERROR); return $this->view->call(__FUNCTION__, $stream, $type); } // Get list of users from this list. $friends = $list->getMembers(); if ($friends) { $stream->get(array('listId' => $id)); } else { $stream->filter = 'list'; } } if ($type == 'following') { $stream->get(array('context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'type' => 'follow')); } // Filter by bookmarks if ($type == 'bookmarks') { $stream->get(array('guest' => true, 'type' => 'bookmarks')); } // Filter by sticky if ($type == 'sticky') { $stream->get(array('userId' => $this->my->id, 'type' => 'sticky')); } // Filter stream items by event if ($type == 'event') { $id = $this->input->get('id', 0, 'int'); $event = FD::event($id); // Check if the user is a member of the group if (!$event->getGuest()->isGuest() && !$this->my->isSiteAdmin()) { $this->view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_EVENTS_NO_PERMISSIONS'), SOCIAL_MSG_ERROR); return $this->view->call(__FUNCTION__, $stream, $type); } //lets get the sticky posts 1st $stickies = $stream->getStickies(array('clusterId' => $id, 'clusterType' => SOCIAL_TYPE_EVENT, 'limit' => 0)); if ($stickies) { $stream->stickies = $stickies; } $stream->get(array('clusterId' => $id, 'clusterType' => SOCIAL_TYPE_EVENT, 'nosticky' => true)); } if ($type == 'group') { $id = $this->input->get('id', 0, 'int'); $group = FD::group($id); // Check if the user is a member of the group if (!$group->isMember() && !$this->my->isSiteAdmin()) { $this->view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_GROUPS_NO_PERMISSIONS'), SOCIAL_MSG_ERROR); return $this->view->call(__FUNCTION__, $stream, $type); } //lets get the sticky posts 1st $stickies = $stream->getStickies(array('clusterId' => $id, 'clusterType' => SOCIAL_TYPE_GROUP, 'limit' => 0)); if ($stickies) { $stream->stickies = $stickies; } $stream->get(array('clusterId' => $id, 'clusterType' => SOCIAL_TYPE_GROUP, 'nosticky' => true)); } // Get feeds from everyone if ($type == 'everyone') { // $stream->getPublicStream( SOCIAL_STREAM_GUEST_LIMIT, 0 ); $stream->get(array('guest' => true, 'ignoreUser' => true)); } if ($type == 'appFilter') { // we need to use string and not 'word' due to some app name has number. e.g k2 $appType = $this->input->get('id', '', 'string'); $stream->get(array('context' => $appType)); $stream->filter = 'custom'; } // custom filter. if ($type == 'custom') { // Get the id $id = $this->input->get('id', 0, 'int'); $sfilter = FD::table('StreamFilter'); $sfilter->load($id); if ($sfilter->id) { $hashtags = $sfilter->getHashTag(); $tags = explode(',', $hashtags); if ($tags) { $stream->get(array('context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'tag' => $tags)); } } $stream->filter = 'custom'; } // Get feeds from the current user and friends only. if ($type == 'me') { $stream->get(); } // $nextStartDate = $stream->getNextStartDate(); // echo $stream->html();exit; return $this->view->call(__FUNCTION__, $stream, $type, $hashtags); }
public function onAfterDeleteTopic($topic) { FD::stream()->delete($topic->id, 'thread.new'); }
private function processGroups() { $config = FD::config(); $db = FD::db(); $sql = $db->sql(); $query = 'select a.*, c.uid as `escatid`'; $query .= ' from `#__community_groups` as a'; $query .= ' inner join `#__social_migrators` as c on a.`categoryid` = c.`oid` and c.`element` = ' . $db->Quote('groupcategory') . ' and c.`component` = ' . $db->Quote('com_community'); $query .= ' where not exists ( '; $query .= ' select b.`id` from `#__social_migrators` as b'; $query .= ' where a.`id` = b.`oid` and b.`element` = ' . $db->Quote('groups') . ' and b.`component` = ' . $db->Quote($this->name); $query .= ' )'; $query .= ' ORDER BY a.`id` ASC'; $query .= ' LIMIT ' . $this->limit; $sql->raw($query); $db->setQuery($sql); $jsGroups = $db->loadObjectList(); if (count($jsGroups) <= 0) { return null; } foreach ($jsGroups as $jsGroup) { $esGroup = FD::table('Cluster'); $esGroup->category_id = $jsGroup->escatid; $esGroup->cluster_type = SOCIAL_TYPE_GROUP; $esGroup->creator_type = SOCIAL_TYPE_USER; $esGroup->creator_uid = $jsGroup->ownerid; $esGroup->title = $jsGroup->name; $esGroup->description = $jsGroup->description; $esGroup->alias = JFilterOutput::stringURLSafe($jsGroup->name); $esGroup->state = $jsGroup->published; $esGroup->created = $jsGroup->created; $esGroup->params = null; // TODO: check what params we need to store. $esGroup->hits = 0; $esGroup->type = $jsGroup->approvals == 1 ? SOCIAL_GROUPS_PRIVATE_TYPE : SOCIAL_GROUPS_PUBLIC_TYPE; $esGroup->key = ''; // TODO: check what is this key for $state = $esGroup->store(); if ($state) { // Add group creation stream. if ($config->get('groups.stream.create')) { $stream = FD::stream(); $streamTemplate = $stream->getTemplate(); // Set the actor $streamTemplate->setActor($jsGroup->ownerid, SOCIAL_TYPE_USER); // Set the context $streamTemplate->setContext($esGroup->id, SOCIAL_TYPE_GROUPS); $streamTemplate->setVerb('create'); $streamTemplate->setSiteWide(); // $streamTemplate->setPublicStream( 'core.view' ); // Set the params to cache the group data $registry = FD::registry(); $registry->set('group', $esGroup); // Set the params to cache the group data $streamTemplate->setParams($registry); $streamTemplate->setDate($jsGroup->created); $streamTemplate->setAccess('core.view'); // Add stream template. $stream->add($streamTemplate); } //end add stream $this->log('groups', $jsGroup->id, $esGroup->id); $this->info->setInfo('Group \'' . $jsGroup->name . '\' has migrated succefully into EasySocial.'); } } //end foreach return $this->info; }
/** * retrieve more stream items. ( used in pagination ) * * @since 1.0 * @access public * return StreamItem object * */ public function loadmore() { // Check for request forgeries. FD::checkToken(); $isCluster = JRequest::getWord('iscluster', false); // Get the type of the stream to load. $type = JRequest::getWord('type', 'me'); // In order to access the dashboard apps, user must be logged in. if (!$isCluster) { FD::requireLogin(); } // Get the current view. $view = FD::view('Stream', false); $startlimit = JRequest::getVar('startlimit', 0); // Get the context $context = JRequest::getVar('context'); // Get the stream $stream = FD::stream(); if (!$type) { $view->setMessage(JText::_('Invalid feed type provided.'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__, $stream); } // Get feeds from user's friend list. if ($type == 'list') { // The id of the friend list. $id = JRequest::getInt('id', 0); // @TODO: We need to filter stream items from friends in specific friend list. if (!empty($id)) { $listsModel = FD::model('Lists'); $memberIds = $listsModel->getMembers($id, true); if ($memberIds) { $stream->get(array('listId' => $id, 'context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'type' => SOCIAL_TYPE_USER, 'startlimit' => $startlimit)); } } } // custom filter. if ($type == 'custom') { $id = JRequest::getInt('id', 0); $sfilter = FD::table('StreamFilter'); $sfilter->load($id); if ($sfilter->id) { $hashtags = $sfilter->getHashTag(); $tags = explode(',', $hashtags); if ($tags) { $stream->get(array('context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'tag' => $tags, 'startlimit' => $startlimit)); } } } if ($type == 'hashtag') { // at this point, the tag passed in is the one without the id. $tags = JRequest::getVar('tag', ''); if ($tags) { $stream->get(array('context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'tag' => $tags, 'startlimit' => $startlimit)); } } if ($type == 'following') { $stream->get(array('context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'type' => 'follow', 'startlimit' => $startlimit)); } if ($type == 'bookmarks') { $stream->get(array('guest' => true, 'type' => 'bookmarks', 'startlimit' => $startlimit)); } if ($type == 'appFilter') { $stream->get(array('context' => $context, 'startlimit' => $startlimit)); } // Get feeds from everyone if ($type == 'everyone') { // $stream->getPublicStream( SOCIAL_STREAM_GUEST_LIMIT, 0 ); $stream->get(array('guest' => true, 'ignoreUser' => true, 'startlimit' => $startlimit)); } // Get feeds from the user profile. if ($type == 'profile') { $uid = JRequest::getVar('id', ''); $stream->get(array('profileId' => $uid, 'startlimit' => $startlimit)); } // Get feeds from the current user and friends only. if ($type == 'me') { $uid = JRequest::getVar('id', ''); $stream->get(array('userId' => $uid, 'context' => SOCIAL_STREAM_CONTEXT_TYPE_ALL, 'type' => SOCIAL_TYPE_USER, 'startlimit' => $startlimit)); } //event category if ($type == 'eventcategory') { $uid = JRequest::getVar('id', ''); $stream->get(array('clusterCategory' => $uid, 'clusterType' => SOCIAL_TYPE_EVENT, 'startlimit' => $startlimit)); } //event category if ($type == 'groupcategory') { $uid = JRequest::getVar('id', ''); $stream->get(array('clusterCategory' => $uid, 'clusterType' => SOCIAL_TYPE_GROUP, 'startlimit' => $startlimit)); } //cluster types $clusters = array(SOCIAL_TYPE_GROUP, SOCIAL_TYPE_EVENT); if (in_array($type, $clusters)) { $clusterId = JRequest::getVar('id', ''); $tags = JRequest::getVar('tag', ''); $filterId = JRequest::getInt('filterId'); // this is a cluster type loadmore $options = array('clusterId' => $clusterId, 'clusterType' => $type, 'tag' => $tags, 'startlimit' => $startlimit); if ($context) { $options['context'] = $context; } if ($filterId) { $sfilter = FD::table('StreamFilter'); $sfilter->load($filterId); $hashtags = $sfilter->getHashTag(); $tags = explode(',', $hashtags); if ($tags) { $options['tag'] = $tags; } } $stream->get($options); } return $view->call(__FUNCTION__, $stream); }
public function addTostream($my, $group, $registry) { $stream = FD::stream(); $streamTemplate = $stream->getTemplate(); // Set the actor $streamTemplate->setActor($my->id, SOCIAL_TYPE_USER); // Set the context $streamTemplate->setContext($group->id, SOCIAL_TYPE_GROUPS); $streamTemplate->setVerb('create'); $streamTemplate->setSiteWide(); $streamTemplate->setAccess('core.view'); $streamTemplate->setCluster($group->id, SOCIAL_TYPE_GROUP, $group->type); // Set the params to cache the group data $registry = FD::registry(); $registry->set('group', $group); // Set the params to cache the group data $streamTemplate->setParams($registry); // Add stream template. $stream->add($streamTemplate); return true; }
/** * Creates a new stream item * * @since 1.0 * @access public * @param string * @return */ public function create($args = array()) { // The content of the story $content = isset($args['content']) ? $args['content'] : ''; // Context ids, and type that are related to the story $contextIds = isset($args['contextIds']) ? $args['contextIds'] : ''; $contextType = isset($args['contextType']) ? $args['contextType'] : ''; // The person that created this new story $actorId = isset($args['actorId']) ? $args['actorId'] : ''; // If the object is posting on another object, the target object id should be passed in here. $targetId = isset($args['targetId']) ? $args['targetId'] : null; // If the story is associated with a location, it should be processed. $location = isset($args['location']) ? $args['location'] : null; // If the story is being tagged with other users. $with = isset($args['with']) ? $args['with'] : null; // If the content of the story contains mentions using @ and # tags. $mentions = isset($args['mentions']) ? $args['mentions'] : array(); // If the story belongs in a cluster $cluster = isset($args['cluster']) ? $args['cluster'] : ''; $clusterType = isset($args['clusterType']) ? $args['clusterType'] : SOCIAL_TYPE_GROUP; // If the story contains a mood $mood = isset($args['mood']) ? $args['mood'] : null; // Store this into the stream now. $stream = FD::stream(); // Ensure that context ids are always array $contextIds = FD::makeArray($contextIds); // Determines which trigger group to call $group = $cluster ? $clusterType : SOCIAL_TYPE_USER; // Load apps FD::apps()->load($group); // Load up the dispatcher so that we can trigger this. $dispatcher = FD::dispatcher(); // This is to satisfy the setContext method. $contextId = isset($contextIds[0]) ? $contextIds[0] : 0; // Get the stream template $template = $stream->getTemplate(); $template->setActor($actorId, $this->type); $template->setContext($contextId, $contextType); $template->setContent($content); $verb = $contextType == 'photos' ? 'share' : 'create'; $template->setVerb($verb); $privacyRule = isset($args['privacyRule']) ? $args['privacyRule'] : null; $privacyValue = isset($args['privacyValue']) ? $args['privacyValue'] : null; $privacyCustom = isset($args['privacyCustom']) ? $args['privacyCustom'] : null; if (!$privacyRule) { $privacyRule = $contextType == 'photos' ? 'photos.view' : 'story.view'; } if ($privacyValue && is_string($privacyValue)) { $privacyValue = FD::privacy()->toValue($privacyValue); } if ($privacyCustom) { $privacyCustom = explode(',', $privacyCustom); } // Set this stream to be public $template->setAccess($privacyRule, $privacyValue, $privacyCustom); // Set mentions $template->setMentions($mentions); // Set the users tagged in the stream. $template->setWith($with); // Set the location of the stream $template->setLocation($location); // Set the mood if (!is_null($mood)) { $template->setMood($mood); } // If there's a target, we want it to appear on their stream too if ($targetId) { $template->setTarget($targetId); } if ($contextType == 'photos') { if (count($contextIds) > 0) { foreach ($contextIds as $photoId) { $template->setChild($photoId); } } } if ($cluster) { $clusterObj = FD::cluster($clusterType, $cluster); if ($clusterObj) { // Set the params to cache the group data $registry = FD::registry(); $registry->set($clusterType, $clusterObj); // Set the params to cache the group data $template->setParams($registry); $template->setCluster($cluster, $clusterType, $clusterObj->type); } else { $template->setCluster($cluster, $clusterType, 1); } } // Build the arguments for the trigger $args = array(&$template, &$stream, &$content); // @trigger onBeforeStorySave $dispatcher->trigger($group, 'onBeforeStorySave', $args); // Create the new stream item. $streamItem = $stream->add($template); // Store link items $this->storeLinks($stream, $streamItem, $template); // Set the notification type $notificationType = SOCIAL_TYPE_STORY; // Construct our new arguments $args = array(&$stream, &$streamItem, &$template); // @trigger onAfterStorySave $dispatcher->trigger($group, 'onAfterStorySave', $args); // Send a notification to the recipient if needed. if ($targetId && $actorId != $targetId) { $this->notify($targetId, $streamItem, $template->content, $contextIds, $contextType, $notificationType); } // Send a notification alert if there are mentions if ($mentions && !empty($mentions)) { $this->notifyMentions($streamItem, $mentions, $contextType, $contextIds, $template->content, $targetId); } return $streamItem; }
/** * Proxy function to remove the relationship and carry out any necessary action on removing a relationship. * * @author Jason Rey <*****@*****.**> * @since 1.0 * @access public * @return boolean True if success. */ public function remove() { $state = $this->delete(); if (!$state) { return false; } // Send notification here // Delete stream // It is possible that there are 2 records that needs to be searched // TODO: need verb FD::stream()->delete($this->id, 'relationship'); $opposite = $this->getOppositeTable(); if ($opposite) { FD::stream()->delete($opposite->id, 'relationship'); } return true; }
/** * Creates a new discussion * * @since 1.2 * @access public * @param string * @return */ public function save() { // Check for request forgeriess FD::checkToken(); // Ensure that the user is logged in. FD::requireLogin(); // Load up ajax lib $ajax = FD::ajax(); // Load the discussion $id = JRequest::getInt('id'); $discussion = FD::table('Discussion'); $discussion->load($id); // Get the current logged in user. $my = FD::user(); // Get the group $groupId = JRequest::getInt('cluster_id', 0); $group = FD::group($groupId); // Only allow owner and admin to modify the if ($discussion->id) { if ($discussion->created_by != $my->id && !$group->isAdmin() && !$my->isSiteAdmin()) { return $this->redirect($group->getPermalink(false)); } } // Check if the user is allowed to create a discussion if (!$group->isMember()) { FD::info()->set(JText::_('APP_GROUP_DISCUSSIONS_NOT_ALLOWED_CREATE'), SOCIAL_MSG_ERROR); // Perform a redirection return JFactory::getApplication()->redirect(FRoute::dashboard()); } // Assign discussion properties $discussion->uid = $group->id; $discussion->type = SOCIAL_TYPE_GROUP; $discussion->title = JRequest::getVar('title', ''); $discussion->content = JRequest::getVar('content', '', 'POST', 'none', JREQUEST_ALLOWRAW); // If discussion is edited, we don't want to modify the following items if (!$discussion->id) { $discussion->created_by = $my->id; $discussion->parent_id = 0; $discussion->hits = 0; $discussion->state = SOCIAL_STATE_PUBLISHED; $discussion->votes = 0; $discussion->lock = false; } $app = $this->getApp(); // Ensure that the title is valid if (!$discussion->title) { Foundry::info()->set(JText::_('APP_GROUP_DISCUSSIONS_INVALID_TITLE'), SOCIAL_MSG_ERROR); // Get the redirection url $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'create', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias()), false); return $this->redirect($url); } // Lock the discussion $state = $discussion->store(); if (!$state) { FD::info()->set(JText::_('APP_GROUP_DISCUSSIONS_DISCUSSION_CREATED_FAILED')); // Get the redirection url $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'form', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias()), false); return $this->redirect($url); } // Process any files that needs to be created. $discussion->mapFiles(); // Get the app $app = $this->getApp(); // If it is a new discussion, we want to run some other stuffs here. if (!$id) { // @points: groups.discussion.create // Add points to the user that updated the group $points = FD::points(); $points->assign('groups.discussion.create', 'com_easysocial', $my->id); // Create a new stream item for this discussion $stream = FD::stream(); // Get the stream template $tpl = $stream->getTemplate(); // Someone just joined the group $tpl->setActor($my->id, SOCIAL_TYPE_USER); // Set the context $tpl->setContext($discussion->id, 'discussions'); // Set the cluster $tpl->setCluster($group->id, SOCIAL_TYPE_GROUP, $group->type); // Set the verb $tpl->setVerb('create'); // Set the params to cache the group data $registry = FD::registry(); $registry->set('group', $group); $registry->set('discussion', $discussion); $tpl->setParams($registry); $tpl->setAccess('core.view'); // Add the stream $stream->add($tpl); // Set info message FD::info()->set(false, JText::_('APP_GROUP_DISCUSSIONS_DISCUSSION_CREATED_SUCCESS'), SOCIAL_MSG_SUCCESS); // Send notification to group members only if it is new discussion $options = array(); $options['permalink'] = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias(), 'discussionId' => $discussion->id, 'external' => true), false); $options['discussionId'] = $discussion->id; $options['discussionTitle'] = $discussion->title; $options['discussionContent'] = $discussion->getContent(); $options['userId'] = $discussion->created_by; $group->notifyMembers('discussion.create', $options); } // Get the redirection url $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias(), 'discussionId' => $discussion->id), false); // Perform a redirection $this->redirect($url); }
/** * Deletes all replies from a discussion * * @since 1.2 * @access public * @param int The unique id it is associated with. * @return Array An array of SocialTableDiscussion */ public function deleteReplies($id) { $db = FD::db(); $sql = $db->sql(); // Get a list of replies so we can delete their respective stream items first $replies = $this->getReplies($id); if (!$replies) { return; } foreach ($replies as $reply) { // Delete all stream items for the replies FD::stream()->delete($reply->id, 'discussions'); // Delete all files related to this reply. $this->deleteFiles($reply->id); } // Now we delete all the items $sql->delete('#__social_discussions'); $sql->where('parent_id', $id); $db->setQuery($sql); $state = $db->Query(); return $state; }
private function processConnection() { $db = FD::db(); $sql = $db->sql(); $query = 'select a.*'; $query .= ' from `#__comprofiler_members` as a'; $query .= ' where not exists ( '; $query .= ' select b.`id` from `#__social_migrators` as b'; $query .= ' where a.`referenceid` = b.`oid` and b.`element` = ' . $db->Quote('connection') . ' and b.`component` = ' . $db->Quote($this->name); $query .= ' )'; $query .= ' and a.`accepted` = ' . $db->Quote('1'); $query .= ' LIMIT ' . $this->limit; $sql->raw($query); $db->setQuery($sql); $cbConns = $db->loadObjectList(); if (count($cbConns) <= 0) { return null; } foreach ($cbConns as $cbConn) { //let check if this two user already a fren in ES or not. $actor = $cbConn->referenceid; $target = $cbConn->memberid; $query = 'select a.`id` from `#__social_friends` as a'; $query .= ' where (a.`actor_id` = ' . $db->Quote($actor) . ' and a.`target_id` = ' . $db->Quote($target); $query .= ' OR a.`target_id` = ' . $db->Quote($actor) . ' and a.`actor_id` = ' . $db->Quote($target) . ')'; $sql->clear(); $sql->raw($query); $db->setQuery($sql); $esFriends = $db->loadObjectList(); if (count($esFriends) > 0) { // this mean they are already have connection in ES. lets log into mgirator table. foreach ($esFriends as $friend) { $this->log('connection', $cbConn->referenceid, $friend->id); } $this->info->setInfo('User \'' . $actor . '\' already connected with user \'' . $target . '\' so no migration need for these two users.'); continue; // return $this->info; } // lets add into social friend table $esFriendTbl = FD::table('Friend'); $esFriendTbl->actor_id = $actor; $esFriendTbl->target_id = $target; $esFriendTbl->state = $cbConn->pending == '1' ? SOCIAL_FRIENDS_STATE_PENDING : SOCIAL_FRIENDS_STATE_FRIENDS; $esFriendTbl->created = $cbConn->membersince; $esFriendTbl->store(); $newFriendId = $esFriendTbl->id; // done. lets add into log table. $this->log('connection', $cbConn->referenceid, $newFriendId); if ($esFriendTbl->state == SOCIAL_FRIENDS_STATE_FRIENDS) { $stream = FD::stream(); $streamTemplate = $stream->getTemplate(); // Set the actor. $streamTemplate->setActor($actor, SOCIAL_TYPE_USER); // Set the context. $streamTemplate->setContext($esFriendTbl->id, SOCIAL_TYPE_FRIEND); // Set the actor. $streamTemplate->setTarget($target); // Set the verb. $streamTemplate->setVerb('add'); // set to aggreate friend $streamTemplate->setAggregate(true); // set the stream creation date $streamTemplate->setDate($cbConn->membersince); $streamTemplate->setAccess('core.view'); // Create the stream data. $stream->add($streamTemplate); } $this->info->setInfo('User \'' . $actor . '\' is now connected with user \'' . $target . '\' in your EasySocial.'); } // end foreach return $this->info; }
/** * Deletes a profile off the system. Any related profiles stuffs should also be deleted here. * * @since 1.0 * @access public * @param mixed An optional primary key value to delete. If not set the instance property value is used. */ public function delete($pk = null) { // Try to delete this profile item. $state = parent::delete($pk); // Delete custom fields created for this profile type if ($state) { // Delete all field relations to this profile. $model = FD::model('Fields'); $model->deleteFields($this->id, SOCIAL_TYPE_PROFILES); // Delete all stream related items. $stream = FD::stream(); $stream->delete($this->id, SOCIAL_TYPE_PROFILES); // Delete profile avatar. $avatar = FD::table('Avatar'); if ($avatar->load(array('uid' => $this->id, 'type' => SOCIAL_TYPE_PROFILES))) { $avatar->delete(); } // Delete default avatars for this profile. $avatarModel = FD::model("Avatars"); $avatarModel->deleteDefaultAvatars($this->id, SOCIAL_TYPE_PROFILES); } return $state; }
/** * Submits a reply * * @since 1.2 * @access public * @return */ public function submit() { // Check for request forgeriess FD::checkToken(); // Ensure that the user is logged in. FD::requireLogin(); // Load up ajax lib $ajax = FD::ajax(); // Get the group $groupId = JRequest::getInt('groupId'); $group = FD::group($groupId); // Get the discussion $id = JRequest::getInt('id'); $discussion = FD::table('Discussion'); $discussion->load($id); // Get the current user $my = FD::user(); // Check whether the viewer can really reply to the discussion if (!$group->isMember()) { return $this->reject(); } // Test for locked discussion. if ($discussion->lock && !$group->isAdmin()) { $obj = new stdClass(); $obj->message = JText::_('APP_GROUP_DISCUSSIONS_DISCUSSION_IS_LOCKED'); $obj->type = SOCIAL_MSG_ERROR; return $ajax->reject($obj); } // Get the content // $content = JRequest::getVar( 'content' , '' ); $content = JRequest::getVar('content', '', 'post', 'none', JREQUEST_ALLOWRAW); if (empty($content)) { $obj = new stdClass(); $obj->message = JText::_('APP_GROUP_DISCUSSIONS_EMPTY_REPLY_ERROR'); $obj->type = SOCIAL_MSG_ERROR; return $ajax->reject($obj); } $reply = FD::table('Discussion'); $reply->uid = $discussion->uid; $reply->type = $discussion->type; $reply->content = $content; $reply->created_by = $my->id; $reply->parent_id = $discussion->id; $reply->state = SOCIAL_STATE_PUBLISHED; // Save the reply. $reply->store(); if (!$id) { // @points: groups.discussion.reply // Earn points when posting a reply $points = FD::points(); $points->assign('groups.discussion.reply', 'com_easysocial', $reply->created_by); } // Create a new stream item for this discussion $stream = FD::stream(); // Get the stream template $tpl = $stream->getTemplate(); // Someone just joined the group $tpl->setActor($my->id, SOCIAL_TYPE_USER); // Set the context $tpl->setContext($discussion->id, 'discussions'); // Set the cluster $tpl->setCluster($group->id, SOCIAL_TYPE_GROUP, $group->type); // Set the verb $tpl->setVerb('reply'); // Set the params to cache the group data $registry = FD::registry(); $registry->set('group', $group); $registry->set('reply', $reply); $registry->set('discussion', $discussion); $tpl->setParams($registry); $tpl->setAccess('core.view'); // Add the stream $stream->add($tpl); // Update the parent's reply counter. $discussion->sync($reply); // Before we populate the output, we need to format it according to the theme's specs. $reply->author = $my; // Load the contents $theme = FD::themes(); // Since this reply is new, we don't have an answer for this item. $answer = false; $theme->set('question', $discussion); $theme->set('group', $group); $theme->set('answer', $answer); $theme->set('reply', $reply); $contents = $theme->output('apps/group/discussions/canvas/item.reply'); // Send notification to group members $options = array(); $options['permalink'] = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $this->getApp()->getAlias(), 'discussionId' => $discussion->id, 'external' => true), false); $options['title'] = $discussion->title; $options['content'] = $reply->getContent(); $options['discussionId'] = $reply->id; $options['userId'] = $reply->created_by; $options['targets'] = $discussion->getParticipants(array($reply->created_by)); $group->notifyMembers('discussion.reply', $options); return $ajax->resolve($contents); }
/** * Some desc * * @since 1.0 * @access public * @param string * @return */ public function addStream($verb) { if ($verb == 'update') { // Add stream item when a new photo is uploaded. $stream = FD::stream(); $streamTemplate = $stream->getTemplate(); // Set the actor. $streamTemplate->setActor($this->uid, SOCIAL_TYPE_USER); // Set the context. $streamTemplate->setContext($this->id, SOCIAL_TYPE_AVATAR); // Set the verb. $streamTemplate->setVerb('update'); // $streamTemplate->setType('full'); // Create the stream data. $stream->add($streamTemplate); } }