public function display($tpl = null) { $auth = JRequest::getString('auth'); // Get the current logged in user's information $model = FD::model('Users'); $id = $model->getUserIdFromAuth($auth); $userId = JRequest::getInt('userid'); // If user id is not passed in, return logged in user if (!$userId) { $userId = $id; } // If we still can't find user's details, throw an error if (!$userId) { $this->set('code', 403); $this->set('message', JText::_('Invalid user id provided.')); return parent::display(); } $me = FD::user($id); $user = FD::user($userId); $this->set('id', $userId); $this->set('isself', $id == $userId); $this->set('isfriend', $user->isFriends($id)); $this->set('isfollower', $user->isFollowed($id)); $this->set('username', $user->username); $this->set('friend_count', $user->getTotalFriends()); $this->set('follower_count', $user->getTotalFollowing()); $this->set('badges', $user->getTotalBadges()); $this->set('points', $user->getPoints()); $this->set('avatar_thumb', $user->getAvatar()); $birthday = $user->getFieldValue('BIRTHDAY'); if (!empty($birthday)) { $this->set('age', $birthday->value->toAge()); } $gender = $user->getFieldValue('GENDER'); $this->set('gender', !empty($gender) ? $gender->data : 0); // Prepare DISPLAY custom fields FD::language()->loadAdmin(); // FD::apps()->loadAllLanguages(); $steps = FD::model('steps')->getSteps($user->profile_id, SOCIAL_TYPE_PROFILES, SOCIAL_PROFILES_VIEW_DISPLAY); $fields = FD::model('fields')->getCustomFields(array('profile_id' => $user->profile_id, 'data' => true, 'dataId' => $user->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_DISPLAY)); $library = FD::fields(); $args = array(&$user); $library->trigger('onGetValue', SOCIAL_FIELDS_GROUP_USER, $fields, $args); // Get the step mapping first $profileSteps = array(); foreach ($steps as $step) { $profileSteps[$step->id] = JText::_($step->title); } $profileFields = array(); foreach ($fields as $field) { $value = (string) $field->value; if (!empty($value)) { $data = array('group_id' => $field->step_id, 'group_name' => $profileSteps[$field->step_id], 'field_id' => $field->id, 'field_name' => JText::_($field->title), 'field_value' => (string) $field->value); $profileFields[] = $data; } } $this->set('more_info', $profileFields); $this->set('code', 200); parent::display(); }
/** * Allows remote user to authenticate via a normal http request and returns with an authentication code. * * @since 1.2.8 * @access public * @param string * @return */ public function auth() { $username = JRequest::getVar('username'); $password = JRequest::getVar('password'); $data = array('username' => $username, 'password' => $password); $app = JFactory::getApplication(); $state = $app->login($data); if ($state === false) { $this->set('code', 403); $this->set('message', JText::_('Invalid username or password provided')); return parent::display(); } // Get the user's id based on the username. $model = FD::model('Users'); $id = $model->getUserId('username', $username); if (!$id) { $this->set('code', 403); $this->set('message', JText::_('Unable to locate the user id with the given username.')); return parent::display(); } $user = FD::user($id); // User logs in successfully. Generate an authentication code for the user $user->auth = md5($user->password . JFactory::getDate()->toSql()); $user->store(); $this->set('auth', $user->auth); $this->set('code', 200); $this->set('id', $user->id); return parent::display(); }
/** * Responsible to output the single stream layout. * * @access public * @return null * */ public function display() { // Unauthorized users should not be allowed to access this page. FD::requireLogin(); // Check for user profile completeness FD::checkCompleteProfile(); // Get the current logged in user. $user = FD::user(); // Get user's privacy $privacy = FD::get('Privacy')->getUserPrivacy($user->id); $this->set('user', $user); $this->set('privacy', $privacy); echo parent::display('site/privacy/default'); }
/** * Displays the photo item * * @since 1.0 * @access public */ public function item() { // Get the user's id by validation $userId = $this->validateAuth(); // Available type: photo, cover, avatar $type = $this->input->getString('type', 'photo'); // Available group: user, group, event $group = $this->input->getString('group', SOCIAL_TYPE_USER); // This id varies depending on what $type is $id = $this->input->get('id', 0, 'int'); $photo = FD::table('Photo'); if ($type == 'photo') { $photo->load($id); } if ($type == 'avatar') { // If there is no id passed in, then we use the logged in userId instead if ($group == SOCIAL_TYPE_USER) { if (empty($id)) { $id = $userId; } } $avatar = FD::table('Avatar'); $avatar->load(array('uid' => $id, 'type' => $group)); $photo->load($avatar->photo_id); } if ($type == 'cover') { // If there is no id passed in, then we use the logged in userId instead if ($group == SOCIAL_TYPE_USER) { if (empty($id)) { $id = $userId; } } $cover = FD::table('Cover'); $cover->load(array('uid' => $id, 'type' => $group)); $photo->load($cover->photo_id); } // Determine the size of the photo to render $size = $this->input->get('size', 'thumbnail', 'cmd'); // Get the photo source $src = $photo->getSource($size); $result = new stdClass(); $result->url = $photo->getSource($size); $result->title = $photo->get('title'); $result->created = $photo->created; $result->assigned_date = $photo->assigned_date; $result->width = $photo->getWidth(); $result->height = $photo->getHeight(); $this->set('photo', $result); parent::display(); }
/** * 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); }
/** * Default display method for leader board * * @since 1.0 * @access public * @param string * @return */ function display($tpl = null) { // Check for user profile completeness FD::checkCompleteProfile(); $config = FD::config(); $limit = $config->get('layout.leaderboard.limit'); $model = FD::model('Leaderboard'); // Should we exclude admin here $excludeAdmin = !$config->get('leaderboard.listings.admin'); $options = array('ordering' => 'points', 'limit' => $limit, 'excludeAdmin' => $excludeAdmin); $users = $model->getLadder($options, false); // Set the page title FD::page()->title(JText::_('COM_EASYSOCIAL_PAGE_TITLE_LEADERBOARD')); $this->set('users', $users); echo parent::display('site/leaderboard/default'); }
/** * Toggle the likes on an object. * * @since 1.0 * @access public * @param * @return string */ public function toggle() { // Validate the current request $userId = $this->validateAuth(); // Get the item properties $id = $this->input->get('uid', 0, 'int'); $type = $this->input->get('element', '', 'cmd'); $group = $this->input->get('group', SOCIAL_APPS_GROUP_USER, 'cmd'); $itemVerb = $this->input->get('verb', '', 'string'); // Get the stream id. $streamid = $this->input->get('stream_id', 0, 'int'); // If id is invalid, throw an error. if (!$id || !$type) { $this->set('status', 0); return parent::display(); } // Get current logged in user. $my = FD::user(); // Load likes library. $model = FD::model('Likes'); // Build the key for likes $key = $type . '.' . $group; if ($itemVerb) { $key = $key . '.' . $itemVerb; } // Determine if user has liked this item previously. $hasLiked = $model->hasLiked($id, $key, $my->id); // If user had already liked this item, we need to unlike it. if ($hasLiked) { $state = $model->unlike($id, $key, $my->id, $streamid); } else { $state = $model->like($id, $key, $my->id, $streamid); //now we need to update the associated stream id from the liked object if ($streamid) { $stream = FD::stream(); $stream->updateModified($streamid); } } // The current action $verb = $hasLiked ? 'unlike' : 'like'; $this->set('status', $state ? 1 : 0); parent::display(); }
/** * Displays user's points history * * @since 1.0 * @access public * @param string * @return */ public function getHistory() { $ajax = FD::ajax(); // Get the user id to lookup $id = JRequest::getInt('id'); // Load the user based on the id. $user = FD::user($id); $config = FD::config(); $options = array('limit' => $config->get('points.history.limit')); $model = FD::model('Points'); // Get a list of histories for the user's points achievements. $histories = $model->getHistory($user->id, $options); $pagination = $model->getPagination(); $this->set('paginate', true); $this->set('histories', $histories); $this->set('user', $user); $contents = parent::display('site/points/default.history.item'); $done = $pagination->total <= $pagination->limitstart + $pagination->limit; return $ajax->resolve($contents, $pagination->pagesCurrent * $pagination->limit, $done); }
/** * Displays a single profile item layout * * @since 4.0 * @access public * @param string * @return */ public function item() { $id = $this->input->get('id', 0, 'int'); // Get the profile object $profile = FD::table('Profile'); $profile->load($id); if (!$id || !$profile->id) { return JError::raiseError(404, JText::_('COM_EASYSOCIAL_404_PROFILE_NOT_FOUND')); } $model = FD::model('Profiles'); $randomMembers = array(); // if this profile is a ESAD profile, we do not show the random members if ($profile->community_access) { $randomMembers = $model->getMembers($profile->id, array('randomize' => true, 'limit' => 20)); } $totalUsers = $profile->getMembersCount(); // Get statistics of user registration for this profile type $stats = $model->getRegistrationStats($profile->id); $stats = $stats->profiles[0]->items; // Get the stream for this profile $startlimit = JRequest::getInt('limitstart', 0); $stream = FD::stream(); $options = array('profileId' => $profile->id); if ($startlimit) { $options['startlimit'] = $startlimit; } $stream->get($options); // Set the page title to this category FD::page()->title($profile->get('title')); // Set the breadcrumbs FD::page()->breadcrumb($profile->get('title')); // Get a list of random albums from this profile $albums = $model->getRandomAlbums(array('core' => false, 'withCovers' => true)); $this->set('albums', $albums); $this->set('stream', $stream); $this->set('stats', $stats); $this->set('randomMembers', $randomMembers); $this->set('totalUsers', $totalUsers); $this->set('profile', $profile); echo parent::display('site/profiles/item'); }
/** * Restful api to share a new story * * @since 1.2 * @access public * @param string * @return */ public function share() { // Validate the user first $userId = $this->validateAuth(); // Get the content for the story $content = $this->input->get('content', '', 'default'); // The target item to comment on $target = $this->input->get('target_user', 0, 'int'); if (!$content) { $this->set('code', '403'); $this->set('message', JText::_('Please enter some contents.')); return parent::display(); } // Load up story library $story = FD::story(SOCIAL_TYPE_USER); // Create the story $args = array('content' => $content, 'contextIds' => $target, 'contextType' => SOCIAL_TYPE_STORY, 'actorId' => $userId); $result = $story->create($args); $this->set('status', 1); parent::display(); }
/** * Displays a list of notifications a user has. * * @since 1.0 * @access public */ public function display($tpl = null) { // Unauthorized users should not be allowed to access this page. FD::requireLogin(); // Check for user profile completeness FD::checkCompleteProfile(); // Get the current logged in user. $user = FD::user(); // Set the page title FD::page()->title(JText::_('COM_EASYSOCIAL_PAGE_TITLE_ALL_NOTIFICATIONS')); // Set breadcrumbs FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_ALL_NOTIFICATIONS')); $config = FD::config(); $paginationLimit = $config->get('notifications.general.pagination'); // Get notifications model. $options = array('target_id' => $user->id, 'target_type' => SOCIAL_TYPE_USER, 'group' => SOCIAL_NOTIFICATION_GROUP_ITEMS, 'limit' => $paginationLimit); $lib = FD::notification(); $items = $lib->getItems($options); $this->set('items', $items); $this->set('startlimit', $paginationLimit); parent::display('site/notifications/default'); }
/** * 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'); }
/** * Responsible to output the contents wrapped within the photo view. * * @since 1.0 * @access public * @param string * @return */ public function output(SocialPhoto $lib, $content = '') { // Get the current photo table $photo = $lib->data; // Determines if the user can really view the photo's from the current album. if (!$lib->albumViewable()) { // If the user can't view the entire album, just show a single photo $photos = array($photo); } else { $photos = $lib->getAlbumPhotos(array('limit' => 2048)); } $this->set('id', $photo->id); $this->set('album', $lib->albumLib->data); $this->set('photos', $photos); $this->set('lib', $lib); $this->set('content', $content); $this->set('uuid', uniqid()); echo parent::display('site/photos/default'); }
/** * Responsible to output the activity log for a user * * @access public * @return null */ public function display($tpl = null) { // Unauthorized users should not be allowed to access this page. FD::requireLogin(); // Check for user profile completeness FD::checkCompleteProfile(); // Get the necessary attributes from the request $filterType = $this->input->get('type', 'all', 'default'); $active = $filterType; $context = SOCIAL_STREAM_CONTEXT_TYPE_ALL; // Default title $title = JText::sprintf('COM_EASYSOCIAL_ACTIVITY_ITEM_TITLE', ucfirst($filterType)); if ($filterType == 'all') { $title = JText::_('COM_EASYSOCIAL_ACTIVITY_YOUR_LOGS'); } if ($filterType == 'hidden') { $title = JText::_('COM_EASYSOCIAL_ACTIVITY_YOUR_HIDDEN_ACTIVITIES'); } if ($filterType == 'hiddenapp') { $title = JText::_('COM_EASYSOCIAL_ACTIVITY_YOUR_HIDDEN_APPS'); } if ($filterType == 'hiddenactor') { $title = JText::_('COM_EASYSOCIAL_ACTIVITY_YOUR_HIDDEN_ACTORS'); } // Set the page title $this->page->title($title); // Set the page breadcrumb $this->page->breadcrumb($title); if ($filterType != 'all' && $filterType != 'hidden' && $filterType != 'hiddenapp' && $filterType != 'hiddenactor') { $context = $filterType; $filterType = 'all'; } // Load up activities model $model = FD::model('Activities'); if ($filterType == 'hiddenapp') { $activities = $model->getHiddenApps($this->my->id); $nextLimit = $model->getNextLimit('0'); } else { if ($filterType == 'hiddenactor') { $activities = $model->getHiddenActors($this->my->id); $nextLimit = $model->getNextLimit('0'); } else { // Retrieve user activities. $stream = FD::stream(); $options = array('uId' => $this->my->id, 'context' => $context, 'filter' => $filterType); $activities = $stream->getActivityLogs($options); $nextLimit = $stream->getActivityNextLimit(); } } // Get a list of apps $result = $model->getApps(); $apps = array(); foreach ($result as $app) { if (!$app->hasActivityLog()) { continue; } $app->favicon = ''; $app->image = $app->getIcon(); $favicon = $app->getFavIcon(); if ($favicon) { $app->favicon = $favicon; } // Load the app's css $app->loadCss(); $apps[] = $app; } $this->set('active', $active); $this->set('title', $title); $this->set('apps', $apps); $this->set('activities', $activities); $this->set('nextlimit', $nextLimit); $this->set('filtertype', $filterType); echo parent::display('site/activities/default'); }
/** * Displays the advanced search form * * @since 1.0 * @access public */ public function advanced($tpl = null) { // Check for user profile completeness FD::checkCompleteProfile(); // Set the page title FD::page()->title(JText::_('COM_EASYSOCIAL_PAGE_TITLE_ADVANCED_SEARCH')); // Set the page breadcrumb FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_ADVANCED_SEARCH')); // Get current logged in user. $my = FD::user(); $config = FD::config(); // What is this? - this is advanced search filter id. $fid = JRequest::getInt('fid', 0); // Get filters $model = FD::model('Search'); $filters = $model->getFilters($my->id); // Load up advanced search library $library = FD::get('AdvancedSearch'); // default values // Get values from posted data $match = JRequest::getVar('matchType', 'all'); $avatarOnly = JRequest::getInt('avatarOnly', 0); $sort = JRequest::getVar('sort', $config->get('users.advancedsearch.sorting', 'default')); // Get values from posted data $values = array(); $values['criterias'] = JRequest::getVar('criterias'); $values['datakeys'] = JRequest::getVar('datakeys'); $values['operators'] = JRequest::getVar('operators'); $values['conditions'] = JRequest::getVar('conditions'); $values['match'] = $match; $values['avatarOnly'] = $avatarOnly; $values['sort'] = $sort; // echo '<pre>';print_r( $values );echo '</pre>';exit; // Default values $results = null; $total = 0; $nextlimit = null; $criteriaHTML = ''; if ($fid && empty($values['criterias'])) { // we need to load the data from db and do the search based on the saved filter. $filter = FD::table('SearchFilter'); $filter->load($fid); // data saved as json format. so we need to decode it. $dataFilter = FD::json()->decode($filter->filter); // override with the one from db. $values['criterias'] = isset($dataFilter->{'criterias[]'}) ? $dataFilter->{'criterias[]'} : ''; $values['datakeys'] = isset($dataFilter->{'datakeys[]'}) ? $dataFilter->{'datakeys[]'} : ''; $values['operators'] = isset($dataFilter->{'operators[]'}) ? $dataFilter->{'operators[]'} : ''; $values['conditions'] = isset($dataFilter->{'conditions[]'}) ? $dataFilter->{'conditions[]'} : ''; // we need check if the item passed in is array or not. if not, make it an array. if (!is_array($values['criterias'])) { $values['criterias'] = array($values['criterias']); } if (!is_array($values['datakeys'])) { $values['datakeys'] = array($values['datakeys']); } if (!is_array($values['operators'])) { $values['operators'] = array($values['operators']); } if (!is_array($values['conditions'])) { $values['conditions'] = array($values['conditions']); } $values['match'] = isset($dataFilter->matchType) ? $dataFilter->matchType : 'all'; $values['avatarOnly'] = isset($dataFilter->avatarOnly) ? true : false; $values['sort'] = isset($dataFilter->sort) ? $dataFilter->sort : $config->get('users.advancedsearch.sorting', 'default'); $match = $values['match']; $avatarOnly = $values['avatarOnly']; $sort = $values['sort']; } $displayOptions = array(); // If there are criterias, we know the user is making a post request to search if ($values['criterias']) { $results = $library->search($values); $displayOptions = $library->getDisplayOptions(); $total = $library->getTotal(); $nextlimit = $library->getNextLimit(); } // Get search criteria output $criteriaHTML = $library->getCriteriaHTML(array(), $values); if (!$criteriaHTML) { $criteriaHTML = $library->getCriteriaHTML(array()); } $this->set('criteriaHTML', $criteriaHTML); $this->set('match', $match); $this->set('avatarOnly', $avatarOnly); $this->set('sort', $sort); $this->set('results', $results); $this->set('total', $total); $this->set('nextlimit', $nextlimit); $this->set('filters', $filters); $this->set('fid', $fid); $this->set('displayOptions', $displayOptions); echo parent::display('site/advancedsearch/user/default'); }
/** * 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'); }
/** * 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'); // // 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 ); $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 = FD::get('toolbar')->getRedirectionUrl($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'); }
/** * Post process after a user has been rejected * * @since 1.0 * @access public */ public function rejectUser() { FD::info()->set($this->getMessage()); echo parent::display('site/registration/moderation.rejected'); }
/** * Displays a restricted page * * @since 1.0 * @access public * @param int The user's id */ public function restricted($user) { $this->set('showProfileHeader', true); $this->set('user', $user); echo parent::display('site/followers/restricted'); }
public function display($tpl = null) { $auth = $this->input->getString('auth'); // Get the current logged in user's information $model = FD::model('Users'); $id = $model->getUserIdFromAuth($auth); $userId = $this->input->getInt('userid'); $limit = $this->input->getInt('limit'); $startlimit = $this->input->getInt('startlimit'); $filter = $this->input->getString('filter', 'me'); // If user id is not passed in, return logged in user if (!$userId) { $userId = $id; } // If we still can't find user's details, throw an error if (!$userId || !$auth) { $this->set('code', 403); $this->set('message', JText::_('Invalid user id provided.')); return parent::display(); } // Get the stream library $stream = FD::stream(); $options = array('userId' => $userId, 'startlimit' => $startlimit, 'limi' => $limit); switch ($filter) { case 'everyone': $options['guest'] = true; $options['ignoreUser'] = true; break; case 'following': case 'follow': $options['type'] = 'follow'; break; case 'bookmarks': $options['guest'] = true; $options['type'] = 'bookmarks'; case 'me': // nohting to set break; case 'hashtag': $tag = $this->input->getString('tag', ''); $options['tag'] = $tag; break; default: $options['context'] = $filter; break; } // $stream->get(array('userId' => $userId, 'startlimit' => $startlimit, 'limit' => $limit, 'type' => $filter)); $stream->get($options); $result = $stream->toArray(); $data = new stdClass(); $data->items = array(); if (!$result) { $this->set('items', array()); } // Set the url to this listing $data->url = FRoute::stream(); // Follows the spec of http://activitystrea.ms/specs/json/1.0/ foreach ($result as $row) { $item = new stdClass(); // Set the stream title $item->title = strip_tags($row->title); // Set the stream content $item->raw_content = $row->content_raw; $item->content = $row->content; // Set the publish date $item->published = $row->created->toMySQL(); // Set the generator $item->generator = new stdClass(); $item->generator->url = JURI::root(); // Set the generator $item->provider = new stdClass(); $item->provider->url = JURI::root(); // Set the verb $item->verb = $row->verb; // Set the actor $item->actor = new stdClass(); $item->actor->id = $row->actor->id; $item->actor->url = $row->actor->getPermalink(); $item->actor->objectType = 'person'; // Set actors image $item->actor->image = new stdClass(); $item->actor->image->url = $row->actor->getAvatar(); $item->actor->image->width = SOCIAL_AVATAR_MEDIUM_WIDTH; $item->actor->image->height = SOCIAL_AVATAR_MEDIUM_HEIGHT; // Set the actors name $item->actor->displayName = $row->actor->getName(); // These properties onwards are not activity stream specs $item->icon = $row->fonticon; // Like id should contain the exact item id $item->likes = new stdClass(); if (!is_bool($row->likes)) { $item->likes->uid = $row->likes->uid; $item->likes->element = $row->likes->element; $item->likes->group = $row->likes->group; $item->likes->verb = $row->likes->verb; $item->likes->hasLiked = $row->likes->hasLiked(); $item->likes->stream_id = $row->likes->stream_id; // Get the total likes $item->likes->total = $row->likes->getCount(); } $item->comments = new stdClass(); if (!is_bool($row->comments)) { $item->comments->uid = $row->comments->uid; $item->comments->element = $row->comments->element; $item->comments->group = $row->comments->group; $item->comments->verb = $row->comments->verb; $item->comments->stream_id = $row->comments->stream_id; // Get the total likes $item->comments->total = $row->comments->getCount(); } // Set the lapsed time $item->lapsed = $row->lapsed; // set the if this stream is mini mode or not. // mini mode should not have any actions such as - likes, comments, share and etc. $item->mini = $row->display == SOCIAL_STREAM_DISPLAY_MINI ? true : false; $data->items[] = $item; } $this->set('data', $data); parent::display(); }
/** * Displays the invite friends form * * @since 1.3 * @access public * @param string * @return */ public function invite() { // Requires user to be logged into the site FD::requireLogin(); // Ensure that invites are enabled if (!$this->config->get('friends.invites.enabled')) { return JError::raiseError(500, JText::_('COM_EASYSOCIAL_FEATURE_NOT_AVAILABLE')); } $editor = JFactory::getEditor(); $this->set('editor', $editor); parent::display('site/friends/form.invite'); }
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'); }
/** * Deprecated in 1.3. Use layout=item&type=info instead. * Displays the information about a group. * * @since 1.2 * @access public * @param string * @return */ public function info() { // Check if this feature is enabled. $this->checkFeature(); $id = $this->input->get('id', 0, 'int'); $group = FD::group($id); // Check if the group is valid if (!$id || !$group->id) { $this->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_INVALID_GROUP_ID'), SOCIAL_MSG_ERROR); FD::info()->set($this->getMessage()); return $this->redirect(FRoute::dashboard(array(), false)); } // Deprecated and just redirect to the item page with type=info return $this->redirect(FRoute::groups(array('layout' => 'item', 'type' => 'info', 'id' => $group->getAlias()))); // Check if the group is accessible if ($group->type == SOCIAL_GROUPS_INVITE_TYPE && !$group->isMember()) { $this->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_NOT_ALLOWED'), SOCIAL_MSG_ERROR); FD::info()->set($this->getMessage()); return $this->redirect(FRoute::dashboard(array(), false)); } // Set the page title. FD::page()->title($group->getName()); // Set the breadcrumbs FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_GROUPS_PAGE_TITLE'), FRoute::groups()); FD::page()->breadcrumb($group->getName()); // Determine if the user shouldn't be able to view the group's content if ($group->type == SOCIAL_GROUPS_PRIVATE_TYPE && !$group->isMember()) { // Display private group contents; return; } // Load language file from back end. FD::language()->loadAdmin(); // Get the custom fields steps. // Get the steps model $stepsModel = FD::model('Steps'); $steps = $stepsModel->getSteps($group->category_id, SOCIAL_TYPE_CLUSTERS, SOCIAL_PROFILES_VIEW_DISPLAY); // Get the fields library $fields = FD::fields(); // Enforce privacy to be false for groups $fields->init(array('privacy' => false)); $fieldsModel = FD::model('Fields'); $incomplete = false; // Get the custom fields for each of the steps. foreach ($steps as &$step) { $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $group->id, 'dataType' => SOCIAL_TYPE_GROUP, 'visible' => SOCIAL_PROFILES_VIEW_DISPLAY)); // Trigger onDisplay for custom fields. if (!empty($step->fields)) { $args = array($group); $fields->trigger('onDisplay', SOCIAL_FIELDS_GROUP_GROUP, $step->fields, $args); } $step->hide = true; foreach ($step->fields as $field) { // If the key output is set but is empty, means that the field does have an output, but there is no data to show // In this case, we mark this profile as incomplete // Incomplete profile will have a info displayed above saying "complete your profile now" // If incomplete has been marked true, then no point marking it as true again // We don't break from the loop here because there is other checking going on if (isset($field->output) && empty($field->output) && $incomplete === false) { $incomplete = true; } // As long as one of the field in the step has an output, then this step shouldn't be hidden // If step has been marked false, then no point marking it as false again // We don't break from the loop here because there is other checking going on if (!empty($field->output) && $step->hide === true) { $step->hide = false; } } } // Set template variables $this->set('incomplete', $incomplete); $this->set('steps', $steps); $this->set('group', $group); parent::display('site/groups/info'); }
/** * When a conversation is marked as read. * * @since 1.0 * @access public * @param null */ public function read() { // Prevent unauthorized access. FD::requireLogin(); // Check for user profile completeness FD::checkCompleteProfile(); // Get the conversation id $id = $this->input->get('id', 0, 'int'); $conversation = FD::table('Conversation'); $loaded = $conversation->load($id); // Check if the conversation id provided is valid. if (!$id || !$loaded) { $this->info->set(JText::_('COM_EASYSOCIAL_CONVERSATIONS_ERROR_INVALID_ID'), SOCIAL_MSG_ERROR); $url = FRoute::conversations(array(), false); return $this->redirect($url); } // Check if the user has access to read this discussion. if (!$conversation->isReadable($this->my->id)) { $this->info->set(JText::_('COM_EASYSOCIAL_CONVERSATIONS_NOT_ALLOWED_TO_READ'), SOCIAL_MSG_ERROR); $url = FRoute::conversations(array(), false); return $this->redirect($url); } // Retrieve conversations model. $model = FD::model('Conversations'); // Always reset the limistart to 0 so that when the page refresh, system will not get the 'previous' saved limitstart. $model->setState('limitstart', 0); // Get list of files in this conversation $filesModel = FD::model('Files'); // Get a list of all the message ids from this conversation. $files = $filesModel->getFiles($model->getMessageIds($conversation->id), SOCIAL_TYPE_CONVERSATIONS); // Get a list of participants for this particular conversation except myself. $participants = $model->getParticipants($conversation->id); // this flag is to indicate if there is only one participant and the participant is a ESAD. $isESADuser = false; if (count($participants) == 2) { foreach ($participants as $pUser) { if ($pUser->id != $this->my->id && !$pUser->hasCommunityAccess()) { $isESADuser = true; } } } // Fetch a list of messages for this particular conversation $messages = $model->setLimit($this->themeConfig->get('messages_limit'))->getMessages($conversation->id, $this->my->id); // Beautify the names $participantNames = FD::string()->namesToStream($participants, false, 3, false); $title = JText::sprintf('COM_EASYSOCIAL_PAGE_TITLE_CONVERSATIONS_READ', $participantNames); // Set title FD::page()->title($title); // Set breadcrumbs FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_CONVERSATIONS_INBOX'), FRoute::conversations()); FD::page()->breadcrumb($title); // @trigger: onPrepareConversations $dispatcher = FD::dispatcher(); $args = array(&$messages); $dispatcher->trigger(SOCIAL_TYPE_USER, 'onPrepareConversations', $args); // Get pagination $pagination = $model->getPagination(); // Determine if load previous messages should appear. $loadPrevious = $pagination->total > $pagination->limit; // Mark conversation as read because the viewer is already reading the conversation. $conversation->markAsRead($this->my->id); // Get total number of messages sent today $totalSentDaily = $model->getTotalSentDaily($this->my->id); // @points: conversation.read // Assign points when user reads a conversation $points = FD::points(); $points->assign('conversation.read', 'com_easysocial', $this->my->id); $this->set('files', $files); $this->set('totalSentDaily', $totalSentDaily); $this->set('loadPrevious', $loadPrevious); $this->set('conversation', $conversation); $this->set('participants', $participants); $this->set('messages', $messages); $this->set('pagination', $pagination); $this->set('isESADuser', $isESADuser); echo parent::display('site/conversations/read'); }
/** * 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'); }
/** * Edit privacy form * * @since 1.0 * @access public * @param string * @return */ public function editPrivacy() { // User needs to be logged in FD::requireLogin(); // Check for user profile completeness FD::checkCompleteProfile(); // Get the current logged in user. $my = FD::user(); // Get user's privacy $privacyLib = FD::privacy($my->id); $result = $privacyLib->getData(); // Set page title FD::page()->title(JText::_('COM_EASYSOCIAL_PAGE_TITLE_PRIVACY_SETTINGS')); // Set the page breadcrumb FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_PROFILE'), FRoute::profile()); FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_PRIVACY_SETTINGS')); $privacy = array(); // Update the privacy data with proper properties. foreach ($result as $group => $items) { // We do not want to show field privacy rules here because it does not make sense for user to set a default value // Most of the fields only have 1 and it is set in Edit Profile page if ($group === 'field') { continue; } foreach ($items as &$item) { $rule = strtoupper(JString::str_ireplace('.', '_', $item->rule)); $groupKey = strtoupper($group); $item->groupKey = $groupKey; $item->label = JText::_('COM_EASYSOCIAL_PRIVACY_LABEL_' . $groupKey . '_' . $rule); $item->tips = JText::_('COM_EASYSOCIAL_PRIVACY_TIPS_' . $groupKey . '_' . $rule); } $privacy[$group] = $items; } // Get a list of blocked users for this user $model = FD::model('Blocks'); $blocked = $model->getBlockedUsers($this->my->id); $this->set('blocked', $blocked); $this->set('privacy', $privacy); parent::display('site/profile/default.edit.privacy'); }
function register($tpl = null) { parent::display('site.oauth.registration_facebook'); }
/** * Some desc * * @since 1.0 * @access public * @param string * @return */ public function allowed($uid, $type) { if ($type == SOCIAL_TYPE_GROUP) { $group = FD::group($uid); if (!$group->id) { return JError::raiseError(JText::_('COM_EASYSOCIAL_GROUPS_GROUP_NOT_FOUND'), 404); } if ($group->isOpen()) { return true; } if ($group->isClosed() && !$group->isMember()) { // Display private info $this->set('group', $group); parent::display('site/groups/restricted'); return false; } } // @TODO: Other user checks. return true; }
/** * Handle the output after a reply is posted. */ public function reply($data) { echo FD::json()->encode($data); parent::display(); }
/** * Displays the albums a user has * * @since 1.0 * @access public * @author Mark Lee <*****@*****.**> */ public function output($uid, $type, $content = '', $album = false) { // Load up the albums library $lib = FD::albums($uid, $type, $album ? $album->id : null); // If no layout was given, load recent layout $layout = $this->input->get('layout', 'recent', 'cmd'); // Browser menu $id = $this->input->get('id', '', 'int'); // Load up the model $model = FD::model('Albums'); // Get a list of core albums $coreAlbums = $model->getAlbums($lib->uid, $lib->type, array('coreAlbumsOnly' => true)); // Get a list of normal albums $options = array(); $options['core'] = false; $options['order'] = 'a.assigned_date'; $options['direction'] = 'DESC'; $options['privacy'] = true; $albums = $model->getAlbums($lib->uid, $lib->type, $options); // Browser frame // Get the user alias $userAlias = ''; // $userAlias = $user->getAlias(); $this->set('lib', $lib); $this->set('userAlias', $userAlias); $this->set('id', $id); $this->set('coreAlbums', $coreAlbums); $this->set('albums', $albums); $this->set('content', $content); $this->set('uuid', uniqid()); $this->set('layout', $layout); echo parent::display('site/albums/default'); }