| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package VikBooking |
| 4 | 4 | * @subpackage com_vikbooking |
| 5 | - * @author Alessio Gaggii - e4j - Extensionsforjoomla.com | |
| 6 | - * @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved. | |
| 5 | + * @author Alessio Gaggii - E4J srl | |
| 6 | + * @copyright Copyright (C) 2025 E4J srl. All rights reserved. | |
| 7 | 7 | * @license GNU General Public License version 2 or later; see LICENSE |
| 8 | 8 | * @link https://vikwp.com |
| 9 | 9 | */ |
| 10 | 10 | |
| @@ -19,8 +19,12 @@ | ||
| 19 | 19 | { |
| 20 | 20 | // Set the toolbar |
| 21 | 21 | $this->addToolBar(); |
| 22 | 22 | |
| 23 | + if (!JFactory::getUser()->authorise('core.vbo.availability', 'com_vikbooking')) { | |
| 24 | + VBOHttpDocument::getInstance()->close(403, JText::translate('JERROR_ALERTNOAUTHOR')); | |
| 25 | + } | |
| 26 | + | |
| 23 | 27 | $dbo = JFactory::getDbo(); |
| 24 | 28 | $app = JFactory::getApplication(); |
| 25 | 29 | |
| 26 | 30 | if (file_exists(VCM_ADMIN_PATH.DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.'vcm-channels.css')) { |
| @@ -28,19 +32,38 @@ | ||
| 28 | 32 | $document->addStyleSheet(VCM_ADMIN_URI.'assets/css/vcm-channels.css'); |
| 29 | 33 | } |
| 30 | 34 | $session = JFactory::getSession(); |
| 31 | 35 | $cookie = JFactory::getApplication()->input->cookie; |
| 32 | - $pmonth = VikRequest::getString('month', '', 'request'); | |
| 33 | - $pmnum = VikRequest::getInt('mnum', '', 'request'); | |
| 36 | + $pmonth = VikRequest::getInt('month', 0, 'request'); | |
| 37 | + $pmnum = VikRequest::getInt('mnum', 0, 'request'); | |
| 34 | 38 | $cmnum = $cookie->get('vbOvwMnum', '', 'string'); |
| 35 | 39 | $punits_show_type = VikRequest::getString('units_show_type', '', 'request'); |
| 40 | + | |
| 36 | 41 | // category filter |
| 37 | 42 | $pcategory_id = VikRequest::getString('category_id', '', 'request'); |
| 38 | 43 | $scategory_id = $session->get('vbOvwCatid', 0); |
| 39 | 44 | $pcategory_id = !strlen($pcategory_id) && !empty($scategory_id) ? $scategory_id : $pcategory_id; |
| 40 | 45 | $session->set('vbOvwCatid', $pcategory_id); |
| 41 | - // | |
| 42 | - | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Apply task manager filters. | |
| 49 | + * | |
| 50 | + * @since 1.18.0 (J) - 1.8.0 (WP) | |
| 51 | + */ | |
| 52 | + $tmfilters = (array) $app->input->get('tmfilters', [], 'array'); | |
| 53 | + if (empty($pmonth)) { | |
| 54 | + // overwrite the first month to display | |
| 55 | + if (($tmfilters['dates'] ?? '') && preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}\s?:\s?[0-9]{4}-[0-9]{2}-[0-9]{2}$/', (string) $tmfilters['dates'])) { | |
| 56 | + // custom range of dates filter will overwrite the current month to display | |
| 57 | + $dparts = explode(':', $tmfilters['dates']); | |
| 58 | + $begin_ts = strtotime(trim($dparts[0])); | |
| 59 | + $pmonth = strtotime(date('Y-m-01', $begin_ts)); | |
| 60 | + } elseif (($tmfilters['calendar_month'] ?? '') && preg_match('/01$/', (string) $tmfilters['calendar_month'])) { | |
| 61 | + // overwrite the current month to display | |
| 62 | + $pmonth = strtotime($tmfilters['calendar_month']) ?: $pmonth; | |
| 63 | + } | |
| 64 | + } | |
| 65 | + | |
| 43 | 66 | $pbmode = VikRequest::getString('bmode', '', 'request'); |
| 44 | 67 | if (!empty($pbmode) && ($pbmode == 'classic' || $pbmode == 'tags')) { |
| 45 | 68 | VikRequest::setCookie('vbTagsMode', $pbmode, (time() + (86400 * 365)), '/'); |
| 46 | 69 | $session->set('vbTagsMode', $pbmode); |
| @@ -48,9 +71,9 @@ | ||
| 48 | 71 | $cbmode = $cookie->get('vbTagsMode', '', 'string'); |
| 49 | 72 | $pbmode = (!empty($cbmode) && ($cbmode == 'classic' || $cbmode == 'tags') ? $cbmode : 'classic'); |
| 50 | 73 | VikRequest::setCookie('vbTagsMode', $pbmode, (time() + (86400 * 365)), '/'); |
| 51 | 74 | $session->set('vbTagsMode', $pbmode); |
| 52 | - } | |
| 75 | + } | |
| 53 | 76 | |
| 54 | 77 | if (!empty($punits_show_type)) { |
| 55 | 78 | $session->set('vbUnitsShowType', $punits_show_type); |
| 56 | 79 | } |
| @@ -157,8 +180,12 @@ | ||
| 157 | 180 | $q = "SELECT SQL_CALC_FOUND_ROWS `r`.* FROM `#__vikbooking_rooms` AS `r`" . (!empty($catfilter) ? " WHERE " . $catfilter : '') . " ORDER BY `r`.`name` ASC"; |
| 158 | 181 | $dbo->setQuery($q, $lim0, $lim); |
| 159 | 182 | $rows = $dbo->loadAssocList(); |
| 160 | 183 | if (!$rows) { |
| 184 | + if ($session->get('vbOvwCatid', '')) { | |
| 185 | + // unset empty category with no rooms | |
| 186 | + $session->set('vbOvwCatid', 0); | |
| 187 | + } | |
| 161 | 188 | VikError::raiseWarning('', JText::translate('VBOVERVIEWNOROOMS')); |
| 162 | 189 | $app->redirect("index.php?option=com_vikbooking"); |
| 163 | 190 | $app->close(); |
| 164 | 191 | } |