Example #1
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.0
  * @access    public
  * @param    int        The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $event = FD::event($uid);
     $editor = JFactory::getEditor();
     $guest = $event->getGuest();
     // Only allow group admin to create or edit news
     if (!$guest->isAdmin() && !$this->my->isSiteAdmin()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_EVENTS_ONLY_GUEST_ARE_ALLOWED'), SOCIAL_MSG_ERROR);
         return $this->redirect($event->getPermalink(false));
     }
     // Determines if this item is being edited
     $id = $this->input->get('newsId', 0, 'int');
     $news = FD::table('EventNews');
     $news->load($id);
     FD::page()->title(JText::_('APP_EVENT_NEWS_FORM_UPDATE_PAGE_TITLE'));
     // Determine if this is a new record or not
     if (!$id) {
         $news->comments = true;
         FD::page()->title(JText::_('APP_EVENT_NEWS_FORM_CREATE_PAGE_TITLE'));
     }
     // Get app params
     $params = $this->app->getParams();
     $this->set('params', $params);
     $this->set('news', $news);
     $this->set('editor', $editor);
     $this->set('event', $event);
     echo parent::display('canvas/form');
 }
Example #2
0
 /**
  * Default method to display the registration page.
  *
  * @since	1.0
  * @access	public
  * @author	Mark Lee <*****@*****.**>
  */
 function item($tpl = null)
 {
     // Check for user profile completeness
     FD::checkCompleteProfile();
     $config = FD::config();
     if (!$config->get('badges.enabled')) {
         return $this->redirect(FRoute::dashboard(array(), false));
     }
     // Get id of badge
     $id = JRequest::getInt('id');
     $badge = FD::table('Badge');
     $badge->load($id);
     if (!$id || !$badge->id) {
         FD::info()->set(JText::_('COM_EASYSOCIAL_BADGES_INVALID_BADGE_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         $this->redirect(FRoute::badges());
         $this->close();
     }
     // Load the badge language
     $badge->loadLanguage();
     // Set the page title
     FD::page()->title($badge->get('title'));
     // Set the page breadcrumb
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_BADGES'), FRoute::badges());
     FD::page()->breadcrumb($badge->get('title'));
     // Get the badges model
     $options = array('start' => 0, 'limit' => FD::themes()->getConfig()->get('achieverslimit', 50));
     $achievers = $badge->getAchievers($options);
     $totalAchievers = $badge->getTotalAchievers();
     $this->set('totalAchievers', $totalAchievers);
     $this->set('achievers', $achievers);
     $this->set('badge', $badge);
     parent::display('site/badges/default.item');
 }
Example #3
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.3
  * @access   public
  * @param    int        The event id
  */
 public function display($id = null, $docType = null)
 {
     // Load up the event
     $event = FD::event($id);
     // Check if the viewer is really allowed to view news
     if ($event->isInviteOnly() && $event->isClosed() && !$event->getGuest()->isGuest() && !$this->my->isSiteAdmin()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_EVENTS_ONLY_GUEST_ARE_ALLOWED'), SOCIAL_MSG_ERROR);
         return $this->redirect($event->getPermalink(false));
     }
     $params = $this->app->getParams();
     // Set the max length of the item
     $options = array('limit' => (int) $params->get('total', 10));
     $model = FD::model('Clusters');
     $items = $model->getNews($event->id, $options);
     $pagination = $model->getPagination();
     // Format the item's content.
     $this->format($items, $params);
     $pagination->setVar('option', 'com_easysocial');
     $pagination->setVar('view', 'events');
     $pagination->setVar('layout', 'item');
     $pagination->setVar('id', $event->getAlias());
     $pagination->setVar('appId', $this->app->getAlias());
     $this->set('params', $params);
     $this->set('pagination', $pagination);
     $this->set('event', $event);
     $this->set('items', $items);
     echo parent::display('canvas/default');
 }
Example #4
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($userId = null, $docType = null)
 {
     // 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');
 }
Example #5
0
 /**
  * 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 &amp; are replaced with &
     $url = str_ireplace('&amp;', '&', $table->url);
     $this->redirect(FRoute::_($url, false));
     $this->close();
 }
Example #6
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $group = FD::group($uid);
     $editor = JFactory::getEditor();
     // Only allow group admin to create or edit news
     if (!$group->isAdmin() && !$this->my->isSiteAdmin()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_GROUPS_ONLY_MEMBER_ARE_ALLOWED'), SOCIAL_MSG_ERROR);
         return $this->redirect($group->getPermalink(false));
     }
     $id = JRequest::getInt('newsId');
     $news = FD::table('GroupNews');
     $news->load($id);
     FD::page()->title(JText::_('APP_GROUP_NEWS_FORM_UPDATE_PAGE_TITLE'));
     // Determine if this is a new record or not
     if (!$id) {
         $news->comments = true;
         FD::page()->title(JText::_('APP_GROUP_NEWS_FORM_CREATE_PAGE_TITLE'));
     }
     // Get app params
     $params = $this->app->getParams();
     $this->set('params', $params);
     $this->set('news', $news);
     $this->set('editor', $editor);
     $this->set('group', $group);
     echo parent::display('canvas/form');
 }
Example #7
0
 /**
  * Allows user to save settings
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function saveSettings()
 {
     // Check for request forgeries
     FD::checkToken();
     // Ensure that the user is logged in.
     FD::requireLogin();
     // Get current view.
     $view = $this->getCurrentView();
     // Get current logged in user
     $my = FD::user();
     // Get the app id from request.
     $id = JRequest::getInt('id');
     // Try to load the app
     $app = FD::table('App');
     $app->load($id);
     if (!$id || !$app->id) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_APPS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Ensure that the user can really access this app settings.
     if (!$app->isInstalled()) {
         return $ajax->reject(FD::info()->set(JText::_('COM_EASYSOCIAL_APPS_SETTINGS_NOT_INSTALLED'), SOCIAL_MSG_ERROR));
     }
     $data = JRequest::getVar('data', '');
     // Convert the object to proper json string
     $raw = FD::makeJSON($data);
     $map = FD::table('AppsMap');
     $map->load(array('uid' => $my->id, 'app_id' => $app->id));
     $map->params = $raw;
     // Store user params
     $map->store();
     return $view->call(__FUNCTION__);
 }
Example #8
0
 /**
  * Post processing after a user grants access to the app.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function grant($callback)
 {
     FD::info()->set($this->getMessage());
     if (empty($callback)) {
         // Do our own standard procedure when callbacks are not provided.
     }
     $this->redirect($callback);
 }
Example #9
0
 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();
 }
Example #10
0
 public function saveFilter($filter)
 {
     // Unauthorized users should not be allowed to access this page.
     FD::requireLogin();
     FD::info()->set($this->getMessage());
     if ($filter->id) {
         //$this->redirect( FRoute::stream( array( 'layout' => 'form', 'id' => $filter->id ) , false ) );
         $this->redirect(FRoute::dashboard(array(), false));
     } else {
         $model = FD::model('Stream');
         $items = $model->getFilters(FD::user()->id);
         $this->set('items', $items);
         $this->set('filter', $filter);
         echo parent::display('site/stream/filter.form');
     }
 }
Example #11
0
 public function form($keys = null)
 {
     // Check access
     if (!$this->authorise('easysocial.access.maintenance')) {
         $this->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
     }
     if ($this->hasErrors() || empty($keys)) {
         FD::info()->set($this->getMessage());
         return $this->redirect('index.php?option=com_easysocial&view=maintenance');
     }
     $this->setHeading('COM_EASYSOCIAL_HEADING_MAINTENANCE_EXECUTING');
     $this->setDescription('COM_EASYSOCIAL_DESCRIPTION_MAINTENANCE_EXECUTING');
     $model = FD::model('maintenance');
     $scripts = $model->getItemByKeys($keys);
     $this->set('scripts', $scripts);
     echo parent::display('admin/maintenance/form');
 }
Example #12
0
 /**
  * Displays the application output in the canvas.
  *
  * @since   1.0
  * @access  public
  * @param   int     The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $group = FD::group($uid);
     if (!$group->isMember() && !$this->my->isSiteAdmin()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_GROUPS_ONLY_MEMBER_ARE_ALLOWED'), SOCIAL_MSG_ERROR);
         return $this->redirect($group->getPermalink(false));
     }
     // Set the page title
     FD::page()->title(JText::_('APP_GROUP_DISCUSSIONS_PAGE_TITLE_CREATE'));
     // Get the discussion item
     $discussion = FD::table('Discussion');
     // Determines if we should allow file sharing
     $access = $group->getAccess();
     $files = $access->get('files.enabled', true);
     $this->set('files', $files);
     $this->set('discussion', $discussion);
     $this->set('group', $group);
     echo parent::display('canvas/form');
 }
Example #13
0
 /**
  * Displays the application output in the canvas.
  *
  * @since    1.0
  * @access    public
  * @param    int        The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $event = FD::event($uid);
     // Check if the user is a member of the group
     if (!$event->getGuest()->isGuest() && !$this->my->isSiteAdmin()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_EVENTS_ONLY_GUEST_ARE_ALLOWED'), SOCIAL_MSG_ERROR);
         return $this->redirect($event->getPermalink(false));
     }
     // Set the page title
     FD::page()->title(JText::_('APP_EVENT_DISCUSSIONS_PAGE_TITLE_CREATE'));
     // Get the discussion item
     $discussion = FD::table('Discussion');
     // Determines if we should allow file sharing
     $access = $event->getAccess();
     $files = $access->get('files.enabled', true);
     $this->set('files', $files);
     $this->set('discussion', $discussion);
     $this->set('event', $event);
     echo parent::display('canvas/form');
 }
Example #14
0
 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}();
 }
Example #15
0
 /**
  * Displays the single note item
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($userId = null, $docType = null)
 {
     $id = JRequest::getInt('cid');
     $appid = JRequest::getInt('id');
     // Get the current owner of this app canvas
     $user = FD::user($userId);
     $note = $this->getTable('Note');
     $note->load($id);
     if (!$id || !$note) {
         FD::info()->set(false, JText::_('APP_USER_NOTES_INVALID_NOTE_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $this->redirect(FD::profile(array('id' => $user->getAlias()), false));
     }
     // Load up likes library for this note.
     $likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER);
     // Load up comments library for this note.
     $comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => ''));
     $this->set('likes', $likes);
     $this->set('comments', $comments);
     $this->set('note', $note);
     $this->set('user', $user);
     $this->set('appId', $appid);
     echo parent::display('canvas/default');
 }
Example #16
0
 /**
  * This is the first entry point when the social site redirects back to this callback.
  * It is responsible to close the popup and redirect to the appropriate url.
  *
  * @since	1.0
  * @access	public
  */
 public function requestPermissions()
 {
     $config = FD::config();
     // Get allowed clients
     $allowedClients = array_keys((array) $config->get('oauth'));
     // Get the current client.
     $oauthClient = JRequest::getWord('client');
     if (!in_array($oauthClient, $allowedClients)) {
         FD::info()->set(false, JText::sprintf('COM_EASYSOCIAL_OAUTH_INVALID_OAUTH_CLIENT_PROVIDED', $oauthClient), SOCIAL_MSG_ERROR);
         $this->redirect('index.php?option=com_easysocial&view=login');
         $this->close();
         return;
     }
     $consumer = FD::OAuth(SOCIAL_TYPE_FACEBOOK);
     $permissions = JRequest::getVar('permissions');
     // Add permissions for this client
     $consumer->addPermission($permissions);
     // Get the return url
     $return = JRequest::getVar('return_to');
     $return = base64_decode($return);
     $this->set('redirect', $return);
     parent::display('site/registration/oauth.popup');
 }
Example #17
0
 /**
  * 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);
 }
Example #18
0
 /**
  * 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');
 }
Example #19
0
 /**
  * Replicate's Joomla login behavior
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function login()
 {
     JSession::checkToken('post') or jexit(JText::_('JInvalid_Token'));
     $app = JFactory::getApplication();
     // Populate the data array:
     $data = array();
     $data['return'] = base64_decode($app->input->post->get('return', '', 'BASE64'));
     $data['username'] = JRequest::getVar('username', '', 'method', 'username');
     $data['password'] = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
     $data['secretkey'] = JRequest::getString('secretkey', '');
     // Get the user's state because there could be instances where Joomla is redirecting users
     $tmp = $app->getUserState('users.login.form.data');
     if (isset($tmp['return']) && !empty($tmp['return'])) {
         $data['return'] = $tmp['return'];
     }
     // Set the return URL if empty.
     if (empty($data['return'])) {
         $data['return'] = 'index.php?option=com_easysocial&view=login';
     }
     // Set the return URL in the user state to allow modification by plugins
     $app->setUserState('users.login.form.return', $data['return']);
     // Get the log in options.
     $options = array();
     $options['remember'] = JRequest::getBool('remember', false);
     $options['return'] = $data['return'];
     // Silent! Kill you!
     $options['silent'] = true;
     // Get the log in credentials.
     $credentials = array();
     $credentials['username'] = $data['username'];
     $credentials['password'] = $data['password'];
     $credentials['secretkey'] = $data['secretkey'];
     // Perform the log in.
     if (true === $app->login($credentials, $options)) {
         // Set the remember state
         if ($options['remember'] == true) {
             $app->setUserState('rememberLogin', true);
         }
         // Success
         $app->setUserState('users.login.form.data', array());
         // Redirect link should use the return data instead of relying it on getUserState('users.login.form.return')
         // Because EasySocial has its own settings of login redirection, hence this should respect the return link passed
         // We cannot fallback because the return link needs to be set in the options before calling login, and as such, the fallback has been set before calling $app->login, and no fallback is needed here.
         $app->redirect(JRoute::_($data['return'], false));
     } else {
         // Login failed !
         $data['remember'] = (int) $options['remember'];
         $app->setUserState('users.login.form.data', $data);
         $returnFailed = base64_decode($app->input->post->get('returnFailed', '', 'BASE64'));
         if (empty($returnFailed)) {
             $returnFailed = FRoute::login(array(), false);
         }
         FD::info()->set(null, JText::_('JGLOBAL_AUTH_INVALID_PASS'), SOCIAL_MSG_ERROR);
         $app->redirect($returnFailed);
     }
 }
Example #20
0
 public function switchCategory()
 {
     FD::info()->set($this->getMessage());
     $this->redirect('index.php?option=com_easysocial&view=groups');
 }
Example #21
0
 /**
  * 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);
 }
Example #22
0
 public function restoreTrash($tpl = null)
 {
     FD::info()->set($this->getMessage());
     return $this->redirect(FRoute::url(array('view' => 'stream')));
 }
Example #23
0
 /**
  * Post processing for deleting an item
  *
  * @since	1.0
  * @access	public
  * @return
  */
 public function cancel()
 {
     FD::info()->set($this->getMessage());
     $this->redirect('index.php?option=com_easysocial&view=privacy');
     $this->close();
 }
Example #24
0
 public static function checkCompleteProfile()
 {
     $config = FD::config();
     $my = FD::user();
     // If user is not registered, or no profile id, or settings is not enabled, we cannot do anything to check
     if (empty($my->id) || empty($my->profile_id) || !$config->get('user.completeprofile.required', false)) {
         return true;
     }
     $total = $my->getProfile()->getTotalFields(SOCIAL_PROFILES_VIEW_EDIT);
     $filled = $my->completed_fields;
     // Avoid using maintenance script to do this because it is possible that a site might have >1000 users
     // Using this method instead so that every user will at least get executed once during login
     // Won't happen on subsequent logins
     if (empty($filled)) {
         $fields = FD::model('Fields')->getCustomFields(array('profile_id' => $my->getProfile()->id, 'data' => true, 'dataId' => $my->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_EDIT, 'group' => SOCIAL_FIELDS_GROUP_USER));
         $args = array(&$my);
         $completedFields = FD::fields()->trigger('onProfileCompleteCheck', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
         $table = FD::table('Users');
         $table->load(array('user_id' => $my->id));
         $table->completed_fields = count($completedFields);
         $table->store();
         $filled = $table->completed_fields;
     }
     if ($total == $filled) {
         return true;
     }
     $percentage = (int) ($filled / $total * 100);
     if ($percentage < 100) {
         $action = $config->get('user.completeprofile.action', 'info');
         if ($action === 'redirect') {
             $mainframe = JFactory::getApplication();
             $mainframe->redirect(FRoute::profile(array('layout' => 'edit')));
         }
         if ($action === 'info' || $action === 'infoprofile' && JRequest::getVar('view') === 'profile') {
             $incompleteMessage = JText::sprintf('COM_EASYSOCIAL_PROFILE_YOUR_PROFILE_IS_INCOMPLETE', $percentage, FRoute::profile(array('layout' => 'edit')));
             FD::info()->set(false, $incompleteMessage, SOCIAL_MSG_WARNING, 'easysocial.profilecompletecheck');
         }
         return false;
     }
     return true;
 }
Example #25
0
 public function publish()
 {
     FD::info()->set($this->getMessage());
     return $this->redirect('index.php?option=com_easysocial&view=alerts');
 }
Example #26
0
 /**
  * Post process after badge has been inserted for user
  *
  * @since	1.0
  * @access	public
  */
 public function insertBadge()
 {
     FD::info()->set($this->getMessage());
     $this->redirect('index.php?option=com_easysocial&view=users');
 }
Example #27
0
 /**
  * post processing after group filter get deleted.
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function deleteFilter($groupId)
 {
     $ajax = FD::ajax();
     FD::requireLogin();
     FD::info()->set($this->getMessage());
     $group = FD::group($groupId);
     $url = FRoute::groups(array('layout' => 'item', 'id' => $group->getAlias()), false);
     return $ajax->redirect($url);
 }
Example #28
0
 public function upload()
 {
     // Get info object.
     $info = FD::info();
     $info->set($this->getMessage());
     return $this->redirect('index.php?option=com_easysocial&view=badges&layout=install');
 }
Example #29
0
 /**
  * Display app settings
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function settings()
 {
     // User must be logged in.
     FD::requireLogin();
     // Get the ajax library
     $ajax = FD::ajax();
     // Get the themes library
     $theme = FD::themes();
     // Get the app id from request.
     $id = JRequest::getInt('id');
     // Try to load the app
     $app = FD::table('App');
     $app->load($id);
     if (!$id || !$app->id) {
         return $ajax->reject(FD::info()->set(JText::_('COM_EASYSOCIAL_APPS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR));
     }
     // Ensure that the user can really access this app settings.
     if (!$app->isInstalled()) {
         return $ajax->reject(FD::info()->set(JText::_('COM_EASYSOCIAL_APPS_SETTINGS_NOT_INSTALLED'), SOCIAL_MSG_ERROR));
     }
     // $app->loadLanguage();
     // Get current registry object for the current user.
     $params = $app->getUserParams();
     // Render user settings from the app.
     $form = $app->renderForm('user', $params);
     $theme->set('id', $app->id);
     $theme->set('form', $form);
     $output = $theme->output('site/apps/dialog.settings');
     return $ajax->resolve($output);
 }
Example #30
0
 /**
  * Post process after synchronizing the database columns
  *
  * @since	1.0
  * @access	public
  * @return
  */
 public function sync()
 {
     FD::info()->set($this->getMessage());
     $this->redirect('index.php?option=com_easysocial');
 }