Ejemplo n.º 1
0
 /**
  *
  * @param type $tpl
  * @return type
  */
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $groupId = $jinput->get('groupid', '', 'INT');
     $eventparent = $jinput->get('parent', '', 'INT');
     if (!empty($groupId)) {
         $group = JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         // @rule: Test if the group is unpublished, don't display it at all.
         if (!$group->published) {
             echo JText::_('COM_COMMUNITY_GROUPS_UNPUBLISH_WARNING');
             return;
         }
         if ($group->isPrivate() && !$group->isMember($my->id)) {
             echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION');
             return;
         }
         // Set pathway for group videos
         // Community > Groups > Group Name > Events
         $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
         $this->addPathway($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId));
     }
     //page title
     $this->addPathway(JText::_('COM_COMMUNITY_EVENTS'), CRoute::_('index.php?option=com_community&view=events'));
     // Get category id from the query string if there are any.
     $categoryId = $jinput->get('categoryid', 0, 'STRING');
     //string because it might contain featured_only
     $limitstart = $jinput->get('limitstart', 0, 'INT');
     //JRequest::getVar( 'limitstart' , 0 );
     $showFeaturedOnly = false;
     if (!is_numeric($categoryId) && $categoryId == 'featured_only') {
         $categoryId = 0;
         $showFeaturedOnly = true;
     }
     $category = JTable::getInstance('EventCategory', 'CTable');
     $category->load($categoryId);
     if ($groupId) {
         CHeadHelper::setType('website', JText::_('COM_COMMUNITY_GROUP_EVENT'));
     } else {
         if (isset($category) && $category->id != 0) {
             $title = JText::sprintf('COM_COMMUNITY_EVENTS_CATEGORY_NAME', str_replace('&', '&', JText::_($this->escape($category->name))));
             CHeadHelper::setType('website', $title);
         } else {
             CHeadHelper::setType('website', JText::_('COM_COMMUNITY_EVENTS'));
         }
     }
     $feedLink = CRoute::_('index.php?option=com_community&view=events&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_ALL_EVENTS_FEED') . '" href="' . $feedLink . '"/>';
     $document->addCustomTag($feed);
     $data = new stdClass();
     $sorted = $jinput->get('sort', 'startdate', 'STRING');
     /* begin: UNLIMITED LEVEL BREADCRUMBS PROCESSING */
     if ($category->parent == COMMUNITY_NO_PARENT) {
         $this->addPathway(JText::_($this->escape($category->name)), CRoute::_('index.php?option=com_community&view=events&task=display&categoryid=' . $category->id));
     } else {
         // Parent Category
         $parentsInArray = array();
         $n = 0;
         $parentId = $category->id;
         $parent = JTable::getInstance('EventCategory', 'CTable');
         do {
             $parent->load($parentId);
             $parentId = $parent->parent;
             $parentsInArray[$n]['id'] = $parent->id;
             $parentsInArray[$n]['parent'] = $parent->parent;
             $parentsInArray[$n]['name'] = $parent->name;
             $n++;
         } while ($parent->parent > COMMUNITY_NO_PARENT);
         for ($i = count($parentsInArray) - 1; $i >= 0; $i--) {
             $this->addPathway($parentsInArray[$i]['name'], CRoute::_('index.php?option=com_community&view=events&task=display&categoryid=' . $parentsInArray[$i]['id']));
         }
     }
     /* end: UNLIMITED LEVEL BREADCRUMBS PROCESSING */
     $data->categories = $this->_cachedCall('_getEventsCategories', array($category->id), '', array(COMMUNITY_CACHE_TAG_EVENTS_CAT));
     $model = CFactory::getModel('events');
     // Get event in category and it's children.
     $categories = $model->getAllCategories();
     $categoryIds = CCategoryHelper::getCategoryChilds($categories, $category->id);
     if ($category->id > 0) {
         $categoryIds[] = (int) $category->id;
     }
     //CFactory::load( 'helpers' , 'event' );
     $event = JTable::getInstance('Event', 'CTable');
     $handler = CEventHelper::getHandler($event);
     // It is safe to pass 0 as the category id as the model itself checks for this value.
     $data->events = $model->getEvents($categoryIds, null, $sorted, null, true, false, null, array('parent' => $eventparent), $showFeaturedOnly ? 'featured_only' : $handler->getContentTypes(), $handler->getContentId());
     // Get pagination object
     $data->pagination = $model->getPagination();
     $eventsHTML = $this->_cachedCall('_getEventsHTML', array($data->events, false, $data->pagination), '', array(COMMUNITY_CACHE_TAG_EVENTS));
     //Cache Group Featured List
     $featuredEvents = $this->_cachedCall('getEventsFeaturedList', array(), '', array(COMMUNITY_CACHE_TAG_FEATURED));
     $featuredHTML = $featuredEvents['HTML'];
     //no Featured Event headline slideshow on Category filtered page
     if (!empty($categoryId)) {
         $featuredHTML = '';
     }
     $sortItems = array('latest' => JText::_('COM_COMMUNITY_EVENTS_SORT_CREATED'), 'startdate' => JText::_('COM_COMMUNITY_EVENTS_SORT_COMING'));
     $title = JText::_('COM_COMMUNITY_EVENTS');
     if ($groupId) {
         $title = JText::_('COM_COMMUNITY_GROUP_EVENTS');
     }
     $config = CFactory::getConfig();
     $canSearch = !$config->get('enableguestsearchevents') && COwnerHelper::isRegisteredUser() || $config->get('enableguestsearchevents') ? true : false;
     $tmpl = new CTemplate();
     $tmpl->set('handler', $handler)->set('canSearch', $canSearch)->set('pageTitle', $title)->set('featuredHTML', $featuredHTML)->set('index', true)->set('categories', $data->categories)->set('eventsHTML', $eventsHTML)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('sortings', CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'startdate'))->set('my', $my)->set('isGroup', $groupId ? $groupId : false)->set('submenu', $this->showSubmenu(false))->set('createLink', $groupId ? CRoute::_('index.php?option=com_community&view=events&groupid=' . $groupId . '&task=create') : CRoute::_('index.php?option=com_community&view=events&task=create'));
     if ($groupId) {
         $tmpl->set('canCreate', $my->authorise('community.create', 'groups.events.' . $groupId))->set('groupMiniHeader', CMiniHeader::showGroupMiniHeader($groupId));
     } else {
         $tmpl->set('canCreate', $my->authorise('community.create', 'events'));
     }
     echo $tmpl->fetch('events/base');
 }
Ejemplo n.º 2
0
 */
defined('_JEXEC') or die('Restricted access');
include_once JPATH_BASE . '/components/com_community/defines.community.php';
require_once JPATH_BASE . '/components/com_community/libraries/core.php';
JFactory::getLanguage()->isRTL() ? CTemplate::addStylesheet('style.rtl') : CTemplate::addStylesheet('style');
$default = $params->get('default');
$upcomingOnly = $params->get('upcomingOnly', false);
$default = $params->get('default');
$model = CFactory::getModel('Events');
/* Follow component */
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
$categoryId = JRequest::getInt('categoryid', 0);
$category = JTable::getInstance('EventCategory', 'CTable');
$category->load($categoryId);
$sorted = $jinput->get->get('sort', 'startdate', 'STRING');
//JRequest::getVar( 'sort' , 'startdate' , 'GET' );
$eventparent = $jinput->get->get('parent', '', 'INT');
$event = JTable::getInstance('Event', 'CTable');
$handler = CEventHelper::getHandler($event);
$categories = $model->getAllCategories();
$categoryIds = CCategoryHelper::getCategoryChilds($categories, $category->id);
$result = $model->getEvents($categoryIds, null, $sorted, null, true, false, null, array('parent' => $eventparent), $handler->getContentTypes(), 0, $default, $upcomingOnly, false);
//$result = $model->getEvents(null, null, null, null, true, false, null, null, CEventHelper::ALL_TYPES, 0, $default);
$events = array();
foreach ($result as $row) {
    $event = JTable::getInstance('Event', 'CTable');
    $event->bind($row);
    $events[] = $event;
}
require JModuleHelper::getLayoutPath('mod_community_events', $params->get('layout', 'default'));
Ejemplo n.º 3
0
 public function myvideos($id = null)
 {
     $document = JFactory::getDocument();
     $my = CFactory::getUser();
     $userid = JRequest::getInt('userid', $my->id);
     $user = CFactory::getUser($userid);
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $categoryId = $jinput->get('catid', 0, 'INT');
     $categoryId = $jinput->get('catid', 0, 'INT');
     $category = JTable::getInstance('VideosCategory', 'CTable');
     $category->load($categoryId);
     // Set document title
     $blocked = $user->isBlocked();
     if ($blocked && !COwnerHelper::isCommunityAdmin()) {
         $tmpl = new CTemplate();
         echo $tmpl->fetch('profile.blocked');
         return;
     }
     if ($my->id == $user->id) {
         $title = JText::_('COM_COMMUNITY_VIDEOS_MY');
     } else {
         $title = JText::sprintf('COM_COMMUNITY_VIDEOS_USERS_VIDEO_TITLE', $user->getDisplayName());
     }
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', $title);
     // Set pathway
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $this->addPathway(JText::_('COM_COMMUNITY_VIDEOS'), CRoute::_('index.php?option=com_community&view=videos'));
     $this->addPathway($title);
     $feedLink = CRoute::_('index.php?option=com_community&view=videos&userid=' . $user->id . '&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_MY_VIDEOS_FEED') . '" href="' . $feedLink . '"/>';
     $document->addCustomTag($feed);
     // Show the mini header when viewing other's photos
     if ($my->id != $user->id) {
         $this->attachMiniHeaderUser($user->id);
     }
     // Display submenu
     $this->_addSubmenu();
     // Get data from DB
     $model = CFactory::getModel('videos');
     //CFactory::load( 'helpers' , 'friends' );
     if ($my->id == $user->id || COwnerHelper::isCommunityAdmin()) {
         $permission = 40;
     } elseif (CFriendsHelper::isConnected($my->id, $user->id)) {
         $permission = 30;
     } elseif ($my->id != 0) {
         $permission = 20;
     } else {
         $permission = 10;
     }
     // Get in category and it's children.
     $categories = $model->getAllCategories();
     $categoryIds = CCategoryHelper::getCategoryChilds($categories, $category->id);
     $categoryIds[] = $categoryId;
     $filters = array('creator' => $user->id, 'category_id' => $categoryIds, 'status' => 'ready', 'sorting' => $jinput->get('sort', 'latest', 'STRING'), 'permissions' => $permission);
     $videos = $model->getVideos($filters);
     $sortItems = $this->_getSortOptions();
     //pagination
     $pagination = $model->getPagination();
     $videosHTML = $this->_getVideosHTML($videos, $pagination);
     //This is local file
     $categories = $this->getFullVideoCategories();
     $sortItems = $this->_getSortOptions();
     $allVideosUrl = 'index.php?option=com_community&view=videos';
     $catVideoUrl = 'index.php?option=com_community&view=videos&task=myvideos&userid=' . $userid . '&catid=';
     $pendingVideos = $this->model->hasPendingVideos($my->id, VIDEO_USER_TYPE);
     $tmpl = new CTemplate();
     $tmpl->set('user', $user)->set('sort', $jinput->get('sort', 'latest', 'STRING'))->set('currentTask', JRequest::getCmd('task', ''))->set('isMyVideo', true)->set('videosHTML', $videosHTML)->set('$category', $category)->set('categories', $categories)->set('currentUrl', CRoute::getURI())->set('allVideosUrl', $allVideosUrl)->set('catVideoUrl', $catVideoUrl)->set('categories', $this->getFullVideoCategories())->set('category', $category)->set('categoryId', $categoryId)->set('pendingVideos', $pendingVideos)->set('sortings', CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest'))->set('submenu', $this->showSubmenu(false))->set('pagination', $pagination);
     if ($userid == $my->id) {
         $tmpl->set('canCreate', $my->authorise('community.create', 'videos'));
     } else {
         $tmpl->set('canCreate', 0);
     }
     echo $tmpl->fetch('videos/base');
 }
Ejemplo n.º 4
0
 /**
  * Loads the categories
  *
  * @access	public
  * @return	array	An array of categories object
  * @since	1.2
  */
 public function getCategories($categoryId = null)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $cache = CFactory::getFastCache();
     $cacheid = serialize(func_get_args()) . serialize(JRequest::get());
     if ($data = $cache->get($cacheid)) {
         return $data;
     }
     $my = CFactory::getUser();
     $permissions = $my->id == 0 ? 0 : 20;
     $groupId = $jinput->get->get('groupid', '', 'INT');
     //JRequest::getVar('groupid' , '' , 'GET');
     $conditions = '';
     $db = $this->getDBO();
     if (!empty($groupId)) {
         $conditions = ' AND v.' . $db->quoteName('creator_type') . ' = ' . $db->quote(VIDEO_GROUP_TYPE);
         //$conditions	.= ' AND b.groupid = ' . $groupId;
         $conditions .= ' AND g.' . $db->quoteName('id') . ' = ' . $db->Quote($groupId);
     } else {
         $conditions .= ' AND (g.' . $db->quoteName('approvals') . ' = ' . $db->Quote('0') . ' OR g.' . $db->quoteName('approvals') . ' IS NULL)';
     }
     $allcats = $this->getAllCategories($categoryId);
     $allCatsNoFilter = $this->getAllCategories();
     $result = array();
     foreach ($allcats as $cat) {
         $categoryIds = CCategoryHelper::getCategoryChilds($allCatsNoFilter, $cat->id);
         if ((int) $cat->id > 0) {
             $categoryIds[] = (int) $cat->id;
         }
         if (is_array($categoryIds)) {
             $categoryIds = implode($categoryIds, ',');
             $categoryCondition = $db->quoteName('category_id') . ' IN (' . $categoryIds . ') ';
         } else {
             $categoryCondition = $db->quoteName('category_id') . ' = ' . $db->Quote($cat->id);
         }
         $query = ' SELECT COUNT(v.' . $db->quoteName('id') . ') AS count' . ' FROM ' . $db->quoteName('#__community_videos') . ' AS v' . ' LEFT JOIN ' . $db->quoteName('#__community_groups') . ' AS g ON g.' . $db->quoteName('id') . ' = v.' . $db->quoteName('groupid') . ' WHERE v.' . $categoryCondition . ' AND v.' . $db->quoteName('status') . ' = ' . $db->Quote('ready') . ' AND v.' . $db->quoteName('published') . ' = ' . $db->Quote(1) . ' AND v.' . $db->quoteName('permissions') . ' <= ' . $db->Quote($permissions) . $conditions;
         $db->setQuery($query);
         $cat->count = $db->loadResult();
         $result[] = $cat;
     }
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     $cache->store($result, $cacheid, array(COMMUNITY_CACHE_TAG_VIDEOS_CAT));
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * showAllGroups
  * */
 public function getShowAllGroups($category, $sorted)
 {
     $model = CFactory::getModel('groups');
     // Get group in category and it's children.
     $categories = $model->getAllCategories();
     $categoryIds = CCategoryHelper::getCategoryChilds($categories, $category);
     if ((int) $category > 0) {
         $categoryIds[] = (int) $category;
     }
     // It is safe to pass 0 as the category id as the model itself checks for this value.
     $data = new StdClass();
     $data->groups = $model->getAllGroups($categoryIds, $sorted);
     // Get pagination object
     $data->pagination = $model->getPagination();
     // Get the template for the group lists
     $groupsHTML['HTML'] = $this->_getGroupsHTML($data->groups, $data->pagination);
     return $groupsHTML;
 }