/** * Checks access permissions of the user regarding on the groupid * * @author Christoph Lukes * @since 0.9 * * @param int $recurse * @param int $level * @return boolean True on success */ function validate_user($recurse, $level) { $user =& JFactory::getUser(); //only check when user is logged in if ($user->get('id')) { $acl =& JFactory::getACL(); $superuser = UserAcl::superuser(); $groupid = $user->get('gid'); if ($recurse) { $recursec = 'RECURSE'; } else { $recursec = 'NO_RECURSE'; } //open for superuser or registered and thats all what is needed //level = -1 all registered users //level = -2 disabled if ($level == -1 && $groupid > 0 || $superuser && $level != -2) { return true; //if not proceed checking } else { //User has exactly the needed groupid->ok if ($groupid == $level) { return true; } //User hasn't the needed groupid, check if he is a member of a member group if ($recursec == 'RECURSE') { $group_childs = array(); $group_childs = $acl->get_group_children($level, 'ARO', $recursec); //ugly workaround to merge Public Frontend and Public Backend if ($groupid >= 23) { $public_backend = array(23, 24, 25); $group_childs = array_merge($group_childs, $public_backend); } if (is_array($group_childs) && count($group_childs) > 0) { //Childgroups exists than check if user belongs to one of it if (in_array($groupid, $group_childs)) { //User belongs to one of it -> ok return true; } } } } //end logged in check } //oh oh, user has no permissions return false; }
public function getUpcomingVenueEvents() { $mainframe =& JFactory::getApplication(); $db = JFactory::getDBO(); $params = $mainframe->getParams(); $acl =& UserAcl::getInstance(); $gids = $acl->getUserGroupsIds(); if (!is_array($gids) || !count($gids)) { $gids = array(0); } $gids = implode(',', $gids); $q = ' SELECT e.*, IF (x.course_credit = 0, "", x.course_credit) AS course_credit, ' . ' x.id AS xref, x.dates, x.enddates, x.times, x.endtimes, v.venue, x.venueid, x.icaldetails, x.icalvenue, ' . ' v.city AS location, v.id AS venueid, v.country, x.title as session_title, ' . ' CASE WHEN CHAR_LENGTH(x.title) THEN CONCAT_WS(\' - \', e.title, x.title) ELSE e.title END as full_title, ' . ' CASE WHEN CHAR_LENGTH(e.alias) THEN CONCAT_WS(":", e.id, e.alias) ELSE e.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(x.alias) THEN CONCAT_WS(\':\', x.id, x.alias) ELSE x.id END as xslug, ' . ' CASE WHEN CHAR_LENGTH(v.alias) THEN CONCAT_WS(":", v.id, v.alias) ELSE v.id END as venueslug ' . ' FROM #__redevent_venues v ' . ' LEFT JOIN #__redevent_venue_category_xref AS xvcat ON v.id = xvcat.venue_id' . ' LEFT JOIN #__redevent_venues_categories AS vc ON xvcat.category_id = vc.id' . ' LEFT JOIN #__redevent_event_venue_xref x ON x.venueid = v.id ' . ' LEFT JOIN #__redevent_events e ON x.eventid = e.id ' . ' LEFT JOIN #__redevent_event_category_xref AS xcat ON xcat.event_id = e.id' . ' LEFT JOIN #__redevent_categories AS c ON c.id = xcat.category_id ' . ' LEFT JOIN #__redevent_groups_venues AS gv ON gv.venue_id = v.id AND gv.group_id IN (' . $gids . ')' . ' LEFT JOIN #__redevent_groups_venues_categories AS gvc ON gvc.category_id = vc.id AND gvc.group_id IN (' . $gids . ')' . ' LEFT JOIN #__redevent_groups_categories AS gc ON gc.category_id = c.id AND gc.group_id IN (' . $gids . ')' . ' WHERE x.published = 1 ' . ' AND x.venueid = ' . JRequest::getInt('id') . ' AND (v.private = 0 OR gv.id IS NOT NULL) ' . ' AND (c.private = 0 OR gc.id IS NOT NULL) ' . ' AND (vc.private = 0 OR vc.private IS NULL OR gvc.id IS NOT NULL) ' . ' GROUP BY x.id ' . ' ORDER BY x.dates '; $db->setQuery($q); $rows = $db->loadObjectList(); $rows = $this->_getPrices($rows); return $rows; }
function _displayEdit($tpl = null) { $user =& JFactory::getUser(); $acl = new UserAcl(); $xref = JRequest::getInt('xref'); $submitter_id = JRequest::getInt('submitter_id'); if (!$submitter_id) { JError::raise(0, 'Registration id required'); return false; } $model = $this->getModel(); $model->setXref($xref); $course = $this->get('SessionDetails'); $registration = $model->getRegistration($submitter_id); if (!$registration) { JError::raise(0, $model->getError); return false; } if ($acl->canManageAttendees($registration->xref) && JRequest::getVar('task') == 'manageredit') { $action = JRoute::_(RedeventHelperRoute::getRegistrationRoute($xref, 'managerupdate')); } else { if ($registration->uid == $user->get('id')) { $action = JRoute::_(RedeventHelperRoute::getRegistrationRoute($xref, 'update')); } else { JError::raiseError(403, 'NOT AUTHORIZED'); return false; } } $rfoptions = array(); $prices = $this->get('Pricegroups'); $field = array(); $field['label'] = '<label for="pricegroup_id">' . JText::_('COM_REDEVENT_REGISTRATION_PRICE') . '</label>'; $field['field'] = redEVENTHelper::getRfPricesSelect($prices, $registration->pricegroup_id); $rfoptions['extrafields'][] = $field; $rfcore = new RedformCore(); $rfields = $rfcore->getFormFields($course->redform_id, array($submitter_id), 1, $rfoptions); $this->assign('action', $action); $this->assign('rfields', $rfields); $this->assign('xref', $xref); parent::display($tpl); }
public function getUpcomingEvents() { $mainframe =& JFactory::getApplication(); $db = JFactory::getDBO(); $params = $mainframe->getParams(); $acl =& UserAcl::getInstance(); $gids = $acl->getUserGroupsIds(); if (!is_array($gids) || !count($gids)) { $gids = array(0); } $gids = implode(',', $gids); $q = ' SELECT e.*, IF (x.course_credit = 0, "", x.course_credit) AS course_credit, x.id AS xref, ' . ' x.dates, x.enddates, x.times, x.endtimes, x.icaldetails, x.icalvenue, ' . ' v.venue, x.venueid, v.city AS location, v.id AS venueid, v.country, ' . ' x.title as session_title, ' . ' CASE WHEN CHAR_LENGTH(x.title) THEN CONCAT_WS(\' - \', e.title, x.title) ELSE e.title END as full_title, ' . ' CASE WHEN CHAR_LENGTH(e.alias) THEN CONCAT_WS(\':\', e.id, e.alias) ELSE e.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(x.alias) THEN CONCAT_WS(\':\', x.id, x.alias) ELSE x.id END as xslug, ' . ' CASE WHEN CHAR_LENGTH(v.alias) THEN CONCAT_WS(\':\', v.id, v.alias) ELSE v.id END as venueslug ' . ' FROM #__redevent_venues v ' . ' LEFT JOIN #__redevent_venue_category_xref AS xvcat ON v.id = xvcat.venue_id' . ' LEFT JOIN #__redevent_venues_categories AS vc ON xvcat.category_id = vc.id' . ' LEFT JOIN #__redevent_event_venue_xref x ON x.venueid = v.id ' . ' LEFT JOIN #__redevent_events e ON x.eventid = e.id ' . ' LEFT JOIN #__redevent_event_category_xref AS xcat ON xcat.event_id = e.id' . ' LEFT JOIN #__redevent_categories AS c ON c.id = xcat.category_id ' . ' LEFT JOIN #__redevent_groups_venues AS gv ON gv.venue_id = v.id AND gv.group_id IN (' . $gids . ')' . ' LEFT JOIN #__redevent_groups_venues_categories AS gvc ON gvc.category_id = vc.id AND gvc.group_id IN (' . $gids . ')' . ' LEFT JOIN #__redevent_groups_categories AS gc ON gc.category_id = c.id AND gc.group_id IN (' . $gids . ')' . ' WHERE x.published = 1 ' . ' AND (v.private = 0 OR gv.id IS NOT NULL) ' . ' AND (c.private = 0 OR gc.id IS NOT NULL) ' . ' AND (vc.private = 0 OR vc.private IS NULL OR gvc.id IS NOT NULL) ' . ' AND ( ( (CASE WHEN x.times THEN CONCAT(x.dates, " ", x.times) ELSE x.dates END) > NOW() AND x.dates < DATE_ADD(NOW(), INTERVAL ' . $params->getValue('upcoming_days_ahead', 30) . ' DAY) ) '; if ($params->getValue('show_days_no_date', 0) == 1) { $q .= " OR x.dates = '0000-00-00' "; } $q .= " ) "; $q .= ' GROUP BY x.id '; $q .= " ORDER BY x.dates "; $q .= "LIMIT " . $params->getValue('show_number_courses', 10); $db->setQuery($q); $rows = $db->loadObjectList(); $rows = $this->_getPrices($rows); return $rows; }
/** * Method to get the Category * * @access public * @return integer */ function getCategory() { if (!$this->_category) { $user =& JFactory::getUser(); $query = 'SELECT *,' . ' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug' . ' FROM #__redevent_categories' . ' WHERE id = ' . $this->_id; $this->_db->setQuery($query); $this->_category = $this->_db->loadObject(); if ($this->_category->private) { $acl =& UserAcl::getInstance(); $cats = $acl->getManagedCategories(); if (!is_array($cats) || !in_array($this->_category->id, $cats)) { JError::raiseError(403, JText::_('COM_REDEVENT_ACCESS_NOT_ALLOWED')); } } $this->_category->attachments = REAttach::getAttachments('category' . $this->_category->id, max($user->getAuthorisedViewLevels())); } return $this->_category; }
/** * 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; }
/** * return true if user allowed to manage attendees * * @return boolean */ function getViewAttendees() { $acl = UserAcl::getInstance(); return $acl->canViewAttendees($this->_xref); }
/** * Check if the user can register to the specified xref. * * Returns an object with properties canregister and status * * @param $xref_id * @param $user_id * @return object (canregister, status) */ function canRegister($xref_id, $user_id = null) { if (!file_exists(JPATH_SITE . DS . 'components' . DS . 'com_redform' . DS . 'redform.core.php')) { JError::raiseWarning(0, JText::_('COM_REDEVENT_REGISTRATION_NOT_ALLOWED_REDFORMCORE_NOT_FOUND')); $result->canregister = 0; $result->status = JText::_('COM_REDEVENT_REGISTRATION_NOT_ALLOWED_REDFORMCORE_NOT_FOUND'); return $result; } $app =& JFactory::getApplication(); $db =& JFactory::getDBO(); $user =& JFactory::getUser($user_id); $result = new stdclass(); $result->canregister = 1; $acl = UserAcl::getInstance(); if ($acl->canManageAttendees($xref_id)) { return $result; } $query = ' SELECT x.dates, x.times, x.enddates, x.endtimes, x.maxattendees, x.maxwaitinglist, x.registrationend, e.registra, e.max_multi_signup ' . ' FROM #__redevent_event_venue_xref AS x ' . ' INNER JOIN #__redevent_events AS e ON x.eventid = e.id ' . ' WHERE x.id=' . $db->Quote($xref_id); $db->setQuery($query); $event =& $db->loadObject(); // we need to take into account the server offset into account for the registration dates $now = JFactory::getDate(); $now->setOffset($app->getCfg('offset')); $now_unix = $now->toUnix('true'); // first, let's check the thing that don't need database queries if (!$event->registra) { $result->canregister = 0; $result->status = JText::_('COM_REDEVENT_NO_REGISTRATION_FOR_THIS_EVENT'); $result->error = 'noregistration'; return $result; } else { if (redEVENTHelper::isValidDate($event->registrationend)) { if (strtotime($event->registrationend) < $now_unix) { $result->canregister = 0; $result->status = JText::_('COM_REDEVENT_REGISTRATION_IS_OVER'); $result->error = 'isover'; return $result; } } else { if (redEVENTHelper::isValidDate($event->dates) && strtotime($event->dates . ' ' . $event->times) < $now_unix) { // it's separated from previous case so that it is not checked if a registration end was set $result->canregister = 0; $result->status = JText::_('COM_REDEVENT_REGISTRATION_IS_OVER'); $result->error = 'isover'; return $result; } } } // now check the max registrations and waiting list if ($event->maxattendees) { // get places taken $q = "SELECT waitinglist, COUNT(id) AS total\n FROM #__redevent_register\n WHERE xref = " . $db->Quote($xref_id) . "\n AND confirmed = 1\n\t\t AND cancelled = 0\n GROUP BY waitinglist"; $db->setQuery($q); $res = $db->loadObjectList('waitinglist'); $event->registered = isset($res[0]) ? $res[0]->total : 0; $event->waiting = isset($res[1]) ? $res[1]->total : 0; if ($event->maxattendees <= $event->registered && $event->maxwaitinglist <= $event->waiting) { $result->canregister = 0; $result->status = JText::_('COM_REDEVENT_EVENT_FULL'); $result->error = 'isfull'; return $result; } } // check if the user has pending unconfirm registration for the session if ($user->get('id')) { $q = "SELECT COUNT(r.id) AS total\n FROM #__redevent_register AS r\n WHERE r.xref = " . $db->Quote($xref_id) . "\n AND r.confirmed = 0\n AND r.uid = " . $db->Quote($user->get('id')); $db->setQuery($q); $res = $db->loadResult(); if ($res) { $result->canregister = 0; $result->status = JTEXT::_('COM_REDEVENT_REGISTRATION_NOT_ALLOWED_PENDING_UNCONFIRM_REGISTRATION'); $result->error = 'haspending'; return $result; } } // then the max registration per user if ($user->get('id')) { $q = "SELECT COUNT(r.id) AS total\n FROM #__redevent_register AS r\n WHERE r.xref = " . $db->Quote($xref_id) . "\n AND r.confirmed = 1\n\t\t AND r.cancelled = 0\n AND r.uid = " . $db->Quote($user->get('id')) . "\n "; // if there is a submit key set, it means we are reviewing, so we need to discard this submit_key from the count. if (JRequest::getVar('submit_key')) { $q .= ' AND r.submit_key <> ' . $db->Quote(JRequest::getVar('submit_key', '')); } $db->setQuery($q); $event->userregistered = $db->loadResult(); // in case this is a review, user has already registered... but not finished yet. if ($event->userregistered && JRequest::getVar('event_task') == 'review') { $event->userregistered--; } } else { $event->userregistered = 0; } if ($event->userregistered >= ($event->max_multi_signup ? $event->max_multi_signup : 1)) { $result->canregister = 0; $result->status = JText::_('COM_REDEVENT_USER_MAX_REGISTRATION_REACHED'); $result->error = 'usermax'; return $result; } return $result; }
function manageattendees() { $acl = UserAcl::getInstance(); $xref = JRequest::getInt('xref'); if ($acl->canManageAttendees($xref)) { $layout = 'manageattendees'; } else { if ($acl->canViewAttendees($xref)) { $layout = 'default'; } else { $this->setRedirect(RedeventHelperRoute::getMyEventsRoute(), JText::_('COM_REDEVENT_ACCESS_NOT_ALLOWED'), 'error'); $this->redirect(); } } JRequest::setvar('view', 'attendees'); JRequest::setvar('layout', $layout); parent::display(); }
/** * Method to get the Category * * @access public * @return integer */ function getCategory() { if (!$this->_category) { $query = 'SELECT *,' . ' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug' . ' FROM #__redevent_venues_categories' . ' WHERE id = ' . $this->_id; $this->_db->setQuery($query); $this->_category = $this->_db->loadObject(); if ($this->_category->private) { $acl =& UserAcl::getInstance(); $cats = $acl->getManagedVenuesCategories(); if (!is_array($cats) || !in_array($this->_category->id, $cats)) { JError::raiseError(403, JText::_('COM_REDEVENT_ACCESS_NOT_ALLOWED')); } } } return $this->_category; }
function getEventsOptions() { // Get the WHERE and ORDER BY clauses for the query $where = $this->_buildEventsOptionsWhere(); $customs = $this->getCustomFields(); $xcustoms = $this->getXrefCustomFields(); $acl =& UserAcl::getInstance(); $gids = $acl->getUserGroupsIds(); if (!is_array($gids) || !count($gids)) { $gids = array(0); } $gids = implode(',', $gids); //Get Events from Database $query = 'SELECT a.id AS value, a.title AS text '; // add the custom fields foreach ((array) $customs as $c) { $query .= ', a.custom' . $c->id; } // add the custom fields foreach ((array) $xcustoms as $c) { $query .= ', x.custom' . $c->id; } $query .= ' FROM #__redevent_event_venue_xref AS x' . ' INNER JOIN #__redevent_events AS a ON a.id = x.eventid' . ' INNER JOIN #__redevent_venues AS l ON l.id = x.venueid' . ' LEFT JOIN #__redevent_venue_category_xref AS xvcat ON l.id = xvcat.venue_id' . ' LEFT JOIN #__redevent_venues_categories AS vc ON xvcat.category_id = vc.id' . ' INNER JOIN #__redevent_event_category_xref AS xcat ON xcat.event_id = a.id' . ' INNER JOIN #__redevent_categories AS c ON c.id = xcat.category_id ' . ' LEFT JOIN #__redevent_groups_venues AS gv ON gv.venue_id = l.id AND gv.group_id IN (' . $gids . ')' . ' LEFT JOIN #__redevent_groups_venues_categories AS gvc ON gvc.category_id = vc.id AND gvc.group_id IN (' . $gids . ')' . ' LEFT JOIN #__redevent_groups_categories AS gc ON gc.category_id = c.id AND gc.group_id IN (' . $gids . ')'; $query .= $where . ' AND (l.private = 0 OR gv.id IS NOT NULL) ' . ' AND (c.private = 0 OR gc.id IS NOT NULL) ' . ' AND (vc.private = 0 OR vc.private IS NULL OR gvc.id IS NOT NULL) ' . ' GROUP BY (a.id) ' . ' ORDER BY a.title, x.title ASC '; $this->_db->setQuery($query); return $this->_db->loadObjectList(); }
function deletexref() { $acl = new UserAcl(); $xref = JRequest::getInt('xref'); if (!$acl->canEditXref($xref)) { $msg = JText::_('COM_REDEVENT_MYEVENTS_DELETE_XREF_NOTE_ALLOWED'); $this->setRedirect(JRoute::_(RedeventHelperRoute::getMyEventsRoute(), false), $msg, 'error'); return; } $model = $this->getModel('editevent'); if ($model->deletexref($xref)) { $msg = JText::_('COM_REDEVENT_EVENT_DATE_DELETED'); $this->setRedirect(JRoute::_(RedeventHelperRoute::getMyEventsRoute(), false), $msg); } else { $msg = JText::_('COM_REDEVENT_EVENT_DATE_DELETION_ERROR') . '<br>' . $model->getError(); $this->setRedirect(JRoute::_(RedeventHelperRoute::getMyEventsRoute(), false), $msg, 'error'); } }
/** * Creates the output for the details view * * @since 0.9 */ function display($tpl = null) { $mainframe =& JFactory::getApplication(); $uri =& JFactory::getUri(); /* Set which page to show */ $tpl = JRequest::getVar('page', null); $params =& $mainframe->getParams('com_redevent'); $document = JFactory::getDocument(); $user = JFactory::getUser(); $dispatcher = JDispatcher::getInstance(); $elsettings = redEVENTHelper::config(); $acl = UserAcl::getInstance(); if ($params->get('gplusone', 1)) { $document->addScript('https://apis.google.com/js/plusone.js'); } if ($params->get('tweet', 1)) { $document->addScript('http://platform.twitter.com/widgets.js'); } $row = $this->get('Details'); $registers = $this->get('Registers'); $roles = $this->get('Roles'); $prices = $this->get('Prices'); $register_fields = $this->get('FormFields'); $regcheck = $this->get('Usercheck'); /* Get the venues information */ $this->_venues = $this->get('Venues'); /* This loads the tags replacer */ JView::loadHelper('tags'); $tags = new redEVENT_tags(); $tags->setEventId(JRequest::getInt('id')); $tags->setXref(JRequest::getInt('xref')); $this->assignRef('tags', $tags); //get menu information $menu =& JSite::getMenu(); $item = $menu->getActive(); if (!$item) { $item = $menu->getDefault(); } //Check if the id exists if ($row->did == 0) { return JError::raiseError(404, JText::sprintf('COM_REDEVENT_Event_d_not_found', $row->did)); } //Check if user has access to the details if ($params->get('showdetails', 1) == 0) { $mainframe->redirect('index.php', JText::_('COM_REDEVENT_EVENT_DETAILS_NOT_AVAILABLE'), 'error'); } //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]-->'); //Print $pop = JRequest::getBool('pop'); $params->def('page_title', $row->full_title); if ($pop) { $params->set('popup', 1); } $print_link = JRoute::_('index.php?option=com_redevent&view=details&id=' . $row->slug . '&xref=' . JRequest::getInt('xref') . '&pop=1&tmpl=component'); //pathway $pathway =& $mainframe->getPathWay(); $pathway->addItem($row->full_title, JRoute::_('index.php?option=com_redevent&view=details&id=' . $row->slug)); //Check user if he can edit $allowedtoeditevent = $acl->canEditEvent($row->did); //Timecheck for registration $jetzt = date("Y-m-d"); $now = strtotime($jetzt); $date = strtotime($row->dates); $timecheck = $now - $date; //is the user allready registered at the event if ($regcheck) { // add javascript code for cancel button on attendees layout. JHTML::_('behavior.mootools'); $js = " window.addEvent('domready', function(){\n\t\t \$\$('.unreglink').addEvent('click', function(event){\n\t\t if (confirm('" . JText::_('COM_REDEVENT_CONFIRM_CANCEL_REGISTRATION') . "')) {\n \treturn true;\n\t }\n\t else {\n\t \tif (event.preventDefault) {\n\t \t\tevent.preventDefault();\n\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\tevent.returnValue = false;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\treturn false;\n \t}\n\t\t });\t\t \n\t\t }); "; $document->addScriptDeclaration($js); } //Generate Eventdescription if ($row->datdescription == '' || $row->datdescription == '<br />') { $row->datdescription = JText::_('COM_REDEVENT_NO_DESCRIPTION'); } else { //Execute Plugins $row->datdescription = JHTML::_('content.prepare', $row->datdescription); } // generate Metatags $meta_keywords_content = ""; if (!empty($row->meta_keywords)) { $keywords = explode(",", $row->meta_keywords); foreach ($keywords as $keyword) { if ($meta_keywords_content != "") { $meta_keywords_content .= ", "; } if (preg_match("/[\\/[\\/]/", $keyword)) { $keyword = trim(str_replace("[", "", str_replace("]", "", $keyword))); $buffer = $this->keyword_switcher($keyword, $row, $elsettings->get('formattime', '%H:%M'), $elsettings->get('formatdate', '%d.%m.%Y')); if ($buffer != "") { $meta_keywords_content .= $buffer; } else { $meta_keywords_content = substr($meta_keywords_content, 0, strlen($meta_keywords_content) - 2); // remove the comma and the white space } } else { $meta_keywords_content .= $keyword; } } } if (!empty($row->meta_description)) { $description = explode("[", $row->meta_description); $description_content = ""; foreach ($description as $desc) { $keyword = substr($desc, 0, strpos($desc, "]", 0)); if ($keyword != "") { $description_content .= $this->keyword_switcher($keyword, $row, $elsettings->get('formattime', '%H:%M'), $elsettings->get('formatdate', '%d.%m.%Y')); $description_content .= substr($desc, strpos($desc, "]", 0) + 1); } else { $description_content .= $desc; } } } else { $description_content = ""; } //set page title and meta stuff $document->setTitle($row->full_title); $document->setMetadata('keywords', $meta_keywords_content); $document->setDescription(strip_tags($description_content)); // more metadata $document->addCustomTag('<meta property="og:title" content="' . $row->full_title . '"/>'); $document->addCustomTag('<meta property="og:type" content="event"/>'); $document->addCustomTag('<meta property="og:url" content="' . htmlspecialchars($uri->toString()) . '"/>'); if ($row->datimage) { $document->addCustomTag('<meta property="og:image" content="' . JURI::base() . 'images/redevent/events/' . $row->datimage . '"/>'); } $document->addCustomTag('<meta property="og:site_name" content="' . $mainframe->getCfg('sitename') . '"/>'); $document->addCustomTag('<meta property="og:description" content="' . JFilterOutput::cleanText($row->summary) . '"/>'); //build the url if (!empty($row->url) && strtolower(substr($row->url, 0, 7)) != "http://") { $row->url = 'http://' . $row->url; } /* Get the Venue Dates */ $venuedates = $this->get('VenueDates'); //add alternate feed link $link = 'index.php?option=com_redevent&view=details&format=feed'; if (!empty($row->slug)) { $link .= '&id=' . $row->slug; } $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); // check unregistration rights $unreg_check = redEVENTHelper::canUnregister($row->xref); //manages attendees $manage_attendees = $this->get('ManageAttendees') || $this->get('ViewFullAttendees'); $candeleteattendees = $this->get('ManageAttendees'); $view_attendees_list = $row->show_names && in_array($params->get('frontend_view_attendees_access'), JFactory::getUser()->getAuthorisedViewLevels()); //assign vars to jview $this->assignRef('row', $row); $this->assignRef('params', $params); $this->assignRef('user', $user); $this->assignRef('allowedtoeditevent', $allowedtoeditevent); $this->assignRef('manage_attendees', $manage_attendees); $this->assignRef('view_attendees_list', $view_attendees_list); $this->assignRef('candeleteattendees', $candeleteattendees); $this->assignRef('print_link', $print_link); $this->assignRef('registers', $registers); $this->assignRef('registersfields', $register_fields); $this->assignRef('elsettings', $elsettings); $this->assignRef('item', $item); $this->assignRef('messages', $messages); $this->assignRef('venuedates', $venuedates); $this->assignRef('unreg_check', $unreg_check); $this->assignRef('roles', $roles); $this->assignRef('prices', $prices); $this->assignRef('uri', $uri); $this->assignRef('lang', JFactory::getLanguage()); if ($params->get('fbopengraph', 1)) { $this->_opengraph(); } $tpl = JRequest::getVar('tpl', $tpl); if ($tpl == '') { switch ($row->details_layout) { case 2: $this->setLayout('fixed'); break; case 1: $this->setLayout('default'); break; case 0: $this->setLayout($params->get('details_layout', 'fixed')); break; } } parent::display($tpl); }
/** * Build the query * * @access private * @return string */ function _buildQuery() { //check archive task $task = JRequest::getVar('task', '', '', 'string'); if ($task == 'archive') { $eventstate = ' AND x.published = -1'; } else { $eventstate = ' AND x.published = 1'; } $mainframe =& JFactory::getApplication(); // Get the paramaters of the active menu item $params =& $mainframe->getParams('com_redevent'); if ($params->get('display_all_venues', 0) == 0) { $filter = ' AND x.eventid IS NOT NULL '; } else { $filter = ''; } if ($this->_category) { $filter .= ' AND c.lft BETWEEN ' . $this->_db->Quote($this->_category->lft) . ' AND ' . $this->_db->Quote($this->_category->rgt); } $acl =& UserAcl::getInstance(); $gids = $acl->getUserGroupsIds(); if (!is_array($gids) || !count($gids)) { $gids = array(0); } $gids = implode(',', $gids); //get venues $query = 'SELECT v.*, v.id as venueid, COUNT( x.eventid ) AS assignedevents,' . ' CASE WHEN CHAR_LENGTH(v.alias) THEN CONCAT_WS(\':\', v.id, v.alias) ELSE v.id END as slug ' . ' FROM #__redevent_venues as v' . ' LEFT JOIN #__redevent_event_venue_xref AS x ON v.id = x.venueid ' . $eventstate . ' LEFT JOIN #__redevent_venue_category_xref AS xc ON xc.venue_id = v.id ' . ' LEFT JOIN #__redevent_venues_categories AS c ON c.id = xc.category_id ' . ' LEFT JOIN #__redevent_groups_venues AS gv ON gv.venue_id = v.id ' . ' LEFT JOIN #__redevent_groups_venues_categories AS gvc ON gvc.category_id = c.id ' . ' WHERE v.published = 1' . ' AND (v.private = 0 OR gv.group_id IN (' . $gids . ')) ' . ' AND (c.private = 0 OR c.private IS NULL OR gvc.group_id IN (' . $gids . ')) ' . $filter . ' GROUP BY v.id' . ' ORDER BY v.venue'; return $query; }
/** * Build the query * * @access private * @return string */ function _buildQuery() { $app =& JFactory::getApplication(); $vcat = $app->getUserState('com_redevent.venuesmap.vcat'); $cat = $app->getUserState('com_redevent.venuesmap.cat'); $customs = $app->getUserState('com_redevent.venuesmap.filter_customs'); $params = $app->getParams(); $acl =& UserAcl::getInstance(); $gids = $acl->getUserGroupsIds(); if (!is_array($gids) || !count($gids)) { $gids = array(0); } $gids = implode(',', $gids); //check archive task $task = JRequest::getVar('task', '', '', 'string'); if ($task == 'archive') { $eventstate = ' AND x.published = -1'; } else { $eventstate = ' AND x.published = 1'; } //get events $query = 'SELECT v.*, COUNT(x.id) AS assignedevents,' . ' CASE WHEN CHAR_LENGTH(v.alias) THEN CONCAT_WS(\':\', v.id, v.alias) ELSE v.id END as slug' . ' FROM #__redevent_venues as v' . ' LEFT JOIN #__redevent_venue_category_xref AS xvcat ON xvcat.venue_id = v.id ' . ' LEFT JOIN #__redevent_venues_categories AS vcat ON vcat.id = xvcat.category_id ' . ' LEFT JOIN #__redevent_groups_venues AS gv ON gv.venue_id = v.id ' . ' LEFT JOIN #__redevent_groups_venues_categories AS gvc ON gvc.category_id = vcat.id '; if ($params->get('show_empty_venues', 0)) { $query .= ' LEFT JOIN #__redevent_event_venue_xref AS x ON x.venueid = v.id' . $eventstate; $query .= ' LEFT JOIN #__redevent_events AS e ON x.eventid = e.id'; } else { $query .= ' INNER JOIN #__redevent_event_venue_xref AS x ON x.venueid = v.id' . $eventstate; $query .= ' INNER JOIN #__redevent_events AS e ON x.eventid = e.id'; } if ($cat) { $query .= ' INNER JOIN #__redevent_event_category_xref AS xcat ON xcat.event_id = x.eventid ' . ' INNER JOIN #__redevent_categories AS cat ON cat.id = xcat.category_id ' . ' INNER JOIN #__redevent_categories AS topcat ON cat.lft BETWEEN topcat.lft AND topcat.rgt '; } if ($vcat) { $query .= ' INNER JOIN #__redevent_venues_categories AS top ON vcat.lft BETWEEN top.lft AND top.rgt '; } // where $query .= ' WHERE v.published = 1 ' . ' AND (v.private = 0 OR gv.group_id IN (' . $gids . ')) ' . ' AND (vcat.private = 0 OR vcat.private IS NULL OR gvc.group_id IN (' . $gids . ')) '; if ($cat) { $query .= ' AND topcat.id = ' . $this->_db->Quote($cat); } if ($vcat) { $query .= ' AND top.id = ' . $this->_db->Quote($vcat); } foreach ((array) $customs as $key => $custom) { if ($custom != '') { if (is_array($custom)) { $custom = implode("/n", $custom); } $query .= ' AND custom' . $key . ' LIKE ' . $this->_db->Quote('%' . $custom . '%'); } } $query .= ' GROUP BY v.id' . ' ORDER BY v.venue'; return $query; }
/** * Method to get the Venue * * @access public * @return array */ function getVenue() { $user =& JFactory::getUser(); //Location holen $query = 'SELECT *, v.id AS venueid, ' . ' CASE WHEN CHAR_LENGTH(v.alias) THEN CONCAT_WS(\':\', v.id, v.alias) ELSE v.id END as slug ' . ' FROM #__redevent_venues AS v' . ' WHERE v.id = ' . $this->_id; $this->_db->setQuery($query); $_venue = $this->_db->loadObject(); if ($_venue->private) { $acl =& UserAcl::getInstance(); $cats = $acl->getManagedVenues(); if (!is_array($cats) || !in_array($_venue->id, $cats)) { JError::raiseError(403, JText::_('COM_REDEVENT_ACCESS_NOT_ALLOWED')); } } $_venue->attachments = REAttach::getAttachments('venue' . $_venue->id, max($user->getAuthorisedViewLevels())); return $_venue; }
/** * Cancel a registration * * @access public * @param int $register_id * @return boolean true on success * @since 2.0 */ function cancelregistration($register_id, $xref) { $user =& JFactory::getUser(); $userid = $user->get('id'); $acl = UserAcl::getInstance(); if ($userid < 1) { JError::raiseError(403, JText::_('COM_REDEVENT_ALERTNOTAUTH')); return; } // first, check if the user is allowed to unregister from this // he must be the one that submitted the form, plus the unregistration must be allowed $q = ' SELECT s.*, r.uid, e.unregistra, x.dates, x.times, x.registrationend ' . ' FROM #__rwf_submitters AS s ' . ' INNER JOIN #__redevent_register AS r ON r.sid = s.id ' . ' INNER JOIN #__redevent_event_venue_xref AS x ON x.id = r.xref ' . ' INNER JOIN #__redevent_events AS e ON x.eventid = e.id ' . ' WHERE r.id = ' . $this->_db->Quote($register_id); $this->_db->setQuery($q); $submitterinfo = $this->_db->loadObject(); // or be allowed to manage attendees $manager = $acl->canManageAttendees($xref); if (!redEVENTHelper::canUnregister($xref) && !$manager) { $this->setError(JText::_('COM_REDEVENT_UNREGISTRATION_NOT_ALLOWED')); return false; } if (($submitterinfo->uid != $userid || $submitterinfo->unregistra == 0) && !$manager) { $this->setError(JText::_('COM_REDEVENT_UNREGISTRATION_NOT_ALLOWED')); return false; } // Now that we made sure, we can delete the submitter and corresponding form values /* Delete the redFORM entry first */ /* Submitter answers first*/ $q = ' UPDATE #__redevent_register AS r ' . ' SET r.cancelled = 1 ' . ' WHERE r.id = ' . $this->_db->Quote($register_id); $this->_db->setQuery($q); if (!$this->_db->query()) { $this->setError(JText::_('COM_REDEVENT_ERROR_CANNOT_DELETE_REGISTRATION')); return false; } return true; }
/** * Creates the output for venue submissions * * @since 0.5 * @param int $tpl */ function display($tpl = null) { $mainframe =& JFactory::getApplication(); $editor =& JFactory::getEditor(); $document =& JFactory::getDocument(); $elsettings =& redEVENTHelper::config(); $params =& $mainframe->getParams(); $acl = UserAcl::getInstance(); // Get requests $id = JRequest::getInt('id'); if ($id && !$acl->canEditVenue($id)) { echo JText::_('COM_REDEVENT_USER_NOT_ALLOWED_TO_EDIT_THIS_VENUE'); return; } else { if (!$id && !$acl->canAddVenue()) { echo JText::_('COM_REDEVENT_USER_NOT_ALLOWED_TO_ADD_VENUE'); return; } } //Get Data from the model $row = $this->Get('Venue'); JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'locdescription'); JHTML::_('behavior.formvalidation'); JHTML::_('behavior.tooltip'); JHTML::_('behavior.mootools'); //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]-->'); $document->addScript('components/com_redevent/assets/js/attachments.js'); $document->addScriptDeclaration('var removemsg = "' . JText::_('COM_REDEVENT_ATTACHMENT_CONFIRM_MSG') . '";'); // Get the menu object of the active menu item $menu =& JSite::getMenu(); $item = $menu->getActive(); $params =& $mainframe->getParams('com_redevent'); $id ? $title = JText::_('COM_REDEVENT_EDIT_VENUE') : ($title = JText::_('COM_REDEVENT_ADD_VENUE')); //pathway $pathway =& $mainframe->getPathWay(); $pathway->addItem($title, ''); //Set Title $document->setTitle($title); //editor user // $editoruser = ELUser::editoruser(); $editoruser = true; //transform <br /> and <br> back to \r\n for non editorusers if (!$editoruser) { $row->locdescription = redEVENTHelper::br2break($row->locdescription); } //Get image $limage = redEVENTImage::flyercreator($row->locimage); //Set the info image $infoimage = JHTML::_('image', 'components/com_redevent/assets/images/icon-16-hint.png', JText::_('COM_REDEVENT_NOTES')); $lists = array(); // categories selector $selected = array(); foreach ((array) $row->categories as $cat) { $selected[] = $cat; } $options = (array) $this->get('CategoryOptions'); $lists['categories'] = JHTML::_('select.genericlist', $options, 'categories[]', 'class="inputbox validate-categories" multiple="multiple" size="' . min(3, max(10, count($options))) . '"', 'value', 'text', $selected); // country $options = redEVENTHelperCountries::getCountryOptions('value', 'text', true); $lists['country'] = JHTML::_('select.genericlist', $options, 'country', '', 'value', 'text', $row->country); // published state selector $canpublish = $acl->canPublishVenue($id); $published = array(JHTML::_('select.option', '1', JText::_('COM_REDEVENT_PUBLISHED')), JHTML::_('select.option', '0', JText::_('COM_REDEVENT_UNPUBLISHED'))); $lists['published'] = JHTML::_('select.radiolist', $published, 'published', '', 'value', 'text', $row->published); $this->assignRef('row', $row); $this->assignRef('editor', $editor); $this->assignRef('editoruser', $editoruser); $this->assignRef('limage', $limage); $this->assignRef('infoimage', $infoimage); $this->assignRef('elsettings', $elsettings); $this->assignRef('lists', $lists); $this->assignRef('item', $item); $this->assignRef('params', $params); $this->assignRef('canpublish', $canpublish); $this->assignRef('access', redEVENTHelper::getAccesslevelOptions()); parent::display($tpl); }
function _displayEventdate($tpl = null) { $mainframe =& Jfactory::getApplication(); $document =& JFactory::getDocument(); $params =& $mainframe->getParams(); $editor =& JFactory::getEditor(); // echo '<pre>';print_r($this); echo '</pre>';exit; $useracl = UserAcl::getInstance(); JHTML::_('behavior.mootools'); $document->addScript('components/com_redevent/assets/js/xref_roles.js'); $document->addScriptDeclaration('var txt_remove = "' . JText::_('COM_REDEVENT_REMOVE') . '";'); $document->addScript('components/com_redevent/assets/js/xref_prices.js'); $document->addStyleSheet($this->baseurl . '/components/com_redevent/assets/css/editevent.css'); // get xref data $xref =& $this->get('SessionDetails'); $customs =& $this->get('XrefCustomfields'); $roles =& $this->get('SessionRoles'); $prices =& $this->get('SessionPrices'); $canpublish = $useracl->canPublishEvent($xref->eventid); // form elements $lists = array(); // events if ($xref->eventid) { $lists['event'] = $xref->event_title; } else { $events = array(); $events[] = JHTML::_('select.option', '0', JText::_('COM_REDEVENT_SELECT_EVENT')); $events = array_merge($events, $this->get('EventOptions')); $lists['event'] = JHTML::_('select.genericlist', $events, 'eventid', 'size="1" class="inputbox validate-event"', 'value', 'text', $xref->eventid); unset($events); } // venues $venues = array(); $venues[] = JHTML::_('select.option', '0', JText::_('COM_REDEVENT_SELECT_VENUE')); $venues = array_merge($venues, $this->get('VenueOptions')); $lists['venue'] = JHTML::_('select.genericlist', $venues, 'venueid', 'size="1" class="inputbox validate-venue"', 'value', 'text', $xref->venueid); unset($venues); // groups $groups = array(); $groups[] = JHTML::_('select.option', '0', JText::_('COM_REDEVENT_SELECT_GROUP')); $groups = array_merge($groups, $this->get('GroupOptions')); $lists['group'] = JHTML::_('select.genericlist', $groups, 'groupid', 'size="1" class="inputbox"', 'value', 'text', $xref->groupid); unset($groups); // published state selector $published = array(JHTML::_('select.option', '1', JText::_('COM_REDEVENT_PUBLISHED')), JHTML::_('select.option', '0', JText::_('COM_REDEVENT_UNPUBLISHED'))); $lists['published'] = JHTML::_('select.radiolist', $published, 'published', '', 'value', 'text', $xref->published); $rolesoptions = array(JHTML::_('select.option', 0, JText::_('COM_REDEVENT_Select_role'))); $rolesoptions = array_merge($rolesoptions, $this->get('RolesOptions')); $pricegroupsoptions = array(JHTML::_('select.option', 0, JText::_('COM_REDEVENT_PRICEGROUPS_SELECT_PRICEGROUP'))); $pricegroupsoptions = array_merge($pricegroupsoptions, $this->get('PricegroupsOptions')); if ($params->get('edit_recurrence', 0)) { $document->addScript('components/com_redevent/assets/js/xref_recurrence.js'); // Recurrence selector $recur_type = array(JHTML::_('select.option', 'NONE', JText::_('COM_REDEVENT_NO_REPEAT')), JHTML::_('select.option', 'DAILY', JText::_('COM_REDEVENT_DAILY')), JHTML::_('select.option', 'WEEKLY', JText::_('COM_REDEVENT_WEEKLY')), JHTML::_('select.option', 'MONTHLY', JText::_('COM_REDEVENT_MONTHLY')), JHTML::_('select.option', 'YEARLY', JText::_('COM_REDEVENT_YEARLY'))); $lists['recurrence_type'] = JHTML::_('select.radiolist', $recur_type, 'recurrence_type', '', 'value', 'text', $xref->rrules->type ? $xref->rrules->type : 'NONE'); } $this->assignRef('params', $params); $this->assignRef('editor', $editor); $this->assignRef('xref', $xref); $this->assignRef('lists', $lists); $this->assignRef('customfields', $customs); $this->assignRef('roles', $roles); $this->assignRef('rolesoptions', $rolesoptions); $this->assignRef('prices', $prices); $this->assignRef('pricegroupsoptions', $pricegroupsoptions); $this->assign('canpublish', $canpublish); parent::display($tpl); }
/** * Creates the event edit button * * @param int xref id * @since 2.0 */ function eventeditbutton($id, $xref) { $acl =& UserAcl::getInstance(); if (!$acl->canEditEvent($id)) { return ''; } JHTML::_('behavior.tooltip'); $image = JHTML::_('image', 'components/com_redevent/assets/images/calendar_edit.png', JText::_('COM_REDEVENT_EDIT_EVENT')); $overlib = JText::_('COM_REDEVENT_EDIT_EVENT_TIP'); $text = JText::_('COM_REDEVENT_EDIT_EVENT'); $link = RedeventHelperRoute::getEditEventRoute($id, $xref) . '&referer=myevents'; $output = '<a href="' . JRoute::_($link) . '" class="editlinktip hasTip" title="' . $text . '::' . $overlib . '">' . $image . '</a>'; return $output; }
/** * Creates the output for the details view * * @since 0.9 */ function display($tpl = null) { if ($this->getLayout() == 'manageattendees') { return $this->_displayManageAttendees($tpl); } $mainframe =& JFactory::getApplication(); $document = JFactory::getDocument(); $user = JFactory::getUser(); $elsettings = redEVENTHelper::config(); $acl = UserAcl::getInstance(); $uri =& JFactory::getURI(); $model =& $this->getModel(); //manages attendees $manage_attendees = $this->get('ManageAttendees'); $view_full_attendees = $this->get('ViewAttendees'); $row = $this->get('Session'); $registers = $model->getRegisters(); $register_fields = $model->getFormFields(); $roles = $this->get('Roles'); //get menu information $menu =& JSite::getMenu(); $item = $menu->getActive(); if (!$item) { $item = $menu->getDefault(); } $params =& $mainframe->getParams('com_redevent'); //Check if the id exists if (!$row) { return JError::raiseError(404, JText::sprintf('COM_REDEVENT_Session_not_found')); } //Print $pop = JRequest::getBool('pop'); $params->def('page_title', $row->full_title . ' - ' . JText::_('COM_REDEVENT_ATTENDEES')); if ($pop) { $params->set('popup', 1); } $print_link = JRoute::_('index.php?option=com_redevent&view=attendees&xref=' . $row->slug . '&pop=1&tmpl=component'); //pathway $pathway =& $mainframe->getPathWay(); $pathway->addItem(JText::_('COM_REDEVENT_ATTENDEES'), JRoute::_('index.php?option=com_redevent&view=attendees&xref=' . $row->slug)); //set page title and meta stuff $document->setTitle($item->title . ' - ' . $row->full_title); $unreg_check = redEVENTHelper::canUnregister($row->xref); // lists $lists = array(); /* Call the state object */ $state =& $this->get('state'); /* Get the values from the state object that were inserted in the model's construct function */ $lists['order_Dir'] = $state->get('filter_order_Dir'); $lists['order'] = $state->get('filter_order'); //assign vars to jview $this->assignRef('row', $row); $this->assignRef('params', $params); $this->assignRef('user', $user); $this->assignRef('manage_attendees', $manage_attendees); $this->assignRef('view_full_attendees', $view_full_attendees); $this->assignRef('print_link', $print_link); $this->assignRef('registers', $registers); $this->assignRef('registersfields', $register_fields); $this->assignRef('roles', $roles); $this->assignRef('elsettings', $elsettings); $this->assignRef('item', $item); $this->assignRef('unreg_check', $unreg_check); $this->assignRef('action', JRoute::_('index.php?option=com_redevent&view=attendees&xref=' . $row->slug)); $this->assignRef('lists', $lists); $tpl = JRequest::getVar('tpl', $tpl); parent::display($tpl); }
/** * Build the where clause * * @access private * @return string */ function _buildEventsOptionsWhere() { $mainframe =& JFactory::getApplication(); $user =& JFactory::getUser(); $gid = (int) max($user->getAuthorisedViewLevels()); // Get the paramaters of the active menu item $params =& $mainframe->getParams(); $task = JRequest::getWord('task'); $where = array(); // First thing we need to do is to select only needed events if ($task == 'archive') { $where[] = ' x.published = -1 '; } else { $where[] = ' x.published > -1 '; } $acl = UserAcl::getInstance(); if (!$acl->superuser()) { $xrefs = $acl->getCanEditXrefs(); $xrefs = array_merge($acl->getCanViewAttendees(), $xrefs); $xrefs = array_unique($xrefs); if ($xrefs && count($xrefs)) { $where[] = ' x.id IN (' . implode(",", $xrefs) . ')'; } else { $where[] = '0'; } } if ($params->get('showopendates', 1) == 0) { $where[] = ' x.dates IS NOT NULL AND x.dates > 0 '; } if ($params->get('shownonbookable', 1) == 0) { $where[] = ' a.registra > 0 '; } /* * If we have a filter, and this is enabled... lets tack the AND clause * for the filter onto the WHERE clause of the item query. */ if ($params->get('filter_text')) { $filter = JRequest::getString('filter', '', 'request'); $filter_type = JRequest::getWord('filter_type', '', 'request'); if ($filter) { // clean filter variables $filter = JString::strtolower($filter); $filter = $this->_db->Quote('%' . $this->_db->getEscaped($filter, true) . '%', false); $filter_type = JString::strtolower($filter_type); switch ($filter_type) { case 'title': $where[] = ' LOWER( a.title ) LIKE ' . $filter; break; case 'venue': $where[] = ' LOWER( l.venue ) LIKE ' . $filter; break; case 'city': $where[] = ' LOWER( l.city ) LIKE ' . $filter; break; case 'type': $where[] = ' LOWER( c.catname ) LIKE ' . $filter; break; } } } $where = ' WHERE ' . implode(' AND ', $where); return $where; }
/** * Method get the categories query * * @access private * @return array */ function _buildQuery() { $mainframe =& JFactory::getApplication(); $params =& $mainframe->getParams('com_redevent'); $user =& JFactory::getUser(); $gid = max($user->getAuthorisedViewLevels()); $acl =& UserAcl::getInstance(); $gids = $acl->getUserGroupsIds(); if (!is_array($gids) || !count($gids)) { $gids = array(0); } $gids = implode(',', $gids); //get categories if ($params->get('display_all_categories', 1)) { $query = ' SELECT c.*, ' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as slug' . ' FROM #__redevent_categories AS c ' . ' LEFT JOIN #__redevent_groups_categories AS gc ON gc.category_id = c.id AND gc.group_id IN (' . $gids . ')' . ' WHERE c.published = 1 ' . ' AND (c.private = 0 OR gc.id IS NOT NULL) '; if ($this->_parent) { $query .= ' AND c.parent_id = ' . $this->_db->Quote($this->_parent->id); } } else { //check archive task and ensure that only categories get selected if they contain a published/archived event $task = JRequest::getWord('task'); if ($task == 'archive') { $eventstate = ' AND x.published = -1'; } else { $eventstate = ' AND x.published = 1'; } $query = ' SELECT DISTINCT c.*, ' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as slug ' . ' FROM #__redevent_categories AS c ' . ' INNER JOIN #__redevent_categories AS child ON child.lft BETWEEN c.lft AND c.rgt ' . ' INNER JOIN #__redevent_event_category_xref AS xcat ON xcat.category_id = child.id ' . ' INNER JOIN #__redevent_event_venue_xref AS x ON x.eventid = xcat.event_id ' . ' LEFT JOIN #__redevent_groups_categories AS gc ON gc.category_id = c.id AND gc.group_id IN (' . $gids . ')' . ' WHERE child.published = 1 ' . ' AND child.access <= ' . $gid . ' AND (c.private = 0 OR gc.id IS NOT NULL) ' . $eventstate; if ($this->_parent) { $query .= ' AND c.parent_id = ' . $this->_db->Quote($this->_parent->id); } } $query .= ' GROUP BY c.id '; $query .= ' ORDER BY c.ordering ASC '; return $query; }
/** * Creates the Venueevents View * * @since 0.9 */ function display($tpl = null) { $mainframe =& JFactory::getApplication(); $option = JRequest::getCmd('option'); //initialize variables $document =& JFactory::getDocument(); $menu =& JSite::getMenu(); $elsettings =& redEVENTHelper::config(); $item = $menu->getActive(); $params =& $mainframe->getParams('com_redevent'); $uri =& JFactory::getURI(); $acl = UserAcl::getInstance(); //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]-->'); // add js JHTML::_('behavior.mootools'); // for filter hint $document->addScript($this->baseurl . '/components/com_redevent/assets/js/eventslist.js'); // Request variables $limitstart = JRequest::getInt('limitstart'); $limit = $mainframe->getUserStateFromRequest('com_redevent.venueevents.limit', 'limit', $params->def('display_num', 0), 'int'); $pop = JRequest::getBool('pop'); $task = JRequest::getWord('task'); //get data from model $rows =& $this->get('Data'); $venue =& $this->get('Venue'); $total =& $this->get('Total'); $customs =& $this->get('ListCustomFields'); $customsfilters =& $this->get('CustomFilters'); //does the venue exist? if ($venue->id == 0) { return JError::raiseError(404, JText::sprintf('COM_REDEVENT_Venue_d_not_found', $venue->id)); } //are events available? if (!$rows) { $noevents = 1; } else { $noevents = 0; } // Add needed scripts if the lightbox effect is enabled JHTML::_('behavior.modal'); //add alternate feed link $link = 'index.php?option=com_redevent&view=venueevents&format=feed&id=' . $venue->id; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); //pathway $pathway =& $mainframe->getPathWay(); //create the pathway if ($task == 'archive') { $link = JRoute::_(RedeventHelperRoute::getVenueEventsRoute($venue->slug, 'archive')); $pathway->addItem(JText::_('COM_REDEVENT_ARCHIVE') . ' - ' . $venue->venue, $link); $print_link = JRoute::_('index.php?option=com_redevent&view=venueevents&id=' . $venue->slug . '&task=archive&pop=1&tmpl=component'); $pagetitle = $venue->venue . ' - ' . JText::_('COM_REDEVENT_ARCHIVE'); } else { $link = JRoute::_(RedeventHelperRoute::getVenueEventsRoute($venue->slug)); $pathway->addItem($venue->venue, $link); $print_link = JRoute::_('index.php?option=com_redevent&view=venueevents&id=' . $venue->slug . '&pop=1&tmpl=component'); $pagetitle = $venue->venue; } $thumb_link = RedeventHelperRoute::getVenueEventsRoute($venue->slug, null, 'thumb'); $list_link = RedeventHelperRoute::getVenueEventsRoute($venue->slug, null, 'default'); //set Page title $this->document->setTitle($pagetitle); $document->setMetadata('keywords', $venue->meta_keywords); $document->setDescription(strip_tags($venue->meta_description)); //Printfunction $params->def('print', !$mainframe->getCfg('hidePrint')); $params->def('icons', $mainframe->getCfg('icons')); if ($pop) { $params->set('popup', 1); } //Check if the user has access to the form $maintainer = $acl->canEditVenue($venue->id); //Generate Venuedescription if (!empty($venue->locdescription)) { //execute plugins $venuedescription = JHTML::_('content.prepare', $venue->locdescription); } //build the url if (!empty($venue->url) && strtolower(substr($venue->url, 0, 7)) != "http://") { $venue->url = 'http://' . $venue->url; } //prepare the url for output if (strlen(htmlspecialchars($venue->url, ENT_QUOTES)) > 35) { $venue->urlclean = substr(htmlspecialchars($venue->url, ENT_QUOTES), 0, 35) . '...'; } else { $venue->urlclean = htmlspecialchars($venue->url, ENT_QUOTES); } //create flag if ($venue->country) { $venue->countryimg = REOutput::getFlag($venue->country); } // Create the pagination object jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); //create select lists $lists = $this->_buildSortLists($elsettings); $state =& $this->get('state'); $filter_customs = $state->get('filter_customs'); $this->assign('lists', $lists); $this->assign('action', JRoute::_(RedeventHelperRoute::getVenueEventsRoute($venue->slug))); $this->assignRef('rows', $rows); $this->assignRef('customs', $customs); $this->assignRef('noevents', $noevents); $this->assignRef('venue', $venue); $this->assignRef('print_link', $print_link); $this->assignRef('params', $params); $this->assignRef('editlink', $maintainer); $this->assignRef('venuedescription', $venuedescription); $this->assignRef('pageNav', $pageNav); $this->assignRef('elsettings', $elsettings); $this->assignRef('item', $item); $this->assignRef('pagetitle', $pagetitle); $this->assignRef('task', $task); $this->assignRef('config', $elsettings); $this->assignRef('thumb_link', $thumb_link); $this->assignRef('list_link', $list_link); $this->assignRef('customsfilters', $customsfilters); $this->assign('filter_customs', $filter_customs); $cols = explode(',', $params->get('lists_columns', 'date, title, venue, city, category')); $cols = redEVENTHelper::validateColumns($cols); $this->assign('columns', $cols); parent::display($tpl); }
/** * check if user is allowed to addxrefs * @return boolean */ function getCanAddXref() { $acl = UserAcl::getInstance(); return $acl->canAddXref(); }
/** * Build the query * * @access private * @return string */ function _buildQuery() { $acl = UserAcl::getInstance(); $gids = $acl->getUserGroupsIds(); if (!is_array($gids) || !count($gids)) { $gids = array(0); } $gids = implode(',', $gids); // Get the WHERE clauses for the query $where = $this->_buildWhere(); //Get Events from Database $query = ' SELECT DATEDIFF(x.enddates, x.dates) AS datediff, a.id, x.id AS xref, x.dates, x.enddates, x.times, x.endtimes, ' . ' a.title, x.venueid as locid, a.datdescription, a.created, l.venue, l.city, l.state, l.url, l.street, l.country, x.featured, ' . ' a.datimage, ' . ' CASE WHEN CHAR_LENGTH(x.title) THEN CONCAT_WS(\' - \', a.title, x.title) ELSE a.title END as full_title, ' . ' DAYOFMONTH(x.dates) AS start_day, YEAR(x.dates) AS start_year, MONTH(x.dates) AS start_month,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(x.alias) THEN CONCAT_WS(\':\', x.id, x.alias) ELSE x.id END as xslug, ' . ' CASE WHEN CHAR_LENGTH(l.alias) THEN CONCAT_WS(\':\', l.id, l.alias) ELSE l.id END as venueslug' . ' FROM #__redevent_events AS a' . ' INNER JOIN #__redevent_event_venue_xref AS x ON x.eventid = a.id ' . ' INNER JOIN #__redevent_venues AS l ON l.id = x.venueid' . ' LEFT JOIN #__redevent_venue_category_xref AS xvcat ON l.id = xvcat.venue_id' . ' LEFT JOIN #__redevent_venues_categories AS vc ON xvcat.category_id = vc.id' . ' INNER JOIN #__redevent_event_category_xref AS xcat ON xcat.event_id = a.id' . ' INNER JOIN #__redevent_categories AS cat ON cat.id = xcat.category_id' . ' LEFT JOIN #__redevent_groups_venues AS gv ON gv.venue_id = l.id AND gv.group_id IN (' . $gids . ')' . ' LEFT JOIN #__redevent_groups_venues_categories AS gvc ON gvc.category_id = vc.id AND gvc.group_id IN (' . $gids . ')' . ' LEFT JOIN #__redevent_groups_categories AS gc ON gc.category_id = cat.id AND gc.group_id IN (' . $gids . ')' . $where . ' GROUP BY x.id ' . ' ORDER BY x.dates, x.times'; return $query; }
/** * Build the query * * @access private * @return string */ function _buildQuery() { $acl =& UserAcl::getInstance(); $gids = $acl->getUserGroupsIds(); if (!is_array($gids) || !count($gids)) { $gids = array(0); } $gids = implode(',', $gids); //check archive task $task = JRequest::getVar('task', '', '', 'string'); if ($task == 'archive') { $eventstate = ' AND x.published = -1'; } else { $eventstate = ' AND x.published = 1'; } //get categories $query = 'SELECT c.*, COUNT( x.id ) AS assignedevents,' . ' CONCAT_WS(\':\', c.id, c.iso2) as slug' . ' FROM #__redevent_countries as c' . ' INNER JOIN #__redevent_venues as v ON v.country = c.iso2' . ' LEFT JOIN #__redevent_venue_category_xref AS xvcat ON v.id = xvcat.venue_id' . ' LEFT JOIN #__redevent_venues_categories AS vc ON xvcat.category_id = vc.id' . ' INNER JOIN #__redevent_event_venue_xref AS x ON x.venueid = v.id' . ' LEFT JOIN #__redevent_groups_venues AS gv ON gv.venue_id = v.id AND gv.group_id IN (' . $gids . ')' . ' LEFT JOIN #__redevent_groups_venues_categories AS gvc ON gvc.category_id = vc.id AND gvc.group_id IN (' . $gids . ')' . ' LEFT JOIN #__redevent_groups_categories AS gc ON gc.category_id = c.id AND gc.group_id IN (' . $gids . ')' . ' WHERE v.published = 1' . ' AND v.latitude <> 0 AND v.longitude <> 0 ' . ' AND (l.private = 0 OR gv.id IS NOT NULL) ' . ' AND (c.private = 0 OR gc.id IS NOT NULL) ' . ' AND (vc.private = 0 OR vc.private IS NULL OR gvc.id IS NOT NULL) ' . $eventstate . ' GROUP BY c.id' . ' ORDER BY c.name'; return $query; }