/** * logic to get the categories options * * @access public * @return void */ function getCategoryOptions() { $user =& JFactory::getUser(); $app =& JFactory::getApplication(); $params = $app->getParams(); $superuser = UserAcl::superuser(); //administrators or superadministrators have access to all categories, also maintained ones if ($superuser) { $cwhere = ' WHERE c.published = 1'; } else { $acl = UserACl::getInstance(); $managed = $acl->getManagedVenuesCategories(); if (!$managed || !count($managed)) { return false; } $cwhere = ' WHERE c.id IN (' . implode(',', $managed) . ') '; } //get the maintained categories and the categories whithout any group //or just get all if somebody have edit rights $query = ' SELECT c.id, c.name, (COUNT(parent.name) - 1) AS depth, c.ordering ' . ' FROM #__redevent_venues_categories AS c, ' . ' #__redevent_venues_categories AS parent ' . $cwhere . ' AND c.lft BETWEEN parent.lft AND parent.rgt ' . ' GROUP BY c.id ' . ' ORDER BY c.lft;'; $this->_db->setQuery($query); $results = $this->_db->loadObjectList(); $options = array(); foreach ((array) $results as $cat) { $options[] = JHTML::_('select.option', $cat->id, str_repeat('>', $cat->depth) . ' ' . $cat->name); } $this->_categories = $options; return $this->_categories; }
/** * Creates the MyItems View * * @since 1.0 */ function display($tpl = null) { $mainframe =& JFactory::getApplication(); $user =& JFactory::getUser(); if (!$user->get('id')) { $mainframe->redirect('index.php', JText::_('COM_REDEVENT_Only_logged_users_can_access_this_page'), 'error'); } //initialize variables $document =& JFactory::getDocument(); $elsettings =& redEVENTHelper::config(); $pathway =& $mainframe->getPathWay(); $params =& $mainframe->getParams(); $uri =& JFactory::getURI(); $acl =& UserACl::getInstance(); $menu =& JSite::getMenu(); $item = $menu->getActive(); //add css file if (!$params->get('custom_css')) { $document->addStyleSheet($this->baseurl . '/components/com_redevent/assets/css/redevent.css'); } else { $document->addStyleSheet($params->get('custom_css')); } $document->addCustomTag('<!--[if IE]><style type="text/css">.floattext{zoom:1;}, * html #eventlist dd { height: 1%; }</style><![endif]-->'); JHTML::_('behavior.mootools'); $js = " window.addEvent('domready', function(){\n\t\t\t \$\$('.deletelink').addEvent('click', function(event){\n\t\t\t if (confirm('" . JText::_('COM_REDEVENT_CONFIRM_DELETE_DATE') . "')) {\n\t \treturn true;\n\t\t }\n\t\t else {\n\t\t \tif (event.preventDefault) {\n\t\t \t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tevent.returnValue = false;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn false;\n\t \t}\n\t\t\t });\t\t \n\t\t }); "; $document->addScriptDeclaration($js); // get variables $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $limit = $mainframe->getUserStateFromRequest('com_redevent.myevents.limit', 'limit', $params->def('display_num', 5), 'int'); $filter_event = $mainframe->getUserStateFromRequest('com_redevent.myevents.filter_event', 'filter_event', 0, 'int'); $task = JRequest::getWord('task'); $pop = JRequest::getBool('pop'); //get data from model $events =& $this->get('Events'); $venues =& $this->get('Venues'); $attending =& $this->get('Attending'); $groups =& $this->get('Groups'); //paginations $events_pageNav =& $this->get('EventsPagination'); $venues_pageNav =& $this->get('VenuesPagination'); $attending_pageNav =& $this->get('AttendingPagination'); //params $params->def('page_title', $item ? $item->title : 'COM_REDEVENT_VIEW_MYEVENTS_TITLE'); if ($pop) { //If printpopup set true $params->set('popup', 1); } //Set Page title $pagetitle = $params->get('page_title', JText::_('COM_REDEVENT_MY_EVENTS')); $this->document->setTitle($pagetitle); //create select lists $lists = $this->_buildSortLists(); if ($lists['filter']) { $uri->setVar('filter', $lists['filter']); $uri->setVar('filter_type', JRequest::getString('filter_type')); } else { $uri->delVar('filter'); $uri->delVar('filter_type'); } // events filter $hasManagedEvents = false; $options = array(JHTML::_('select.option', 0, JText::_('COM_REDEVENT_select_event'))); if ($ev = $this->get('EventsOptions')) { $hasManagedEvents = count($ev); $options = array_merge($options, $ev); } $lists['filter_event'] = JHTML::_('select.genericlist', $options, 'filter_event', 'onchange="document.getElementById(\'adminForm\').submit();"', 'value', 'text', $filter_event); $this->assign('action', JRoute::_(RedeventHelperRoute::getMyeventsRoute())); $this->assignRef('events', $events); $this->assignRef('venues', $venues); $this->assignRef('attending', $attending); $this->assignRef('groups', $groups); $this->assignRef('task', $task); $this->assignRef('print_link', $print_link); $this->assignRef('params', $params); $this->assignRef('dellink', $dellink); $this->assignRef('events_pageNav', $events_pageNav); $this->assignRef('venues_pageNav', $venues_pageNav); $this->assignRef('attending_pageNav', $attending_pageNav); $this->assignRef('elsettings', $elsettings); $this->assignRef('pagetitle', $pagetitle); $this->assignRef('lists', $lists); $this->assignRef('acl', $acl); $this->assignRef('hasManagedEvents', $hasManagedEvents); $this->assignRef('canAddXref', $acl->canAddXref()); $this->assignRef('canAddEvent', $acl->canAddEvent()); $this->assignRef('canAddVenue', $acl->canAddVenue()); $cols = explode(',', $params->get('lists_columns', 'date, title, venue, city, category')); $cols = redEVENTHelper::validateColumns($cols); $this->assign('columns', $cols); parent::display($tpl); }
/** * return venues lists as options, according to group ACL * * @return array */ function getVenueOptions() { $user =& JFactory::getUser(); $app =& JFactory::getApplication(); $params = $app->getParams(); $superuser = UserAcl::superuser(); $query = ' SELECT v.id AS value, ' . ' CASE WHEN CHAR_LENGTH(v.city) THEN CONCAT_WS(\' - \', v.venue, v.city) ELSE v.venue END as text ' . ' FROM #__redevent_venues AS v '; $where = array(); //administrators or superadministrators have access to all venues, also maintained ones if (!$superuser) { $acl = UserACl::getInstance(); $managed = $acl->getManagedVenues(); if ($managed && count($managed)) { $where[] = ' v.id IN (' . implode(',', $managed) . ')'; } else { $where[] = ' 0 '; } } $where[] = ' v.published = 1 '; $query .= ' WHERE ' . implode(' AND ', $where); $query .= ' GROUP BY v.id '; $query .= ' ORDER BY v.venue ASC '; $this->_db->setQuery($query); $res = $this->_db->loadObjectList(); return $res; }