public function display($tpl = null) { $user = JemFactory::getUser(); $jemsettings = JEMAdmin::config(); // Initialise variables. $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); // loading Mootools JHtml::_('behavior.framework'); // Load css JHtml::_('stylesheet', 'com_jem/backend.css', array(), true); // add style to description of the tooltip (hastip) JHtml::_('behavior.tooltip'); // assign data to template $this->user = $user; $this->jemsettings = $jemsettings; // add toolbar $this->addToolbar(); parent::display($tpl); }
/** * logic to get the categories * * @access public * @return void */ function getCategories($id) { $db = JFactory::getDbo(); $user = JemFactory::getUser(); $userid = (int) $user->get('id'); if (empty($id)) { // for new events also show all categories user is allowed to see, disable non-useable categories // (to show same list in both cases, and allow "unusable" parents for structuring) $mitems = $user->getJemCategories('add', 'event', array('use_disable' => true)); } else { $query = $db->getQuery(true); $query = 'SELECT COUNT(*)' . ' FROM #__jem_events AS e' . ' WHERE e.id = ' . $db->quote($id) . ' AND e.created_by = ' . $db->quote($userid); $db->setQuery($query); $owner = $db->loadResult(); // on edit show all categories user is allowed to see, disable non-useable categories $mitems = $user->getJemCategories(array('add', 'edit'), 'event', array('use_disable' => true, 'owner' => $owner)); } if (!$mitems) { $mitems = array(); $children = array(); $parentid = 0; } else { $children = array(); // First pass - collect children foreach ($mitems as $v) { $pt = $v->parent_id; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } // list childs of "root" which has no parent and normally id 1 $parentid = intval(@isset($children[0][0]->id) ? $children[0][0]->id : 1); } //get list of the items $list = JEMCategories::treerecurse($parentid, '', array(), $children, 9999, 0, 0); // append orphaned categories if (count($mitems) > count($list)) { foreach ($children as $k => $v) { if (($k > 1) && !array_key_exists($k, $list)) { $list = JEMCategories::treerecurse($k, '? ', $list, $children, 999, 0, 0); } } } return $list; }
public function display($tpl = null) { $app = JFactory::getApplication(); //initialise variables $user = JemFactory::getUser(); $db = JFactory::getDBO(); $jemsettings = JEMAdmin::config(); $document = JFactory::getDocument(); $itemid = $app->input->getInt('id', 0) . ':' . $app->input->getInt('Itemid', 0); JHtml::_('behavior.tooltip'); JHtml::_('behavior.modal'); //get var $filter_order = $app->getUserStateFromRequest('com_jem.eventelement.filter_order', 'filter_order', 'a.dates', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest('com_jem.eventelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); $filter_type = $app->getUserStateFromRequest('com_jem.eventelement.'.$itemid.'.filter_type', 'filter_type', '', 'int'); $filter_state = $app->getUserStateFromRequest('com_jem.eventelement.'.$itemid.'.filter_state', 'filter_state', '', 'string'); $filter_search = $app->getUserStateFromRequest('com_jem.eventelement.'.$itemid.'.filter_search', 'filter_search', '', 'string'); $filter_search = $db->escape(trim(JString::strtolower($filter_search))); //prepare the document $document->setTitle(JText::_('COM_JEM_SELECTEVENT')); // Load css JHtml::_('stylesheet', 'com_jem/backend.css', array(), true); //Get data from the model $rows = $this->get('Data'); $pagination = $this->get('Pagination'); //publish unpublished filter //$lists['state'] = JHtml::_('grid.state', $filter_state); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; //Create the filter selectlist $filters = array(); $filters[] = JHtml::_('select.option', '1', JText::_('COM_JEM_EVENT_TITLE')); $filters[] = JHtml::_('select.option', '2', JText::_('COM_JEM_VENUE')); $filters[] = JHtml::_('select.option', '3', JText::_('COM_JEM_CITY')); //$filters[] = JHtml::_('select.option', '4', JText::_('COM_JEM_CATEGORY')); $lists['filter'] = JHtml::_('select.genericlist', $filters, 'filter_type', array('size'=>'1','class'=>'inputbox'), 'value', 'text', $filter_type); // search filter $lists['search']= $filter_search; //assign data to template $this->lists = $lists; $this->filter_state = $filter_state; $this->rows = $rows; $this->pagination = $pagination; $this->jemsettings = $jemsettings; $this->user = $user; parent::display($tpl); }
public function display($tpl = null) { $user = JemFactory::getUser(); $document = JFactory::getDocument(); $url = JUri::root(); $settings = JEMHelper::globalattribs(); // Initialise variables. $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->settings = $settings; $params = $this->state->get('params'); // highlighter $highlighter = $settings->get('highlight','0'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Load css JHtml::_('stylesheet', 'com_jem/backend.css', array(), true); // Add Scripts $document->addScript('http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'); if ($highlighter) { $document->addScript($url.'media/com_jem/js/highlighter.js'); $style = ' .red, .red a { color:red;} '; $document->addStyleDeclaration($style); } //add style to description of the tooltip (hastip) JHtml::_('behavior.tooltip'); // add filter selection for the search $filters = array(); $filters[] = JHtml::_('select.option', '1', JText::_('COM_JEM_VENUE')); $filters[] = JHtml::_('select.option', '2', JText::_('COM_JEM_CITY')); $filters[] = JHtml::_('select.option', '3', JText::_('COM_JEM_STATE')); $filters[] = JHtml::_('select.option', '4', JText::_('COM_JEM_COUNTRY')); $filters[] = JHtml::_('select.option', '5', JText::_('JALL')); $lists['filter'] = JHtml::_('select.genericlist', $filters, 'filter_type', array('size'=>'1','class'=>'inputbox'), 'value', 'text', $this->state->get('filter_type')); //assign data to template $this->lists = $lists; $this->user = $user; // add toolbar $this->addToolbar(); parent::display($tpl); }
/** * Add the page title and toolbar. */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JemFactory::getUser(); $isNew = ($this->item->id == 0); $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); $canDo = JemHelperBackend::getActions(); JToolBarHelper::title($isNew ? JText::_('COM_JEM_ADD_EVENT') : JText::_('COM_JEM_EDIT_EVENT'), 'eventedit'); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit')||$canDo->get('core.create'))) { JToolBarHelper::apply('event.apply'); JToolBarHelper::save('event.save'); } if (!$checkedOut && $canDo->get('core.create')) { JToolBarHelper::save2new('event.save2new'); } // If an existing item, can save to a copy. if (!$isNew && $canDo->get('core.create')) { JToolBarHelper::save2copy('event.save2copy'); } if (empty($this->item->id)) { JToolBarHelper::cancel('event.cancel'); } else { JToolBarHelper::cancel('event.cancel', 'JTOOLBAR_CLOSE'); } JToolBarHelper::divider(); JToolBarHelper::help('editevents', true); }
/** * Method to test whether a record can be deleted. * * @param object A record object. * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. * */ protected function canEditState($record) { $user = JemFactory::getUser(); if (!empty($record->catid)) { return $user->authorise('core.edit.state', 'com_jem.category.'.(int) $record->catid); } else { return $user->authorise('core.edit.state', 'com_jem'); } }
/** * Add Toolbar */ protected function addToolbar() { JToolBarHelper::title(JText::_('COM_JEM_MAIN_TITLE'), 'home'); if (JemFactory::getUser()->authorise('core.manage', 'com_jem')) { JToolBarHelper::preferences('com_jem'); JToolbarHelper::divider(); } JToolBarHelper::help('home', true); }
/** * Add the page title and toolbar. */ protected function addToolbar() { // Initialise variables. $canDo = null; $user = JemFactory::getUser(); // Get the results for each action. $canDo = JEMHelperBackend::getActions(0); JToolBarHelper::title(JText::_('COM_JEM_CATEGORIES'), 'elcategories'); if ($canDo->get('core.create')) { JToolBarHelper::addNew('category.add'); } if ($canDo->get('core.edit' ) || $canDo->get('core.edit.own')) { JToolBarHelper::editList('category.edit'); JToolBarHelper::divider(); } if ($canDo->get('core.edit.state')) { JToolBarHelper::publish('categories.publish', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::unpublish('categories.unpublish', 'JTOOLBAR_UNPUBLISH', true); JToolBarHelper::divider(); JToolBarHelper::archiveList('categories.archive'); } if ($user->authorise('core.admin')) { // todo: is that correct? JToolBarHelper::checkin('categories.checkin'); } if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('COM_JEM_CONFIRM_DELETE', 'categories.remove', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($canDo->get('core.edit.state')) { JToolBarHelper::trash('categories.trash'); } if ($canDo->get('core.admin')) { JToolBarHelper::divider(); JToolBarHelper::custom('categories.rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false); } JToolBarHelper::divider(); JToolBarHelper::help('listcategories', true); }
/** * Method to check if you can edit a record. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * * @return boolean * */ protected function allowEditDisabled($data = array(), $key = 'parent_id') { // Initialise variables. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; $user = JemFactory::getUser(); $userId = $user->get('id'); // Check general edit permission first. if ($user->authorise('core.edit', $this->extension)) { return true; } // Check specific edit permission. if ($user->authorise('core.edit', $this->extension . '.category.' . $recordId)) { return true; } // Fallback on edit.own. // First test if the permission is available. if ($user->authorise('core.edit.own', $this->extension . '.category.' . $recordId) || $user->authorise('core.edit.own', $this->extension)) { // Now test the owner is the user. $ownerId = (int) isset($data['created_user_id']) ? $data['created_user_id'] : 0; if (empty($ownerId) && $recordId) { // Need to do a lookup from the model. $record = $this->getModel()->getItem($recordId); if (empty($record)) { return false; } $ownerId = $record->created_user_id; } // If the owner matches 'me' then do the test. if ($ownerId == $userId) { return true; } } return false; }
/** * Add the page title and toolbar. */ protected function addToolbar() { // Initialise variables. $user = JemFactory::getUser(); $userId = $user->get('id'); $isNew = ($this->item->id == 0); $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId); // Get the results for each action. $canDo = JEMHelperBackend::getActions(); $title = JText::_('COM_JEM_CATEGORY_BASE_'.($isNew?'ADD':'EDIT').'_TITLE'); // Prepare the toolbar. JToolBarHelper::title($title, 'category-'.($isNew?'add':'edit').' -category-'.($isNew?'add':'edit')); // For new records, check the create permission. if ($isNew && (count($user->getAuthorisedCategories('com_jem', 'core.create')) > 0)) { JToolBarHelper::apply('category.apply'); JToolBarHelper::save('category.save'); JToolBarHelper::save2new('category.save2new'); } // If not checked out, can save the item. elseif (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_user_id == $userId))) { JToolBarHelper::apply('category.apply'); JToolBarHelper::save('category.save'); if ($canDo->get('core.create')) { JToolBarHelper::save2new('category.save2new'); } } // If an existing item, can save to a copy. if (!$isNew && $canDo->get('core.create')) { JToolBarHelper::save2copy('category.save2copy'); } if (empty($this->item->id)) { JToolBarHelper::cancel('category.cancel'); } else { JToolBarHelper::cancel('category.cancel', 'JTOOLBAR_CLOSE'); } JToolBarHelper::divider(); JToolBarHelper::help('editcategories', true); }
/** * Add the page title and toolbar. * */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JemFactory::getUser(); $canDo = JEMHelperBackend::getActions(0); JToolBarHelper::title(JText::_('COM_JEM_CSSMANAGER_EDIT_FILE'), 'thememanager'); // Can save the item. if ($canDo->get('core.edit')) { JToolBarHelper::apply('source.apply'); JToolBarHelper::save('source.save'); } JToolBarHelper::cancel('source.cancel', 'JTOOLBAR_CLOSE'); JToolBarHelper::divider(); JToolBarHelper::help('editcss', true); }
/** * Method override to check if you can edit an existing record. * @todo: check if the user is allowed to edit/save * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * * @return boolean */ protected function allowEdit($data = array(), $key = 'id') { // Initialise variables. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; $user = JemFactory::getUser(); if (isset($data['created_by'])) { $created_by = $data['created_by']; } else { $record = $this->getModel()->getItem($recordId); $created_by = isset($record->created_by) ? $record->created_by : false; } if ($user->can('edit', 'event', $recordId, $created_by)) { return true; } // Since there is no asset tracking, revert to the component permissions. return parent::allowEdit($data, $key); }
/** * Add Toolbar */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); //get vars $cid = JFactory::getApplication()->input->get('cid', array(), 'array'); $user = JemFactory::getUser(); $checkedOut = false; // don't know, table hasn't such a field $canDo = JemHelperBackend::getActions(); if (empty($cid[0])) { JToolBarHelper::title(JText::_('COM_JEM_ADD_ATTENDEE'), 'users'); } else { JToolBarHelper::title(JText::_('COM_JEM_EDIT_ATTENDEE'), 'users'); } // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit')||$canDo->get('core.create'))) { JToolBarHelper::apply('attendee.apply'); JToolBarHelper::save('attendee.save'); } if (!$checkedOut && $canDo->get('core.create')) { JToolBarHelper::save2new('attendee.save2new'); } // If an existing item, can save to a copy. if (!empty($cid[0]) && $canDo->get('core.create')) { JToolBarHelper::save2copy('attendee.save2copy'); } if (empty($cid[0])) { JToolBarHelper::cancel('attendee.cancel'); } else { JToolBarHelper::cancel('attendee.cancel', 'JTOOLBAR_CLOSE'); } JToolBarHelper::divider(); JToolBarHelper::help('editattendee', true); }
/** * Method to toggle the featured setting of a list of events. * * @return void * @since 1.6 */ function featured() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $user = JemFactory::getUser(); $ids = JFactory::getApplication()->input->get('cid', array(), 'array'); $values = array('featured' => 1, 'unfeatured' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); $glob_auth = $user->can('publish', 'event'); // general permission for all events // Access checks. foreach ($ids as $i => $id) { if (!$glob_auth && !$user->can('publish', 'event', (int)$id)) { // Prune items that you can't change. unset($ids[$i]); JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); } } if (empty($ids)) { JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Publish the items. if (!$model->featured($ids, $value)) { JError::raiseWarning(500, $model->getError()); } } $this->setRedirect('index.php?option=com_jem&view=events'); }
public function display($tpl = null) { $app = JFactory::getApplication(); $this->totalcats = $this->get('Countcats'); //only admins have access to this view if (!JemFactory::getUser()->authorise('core.manage', 'com_jem')) { JError::raiseWarning('SOME_ERROR_CODE', JText::_('JERROR_ALERTNOAUTHOR')); $app->redirect('index.php?option=com_jem&view=main'); } // Load css JHtml::_('stylesheet', 'com_jem/backend.css', array(), true); // Load Script JHtml::_('behavior.framework'); // add toolbar $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { $this->files = $this->get('Files'); $this->statusLinenumber = $this->get('StatusLinenumber'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $app = JFactory::getApplication(); // initialise variables $document = JFactory::getDocument(); $user = JemFactory::getUser(); // Load css JHtml::_('stylesheet', 'com_jem/backend.css', array(), true); $this->addToolbar(); parent::display($tpl); }
/** * Gets a list of the actions that can be performed. * * @param int The category ID. * * @return JObject * * */ public static function getActions($categoryId = 0) { $user = JemFactory::getUser(); $result = new JObject; if (empty($categoryId)) { $assetName = 'com_jem'; $level = 'component'; } else { $assetName = 'com_jem.category.'.(int) $categoryId; $level = 'category'; } $actions = JAccess::getActions('com_jem', $level); foreach ($actions as $action) { $result->set($action->name, $user->authorise($action->name, $assetName)); } return $result; }
/** * Creates the Venue View */ function display($tpl = null) { if ($this->getLayout() == 'calendar') { ### Venue Calendar view ### $app = JFactory::getApplication(); // Load tooltips behavior JHtml::_('behavior.tooltip'); // initialize variables $document = JFactory::getDocument(); $menu = $app->getMenu(); $menuitem = $menu->getActive(); $jemsettings = JEMHelper::config(); $params = $app->getParams(); $uri = JFactory::getURI(); $pathway = $app->getPathWay(); $jinput = $app->input; $print = $jinput->getBool('print', false); $user = JemFactory::getUser(); // Load css JemHelper::loadCss('jem'); JemHelper::loadCss('calendar'); JemHelper::loadCustomCss(); JemHelper::loadCustomTag(); if ($print) { JemHelper::loadCss('print'); $document->setMetaData('robots', 'noindex, nofollow'); } $evlinkcolor = $params->get('eventlinkcolor'); $evbackgroundcolor = $params->get('eventbackgroundcolor'); $currentdaycolor = $params->get('currentdaycolor'); $eventandmorecolor = $params->get('eventandmorecolor'); $style = ' div#jem .eventcontentinner a, div#jem .eventandmore a {color:' . $evlinkcolor . ';} .eventcontentinner {background-color:'.$evbackgroundcolor .';} .eventandmore {background-color:' . $eventandmorecolor . ';} .today .daynum {background-color:' . $currentdaycolor . ';}'; $document->addStyleDeclaration ($style); // add javascript (using full path - see issue #590) JHtml::_('script', 'media/com_jem/js/calendar.js'); // Retrieve year/month variables $year = $jinput->get('yearID', strftime("%Y"),'int'); $month = $jinput->get('monthID', strftime("%m"),'int'); // get data from model and set the month $model = $this->getModel('VenueCal'); $model->setDate(mktime(0, 0, 1, $month, 1, $year)); $rows = $this->get('Items','VenueCal'); // Set Page title $pagetitle = $params->def('page_title', $menuitem->title); $params->def('page_heading', $params->get('page_title')); $pageclass_sfx = $params->get('pageclass_sfx'); // Add site name to title if param is set if ($app->getCfg('sitename_pagetitles', 0) == 1) { $pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename')); } $document->setTitle($pagetitle); $document->setMetaData('title', $pagetitle); // Check if the user has permission to add things $permissions = new stdClass(); $permissions->canAddEvent = $user->can('add', 'event'); $permissions->canAddVenue = $user->can('add', 'venue'); $itemid = $jinput->getInt('Itemid', 0); $venueID = $jinput->getInt('id', $params->get('id')); $partItemid = ($itemid > 0) ? '&Itemid=' . $itemid : ''; $partVenid = ($venueID > 0) ? '&id=' . $venueID : ''; $partLocid = ($venueID > 0) ? '&locid=' . $venueID : ''; $partDate = ($year ? ('&yearID=' . $year) : '') . ($month ? ('&monthID=' . $month) : ''); $url_base = 'index.php?option=com_jem&view=venue&layout=calendar' . $partVenid . $partItemid; $print_link = JRoute::_($url_base . $partDate . '&print=1&tmpl=component'); // init calendar $cal = new JEMCalendar($year, $month, 0); $cal->enableMonthNav($url_base . ($print ? '&print=1&tmpl=component' : '')); $cal->setFirstWeekDay($params->get('firstweekday',1)); $cal->enableDayLinks('index.php?option=com_jem&view=day'.$partLocid); // map variables $this->rows = $rows; $this->locid = $venueID; $this->params = $params; $this->jemsettings = $jemsettings; $this->permissions = $permissions; $this->cal = $cal; $this->pageclass_sfx = htmlspecialchars($pageclass_sfx); $this->print_link = $print_link; } else { ### Venue List view ### // initialize variables $app = JFactory::getApplication(); $document = JFactory::getDocument(); $menu = $app->getMenu(); $menuitem = $menu->getActive(); $jemsettings = JemHelper::config(); $settings = JemHelper::globalattribs(); $params = $app->getParams('com_jem'); $pathway = $app->getPathWay (); $uri = JFactory::getURI(); $jinput = $app->input; $task = $jinput->getCmd('task', ''); $print = $jinput->getBool('print', false); $user = JemFactory::getUser(); $itemid = $app->input->getInt('id', 0) . ':' . $app->input->getInt('Itemid', 0); // Load css JemHelper::loadCss('jem'); JemHelper::loadCustomCss(); JemHelper::loadCustomTag(); if ($print) { JemHelper::loadCss('print'); $document->setMetaData('robots', 'noindex, nofollow'); } // get data from model $rows = $this->get('Items'); $venue = $this->get('Venue'); // check for data error if (empty($venue)) { $app->enqueueMessage(JText::_('COM_JEM_VENUE_ERROR_VENUE_NOT_FOUND'), 'error'); return false; } // are events available? $noevents = (!$rows) ? 1 : 0; // Decide which parameters should take priority $useMenuItemParams = ($menuitem && $menuitem->query['option'] == 'com_jem' && $menuitem->query['view'] == 'venue' && (!isset($menuitem->query['layout']) || $menuitem->query['layout'] == 'default') && $menuitem->query['id'] == $venue->id); // get search & user-state variables $filter_order = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_order', 'filter_order', 'a.dates', 'cmd'); $filter_order_DirDefault = 'ASC'; // Reverse default order for dates in archive mode if($task == 'archive' && $filter_order == 'a.dates') { $filter_order_DirDefault = 'DESC'; } $filter_order_Dir = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_order_Dir', 'filter_order_Dir', $filter_order_DirDefault, 'word'); $filter_type = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_type', 'filter_type', '', 'int'); $search = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_search', 'filter_search', '', 'string'); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // Get image $limage = JemImage::flyercreator($venue->locimage,'venue'); // Add feed links $link = '&format=feed&id='.$venue->id.'&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); // pathway, page title, page heading if ($useMenuItemParams) { $pagetitle = $params->get('page_title', $menuitem->title ? $menuitem->title : $venue->venue); $pageheading = $params->get('page_heading', $pagetitle); $pathway->setItemName(1, $menuitem->title); } else { $pagetitle = $venue->venue; $pageheading = $pagetitle; $params->set('show_page_heading', 1); // ensure page heading is shown $pathway->addItem($pagetitle, JRoute::_(JemHelperRoute::getVenueRoute($venue->slug))); } $pageclass_sfx = $params->get('pageclass_sfx'); // create the pathway if ($task == 'archive') { $pathway->addItem (JText::_('COM_JEM_ARCHIVE'), JRoute::_(JemHelperRoute::getVenueRoute($venue->slug).'&task=archive')); $print_link = JRoute::_(JEMHelperRoute::getVenueRoute($venue->slug).'&task=archive&print=1&tmpl=component'); $pagetitle .= ' - ' . JText::_('COM_JEM_ARCHIVE'); $pageheading .= ' - ' . JText::_('COM_JEM_ARCHIVE'); } else { //$pathway->addItem($venue->venue, JRoute::_(JEMHelperRoute::getVenueRoute($venue->slug))); $print_link = JRoute::_(JemHelperRoute::getVenueRoute($venue->slug).'&print=1&tmpl=component'); } $params->set('page_heading', $pageheading); // Add site name to title if param is set if ($app->getCfg('sitename_pagetitles', 0) == 1) { $pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename')); } // set Page title & Meta data $document->setTitle($pagetitle); $document->setMetaData('title', $pagetitle); $document->setMetadata('keywords', $venue->meta_keywords); $document->setDescription(strip_tags($venue->meta_description)); // Check if the user has permission to add things $permissions = new stdClass(); $permissions->canAddEvent = $user->can('add', 'event'); $permissions->canAddVenue = $user->can('add', 'venue'); // Check if the user has permission to edit-this venue $permissions->canEditVenue = $user->can('edit', 'venue', $venue->id, $venue->created_by); $permissions->canEditPublishVenue = $user->can(array('edit', 'publish'), 'venue', $venue->id, $venue->created_by); // Generate Venuedescription if (!$venue->locdescription == '' || !$venue->locdescription == '<br />') { // execute plugins $venue->text = $venue->locdescription; $venue->title = $venue->venue; JPluginHelper::importPlugin ('content'); $app->triggerEvent ('onContentPrepare', array ( 'com_jem.venue', &$venue, &$params, 0 )); $venuedescription = $venue->text; } // build the url if (!empty($venue->url) && !preg_match('%^http(s)?://%', $venue->url)) { $venue->url = 'http://' . $venue->url; } // prepare the url for output if (strlen($venue->url) > 35) { $venue->urlclean = $this->escape(substr($venue->url, 0, 35 )) . '...'; } else { $venue->urlclean = $this->escape($venue->url); } // create flag if ($venue->country) { $venue->countryimg = JemHelperCountries::getCountryFlag($venue->country); } // Create the pagination object $pagination = $this->get('Pagination'); // filters $filters = array (); // ALL events have the same venue - so hide this from filter and list $jemsettings->showlocate = 0; if ($jemsettings->showtitle == 1) { $filters[] = JHtml::_('select.option', '1', JText::_('COM_JEM_TITLE')); } if ($jemsettings->showlocate == 1) { $filters[] = JHtml::_('select.option', '2', JText::_('COM_JEM_VENUE')); } if ($jemsettings->showcity == 1) { $filters[] = JHtml::_('select.option', '3', JText::_('COM_JEM_CITY')); } if ($jemsettings->showcat == 1) { $filters[] = JHtml::_('select.option', '4', JText::_('COM_JEM_CATEGORY')); } if ($jemsettings->showstate == 1) { $filters[] = JHtml::_('select.option', '5', JText::_('COM_JEM_STATE')); } $lists['filter'] = JHtml::_('select.genericlist', $filters, 'filter_type', array('size'=>'1','class'=>'inputbox'), 'value', 'text', $filter_type); $lists['search'] = $search; // mapping variables $this->lists = $lists; $this->action = $uri->toString(); $this->rows = $rows; $this->noevents = $noevents; $this->venue = $venue; $this->print_link = $print_link; $this->params = $params; $this->limage = $limage; $this->venuedescription = $venuedescription; $this->pagination = $pagination; $this->jemsettings = $jemsettings; $this->settings = $settings; $this->permissions = $permissions; $this->show_status = $permissions->canEditPublishVenue; $this->item = $menuitem; $this->pagetitle = $pagetitle; $this->task = $task; $this->pageclass_sfx = htmlspecialchars($pageclass_sfx); } parent::display($tpl); }
/** * Changes old Eventlist data to fit the JEM standards * @param string $tablename The name of the table * @param array $data The data to work with * @param int $j15 Import from Joomla! 1.5 * @return array The changed data * * @toto: potentially dangerous references to "foreign" objects: * user id: creator/editor, attendee (!), group member (!) * contact id: contact for events * access id: view access level for events, categories */ public function transformEventlistData($tablename, &$data, $j15) { // attachments - MUST be transformed after potential objects are stored! if (strcasecmp($tablename, 'attachments') == 0) { $default_view_level = JFactory::getConfig()->get('access', 1); $valid_view_levels = $this->_getViewLevels(); $current_user_id = JemFactory::getUser()->get('id'); $valid_user_ids = $this->_getUserIds(); foreach ($data as $row) { // Set view access level to e.g. event's view level or default view level if (isset($row->access) && $j15) { // on Joomla! 1.5 levels are 0 (public), 1 (registered), 2 (special) // now we have (normally) 1 (public), 2 (registered), 3 (special), ... // (hopefully admin hadn't changed this default levels, but we have no other chance) ++$row->access; } if (empty($row->access) || !in_array($row->access, $valid_view_levels)) { $row->access = $this->_getObjectViewLevel($row->object, $default_view_level); } // Check user id if (empty($row->added_by) || !in_array($row->added_by, $valid_user_ids)) { $row->added_by = $current_user_id; } } } // categories elseif (strcasecmp($tablename, 'categories') == 0) { $default_view_level = JFactory::getConfig()->get('access', 1); $valid_view_levels = $this->_getViewLevels(); $current_user_id = JemFactory::getUser()->get('id'); $valid_user_ids = $this->_getUserIds(); foreach ($data as $row) { // JEM now has a root category, so we shift IDs by 1 $row->id++; $row->parent_id++; // Description field has been renamed if ($row->catdescription) { $row->description = $row->catdescription; } // Ensure category has a valid view access level if (isset($row->access) && $j15) { // move from old (0, 1, 2) to (1, 2, 3) ++$row->access; } if (empty($row->access) || !in_array($row->access, $valid_view_levels)) { $row->access = $default_view_level; } // Check user id if (empty($row->created_user_id) || !in_array($row->created_user_id, $valid_user_ids)) { $row->created_user_id = $current_user_id; } } } // cats_event_relations elseif (strcasecmp($tablename, 'cats_event_relations') == 0) { $dataNew = array(); foreach ($data as $row) { // Category-event relations is now stored in seperate table if (isset($row->catsid)) { // events table of EL 1.0.2 $rowNew = new stdClass(); $rowNew->catid = $row->catsid; $rowNew->itemid = $row->id; $rowNew->ordering = 0; // JEM now has a root category, so we shift IDs by 1 $rowNew->catid++; $dataNew[] = $rowNew; } else { // cats_event_relations table of EL 1.1 $row->catid++; $dataNew[] = $row; } } return $dataNew; } // events elseif (strcasecmp($tablename, 'events') == 0) { $default_view_level = JFactory::getConfig()->get('access', 1); $valid_view_levels = $this->_getViewLevels(); $cat_levels = $this->_getCategoryViewLevels(); $current_user_id = JemFactory::getUser()->get('id'); $valid_user_ids = $this->_getUserIds(); foreach ($data as $row) { // No start date is now represented by a NULL value if ($row->dates == '0000-00-00') { $row->dates = null; } // Recurrence fields have changed meaning between EL 1.0.2 and EL 1.1 // Also on EL 1.0.2 we don't know first event of recurrence set // so we MUST ignore archived events (there will be only one published event of each set) if (!isset($row->recurrence_limit_date)) { // EL 1.0.x if ($row->published == -1) { // archived: clear recurrence parameters $row->recurrence_number = 0; $row->recurrence_type = 0; } elseif ($row->recurrence_counter != '0000-00-00') { $row->recurrence_limit_date = $row->recurrence_counter; } $row->recurrence_counter = 0; } else { // EL 1.1 - nothings to adapt } // Published/state values have changed meaning if ($row->published == -1) { $row->published = 2; // archived } // Check if author_ip contains crap if (strpos($row->author_ip, 'COM_EVENTLIST') === 0) { $row->author_ip = ""; } // Description field has been renamed if ($row->datdescription) { $row->introtext = $row->datdescription; } // Set view access level to category's view level or default view level if (isset($row->access) && $j15) { // move from old (0, 1, 2) to (1, 2, 3) ++$row->access; } if (empty($row->access) || !in_array($row->access, $valid_view_levels)) { if (isset($row->catsid)) { $row->access = (empty($row->catsid) || !array_key_exists($row->catsid, $cat_levels)) ? $default_view_level : $cat_levels[$row->catsid]; } else { // no catsid field, so we should have cats_event_relations table // try to find unique level $row->access = $this->_getEventViewLevelFromCats($row->id, $default_view_level, $j15); if (!in_array($row->access, $valid_view_levels)) { $row->access = $default_view_level; } } } // Check user id if (empty($row->created_by) || !in_array($row->created_by, $valid_user_ids)) { $row->created_by = $current_user_id; } } } // groupmembers elseif (strcasecmp($tablename, 'groupmembers') == 0) { $valid_user_ids = $this->_getUserIds(); foreach ($data as $k => $row) { // Check user id - REMOVE unknown users if (empty($row->member) || !in_array($row->member, $valid_user_ids)) { //$row->member = 0; unset($data[$k]); continue; } } } // groups elseif (strcasecmp($tablename, 'groups') == 0) { } // register elseif (strcasecmp($tablename, 'register') == 0) { $valid_user_ids = $this->_getUserIds(); foreach ($data as $k => $row) { // Check if uip contains crap if (strpos($row->uip, 'COM_EVENTLIST') === 0) { $row->uip = ''; } // Check user id - REMOVE unknown users - !!! if (empty($row->uid) || !in_array($row->uid, $valid_user_ids)) { //$row->uid = 0; unset($data[$k]); continue; } } } // venues elseif (strcasecmp($tablename, 'venues') == 0) { $current_user_id = JemFactory::getUser()->get('id'); $valid_user_ids = $this->_getUserIds(); foreach ($data as $row) { // Column name has changed $row->postalCode = $row->plz; // Check if author_ip contains crap if (strpos($row->author_ip, 'COM_EVENTLIST') === 0) { $row->author_ip = ""; } // Country changes if (strcasecmp($row->country, 'AN') == 0) { $row->country = 'NL'; // Netherlands Antilles to Netherlands } // Check user id if (empty($row->created_by) || !in_array($row->created_by, $valid_user_ids)) { $row->created_by = $current_user_id; } } } return $data; }
/** * Batch move categories to a new category. * * @param integer $value The new category ID. * @param array $pks An array of row IDs. * @param array $contexts An array of item contexts. * * @return boolean True on success. * */ protected function batchMove($value, $pks, $contexts) { $parentId = (int) $value; $table = $this->getTable(); $db = $this->getDbo(); $query = $db->getQuery(true); $user = JemFactory::getUser(); $extension = JFactory::getApplication()->input->get('extension', '', 'word'); // Check that the parent exists. if ($parentId) { if (!$table->load($parentId)) { if ($error = $table->getError()) { // Fatal error $this->setError($error); return false; } else { // Non-fatal error $this->setError(JText::_('JGLOBAL_BATCH_MOVE_PARENT_NOT_FOUND')); $parentId = 0; } } // Check that user has create permission for parent category $canCreate = ($parentId == $table->getRootId()) ? $user->authorise('core.create', $extension) : $user->authorise('core.create', $extension . '.category.' . $parentId); if (!$canCreate) { // Error since user cannot create in parent category $this->setError(JText::_('COM_CATEGORIES_BATCH_CANNOT_CREATE')); return false; } // Check that user has edit permission for every category being // moved // Note that the entire batch operation fails if any category lacks // edit permission foreach ($pks as $pk) { if (!$user->authorise('core.edit', $extension . '.category.' . $pk)) { // Error since user cannot edit this category $this->setError(JText::_('COM_CATEGORIES_BATCH_CANNOT_EDIT')); return false; } } } // We are going to store all the children and just move the category $children = array(); // Parent exists so we let's proceed foreach ($pks as $pk) { // Check that the row actually exists if (!$table->load($pk)) { if ($error = $table->getError()) { // Fatal error $this->setError($error); return false; } else { // Not fatal error $this->setError(JText::sprintf('JGLOBAL_BATCH_MOVE_ROW_NOT_FOUND', $pk)); continue; } } // Set the new location in the tree for the node. $table->setLocation($parentId, 'last-child'); // Check if we are moving to a different parent if ($parentId != $table->parent_id) { // Add the child node ids to the children array. $query->clear(); $query->select('id'); $query->from($db->quoteName('#__categories')); $query->where($db->quoteName('lft') . ' BETWEEN ' . (int) $table->lft . ' AND ' . (int) $table->rgt); $db->setQuery($query); $children = array_merge($children, (array) $db->loadColumn()); } // Store the row. if (!$table->store()) { $this->setError($table->getError()); return false; } // Rebuild the tree path. if (!$table->rebuildPath()) { $this->setError($table->getError()); return false; } } // Process the child rows if (!empty($children)) { // Remove any duplicates and sanitize ids. $children = array_unique($children); JArrayHelper::toInteger($children); // Check for a database error. if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); return false; } } return true; }
/** * Method to get the events * * @access public * @return array */ public static function getList(&$params) { mb_internal_encoding('UTF-8'); $db = JFactory::getDBO(); $user = JemFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); # Retrieve Eventslist model for the data $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true)); # Set params for the model # has to go before the getItems function $model->setState('params', $params); # filter published # 0: unpublished # 1: published # 2: archived # -2: trashed # type: # 0: upcoming (not started) - dates,times > now+offset # 1: unfinished (not ended) - enddates,endtimes > now+offset # 2: archived - no limit, but from now back to the past # 3: running (today) - enddates,endtimes > today+offset AND dates,times < tomorrow+offset # 4: featured - ? (same as upcoming yet) $type = (int)$params->get('type'); $offset_hours = (int)$params->get('offset_hours', 0); $max_title_length = (int)$params->get('cuttitle', '25'); # clean parameter data $catids = JemHelper::getValidIds($params->get('catid')); $venids = JemHelper::getValidIds($params->get('venid')); $eventids = JemHelper::getValidIds($params->get('eventid')); $stateloc = $params->get('stateloc'); $stateloc_mode = $params->get('stateloc_mode', 0); # Open date support $opendates = empty($eventids) ? 0 : 1; // allow open dates if limited to specific events $model->setState('filter.opendates', $opendates); # all upcoming or unfinished events if (($type == 0) || ($type == 1)) { $offset_minutes = $offset_hours * 60; $model->setState('filter.published',1); $model->setState('filter.orderby',array('a.dates ASC','a.times ASC')); $cal_from = "(a.dates IS NULL OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > $offset_minutes) "; $cal_from .= ($type == 1) ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > $offset_minutes)) " : ") "; } # archived events only elseif ($type == 2) { $model->setState('filter.published',2); $model->setState('filter.orderby',array('a.dates DESC','a.times DESC')); $cal_from = ""; } # currently running events only (today + offset is inbetween start and end date of event) elseif ($type == 3) { $offset_days = (int)round($offset_hours / 24); $model->setState('filter.published',1); $model->setState('filter.orderby',array('a.dates ASC','a.times ASC')); $cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= $offset_days) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= $offset_days))"; } # featured elseif ($type == 4) { $offset_minutes = $offset_hours * 60; $model->setState('filter.featured',1); $model->setState('filter.orderby',array('a.dates ASC','a.times ASC')); $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > $offset_minutes) "; $cal_from .= " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > $offset_minutes)) "; } $model->setState('filter.calendar_from',$cal_from); $model->setState('filter.groupby','a.id'); # filter category's if ($catids) { $model->setState('filter.category_id', $catids); $model->setState('filter.category_id.include', true); } # filter venue's if ($venids) { $model->setState('filter.venue_id', $venids); $model->setState('filter.venue_id.include', true); } # filter event id's if ($eventids) { $model->setState('filter.event_id', $eventids); $model->setState('filter.event_id.include', true); } # filter venue's state/province if ($stateloc) { $model->setState('filter.venue_state', $stateloc); $model->setState('filter.venue_state.mode', $stateloc_mode); // 0: exact, 1: partial } # count $count = $params->get('count', '2'); $model->setState('list.limit', $count); if ($params->get('use_modal', 0)) { JHtml::_('behavior.modal', 'a.flyermodal'); } # date/time $dateFormat = $params->get('formatdate', ''); $timeFormat = $params->get('formattime', ''); $addSuffix = empty($timeFormat); // if we use component's default time format we can also add corresponding suffix # Retrieve the available Events $events = $model->getItems(); $color = $params->get('color'); $fallback_color = $params->get('fallbackcolor', '#EEEEEE'); # Loop through the result rows and prepare data $lists = array(); $i = 0; foreach ($events as $row) { # create thumbnails if needed and receive imagedata $dimage = $row->datimage ? JEMImage::flyercreator($row->datimage, 'event') : null; $limage = $row->locimage ? JEMImage::flyercreator($row->locimage, 'venue') : null; ################# ## DEFINE LIST ## ################# $lists[$i] = new stdClass(); # check view access if (in_array($row->access, $levels)) { # We know that user has the privilege to view the event $lists[$i]->link = JRoute::_(JEMHelperRoute::getEventRoute($row->slug)); $lists[$i]->linkText = JText::_('MOD_JEM_TEASER_READMORE'); } else { $lists[$i]->link = JRoute::_('index.php?option=com_users&view=login'); $lists[$i]->linkText = JText::_('MOD_JEM_TEASER_READMORE_REGISTER'); } # cut titel $fulltitle = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8'); if (mb_strlen($fulltitle) > $max_title_length) { $title = mb_substr($fulltitle, 0, $max_title_length) . '...'; } else { $title = $fulltitle; } $lists[$i]->title = $title; $lists[$i]->fulltitle = $fulltitle; $lists[$i]->venue = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8'); $lists[$i]->catname = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1))); $lists[$i]->state = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8'); $lists[$i]->city = htmlspecialchars($row->city, ENT_COMPAT, 'UTF-8'); $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_(JEMHelperRoute::getEventRoute($row->slug)) : ''; $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : ''; # time/date static $formats = array('year' => 'Y', 'month' => 'F', 'day' => 'j', 'weekday' => 'l'); static $defaults = array('year' => ' ', 'month' => '', 'day' => '?', 'weekday' => ''); $lists[$i]->day = modJEMteaserHelper::_format_day($row, $params); $tmpdate = empty($row->dates) ? $defaults : self::_format_date_fields($row->dates, $formats); $lists[$i]->dayname = $tmpdate['weekday']; // keep them for backward compatibility $lists[$i]->daynum = $tmpdate['day']; $lists[$i]->month = $tmpdate['month']; $lists[$i]->year = $tmpdate['year']; $lists[$i]->startdate = $tmpdate; $lists[$i]->enddate = empty($row->enddates) ? $defaults : self::_format_date_fields($row->enddates, $formats); list($lists[$i]->date, $lists[$i]->time) = self::_format_date_time($row, $params->get('datemethod', 1), $dateFormat, $timeFormat, $addSuffix); $lists[$i]->dateinfo = JEMOutput::formatDateTime($row->dates, $row->times, $row->enddates, $row->endtimes, $dateFormat, $timeFormat, $addSuffix); if ($dimage == null) { $lists[$i]->eventimage = JUri::base(true).'/media/system/images/blank.png'; $lists[$i]->eventimageorig = JUri::base(true).'/media/system/images/blank.png'; } else { $lists[$i]->eventimage = JUri::base(true).'/'.$dimage['thumb']; $lists[$i]->eventimageorig = JUri::base(true).'/'.$dimage['original']; } if ($limage == null) { $lists[$i]->venueimage = JUri::base(true).'/media/system/images/blank.png'; $lists[$i]->venueimageorig = JUri::base(true).'/media/system/images/blank.png'; } else { $lists[$i]->venueimage = JUri::base(true).'/'.$limage['thumb']; $lists[$i]->venueimageorig = JUri::base(true).'/'.$limage['original']; } $length = $params->get('descriptionlength'); $length2 = 1; $etc = '...'; $etc2 = JText::_('MOD_JEM_TEASER_NO_DESCRIPTION'); //append <br /> tags on line breaking tags so they can be stripped below $description = preg_replace("'<(hr[^/>]*?/|/(div|h[1-6]|li|p|tr))>'si", "$0<br />", $row->introtext); //strip html tags but leave <br /> tags $description = strip_tags($description, "<br>"); //switch <br /> tags to space character if ($params->get('br') == 0) { $description = str_replace('<br />',' ', $description); } // if (strlen($description) > $length) { $length -= strlen($etc); $description = preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $length+1)); $lists[$i]->eventdescription = substr($description, 0, $length).$etc; } elseif (strlen($description) < $length2) { $length -= strlen($etc2); $description = preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $length+1)); $lists[$i]->eventdescription = substr($description, 0, $length).$etc2; } else { $lists[$i]->eventdescription = $description; } $lists[$i]->readmore = strlen(trim($row->fulltext)); $lists[$i]->colorclass = $color; if (($color == 'category') && !empty($row->categories)) { $colors = array(); foreach ($row->categories as $category) { if (!empty($category->color)) { $colors[$category->color] = $category->color; } } $lists[$i]->color = (count($colors) == 1) ? array_pop($colors) : $fallback_color; } $i++; } // foreach ($events as $row) return $lists; }
/** * Creates the Day View */ function display($tpl = null) { // Initialize variables $app = JFactory::getApplication(); $jemsettings = JemHelper::config(); $settings = JemHelper::globalattribs(); $menu = $app->getMenu(); $menuitem = $menu->getActive(); $document = JFactory::getDocument(); $params = $app->getParams(); $uri = JFactory::getURI(); $jinput = $app->input; $task = $jinput->getCmd('task', ''); $print = $jinput->getBool('print', false); $pathway = $app->getPathWay(); $user = JemFactory::getUser(); $itemid = $jinput->getInt('id', 0) . ':' . $jinput->getInt('Itemid', 0); // Decide which parameters should take priority $useMenuItemParams = ($menuitem && $menuitem->query['option'] == 'com_jem' && $menuitem->query['view'] == 'day' && !isset($menuitem->query['id'])); // Retrieving data $requestVenueId = $jinput->getInt('locid', 0); $requestCategoryId = $jinput->getInt('catid', 0); $requestDate = $jinput->getInt('id', 0); // Load css JemHelper::loadCss('jem'); JemHelper::loadCustomCss(); JemHelper::loadCustomTag(); if ($print) { JemHelper::loadCss('print'); $document->setMetaData('robots', 'noindex, nofollow'); } // get variables $filter_order = $app->getUserStateFromRequest('com_jem.day.'.$itemid.'.filter_order', 'filter_order', 'a.dates', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest('com_jem.day.'.$itemid.'.filter_order_Dir', 'filter_order_Dir', '', 'word'); $filter_type = $app->getUserStateFromRequest('com_jem.day.'.$itemid.'.filter_type', 'filter_type', '', 'int'); $search = $app->getUserStateFromRequest('com_jem.day.'.$itemid.'.filter_search', 'filter_search', '', 'string'); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // Get data from model $rows = $this->get('Items'); $day = $this->get('Day'); $daydate = JemOutput::formatdate($day); $showdaydate = true; // show by default // Are events available? $noevents = (!$rows) ? 1 : 0; // Show page heading specified on menu item or TODAY as heading - idea taken from com_content. if ($useMenuItemParams) { $pagetitle = $params->get('page_title', $menuitem->title); $params->def('page_heading', $pagetitle); $pathway->setItemName(1, $menuitem->title); } else { // TODO: If we can integrate $daydate into page_heading we should set $showdaydate to false. $pagetitle = JText::_('COM_JEM_DEFAULT_PAGE_TITLE_DAY'); $params->set('page_heading', $pagetitle); $pathway->addItem($pagetitle); } $pageclass_sfx = $params->get('pageclass_sfx'); // Add site name to title if param is set if ($app->getCfg('sitename_pagetitles', 0) == 1) { $pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename')); } // Set Page title $document->setTitle($pagetitle); if ($requestVenueId){ $print_link = JRoute::_('index.php?option=com_jem&view=day&tmpl=component&print=1&locid='.$requestVenueId.'&id='.$requestDate); } elseif ($requestCategoryId){ $print_link = JRoute::_('index.php?option=com_jem&view=day&tmpl=component&print=1&catid='.$requestCategoryId.'&id='.$requestDate); } else /*(!$requestCategoryId && !$requestVenueId)*/ { $print_link = JRoute::_('index.php?option=com_jem&view=day&tmpl=component&print=1&id='.$requestDate); } // Check if the user has permission to add things $permissions = new stdClass(); $permissions->canAddEvent = $user->can('add', 'event'); $permissions->canAddVenue = $user->can('add', 'venue'); // add alternate feed link (w/o specific date) $link = 'index.php?option=com_jem&view=day&format=feed'; $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); // search filter $filters = array(); if ($jemsettings->showtitle == 1) { $filters[] = JHtml::_('select.option', '1', JText::_('COM_JEM_TITLE')); } if ($jemsettings->showlocate == 1 && !($requestVenueId)) { $filters[] = JHtml::_('select.option', '2', JText::_('COM_JEM_VENUE')); } if ($jemsettings->showcity == 1 && !($requestVenueId)) { $filters[] = JHtml::_('select.option', '3', JText::_('COM_JEM_CITY')); } if ($jemsettings->showcat == 1 && !($requestCategoryId)) { $filters[] = JHtml::_('select.option', '4', JText::_('COM_JEM_CATEGORY')); } if ($jemsettings->showstate == 1 && !($requestVenueId)) { $filters[] = JHtml::_('select.option', '5', JText::_('COM_JEM_STATE')); } $lists['filter'] = JHtml::_('select.genericlist', $filters, 'filter_type', array('size'=>'1','class'=>'inputbox'), 'value', 'text', $filter_type); $lists['search'] = $search; // Create the pagination object $pagination = $this->get('Pagination'); $this->lists = $lists; $this->rows = $rows; $this->noevents = $noevents; $this->print_link = $print_link; $this->params = $params; $this->dellink = $permissions->canAddEvent; // deprecated $this->pagination = $pagination; $this->action = $uri->toString(); $this->task = $task; $this->jemsettings = $jemsettings; $this->settings = $settings; $this->permissions = $permissions; $this->daydate = $daydate; $this->showdaydate = $showdaydate; // if true daydate will be shown as h2 sub heading $this->pageclass_sfx = htmlspecialchars($pageclass_sfx); // Doesn't really help - each view has less or more specific needs. //$this->prepareDocument(); parent::display($tpl); }
/** * Creates the Simple List View */ function display($tpl = null) { // initialize variables $app = JFactory::getApplication(); $document = JFactory::getDocument(); $jemsettings = JemHelper::config(); $settings = JemHelper::globalattribs(); $menu = $app->getMenu(); $menuitem = $menu->getActive(); $params = $app->getParams(); $uri = JFactory::getURI(); $pathway = $app->getPathWay(); $user = JemFactory::getUser(); // Decide which parameters should take priority $useMenuItemParams = ($menuitem && $menuitem->query['option'] == 'com_jem' && $menuitem->query['view'] == 'search'); // add javascript JHtml::_('behavior.framework'); // Load css JemHelper::loadCss('jem'); JemHelper::loadCustomCss(); JemHelper::loadCustomTag(); // Load Script JHtml::_('script', 'com_jem/search.js', false, true); $filter_continent = $app->getUserStateFromRequest('com_jem.search.filter_continent', 'filter_continent', '', 'string'); $filter_country = $app->getUserStateFromRequest('com_jem.search.filter_country', 'filter_country', '', 'string'); $filter_city = $app->getUserStateFromRequest('com_jem.search.filter_city', 'filter_city', '', 'string'); $filter_date_from = $app->getUserStateFromRequest('com_jem.search.filter_date_from', 'filter_date_from', '', 'string'); $filter_date_to = $app->getUserStateFromRequest('com_jem.search.filter_date_to', 'filter_date_to', '', 'string'); $filter_category = $app->getUserStateFromRequest('com_jem.search.filter_category', 'filter_category', 0, 'int'); $task = $app->input->get('task', ''); // get data from model $rows = $this->get('Data'); // are events available? $noevents = (!$rows) ? 1 : 0; // Check to see which parameters should take priority if ($useMenuItemParams) { // Menu item params take priority $pagetitle = $params->def('page_title', $menuitem ? $menuitem->title : JText::_('COM_JEM_SEARCH')); $pageheading = $params->def('page_heading', $pagetitle); $pathway->setItemName(1, $menuitem->title); } else { $pagetitle = JText::_('COM_JEM_SEARCH'); $pageheading = $pagetitle; $params->set('introtext', ''); // there is no introtext in that case $params->set('showintrotext', 0); $pathway->addItem(1, $pagetitle); } $pageclass_sfx = $params->get('pageclass_sfx'); if ($task == 'archive') { $pathway->addItem(JText::_('COM_JEM_ARCHIVE'), JRoute::_('index.php?option=com_jem&view=search&task=archive')); $pagetitle .= ' - ' . JText::_('COM_JEM_ARCHIVE'); $pageheading .= ' - ' . JText::_('COM_JEM_ARCHIVE'); } $pageclass_sfx = $params->get('pageclass_sfx'); $params->set('page_heading', $pageheading); // Add site name to title if param is set if ($app->getCfg('sitename_pagetitles', 0) == 1) { $pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename')); } // Set Page title $document->setTitle($pagetitle); $document->setMetadata('title' , $pagetitle); // No permissions required/useful on this view $permissions = new stdClass(); // create select lists $lists = $this->_buildSortLists(); if ($lists['filter']) { //$uri->setVar('filter', $app->input->getString('filter', '')); //$filter = $app->getUserStateFromRequest('com_jem.jem.filter', 'filter', '', 'string'); $uri->setVar('filter', $lists['filter']); $uri->setVar('filter_type', $app->input->getString('filter_type', '')); } else { $uri->delVar('filter'); $uri->delVar('filter_type'); } // Cause of group limits we can't use class here to build the categories tree $categories = $this->get('CategoryTree'); $catoptions = array(); $catoptions[] = JHtml::_('select.option', '1', JText::_('COM_JEM_SELECT_CATEGORY')); $catoptions = array_merge($catoptions, JemCategories::getcatselectoptions($categories)); $selectedcats = ($filter_category) ? array($filter_category) : array(); // build selectlists $lists['categories'] = JHtml::_('select.genericlist', $catoptions, 'filter_category', array('size'=>'1', 'class'=>'inputbox'), 'value', 'text', $selectedcats); // Create the pagination object $pagination = $this->get('Pagination'); // date filter $lists['date_from'] = JHtml::_('calendar', $filter_date_from, 'filter_date_from', 'filter_date_from', '%Y-%m-%d', array('class'=>"inputbox")); $lists['date_to'] = JHtml::_('calendar', $filter_date_to, 'filter_date_to', 'filter_date_to', '%Y-%m-%d', array('class'=>"inputbox")); // country filter $continents = array(); $continents[] = JHtml::_('select.option', '', JText::_('COM_JEM_SELECT_CONTINENT')); $continents[] = JHtml::_('select.option', 'AF', JText::_('COM_JEM_AFRICA')); $continents[] = JHtml::_('select.option', 'AS', JText::_('COM_JEM_ASIA')); $continents[] = JHtml::_('select.option', 'EU', JText::_('COM_JEM_EUROPE')); $continents[] = JHtml::_('select.option', 'NA', JText::_('COM_JEM_NORTH_AMERICA')); $continents[] = JHtml::_('select.option', 'SA', JText::_('COM_JEM_SOUTH_AMERICA')); $continents[] = JHtml::_('select.option', 'OC', JText::_('COM_JEM_OCEANIA')); $continents[] = JHtml::_('select.option', 'AN', JText::_('COM_JEM_ANTARCTICA')); $lists['continents'] = JHtml::_('select.genericlist', $continents, 'filter_continent', array('class'=>'inputbox'), 'value', 'text', $filter_continent); unset($continents); // country filter $countries = array(); $countries[] = JHtml::_('select.option', '', JText::_('COM_JEM_SELECT_COUNTRY')); $countries = array_merge($countries, $this->get('CountryOptions')); $lists['countries'] = JHtml::_('select.genericlist', $countries, 'filter_country', array('class'=>'inputbox'), 'value', 'text', $filter_country); unset($countries); // city filter if ($filter_country) { $cities = array(); $cities[] = JHtml::_('select.option', '', JText::_('COM_JEM_SELECT_CITY')); $cities = array_merge($cities, $this->get('CityOptions')); $lists['cities'] = JHtml::_('select.genericlist', $cities, 'filter_city', array('class'=>'inputbox'), 'value', 'text', $filter_city); unset($cities); } $this->lists = $lists; $this->action = $uri->toString(); $this->rows = $rows; $this->task = $task; $this->noevents = $noevents; $this->params = $params; $this->pagination = $pagination; $this->jemsettings = $jemsettings; $this->settings = $settings; $this->permissions = $permissions; $this->pagetitle = $pagetitle; $this->filter_continent = $filter_continent; $this->filter_country = $filter_country; $this->document = $document; $this->pageclass_sfx = htmlspecialchars($pageclass_sfx); parent::display($tpl); }
/** * Editvenue-View */ public function display($tpl = null) { // Initialise variables. $jemsettings = JemHelper::config(); $settings = JemHelper::globalattribs(); $app = JFactory::getApplication(); $user = JemFactory::getUser(); $document = JFactory::getDocument(); $model = $this->getModel(); $menu = $app->getMenu(); $menuitem = $menu->getActive(); $pathway = $app->getPathway(); $url = JUri::root(); $language = JFactory::getLanguage(); $language = $language->getTag(); $language = substr($language, 0,2); // Get model data. $this->state = $this->get('State'); $this->item = $this->get('Item'); $this->params = $this->state->get('params'); // Create a shortcut for $item and params. $item = $this->item; $params = $this->params; $this->form = $this->get('Form'); $this->return_page = $this->get('ReturnPage'); // check for data error if (empty($item)) { $app->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error'); return false; } // check for guest if (!$user || $user->id == 0) { $app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error'); return false; } if (empty($item->id)) { // Check if the user has access to the form $authorised = $user->can('add', 'venue'); } else { // Check if user can edit $authorised = $user->can('edit', 'venue', $item->id, $item->created_by); } if ($authorised !== true) { $app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error'); return false; } // Decide which parameters should take priority $useMenuItemParams = ($menuitem && $menuitem->query['option'] == 'com_jem' && $menuitem->query['view'] == 'editvenue' && 0 == $item->id); // menu item is always for new venues $title = ($item->id == 0) ? JText::_('COM_JEM_EDITVENUE_VENUE_ADD') : JText::sprintf('COM_JEM_EDITVENUE_VENUE_EDIT', $item->venue); if ($useMenuItemParams) { $pagetitle = $menuitem->title ? $menuitem->title : $title; $params->def('page_title', $pagetitle); $params->def('page_heading', $pagetitle); $pathway->setItemName(1, $pagetitle); // Load layout from menu item if one is set else from venue if there is one set if (isset($menuitem->query['layout'])) { $this->setLayout($menuitem->query['layout']); } elseif ($layout = $item->params->get('venue_layout')) { $this->setLayout($layout); } $item->params->merge($params); } else { $pagetitle = $title; $params->set('page_title', $pagetitle); $params->set('page_heading', $pagetitle); $params->set('show_page_heading', 1); // ensure page heading is shown $params->set('introtext', ''); // there is no introtext in that case $params->set('showintrotext', 0); $pathway->addItem($pagetitle, ''); // link not required here so '' is ok // Check for alternative layouts (since we are not in an edit-venue menu item) // Load layout from venue if one is set if ($layout = $item->params->get('venue_layout')) { $this->setLayout($layout); } $temp = clone($params); $temp->merge($item->params); $item->params = $temp; } $publisher = $user->can('publish', 'venue', $item->id, $item->created_by); if (!empty($this->item) && isset($this->item->id)) { // $this->item->images = json_decode($this->item->images); // $this->item->urls = json_decode($this->item->urls); $tmp = new stdClass(); // $tmp->images = $this->item->images; // $tmp->urls = $this->item->urls; $this->form->bind($tmp); } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } JHtml::_('behavior.framework'); JHtml::_('behavior.formvalidation'); JHtml::_('behavior.tooltip'); $access2 = JemHelper::getAccesslevelOptions(true); $this->access = $access2; // Load css JemHelper::loadCss('geostyle'); JemHelper::loadCss('jem'); JemHelper::loadCustomCss(); JemHelper::loadCustomTag(); // Load script JHtml::_('script', 'com_jem/attachments.js', false, true); JHtml::_('script', 'com_jem/other.js', false, true); $document->addScript('http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language='.$language); // Noconflict $document->addCustomTag( '<script type="text/javascript">jQuery.noConflict();</script>' ); // JQuery scripts $document->addScript('http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'); JHtml::_('script', 'com_jem/jquery.geocomplete.js', false, true); // No permissions required/useful on this view $permissions = new stdClass(); $this->pageclass_sfx = htmlspecialchars($item->params->get('pageclass_sfx')); $this->jemsettings = $jemsettings; $this->settings = $settings; $this->permissions = $permissions; $this->limage = JemImage::flyercreator($this->item->locimage, 'venue'); $this->infoimage = JHtml::_('image', 'com_jem/icon-16-hint.png', JText::_('COM_JEM_NOTES'), NULL, true); $this->user = $user; if (!$publisher) { $this->form->setFieldAttribute('published', 'default', 0); $this->form->setFieldAttribute('published', 'readonly', 'true'); } $this->_prepareDocument(); parent::display($tpl); }
/** * Creates the edit button * * @param int $Itemid * @param int $id * @param array $params * @param int $allowedtoedit * @param string $view * * Views: * Event, Venue */ static function editbutton($item, $params, $attribs, $allowedtoedit, $view) { if ($allowedtoedit) { $app = JFactory::getApplication(); if ($app->input->get('print','','int')) { return; } // Ignore if the state is negative (trashed). if ($item->published < 0) { return; } // Initialise variables. $user = JemFactory::getUser(); $userId = $user->get('id'); $uri = JFactory::getURI(); $settings = JemHelper::globalattribs(); JHtml::_('behavior.tooltip'); // On Joomla Edit icon is always used regardless if "Show icons" is set to Yes or No. $showIcon = 1; //$settings->get('global_show_icons', 1); switch ($view) { case 'editevent': if (property_exists($item, 'checked_out') && property_exists($item, 'checked_out_time') && $item->checked_out > 0 && $item->checked_out != $userId) { $checkoutUser = JFactory::getUser($item->checked_out); $button = JHtml::_('image', 'system/checked_out.png', NULL, NULL, true); $date = JHtml::_('date', $item->checked_out_time); return '<span '.JEMOutput::tooltip(JText::_('JLIB_HTML_CHECKED_OUT'), htmlspecialchars(JText::sprintf('COM_JEM_GLOBAL_CHECKED_OUT_BY', $checkoutUser->name).' <br /> '.$date, ENT_COMPAT, 'UTF-8')).'>'.$button.'</span>'; } if ($showIcon) { $image = JHtml::_('image', 'com_jem/calendar_edit.png', JText::_('COM_JEM_EDIT_EVENT'), NULL, true); } else { $image = JText::_('COM_JEM_EDIT_EVENT'); } $id = $item->did; $overlib = JText::_('COM_JEM_EDIT_EVENT_DESC'); $text = JText::_('COM_JEM_EDIT_EVENT'); $url = 'index.php?option=com_jem&task=event.edit&a_id='.$id.'&return='.base64_encode(urlencode($uri)); break; case 'editvenue': if (property_exists($item, 'vChecked_out') && property_exists($item, 'vChecked_out_time') && $item->vChecked_out > 0 && $item->vChecked_out != $userId) { $checkoutUser = JFactory::getUser($item->vChecked_out); $button = JHtml::_('image', 'system/checked_out.png', NULL, NULL, true); $date = JHtml::_('date', $item->vChecked_out_time); return '<span '.JEMOutput::tooltip(JText::_('JLIB_HTML_CHECKED_OUT'), htmlspecialchars(JText::sprintf('COM_JEM_GLOBAL_CHECKED_OUT_BY', $checkoutUser->name).' <br /> '.$date, ENT_COMPAT, 'UTF-8')).'>'.$button.'</span>'; } if ($showIcon) { $image = JHtml::_('image', 'com_jem/calendar_edit.png', JText::_('COM_JEM_EDIT_VENUE'), NULL, true); } else { $image = JText::_('COM_JEM_EDIT_VENUE'); } $id = $item->locid; $overlib = JText::_('COM_JEM_EDIT_VENUE_DESC'); $text = JText::_('COM_JEM_EDIT_VENUE'); $url = 'index.php?option=com_jem&task=venue.edit&a_id='.$id.'&return='.base64_encode(urlencode($uri)); break; case 'venue': if (property_exists($item, 'vChecked_out') && property_exists($item, 'vChecked_out_time') && $item->vChecked_out > 0 && $item->vChecked_out != $userId) { $checkoutUser = JFactory::getUser($item->vChecked_out); $button = JHtml::_('image', 'system/checked_out.png', NULL, NULL, true); $date = JHtml::_('date', $item->vChecked_out_time); return '<span '.JEMOutput::tooltip(JText::_('JLIB_HTML_CHECKED_OUT'), htmlspecialchars(JText::sprintf('COM_JEM_GLOBAL_CHECKED_OUT_BY', $checkoutUser->name).' <br /> '.$date, ENT_COMPAT, 'UTF-8')).'>'.$button.'</span>'; } if ($showIcon) { $image = JHtml::_('image', 'com_jem/calendar_edit.png', JText::_('COM_JEM_EDIT_VENUE'), NULL, true); } else { $image = JText::_('COM_JEM_EDIT_VENUE'); } $id = $item->id; $overlib = JText::_('COM_JEM_EDIT_VENUE_DESC'); $text = JText::_('COM_JEM_EDIT_VENUE'); $url = 'index.php?option=com_jem&task=venue.edit&a_id='.$id.'&return='.base64_encode(urlencode($uri)); break; } if (!$url) { return; // we need at least url to generate useful output } $output = JHtml::_('link', JRoute::_($url), $image, JEMOutput::tooltip($text, $overlib)); return $output; } }
/** * Retrieve Categories * * Due to multi-cat this function is needed * filter-index (4) is pointing to the cats */ function getCategories($id) { $user = JemFactory::getUser(); $userid = (int) $user->get('id'); $levels = $user->getAuthorisedViewLevels(); $app = JFactory::getApplication(); $params = $app->getParams(); $catswitch = $params->get('categoryswitch', '0'); $settings = JemHelper::globalattribs(); // Query $db = JFactory::getDBO(); $query = $db->getQuery(true); $case_when_c = ' CASE WHEN '; $case_when_c .= $query->charLength('c.alias'); $case_when_c .= ' THEN '; $id_c = $query->castAsChar('c.id'); $case_when_c .= $query->concatenate(array($id_c, 'c.alias'), ':'); $case_when_c .= ' ELSE '; $case_when_c .= $id_c.' END as catslug'; $query->select(array('DISTINCT c.id','c.catname','c.access','c.checked_out AS cchecked_out','c.color',$case_when_c)); $query->from('#__jem_categories as c'); $query->join('LEFT', '#__jem_cats_event_relations AS rel ON rel.catid = c.id'); $query->select(array('a.id AS multi')); $query->join('LEFT','#__jem_events AS a ON a.id = rel.itemid'); if ($id != 'all'){ $query->where('rel.itemid ='.(int)$id); } $query->where('c.published = 1'); ################### ## FILTER-ACCESS ## ################### # Filter by access level. ################################### ## FILTER - MAINTAINER/JEM GROUP ## ################################### # as maintainter someone who is registered can see a category that has special rights # let's see if the user has access to this category. // $query3 = $db->getQuery(true); // $query3 = 'SELECT gr.id' // . ' FROM #__jem_groups AS gr' // . ' LEFT JOIN #__jem_groupmembers AS g ON g.group_id = gr.id' // . ' WHERE g.member = ' . (int) $user->get('id') // // . ' AND ' .$db->quoteName('gr.addevent') . ' = 1 ' // . ' AND g.member NOT LIKE 0'; // $db->setQuery($query3); // $groupnumber = $db->loadColumn(); // $jemgroups = implode(',',$groupnumber); // JEM groups doesn't overrule view access levels! // if ($jemgroups) { // $query->where('(c.access IN ('.$groups.') OR c.groupid IN ('.$jemgroups.'))'); // } else { $query->where('(c.access IN ('.implode(',', $levels).'))'); // } ####################### ## FILTER - CATEGORY ## ####################### # set filter for top_category $top_cat = $this->getState('filter.category_top'); if ($top_cat) { $query->where($top_cat); } # Filter by a single or group of categories. $categoryId = $this->getState('filter.category_id'); if (is_numeric($categoryId)) { $type = $this->getState('filter.category_id.include', true) ? '= ' : '<> '; $query->where('c.id '.$type.(int) $categoryId); } elseif (is_array($categoryId) && count($categoryId)) { JArrayHelper::toInteger($categoryId); $categoryId = implode(',', $categoryId); $type = $this->getState('filter.category_id.include', true) ? 'IN' : 'NOT IN'; $query->where('c.id '.$type.' ('.$categoryId.')'); } # filter set by day-view $requestCategoryId = $this->getState('filter.req_catid'); if ($requestCategoryId) { $query->where('c.id = '.$db->quote($requestCategoryId)); } ################### ## FILTER-SEARCH ## ################### # define variables $filter = $this->getState('filter.filter_type'); $search = $this->getState('filter.filter_search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('c.id = '.(int) substr($search, 3)); } else { $search = $db->Quote('%'.$db->escape($search, true).'%', false); if ($search && $settings->get('global_show_filter')) { if ($filter == 4) { $query->where('c.catname LIKE '.$search); } } } } $db->setQuery($query); if ($id == 'all') { $cats = $db->loadColumn(0); $cats = array_unique($cats); } else { $cats = $db->loadObjectList(); } return $cats; }
public function display($tpl = null) { $app = JFactory::getApplication(); if($this->getLayout() == 'print') { $this->_displayprint($tpl); return; } //initialise variables $document = JFactory::getDocument(); $user = JemFactory::getUser(); $settings = JEMHelper::globalattribs(); $params = $app->getParams(); $menu = $app->getMenu(); $menuitem = $menu->getActive(); $uri = JFactory::getURI(); //redirect if not logged in if (!$user->get('id')) { $app->enqueueMessage(JText::_('COM_JEM_NEED_LOGGED_IN'), 'error'); return false; } // Load css JemHelper::loadCss('jem'); JemHelper::loadCustomTag(); //get vars $filter_order = $app->getUserStateFromRequest('com_jem.attendees.filter_order', 'filter_order', 'u.username', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest('com_jem.attendees.filter_order_Dir', 'filter_order_Dir', '', 'word'); $filter_waiting = $app->getUserStateFromRequest('com_jem.attendees.waiting', 'filter_waiting', 0, 'int'); $filter = $app->getUserStateFromRequest('com_jem.attendees.filter', 'filter', '', 'int'); $search = $app->getUserStateFromRequest('com_jem.attendees.filter_search', 'filter_search', '', 'string'); // Get data from the model $rows = $this->get('Data'); $pagination = $this->get('Pagination'); $event = $this->get('Event'); // Merge params. // Because this view is not useable for menu item we always overwrite $params. $pagetitle = JText::_('COM_JEM_MYEVENT_MANAGEATTENDEES') . ' - ' . $event->title; $params->set('page_heading', JText::_('COM_JEM_MYEVENT_MANAGEATTENDEES')); // event title is shown separate //$params->set('show_page_heading', 1); // always show? $params->set('introtext', ''); // there can't be an introtext $params->set('showintrotext', 0); $pageclass_sfx = $params->get('pageclass_sfx'); // Add site name to title if param is set if ($app->getCfg('sitename_pagetitles', 0) == 1) { $pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename')); } $document->setTitle($pagetitle); $pathway = $app->getPathWay(); if($menuitem) { $pathway->setItemName(1, $menuitem->title); } $pathway->addItem('Att:'.$event->title); // Emailaddress $enableemailaddress = $params->get('enableemailaddress', 0); $print_link = 'index.php?option=com_jem&view=attendees&layout=print&task=print&tmpl=component&id='.$event->id; $backlink = 'attendees'; //build filter selectlist $filters = array(); if ($settings->get('global_regname', '1')) { $filters[] = JHtml::_('select.option', '1', JText::_('COM_JEM_NAME')); } else { $filters[] = JHtml::_('select.option', '2', JText::_('COM_JEM_USERNAME')); } $lists['filter'] = JHtml::_('select.genericlist', $filters, 'filter', array('size'=>'1','class'=>'inputbox'), 'value', 'text', $filter); // search filter $lists['search'] = $search; // waiting list status $options = array(JHtml::_('select.option', 0, JText::_('COM_JEM_ATT_FILTER_ALL')), JHtml::_('select.option', 1, JText::_('COM_JEM_ATT_FILTER_ATTENDING')), JHtml::_('select.option', 2, JText::_('COM_JEM_ATT_FILTER_WAITING'))) ; $lists['waiting'] = JHtml::_('select.genericlist', $options, 'filter_waiting', array('class'=>'inputbox','onChange'=>'this.form.submit();'), 'value', 'text', $filter_waiting); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; //assign to template $this->params = $params; $this->lists = $lists; $this->enableemailaddress = $enableemailaddress; $this->rows = $rows; $this->pagination = $pagination; $this->event = $event; $this->pagetitle = $pagetitle; $this->backlink = $backlink; $this->print_link = $print_link; $this->item = $menuitem; $this->action = $uri->toString(); $this->pageclass_sfx = htmlspecialchars($pageclass_sfx); $this->settings = $settings; parent::display($tpl); }
/** * Method to get the field options. * * @return array The field option objects. */ protected function getOptions() { // Initialise variables. $options = array(); $name = (string) $this->element['name']; // Let's get the id for the current item, either category or content item. $jinput = JFactory::getApplication()->input; // For categories the old category is the category id 0 for new category. if ($this->element['parent']) { $oldCat = $jinput->get('id',0); $oldParent = $this->form->getValue($name); } else // For items the old category is the category they are in when opened or 0 if new. { $thisItem = $jinput->get('id',0); $oldCat = $this->form->getValue($name); } $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('a.id AS value, a.title AS text, a.level'); $query->from('#__categories AS a'); $query->join('LEFT', $db->quoteName('#__categories').' AS b ON a.lft > b.lft AND a.rgt < b.rgt'); // Filter by the type if ($extension = $this->form->getValue('extension')) { $query->where('(a.extension = '.$db->quote($extension).' OR a.parent_id = 0)'); } if ($this->element['parent']) { // Prevent parenting to children of this item. if ($id = $this->form->getValue('id')) { $query->join('LEFT', $db->quoteName('#__categories').' AS p ON p.id = '.(int) $id); $query->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)'); $rowQuery = $db->getQuery(true); $rowQuery->select('a.id AS value, a.title AS text, a.level, a.parent_id'); $rowQuery->from('#__categories AS a'); $rowQuery->where('a.id = ' . (int) $id); $db->setQuery($rowQuery); $row = $db->loadObject(); } } $query->where('a.published IN (0,1)'); $query->group('a.id, a.title, a.level, a.lft, a.rgt, a.extension, a.parent_id'); $query->order('a.lft ASC'); // Get the options. $db->setQuery($query); $options = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } // Pad the option text with spaces using depth level as a multiplier. for ($i = 0, $n = count($options); $i < $n; $i++) { // Translate ROOT if ($options[$i]->level == 0) { $options[$i]->text = JText::_('JGLOBAL_ROOT_PARENT'); } $options[$i]->text = str_repeat('- ', $options[$i]->level).$options[$i]->text; } // Initialise variables. // Get the current user object. $user = JemFactory::getUser(); // For new items we want a list of categories you are allowed to create in. if ($oldCat == 0) { foreach ($options as $i => $option) { // To take save or create in a category you need to have create rights for that category // unless the item is already in that category. // Unset the option if the user isn't authorised for it. In this field assets are always categories. if ($user->authorise('core.create', $extension . '.category.' . $option->value) != true ) { unset($options[$i]); } } } // If you have an existing category id things are more complex. else { //$categoryOld = $this->form->getValue($name); foreach ($options as $i => $option) { // If you are only allowed to edit in this category but not edit.state, you should not get any // option to change the category parent for a category or the category for a content item, // but you should be able to save in that category. if ($user->authorise('core.edit.state', $extension . '.category.' . $oldCat) != true) { if ($option->value != $oldCat) {//echo 'y'; unset($options[$i]); } } // However, if you can edit.state you can also move this to another category for which you have // create permission and you should also still be able to save in the current category. elseif (($user->authorise('core.create', $extension . '.category.' . $option->value) != true) && $option->value != $oldCat) {//echo 'x'; unset($options[$i]); } } } if (isset($row) && !isset($options[0])) { if ($row->parent_id == '1') { $parent = new stdClass(); $parent->text = JText::_('JGLOBAL_ROOT_PARENT'); array_unshift($options, $parent); } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Overloaded JTable::store to set created/modified and user id. * * @param boolean $updateNulls True to update fields even if they are null. * @return boolean True on success. */ public function store($updateNulls = false) { $date = JFactory::getDate(); $user = JemFactory::getUser(); if ($this->id){ // Existing category $this->modified_time = $date->toSql(); $this->modified_user_id = $user->get('id'); } else { // New category $this->created_time = $date->toSql(); $this->created_user_id = $user->get('id'); } // Verify that the alias is unique $table = JTable::getInstance('Category', 'JEMTable', array('dbo' => $this->getDbo())); if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id)) && ($table->id != $this->id || $this->id == 0)) { $this->setError(JText::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS')); return false; } return parent::store($updateNulls); }
/** * Display the view */ function display($cachable = false, $urlparams = false) { $document = JFactory::getDocument(); $user = JemFactory::getUser(); // Set the default view name and format from the Request. $jinput = JFactory::getApplication()->input; $id = $jinput->getInt('a_id', 0); $viewName = $jinput->getCmd('view', 'eventslist'); $viewFormat = $document->getType(); $layoutName = $jinput->getCmd('layout', 'edit'); // Check for edit form. if ($viewName == 'editevent' && !$this->checkEditId('com_jem.edit.event', $id)) { // Somehow the person just went to the form - we don't allow that. return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); } $view = $this->getView($viewName, $viewFormat); if ($view) { // Do any specific processing by view. switch ($viewName) { case 'attendees': case 'calendar': case 'categories': case 'categoriesdetailed': case 'category': case 'day': case 'editevent': case 'editvenue': case 'event': case 'eventslist': case 'myattendances': case 'myevents': case 'myvenues': case 'search': case 'venue': case 'venues': case 'weekcal': $model = $this->getModel($viewName); break; default: $model = $this->getModel('eventslist'); break; } // Push the model into the view if ($viewName == 'venue') { $model1 = $this->getModel('Venue'); $model2 = $this->getModel('VenueCal'); $view->setModel($model1, true); $view->setModel($model2); } elseif($viewName == 'category') { $model1 = $this->getModel('Category'); $model2 = $this->getModel('CategoryCal'); $view->setModel($model1, true); $view->setModel($model2); } else { $view->setModel($model, true); } $view->setLayout($layoutName); // Push document object into the view. $view->document = $document; $view->display(); } }