/** * logic to get the categories * * @return void */ public function getCategories() { $user = JFactory::getUser(); $jemsettings = JEMHelper::config(); $userid = (int) $user->get('id'); $superuser = JEMUser::superuser(); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select(array('c.*')); $query->from($db->quoteName('#__jem_categories') . ' AS c'); $query->where(array('c.published = 1 ')); $query->order(array('c.parent_id', 'c.ordering')); $db->setQuery($query); $mitems = $db->loadObjectList(); # Check for a database error. if ($db->getErrorNum()) { JError::raiseNotice(500, $db->getErrorMsg()); } if (!$mitems) { $mitems = array(); $children = array(); $parentid = $mitems; } else { $mitems_temp = $mitems; $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; } $parentid = intval($mitems[0]->parent_id); } # get list of the items $list = JemCategories::treerecurse($parentid, '', array(), $children, 9999, 0, 0); return $list; }
static function statuslabel($published = false) { # @todo check function $user = JFactory::getUser(); $app = JFactory::getApplication(); $userId = $user->get('id'); $admin = JEMUser::superuser(); $status = ''; if ($published != 1 && $published != 2 && $admin) { # determine the type and set variables switch ($published) { case '1': $status = 'JPUBLISHED'; break; case '0': $status = 'JUNPUBLISHED'; break; case '2': $status = 'JARCHIVED'; break; case '-2': $status = 'JTRASHED'; break; } return '<span class="label">' . JText::_($status) . '</span>'; } }
protected function getOptions() { // Initialise variables. $options = array(); $published = $this->element['published'] ? $this->element['published'] : array(0, 1); $name = (string) $this->element['name']; $action = (string) $this->element['action']; $frontedit = $this->element['frontedit']; $jinput = JFactory::getApplication()->input; $db = JFactory::getDbo(); $a_id = $jinput->get('a_id', null); // retrieve data if ($frontedit) { $user = JFactory::getUser(); $jemsettings = JEMHelper::config(); $userid = (int) $user->get('id'); $superuser = JEMUser::superuser(); $levels = $user->getAuthorisedViewLevels(); $settings = JemHelper::globalattribs(); $guestcat = $settings->get('guest_category', '0'); $jinput = JFactory::getApplication()->input; $valguest = JEMUser::validate_guest(); $name = (string) $this->element['name']; $db = JFactory::getDbo(); $auth_joomlagr = $user->getAuthorisedGroups(); $oldCat = 0; $query = $db->getQuery(true)->select('a.id AS value, a.catname AS text, a.level, a.published')->from('#__jem_categories AS a')->join('LEFT', $db->quoteName('#__jem_categories') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt'); if (is_numeric($published)) { $query->where('a.published = ' . (int) $published); } elseif (is_array($published)) { JArrayHelper::toInteger($published); $query->where('a.published IN (' . implode(',', $published) . ')'); } // specific code if (!$valguest) { $validated = false; if ($superuser) { // no need to restrict to category's $validated = true; } if (!$validated) { // in this case it's going to be difficult // catch the groupnumber of the user+add rights $query2 = $db->getQuery(true); $query2->select(array('gr.id')); $query2->from($db->quoteName('#__jem_groups') . ' AS gr'); $query2->join('LEFT', '#__jem_groupmembers AS g ON g.group_id = gr.id'); $query2->where(array('g.member = ' . (int) $user->get('id'), $db->quoteName('gr.addevent') . ' =1', 'g.member NOT LIKE 0')); $db->setQuery($query2); $groupnumber = $db->loadColumn(); // is the user member of a group with edit rights? if ($groupnumber) { // restrict submission into maintained categories only $query->where(array('a.groupid IN (' . implode(',', $groupnumber) . ')')); } else { return false; } } } else { // $specified guest category $query->where(array('a.id = ' . $guestcat)); } $query->group('a.id, a.catname, a.level, a.lft, a.rgt, a.parent_id, a.published')->order('a.lft ASC'); $db->setQuery($query); } try { $options = $db->loadObjectList(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage); } // Pad the option text with spaces using depth level as a multiplier. for ($i = 0, $n = count($options); $i < $n; $i++) { // remove root if ($this->element['removeroot'] == true) { if ($options[$i]->level == 0) { unset($options[$i]); continue; } $options[$i]->level = $options[$i]->level - 1; } if ($options[$i]->published == 1) { $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text; } else { $options[$i]->text = str_repeat('- ', $options[$i]->level) . '[' . $options[$i]->text . ']'; } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Creates the Simple List View */ function display($tpl = null) { // initialize variables $state = $this->get('State'); $document = JFactory::getDocument(); $app = JFactory::getApplication(); $jinput = $app->input; $jemsettings = JemHelper::config(); $settings = JemHelper::globalattribs(); $menu = $app->getMenu(); $menuitem = $menu->getActive(); $params = $state->params; $uri = JFactory::getURI(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $itemid = $jinput->getInt('id', 0) . ':' . $jinput->getInt('Itemid', 0); $print = $jinput->getBool('print'); $admin = JEMUser::superuser(); $task = $jinput->getCmd('task'); $template = $app->getTemplate(); // Load css JemHelper::loadCss('jem'); JemHelper::loadCustomCss(); JemHelper::loadCustomTag(); if ($print) { JemHelper::loadCss('print'); $document->setMetaData('robots', 'noindex, nofollow'); } // userstate variables $filter_order = $app->getUserStateFromRequest('com_jem.eventslist.' . $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.eventslist.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', $filter_order_DirDefault, 'word'); $filter_type = $app->getUserStateFromRequest('com_jem.eventslist.' . $itemid . '.filter_type', 'filter_type', '', 'int'); $search = $app->getUserStateFromRequest('com_jem.eventslist.' . $itemid . '.filter_search', 'filter_search', '', 'string'); $search = $db->escape(trim(JString::strtolower($search))); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // get data from model $rows = $this->get('Items'); // are events available? if (!$rows) { $noevents = 1; } else { $noevents = 0; } # print-link if ($task == 'archive') { $print_link = JRoute::_('index.php?view=eventslist&task=archive&tmpl=component&print=1'); } else { $print_link = JRoute::_('index.php?view=eventslist&tmpl=component&print=1'); } // Check if the user has access to the form $maintainer = JemUser::ismaintainer('add'); $genaccess = JemUser::validate_user($jemsettings->evdelrec, $jemsettings->delivereventsyes); if ($maintainer || $genaccess || $user->authorise('core.create', 'com_jem')) { $dellink = 1; } else { $dellink = 0; } # Check if the user has access to the add-venueform $maintainer2 = JemUser::venuegroups('add'); $genaccess2 = JemUser::validate_user($jemsettings->locdelrec, $jemsettings->deliverlocsyes); if ($maintainer2 || $genaccess2) { $addvenuelink = 1; } else { $addvenuelink = 0; } // search filter $filters = array(); $filters[] = JHtml::_('select.option', '0', '— ' . JText::_('COM_JEM_GLOBAL_SELECT_FILTER') . ' —'); 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')); } $lists['filter'] = JHtml::_('select.genericlist', $filters, 'filter_type', array('size' => '1', 'class' => 'inputbox input-medium'), 'value', 'text', $filter_type); $lists['search'] = $search; $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->pagination = $this->get('Pagination'); $this->lists = $lists; $this->action = $uri->toString(); $this->rows = $rows; $this->task = $task; $this->noevents = $noevents; $this->params = $params; $this->addvenuelink = $addvenuelink; $this->dellink = $dellink; $this->jemsettings = $jemsettings; $this->settings = $settings; $this->print = $print; $this->print_link = $print_link; $this->admin = $admin; $this->_prepareDocument(); parent::display($tpl); }