| Server IP : 104.21.84.107 / Your IP : 104.23.197.209 Web Server : Apache/2.4.63 (Ubuntu) System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.4.5 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/fcs/administrator/components/com_dpcalendar/src/Controller/ |
Upload File : |
<?php
/**
* @package DPCalendar
* @copyright Copyright (C) 2014 Digital Peak GmbH. <https://www.digital-peak.com>
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
*/
namespace DigitalPeak\Component\DPCalendar\Administrator\Controller;
\defined('_JEXEC') or die();
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Session\Session;
use Joomla\CMS\User\CurrentUserInterface;
use Joomla\CMS\User\CurrentUserTrait;
use Joomla\Input\Input;
use Joomla\Utilities\ArrayHelper;
class EventsController extends AdminController implements CurrentUserInterface
{
use CurrentUserTrait;
public function __construct($config = [], ?MVCFactoryInterface $factory = null, ?CMSApplication $app = null, ?Input $input = null)
{
parent::__construct($config, $factory, $app, $input);
$this->registerTask('unfeatured', 'featured');
}
public function getModel($name = 'Event', $prefix = 'Administrator', $config = ['ignore_request' => true])
{
return parent::getModel($name, $prefix, $config);
}
public function featured(): void
{
// Check for request forgeries
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
$user = $this->getCurrentUser();
$ids = $this->input->get('cid', [], 'array');
$values = [
'featured' => 1,
'unfeatured' => 0
];
$task = $this->getTask();
$value = ArrayHelper::getValue($values, $task, 0, 'int');
$ids = ArrayHelper::toInteger($ids);
$model = $this->getModel('Events');
$model->setState('filter.ids', $ids);
// Access checks.
foreach ($model->getItems() as $i => $event) {
if (!$user->authorise('core.edit.state', 'com_dpcalendar.category.' . (int)$event->catid)) {
// Prune items that you can't change.
unset($ids[$i]);
$this->app->enqueueMessage(Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'warning');
}
}
if (empty($ids)) {
$this->app->enqueueMessage(Text::_('JERROR_NO_ITEMS_SELECTED'), 'warning');
} else {
// Get the model.
$model = $this->getModel('Event');
// Publish the items.
if (!$model->featured($ids, $value)) {
$this->app->enqueueMessage($model->getError(), 'warning');
}
}
$this->setRedirect('index.php?option=com_dpcalendar&view=events');
}
}