public function display($tpl = null) { $user = JFactory::getUser(); $document = JFactory::getDocument(); $settings = JEMHelper::globalattribs(); $jemsettings = JEMAdmin::config(); $url = JUri::root(); // Initialise variables. $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); // Retrieving params $params = $this->state->get('params'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // loading Mootools JHtml::_('behavior.framework'); // Load css JHtml::_('stylesheet', 'com_jem/backend.css', array(), true); // Load Scripts $document->addScript('http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'); $document->addCustomTag('<script type="text/javascript">jQuery.noConflict();</script>'); // assign data to template $this->user = $user; $this->jemsettings = $jemsettings; $this->settings = $settings; // add toolbar $this->addToolbar(); parent::display($tpl); }
/** * Constructor * */ public function __construct() { parent::__construct(); $app = JFactory::getApplication(); $jemsettings = JEMHelper::config(); $settings = JEMHelper::globalattribs(); $id = $app->input->getInt('id', 0); $this->setId((int)$id); $this->_reguser = $settings->get('global_regname', '1'); /* in J! 3.3.6 limitstart is removed from request - but we need it! */ if ($app->input->getInt('limitstart', null) === null) { $app->setUserState('com_jem.attendees.limitstart', 0); } $limit = $app->getUserStateFromRequest( 'com_jem.attendees.limit', 'limit', $jemsettings->display_num, 'int'); $limitstart = $app->getUserStateFromRequest( 'com_jem.attendees.limitstart', 'limitstart', 0, 'int' ); // correct start value if required $limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0; $this->setState('limit', $limit); $this->setState('limitstart', $limitstart); //set unlimited if export or print action | task=export or task=print $task = $app->input->get('task', ''); $this->setState('unlimited', ($task == 'export' || $task == 'print') ? '1' : ''); }
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); }
public function display($tpl = null) { $user = JFactory::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->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); $this->settings = $settings; $params = $this->state->get('params'); // 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); $this->user = $user; # add toolbar $this->addToolbar(); parent::display($tpl); }
/** * Constructor * * */ public function __construct() { parent::__construct(); $settings = JEMHelper::globalattribs(); $this->regname = $settings->get('global_regname','1'); $array = JFactory::getApplication()->input->get('cid', array(), 'array'); $this->setId((int)$array[0]); }
/** * Build the where clause * * @access private * @return string */ protected function _buildVenuesWhere() { $app = JFactory::getApplication(); $user = JemFactory::getUser(); $settings = JEMHelper::globalattribs(); $filter = $app->getUserStateFromRequest('com_jem.myvenues.filter', 'filter', '', 'int'); $search = $app->getUserStateFromRequest('com_jem.myvenues.filter_search', 'filter_search', '', 'string'); $search = $this->_db->escape(trim(JString::strtolower($search))); $where = array(); // $where[] = ' l.published = 1'; // then if the user is creator of the event $where [] = ' l.created_by = '.$this->_db->Quote($user->id); if ($settings->get('global_show_filter') && $search) { switch($filter) { case 1: // $where[] = ' LOWER(a.title) LIKE \'%'.$search.'%\' '; break; case 2: $where[] = ' LOWER(l.venue) LIKE \'%'.$search.'%\' '; break; case 3: $where[] = ' LOWER(l.city) LIKE \'%'.$search.'%\' '; break; case 4: // $where[] = ' LOWER(c.catname) LIKE \'%'.$search.'%\' '; break; case 5: default: $where[] = ' LOWER(l.state) LIKE \'%'.$search.'%\' '; } } $where = (count($where) ? ' WHERE ' . implode(' AND ', $where) : ''); return $where; }
/** * Method to get event data. * * @param integer The id of the event. * * @return mixed item data object on success, false on failure. */ public function getItem($itemId = null) { $jemsettings = JemHelper::config(); // Initialise variables. $itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('event.id'); // Get a row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($itemId); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return false; } $properties = $table->getProperties(1); $value = JArrayHelper::toObject($properties, 'JObject'); // Backup current recurrence values if ($value->id) { $value->recurr_bak = new stdClass(); foreach (get_object_vars($value) as $k => $v) { if (strncmp('recurrence_', $k, 11) === 0) { $value->recurr_bak->{$k} = $v; } } } // Convert attrib field to Registry. $registry = new JRegistry(); $registry->loadString($value->attribs); $globalregistry = JEMHelper::globalattribs(); $value->params = clone $globalregistry; $value->params->merge($registry); // Compute selected asset permissions. $user = JFactory::getUser(); $userId = $user->get('id'); //$asset = 'com_jem.event.' . $value->id; $asset = 'com_jem'; $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select(array('count(id)')); $query->from('#__jem_register'); $query->where(array('event= ' . $db->quote($itemId), 'waiting= 0')); $db->setQuery($query); $res = $db->loadResult(); $value->booked = $res; $files = JEMAttachment::getAttachments('event' . $itemId); $value->attachments = $files; // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $value->params->set('access-edit', true); } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { // Check for a valid user and that they are the owner. if ($userId == $value->created_by) { $value->params->set('access-edit', true); } } // Check edit state permission. if ($itemId) { // Existing item $value->params->set('access-change', $user->authorise('core.edit.state', $asset)); } else { // New item. $catId = (int) $this->getState('event.catid'); if ($catId) { $value->params->set('access-change', $user->authorise('core.edit.state', 'com_jem.category.' . $catId)); $value->catid = $catId; } else { $value->params->set('access-change', $user->authorise('core.edit.state', 'com_jem')); } } //////////////// $venueQuery = $db->getQuery(true); $venueQuery->select(array('alias')); $venueQuery->from('#__jem_venues'); $venueQuery->where(array('id= ' . $db->quote($value->locid))); $db->setQuery($venueQuery); $venueResult = $db->loadResult(); $value->localias = $venueResult; //////////////// $value->author_ip = $jemsettings->storeip ? JemHelper::retrieveIP() : false; $value->articletext = $value->introtext; if (!empty($value->fulltext)) { $value->articletext .= '<hr id="system-readmore" />' . $value->fulltext; } return $value; }
/** * Method to get event data. * * @param integer The id of the event. * @return mixed item data object on success, false on failure. */ public function &getItem($pk = null) { // Initialise variables. $pk = !empty($pk) ? $pk : (int) $this->getState('event.id'); if ($this->_item === null) { $this->_item = array(); } if (!isset($this->_item[$pk])) { try { $settings = JEMHelper::globalattribs(); $db = $this->getDbo(); $query = $db->getQuery(true); $query->select($this->getState('item.select', 'a.id, a.access, a.attribs, a.metadata, a.registra, a.custom1, a.custom2, a.custom3, a.custom4, a.custom5, a.custom6, a.custom7, a.custom8, a.custom9, a.custom10, a.times, a.endtimes, a.dates, a.enddates, a.id AS did, a.title, a.alias, ' . 'a.created, a.unregistra, a.published, a.created_by, ' . 'CASE WHEN a.modified = 0 THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, a.checked_out, a.checked_out_time, ' . 'a.datimage, a.version, ' . 'a.meta_keywords, a.created_by_alias, a.introtext, a.fulltext, a.maxplaces, a.waitinglist, a.meta_description, a.hits, a.language, a.recurrence_group,' . 'a.recurrence_type, a.recurrence_first_id')); $query->from('#__jem_events AS a'); // Join on user table. $name = $settings->get('global_regname', '1') ? 'u.name' : 'u.username'; $query->select(array($name . ' AS author', 'u.name', 'u.username')); $query->join('LEFT', '#__users AS u on u.id = a.created_by'); // Join on contact-user table. $query->select('con.id AS conid, con.name AS conname, con.telephone AS contelephone, con.email_to AS conemail'); $query->join('LEFT', '#__contact_details AS con ON con.id = a.contactid'); // Join on venue table. $query->select('l.custom1 AS venue1, l.custom2 AS venue2, l.custom3 AS venue3, l.custom4 AS venue4, l.custom5 AS venue5, l.custom6 AS venue6, l.custom7 AS venue7, l.custom8 AS venue8, l.custom9 AS venue9, l.custom10 AS venue10, ' . 'l.id AS locid, l.alias AS localias, l.venue, l.city, l.state, l.url, l.locdescription, l.locimage, l.city, l.postalCode, l.street, l.country,l.phone,l.fax,l.email,l.map, l.created_by AS venueowner, l.latitude, l.longitude, l.timezone, l.checked_out AS vChecked_out, l.checked_out_time AS vChecked_out_time'); $query->join('LEFT', '#__jem_venues AS l ON a.locid = l.id'); # join over the category-tables $query->join('LEFT', '#__jem_cats_event_relations AS rel ON rel.itemid = a.id'); $query->join('LEFT', '#__jem_categories AS c ON c.id = rel.catid'); // Filter by language /* commented out yet because it's incomplete if ($this->getState('filter.language')) { $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); } */ $query->where('a.id = ' . (int) $pk); // Filter by start and end dates. $nullDate = $db->Quote($db->getNullDate()); $date = JFactory::getDate(); $nowDate = $db->Quote($date->toSql()); // Filter by published state. $published = $this->getState('filter.published'); $archived = $this->getState('filter.archived'); if (is_numeric($published)) { $query->where('(a.published = ' . (int) $published . ' OR a.published =' . (int) $archived . ')'); } ##################### ### FILTER - BYCAT ## ##################### $cats = $this->getCategories('all'); $query->where('c.id IN (' . implode(',', $cats) . ')'); //$query->group('a.id'); $db->setQuery($query); $data = $db->loadObject(); if ($error = $db->getErrorMsg()) { throw new Exception($error); } if (empty($data)) { throw new Exception(JText::_('COM_JEM_EVENT_ERROR_EVENT_NOT_FOUND'), 404); } // Convert parameter fields to objects. $registry = new JRegistry(); $registry->loadString($data->attribs); $globalattribs = JEMHelper::globalattribs(); $globalregistry = new JRegistry(); $globalregistry->loadString($globalattribs); $data->params = clone $globalregistry; $data->params->merge($registry); $registry = new JRegistry(); $registry->loadString($data->metadata); $data->metadata = $registry; // Compute selected asset permissions. $user = JFactory::getUser(); // Technically guest could edit an event, but lets not check // that to improve performance a little. if (!$user->get('guest')) { $userId = $user->get('id'); $asset = 'com_jem.event.' . $data->id; // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $data->params->set('access-edit', true); } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { // Check for a valid user and that they are the owner. if ($userId == $data->created_by) { $data->params->set('access-edit', true); } } } // Compute view access permissions. if ($access = $this->getState('filter.access')) { // If the access filter has been set, we already know this // user can view. $data->params->set('access-view', true); } else { # retrieve category's that the user is able to see # if there is no category the event should not be displayed $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); $category_viewable = $this->getCategories($pk); if ($category_viewable) { $data->params->set('access-view', true); } } $this->_item[$pk] = $data; } catch (JException $e) { if ($e->getCode() == 404) { // Need to go thru the error handler to allow Redirect to work. JError::raiseError(404, $e->getMessage()); return false; } else { $this->setError($e); $this->_item[$pk] = false; return false; } } } // Define Attachments $user = JFactory::getUser(); $this->_item[$pk]->attachments = JEMAttachment::getAttachments('event' . $this->_item[$pk]->did); // Define Venue-Attachments $this->_item[$pk]->vattachments = JEMAttachment::getAttachments('venue' . $this->_item[$pk]->locid); // Define Booked $db = $this->getDbo(); $query = $db->getQuery(true); $query->select(array('COUNT(*)')); $query->from('#__jem_register'); $query->where(array('event= ' . $db->quote($this->_item[$pk]->did), 'waiting= 0')); $db->setQuery($query); $res = $db->loadResult(); $this->_item[$pk]->booked = $res; // Define Waiters $db = $this->getDbo(); $query = $db->getQuery(true); $query->select(array('COUNT(*)')); $query->from('#__jem_register'); $query->where(array('event= ' . $db->quote($this->_item[$pk]->did), 'waiting= 1')); $db->setQuery($query); $res2 = $db->loadResult(); $this->_item[$pk]->waiters = $res2; return $this->_item[$pk]; }
/** * Build the where clause * * @access private * @return string */ protected function _buildVenuesWhere() { $app = JFactory::getApplication(); $user = JFactory::getUser(); $settings = JEMHelper::globalattribs(); $user = JFactory::getUser(); $jinput = JFactory::getApplication()->input; $itemid = $jinput->getInt('id', 0) . ':' . $jinput->getInt('Itemid', 0); $filter_type = $app->getUserStateFromRequest('com_jem.myvenues.' . $itemid . '.filter_type', 'filter_type', '', 'int'); $search = $app->getUserStateFromRequest('com_jem.myvenues.' . $itemid . '.filter_search', 'filter_search', '', 'string'); $search = $this->_db->escape(trim(JString::strtolower($search))); $where = array(); $where[] = ' l.published IN (0,1,2,-2)'; // check if venue is created by the user $where[] = ' l.created_by = ' . $this->_db->Quote($user->id); if ($settings->get('global_show_filter') && $search) { switch ($filter_type) { case 1: // $where[] = ' LOWER(a.title) LIKE \'%'.$search.'%\' '; break; case 2: $where[] = ' LOWER(l.venue) LIKE \'%' . $search . '%\' '; break; case 3: $where[] = ' LOWER(l.city) LIKE \'%' . $search . '%\' '; break; case 4: // $where[] = ' LOWER(c.catname) LIKE \'%'.$search.'%\' '; break; case 5: default: $where[] = ' LOWER(l.state) LIKE \'%' . $search . '%\' '; } } $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : ''; return $where; }
/** * Method to get the events * * @access public * @return array */ public static function getList(&$params) { mb_internal_encoding('UTF-8'); // 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); $model->setState('filter.access', true); // filter published // 0: unpublished // 1: published // 2: archived // -2: trashed $type = $params->get('type'); $offset_hourss = $params->get('offset_hours', 0); // all upcoming events if ($type == 0 || $type == 1) { $offset_minutes = $offset_hourss * 60; $model->setState('filter.published', 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 .= $type == 1 ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) " : ") "; } elseif ($type == 2) { $model->setState('filter.published', 2); $model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC')); $cal_from = ""; } elseif ($type == 3) { $offset_days = (int) round($offset_hourss / 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}))"; } elseif ($type == 4) { $offset_minutes = $offset_hourss * 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'); // clean parameter data $catids = $params->get('catid'); $venids = $params->get('venid'); $eventids = $params->get('eventid'); // 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); } // count $count = $params->get('count', '2'); if ($params->get('use_modal', 0)) { JHtml::_('behavior.modal', 'a.flyermodal'); } $model->setState('list.limit', $count); // Retrieve the available Events $events = $model->getItems(); if (!$events) { return array(); } // Loop through the result rows and prepare data $i = 0; $lists = array(); $FixItemID = $params->get('FixItemID', ''); $eventimg = $params->get('eventimg', 1); $venueimg = $params->get('venueimg', 1); foreach ($events as $row) { // create thumbnails if needed and receive imagedata if ($row->datimage) { $dimage = JEMImage::flyercreator($row->datimage, 'event'); } else { $dimage = null; } if ($row->locimage) { $limage = JEMImage::flyercreator($row->locimage, 'venue'); } else { $limage = null; } // cut titel $length = mb_strlen($row->title); $maxlength = $params->get('cuttitle', '18'); if ($length > $maxlength && $maxlength > 0) { $row->title = mb_substr($row->title, 0, $maxlength); $row->title = $row->title . '...'; } /** * DEFINE LIST **/ $settings = JEMHelper::globalattribs(); $access = !$settings->get('show_noauth', '0'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $lists[$i] = new stdClass(); $lists[$i]->title = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8'); $lists[$i]->venue = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8'); $lists[$i]->state = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8'); $lists[$i]->city = htmlspecialchars($row->city, ENT_COMPAT, 'UTF-8'); // time/date $lists[$i]->date = modJEMteaserHelper::_format_date($row, $params); $lists[$i]->day = modJEMteaserHelper::_format_day($row, $params); $lists[$i]->dayname = modJEMteaserHelper::_format_dayname($row); $lists[$i]->daynum = modJEMteaserHelper::_format_daynum($row); $lists[$i]->month = modJEMteaserHelper::_format_month($row); $lists[$i]->year = modJEMteaserHelper::_format_year($row); $lists[$i]->time = $row->times ? modJEMteaserHelper::_format_time($row->dates, $row->times, $params) : ''; if ($access || in_array($row->access, $authorised)) { // We know that user has the privilege to view the event if ($FixItemID) { $lists[$i]->link = JRoute::_('index.php?option=com_jem&view=event&id=' . $row->slug . '&Itemid=' . $FixItemID); } else { $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'); } if ($FixItemID) { $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_('index.php?option=com_jem&view=event&id=' . $row->slug . '&Itemid=' . $FixItemID) : ''; $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_('index.php?option=com_jem&view=venue&id=' . $row->venueslug . '&Itemid=' . $FixItemID) : ''; } else { $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_(JEMHelperRoute::getEventRoute($row->slug)) : ''; $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : ''; } $lists[$i]->catname = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1), false, $FixItemID)); // images if ($eventimg) { if ($dimage == null) { $lists[$i]->eventimage = ''; $lists[$i]->eventimageorig = ''; } else { $lists[$i]->eventimage = JURI::base(true) . '/' . $dimage['thumb']; $lists[$i]->eventimageorig = JURI::base(true) . '/' . $dimage['original']; } } else { $lists[$i]->eventimage = ''; $lists[$i]->eventimageorig = ''; } if ($venueimg) { if ($limage == null) { $lists[$i]->venueimage = ''; $lists[$i]->venueimageorig = ''; } else { $lists[$i]->venueimage = JURI::base(true) . '/' . $limage['thumb']; $lists[$i]->venueimageorig = JURI::base(true) . '/' . $limage['original']; } } else { $lists[$i]->venueimage = ''; $lists[$i]->venueimageorig = ''; } $length = $params->get('descriptionlength'); $length2 = 1; $etc = '...'; $etc2 = JText::_('MOD_JEM_TEASER_NO_DESCRIPTION'); //strip html tags but leave <br /> tags $description = strip_tags($row->introtext, "<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; } else { if (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)); $i++; } return $lists; }
/** * Build the where clause * * @access private * @return string */ protected function _buildAttendingWhere() { $app = JFactory::getApplication(); // Get the paramaters of the active menu item $params = $app->getParams(); $task = $app->input->get('task', ''); $settings = JEMHelper::globalattribs(); $user = JemFactory::getUser(); // Support Joomla access levels instead of single group id $levels = $user->getAuthorisedViewLevels(); $filter = $app->getUserStateFromRequest('com_jem.myattendances.filter', 'filter', '', 'int'); $search = $app->getUserStateFromRequest('com_jem.myattendances.filter_search', 'filter_search', '', 'string'); $search = $this->_db->escape(trim(JString::strtolower($search))); $where = array(); // First thing we need to do is to select only needed events if ($task == 'archive') { $where[] = ' a.published = 2'; } else { $where[] = ' a.published = 1'; } $where[] = ' c.published = 1'; $where[] = ' a.access IN (' . implode(',', $levels) . ')'; $where[] = ' c.access IN (' . implode(',', $levels) . ')'; //limit output so only future events the user attends will be shown // but also allow events without start date because they will be normally in the future too if ($params->get('filtermyregs')) { $where [] = ' (a.dates IS NULL OR DATE_SUB(NOW(), INTERVAL '.(int)$params->get('myregspast').' DAY) < (IF (a.enddates IS NOT NULL, a.enddates, a.dates)))'; } // then if the user is attending the event $where [] = ' r.uid = '.$this->_db->Quote($user->id); if ($settings->get('global_show_filter') && $search) { switch($filter) { case 1: $where[] = ' LOWER(a.title) LIKE \'%'.$search.'%\' '; break; case 2: $where[] = ' LOWER(l.venue) LIKE \'%'.$search.'%\' '; break; case 3: $where[] = ' LOWER(l.city) LIKE \'%'.$search.'%\' '; break; case 4: $where[] = ' LOWER(c.catname) LIKE \'%'.$search.'%\' '; break; case 5: default: $where[] = ' LOWER(l.state) LIKE \'%'.$search.'%\' '; } } $where = (count($where) ? ' WHERE ' . implode(' AND ', $where) : ''); return $where; }
/** * Method to get event data. * * @param integer The id of the event. * * @return mixed item data object on success, false on failure. */ public function getItem($itemId = null) { $jemsettings = JemHelper::config(); // Initialise variables. $itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('event.id'); // Get a row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($itemId); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return false; } $properties = $table->getProperties(1); $value = JArrayHelper::toObject($properties, 'JObject'); // Convert attrib field to Registry. $registry = new JRegistry(); $registry->loadString($value->attribs); $globalsettings = JEMHelper::globalattribs(); $globalregistry = new JRegistry(); $globalregistry->loadString($globalsettings); $value->params = clone $globalregistry; $value->params->merge($registry); // Compute selected asset permissions. $user = JFactory::getUser(); $userId = $user->get('id'); //$asset = 'com_jem.event.' . $value->id; $asset = 'com_jem'; $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select(array('count(id)')); $query->from('#__jem_register'); $query->where(array('event= ' . $db->quote($itemId), 'waiting= 0')); $db->setQuery($query); $res = $db->loadResult(); $value->booked = $res; $files = JEMAttachment::getAttachments('event' . $itemId); $value->attachments = $files; ################ ## RECURRENCE ## ################ # check recurrence if ($value->recurrence_group) { # this event is part of a recurrence-group # # check for groupid & groupid_ref (recurrence_table) # - groupid = $item->recurrence_group # - groupid_ref = $item->recurrence_group # - Itemid = $item->id $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select(array('count(id)')); $query->from('#__jem_recurrence'); $query->where(array('groupid= ' . $value->recurrence_group, 'itemid= ' . $value->id, 'groupid = groupid_ref')); $db->setQuery($query); $rec_groupset_check = $db->loadResult(); if ($rec_groupset_check == '1') { $value->recurrence_groupcheck = true; } else { $value->recurrence_groupcheck = false; } } else { $value->recurrence_groupcheck = false; } ############## ## HOLIDAYS ## ############## # Retrieve dates that are holidays and enabled. $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('holiday'); $query->from('#__jem_dates'); $query->where(array('enabled = 1', 'holiday = 1')); $db->setQuery($query); $holidays = $db->loadColumn(); if ($holidays) { $value->recurrence_country_holidays = true; } else { $value->recurrence_country_holidays = false; } // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $value->params->set('access-edit', true); } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { // Check for a valid user and that they are the owner. if ($userId == $value->created_by) { $value->params->set('access-edit', true); } } // Check edit state permission. if ($itemId) { // Existing item $value->params->set('access-change', $user->authorise('core.edit.state', $asset)); } else { // New item. $catId = (int) $this->getState('event.catid'); if ($catId) { $value->params->set('access-change', $user->authorise('core.edit.state', 'com_jem.category.' . $catId)); $value->catid = $catId; } else { $access_change = $user->authorise('core.edit.state', 'com_jem'); $value->params->set('access-change', $access_change); } } $value->author_ip = $jemsettings->storeip ? JemHelper::retrieveIP() : false; $value->articletext = $value->introtext; if (!empty($value->fulltext)) { $value->articletext .= '<hr id="system-readmore" />' . $value->fulltext; } if (!empty($value->datimage)) { if (strpos($value->datimage, 'images/') !== false) { # the image selected contains the images path } else { # the image selected doesn't have the /images/ path # we're looking at the locimage so we'll append the venues folder $value->datimage = 'images/jem/events/' . $value->datimage; } } $admin = JFactory::getUser()->authorise('core.manage', 'com_jem'); if ($admin) { $value->admin = true; } else { $value->admin = false; } return $value; }
protected static function getRouteWithoutId($my) { $settings = JEMHelper::globalattribs(); $defaultItemid = $settings->get('default_Itemid'); $needles = array(); $needles[$my] = array(self::ARTIFICALID); // Create the link $link = 'index.php?option=com_jem&view='.$my; if ($item = self::_findItem($needles)) { $link .= '&Itemid='.$item; } elseif ($item = self::_findItem()) { if (isset($defaultItemid)) { $link .= '&Itemid='.$defaultItemid; } else { $link .= '&Itemid='.$item; } } return $link; }
/** * Method to get the registered users * * @access public * @return object * */ function getRegisters($event = false) { if (empty($event)) { return false; } // avatars should be displayed $settings = JEMHelper::globalattribs(); $user = JemFactory::getUser(); switch ($settings->get('event_show_attendeenames', 2)) { case 0: // show to none default: return false; case 1: // show to admins if (!$user->authorise('core.manage', 'com_jem')) { return false; } break; case 2: // show to registered if ($user->get('guest')) { return false; } break; case 3: // show to all break; } $avatar = ''; $join = ''; if ($settings->get('event_comunoption','0') == 1 && $settings->get('event_comunsolution','0') == 1) { $avatar = ', c.avatar'; $join = ' LEFT JOIN #__comprofiler as c ON c.user_id = r.uid'; } $name = $settings->get('global_regname','1') ? 'u.name' : 'u.username'; // Get registered users $db = $this->getDbo(); $query = $db->getQuery(true); $query = 'SELECT ' . $name . ' AS name, r.uid' . $avatar . ' FROM #__jem_register AS r' . ' LEFT JOIN #__users AS u ON u.id = r.uid' . $join . ' WHERE event = '. $db->quote($event) . ' AND waiting = 0 '; $db->setQuery($query); $registered = $db->loadObjectList(); return $registered; }
/** * Build the where clause * * @access private * @return string */ protected function _buildWhere() { $app = JFactory::getApplication(); $task = $app->input->get('task', ''); $params = $app->getParams(); $settings = JEMHelper::globalattribs(); $user = JemFactory::getUser(); // Support Joomla access levels instead of single group id $levels = $user->getAuthorisedViewLevels(); $filter = $app->getUserStateFromRequest('com_jem.myevents.filter', 'filter', '', 'int'); $search = $app->getUserStateFromRequest('com_jem.myevents.filter_search', 'filter_search', '', 'string'); $search = $this->_db->escape(trim(JString::strtolower($search))); $where = array(); // First thing we need to do is to select only needed events if ($task == 'archive') { $where[] = ' a.published = 2'; } else { $where[] = ' (a.published = 1 OR a.published = 0)'; } $where[] = ' c.published = 1'; $where[] = ' a.access IN (' . implode(',', $levels) . ')'; $where[] = ' c.access IN (' . implode(',', $levels) . ')'; // then if the user is the owner of the event $where[] = ' a.created_by = '.$this->_db->Quote($user->id); // get excluded categories $excluded_cats = trim($params->get('excluded_cats', '')); if ($excluded_cats != '') { $cats_excluded = explode(',', $excluded_cats); JArrayHelper::toInteger($cats_excluded); $where [] = ' c.id NOT IN (' . implode(',', $cats_excluded) . ')'; } // === END Excluded categories add === // if ($settings->get('global_show_filter') && $search) { switch($filter) { case 1: $where[] = ' LOWER(a.title) LIKE \'%'.$search.'%\' '; break; case 2: $where[] = ' LOWER(l.venue) LIKE \'%'.$search.'%\' '; break; case 3: $where[] = ' LOWER(l.city) LIKE \'%'.$search.'%\' '; break; case 4: $where[] = ' LOWER(c.catname) LIKE \'%'.$search.'%\' '; break; case 5: default: $where[] = ' LOWER(l.state) LIKE \'%'.$search.'%\' '; } } $where = (count($where) ? ' WHERE ' . implode(' AND ', $where) : ''); return $where; }
/** * Build the where clause * * @access private * @return string */ protected function _buildWhere() { $app = JFactory::getApplication(); $jinput = $app->input; $task = $jinput->getCmd('task'); $params = $app->getParams(); $settings = JEMHelper::globalattribs(); $user = JFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); $itemid = $jinput->getInt('id', 0) . ':' . $jinput->getInt('Itemid', 0); $db = JFactory::getDBO(); $filter_type = $app->getUserStateFromRequest('com_jem.myevents.' . $itemid . '.filter_type', 'filter_type', '', 'int'); if ($filter_type == 0) { $filter_type = 1; } $search = $app->getUserStateFromRequest('com_jem.myevents.' . $itemid . '.filter_search', 'filter_search', '', 'string'); $search = $this->_db->escape(trim(JString::strtolower($search))); $where = array(); // First thing we need to do is to select only needed events if ($task == 'archive') { $where[] = ' a.published = 2'; } else { $where[] = ' (a.published = 1 OR a.published = 0)'; } $where[] = ' c.published = 1'; $where[] = ' c.access IN (' . implode(',', $levels) . ')'; // then if the user is the owner of the event $where[] = ' a.created_by = ' . $this->_db->Quote($user->id); // get excluded categories $excluded_cats = trim($params->get('excluded_cats', '')); if ($excluded_cats != '') { $cats_excluded = explode(',', $excluded_cats); $where[] = ' (c.id!=' . implode(' AND c.id!=', $cats_excluded) . ')'; } // === END Excluded categories add === // if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); if ($search && $settings->get('global_show_filter')) { switch ($filter_type) { case 1: $where[] = ' LOWER(a.title) LIKE ' . $search; break; case 2: $where[] = ' LOWER(l.venue) LIKE ' . $search; break; case 3: $where[] = ' LOWER(l.city) LIKE ' . $search; break; case 4: $where[] = ' LOWER(c.catname) LIKE ' . $search; break; case 5: default: $where[] = ' LOWER(l.state) LIKE ' . $search; } } } } $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : ''; return $where; }
/** * Exporttask * view: attendees */ function export() { $app = JFactory::getApplication(); $settings = JEMHelper::globalattribs(); $params = $app->getParams(); $enableemailadress = $params->get('enableemailaddress', 0); $model = $this->getModel('attendees'); $datas = $model->getData(); $event = $model->getEvent(); $waitinglist = isset($event->waitinglist) ? $event->waitinglist : false; header('Content-Type: text/x-csv'); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Disposition: attachment; filename=attendees.csv'); header('Pragma: no-cache'); $userfield = $settings->get('global_regname', '1') ? 'name' : 'username'; $export = ''; foreach ($datas as $data) { $cols = array(); $cols[] = '"' . str_replace("\"", "\"\"", $data->$userfield) . '"'; if ($enableemailadress == 1) { $cols[] = '"' . str_replace("\"", "\"\"", $data->email) . '"'; } $cols[] = '"' . str_replace("\"", "\"\"", JHtml::_('date',$data->uregdate, JText::_('DATE_FORMAT_LC2'))) . '"'; if ($waitinglist) { $cols[] = '"' . JText::_($data->waiting ? 'COM_JEM_ATTENDEES_ON_WAITINGLIST' : 'COM_JEM_ATTENDEES_ATTENDING') . '"'; } $export .= implode(';', $cols) . "\r\n"; } echo $export; $app->close(); }
/** * Prepares the print screen * * @param $tpl */ protected function _displayprint($tpl = null) { $document = JFactory::getDocument(); $app = JFactory::getApplication(); $params = $app->getParams(); $settings = JEMHelper::globalattribs(); // Load css JemHelper::loadCss('backend'); JemHelper::loadCss('jem'); JemHelper::loadCss('print'); JemHelper::loadCustomTag(); $document->setMetaData('robots', 'noindex, nofollow'); // Emailaddress $enableemailaddress = $params->get('enableemailaddress', 0); $rows = $this->get('Data'); $event = $this->get('Event'); //assign data to template $this->rows = $rows; $this->event = $event; $this->enableemailaddress = $enableemailaddress; $this->settings = $settings; parent::display($tpl); }
/** * Determines the Itemid * * searches if a menuitem for this item exists * if not the active menuitem will be returned * * @param array The id and view * * * @return int Itemid */ protected static function _findItem($needles = null) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); if (!isset(self::$FixedItemid)) { $settings = JEMHelper::globalattribs(); $defaultItemid = $settings->get('default_Itemid'); } else { if (isset(self::$FixedItemid)) { $defaultItemid = self::$FixedItemid; } } // Prepare the reverse lookup array. if (!isset(self::$lookup2)) { self::$lookup2 = array(); $component = JComponentHelper::getComponent('com_jem'); $items = $menus->getItems('component_id', $component->id); // loop trough the menu-items of the component if ($items) { foreach ($items as $item) { if (isset($item->query) && isset($item->query['view'])) { // skip Calendar-layout if (isset($item->query['layout']) && $item->query['layout'] == 'calendar') { continue; } // define $view variable $view = $item->query['view']; // skip several views if (isset($item->query['view'])) { if ($view == 'calendar' || $view == 'search' || $view == 'venues') { continue; } } if (!isset(self::$lookup2[$view])) { self::$lookup2[$view] = array(); } } // check for Id's if (isset($item->query['id'])) { if (!isset(self::$lookup2[$view][$item->query['id']])) { self::$lookup2[$view][$item->query['id']] = $item->id; } } else { // Some views have no ID, but we have to set one self::$lookup2[$view][self::ARTIFICALID] = $item->id; } } } } // at this point we collected itemid's linking to the component if ($needles) { foreach ($needles as $view => $ids) { if (isset(self::$lookup2[$view])) { foreach ($ids as $id) { if (isset(self::$lookup2[$view][(int) $id])) { return self::$lookup2[$view][(int) $id]; } } } } } if ($defaultItemid) { return $defaultItemid; } else { $active = $menus->getActive(); if ($active && $active->component == 'com_jem') { return $active->id; } $component = JComponentHelper::getComponent('com_jem'); $items = $menus->getItems(array('component_id', 'link'), array($component->id, 'index.php?option=com_jem&view=eventslist'), false); $default = reset($items); return !empty($default->id) ? $default->id : null; } }