public function showGroupMiniHeader($groupId) { CMiniHeader::load(); $option = JRequest::getVar('option', '', 'REQUEST'); JFactory::getLanguage()->load('com_community'); CFactory::load('models', 'groups'); $group =& JTable::getInstance('Group', 'CTable'); $group->load($groupId); $my = CFactory::getUser(); // @rule: Test if the group is unpublished, don't display it at all. if (!$group->published) { return ''; } if (!empty($group->id) && $group->id != 0) { $isMember = $group->isMember($my->id); $config = CFactory::getConfig(); $tmpl = new CTemplate(); $tmpl->set('my', $my); $tmpl->set('group', $group); $tmpl->set('isMember', $isMember); $tmpl->set('config', $config); $showMiniHeader = $option == 'com_community' ? $tmpl->fetch('groups.miniheader') : '<div id="community-wrap" style="min-height:50px;">' . $tmpl->fetch('groups.miniheader') . '</div>'; return $showMiniHeader; } }
public static function showGroupMiniHeader($groupId) { CMiniHeader::load(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $option = $jinput->request->get('option', '', 'STRING'); //JRequest::getVar('option', '', 'REQUEST'); JFactory::getLanguage()->load('com_community'); $group = JTable::getInstance('Group', 'CTable'); $group->load($groupId); $my = CFactory::getUser(); $isBanned = $group->isBanned($my->id); // @rule: Test if the group is unpublished, don't display it at all. if (!$group->published) { return ''; } if (!empty($group->id) && $group->id != 0) { $fileModel = CFactory::getModel('files'); $params = $group->getParams(); $isMember = $group->isMember($my->id); $config = CFactory::getConfig(); $eventsModel = CFactory::getModel('Events'); $totalEvents = $eventsModel->getTotalGroupEvents($group->id); $discussModel = CFactory::getModel('discussions'); $discussions = $discussModel->getDiscussionTopics($group->id, '10', 0); $totalDiscussion = $discussModel->total; $bulletinModel = CFactory::getModel('bulletins'); $bulletins = $bulletinModel->getBulletins($groupId); $totalBulletin = $bulletinModel->total; $allowManagePhotos = CGroupHelper::allowManagePhoto($group->id); $allowManageVideos = CGroupHelper::allowManageVideo($group->id); $allowCreateEvent = CGroupHelper::allowCreateEvent($my->id, $group->id); $photosModel = CFactory::getModel('photos'); $albums = $photosModel->getGroupAlbums($group->id, true, false, $params->get('grouprecentphotos', GROUP_PHOTO_RECENT_LIMIT)); $totalPhotos = 0; foreach ($albums as $album) { $albumParams = new CParameter($album->params); $totalPhotos = $totalPhotos + $albumParams->get('count'); } $videoModel = CFactory::getModel('videos'); $tmpVideos = $videoModel->getGroupVideos($groupId, '', $params->get('grouprecentvideos', GROUP_VIDEO_RECENT_LIMIT)); $totalVideos = $videoModel->total ? $videoModel->total : 0; // Get like $likes = new CLike(); $isUserLiked = false; if ($isLikeEnabled = $likes->enabled('groups')) { $isUserLiked = $likes->userLiked('groups', $group->id, $my->id); } $totalLikes = $likes->getLikeCount('groups', $group->id); $tmpl = new CTemplate(); $groupModel = CFactory::getModel('groups'); $membersCount = $group->membercount; // If I have tried to join this group, but not yet approved, display a notice $waitingApproval = false; if ($groupModel->isWaitingAuthorization($my->id, $group->id)) { $waitingApproval = true; } $groupsModel = CFactory::getModel('groups'); $bannedMembers = $groupsModel->getBannedMembers($group->id); $tmpl->set('my', $my)->set('isBanned', $isBanned)->set('group', $group)->set('membersCount', $membersCount)->set('showEvents', $config->get('group_events') && $config->get('enableevents') && $params->get('eventpermission', 1) >= 1)->set('totalEvents', $totalEvents)->set('totalDiscussion', $totalDiscussion)->set('totalBulletin', $totalBulletin)->set('showPhotos', $params->get('photopermission') != -1 && $config->get('enablephotos') && $config->get('groupphotos'))->set('showVideos', $params->get('videopermission') != -1 && $config->get('enablevideos') && $config->get('groupvideos'))->set('isSuperAdmin', COwnerHelper::isCommunityAdmin())->set('isMine', $my->id == $group->ownerid)->set('totalVideos', $totalVideos)->set('totalPhotos', $totalPhotos)->set('isAdmin', $groupModel->isAdmin($my->id, $group->id))->set('isFile', $fileModel->isfileAvailable($group->id, 'group'))->set('isLikeEnabled', $isLikeEnabled)->set('totalLikes', $totalLikes)->set('isMember', $isMember)->set('config', $config)->set('totalBannedMembers', count($bannedMembers))->set('isUserLiked', $isUserLiked)->set('allowManagePhotos', $allowManagePhotos)->set('allowManageVideos', $allowManageVideos)->set('allowCreateEvent', $allowCreateEvent)->set('waitingApproval', $waitingApproval); $showMiniHeader = $option == 'com_community' ? $tmpl->fetch('groups/miniheader') : '<div id="community-wrap">' . $tmpl->fetch('groups/miniheader') . '</div>'; return $showMiniHeader; } }