primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,24 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Model\AdminModel;
abstract class JemModelAdmin extends AdminModel
{
protected function _prepareTable($table)
{
// Derived class will provide its own implementation if required.
}
protected function prepareTable($table)
{
$this->_prepareTable($table);
}
}

View File

@ -0,0 +1,392 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Log\Log;
/**
* Model: Attendee
*/
class JemModelAttendee extends BaseDatabaseModel
{
/**
* attendee id
*
* @var int
*/
protected $_id = null;
/**
* Category data array
*
* @var array
*/
protected $_data = null;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$jinput = Factory::getApplication()->input;
$array = $jinput->get('id', 0, 'array');
if(is_array($array))
{
$this->setId((int)$array[0]);
}
}
/**
* Method to set the identifier
*
* @access public
* @param int category identifier
*/
public function setId($id)
{
// Set category id and wipe data
$this->_id = $id;
$this->_data = null;
}
/**
* Method to get data
*
* @access public
* @return array
*/
public function getData()
{
if (!$this->_loadData()) {
$this->_initData();
}
return $this->_data;
}
/**
* Method to load data
*
* @access protected
* @return boolean True on success
*/
protected function _loadData()
{
// Lets load the content if it doesn't already exist
if (empty($this->_data))
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select(array('r.*','u.name AS username', 'a.title AS eventtitle', 'a.waitinglist', 'a.maxbookeduser', 'a.minbookeduser', 'a.recurrence_type', 'a.seriesbooking'));
$query->from('#__jem_register as r');
$query->join('LEFT', '#__users AS u ON (u.id = r.uid)');
$query->join('LEFT', '#__jem_events AS a ON (a.id = r.event)');
$query->where(array('r.id= '.$db->quote($this->_id)));
$this->_db->setQuery($query);
$this->_data = $this->_db->loadObject();
// Merge status and waiting
if (!empty($this->_data) && !empty($this->_data->waiting) && ($this->_data->status == 1)) {
$this->_data->status = 2;
}
return (boolean) $this->_data;
}
return true;
}
/**
* Method to initialise the data
*
* @access protected
* @return boolean True on success
*/
protected function _initData()
{
// Lets load the content if it doesn't already exist
if (empty($this->_data))
{
$data = Table::getInstance('jem_register', '');
$data->username = null;
if (empty($data->eventtitle)) {
$jinput = Factory::getApplication()->input;
$eventid = $jinput->getInt('eventid', 0);
$table = $this->getTable('Event', 'JemTable');
$table->load($eventid);
if (!empty($table->title)) {
$data->eventtitle = $table->title;
$data->event = $table->id;
$data->maxbookeduser = $table->maxbookeduser;
$data->minbookeduser = $table->minbookeduser;
$data->recurrence_type = $table->recurrence_type;
$data->seriesbooking = $table->seriesbooking;
}
$data->waitinglist = isset($table->waitinglist) ? $table->waitinglist : 0;
}
$this->_data = $data;
}
return true;
}
public function toggle()
{
$attendee = $this->getData();
if (!$attendee->id) {
$this->setError(Text::_('COM_JEM_MISSING_ATTENDEE_ID'));
return false;
}
$row = Table::getInstance('jem_register', '');
$row->bind($attendee);
$row->waiting = ($attendee->waiting || ($attendee->status == 2)) ? 0 : 1;
if ($row->status == 2) {
$row->status = 1;
}
return $row->store();
}
/**
* Method to store the attendee
*
* @access public
* @return boolean True on success
*
*/
public function store($data)
{
$eventid = $data['event'];
$userid = $data['uid'];
$id = !empty($data['id']) ? (int)$data['id'] : 0;
$status = isset($data['status']) ? $data['status'] : false;
// Split status and waiting
if ($status !== false) {
if ($status == 2) {
$data['status'] = 1;
$data['waiting'] = 1;
} elseif ($status == 1) {
$data['waiting'] = 0;
}
}
// $row = $this->getTable('jem_register', '');
$row = Table::getInstance('jem_register', '');
if ($id > 0) {
$row->load($id);
$old_data = clone $row;
}
// bind it to the table
if (!$row->bind($data)) {
Factory::getApplication()->enqueueMessage($row->getError(), 'error');
return false;
}
// sanitise id field
$row->id = (int)$row->id;
$db = Factory::getContainer()->get('DatabaseDriver');
// Check if user is already registered to this event
$query = $db->getQuery(true);
$query->select(array('COUNT(id) AS count'));
$query->from('#__jem_register');
$query->where('event = '.$db->quote($eventid));
$query->where('uid = '.$db->quote($userid));
if ($row->id) {
$query->where('id != '.$db->quote($row->id));
}
$db->setQuery($query);
$cnt = $db->loadResult();
if ($cnt > 0) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_ERROR_USER_ALREADY_REGISTERED'), 'warning');
return false;
}
// Are we saving from an item edit?
if ($row->id) {
} else {
if ($row->status === 0) {
// todo: add "invited" field to store such timestamps?
} else { // except status "invited"
$row->uregdate = gmdate('Y-m-d H:i:s');
}
// Get event
$query = $db->getQuery(true);
$query->select(array('id','maxplaces','waitinglist','recurrence_first_id','recurrence_type','seriesbooking','singlebooking'));
$query->from('#__jem_events');
$query->where('id= '.$db->quote($eventid));
$db->setQuery($query);
$event = $db->loadObject();
// If recurrence event, save series event
$events = array();
if($event->recurrence_type){
// Retrieving seriesbooking
$seriesbooking = $data["seriesbooking"];
$singlebooking = $data["singlebooking"];
// If event has 'seriesbooking' active
if($event->seriesbooking && $seriesbooking && !$singlebooking){
//GEt date and time now
$dateFrom = date('Y-m-d', time());
$timeFrom = date('H:i', time());
// Get the all recurrence events of serie from now
$query = $db->getQuery(true);
$query->select(array('id','recurrence_first_id','maxplaces','waitinglist','recurrence_type','seriesbooking','singlebooking'));
$query->from('#__jem_events as a');
$query->where('((a.recurrence_first_id = 0 AND a.id = ' . (int)($event->recurrence_first_id?$event->recurrence_first_id:$event->id) . ') OR a.recurrence_first_id = ' . (int)($event->recurrence_first_id?$event->recurrence_first_id:$event->id) . ")");
$query->where("(a.dates > '" . $dateFrom . "' OR a.dates = '" . $dateFrom . "' AND dates >= '" . $timeFrom . "')");
$db->setQuery($query);
$events = $db->loadObjectList();
}
}
if (!isset($events) || !count ($events)){
$events [] = clone $event;
}
foreach ($events as $e) {
// Check if user is registered to each series event
$query = $db->getQuery(true);
$query->select(array('COUNT(id) AS count'));
$query->from('#__jem_register');
$query->where('event = '.$db->quote($e->id));
$query->where('uid = '.$db->quote($userid));
$db->setQuery($query);
$cnt = $db->loadResult();
if ($cnt > 0) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_ERROR_USER_ALREADY_REGISTERED') . '[id: ' . $e->id . ']', 'warning');
continue;
}
$row_aux= clone $row;
$row_aux->event = $e->id;
// Get register information of the event
$query = $db->getQuery(true);
$query->select(array('COUNT(id) AS registered', 'COALESCE(SUM(waiting), 0) AS waiting'));
$query->from('#__jem_register');
$query->where('status = 1 AND event = ' . $db->quote($e->id));
$db->setQuery($query);
$register = $db->loadObject();
// If no one is registered yet, $register is null!
if (is_null($register)) {
$register = new stdClass;
$register->registered = 0;
$register->waiting = 0;
$register->booked = 0;
} else {
$register->booked = $register->registered + $register->waiting;
}
// put on waiting list ?
if (($event->maxplaces > 0) && ($status == 1)) // there is a max and user will attend
{
// check if the user should go on waiting list
if ($register->booked >= $event->maxplaces) {
if (!$event->waitinglist) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_ERROR_REGISTER_EVENT_IS_FULL'), 'warning');
return false;
} else {
$row_aux->waiting = 1;
}
}else{
$row_aux->status = $status;
}
}else{
$row_aux->status = $status;
}
// Make sure the data is valid
if (!$row_aux->check()) {
$this->setError($row->getError());
return false;
}
// Store it in the db
if (!$row_aux->store()) {
Factory::getApplication()->enqueueMessage($row->getError(), 'error');
return false;
}
}
return $row;
}
}
/**
* Method to set status of registered
*
* @param array $pks IDs of the attendee records
* @param int $value Status value: -1 - "not attending", 0 - "invited", 1 - "attending", 2 - "on waiting list"
* @return boolean True on success.
*/
public function setStatus($pks, $value = 1)
{
// Sanitize the ids.
$pks = (array)$pks;
\Joomla\Utilities\ArrayHelper::toInteger($pks);
if (empty($pks)) {
$this->setError(Text::_('JERROR_NO_ITEMS_SELECTED'));
return false;
}
// Split status and waiting
if ($value == 2) {
$status = 1;
$waiting = 1;
} else {
$status = (int)$value;
$waiting = 0;
}
try {
$db = Factory::getContainer()->get('DatabaseDriver');
$db->setQuery(
'UPDATE #__jem_register' .
' SET status = '.$status.', waiting = '.$waiting.
' WHERE id IN ('.implode(',', $pks).')'
);
if ($db->execute() === false) {
throw new Exception($db->getErrorMsg());
}
} catch (Exception $e) {
JemHelper::addLogEntry($e->getMessage(), __METHOD__, Log::ERROR);
$this->setError($e->getMessage());
return false;
}
// JemHelper::addLogEntry("Registration status of record(s) ".implode(', ', $pks)." set to $value", __METHOD__, Log::DEBUG);
return true;
}
}

View File

@ -0,0 +1,271 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
/**
* Model: Attendees
*/
class JemModelAttendees extends ListModel
{
protected $eventid = 0;
/**
* Constructor
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'u.name', 'u.username',
'r.uid', 'r.waiting',
'r.uregdate','r.id'
);
}
parent::__construct($config);
$app = Factory::getApplication();
$eventid = $app->input->getInt('eventid', 0);
$this->setId($eventid);
}
public function setId($eventid)
{
$this->eventid = $eventid;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*/
protected function populateState($ordering = null, $direction = null)
{
$app = Factory::getApplication();
$limit = $app->getUserStateFromRequest('com_jem.attendees.limit', 'limit', $app->get('list_limit'), 'int');
$limitstart = $app->getUserStateFromRequest('com_jem.attendees.limitstart', 'limitstart', 0, 'int');
$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->getCmd('task');
$this->setState('unlimited', ($task == 'export' || $task == 'print') ? '1' : '');
$filter_type = $app->getUserStateFromRequest( 'com_jem.attendees.filter_type', 'filter_type', 0, 'int' );
$this->setState('filter_type', $filter_type);
$filter_search = $app->getUserStateFromRequest( 'com_jem.attendees.filter_search', 'filter_search', '', 'string' );
$this->setState('filter_search', $filter_search);
$filter_status = $app->getUserStateFromRequest( 'com_jem.attendees.filter_status', 'filter_status', -2, 'int' );
$this->setState('filter_status', $filter_status);
parent::populateState('u.username', 'asc');
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id.= ':' . $this->getState('filter_search');
$id.= ':' . $this->getState('filter_status');
$id.= ':' . $this->getState('filter_type');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select($this->getState('list.select', 'r.*'));
$query->from($db->quoteName('#__jem_register').' AS r');
// Join event data
$query->select('a.waitinglist AS waitinglist');
$query->join('LEFT', '#__jem_events AS a ON (r.event = a.id)');
// Join user info
$query->select(array('u.username','u.name','u.email'));
$query->join('LEFT', '#__users AS u ON (u.id = r.uid)');
// load only data from current event
$query->where('r.event = '.$db->Quote($this->eventid));
// TODO: filter status
$filter_status = $this->getState('filter_status', -2);
if ($filter_status > -2) {
if ($filter_status >= 1) {
$waiting = $filter_status == 2 ? 1 : 0;
$filter_status = 1;
$query->where('(a.waitinglist = 0 OR r.waiting = '.$db->quote($waiting).')');
}
$query->where('r.status = '.$db->quote($filter_status));
}
// search name
$filter_type = $this->getState('filter_type');
$filter_search = $this->getState('filter_search');
if (!empty($filter_search) && $filter_type == 1) {
$filter_search = $db->Quote('%'.$db->escape($filter_search, true).'%');
$query->where('u.name LIKE '.$filter_search);
}
// search username
if (!empty($filter_search) && $filter_type == 2) {
$filter_search = $db->Quote('%'.$db->escape($filter_search, true).'%');
$query->where('u.username LIKE '.$filter_search);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
$query->order($db->escape($orderCol.' '.$orderDirn));
return $query;
}
/**
* Get event data
*
* @access public
* @return object
*/
public function getEvent()
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select(array('id','title','dates','maxplaces','waitinglist'));
$query->from('#__jem_events');
$query->where('id = '.$db->Quote($this->eventid));
$db->setQuery( $query );
$event = $db->loadObject();
return $event;
}
/**
* Delete registered users
*
* @access public
* @return true on success
*/
public function remove($cid = array())
{
if (is_array($cid) && count($cid))
{
\Joomla\Utilities\ArrayHelper::toInteger($cid);
$user = implode(',', $cid);
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__jem_register'));
$query->where('id IN ('.$user.')');
$db->setQuery($query);
// TODO: use exception handling
if ($db->execute() === false) {
throw new Exception($db->getErrorMsg(), 500);
}
}
return true;
}
/**
* Returns a CSV file with Attendee data
* @return boolean
*/
public function getCsv()
{
$jemconfig = JemConfig::getInstance()->toRegistry();
$separator = $jemconfig->get('csv_separator', ';');
$delimiter = $jemconfig->get('csv_delimiter', '"');
$csv_bom = $jemconfig->get('csv_bom', '1');
$comments = $jemconfig->get('regallowcomments', 0);
$event = $this->getEvent();
$items = $this->getItems();
$waitinglist = isset($event->waitinglist) ? $event->waitinglist : false;
$csv = fopen('php://output', 'w');
$header = array(
Text::_('COM_JEM_NAME'),
Text::_('COM_JEM_USERNAME'),
Text::_('COM_JEM_EMAIL'),
Text::_('COM_JEM_REGDATE'),
Text::_('COM_JEM_ATTENDEES_PLACES'),
Text::_('COM_JEM_HEADER_WAITINGLIST_STATUS')
);
if ($comments) {
$header[] = Text::_('COM_JEM_COMMENT');
}
$header[] = Text::_('COM_JEM_ATTENDEES_REGID');
fputcsv($csv, $header, $separator, $delimiter);
foreach ($items as $item)
{
$status = isset($item->status) ? $item->status : 1;
if ($status < 0) {
$txt_stat = 'COM_JEM_ATTENDEES_NOT_ATTENDING';
} elseif ($status > 0) {
$txt_stat = $item->waiting ? 'COM_JEM_ATTENDEES_ON_WAITINGLIST' : 'COM_JEM_ATTENDEES_ATTENDING';
} else {
$txt_stat = 'COM_JEM_ATTENDEES_INVITED';
}
$data = array(
$item->name,
$item->username,
$item->email,
empty($item->uregdate) ? '' : HTMLHelper::_('date', $item->uregdate, Text::_('DATE_FORMAT_LC2')),
$item->places,
Text::_($txt_stat)
);
if ($comments) {
$comment = strip_tags($item->comment);
// comments are limited to 255 characters in db so we don't need to truncate them on export
$data[] = $comment;
}
$data[] = $item->uid;
fputcsv($csv, $data, $separator, $delimiter);
}
return fclose($csv);
}
}

View File

@ -0,0 +1,254 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
/**
* Categories Model
*
*/
class JemModelCategories extends ListModel
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.catname',
'alias', 'a.alias',
'published', 'a.published',
'access', 'a.access', 'access_level',
'language', 'a.language',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'created_time', 'a.created_time',
'created_user_id', 'a.created_user_id',
'lft', 'a.lft',
'rgt', 'a.rgt',
'level', 'a.level',
'path', 'a.path',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string An optional ordering field.
* @param string An optional direction (asc|desc).
*
* @return void
*/
protected function populateState($ordering = null, $direction = null)
{
// Initialise variables.
$app = Factory::getApplication();
$context = $this->context;
$extension = $app->getUserStateFromRequest('com_jem.categories.filter.extension', 'extension', 'com_jem', 'cmd');
$this->setState('filter.extension', $extension);
$parts = explode('.', $extension);
// extract the component name
$this->setState('filter.component', $parts[0]);
// extract the optional section name
$this->setState('filter.section', (count($parts) > 1) ? $parts[1] : null);
$search = $this->getUserStateFromRequest($context.'.search', 'filter_search');
$this->setState('filter.search', $search);
$level = $this->getUserStateFromRequest($context.'.filter.level', 'filter_level', 0, 'int');
$this->setState('filter.level', $level);
$access = $this->getUserStateFromRequest($context.'.filter.access', 'filter_access', 0, 'int');
$this->setState('filter.access', $access);
$published = $this->getUserStateFromRequest($context.'.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
$language = $this->getUserStateFromRequest($context.'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
// List state information.
parent::populateState('a.lft', 'asc');
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
$id .= ':'.$this->getState('filter.extension');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.language');
return parent::getStoreId($id);
}
/**
* @return string
*/
protected function getListQuery()
{
// Create a new query object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$user = JemFactory::getUser();
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.catname, a.color, a.alias, a.note, a.published, a.access' .
', a.checked_out, a.groupid, a.checked_out_time, a.created_user_id' .
', a.path, a.parent_id, a.level, a.lft, a.rgt' .
', a.language'
)
);
$query->from('#__jem_categories AS a');
// Join over the language
$query->select('l.title AS language_title');
$query->join('LEFT', $db->quoteName('#__languages').' AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Join over the users for the author.
$query->select('ua.name AS author_name');
$query->join('LEFT', '#__users AS ua ON ua.id = a.created_user_id');
// Join over the groups
$query->select('gr.name AS catgroup');
$query->join('LEFT', '#__jem_groups AS gr ON gr.id = a.groupid');
// Filter on the level.
if ($level = $this->getState('filter.level')) {
$query->where('a.level <= '.(int) $level);
}
// Filter by access level.
if ($access = $this->getState('filter.access')) {
$query->where('a.access = ' . (int) $access);
}
// Implement View Level Access
if (!$user->authorise('core.admin'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN ('.$groups.')');
}
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = ' . (int) $published);
}
elseif ($published === '') {
$query->where('(a.published IN (0, 1))');
}
$query->where('(a.alias NOT LIKE "root")');
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
elseif (stripos($search, 'author:') === 0) {
$search = $db->Quote('%'.$db->escape(substr($search, 7), true).'%');
$query->where('(ua.name LIKE '.$search.' OR ua.username LIKE '.$search.')');
}
else {
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('(a.title LIKE '.$search.' OR a.alias LIKE '.$search.' OR a.note LIKE '.$search.')');
}
}
// Filter on the language.
if ($language = $this->getState('filter.language')) {
$query->where('a.language = '.$db->quote($language));
}
// Add the list ordering clause
$listOrdering = $this->getState('list.ordering', 'a.lft');
$listDirn = $db->escape($this->getState('list.direction', 'ASC'));
if ($listOrdering == 'a.access') {
$query->order('a.access '.$listDirn.', a.lft '.$listDirn);
} else {
$query->order($db->escape($listOrdering).' '.$listDirn);
}
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
/**
*
*/
public function getItems()
{
$items = parent::getItems();
$app = Factory::getApplication();
foreach ($items as $item) {
$item->assignedevents = $this->countCatEvents($item->id);
}
return $items;
}
private function countCatEvents($id)
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query = 'SELECT COUNT(catid) as num'
.' FROM #__jem_cats_event_relations'
.' WHERE catid = '.(int)$id
.' GROUP BY catid'
;
$db->setQuery($query);
$result = $db->loadResult('catid');
return $result;
}
}

View File

@ -0,0 +1,897 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\Registry\Registry;
use Joomla\CMS\Date\Date;
/**
* Category Model
*/
class JemModelCategory extends AdminModel
{
/**
* The prefix to use with controller messages.
* @var string
*/
protected $text_prefix = 'COM_JEM_CATEGORIES';
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
* permission set in the component.
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->published != -2) {
return;
}
$user = JemFactory::getUser();
return $user->authorise('core.delete', 'com_jem');
}
}
/**
* Method to test whether a record can have its state changed.
*
* @param object $record 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();
// Check for existing category.
if (!empty($record->id)) {
return $user->authorise('core.edit.state', 'com_jem' . '.category.' . (int) $record->id);
}
// New category, so check against the parent.
elseif (!empty($record->parent_id)) {
return $user->authorise('core.edit.state', 'com_jem' . '.category.' . (int) $record->parent_id);
}
// Default to component settings if neither category nor parent known.
else {
return $user->authorise('core.edit.state', 'com_jem');
}
}
/**
* Auto-populate the model state.
*
* @Note Calling getState in this method will result in recursion.
*/
protected function populateState()
{
$app = Factory::getApplication('administrator');
$parentId = $app->input->getInt('parent_id', 0);
$this->setState('category.parent_id', $parentId);
// Load the User state.
$pk = (int) $app->input->getInt('id', 0);
$this->setState($this->getName() . '.id', $pk);
// Load the parameters.
$params = ComponentHelper::getParams('com_jem');
$this->setState('params', $params);
}
/**
* Method to get a table object, load it if necessary.
*
* @param string $type The table name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return Table A Table object
*/
public function getTable($type = 'Category', $prefix = 'JemTable', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
/**
* Method to get a category.
*
* @param integer $pk An optional id of the object to get, otherwise the id
* from the model state is used.
*
* @return mixed Category data object on success, false on failure.
*/
public function getItem($pk = null)
{
if ($result = parent::getItem($pk))
{
// Prime required properties.
if (empty($result->id)) {
$result->parent_id = $this->getState('category.parent_id');
}
// Convert the metadata field to an array.
$registry = new Registry();
$registry->loadString($result->metadata ?? '{}');
$result->metadata = $registry->toArray();
// Convert the created and modified dates to local user time for
// display in the form.
jimport('joomla.utilities.date');
$tz = new DateTimeZone(Factory::getApplication()->getCfg('offset'));
if (intval($result->created_time)) {
$date = new Date($result->created_time);
$date->setTimezone($tz);
$result->created_time = $date->toSql(true);
}
else {
$result->created_time = null;
}
if (intval($result->modified_time)) {
$date = new Date($result->modified_time);
$date->setTimezone($tz);
$result->modified_time = $date->toSql(true);
}
else {
$result->modified_time = null;
}
}
return $result;
}
/**
* Method to get the row form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
* (default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_jem.category', 'category',
array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
/**
* A protected method to get the where clause for the reorder
* This ensures that the row will be moved relative to a row with the same
* extension
*
* @param JCategoryTable $table Current table instance
*
* @return array An array of conditions to add to add to ordering queries.
*/
protected function getReorderConditionsDISABLED($table)
{
return 'extension = ' . $this->_db->Quote($table->extension);
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_jem.edit.category.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
// Initialise variables;
$dispatcher = JemFactory::getDispatcher();
$table = $this->getTable();
$jinput = Factory::getApplication()->input;
$pk = (!empty($data['id'])) ? $data['id'] : (int) $this->getState($this->getName() . '.id');
$isNew = true;
// Include the content plugins for the on save events.
PluginHelper::importPlugin('content');
// Load the row if saving an existing category.
if ($pk > 0) {
$table->load($pk);
$isNew = false;
}
// Set the new parent id if parent id not matched OR while New/Save as
// Copy .
if ($table->parent_id != $data['parent_id'] || $data['id'] == 0) {
$table->setLocation($data['parent_id'], 'last-child');
}
$data['title'] = isset($data['title']) ? $data['title'] : '';
$data['note'] = isset($data['note']) ? $data['note'] : '';
$data['language'] = isset($data['language']) ? $data['language'] : '';
$data['path'] = isset($data['path']) ? $data['path'] : '';
$data['metadata'] = isset($data['metadata']) ? $data['metadata'] : '';
// Alter the title for save as copy
if ($jinput->get('task', '') == 'save2copy') {
list ($title, $alias) = $this->generateNewTitle($data['parent_id'], $data['alias'], $data['title']);
$data['title'] = $title;
$data['alias'] = $alias;
// also reset creation date, modification fields, hit counter, version
unset($data['created_time']);
unset($data['modified_time']);
unset($data['modified_user_id']);
}
$groupid = $jinput->get('groupid', '', 'int');
$table->groupid = $groupid;
$color = $jinput->get('color', '', 'html');
if (!preg_match('/^#[0-9A-Fa-f]{6}$/', $color)) {
$color = '';
}
$table->color = $color;
// Bind the data.
if (!$table->bind($data)) {
$this->setError($table->getError());
return false;
}
// Bind the rules.
if (isset($data['rules'])) {
$rules = new JAccessRules($data['rules']);
$table->setRules($rules);
}
// Check the data.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Trigger the onContentBeforeSave event.
// $result = $dispatcher->triggerEvent($this->event_before_save, array($this->option . '.' . $this->name, &$table, $isNew));
$result = $dispatcher->triggerEvent($this->event_before_save, array($this->option . '.' . $this->name, &$table, $isNew,''));
if (in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
// Trigger the onContentAfterSave event.
$dispatcher->triggerEvent($this->event_after_save, array($this->option . '.' . $this->name, &$table, $isNew));
// Rebuild the path for the category:
if (!$table->rebuildPath($table->id)) {
$this->setError($table->getError());
return false;
}
// Rebuild the paths of the category's children:
if (!$table->rebuild($table->id, $table->lft, $table->level, $table->path)) {
$this->setError($table->getError());
return false;
}
$this->setState($this->getName() . '.id', $table->id);
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*/
public function publish(&$pks, $value = 1)
{
if (parent::publish($pks, $value)) {
// Initialise variables.
$dispatcher = JemFactory::getDispatcher();
$extension = Factory::getApplication()->input->getCmd('extension', '');
// Include the content plugins for the change of category state
// event.
PluginHelper::importPlugin('content');
// Trigger the onCategoryChangeState event.
$dispatcher->triggerEvent('onCategoryChangeState', array($extension, $pks, $value));
return true;
}
}
/**
* Method rebuild the entire nested set tree.
*
* @return boolean False on failure or error, true otherwise.
*/
public function rebuild()
{
// Get an instance of the table object.
$table = $this->getTable();
if (!$table->rebuild()) {
$this->setError($table->getError());
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Method to save the reordered nested set tree.
* First we save the new order values in the lft values of the changed ids.
* Then we invoke the table rebuild to implement the new ordering.
*
* @param array $idArray An array of primary key ids.
* @param integer $lft_array The lft value
*
* @return boolean False on failure or error, True otherwise
*/
public function saveorder($idArray = null, $lft_array = null)
{
// Get an instance of the table object.
$table = $this->getTable();
if (!$table->saveorder($idArray, $lft_array)) {
$this->setError($table->getError());
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch copy categories to a new category.
*
* @param integer $value The new category.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on failure.
*/
protected function batchCopy($value, $pks, $contexts)
{
// $value comes as {parent_id}.{extension}
$parts = explode('.', $value);
$parentId = (int) \Joomla\Utilities\ArrayHelper::getValue($parts, 0, 1);
$table = $this->getTable();
$db = Factory::getContainer()->get('DatabaseDriver');
$user = JemFactory::getUser();
$extension = Factory::getApplication()->input->get('extension', '', 'word');
$i = 0;
// 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(Text::_('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(Text::_('COM_CATEGORIES_BATCH_CANNOT_CREATE'));
return false;
}
}
// If the parent is 0, set it to the ID of the root item in the tree
if (empty($parentId)) {
if (!$parentId = $table->getRootId()) {
$this->setError($parentId->getError());
return false;
}
// Make sure we can create in root
elseif (!$user->authorise('core.create', $extension)) {
$this->setError(Text::_('COM_CATEGORIES_BATCH_CANNOT_CREATE'));
return false;
}
}
// We need to log the parent ID
$parents = array();
// Calculate the emergency stop count as a precaution against a runaway
// loop bug
$query = $db->getQuery(true);
$query->select('COUNT(id)');
$query->from($db->quoteName('#__categories'));
$db->setQuery($query);
$count = $db->loadResult();
if ($error = $count->getError()) {
$this->setError($error);
return false;
}
// Parent exists so we let's proceed
while (!empty($pks) && $count > 0)
{
// Pop the first id off the stack
$pk = array_shift($pks);
$table->reset();
// 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(Text::sprintf('JGLOBAL_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// Copy is a bit tricky, because we also need to copy the children
$query->clear();
$query->select('id');
$query->from($db->quoteName('#__categories'));
$query->where('lft > ' . (int) $table->lft);
$query->where('rgt < ' . (int) $table->rgt);
$db->setQuery($query);
$childIds = $db->loadColumn();
// Add child ID's to the array only if they aren't already there.
foreach ($childIds as $childId) {
if (!in_array($childId, $pks)) {
array_push($pks, $childId);
}
}
// Make a copy of the old ID and Parent ID
$oldId = $table->id;
$oldParentId = $table->parent_id;
// Reset the id because we are making a copy.
$table->id = 0;
// If we a copying children, the Old ID will turn up in the parents
// list
// otherwise it's a new top level item
$table->parent_id = isset($parents[$oldParentId]) ? $parents[$oldParentId] : $parentId;
// Set the new location in the tree for the node.
$table->setLocation($table->parent_id, 'last-child');
// TODO: Deal with ordering?
// $table->ordering = 1;
$table->level = null;
$table->asset_id = null;
$table->lft = null;
$table->rgt = null;
// Alter the title & alias
list ($title, $alias) = $this->generateNewTitle($table->parent_id, $table->alias, $table->catname);
$table->title = $title;
$table->alias = $alias;
// Store the row.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
// Get the new item ID
$newId = $table->get('id');
// Add the new ID to the array
$newIds[$i] = $newId;
$i++;
// Now we log the old 'parent' to the new 'parent'
$parents[$oldId] = $table->id;
$count--;
}
// Rebuild the hierarchy.
if (!$table->rebuild()) {
$this->setError($table->getError());
return false;
}
// Rebuild the tree path.
if (!$table->rebuildPath($table->id)) {
$this->setError($table->getError());
return false;
}
return $newIds;
}
/**
* 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 = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$user = JemFactory::getUser();
$extension = Factory::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(Text::_('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(Text::_('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(Text::_('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(Text::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);
\Joomla\Utilities\ArrayHelper::toInteger($children);
// Check for a database error.
// if ($db->getErrorNum()) {
// $this->setError($db->getErrorMsg());
// return false;
// }
}
return true;
}
/**
* Custom clean the cache of com_content and content modules
*
* TODO: Should this clean caches of JEM, e.g. com_jem and mod_jem* ?
*/
protected function cleanCache($group = null, $client_id = 0)
{
$extension = Factory::getApplication()->input->getCmd('extension', '');
switch ($extension)
{
case 'com_content':
parent::cleanCache('com_content');
parent::cleanCache('mod_articles_archive');
parent::cleanCache('mod_articles_categories');
parent::cleanCache('mod_articles_category');
parent::cleanCache('mod_articles_latest');
parent::cleanCache('mod_articles_news');
parent::cleanCache('mod_articles_popular');
break;
default:
parent::cleanCache($extension);
break;
}
}
/**
* Method to change the title & alias.
*
* @param integer $parent_id The id of the parent.
* @param string $alias The alias.
* @param string $title The title.
*
* @return array Contains the modified title and alias.
*/
protected function generateNewTitle($parent_id, $alias, $title)
{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias, 'parent_id' => $parent_id))) {
$title = \Joomla\String\StringHelper::increment($title);
$alias = \Joomla\String\StringHelper::increment($alias, 'dash');
}
return array($title, $alias);
}
/**
* Method to get the group data
*
* @access public
* @return boolean on success
*/
public function getGroups()
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = 'SELECT id AS value, name AS text'
. ' FROM #__jem_groups'
. ' ORDER BY name';
$db->setQuery($query);
$groups = $db->loadObjectList('value');
return $groups;
}
/**
* Method to remove a category
*
* @todo: check if finder-plugin is being triggered
* move to Candelete function
*
* @access public
* @return string $msg
*/
public function delete(&$cids)
{
\Joomla\Utilities\ArrayHelper::toInteger($cids);
// Add all children to the list
foreach ($cids as $id) {
$this->_addCategories($id, $cids);
}
$cids = implode(',', $cids);
if (strlen($cids) == 0) {
Factory::getApplication()->enqueueMessage($this->_db->stderr(), 'error');
return false;
}
$query = 'SELECT c.id, c.catname, COUNT( e.catid ) AS numcat'
. ' FROM #__jem_categories AS c'
. ' LEFT JOIN #__jem_cats_event_relations AS e ON e.catid = c.id'
. ' WHERE c.id IN (' . $cids .')' . ' GROUP BY c.id';
$this->_db->setQuery($query);
if (!($rows = $this->_db->loadObjectList())) {
Factory::getApplication()->enqueueMessage($this->_db->stderr(), 'error');
return false;
}
$err = array();
$cid = array();
// TODO: Categories and its childs without assigned items will not be
// deleted if another tree has any item entry
foreach ($rows as $row) {
if ($row->numcat == 0) {
$cid[] = $row->id;
}
else {
$err[] = $row->catname;
}
}
if (count($cid) && count($err) == 0) {
$cids = implode(',', $cid);
$query = 'DELETE FROM #__jem_categories'
. ' WHERE id IN (' . $cids . ')';
$this->_db->setQuery($query);
// TODO: use exception handling
if ($this->_db->execute() === false) {
$this->setError($this->_db->getError());
return false;
}
}
if (count($err)) {
$cids = implode(', ', $err);
$msg = Text::sprintf('COM_JEM_EVENT_ASSIGNED_CATEGORY', $cids);
return $msg;
}
else {
$total = count($cid);
$msg = Text::plural('COM_JEM_CATEGORIES_N_ITEMS_DELETED', $total);
return $msg;
}
}
/**
* Method to add children/parents to a specific category
*
* @param int $id
* @param array $list
* @param string $type
* @return object
*/
protected function _addCategories($id, &$list, $type = 'children')
{
// Initialize variables
$return = true;
if ($type == 'children') {
$get = 'id';
$source = 'parent_id';
} else {
$get = 'parent_id';
$source = 'id';
}
// Get all rows with parent of $id
$query = 'SELECT ' . $get
. ' FROM #__jem_categories'
. ' WHERE ' . $source . ' = ' . (int)$id;
$this->_db->setQuery( $query );
// Make sure there aren't any errors
// if ($this->_db->getErrorNum()) {
// $this->setError($this->_db->getErrorMsg());
// return false;
// }
try
{
$rows = $this->_db->loadObjectList();
}
catch (\InvalidArgumentException $e)
{
$this->setError($e->getMessage());
return false;
}
// Recursively iterate through all children
foreach ($rows as $row)
{
$found = false;
foreach ($list as $idx)
{
if ($idx == $row->$get) {
$found = true;
break;
}
}
if (!$found) {
$list[] = $row->$get;
}
$return = $this->_addCategories($row->$get, $list, $type);
}
return $return;
}
}

View File

@ -0,0 +1,184 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Filter\InputFilter;
/**
* Categoryelement-Model
*/
class JemModelCategoryelement extends BaseDatabaseModel
{
/**
* Pagination object
*
* @var object
*/
protected $_pagination = null;
/**
* Category id
*
* @var int
*/
protected $_id = null;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$jinput = Factory::getApplication()->input;
$array = $jinput->get('cid', 0, 'array');
if(is_array($this) && $this->setId((int)$array[0]));
}
/**
* Method to set the category identifier
*
* @access public
* @param int Category identifier
*/
public function setId($id)
{
// Set id
$this->_id = $id;
}
/**
* Method to get categories item data
*
* @access public
* @return array
*/
public function getData()
{
$app = Factory::getApplication();
$db = Factory::getContainer()->get('DatabaseDriver');
$itemid = $app->input->getInt('id', 0) . ':' . $app->input->getInt('Itemid', 0);
$limit = $app->getUserStateFromRequest('com_jem.limit', 'limit', $app->get('list_limit'), 'int');
$limitstart = $app->getUserStateFromRequest('com_jem.limitstart', 'limitstart', 0, 'int');
$limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0;
$filter_order = $app->getUserStateFromRequest('com_jem.categoryelement.filter_order', 'filter_order', 'c.lft', 'cmd');
$filter_order_Dir = $app->getUserStateFromRequest('com_jem.categoryelement.filter_order_Dir', 'filter_order_Dir', '', 'word');
$filter_state = $app->getUserStateFromRequest('com_jem.categoryelement.'.$itemid.'.filter_state', 'filter_state', '', 'string');
$search = $app->getUserStateFromRequest('com_jem.categoryelement.'.$itemid.'.filter_search', 'filter_search', '', 'string');
$search = $db->escape(trim(\Joomla\String\StringHelper::strtolower($search)));
$filter_order = InputFilter::getinstance()->clean($filter_order, 'cmd');
$filter_order_Dir = InputFilter::getinstance()->clean($filter_order_Dir, 'word');
$orderby = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir;
$state = array(1);
if (is_numeric($filter_state)) {
$where = ' WHERE c.published = '.(int) $filter_state;
} else {
$where = ' WHERE c.published IN (' . implode(',', $state) . ')';
//$where .= ' AND c.alias NOT LIKE "root"';
}
$where2 = ' AND c.published IN (' . implode(',', $state) . ')';
//$where2 .= ' AND c.alias NOT LIKE "root"';
// select the records
// note, since this is a tree we have to do the limits code-side
if ($search) {
$query = 'SELECT c.id FROM #__jem_categories AS c' . ' WHERE LOWER(c.catname) LIKE ' . $db->Quote('%' . $this->_db->escape($search, true) . '%', false) . $where2;
$db->setQuery($query);
$search_rows = $db->loadColumn();
}
$query = 'SELECT c.*, u.name AS editor, g.title AS groupname, gr.name AS catgroup'
. ' FROM #__jem_categories AS c' . ' LEFT JOIN #__viewlevels AS g ON g.id = c.access'
. ' LEFT JOIN #__users AS u ON u.id = c.checked_out'
. ' LEFT JOIN #__jem_groups AS gr ON gr.id = c.groupid'
. $where
// . ' ORDER BY c.parent_id, c.ordering';
. $orderby;
// Check for a database error.
// if ($db->getErrorNum()) {
// Factory::getApplication()->enqueueMessage($db->getErrorMsg(), 'notice');
// }
try
{
$db->setQuery($query);
$mitems = $db->loadObjectList();
}
catch (RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'notice');
}
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);
// eventually only pick out the searched items.
if ($search) {
$list1 = array();
foreach ($search_rows as $sid) {
foreach ($list as $item) {
if ($item->id == $sid) {
$list1[] = $item;
}
}
}
// replace full list with found items
$list = $list1;
}
$total = count($list);
$this->_pagination = new Pagination($total, $limitstart, $limit);
// slice out elements based on limits
$list = array_slice($list, $this->_pagination->limitstart, $this->_pagination->limit);
return $list;
}
public function getPagination()
{
if ($this->_pagination == null) {
$this->getItems();
}
return $this->_pagination;
}
}
?>

View File

@ -0,0 +1,161 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Filter\InputFilter;
jimport('joomla.application.component.model');
/**
* Contactelement-Model
*/
class JemModelContactelement extends BaseDatabaseModel
{
///**
// * Category data array
// *
// * @var array
// */
//protected $_data = null;
///**
// * Category total
// *
// * @var integer
// */
//protected $_total = null;
///**
// * Pagination object
// *
// * @var object
// */
//protected $_pagination = null;
///**
// * Categorie id
// *
// * @var int
// */
//protected $_id = null;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$app = Factory::getApplication();
$limit = $app->getUserStateFromRequest( 'com_jem.limit', 'limit', $app->get('list_limit'), 'int');
$limitstart = $app->getUserStateFromRequest( 'com_jem.limitstart', 'limitstart', 0, 'int' );
$limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0;
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
/**
* Method to get data
*/
public function getData()
{
$query = $this->buildQuery();
$pagination = $this->getPagination();
$rows = $this->_getList($query, $pagination->limitstart, $pagination->limit);
return $rows;
}
/**
* Query
*/
protected function buildQuery()
{
$app = Factory::getApplication();
$filter_order = $app->getUserStateFromRequest( 'com_jem.contactelement.filter_order','filter_order','con.ordering','cmd');
$filter_order_Dir = $app->getUserStateFromRequest( 'com_jem.contactelement.filter_order_Dir','filter_order_Dir','','word' );
$filter_order = InputFilter::getinstance()->clean($filter_order, 'cmd');
$filter_order_Dir = InputFilter::getinstance()->clean($filter_order_Dir, 'word');
$filter_type = $app->getUserStateFromRequest('com_jem.contactelement.filter_type','filter_type',0,'int');
$search = $app->getUserStateFromRequest('com_jem.contactelement.filter_search','filter_search','','string');
$search = $this->_db->escape( trim(\Joomla\String\StringHelper::strtolower( $search ) ) );
// start query
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select(array('con.*'));
$query->from('#__contact_details as con');
// where
$where = array();
$where[] = 'con.published = 1';
// search
if ($search) {
switch ($filter_type) {
case 1: /* name */
$where[] = 'LOWER(con.name) LIKE \'%'.$search.'%\' ';
break;
case 2: /* address */
$where[] = 'LOWER(con.address) LIKE \'%'.$search.'%\' ';
break;
case 3: /* city */
$where[] = 'LOWER(con.suburb) LIKE \'%'.$search.'%\' ';
break;
case 4: /* state */
$where[] = 'LOWER(con.state) LIKE \'%'.$search.'%\' ';
break;
}
}
$query->where($where);
// order
if ($filter_order != '') {
$orderby = $filter_order . ' ' . $filter_order_Dir;
} else {
$orderby = 'con.name';
}
$query->order($orderby);
return $query;
}
/**
* Method to get a pagination object for the contactelement
*
* @access public
* @return integer
*/
public function getPagination()
{
$limit = $this->getState('limit');
$limitstart = $this->getState('limitstart');
$query = $this->buildQuery();
$total = $this->_getListCount($query);
// Create the pagination object
$pagination = new Pagination($total, $limitstart, $limit);
return $pagination;
}
}
?>

View File

@ -0,0 +1,191 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Filesystem\Path;
/**
* Model-CSSManager
*/
class JemModelCssmanager extends BaseDatabaseModel
{
/**
* Internal method to get file properties.
*
* @param string The base path.
* @param string The file name.
* @return object
*/
protected function getFile($path, $name)
{
$temp = new stdClass;
$temp->name = $name;
$temp->exists = file_exists($path.$name);
$temp->id = base64_encode($name);
if ($temp->exists) {
$ext = File::getExt($path.$name);
if ($ext != 'css') {
# the file is valid but the extension not so let's return false
$temp->ext = false;
} else {
$temp->ext = true;
}
}
return $temp;
}
/**
* Internal method to get file properties.
*
* @param string The base path.
* @param string The file name.
* @return object
*/
protected function getCustomFile($path, $name)
{
$temp = new stdClass;
$temp->name = $name;
$temp->exists = file_exists($path.$name);
$filename = 'custom#:'.$name;
$temp->id = base64_encode($filename);
if ($temp->exists) {
$ext = File::getExt($path.$name);
if ($ext != 'css') {
# the file is valid but the extension not so let's return false
$temp->ext = false;
} else {
$temp->ext = true;
}
}
return $temp;
}
/**
* Method to get a list of all the files to edit in a template.
*
* @return array A nested array of relevant files.
*/
public function getFiles()
{
// Initialise variables.
$result = array();
$path = Path::clean(JPATH_ROOT.'/media/com_jem/');
// Check if the template path exists.
if (is_dir($path)) {
// Handle the CSS files.
$files = Folder::files($path.'/css', '\.css$', false, false);
foreach ($files as $file) {
$result['css'][] = $this->getFile($path.'/css/', $file);
}
} else {
$this->setError(Text::_('COM_JEM_CSSMANAGER_ERROR_CSS_FOLDER_NOT_FOUND'));
return false;
}
# define array with custom css files
$settings = JemHelper::retrieveCss();
$custom = array();
$custom[] = $settings->get('css_backend_customfile');
$custom[] = $settings->get('css_calendar_customfile');
$custom[] = $settings->get('css_colorpicker_customfile');
$custom[] = $settings->get('css_geostyle_customfile');
$custom[] = $settings->get('css_googlemap_customfile');
$custom[] = $settings->get('css_jem_customfile');
$custom[] = $settings->get('css_print_customfile');
foreach ($custom as $cfile)
{
if ($cfile) {
$rf = $this->getCustomFile($path.'css/custom/',$cfile);
if ($rf->exists && $rf->ext) {
$result['custom'][] = $rf;
}
}
}
return $result;
}
/**
* Method to auto-populate the model state.
*
* @Note Calling getState in this method will result in recursion.
*/
protected function populateState()
{
$app = Factory::getApplication('administrator');
// Load the parameters.
$params = ComponentHelper::getParams('com_jem');
$this->setState('params', $params);
}
/**
* Detect if option linenumbers is enabled
* plugin: codemirror
*/
public function getStatusLinenumber()
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('params');
$query->from('#__extensions');
$query->where(array("type = 'plugin'", "element = 'codemirror'"));
$db->setQuery($query);
$manifest = json_decode($db->loadResult(), true);
return array_key_exists('linenumbers', $manifest) ? $manifest['linenumbers'] : false;
}
/**
* Sets parameter values in the component's row of the extension table
*
* @param $param_array An array holding the params to store
*/
public function setStatusLinenumber($status)
{
// read the existing component value(s)
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('params')
->from('#__extensions')
->where(array("type = 'plugin'", "element = 'codemirror'"));
$db->setQuery($query);
$params = json_decode($db->loadResult(), true);
$params['linenumbers'] = $status;
// store the combined new and existing values back as a JSON string
$paramsString = json_encode($params);
$query = $db->getQuery(true);
$query->update('#__extensions')
->set('params = '.$db->quote($paramsString))
->where(array("type = 'plugin'", "element = 'codemirror'"));
$db->setQuery($query);
$db->execute();
}
}
?>

View File

@ -0,0 +1,854 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Registry\Registry;
use Joomla\CMS\Log\Log;
require_once __DIR__ . '/admin.php';
/**
* Event model.
*/
class JemModelEvent extends JemModelAdmin
{
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 2.2.2
*/
public function publish(&$pks, $value = 1)
{
// Additionally include the JEM plugins for the onContentChangeState event.
PluginHelper::importPlugin('jem');
return parent::publish($pks, $value);
}
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
*/
protected function canDelete($record)
{
$result = false;
if (!empty($record->id) && ($record->published == -2)) {
$user = JemFactory::getUser();
$result = $user->can('delete', 'event', $record->id, $record->created_by, !empty($record->catid) ? $record->catid : false);
}
return $result;
}
/**
* Method to test whether a record can be published/unpublished.
*
* @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();
$id = isset($record->id) ? $record->id : false; // isset ensures 0 !== false
$owner = !empty($record->created_by) ? $record->created_by : false;
$cats = !empty($record->catid) ? array($record->catid) : false;
return $user->can('publish', 'event', $id, $owner, $cats);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional.
* @return Table A database object
*/
public function getTable($type = 'Event', $prefix = 'JemTable', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return mixed A JForm object on success, false on failure
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_jem.event', 'event', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
/**
* Method to get a single record.
*
* @param integer The id of the primary key.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($pk = null)
{
$jemsettings = JemAdmin::config();
if ($item = parent::getItem($pk)){
// Convert the params field to an array.
// (this may throw an exception - but there is nothings we can do)
$registry = new Registry;
$registry->loadString($item->attribs ?? '{}');
$item->attribs = $registry->toArray();
// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($item->metadata ?? '{}');
$item->metadata = $registry->toArray();
$item->articletext = ($item->fulltext && trim($item->fulltext) != '') ? $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext : $item->introtext;
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('SUM(places)');
$query->from('#__jem_register');
$query->where(array('event= '.$db->quote($item->id), 'status=1', 'waiting=0'));
$db->setQuery($query);
$res = $db->loadResult();
$item->booked = $res;
$files = JemAttachment::getAttachments('event'.$item->id);
$item->attachments = $files;
if ($item->id){
// Store current recurrence values
$item->recurr_bak = new stdClass;
foreach (get_object_vars($item) as $k => $v) {
if (strncmp('recurrence_', $k, 11) === 0) {
$item->recurr_bak->$k = $v;
}
}
}
$item->author_ip = $jemsettings->storeip ? JemHelper::retrieveIP() : false;
if (empty($item->id)){
$item->country = $jemsettings->defaultCountry;
}
}
return $item;
}
/**
* Method to get the data that should be injected in the form.
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_jem.edit.event.data', array());
if (empty($data)){
$data = $this->getItem();
}
return $data;
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param $table Table-object.
*/
protected function _prepareTable($table)
{
$jinput = Factory::getApplication()->input;
$db = Factory::getContainer()->get('DatabaseDriver');
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
// Increment version number.
$table->version ++;
//get time-values from time selectlist and combine them accordingly
$starthours = $jinput->get('starthours','','cmd');
$startminutes = $jinput->get('startminutes','','cmd');
$endhours = $jinput->get('endhours','','cmd');
$endminutes = $jinput->get('endminutes','','cmd');
// StartTime
if ($starthours != '' && $startminutes != '') {
$table->times = $starthours.':'.$startminutes;
} else if ($starthours != '' && $startminutes == '') {
$startminutes = "00";
$table->times = $starthours.':'.$startminutes;
} else if ($starthours == '' && $startminutes != '') {
$starthours = "00";
$table->times = $starthours.':'.$startminutes;
} else {
$table->times = "";
}
// EndTime
if ($endhours != '' && $endminutes != '') {
$table->endtimes = $endhours.':'.$endminutes;
} else if ($endhours != '' && $endminutes == '') {
$endminutes = "00";
$table->endtimes = $endhours.':'.$endminutes;
} else if ($endhours == '' && $endminutes != '') {
$endhours = "00";
$table->endtimes = $endhours.':'.$endminutes;
} else {
$table->endtimes = "";
}
}
/**
* Method to save the form data.
*
* @param $data array
*/
public function save($data)
{
// Variables
$app = Factory::getApplication();
$jinput = $app->input;
$jemsettings = JemHelper::config();
$table = $this->getTable();
// Check if we're in the front or back
$backend = (bool)$app->isClient('administrator');
$new = (bool)empty($data['id']);
// Variables
$cats = $data['cats'];
$invitedusers = isset($data['invited']) ? $data['invited'] : '';
$recurrencenumber = $jinput->get('recurrence_number', '', 'int');
$recurrencebyday = $jinput->get('recurrence_byday', '', 'string');
$metakeywords = $jinput->get('meta_keywords', '', '');
$metadescription = $jinput->get('meta_description', '', '');
$task = $jinput->get('task', '', 'cmd');
$data['metadata'] = isset($data['metadata']) ? $data['metadata'] : '';
$data['attribs'] = isset($data['attribs']) ? $data['attribs'] : '';
$data['ordering'] = isset($data['ordering']) ? $data['ordering'] : '';
// convert international date formats...
$db = Factory::getContainer()->get('DatabaseDriver');
if (!empty($data['dates']) && ($data['dates'] != null)) {
$d = Factory::getDate($data['dates'], 'UTC');
$data['dates'] = $d->format('Y-m-d', true, false);
}
if (!empty($data['enddates']) && ($data['enddates'] != null)) {
$d = Factory::getDate($data['enddates'], 'UTC');
$data['enddates'] = $d->format('Y-m-d', true, false);
}
if (!empty($data['recurrence_limit_date']) && ($data['recurrence_limit_date'] != null)) {
$d = Factory::getDate($data['recurrence_limit_date'], 'UTC');
$data['recurrence_limit_date'] = $d->format('Y-m-d', true, false);
}
// Load the event from db, detect if the event isn't new and is recurrence type.
// In this case, the event just needs to be updated if the recurrence setting hasn't changed.
$save = true;
if(!$new && $data["recurrence_type"]) {
// This is event exist in event table and it's recurrence
$save = false;
$this->eventid = $data["id"];
// Get data event in DB
$eventdb = (array)$this->getEventAllData();
// Categories
$eventdb ['cats'] = $this->getEventCats();
if(isset($data['cats'][0])){
$data['cats'] = implode(',', $data['cats']);
}
// Times
if ($_REQUEST['starthours']){
$starthours = $jinput->get('starthours', '', 'int');
$startminutes = $jinput->get('startminutes', '', 'int');
if ($startminutes){
$data['times'] = str_pad($starthours,2,'0', STR_PAD_LEFT) . ':' . str_pad($startminutes,2,'0', STR_PAD_LEFT) . ':00';
} else {
$data['times'] = str_pad($starthours,2,'0', STR_PAD_LEFT) . ':00:00';
}
} else {
$data['times'] = null;
}
//Endtimes
if ($_REQUEST['endhours']){
$endhours = $jinput->get('endhours', '', 'int');
$endminutes = $jinput->get('endminutes', '', 'int');
if ($endminutes){
$data['endtimes'] = str_pad($endhours,2,'0', STR_PAD_LEFT) . ':' . str_pad($endminutes,2,'0', STR_PAD_LEFT) . ':00';
} else {
$data['endtimes'] = str_pad($endhours,2,'0', STR_PAD_LEFT) . ':00:00';
}
} else {
$data['endtimes'] = null;
}
// Alias
if(isset($data['alias'])) {
if (!$data['alias']) {
$alias = strtolower($data['title']);
$alias = preg_replace('/[^a-z0-9]+/i', '-', $alias);
$alias = preg_replace('/-+/', '-', $alias);
$data['alias'] = trim($alias, '-');
}
}else{
$data['alias'] = $eventdb['alias'];
}
// Introtext
$data['introtext'] = $data['articletext'];
// Contact
if($data['contactid'] == ''){
$data['contactid'] = 0;
}
// Times <= Endtimes
if($data['enddates']!== null && $data['enddates'] != ''){
if($data['dates'] > $data['enddates']){
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_EVENT_ERROR_END_BEFORE_START_DATES') . ' [ID:' . $data['id'] . ']', 'error');
return false;
} else {
if($data['dates'] == $data['enddates']){
if($data['endtimes'] !== null && $data['endtimes'] != '') {
if ($data['times'] > $data['endtimes']) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_EVENT_ERROR_END_BEFORE_START_TIMES') . ' [ID:' . $data['id'] . ']', 'error');
return false;
}
}
}
}
}
// Get the fields changed
$diff = array_diff_assoc($data, $eventdb);
//If $diff contains some of fields (Defined in $fieldNotAllow) then dissolve recurrence and save again serie
//If not, update de field of this event (save=false).
$fieldNotAllow = ['recurrence_first_id', 'recurrence_number', 'recurrence_type', 'recurrence_counter', 'recurrence_limit', 'recurrence_limit_date', 'recurrence_byday'];
foreach ($diff as $d => $value) {
if (in_array($d, $fieldNotAllow)) {
// This event must be updated its fields
$data[$d] = $value;
$save = true;
}
}
// If $save is true and recurrence_first_id != 0 then this event must be the first event of a new recurrence (series)
if($save){
if($eventdb['recurrence_first_id'] != 0) {
// Convert to root event
$data['recurrence_first_id'] = 0;
// Copy the recurrence data if it doesn't exist
if (!isset($data['recurrence_number'])) {
$data['recurrence_number'] = $eventdb['recurrence_number'];
}
if (!isset($data['recurrence_type'])) {
$data['recurrence_type'] = $eventdb['recurrence_type'];
}
if (!isset($data['recurrence_counter'])) {
$data['recurrence_counter'] = $eventdb['recurrence_counter'];
}
if (!isset($data['recurrence_limit'])) {
$data['recurrence_limit'] = $eventdb['recurrence_limit'];
}
if (!isset($data['recurrence_limit_date'])) {
$data['recurrence_limit_date'] = $eventdb['recurrence_limit_date'];
}
if (!isset($data['recurrence_byday'])) {
$data['recurrence_byday'] = $eventdb['recurrence_byday'];
}
}
}
}
if($save) {
// set to null if registration is empty
if($data['registra_from'] == ''){
$data['registra_from'] = null;
}
if($data['registra_until'] == ''){
$data['registra_until'] = null;
}
if($data['unregistra_until'] == ''){
$data['unregistra_until'] = null;
}
if($data['reginvitedonly']== null){
$data['reginvitedonly'] = 0;
}
// event maybe first of recurrence set -> dissolve complete set
if (JemHelper::dissolve_recurrence($data['id'])) {
$this->cleanCache();
}
if ($data['dates'] == null || $data['recurrence_type'] == '0') {
$data['recurrence_number'] = '0';
$data['recurrence_byday'] = '0';
$data['recurrence_counter'] = '0';
$data['recurrence_type'] = '0';
$data['recurrence_limit'] = '0';
$data['recurrence_limit_date'] = null;
$data['recurrence_first_id'] = '0';
} else {
if (!$new) {
// edited event maybe part of a recurrence set
// -> drop event from set
$data['recurrence_first_id'] = '0';
$data['recurrence_counter'] = '0';
}
$data['recurrence_number'] = $recurrencenumber;
$data['recurrence_byday'] = $recurrencebyday;
if (!empty($data['recurrence_limit_date']) && ($data['recurrence_limit_date'] != null)) {
$d = Factory::getDate($data['recurrence_limit_date'], 'UTC');
$data['recurrence_limit_date'] = $d->format('Y-m-d', true, false);
}
}
$data['meta_keywords'] = $metakeywords;
$data['meta_description'] = $metadescription;
// Store IP of author only.
if ($new) {
$author_ip = $jinput->get('author_ip', '', 'string');
$data['author_ip'] = $author_ip;
}
// Store as copy - reset creation date, modification fields, hit counter, version
if ($task == 'save2copy') {
unset($data['created']);
unset($data['modified']);
unset($data['modified_by']);
unset($data['version']);
unset($data['hits']);
}
// Save the event
$saved = parent::save($data);
if ($saved) {
// At this point we do have an id.
$pk = $this->getState($this->getName() . '.id');
if (isset($data['featured'])) {
$this->featured($pk, $data['featured']);
}
// on frontend attachment uploads maybe forbidden
// so allow changing name or description only
$allowed = $backend || ($jemsettings->attachmentenabled > 0);
if ($allowed) {
// attachments, new ones first
$attachments = $jinput->files->get('attach', array(), 'array');
$attach_name = $jinput->post->get('attach-name', array(), 'array');
$attach_descr = $jinput->post->get('attach-desc', array(), 'array');
$attach_access = $jinput->post->get('attach-access', array(), 'array');
foreach ($attachments as $n => &$a) {
$a['customname'] = array_key_exists($n, $attach_access) ? $attach_name[$n] : '';
$a['description'] = array_key_exists($n, $attach_access) ? $attach_descr[$n] : '';
$a['access'] = array_key_exists($n, $attach_access) ? $attach_access[$n] : '';
}
JemAttachment::postUpload($attachments, 'event' . $pk);
}
// and update old ones
$old = array();
$old['id'] = $jinput->post->get('attached-id', array(), 'array');
$old['name'] = $jinput->post->get('attached-name', array(), 'array');
$old['description'] = $jinput->post->get('attached-desc', array(), 'array');
$old['access'] = $jinput->post->get('attached-access', array(), 'array');
foreach ($old['id'] as $k => $id) {
$attach = array();
$attach['id'] = $id;
$attach['name'] = $old['name'][$k];
$attach['description'] = $old['description'][$k];
if ($allowed) {
$attach['access'] = $old['access'][$k];
} // else don't touch this field
JemAttachment::update($attach);
}
// Store cats
if (!$this->_storeCategoriesSelected($pk, $cats, !$backend, $new)) {
// JemHelper::addLogEntry('Error storing categories for event ' . $pk, __METHOD__, Log::ERROR);
$this->setError(Text::_('COM_JEM_EVENT_ERROR_STORE_CATEGORIES'));
$saved = false;
}
// Store invited users (frontend only, on backend no attendees on editevent view)
if (!$backend && ($jemsettings->regallowinvitation == 1)) {
if (!$this->_storeUsersInvited($pk, $invitedusers, !$backend, $new)) {
// JemHelper::addLogEntry('Error storing users invited for event ' . $pk, __METHOD__, Log::ERROR);
$this->setError(Text::_('COM_JEM_EVENT_ERROR_STORE_INVITED_USERS'));
$saved = false;
}
}
// check for recurrence
// when filled it will perform the cleanup function
$table->load($pk);
if (($table->recurrence_number > 0) && ($table->dates != null)) {
JemHelper::cleanup(2); // 2 = force on save, needs special attention
}
}
}else{
// Update field of this event
$fieldAllow=['title', 'locid', 'cats', 'dates', 'enddates', 'times', 'endtimes', 'title', 'alias', 'modified', 'modified_by', 'version', 'author_ip', 'created', 'introtext', 'meta_keywords', 'meta_description', 'datimage', 'checked_out', 'checked_out_time', 'registra', 'registra_from', 'registra_until', 'unregistra', 'unregistra_until', 'maxplaces', 'minbookeduser', 'maxbookeduser', 'reservedplaces', 'waitinglist', 'requestanswer', 'seriesbooking', 'singlebooking', 'published', 'contactid', 'custom1', 'custom2', 'custom3', 'custom4', 'custom5', 'custom6', 'custom7', 'custom8', 'custom9', 'custom10', 'fulltext', 'created_by_alias', 'access', 'featured', 'language'];
$saved = true;
$fieldsupdated="";
foreach ($diff as $d => $value){
if(in_array($d, $fieldAllow)) {
$this->updateField($data['id'], $d, $value);
$fieldsupdated = $fieldsupdated . ($fieldsupdated!=''? ', ':'') . $d;
}
}
if($fieldsupdated!='') {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_EVENT_FIELDS_EVENT_UPDATED') . ' ' . $fieldsupdated . ' [ID:' . $data['id'] . ']', 'info');
}
$table->load($data['id']);
if (isset($table->id)) {
$this->setState($this->getName() . '.id', $table->id);
}
}
return $saved;
}
/**
* Get event all data
*
* @access public
* @return object
*/
public function getEventAllData()
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('*');
$query->from('#__jem_events');
$query->where('id = '.$db->Quote($this->eventid));
$db->setQuery( $query );
$event = $db->loadObject();
return $event;
}
/**
* Get categories of event
*
* @access public
* @return string
*/
public function getEventCats()
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('GROUP_CONCAT(catid) as cats');
$query->from('#__jem_cats_event_relations');
$query->where('itemid = '.$db->Quote($this->eventid));
$db->setQuery( $query );
$cats = $db->loadResult();
return $cats;
}
/**
* Method to update cats_event_selections table.
* Records of previously selected categories will be removed
* and newly selected categories will be stored.
* Because user may not have permissions for all categories on frontend
* records with non-permitted categories will be untouched.
*
* @param int The event id.
* @param array The categories user has selected.
* @param bool Flag to indicate if we are on frontend
* @param bool Flag to indicate new event
*
* @return boolean True on success.
*/
protected function _storeCategoriesSelected($eventId, $categories, $frontend, $new)
{
$user = JemFactory::getUser();
$db = Factory::getContainer()->get('DatabaseDriver');
$eventId = (int)$eventId;
if (empty($eventId) || !is_array($categories)) {
return false;
}
// get previous entries
$query = $db->getQuery(true);
$query->select('catid')
->from('#__jem_cats_event_relations')
->where('itemid = ' . $eventId)
->order('catid');
$db->setQuery($query);
$cur_cats = $db->loadColumn();
if (!is_array($cur_cats)) {
return false;
}
$ret = true;
$del_cats = array_diff($cur_cats, $categories);
$add_cats = array_diff($categories, $cur_cats);
/* Attention!
* On frontend user maybe not permitted to see all categories attached.
* But these categories must not removed from this event!
*/
if ($frontend) {
// Note: JFormFieldCatOptions calls the same function to know which categories user is allowed (un)select.
$limit_cats = array_keys($user->getJemCategories($new ? array('add') : array('add', 'edit'), 'event'));
$del_cats = array_intersect($del_cats, $limit_cats);
$add_cats = array_intersect($add_cats, $limit_cats);
}
if (!empty($del_cats)) {
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__jem_cats_event_relations'));
$query->where('itemid = ' . $eventId);
$query->where('catid IN (' . implode(',', $del_cats) . ')');
$db->setQuery($query);
$ret &= ($db->execute() !== false);
}
if (!empty($add_cats)) {
$query = $db->getQuery(true);
$query->insert($db->quoteName('#__jem_cats_event_relations'))
->columns($db->quoteName(array('catid', 'itemid','ordering')));
foreach ($add_cats as $catid) {
$query->values((int)$catid . ',' . $eventId.','.'0');
}
$db->setQuery($query);
$ret &= ($db->execute() !== false);
}
return $ret;
}
/**
* Method to update cats_event_selections table.
* Records of previously selected categories will be removed
* and newly selected categories will be stored.
* Because user may not have permissions for all categories on frontend
* records with non-permitted categories will be untouched.
*
* @param int The event id.
* @param mixed The user ids as array or comma separated string.
* @param bool Flag to indicate if we are on frontend
* @param bool Flag to indicate new event
*
* @return boolean True on success.
*/
protected function _storeUsersInvited($eventId, $users, $frontend, $new)
{
$eventId = (int)$eventId;
if (!is_array($users)) {
$users = explode(',', $users);
}
$users = array_unique($users);
$users = array_filter($users);
if (empty($eventId)) {
return false;
}
$db = Factory::getContainer()->get('DatabaseDriver');
# Get current registrations
$query = $db->getQuery(true);
$query->select(array('reg.id, reg.uid, reg.status, reg.waiting'));
$query->from('#__jem_register As reg');
$query->where('reg.event = ' . $eventId);
$db->setQuery($query);
$regs = $db->loadObjectList('uid');
PluginHelper::importPlugin('jem');
$dispatcher = JemFactory::getDispatcher();
# Add new records, ignore users already registered
foreach ($users AS $user)
{
if (!array_key_exists($user, $regs)) {
$query = $db->getQuery(true);
$query->insert('#__jem_register');
$query->columns(array('event', 'uid', 'status'));
$query->values($eventId.','.$user.',0');
$db->setQuery($query);
try {
$ret = $db->execute();
} catch (Exception $e) {
JemHelper::addLogEntry('Exception: '. $e->getMessage(), __METHOD__, Log::ERROR);
$ret = false;
}
if ($ret !== false) {
$id = $db->insertid();
$dispatcher->triggerEvent('onEventUserRegistered', array($id));
}
}
}
# Remove obsolete invitations
foreach ($regs as $reg)
{
if (($reg->status == 0) && (array_search($reg->uid, $users) === false)) {
$query = $db->getQuery(true);
$query->delete('#__jem_register');
$query->where('id = '.$reg->id);
$db->setQuery($query);
try {
$ret = $db->execute();
} catch (Exception $e) {
JemHelper::addLogEntry('Exception: '. $e->getMessage(), __METHOD__, Log::ERROR);
$ret = false;
}
if ($ret !== false) {
$dispatcher->triggerEvent('onEventUserUnregistered', array($eventId, $reg));
}
}
}
$cache = Factory::getCache('com_jem');
$cache->clean();
return true;
}
/**
* Method to toggle the featured setting of articles.
*
* @param array The ids of the items to toggle.
* @param int The value to toggle to.
*
* @return boolean True on success.
*/
public function featured($pks, $value = 0)
{
// Sanitize the ids.
$pks = (array)$pks;
\Joomla\Utilities\ArrayHelper::toInteger($pks);
if (empty($pks)) {
$this->setError(Text::_('COM_JEM_EVENTS_NO_ITEM_SELECTED'));
return false;
}
try {
$db = Factory::getContainer()->get('DatabaseDriver');
$db->setQuery(
'UPDATE #__jem_events' .
' SET featured = '.(int) $value.
' WHERE id IN ('.implode(',', $pks).')'
);
$db->execute() ;
} catch (Exception $e) {
$this->setError($e->getMessage());
return false;
}
$this->cleanCache();
return true;
}
/**
* Method to update the field in the events table.
*
* @param int The id of event.
* @param string The field of event table.
* @param string The value of field (to update).
*
* @return boolean True on success.
*/
public function updateField($eventid, $field, $value)
{
// Sanitize the ids.
$eventid = (int)$eventid;
if (empty($eventid)) {
$this->setError(Text::_('COM_JEM_EVENTS_NO_ITEM_SELECTED'));
return false;
}
try {
$db = Factory::getContainer()->get('DatabaseDriver');
if($field == 'cats'){
$cats = explode (',', $value);
// Delete all old categories for id event
$db->setQuery('DELETE FROM #__jem_cats_event_relations WHERE itemid = ' . $db->quote($eventid) );
$db->execute();
// Insert new categories for id event
foreach($cats as $c){
$db->setQuery('INSERT INTO #__jem_cats_event_relations (catid, itemid, ordering) VALUES (' . $c . ',' . $db->quote($eventid) . ',0)');
$db->execute();
}
} else {
// Update the value of field into events table
$db->setQuery('UPDATE #__jem_events SET ' . $field . ' = ' . ($value!==null ? $db->quote($value) : 'null') . ' WHERE id = ' . $db->quote($eventid));
$db->execute();
}
} catch (Exception $e) {
$this->setError($e->getMessage());
return false;
}
$this->cleanCache();
return true;
}
}

View File

@ -0,0 +1,241 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Filter\InputFilter;
/**
* Eventelement Model
*/
class JemModelEventelement extends BaseDatabaseModel
{
/**
* Events data array
*
* @var array
*/
protected $_data = null;
/**
* Events total
*
* @var integer
*/
protected $_total = null;
/**
* Pagination object
*
* @var object
*/
protected $_pagination = null;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$app = Factory::getApplication();
$limit = $app->getUserStateFromRequest( 'com_jem.limit', 'limit', $app->get('list_limit'), 'int');
$limitstart = $app->getUserStateFromRequest( 'com_jem.limitstart', 'limitstart', 0, 'int' );
$limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0;
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
/**
* Method to get categories item data
*
* @access public
* @return array
*/
public function getData()
{
// Lets load the content if it doesn't already exist
if (empty($this->_data))
{
$query = $this->_buildQuery();
$this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
if (is_array($this->_data)) {
foreach ($this->_data as $item) {
$item->categories = $this->getCategories($item->id);
//remove events without categories (users have no access to them)
if (empty($item->categories)) {
unset($this->_data[$i]);
}
}
}
}
return $this->_data;
}
/**
* Total nr of events
*
* @access public
* @return integer
*/
public function getTotal()
{
// Lets load the content if it doesn't already exist
if (empty($this->_total))
{
$query = $this->_buildQuery();
$this->_total = $this->_getListCount($query);
}
return $this->_total;
}
/**
* Method to get a pagination object for the events
*
* @access public
* @return integer
*/
public function getPagination()
{
// Lets load the content if it doesn't already exist
if (empty($this->_pagination))
{
$this->_pagination = new Pagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_pagination;
}
/**
* Build the query
*
* @access protected
* @return string
*/
protected function _buildQuery()
{
// Get the WHERE and ORDER BY clauses for the query
$where = $this->_buildContentWhere();
$orderby = $this->_buildContentOrderBy();
$query = 'SELECT a.*, loc.venue, loc.city,c.catname'
. ' FROM #__jem_events AS a'
. ' LEFT JOIN #__jem_venues AS loc ON loc.id = a.locid'
. ' LEFT JOIN #__jem_cats_event_relations AS rel ON rel.itemid = a.id'
. ' LEFT JOIN #__jem_categories AS c ON c.id = rel.catid'
. $where
. ' GROUP BY a.id'
. $orderby
;
return $query;
}
/**
* Build the order clause
*
* @access protected
* @return string
*/
protected function _buildContentOrderBy()
{
$app = Factory::getApplication();
$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_order = InputFilter::getInstance()->clean($filter_order, 'cmd');
$filter_order_Dir = InputFilter::getInstance()->clean($filter_order_Dir, 'word');
$orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir.', a.dates';
return $orderby;
}
/**
* Build the where clause
*
* @access protected
* @return string
*/
protected function _buildContentWhere()
{
$app = Factory::getApplication();
$user = JemFactory::getUser();
$levels = $user->getAuthorisedViewLevels();
$itemid = $app->input->getInt('id', 0) . ':' . $app->input->getInt('Itemid', 0);
$published = $app->getUserStateFromRequest('com_jem.eventelement.'.$itemid.'.filter_state', 'filter_state', '', 'string');
$filter_type = $app->getUserStateFromRequest('com_jem.eventelement.'.$itemid.'.filter_type', 'filter_type', 0, 'int');
$filter_search = $app->getUserStateFromRequest('com_jem.eventelement.'.$itemid.'.filter_search', 'filter_search', '', 'string');
$filter_search = $this->_db->escape(trim(\Joomla\String\StringHelper::strtolower($filter_search)));
$where = array();
// Filter by published state
if (is_numeric($published)) {
$where[] = 'a.published = '.(int) $published;
} elseif ($published === '') {
$where[] = '(a.published IN (1))';
}
$where[] = ' c.published = 1';
$where[] = ' c.access IN (' . implode(',', $levels) . ')';
if (!empty($filter_search)) {
switch ($filter_type) {
case 1:
$where[] = ' LOWER(a.title) LIKE \'%'.$filter_search.'%\' ';
break;
case 2:
$where[] = ' LOWER(loc.venue) LIKE \'%'.$filter_search.'%\' ';
break;
case 3:
$where[] = ' LOWER(loc.city) LIKE \'%'.$filter_search.'%\' ';
break;
case 4:
$where[] = ' LOWER(c.catname) LIKE \'%'.$filter_search.'%\' ';
break;
}
}
$where = (count($where) ? ' WHERE (' . implode(') AND (', $where) . ')' : '');
return $where;
}
public function getCategories($id)
{
$query = 'SELECT DISTINCT c.id, c.catname, c.checked_out AS cchecked_out'
. ' FROM #__jem_categories AS c'
. ' LEFT JOIN #__jem_cats_event_relations AS rel ON rel.catid = c.id'
. ' WHERE rel.itemid = '.(int)$id
;
$this->_db->setQuery( $query );
$cats = $this->_db->loadObjectList();
foreach ($cats as &$cat) {
$jc = new JemCategories($cat->id);
$cat->parentcats = $jc->getParentlist();
}
return $cats;
}
}
?>

View File

@ -0,0 +1,343 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Component\ComponentHelper;
/**
* Model-Events
**/
class JemModelEvents extends ListModel
{
/**
* Constructor.
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'alias', 'a.alias',
'title', 'a.title',
'state', 'a.state',
'times', 'a.times',
'venue','loc.venue',
'city','loc.city',
'dates', 'a.dates',
'hits', 'a.hits',
'id', 'a.id',
'catname', 'c.catname',
'featured', 'a.featured',
'access', 'a.access', 'access_level',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* @Note Calling getState in this method will result in recursion.
*/
protected function populateState($ordering = null, $direction = null)
{
$search = $this->getUserStateFromRequest($this->context.'.filter_search', 'filter_search');
$this->setState('filter_search', $search);
$published = $this->getUserStateFromRequest($this->context.'.filter_state', 'filter_state', '', 'string');
$this->setState('filter_state', $published);
$filterfield = $this->getUserStateFromRequest($this->context.'.filter_type', 'filter_type', 0, 'int');
$this->setState('filter_type', $filterfield);
$begin = $this->getUserStateFromRequest($this->context.'.filter_begin', 'filter_begin', '', 'string');
$this->setState('filter_begin', $begin);
$end = $this->getUserStateFromRequest($this->context.'.filter_end', 'filter_end', '', 'string');
$this->setState('filter_end', $end);
$access = $this->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', 0, 'int');
$this->setState('filter.access', $access);
// Load the parameters.
$params = ComponentHelper::getParams('com_jem');
$this->setState('params', $params);
// List state information.
parent::populateState('a.dates', 'asc');
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter_search');
$id .= ':' . $this->getState('filter_published');
$id .= ':' . $this->getState('filter_type');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select($this->getState('list.select', 'a.*'));
$query->from($db->quoteName('#__jem_events').' AS a');
// Join over the venue.
$query->select('loc.venue, loc.city, loc.state, loc.checked_out AS vchecked_out');
$query->join('LEFT', '#__jem_venues AS loc ON loc.id = a.locid');
// Join over the users for the checked out user.
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id = a.checked_out');
// Join over the user who modified the event.
$query->select('um.name AS modified_by');
$query->join('LEFT', '#__users AS um ON um.id = a.modified_by');
// Join over the author & email.
$query->select('u.email, u.name AS author');
$query->join('LEFT', '#__users AS u ON u.id = a.created_by');
// Join over the view access level.
$query->select('vl.title AS access_level');
$query->join('LEFT', '#__viewlevels AS vl ON vl.id = a.access');
// Join over the country.
$query->select('co.name AS country');
$query->join('LEFT', '#__jem_countries AS co ON co.iso2 = loc.country');
// Filter by published state
$published = $this->getState('filter_state');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
} elseif ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by access level.
if ($access = $this->getState('filter.access')) {
$query->where('a.access = ' . (int) $access);
}
// Filter by Date
$startDate = $this->getState('filter_begin');
$endDate = $this->getState('filter_end');
if (!empty($startDate) && !empty($endDate)) {
$query->where('(a.dates >= '.$db->Quote($startDate).')');
$query->where('(a.enddates <= ' . $db->Quote($endDate) . ' OR (a.enddates is null AND a.dates <= ' . $db->Quote($endDate) . '))');
} else {
if (!empty($startDate)) {
$query->where('(a.dates IS NULL OR a.dates >= '.$db->Quote($startDate).')');
}
if (!empty($endDate)) {
$query->where('(a.enddates IS NULL OR a.enddates <= ' . $db->Quote($endDate) . ' OR (a.enddates is null AND a.dates <= ' . $db->Quote($endDate) . '))');
}
}
// Filter by search in title
$filter = $this->getState('filter_type');
$search = $this->getState('filter_search');
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) {
switch ($filter) {
case 1:
/* search event-title or alias */
$query->where('(a.title LIKE '.$search.' OR a.alias LIKE '.$search.')');
break;
case 2:
/* search venue */
$query->where('loc.venue LIKE '.$search);
break;
case 3:
/* search city */
$query->where('loc.city LIKE '.$search);
break;
case 4:
/* search category */
/* we need to do that here to get correct counting */
$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');
$query->where('c.catname LIKE '.$search);
break;
case 5:
/* search state */
$query->where('loc.state LIKE '.$search);
break;
case 6:
/* search country */
$query->where('co.name LIKE '.$search);
break;
case 7:
/* search all */
$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');
$query->where('(a.title LIKE '.$search.' OR a.alias LIKE '.$search.' OR loc.city LIKE '.$search.' OR loc.state LIKE '.$search.' OR co.name LIKE '.$search.' OR loc.venue LIKE '.$search.' OR c.catname LIKE '.$search.')');
break;
default:
/* search event and location (city, state, country)*/
$query->where('(a.title LIKE '.$search.' OR a.alias LIKE '.$search.' OR loc.city LIKE '.$search.' OR loc.state LIKE '.$search.' OR co.name LIKE '.$search.')');
}
}
}
}
$query->group('a.id');
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
$query->order($db->escape($orderCol.' '.$orderDirn));
return $query;
}
/**
* Method to get the userinformation of edited/submitted events
*
* @return object
*/
public function getItems()
{
$items = parent::getItems();
$filter = $this->getState('filter_type');
$search = $this->getState('filter_search');
foreach ($items as $index => $item) {
$item->categories = $this->getCategories($item->id);
# check if the item-categories is empty
# in case of filtering we will unset the items without the reqeusted category
if ($search) {
if ($filter == 4) {
if (empty($item->categories)) {
unset ($items[$index]);
}
}
}
}
JemHelper::getAttendeesNumbers($items); // writes directly into $items
if ($items) {
return $items;
}
return array();
}
/**
* Retrieve Categories
*
* Due to multi-cat this function is needed
* filter-index (4) is pointing to the cats
*/
public function getCategories($id)
{
$user = JemFactory::getUser();
$levels = $user->getAuthorisedViewLevels();
# Query
$db = Factory::getContainer()->get('DatabaseDriver');
$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.path','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');
$query->where('rel.itemid ='.(int)$id);
###################
## FILTER-ACCESS ##
###################
# Filter by access level.
$access = $this->getState('filter.access');
if ($access){
$groups = implode(',', $levels);
$query->where('c.access IN ('.$groups.')');
}
###################
## FILTER-SEARCH ##
###################
# define variables
$filter = $this->getState('filter_type');
$search = $this->getState('filter_search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('c.id = ' . (int)substr($search, 3));
} else {
/* In case of a search string the db query had already filtered out
* all events without a matching caterory.
* So we can here return all categories of the event
* which the user is allowed to see.
*/
/*
$search = $db->Quote('%'.$db->escape($search, true).'%');
if($search) {
if ($filter == 4) {
$query->where('c.catname LIKE '.$search);
}
}
*/
}
}
$db->setQuery($query);
$cats = $db->loadObjectList();
return $cats;
}
}

View File

@ -0,0 +1,391 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*
* Based on: https://gist.github.com/dongilbert/4195504
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Component\ComponentHelper;
jimport('joomla.application.component.modellist');
/**
* JEM Component Export Model
*/
class JemModelExport extends ListModel
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id',
'a.id'
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* @Note Calling getState in this method will result in recursion.
*/
protected function populateState($ordering = null, $direction = null)
{
// Load the filter state.
$filter_form_type = $this->getUserStateFromRequest($this->context . '.filter.form_type', 'filter_form_type');
$this->setState('filter.form_type', $filter_form_type);
$filter_start_date = $this->getUserStateFromRequest($this->context . '.filter.start_date', 'filter_start_date');
$this->setState('filter.start_date', $filter_start_date);
$filter_end_date = $this->getUserStateFromRequest($this->context . '.filter.end_date', 'filter_end_date');
$this->setState('filter.end_date', $filter_end_date);
// Load the parameters.
$params = ComponentHelper::getParams('com_jem');
$this->setState('params', $params);
// List state information.
parent::populateState('a.first_name', 'asc');
}
/**
* Build an SQL query to load the Events data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Retrieve variables
$jinput = Factory::getApplication()->input;
$startdate = $jinput->get('dates', '', 'string');
$enddate = $jinput->get('enddates', '', 'string');
$cats = $jinput->get('cid', array(), 'array');
// Create a new query object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('#__jem_events AS a');
$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');
// check if startdate and/or enddate are set.
if (!empty($startdate)) {
// note: open date is always after $startdate
$query->where('((a.dates IS NULL) OR (DATEDIFF(IF (a.enddates IS NOT NULL, a.enddates, a.dates), ' . $db->quote($startdate) . ') >= 0))');
}
if (!empty($enddate)) {
// note: open date is before $enddate as long as $enddate is not before today
$query->where('(((a.dates IS NULL) AND (DATEDIFF(CURDATE(), ' . $db->quote($enddate) . ') <= 0)) OR (DATEDIFF(a.dates, ' . $db->quote($enddate) . ') <= 0))');
}
// check if specific category's have been selected
if (! empty($cats)) {
\Joomla\Utilities\ArrayHelper::toInteger($cats);
$query->where(' c.id IN (' . implode(',', $cats) . ')');
}
// Group the query
$query->group('a.id');
return $query;
}
/**
* Returns a CSV file with Events data
*
* @return boolean
*/
public function getCsv()
{
$this->populateState();
$jinput = Factory::getApplication()->input;
$includecategories = $jinput->get('categorycolumn', 0, 'int');
$db = Factory::getContainer()->get('DatabaseDriver');
$jemconfig = JemConfig::getInstance()->toRegistry();
$separator = $jemconfig->get('csv_separator', ';');
$delimiter = $jemconfig->get('csv_delimiter', '"');
$csv_bom = $jemconfig->get('csv_bom', '1');
$csv = fopen('php://output', 'w');
if ($csv_bom ==1 ) {
//add BOM to fix UTF-8 in Excel
fputs($csv, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
}
if ($includecategories == 1) {
$events = array_keys($db->getTableColumns('#__jem_events'));
$categories = array();
$categories[] = "categories";
$header = array_merge($events, $categories);
fputcsv($csv, $header, $separator, $delimiter);
$query = $this->getListQuery();
$items = $this->_getList($query);
foreach ($items as $item) {
$item->categories = $this->getCatEvent($item->id);
}
} else {
$header = array_keys($db->getTableColumns('#__jem_events'));
fputcsv($csv, $header, $separator, $delimiter);
$query = $this->getListQuery();
$items = $this->_getList($query);
}
foreach ($items as $lines) {
fputcsv($csv, (array) $lines, $separator, $delimiter);
}
return fclose($csv);
}
/**
* Build an SQL query to load the Categories data.
*
* @return JDatabaseQuery
*/
protected function getListQuerycats()
{
// Create a new query object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('#__jem_categories AS a');
return $query;
}
/**
* Returns a CSV file with Categories data
*
* @return boolean
*/
public function getCsvcats()
{
$this->populateState();
$jemconfig = JemConfig::getInstance()->toRegistry();
$separator = $jemconfig->get('csv_separator', ';');
$delimiter = $jemconfig->get('csv_delimiter', '"');
$csv_bom = $jemconfig->get('csv_bom', '1');
$csv = fopen('php://output', 'w');
if ($csv_bom ==1 ) {
//add BOM to fix UTF-8 in Excel
fputs($csv, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
}
$db = Factory::getContainer()->get('DatabaseDriver');
$header = array_keys($db->getTableColumns('#__jem_categories'));
fputcsv($csv, $header, $separator, $delimiter);
$db->setQuery($this->getListQuerycats());
$items = $db->loadObjectList();
foreach ($items as $lines) {
fputcsv($csv, (array) $lines, $separator, $delimiter);
}
return fclose($csv);
}
/**
* Build an SQL query to load the Venues data.
*
* @return JDatabaseQuery
*/
protected function getListQueryvenues()
{
// Create a new query object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('#__jem_venues AS a');
return $query;
}
/**
* Returns a CSV file with Venues data
* @return boolean
*/
public function getCsvvenues()
{
$this->populateState();
$jemconfig = JemConfig::getInstance()->toRegistry();
$separator = $jemconfig->get('csv_separator', ';');
$delimiter = $jemconfig->get('csv_delimiter', '"');
$csv_bom = $jemconfig->get('csv_bom', '1');
$csv = fopen('php://output', 'w');
if ($csv_bom ==1 ) {
//add BOM to fix UTF-8 in Excel
fputs($csv, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
}
$db = Factory::getContainer()->get('DatabaseDriver');
$header = array_keys($db->getTableColumns('#__jem_venues'));
fputcsv($csv, $header, $separator, $delimiter);
$db->setQuery($this->getListQueryvenues());
$items = $db->loadObjectList();
foreach ($items as $lines) {
fputcsv($csv, (array) $lines, $separator, $delimiter);
}
return fclose($csv);
}
/**
* Build an SQL query to load the Cats/Events data.
*
* @return JDatabaseQuery
*/
protected function getListQuerycatsevents()
{
// Create a new query object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('#__jem_cats_event_relations AS a');
return $query;
}
/**
* Returns a CSV file with Cats/Events data
* @return boolean
*/
public function getCsvcatsevents()
{
$this->populateState();
$jemconfig = JemConfig::getInstance()->toRegistry();
$separator = $jemconfig->get('csv_separator', ';');
$delimiter = $jemconfig->get('csv_delimiter', '"');
$csv_bom = $jemconfig->get('csv_bom', '1');
$csv = fopen('php://output', 'w');
if ($csv_bom ==1 ) {
//add BOM to fix UTF-8 in Excel
fputs($csv, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
}
$db = Factory::getContainer()->get('DatabaseDriver');
$header = array_keys($db->getTableColumns('#__jem_cats_event_relations'));
fputcsv($csv, $header, $separator, $delimiter);
$db->setQuery($this->getListQuerycatsevents());
$items = $db->loadObjectList();
foreach ($items as $lines) {
fputcsv($csv, (array) $lines, $separator, $delimiter);
}
return fclose($csv);
}
/**
* logic to get the categories
*/
public function getCategories()
{
// @todo alter function
$db = Factory::getContainer()->get('DatabaseDriver');
$where = ' WHERE c.published = 1';
$query = 'SELECT c.* FROM #__jem_categories AS c' . $where . ' ORDER BY parent_id, c.lft';
// Check for a database error.
// if ($db->getErrorNum()){
// Factory::getApplication()->enqueueMessage($db->getErrorMsg(), 'notice');
// }
try
{
$db->setQuery($query);
$mitems = $db->loadObjectList();
}
catch (RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'notice');
}
if (!$mitems) {
$children = array();
$mitems = array();
$parentid = 0;
} else {
$children = array();
// First pass - collect children
foreach ($mitems as $v) {
$pt = $v->parent_id;
$list = isset($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);
return $list;
}
/**
* Get Category IDs for a specific event.
*
* @param int $id event id
* @return string|boolean Comma separated list of ids on success or false otherwise.
*/
public function getCatEvent($id)
{
// Create a new query object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('catid');
$query->from('#__jem_cats_event_relations');
$query->where('itemid = ' . $db->quote($id));
$db->setQuery($query);
$catidlist = $db->loadObjectList();
if (is_array($catidlist) && count($catidlist)) {
$catidarray = array();
foreach ($catidlist as $obj) {
$catidarray[] = $obj->catid;
}
$catids = implode(',', $catidarray);
} else {
$catids = false;
}
return $catids;
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Form\Field\CalendarField;
FormHelper::loadFieldClass('calendar');
/**
* Form Field class for JEM needs.
*
* Advances CalendarField for better country-specific date format support.
*
* @since 2.2.3
*/
class JFormFieldCalendarJem extends CalendarField
{
/**
* The form field type.
*
* @var string
*/
protected $type = 'CalendarJem';
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
if (!empty($this->hint)) {
return $data;
}
// add hint regarding date/time format accepted in edit field
$exampleTimestamp = strtotime("NOW");
$date_format = str_replace("%","",$this->format);
$hint = Text::sprintf('COM_JEM_DATEFIELD_HINT', date($date_format, $exampleTimestamp));
$extraData = array(
'hint' => $hint,
);
return array_merge($data, $extraData);
}
}

View File

@ -0,0 +1,88 @@
<?php
/**
* @version 2.2.3
* @package JEM
* @copyright (C) 2013-2017 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('calendar');
/**
* Form Field class for JEM needs.
*
* Advances JFormFieldCalendar for better country-specific date format support.
*
* @since 2.2.3
*/
if (version_compare(JVERSION, '3.7', 'ge')) {
class JFormFieldCalendarJem extends JFormFieldCalendar
{
/**
* The form field type.
*
* @var string
*/
protected $type = 'CalendarJem';
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
if (!empty($this->hint)) {
return $data;
}
// add hint regarding date/time format accepted in edit field
$exampleTimestamp = strtotime("NOW");
$hint = JText::sprintf('COM_JEM_DATEFIELD_HINT', strftime($this->format, $exampleTimestamp));
$extraData = array(
'hint' => $hint,
);
return array_merge($data, $extraData);
}
}
} else {
class JFormFieldCalendarJem extends JFormFieldCalendar
{
/**
* The form field type.
*
* @var string
* @note MUST be public.
*/
public $type = 'CalendarJem';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*/
protected function getInput()
{
// don't translate format; it MUST be Y-m-d to keep calendar popup working
if (empty($this->hint)) {
// add hint regarding date/time format accepted in edit field
$exampleTimestamp = strtotime("NOW");
$this->hint = JText::sprintf('COM_JEM_DATEFIELD_HINT', strftime($this->format, $exampleTimestamp));
}
return parent::getInput();
}
}
}

View File

@ -0,0 +1,126 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Session\Session;
FormHelper::loadFieldClass('list');
/**
* Category select
*
* @package JEM
*
*/
class JFormFieldCategories extends ListField
{
protected $type = 'Categories';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
*/
protected function getInput()
{
$app = Factory::getApplication();
$document = $app->getDocument();
$wa = $document->getWebAssetManager();
// Build the script.
$script = array();
$script[] = ' function jSelectCategory_'.$this->id.'(id, category, object) {';
$script[] = ' document.getElementById("'.$this->id.'_id").value = id;';
$script[] = ' document.getElementById("'.$this->id.'_name").value = category;';
// $script[] = ' SqueezeBox.close();';
$script[] = ' $("#categories-modal").modal("hide");';
$script[] = ' };';
// Add the script to the document head.
$wa->addInlineScript(implode("\n", $script));
// Setup variables for display.
$html = array();
$link = 'index.php?option=com_jem&amp;view=categoryelement&amp;tmpl=component&amp;function=jSelectCategory_'.$this->id;
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('catname');
$query->from('#__jem_categories');
$query->where('id='.(int)$this->value);
try
{
$db->setQuery($query);
$category = $db->loadResult();
}
catch (RuntimeException $e)
{
$app->enqueueMessage($e->getMessage(), 'warning');
}
// if ($error = $db->getErrorMsg()) {
// Factory::getApplication()->enqueueMessage($error, 'warning');
// }
if (empty($category)) {
$category = Text::_('COM_JEM_SELECT_CATEGORY');
}
$category = htmlspecialchars($category, ENT_QUOTES, 'UTF-8');
// The current user display field.
$html[] = '<div class="fltlft">';
$html[] = ' <input type="text" id="'.$this->id.'_name" value="'.$category.'" disabled="disabled" size="35" class="form-control valid form-control-success" />';
$html[] = '</div>';
// The user select button.
$html[] = '<div class="button2-left">';
$html[] = ' <div class="blank">';
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'categories-modal',
array(
'url' => $link.'&amp;'.Session::getFormToken().'=1',
'title' => Text::_('COM_JEM_SELECT_CATEGORY'),
'width' => '800px',
'height' => '450px',
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('COM_JEM_CLOSE') . '</button>'
)
);
$html[] ='<button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#categories-modal">'.Text::_('COM_JEM_SELECT_CATEGORY').'
</button>';
$html[] = ' </div>';
$html[] = '</div>';
// The active category-id field.
if (0 == (int)$this->value) {
$value = '';
} else {
$value = (int)$this->value;
}
// class='required' for client side validation
$class = '';
if ($this->required) {
$class = ' class="required modal-value"';
}
$html[] = '<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
return implode("\n", $html);
}
}
?>

View File

@ -0,0 +1,237 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\HTML\HTMLHelper;
// ensure JemFactory is loaded (because field maybe used by modules too)
require_once(JPATH_SITE.'/components/com_jem/factory.php');
FormHelper::loadFieldClass('list');
/**
* Category Form
*/
class JFormFieldCategoryEdit extends ListField
{
/**
* A flexible category list that respects access controls
*
* @var string
*/
public $type = 'CategoryEdit';
/**
* Method to get a list of categories that respects access controls and can be used for
* either category assignment or parent category assignment in edit screens.
* Use the parent element to indicate that the field will be used for assigning parent categories.
*
* @return array The field option objects.
*/
protected function getOptions()
{
// Initialise variables.
$options = array();
$published = $this->element['published']? $this->element['published'] : array(0,1);
$name = (string) $this->element['name'];
// Let's get the id for the current item, either category or content item.
$jinput = Factory::getApplication()->input;
// Load the category options for a given extension.
// For categories the old category is the category id or 0 for new category.
if ($this->element['parent'])
{
$oldCat = $jinput->get('id', 0);
$oldParent = $this->form->getValue($name, 0);
//$extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $jinput->get('extension','com_content');
}
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, 0);
//$extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $jinput->get('option','com_content');
}
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('a.id AS value, a.catname AS text, a.level, a.published');
$query->from('#__jem_categories AS a');
$query->join('LEFT', $db->quoteName('#__jem_categories').' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
// Filter by the extension type
//if ($this->element['parent'] == true)
//{
// $query->where('(a.parent_id = 0)');
//}
// If parent isn't explicitly stated but we are in com_categories assume we want parents
if ($oldCat != 0 && ($this->element['parent'] == true ))
{
// Prevent parenting to children of this item.
// To rearrange parents and children move the children up, not the parents down.
$query->join('LEFT', $db->quoteName('#__jem_categories').' AS p ON p.id = '.(int) $oldCat);
$query->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
$rowQuery = $db->getQuery(true);
$rowQuery->select('a.id AS value, a.catname AS text, a.level, a.parent_id');
$rowQuery->from('#__jem_categories AS a');
$rowQuery->where('a.id = ' . (int) $oldCat);
$db->setQuery($rowQuery);
$row = $db->loadObject();
}
// Filter on the published state
if (is_numeric($published))
{
$query->where('a.published = ' . (int) $published);
}
elseif (is_array($published) && count($published))
{
\Joomla\Utilities\ArrayHelper::toInteger($published);
$query->where('a.published IN (' . implode(',', $published) . ')');
}
if ($this->element['removeroot'] == true) {
$query->where('a.catname NOT LIKE "root"');
}
$query->group('a.id, a.catname, a.level, a.lft, a.rgt, a.parent_id, a.published');
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
// Check for a database error.
// if ($db->getErrorNum()) {
// Factory::getApplication()->enqueueMessage($db->getErrorMsg(), 'warning');
// }
}
catch (RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getErrorMsg(), 'warning');
}
// Pad the option text with spaces using depth level as a multiplier.
for ($i = 0, $n = (is_array($options) ? count($options) : 0); $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;
}
// Translate ROOT
if ($this->element['parent'] == true)
{
if ($options[$i]->level == 0)
{
$options[$i]->text = Text::_('JGLOBAL_ROOT_PARENT');
}
}
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 . ']';
}
}
// 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', 'com_jem' . '.category.' . $option->value) != true )
{
unset($options[$i]);
}
}
}
// If you have an existing category id things are more complex.
else
{
// 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.
foreach ($options as $i => $option)
{
if ($user->authorise('core.edit.state', 'com_jem' . '.category.' . $oldCat) != true && !isset($oldParent))
{
if ($option->value != $oldCat )
{
unset($options[$i]);
}
}
if ($user->authorise('core.edit.state', 'com_jem' . '.category.' . $oldCat) != true
&& (isset($oldParent)) && $option->value != $oldParent)
{
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.
if (($user->authorise('core.create', 'com_jem' . '.category.' . $option->value) != true)
&& ($option->value != $oldCat && !isset($oldParent)))
{
{
unset($options[$i]);
}
}
if (($user->authorise('core.create', 'com_jem' . '.category.' . $option->value) != true)
&& (isset($oldParent)) && $option->value != $oldParent)
{
{
unset($options[$i]);
}
}
}
}
if (($this->element['parent'] == true)
&& (isset($row) && !isset($options[0])) && isset($this->element['show_root']))
{
if ($row->parent_id == '1') {
$parent = new stdClass();
$parent->text = Text::_('JGLOBAL_ROOT_PARENT');
array_unshift($options, $parent);
}
array_unshift($options, HTMLHelper::_('select.option', '0', Text::_('JGLOBAL_ROOT')));
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}

View File

@ -0,0 +1,179 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
// ensure JemFactory is loaded (because field maybe used by modules too)
require_once(JPATH_SITE.'/components/com_jem/factory.php');
FormHelper::loadFieldClass('list');
/**
* Category formfield.
*
*/
class JFormFieldCategoryParent extends ListField
{
/**
* The form field type.
*
* @var string
*/
protected $type = 'CategoryParent';
/**
* 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 = Factory::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 = Factory::getContainer()->get('DatabaseDriver');
$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);
// Check for a database error.
// if ($db->getErrorNum()) {
// Factory::getApplication()->enqueueMessage($db->getErrorMsg(), 'warning');
// }
try
{
$options = $db->loadObjectList();
}
catch (\InvalidArgumentException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning');
}
// Pad the option text with spaces using depth level as a multiplier.
for ($i = 0, $n = (is_array($options) ? count($options) : 0); $i < $n; $i++)
{
// Translate ROOT
if ($options[$i]->level == 0) {
$options[$i]->text = Text::_('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 = Text::_('JGLOBAL_ROOT_PARENT');
array_unshift($options, $parent);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}

View File

@ -0,0 +1,114 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\HTML\HTMLHelper;
FormHelper::loadFieldClass('list');
/**
* CatOptions Field class.
*/
class JFormFieldCatOptions extends ListField
{
/**
* The category options field type.
*/
protected $type = 'CatOptions';
/**
* Create Input
* @see ListField::getInput()
*/
public function getInput()
{
$attr = '';
// Initialize field attributes.
$attr .= !empty($this->class) ? ' class="' . $this->class . '"' : '';
$attr .= !empty($this->size) ? ' size="' . $this->size . '"' : '';
$attr .= $this->multiple ? ' multiple' : '';
$attr .= $this->required ? ' required aria-required="true"' : '';
// To avoid user's confusion, readonly="true" should imply disabled="true".
if ((string) $this->readonly == '1' || (string) $this->readonly == 'true' || (string) $this->disabled == '1'|| (string) $this->disabled == 'true')
{
$attr .= ' disabled="disabled"';
}
// Initialize JavaScript field attributes.
$attr .= $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
// Get the field options.
$options = (array) $this->getOptions();
$jinput = Factory::getApplication()->input;
$currentid = $jinput->getInt('id');
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('DISTINCT catid');
$query->from('#__jem_cats_event_relations');
$query->where('itemid = '. $db->quote($currentid));
$db->setQuery($query);
$selectedcats = $db->loadColumn();
// Create a read-only list (no name) with a hidden input to store the value.
if ((string) $this->readonly == '1' || (string) $this->readonly == 'true')
{
$html[] = HTMLHelper::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $selectedcats,$this->id);
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($selectedcats, ENT_COMPAT, 'UTF-8') . '"/>';
}
else
// Create a regular list.
{
$html[] = HTMLHelper::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $selectedcats,$this->id);
}
return implode($html);
}
/**
* Retrieve Options
* @see ListField::getOptions()
*/
protected function getOptions()
{
$options = JemCategories::getCategoriesTree();
$options = array_values($options);
// Pad the option text with spaces using depth level as a multiplier
# the level has to be decreased as we are having a (invisible) root
# treename is generated by the function so let's use that one instead of the Joomla way
for ($i = 0, $n = (is_array($options) ? count($options) : 0); $i < $n; $i++)
{
/*
if ($options[$i]->published == 1)
{
$options[$i]->text = str_repeat('- ', ($options[$i]->level - 1)) . $options[$i]->text;
}
else
{
$options[$i]->text = str_repeat('- ', ($options[$i]->level - 1)) . '[' . $options[$i]->text . ']';
}
*/
$options[$i]->text = $options[$i]->treename;
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormField;
//JFormHelper::loadFieldClass('list');
jimport('joomla.html.html');
/**
* CountryOptions Field class.
*
*
*/
class JFormFieldCatOptions2 extends FormField
{
/**
* The form field type.
*
*/
protected $type = 'CatOptions2';
public function getInput()
{
$attr = '';
// Initialize some field attributes.
$attr .= $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
// To avoid user's confusion, readonly="true" should imply disabled="true".
if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
$attr .= ' disabled="disabled"';
}
//$attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
$attr .= $this->multiple ? ' multiple="multiple"' : '';
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
//$attr .= $this->element['required'] ? ' class="required modal-value"' : "";
// if ($this->required) {
// $class = ' class="required modal-value"';
// }
// Output
//$categories = JEMCategories::getCategoriesTree(0);
//$Lists['parent_id'] = JEMCategories::buildcatselect($categories, 'parent_id', $row->parent_id, 1);
$currentid = Factory::getApplication()->input->getInt('id');
$categories = JEMCategories::getCategoriesTree(0);
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query = 'SELECT DISTINCT parent_id FROM #__jem_categories WHERE id = '. $db->quote($currentid);
$db->setQuery($query);
$currentparent_id = $db->loadColumn();
return JEMCategories::buildcatselect($categories, 'parent_id', $currentparent_id, 1);
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
/**
* CountryOptions Field class.
*
*
*/
class JFormFieldCountryOptions extends ListField
{
/**
* The form field type.
*
*/
protected $type = 'CountryOptions';
/**
* Method to get the Country options.
*
*/
public function getOptions()
{
return JEMHelperBackend::getCountryOptions();
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\FormField;
/**
* Color Form Field
*/
class JFormFieldCustomColor extends FormField
{
/**
* The form field type.
*/
protected $type = 'CustomColor';
/**
* Method to get the field input markup.
*/
protected function getInput()
{
// Initialize field attributes.
$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
$classes = (string) $this->element['class'];
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
if (!$disabled)
{
$classes .= ' colorpicker';
}
// load script.
$script = array();
$script[] = ' function jClearColor(id) {';
$script[] = ' document.getElementById(id).value = "";';
$script[] = ' document.getElementById(id).style.background = "";';
$script[] = ' }';
// Add the script to the document head.
Factory::getApplication()->getDocument()->getWebAssetManager()->addInlineScript(implode("\n", $script));
// Initialize JavaScript field attributes.
$onclick = ' onclick="openPicker(\''.$this->id.'\', -200, 20)"';
$class = $classes ? ' class="' . trim($classes) . '"' : '';
$html = array();
$html[] = '<input style="background:'.$this->value.'" type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="'
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $size .$onclick. '/>';
$html[] = '<input title="'.Text::_('JCLEAR').'" type="text" class="button" size="1" value="" id="clear" onclick="return jClearColor(\''.$this->id.'\')">';
return implode("\n", $html);
}
}

View File

@ -0,0 +1,43 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
//JFormHelper::loadFieldClass('list');
jimport('joomla.html.html');
/**
* Endtime Field class.
*
*
*/
class JFormFieldEndtime extends FormField
{
/**
* The form field type.
*
*/
protected $type = 'Endtime';
public function getInput()
{
$endhours = JEMHelper::buildtimeselect(23, 'endhours', substr( $this->value, 0, 2 ),array('class'=>'form-select','class'=>'select-time'));
$endminutes = JEMHelper::buildtimeselect(59, 'endminutes', substr($this->value, 3, 2 ),array('class'=>'form-select','class'=>'select-time'));
$var2 = $endhours.$endminutes;
return $var2;
}
}

View File

@ -0,0 +1,120 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Session\Session;
jimport('joomla.form.formfield');
jimport('joomla.html.parameter.element');
FormHelper::loadFieldClass('list');
/**
* Renders an event element
*
* @package JEM
*
*/
class JFormFieldEvent extends ListField
{
protected $type = 'title';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
*/
protected function getInput()
{
// Build the script.
$script = array();
$script[] = ' function elSelectEvent(id, title, object) {';
$script[] = ' document.getElementById("'.$this->id.'_id").value = id;';
$script[] = ' document.getElementById("'.$this->id.'_name").value = title;';
// $script[] = ' SqueezeBox.close();';
$script[] = ' $("#event-modal").modal("hide");';
$script[] = ' }';
// Add the script to the document head.
Factory::getApplication()->getDocument()->getWebAssetManager()->addInlineScript(implode("\n", $script));
// Setup variables for display.
$html = array();
$link = 'index.php?option=com_jem&amp;view=eventelement&amp;tmpl=component&amp;object='.$this->id;
$db = Factory::getContainer()->get('DatabaseDriver');
$db->setQuery(
'SELECT title' .
' FROM #__jem_events' .
' WHERE id = '.(int) $this->value
);
try
{
$title = $db->loadResult();
}
catch (RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning');
}
if (empty($title)) {
$title = Text::_('COM_JEM_SELECT_EVENT');
}
$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// The current user display field.
$html[] = '<div class="fltlft">';
$html[] = ' <input type="text" id="'.$this->id.'_name" value="'.$title.'" disabled="disabled" size="35" class="form-control valid form-control-success" />';
$html[] = '</div>';
// The user select button.
$html[] = '<div class="button2-left">';
$html[] = ' <div class="blank">';
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'event-modal',
array(
'url' => $link.'&amp;'.Session::getFormToken().'=1',
'title' => Text::_('COM_JEM_SELECT_EVENT'),
'width' => '800px',
'height' => '450px',
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('COM_JEM_CLOSE') . '</button>'
)
);
$html[] ='<button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#event-modal">'.Text::_('COM_JEM_SELECT_EVENT').'
</button>';
$html[] = ' </div>';
$html[] = '</div>';
// The active event-id field.
if (0 == (int)$this->value) {
$value = '';
} else {
$value = (int)$this->value;
}
// class='required' for client side validation
$class = '';
if ($this->required) {
$class = ' class="required modal-value"';
}
$html[] = '<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
return implode("\n", $html);
}
}
?>

View File

@ -0,0 +1,38 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\FormField;
/**
*/
class JFormFieldFootertext extends FormField
{
/**
* The form field type.
*/
protected $type = 'Footertext';
/**
*/
protected function getInput()
{
// Initialize some field attributes.
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
$columns = $this->element['cols'] ? ' cols="' . (int) $this->element['cols'] . '"' : '';
$rows = $this->element['rows'] ? ' rows="' . (int) $this->element['rows'] . '"' : '';
// Initialize JavaScript field attributes.
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
return '<textarea name="' . $this->name . '" id="' . $this->id . '"' . $columns . $rows . $class . $disabled . $onchange . '>'
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '</textarea>';
}
}

View File

@ -0,0 +1,36 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\FormField;
/**
* Hits Field.
*/
class JFormFieldHits extends FormField
{
/**
* The form field type.
* @var string
*/
protected $type = 'Hits';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*/
protected function getInput()
{
$onclick = ' onclick="document.getElementById(\''.$this->id.'\').value=\'0\';"';
return '<input type="text" name="'.$this->name.'" id="'.$this->id.'" class="form-control field-user-input-name valid form-control-success w-20" value="'.htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8').'" readonly="readonly" style="display:inline-block;" /><input type="button"'.$onclick.' value="'.Text::_('COM_JEM_RESET_HITS').'" class="btn btn-primary selectcat" />';
}
}

View File

@ -0,0 +1,129 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\HTML\HTMLHelper;
jimport('joomla.form.formfield');
jimport('joomla.html.parameter.element');
FormHelper::loadFieldClass('list');
/**
* Imageselect Field
*
*/
class JFormFieldImageselect extends ListField
{
protected $type = 'Imageselect';
public function getLabel() {
// code that returns HTML that will be shown as the label
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
*/
public function getInput()
{
// ImageType
$imagetype = $this->element['imagetype'];
// Build the script.
$script = array();
$script[] = ' function SelectImage(image, imagename) {';
$script[] = ' document.getElementById(\'a_image\').value = image';
$script[] = ' document.getElementById(\'a_imagename\').value = imagename';
$script[] = ' document.getElementById(\'imagelib\').src = \'../images/jem/'.$imagetype.'/\' + image';
// $script[] = ' window.parent.SqueezeBox.close()';
$script[] = ' $(".btn-close").trigger("click");';
$script[] = ' }';
switch ($imagetype)
{
case 'categories':
$task = 'categoriesimg';
$taskselect = 'selectcategoriesimg';
break;
case 'events':
$task = 'eventimg';
$taskselect = 'selecteventimg';
break;
case 'venues':
$task = 'venueimg';
$taskselect = 'selectvenueimg';
break;
}
// Add the script to the document head.
Factory::getApplication()->getDocument()->getWebAssetManager()->addInlineScript(implode("\n", $script));
// Setup variables for display.
$html = array();
$link = 'index.php?option=com_jem&amp;view=imagehandler&amp;layout=uploadimage&amp;task='.$task.'&amp;tmpl=component';
$link2 = 'index.php?option=com_jem&amp;view=imagehandler&amp;task='.$taskselect.'&amp;tmpl=component';
//
$html[] = "<div class=\"fltlft\">";
$html[] = "<input class=\"form-control\" style=\"background: #fff;\" type=\"text\" id=\"a_imagename\" value=\"$this->value\" disabled=\"disabled\" onchange=\"javascript:if (document.forms[0].a_imagename.value!='') {document.imagelib.src='../images/jem/$imagetype/' + document.forms[0].a_imagename.value} else {document.imagelib.src='../media/com_jem/images/blank.png'}\"; />";
$html[] = "</div>";
$html[] = "<div class=\"button2-left\"><div class=\"blank\">";
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'imageupload-modal',
array(
'url' => $link,
'title' => Text::_('COM_JEM_UPLOAD'),
'width' => '650px',
'height' => '500px',
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('COM_JEM_CLOSE') . '</button>'
)
);
$html[] ='<button type="button" class="btn btn-primary btn-margin" data-bs-toggle="modal" data-bs-target="#imageupload-modal">'.Text::_('COM_JEM_UPLOAD').'
</button>';
$html[] ='</div></div>';
// $html[] = "<div class=\"button2-left\"><div class=\"blank\"><a class=\"modal\" title=\"".Text::_('COM_JEM_SELECTIMAGE')."\" href=\"$link2\" rel=\"{handler: 'iframe', size: {x: 650, y: 375}}\">".Text::_('COM_JEM_SELECTIMAGE')."</a></div></div>\n";
$html[] = "<div class=\"button2-left\"><div class=\"blank\">";
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'imageselect-modal',
array(
'url' => $link2,
'title' => Text::_('COM_JEM_SELECTIMAGE'),
'width' => '650px',
'height' => '500px',
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('COM_JEM_CLOSE') . '</button>'
)
);
$html[] = "<button type=\"button\" class=\"btn btn-primary btn-margin\" data-bs-toggle=\"modal\" data-bs-target=\"#imageselect-modal\">".Text::_('COM_JEM_SELECTIMAGE')."
</button>";
$html[] = "</div></div>";
$html[] = "\n&nbsp;<input class=\"btn btn-danger btn-margin\" type=\"button\" onclick=\"SelectImage('', '".Text::_('COM_JEM_SELECTIMAGE')."');\" value=\"".Text::_('COM_JEM_RESET')."\" />";
$html[] = "\n<input type=\"hidden\" id=\"a_image\" name=\"$this->name\" value=\"$this->value\" />";
$html[] = "<img src=\"../media/com_jem/images/blank.png\" name=\"imagelib\" id=\"imagelib\" class=\"venue-image\" alt=\"".Text::_('COM_JEM_SELECTIMAGE_PREVIEW')."\" />";
$html[] = "<script type=\"text/javascript\">";
$html[] = "if (document.forms[0].a_imagename.value!='') {";
$html[] = "var imname = document.forms[0].a_imagename.value;";
$html[] = "jsimg='../images/jem/$imagetype/' + imname;";
$html[] = "document.getElementById('imagelib').src= jsimg;";
$html[] = "}";
$html[] = "</script>";
return implode("\n", $html);
}
}
?>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,119 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Form\FormField;
/**
* Contact select
*/
class JFormFieldModal_Contact extends FormField
{
/**
* field type
*/
protected $type = 'Modal_Contact';
/**
* Method to get the field input markup
*/
protected function getInput()
{
// Build the script
$script = array();
$script[] = ' function jSelectContact_'.$this->id.'(id, name, object) {';
$script[] = ' document.getElementById("'.$this->id.'_id").value = id;';
$script[] = ' document.getElementById("'.$this->id.'_name").value = name;';
// $script[] = ' SqueezeBox.close();';
$script[] = ' $("#contact-modal").modal("hide");';
$script[] = ' }';
// Add to document head
Factory::getApplication()->getDocument()->getWebAssetManager()->addInlineScript(implode("\n", $script));
// Setup variables for display
$html = array();
$link = 'index.php?option=com_jem&amp;view=contactelement&amp;tmpl=component&amp;function=jSelectContact_'.$this->id;
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('name');
$query->from('#__contact_details');
$query->where(array('id='.(int)$this->value));
// if ($error = $db->getErrorMsg()) {
// Factory::getApplication()->enqueueMessage($error, 'warning');
// }
try
{
$db->setQuery($query);
$contact = $db->loadResult();
}
catch (RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'notice');
}
if (empty($contact)) {
$contact = Text::_('COM_JEM_SELECTCONTACT');
}
$contact = htmlspecialchars($contact, ENT_QUOTES, 'UTF-8');
// The current contact input field
$html[] = '<div class="fltlft">';
$html[] = ' <input type="text" id="'.$this->id.'_name" value="'.$contact.'" disabled="disabled" size="35" class="form-control valid form-control-success" />';
$html[] = '</div>';
// The contact select button
$html[] = '<div class="button2-left">';
$html[] = ' <div class="blank">';
// $html[] = ' <a class="modal" title="'.Text::_('COM_JEM_SELECT').'" href="'.$link.'&amp;'.Session::getFormToken().'=1" rel="{handler: \'iframe\', size: {x:800, y:450}}">'.
// Text::_('COM_JEM_SELECT').'</a>';
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'contact-modal',
array(
'url' => $link.'&amp;'.Session::getFormToken().'=1',
'title' => Text::_('COM_JEM_SELECT'),
'width' => '800px',
'height' => '450px',
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('COM_JEM_CLOSE') . '</button>'
)
);
$html[] ='<button type="button" class="btn btn-link btn-primary" data-bs-toggle="modal" data-bs-target="#contact-modal">'.Text::_('COM_JEM_SELECT').'
</button>';
$html[] = ' </div>';
$html[] = '</div>';
// The active contact id field
if (0 == (int)$this->value) {
$value = '';
} else {
$value = (int)$this->value;
}
// class='required' for client side validation
$class = '';
if ($this->required) {
$class = ' class="required modal-value"';
}
$html[] = '<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
return implode("\n", $html);
}
}
?>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,119 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Form\FormField;
/**
* Venue Select
*/
class JFormFieldModal_Venue extends FormField
{
/**
* field type
* @var string
*/
protected $type = 'Modal_Venue';
/**
* Method to get the field input markup
*/
protected function getInput()
{
// Build the script
$script = array();
$script[] = ' function jSelectVenue_'.$this->id.'(id, venue, object) {';
$script[] = ' document.getElementById("'.$this->id.'_id").value = id;';
$script[] = ' document.getElementById("'.$this->id.'_name").value = venue;';
// $script[] = ' SqueezeBox.close();';
$script[] = ' $("#venue-modal-1").modal("hide");';
$script[] = ' }';
// Add to document head
Factory::getApplication()->getDocument()->getWebAssetManager()->addInlineScript(implode("\n", $script));
// Setup variables for display
$html = array();
$link = 'index.php?option=com_jem&amp;view=venueelement&amp;tmpl=component&amp;function=jSelectVenue_'.$this->id;
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('venue');
$query->from('#__jem_venues');
$query->where(array('id='.(int)$this->value));
// if ($error = $db->getErrorMsg()) {
// Factory::getApplication()->enqueueMessage($error, 'warning');
// }
try
{
$db->setQuery($query);
$venue = $db->loadResult();
}
catch (RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'notice');
}
if (empty($venue)) {
$venue = Text::_('COM_JEM_SELECTVENUE');
}
$venue = htmlspecialchars($venue, ENT_QUOTES, 'UTF-8');
// The current venue input field
$html[] = '<div class="fltlft">';
$html[] = ' <input type="text" id="'.$this->id.'_name" value="'.$venue.'" disabled="disabled" size="35" class="form-control valid form-control-success" />';
$html[] = '</div>';
// The venue select button
$html[] = '<div class="button2-left">';
$html[] = ' <div class="blank">';
// $html[] = ' <a class="modal" title="'.Text::_('COM_JEM_SELECT').'" href="'.$link.'&amp;'.Session::getFormToken().'=1" rel="{handler: \'iframe\', size: {x:800, y:450}}">'.
// Text::_('COM_JEM_SELECT').'</a>';
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'venue-modal-1',
array(
'url' => $link.'&amp;'.Session::getFormToken().'=1',
'title' => Text::_('COM_JEM_SELECT'),
'width' => '800px',
'height' => '450px',
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('COM_JEM_CLOSE') . '</button>'
)
);
$html[] ='<button type="button" class="btn btn-link btn-primary" data-bs-dismiss="modal" data-bs-toggle="modal" data-bs-target="#venue-modal-1">'.Text::_('COM_JEM_SELECT').'
</button>';
$html[] = ' </div>';
$html[] = '</div>';
// The active venue id field
if (0 == (int)$this->value) {
$value = '';
} else {
$value = (int)$this->value;
}
// class='required' for client side validation
$class = '';
if ($this->required) {
$class = ' class="required modal-value"';
}
$html[] = '<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
return implode("\n", $html);
}
}
?>

View File

@ -0,0 +1,43 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
//JFormHelper::loadFieldClass('list');
jimport('joomla.html.html');
/**
* StartHours Field class.
*
*
*/
class JFormFieldStarthours extends FormField
{
/**
* The form field type.
*
*/
protected $type = 'Starthours';
public function getInput()
{
$starthours = JEMAdmin::buildtimeselect(23, 'starthours', substr( $this->name, 0, 2 ));
$startminutes = JEMAdmin::buildtimeselect(59, 'startminutes', substr( $this->name, 3, 2 ));
$var2 = $starthours.$startminutes;
return $var2;
}
}

View File

@ -0,0 +1,43 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
//JFormHelper::loadFieldClass('list');
jimport('joomla.html.html');
/**
* CountryOptions Field class.
*
*
*/
class JFormFieldStartminutes extends FormField
{
/**
* The form field type.
*
*/
protected $type = 'Startminutes';
public function getInput()
{
$startminutes = JEMAdmin::buildtimeselect(59, 'startminutes', substr( $this->name, 3, 2 ), array('class'=>'form-select','class'=>'select-time'));
return $startminutes;
}
}

View File

@ -0,0 +1,45 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
//JFormHelper::loadFieldClass('list');
jimport('joomla.html.html');
/**
* CountryOptions Field class.
*
*
*/
class JFormFieldStarttime extends FormField
{
/**
* The form field type.
*
*/
protected $type = 'Starttime';
public function getInput()
{
$starthours = JEMHelper::buildtimeselect(23, 'starthours', substr( $this->value, 0, 2 ),array('class'=>'form-select','class'=>'select-time'));
$startminutes = JEMHelper::buildtimeselect(59, 'startminutes', substr($this->value, 3, 2 ),array('class'=>'form-select','class'=>'select-time'));
$var2 = $starthours.$startminutes;
return $var2;
}
}

View File

@ -0,0 +1,123 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Session\Session;
jimport('joomla.form.formfield');
jimport('joomla.html.parameter.element');
FormHelper::loadFieldClass('list');
/**
* Renders an venue element
*
* @package JEM
*
*/
class JFormFieldVenue extends ListField
{
protected $type = 'Venue';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
*/
protected function getInput()
{
// Build the script.
$script = array();
$script[] = ' function elSelectVenue(id, venue, object) {';
$script[] = ' document.getElementById("'.$this->id.'_id").value = id;';
$script[] = ' document.getElementById("'.$this->id.'_name").value = venue;';
// $script[] = ' SqueezeBox.close();';
$script[] = ' $("#venue-modal").modal("hide");';
$script[] = ' }';
// Add the script to the document head.
Factory::getApplication()->getDocument()->getWebAssetManager()->addInlineScript(implode("\n", $script));
// Setup variables for display.
$html = array();
$link = 'index.php?option=com_jem&amp;view=venueelement&amp;tmpl=component&amp;object='.$this->id;
$db = Factory::getContainer()->get('DatabaseDriver');
$db->setQuery(
'SELECT venue' .
' FROM #__jem_venues' .
' WHERE id = '.(int) $this->value
);
try
{
$title = $db->loadResult();
}
catch (RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning');
}
if (empty($title)) {
$title = Text::_('COM_JEM_SELECT_VENUE');
}
$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// The current user display field.
$html[] = '<div class="fltlft">';
$html[] = ' <input type="text" id="'.$this->id.'_name" value="'.$title.'" disabled="disabled" size="35" class="form-control valid form-control-success" />';
$html[] = '</div>';
//
$html[] = '<div class="button2-left">';
$html[] = ' <div class="blank">';
// $html[] = ' <a class="modal" title="'.Text::_('COM_JEM_SELECT_VENUE').'" href="'.$link.'&amp;'.Session::getFormToken().'=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">'.Text::_('COM_JEM_SELECT_VENUE').'</a>';
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'venue-modal',
array(
'url' => $link.'&amp;'.Session::getFormToken().'=1',
'title' => Text::_('COM_JEM_SELECT_VENUE'),
'width' => '800px',
'height' => '450px',
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('COM_JEM_CLOSE') . '</button>'
)
);
$html[] ='<button type="button" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#venue-modal">'.Text::_('COM_JEM_SELECT_VENUE').'
</button>';
$html[] = ' </div>';
$html[] = '</div>';
// The active venue-id field.
if (0 == (int)$this->value) {
$value = '';
} else {
$value = (int)$this->value;
}
// class='required' for client side validation
$class = '';
if ($this->required) {
$class = ' class="required modal-value"';
}
$html[] = '<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
return implode("\n", $html);
}
}
?>

View File

@ -0,0 +1,78 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
/**
* Field: Venueoptions
*/
class JFormFieldVenueoptions extends ListField
{
/**
* A venue list
*/
public $type = 'Venueoptions';
/**
* @return array The field option objects.
*/
protected function getOptions()
{
// Initialise variables.
$options = array();
$published = $this->element['published']? $this->element['published'] : array(0,1);
$name = (string) $this->element['name'];
// Let's get the id for the current item
$jinput = Factory::getApplication()->input;
// Create SQL
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('l.id AS value, l.venue AS text, l.published');
$query->from('#__jem_venues AS l');
// Filter on the published state
if (is_numeric($published))
{
$query->where('l.published = ' . (int) $published);
}
elseif (is_array($published))
{
\Joomla\Utilities\ArrayHelper::toInteger($published);
$query->where('l.published IN (' . implode(',', $published) . ')');
}
$query->group('l.id');
$query->order('l.venue');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
Factory::getApplication()->enqueueMessage($e->getMessage, 'warning');
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}

View File

@ -0,0 +1,212 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<config>
<inlinehelp button="show"/>
</config>
<fieldset name="details"
addfieldpath="/administrator/components/com_jem/models/fields"
>
<field name="id" type="text"
default="0"
label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC"
class="readonly"
readonly="true"
/>
<field name="asset_id" type="hidden"
filter="unset"
/>
<field name="catname" type="text"
class="inputbox"
size="20"
label="COM_JEM_CATEGORY"
description="COM_JEM_CATEGORY"
required="true"
/>
<field name="alias" type="text"
class="inputbox" size="20"
label="COM_JEM_ALIAS"
description="COM_JEM_ALIAS"
required="false"
hint="JFIELD_ALIAS_PLACEHOLDER"
/>
<field name="color" type="color"
class="form-control"
default=""
size="8"
label="COM_JEM_CATEGORY_COLOR"
description="COM_JEM_CATEGORY_COLOR"
/>
<field name="description" type="editor"
hide="pagebreak,readmore"
class="inputbox"
default=""
width="100%"
label="COM_JEM_CATEGORY_DESCRIPTION"
description="COM_JEM_CATEGORY_DESCRIPTION_DESC"
filter="safehtml"
/>
<field name="published" type="list"
class="inputbox"
default="1"
size="1"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field name="parent_id" type="categoryedit"
label="COM_JEM_CATEGORY_FIELD_PARENT_LABEL"
description="COM_JEM_CATEGORY_FIELD_PARENT_DESC"
class="inputbox"
/>
<field name="lft" type="hidden"
filter="unset"
/>
<field name="rgt" type="hidden"
filter="unset"
/>
<field name="level" type="hidden"
filter="unset"
/>
<field name="path" type="text"
label="CATEGORIES_PATH_LABEL"
description="CATEGORIES_PATH_DESC"
class="readonly"
size="40"
readonly="true"
/>
</fieldset>
<field name="access" type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
class="inputbox"
/>
<fieldset name="publish">
<field name="id" type="text"
default="0"
readonly="true"
class="readonly"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
/>
</fieldset>
<field name="rules" type="rules"
id="rules"
label="JFIELD_RULES_LABEL"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_jem"
section="category"
/>
<fieldset name="request"
addfieldpath="/administrator/components/com_jem/models/fields"
>
<field name="locid" type="modal_venue"
label="COM_JEM_VENUE"
description="COM_JEM_VENUE"
size="40"
required="false"
/>
<field name="contactid" type="modal_contact"
label="COM_JEM_CONTACT"
description="COM_JEM_CONTACT"
size="40"
required="false"
/>
</fieldset>
<fieldset name="confemail" label="COM_JEM_CATEGORY_FIELDSET_EMAIL">
<field name="email" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_CATEGORY_INPUT_EMAIL"
/>
<field name="emailacljl" type="radio"
class="inputbox btn-group btn-group-yesno"
label="COM_JEM_CATEGORY_SEND_EMAIL_USER_ACL"
description="COM_JEM_CATEGORY_SEND_EMAIL_USER_ACL_DESC"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
<fieldset name="image" label="COM_JEM_IMAGE">
<field name="image" type="imageselect"
class="inputbox form-control"
size="40"
label="COM_JEM_IMAGESELECT"
imagetype="categories"
description="COM_JEM_IMAGESELECT"
/>
</fieldset>
<fieldset name="meta" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<field name="meta_keywords" type="textarea"
class="inputbox"
rows="3" cols="30"
label="JFIELD_META_KEYWORDS_LABEL"
description="COM_JEM_FIELD_METAKEYWORDS_DESC"
/>
<field name="meta_description" type="textarea"
class="inputbox"
rows="3" cols="30"
label="JFIELD_META_DESCRIPTION_LABEL"
description="COM_JEM_FIELD_METADESCRIPTION_DESC"
/>
</fieldset>
<field name="metadesc" type="textarea"
label="JFIELD_META_DESCRIPTION_LABEL"
description="JFIELD_META_DESCRIPTION_DESC"
rows="3"
cols="40"
/>
<field name="metakey" type="textarea"
label="JFIELD_META_KEYWORDS_LABEL"
description="JFIELD_META_KEYWORDS_DESC"
rows="3"
cols="40"
/>
<field name="created_user_id" type="user"
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
desc="JGLOBAL_FIELD_CREATED_BY_DESC"
/>
<field name="created_time" type="text"
label="JGLOBAL_CREATED_DATE"
class="readonly"
filter="unset"
readonly="true"
/>
<field name="modified_user_id" type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
filter="unset"
/>
<field name="modified_time" type="text"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
class="readonly"
filter="unset"
readonly="true"
/>
<field name="language" type="contentlanguage"
label="JFIELD_LANGUAGE_LABEL"
description="COM_CATEGORIES_FIELD_LANGUAGE_DESC"
class="inputbox"
>
<option value="*">JALL</option>
</field>
</form>

View File

@ -0,0 +1,698 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<config>
<inlinehelp button="show"/>
</config>
<fieldset name="details" addfieldpath="/administrator/components/com_jem/models/fields">
<field name="articletext" type="editor"
class="inputbox"
label="COM_JEM_EVENT_FIELD_ARTICLETEXT_LABEL"
description="COM_JEM_EVENT_FIELD_ARTICLETEXT_DESC"
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
hide="pagebreak"
/>
<field name="featured" type="radio"
class="inputbox btn-group btn-group-yesno"
label="JFEATURED"
description="COM_JEM_EVENT_FIELD_FEATURED_DESC"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="access" type="accesslevel"
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
class="inputbox"
size="1"
/>
<field name="title" type="text"
class="inputbox"
size="40"
label="COM_JEM_EVENT_TITLE"
description="COM_JEM_EVENT_TITLE"
required="true"
/>
<field name="alias" type="text"
class="inputbox"
size="40"
label="COM_JEM_ALIAS"
description="COM_JEM_ALIAS"
required="false"
hint="JFIELD_ALIAS_PLACEHOLDER"
/>
<field name="datdescription" type="editor"
hide="pagebreak,readmore"
class="inputbox"
rows="3" cols="40"
label="COM_JEM_EVENT_DESCRIPTION"
description="COM_JEM_EVENT_DESCRIPTION_DESC"
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
/>
<field name="dates" type="calendarjem"
label="COM_JEM_STARTDATE"
description="COM_JEM_STARTDATE"
class="inputbox"
size="22"
format="%Y-%m-%d"
translateformat="true"
filter="string"
showtime="false"
/>
<field name="enddates" type="calendarjem"
label="COM_JEM_ENDDATE"
description="COM_JEM_ENDDATE"
class="inputbox"
size="22"
format="%Y-%m-%d"
translateformat="true"
filter="string"
showtime="false"
/>
<field name="times" type="starttime"
class="inputbox"
size="10"
label="COM_JEM_STARTTIME"
description="COM_JEM_STARTTIME_DESC"
required="false"
/>
<field name="endtimes" type="endtime"
class="inputbox"
size="10"
label="COM_JEM_ENDTIME"
description="COM_JEM_ENDTIME_DESC"
required="false"
/>
<field name="cats" type="catoptions"
multiple="true"
class="inputbox form-select"
size="4"
label="COM_JEM_FIELD_CATEGORIES"
labelclass=""
description="COM_JEM_FIELD_CATEGORIES_DESC"
required="true"
/>
<field name="hits" type="hits"
default="0"
label="COM_JEM_EVENT_FIELD_HITS_LABEL"
description="COM_JEM_EVENT_FIELD_HITS_DESC"
/>
</fieldset>
<fieldset name="publish">
<field name="id" type="text"
default="0"
readonly="true"
class="readonly"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
/>
<field name="created" type="calendar"
class="readonly"
label="JGLOBAL_FIELD_CREATED_LABEL"
description="JGLOBAL_FIELD_CREATED_DESC"
size="22"
default="now"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
translateformat="true"
filter="user_utc"
showtime="true"
filterformat="%Y-%m-%d %H:%M:%S"
/>
<field name="modified" type="calendar"
class="readonly"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
description="COM_JEM_EDITED_AT"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
translateformat="true"
filter="user_utc"
showtime="true"
filterformat="%Y-%m-%d %H:%M:%S"
/>
<field name="version" type="text"
default="0"
readonly="true"
class="readonly"
label="COM_JEM_REVISED"
description="COM_JEM_REVISED"
/>
<field name="created_by" type="user"
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
description="JGLOBAL_FIELD_CREATED_BY_Desc"
/>
<field name="created_by_alias" type="text"
label="COM_JEM_FIELD_CREATED_BY_ALIAS_LABEL"
description="COM_JEM_FIELD_CREATED_BY_ALIAS_DESC"
class="inputbox"
size="20"
/>
<field name="published" type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
class="inputbox"
size="1"
default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
</fieldset>
<fieldset name="request"
addfieldpath="/administrator/components/com_jem/models/fields"
>
<field name="locid" type="modal_venue"
label="COM_JEM_VENUE"
description="COM_JEM_SELECTVENUE_DESC"
size="40"
required="false"
default="0"
/>
<field name="contactid" type="modal_contact"
label="COM_JEM_CONTACT"
description="COM_JEM_CONTACT_DESC"
size="40"
required="false"
default="0"
/>
</fieldset>
<fieldset name="image"
label="COM_JEM_IMAGE"
>
<field name="datimage" type="imageselect"
class="inputbox"
size="40"
label="COM_JEM_IMAGESELECT"
imagetype="events"
description="COM_JEM_IMAGESELECT"
/>
</fieldset>
<fieldset name="custom">
<field name="custom1" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_EVENT_CUSTOM_FIELD1"
description="COM_JEM_EVENT_CUSTOM_FIELD1_DESC"
/>
<field name="custom2" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_EVENT_CUSTOM_FIELD2"
description="COM_JEM_EVENT_CUSTOM_FIELD2_DESC"
/>
<field name="custom3" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_EVENT_CUSTOM_FIELD3"
description="COM_JEM_EVENT_CUSTOM_FIELD3_DESC"
/>
<field name="custom4" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_EVENT_CUSTOM_FIELD4"
description="COM_JEM_EVENT_CUSTOM_FIELD4_DESC"
/>
<field name="custom5" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_EVENT_CUSTOM_FIELD5"
description="COM_JEM_EVENT_CUSTOM_FIELD5_DESC"
/>
<field name="custom6" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_EVENT_CUSTOM_FIELD6"
description="COM_JEM_EVENT_CUSTOM_FIELD6_DESC"
/>
<field name="custom7" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_EVENT_CUSTOM_FIELD7"
description="COM_JEM_EVENT_CUSTOM_FIELD7_DESC"
/>
<field name="custom8" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_EVENT_CUSTOM_FIELD8"
description="COM_JEM_EVENT_CUSTOM_FIELD8_DESC"
/>
<field name="custom9" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_EVENT_CUSTOM_FIELD9"
description="COM_JEM_EVENT_CUSTOM_FIELD9_DESC"
/>
<field name="custom10" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_EVENT_CUSTOM_FIELD10"
description="COM_JEM_EVENT_CUSTOM_FIELD10_DESC"
/>
</fieldset>
<fieldset name="registration">
<field name="registra" type="list"
label="COM_JEM_EVENT_FIELD_ENABLE_REGISTRATION"
description="COM_JEM_EVENT_FIELD_ENABLE_REGISTRATION_DESC"
class="inputbox"
default="0"
required="false"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
<option value="2">COM_JEM_EVENT_FIELD_FROM</option>
</field>
<field name="registra_from" type="calendar"
label="COM_JEM_EVENT_FIELD_REGISTRATION_FROM"
description="COM_JEM_EVENT_FIELD_REGISTRATION_FROM_DESC"
class="input-medium"
default="now"
filter="user_utc"
format="%Y-%m-%d %H:%M:%S"
filterformat="Y-m-d H:i:s"
singleheader="true"
showtime="true"
timeformat="24"
todaybutton="true"
weeknumbers="true"
filltable="true"
showon="registra:2"
/>
<field name="registra_until" type="calendar"
label="COM_JEM_EVENT_FIELD_REGISTRATION_UNTIL"
description="COM_JEM_EVENT_FIELD_REGISTRATION_UNTIL_DESC"
class="input-medium"
filter="user_utc"
format="%Y-%m-%d %H:%M:%S"
filterformat="Y-m-d H:i:s"
singleheader="true"
showtime="true"
timeformat="24"
todaybutton="true"
weeknumbers="true"
filltable="true"
showon="registra:2"
/>
<field name="reginvitedonly" type="checkbox"
class="inputbox"
label="COM_JEM_EDITEVENT_FIELD_REG_INVITED_ONLY"
description="COM_JEM_EDITEVENT_FIELD_REG_INVITED_ONLY_DESC"
checked="0"
/>
<field name="unregistra" type="list"
label="COM_JEM_EVENT_FIELD_ENABLE_ANNULATION"
description="COM_JEM_EVENT_FIELD_ENABLE_ANNULATION_DESC"
class="inputbox"
default="0"
required="false"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
<option value="2">COM_JEM_EVENT_FIELD_UNTIL</option>
</field>
<field name="unregistra_until" type="calendar"
label="COM_JEM_EVENT_FIELD_ANNULATION_UNTIL"
description="COM_JEM_EVENT_FIELD_ANNULATION_UNTIL_DESC"
class="input-medium"
filter="user_utc"
format="%Y-%m-%d %H:%M:%S"
filterformat="Y-m-d H:i:s"
singleheader="true"
showtime="true"
timeformat="24"
todaybutton="true"
weeknumbers="true"
filltable="true"
showon="unregistra:2"
/>
<field name="maxplaces" type="number"
size="4"
class="inputbox"
label="COM_JEM_MAX_PLACES"
description="COM_JEM_MAX_PLACES_DESC"
filter="integer"
default="0"
min="0"
/>
<field name="minbookeduser" type="number"
size="4"
class="inputbox"
label="COM_JEM_MINIMUM_BOOKED_PLACES_PER_USER"
description="COM_JEM_MINIMUM_BOOKED_PLACES_PER_USER_DESC"
filter="integer"
default="1"
min="1"
/>
<field name="maxbookeduser" type="number"
size="4"
class="inputbox"
label="COM_JEM_MAXIMUM_BOOKED_PLACES_PER_USER"
description="COM_JEM_MAXIMUM_BOOKED_PLACES_PER_USER_DESC"
filter="integer"
default="1"
min="1"
/>
<field name="reservedplaces" type="number"
size="4"
class="inputbox"
label="COM_JEM_RESERVED_PLACES"
description="COM_JEM_RESERVED_PLACES_DESC"
filter="integer"
default="0"
min="0"
/>
<field name="invited" type="modal_users"
label="COM_JEM_EDITEVENT_FIELD_INVITED_USERS"
description="COM_JEM_EDITEVENT_FIELD_INVITED_USERS_DESC"
size="4"
required="false"
/>
<field name="avplaces" type="text"
size="4"
class="readonly"
readonly="true"
disabled="true"
label="COM_JEM_AVAILABLE_PLACES"
description="COM_JEM_AVAILABLE_PLACES_DESC"
/>
<field name="waitinglist" type="checkbox"
class="inputbox btn-group btn-group-yesno"
label="COM_JEM_ENABLE_WAITINGLIST"
description="COM_JEM_ENABLE_WAITINGLIST_DESC"
value="1"
checked="0"
/>
<field name="requestanswer" type="checkbox"
class="inputbox btn-group btn-group-yesno"
label="COM_JEM_REQUEST_ANSWER_ASSISTENCE"
description="COM_JEM_REQUEST_ANSWER_ASSISTENCE_DESC"
value="1"
checked="0"
/>
<field name="seriesbooking" type="checkbox"
size="1"
class="inputbox"
label="COM_JEM_EDITEVENT_FIELD_SERIES_EVENT_BOOKING"
description="COM_JEM_EDITEVENT_FIELD_SERIES_EVENT_BOOKING_DESC"
value="1"
checked="0"
/>
<field name="singlebooking" type="checkbox"
size="1"
class="inputbox"
label="COM_JEM_EDITEVENT_FIELD_SINGLE_EVENT_BOOKING"
description="COM_JEM_EDITEVENT_FIELD_SINGLE_EVENT_BOOKING_DESC"
value="1"
checked="0"
/>
</fieldset>
<fieldset name="recurrence"
label="COM_JEM_RECURRING_EVENTS"
>
<field name="recurrence_type" type="list"
default="0"
label="COM_JEM_RECURRENCE"
description="COM_JEM_RECURRENCE"
>
<option value="0">COM_JEM_NOTHING</option>
<option value="1">COM_JEM_DAILY</option>
<option value="2">COM_JEM_WEEKLY</option>
<option value="3">COM_JEM_MONTHLY</option>
<option value="4">COM_JEM_WEEKDAY</option>
<option value="5">COM_JEM_YEARLY</option>
</field>
<field name="recurrence_limit_date" type="calendarjem"
default="now"
label="COM_JEM_RECURRENCE_COUNTER"
description="COM_JEM_RECURRENCE_COUNTER"
class="inputbox"
size="22"
format="%Y-%m-%d"
translateformat="true"
filter="string"
showtime="false"
/>
</fieldset>
<fieldset name="meta"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS"
>
<field name="meta_keywords" type="textarea"
id="meta_keywordsOR"
label="JFIELD_META_KEYWORDS_LABEL"
description="JFIELD_META_KEYWORDS_DESC"
class="inputbox"
rows="3" cols="30"
/>
<field name="meta_description" type="textarea"
id="meta_descriptionOR"
label="JFIELD_META_DESCRIPTION_LABEL"
description="JFIELD_META_DESCRIPTION_DESC"
class="inputbox"
rows="3" cols="30"
/>
</fieldset>
<fields name="attribs">
<fieldset name="basic"
label="COM_JEM_EVENT_FIELDSET_ATTRIBS_LABEL"
>
<field name="event_show_author" type="list"
label="COM_JEM_EVENT_FIELD_SHOW_AUTHOR_LABEL"
description="COM_JEM_EVENT_FIELD_SHOW_AUTHOR_DESC"
default=""
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="event_link_author" type="list"
label="COM_JEM_EVENT_FIELD_LINK_AUTHOR_LABEL"
description="COM_JEM_EVENT_FIELD_LINK_AUTHOR_DESC"
default=""
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="event_show_contact" type="list"
label="COM_JEM_EVENT_FIELD_SHOW_CONTACT_LABEL"
description="COM_JEM_EVENT_FIELD_SHOW_CONTACT_DESC"
default=""
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="event_link_contact" type="list"
label="COM_JEM_EVENT_FIELD_LINK_CONTACT_LABEL"
description="COM_JEM_EVENT_FIELD_LINK_CONTACT_DESC"
default=""
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="event_show_hits" type="list"
label="COM_JEM_EVENT_FIELD_SHOW_HITS_LABEL"
description="COM_JEM_EVENT_FIELD_SHOW_HITS_DESC"
default=""
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="event_show_print_icon" type="list"
label="JGLOBAL_SHOW_PRINT_ICON_LABEL"
description="JGLOBAL_SHOW_PRINT_ICON_DESC"
default=""
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="event_show_email_icon" type="list"
label="JGLOBAL_SHOW_EMAIL_ICON_LABEL"
description="JGLOBAL_SHOW_EMAIL_ICON_DESC"
default=""
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="event_show_ical_icon" type="list"
label="COM_JEM_EVENT_FIELD_SHOW_ICAL_ICON"
description="COM_JEM_EVENT_FIELD_SHOW_ICAL_ICON_DESC"
default=""
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="event_show_detailstitle" type="list"
label="COM_JEM_DISPLAY_EVENT_TITLE"
description="COM_JEM_DISPLAY_EVENT_TITLE_DESC"
class="inputbox"
default=""
required="false"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="evvenues"
label="COM_JEM_VENUES"
>
<field name="event_show_locdescription" type="list"
label="COM_JEM_DISPLAY_VENUE_DESCRIPT"
description="COM_JEM_DISPLAY_VENUE_DESCRIPT_DESC"
class="inputbox"
default=""
required="false"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="event_show_detailsadress" type="list"
label="COM_JEM_DISPLAY_ADDRESS"
description="COM_JEM_DISPLAY_ADDRESS_DESC"
class="inputbox"
default=""
required="false"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="event_show_detlinkvenue" type="list"
label="COM_JEM_DISPLAY_ADDRESS"
description="COM_JEM_DISPLAY_ADDRESS_DESC"
class="inputbox"
default=""
required="false"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">COM_JEM_NO_LINK</option>
<option value="1">COM_JEM_LINK_TO_URL</option>
<option value="2">COM_JEM_LINK_TO_VENUEVIEW</option>
</field>
<field name="event_show_mapserv" type="list"
label="COM_JEM_DISPLAY_LINK_TO_MAP"
description="COM_JEM_DISPLAY_LINK_TO_MAP_DESC"
class="inputbox"
default=""
required="false"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">COM_JEM_NO_MAP_SERVICE</option>
<option value="1">COM_JEM_GOOGLE_MAP_LINK</option>
<option value="2">COM_JEM_GOOGLE_MAP_DISP</option>
<option value="3">COM_JEM_GOOGLE_MAP_DISP_API</option>
<option value="4">COM_JEM_OSM_MAP_LINK</option>
<option value="5">COM_JEM_OSM_MAP_DISP</option>
</field>
<field name="event_tld" type="text"
label="COM_JEM_GOOGLE_MAP_TLD"
description="COM_JEM_GOOGLE_MAP_TLD_DESC"
class="inputbox"
size="10"
maxlength="10"
required="false"
/>
<field name="event_lg" type="text"
label="COM_JEM_GOOGLE_MAP_LG"
description="COM_JEM_GOOGLE_MAP_LG_DESC"
class="inputbox"
size="10"
maxlength="10"
required="false"
/>
</fieldset>
<fieldset name="evregistration"
label="COM_JEM_REGISTRATION"
>
<field name="event_comunsolution" type="list"
label="COM_JEM_COM_SOL"
description="COM_JEM_COM_SOL_DESC"
class="inputbox"
default=""
required="false"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">COM_JEM_DONT_USE_COM_SOL</option>
<option value="1">COM_JEM_COMBUILDER</option>
</field>
<field name="event_comunoption" type="list"
label="COM_JEM_TYPE_COM_INTEGRATION"
description="COM_JEM_TYPE_COM_INTEGRATION_DESC"
class="inputbox"
default=""
required="false"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">COM_JEM_LINK_PROFILE</option>
<option value="1">COM_JEM_LINK_AVATAR</option>
</field>
</fieldset>
<fieldset name="evevents"
label="COM_JEM_EVENTS"
>
<field name="event_show_description" type="list"
label="COM_JEM_DISPLAY_EVENT_DESCRIPT"
description="COM_JEM_DISPLAY_EVENT_DESCRIPT_DESC"
class="inputbox"
default=""
required="false"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
</fields>
<fields name="metadata">
<field name="robots" type="list"
label="JFIELD_METADATA_ROBOTS_LABEL"
description="JFIELD_METADATA_ROBOTS_DESC"
default=""
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="index, follow">COM_JEM_INDEX_FOLLOW</option>
<option value="noindex, follow">COM_JEM_NOINDEX_FOLLOW</option>
<option value="index, nofollow">COM_JEM_INDEX_NOFOLLOW</option>
<option value="noindex, nofollow">COM_JEM_NOINDEX_NOFOLLOW</option>
</field>
<field name="author" type="text"
label="JAUTHOR"
description="JFIELD_METADATA_AUTHOR_DESC"
size="20" />
<field name="rights" type="textarea"
label="JFIELD_META_RIGHTS_LABEL"
description="JFIELD_META_RIGHTS_DESC"
required="false"
filter="string"
cols="30" rows="2" />
</fields>
</form>

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<config>
<inlinehelp button="show"/>
</config>
<fieldset name="details"
addfieldpath="/administrator/components/com_jem/models/fields"
>
<field name="name" type="text"
class="inputbox"
size="40"
label="COM_JEM_GROUP_NAME"
description="COM_JEM_GROUP_NAME"
required="true"
/>
<field name="description" type="editor"
class="inputbox"
label="COM_JEM_GROUP_DESCRIPTION"
description="COM_JEM_GROUP_DESCRIPTION_DESC"
hide="pagebreak,readmore"
filter="safehtml"
rows="3" cols="40"
/>
<field name="id" type="text"
class="readonly"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
default="0"
readonly="true"
/>
<field name="addvenue" type="radio"
class="inputbox btn-group btn-group-yesno"
label="COM_JEM_GROUP_ADDVENUE"
description="COM_JEM_GROUP_ADDVENUE_DESC"
default="0"
required="false"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="publishvenue" type="radio"
class="inputbox btn-group btn-group-yesno"
label="COM_JEM_GROUP_PUBLISHVENUE"
description="COM_JEM_GROUP_PUBLISHVENUE_DESC"
default="0"
required="false"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="editvenue" type="radio"
class="inputbox btn-group btn-group-yesno"
label="COM_JEM_GROUP_EDITVENUE"
description="COM_JEM_GROUP_EDITVENUE_DESC"
default="0"
required="false"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field type="spacer" name="spacer" hr="true" />
<field name="addevent" type="radio"
class="inputbox btn-group btn-group-yesno"
label="COM_JEM_GROUP_ADDEVENT"
description="COM_JEM_GROUP_ADDEVENT_DESC"
default="0"
required="false"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="publishevent" type="radio"
class="inputbox btn-group btn-group-yesno"
label="COM_JEM_GROUP_PUBLISHEVENT"
description="COM_JEM_GROUP_PUBLISHEVENT_DESC"
default="0"
required="false"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="editevent" type="radio"
class="inputbox btn-group btn-group-yesno"
label="COM_JEM_GROUP_EDITEVENT"
description="COM_JEM_GROUP_EDITEVENT_DESC"
default="0"
required="false"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field name="extension_id" type="hidden" />
<field name="filename" type="hidden" />
<field name="source" type="editor"
editor="codemirror|none"
buttons="no"
label="COM_JEM_CSSMANAGER_FIELD_SOURCE_LABEL"
description="COM_JEM_CSSMANAGER_FIELD_SOURCE_DESC"
rows="20"
cols="80"
filter="raw"
/>
</fieldset>
</form>

View File

@ -0,0 +1,252 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<config>
<inlinehelp button="show"/>
</config>
<fieldset name="details"
addfieldpath="/administrator/components/com_jem/models/fields"
>
<field name="id" type="text"
default="0"
readonly="true"
class="readonly"
label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC"
/>
<field name="venue" type="text"
class="inputbox"
size="40"
label="COM_JEM_VENUE"
description="COM_JEM_VENUE"
required="true"
/>
<field name="alias" type="text"
class="inputbox"
size="40"
label="COM_JEM_ALIAS"
description="COM_JEM_ALIAS"
hint="JFIELD_ALIAS_PLACEHOLDER"
/>
<field name="url" type="text"
class="inputbox"
size="40"
label="COM_JEM_WEBSITE"
description="COM_JEM_WEBSITE_DESC"
/>
<field name="street" type="text"
id="street"
class="inputbox"
size="40"
label="COM_JEM_STREET"
description="COM_JEM_STREET"
/>
<field name="locdescription" type="editor"
filter="\Joomla\CMS\Component\ComponentHelper::filterText"
hide="pagebreak,readmore,image"
class="inputbox"
rows="3" cols="20"
width="100%"
label="COM_JEM_VENUE_FIELD_DESCRIPTION"
description="COM_JEM_VENUE_FIELD_DESCRIPTION_DESC"
/>
<field name="latitude" type="text"
class="inputbox"
size="40"
label="COM_JEM_LATITUDE"
description="COM_JEM_LATITUDE_DESC"
/>
<field name="longitude" type="text"
class="inputbox"
size="40"
label="COM_JEM_LONGITUDE"
description="COM_JEM_LONGITUDE_DESC"
/>
<field name="postalCode" type="text"
class="inputbox"
size="40"
label="COM_JEM_ZIP"
description="COM_JEM_ZIP"
/>
<field name="city" type="text"
class="inputbox"
size="40"
label="COM_JEM_CITY"
description="COM_JEM_CITY"
/>
<field name="state" type="text"
class="inputbox"
size="40"
label="COM_JEM_STATE"
description="COM_JEM_STATE"
/>
<field name="map" type="checkbox"
class="inputbox"
size="40"
label="COM_JEM_ENABLE_MAP"
description="COM_JEM_ENABLE_MAP"
value="1"
checked="0"
/>
<field name="locimage" type="imageselect"
class="inputbox"
size="40"
imagetype="venues"
label="COM_JEM_IMAGESELECT"
description="COM_JEM_IMAGESELECT"
/>
<field name="published" type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
class="inputbox m-0"
filter="intval"
size="1"
default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field name="country" type="countryoptions"
label="COM_JEM_GLOBAL_FIELD_COUNTRY"
description="COM_JEM_GLOBAL_FIELD_COUNTRY_DESC"
class="select_country m-0"
/>
</fieldset>
<fieldset name="custom">
<field name="custom1" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_VENUE_CUSTOM_FIELD1"
description="COM_JEM_VENUE_CUSTOM_FIELD1_DESC"
/>
<field name="custom2" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_VENUE_CUSTOM_FIELD2"
description="COM_JEM_VENUE_CUSTOM_FIELD2_DESC"
/>
<field name="custom3" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_VENUE_CUSTOM_FIELD3"
description="COM_JEM_VENUE_CUSTOM_FIELD3_DESC"
/>
<field name="custom4" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_VENUE_CUSTOM_FIELD4"
description="COM_JEM_VENUE_CUSTOM_FIELD4_DESC"
/>
<field name="custom5" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_VENUE_CUSTOM_FIELD5"
description="COM_JEM_VENUE_CUSTOM_FIELD5_DESC"
/>
<field name="custom6" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_VENUE_CUSTOM_FIELD6"
description="COM_JEM_VENUE_CUSTOM_FIELD6_DESC"
/>
<field name="custom7" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_VENUE_CUSTOM_FIELD7"
description="COM_JEM_VENUE_CUSTOM_FIELD7_DESC"
/>
<field name="custom8" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_VENUE_CUSTOM_FIELD8"
description="COM_JEM_VENUE_CUSTOM_FIELD8_DESC"
/>
<field name="custom9" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_VENUE_CUSTOM_FIELD9"
description="COM_JEM_VENUE_CUSTOM_FIELD9_DESC"
/>
<field name="custom10" type="text"
size="20"
readonly="false"
class="inputbox"
label="COM_JEM_VENUE_CUSTOM_FIELD10"
description="COM_JEM_VENUE_CUSTOM_FIELD10_DESC"
/>
</fieldset>
<fieldset name="publish"
label="COM_JEM_FIELDSET_PUBLISHING"
>
<field name="created_by" type="user"
label="COM_JEM_FIELD_CREATED_BY_LABEL"
description="COM_JEM_FIELD_CREATED_BY_DESC"
/>
<field name="created" type="calendar"
class="readonly"
label="JGLOBAL_FIELD_CREATED_LABEL"
description="JGLOBAL_FIELD_CREATED_DESC"
size="22"
default="now"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
translateformat="false"
filter="user_utc"
showtime="true"
filterformat="Y-m-d H:i:s"
/>
<field name="version" type="text"
class="readonly"
label="COM_JEM_FIELD_VERSION_LABEL"
description="COM_JEM_FIELD_VERSION_DESC"
size="6"
readonly="true"
filter="unset"
/>
<field name="modified" type="calendar"
class="readonly"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
description="COM_JEM_FIELD_MODIFIED_DESC"
size="22"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
translateformat="false"
filter="user_utc"
showtime="true"
filterformat="Y-m-d H:i:s"
/>
<field name="modified_by" type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
filter="unset"
/>
</fieldset>
<fieldset name="meta"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS"
>
<field name="meta_keywords" type="textarea"
class="inputbox"
rows="3" cols="30"
label="JFIELD_META_KEYWORDS_LABEL"
description="COM_JEM_FIELD_METAKEYWORDS_DESC"
/>
<field name="meta_description" type="textarea"
class="inputbox"
rows="3" cols="30"
label="JFIELD_META_DESCRIPTION_LABEL"
description="COM_JEM_FIELD_METADESCRIPTION_DESC"
/>
</fieldset>
</form>

View File

@ -0,0 +1,263 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
require_once __DIR__ . '/admin.php';
/**
* JEM Component Group Model
*
*/
class JemModelGroup extends JemModelAdmin
{
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
*/
protected function canDelete($record)
{
if (!empty($record->id) && ($record->published == -2))
{
$user = JemFactory::getUser();
if (!empty($record->catid)) {
return $user->authorise('core.delete', 'com_jem.category.'.(int) $record->catid);
} else {
return $user->authorise('core.delete', 'com_jem');
}
}
return false;
}
/**
* 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');
}
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param type The table type to instantiate. Optional.
* @param string A prefix for the table class name. Optional.
* @param array Configuration data for model. Optional.
* @return Table A database object
*/
public function getTable($type = 'Group', $prefix = 'JemTable', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form. Optional.
* @param boolean $loadData True if the form is to load its own data (default case), false if not. Optional.
* @return mixed A JForm object on success, false on failure
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_jem.group', 'group', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
/**
* Method to get a single record.
*
* @param integer The id of the primary key.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($pk = null)
{
$item = parent::getItem($pk);
return $item;
}
/**
* Method to get the data that should be injected in the form.
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_jem.edit.group.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param Table The table object to prepare.
*
*/
protected function _prepareTable($table)
{
$db = Factory::getContainer()->get('DatabaseDriver');
$app = Factory::getApplication();
// Make sure the data is valid
if (!$table->check()) {
$this->setError($table->getError());
return;
}
// Store data
if (!$table->store(true)) {
throw new Exception($table->getError(), 500);
}
$members = $app->input->get('maintainers', array(), 'array');
// Updating group references
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__jem_groupmembers'));
$query->where('group_id = '.(int)$table->id);
$db->setQuery($query);
$db->execute();
foreach($members as $member)
{
$member = intval($member);
$query = $db->getQuery(true);
$columns = array('group_id', 'member');
$values = array((int)$table->id, $member);
$query->insert($db->quoteName('#__jem_groupmembers'))
->columns($db->quoteName($columns))
->values(implode(',', $values));
$db->setQuery($query);
$db->execute();
}
}
/**
* Method to get the members data
*
* @access public
* @return array List of members
*
*/
public function getMembers()
{
$members = $this->_members();
$users = array();
if (!empty($members)) {
$query = 'SELECT id AS value, username, name'
. ' FROM #__users'
. ' WHERE id IN ('.$members.')'
. ' ORDER BY name ASC'
;
$this->_db->setQuery($query);
$users = $this->_db->loadObjectList();
foreach ($users as &$user) {
$user->text = $user->name . ' (' . $user->username . ')';
}
}
return $users;
}
/**
* Method to get the selected members.
*
* @access protected
* @return string
*
*/
protected function _members()
{
$item = parent::getItem();
$members = null;
//get selected members
if ($item->id) {
$query = 'SELECT member'
. ' FROM #__jem_groupmembers'
. ' WHERE group_id = '.(int)$item->id;
$this->_db->setQuery ($query);
$member_ids = $this->_db->loadColumn();
if (is_array($member_ids)) {
$members = implode(',', $member_ids);
}
}
return $members;
}
/**
* Method to get the available users.
*
* @access public
* @return mixed
*
*/
public function getAvailable()
{
$members = $this->_members();
// get non selected members
$query = 'SELECT id AS value, username, name FROM #__users';
$query .= ' WHERE block = 0' ;
if ($members) {
$query .= ' AND id NOT IN ('.$members.')' ;
}
$query .= ' ORDER BY name ASC';
$this->_db->setQuery($query);
$available = $this->_db->loadObjectList();
foreach ($available as &$item) {
$item->text = $item->name . ' (' . $item->username . ')';
}
return $available;
}
}

View File

@ -0,0 +1,183 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Component\ComponentHelper;
/**
* JEM Component Groups Model
*
**/
class JemModelGroups extends ListModel
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'name', 'a.name',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* @Note Calling getState in this method will result in recursion.
*/
protected function populateState($ordering = null, $direction = null)
{
$search = $this->getUserStateFromRequest($this->context.'.filter_search', 'filter_search');
$this->setState('filter_search', $search);
$published = $this->getUserStateFromRequest($this->context.'.filter_state', 'filter_state', '', 'string');
$this->setState('filter_state', $published);
// $filterfield = $this->getUserStateFromRequest($this->context.'.filter_type', 'filter_type', 0, 'int');
// $this->setState('filter_type', $filterfield);
// Load the parameters.
$params = ComponentHelper::getParams('com_jem');
$this->setState('params', $params);
// List state information.
parent::populateState('a.name', 'asc');
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
* @return string A store id.
*
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter_search');
$id .= ':' . $this->getState('filter_published');
// $id .= ':' . $this->getState('filter_type');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
*/
protected function getListQuery()
{
// Create a new query object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select($this->getState('list.select', 'a.*'));
$query->from($db->quoteName('#__jem_groups').' AS a');
// Join over the users for the checked out user.
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id = a.checked_out');
$search = $this->getState('filter_search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
} else {
$search = $db->Quote('%'.$db->escape($search, true).'%');
/* search category */
if ($search) {
$query->where('a.name LIKE '.$search);
}
}
}
// $query->group('a.id');
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
//if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
// $orderCol = 'c.title '.$orderDirn.', a.ordering';
//}
$query->order($db->escape($orderCol.' '.$orderDirn));
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
/**
* Method to get the userinformation of edited/submitted venues
*
* @access private
* @return object
*
*/
public function getItems()
{
$items = parent::getItems();
return $items;
}
/**
* Method to remove a group
*
* @access public
* @return boolean True on success
*
*/
public function delete($cid = array())
{
if (is_array($cid) && count($cid))
{
\Joomla\Utilities\ArrayHelper::toInteger($cid);
$cids = implode(',', $cid);
$query = 'DELETE FROM #__jem_groups'
. ' WHERE id IN ('. $cids .')'
;
$this->_db->setQuery($query);
if ($this->_db->execute() === false) {
$this->setError($this->_db->getError());
return false;
}
$query = 'DELETE FROM #__jem_groupmembers'
. ' WHERE group_id IN ('. $cids .')'
;
$this->_db->setQuery($query);
if ($this->_db->execute() === false) {
$this->setError($this->_db->getError());
return false;
}
}
return true;
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
/**
* JEM Component Help Model
*
* @package JEM
*
*/
class JemModelHelp extends BaseDatabaseModel
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
}
?>

View File

@ -0,0 +1,219 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filter\InputFilter;
jimport('joomla.filesystem.file');
/**
* Housekeeping-Model
*/
class JemModelHousekeeping extends BaseDatabaseModel
{
const EVENTS = 1;
const VENUES = 2;
const CATEGORIES = 3;
/**
* Map logical name to folder and db names
* @var stdClass
*/
private $map = null;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$map = array();
$map[JemModelHousekeeping::EVENTS] = array("folder" => "events", "table" => "events", "field" => "datimage");
$map[JemModelHousekeeping::VENUES] = array("folder" => "venues", "table" => "venues", "field" => "locimage");
$map[JemModelHousekeeping::CATEGORIES] = array("folder" => "categories", "table" => "categories", "field" => "image");
$this->map = $map;
}
/**
* Method to delete the images
*
* @access public
* @return int
*/
public function delete($type)
{
// Set FTP credentials, if given
jimport('joomla.client.helper');
ClientHelper::setCredentialsFromRequest('ftp');
// Get some data from the request
$images = $this->getImages($type);
$folder = $this->map[$type]['folder'];
$count = count($images);
$fail = 0;
foreach ($images as $image)
{
if ($image !== InputFilter::getInstance()->clean($image, 'path')) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_UNABLE_TO_DELETE').' '.htmlspecialchars($image, ENT_COMPAT, 'UTF-8'), 'warning');
$fail++;
continue;
}
$fullPath = Path::clean(JPATH_SITE.'/images/jem/'.$folder.'/'.$image);
$fullPaththumb = Path::clean(JPATH_SITE.'/images/jem/'.$folder.'/small/'.$image);
if (is_file($fullPath)) {
File::delete($fullPath);
if (File::exists($fullPaththumb)) {
File::delete($fullPaththumb);
}
}
}
$deleted = $count - $fail;
return $deleted;
}
/**
* Deletes zombie cats_event_relations with no existing event or category
* @return boolean
*/
public function cleanupCatsEventRelations()
{
$db = Factory::getContainer()->get('DatabaseDriver');
$db->setQuery('DELETE cat FROM #__jem_cats_event_relations as cat'
.' LEFT OUTER JOIN #__jem_events as e ON cat.itemid = e.id'
.' WHERE e.id IS NULL');
$db->execute();
$db->setQuery('DELETE cat FROM #__jem_cats_event_relations as cat'
.' LEFT OUTER JOIN #__jem_categories as c ON cat.catid = c.id'
.' WHERE c.id IS NULL');
$db->execute();
return true;
}
/**
* Truncates JEM tables with exception of settings table
*/
public function truncateAllData()
{
$result = true;
$tables = array('attachments', 'categories', 'cats_event_relations', 'events', 'groupmembers', 'groups', 'register', 'venues');
$db = Factory::getContainer()->get('DatabaseDriver');
foreach ($tables as $table) {
$db->setQuery('TRUNCATE #__jem_'.$table);
if ($db->execute() === false) {
// report but continue
JemHelper::addLogEntry('Error truncating #__jem_'.$table, __METHOD__, Log::ERROR);
$result = false;
}
}
$categoryTable = $this->getTable('category', 'JemTable');
$categoryTable->addRoot();
return $result;
}
/**
* Method to count the cat_relations table
*
* @access public
* @return int
*/
public function getCountcats()
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select(array('*'));
$query->from('#__jem_cats_event_relations');
$db->setQuery($query);
$db->execute();
$total = $db->loadObjectList();
return is_array($total) ? count($total) : 0;
}
/**
* Method to determine the images to delete
*
* @access private
* @return array
*/
private function getImages($type)
{
$images = array_diff($this->getAvailable($type), $this->getAssigned($type));
return $images;
}
/**
* Method to determine the assigned images
*
* @access private
* @return array
*/
private function getAssigned($type)
{
$query = 'SELECT '.$this->map[$type]['field'].' FROM #__jem_'.$this->map[$type]['table'];
$this->_db->setQuery($query);
$assigned = $this->_db->loadColumn();
return $assigned;
}
/**
* Method to determine the unassigned images
*
* @access private
* @return array
*/
private function getAvailable($type)
{
// Initialize variables
$basePath = JPATH_SITE.'/images/jem/'.$this->map[$type]['folder'];
$images = array ();
// Get the list of files and folders from the given folder
$fileList = Folder::files($basePath);
// Iterate over the files if they exist
if ($fileList !== false) {
foreach ($fileList as $file)
{
if (is_file($basePath.'/'.$file) && substr($file, 0, 1) != '.') {
$images[] = $file;
}
}
}
return $images;
}
}
?>

View File

@ -0,0 +1,221 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Filesystem\Path;
/**
* JEM Component Imagehandler Model
*
* @package JEM
*/
class JemModelImagehandler extends BaseDatabaseModel
{
/**
* Array to cache list of images
*
* @var array
*/
protected $_list = null;
/**
* Pagination object
*
* @var object
*/
protected $_pagination = null;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$app = Factory::getApplication();
$option = $app->input->getString('option', 'com_jem');
$task = $app->input->getVar('task', '');
$limit = $app->getUserStateFromRequest($option.'imageselect'.$task.'limit', 'limit', $app->get('list_limit'), 'int');
$limitstart = $app->getUserStateFromRequest($option.'imageselect'.$task.'limitstart', 'limitstart', 0, 'int');
$limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0;
$search = $app->getUserStateFromRequest($option.'.filter_search', 'filter_search', '', 'string');
$search = trim(\Joomla\String\StringHelper::strtolower($search));
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
$this->setState('search', $search);
}
function getState($property = null, $default = null)
{
static $set = false;
if (!$set) {
$folder = Factory::getApplication()->input->get('folder', '');
$this->setState('folder', $folder);
$set = true;
}
return parent::getState($property);
}
/**
* Build imagelist
*
* @return array $list The imagefiles from a directory to display
*/
public function getImages()
{
$list = $this->getList();
$listimg = array();
$s = $this->getState('limitstart');
$l = $this->getState('limit');
$t = $this->getState('total');
if ($t < ($s + $l)) {
$l = $t - $s;
}
for ($i = $s; $i < $s + $l; $i++)
{
$list[$i]->size = $this->_parseSize(filesize($list[$i]->path));
$info = getimagesize($list[$i]->path);
if ($info === false) {
continue; // skip file on error
}
$list[$i]->width = $info[0];
$list[$i]->height = $info[1];
//$list[$i]->type = $info[2];
//$list[$i]->mime = $info['mime'];
if (($info[0] > 60) || ($info[1] > 60)) {
$dimensions = $this->_imageResize($info[0], $info[1], 60);
$list[$i]->width_60 = $dimensions[0];
$list[$i]->height_60 = $dimensions[1];
} else {
$list[$i]->width_60 = $list[$i]->width;
$list[$i]->height_60 = $list[$i]->height;
}
$listimg[] = $list[$i];
}
return $listimg;
}
/**
* Build imagelist
*
* @return array $list The imagefiles from a directory
*/
public function getList()
{
// Only process the list once per request
if (!is_array($this->_list))
{
// Get folder from request
$folder = $this->getState('folder');
$search = $this->getState('search');
// Initialize variables
$basePath = JPATH_SITE.'/images/jem/'.$folder;
// Get the list of files and folders from the given folder
$fileList = Folder::files($basePath);
// Iterate over the files if they exist
if ($fileList !== false) {
$this->_list = array();
foreach ($fileList as $file) {
if (is_file($basePath.'/'.$file) && substr($file, 0, 1) != '.') {
if (empty($search) || stristr($file, $search)) {
$tmp = new CMSObject();
$tmp->name = $file;
$tmp->path = Path::clean($basePath.'/'.$file);
$this->_list[] = $tmp;
}
}
}
}
$this->setState('total', is_array($this->_list) ? count($this->_list) : 0);
}
return $this->_list;
}
/**
* Method to get a pagination object for the images
*
* @access public
* @return integer
*/
public function getPagination()
{
if (empty($this->_pagination)) {
$this->_pagination = new Pagination($this->getState('total'), $this->getState('limitstart'), $this->getState('limit'));
}
return $this->_pagination;
}
/**
* Build display size
*
* @return array width and height
*/
protected function _imageResize($width, $height, $target)
{
if (($width > 0) && ($height > 0)) {
//takes the larger size of the width and height and applies the
//formula accordingly...this is so this script will work
//dynamically with any size image
if ($width > $height) {
$percentage = ($target / $width);
} else {
$percentage = ($target / $height);
}
//gets the new value and applies the percentage, then rounds the value
$width = round($width * $percentage);
$height = round($height * $percentage);
}
return array($width, $height);
}
/**
* Return human readable size info
*
* @return string size of image
*/
protected function _parseSize($size)
{
if ($size < 1024) {
return $size . ' Bytes';
} elseif ($size < (1024 * 1024)) {
return sprintf('%01.2f', $size / 1024.0) . ' kB';
} else {
return sprintf('%01.2f', $size / (1024.0 * 1024)) . ' MB';
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,107 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
/**
* JEM Component Main Model
*
* @package JEM
*/
class JemModelMain extends BaseDatabaseModel
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
/**
* Get number of items for given states of a table
*
* @param string $tablename Name of the table
* @param array $map Maps state name to state number
* @return stdClass
*/
protected function getStateData($tablename, &$map = null)
{
$db = Factory::getContainer()->get('DatabaseDriver');
if($map == null) {
$map = array('published' => 1, 'unpublished' => 0, 'archived' => 2, 'trashed' => -2);
}
// Get nr of all states of events
$query = $db->getQuery(true);
$query->select(array('published', 'COUNT(published) as num'));
$query->from($db->quoteName($tablename));
if ($tablename == "#__jem_categories")
{
$query->where('alias NOT LIKE "root"');
}
$query->group('published');
$db->setQuery($query);
$result = $db->loadObjectList("published");
$data = new stdClass();
$data->total = 0;
foreach ($map as $key => $value) {
if ($result) {
// Check whether we have the current state in the DB result
if(array_key_exists($value, $result)) {
$data->$key = $result[$value]->num;
$data->total += $data->$key;
} else {
$data->$key = 0;
}
} else {
$data->$key = 0;
}
}
return $data;
}
/**
* Returns number of events for all possible states
*
* @return stdClass
*/
public function getEventsData()
{
return $this->getStateData('#__jem_events');
}
/**
* Returns number of venues for all possible states
*
* @return stdClass
*/
public function getVenuesData()
{
return $this->getStateData('#__jem_venues');
}
/**
* Returns number of categories for all possible states
*
* @return stdClass
*/
public function getCategoriesData()
{
return $this->getStateData('#__jem_categories');
}
}
?>

View File

@ -0,0 +1,306 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\Archive\Archive;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
// TODO: Improve error handling
/**
* Sampledata Model
*/
class JemModelSampledata extends BaseDatabaseModel
{
/**
* Sample data directory
*
* @var string
*/
private $sampleDataDir = null;
/**
* Files data array
*
* @var array
*/
private $filelist = array();
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
if ($this->checkForJemData()) {
return false;
}
$this->sampleDataDir = JPATH_COMPONENT_ADMINISTRATOR . '/assets/';
$this->filelist = $this->unpack();
}
/**
* Process sampledata
*
* @return boolean True on success
*/
public function loadData()
{
if ($this->checkForJemData()) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_SAMPLEDATA_DATA_ALREADY_INSTALLED'), 'warning');
return false;
}
$scriptfile = $this->sampleDataDir . 'sampledata.sql';
// load sql file
if (!($buffer = file_get_contents($scriptfile))) {
return false;
}
// extract queries out of sql file
$queries = $this->splitSql($buffer);
// Process queries
foreach ($queries as $query) {
$query = trim($query);
if ($query != '' && $query[0] != '#') {
$this->_db->setQuery($query);
$this->_db->execute();
}
}
// assign admin userid to created_events
$this->assignAdminId();
// move images in proper directory
$this->moveImages();
// delete temporary extraction folder
if (!$this->deleteTmpFolder()) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_SAMPLEDATA_UNABLE_TO_DELETE_TMP_FOLDER'), 'warning');
}
return true;
}
/**
* Unpack archive and build array of files
*
* @return boolean Ambigous mixed>
*/
private function unpack()
{
jimport('joomla.filesystem.archive');
$archive = $this->sampleDataDir . 'sampledata.zip';
// Temporary folder to extract the archive into
$tmpdir = uniqid('sample_');
// Clean the paths to use for archive extraction
$extractdir = Path::clean(JPATH_ROOT . '/tmp/' . $tmpdir);
$archive = Path::clean($archive);
// extract archive
try {
$archiveObj = new Archive(array('tmp_path' => Factory::getApplication()->get('tmp_path')));
$result = $archiveObj->extract($archive, $extractdir);
} catch (\Exception $e) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_SAMPLEDATA_UNABLE_TO_EXTRACT_ARCHIVE'), 'warning');
return false;
}
if ($result === false) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_SAMPLEDATA_UNABLE_TO_EXTRACT_ARCHIVE'), 'warning');
return false;
}
// return the files found in the extract folder and also folder name
$files = array();
if ($handle = opendir($extractdir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$files[] = $file;
continue;
}
}
closedir($handle);
}
$filelist['files'] = $files;
$filelist['folder'] = $extractdir;
return $filelist;
}
/**
* Split sql to single queries
*
* @return array
*/
private function splitSql($sql)
{
$sql = trim($sql);
$sql = preg_replace("/\n\#[^\n]*/", '', "\n" . $sql);
$buffer = array();
$ret = array();
$in_string = false;
for ($i = 0; $i < strlen($sql) - 1; $i++) {
if ($sql[$i] == ";" && !$in_string) {
$ret[] = substr($sql, 0, $i);
$sql = substr($sql, $i + 1);
$i = 0;
}
if ($in_string && ($sql[$i] == $in_string) && $buffer[1] != "\\") {
$in_string = false;
}
elseif (!$in_string && ($sql[$i] == '"' || $sql[$i] == "'") && (!isset($buffer[0]) || $buffer[0] != "\\")) {
$in_string = $sql[$i];
}
if (isset($buffer[1])) {
$buffer[0] = $buffer[1];
}
$buffer[1] = $sql[$i];
}
if (!empty($sql)) {
$ret[] = $sql;
}
return ($ret);
}
/**
* Copy images into the venues/events folder
*
* @return boolean True on success
*/
private function moveImages()
{
$imagebase = JPATH_ROOT . '/images/jem';
foreach ($this->filelist['files'] as $file) {
$subDirectory = "/";
if (strpos($file, "event") !== false) {
$subDirectory .= "events/";
}
elseif (strpos($file, "venue") !== false) {
$subDirectory .= "venues/";
}
elseif (strpos($file, "category") !== false) {
$subDirectory .= "categories/";
}
else {
// Nothing matched. Skip this file
continue;
}
if (strpos($file, "thumb") !== false) {
$subDirectory .= "small/";
}
File::copy($this->filelist['folder'] . '/' . $file, $imagebase . $subDirectory . $file);
}
return true;
}
/**
* Delete temporary folder
*
* @return boolean True on success
*/
private function deleteTmpFolder()
{
if ($this->filelist['folder']) {
if (!Folder::delete($this->filelist['folder'])) {
return false;
}
return true;
}
return false;
}
/**
* Checks if JEM data already exists
*
* @return boolean True if data exists
*/
private function checkForJemData()
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select("id");
$query->from('#__jem_categories');
$query->where('alias NOT LIKE "root"');
$db->setQuery($query);
$result = $db->loadResult();
if ($result == null) {
return false;
}
return true;
}
/**
* Assign admin-id to created events
*
* @return boolean True if data exists
*/
private function assignAdminId()
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select("id");
$query->from('#__users');
$query->where('name LIKE "Super User"');
$db->setQuery($query);
$result = $db->loadResult();
if ($result == null) {
// use current user as fallback if user is allowed to manage JEM
$user = JemFactory::getUser();
if ($user->authorise('core.manage', 'com_jem')) {
$result = $user->get('id');
}
if (empty($result)) {
return false;
}
}
$query = $db->getQuery(true);
$query->update('#__jem_events');
$query->set('created_by = '.$db->quote((int)$result));
$query->where(array('created_by = 62'));
$db->setQuery($query);
$db->execute();
$query = $db->getQuery(true);
$query->update('#__jem_venues');
$query->set('created_by = '.$db->quote((int)$result));
$query->where(array('created_by = 62'));
$db->setQuery($query);
$db->execute();
return true;
}
}
?>

View File

@ -0,0 +1,243 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Component\ComponentHelper;
/**
* JEM Component Settings Model
*
*/
class JemModelSettings extends AdminModel
{
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return mixed A JForm object on success, false on failure
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_jem.settings', 'settings', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
/**
* Loading the table data
*/
public function getData()
{
$config = JemConfig::getInstance();
$data = $config->toObject();
return $data;
}
/**
* Method to get the data that should be injected in the form.
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_jem.edit.settings.data', array());
if (empty($data)) {
$data = $this->getData();
}
return $data;
}
/**
* Saves the settings
*/
public function store($data)
{
// If the source value is an object, get its accessible properties.
if (is_object($data)) {
$data = get_object_vars($data);
}
// additional data:
$jinput = Factory::getApplication()->input;
$varmetakey = $jinput->get('meta_keywords','','');
$data['meta_keywords'] = implode(', ', array_filter($varmetakey));
$data['lastupdate'] = $jinput->get('lastupdate','',''); // 'lastupdate' indicates last cleanup etc., not when config as stored.
// sanitize
if (empty($data['imagewidth'])) {
$data['imagewidth'] = 100;
}
if (empty($data['imagehight'])) {
$data['imagehight'] = 100;
}
//
// Store into new table
//
$config = JemConfig::getInstance();
// Bind the form fields to the table
if (!$config->bind($data)) {
$this->setError(Text::_('?'));
return false;
}
if (!$config->store()) {
$this->setError(Text::_('?'));
return false;
}
//
// Old table - deprecated, maybe already removed
//
try {
$settings = Table::getInstance('Settings', 'JemTable');
$fields = $settings->getFields();
if (!empty($fields)) {
// Bind the form fields to the table
if (!$settings->bind($data,'')) {
$this->setError($settings->getError());
return false;
}
$varmetakey = $jinput->get('meta_keywords','','');
$settings->meta_keywords = $varmetakey;
$meta_key="";
foreach ($settings->meta_keywords as $meta_keyword) {
if ($meta_key != "") {
$meta_key .= ", ";
}
$meta_key .= $meta_keyword;
}
// binding the input fields (outside the jform)
$varlastupdate = $jinput->get('lastupdate','','');
$settings->lastupdate = $varlastupdate;
$settings->meta_keywords = $meta_key;
$settings->id = 1;
if (!$settings->store()) {
$this->setError($settings->getError());
return false;
}
}
// else: ok, old table removed - simply ignore
}
catch(Exception $e) {
// ok, old table removed - simply ignore
}
return true;
}
/**
* Method to auto-populate the model state.
*
* @Note Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState()
{
$app = Factory::getApplication();
// Load the parameters.
$params = ComponentHelper::getParams('com_jem');
$this->setState('params', $params);
}
/**
* Return config information
*/
public function getConfigInfo()
{
$config = new stdClass();
// Get PHP version and optionally if Magic Quotes are enabled or not
$phpversion = phpversion();
if (version_compare($phpversion, '5.4', '<')) {
$quote = (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) ? "enabled" : "disabled";
} else { // since PHP 5.4 magic quotes has completely removed
$quote = '';
}
$config->vs_php = $phpversion;
$config->vs_php_magicquotes = $quote;
// Get GD version.
$gd_version = '?';
if (function_exists('gd_info')) {
$gd_info = gd_info();
if (array_key_exists('GD Version', $gd_info)) {
$gd_version = $gd_info['GD Version'];
}
} else {
ob_start();
if (phpinfo(INFO_MODULES)) {
$info = strip_tags(ob_get_contents());
}
ob_end_clean();
preg_match('/gd support\w*(.*)/i', $info, $gd_sup);
preg_match('/gd version\w*(.*)/i', $info, $gd_ver);
if (count($gd_ver) > 0) {
$gd_version = trim($gd_ver[1]);
}
if (count($gd_sup) > 0) {
$gd_version .= ' (' . trim($gd_sup[1]) . ')';
}
}
$config->vs_gd = $gd_version;
// Get info about all JEM parts
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select(array('name', 'type', 'enabled', 'manifest_cache'));
$query->from('#__extensions');
$query->where(array('name LIKE "%jem%"'));
$db->setQuery($query);
$extensions = $db->loadObjectList('name');
$known_extensions = array('pkg_jem', 'com_jem', 'mod_jem', 'mod_jem_cal', 'mod_jem_calajax',
'mod_jem_banner', 'mod_jem_jubilee', 'mod_jem_teaser', 'mod_jem_wide',
'plg_content_jem', 'plg_content_jemlistevents',
'plg_finder_jem', 'plg_search_jem',
'plg_quickicon_jem', 'Quick Icon - JEM',
'plg_jem_comments', 'plg_jem_mailer', 'plg_jem_demo',
'AcyMailing Tag : insert events from JEM 2.1+');
foreach ($extensions as $name => $extension) {
if (in_array($name, $known_extensions)) {
$manifest = json_decode($extension->manifest_cache, true);
$extension->version = (!empty($manifest) && array_key_exists('version', $manifest)) ? $manifest['version'] : '?';
$extension->creationDate = (!empty($manifest) && array_key_exists('creationDate', $manifest)) ? $manifest['creationDate'] : '?';
$extension->author = (!empty($manifest) && array_key_exists('author', $manifest)) ? $manifest['author'] : '?';
$config->$name = clone $extension;
}
}
return $config;
}
}

View File

@ -0,0 +1,205 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Plugin\PluginHelper;
/**
* Source Model
*/
class JemModelSource extends AdminModel
{
/**
* Cache for the template information.
*
* @var object
*/
private $_template = null;
/**
* Method to auto-populate the model state.
*
* @Note Calling getState in this method will result in recursion.
*/
protected function populateState()
{
$app = Factory::getApplication('administrator');
// Load the User state.
$id = $app->getUserState('com_jem.edit.source.id');
// Parse the template id out of the compound reference.
$temp = $id ? (base64_decode($id)) : $id;
$fileName = $temp;
if(!empty($fileName))
{
$this->setState('filename', $fileName);
// Save the syntax for later use
$app->setUserState('editor.source.syntax', File::getExt($fileName));
}
// Load the parameters.
$params = ComponentHelper::getParams('com_jem');
$this->setState('params', $params);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return JForm A JForm object on success, false on failure
*/
public function getForm($data = array(), $loadData = true)
{
// Initialise variables.
$app = Factory::getApplication();
// Codemirror or Editor None should be enabled
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('COUNT(*)');
$query->from('#__extensions as a');
$query->where('((a.name ='.$db->quote('plg_editors_codemirror').' AND a.enabled = 1) OR (a.name ='.$db->quote('plg_editors_none').' AND a.enabled = 1))');
$db->setQuery($query);
$state = $db->loadResult();
if ((int)$state < 1 ) {
$app->enqueueMessage(Text::_('COM_JEM_CSSMANAGER_ERROR_EDITOR_DISABLED'), 'warning');
}
// Get the form.
$form = $this->loadForm('com_jem.source', 'source', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_jem.edit.source.data', array());
if (empty($data)) {
$data = $this->getSource();
}
return $data;
}
/**
* Method to get a single record.
*
* @return mixed Object on success, false on failure.
*/
public function getSource()
{
$fileName = $this->getState('filename');
$custom = $fileName ? stripos($fileName, 'custom#:') : false;
# custom file?
if ($custom !== false) {
$file = str_replace('custom#:', '', $fileName);
$filePath = Path::clean(JPATH_ROOT . '/media/com_jem/css/custom/' . $file);
} else {
$file = $fileName;
$filePath = Path::clean(JPATH_ROOT . '/media/com_jem/css/' . $file);
}
$item = new stdClass;
if(file_exists($filePath)){
if ($file) {
$item->custom = $custom !== false;
$item->filename = $file;
$item->source = file_get_contents($filePath);
} else {
$item->custom = false;
$item->filename = false;
$item->source = false;
}
}else{
$this->setError(Text::_('COM_JEM_CSSMANAGER_ERROR_SOURCE_FILE_NOT_FOUND'));
}
return $item;
}
/**
* Method to store the source file contents.
*
* @param array The souce data to save.
*
* @return boolean True on success, false otherwise and internal error set.
*/
public function save($data)
{
$dispatcher = JemFactory::getDispatcher();
$fileName = $this->getState('filename');
$custom = $fileName ? stripos($fileName, 'custom#:') : false;
# custom file?
if ($custom !== false) {
$file = str_replace('custom#:', '', $fileName);
$filePath = Path::clean(JPATH_ROOT . '/media/com_jem/css/custom/' . $file);
} else {
$file = $fileName;
$filePath = Path::clean(JPATH_ROOT . '/media/com_jem/css/' . $file);
}
// Include the extension plugins for the save events.
PluginHelper::importPlugin('extension');
// Set FTP credentials, if given.
ClientHelper::setCredentialsFromRequest('ftp');
$ftp = ClientHelper::getCredentials('ftp');
// Trigger the onExtensionBeforeSave event.
$result = $dispatcher->triggerEvent('onExtensionBeforeSave', array('com_jem.source', (object)$data, false));
if (in_array(false, $result, true)) {
$this->setError(Text::sprintf('COM_JEM_CSSMANAGER_ERROR_FAILED_TO_SAVE_FILENAME', $file));
return false;
}
// Try to make the template file writeable.
if (!$ftp['enabled'] && Path::isOwner($filePath) && !Path::setPermissions($filePath, '0644')) {
$this->setError(Text::_('COM_JEM_CSSMANAGER_ERROR_SOURCE_FILE_NOT_WRITABLE'));
return false;
}
$return = File::write($filePath, $data['source']);
// But report save error with higher priority
if (!$return) {
$this->setError(Text::sprintf('COM_JEM_CSSMANAGER_ERROR_FAILED_TO_SAVE_FILENAME', $file));
return false;
}
// Try to make the custom template file read-only again.
if (!$ftp['enabled'] && Path::isOwner($filePath) && !Path::setPermissions($filePath, '0444')) {
$this->setError(Text::_('COM_JEM_CSSMANAGER_ERROR_SOURCE_FILE_NOT_UNWRITABLE'));
return false;
}
return true;
}
}

View File

@ -0,0 +1,86 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Filesystem\File;
/**
* Model-Updatecheck
*/
class JemModelUpdatecheck extends BaseDatabaseModel
{
protected $_updatedata = null;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
/**
* Retrieval of update-data
*/
public function getUpdatedata()
{
$installedversion = JemHelper::getParam(1, 'version', 1, 'com_jem');
$updateFile = "https://www.joomlaeventmanager.net/updatecheck/update_pkg_jem.xml";
$checkFile = self::CheckFile($updateFile);
$updatedata = new stdClass();
if ($checkFile) {
$xml = simplexml_load_string(file_get_contents($updateFile));
$jversion = JVERSION;
foreach($xml->update as $updatexml) {
$version = $updatexml->targetplatform["version"]->__toString();
if (preg_match('/^' . $version . '/', $jversion)) {
//version to check, not visible in table
$updatedata->version = $updatexml->version;
//in table
$updatedata->versiondetail = $updatexml->version;
$updatedata->date = JemOutput::formatdate($updatexml->date);
$updatedata->info = $updatexml->infourl;
$updatedata->download = $updatexml->downloads->downloadurl;
$updatedata->notes = explode(';', $updatexml->notes);
$updatedata->changes = explode(';', $updatexml->changes);
$updatedata->failed = 0;
$updatedata->installedversion = $installedversion;
$updatedata->current = version_compare($installedversion, $updatedata->version);
}
}
} else {
$updatedata->failed = 1;
$updatedata->installedversion = $installedversion;
}
return $updatedata;
}
/**
* Check to see if update-file exists
*/
protected static function CheckFile($filename)
{
$ext = File::getExt($filename);
if ($ext == 'xml') {
if (@file_get_contents($filename, 0, null, 0, 1)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
}
?>

View File

@ -0,0 +1,144 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Filter\InputFilter;
/**
* Userelement-Model
*/
class JemModelUserelement extends BaseDatabaseModel
{
/**
* data array
*
* @var array
*/
protected $_data = null;
/**
* total
*
* @var integer
*/
protected $_total = null;
/**
* Pagination object
*
* @var object
*/
protected $_pagination = null;
/**
* Constructor
*
*/
public function __construct()
{
parent::__construct();
$app = Factory::getApplication();
$limit = $app->getUserStateFromRequest( 'com_jem.limit', 'limit', $app->get('list_limit'), 'int');
$limitstart = $app->getUserStateFromRequest( 'com_jem.limitstart', 'limitstart', 0, 'int' );
$limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0;
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
/**
* Method to get data
*
* @access public
* @return array
*/
public function getData()
{
$query = $this->buildQuery();
$pagination = $this->getPagination();
$rows = $this->_getList($query, $pagination->limitstart, $pagination->limit);
return $rows;
}
/**
* Query
*/
protected function buildQuery()
{
$app = Factory::getApplication();
$jemsettings = JemHelper::config();
$filter_order = $app->getUserStateFromRequest( 'com_jem.userelement.filter_order', 'filter_order', 'u.name', 'cmd' );
$filter_order_Dir = $app->getUserStateFromRequest( 'com_jem.userelement.filter_order_Dir', 'filter_order_Dir', '', 'word' );
$filter_order = InputFilter::getInstance()->clean($filter_order, 'cmd');
$filter_order_Dir = InputFilter::getInstance()->clean($filter_order_Dir, 'word');
$search = $app->getUserStateFromRequest('com_jem.userelement.filter_search', 'filter_search', '', 'string' );
$search = $this->_db->escape( trim(\Joomla\String\StringHelper::strtolower( $search ) ) );
// start query
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select(array('u.id', 'u.name', 'u.username', 'u.email'));
$query->from('#__users as u');
// where
$where = array();
$where[] = 'u.block = 0';
/*
* Search name
*/
if ($search) {
$where[] = ' LOWER(u.name) LIKE \'%'.$search.'%\' ';
}
$query->where($where);
// ordering
$orderby = '';
$orderby = $filter_order.' '.$filter_order_Dir;
$query->order($orderby);
return $query;
}
/**
* Method to get a pagination object
*
* @access public
* @return integer
*/
public function getPagination()
{
$app = Factory::getApplication();
$jemsettings = JemHelper::config();
$limit = $app->getUserStateFromRequest('com_jem.userelement.limit', 'limit', $jemsettings->display_num, 'int');
$limitstart = $app->input->getInt('limitstart', 0);
$query = $this->buildQuery();
$total = $this->_getListCount($query);
// Create the pagination object
$pagination = new Pagination($total, $limitstart, $limit);
return $pagination;
}
}
?>

View File

@ -0,0 +1,185 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
/**
* JEM Component users Model
*
* @package JEM
*
*/
class JemModelUsers extends BaseDatabaseModel
{
/**
* data array
*
* @var array
*/
protected $_data = null;
/**
* total
*
* @var integer
*/
protected $_total = null;
/**
* Pagination object
*
* @var object
*/
protected $_pagination = null;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$app = Factory::getApplication();
$limit = $app->getUserStateFromRequest( 'com_jem.limit', 'limit', $app->get('list_limit'), 'int');
$limitstart = $app->getUserStateFromRequest( 'com_jem.limitstart', 'limitstart', 0, 'int' );
$limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0;
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
/**
* Method to get venues item data
*
* @access public
* @return array
*/
function getData()
{
// Lets load the venues if they doesn't already exist
if (empty($this->_data))
{
$query = $this->_buildQuery();
$this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
}
return $this->_data;
}
/**
* Total nr of venues
*
* @access public
* @return integer
*/
function getTotal()
{
// Lets load the content if it doesn't already exist
if (empty($this->_total))
{
$query = $this->_buildQuery();
$this->_total = $this->_getListCount($query);
}
return $this->_total;
}
/**
* Method to get a pagination object for the venues
*
* @access public
* @return integer
*/
function getPagination()
{
// Lets load the content if it doesn't already exist
if (empty($this->_pagination))
{
jimport('joomla.html.pagination');
$this->_pagination = new Pagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_pagination;
}
/**
* Method to build the query for the venues
*
* @access private
* @return string
*/
protected function _buildQuery()
{
// Get the WHERE and ORDER BY clauses for the query
$where = $this->_buildContentWhere();
$orderby = $this->_buildContentOrderBy();
$query = 'SELECT u.id, u.name, u.username, u.email '
. ' FROM #__users AS u '
. $where
. $orderby
;
return $query;
}
/**
* Method to build the orderby clause of the query for the venues
*
* @access private
* @return string
*/
protected function _buildContentOrderBy()
{
$app = Factory::getApplication();
$filter_order = $app->getUserStateFromRequest( 'com_jem.users.filter_order', 'filter_order', 'u.name', 'cmd' );
$filter_order_Dir = $app->getUserStateFromRequest( 'com_jem.users.filter_order_Dir', 'filter_order_Dir', '', 'word' );
$filter_order = JFilterInput::getInstance()->clean($filter_order, 'cmd');
$filter_order_Dir = JFilterInput::getInstance()->clean($filter_order_Dir, 'word');
$orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir;
return $orderby;
}
/**
* Method to build the where clause of the query for the venues
*
* @access private
* @return string
*/
protected function _buildContentWhere()
{
$app = Factory::getApplication();
$search = $app->getUserStateFromRequest( 'com_jem.users.search', 'search', '', 'string' );
$search = $this->_db->escape( trim(\Joomla\String\StringHelper::strtolower( $search ) ) );
$where = array();
/*
* Search venues
*/
if ($search) {
$where[] = ' LOWER(u.name) LIKE \'%'.$search.'%\' ';
}
$where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
return $where;
}
}
?>

View File

@ -0,0 +1,324 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
require_once __DIR__ . '/admin.php';
/**
* Model: Venue
*/
class JemModelVenue extends JemModelAdmin
{
/**
* Method to change the published state of one or more records.
*
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state.
*
* @return boolean True on success.
*
* @since 2.2.2
*/
public function publish(&$pks, $value = 1)
{
// Additionally include the JEM plugins for the onContentChangeState event.
PluginHelper::importPlugin('jem');
return parent::publish($pks, $value);
}
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
$user = JemFactory::getUser();
return $user->authorise('core.delete', 'com_jem');
}
}
/**
* Method to delete a venue
*/
public function delete(&$pks = array())
{
$return = array();
if ($pks)
{
$pksTodelete = array();
$errorNotice = array();
$db = Factory::getContainer()->get('DatabaseDriver');
foreach ($pks as $pk)
{
$result = array();
$query = $db->getQuery(true);
$query->select(array('COUNT(e.locid) as AssignedEvents'));
$query->from($db->quoteName('#__jem_venues').' AS v');
$query->join('LEFT', '#__jem_events AS e ON e.locid = v.id');
$query->where(array('v.id = '.$pk));
$query->group('v.id');
$db->setQuery($query);
$assignedEvents = $db->loadResult();
if ($assignedEvents > 0)
{
$result[] = Text::_('COM_JEM_VENUE_ASSIGNED_EVENT');
}
if ($result)
{
$pkInfo = array("id:".$pk);
$result = array_merge($pkInfo,$result);
$errorNotice[] = $result;
}
else
{
$pksTodelete[] = $pk;
}
}
if ($pksTodelete)
{
$return['removed'] = parent::delete($pksTodelete);
$return['removedCount'] = count($pksTodelete);
}
else
{
$return['removed'] = false;
$return['removedCount'] = false;
}
if ($errorNotice)
{
$return['error'] = $errorNotice;
}
else
{
$return['error'] = false;
}
return $return;
}
$return['removed'] = false;
$return['error'] = false;
$return['removedCount'] = false;
return $return;
}
/**
* 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');
}
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string The table to instantiate
* @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional.
* @return Table A database object
*/
public function getTable($type = 'Venue', $prefix = 'JemTable', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return mixed A JForm object on success, false on failure
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_jem.venue', 'venue', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
/**
* Method to get a single record.
*
* @param integer The id of the primary key.
*
* @return mixed Object on success, false on failure.
*/
public function getItem($pk = null)
{
$jemsettings = JemAdmin::config();
if ($item = parent::getItem($pk)) {
$files = JemAttachment::getAttachments('venue'.$item->id);
$item->attachments = $files;
}
$item->author_ip = $jemsettings->storeip ? JemHelper::retrieveIP() : false;
if (empty($item->id)) {
$item->country = $jemsettings->defaultCountry;
}
return $item;
}
/**
* Method to get the data that should be injected in the form.
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_jem.edit.venue.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param $table Table-object.
*/
protected function _prepareTable($table)
{
$db = Factory::getContainer()->get('DatabaseDriver');
$table->venue = htmlspecialchars_decode($table->venue, ENT_QUOTES);
// Increment version number.
$table->version ++;
}
/**
* Method to save the form data.
*
* @param $data array
*/
public function save($data)
{
// Variables
$app = Factory::getApplication();
$jinput = $app->input;
$jemsettings = JemHelper::config();
$task = $jinput->get('task', '', 'cmd');
// Check if we're in the front or back
$backend = (bool)$app->isClient('administrator');
$new = (bool)empty($data['id']);
// Store IP of author only.
if ($new) {
$author_ip = $jinput->get('author_ip', '', 'string');
$data['author_ip'] = $author_ip;
}
$data['modified'] = (isset($data['modified']) && !empty($data['modified'])) ? $data['modified'] : null;
$data['publish_up'] = (isset($data['publish_up']) && !empty($data['publish_up'])) ? $data['publish_up'] : null;
$data['publish_down'] = (isset($data['publish_down']) && !empty($data['publish_down'])) ? $data['publish_down'] : null;
$data['publish_down'] = (isset($data['publish_down']) && !empty($data['publish_down'])) ? $data['publish_down'] : null;
$data['attribs'] = (isset($data['attribs'])) ? $data['attribs'] : '';
$data['language'] = (isset($data['language'])) ? $data['language'] : '';
$data['latitude'] = (isset($data['latitude']) && !empty($data['latitude'])) ? $data['latitude'] : 0;
$data['longitude'] = (isset($data['longitude']) && !empty($data['longitude'])) ? $data['longitude'] : 0;
// Store as copy - reset creation date, modification fields, hit counter, version
if ($task == 'save2copy') {
unset($data['created']);
unset($data['modified']);
unset($data['modified_by']);
unset($data['version']);
// unset($data['hits']);
}
//uppercase needed by mapservices
if ($data['country']) {
$data['country'] = \Joomla\String\StringHelper::strtoupper($data['country']);
}
// Save the venue
$saved = parent::save($data);
if ($saved) {
// At this point we do have an id.
$pk = $this->getState($this->getName() . '.id');
// on frontend attachment uploads maybe forbidden
// so allow changing name or description only
$allowed = $backend || ($jemsettings->attachmentenabled > 0);
if ($allowed) {
// attachments, new ones first
$attachments = $jinput->files->get('attach', array(), 'array');
$attach_name = $jinput->post->get('attach-name', array(), 'array');
$attach_descr = $jinput->post->get('attach-desc', array(), 'array');
$attach_access = $jinput->post->get('attach-access', array(), 'array');
foreach($attachments as $n => &$a) {
$a['customname'] = array_key_exists($n, $attach_access) ? $attach_name[$n] : '';
$a['description'] = array_key_exists($n, $attach_access) ? $attach_descr[$n] : '';
$a['access'] = array_key_exists($n, $attach_access) ? $attach_access[$n] : '';
}
JemAttachment::postUpload($attachments, 'venue' . $pk);
}
// and update old ones
$old = array();
$old['id'] = $jinput->post->get('attached-id', array(), 'array');
$old['name'] = $jinput->post->get('attached-name', array(), 'array');
$old['description'] = $jinput->post->get('attached-desc', array(), 'array');
$old['access'] = $jinput->post->get('attached-access', array(), 'array');
foreach ($old['id'] as $k => $id){
$attach = array();
$attach['id'] = $id;
$attach['name'] = $old['name'][$k];
$attach['description'] = $old['description'][$k];
if ($allowed) {
$attach['access'] = $old['access'][$k];
} // else don't touch this field
JemAttachment::update($attach);
}
}
return $saved;
}
}

View File

@ -0,0 +1,160 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Filter\InputFilter;
/**
* Venueelement-Model
*/
class JemModelVenueelement extends BaseDatabaseModel
{
/**
* data array
*
* @var array
*/
protected $_data = null;
/**
* total
*
* @var integer
*/
protected $_total = null;
/**
* Pagination object
*
* @var object
*/
protected $_pagination = null;
/**
* id
*
* @var int
*/
protected $_id = null;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$app = Factory::getApplication();
$jemsettings = JemHelper::config();
// $itemid = $app->input->getInt('id', 0) . ':' . $app->input->getInt('Itemid', 0);
$limit = $app->getUserStateFromRequest('com_jem.venueelement.limit', 'limit', $jemsettings->display_num, 'int');
$limitstart = $app->input->getInt('limitstart', 0);
$limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0;
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
/**
* Get venue-data
*/
public function getData()
{
// Lets load the content if it doesn't already exist
if (empty($this->_data))
{
$query = $this->buildQuery();
$pagination = $this->getPagination();
$this->_data = $this->_getList($query, $pagination->limitstart, $pagination->limit);
}
return $this->_data;
}
/**
* venue-query
*/
protected function buildQuery()
{
$app = Factory::getApplication();
$jemsettings = JemHelper::config();
$itemid = $app->input->getInt('id', 0) . ':' . $app->input->getInt('Itemid', 0);
$filter_order = $app->getUserStateFromRequest('com_jem.venueelement.'.$itemid.'.filter_order', 'filter_order', 'l.ordering', 'cmd' );
$filter_order_Dir = $app->getUserStateFromRequest('com_jem.venueelement.'.$itemid.'.filter_order_Dir', 'filter_order_Dir', '', 'word' );
$filter_order = InputFilter::getinstance()->clean($filter_order, 'cmd');
$filter_order_Dir = InputFilter::getinstance()->clean($filter_order_Dir, 'word');
$filter_type = $app->getUserStateFromRequest('com_jem.venueelement.'.$itemid.'.filter_type', 'filter_type', 0, 'int' );
$search = $app->getUserStateFromRequest('com_jem.venueelement.'.$itemid.'.filter_search', 'filter_search', '', 'string' );
$search = $this->_db->escape(trim(\Joomla\String\StringHelper::strtolower($search)));
// Query
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select(array('l.id', 'l.state', 'l.city', 'l.country', 'l.published', 'l.venue', 'l.ordering'));
$query->from('#__jem_venues as l');
// where
$where = array();
$where[] = 'l.published = 1';
/* something to search for? (we like to search for "0" too) */
if ($search || ($search === "0")) {
switch ($filter_type) {
case 1: /* Search venues */
$where[] = 'LOWER(l.venue) LIKE "%' . $search . '%"';
break;
case 2: // Search city
$where[] = 'LOWER(l.city) LIKE "%' . $search . '%"';
break;
case 3: // Search state
$where[] = 'LOWER(l.state) LIKE "%' . $search . '%"';
}
}
$query->where($where);
$orderby = array($filter_order.' '.$filter_order_Dir, 'l.ordering ASC');
$query->order($orderby);
return $query;
}
/**
* Method to get a pagination object
*
* @access public
* @return integer
*/
public function getPagination()
{
// Lets load the content if it doesn't already exist
if (empty($this->_pagination))
{
$limit = $this->getState('limit');
$limitstart = $this->getState('limitstart');
$query = $this->buildQuery();
$total = $this->_getListCount($query);
// Create the pagination object
$this->_pagination = new Pagination($total, $limitstart, $limit);
}
return $this->_pagination;
}
}
?>

View File

@ -0,0 +1,184 @@
<?php
/**
* @package JEM
* @copyright (C) 2013-2024 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Component\ComponentHelper;
/**
* Model: Venues
**/
class JemModelVenues extends ListModel
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'venue', 'a.venue',
'alias', 'a.alias',
'state', 'a.state',
'country', 'a.country',
'url', 'a.url',
'street', 'a.street',
'postalCode', 'a.postalCode',
'city', 'a.city',
'ordering', 'a.ordering',
'created', 'a.created',
'assignedevents'
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* @Note Calling getState in this method will result in recursion.
*/
protected function populateState($ordering = null, $direction = null)
{
$search = $this->getUserStateFromRequest($this->context.'.filter_search', 'filter_search');
$this->setState('filter_search', $search);
$published = $this->getUserStateFromRequest($this->context.'.filter_state', 'filter_state', '', 'string');
$this->setState('filter_state', $published);
$filter_type = $this->getUserStateFromRequest($this->context.'.filter_type', 'filter_type', 0, 'int');
$this->setState('filter_type', $filter_type);
$params = ComponentHelper::getParams('com_jem');
$this->setState('params', $params);
parent::populateState('a.venue', 'asc');
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter_search');
$id .= ':' . $this->getState('filter_published');
$id .= ':' . $this->getState('filter_type');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.venue, a.alias, a.url, a.street, a.postalCode, a.city, a.state, a.country,'
.'a.latitude, a.longitude, a.locdescription, a.meta_keywords, a.meta_description,'
.'a.locimage, a.map, a.created_by, a.author_ip, a.created, a.modified,'
.'a.modified_by, a.version, a.published, a.checked_out, a.checked_out_time,'
.'a.ordering, a.publish_up, a.publish_down'
)
);
$query->from($db->quoteName('#__jem_venues').' AS a');
// Join over the users for the checked out user.
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id = a.checked_out');
// Join over the user who modified the event.
$query->select('um.name AS modified_by');
$query->join('LEFT', '#__users AS um ON um.id = a.modified_by');
// Join over the author & email.
$query->select('u.email, u.name AS author');
$query->join('LEFT', '#__users AS u ON u.id = a.created_by');
// Join over the assigned events
$query->select('COUNT(e.locid) AS assignedevents');
$query->join('LEFT OUTER', '#__jem_events AS e ON e.locid = a.id');
$query->group('a.id');
// Filter by published state
$published = $this->getState('filter_state');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
} elseif ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by search in title
$filter_type = $this->getState('filter_type');
$search = $this->getState('filter_search');
if (!empty($search)) {
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
} else {
$search = $db->Quote('%'.$db->escape($search, true).'%', false);
if($search) {
switch($filter_type) {
case 1:
/* search venue or alias */
$query->where('(a.venue LIKE '.$search.' OR a.alias LIKE '.$search.')');
break;
case 2:
/* search city */
$query->where('a.city LIKE '.$search);
break;
case 3:
/* search state */
$query->where('a.state LIKE '.$search);
break;
case 4:
/* search country */
$query->where('a.country LIKE '.$search);
break;
case 5:
default:
/* search all */
$query->where('(a.venue LIKE '.$search.' OR a.alias LIKE '.$search.' OR a.city LIKE '.$search.' OR a.state LIKE '.$search.' OR a.country LIKE '.$search.')');
}
}
}
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
$query->order($db->escape($orderCol.' '.$orderDirn));
return $query;
}
}