function getJoomlaAvatar($registerType, $profileLink, $user) { $html = ''; if ($registerType == 'jomsocial' && file_exists(JPATH_BASE . '/components/com_community/libraries/core.php')) { $jsUser = CFactory::getUser($user->id); $avatarURL = $jsUser->getThumbAvatar(); $html = $this->getAvatarHtml($avatarURL, $profileLink, "_self"); } else { if ($registerType == 'easysocial' && file_exists(JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php')) { $avatarURL = Foundry::user($user->id)->getAvatar(); $html = $this->getAvatarHtml($avatarURL, $profileLink, "_self"); } else { if ($registerType == "communitybuilder" && file_exists(JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php')) { include_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php'; $cbUser = CBuser::getInstance($user->id); $avatar = $cbUser->getField('avatar', null, 'csv', 'none', 'list'); $html = $this->getAvatarHtml($avatar, $profileLink, "_self"); } else { if ($registerType == 'kunena' && JFolder::exists(JPATH_SITE . '/components/com_kunena')) { $db = JFactory::getDbo(); $query = "SELECT avatar FROM #__kunena_users WHERE userid = " . $user->id; $db->setQuery($query); $avatarURL = $db->loadResult(); if ($avatarURL) { $avatarURL = JRoute::_('media/kunena/avatars/' . $avatarURL, false); } $html = $this->getAvatarHtml($avatarURL, $profileLink, "_self"); } } } } return $html; }
/** * Displays the application output in the canvas. * * @param int The user id that is currently being viewed. * @param string layout path * @since 1.0 * @access public */ public function display($userId = null, $docType = null) { // Get the user params $params = $this->getUserParams($userId); // Get the app params $appParams = $this->app->getParams(); // Get the blog model $total = (int) $params->get('total', $appParams->get('total', 5)); $pin_width = (int) $appParams->get('pin_width', 145); $pin_padding = (int) $appParams->get('pin_padding', 3); // Get list of all products created by the user on the site. $input = JFactory::getApplication()->input; $storeid = $input->get('storeid', '', 'INT'); $model = $this->getModel('q2cmyproducts'); $products = $model->getItems($userId, $total, $storeid); $productsCount = $model->getProductsCount($userId, $storeid); $user = Foundry::user($userId); // Get store list of user require_once JPATH_ROOT . '/components/com_quick2cart/helpers/storeHelper.php'; $storeHelper = new storeHelper(); $storelist = $storeHelper->getUserStore($userId); $this->set('user', $user); $this->set('userId', $userId); $this->set('total', $total); $this->set('pin_width', $pin_width); $this->set('pin_padding', $pin_padding); $this->set('products', $products); $this->set('productsCount', $productsCount); $this->set('storelists', $storelist); echo parent::display('profile/default'); }
/** * Shares a story through 3rd party oauth clients * * @param TableBlog $blog A blog table object * @param string $type The type of oauth client * * @return boolean True on success and false otherwise. **/ public function getHTML($bloggerid = "") { $html = ''; $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); if ($config->get('main_jomsocial_messaging') && $my->id != $bloggerid) { $file_core = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; $file_messaging = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'messaging.php'; if (file_exists($file_core) && file_exists($file_messaging)) { require_once $file_core; require_once $file_messaging; CMessaging::load(); $html = '<a href="javascript:void(0);" onclick="' . CMessaging::getPopup($bloggerid) . '" class="author-message" title="' . JText::_('COM_EASYBLOG_MESSAGE_AUTHOR') . '"><span>' . JText::_('COM_EASYBLOG_MESSAGE_AUTHOR') . '</span></a>'; } } $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('integrations_easysocial_conversations') && $easysocial->exists() && $my->id != $bloggerid) { $easysocial->init(); $user = Foundry::user($bloggerid); $theme = new CodeThemes(); $theme->set('user', $user); $html = $theme->fetch('easysocial.conversation.php'); } return $html; }
function onPromoteData($id) { $db = JFactory::getDBO(); $Itemid = JRequest::getInt('Itemid'); $eschk = $this->_chkextension(); if (!empty($eschk)) { /*$query = "SELECT cf.id FROM #__community_fields as cf LEFT JOIN #__community_fields_values AS cfv ON cfv.field_id=cf.id WHERE cf.name like '%About me%' AND cfv.user_id=".$id; $db->setQuery($query); $fieldid = $db->loadresult(); */ $query = "SELECT u.name AS title\n\t\t\t\t\t\tFROM #__users AS u\n\t\t\t\t\t\tWHERE u.id =" . $id; $db->setQuery($query); $previewdata = $db->loadobjectlist(); //if($fieldid) //$query .= " AND cfv.field_id=".$fieldid; require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; $user = Foundry::user($id); //easysocial data for user $activitysocialintegrationprofiledata = new activitysocialintegrationprofiledata(); $img_path = $activitysocialintegrationprofiledata->getUserAvatar('EasySocial', JFactory::getUser($id)); $link = $activitysocialintegrationprofiledata->getUserProfileUrl('EasySocial', $id); $previewdata[0]->image = $img_path; $previewdata[0]->url = JUri::root() . substr(JRoute::_($link, false), strlen(JUri::base(true)) + 1); $previewdata[0]->bodytext = ''; return $previewdata; } else { return ''; } }
public function getLink() { $user = Foundry::user($this->profile->id); if ($this->komentoprofile) { return JRoute::_('index.php?option=com_komento&view=profile&id=' . $this->profile->id); } return $user->getPermalink(); }
function _getAvatar($profile) { $easysocial = EasyBlogHelper::getHelper('EasySocial'); $easysocial->init(); $user = Foundry::user($profile->id); $avatar = new stdClass(); $avatar->link = $user->getAvatar(); return $avatar; }
public function getAvatar($profile) { $easysocial = EB::easysocial(); if (!$easysocial->exists()) { return false; } // Load the user $user = Foundry::user($profile->id); return $user->getAvatar(); }
public function isValidNode() { if (!$this->group->id) { $this->lib->setError(JText::_('Sorry, but the group id provided is not a valid group id.')); return false; } if (Foundry::user()->id != $this->group->creator_uid) { if (FD::user()->isBlockedBy($this->group->creator_uid)) { return JError::raiseError(404, JText::_('COM_EASYSOCIAL_GROUPS_GROUP_NOT_FOUND')); } } return true; }
public function getHTML($bloggerid = "") { $config = EB::config(); $html = ''; $easysocial = EB::easysocial(); if ($config->get('integrations_easysocial_badges') && $easysocial->exists()) { $easysocial->init(); $user = Foundry::user($bloggerid); $badges = $user->getBadges(); $theme = EB::template(); $theme->set('badges', $badges); $html = $theme->output('site/easysocial/achievements'); } return $html; }
public function getHTML($bloggerid = "") { $config = EasyBlogHelper::getConfig(); $html = ''; $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('integrations_easysocial_badges') && $easysocial->exists()) { $easysocial->init(); $user = Foundry::user($bloggerid); $badges = $user->getBadges(); $theme = new CodeThemes(); $theme->set('badges', $badges); $html = $theme->fetch('easysocial.achievements.php'); } return $html; }
/** * Display the list of photos a user has uploaded * * @since 1.0 * @access public * @param string * @return */ public function getAlbums($user) { $params = $this->getUserParams($user->id); $appParam = $this->app->getParams(); $albums = array(); // Load up albums model $model = FD::model('Albums'); $sorting = $params->get('ordering', $appParam->get('ordering', 'latest')); $options = array('order' => 'assigned_date', 'direction' => $sorting == 'latest' ? 'desc' : 'asc'); $options['excludeblocked'] = 1; // privacy lib $privacy = Foundry::privacy(Foundry::user()->id); $results = $model->getAlbums($user->id, SOCIAL_TYPE_USER, $options); if ($results) { foreach ($results as $item) { // we need to check the photo's album privacy to see if user allow to view or not. if ($privacy->validate('albums.view', $item->id, SOCIAL_TYPE_ALBUM, $item->user_id)) { $albums[] = $item; } } } if (empty($albums)) { return; } // If sorting is set to random, then we shuffle the albums if ($sorting == 'random') { shuffle($albums); } // since we are getting all albums belong to user, // we do not need to run another query to count the albums. // just do array count will be fine. // $total = $model->getTotalAlbums($options); $total = count($albums); $limit = $params->get('limit', $appParam->get('limit', 10)); $this->set('total', $total); $this->set('appParams', $appParam); $this->set('params', $params); $this->set('user', $user); $this->set('albums', $albums); $this->set('limit', $limit); $this->set('privacy', $privacy); return parent::display('widgets/profile/albums'); }
/** * * * @since 1.2 * @access public * @param string * @return */ public function execute($item) { // Get comment participants $model = FD::model('Comments'); $users = $model->getParticipants($item->uid, $item->context_type); // Include the actor of the stream item as the recipient // Exclude myself from the list of users. // Ensure that the values are unique $users[] = $item->actor_id; $users = array_values(array_unique(array_diff($users, array(Foundry::user()->id)))); // Convert the names to stream-ish $names = Foundry::string()->namesToNotifications($users); $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR'; // By default content is always empty; $content = ''; // Only show the content when there is only 1 item if (count($users) == 1 && !empty($item->content)) { $content = JString::substr(strip_tags($item->content), 0, 30); if (JString::strlen($item->content) > 30) { $content .= JText::_('COM_EASYSOCIAL_ELLIPSES'); } } // Load the milestone $milestone = FD::table('Milestone'); $state = $milestone->load($item->uid); if (!$state) { return; } // We need to generate the notification message differently for the author of the item and the recipients of the item. if ($milestone->owner_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) { $item->title = JText::sprintf('APP_GROUP_TASKS_USER_COMMENTED_ON_YOUR_MILESTONE', $names); return $item; } if ($milestone->owner_id == $item->actor_id && count($users) == 1) { $item->title = JText::sprintf('APP_GROUP_TASKS_USER_COMMENTED_ON_THEIR_MILESTONE', $names); return $item; } // This is for 3rd party viewers $item->title = JText::sprintf('APP_GROUP_TASKS_USER_COMMENTED_ON_USERS_MILESTONE', $names, Foundry::user($milestone->owner_id)->getName()); return $item; }
public function getHTML($bloggerid = "") { $html = ''; $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); // We don't want to show the link to the same user if ($my->id == $bloggerid) { return; } if ($config->get('main_jomsocial_friends')) { $file_core = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; $file_messaging = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'friends.php'; jimport('joomla.filesystem.file'); if (JFile::exists($file_core) && JFile::exists($file_messaging)) { require_once $file_core; require_once $file_messaging; $user = CFactory::getUser(); $model = CFactory::getModel('Friends'); $friends = $model->getFriendIds($bloggerid); if (!in_array($my->id, $friends)) { CFriends::load(); $html = '<a href="javascript:void(0);" onclick="' . CFriends::getPopup($bloggerid) . '" class="author-friend"><span>' . JText::_('COM_EASYBLOG_ADD_FRIEND') . '</span></a>'; } } } $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('integrations_easysocial_friends') && $easysocial->exists()) { $user = Foundry::user($bloggerid); // Check if the user is friends with the current viewer. if ($user->isFriends($my->id)) { return; } $easysocial->init(); $theme = new CodeThemes(); $theme->set('id', $bloggerid); $html = $theme->fetch('easysocial.friends.php'); } return $html; }
public function getHTML($bloggerid = "") { $html = ''; $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); // We don't want to show the link to the same user if ($my->id == $bloggerid) { return; } $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('integrations_easysocial_followers') && $easysocial->exists()) { $user = Foundry::user($bloggerid); $followed = $user->isFollowed($my->id); if ($followed) { return; } $easysocial->init(); $theme = new CodeThemes(); $theme->set('id', $bloggerid); $html = $theme->fetch('easysocial.followers.php'); } return $html; }
/** * Retrieves a list of participants in this conversation. * * @since 1.0 * @access public * @param Array (Optional) $exclusions An array of user's node id that should be excluded. * * @return Array An array of SocialTablePeople objects containing all the participants. */ public function getParticipants($exclusions = array()) { static $_cache = array(); $key = $this->id . '_'; if (is_array($exclusions)) { $key .= implode('_', $exclusions); } else { $key .= $exclusions; } if (!isset($_cache[$key])) { $model = FD::model('Conversations'); $result = $model->getParticipants($this->id, $exclusions); if (!$result) { $creator = Foundry::user($this->created_by); $result = array($creator); } $_cache[$key] = $result; } return $_cache[$key]; }
private function getUniqueUsers($item, $users, $ownerId) { // Exclude myself from the list of users. $index = array_search(Foundry::user()->id, $users); if ($index !== false) { unset($users[$index]); $users = array_values($users); } // Add the author of the photo as the recipient if ($item->actor_id != $ownerId) { $users[] = $ownerId; } // Ensure that the values are unique $users = array_unique($users); $users = array_values($users); // Exclude the stream creator and the current logged in user from the list. if ($users) { for ($i = 0; $i < count($users); $i++) { if ($users[$i] == Foundry::user()->id) { unset($users[$i]); } } $users = array_values($users); } return $users; }
public static function get_user_points($system, $userid = 0) { if (!$userid) { return 0; } $app = JFactory::getApplication(); switch ($system) { case 'cjblog': $api = JPATH_ROOT . '/components/com_cjblog/api.php'; if (file_exists($api)) { include_once $api; $profile = CjBlogApi::get_user_profile($userid); if (!empty($profile)) { return $profile['points']; } } break; case 'aup': $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (file_exists($api_AUP)) { require_once $api_AUP; $profile = AlphaUserPointsHelper::getUserInfo('', $userid); if (!empty($profile)) { return $profile->points; } } break; case 'jomsocial': $db = JFactory::getDbo(); $query = 'select points from #__community_users where userid=' . (int) $userid; $db->setQuery($query); return (int) $db->loadResult(); case 'easysocial': require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; $my = Foundry::user($userid); $points = $my->getPoints(); return $points; default: return 0; } return -1; }
public function sendNotification(JUser $sender, JUser $receiver, $content = "JS Notification", $options = array()) { $recipient[] = $receiver->id; // If you do not want to send email, $emailOptions should be set to false // $emailOptions - An array of options to define in the mail // Email template $emailOptions = false; // If you do not want to send system notifications, set this to false. // $systemOptions - The internal system notifications // System notification template $myUser = Foundry::user($receiver->id); $systemOptions['url'] = JRoute::_($myUser->getPermalink()); $title = $myUser->getName() . " " . $notification_msg; Foundry::notify($options['command'], $recipient, $emailOptions, $systemOptions); }
function getEasySocialUserAvatar($userid) { require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; $user = Foundry::user($userid); $uimage = $user->getAvatar(); return $uimage; }
/** * Default method to display the group entry page. * * @since 1.2 * @access public * @author Mark Lee <*****@*****.**> */ public function item($tpl = null) { // Check if this feature is enabled. $this->checkFeature(); // Check for user profile completeness FD::checkCompleteProfile(); $id = $this->input->get('id', 0, 'int'); $group = FD::group($id); // Check if the group is valid if (!$id || !$group->id) { return JError::raiseError(404, JText::_('COM_EASYSOCIAL_GROUPS_GROUP_NOT_FOUND')); } // Ensure that the group is published if (!$group->isPublished()) { $this->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_UNAVAILABLE'), SOCIAL_MSG_ERROR); FD::info()->set($this->getMessage()); return $this->redirect(FRoute::dashboard(array(), false)); } // Check if the group is accessible if ($group->isInviteOnly() && !$group->isMember() && !$group->isInvited() && !$this->my->isSiteAdmin()) { $this->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_NOT_ALLOWED'), SOCIAL_MSG_ERROR); FD::info()->set($this->getMessage()); return $this->redirect(FRoute::dashboard(array(), false)); } if (Foundry::user()->id != $group->creator_uid) { if (FD::user()->isBlockedBy($group->creator_uid)) { return JError::raiseError(404, JText::_('COM_EASYSOCIAL_GROUPS_GROUP_NOT_FOUND')); } } // 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()); $this->set('group', $group); if (($group->isInviteOnly() || $group->isClosed()) && !$group->isMember() && !$this->my->isSiteAdmin()) { // Display private group contents; return parent::display('site/groups/restricted'); } // Update the hit counter $group->hit(); // Get the start limit $startlimit = $this->input->get('limitstart', 0, 'int'); // Get the context $context = $this->input->get('app', '', 'cmd'); $this->set('context', $context); // Get group's filter for this logged in user. $filters = $group->getFilters($this->my->id); $this->set('filters', $filters); // Get a list of application filters $streamModel = FD::model('Stream'); $appFilters = $streamModel->getAppFilters(SOCIAL_TYPE_GROUP); $this->set('appFilters', $appFilters); // Load list of apps for this group $model = FD::model('Apps'); // Retrieve apps $apps = $model->getGroupApps($group->id); // We need to load the app's own css file. foreach ($apps as $app) { // Load app's css $app->loadCss(); } $this->set('apps', $apps); $appId = $this->input->get('appId', 0, 'int'); $contents = ''; $isAppView = false; if ($appId) { // Load the application. $app = FD::table('App'); $app->load($appId); $app->loadCss(); FD::page()->title($group->getName() . ' - ' . $app->get('title')); // Load the library. $lib = FD::apps(); $contents = $lib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'groups', $app, array('groupId' => $group->id)); $isAppView = true; } $this->set('appId', $appId); // Determines if we should display the custom content based on type. $type = $this->input->get('type', '', 'cmd'); if (!$isAppView && empty($type)) { $type = FD::config()->get('groups.item.display', 'timeline'); } $filterId = $this->input->get('filterId', 0, 'int'); if ($type == 'filterForm') { $theme = FD::themes(); $streamFilter = FD::table('StreamFilter'); if ($filterId) { $streamFilter->load($filterId); } $theme->set('controller', 'groups'); $theme->set('filter', $streamFilter); $theme->set('uid', $group->id); $contents = $theme->output('site/stream/form.edit'); } if ($type == 'info') { FD::language()->loadAdmin(); $currentStep = JRequest::getInt('step', 1); $steps = FD::model('Steps')->getSteps($group->category_id, SOCIAL_TYPE_CLUSTERS, SOCIAL_GROUPS_VIEW_DISPLAY); $fieldsLib = FD::fields(); $fieldsLib->init(array('privacy' => false)); $fieldsModel = FD::model('Fields'); $index = 1; foreach ($steps as $step) { $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $group->id, 'dataType' => SOCIAL_TYPE_GROUP, 'visible' => SOCIAL_GROUPS_VIEW_DISPLAY)); if (!empty($step->fields)) { $args = array($group); $fieldsLib->trigger('onDisplay', SOCIAL_FIELDS_GROUP_GROUP, $step->fields, $args); } $step->hide = true; foreach ($step->fields as $field) { // 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; } } if ($index === 1) { $step->url = FRoute::groups(array('layout' => 'item', 'id' => $group->getAlias(), 'type' => 'info'), false); } else { $step->url = FRoute::groups(array('layout' => 'item', 'id' => $group->getAlias(), 'type' => 'info', 'infostep' => $index), false); } $step->title = $step->get('title'); $step->active = !$step->hide && $currentStep == $index; if ($step->active) { $theme = FD::themes(); $theme->set('fields', $step->fields); $contents = $theme->output('site/groups/item.info'); } $step->index = $index; $index++; } $this->set('infoSteps', $steps); } $this->set('type', $type); $this->set('filterId', $filterId); $this->set('contents', $contents); if (!empty($contents)) { return parent::display('site/groups/item'); } // If no content, only we get the stream. No point getting stream and contents at the same time. // Retrieve group's stream $stream = FD::stream(); // Determine if the current request is for "tags" $hashtag = $this->input->get('tag', 0); $hashtagAlias = $this->input->get('tag'); if ($hashtag) { // get the actual hashtag $tag = $stream->getHashTag($hashtag); $hashtag = $tag->title; } else { $hashtag = JRequest::getVar('tag'); } // Retrieve story form for group $story = FD::get('Story', SOCIAL_TYPE_GROUP); $story->setCluster($group->id, SOCIAL_TYPE_GROUP); $story->showPrivacy(false); if ($hashtag) { $story->setHashtags(array($hashtag)); } // only group members allowed to post story updates on group page. if ($group->isMember() || $this->my->isSiteAdmin()) { $stream->story = $story; } // lets get stream items for this group $options = array('clusterId' => $group->id, 'clusterType' => SOCIAL_TYPE_GROUP); // stream filter id $filterId = $this->input->get('filterId', 0, 'int'); if ($filterId) { $sfilter = FD::table('StreamFilter'); $sfilter->load($filterId); $hashtags = $sfilter->getHashTag(); $tags = explode(',', $hashtags); if ($tags) { $options['tag'] = $tags; } } // we only wan streams thats has this hashtag associated. if ($hashtag) { $options['tag'] = array($hashtag); } $options['startlimit'] = $startlimit; // Filter stream item by specific context type if ($context) { $options['context'] = $context; } $stream->get($options); // Apply opengraph tags for the group. FD::opengraph()->addGroup($group); $this->set('context', $context); $this->set('stream', $stream); $this->set('hashtag', $hashtag); $this->set('hashtagAlias', $hashtagAlias); parent::display('site/groups/item'); }
public function pushActivity($actor_id, $act_type, $act_subtype, $act_description, $act_link, $act_title, $act_access) { if ($actor_id != 0) { $myUser = Foundry::user($actor_id); } $stream = Foundry::stream(); $template = $stream->getTemplate(); $template->setActor($actor_id, SOCIAL_TYPE_USER); $template->setContext($actor_id, SOCIAL_TYPE_USERS); $template->setVerb('invite'); $template->setType(SOCIAL_STREAM_DISPLAY_MINI); if ($actor_id != 0) { $userProfileLink = '<a href="' . $myUser->getPermalink() . '">' . $myUser->getName() . '</a>'; $title = $userProfileLink . " " . $act_description; } else { $title = "A guest " . $act_description; } $template->setTitle($title); $template->setAggregate(false); $template->setPublicStream('core.view'); $stream->add($template); return true; }
/** * Determines if the viewer has access to view this article * * @since 1.2 * @access public * @param string * @return */ public function canView(&$article) { $my = Foundry::user(); $viewLevels = $my->getAuthorisedViewLevels(); if (!in_array($article->access, $viewLevels) || !in_array($article->category->access, $viewLevels)) { return false; } return true; }
/** * Displays a user profile to a 3rd person perspective. * * @since 1.0 * @access public * @param null * @return null **/ public function display($tpl = null) { // Get the user's id. $id = $this->input->get('id', 0, 'int'); // The current logged in user might be viewing their own profile. if ($id == 0) { $id = FD::user()->id; } // When the user tries to view his own profile but if he isn't logged in, throw a login page. if ($id == 0) { return FD::requireLogin(); } // Check for user profile completeness FD::checkCompleteProfile(); // Get the user's object. $user = FD::user($id); // If the user still don't exist, throw a 404 if (!$user->id) { return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER')); } if (Foundry::user()->id != $user->id) { if (FD::user()->isBlockedBy($user->id)) { return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER')); } } if ($user->isBlock()) { FD::info()->set(JText::sprintf('COM_EASYSOCIAL_PROFILE_USER_NOT_EXIST', $user->getName()), SOCIAL_MSG_ERROR); return $this->redirect(FRoute::dashboard(array(), false)); } // Set the page title FD::page()->title(FD::string()->escape($user->getName())); // Set the page breadcrumb FD::page()->breadcrumb(FD::string()->escape($user->getName())); // Apply opengraph tags. FD::opengraph()->addProfile($user); // Get the current logged in user's object. $my = FD::user(); // Do not assign badge if i view myself. if ($user->id != $my->id && $my->id) { // @badge: profile.view $badge = FD::badges(); $badge->log('com_easysocial', 'profile.view', $my->id, JText::_('COM_EASYSOCIAL_PROFILE_VIEWED_A_PROFILE')); } $startlimit = JRequest::getInt('limitstart', 0); // Determine if the current request is to load an app $appId = JRequest::getInt('appId'); // Get site configuration $config = FD::config(); // Get the apps library. $appsLib = FD::apps(); $contents = ''; if ($appId) { // Load the app $app = FD::table('App'); $app->load($appId); // Check if the user has access to this app if (!$app->accessible($user->id)) { FD::info()->set(null, JText::_('COM_EASYSOCIAL_PROFILE_APP_IS_NOT_INSTALLED_BY_USER'), SOCIAL_MSG_ERROR); return $this->redirect(FRoute::profile(array('id' => $user->getAlias()), false)); } // Set the page title FD::page()->title(FD::string()->escape($user->getName()) . ' - ' . $app->get('title')); $contents = $appsLib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'profile', $app, array('userId' => $user->id)); } $layout = JRequest::getCmd('layout'); // @since 1.3.7 // If layout is empty, means we want to get the default view // Previously timeline is always the default if (empty($appId) && empty($layout)) { $defaultDisplay = FD::config()->get('users.profile.display', 'timeline'); $layout = $defaultDisplay; } if ($layout === 'about') { FD::language()->loadAdmin(); $currentStep = JRequest::getInt('step', 1); $steps = FD::model('Steps')->getSteps($user->profile_id, SOCIAL_TYPE_PROFILES, SOCIAL_PROFILES_VIEW_DISPLAY); $fieldsLib = FD::fields(); $fieldsModel = FD::model('Fields'); $index = 1; foreach ($steps as $step) { $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $user->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_DISPLAY)); if (!empty($step->fields)) { $args = array($user); $fieldsLib->trigger('onDisplay', SOCIAL_FIELDS_GROUP_USER, $step->fields, $args); } $step->hide = true; foreach ($step->fields as $field) { // 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; } } if ($index === 1) { $step->url = FRoute::profile(array('id' => $user->getAlias(), 'layout' => 'about'), false); } else { $step->url = FRoute::profile(array('id' => $user->getAlias(), 'layout' => 'about', 'step' => $index), false); } $step->title = $step->get('title'); $step->active = !$step->hide && $currentStep == $index; if ($step->active) { $theme = FD::themes(); $theme->set('fields', $step->fields); $contents = $theme->output('site/events/item.info'); } $step->index = $index; $index++; } $this->set('infoSteps', $steps); } // If contents is still empty at this point, then we just get the stream items as the content if (empty($contents)) { // Mark timeline item as the active one $this->set('timeline', true); // Retrieve user's stream $theme = FD::themes(); // Get story $story = FD::get('Story', SOCIAL_TYPE_USER); $story->target = $user->id; $stream = FD::stream(); $stream->get(array('userId' => $user->id, 'startlimit' => $startlimit)); if (FD::user()->id) { // only logged in user can submit story. $stream->story = $story; } // Set stream to theme $theme->set('stream', $stream); $contents = $theme->output('site/profile/default.stream'); } $this->set('contents', $contents); $privacy = $my->getPrivacy(); // Let's test if the current viewer is allowed to view this profile. if ($my->id != $user->id) { if (!$privacy->validate('profiles.view', $user->id, SOCIAL_TYPE_USER)) { $this->set('user', $user); parent::display('site/profile/restricted'); return; } } // Get user's cover object $cover = $user->getCoverData(); $this->set('cover', $cover); // If we're setting a cover $coverId = JRequest::getInt('cover_id', null); if ($coverId) { // Load cover photo $newCover = FD::table('Photo'); $newCover->load($coverId); // If the cover photo belongs to the user if ($newCover->isMine()) { // Then allow replacement of cover $this->set('newCover', $newCover); } } $photosModel = FD::model('Photos'); $photos = array(); // $photos = $photosModel->getPhotos( array( 'uid' => $user->id ) ); // not using? it seems like no one is referencing this photos. $totalPhotos = 0; // Retrieve list of apps for this user $appsModel = FD::model('Apps'); $options = array('view' => 'profile', 'uid' => $user->id, 'key' => SOCIAL_TYPE_USER); $apps = $appsModel->getApps($options); // Set the apps lib $this->set('appsLib', $appsLib); $this->set('totalPhotos', $totalPhotos); $this->set('photos', $photos); $this->set('apps', $apps); $this->set('activeApp', $appId); $this->set('privacy', $privacy); $this->set('user', $user); // Load the output of the profile. echo parent::display('site/profile/default'); }
public function getProfileLink($defaultItemId = '') { static $instance = array(); static $phpbbDB = null; static $phpbbpath = null; static $isBlogger = array(); // since it's for avatar, we'll follow the avatar's integration $config = EasyBlogHelper::getConfig(); $source = $config->get('layout_avatarIntegration'); if (!$config->get('main_nonblogger_profile')) { // 1st check if this user a blogger or not. $showLink = false; if (isset($isBlogger[$this->id])) { $showLink = $isBlogger[$this->id]; } else { $showLink = EasyBlogHelper::isBlogger($this->id); $isBlogger[$this->id] = $showLink; } if (!$showLink) { return 'javascript: void(0);'; } } // phpbb case if ($source == 'phpbb' && $phpbbDB === null) { $phpbbpath = $config->get('layout_phpbb_path'); $file = JPATH_ROOT . DIRECTORY_SEPARATOR . $phpbbpath . DIRECTORY_SEPARATOR . 'config.php'; if (JFile::exists($file)) { require $file; $host = $dbhost; $user = $dbuser; $password = $dbpasswd; $database = $dbname; $prefix = $table_prefix; $driver = $dbms; $debug = 0; $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix); $phpbbDB = JDatabase::getInstance($options); } else { $phpbbDB = false; } } if ($phpbbDB === false) { // can't get phpbb's config file, fallback to default profile link $source = 'default'; } // Always use the core linking if user does not wants this. if (!$config->get('layout_avatar_link_name')) { $source = 'default'; } // to ensure the passed in value is only a number $defaultItemId = str_replace('&Itemid=', '', $defaultItemId); // to ensure the uniqueness of the key $key = $source . '-' . $defaultItemId; // this is where the magic starts if (!isset($instance[$this->id][$key])) { $defaultItemId = !empty($defaultItemId) ? '&Itemid=' . $defaultItemId : ''; $defaultLink = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $this->id . $defaultItemId); switch ($source) { case 'k2': $file1 = JPATH_ROOT . '/components/com_k2/helpers/route.php'; $file2 = JPATH_ROOT . '/components/com_k2/helpers/utilities.php'; jimport('joomla.filesystem.file'); if (JFile::exists($file1) && JFile::exists($file2)) { require_once $file1; require_once $file2; $ret = K2HelperRoute::getUserRoute($this->id); } else { $ret = $defaultLink; } break; case 'mightyregistration': $ret = JRoute::_('index.php?option=com_community&view=profile&user_id=' . $this->id, false); break; case 'communitybuilder': $ret = JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='******'easysocial': $easysocial = EasyBlogHelper::getHelper('EasySocial'); $ret = ''; if ($easysocial->exists()) { $easysocial->init(); $user = Foundry::user($this->id); $ret = $user->getPermalink(); } break; case 'jomsocial': $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; $ret = JFile::exists($file) && (require_once $file) ? CRoute::_('index.php?option=com_community&view=profile&userid=' . $this->id) : ''; break; case 'kunena': $ret = JRoute::_('index.php?option=com_kunena&func=fbprofile&userid=' . $this->id, false); break; case 'phpbb': $juser = JFactory::getUser($this->id); $query = 'SELECT ' . $phpbbDB->nameQuote('user_id') . ' ' . 'FROM ' . $phpbbDB->nameQuote('#__users') . ' WHERE LOWER(' . $phpbbDB->nameQuote('username') . ') = LOWER(' . $phpbbDB->quote($juser->username) . ') '; $phpbbDB->setQuery($query, 0, 1); $phpbbuserid = $phpbbDB->loadResult(); $ret = $phpbbuserid ? JURI::root() . rtrim($phpbbpath, '/') . '/memberlist.php?mode=viewprofile&u=' . $phpbbuserid : ''; break; case 'anahita': $person = KFactory::get('lib.anahita.se.person.helper')->getPerson($this->id); $ret = $person->getURL(); break; case 'easydiscuss': $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easydiscuss' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'router.php'; $ret = JFile::exists($file) && (require_once $file) ? DiscussRouter::_('index.php?option=com_easydiscuss&view=profile&id=' . $this->id, false) : ''; break; case 'gravatar': case 'default': default: $ret = ''; break; } $instance[$this->id][$key] = $ret ? $ret : $defaultLink; } return $instance[$this->id][$key]; }
public function onUserAfterSave($user, $isnew, $success, $msg) { if ($isnew) { // Initialise EasySocial's Foundry Framework // Include main file. jimport('joomla.filesystem.file'); $path = JPATH_ROOT . '/administrator/components/com_easysocial/includes/foundry.php'; if (!JFile::exists($path)) { return false; } // Include the foundry engine require_once $path; $success = true; // Check if Foundry exists if (!Foundry::exists()) { Foundry::language()->loadSite(); echo JText::_('COM_EASYSOCIAL_FOUNDRY_DEPENDENCY_MISSING'); return; } if (!$success) { return false; } // Things that need to do here // 1. Insert user record into #__social_users // 2. Get the default profile // 3. Insert mapping into #__social_profiles_maps $userTable = Foundry::table('users'); $state = $userTable->load($user['id']); // If no user is found in #__social_users, then only we insert // If user is found, means the registration is coming from EasySocial itself. // The purpose here is to insert the user data if the registration is handled by other services if (!$state) { // Assign the user id $userTable->user_id = $user['id']; // Filter the username so that it becomes a valid alias $alias = JFilterOutput::stringURLSafe($user['username']); // Check if the alias exists. $userModel = Foundry::model('Users'); // Keep the original state of the alias $tmp = $alias; while ($userModel->aliasExists($alias, $user['id'])) { // Generate a new alias for the user. $alias = $tmp . '-' . rand(1, 150); } $userTable->alias = $alias; $userTable->state = $user['block'] === SOCIAL_JOOMLA_USER_BLOCKED ? SOCIAL_USER_STATE_PENDING : SOCIAL_USER_STATE_ENABLED; $userTable->type = 'joomla'; $userTable->store(); $profileModel = Foundry::model('Profiles'); $defaultProfile = $profileModel->getDefaultProfile(); if ($defaultProfile) { $defaultProfile->addUser($user['id']); } $controller = JRequest::getCmd('controller', ''); if ($controller != 'registration') { // if this user saving is coming from registration, then we dont add the user into finder. let the registration controller do the job. // Get the user object now $esUser = Foundry::user($user['id']); // Sync the index $esUser->syncIndex(); } } } return true; }
public function checkPrivacy($blog) { $obj = new stdClass(); $obj->allowed = EasyBlogHelper::isLoggedIn(); $obj->message = ''; // If it is public or site amdin, always allow browser to access. if (!$blog->access || EasyBlogHelper::isSiteAdmin()) { $obj->allowed = true; return $obj; } $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; $easysocial = EasyBlogHelper::getHelper('EasySocial'); if ($config->get('integrations_easysocial_privacy') && $easysocial->exists()) { switch ($blog->access) { case '10': $obj->allowed = EasyBlogHelper::isLoggedIn(); $obj->error = $obj->allowed ? '' : $this->getErrorHTML(); break; case '30': // if user is the blog author, we always allow. $obj->allowed = $my->id == $blog->created_by ? true : false; if (!$obj->allowed) { $obj->allowed = Foundry::user($my->id)->isFriends($blog->created_by); } $obj->error = $obj->allowed ? '' : $this->getErrorHTML('privacy.friends'); break; case '40': $obj->allowed = $my->id == $blog->created_by; $obj->error = $obj->allowed ? '' : $this->getErrorHTML('privacy.owner'); break; } return $obj; } else { if ($config->get('main_jomsocial_privacy') && JFile::exists($file)) { switch ($blog->access) { case '20': $obj->allowed = EasyBlogHelper::isLoggedIn(); $obj->error = $obj->allowed ? '' : $this->getErrorHTML(); break; case '30': require_once $file; $obj->allowed = CFactory::getUser($my->id)->isFriendWith($blog->created_by); $obj->error = $obj->allowed ? '' : $this->getErrorHTML('privacy.friends'); break; case '40': $obj->allowed = $my->id == $blog->created_by; $obj->error = $obj->allowed ? '' : $this->getErrorHTML('privacy.owner'); break; } return $obj; } } if ($blog->access) { $obj->allowed = EasyBlogHelper::isLoggedIn(); $obj->error = $obj->allowed ? '' : $this->getErrorHTML(); } // If not integrated with any privacy providers, we assume that the blog // is private. return $obj; }
/** * Notify site subscribers whenever a new blog post is created * * @since 1.0 * @access public * @param string * @return */ public function notifySubscribers(EasyBlogTableBlog $blog, $action, $comment = null) { // We don't want to notify via e-mail $emailOptions = false; $recipients = array(); $rule = ''; if ($action == 'new.post') { $recipients = $blog->getRegisteredSubscribers('new', array($blog->created_by)); $permalink = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id); $image = ''; if ($blog->getImage()) { $image = $blog->getImage()->getSource('frontpage'); } $options = array('uid' => $blog->id, 'actor_id' => $blog->created_by, 'title' => JText::sprintf('COM_EASYBLOG_EASYSOCIAL_NOTIFICATION_NEW_BLOG_POST', $blog->title), 'type' => 'blog', 'url' => $permalink, 'image' => $image); $rule = 'blog.create'; } if ($action == 'new.comment') { $recipients = $comment->getSubscribers($blog, array($comment->created_by)); $recipients = array_merge($recipients, array($blog->created_by)); $permalink = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id); $image = ''; if ($blog->getImage()) { $image = $blog->getImage()->getSource('frontpage'); } $content = JString::substr(strip_tags($comment->comment), 0, 50); $options = array('uid' => $blog->id, 'actor_id' => $comment->created_by, 'title' => JText::sprintf('COM_EASYBLOG_EASYSOCIAL_NOTIFICATION_NEW_COMMENT_ON_THE_BLOG_POST', $content, $blog->title), 'type' => 'blog', 'url' => $permalink, 'image' => $image, 'actor_id' => $comment->created_by); $rule = 'blog.comment'; } if ($action == 'ratings.add') { // Get blog post owner $recipients = array($blog->created_by); $permalink = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id); $image = ''; if ($blog->getImage()) { $image = $blog->getImage()->getSource('frontpage'); } $my = Foundry::user(); $options = array('uid' => $blog->id, 'actor_id' => $my->id, 'title' => JText::sprintf('COM_EASYBLOG_EASYSOCIAL_NOTIFICATION_NEW_RATINGS_FOR_YOUR_BLOG_POST', $blog->title), 'type' => 'blog', 'url' => $permalink, 'image' => $image, 'actor_id' => $my->id); $rule = 'blog.ratings'; } if (empty($rule)) { return false; } // Send notifications to the receivers when they unlock the badge Foundry::notify($rule, $recipients, $emailOptions, $options); }
public static function getList($params) { $app = JFactory::getApplication(); $lang = JFactory::getLanguage(); $user = JFactory::getUser(); $db = JFactory::getDbo(); $query = $db->getQuery(true); // Source $source = $params->get('source', 'categories'); $exclude = $params->get('exclude', array()); $articles_k2 = $params->get('articles_k2', array()); $categories_k2 = $params->get('categories_k2', array()); // General $readmore = $params->get('readmore', ''); $ordering = $params->get('ordering', 'random'); $item_counts = $params->get('item_counts', 5); $skip_counts = $params->get('skip_counts', 0); $limit_intro = $params->get('limit_intro', 200); // Display $show_date = $params->get('show_date', 1); $show_hits = $params->get('show_hits', 1); $show_tags = $params->get('show_tags', 1); $show_image = $params->get('show_image', 1); $show_intro = $params->get('show_intro', 1); $show_title = $params->get('show_title', 1); $show_author = $params->get('show_author', 1); $show_avatar = $params->get('show_avatar', 1); $show_rating = $params->get('show_rating', 1); $show_profile = $params->get('show_profile', 1); $show_category = $params->get('show_category', 1); $show_comments = $params->get('show_comments', 1); // Date $date_type = $params->get('date_type', 'created'); $date_format = $params->get('date_format', 'd F Y'); // Image $image_width = $params->get('image_width', 200); $image_height = $params->get('image_height', 100); $image_quality = $params->get('image_quality', 100); $image_link = $params->get('image_link', 'none'); $image_title = $params->get('image_title', 1); $image_resize = $params->get('image_resize', 1); $image_source = $params->get('image_source', 'auto'); // 3rd-party $avatar_width = $params->get('avatar_width', 60); $avatar_height = $params->get('avatar_height', 60); $avatar_system = $params->get('avatar_system', 'kunena'); $profile_system = $params->get('profile_system', 'kunena'); $comments_system = $params->get('comments_system', 'komento'); // User access $authorised = implode(',', $user->getAuthorisedViewLevels()); // Clean HTML tags $clean_intro = $params->get('clean_intro', 1); $allowed_tags = str_replace(' ', '', $params->get('allowed_tags')); $allowed_tags = "<" . str_replace(',', '><', $allowed_tags) . ">"; // Content filtering $tags_k2 = $params->get('tags_k2', array()); $author = $params->get('author', array()); $featured = $params->get('featured', 0); // Featured label/ribbon $featured_label = $params->get('featured_label', 0); $featured_label_text = $params->get('featured_label_text', 'Featured'); $featured_label_color = $params->get('featured_label_color', '#e52626'); // Link $title_link = $params->get('title_link', 1); $category_link = $params->get('category_link', 1); if (JFile::exists(JPATH_SITE . '/components/com_k2/k2.php')) { if ($source == 'categories' && $categories_k2) { if ($categories_k2[0] != '') { $categories_k2 = count($categories_k2) == 1 ? ' = ' . $categories_k2[0] . '' : 'IN (' . implode(',', $categories_k2) . ')'; $query->where('a.catid ' . $categories_k2); } $exclude ? $query->where('a.id NOT IN (' . $exclude . ')') : ''; } else { if ($source == 'articles' && $articles_k2) { $query->where('a.id IN (' . implode(',', $articles_k2) . ')'); } else { echo JText::_('MOD_GIANTCONTENT_ERROR_SOURCE'); return; } } } else { echo JText::_('MOD_GIANTCONTENT_ERROR_TYPE_K2'); return; } // Ordering switch ($ordering) { case 'random': $orderBy = 'RAND()'; break; case 'id_asc': $orderBy = 'a.id ASC'; break; case 'id_desc': $orderBy = 'a.id DESC'; break; case 'title_asc': $orderBy = 'a.title ASC'; break; case 'title_desc': $orderBy = 'a.title DESC'; break; case 'popular_last': $orderBy = 'a.hits ASC'; break; case 'popular_first': $orderBy = 'a.hits DESC'; break; case 'created_oldest': $orderBy = 'date ASC'; break; case 'created_newest': $orderBy = 'date DESC'; break; case 'most_rated': $orderBy = 'rating_total DESC, r.rating_count DESC'; break; case 'least_rated': $orderBy = 'rating_total ASC, r.rating_count ASC'; break; case 'most_commented': $orderBy = 'comments_count DESC, comments_date DESC'; break; case 'latest_commented': $orderBy = 'comments_date DESC, date DESC'; break; } // Content $query->select('a.id, a.title, a.alias, a.introtext, a.fulltext, a.hits'); $query->from('#__k2_items AS a'); // Category $query->select('a.catid AS category_id, c.name AS category_name, c.alias AS category_alias'); $query->join('LEFT', '#__k2_categories AS c ON c.id = a.catid'); // Join user $query->select('u.id AS user_id, u.email AS user_email, u.name AS user_name, a.created_by_alias AS user_alias'); $query->join('LEFT', '#__users AS u ON u.id = a.created_by'); // Join rating $query->select('ROUND(AVG(r.rating_sum / r.rating_count), 2) AS rating_average, r.rating_count'); $query->join('LEFT', '#__k2_rating AS r ON r.itemID = a.id'); // Select date if ($date_type !== 'created') { $query->select('CASE WHEN a.' . $date_type . ' = "0000-00-00 00:00:00" THEN a.created ELSE a.' . $date_type . ' END AS date'); } else { $query->select('a.created AS date'); } // Join avatar for author if ($show_avatar) { switch ($avatar_system) { // K2 avatar integration - http://getk2.org case 'k2': if (JFile::exists(JPATH_SITE . '/components/com_k2/k2.php')) { $query->select('ua.image AS avatar_user'); $query->join('LEFT', '#__k2_users AS ua ON ua.userID = u.id'); $avatar_path = 'media/k2/users/'; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_K2'); return; } break; // Kunena avatar integration - http://kunena.org // Kunena avatar integration - http://kunena.org case 'kunena': if (JFile::exists(JPATH_SITE . '/components/com_kunena/kunena.php')) { $query->select('ua.avatar AS avatar_user'); $query->join('LEFT', '#__kunena_users AS ua ON ua.userid = u.id'); $avatar_path = 'media/kunena/avatars/'; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_KUNENA'); return; } break; // JomSocial avatar integration - http://jomsocial.com // JomSocial avatar integration - http://jomsocial.com case 'jomsocial': if (JFile::exists(JPATH_SITE . '/components/com_community/community.php')) { $query->select("ua.avatar AS avatar_user"); $query->join('LEFT', '#__community_users AS ua ON ua.userid = u.id'); $avatar_path = ''; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_JOMSOCIAL'); return; } break; // Comprofiler avatar integration - http://joomlapolis.com // Comprofiler avatar integration - http://joomlapolis.com case 'comprofiler': if (JFile::exists(JPATH_SITE . '/components/com_comprofiler/comprofiler.php')) { $query->select('ua.avatar AS avatar_user'); $query->join('LEFT', '#__comprofiler AS ua ON ua.user_id = u.id'); $avatar_path = 'images/comprofiler/'; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_COMPROFILER'); return; } break; // EasyBlog avatar integration - http://stackideas.com // EasyBlog avatar integration - http://stackideas.com case 'easyblog': if (JFile::exists(JPATH_SITE . '/components/com_easyblog/easyblog.php')) { $query->select("ua.avatar AS avatar_user"); $query->join('LEFT', '#__easyblog_users AS ua ON ua.id = u.id'); $avatar_path = 'images/easyblog_avatar/'; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_EASYBLOG'); return; } break; // EasySocial avatar integration - http://stackideas.com // EasySocial avatar integration - http://stackideas.com case 'easysocial': if (JFile::exists(JPATH_SITE . '/components/com_easysocial/easysocial.php')) { $query->select("ua.large AS avatar_user"); $query->join('LEFT', '#__social_avatars AS ua ON ua.uid = u.id'); $avatar_path = 'media/com_easysocial/avatars/users/'; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_EASYSOCIAL'); return; } break; // EasyDiscuss avatar integration - http://stackideas.com // EasyDiscuss avatar integration - http://stackideas.com case 'easydiscuss': if (JFile::exists(JPATH_SITE . '/components/com_easydiscuss/easydiscuss.php')) { $query->select("ua.avatar AS avatar_user"); $query->join('LEFT', '#__discuss_users AS ua ON ua.id = u.id'); $avatar_path = 'images/discuss_avatar/'; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_EASYDISCUSS'); return; } break; } } // Join comments for content if ($show_comments || $ordering == 'most_commented' || $ordering == 'latest_commented') { switch ($comments_system) { // Default comment system case 'default': $query->select('COUNT(cm.id) AS comments_count, MAX(cm.commentDate) AS comments_date'); $query->join('LEFT', '#__k2_comments AS cm ON cm.itemID = a.id AND cm.published = 1'); $comments_link = '#itemCommentsAnchor'; break; // Komento comment integration - http://stackideas.com // Komento comment integration - http://stackideas.com case 'komento': if (JFile::exists(JPATH_SITE . '/components/com_komento/komento.php')) { $query->select('COUNT(cm.id) AS comments_count, MAX(cm.created) AS comments_date'); $query->join('LEFT', '#__komento_comments AS cm ON cm.cid = a.id AND cm.component = "com_k2" AND cm.published = 1'); $comments_link = '#section-kmt'; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_COMMENTS_SYSTEM_KOMENTO'); return; } break; // CComment comment integration - http://compojoom.com // CComment comment integration - http://compojoom.com case 'ccomment': if (JFile::exists(JPATH_SITE . '/components/com_comment/comment.php')) { $query->select('COUNT(cm.id) AS comments_count, MAX(cm.date) AS comments_date'); $query->join('LEFT', '#__comment AS cm ON cm.contentid = a.id AND cm.component = "com_k2" AND cm.published = 1'); $comments_link = '#!/ccomment'; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_COMMENTS_SYSTEM_CCOMMENT'); return; } break; // JComments comment integration - http://joomlatune.com // JComments comment integration - http://joomlatune.com case 'jcomments': if (JFile::exists(JPATH_SITE . '/components/com_jcomments/jcomments.php')) { $query->select('COUNT(cm.id) AS comments_count, MAX(cm.date) AS comments_date'); $query->join('LEFT', '#__jcomments AS cm ON cm.object_id = a.id AND cm.object_group = "com_k2" AND cm.published = 1'); $comments_link = '#comments'; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_COMMENTS_SYSTEM_JCOMMENTS'); return; } break; // JA Comment comment integration - http://joomlart.com // JA Comment comment integration - http://joomlart.com case 'jacomment': if (JFile::exists(JPATH_SITE . '/components/com_jacomment/jacomment.php')) { $query->select('COUNT(cm.id) AS comments_count, MAX(cm.date) AS comments_date'); $query->join('LEFT', '#__jacomment_items AS cm ON cm.contentid = a.id AND cm.option = "com_k2" AND cm.published = 1'); $comments_link = '#jac-wrapper'; } else { echo JText::_('MOD_GIANTCONTENT_ERROR_COMMENTS_SYSTEM_JACOMMENT'); return; } break; } } // Filter tags if ($tags_k2) { $query->join('INNER', '#__k2_tags_xref AS t ON t.itemID = a.id'); $query->where('t.tagID IN (' . implode(',', $tags_k2) . ')'); } // Filter author if ($author) { $query->where('a.created_by IN (' . implode(',', $author) . ')'); } // Filter featured if ($featured) { $query->where('a.featured = 1'); } // Access or published $query->where('a.trash = 0 AND c.trash = 0 AND a.published = 1 AND c.published = 1 AND a.access IN (' . $authorised . ') AND c.access IN (' . $authorised . ') AND a.publish_up <= "' . JFactory::getDate() . '"'); $query->group('a.id'); $query->order($orderBy); $db->setQuery($query, $skip_counts, $item_counts); $items = $db->loadObjectList(); $lists = array(); foreach ($items as $i => &$item) { $lists[$i] = new stdClass(); $lists[$i]->id = $item->id; $lists[$i]->date = ''; $lists[$i]->hits = ''; $lists[$i]->link = ''; $lists[$i]->tags = ''; $lists[$i]->intro = ''; $lists[$i]->image = ''; $lists[$i]->title = ''; $lists[$i]->author = ''; $lists[$i]->avatar = ''; $lists[$i]->rating = ''; $lists[$i]->featured = ''; $lists[$i]->category = ''; $lists[$i]->comments = ''; $lists[$i]->readmore = ''; $lists[$i]->fulltext = $item->fulltext; $lists[$i]->introtext = $item->introtext; $lists[$i]->category_id = $item->category_id; $lists[$i]->category_alias = $item->category_alias; // Content link $lists[$i]->link = JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . $item->alias, $item->category_id)); // Readmore link $lists[$i]->readmore = $readmore ? '<a href="' . $lists[$i]->link . '"><span>' . $readmore . '</span></a>' : ''; // Show content date $lists[$i]->date = $show_date ? JHtml::_('date', $item->date, $date_format) : ''; // Show content hits $lists[$i]->hits = $show_hits ? '<span>' . $item->hits . '</span>' : ''; // Show content image if ($show_image) { $img = array(); $image = md5("Image" . $item->id); if (JFile::exists(JPATH_SITE . '/media/k2/items/src/' . $image . '.jpg')) { $image = 'media/k2/items/src/' . $image . '.jpg'; } else { $image = ''; } if ($image_source == 'auto') { if (@$image) { $img_source = 'media'; } else { $img_source = 'content'; } } else { $img_source = $image_source; } if ($img_source == 'media') { if (@$image) { $img['src'] = $image; $img['alt'] = $item->title; $img['ttl'] = $item->title; } } else { $pattern = '/<img[^>]+>/i'; preg_match($pattern, $item->introtext, $img_tag); if (!count($img_tag)) { preg_match($pattern, $item->fulltext, $img_tag); } if (count($img_tag)) { preg_match_all('/(src|alt|title)\\s*=\\s*(["\'])(.*?)\\2/i', $img_tag[0], $img_elem); $img_elem = array_combine($img_elem[1], $img_elem[3]); if (@$img_elem['src']) { $img['src'] = trim(@$img_elem['src']); $img['alt'] = trim(@$img_elem['alt']); $img['ttl'] = trim(@$img_elem['title']); $item->introtext = preg_replace($pattern, '', $item->introtext, 1); } } } if (!@$img['src']) { // Default image $img['src'] = 'modules/mod_giantcontent/assets/images/default.png'; $img['alt'] = $item->title; } if ($img['src']) { $img_src = $img_attr = $img_title = ''; // Use timthumb to resize image if ($image_resize) { $img_src = JURI::base(true) . '/modules/mod_giantcontent/assets/libraries/includes/timthumb.php?src='; $img_attr = '&w=' . $image_width . '&h=' . $image_height . '&q=' . $image_quality; } $img_src = $img_src && strncasecmp($img['src'], "http", 4) !== 0 ? $img_src . JURI::base(true) . '/' : $img_src; $img['ttl'] = $image_title ? $item->title : @$img['ttl']; $img_title = $img['ttl'] ? 'title="' . $img['ttl'] . '"' : ''; $lists[$i]->image = '<img src="' . @$img_src . @$img['src'] . @$img_attr . '" alt="' . @$img['alt'] . '" ' . @$img_title . ' />'; switch ($image_link) { case 'none': $lists[$i]->image = $lists[$i]->image; break; case 'content': $lists[$i]->image = '<a href="' . $lists[$i]->link . '">' . $lists[$i]->image . '</a>'; break; case 'shadowbox': $lists[$i]->image = '<a href="' . @$img['src'] . '" rel="shadowbox" ' . @$img_title . '>' . $lists[$i]->image . '</a>'; break; } $lists[$i]->image_src = @$img['src']; $lists[$i]->image_alt = @$img['alt']; $lists[$i]->image_title = @$img['ttl']; } } // Show author profile if ($show_profile) { switch ($profile_system) { // K2 profile integration - http://getk2.org case 'k2': if (JFile::exists(JPATH_SITE . '/components/com_k2/k2.php')) { require_once JPATH_SITE . '/components/com_k2/helpers/route.php'; $profile_link = JRoute::_(K2HelperRoute::getUserRoute($item->user_id)); } else { echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_K2'); return; } break; // Kunena profile integration - http://kunena.org // Kunena profile integration - http://kunena.org case 'kunena': if (JFile::exists(JPATH_SITE . '/components/com_kunena/kunena.php')) { $profile_link = KunenaRoute::_('index.php?option=com_kunena&view=profile&userid=' . $item->user_id); } else { echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_KUNENA'); return; } break; // JomSocial profile integration - http://jomsocial.com // JomSocial profile integration - http://jomsocial.com case 'jomsocial': if (JFile::exists(JPATH_SITE . '/components/com_community/community.php')) { require_once JPATH_SITE . '/components/com_community/libraries/core.php'; $profile_link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $item->user_id); } else { echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_JOMSOCIAL'); return; } break; // Comprofiler profile integration - http://joomlapolis.com // Comprofiler profile integration - http://joomlapolis.com case 'comprofiler': if (JFile::exists(JPATH_SITE . '/components/com_comprofiler/comprofiler.php')) { $profile_link = JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='******'MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_COMPROFILER'); return; } break; // EasyBlog profile integration - http://stackideas.com // EasyBlog profile integration - http://stackideas.com case 'easyblog': if (JFile::exists(JPATH_SITE . '/components/com_easyblog/easyblog.php')) { require_once JPATH_SITE . '/components/com_easyblog/helpers/router.php'; $profile_link = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $item->user_id); } else { echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_EASYBLOG'); return; } break; // EasySocial profile integration - http://stackideas.com // EasySocial profile integration - http://stackideas.com case 'easysocial': if (JFile::exists(JPATH_SITE . '/components/com_easysocial/easysocial.php')) { $profile_link = Foundry::user($item->user_id)->getPermalink(); } else { echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_EASYSOCIAL'); return; } break; // EasyDiscuss profile integration - http://stackideas.com // EasyDiscuss profile integration - http://stackideas.com case 'easydiscuss': if (JFile::exists(JPATH_SITE . '/components/com_easydiscuss/easydiscuss.php')) { require_once JPATH_SITE . '/components/com_easydiscuss/helpers/router.php'; $profile_link = DiscussHelper::getTable('Profile')->load($item->user_id)->getLink(); } else { echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_EASYDISCUSS'); return; } break; } } // Show content intro if ($show_intro) { // Clean HTML tags if ($clean_intro) { $item->introtext = strip_tags($item->introtext, $allowed_tags); $item->introtext = str_replace(' ', ' ', $item->introtext); $item->introtext = preg_replace('/\\s{2,}/u', ' ', trim($item->introtext)); } $lists[$i]->intro = $limit_intro ? self::truncateText($item->introtext, $limit_intro) : $item->introtext; } // Show content title if ($show_title) { $lists[$i]->title_name = $item->title; $lists[$i]->title = $title_link ? '<a href="' . $lists[$i]->link . '">' . $lists[$i]->title_name . '</a>' : $lists[$i]->title_name; } // Show content category if ($show_category) { $lists[$i]->category_name = $item->category_name; $lists[$i]->category_link = JRoute::_(K2HelperRoute::getCategoryRoute($item->category_id . ':' . $item->category_alias)); $lists[$i]->category = $category_link ? '<a href="' . $lists[$i]->category_link . '">' . $lists[$i]->category_name . '</a>' : $lists[$i]->category_name; } // Show content comments if ($show_comments) { $lists[$i]->comments_count = $item->comments_count; $lists[$i]->comments_link = $lists[$i]->link . $comments_link; $lists[$i]->comments = '<a href="' . $lists[$i]->comments_link . '">' . $item->comments_count . '</a>'; } // Show content author if ($show_author) { $lists[$i]->author_name = $item->user_alias ? $item->user_alias : $item->user_name; $lists[$i]->author = $show_profile ? '<a href="' . $profile_link . '">' . $lists[$i]->author_name . '</a>' : $lists[$i]->author_name; } // Show profile avatar if ($show_avatar) { $avatar_src = 'modules/mod_giantcontent/assets/libraries/includes/timthumb.php?src=' . JURI::base(true) . '/'; $avatar_attr = '&w=' . $avatar_width . '&h=' . $avatar_height; $avatar_default = '<img src="' . $avatar_src . '/modules/mod_giantcontent/assets/images/avatar.png' . $avatar_attr . '" alt="' . $item->user_name . '" />'; $lists[$i]->avatar_user = $item->avatar_user; if ($avatar_system == 'easysocial') { $avatar_img = $avatar_path . $item->user_id . '/' . $item->avatar_user; } else { $avatar_img = $avatar_path . $item->avatar_user; } if (JFile::exists($avatar_img)) { $lists[$i]->avatar = '<img src="' . $avatar_src . $avatar_img . $avatar_attr . '" alt="' . $item->user_name . '" />'; $lists[$i]->avatar = $show_profile ? '<a href="' . $profile_link . '">' . $lists[$i]->avatar . '</a>' : $lists[$i]->avatar; } else { $lists[$i]->avatar = $show_profile ? '<a href="' . $profile_link . '">' . $avatar_default . '</a>' : $avatar_default; } } // Show content rating if ($show_rating) { if ($item->rating_count > 0) { $lists[$i]->rating_count = $item->rating_count; $lists[$i]->rating_average = $item->rating_average; } else { $lists[$i]->rating_count = 0; $lists[$i]->rating_average = 0.0; } $rating_current = $item->rating_average * 20; $lists[$i]->rating = '<span class="gc-rating-list"><span style="width:' . $rating_current . '%;" class="gc-rating-current"></span></span>'; } // Show content tags if ($show_tags) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('t.id, t.name AS title'); $query->from('#__k2_tags AS t'); $query->join('LEFT', '#__k2_tags_xref AS tm ON tm.tagID = t.id'); $query->where('t.published = 1 AND tm.itemID = ' . $item->id); $db->setQuery($query); $tags = $db->loadObjectList(); $list_tags = ''; if ($tags) { foreach ($tags as $tag) { $link_tags = JRoute::_(K2HelperRoute::getTagRoute($tag->title)); $list_tags .= '<a class="gc-tag" href="' . $link_tags . '">' . $tag->title . '</a>'; } } $lists[$i]->tags = $list_tags; } // Show featured label if ($featured_label) { $db = JFactory::getDbo(); $db->setQuery('SELECT * FROM #__k2_items WHERE id = ' . $item->id . ' AND featured = 1'); $featured = $db->loadResult(); if ($featured) { $lists[$i]->featured = '<span class="gc-featured" style="background: ' . $featured_label_color . '">' . $featured_label_text . '</span>'; } } } return $lists; }
} elseif ($visitor->thumb && $visitor->avatarapproved != '1') { $thumb = $juri . 'components/com_comprofiler/plugin/templates/default/images/avatar/pending_n.png'; } else { $thumb = $juri . 'images/comprofiler/' . $visitor->thumb; } $profile_url = JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='******'&Itemid=' . $app->input->get('Itemid', '', 'int')); } elseif ($profileman == 'js') { $visitor_naming = $visitor->{$js_naming}; if (!$visitor->thumb) { $thumb = $juri . 'components/com_community/assets/user-Male-thumb.png'; } else { $thumb = $juri_storage . $visitor->thumb; } $profile_url = JRoute::_('index.php?option=com_community&view=profile&userid=' . $visitor->visitor_userid . '&Itemid=' . $this->profileItemid); } elseif ($profileman == 'es') { $his = Foundry::user($visitor->visitor_userid); $thumb = $his->getAvatar(SOCIAL_AVATAR_MEDIUM); $visitor_naming = $his->getName(); $profile_url = JRoute::_('index.php?option=com_easysocial&view=profile&id=' . $visitor->visitor_userid . ':' . $visitor->username . '&Itemid=' . $this->profileItemid); } echo '<div class="wvmp_visitor" data-popbox="module://easysocial/profile/popbox" data-user-id="' . $visitor->visitor_userid . '">'; if ($profileman != '0') { echo '<div class="wvmp_thumb"> <a href="' . $profile_url . '" ><img src="' . $thumb . '" width="64" heigh="64" alt="thumb" /></a></div>'; } echo '<div><a href="' . $profile_url . '" ><i class="vmv-icon-user"></i> ' . $visitor_naming . '</a></div> <div title="' . JText::_('COM_VMVENDOR_PROFILEVISITS_LATESTVISIT') . '"><i class="vmv-icon-calendar"></i> ' . JHtml::date($visitor->date, $date_format, $tz = false) . '</div> </div>'; } echo '</div>'; } else {
private static function easysocial($profile) { $file = JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; if (!JFile::exists($file)) { return false; } require_once $file; $avatarLink = Foundry::user($profile->id)->getAvatar(SOCIAL_AVATAR_MEDIUM); $profileLink = Foundry::user($profile->id)->getPermalink(); return array($avatarLink, $profileLink); }