/** * Retrieves the redirection url for sign in / sign out. * * @since 1.0 * @access public * @param string * @return */ public function getRedirectionUrl($menuId) { $menu = JFactory::getApplication()->getMenu(); $menuItem = $menu->getItem($menuId); // Set the default return URL. $return = FRoute::dashboard(array(), false); if ($menuItem) { if ($menuItem->component != 'com_easysocial') { if (strpos($menuItem->link, '?') > 0) { $return = JRoute::_($menuItem->link . '&Itemid=' . $menuItem->id, false); } else { $return = JRoute::_($menuItem->link . '?Itemid=' . $menuItem->id, false); } // If the logout return is null, it means the menu item is on the home page. if (!$return || isset($menuItem->home) && $menuItem->home) { $return = JURI::root(); } } if ($menuItem->component == 'com_easysocial') { $view = isset($menuItem->query['view']) ? $menuItem->query['view'] : ''; if ($view) { $queries = $menuItem->query; unset($queries['option']); unset($queries['view']); $arguments = array($queries, false); $return = call_user_func_array(array('FRoute', $view), $arguments); } } } return $return; }
/** * Redirects a notification item to the intended location * * @since 1.0 * @access public * @param string * @return */ public function route() { // The user needs to be logged in to access notifications FD::requireLogin(); // Get the notification id $id = $this->input->get('id', 0, 'int'); $table = FD::table('Notification'); $table->load($id); // Default redirection URL $redirect = FRoute::dashboard(array(), false); if (!$id || !$table->id) { $this->info->set(JText::_('COM_EASYSOCIAL_NOTIFICATIONS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR); return $this->redirect($redirect); } // Ensure that the viewer really owns this item if ($table->target_id != $this->my->id) { $this->info->set(JText::_('COM_EASYSOCIAL_NOTIFICATIONS_NOT_ALLOWED'), SOCIAL_MSG_ERROR); return $this->redirect($redirect); } // Mark the notification item as read $table->markAsRead(); // Ensure that all & are replaced with & $url = str_ireplace('&', '&', $table->url); $redirect = FRoute::_($url, false); $this->redirect($redirect); $this->close(); }
/** * Displays the application output in the canvas. * * @since 1.0 * @access public * @param int The user id that is currently being viewed. */ public function display($userId = null, $docType = null) { // Require user to be logged in FD::requireLogin(); $id = JRequest::getVar('schedule_id'); // Get the user that's being accessed. $user = FD::user($userId); $calendar = FD::table('Calendar'); $calendar->load($id); if (!$calendar->id || !$id) { FD::info()->set(false, JText::_('APP_CALENDAR_CANVAS_INVALID_SCHEDULE_ID'), SOCIAL_MSG_ERROR); return $this->redirect(FD::profile(array('id' => $user->getAlias()), false)); } $my = FD::user(); $privacy = FD::privacy($my->id); $result = $privacy->validate('apps.calendar', $calendar->id, 'view', $user->id); if (!$result) { FD::info()->set(false, JText::_('APP_CALENDAR_NO_ACCESS'), SOCIAL_MSG_ERROR); JFactory::getApplication()->redirect(FRoute::dashboard()); } FD::page()->title($calendar->title); // Render the comments and likes $likes = FD::likes(); $likes->get($id, 'calendar', 'create', SOCIAL_APPS_GROUP_USER); // Apply comments on the stream $comments = FD::comments($id, 'calendar', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::albums(array('layout' => 'item', 'id' => $id)))); $params = $this->app->getParams(); $this->set('params', $params); $this->set('likes', $likes); $this->set('comments', $comments); $this->set('calendar', $calendar); $this->set('user', $user); echo parent::display('canvas/item/default'); }
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); } } }
/** * Redirects a notification item to the intended location * * @since 1.0 * @access public * @param string * @return */ public function route() { // The user needs to be logged in to access notifications FD::requireLogin(); // Check for user profile completeness FD::checkCompleteProfile(); $id = JRequest::getInt('id'); $table = FD::table('Notification'); $table->load($id); if (!$id || !$table->id) { FD::info()->set(JText::_('COM_EASYSOCIAL_NOTIFICATIONS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR); return $this->redirect(FRoute::dashboard(array(), false)); } // Check if the user is allowed to view this notification item. $my = FD::user(); if ($table->target_id != $my->id) { FD::info()->set(JText::_('COM_EASYSOCIAL_NOTIFICATIONS_NOT_ALLOWED'), SOCIAL_MSG_ERROR); return $this->redirect(FRoute::dashboard(array(), false)); } // Mark the notification item as read $table->markAsRead(); // Ensure that all & are replaced with & $url = str_ireplace('&', '&', $table->url); $this->redirect(FRoute::_($url, false)); $this->close(); }
/** * Responsible to display the generic login form. * * @since 1.0 * @access public */ public function display($tpl = null) { $my = FD::user(); // If user is already logged in, they should not see this page. if ($my->id > 0) { return $this->redirect(FRoute::dashboard(array(), false)); } // Add page title FD::page()->title(JText::_('COM_EASYSOCIAL_LOGIN_PAGE_TITLE')); // Add breadcrumb FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_LOGIN_PAGE_BREADCRUMB')); // Facebook codes. $facebook = FD::oauth('Facebook'); $config = FD::config(); $loginMenu = $config->get('general.site.login'); // Get any callback urls. $return = FD::getCallback(); // If return value is empty, always redirect back to the dashboard if (!$return) { // Determine if there's a login redirection $urlFromCaller = FD::input()->getVar('return', ''); if ($urlFromCaller) { $return = $urlFromCaller; } else { if ($loginMenu != 'null') { $return = FRoute::getMenuLink($loginMenu); } else { $return = FRoute::dashboard(array(), false); } $return = base64_encode($return); } } else { $return = base64_encode($return); } if ($config->get('registrations.enabled')) { $profileId = $config->get('registrations.mini.profile', 'default'); if ($profileId === 'default') { $profileId = Foundry::model('profiles')->getDefaultProfile()->id; } $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId); $fieldsModel = Foundry::model('fields'); $fields = $fieldsModel->getCustomFields($options); if (!empty($fields)) { FD::language()->loadAdmin(); $fieldsLib = FD::fields(); $session = JFactory::getSession(); $registration = FD::table('Registration'); $registration->load($session->getId()); $data = $registration->getValues(); $args = array(&$data, &$registration); $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args); $this->set('fields', $fields); } } $this->set('return', $return); $this->set('facebook', $facebook); return parent::display('site/login/default'); }
private function checkFeature() { $config = FD::config(); // Do not allow user to access photos if it's not enabled if (!$config->get('photos.enabled')) { $this->setMessage(JText::_('COM_EASYSOCIAL_ALBUMS_PHOTOS_DISABLED'), SOCIAL_MSG_ERROR); FD::info()->set($this->getMessage()); $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } }
/** * Responsible to display the generic login form via ajax * * @since 1.0 * @access public */ public function form($tpl = null) { $ajax = FD::ajax(); $my = FD::user(); // If user is already logged in, they should not see this page. if ($my->id > 0) { $this->setMessage(JText::_('COM_EASYSOCIAL_LOGIN_ALREADY_LOGGED_IN'), SOCIAL_MSG_ERROR); return $ajax->reject($this->getMessage()); } // Facebook codes. $facebook = FD::oauth('Facebook'); // Get any callback urls. $return = FD::getCallback(); // If return value is empty, always redirect back to the dashboard if (!$return) { $return = FRoute::dashboard(array(), false); } // Determine if there's a login redirection $config = FD::config(); $loginMenu = $config->get('general.site.login'); if ($loginMenu != 'null') { $return = FD::get('toolbar')->getRedirectionUrl($loginMenu); } $return = base64_encode($return); $this->set('return', $return); $this->set('facebook', $facebook); if ($config->get('registrations.enabled')) { $profileId = $config->get('registrations.mini.profile', 'default'); if ($profileId === 'default') { $profileId = Foundry::model('profiles')->getDefaultProfile()->id; } $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId); $fieldsModel = FD::model('Fields'); $fields = $fieldsModel->getCustomFields($options); if (!empty($fields)) { FD::language()->loadAdmin(); $fieldsLib = FD::fields(); $session = JFactory::getSession(); $registration = FD::table('Registration'); $registration->load($session->getId()); $data = $registration->getValues(); $args = array(&$data, &$registration); $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args); $this->set('fields', $fields); } } $contents = parent::display('site/login/dialog.login'); return $ajax->resolve($contents); }
public function preview() { $fileid = JRequest::getInt('uid'); if (empty($fileid)) { FD::info()->set((object) array('message' => JText::_('PLG_FIELDS_FILE_ERROR_INVALID_FILE_ID'), 'type' => SOCIAL_MSG_ERROR)); $this->redirect(FRoute::dashboard(array(), false)); } $file = FD::table('file'); $state = $file->load($fileid); if (!$state || !$file->hasPreview() || !$this->params->get('allow_preview')) { FD::info()->set((object) array('message' => JText::_('PLG_FIELDS_FILE_ERROR_PREVIEW_NOT_ALLOWED'), 'type' => SOCIAL_MSG_ERROR)); $this->redirect(FRoute::dashboard(array(), false)); } $file->preview(); }
public function display($tpl = null) { $fieldid = JRequest::getInt('id'); $task = JRequest::getWord('task'); $field = FD::table('field'); $state = $field->load($fieldid); if (!$state) { FD::info()->set(JText::_('COM_EASYSOCIAL_FIELDS_INVALID_ID'), SOCIAL_MSG_ERROR); $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } $app = $field->getApp(); if (!$app) { FD::info()->set(JText::sprintf('COM_EASYSOCIAL_FIELDS_APP_DOES_NOT_EXIST', $app->element), SOCIAL_MSG_ERROR); $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } $base = SOCIAL_FIELDS . '/' . $app->group . '/' . $app->element . '/views'; $classname = 'SocialFieldView' . ucfirst($app->group) . ucfirst($app->element); if (!class_exists($classname)) { if (!JFile::exists($base . '/' . $app->element . '.php')) { FD::info()->set(JText::sprintf('COM_EASYSOCIAL_FIELDS_VIEW_DOES_NOT_EXIST', $app->element), SOCIAL_MSG_ERROR); $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } require_once $base . '/' . $app->element . '.php'; } if (!class_exists($classname)) { FD::info()->set(JText::sprintf('COM_EASYSOCIAL_FIELDS_CLASS_DOES_NOT_EXIST', $classname), SOCIAL_MSG_ERROR); $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } $view = new $classname($app->group, $app->element); if (!is_callable(array($view, $task))) { FD::info()->set(JText::sprintf('COM_EASYSOCIAL_FIELDS_METHOD_DOES_NOT_EXIST', $task), SOCIAL_MSG_ERROR); $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } $view->init($field); return $view->{$task}(); }
/** * Allows viewer to download a conversation file * * @since 1.2 * @access public * @param string * @return */ public function preview() { // Check if this feature is enabled. $this->checkFeature(); // Currently only registered users are allowed to view a file. FD::requireLogin(); // Get the file id from the request $fileId = JRequest::getInt('fileid', null); $file = FD::table('File'); $file->load($fileId); if (!$file->id || !$fileId) { // Throw error message here. $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } // Load up the group $group = FD::group($file->uid); // Ensure that the user can really view this group if (!$group->canViewItem()) { // Throw error message here. $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } $file->preview(); exit; }
<input type="password" placeholder="<?php echo JText::_('COM_EASYSOCIAL_PLACEHOLDER_YOUR_PASSWORD'); ?> " name="password" id="userPassword" class="full-width"> <label class="checkbox fd-small mt-10"> <input type="checkbox"> <span class="fd-small" name="remember"><?php echo JText::_('COM_EASYSOCIAL_LOGIN_REMEMBER_YOU'); ?> </span> </label> <button class="mt-20 btn btn-es-success btn-login btn-large btn-block" type="submit"><?php echo JText::_('COM_EASYSOCIAL_LOG_ME_IN_BUTTON'); ?> </button> </fieldset> <input type="hidden" name="option" value="com_users" /> <input type="hidden" name="task" value="user.login" /> <input type="hidden" name="return" value="<?php echo base64_encode(FRoute::dashboard(array(), false)); ?> " /> <input type="hidden" name="<?php echo FD::token(); ?> " value="1" /> </form>
/** * Retrieves the list of discussions * * @since 1.2 * @access public */ public function getDiscussions() { // Check for request forgeriess FD::checkToken(); // Ensure that the user is logged in. FD::requireLogin(); // Load the discussion $id = $this->input->get('id', 0, 'int'); $event = FD::event($id); // Check if the viewer can really browse discussions from this group. if (!$event->isOpen() && !$event->getGuest()->isGuest()) { FD::info()->set(JText::_('APP_EVENT_DISCUSSIONS_NOT_ALLOWED_VIEWING'), SOCIAL_MSG_ERROR); // Perform a redirection return $this->redirect(FRoute::dashboard()); } // Get the current filter type $filter = $this->input->get('filter', 'all', 'word'); $options = array(); if ($filter == 'unanswered') { $options['unanswered'] = true; } if ($filter == 'locked') { $options['locked'] = true; } if ($filter == 'resolved') { $options['resolved'] = true; } // Get the current group app $app = $this->getApp(); $params = $app->getParams(); // Get total number of discussions to display $options['limit'] = $params->get('total', 10); $model = FD::model('Discussions'); $discussions = $model->getDiscussions($event->id, SOCIAL_TYPE_EVENT, $options); $pagination = $model->getPagination(); $pagination->setVar('view', 'events'); $pagination->setVar('layout', 'item'); $pagination->setVar('id', $event->getAlias()); $pagination->setVar('appId', $this->getApp()->id); $pagination->setVar('filter', $filter); $theme = FD::themes(); $theme->set('params', $params); $theme->set('pagination', $pagination); $theme->set('app', $app); $theme->set('event', $event); $theme->set('discussions', $discussions); $contents = $theme->output('apps/event/discussions/events/default.list'); $empty = empty($discussions); return $this->ajax->resolve($contents, $empty); }
/** * Displays the application in a main canvas layout which is the full width of the component. * Example: * index.php?option=com_easysocial&view=apps&layout=canvas&id=[id]&appView=[appView] * * @since 1.0 * @access public * @param null * @return null * */ public function canvas() { // Check for user profile completeness FD::checkCompleteProfile(); // Get the unique id of the item that is being viewed $uid = $this->input->get('uid', null, 'int'); $type = $this->input->get('type', SOCIAL_TYPE_USER, 'word'); // Determines if the type is accessible if (!$this->allowed($uid, $type)) { return; } // Get the current app id. $id = $this->input->get('id', 0, 'int'); // Get the current app. $app = FD::table('App'); $state = $app->load($id); // Default redirection url $redirect = FRoute::dashboard(array(), false); // Check if the user has access to this app if (!$app->accessible($uid, $type) && $type == SOCIAL_TYPE_USER) { $this->info->set(null, JText::_('COM_EASYSOCIAL_APPS_CANVAS_APP_IS_NOT_INSTALLED'), SOCIAL_MSG_ERROR); return $this->redirect($redirect); } // If id is not provided, we need to throw some errors here. if (!$id || !$state) { $this->setMessage(JText::_('COM_EASYSOCIAL_APPS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR); $info->set($this->getMessage()); return $this->redirect($redirect); } // Try to load the app's css. $app->loadCss(); // Check if the app provides any custom view $appView = $this->input->get('customView', 'canvas', 'default'); // We need to set the breadcrumb for the cluster type if ($type == 'group') { $group = FD::group($uid); $this->page->breadcrumb($group->getName()); } // Set the breadcrumbs with the app's title $this->page->breadcrumb($app->get('title')); // Load the library. $lib = FD::apps(); $contents = $lib->renderView(SOCIAL_APPS_VIEW_TYPE_CANVAS, $appView, $app, array('uid' => $uid)); $this->set('uid', $uid); $this->set('contents', $contents); $template = 'site/apps/default.canvas.' . strtolower($type); echo parent::display($template); }
/** * Displays a list of badges the user has achieved * * @since 1.0 * @access public * @param string * @return */ public function achievements() { // Check for user profile completeness FD::checkCompleteProfile(); $config = FD::config(); if (!$config->get('badges.enabled')) { return $this->redirect(FRoute::dashboard(array(), false)); } // Get the current user id that should be displayed $userId = JRequest::getInt('userid', null); $user = FD::user($userId); // If user is not found, we need to redirect back to the dashboard page if (!$user->id) { return $this->redirect(FRoute::dashboard(array(), false)); } $title = JText::_('COM_EASYSOCIAL_PAGE_TITLE_ACHIEVEMENTS'); if (!$user->isViewer()) { $title = JText::sprintf('COM_EASYSOCIAL_PAGE_TITLE_ACHIEVEMENTS_USER', $user->getName()); // Let's test if the current viewer is allowed to view this user's achievements. $my = FD::user(); $privacy = $my->getPrivacy(); $allowed = $privacy->validate('achievements.view', $user->id, SOCIAL_TYPE_USER); if (!$allowed) { $this->set('user', $user); parent::display('site/badges/restricted'); return; } } // Set the page title FD::page()->title($title); // Set the page breadcrumb FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_ACHIEVEMENTS'), FRoute::badges(array('userid' => $userId, 'layout' => 'achievements'))); // Load admin translations FD::language()->loadAdmin(); // @TODO: Check for privacy $model = FD::model('badges'); $badges = $model->getBadges($user->id); $totalBadges = count($badges); $this->set('totalBadges', $totalBadges); $this->set('badges', $badges); $this->set('user', $user); parent::display('site/badges/achievements'); }
<div class="row"> <div class="col-md-12"> <h3 class="pull-left"> <a href="<?php echo FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $hashtagAlias)); ?> ">#<?php echo $hashtag; ?> </a> </h3> </div> </div> <p class="fd-small"> <?php echo JText::sprintf('COM_EASYSOCIAL_STREAM_HASHTAG_CURRENTLY_FILTERING', '<a href="' . FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $hashtagAlias)) . '">#' . $hashtag . '</a>'); ?> </p> </div> <hr /> <?php } ?> <div data-unity-real-content> <?php echo $stream->html(false, JText::_('COM_EASYSOCIAL_UNITY_STREAM_LOGIN_TO_VIEW')); ?> <?php echo $this->includeTemplate('site/dashboard/default.stream.login'); ?>
/** * This is when user clicks on Create account which we will automatically register them on the site. * * @since 1.0 * @access public * @param string * @return */ public function oauthSignup() { // Load our own configuration. $config = FD::config(); // Retrieve current view. $view = $this->getCurrentView(); // Get the current client $client = JRequest::getWord('client'); // Get allowed clients $allowedClients = array_keys((array) $config->get('oauth')); // Check for allowed clients. if (!in_array($client, $allowedClients)) { $view->setMessage(JText::sprintf('COM_EASYSOCIAL_OAUTH_INVALID_OAUTH_CLIENT_PROVIDED', $client), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } // Load up oauth library $oauthClient = FD::oauth($client); // Get the external user id. $oauthUserId = $oauthClient->getUser(); // Determines if the oauth id is already registered on the site. $isRegistered = $oauthClient->isRegistered(); // If user has already registered previously, just log them in. if ($isRegistered) { $state = $oauthClient->login(); if ($state) { $view->setMessage('COM_EASYSOCIAL_OAUTH_AUTHENTICATED_ACCOUNT_SUCCESS', SOCIAL_MSG_SUCCESS); } return $view->call(__FUNCTION__); } // Get the access tokens. $accessToken = $oauthClient->getAccess(); // Retrieve user's information try { $meta = $oauthClient->getUserMeta(); } catch (Exception $e) { $app = JFactory::getApplication(); // Use dashboard here instead of login because api error calls might come from after user have successfully logged in $url = FRoute::dashboard(array(), false); $message = (object) array('message' => JText::sprintf('COM_EASYSOCIAL_OAUTH_FACEBOOK_ERROR_MESSAGE', $e->getMessage()), 'type' => SOCIAL_MSG_ERROR); FD::info()->set($message); $app->redirect($url); $app->close(); } // Get the registration type. $registrationType = $config->get('oauth.' . $client . '.registration.type'); // Load up registration model $model = FD::model('Registration'); // If this is a simplified registration, check if the user name exists. if ($registrationType == 'simplified') { // If the username or email exists if ($model->isEmailExists($meta['email']) || $model->isUsernameExists($meta['username'])) { return $view->call('oauthPreferences', $meta['profileId'], $meta['username'], $meta['email'], $client); } } // Create user account $user = $model->createOauthUser($accessToken, $meta, $oauthClient); // @badge: registration.create // Assign badge for the person that initiated the friend request. $badge = FD::badges(); $badge->log('com_easysocial', 'registration.create', $user->id, JText::_('COM_EASYSOCIAL_REGISTRATION_BADGE_REGISTERED')); if (!$user) { $view->setMessage($model->getError(), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } // If the profile type is auto login, we need to log the user in $profile = FD::table('Profile'); $profile->load($meta['profileId']); // Check if the profile type requires activation. Only log the user in when user is supposed to automatically login. $type = $profile->getRegistrationType(false, true); // Send notification to admin if necessary. $model->notifyAdmins($meta, $user, $profile, true); JFactory::getSession()->clear('user'); // Only log the user in if the profile allows this. if ($type == 'auto') { // Log the user in $oauthClient->login(); // Once the user is logged in, get the new user object. $my = FD::user(); // @points: user.register // Assign points when user registers on the site. $points = FD::points(); $points->assign('user.registration', 'com_easysocial', $my->id); // Add activity logging when a uer registers on the site. if ($config->get('registrations.stream.create')) { $stream = FD::stream(); $streamTemplate = $stream->getTemplate(); // Set the actor $streamTemplate->setActor($my->id, SOCIAL_TYPE_USER); // Set the context $streamTemplate->setContext($my->id, SOCIAL_TYPE_PROFILES); // Set the verb $streamTemplate->setVerb('register'); $streamTemplate->setSiteWide(); $streamTemplate->setAccess('core.view'); // Add stream template. $stream->add($streamTemplate); } } else { // Send notification to user $model->notify($meta, $user, $profile, true); } return $view->call('oauthCreateAccount', $user); }
/** * Default method to display the registration page. * * @since 1.0 * @access public * @author Mark Lee <*****@*****.**> */ function item($tpl = null) { $this->checkFeature(); // Check for user profile completeness FD::checkCompleteProfile(); $id = JRequest::getInt('id'); $point = FD::table('Points'); $point->load($id); if (!$id || !$point->id) { FD::info()->set(null, JText::_('The points id provided is not a valid id.'), SOCIAL_MSG_ERROR); return $this->redirect(FRoute::dashboard(array(), false)); } $point->loadLanguage(); // Load language file. JFactory::getLanguage()->load('com_easysocial', JPATH_ROOT . '/administrator'); // Set the page title FD::page()->title($point->get('title')); // Set the page breadcrumb FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_POINTS'), FRoute::points()); FD::page()->breadcrumb($point->get('title')); // Get list of point achievers. $achievers = $point->getAchievers(); $this->set('achievers', $achievers); $this->set('point', $point); parent::display('site/points/default.item'); }
/** * 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); }
<?php if (isset($hashtag) && $hashtag) { ?> <li class="dashboard-filter active" style="display:none;" data-dashboardSidebar-menu data-dashboardFeeds-item data-type="hashtag" data-id="" data-tag="<?php echo $hashtag; ?> " data-url="<?php echo FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $hashtag)); ?> " data-title="<?php echo $this->html('string.escape', '#' . $hashtag); ?> " > <a href="javascript:void(0);"> <i class="ies-tag mr-5"></i> <?php echo '#' . $hashtag; ?> </a> </li> <?php }
/** * Allows viewer to download a conversation file * * @since 1.0 * @access public * @param string * @return */ public function preview() { // Currently only registered users are allowed to view a file. FD::requireLogin(); // Get the file id from the request $fileId = JRequest::getInt('fileid', null); $file = FD::table('File'); $file->load($fileId); if (!$file->id || !$fileId) { // Throw error message here. $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } // Load up the conversation message $message = FD::table('ConversationMessage'); $message->load($file->uid); // Something went wrong with this discussion as it doesn't have participants if (!$message->id) { // Throw error message here. $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } $conversation = FD::table('Conversation'); $conversation->load($message->conversation_id); // Something went wrong with this discussion as it doesn't have participants if (!$conversation->id) { // Throw error message here. $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } // Get the current viewer $my = FD::user(); // Check if viewer is a participant if (!$conversation->isParticipant($my->id)) { // Throw error message here. $this->redirect(FRoute::dashboard(array(), false)); $this->close(); } $file->preview(); exit; }
/** * Processes a text and replace the mentions / hashtags hyperlinks. * * @since 1.2 * @access public * @param string * @return */ public function processTags($tags, $message, $simpleTags = false) { // We need to merge the mentions and hashtags since we are based on the offset. foreach ($tags as $tag) { if ($tag->type == 'entity' || $tag->type == 'user') { if (isset($tag->user) && $tag->user instanceof SocialUser) { $user = $tag->user; } else { $user = FD::user($tag->item_id); } if ($simpleTags) { $data = new stdClass(); $data->type = $tag->type; $data->link = $user->getPermalink(); $data->title = $user->getName(); $data->id = $user->id; $replace = '[tag]' . FD::json()->encode($data) . '[/tag]'; } else { $replace = '<a href="' . $user->getPermalink() . '" data-popbox="module://easysocial/profile/popbox" data-popbox-position="top-left" data-user-id="' . $user->id . '" class="mentions-user">' . $user->getName() . '</a>'; } } if ($tag->type == 'hashtag') { $alias = JFilterOutput::stringURLSafe($tag->title); $url = FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $alias)); if ($simpleTags) { $data = new stdClass(); $data->type = $tag->type; $data->link = $url; $data->title = $tag->title; $data->id = $tag->id; $replace = '[tag]' . FD::json()->encode($data) . '[/tag]'; } else { $replace = '<a href="' . $url . '" class="mentions-hashtag">#' . $tag->title . '</a>'; } } $message = JString::substr_replace($message, $replace, $tag->offset, $tag->length); } return $message; }
?> <li class="widget-filter custom-filter<?php echo $filter->favicon ? ' has-fonticon' : ''; echo $hide ? ' hide' : ''; echo $filterId == $filter->alias ? ' active' : ''; ?> " data-dashboardSidebar-menu data-sidebar-app-filter data-type="appFilter" > <a href="javascript:void(0);" data-dashboardFeeds-item data-type="appFilter" data-url="<?php echo FRoute::dashboard(array('type' => 'appFilter', 'filterid' => $filter->alias)); ?> " data-id="<?php echo $filter->alias; ?> " data-title="<?php echo $this->html('string.escape', $filter->title); ?> " class="data-dashboardfeeds-item" > <span class="es-app-filter"> <?php if ($filter->image) {
public function form() { // Check for user profile completeness FD::checkCompleteProfile(); // Unauthorized users should not be allowed to access this page. FD::requireLogin(); $my = FD::user(); $id = JRequest::getInt('id', 0); $filter = FD::table('StreamFilter'); $filter->load($id); $model = FD::model('Stream'); $items = $model->getFilters($my->id); $this->set('filter', $filter); $this->set('items', $items); // Set page title if ($filter->id) { FD::page()->title(JText::sprintf('COM_EASYSOCIAL_STREAM_FILTER_EDIT_FILTER', $filter->title)); } else { FD::page()->title(JText::_('COM_EASYSOCIAL_STREAM_FILTER_CREATE_NEW_FILTER')); } // Set the page breadcrumb FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_DASHBOARD'), FRoute::dashboard()); FD::page()->breadcrumb(JText::_('Filter')); echo parent::display('site/stream/filter.form'); }
/** * Processes mentions in a stream object * * @since 1.0 * @access public * @param string * @return */ public function formatMentions(SocialStreamItem &$stream) { // Get the current view $view = JRequest::getCmd('view', ''); // Get the stream's content $content = $stream->content; // Get tags for the stream $tags = isset($stream->tags) ? $stream->tags : array(); // If there is no tags, just skip this and escape the content if (!$tags) { return FD::string()->escape($content); } // We need to store the changes in an array and replace it accordingly based on the counter. $items = array(); // We need to merge the mentions and hashtags since we are based on the offset. $i = 0; foreach ($tags as $tag) { if ($tag->type == 'user') { $replace = '<a href="' . $tag->user->getPermalink() . '" data-popbox="module://easysocial/profile/popbox" data-popbox-position="top-left" data-user-id="' . $tag->user->id . '" class="mentions-user">' . $tag->user->getName() . '</a>'; } if ($tag->type == 'hashtag') { // $alias = JFilterOutput::stringURLSafe($tag->title); $alias = $tag->title; $url = ''; if ($view == 'groups') { $clusterReg = FD::registry($stream->params); $object = $clusterReg->get($stream->cluster_type); switch ($stream->cluster_type) { case SOCIAL_TYPE_GROUP: // for now we assume all is group type. $group = new SocialGroup(); $group->bind($object); $url = FRoute::groups(array('layout' => 'item', 'id' => $group->getAlias(), 'tag' => $alias)); break; case SOCIAL_TYPE_EVENT: $event = new SocialEvent(); $event->bind($object); $url = FRoute::events(array('layout' => 'item', 'id' => $event->getAlias(), 'tag' => $alias)); break; default: FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $alias)); break; } } else { $url = FRoute::dashboard(array('layout' => 'hashtag', 'tag' => $alias)); } $replace = '<a href="' . $url . '" class="mentions-hashtag">#' . $tag->title . '</a>'; } $links[$i] = $replace; $replace = '[si:mentions]' . $i . '[/si:mentions]'; $content = JString::substr_replace($content, $replace, $tag->offset, $tag->length); $i++; } // Once we have the content, escape it $content = FD::string()->escape($content); if ($links) { for ($x = 0; $x < count($links); $x++) { $content = str_ireplace('[si:mentions]' . $x . '[/si:mentions]', $links[$x], $content); } } return $content; }
?> " 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(); ?> " class="app-icon-small mr-5" /> <?php echo $app->getAppTitle(); ?>
/** * Retrieves the list of discussions * * @since 1.2 * @access public */ public function getDiscussions() { // 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'); $group = FD::group($id); // Get the current logged in user. $user = FD::user(); // Check if the viewer can really browse discussions from this group. if (!$group->isMember() && ($group->isClosed() || $group->isInviteOnly())) { FD::info()->set(JText::_('APP_GROUP_DISCUSSIONS_NOT_ALLOWED_VIEWING'), SOCIAL_MSG_ERROR); // Perform a redirection return $this->redirect(FRoute::dashboard()); } // Get the current filter type $filter = JRequest::getWord('filter', 'all'); $options = array(); if ($filter == 'unanswered') { $options['unanswered'] = true; } if ($filter == 'locked') { $options['locked'] = true; } if ($filter == 'resolved') { $options['resolved'] = true; } // Get the current group app $app = $this->getApp(); $params = $app->getParams(); // Get total number of discussions to display $options['limit'] = $params->get('total', 10); $model = FD::model('Discussions'); $discussions = $model->getDiscussions($group->id, SOCIAL_TYPE_GROUP, $options); $pagination = $model->getPagination(); $pagination->setVar('view', 'groups'); $pagination->setVar('layout', 'item'); $pagination->setVar('id', $group->getAlias()); $pagination->setVar('appId', $this->getApp()->id); $pagination->setVar('filter', $filter); $theme = FD::themes(); $theme->set('params', $params); $theme->set('pagination', $pagination); $theme->set('app', $app); $theme->set('group', $group); $theme->set('discussions', $discussions); $contents = $theme->output('apps/group/discussions/groups/default.list'); $empty = empty($discussions); return $ajax->resolve($contents, $empty); }
/** * Responsible for post processing after a user signs up with their oauth account * * @since 1.0 * @access public * @param string * @return */ public function oauthCreateAccount($user = null) { if ($this->hasErrors()) { // Throw some errors here. FD::info()->set($this->getMessage()); return $this->redirect(FRoute::dashboard(array(), false)); } return $this->redirect(FRoute::registration(array('layout' => 'completed', 'userid' => $user->id, 'id' => $user->profile_id, 'oauth' => 1), false)); }
<?php if (!$this->my->guest) { ?> <ul class="fd-nav pull-left"> <?php if ($dashboard) { ?> <li class="toolbarItem toolbar-home" data-toolbar-item> <a data-original-title="<?php echo JText::_('COM_EASYSOCIAL_TOOLBAR_DASHBOARD', true); ?> " data-placement="top" data-es-provide="tooltip" href="<?php echo FRoute::dashboard(); ?> " > <i class="ies-home"></i> <span class="visible-phone"><?php echo JText::_('COM_EASYSOCIAL_TOOLBAR_DASHBOARD', true); ?> </span> </a> </li> <li class="divider-vertical"></li> <?php } ?>
/** * Post processing after the user wants to delete their account * * @since 1.0 * @access public * @param string * @return */ public function delete() { FD::info()->set($this->getMessage()); $this->redirect(FRoute::dashboard(array(), false)); }