function getBlockUserHTML($userId, $isBlocked) { return CUserHelper::getBlockUserHTML($userId, $isBlocked); }
/** * Displays the viewing profile page. * * @access public * @param array An associative array to display the fields */ function profile(&$data) { $mainframe =& JFactory::getApplication(); $my = CFactory::getUser(); $config = CFactory::getConfig(); $userid = JRequest::getVar('userid', $my->id); $user = CFactory::getUser($userid); $userId = JRequest::getVar('userid', '', 'GET'); if ($my->id != 0 && empty($userId)) { CFactory::setActiveProfile($my->id); $user = $my; } // Display breadcrumb regardless whether the user is blocked or not $pathway =& $mainframe->getPathway(); $pathway->addItem($user->getDisplayName(), ''); // Get profile video information $params = $user->getParams(); $videoid = $params->get('profileVideo', 0); CFactory::load('helpers', 'owner'); $blocked = $user->isBlocked(); if ($blocked && !COwnerHelper::isCommunityAdmin()) { $tmpl = new CTemplate(); echo $tmpl->fetch('profile.blocked'); return; } // If the current browser is a site admin, display some notice that user is blocked. if ($blocked) { $this->addWarning(JText::_('CC USER ACCOUNT BANNED')); } // access check if (!$this->accessAllowed('privacyProfileView')) { return; } require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'userpoints.php'; $appsLib =& CAppPlugins::getInstance(); $appsLib->loadApplications(); CFactory::load('helpers', 'string'); $document =& JFactory::getDocument(); $status = $user->getStatus(COMMUNITY_RAW_STATUS); $status = empty($status) ? '' : ' : ' . $status; $document->setTitle($user->getDisplayName(COMMUNITY_RAW_STATUS) . $status); $document->setMetaData('description', JText::sprintf('CC PROFILE META DESCRIPTION', $user->getDisplayName(), $config->get('sitename'), CStringHelper::escape($status))); $feedLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER FEEDS') . '" href="' . $feedLink . '"/>'; $mainframe->addCustomHeadTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id . '&showfriends=true&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER FRIENDS FEEDS') . '" href="' . $feedLink . '"/>'; $mainframe->addCustomHeadTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=photos&task=myphotos&userid=' . $user->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER PHOTO FEEDS') . '" href="' . $feedLink . '"/>'; $mainframe->addCustomHeadTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=videos&userid=' . $user->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO USER VIDEO FEEDS') . '" href="' . $feedLink . '"/>'; $mainframe->addCustomHeadTag($feed); // Get profile video information $params = $user->getParams(); $data->videoid = $params->get('profileVideo', 0); // Show profile header $headerHTML = $this->_showHeader($data); // Load user application $apps = $data->apps; // Load community applications plugin $app =& CAppPlugins::getInstance(); $appsModel = CFactory::getModel('apps'); $tmpAppData = $app->triggerEvent('onProfileDisplay', '', true); $appData = array(); // @rule: Only display necessary apps. $count = count($tmpAppData); for ($i = 0; $i < $count; $i++) { $app =& $tmpAppData[$i]; $privacy = $appsModel->getPrivacy($user->id, $app->name); if ($this->appPrivacyAllowed($privacy)) { $appData[] = $app; } } unset($tmpAppData); // Split the apps into different list for different positon $appsInPositions = array(); foreach ($appData as &$app) { $appsInPositions[$app->position][] = $app; } $tmpl = new CTemplate(); $contenHTML = array(); $contenHTML['content'] = ''; $contenHTML['sidebar-top'] = ''; $contenHTML['sidebar-bottom'] = ''; $jscript = ''; foreach ($appsInPositions as $position => $appData) { ob_start(); foreach ($appData as $app) { // If the apps content is empty, we ignore this app from showing // the header in profile page. if (JString::trim($app->data) == "") { continue; } $tmpl->set('app', $app); $tmpl->set('isOwner', COwnerHelper::isMine($my->id, $user->id)); switch ($position) { case 'sidebar-top': case 'sidebar-bottom': echo $tmpl->fetch('application.widget'); break; default: echo $tmpl->fetch('application.box'); } } $contenHTML[$position] = ob_get_contents(); ob_end_clean(); } // Get the config $config = CFactory::getConfig(); // get total group $groupsModel = CFactory::getModel('groups'); $totalgroups = $groupsModel->getGroupsCount($user->id); // get total friend $friendsModel = CFactory::getModel('friends'); $totalfriends = $user->getFriendCount(); // get total photos $photosModel = CFactory::getModel('photos'); $totalphotos = $photosModel->getPhotosCount($user->id); // get total activities $activitiesModel = CFactory::getModel('activities'); $totalactivities = $activitiesModel->getActivityCount($user->id); $isMine = COwnerHelper::isMine($my->id, $user->id); $isCommunityAdmin = COwnerHelper::isCommunityAdmin($user->id); // Get reporting html CFactory::load('libraries', 'reporting'); $report = new CReportingLibrary(); $reportHTML = $isMine ? '' : $report->getReportingHTML(JText::_('CC REPORT BAD USER'), 'profile,reportProfile', array($user->id)); // Check if user is blocked $blockUserModel = CFactory::getModel('block'); $isBlocked = $blockUserModel->getBlockStatus($user->id, $my->id); // Get block user html CFactory::load('helpers', 'user'); $blockUserHTML = $isMine || $isCommunityAdmin ? '' : CUserHelper::getBlockUserHTML($user->id, $isBlocked); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=profile&userid=' . $user->id)); $bookmarksHTML = $bookmarks->getHTML(); // Get like // cater for buble, blueface template $likesHTML = ''; if ($user->getParams()->get('profileLikes', true)) { CFactory::load('libraries', 'like'); $likes = new CLike(); $likesHTML = $my->id == 0 ? $likes->getHtmlPublic('profile', $user->id) : $likes->getHTML('profile', $user->id, $my->id); } $tmpl = new CTemplate(); $tmpl->set('blockUserHTML', $blockUserHTML); $tmpl->set('bookmarksHTML', $bookmarksHTML); $tmpl->set('profileOwnerName', $user->getDisplayName()); $tmpl->set('totalgroups', $totalgroups); $tmpl->set('totalfriends', $totalfriends); $tmpl->set('totalphotos', $totalphotos); $tmpl->set('totalactivities', $totalactivities); $tmpl->set('reportsHTML', $reportHTML); $tmpl->set('mainframe', $mainframe); $tmpl->set('config', $config); $tmpl->set('about', $this->_getProfileHTML($data->profile)); $tmpl->set('friends', $this->_getFriendsHTML()); $tmpl->set('groups', $this->_getGroupsHTML()); $tmpl->set('newsfeed', $this->_getNewsfeedHTML()); $tmpl->set('header', $headerHTML); $tmpl->set('adminControlHTML', $this->_getAdminControlHTML($user->id)); $tmpl->set('content', $contenHTML['content']); $tmpl->set('sidebarTop', $contenHTML['sidebar-top']); $tmpl->set('sidebarBottom', $contenHTML['sidebar-bottom']); $tmpl->set('isMine', $isMine); $tmpl->set('jscript', ''); // maintain for 1.8.0 template compatibility $tmpl->setRef('user', $user); $tmpl->set('my', $my); $tmpl->set('videoid', $data->videoid); $tmpl->set('likesHTML', $likesHTML); $html = $tmpl->fetch('profile.index'); echo $html; }