public function ajaxgetFileList($extension, $groupId, $limitstart = 0, $limit = 8, $type) { $fileLib = new CFilesLibrary(); $model = CFactory::getModel('files'); $field = $type . 'id'; switch ($extension) { case 'mostdownload': $data = $model->getTopDownload($groupId, $limitstart, $limit, $field); foreach ($data as $key => $_data) { $data[$key] = $fileLib->convertToMb($_data); $data[$key] = $fileLib->getParentType($_data); $data[$key] = $fileLib->getParentName($_data); $data[$key]->deleteable = $fileLib->checkDeleteable($type, $_data, CFactory::getUser()); $data[$key]->user = CFactory::getUser($_data->creator); } $tmpl = new CTemplate(); $tmpl->set('data', $data); $html = $tmpl->fetch('files.listing'); break; default: $defaultextension = array('document', 'archive', 'images', 'multimedia', 'miscellaneous'); $data = $model->getFileList($type, $groupId, $limitstart, $limit, $extension); foreach ($data as $key => $_data) { $data[$key] = $fileLib->convertToMb($_data); $data[$key] = $fileLib->getParentType($_data); $data[$key] = $fileLib->getParentName($_data); $data[$key]->user = CFactory::getUser($_data->creator); $data[$key]->deleteable = $fileLib->checkDeleteable($type, $_data, CFactory::getUser()); if ($_data->type !== $extension && in_array($extension, $defaultextension, true)) { unset($data[$key]); } } $tmpl = new CTemplate(); $tmpl->set('data', $data); $html = $tmpl->fetch('files.listing'); break; } $json = array(); $json['html'] = $html; //calculate pending files list $loadedFiles = $limitstart + count($data); $totalFiles = $model->getGroupFileCount($groupId, $extension, $field); if ($totalFiles > $loadedFiles) { //update limitstart $limitstart = $limitstart + count($data); $moreCount = $totalFiles - $loadedFiles; //load more option $json['next'] = $limitstart; $json['count'] = $moreCount; } die(json_encode($json)); }
/** * View method to display specific discussion from a group * @since 2.4 * @access public * @param Object Data object passed from controller */ public function viewdiscussion() { $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $config = CFactory::getConfig(); CWindow::load(); $jinput = JFactory::getApplication()->input; $my = CFactory::getUser(); $groupId = $jinput->get('groupid', 0, 'INT'); $topicId = $jinput->get('topicid', 0, 'INT'); // Load necessary library and objects $groupModel = CFactory::getModel('groups'); $group = JTable::getInstance('Group', 'CTable'); $discussion = JTable::getInstance('Discussion', 'CTable'); $group->load($groupId); $discussion->load($topicId); $isBanned = $group->isBanned($my->id); $document->addCustomTag('<link rel="image_src" href="' . $group->getThumbAvatar() . '" />'); // @rule: Test if the group is unpublished, don't display it at all. if (!$group->published) { $this->_redirectUnpublishGroup(); return; } $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&topicid=' . $topicId . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_GROUPS_LATEST_FEED') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); if ($group->approvals == 1 && !$group->isMember($my->id) && !COwnerHelper::isCommunityAdmin()) { $this->noAccess(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE')); return; } // Execute discussion onDisplay filter $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); $args = array(); $args[] = $discussion; $appsLib->triggerEvent('onDiscussionDisplay', $args); // Get the discussion creator info $creator = CFactory::getUser($discussion->creator); // Format the date accordingly. //$discussion->created = CTimeHelper::getDate( $discussion->created ); $dayinterval = ACTIVITY_INTERVAL_DAY; $timeFormat = $config->get('activitiestimeformat'); $dayFormat = $config->get('activitiesdayformat'); if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) { $discussion->created = CTimeHelper::getDate($discussion->created)->format(JText::_('DATE_FORMAT_LC2'), true); } else { $discussion->created = CTimeHelper::timeLapse(CTimeHelper::getDate($discussion->created)); } if ($creator->block) { $discussion->title = $discussion->message = JText::_('COM_COMMUNITY_CENSORED'); } /** * Opengraph */ CHeadHelper::setType('website', JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_TITTLE', $discussion->title), $discussion->message); // Add pathways $this->_addGroupInPathway($group->id); $this->addPathway(JText::_('COM_COMMUNITY_GROUPS_DISCUSSION_TITLE'), CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id)); $this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_TITTLE', $discussion->title)); $isGroupAdmin = $groupModel->isAdmin($my->id, $group->id); if ($my->id == $creator->id || $isGroupAdmin || COwnerHelper::isCommunityAdmin()) { $title = JText::_('COM_COMMUNITY_DELETE_DISCUSSION'); $titleLock = $discussion->lock ? JText::_('COM_COMMUNITY_UNLOCK_DISCUSSION') : JText::_('COM_COMMUNITY_LOCK_DISCUSSION'); $actionLock = $discussion->lock ? JText::_('COM_COMMUNITY_UNLOCK') : JText::_('COM_COMMUNITY_LOCK'); $this->addSubmenuItem('', $actionLock, "joms.api.discussionLock('" . $group->id . "', '" . $discussion->id . "');", SUBMENU_RIGHT); $this->addSubmenuItem('', JText::_('COM_COMMUNITY_DELETE'), "joms.api.discussionRemove('" . $group->id . "', '" . $discussion->id . "');", SUBMENU_RIGHT); $this->addSubmenuItem('index.php?option=com_community&view=groups&task=editdiscussion&groupid=' . $group->id . '&topicid=' . $discussion->id, JText::_('COM_COMMUNITY_EDIT'), '', SUBMENU_RIGHT); } $wallContent = CWallLibrary::getWallContents('discussions', $discussion->id, $isGroupAdmin, $config->get('stream_default_comments'), 0, 'wall/content', 'groups,discussion'); $wallCount = CWallLibrary::getWallCount('discussions', $discussion->id); $viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=discussapp&topicid=' . $discussion->id . '&app=walls'); $wallViewAll = ''; if ($wallCount > $config->get('stream_default_comments')) { $wallViewAll = CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount); } // Test if the current browser is a member of the group $isMember = $group->isMember($my->id); $waitingApproval = false; // If I have tried to join this group, but not yet approved, display a notice if ($groupModel->isWaitingAuthorization($my->id, $group->id)) { $waitingApproval = true; } $wallForm = ''; $config = CFactory::getConfig(); // Only get the wall form if user is really allowed to see it. if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && $isMember && !$isBanned && !$waitingApproval || COwnerHelper::isCommunityAdmin()) { $outputLock = '<div class="cAlert">' . JText::_('COM_COMMUNITY_DISCUSSION_LOCKED_NOTICE') . '</div>'; $outputUnLock = CWallLibrary::getWallInputForm($discussion->id, 'groups,ajaxSaveDiscussionWall', 'groups,ajaxRemoveReply'); $wallForm = $discussion->lock ? $outputLock : $outputUnLock; } if (empty($wallForm)) { //user must join in order to see this page $tmpl = new CTemplate(); $wallForm = $tmpl->set('groupid', $groupId)->fetch('groups.joingroup'); $outputLock = '<div class="cAlert">' . JText::_('COM_COMMUNITY_DISCUSSION_LOCKED_NOTICE') . '</div>'; $outputUnLock = CWallLibrary::getWallInputForm($discussion->id, 'groups,ajaxSaveDiscussionWall', 'groups,ajaxRemoveReply'); $wallForm2 = '<div class="cWall-Header">' . JText::_('COM_COMMUNITY_REPLIES') . '</div>'; $wallForm2 .= $discussion->lock ? $outputLock : $outputUnLock; $wallForm = $wallForm . '<div style="display:none" class="reply-form">' . $wallForm2 . '</div>'; } $config = CFactory::getConfig(); // Get creator link $creatorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $creator->id); // Get reporting html $report = new CReportingLibrary(); $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_GROUPS_DISCUSSION_REPORT'), 'groups,reportDiscussion', array($discussion->id)); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $group->id . '&topicid=' . $discussion->id)); $bookmarksHTML = $bookmarks->getHTML(); //filesharing $filesharingHTML = ''; $permission = CGroupHelper::getMediaPermission($groupId); if ($config->get('groupdiscussfilesharing') && $permission->params->get('groupdiscussionfilesharing')) { $file = new CFilesLibrary(); $filesharingHTML = $file->getFileHTML('discussion', $discussion->id); } $tmpl = new CTemplate(); echo $tmpl->set('bookmarksHTML', $bookmarksHTML)->set('discussion', $discussion)->set('creator', $creator)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('wallCount', $wallCount)->set('wallViewAll', $wallViewAll)->set('creatorLink', $creatorLink)->set('reportHTML', $reportHTML)->set('filesharingHTML', $filesharingHTML)->set('group', $group)->set('canCreate', $my->authorise('community.create', 'groups.discussions.' . $group->id))->set('isTimeLapsed', $config->get('activitydateformat'))->set('submenu', $this->showSubmenu(false))->fetch('groups.viewdiscussion'); }