__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
<?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\Site\Model;

defined('_JEXEC') or die();

use DigitalPeak\Component\DPCalendar\Administrator\Calendar\CalendarInterface;
use DigitalPeak\Component\DPCalendar\Administrator\Helper\DPCalendarHelper;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormFactoryAwareInterface;
use Joomla\CMS\Form\FormFactoryAwareTrait;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Registry\Registry;

class CalendarModel extends ListModel implements FormFactoryAwareInterface
{
	use FormFactoryAwareTrait;

	private ?array $items    = null;
	private ?array $allItems = null;

	protected function populateState($ordering = null, $direction = null)
	{
		$app = Factory::getApplication();

		$this->setState('filter.extension', 'com_dpcalendar');

		if (!$app->getInput()->getString('ids', '')) {
			$this->setState('filter.parentIds', $this->state->get('parameters.menu', new Registry())->get('ids'));
			$this->setState('filter.categories', []);
		} else {
			$this->setState('filter.categories', explode(',', (string)$app->getInput()->getString('ids')));
			$this->setState('filter.parentIds', $this->setState('filter.categories'));
		}

		$this->setState('params', $app instanceof SiteApplication ? $app->getParams() : ComponentHelper::getParams('com_dpcalendar'));

		$this->setState('filter.published', 1);
		$this->setState('filter.access', true);
	}

	protected function getStoreId($id = '')
	{
		// Compile the store id
		$id .= ':' . $this->getState('filter.extension');
		$id .= ':' . $this->getState('filter.published');
		$id .= ':' . $this->getState('filter.access');

		return parent::getStoreId($id);
	}

	public function getItems(): array
	{
		if ($this->items === null) {
			$this->items    = [];
			$this->allItems = [];

			foreach ((array)$this->getState('filter.parentIds', ['root']) as $calendar) {
				if ($calendar == '-1') {
					$calendar = 'root';
				}

				$parent = $this->bootComponent('dpcalendar')->getMVCFactory()->createModel('Calendar', 'Administrator')->getCalendar($calendar);
				if ($parent == null) {
					continue;
				}

				if ($parent->getId() !== 'root') {
					$this->items[$parent->getId()]    = $parent;
					$this->allItems[$parent->getId()] = $parent;
				}

				$tmp     = $parent->getChildren(true);
				$filters = $this->getState('filter.categories');
				foreach ($tmp as $child) {
					$item = $this->bootComponent('dpcalendar')->getMVCFactory()->createModel('Calendar', 'Administrator')->getCalendar($child->getId());
					if (!$item instanceof CalendarInterface) {
						continue;
					}

					$this->allItems[$item->getId()] = $item;

					if (!empty($filters) && !in_array($item->getId(), $filters)) {
						continue;
					}
					$this->items[$item->getId()] = $item;
				}
			}

			// Add external calendars or only the private ones when not all is set
			PluginHelper::importPlugin('dpcalendar');
			$tmp = Factory::getApplication()->triggerEvent(
				'onCalendarsFetch',
				[null, in_array('-1', (array)$this->getState('filter.parentIds', ['root'])) ? null : 'cd']
			);
			if (!empty($tmp)) {
				foreach ($tmp as $tmpCalendars) {
					foreach ($tmpCalendars as $calendar) {
						$this->items[$calendar->getId()]    = $calendar;
						$this->allItems[$calendar->getId()] = $calendar;
					}
				}
			}
		}

		return $this->items;
	}

	public function getAllItems(): array
	{
		if ($this->allItems === null) {
			$this->getItems();
		}

		return $this->allItems !== null && $this->allItems !== [] ? $this->allItems : [];
	}

	public function getQuickAddForm(Registry $params): Form
	{
		$format = $params->get('event_form_date_format', 'd.m.Y') . ' ' . $params->get('event_form_time_format', 'H:i');
		$date   = DPCalendarHelper::getDate();

		$form = $this->getFormFactory()->createForm('com_dpcalendar.event.quickadd', ['control' => 'jform']);
		$form->loadFile(JPATH_ADMINISTRATOR . '/components/com_dpcalendar/forms/event.xml');
		$form->setValue('start_date', null, $date->format($format, false));

		$date->modify('+1 hour');
		$form->setValue('end_date', null, $date->format($format, false));

		$form->setFieldAttribute('start_date', 'format', $params->get('event_form_date_format', 'd.m.Y'));
		$form->setFieldAttribute('start_date', 'formatTime', $params->get('event_form_time_format', 'H:i'));
		$form->setFieldAttribute('start_date', 'formatted', true);
		$form->setFieldAttribute('end_date', 'format', $params->get('event_form_date_format', 'd.m.Y'));
		$form->setFieldAttribute('end_date', 'formatTime', $params->get('event_form_time_format', 'H:i'));
		$form->setFieldAttribute('end_date', 'formatted', true);

		$form->setFieldAttribute('start_date', 'min_time', $params->get('event_form_min_time'));
		$form->setFieldAttribute('start_date', 'max_time', $params->get('event_form_max_time'));
		$form->setFieldAttribute('end_date', 'min_time', $params->get('event_form_min_time'));
		$form->setFieldAttribute('end_date', 'max_time', $params->get('event_form_max_time'));

		// Enable to load only calendars with create permission
		$form->setFieldAttribute('catid', 'action', 'true');
		$form->setFieldAttribute('catid', 'calendar_filter', implode(',', $params->get('event_form_calendars', [])));

		// Color
		$form->setValue('color', null, $params->get('event_form_color'));
		$form->setFieldAttribute('color', 'type', 'hidden');

		return $form;
	}
}

Filemanager

Name Type Size Permission Actions
CalendarModel.php File 5.55 KB 0664
EventModel.php File 13.23 KB 0664
EventsModel.php File 26.1 KB 0664
FormModel.php File 7.93 KB 0664
Filemanager