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,30 @@
<?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\Controller\BaseController;
/**
* JEM Component Attachments Controller
*
* @package JEM
*
*/
class JemControllerAttachments extends BaseController
{
/**
* Constructor
*
*/
public function __construct()
{
parent::__construct();
}
}
?>

View File

@ -0,0 +1,162 @@
<?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\Controller\BaseController;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Session\Session;
/**
* Controller: Attendee
*/
class JemControllerAttendee extends BaseController
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
// Register Extra task
$this->registerTask('add', 'edit');
$this->registerTask('apply', 'save');
$this->registerTask('save2new', 'save');
$this->registerTask('save2copy', 'save');
}
/**
* redirect to events page
*/
public function back()
{
$this->setRedirect('index.php?option=com_jem&view=attendees&eventid='. Factory::getApplication()->input->getInt('event', 0));
}
/**
* logic for cancel an action
*
* @access public
* @return void
*/
public function cancel()
{
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
$attendee = Table::getInstance('jem_register', '');
$attendee->bind(Factory::getApplication()->input->post->getArray(/*get them all*/));
$attendee->checkin();
$this->setRedirect('index.php?option=com_jem&view=attendees&eventid='. Factory::getApplication()->input->getInt('event', 0));
}
/**
* saves the attendee in the database
*
* @access public
* @return void
*/
public function save()
{
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
// Defining JInput
$jinput = Factory::getApplication()->input;
// retrieving task "apply"
$task = $jinput->getCmd('task');
// Retrieving $post
$post = $jinput->post->getArray(/*get them all*/);
// Retrieving email-setting
$sendemail = $jinput->getInt('sendemail','0');
// Retrieving event-id
$eventid = $jinput->getInt('event');
// the id in case of edit
$id = (!empty($post['id']) ? $post['id'] : 0);
$model = $this->getModel('attendee');
// Handle task 'save2copy' - reset id to store as new record, then like 'apply'.
if ($task == 'save2copy') {
$post['id'] = 0;
$id = 0;
$task = 'apply';
}
// handle changing the user - must also trigger onEventUserUnregistered
$uid = (!empty($post['uid']) ? $post['uid'] : 0);
if ($uid && $id) {
$model->setId($id);
$old_data = $model->getData();
}
$old_uid = (!empty($old_data->uid) ? $old_data->uid : 0);
$old_status = (!empty($old_data->status) ? $old_data->status : 0);
if ($row = $model->store($post)) {
if ($sendemail == 1) {
PluginHelper::importPlugin('jem');
$dispatcher = JemFactory::getDispatcher();
// there was a user and it's overwritten by a new user -> send unregister mails
if ($old_uid && ($old_uid != $uid)) {
$dispatcher->triggerEvent('onEventUserUnregistered', array($old_data->event, $old_data));
}
// there is a new user which wasn't before -> send register mails
if ($uid && (($old_uid != $uid) || ($row->status != $old_status))) {
$dispatcher->triggerEvent('onEventUserRegistered', array($row->id));
}
// but show warning if mailer is disabled
if (!PluginHelper::isEnabled('jem', 'mailer')) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_GLOBAL_MAILERPLUGIN_DISABLED'), 'notice');
}
}
switch ($task)
{
case 'apply':
// Redirect back to the edit screen.
$link = 'index.php?option=com_jem&view=attendee&hidemainmenu=1&cid[]='.$row->id.'&eventid='.$row->event;
break;
case 'save2new':
// Redirect back to the edit screen for new record.
$link = 'index.php?option=com_jem&view=attendee&hidemainmenu=1&eventid='.$row->event;
break;
default:
// Redirect to the list screen.
$link = 'index.php?option=com_jem&view=attendees&eventid='.$row->event;
break;
}
$msg = Text::_('COM_JEM_ATTENDEE_SAVED');
$cache = Factory::getCache('com_jem');
$cache->clean();
} else {
$msg = '';
$link = 'index.php?option=com_jem&view=attendees&eventid='.$eventid;
}
$this->setRedirect($link, $msg);
}
public function selectUser()
{
$jinput = Factory::getApplication()->input;
$jinput->set('view', 'userelement');
parent::display();
}
}

View File

@ -0,0 +1,275 @@
<?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\Controller\BaseController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Log\Log;
/**
* Controller: Attendees
*/
class JemControllerAttendees extends BaseController
{
/**
* Constructor
*/
public function __construct($config = array())
{
parent::__construct($config);
// Register Extra task
$this->registerTask('add', 'edit');
$this->registerTask('apply', 'save');
$this->registerTask('onWaitinglist', 'toggleStatus');
$this->registerTask('offWaitinglist', 'toggleStatus');
$this->registerTask('setNotAttending','setStatus');
$this->registerTask('setAttending', 'setStatus');
$this->registerTask('setWaitinglist', 'setStatus');
}
/**
* Delete attendees
*
* @return true on sucess
* @access private
*/
public function remove()
{
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
$jinput = Factory::getApplication()->input;
$cid = $jinput->get('cid', 0, 'array');
$eventid = $jinput->getInt('eventid');
if (!is_array($cid) || count($cid) < 1) {
throw new Exception(Text::_('COM_JEM_SELECT_ITEM_TO_DELETE'), 500);
}
$total = count($cid);
PluginHelper::importPlugin('jem');
$dispatcher = JemFactory::getDispatcher();
$modelAttendeeList = $this->getModel('attendees');
$modelAttendeeItem = $this->getModel('attendee');
// We need information about every entry to delete for mailer.
// But we should first delete the entry and than on success send the mails.
foreach ($cid as $reg_id) {
$modelAttendeeItem->setId($reg_id);
$entry = $modelAttendeeItem->getData();
if ($modelAttendeeList->remove(array($reg_id))) {
$dispatcher->triggerEvent('onEventUserUnregistered', array($entry->event, $entry));
} else {
$error = true;
}
}
if (!empty($error)) {
echo "<script> alert('" . $modelAttendeeList->getError() . "'); window.history.go(-1); </script>\n";
}
$cache = Factory::getCache('com_jem');
$cache->clean();
$msg = $total . ' ' . Text::_('COM_JEM_REGISTERED_USERS_DELETED');
$this->setRedirect('index.php?option=com_jem&view=attendees&eventid=' . $eventid, $msg);
}
/**
* Function to export
*/
public function export()
{
// Check for request forgeries
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
header('Content-Type: text/x-csv');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: attachment; filename=attendees.csv');
header('Pragma: no-cache');
$model = $this->getModel('attendees');
$model->getCsv();
jexit();
}
/**
* redirect to events page
*/
public function back()
{
$this->setRedirect('index.php?option=com_jem&view=events');
}
/**
* Function to change status
*/
public function toggleStatus()
{
// Check for request forgeries
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
$app = Factory::getApplication();
$pks = $app->input->get('cid', array(), 'array');
$task = $this->getTask();
if (empty($pks)) {
Factory::getApplication()->enqueueMessage(Text::_('JERROR_NO_ITEMS_SELECTED'), 'warning');
} else {
\Joomla\Utilities\ArrayHelper::toInteger($pks);
$model = $this->getModel('attendee');
PluginHelper::importPlugin('jem');
$dispatcher = JemFactory::getDispatcher();
foreach ($pks AS $pk) {
$model->setId($pk);
$attendee = $model->getData();
$res = $model->toggle();
if ($res) {
$dispatcher->triggerEvent('onUserOnOffWaitinglist', array($pk));
if ($attendee->waiting) {
$msg = Text::_('COM_JEM_ADDED_TO_ATTENDING');
} else {
$msg = Text::_('COM_JEM_ADDED_TO_WAITING');
}
$type = 'message';
} else {
$msg = Text::_('COM_JEM_WAITINGLIST_TOGGLE_ERROR') . ': ' . $model->getError();
$type = 'error';
}
if ($task !== 'toggleStatus') {
$app->enqueueMessage($msg, $type);
}
}
}
if ($task === 'toggleStatus') {
# here we are selecting more rows so a general message would be better
$msg = Text::_('COM_JEM_ATTENDEES_CHANGEDSTATUS');
$type = "message";
$app->enqueueMessage($msg, $type);
}
$this->setRedirect('index.php?option=com_jem&view=attendees&eventid=' . $attendee->event);
$this->redirect();
}
/**
* logic to create the edit attendee view
*
* @access public
* @return void
*
*/
public function edit()
{
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
$jinput = Factory::getApplication()->input;
$jinput->set('view', 'attendee');
// 'attendee' expects event id as 'event' not 'id'
$jinput->set('event', $jinput->getInt('eventid'));
$jinput->set('id', null);
$jinput->set('hidemainmenu', '1');
parent::display();
}
/**
* Method to change status of selected rows.
*
* @return void
*/
public function setStatus()
{
// Check for request forgeries
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
$app = Factory::getApplication();
$user = $app->getIdentity();
$eventid = $app->input->getInt('eventid');
$ids = $app->input->get('cid', array(), 'array');
$values = array('setWaitinglist' => 2, 'setAttending' => 1, 'setInvited' => 0, 'setNotAttending' => -1);
$task = $this->getTask();
$value = \Joomla\Utilities\ArrayHelper::getValue($values, $task, 0, 'int');
if (empty($ids))
{
$message = Text::_('JERROR_NO_ITEMS_SELECTED');
Factory::getApplication()->enqueueMessage($message, 'warning');
}
else
{
// Get the model.
$model = $this->getModel('attendee');
// Publish the items.
if (!$model->setStatus($ids, $value))
{
$message = $model->getError();
JemHelper::addLogEntry($message, __METHOD__, Log::ERROR);
Factory::getApplication()->enqueueMessage($message, 'warning');
}
else
{
PluginHelper::importPlugin('jem');
$dispatcher = JemFactory::getDispatcher();
switch ($value) {
case -1:
$message = Text::plural('COM_JEM_ATTENDEES_N_ITEMS_NOTATTENDING', count($ids));
foreach ($ids AS $pk) {
// onEventUserUnregistered($eventid, $record, $recordid)
$dispatcher->triggerEvent('onEventUserUnregistered', array($eventid, false, $pk));
}
break;
case 0:
$message = Text::plural('COM_JEM_ATTENDEES_N_ITEMS_INVITED', count($ids));
foreach ($ids AS $pk) {
// onEventUserRegistered($recordid)
$dispatcher->triggerEvent('onEventUserRegistered', array($pk));
}
break;
case 1:
$message = Text::plural('COM_JEM_ATTENDEES_N_ITEMS_ATTENDING', count($ids));
foreach ($ids AS $pk) {
// onEventUserRegistered($recordid)
$dispatcher->triggerEvent('onEventUserRegistered', array($pk));
}
break;
case 2:
$message = Text::plural('COM_JEM_ATTENDEES_N_ITEMS_WAITINGLIST', count($ids));
foreach ($ids AS $pk) {
// onUserOnOffWaitinglist($recordid)
$dispatcher->triggerEvent('onUserOnOffWaitinglist', array($pk));
}
break;
}
JemHelper::addLogEntry($message, __METHOD__, Log::DEBUG);
}
}
$this->setRedirect(Route::_('index.php?option=com_jem&view=attendees&eventid=' . $eventid, false), $message);
}
}

View File

@ -0,0 +1,155 @@
<?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\Controller\AdminController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
/**
* Categories Controller
*/
class JemControllerCategories extends AdminController
{
protected $text_prefix = 'COM_JEM_CATEGORIES';
/**
* Proxy for getModel
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
*
* @return object The model.
*/
public function getModel($name = 'Category', $prefix = 'JemModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
/**
* Rebuild the nested set tree.
*
* @return bool False on failure or error, true on success.
*/
public function rebuild()
{
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
$this->setRedirect(Route::_('index.php?option=com_jem&view=categories', false));
// Initialise variables.
$model = $this->getModel();
if ($model->rebuild()) {
// Rebuild succeeded.
$this->setMessage(Text::_('COM_JEM_CATEGORIES_REBUILD_SUCCESS'));
return true;
} else {
// Rebuild failed.
$this->setMessage(Text::_('COM_JEM_CATEGORIES_REBUILD_FAILURE'));
return false;
}
}
/**
* Save the manual order inputs from the categories list page.
*
* @return void
*/
public function saveorderDisabled()
{
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
// Get the arrays from the Request
$order = Factory::getApplication()->input->post->get('order', array(), 'array');
$originalOrder = explode(',', Factory::getApplication()->input->getString('original_order_values', ''));
// Make sure something has changed
if ($order !== $originalOrder) {
parent::saveorder();
} else {
// Nothing to reorder
$this->setRedirect(Route::_('index.php?option='.$this->option.'&view='.$this->view_list, false));
return true;
}
}
/** Deletes and returns correctly.
*
* @return void
*/
public function deleteDisabled()
{
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
// Get items to remove from the request.
$cid = Factory::getApplication()->input->get('cid', array(), 'array');
$extension = Factory::getApplication()->input->get('extension', '');
if (!is_array($cid) || count($cid) < 1)
{
Factory::getApplication()->enqueueMessage(Text::_($this->text_prefix . '_NO_ITEM_SELECTED'), 'warning');
}
else
{
// Get the model.
$model = $this->getModel();
// Make sure the item ids are integers
jimport('joomla.utilities.arrayhelper');
\Joomla\Utilities\ArrayHelper::toInteger($cid);
// Remove the items.
if ($model->delete($cid))
{
$this->setMessage(Text::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
}
else
{
$this->setMessage($model->getError());
}
}
$this->setRedirect(Route::_('index.php?option=' . $this->option . '&extension=' . $extension, false));
}
/**
* Logic to delete categories
*
* @access public
* @return void
*
*/
public function remove()
{
// Check for request forgeries
Session::checkToken() or jexit('Invalid Token');
$cid= Factory::getApplication()->input->post->get('cid', array(), 'array');
if (!is_array($cid) || count($cid) < 1) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_SELECT_ITEM_TO_DELETE'), 'warning');
}
$model = $this->getModel('category');
$msg = $model->delete($cid);
$cache = Factory::getCache('com_jem');
$cache->clean();
$this->setRedirect('index.php?option=com_jem&view=categories', $msg);
}
}

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\Language\Text;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\Session\Session;
/**
* Category Controller
*/
class JemControllerCategory extends FormController
{
/**
* The extension for which the categories apply.
*
* @var string
*/
protected $text_prefix = 'COM_JEM_CATEGORY';
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JController
*/
public function __construct($config = array())
{
parent::__construct($config);
}
/**
* Method to check if you can add a new record.
*
* @param array $data An array of input data.
*
* @return boolean
*
*/
protected function allowAddDisabled($data = array())
{
$user = JemFactory::getUser();
return ($user->authorise('core.create', $this->extension) || count($user->getAuthorisedCategories($this->extension, 'core.create')));
}
/**
* Method to check if you can edit a record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
*/
protected function allowEditDisabled($data = array(), $key = 'parent_id')
{
// Initialise variables.
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$user = JemFactory::getUser();
$userId = $user->get('id');
// Check general edit permission first.
if ($user->authorise('core.edit', $this->extension))
{
return true;
}
// Check specific edit permission.
if ($user->authorise('core.edit', $this->extension . '.category.' . $recordId))
{
return true;
}
// Fallback on edit.own.
// First test if the permission is available.
if ($user->authorise('core.edit.own', $this->extension . '.category.' . $recordId) || $user->authorise('core.edit.own', $this->extension))
{
// Now test the owner is the user.
$ownerId = (int) isset($data['created_user_id']) ? $data['created_user_id'] : 0;
if (empty($ownerId) && $recordId)
{
// Need to do a lookup from the model.
$record = $this->getModel()->getItem($recordId);
if (empty($record))
{
return false;
}
$ownerId = $record->created_user_id;
}
// If the owner matches 'me' then do the test.
if ($ownerId == $userId)
{
return true;
}
}
return false;
}
/**
* Method to run batch operations.
*
* @param object $model The model.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
*/
public function batchDisabled($model = null)
{
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
// Set the model
$model = $this->getModel('Category');
// Preset the redirect
$this->setRedirect('index.php?option=com_jem&view=categories&extension=' . $this->extension);
return parent::batch($model);
}
/**
* Gets the URL arguments to append to an item redirect.
*
* @param integer $recordId The primary key id for the item.
* @param string $urlVar The name of the URL variable for the id.
*
* @return string The arguments to append to the redirect URL.
*
*/
protected function getRedirectToItemAppendDisabled($recordId = null, $urlVar = 'id')
{
$append = parent::getRedirectToItemAppend($recordId);
$append .= '&extension=' . $this->extension;
return $append;
}
/**
* Gets the URL arguments to append to a list redirect.
*
* @return string The arguments to append to the redirect URL.
*
*/
protected function getRedirectToListAppendDisabled()
{
$append = parent::getRedirectToListAppend();
$append .= '&extension=' . $this->extension;
return $append;
}
}

View File

@ -0,0 +1,76 @@
<?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\Controller\AdminController;
/**
* JEM Component Cssmanager Controller
*/
class JemControllerCssmanager extends AdminController
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
// Register Extra task
$this->registerTask('setlinenumber', 'linenumber');
$this->registerTask('disablelinenumber', 'linenumber');
}
/**
* Proxy for getModel.
*/
public function getModel($name = 'Cssmanager', $prefix = 'JemModel', $config = array())
{
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
return $model;
}
/**
*
*/
public function cancel()
{
$this->setRedirect('index.php?option=com_jem&view=main');
}
public function back()
{
$this->setRedirect('index.php?option=com_jem&view=main');
}
/**
*
*/
public function linenumber()
{
$task = Factory::getApplication()->input->get('task', '');
$model = $this->getModel();
switch ($task)
{
case 'setlinenumber' :
$model->setStatusLinenumber(1);
break;
default :
$model->setStatusLinenumber(0);
break;
}
$this->setRedirect('index.php?option=com_jem&view=cssmanager');
}
}

View File

@ -0,0 +1,72 @@
<?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\Plugin\PluginHelper;
require_once (JPATH_COMPONENT_SITE.'/classes/controller.form.class.php');
/**
* JEM Component Event Controller
*
*/
class JemControllerEvent extends JemControllerForm
{
/**
* @var string The prefix to use with controller messages.
*
*/
protected $text_prefix = 'COM_JEM_EVENT';
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* @see JController
*
*/
public function __construct($config = array())
{
parent::__construct($config);
}
/**
* Function that allows child controller access to model data
* after the data has been saved.
* Here used to trigger the jem plugins, mainly the mailer.
*
* @param JModel(Legacy) $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @note On J! 2.5 first param is 'JModel &$model' but
* on J! 3.x it's 'JModelLegacy $model'
* one of the bad things making extension developer's life hard.
*/
protected function _postSaveHook($model, $validData = array())
{
$isNew = $model->getState('event.new');
$id = $model->getState('event.id');
// trigger all jem plugins
PluginHelper::importPlugin('jem');
$dispatcher = JemFactory::getDispatcher();
$dispatcher->triggerEvent('onEventEdited', array($id, $isNew));
// but show warning if mailer is disabled
if (!PluginHelper::isEnabled('jem', 'mailer')) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_GLOBAL_MAILERPLUGIN_DISABLED'), 'notice');
}
}
}

View File

@ -0,0 +1,97 @@
<?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\Controller\AdminController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
/**
* Events Controller
*/
class JemControllerEvents extends AdminController
{
/**
* @var string The prefix to use with controller messages.
*
*/
protected $text_prefix = 'COM_JEM_EVENTS';
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* @see JController
*/
public function __construct($config = array())
{
parent::__construct($config);
$this->registerTask('unfeatured', 'featured');
}
/**
* Method to toggle the featured setting of a list of events.
*
* @return void
* @since 1.6
*/
public function featured()
{
// Check for request forgeries
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
// Initialise variables.
$user = JemFactory::getUser();
$ids = Factory::getApplication()->input->get('cid', array(), 'array');
$values = array('featured' => 1, 'unfeatured' => 0);
$task = $this->getTask();
$value = \Joomla\Utilities\ArrayHelper::getValue($values, $task, 0, 'int');
$glob_auth = $user->can('publish', 'event'); // general permission for all events
// Access checks.
foreach ($ids as $i => $id)
{
if (!$glob_auth && !$user->can('publish', 'event', (int)$id)) {
// Prune items that you can't change.
unset($ids[$i]);
Factory::getApplication()->enqueueMessage(Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'notice');
}
}
if (empty($ids)) {
Factory::getApplication()->enqueueMessage(Text::_('JERROR_NO_ITEMS_SELECTED'), 'warning');
}
else {
// Get the model.
$model = $this->getModel();
// Publish the items.
if (!$model->featured($ids, $value)) {
Factory::getApplication()->enqueueMessage($model->getError(), 'warning');
}
}
$this->setRedirect('index.php?option=com_jem&view=events');
}
/**
* Proxy for getModel.
*
*/
public function getModel($name = 'Event', $prefix = 'JemModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
}
?>

View File

@ -0,0 +1,81 @@
<?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\MVC\Controller\AdminController;
use Joomla\CMS\Session\Session;
/**
* JEM Component Export Controller
*
*/
class JemControllerExport extends AdminController
{
/**
* Proxy for getModel.
*
*/
public function getModel($name = 'Export', $prefix = 'JemModel', $config=array()) {
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
return $model;
}
public function export()
{
// Check for request forgeries
Session::checkToken() or jexit('Invalid Token');
$this->sendHeaders("jem_export-" . date('Ymd-His') . ".csv", "text/csv");
$this->getModel()->getCsv();
jexit();
}
public function exportcats()
{
// Check for request forgeries
Session::checkToken() or jexit('Invalid Token');
$this->sendHeaders("categories.csv", "text/csv");
$this->getModel()->getCsvcats();
jexit();
}
public function exportvenues()
{
// Check for request forgeries
Session::checkToken() or jexit('Invalid Token');
$this->sendHeaders("venues.csv", "text/csv");
$this->getModel()->getCsvvenues();
jexit();
}
public function exportcatevents()
{
// Check for request forgeries
Session::checkToken() or jexit('Invalid Token');
$this->sendHeaders("catevents.csv", "text/csv");
$this->getModel()->getCsvcatsevents();
jexit();
}
private function sendHeaders($filename = 'export.csv', $contentType = 'text/plain')
{
// TODO: Use UTF-8
// We have to fix the model->getCsv* methods too!
// header("Content-type: text/csv; charset=UTF-8");
header("Content-type: text/csv;");
header("Content-Disposition: attachment; filename=" . $filename);
header("Pragma: no-cache");
header("Expires: 0");
}
}

View File

@ -0,0 +1,37 @@
<?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\Controller\FormController;
/**
* JEM Component Group Controller
*
*/
class JemControllerGroup extends FormController
{
/**
* @var string The prefix to use with controller messages.
*
*/
protected $text_prefix = 'COM_JEM_GROUP';
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
*
*/
public function __construct($config = array())
{
parent::__construct($config);
}
}

View File

@ -0,0 +1,71 @@
<?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\Controller\AdminController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
/**
* JEM Component Groups Controller
*
*/
class JemControllerGroups extends AdminController
{
/**
* @var string The prefix to use with controller messages.
*
*/
protected $text_prefix = 'COM_JEM_GROUPS';
/**
* Proxy for getModel.
*
*/
public function getModel($name = 'Group', $prefix = 'JemModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
/**
* logic to remove a group
*
* @access public
* @return void
*
*/
public function remove()
{
// Check for request forgeries
Session::checkToken() or jexit('Invalid Token');
$jinput = Factory::getApplication()->input;
$cid = $jinput->get('cid', 0, 'array');
if (!is_array($cid) || count($cid) < 1) {
throw new Exception(Text::_('COM_JEM_SELECT_ITEM_TO_DELETE'), 500);
}
$total = count($cid);
$model = $this->getModel('groups');
if(!$model->delete($cid)) {
echo "<script> alert('".$model->getError()."'); window.history.go(-1); </script>\n";
}
$msg = $total.' '.Text::_('COM_JEM_GROUPS_DELETED');
$this->setRedirect('index.php?option=com_jem&view=groups', $msg);
}
}
?>

View File

@ -0,0 +1,121 @@
<?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\Controller\BaseController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
/**
* Housekeeping-Controller
*/
class JemControllerHousekeeping extends BaseController
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
// Register Extra task
$this->registerTask('cleaneventimg', 'delete');
$this->registerTask('cleanvenueimg', 'delete');
$this->registerTask('cleancategoryimg', 'delete');
}
/**
* logic to massdelete unassigned images
*
* @access public
* @return void
*
*/
public function delete()
{
// Check for request forgeries
Session::checkToken('get') or jexit('Invalid Token');
$task = Factory::getApplication()->input->get('task', '');
$model = $this->getModel('housekeeping');
if ($task == 'cleaneventimg') {
$total = $model->delete($model::EVENTS);
} elseif ($task == 'cleanvenueimg') {
$total = $model->delete($model::VENUES);
} elseif ($task == 'cleancategoryimg') {
$total = $model->delete($model::CATEGORIES);
}
$link = 'index.php?option=com_jem&view=housekeeping';
$msg = Text::sprintf('COM_JEM_HOUSEKEEPING_IMAGES_DELETED', $total);
$this->setRedirect($link, $msg);
}
/**
* logic to truncate table cats_relations
*
* @access public
* @return void
*
*/
public function cleanupCatsEventRelations()
{
// Check for request forgeries
Session::checkToken('get') or jexit('Invalid Token');
$model = $this->getModel('housekeeping');
$model->cleanupCatsEventRelations();
$link = 'index.php?option=com_jem&view=housekeeping';
$msg = Text::_('COM_JEM_HOUSEKEEPING_CLEANUP_CATSEVENT_RELS_DONE');
$this->setRedirect($link, $msg);
}
/**
* Truncates JEM tables with exception of settings table
*/
public function truncateAllData()
{
// Check for request forgeries
Session::checkToken('get') or jexit('Invalid Token');
$model = $this->getModel('housekeeping');
$model->truncateAllData();
$link = 'index.php?option=com_jem&view=housekeeping';
$msg = Text::_('COM_JEM_HOUSEKEEPING_TRUNCATE_ALL_DATA_DONE');
$this->setRedirect($link, $msg);
}
/**
* Triggerarchive + Recurrences
*
* @access public
* @return void
*
*/
public function triggerarchive()
{
// Check for request forgeries
Session::checkToken('get') or jexit('Invalid Token');
JemHelper::cleanup(1);
$link = 'index.php?option=com_jem&view=housekeeping';
$msg = Text::_('COM_JEM_HOUSEKEEPING_AUTOARCHIVE_DONE');
$this->setRedirect($link, $msg);
}
}
?>

View File

@ -0,0 +1,148 @@
<?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\Client\ClientHelper;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Filesystem\Path;
/**
* JEM Component Imagehandler Controller
*
* @package JEM
*
*/
class JemControllerImagehandler extends BaseController
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
// Register Extra task
$this->registerTask('eventimgup', 'uploadimage');
$this->registerTask('venueimgup', 'uploadimage');
$this->registerTask('categoriesimgup', 'uploadimage');
}
/**
* logic for uploading an image
*
* @access public
* @return void
*/
public function uploadimage()
{
// Check for request forgeries
Session::checkToken() or jexit('Invalid token');
$app = Factory::getApplication();
$jemsettings = JemAdmin::config();
$file = Factory::getApplication()->input->files->get('userfile', array(), 'array');
$task = Factory::getApplication()->input->get('task', '');
// Set FTP credentials, if given
ClientHelper::setCredentialsFromRequest('ftp');
//set the target directory
if ($task == 'venueimgup') {
$base_Dir = JPATH_SITE.'/images/jem/venues/';
} else if ($task == 'eventimgup') {
$base_Dir = JPATH_SITE.'/images/jem/events/';
} else if ($task == 'categoriesimgup') {
$base_Dir = JPATH_SITE.'/images/jem/categories/';
}
//do we have an upload?
if (empty($file['name'])) {
echo "<script> alert('".Text::_('COM_JEM_IMAGE_EMPTY')."'); window.history.go(-1); </script>\n";
$app->close();
}
//check the image
$check = JemImage::check($file, $jemsettings);
if ($check === false) {
$app->redirect($_SERVER['HTTP_REFERER']);
}
//sanitize the image filename
$filename = JemImage::sanitize($base_Dir, $file['name']);
$filepath = $base_Dir . $filename;
//upload the image
if (!File::upload($file['tmp_name'], $filepath)) {
echo "<script> alert('".Text::_('COM_JEM_UPLOAD_FAILED')."'); </script>\n";
$app->close();
} else {
echo "<script> alert('".Text::_('COM_JEM_UPLOAD_COMPLETE')."'); window.parent.SelectImage('$filename', '$filename'); </script>\n";
$app->close();
}
}
/**
* logic to mass delete images
*
* @access public
* @return void
*/
public function delete()
{
// Check for request forgeries
Session::checkToken('get') or jexit('Invalid Token');
$app = Factory::getApplication();
// Set FTP credentials, if given
ClientHelper::setCredentialsFromRequest('ftp');
// Get some data from the request
$images = Factory::getApplication()->input->get('rm', array(), 'array');
$folder = Factory::getApplication()->input->get('folder', '');
if (count($images)) {
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');
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);
}
}
}
}
if ($folder == 'events') {
$task = 'selecteventimg';
} else if ($folder == 'venues') {
$task = 'selectvenueimg';
} else if ($folder == 'categories') {
$task = 'selectcategoriesimg';
}
$app->redirect('index.php?option=com_jem&view=imagehandler&task='.$task.'&tmpl=component');
}
}
?>

View File

@ -0,0 +1,385 @@
<?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\Controller\BaseController;
use Joomla\CMS\Session\Session;
// helper callback function to convert all elements of an array
function jem_convert_ansi2utf8(&$value, $key)
{
$value = iconv('windows-1252', 'utf-8', $value);
}
/**
* JEM Component Import Controller
*
* @package JEM
*
*/
class JemControllerImport extends BaseController
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
public function csveventimport()
{
$this->CsvImport('events', 'events');
}
public function csvcategoriesimport()
{
$this->CsvImport('categories', 'categories');
}
public function csvvenuesimport()
{
$this->CsvImport('venues', 'venues');
}
public function csvcateventsimport()
{
$this->CsvImport('catevents', 'cats_event_relations');
}
private function CsvImport($type, $dbname)
{
// Check for request forgeries
Session::checkToken() or jexit('Invalid Token');
$replace = Factory::getApplication()->input->post->getInt('replace_'.$type, 0);
$object = Table::getInstance('jem_'.$dbname, '');
$object_fields = get_object_vars($object);
$jemconfig = JemConfig::getInstance()->toRegistry();
$separator = $jemconfig->get('csv_separator', ';');
$delimiter = $jemconfig->get('csv_delimiter', '"');
if ($type === 'events') {
// add additional fields
$object_fields['categories'] = '';
}
$msg = '';
$file = Factory::getApplication()->input->files->get('File'.$type, array(), 'array');
if (empty($file['name']))
{
$msg = Text::_('COM_JEM_IMPORT_SELECT_FILE');
$this->setRedirect('index.php?option=com_jem&view=import', $msg, 'error');
return;
}
if ($file['name']) {
$handle = fopen($file['tmp_name'], 'r');
if (!$handle) {
$msg = Text::_('COM_JEM_IMPORT_OPEN_FILE_ERROR');
$this->setRedirect('index.php?option=com_jem&view=import', $msg, 'error');
return;
}
// search for bom - then it is utf-8
$bom = pack('CCC', 0xEF, 0xBB, 0xBF);
$fc = fread($handle, 3);
$convert = strncmp($fc, $bom, 3) !== 0;
if ($convert) {
// no bom - rewind file
fseek($handle, 0);
}
// get fields, on first row of the file
$fields = array();
if (($data = fgetcsv($handle, 1000, $separator, $delimiter)) !== false) {
$numfields = count($data);
// convert from ansi to utf-8 if required
if ($convert) {
$msg .= "<p>".Text::_('COM_JEM_IMPORT_BOM_NOT_FOUND')."</p>\n";
array_walk($data, 'jem_convert_ansi2utf8');
}
for ($c = 0; $c < $numfields; $c++) {
// here, we make sure that the field match one of the fields of jem_venues table or special fields,
// otherwise, we don't add it
if (array_key_exists($data[$c], $object_fields)) {
$fields[$c] = $data[$c];
}
}
}
// If there is no validated fields, there is a problem...
if (!count($fields)) {
$msg .= "<p>".Text::_('COM_JEM_IMPORT_PARSE_ERROR')."</p>\n";
$msg .= "<p>".Text::_('COM_JEM_IMPORT_PARSE_ERROR_INFOTEXT')."</p>\n";
$this->setRedirect('index.php?option=com_jem&view=import', $msg, 'error');
return;
} else {
$msg .= "<p>".Text::sprintf('COM_JEM_IMPORT_NUMBER_OF_FIELDS', $numfields)."</p>\n";
$msg .= "<p>".Text::sprintf('COM_JEM_IMPORT_NUMBER_OF_FIELDS_USEABLE', count($fields))."</p>\n";
}
// Now get the records, meaning the rest of the rows.
$records = array();
$row = 1;
while (($data = fgetcsv($handle, 10000, $separator, $delimiter)) !== FALSE) {
$num = count($data);
if ($numfields != $num) {
$msg .= "<p>".Text::sprintf('COM_JEM_IMPORT_NUMBER_OF_FIELDS_COUNT_ERROR', $num, $row)."</p>\n";
} else {
// convert from ansi to utf-8 if required
if ($convert) {
array_walk($data, 'jem_convert_ansi2utf8');
}
$r = array();
// only extract columns with validated header, from previous step.
foreach ($fields as $k => $v) {
$r[$k] = $this->_formatcsvfield($v, $data[$k]);
}
$records[] = $r;
}
$row++;
}
fclose($handle);
$msg .= "<p>".Text::sprintf('COM_JEM_IMPORT_NUMBER_OF_ROWS_FOUND', count($records))."</p>\n";
// database update
if (count($records)) {
$model = $this->getModel('import');
$result = $model->{$type.'import'}($fields, $records, $replace);
if ($result['added']) {
$msg .= "<p>" . Text::sprintf('COM_JEM_IMPORT_NUMBER_OF_ROWS_ADDED', $result['added']) . "</p>\n";
}
if ($result['updated']){
$msg .= "<p>" . Text::sprintf('COM_JEM_IMPORT_NUMBER_OF_ROWS_UPDATED', $result['updated']) . "</p>\n";
}
if ($result['duplicated']){
$msg .= "<p>" . Text::sprintf('COM_JEM_IMPORT_NUMBER_OF_ROWS_DUPLICATED', $result['duplicated']) . " [Id events: " . $result['duplicatedids'] . "]</p>\n";
}
if ($result['replaced']){
$msg .= "<p>" . Text::sprintf('COM_JEM_IMPORT_NUMBER_OF_ROWS_REPLACED', $result['replaced']) . " [Id events: " . $result['replacedids'] . "]</p>\n";
}
if ($result['ignored']){
$msg .= "<p>" . Text::sprintf('COM_JEM_IMPORT_NUMBER_OF_ROWS_IGNORED', $result['ignored']) . " [Id events: " . $result['ignoredids'] . "]</p>\n";
}
if ($result['error']){
$msg .= "<p>" . Text::sprintf('COM_JEM_IMPORT_NUMBER_OF_ROWS_ERROR', $result['error']) . " [Id events: " . $result['errorids'] . "]</p>\n";
}
}
$this->setRedirect('index.php?option=com_jem&view=import', $msg);
} else {
parent::display();
}
}
/**
* handle specific fields conversion if needed
*
* @param string column name
* @param string $value
* @return string
*/
protected function _formatcsvfield($type, $value)
{
switch($type) {
case 'times':
case 'endtimes':
if ($value !== '' && strtoupper($value) !== 'NULL') {
$time = strtotime($value);
$field = date('H:i:s',$time);
} else {
$field = null;
}
break;
case 'dates':
case 'enddates':
case 'recurrence_limit_date':
if ($value !== '' && strtoupper($value) !== 'NULL' && $value != '0000-00-00') {
$date = strtotime($value);
$field = date('Y-m-d', $date);
} else {
$field = null;
}
break;
default:
$field = $value;
break;
}
return $field;
}
/**
* Imports data from an old Eventlist installation
*/
public function eventlistImport()
{
// Check for request forgeries
Session::checkToken() or jexit('Invalid Token');
$model = $this->getModel('import');
$size = 5000;
// Handling the different names for all classes and db table names (possibly substrings)
// EL 1.0.2 doesn't have tables attachments and cats_event_descriptions
// EL 1.1 has both tables but events doesn't contain field catsid
// also the recurrence fields are different
// And EL 1.1 runs on J! 1.5 only - which has different access level ids (fixed (0, 1, 2) instead of (1, 2, 3, ...))
$tables = new stdClass();
// Note: 'attachments' MUST be last entry!
$tables->eltables = array("categories", "events", "cats_event_relations", "groupmembers", "groups", "register", "venues", "attachments");
$tables->jemtables = array("categories", "events", "cats_event_relations", "groupmembers", "groups", "register", "venues", "attachments");
$app = Factory::getApplication();
$jinput = $app->input;
$step = $jinput->get('step', 0, 'INT');
$current = $jinput->get->get('current', 0, 'INT');
$total = $jinput->get->get('total', 0, 'INT');
$table = $jinput->get->get('table', 0, 'INT');
$prefix = $app->getUserStateFromRequest('com_jem.import.elimport.prefix', 'prefix', '#__', 'cmd');
$copyImages = $app->getUserStateFromRequest('com_jem.import.elimport.copyImages', 'copyImages', 0, 'int');
$copyAttachments = $app->getUserStateFromRequest('com_jem.import.elimport.copyAttachments', 'copyAttachments', 0, 'int');
$fromJ15 = $app->getUserStateFromRequest('com_jem.import.elimport.fromJ15', 'fromJ15', '0', 'int'); // import from Joomla! 1.5 site?
$link = 'index.php?option=com_jem&view=import';
$msg = Text::_('COM_JEM_IMPORT_EL_IMPORT_WORK_IN_PROGRESS')." ";
if ($jinput->get('startToken', 0, 'INT') || ($step === 1)) {
// Are the JEM tables empty at start? If no, stop import
if ($model->getExistingJemData()) {
$this->setRedirect($link);
return;
}
}
if ($step <= 1) {
$app->setUserState('com_jem.import.elimport.copyImages', '0');
$app->setUserState('com_jem.import.elimport.copyAttachments', '0');
$app->setUserState('com_jem.import.elimport.fromJ15', '0');
if ($step === 1) {
$attachments = $model->getEventlistTableCount("eventlist_attachments") !== null;
$app->setUserState('com_jem.import.elimport.attachmentsPossible', $attachments);
}
parent::display();
return;
} elseif ($step === 2) {
// Special handling of cats_event_relations table which only exists on EL 1.1
if (($tables->eltables[$table] == 'cats_event_relations')) {
$tot = $model->getEventlistTableCount("eventlist_".$tables->eltables[$table]);
if (!empty($tot)) {
$total = $tot;
} else {
$tables->eltables[$table] = 'events';
}
}
// Get number of rows if it is still 0 or we have moved to the next table
if ($total == 0 || $current == 0) {
$total = $model->getEventlistTableCount("eventlist_".$tables->eltables[$table]);
}
// If $total is null, the table does not exist, so we skip import for this table.
if ($total === null) {
// This helps to prevent special cases in the following code
$total = 0;
} else {
// The real work is done here:
// Loading from EL tables, changing data, storing in JEM tables
$data = $model->getEventlistData("eventlist_".$tables->eltables[$table], $current, $size);
$data = $model->transformEventlistData($tables->jemtables[$table], $data, $fromJ15);
$model->storeJemData("jem_".$tables->jemtables[$table], $data);
}
// Proceed with next bunch of data
$current += $size;
// Current table is imported completely, proceed with next table
if ($current > $total) {
$table++;
$current = 0;
}
// Check if table import is complete
if ($current <= $total && $table < count($tables->eltables)) {
// Don't add default prefix to link because of special character #
if ($prefix == "#__") {
$prefix = "";
}
$link .= '&step='.$step.'&table='.$table.'&current='.$current.'&total='.$total;
//todo: we say "importing..." so we must show table of next step - but we don't know their entry count ($total).
$msg .= Text::sprintf('COM_JEM_IMPORT_EL_IMPORT_WORKING_STEP_COPY_DB', $tables->jemtables[$table], $current, '?');
} else {
$step++;
$link .= '&step='.$step;
$msg .= Text::_('COM_JEM_IMPORT_EL_IMPORT_WORKING_STEP_REBUILD');
}
} elseif ($step === 3) {
// We have to rebuild the hierarchy of the categories due to the plain database insertion
Table::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.'/tables');
$categoryTable = Table::getInstance('Category', 'JemTable');
$categoryTable->rebuild();
$step++;
$link .= '&step='.$step;
if ($copyImages) {
$msg .= Text::_('COM_JEM_IMPORT_EL_IMPORT_WORKING_STEP_COPY_IMAGES');
} else {
$msg .= Text::_('COM_JEM_IMPORT_EL_IMPORT_WORKING_STEP_COPY_IMAGES_SKIPPED');
}
} elseif ($step === 4) {
// Copy EL images to JEM image destination?
if ($copyImages) {
$model->copyImages();
}
$step++;
$link .= '&step='.$step;
if ($copyAttachments) {
$msg .= Text::_('COM_JEM_IMPORT_EL_IMPORT_WORKING_STEP_COPY_ATTACHMENTS');
} else {
$msg .= Text::_('COM_JEM_IMPORT_EL_IMPORT_WORKING_STEP_COPY_ATTACHMENTS_SKIPPED');
}
} elseif ($step === 5) {
// Copy EL images to JEM image destination?
if ($copyAttachments) {
$model->copyAttachments();
}
$step++;
$link .= '&step='.$step;
$msg = Text::_('COM_JEM_IMPORT_EL_IMPORT_FINISHED');
} else {
// cleanup stored fields for users importing multiple time ;-)
$app->setUserState('com_jem.import.elimport.prefix', null);
$app->setUserState('com_jem.import.elimport.copyImages', null);
$app->setUserState('com_jem.import.elimport.copyAttachments', null);
$app->setUserState('com_jem.import.elimport.fromJ15', null);
$app->setUserState('com_jem.import.elimport.attachmentsPossible', null);
// perform forced cleanup (archive, delete, recurrence)
JemHelper::cleanup(true);
$msg = Text::_('COM_JEM_IMPORT_EL_IMPORT_FINISHED');
}
$app->enqueueMessage($msg);
$this->setRedirect($link);
}
}
?>

View File

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

View File

@ -0,0 +1,64 @@
<?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;
jimport('joomla.application.component.controller');
/**
* JEM Component Plugins Controller
*
* @package JEM
*
*/
use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\BaseController;
class JemControllerPlugins extends BaseController
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
/**
* Handles Plugin screen
*
* @access public
* @return void
*/
public function plugins()
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select(array('count(*)'));
$query->from('#__extensions AS p');
$query->where(array('p.name LIKE '.$db->quote("%jem%"), 'p.type = '.$db->quote("plugin")));
$db->setQuery($query);
$total = $db->loadResult();
//any plugins installed? if not redirect to installation screen
if ($total > 0){
// $link = 'index.php?option=com_plugins&filter_search=jem';
$link = 'index.php?option=com_plugins&filter[search]=jem';
$msg = "";
} else {
$link = 'index.php?option=com_installer';
$msg = Text::_("COM_JEM_PLUGINS_NOPLUGINSINSTALLED");
}
$this->setRedirect($link, $msg);
}
}
?>

View File

@ -0,0 +1,46 @@
<?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\Controller\BaseController;
use Joomla\CMS\Language\Text;
/**
* JEM Component Sampledata Controller
* @package JEM
*/
class JemControllerSampledata extends BaseController
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
/**
* Process sampledata
*/
public function load()
{
$model = $this->getModel('sampledata');
if (!$model->loadData()) {
$msg = Text::_('COM_JEM_SAMPLEDATA_FAILED');
} else {
$msg = Text::_('COM_JEM_SAMPLEDATA_SUCCESSFULL');
}
$link = 'index.php?option=com_jem&view=main';
$this->setRedirect($link, $msg);
}
}
?>

View File

@ -0,0 +1,177 @@
<?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\Controller\BaseController;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
/**
* JEM Component Settings Controller
*/
class JemControllerSettings extends BaseController
{
public function __construct($config = array())
{
parent::__construct($config);
// Map the apply task to the save method.
$this->registerTask('apply', 'save');
}
/**
* Method to check if you can add a new record.
*
* @return boolean
*/
protected function allowEdit()
{
return JemFactory::getUser()->authorise('core.manage', 'com_jem');
}
/**
* Method to check if you can save a new or existing record.
*
* @return boolean
*/
protected function allowSave()
{
return $this->allowEdit();
}
/**
* Method to get a model object, loading it if required.
*
* @param string The model name. Optional.
* @param string The class prefix. Optional.
* @param array Configuration data for model. Optional.
*
* @return object The model.
*/
public function getModel($name = 'Settings', $prefix = 'JemModel', $config = array())
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
/**
* Method to save the configuration data.
*
* @param array An array containing all global config data.
* @return bool True on success, false on failure.
* @since 1.6
*/
public function save()
{
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
// Initialise variables.
$app = Factory::getApplication();
$data = $app->input->get('jform', array(), 'array');
$task = $this->getTask();
$model = $this->getModel();
$context = 'com_jem.edit.settings';
// Access check.
if (!$this->allowSave()) {
Factory::getApplication()->enqueueMessage(Text::_('JERROR_SAVE_NOT_PERMITTED'), 'warning');
}
// Validate the posted data.
$form = $model->getForm();
if (!$form) {
Factory::getApplication()->enqueueMessage($model->getError(), 'error');
return false;
}
// Validate the posted data.
$form = $model->getForm();
$data = $model->validate($form, $data);
// Check for validation errors.
if ($data === false) {
// Get the validation messages.
$errors = $model->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
if ($errors[$i] instanceof Exception) {
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
}
else {
$app->enqueueMessage($errors[$i], 'warning');
}
}
// Save the data in the session.
$app->setUserState($context . '.data', $data);
// Redirect back to the edit screen.
$this->setRedirect(Route::_('index.php?option=com_jem&view=settings', false));
return false;
}
// Attempt to save the data.
if (!$model->store($data)) {
// Save the data in the session.
$app->setUserState($context . '.data', $data);
// Redirect back to the edit screen.
$this->setMessage(Text::sprintf('JERROR_SAVE_FAILED', $model->getError()), 'warning');
$this->setRedirect(Route::_('index.php?option=com_jem&view=settings', false));
return false;
}
$this->setMessage(Text::_('COM_JEM_SETTINGS_SAVED'));
// Redirect the user and adjust session state based on the chosen task.
switch ($task)
{
case 'apply':
// Reset the record data in the session.
$app->setUserState($context . '.data', null);
// Redirect back to the edit screen.
$this->setRedirect(Route::_('index.php?option=com_jem&view=settings', false));
break;
default:
// Clear the record id and data from the session.
$app->setUserState($context . '.id', null);
$app->setUserState($context . '.data', null);
// Redirect to the list screen.
$this->setRedirect(Route::_('index.php?option=com_jem&view=main', false));
break;
}
}
/**
* Cancel operation
*/
public function cancel()
{
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
// Check if the user is authorized to do this.
if (!JemFactory::getUser()->authorise('core.admin', 'com_jem')) {
Factory::getApplication()->redirect('index.php', Text::_('JERROR_ALERTNOAUTHOR'));
return;
}
$this->setRedirect('index.php?option=com_jem');
}
}

View File

@ -0,0 +1,238 @@
<?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\Controller\BaseController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
/**
* Source controller class
*/
class JemControllerSource extends BaseController
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
*/
public function __construct($config = array())
{
parent::__construct($config);
// Apply, Save & New, and Save As copy should be standard on forms.
$this->registerTask('apply', 'save');
}
/**
* Method to check if you can add a new record.
*
* @return boolean
*/
protected function allowEdit()
{
return JemFactory::getUser()->authorise('core.edit', 'com_jem');
}
/**
* Method to check if you can save a new or existing record.
*
* @return boolean
*/
protected function allowSave()
{
return $this->allowEdit();
}
/**
* Method to get a model object, loading it if required.
*
* @param string The model name. Optional.
* @param string The class prefix. Optional.
* @param array Configuration array for model. Optional.
*
* @return object The model.
*/
public function getModel($name = 'Source', $prefix = 'JemModel', $config = array())
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
/**
* This controller does not have a display method. Redirect back to the list view of the component.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*
*/
public function display($cachable = false, $urlparams = array())
{
$this->setRedirect(Route::_('index.php?option=com_jem&view=cssmanager', false));
}
/**
* Method to edit an existing record.
*
* @return boolean True on success.
*/
public function edit()
{
// Initialise variables.
$app = Factory::getApplication();
$model = $this->getModel();
$recordId = $app->input->get('id', '');
$context = 'com_jem.edit.source';
if (preg_match('#\.\.#', base64_decode($recordId))) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_CSSMANAGER_ERROR_SOURCE_FILE_NOT_FOUND'), 'warning');
}
// Access check.
if (!$this->allowEdit()) {
Factory::getApplication()->enqueueMessage(Text::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'), 'warning');
}
// Check-out succeeded, push the new record id into the session.
$app->setUserState($context.'.id', $recordId);
$app->setUserState($context.'.data', null);
$this->setRedirect('index.php?option=com_jem&view=source&layout=edit');
return true;
}
/**
* Method to cancel an edit
*/
public function cancel()
{
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
// Initialise variables.
$app = Factory::getApplication();
$model = $this->getModel();
$context = 'com_jem.edit.source';
// Clean the session data and redirect.
$app->setUserState($context.'.id', null);
$app->setUserState($context.'.data', null);
$this->setRedirect(Route::_('index.php?option=com_jem&view=cssmanager', false));
}
/**
* Saves a template source file.
*
* @return boolean True on success.
*/
public function save()
{
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
// Initialise variables.
$app = Factory::getApplication();
$data = $app->input->get('jform', array(), 'array');
$context = 'com_jem.edit.source';
$task = $this->getTask();
$model = $this->getModel();
$file = $model->getState('filename');
$custom = stripos($file, 'custom#:');
# custom file?
if ($custom !== false) {
$file = str_replace('custom#:', '', $file);
}
// Access check.
if (!$this->allowSave()) {
Factory::getApplication()->enqueueMessage(Text::_('JERROR_SAVE_NOT_PERMITTED'), 'warning');
}
// Match the stored id's with the submitted.
if (empty($data['filename']) || ($data['filename'] != $file)) {
throw new Exception(Text::_('COM_JEM_CSSMANAGER_ERROR_SOURCE_ID_FILENAME_MISMATCH'), 500);
}
// Validate the posted data.
$form = $model->getForm();
if (!$form)
{
Factory::getApplication()->enqueueMessage($model->getError(), 'error');
return false;
}
$data = $model->validate($form, $data);
// Check for validation errors.
if ($data === false)
{
// Get the validation messages.
$errors = $model->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof Exception) {
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
}
else {
$app->enqueueMessage($errors[$i], 'warning');
}
}
// Save the data in the session.
$app->setUserState($context.'.data', $data);
// Redirect back to the edit screen.
$this->setRedirect(Route::_('index.php?option=com_jem&view=source&layout=edit', false));
return false;
}
// Attempt to save the data.
if (!$model->save($data))
{
// Save the data in the session.
$app->setUserState($context.'.data', $data);
// Redirect back to the edit screen.
$this->setMessage(Text::sprintf('JERROR_SAVE_FAILED', $model->getError()), 'warning');
$this->setRedirect(Route::_('index.php?option=com_jem&view=source&layout=edit', false));
return false;
}
$this->setMessage(Text::_('COM_JEM_CSSMANAGER_FILE_SAVE_SUCCESS'));
// Redirect the user and adjust session state based on the chosen task.
switch ($task)
{
case 'apply':
// Reset the record data in the session.
$app->setUserState($context.'.data', null);
// Redirect back to the edit screen.
$this->setRedirect(Route::_('index.php?option=com_jem&view=source&layout=edit', false));
break;
default:
// Clear the record id and data from the session.
$app->setUserState($context.'.id', null);
$app->setUserState($context.'.data', null);
// Redirect to the list screen.
$this->setRedirect(Route::_('index.php?option=com_jem&view=cssmanager', false));
break;
}
}
}

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\Controller\BaseController;
/**
* JEM Component Updatecheck Controller
*
* @package JEM
*
*/
class JemControllerUpdatecheck extends BaseController
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
}
?>

View File

@ -0,0 +1,65 @@
<?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\Plugin\PluginHelper;
require_once (JPATH_COMPONENT_SITE.'/classes/controller.form.class.php');
/**
* Controller: Venue
*/
class JemControllerVenue extends JemControllerForm
{
/**
* @var string The prefix to use with controller messages.
*/
protected $text_prefix = 'COM_JEM_VENUE';
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
*/
public function __construct($config = array())
{
parent::__construct($config);
}
/**
* Function that allows child controller access to model data
* after the data has been saved.
* Here used to trigger the jem plugins, mainly the mailer.
*
* @param JModel(Legacy) $model The data model object.
* @param array $validData The validated data.
*
* @return void
*/
protected function _postSaveHook($model, $validData = array())
{
$isNew = $model->getState('venue.new');
$id = $model->getState('venue.id');
// trigger all jem plugins
PluginHelper::importPlugin('jem');
$dispatcher = JemFactory::getDispatcher();
$dispatcher->triggerEvent('onVenueEdited', array($id, $isNew));
// but show warning if mailer is disabled
if (!PluginHelper::isEnabled('jem', 'mailer')) {
Factory::getApplication()->enqueueMessage(Text::_('COM_JEM_GLOBAL_MAILERPLUGIN_DISABLED'), 'notice');
}
}
}

View File

@ -0,0 +1,88 @@
<?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\Controller\AdminController;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
/**
* Controller: Venues
*/
class JemControllerVenues extends AdminController
{
/**
* @var string The prefix to use with controller messages.
*/
protected $text_prefix = 'COM_JEM_VENUES';
/**
* Proxy for getModel.
*/
public function getModel($name = 'Venue', $prefix = 'JemModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
/**
* logic for remove venues
*
* @access public
*/
public function remove()
{
// Check for token
Session::checkToken() or jexit(Text::_('COM_JEM_GLOBAL_INVALID_TOKEN'));
$app = Factory::getApplication();
$user = Factory::getApplication()->getIdentity();
$jinput = $app->input;
$cid = $jinput->get('cid',array(),'array');
if (!is_array( $cid ) || count( $cid ) < 1) {
throw new Exception(Text::_('COM_JEM_SELECT_AN_ITEM_TO_DELETE'), 500);
} else {
$model = $this->getModel('venue');
ArrayHelper::toInteger($cid);
// trigger delete function in the model
$result = $model->delete($cid);
if($result['removed'])
{
$app->enqueueMessage(Text::plural($this->text_prefix.'_N_ITEMS_DELETED',$result['removedCount']));
}
if($result['error'])
{
$app->enqueueMessage(Text::_('COM_JEM_VENUES_UNABLETODELETE'),'warning');
foreach ($result['error'] AS $error)
{
$html = array();
$html[] = '<span class="label label-info">'.$error[0].'</span>';
$html[] = '<br>';
unset($error[0]);
$html[] = implode('<br>', $error);
$app->enqueueMessage(implode("\n",$html),'warning');
}
}
$this->postDeleteHook($model,$cid);
}
$cache = Factory::getCache('com_jem');
$cache->clean();
$this->setRedirect( 'index.php?option=com_jem&view=venues');
}
}