/** * Displays the application output in the canvas. * * @since 1.0 * @access public * @param int The user id that is currently being viewed. */ public function display($uid = null, $docType = null) { $event = FD::event($uid); // Get the article item $news = FD::table('EventNews'); $news->load($this->input->get('newsId', 0, 'int')); // Check if the user is really allowed to view this item if (!$event->canViewItem()) { return $this->redirect($event->getPermalink(false)); } // Get the author of the article $author = FD::user($news->created_by); // Get the url for the article $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $this->app->getAlias(), 'articleId' => $news->id), false); // Apply comments for the article $comments = FD::comments($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT, array('url' => $url)); // Apply likes for the article $likes = FD::likes()->get($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT); // Set the page title FD::page()->title($news->get('title')); // Retrieve the params $params = $this->app->getParams(); $this->set('app', $this->app); $this->set('params', $params); $this->set('event', $event); $this->set('likes', $likes); $this->set('comments', $comments); $this->set('author', $author); $this->set('news', $news); echo parent::display('canvas/item'); }
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); } }
/** * Displays the application output in the canvas. * * @since 1.0 * @access public * @param int The user id that is currently being viewed. */ public function display($uid = null, $docType = null) { FD::requireLogin(); $event = FD::event($uid); if (!$event->canViewItem()) { return $this->redirect($event->getPermalink(false)); } // Load up the app params $params = $this->app->getParams(); // Get the discussion item $id = $this->input->get('discussionId', 0, 'int'); $discussion = FD::table('Discussion'); $discussion->load($id); // Get the author of the article $author = FD::user($discussion->created_by); // Get the url for the article $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $this->app->getAlias(), 'discussionId' => $discussion->id), false); // Set the page title FD::page()->title($discussion->get('title')); // Increment the hits for this discussion item $discussion->addHit(); // Get a list of other news $model = FD::model('Discussions'); $replies = $model->getReplies($discussion->id, array('ordering' => 'created')); $participants = $model->getParticipants($discussion->id); // Get the answer $answer = false; if ($discussion->answer_id) { $answer = FD::table('Discussion'); $answer->load($discussion->answer_id); $answer->author = FD::user($answer->created_by); } // Determines if we should allow file sharing $access = $event->getAccess(); $files = $access->get('files.enabled', true); $this->set('app', $this->app); $this->set('files', $files); $this->set('params', $params); $this->set('answer', $answer); $this->set('participants', $participants); $this->set('discussion', $discussion); $this->set('event', $event); $this->set('replies', $replies); $this->set('author', $author); echo parent::display('canvas/item'); }
/** * Retrieves the new article form * * @since 1.2 * @access public * @return */ public function save() { // Check for request forgeriess FD::checkToken(); // Ensure that the user is logged in. FD::requireLogin(); // Determines if this is an edited news. $id = $this->input->get('newsId', 0, 'int'); // Load up the news obj $news = FD::table('EventNews'); $news->load($id); // Determine the message to display $message = !$news->id ? JText::_('APP_EVENT_NEWS_CREATED_SUCCESSFULLY') : JText::_('APP_EVENT_NEWS_UPDATED_SUCCESSFULLY'); // Load the event object $event = FD::event($this->input->get('cluster_id', 0, 'int')); if (!$event) { return $this->redirect($event->getPermalink(false)); } // Get the app id $app = $this->getApp(); if (!$event->isAdmin()) { $url = FRoute::events($event->getPermalink(false)); return $this->redirect($url); } $options = array(); $options['title'] = $this->input->get('title', '', 'default'); $options['content'] = $this->input->get('news_content', '', 'raw'); $options['comments'] = $this->input->get('comments', true, 'bool'); $options['state'] = SOCIAL_STATE_PUBLISHED; // Only bind this if it's a new item if (!$news->id) { $options['cluster_id'] = $event->id; $options['created_by'] = $this->my->id; $options['hits'] = 0; } // Bind the data $news->bind($options); // Check if there are any errors if (!$news->check()) { FD::info()->set($news->getError(), SOCIAL_MSG_ERROR); $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'form', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias()), false); return $this->redirect($url); } // If everything is okay, bind the data. $news->store(); // If it is a new item, we want to run some other stuffs here. if (!$id) { // @points: events.news.create // Add points to the user that updated the event $points = FD::points(); $points->assign('events.news.create', 'com_easysocial', $this->my->id); } // Redirect to the appropriate page now $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'newsId' => $news->id), false); $app = $this->getApp(); $permalink = $app->getPermalink('canvas', array('customView' => 'item', 'eventId' => $event->id, 'newsId' => $news->id)); // Notify users about the news. $options = array('userId' => $this->my->id, 'permalink' => $permalink, 'newsId' => $news->id, 'newsTitle' => $news->title, 'newsContent' => strip_tags($news->content)); $event->notifyMembers('news.create', $options); FD::info()->set($message, SOCIAL_MSG_SUCCESS); // Perform a redirection $this->redirect($url); }
/** * 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); }
/** * 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); }
echo JText::_('APP_GROUP_DISCUSSIONS_REPLIES'); ?> </li> <?php } ?> </ul> </div> <?php } ?> <div class="media-body"> <h3> <a href="<?php echo FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias(), 'discussionId' => $discussion->id), false); ?> "> <?php echo $discussion->get('title'); ?> </a> <span class="label label-success label-resolved"><?php echo JText::_('APP_GROUP_DISCUSSIONS_RESOLVED'); ?> </span> <span class="label label-warning label-locked"><i class="ies-locked locked-icon"></i> <?php echo JText::_('APP_GROUP_DISCUSSIONS_LOCKED'); ?> </span> <span class="label label-danger label-unanswered"><?php
"> <?php echo JText::_('COM_EASYSOCIAL_TOOLBAR_PROFILE_POINTS_HISTORY'); ?> </a> </li> <?php } ?> <li class="<?php echo $view == 'apps' ? 'active' : ''; ?> "> <a href="<?php echo FRoute::apps(); ?> "> <?php echo JText::_('COM_EASYSOCIAL_TOOLBAR_APPS'); ?> </a> </li> <li class="<?php echo $view == 'activities' ? 'active' : ''; ?> "> <a href="<?php echo FRoute::activities(); ?> ">
data-original-title="<?php echo JText::_('COM_EASYSOCIAL_APPS_SORT_RECENT_ADDED', true); ?> " > <i class="ies-upload-2 ies-small"></i> </a> <a class="btn btn-es trending<?php echo $sort == 'trending' ? ' active' : ''; ?> " data-apps-sort data-apps-sort-type="trending" data-apps-sort-group="user" data-apps-sort-url="<?php echo FRoute::apps(array('sort' => 'trending')); ?> " data-es-provide="tooltip" data-placement="bottom" data-original-title="<?php echo JText::_('COM_EASYSOCIAL_APPS_SORT_TRENDING_APPS', true); ?> " > <i class="ies-fire ies-small"></i> </a> </div> <?php } ?>
* EasySocial is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ defined('_JEXEC') or die('Unauthorized Access'); ?> <li class="note-item" data-apps-notes-item data-id="<?php echo $note->id; ?> "> <div class="row"> <div class="col-md-12"> <a href="<?php echo FRoute::apps(array('layout' => 'canvas', 'id' => $appId, 'cid' => $note->id, 'userid' => $user->getAlias())); ?> " class="note-title pull-left"><?php echo $note->title; ?> </a> <div class="pull-right btn-group"> <a href="javascript:void(0);" data-bs-toggle="dropdown" class="dropdown-toggle_ loginLink btn btn-dropdown"> <i class="icon-es-dropdown"></i> </a> <ul class="dropdown-menu dropdown-menu-user messageDropDown"> <li> <a href="javascript:void(0);" data-apps-notes-edit> <?php echo JText::_('APP_NOTES_EDIT_BUTTON');
foreach ($apps as $app) { ?> <li class="app-item<?php echo $appId == $app->id ? ' active' : ''; ?> " data-id="<?php echo $app->id; ?> " data-layout="<?php echo $app->getViews('dashboard')->type; ?> " data-canvas-url="<?php echo FRoute::apps(array('id' => $app->getAlias(), 'layout' => 'canvas')); ?> " data-embed-url="<?php echo FRoute::dashboard(array('appId' => $app->getAlias())); ?> " data-title="<?php echo $this->html('string.escape', $user->getName()) . ' - ' . $app->get('title'); ?> " data-dashboardSidebar-menu data-dashboardApps-item> <a href="javascript:void(0);"> <img src="<?php echo $app->getIcon();
/** * Retrieves the canvas url * * @since 1.0 * @access public * @param string * @return */ public function getCanvasUrl($options = array(), $xhtml = true) { $default = array('layout' => 'canvas', 'id' => $this->getAlias()); $options = array_merge($default, $options); $url = FRoute::apps($options, $xhtml); return $url; }
} ?> </div> </div> <div class="col-md-3 discussion-meta"> <?php if ($group->isMember()) { ?> <div class="mt-5"> <a href="<?php echo FRoute::apps(array('layout' => 'canvas', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias(), 'customView' => 'create')); ?> " class="btn btn-es-primary btn-create"><i class="ies-pencil"></i> <?php echo JText::_('APP_GROUP_DISCUSSIONS_CREATE_DISCUSSION'); ?> →</a> </div> <?php } ?> <?php if ($params->get('stats_sidebar', true)) { ?> <div class="stats">
public function createStream($discussion, $group, $reply, $log_user) { // Create a new stream item for this discussion $stream = FD::stream(); $my = FD::user($log_user); // Get the stream template $tpl = $stream->getTemplate(); // Someone just joined the group $tpl->setActor($log_user, 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['permalink'] = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $group->id, '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)); return $group->notifyMembers('discussion.reply', $options); }
<?php echo $milestone->title; ?> </h3> <?php if ($group->isAdmin()) { ?> <span class="btn-group pull-right"> <a href="javascript:void(0);" data-bs-toggle="dropdown" class="dropdown-toggle_ btn btn-dropdown"> <i class="icon-es-dropdown"></i> </a> <ul class="dropdown-menu"> <li> <a href="<?php echo FRoute::apps(array('layout' => 'canvas', 'customView' => 'form', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id), false); ?> "><?php echo JText::_('APP_GROUP_TASKS_MILESTONE_EDIT'); ?> </a> </li> <li class="mark-uncomplete"> <a href="javascript:void(0);" data-milestone-mark-uncomplete><?php echo JText::_('APP_GROUP_TASKS_MILESTONE_MARK_UNCOMPLETED'); ?> </a> </li> <li class="mark-completed"> <a href="javascript:void(0);" data-milestone-mark-complete><?php
" data-app-id="<?php echo $app->id; ?> " data-id="<?php echo $user->id; ?> " data-layout="<?php echo $app->getViews('profile')->type; ?> " data-namespace="site/controllers/profile/getAppContents" data-canvas-url="<?php echo FRoute::apps(array('id' => $app->getAlias(), 'layout' => 'canvas', 'uid' => $user->getAlias(), 'type' => SOCIAL_TYPE_USER)); ?> " data-embed-url="<?php echo FRoute::profile(array('id' => $user->getAlias(), 'appId' => $app->getAlias())); ?> " data-title="<?php echo $app->getPageTitle(); ?> " data-profile-apps-item > <a href="javascript:void(0);"> <img src="<?php
<?php /** * @package EasySocial * @copyright Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved. * @license GNU/GPL, see LICENSE.php * EasySocial is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ defined('_JEXEC') or die('Unauthorized Access'); echo JText::sprintf('APP_USER_NOTES_STREAM_CREATED_NOTE', $this->html('html.user', $actor->id), '<a href="' . FRoute::apps(array('layout' => 'canvas', 'id' => $note->getAppId(), 'cid' => $note->id, 'userid' => $actor->getAlias())) . '">' . $note->get('title') . '</a>');
echo $news->content; ?> </div> <div class="group-news-actions"> <div class="es-action-wrap"> <ul class="list-unstyled es-action-feedback"> <li> <a href="javascript:void(0);" class="fd-small"><?php echo $likes->button(); ?> </a> </li> <li> <?php echo FD::sharing(array('url' => FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'articleId' => $news->id), false), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small'))->getHTML(false); ?> </li> </ul> </div> <div data-news-counter class="es-stream-counter<?php echo empty($likes->data) ? ' hide' : ''; ?> "> <div class="es-stream-actions"><?php echo $likes->toHTML(); ?> </div> </div>
/** * Creates a new milestone for tasks * * @since 1.2 * @access public */ public function save() { // Check for request forgeries. FD::checkToken(); // Ensure that the user is logged in. FD::requireLogin(); // Get the current logged in user. $my = FD::user(); // Get the event $eventId = JRequest::getInt('cluster_id', 0); $event = FD::event($eventId); // Check if the user is allowed to create a discussion if (!$event->getGuest()->isGuest() && !$my->isSiteAdmin()) { FD::info()->set(JText::_('APP_EVENT_TASKS_NOT_ALLOWED_HERE'), SOCIAL_MSG_ERROR); // Perform a redirection return JFactory::getApplication()->redirect(FRoute::dashboard()); } // Get the milestone data $id = JRequest::getInt('id'); $milestone = FD::table('Milestone'); $milestone->load($id); $milestone->title = JRequest::getVar('title'); $milestone->uid = (int) $event->id; $milestone->type = SOCIAL_TYPE_EVENT; $milestone->state = SOCIAL_TASK_UNRESOLVED; if ($event->getGuest()->isGuest()) { $milestone->user_id = JRequest::getInt('user_id'); } $milestone->description = JRequest::getVar('description'); $milestone->due = JRequest::getVar('due'); $milestone->owner_id = (int) $my->id; $milestone->store(); // Get the app $app = $this->getApp(); // Get the application params $params = $app->getParams(); // Get the redirection url $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id), false); // If this is new milestone, perform some tasks if (!$id) { // Generate a new stream if ($params->get('stream_milestone', true)) { $milestone->createStream('createMilestone'); } if ($params->get('notify_milestone', true)) { $event->notifyMembers('milestone.create', array('userId' => $my->id, 'id' => $milestone->id, 'title' => $milestone->title, 'content' => $milestone->getContent(), 'permalink' => $url)); } // @points: events.milestone.create // Add points to the user that updated the event $points = FD::points(); $points->assign('events.milestone.create', 'com_easysocial', $my->id); } FD::info()->set(JText::_('APP_EVENT_TASKS_MILESTONE_CREATED')); // Perform a redirection $this->redirect($url); }
public function prepareCreateMilestoneStream(SocialStreamItem $item, $includePrivacy = true) { $params = FD::registry($item->params); $milestone = FD::table('Milestone'); $milestone->bind($params->get('milestone')); // Get the group data FD::load('group'); $group = new SocialGroup(); $group->bind($params->get('group')); // Get the actor $actor = $item->actor; // 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('milestone', $milestone); $this->set('actor', $actor); $this->set('group', $group); $item->title = parent::display('streams/tasks/create.milestone.title'); $item->content = parent::display('streams/tasks/create.milestone.content'); }
/** * Allows caller to create a new task given the milestone id and the event id. * * @since 1.2 * @access public */ public function save() { // Check for request forgeries FD::checkToken(); // Only allow logged in users FD::requireLogin(); // Load up ajax library $ajax = FD::ajax(); // Get the current event and logged in user $eventId = JRequest::getInt('eventId'); $event = FD::event($eventId); $my = FD::user(); if (!$event || !$eventId) { return $ajax->reject(); } // Test if the current user is a member of this event. if (!$event->getGuest()->isGuest()) { return $ajax->reject(); } // Determines if this is a new record $id = JRequest::getInt('id'); $task = FD::table('Task'); $task->load($id); $milestoneId = JRequest::getInt('milestoneId'); $title = JRequest::getVar('title'); $due = JRequest::getVar('due'); $assignee = JRequest::getVar('assignee'); // Save task $task->milestone_id = $milestoneId; $task->uid = $event->id; $task->type = SOCIAL_TYPE_EVENT; $task->title = $title; $task->due = $due; $task->user_id = !$assignee ? $my->id : $assignee; $task->state = SOCIAL_TASK_UNRESOLVED; if (!$task->title) { return $ajax->reject(); } $task->store(); if (!$id) { // @points: events.task.create $points = FD::points(); $points->assign('events.task.create', 'com_easysocial', $my->id); // Get the app $app = $this->getApp(); // Get the application params $params = $app->getParams(); // Send notification if ($params->get('notify_new_task', true)) { $milestone = FD::table('Milestone'); $milestone->load($milestoneId); // Get the redirection url $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'milestoneId' => $milestoneId), false); $event->notifyMembers('task.create', array('userId' => $my->id, 'id' => $task->id, 'title' => $task->title, 'content' => $milestone->description, 'permalink' => $url, 'milestone' => $milestone->title)); } // Create stream $task->createStream('createTask'); } // Get the contents $theme = FD::themes(); $theme->set('event', $event); $theme->set('task', $task); $theme->set('user', $my); $output = $theme->output('apps/event/tasks/views/item.task'); return $ajax->resolve($output); }
private function processTaskStream(SocialStreamItem &$item, $includePrivacy) { $app = FD::table('App'); $app->load(array('group' => SOCIAL_TYPE_EVENT, 'type' => SOCIAL_TYPE_APPS, 'element' => 'tasks')); $event = FD::event($item->cluster_id); $params = FD::registry($item->params); // Get the milestone $milestone = FD::table('Milestone'); $milestone->bind($params->get('milestone')); $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id)); // Do not allow reposting on milestone items $item->repost = false; if ($item->verb == 'createTask') { $items = $params->get('tasks'); $tasks = array(); foreach ($items as $i) { $task = FD::table('Task'); // We don't do bind here because we need to latest state from the database // THe cached params might be an old data. $task->load($i->id); $tasks[] = $task; } $this->set('tasks', $tasks); $this->set('total', count($tasks)); } $this->set('event', $event); $this->set('stream', $item); $this->set('milestone', $milestone); $this->set('permalink', $permalink); $this->set('actor', $item->actor); // streams/tasks/createTask.title // streams/tasks/createTask.content // streams/tasks/createMilestone.title // streams/tasks/createMilestone.content $item->title = parent::display('streams/tasks/' . $item->verb . '.title'); $item->content = parent::display('streams/tasks/' . $item->verb . '.content'); if ($item->verb === 'createMilestone') { $item->opengraph->addDescription(JText::sprintf('APP_USER_EVENTS_TASKS_STREAM_OPENGRAPH_CREATED_MILESTONE', $item->actor->getName(), $milestone->title, $event->getName())); } if ($item->verb === 'createTask') { $item->opengraph->addDescription(JText::sprintf(FD::string()->computeNoun('APP_USER_EVENTS_TASKS_STREAM_OPENGRAPH_ADDED_TASK', count($tasks)), $item->actor->getName(), count($tasks), $milestone->title, $event->getName())); } }
/** * 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); }
} ?> </div> </div> <div class="col-md-3 discussion-meta"> <?php if ($event->getGuest()->isGuest()) { ?> <div class="mt-5"> <a href="<?php echo FRoute::apps(array('layout' => 'canvas', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'customView' => 'create')); ?> " class="btn btn-es-primary btn-create"><i class="ies-pencil"></i> <?php echo JText::_('APP_EVENT_DISCUSSIONS_CREATE_DISCUSSION'); ?> →</a> </div> <?php } ?> <?php if ($params->get('stats_sidebar', true)) { ?> <div class="stats">
public function prepareCreateMilestoneStream(SocialStreamItem $streamItem, $includePrivacy = true) { $params = FD::registry($streamItem->params); $milestone = FD::table('Milestone'); $milestone->bind($params->get('milestone')); // Get the group data FD::load('event'); $event = new SocialEvent(); $event->bind($params->get('event')); // Get the actor $actor = $streamItem->actor; $app = $this->getApp(); $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id)); $this->set('permalink', $permalink); $this->set('milestone', $milestone); $this->set('actor', $actor); $this->set('event', $event); $streamItem->title = parent::display('streams/create.milestone.title'); $streamItem->content = parent::display('streams/create.milestone.content'); $streamItem->opengraph->addDescription(JText::sprintf('APP_EVENT_TASKS_STREAM_OPENGRAPH_CREATE_MILESTONE', $streamItem->actor->getName(), $event->getName())); }
?> <li> <a href="<?php echo FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'newsId' => $article->id), false); ?> #comments"><?php echo JText::_('APP_EVENT_NEWS_COMMENT'); ?> </a> </li> <?php } ?> <li> <a href="<?php echo FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $app->getAlias(), 'newsId' => $article->id), false); ?> "> <?php echo JText::_('APP_EVENT_NEWS_READ_ON'); ?> → </a> </li> </ul> </div> </li> <?php } ?>
private function prepareCreateStream(SocialStreamItem &$item, SocialGroup $group) { if (!$group->canViewItem()) { return; } $params = FD::registry($item->params); $data = $params->get('news'); // Load the group $group = FD::group($data->cluster_id); $news = FD::table('GroupNews'); $news->load($data->id); // Get the permalink $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $this->getApp()->getAlias(), 'newsId' => $news->id), false); // Get the app params $appParams = $this->getApp()->getParams(); // Format the content $this->format($news, $appParams->get('stream_length')); // Attach actions to the stream $this->attachActions($item, $news, $permalink, $appParams); $this->set('group', $group); $this->set('appParams', $appParams); $this->set('permalink', $permalink); $this->set('news', $news); $this->set('actor', $item->actor); // Load up the contents now. $item->title = parent::display('streams/create.title'); $item->content = parent::display('streams/create.content'); }
<?php /** * @package EasySocial * @copyright Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved. * @license GNU/GPL, see LICENSE.php * EasySocial is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ defined('_JEXEC') or die('Unauthorized Access'); echo JText::sprintf('APP_USER_CALENDAR_CREATED_NEW_EVENT_' . $gender, $this->html('html.user', $actor->id), '<a href="' . FRoute::apps(array('layout' => 'canvas', 'id' => $app->getAlias(), 'uid' => $actor->getAlias(), 'type' => SOCIAL_TYPE_USER, 'customView' => 'item', 'schedule_id' => $calendar->id)) . '">' . JText::_('APP_CALENDAR_ADDED_NEW_EVENT') . '</a>', '<a href="' . FRoute::apps(array('layout' => 'canvas', 'id' => $app->getAlias(), 'uid' => $actor->getAlias(), 'type' => SOCIAL_TYPE_USER)) . '">' . JText::_('APP_CALENDAR_STREAM_CALENDAR') . '</a>');
/** * Prepares the stream item for new discussion creation * * @since 1.3 * @access public * @param SocialStreamItem $item The stream item. */ private function prepareLockedStream(&$item) { // Get the context params $params = FD::registry($item->params); $event = FD::event($params->get('event')->id); $discussion = FD::table('Discussion'); $discussion->bind($params->get('discussion')); $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $this->getApp()->getAlias(), 'discussionId' => $discussion->id), false); $item->display = SOCIAL_STREAM_DISPLAY_MINI; $this->set('permalink', $permalink); $this->set('actor', $item->actor); $this->set('discussion', $discussion); // Load up the contents now. $item->title = parent::display('streams/locked.title'); }
function createGroupDiscussion() { //init variable $mainframe = JFactory::getApplication(); $log_user = $this->plugin->get('user')->id; // Load the discussion $discuss_id = $mainframe->input->get('discussion_id', 0, 'INT'); $groupId = $mainframe->input->get('group_id', 0, 'INT'); $wres = new stdClass(); $discussion = FD::table('Discussion'); $discussion->load($discuss_id); // Get the current logged in user. $my = FD::user($log_user); // Get the group $group = FD::group($groupId); // Check if the user is allowed to create a discussion if (!$group->isMember()) { $wres->status = 0; $wres->message[] = 'Not allowed to create group discussion'; return $wres; } // Assign discussion properties $discussion->uid = $group->id; $discussion->type = 'group'; $discussion->title = $mainframe->input->get('title', 0, 'STRING'); $discussion->content = $mainframe->input->get('content', 0, 'STRING'); // 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(); $app = FD::table('App'); $app->load(25); // Ensure that the title is valid if (!$discussion->title) { $wres->status = 0; $wres->message[] = 'Discussion title is empty'; return $wres; } // Lock the discussion $state = $discussion->store(); if (!$state) { $wres->status = 0; $wres->message[] = 'Unable to create discussion,check params'; return $wres; } // 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 (!$discuss_id && $state) { // @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); } $wres->id = $discussion->id; $wres->message[] = 'Group discussion created'; return $wres; }