/** * Allows us to test if the user has access to the album **/ public function hasAccess($userId, $permissionType) { CFactory::load('helpers', 'owner'); CFactory::load('helpers', 'group'); // @rule: For super admin, regardless of what permission, they should be able to access if (COwnerHelper::isCommunityAdmin()) { return true; } switch ($this->type) { case PHOTOS_USER_TYPE: if ($permissionType == 'upload') { return $this->creator == $userId; } if ($permissionType == 'deletephotos') { return $this->creator == $userId; } break; case PHOTOS_GROUP_TYPE: CFactory::load('models', 'groups'); $group =& JTable::getInstance('Group', 'CTable'); $group->load($this->groupid); if ($permissionType == 'upload') { return CGroupHelper::allowManagePhoto($group->id); } if ($permissionType == 'deletephotos') { return $this->creator == $userId || $group->isAdmin($userId); } return false; break; } }
public function setSubmenus() { CFactory::load('helpers', 'group'); CFactory::load('helpers', 'owner'); $task = JRequest::getVar('task', '', 'GET'); $albumId = JRequest::getInt('albumid', 0, 'REQUEST'); $groupId = JRequest::getInt('groupid', '', 'REQUEST'); if (!empty($albumId)) { $album = JTable::getInstance('Album', 'CTable'); $album->load($albumId); $groupId = $album->groupid; } CFactory::load('models', 'groups'); $config = CFactory::getConfig(); $group = JTable::getInstance('Group', 'CTable'); $group->load($groupId); $my = CFactory::getUser(); $albumId = $albumId != 0 ? '&albumid=' . $albumId : ''; // Check if the current user is banned from this group $isBanned = $group->isBanned($my->id); CFactory::load('helpers', 'group'); $allowManagePhotos = CGroupHelper::allowManagePhoto($this->groupid); if (($task == 'uploader' || $task == 'photo') && !empty($albumId)) { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&groupid=' . $this->groupid . '&task=album' . $albumId, JText::_('COM_COMMUNITY_PHOTOS_BACK_TO_ALBUM')); } if ($allowManagePhotos && $task != 'photo' && !$isBanned) { $rawAlbumId = ""; if (!empty($albumId)) { $rawAlbumId = explode('=', $albumId); $rawAlbumId = $rawAlbumId[1]; } if ($task != 'newalbum' && $task != 'editAlbum') { $this->view->addSubmenuItem('javascript:void(0);', JText::_('COM_COMMUNITY_PHOTOS_UPLOAD_PHOTOS'), 'joms.notifications.showUploadPhoto(\'' . $rawAlbumId . '\',' . $this->groupid . '); return false;', true); } if ($task == 'album' && ($my->id == $album->creator && $allowManagePhotos || $group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin())) { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=editAlbum&albumid=' . $album->id . '&groupid=' . $group->id . '&referrer=albumgrp', JText::_('COM_COMMUNITY_EDIT_ALBUM'), '', true); } $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $this->groupid, JText::_('COM_COMMUNITY_PHOTOS_CREATE_PHOTO_ALBUM'), '', true); } if ($task == 'photo') { if ($album->hasAccess($my->id, 'deletephotos')) { $this->view->addSubmenuItem('', JText::_('COM_COMMUNITY_PHOTOS_DELETE'), "joms.gallery.confirmRemovePhoto();", true); } if ($my->id == $album->creator) { $this->view->addSubmenuItem('', JText::_('COM_COMMUNITY_PHOTOS_SET_AVATAR'), "joms.gallery.setProfilePicture();", true); } if ($my->id == $album->creator && $allowManagePhotos || $group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin()) { $this->view->addSubmenuItem('', JText::_('COM_COMMUNITY_PHOTOS_SET_AS_ALBUM_COVER'), "joms.gallery.setPhotoAsDefault();", true); } if (!$config->get('deleteoriginalphotos')) { $this->view->addSubmenuItem('', JText::_('COM_COMMUNITY_DOWNLOAD_IMAGE'), "joms.gallery.downloadPhoto();", true); } if ($groupId != '') { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $groupId, JText::_('COM_COMMUNITY_PHOTOS_CREATE_PHOTO_ALBUM'), '', true); } else { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=newalbum&userid=' . $my->id, JText::_('COM_COMMUNITY_PHOTOS_CREATE_PHOTO_ALBUM'), '', true); } } $this->view->addSubmenuItem('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $this->groupid, JText::_('COM_COMMUNITY_GROUPS_BACK_TO_GROUP')); }
public function addSubmenus($view) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $config = CFactory::getConfig(); $task = $jinput->get->get('task', ''); //JRequest::getVar( 'task' , '' , 'GET' ); $showBackLink = array('invitefriends', 'viewguest', 'uploadavatar', 'edit', 'sendmail', 'app'); $my = CFactory::getUser(); $allowCreateEvent = CGroupHelper::allowCreateEvent($my->id, $this->cid); if ($allowCreateEvent && $config->get('group_events') && $config->get('enableevents') && ($config->get('createevents') || COwnerHelper::isCommunityAdmin())) { $view->addSubmenuItem('index.php?option=com_community&view=events&task=create&groupid=' . $this->cid, JText::_('COM_COMMUNITY_EVENTS_CREATE'), '', SUBMENU_RIGHT); } if ($config->get('event_import_ical')) { $view->addSubmenuItem('index.php?option=com_community&view=events&task=import&groupid=' . $this->cid, JText::_('COM_COMMUNITY_GROUPS_IMPORT_EVENT'), '', SUBMENU_RIGHT); } if (in_array($task, $showBackLink)) { // @rule: Add a link back to the event's page $view->addSubmenuItem('index.php?option=com_community&view=events&task=viewevent&eventid=' . $this->event->id . '&groupid=' . $this->cid, JText::_('COM_COMMUNITY_EVENTS_BACK_BUTTON')); } // @rule: Add a link back to the group's page. $view->addSubmenuItem('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $this->cid, JText::_('COM_COMMUNITY_GROUPS_BACK_TO_GROUP')); $view->addSubmenuItem('index.php?option=com_community&view=events&groupid=' . $this->cid, JText::_('COM_COMMUNITY_EVENTS_ALL')); $view->addSubmenuItem('index.php?option=com_community&view=events&task=pastevents&groupid=' . $this->cid, JText::_('COM_COMMUNITY_EVENTS_PAST_TITLE')); }
public static function allowPhotoWall($groupid) { $permission = CGroupHelper::getMediaPermission($groupid); if ($permission->isMember || $permission->isAdmin || $permission->isSuperAdmin) { return true; } return false; }
public function isAllowedAlbumCreation() { CFactory::load('helpers', 'group'); $allowManagePhotos = CGroupHelper::allowManagePhoto($this->groupid); return $allowManagePhotos; }
public function _addSubmenu() { $my = CFactory::getUser(); $config =& CFactory::getConfig(); $task = JRequest::getVar('task', '', 'REQUEST'); $groupId = JRequest::getVar('groupid', '', 'GET'); $group = JTable::getInstance('Group', 'CTable'); $group->load($groupId); $isBanned = $group->isBanned($my->id); if (!empty($groupId)) { $this->addSubmenuItem('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId, JText::_('COM_COMMUNITY_GROUPS_BACK_TO_GROUP')); $videos = $this->model->hasPendingVideos($groupId, VIDEO_GROUP_TYPE); if ($videos) { $this->addSubmenuItem('index.php?option=com_community&view=videos&task=mypendingvideos&groupid=' . $groupId, JText::_('COM_COMMUNITY_VIDEOS_GROUP_PENDING'), '', SUBMENU_LEFT); } CFactory::load('helpers', 'group'); $allowManageVideos = CGroupHelper::allowManageVideo($groupId); if ($allowManageVideos && !$isBanned) { $this->addSubmenuItem('', JText::_('COM_COMMUNITY_ADD'), 'joms.videos.addVideo(\'' . VIDEO_GROUP_TYPE . '\', \'' . $groupId . '\')', SUBMENU_RIGHT); } } else { $this->addSubmenuItem('index.php?option=com_community&view=videos&task=display', JText::_('COM_COMMUNITY_VIDEOS_ALL_DESC'), '', SUBMENU_LEFT); if (!empty($my->id)) { $this->addSubmenuItem('index.php?option=com_community&view=videos&task=myvideos&userid=' . $my->id, JText::_('COM_COMMUNITY_VIDEOS_MY'), '', SUBMENU_LEFT); $this->addSubmenuItem('', JText::_('COM_COMMUNITY_ADD'), 'joms.videos.addVideo()', SUBMENU_RIGHT); } if (!$config->get('enableguestsearchvideos') && COwnerHelper::isRegisteredUser() || $config->get('enableguestsearchvideos')) { $tmpl = new CTemplate(); $tmpl->set('url', CRoute::_('index.php?option=com_community&view=videos&task=search')); $html = $tmpl->fetch('videos.search.submenu'); $this->addSubmenuItem('index.php?option=com_community&view=videos&task=search', JText::_('COM_COMMUNITY_SEARCH'), 'joms.videos.toggleSearchSubmenu(this)', SUBMENU_LEFT, $html); } $videos = $this->model->hasPendingVideos($my->id, VIDEO_USER_TYPE); if (!empty($my->id) && $videos) { $this->addSubmenuItem('index.php?option=com_community&view=videos&task=mypendingvideos&userid=' . $my->id, JText::_('COM_COMMUNITY_VIDEOS_PENDING'), '', SUBMENU_LEFT); } } }
public function addSubmenus($view) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $config = CFactory::getConfig(); $task = $jinput->get->get('task', ''); //JRequest::getVar( 'task' , '' , 'GET' ); $groupid = $jinput->get->get('groupid', 0, ''); $showBackLink = array('invitefriends', 'uploadavatar', 'edit', 'sendmail', 'app'); $my = CFactory::getUser(); $allowCreateEvent = CGroupHelper::allowCreateEvent($my->id, $this->cid); if (!$groupid) { $view->addSubmenuItem('index.php?option=com_community&view=events&task=display', JText::_('COM_COMMUNITY_EVENTS_ALL')); } if (COwnerHelper::isRegisteredUser()) { $view->addSubmenuItem('index.php?option=com_community&view=events&task=myevents&userid=' . $this->my->id, $groupid ? JText::_('COM_COMMUNITY_EVENT_GROUP_MINE') : JText::_('COM_COMMUNITY_EVENTS_MINE')); //check if there is any pending events invitation $model = CFactory::getModel('events'); $sorted = $jinput->get->get('sort', 'startdate', 'STRING'); //JRequest::getVar( 'sort' , 'startdate' , 'GET' ); $pending = COMMUNITY_EVENT_STATUS_INVITED; $events = $model->getEvents(null, CFactory::getUser()->id, $sorted, null, true, false, $pending); if ($events) { $view->addSubmenuItem('index.php?option=com_community&view=events&task=myinvites&userid=' . $this->my->id, JText::_('COM_COMMUNITY_EVENTS_PENDING_INVITATIONS')); } } if ($allowCreateEvent && $config->get('group_events') && $config->get('enableevents') && ($config->get('createevents') || COwnerHelper::isCommunityAdmin())) { //$view->addSubmenuItem('index.php?option=com_community&view=events&task=create&groupid=' . $this->cid, JText::_('COM_COMMUNITY_EVENTS_CREATE') , '' , SUBMENU_RIGHT ); } if ($config->get('event_import_ical')) { $view->addSubmenuItem('index.php?option=com_community&view=events&task=import&groupid=' . $this->cid, JText::_('COM_COMMUNITY_GROUPS_IMPORT_EVENT'), '', SUBMENU_RIGHT); } if (in_array($task, $showBackLink)) { // @rule: Add a link back to the event's page $view->addSubmenuItem('index.php?option=com_community&view=events&task=viewevent&eventid=' . $this->event->id . '&groupid=' . $this->cid, JText::_('COM_COMMUNITY_EVENTS_BACK_BUTTON')); } // @rule: Add a link back to the group's page. //$view->addSubmenuItem( 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $this->cid , JText::_('COM_COMMUNITY_GROUPS_BACK_TO_GROUP') ); //$view->addSubmenuItem( 'index.php?option=com_community&view=events&groupid=' . $this->cid , JText::_('COM_COMMUNITY_EVENTS_ALL') ); $view->addSubmenuItem('index.php?option=com_community&view=events&task=pastevents&groupid=' . $this->cid, JText::_('COM_COMMUNITY_EVENTS_PAST_TITLE')); }
function _groupPhoto() { $mainframe =& JFactory::getApplication(); $document =& JFactory::getDocument(); // Get necessary properties and load the libraries CFactory::load('models', 'photos'); CFactory::load('helpers', 'friends'); $my = CFactory::getUser(); $model = CFactory::getModel('photos'); $groupId = JRequest::getVar('groupid', '', 'GET'); $albumId = JRequest::getVar('albumid', '', 'GET'); $defaultId = JRequest::getVar('photoid', '', 'GET'); if (empty($albumId)) { echo JText::_('CC NO PROPER ALBUM ID'); return; } // Load the album table $album =& JTable::getInstance('Album', 'CTable'); $album->load($albumId); // Set pathway $pathway =& $mainframe->getPathway(); $pathway->addItem($album->name, ''); CFactory::load('models', 'groups'); $group =& JTable::getInstance('Group', 'CTable'); $group->load($groupId); CFactory::load('helpers', 'group'); //@rule: Do not allow non members to view albums for private group if (!CGroupHelper::allowViewMedia($group->id)) { // Set document title $document->setTitle(JText::_('CC RESTRICTED ACCESS')); $mainframe->enqueueMessage(JText::_('CC RESTRICTED ACCESS', 'notice')); echo JText::_('CC PHOTO NEED GROUP MEMBER PERMISSION'); return; } // Get list of photos and set some limit to be displayed. // @todo: make limit configurable? set to 1000, unlimited? $photos = $model->getPhotos($albumId, 1000); // Set document title CFactory::load('helpers', 'string'); $document->setTitle($album->name); // @checks: Test if album doesnt have any default photo id. We need to get the first row // of the photos to be the default if ($album->photoid == '0') { $album->photoid = count($photos) >= 1 ? $photos[0]->id : '0'; } // Try to see if there is any photo id in the query $defaultId = !empty($defaultId) ? $defaultId : $album->photoid; // Load the default photo $photo =& JTable::getInstance('Photo', 'CTable'); $photo->load($defaultId); // If default has an id of 0, we need to tell the template to dont process anything $default = $photo->id == 0 ? false : $photo; CFactory::load('helpers', 'owner'); //friend list for photo tag CFactory::load('libraries', 'phototagging'); $tagging = new CPhotoTagging(); for ($i = 0; $i < count($photos); $i++) { // Convert the generic object row into CTablePhoto object $item =& JTable::getInstance('Photo', 'CTable'); $item->bind($photos[$i]); $photos[$i] = $item; $row =& $photos[$i]; $taggedList = $tagging->getTaggedList($row->id); for ($t = 0; $t < count($taggedList); $t++) { $tagItem =& $taggedList[$t]; $tagUser = CFactory::getUser($tagItem->userid); $canRemoveTag = 0; // 1st we check the tagged user is the photo owner. // If yes, canRemoveTag == true. // If no, then check on user is the tag creator or not. // If yes, canRemoveTag == true // If no, then check on user whether user is being tagged if (COwnerHelper::isMine($my->id, $row->creator) || COwnerHelper::isMine($my->id, $tagItem->created_by) || COwnerHelper::isMine($my->id, $tagItem->userid)) { $canRemoveTag = 1; } $tagItem->user = $tagUser; $tagItem->canRemoveTag = $canRemoveTag; } $row->tagged = $taggedList; } // for photo tagging. only allow to tag members $groupModel = CFactory::getModel('groups'); $groupMemberIds = $groupModel->getMembersId($groupId, true); $friends = array(); foreach ($groupMemberIds as $grpMemberId) { if ($my->id != $grpMemberId) { $memberUser = CFactory::getUser($grpMemberId); $friends[] = $memberUser; } } if (COwnerHelper::isCommunityAdmin() || $group->isAdmin($my->id) || $group->isMember($my->id)) { array_unshift($friends, $my); } CFactory::load('helpers', 'group'); $allowManagePhotos = CGroupHelper::allowManagePhoto($groupId); // Only add these links when there are photos in the album if ($allowManagePhotos && $default) { $this->addSubmenuItem('', JText::_('CC SET IMAGE AS ALBUM COVER'), "setPhotoAsDefault();", true); $this->addSubmenuItem('', JText::_('CC DELETE IMAGE'), "removePhoto();", true); } // Show wall contents CFactory::load('helpers', 'friends'); // Load up required objects. $friendModel = CFactory::getModel('friends'); $config = CFactory::getConfig(); $showWall = false; $allowTag = false; //check if we can allow the current viewing user to tag the photos if ($group->isMember($my->id) || $group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin()) { $showWall = true; $allowTag = true; } $tmpl = new CTemplate(); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&groupid=' . $group->id)); $bookmarksHTML = $bookmarks->getHTML(); $photoCreator = CFactory::getUser($photo->creator); $tmpl->set('bookmarksHTML', $bookmarksHTML); $tmpl->set('showWall', $showWall); $tmpl->set('allowTag', $allowTag); $tmpl->set('isOwner', $group->isAdmin($my->id)); $tmpl->set('photos', $photos); $tmpl->set('default', $default); $tmpl->set('album', $album); $tmpl->set('friends', $friends); $tmpl->set('config', $config); $tmpl->set('photoCreator', $photoCreator); echo $tmpl->fetch('photos.photo'); }
public function manageable() { CFactory::load('helpers', 'group'); return CGroupHelper::allowManageEvent($this->my->id, $this->cid, $this->event->id); }
/** * Controller method to remove a video **/ public function deleteVideo($videoId = 0, $redirect = true) { if ($this->blockUnregister()) { return; } // Load libraries CFactory::load('models', 'videos'); $video = JTable::getInstance('Video', 'CTable'); $mainframe = JFactory::getApplication(); $video->load((int) $videoId); if (!empty($video->groupid)) { CFactory::load('helpers', 'group'); $allowManageVideos = CGroupHelper::allowManageVideo($video->groupid); CError::assert($allowManageVideos, '', '!empty', __FILE__, __LINE__); } // @rule: Add point when user removes a video CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('video.remove', $video->creator); if ($video->delete()) { // Delete all videos related data $this->_deleteVideoWalls($video->id); $this->_deleteVideoActivities($video->id); $this->_deleteFeaturedVideos($video->id); $this->_deleteVideoFiles($video); $this->_deleteProfileVideo($video->creator, $video->id); if (!empty($video->groupid)) { $message = JText::sprintf('CC VIDEO REMOVED', $video->title); $redirect = CRoute::_('index.php?option=com_community&view=videos&groupid=' . $video->groupid, false); } else { $message = JText::sprintf('CC VIDEO REMOVED', $video->title); $redirect = CRoute::_('index.php?option=com_community&view=videos', false); } /** HTGMOD **/ $this->_triggerEvent('onAfterVideoDelete', $video); /** END HTGMOD **/ } if ($redirect === true) { $mainframe->redirect($redirect, $message); } return $message; }
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; } }
/** * Displays specific groups **/ function viewGroup() { $mainframe =& JFactory::getApplication(); CFactory::load('libraries', 'tooltip'); CFactory::load('libraries', 'wall'); CFactory::load('libraries', 'window'); CWindow::load(); $config = CFactory::getConfig(); $document =& JFactory::getDocument(); // Load appropriate models $groupModel = CFactory::getModel('groups'); $wallModel = CFactory::getModel('wall'); $userModel = CFactory::getModel('user'); $discussModel = CFactory::getModel('discussions'); $bulletinModel = CFactory::getModel('bulletins'); $photosModel = CFactory::getModel('photos'); $groupid = JRequest::getInt('groupid', ''); CError::assert($groupid, '', '!empty', __FILE__, __LINE__); $editGroup = JRequest::getVar('edit', false, 'GET'); $editGroup = $editGroup == 1 ? true : false; // Load the group table. $group =& JTable::getInstance('Group', 'CTable'); $group->load($groupid); $params = $group->getParams(); CFactory::load('helpers', 'string'); $mainframe->appendMetaTag('title', CStringHelper::escape($group->name)); $mainframe->appendMetaTag('description', CStringHelper::escape(strip_tags($group->description))); $mainframe->addCustomHeadTag('<link rel="image_src" href="' . JURI::root() . $group->thumb . '" />'); // @rule: Test if the group is unpublished, don't display it at all. if (!$group->published) { echo JText::_('CC GROUP UNPUBLISHED'); return; } // Show submenu $this->showSubmenu(); // Set the group info to contain proper <br> $group->description = nl2br($group->description); $this->addPathway(JText::_('CC GROUPS'), CRoute::_('index.php?option=com_community&view=groups')); $this->addPathway(JText::sprintf('CC VIEW GROUP TITLE', $group->name), ''); // Load the current browsers data $my = CFactory::getUser(); // If user are invited $isInvited = $groupModel->isInvited($my->id, $groupid); // Get members list for display $members = $groupModel->getMembers($groupid, 12, true, CC_RANDOMIZE, true); $membersCount = $groupModel->total; CError::assert($members, 'array', 'istype', __FILE__, __LINE__); // Is there any my friend is the member of this group? $join = ''; $friendsCount = 0; if ($isInvited) { // Get the invitors $invitors = $groupModel->getInvitors($my->id, $groupid); if (count($invitors) == 1) { $user = CFactory::getUser($invitors[0]->creator); $join = '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } else { for ($i = 0; $i < count($invitors); $i++) { $user = CFactory::getUser($invitors[$i]->creator); if ($i + 1 == count($invitors)) { $join .= ' ' . JText::_('CC AND') . ' ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } else { $join .= ', ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } } } // Get users friends in this group $friendsCount = $groupModel->getFriendsCount($my->id, $groupid); } $admins = $groupModel->getAdmins($groupid, 12, CC_RANDOMIZE); $adminsCount = $groupModel->total; // Get the news $bulletins = $bulletinModel->getBulletins($group->id); $totalBulletin = $bulletinModel->total; CError::assert($bulletins, 'array', 'istype', __FILE__, __LINE__); // Get discussions $discussions = $discussModel->getDiscussionTopics($group->id, '10', $params->get('discussordering', DISCUSSION_ORDER_BYLASTACTIVITY)); $totalDiscussion = $discussModel->total; CError::assert($discussions, 'array', 'istype', __FILE__, __LINE__); // Get list of unapproved members $unapproved = $groupModel->getMembers($group->id, null, false); // Attach avatar of the member to the discussions for ($i = 0; $i < count($discussions); $i++) { $row =& $discussions[$i]; $row->user = CFactory::getUser($row->creator); // Get last replier for the discussion $row->lastreplier = $discussModel->getLastReplier($row->id); if ($row->lastreplier) { $row->lastreplier->post_by = CFactory::getUser($row->lastreplier->post_by); } } // Attach avatar of the admin for ($i = 0; $i < count($admins); $i++) { $row =& $admins[$i]; $admins[$i] = CFactory::getUser($row->id); } // Attach avatar of the member // Pre-load multiple users at once $userids = array(); foreach ($members as $uid) { $userids[] = $uid->id; } CFactory::loadUsers($userids); for ($i = 0; $i < count($members); $i++) { $row =& $members[$i]; $members[$i] = CFactory::getUser($row->id); } // Test if the current user is admin $isAdmin = $groupModel->isAdmin($my->id, $group->id); // Test if the current browser is a member of the group $isMember = $group->isMember($my->id); $waitingApproval = false; // Test if the current user is banned from this group $isBanned = $group->isBanned($my->id); if ($isBanned) { $mainframe->enqueueMessage(JText::_('CC GROUP MEMBER BANNED'), 'error'); } // If I have tried to join this group, but not yet approved, display a notice if ($groupModel->isWaitingAuthorization($my->id, $group->id)) { $waitingApproval = true; } // Get the walls $wallContent = CWallLibrary::getWallContents('groups', $group->id, $isAdmin, 10, 0, 'wall.content', 'groups,group'); $wallCount = CWallLibrary::getWallCount('groups', $group->id); $viewAllLink = false; if (JRequest::getVar('task', '', 'REQUEST') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=app&groupid=' . $group->id . '&app=walls'); } $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount); $wallForm = ''; CFactory::load('helpers', 'owner'); if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && ($isMember && !$isBanned) && !$waitingApproval || COwnerHelper::isCommunityAdmin()) { $wallForm = CWallLibrary::getWallInputForm($group->id, 'groups,ajaxSaveWall', 'groups,ajaxRemoveWall'); } // Get like CFactory::load('libraries', 'like'); $likes = new CLike(); $likesHTML = $isMember && !$isBanned ? $likes->getHTML('groups', $group->id, $my->id) : $likes->getHtmlPublic('groups', $group->id); // Process discussions HTML output $tmpl = new CTemplate(); $tmpl->set('discussions', $discussions); $tmpl->set('groupId', $group->id); $discussionsHTML = $tmpl->fetch('groups.discussionlist'); unset($tmpl); // Get the creator of the discussions for ($i = 0; $i < count($bulletins); $i++) { $row =& $bulletins[$i]; $row->creator = CFactory::getUser($row->created_by); } // Only trigger the bulletins if there is really a need to. if (!empty($bulletins)) { $appsLib =& CAppPlugins::getInstance(); $appsLib->loadApplications(); // Format the bulletins // the bulletins need to be an array or reference to work around // PHP 5.3 pass by value $args = array(); foreach ($bulletins as &$b) { $args[] =& $b; } $appsLib->triggerEvent('onBulletinDisplay', $args); } // Process bulletins HTML output $tmpl = new CTemplate(); $tmpl->set('bulletins', $bulletins); $tmpl->set('groupId', $group->id); $bulletinsHTML = $tmpl->fetch('groups.bulletinlist'); unset($tmpl); $tmpl = new CTemplate(); // Get categories list // We should really load this in saperate file // @todo: editing group should really open a new page if ($my->id == $group->ownerid || COwnerHelper::isCommunityAdmin()) { $categories = $groupModel->getCategories(); CError::assert($categories, 'array', 'istype', __FILE__, __LINE__); $tmpl->set('categories', $categories); } $isMine = $my->id == $group->ownerid; // Get reporting html CFactory::load('libraries', 'reporting'); $report = new CReportingLibrary(); $reportHTML = $report->getReportingHTML(JText::_('CC REPORT GROUP'), 'groups,reportGroup', array($group->id)); $isSuperAdmin = COwnerHelper::isCommunityAdmin(); if ($group->approvals == '1' && !$isMine && !$isMember && !$isSuperAdmin) { $this->addWarning(JText::_('CC PRIVATE GROUP NOTICE')); } $albums =& $photosModel->getGroupAlbums($group->id, true, false, $params->get('grouprecentphotos', GROUP_PHOTO_RECENT_LIMIT)); $totalAlbums = $photosModel->total; CFactory::load('helpers', 'videos'); CFactory::load('libraries', 'videos'); CFactory::load('helpers', 'group'); $videoModel = CFactory::getModel('videos'); $tmpVideos = $videoModel->getGroupVideos($group->id, '', $params->get('grouprecentvideos', GROUP_VIDEO_RECENT_LIMIT)); $videos = array(); if ($tmpVideos) { foreach ($tmpVideos as $videoEntry) { $video =& JTable::getInstance('Video', 'CTable'); $video->bind($videoEntry); $videos[] = $video; } } $videoThumbWidth = CVideoLibrary::thumbSize('width'); $videoThumbHeight = CVideoLibrary::thumbSize('height'); $totalVideos = $videoModel->total; $eventsModel = CFactory::getModel('Events'); $tmpEvents =& $eventsModel->getGroupEvents($group->id, $params->get('grouprecentevents', GROUP_EVENT_RECENT_LIMIT)); $totalEvents = $eventsModel->getTotalGroupEvents($group->id); $events = array(); foreach ($tmpEvents as $event) { $table =& JTable::getInstance('Event', 'CTable'); $table->bind($event); $events[] = $table; } $allowManagePhotos = CGroupHelper::allowManagePhoto($group->id); $allowManageVideos = CGroupHelper::allowManageVideo($group->id); $allowCreateEvent = CGroupHelper::allowCreateEvent($my->id, $group->id); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id)); $bookmarksHTML = $bookmarks->getHTML(); $isCommunityAdmin = COwnerHelper::isCommunityAdmin(); if ($group->approvals == '0' || $isMine || $isMember && !$isBanned || $isCommunityAdmin) { // Set feed url $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewbulletins&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO BULLETIN FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO DISCUSSION FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=photos&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO GROUP PHOTOS FEEDS') . '" href="' . $feedLink . '"/>'; $mainframe->addCustomHeadTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=videos&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO GROUP VIDEOS FEEDS') . '" href="' . $feedLink . '"/>'; $mainframe->addCustomHeadTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=events&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('CC SUBSCRIBE TO GROUP EVENTS FEEDS') . '" href="' . $feedLink . '"/>'; $mainframe->addCustomHeadTag($feed); } $friendsModel = CFactory::getModel('Friends'); $groupsModel = CFactory::getModel('Groups'); $tmpFriends = $friendsModel->getFriends($my->id, 'name', false); $friends = array(); for ($i = 0; $i < count($tmpFriends); $i++) { $friend =& $tmpFriends[$i]; $groupInvite =& JTable::getInstance('GroupInvite', 'CTable'); $groupInvite->load($group->id, $friend->id); if (!$groupsModel->isMember($friend->id, $group->id)) { $friends[] = $friend; } } unset($tmpFriends); CFactory::load('libraries', 'invitation'); $inviteHTML = CInvitation::getHTML($friends, 'groups,inviteUsers', $group->id); $tmpl->setMetaTags('group', $group); $tmpl->set('likesHTML', $likesHTML); $tmpl->set('events', $events); $tmpl->set('totalEvents', $totalEvents); $tmpl->set('inviteHTML', $inviteHTML); $tmpl->set('showEvents', $params->get('eventpermission') != -1); $tmpl->set('showPhotos', $params->get('photopermission') != -1); $tmpl->set('showVideos', $params->get('videopermission') != -1); $tmpl->set('bookmarksHTML', $bookmarksHTML); $tmpl->set('allowManagePhotos', $allowManagePhotos); $tmpl->set('allowManageVideos', $allowManageVideos); $tmpl->set('allowCreateEvent', $allowCreateEvent); $tmpl->set('videos', $videos); $tmpl->set('videoThumbWidth', $videoThumbWidth); $tmpl->set('videoThumbHeight', $videoThumbHeight); $tmpl->set('totalVideos', $totalVideos); $tmpl->set('albums', $albums); $tmpl->set('totalAlbums', $totalAlbums); $tmpl->set('reportHTML', $reportHTML); $tmpl->set('editGroup', $editGroup); $tmpl->set('waitingApproval', $waitingApproval); $tmpl->set('config', $config); $tmpl->set('my', $my); $tmpl->set('isMine', $isMine); $tmpl->set('isAdmin', $isAdmin); $tmpl->set('isSuperAdmin', $isSuperAdmin); $tmpl->set('isMember', $isMember); $tmpl->set('isInvited', $isInvited); $tmpl->set('friendsCount', $friendsCount); $tmpl->set('join', $join); $tmpl->set('unapproved', count($unapproved)); $tmpl->set('membersCount', $membersCount); $tmpl->set('group', $group); $tmpl->set('totalBulletin', $totalBulletin); $tmpl->set('totalDiscussion', $totalDiscussion); $tmpl->set('members', $members); $tmpl->set('admins', $admins); $tmpl->set('adminsCount', $adminsCount); $tmpl->set('bulletins', $bulletins); $tmpl->set('wallForm', $wallForm); $tmpl->set('wallContent', $wallContent); $tmpl->set('discussions', $discussions); $tmpl->set('discussionsHTML', $discussionsHTML); $tmpl->set('bulletinsHTML', $bulletinsHTML); $tmpl->set('isCommunityAdmin', $isCommunityAdmin); $tmpl->set('isBanned', $isBanned); echo $tmpl->fetch('groups.viewgroup'); }
public function upload() { $document = JFactory::getDocument(); $mainframe = JFactory::getApplication(); $my = $this->plugin->get('user'); $creatorType = JRequest::getVar('creatortype', VIDEO_USER_TYPE); $groupid = $creatorType == VIDEO_GROUP_TYPE ? JRequest::getInt('groupid', 0) : 0; $config = CFactory::getConfig(); CFactory::load('helpers', 'videos'); CFactory::load('libraries', 'videos'); $redirect = CVideosHelper::getVideoReturnUrlFromRequest(); // Process according to video creator type if (!empty($groupid)) { CFactory::load('helpers', 'group'); $allowManageVideos = CGroupHelper::allowManageVideo($groupid); $creatorType = VIDEO_GROUP_TYPE; $videoLimit = $config->get('groupvideouploadlimit'); CError::assert($allowManageVideos, '', '!empty', __FILE__, __LINE__); } else { $creatorType = VIDEO_USER_TYPE; $videoLimit = $config->get('videouploadlimit'); } // Check is video upload is permitted CFactory::load('helpers', 'limits'); if (CLimitsHelper::exceededVideoUpload($my->id, $creatorType)) { $message = JText::sprintf('CC VIDEOS CREATION REACH LIMIT', $videoLimit); $this->setError($message); return false; } if (!$config->get('enablevideos')) { $this->setError(JText::_('CC VIDEO DISABLED', 'notice')); return false; } if (!$config->get('enablevideosupload')) { $this->setError(JText::_('CC VIDEO UPLOAD DISABLED', 'notice')); return false; } // Check if the video file is valid $files = JRequest::get('files'); $videoFile = !empty($files['video']) ? $files['video'] : array(); if (empty($files) || empty($videoFile['name']) && $videoFile['size'] < 1) { $this->setError(JText::_('CC VIDEO UPLOAD ERROR', 'error')); return false; } // Check file type. $fileType = $videoFile['type']; // Override from iphone $fileType = 'video/quicktime'; $allowable = CVideosHelper::getValidMIMEType(); if (!in_array($fileType, $allowable)) { $this->setError(JText::sprintf('CC VIDEO FILE TYPE NOT SUPPORTED', $fileType)); return false; } // Check if the video file exceeds file size limit $uploadLimit = $config->get('maxvideouploadsize') * 1024 * 1024; $videoFileSize = sprintf("%u", filesize($videoFile['tmp_name'])); if ($uploadLimit > 0 && $videoFileSize > $uploadLimit) { $this->setError(JText::sprintf('CC VIDEO FILE SIZE EXCEEDED', $uploadLimit)); return false; } // Passed all checking, attempt to save the video file CFactory::load('helpers', 'file'); $folderPath = CVideoLibrary::getPath($my->id, 'original'); $randomFileName = CFileHelper::getRandomFilename($folderPath, $videoFile['name'], ''); $destination = JPATH::clean($folderPath . DS . $randomFileName); if (!CFileHelper::upload($videoFile, $destination)) { $this->setError(JText::_('CC VIDEO UPLOAD FAILED', 'error')); return false; } $config = CFactory::getConfig(); $videofolder = $config->get('videofolder'); CFactory::load('models', 'videos'); $video = JTable::getInstance('Video', 'CTable'); $video->set('path', $videofolder . '/originalvideos/' . $my->id . '/' . $randomFileName); $video->set('title', JRequest::getVar('title')); $video->set('description', JRequest::getVar('description')); $video->set('category_id', JRequest::getInt('category', 0, 'post')); $video->set('permissions', JRequest::getInt('privacy', 0, 'post')); $video->set('creator', $my->id); $video->set('creator_type', $creatorType); $video->set('groupid', $groupid); $video->set('filesize', $videoFileSize); if (!$video->store()) { $this->setError(JText::_('CC VIDEO SAVE ERROR', 'error')); return false; } // Trigger for onVideoCreate $this->_triggerEvent('onVideoCreate', $video); // Video saved, redirect return $video; }
/** * 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'); }
public function _groupVideo() { $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); // Get necessary properties and load the libraries CFactory::load('models', 'videos'); $my = CFactory::getUser(); $model = CFactory::getModel('videos'); $videoId = JRequest::getVar('videoid', '', 'GET'); $groupId = JRequest::getVar('groupid', '', 'GET'); $video = JTable::getInstance('Video', 'CTable'); $video->load($videoId); $video->loadExtra(); CFactory::load('helpers', 'owner'); $user = CFactory::getUser($video->creator); $blocked = $user->isBlocked(); if ($blocked && !COwnerHelper::isCommunityAdmin()) { $tmpl = new CTemplate(); echo $tmpl->fetch('profile.blocked'); return; } if (empty($videoId)) { $url = CRoute::_('index.php?option=com_community&view=videos', false); $mainframe->redirect($url, JText::_('COM_COMMUNITY_VIDEOS_ID_ERROR'), 'warning'); } CFactory::load('helpers', 'group'); // Check permission if (!CGroupHelper::allowViewMedia($groupId)) { // Set document title $document->setTitle(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS')); $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_RESTRICTED_ACCESS', 'notice')); echo JText::_('COM_COMMUNITY_GROUPS_VIDEO_MEMBER_PERMISSION'); } else { // Get extra properties $video->player = $video->getViewHTML($video->getWidth(), $video->getHeight()); $video->hit(); // Get reporting html $reportHTML = ''; CFactory::load('libraries', 'reporting'); $report = new CReportingLibrary(); $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_VIDEOS_REPORT_VIDEOS'), 'videos,reportVideo', array($video->id)); // Set pathway $pathway =& $mainframe->getPathway(); $pathway->addItem('Video', CRoute::_('index.php?option=com_community&view=videos')); $pathway->addItem($video->title, ''); // Set the current user's active profile CFactory::setActiveProfile($video->creator); // Set document title $document->setTitle($video->title); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks($video->permalink); $bookmarksHTML = $bookmarks->getHTML(); $tmpl = new CTemplate(); // Get the walls CFactory::load('libraries', 'wall'); $wallContent = CWallLibrary::getWallContents('videos', $video->id, COwnerHelper::isCommunityAdmin() || $my->id == $video->creator && $my->id != 0, 10, 0); $wallForm = ''; $viewAllLink = false; if (JRequest::getVar('task', '', 'REQUEST') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=videos&task=app&videoid=' . $video->id . '&app=walls'); } $wallForm = CWallLibrary::getWallInputForm($video->id, 'videos,ajaxSaveWall', 'videos,ajaxRemoveWall', $viewAllLink); $redirectUrl = CRoute::getURI(false); $tmpl->set('redirectUrl', $redirectUrl); $tmpl->set('wallForm', $wallForm); $tmpl->set('wallContent', $wallContent); $tmpl->set('bookmarksHTML', $bookmarksHTML); $tmpl->set('reportHTML', $reportHTML); $tmpl->set('video', $video); echo $tmpl->fetch('videos.video'); } }
public function ajaxShowVideoFeatured($video_id) { $objResponse = new JAXResponse(); $allowToView = true; //determine the view premission $my = CFactory::getUser(); $video = JTable::getInstance('Video', 'CTable'); if (!$video->load($video_id)) { $allowToView = false; } /* === Start Premission Checking === */ $user = CFactory::getUser($video->creator); $blocked = $user->isBlocked(); if ($blocked && !COwnerHelper::isCommunityAdmin()) { $allowToView = false; } if ($video->creator_type == VIDEO_GROUP_TYPE) { //CFactory::load( 'helpers' , 'group' ); if (!CGroupHelper::allowViewMedia($video->groupid)) { $allowToView = false; } } else { if (!CPrivacy::isAccessAllowed($my->id, $video->creator, 'custom', $video->permissions)) { switch ($video->permissions) { case '40': $allowToView = false; break; case '30': $allowToView = false; $this->noAccess(JText::sprintf('COM_COMMUNITY_VIDEOS_FRIEND_PERMISSION_MESSAGE', $owner->getDisplayName())); break; default: $allowToView = false; break; } } } /* === End Permission Checking === */ if ($allowToView) { // Hit counter + 1 $video->hit(); $notiHtml = '<div class="cVideo-Player video-player"> ' . $video->getPlayerHTML() . ' </div>'; } else { $notiHtml = JText::_('COM_COMMUNITY_VIDEO_UNABLE_VIEW'); } // Get like //CFactory::load( 'libraries' , 'like' ); $likes = new CLike(); $likesHTML = $likes->getHTML('videos', $video->id, $my->id); // Get wall count //CFactory::load( 'libraries' , 'wall' ); $wallCount = CWallLibrary::getWallCount('videos', $video->id); // Get video link $videoCommentLink = CRoute::_('index.php?option=com_community&view=videos&task=video&videoid=' . $video->id . '&groupid=' . $video->groupid . '&userid=' . $video->creator . '#comments'); $videoLink = CRoute::_('index.php?option=com_community&view=videos&task=video&videoid=' . $video->id . '&groupid=' . $video->groupid . '&userid=' . $video->creator); $creatorName = $video->getCreatorName(); $creatorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $video->creator); $objResponse->addScriptCall('updatePlayer', $notiHtml, $video->title, $likesHTML, $video->getHits(), $wallCount, $videoLink, $videoCommentLink, $creatorName, $creatorLink); $objResponse->sendResponse(); }
/** * Displays specific groups **/ public function viewGroup($group) { $mainframe =& JFactory::getApplication(); CFactory::load('libraries', 'tooltip'); CFactory::load('libraries', 'wall'); CFactory::load('libraries', 'window'); CFactory::load('libraries', 'videos'); CFactory::load('libraries', 'activities'); CFactory::load('helpers', 'group'); CWindow::load(); $config = CFactory::getConfig(); $document = JFactory::getDocument(); $groupLib = new CGroups(); // Load appropriate models $groupModel = CFactory::getModel('groups'); $wallModel = CFactory::getModel('wall'); $userModel = CFactory::getModel('user'); $discussModel = CFactory::getModel('discussions'); $bulletinModel = CFactory::getModel('bulletins'); $photosModel = CFactory::getModel('photos'); $activityModel = CFactory::getModel('activities'); //$groupid = JRequest::getInt( 'groupid' , '' ); //CError::assert( $groupid , '' , '!empty' , __FILE__ , __LINE__ ); $editGroup = JRequest::getVar('edit', false, 'GET'); $editGroup = $editGroup == 1 ? true : false; $params = $group->getParams(); CFactory::load('helpers', 'string'); $document->setMetaData('title', CStringHelper::escape($group->name)); $document->setMetaData('description', CStringHelper::escape(strip_tags($group->description))); $document->addCustomTag('<link rel="image_src" href="' . JURI::root() . $group->thumb . '" />'); // @rule: Test if the group is unpublished, don't display it at all. if (!$group->published) { $this->_redirectUnpublishGroup(); return; } // Show submenu $this->showSubmenu(); // Set the group info to contain proper <br> $group->description = nl2br($group->description); $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups')); $this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_NAME_TITLE', $group->name), ''); // Load the current browsers data $my = CFactory::getUser(); // If user are invited $isInvited = $groupModel->isInvited($my->id, $group->id); // Get members list for display //$members = $groupModel->getAllMember($group->id); //Set limit for member listing on view group page $limit = 12; $approvedMembers = $groupModel->getMembers($group->id, $limit, true, false, true); CError::assert($approvedMembers, 'array', 'istype', __FILE__, __LINE__); $membersCount = $groupModel->total; // Is there any my friend is the member of this group? $join = ''; $friendsCount = 0; if ($isInvited) { // Get the invitors $invitors = $groupModel->getInvitors($my->id, $group->id); if (count($invitors) == 1) { $user = CFactory::getUser($invitors[0]->creator); $join = '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } else { for ($i = 0; $i < count($invitors); $i++) { $user = CFactory::getUser($invitors[$i]->creator); if ($i + 1 == count($invitors)) { $join .= ' ' . JText::_('COM_COMMUNITY_AND') . ' ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } else { $join .= ', ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>'; } } } // Get users friends in this group $friendsCount = $groupModel->getFriendsCount($my->id, $group->id); } $admins = $groupModel->getAdmins($group->id, $limit, CC_RANDOMIZE); // Get list of unapproved members $groupModel->getMembers($group->id, null, false); $unapproved = $groupModel->total; //Get list of approved members // Test if the current user is admin $isAdmin = $groupModel->isAdmin($my->id, $group->id); // Test if the current browser is a member of the group $isMember = $groupModel->isMember($my->id, $group->id); $waitingApproval = false; // Test if the current user is banned from this group $isBanned = $group->isBanned($my->id); // Attach avatar of the member // Pre-load multiple users at once $userids = array(); $limitloop = $limit; foreach ($approvedMembers as $uid) { $userids[] = $uid->id; if (--$limitloop < 1) { break; } } CFactory::loadUsers($userids); $limitloop = $limit; for ($i = 0; $i < count($approvedMembers); $i++) { $row =& $approvedMembers[$i]; $approvedMembers[$i] = CFactory::getUser($row->id); if (--$limitloop < 1) { break; } } if ($isBanned) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_GROUPS_MEMBER_BANNED'), 'error'); } // If I have tried to join this group, but not yet approved, display a notice if ($groupModel->isWaitingAuthorization($my->id, $group->id)) { $waitingApproval = true; } // Get the walls if (!$isBanned) { $wallContent = CWallLibrary::getWallContents('groups', $group->id, $isAdmin, 10, 0, 'wall.content', 'groups,group'); } else { $wallContent = CWallLibrary::getWallContents('groups', $group->id, $isAdmin, 10, 0, 'wall.content', 'groups,group', null, '1'); } $wallCount = CWallLibrary::getWallCount('groups', $group->id); $viewAllLink = false; if (JRequest::getVar('task', '', 'REQUEST') != 'app') { $viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=app&groupid=' . $group->id . '&app=walls'); } $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount); $wallForm = ''; CFactory::load('helpers', 'owner'); if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && ($isMember && !$isBanned) && !$waitingApproval || COwnerHelper::isCommunityAdmin()) { $wallForm = CWallLibrary::getWallInputForm($group->id, 'groups,ajaxSaveWall', 'groups,ajaxRemoveWall'); } // Get like CFactory::load('libraries', 'like'); $likes = new CLike(); $likesHTML = $isMember && !$isBanned ? $likes->getHTML('groups', $group->id, $my->id) : $likes->getHtmlPublic('groups', $group->id); // Get discussions data $discussionData = $this->_cachedCall('_getDiscussionListHTML', array($params, $group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL)); $discussionsHTML = $discussionData['HTML']; $totalDiscussion = $discussionData['total']; $discussions = $discussionData['data']; // Get bulletins data $bulletinData = $this->_cachedCall('_getBulletinListHTML', array($group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL)); $totalBulletin = $bulletinData['total']; $bulletinsHTML = $bulletinData['HTML']; $bulletins = $bulletinData['data']; // Get album data $albumData = $this->_cachedCall('_getAlbums', array($params, $group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL)); $albums = $albumData['data']; $totalAlbums = $albumData['total']; // Get video data $videoData = $this->_getVideos($params, $group->id); $videos = $videoData['data']; $totalVideos = $videoData['total']; $tmpl = new CTemplate(); // Get categories list // We should really load this in saperate file // @todo: editing group should really open a new page if ($my->id == $group->ownerid || COwnerHelper::isCommunityAdmin()) { $categories = $groupModel->getCategories(); CError::assert($categories, 'array', 'istype', __FILE__, __LINE__); $tmpl->set('categories', $categories); } $isMine = $my->id == $group->ownerid; // Get reporting html CFactory::load('libraries', 'reporting'); $report = new CReportingLibrary(); $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_REPORT_GROUP'), 'groups,reportGroup', array($group->id)); $isSuperAdmin = COwnerHelper::isCommunityAdmin(); if ($group->approvals == '1' && !$isMine && !$isMember && !$isSuperAdmin) { $this->addWarning(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE')); } $videoThumbWidth = CVideoLibrary::thumbSize('width'); $videoThumbHeight = CVideoLibrary::thumbSize('height'); $eventsModel = CFactory::getModel('Events'); $tmpEvents =& $eventsModel->getGroupEvents($group->id, $params->get('grouprecentevents', GROUP_EVENT_RECENT_LIMIT)); $totalEvents = $eventsModel->getTotalGroupEvents($group->id); $events = array(); foreach ($tmpEvents as $event) { $table =& JTable::getInstance('Event', 'CTable'); $table->bind($event); $events[] = $table; } $allowManagePhotos = CGroupHelper::allowManagePhoto($group->id); $allowManageVideos = CGroupHelper::allowManageVideo($group->id); $allowCreateEvent = CGroupHelper::allowCreateEvent($my->id, $group->id); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id)); $bookmarksHTML = $bookmarks->getHTML(); $isCommunityAdmin = COwnerHelper::isCommunityAdmin(); if ($group->approvals == '0' || $isMine || $isMember && !$isBanned || $isCommunityAdmin) { // Set feed url $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewbulletins&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_BULLETIN_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_DISCUSSION_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=photos&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_PHOTOS_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=videos&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_VIDEOS_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); $feedLink = CRoute::_('index.php?option=com_community&view=events&groupid=' . $group->id . '&format=feed'); $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_EVENTS_FEEDS') . '" href="' . $feedLink . '"/>'; $document->addCustomTag($feed); } $friendsModel = CFactory::getModel('Friends'); $groupsModel = CFactory::getModel('Groups'); CFactory::load('libraries', 'invitation'); $inviteHTML = CInvitation::getHTML(null, 'groups,inviteUsers', $group->id); // Add tagging code /* $tagsHTML = ''; if($config->get('tags_groups')){ CFactory::load('libraries', 'tags'); $tags = new CTags(); $tagsHTML = $tags->getHTML('groups', $group->id, $isAdmin ); } */ // Upgrade wall to stream @since 2.5 if (!$params->get('stream', FALSE)) { $group->upgradeWallToStream(); } // Add custom stream $activities = new CActivities(); $streamHTML = $groupLib->getStreamHTML($group); $totalStream = $activityModel->getTotalActivities(array("`groupid` = '{$group->id}'")); CFactory::load('libraries', 'userstatus'); $creators = array(); $creators[] = CUserStatusCreator::getMessageInstance(); if ($isAdmin && $params->get('photopermission') == 1 || $isMember && $params->get('photopermission') == 2) { $creators[] = CUserStatusCreator::getPhotoInstance(); } if ($isAdmin && $params->get('videopermission') == 1 || $isMember && $params->get('videopermission') == 2) { $creators[] = CUserStatusCreator::getVideoInstance(); } if ($allowCreateEvent && $config->get('group_events') && $config->get('enableevents') && ($config->get('createevents') || COwnerHelper::isCommunityAdmin())) { $creators[] = CUserStatusCreator::getEventInstance(); } $status = new CUserStatus($group->id, 'groups', $creators); // Get Event Admins $groupAdmins = $group->getAdmins(12, CC_RANDOMIZE); $adminsInArray = array(); // Attach avatar of the admin for ($i = 0; $i < count($groupAdmins); $i++) { $row =& $groupAdmins[$i]; $admin = CFactory::getUser($row->id); array_push($adminsInArray, '<a href="' . CUrlHelper::userLink($admin->id) . '">' . $admin->getDisplayName() . '</a>'); } $adminsList = ltrim(implode(', ', $adminsInArray), ','); echo $tmpl->setMetaTags('group', $group)->set('streamHTML', $streamHTML)->set('status', $status)->set('likesHTML', $likesHTML)->set('events', $events)->set('totalEvents', $totalEvents)->set('inviteHTML', $inviteHTML)->set('showEvents', $config->get('group_events') && $config->get('enableevents'))->set('showPhotos', $params->get('photopermission') != -1)->set('showVideos', $params->get('videopermission') != -1)->set('bookmarksHTML', $bookmarksHTML)->set('allowManagePhotos', $allowManagePhotos)->set('allowManageVideos', $allowManageVideos)->set('allowCreateEvent', $allowCreateEvent)->set('videos', $videos)->set('videoThumbWidth', $videoThumbWidth)->set('videoThumbHeight', $videoThumbHeight)->set('totalVideos', $totalVideos)->set('albums', $albums)->set('totalAlbums', $totalAlbums)->set('reportHTML', $reportHTML)->set('editGroup', $editGroup)->set('waitingApproval', $waitingApproval)->set('config', $config)->set('my', $my)->set('isMine', $isMine)->set('isAdmin', $isAdmin)->set('isSuperAdmin', $isSuperAdmin)->set('isMember', $isMember)->set('isInvited', $isInvited)->set('friendsCount', $friendsCount)->set('join', $join)->set('unapproved', $unapproved)->set('membersCount', $membersCount)->set('group', $group)->set('totalBulletin', $totalBulletin)->set('totalDiscussion', $totalDiscussion)->set('totalVideos', $totalVideos)->set('members', $approvedMembers)->set('bulletins', $bulletins)->set('wallForm', $wallForm)->set('wallContent', $wallContent)->set('discussions', $discussions)->set('discussionsHTML', $discussionsHTML)->set('bulletinsHTML', $bulletinsHTML)->set('isCommunityAdmin', $isCommunityAdmin)->set('isBanned', $isBanned)->set('isPrivate', $group->approvals)->set('limit', $limit)->set('adminsList', $adminsList)->set('alertNewDiscussion', $my->count('group_discussion_' . $group->id) != $totalDiscussion)->set('alertNewBulletin', $my->count('group_bulletin_' . $group->id) != $totalBulletin)->set('alertNewStream', $my->count('group_activity_' . $group->id) != $totalStream)->fetch('groups.viewgroup'); // Update stream count cache, can only set this after we've set the alert aove $my->setCount('group_activity_' . $group->id, $totalStream); }
public function _addSubmenu() { $my = CFactory::getUser(); $config = CFactory::getConfig(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $task = $jinput->request->get('task', '', 'WORD'); $groupId = $jinput->get->get('groupid', 0, 'INT'); $eventId = $jinput->get->get('eventid', 0, 'INT'); if (!empty($groupId)) { /* $group = JTable::getInstance('Group', 'CTable'); $group->load($groupId); $isBanned = $group->isBanned($my->id); */ $videos = $this->model->hasPendingVideos($groupId, VIDEO_GROUP_TYPE); if ($videos) { $this->addSubmenuItem('index.php?option=com_community&view=videos&task=mypendingvideos&groupid=' . $groupId, JText::_('COM_COMMUNITY_VIDEOS_GROUP_PENDING'), '', SUBMENU_LEFT); } $allowManageVideos = CGroupHelper::allowManageVideo($groupId); } elseif ($eventId) { $videos = $this->model->hasPendingVideos($eventId, VIDEO_EVENT_TYPE); if ($videos) { $this->addSubmenuItem('index.php?option=com_community&view=videos&task=mypendingvideos&eventid=' . $eventId, JText::_('COM_COMMUNITY_VIDEOS_EVENT_PENDING'), '', SUBMENU_LEFT); } } else { $this->addSubmenuItem('index.php?option=com_community&view=videos&task=display', JText::_('COM_COMMUNITY_VIDEOS_ALL_DESC'), '', false, '', 'joms-right'); if (!empty($my->id)) { $this->addSubmenuItem('index.php?option=com_community&view=videos&task=myvideos&userid=' . $my->id, JText::_('COM_COMMUNITY_VIDEOS_MY'), '', false, '', 'joms-right'); //$this->addSubmenuItem('', JText::_('COM_COMMUNITY_ADD'), 'joms.videos.addVideo()', SUBMENU_RIGHT); } // if ((!$config->get('enableguestsearchvideos') && COwnerHelper::isRegisteredUser()) || $config->get( // 'enableguestsearchvideos' // ) // ) { // $tmpl = new CTemplate(); // $tmpl->set('url', CRoute::_('index.php?option=com_community&view=videos&task=search')); // $html = $tmpl->fetch('videos.search.submenu'); // $this->addSubmenuItem( // 'index.php?option=com_community&view=videos&task=search', // JText::_('COM_COMMUNITY_SEARCH'), // 'joms.videos.toggleSearchSubmenu(this)', // SUBMENU_LEFT, // $html // ); // } $videos = $this->model->hasPendingVideos($my->id, VIDEO_USER_TYPE); if (!empty($my->id) && $videos && $task != 'mypendingvideos') { $this->addSubmenuItem('index.php?option=com_community&view=videos&task=mypendingvideos&userid=' . $my->id, JText::_('COM_COMMUNITY_VIDEOS_PENDING'), '', SUBMENU_LEFT); } } }
public function isAllowedAlbumCreation() { $allowManagePhotos = CGroupHelper::allowManagePhoto($this->groupid); return $allowManagePhotos; }
/** * Allows us to test if the user has access to the album * */ public function hasAccess($userId, $permissionType) { // @rule: For super admin, regardless of what permission, they should be able to access if (COwnerHelper::isCommunityAdmin()) { return true; } switch ($this->type) { case PHOTOS_PROFILE_TYPE: case PHOTOS_USER_TYPE: if ($permissionType == 'upload') { return $this->creator == $userId; } if ($permissionType == 'deletephotos') { return $this->creator == $userId; } break; case PHOTOS_GROUP_TYPE: $group = JTable::getInstance('Group', 'CTable'); $group->load($this->groupid); if ($permissionType == 'upload') { return CGroupHelper::allowManagePhoto($group->id); } if ($permissionType == 'deletephotos') { return $this->creator == $userId || $group->isAdmin($userId); } return false; break; case PHOTOS_EVENT_TYPE: $event = JTable::getInstance('Event', 'CTable'); $event->load($this->eventid); if ($permissionType == 'upload') { return CEventHelper::allowManagePhoto($event->id); } if ($permissionType == 'deletephotos') { return $this->creator == $userId || $event->isAdmin($userId); } return false; break; } }
public function setSubmenus() { //CFactory::load( 'helpers' , 'group' ); //CFactory::load( 'helpers' , 'owner' ); $jinput = JFactory::getApplication()->input; $task = $userid = $jinput->get('task', '', 'WORD'); //JRequest::getVar( 'task', '', 'GET' ); $albumId = $userid = $jinput->get('albumid', 0, 'INT'); //JRequest::getInt( 'albumid', 0 , 'REQUEST'); $groupId = $userid = $jinput->get('groupid', 0, 'INT'); //JRequest::getInt( 'groupid', '', 'REQUEST' ); if (!empty($albumId)) { $album = JTable::getInstance('Album', 'CTable'); $album->load($albumId); $groupId = $album->groupid; } //CFactory::load( 'models' , 'groups' ); $config = CFactory::getConfig(); $group = JTable::getInstance('Group', 'CTable'); $group->load($groupId); $my = CFactory::getUser(); $albumId = $albumId != 0 ? $albumId : ''; // Check if the current user is banned from this group $isBanned = $group->isBanned($my->id); $allowManagePhotos = CGroupHelper::allowManagePhoto($this->groupid); if (($task == 'uploader' || $task == 'photo') && !empty($albumId)) { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&groupid=' . $this->groupid . '&task=album&albumid=' . $albumId, JText::_('COM_COMMUNITY_PHOTOS_BACK_TO_ALBUM')); } if ($allowManagePhotos && $task != 'photo' && !$isBanned) { /* Group: Upload Photos */ if ($task != 'newalbum' && $task != 'editAlbum') { //$this->view->addSubmenuItem('javascript:void(0);', JText::_('COM_COMMUNITY_PHOTOS_UPLOAD_PHOTOS'), 'joms.notifications.showUploadPhoto(\'' . $albumId . '\',' . $this->groupid . '); return false;', true, '', ''); } if ($task == 'album' && ($my->id == $album->creator && $allowManagePhotos || $group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin())) { $this->view->addSubmenuItem('javascript:', JText::_('COM_COMMUNITY_PHOTOS_ALBUM_DELETE'), "joms.api.albumRemove('" . $album->id . "', '" . $task . "');", true); $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=editAlbum&albumid=' . $album->id . '&groupid=' . $group->id . '&referrer=albumgrp', JText::_('COM_COMMUNITY_EDIT_ALBUM'), '', true); $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=display', JText::_('COM_COMMUNITY_PHOTOS_ALL_PHOTOS'), '', false, '', 'joms-right'); if ($my->id != 0) { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=myphotos&userid=' . $my->id, JText::_('COM_COMMUNITY_PHOTOS_MY_PHOTOS'), '', false, '', 'joms-right'); } } //$this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $this->groupid, JText::_('COM_COMMUNITY_PHOTOS_CREATE_PHOTO_ALBUM'), '', true, '', ''); } if ($task == 'photo') { if ($album->hasAccess($my->id, 'deletephotos')) { $this->view->addSubmenuItem('', JText::_('COM_COMMUNITY_PHOTOS_DELETE'), "joms_delete_photo();", true); } if ($my->id == $album->creator) { $this->view->addSubmenuItem('', JText::_('COM_COMMUNITY_PHOTOS_SET_AVATAR'), "joms_set_as_profile_picture();", true); } if ($my->id == $album->creator && $allowManagePhotos || $group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin()) { $this->view->addSubmenuItem('', JText::_('COM_COMMUNITY_PHOTOS_SET_AS_ALBUM_COVER'), "joms_set_as_album_cover();", true); } if (!$config->get('deleteoriginalphotos')) { $this->view->addSubmenuItem('', JText::_('COM_COMMUNITY_DOWNLOAD_IMAGE'), "joms_download_photo();", true); } if ($groupId != '') { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $groupId, JText::_('COM_COMMUNITY_PHOTOS_CREATE_PHOTO_ALBUM'), '', true); } else { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=newalbum&userid=' . $my->id, JText::_('COM_COMMUNITY_PHOTOS_CREATE_PHOTO_ALBUM'), '', true); } } if ($task == "display") { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $groupId, JText::_('COM_COMMUNITY_PHOTOS_CREATE_PHOTO_ALBUM'), '', true); } //$this->view->addSubmenuItem('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $this->groupid, JText::_('COM_COMMUNITY_GROUPS_BACK_TO_GROUP')); }
public function setSubmenus() { CFactory::load('helpers', 'group'); CFactory::load('helpers', 'owner'); $task = JRequest::getVar('task', '', 'GET'); $albumId = JRequest::getInt('albumid', 0, 'REQUEST'); $groupId = JRequest::getInt('groupid', '', 'REQUEST'); if (!empty($albumId)) { $album = JTable::getInstance('Album', 'CTable'); $album->load($albumId); $groupId = $album->groupid; } CFactory::load('models', 'groups'); $config = CFactory::getConfig(); $group = JTable::getInstance('Group', 'CTable'); $group->load($groupId); $my = CFactory::getUser(); $albumId = $albumId != 0 ? '&albumid=' . $albumId : ''; // Check if the current user is banned from this group $isBanned = $group->isBanned($my->id); CFactory::load('helpers', 'group'); $allowManagePhotos = CGroupHelper::allowManagePhoto($this->groupid); if (($task == 'uploader' || $task == 'photo') && !empty($albumId)) { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&groupid=' . $this->groupid . '&task=album' . $albumId, JText::_('CC BACK TO ALBUM')); } if ($allowManagePhotos && $task != 'photo' && !$isBanned) { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=uploader&groupid=' . $this->groupid . $albumId, JText::_('CC UPLOAD PHOTOS'), '', true); if ($task == 'album' && ($my->id == $album->creator && $allowManagePhotos || $group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin())) { $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=editAlbum&albumid=' . $album->id . '&groupid=' . $group->id, JText::_('CC EDIT ALBUM'), '', true); } $this->view->addSubmenuItem('index.php?option=com_community&view=photos&task=newalbum&groupid=' . $this->groupid, JText::_('CC ADD ALBUM'), '', true); } if ($task == 'photo') { if ($album->hasAccess($my->id, 'deletephotos')) { $this->view->addSubmenuItem('', JText::_('CC DELETE IMAGE'), "joms.gallery.confirmRemovePhoto();", true); } if ($my->id == $album->creator) { $this->view->addSubmenuItem('', JText::_('CC SET AS PROFILE PICTURE'), "joms.gallery.setProfilePicture();", true); } if ($my->id == $album->creator && $allowManagePhotos || $group->isAdmin($my->id) || COwnerHelper::isCommunityAdmin()) { $this->view->addSubmenuItem('', JText::_('CC SET IMAGE AS ALBUM COVER'), "joms.gallery.setPhotoAsDefault();", true); } if (!$config->get('deleteoriginalphotos')) { $this->view->addSubmenuItem('', JText::_('CC DOWNLOAD IMAGE'), "joms.gallery.downloadPhoto();", true); } } $this->view->addSubmenuItem('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $this->groupid, JText::_('CC BACK TO GROUP')); }