ggoffy /
wgevents
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php declare(strict_types=1); |
||
| 2 | |||
| 3 | /* |
||
| 4 | You may not change or alter any portion of this comment or credits |
||
| 5 | of supporting developers from this source code or any supporting source code |
||
| 6 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 7 | |||
| 8 | This program is distributed in the hope that it will be useful, |
||
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 11 | */ |
||
| 12 | |||
| 13 | /** |
||
| 14 | * wgEvents module for xoops |
||
| 15 | * |
||
| 16 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||
| 17 | * @license GPL 2.0 or later |
||
| 18 | * @package wgevents |
||
| 19 | * @since 1.0.0 |
||
| 20 | * @min_xoops 2.5.11 Beta1 |
||
| 21 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||
| 22 | */ |
||
| 23 | |||
| 24 | use XoopsModules\Wgevents; |
||
| 25 | use XoopsModules\Wgevents\{ |
||
| 26 | Helper, |
||
| 27 | Constants, |
||
| 28 | SimpleCalendar |
||
| 29 | }; |
||
| 30 | |||
| 31 | require_once \XOOPS_ROOT_PATH . '/modules/wgevents/include/common.php'; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Function show block |
||
| 35 | * @param $options |
||
| 36 | * @return array |
||
| 37 | * @throws Exception |
||
| 38 | * @throws Exception |
||
| 39 | */ |
||
| 40 | function b_wgevents_calendar_show($options) |
||
| 41 | { |
||
| 42 | $block = []; |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 43 | $typeBlock = $options[0]; |
||
|
0 ignored issues
–
show
|
|||
| 44 | $limit = $options[1]; |
||
| 45 | \array_shift($options); |
||
| 46 | \array_shift($options); |
||
| 47 | |||
| 48 | $helper = Helper::getInstance(); |
||
| 49 | $eventHandler = $helper->getHandler('Event'); |
||
| 50 | $categoryHandler = $helper->getHandler('Category'); |
||
| 51 | |||
| 52 | \xoops_loadLanguage('main', 'wgevents'); |
||
| 53 | |||
| 54 | //default params |
||
| 55 | $year = (int)\date('Y'); |
||
| 56 | $month = (int)\date('n'); |
||
| 57 | $lastday = (int)\date('t', \strtotime($month . '/1/' . $year)); |
||
| 58 | $dayStart = \mktime(0, 0, 0, $month, 1, $year); |
||
| 59 | $dayEnd = \mktime(23, 59, 59, $month, $lastday, $year); |
||
| 60 | |||
| 61 | $filterFrom = $dayStart; |
||
| 62 | $filterTo = $dayEnd; |
||
| 63 | $filterSort = 'datefrom-ASC'; |
||
| 64 | [$sortBy, $orderBy] = \explode('-', $filterSort); |
||
| 65 | |||
| 66 | /*calendar nav bar*/ |
||
| 67 | $arrMonth = [ |
||
| 68 | 1 => \_MA_WGEVENTS_CAL_JANUARY, |
||
| 69 | 2 => \_MA_WGEVENTS_CAL_FEBRUARY, |
||
| 70 | 3 => \_MA_WGEVENTS_CAL_MARCH, |
||
| 71 | 4 => \_MA_WGEVENTS_CAL_APRIL, |
||
| 72 | 5 => \_MA_WGEVENTS_CAL_MAY, |
||
| 73 | 6 => \_MA_WGEVENTS_CAL_JUNE, |
||
| 74 | 7 => \_MA_WGEVENTS_CAL_JULY, |
||
| 75 | 8 => \_MA_WGEVENTS_CAL_AUGUST, |
||
| 76 | 9 => \_MA_WGEVENTS_CAL_SEPTEMBER, |
||
| 77 | 10 => \_MA_WGEVENTS_CAL_OCTOBER, |
||
| 78 | 11 => \_MA_WGEVENTS_CAL_NOVEMBER, |
||
| 79 | 12 => \_MA_WGEVENTS_CAL_DECEMBER |
||
| 80 | ]; |
||
| 81 | $GLOBALS['xoopsTpl']->assign('monthNav', $arrMonth[\date('n', $filterFrom)]); |
||
| 82 | $GLOBALS['xoopsTpl']->assign('yearNav', \date('Y', $filterFrom)); |
||
| 83 | |||
| 84 | $GLOBALS['xoTheme']->addStylesheet(\WGEVENTS_URL . '/class/SimpleCalendar/css/SimpleCalendarMini.css', null); |
||
| 85 | $calendar = new SimpleCalendar\SimpleCalendarMini(); |
||
| 86 | $calendar->setStartOfWeek($helper->getConfig('cal_firstday')); |
||
| 87 | $calendar->setWeekDayNames([ |
||
| 88 | \_MA_WGEVENTS_CAL_MIN_SUNDAY, |
||
| 89 | \_MA_WGEVENTS_CAL_MIN_MONDAY, |
||
| 90 | \_MA_WGEVENTS_CAL_MIN_TUESDAY, |
||
| 91 | \_MA_WGEVENTS_CAL_MIN_WEDNESDAY, |
||
| 92 | \_MA_WGEVENTS_CAL_MIN_THURSDAY, |
||
| 93 | \_MA_WGEVENTS_CAL_MIN_FRIDAY, |
||
| 94 | \_MA_WGEVENTS_CAL_MIN_SATURDAY ]); |
||
| 95 | |||
| 96 | // get categories collection |
||
| 97 | $categories = $categoryHandler->getCollection(); |
||
| 98 | // get events of period |
||
| 99 | $eventsArr = $eventHandler->getEvents(0, 0, $filterFrom, $filterTo, $sortBy, $orderBy); |
||
| 100 | |||
| 101 | $eventsCount = $eventsArr['count']; |
||
| 102 | if ($eventsCount > 0) { |
||
| 103 | $calendar->setDate($filterFrom); |
||
| 104 | $GLOBALS['xoopsTpl']->assign('eventsCount', $eventsCount); |
||
| 105 | foreach($eventsArr['eventsAll'] as $event) { |
||
| 106 | $badgeStyle = 'border:1px solid ' . $categories[$event->getVar('catid')]['bordercolor'] . '!important;'; |
||
| 107 | $badgeStyle .= 'background-color:' . $categories[$event->getVar('catid')]['bgcolor'] . '!important;'; |
||
| 108 | $badgeStyle .= 'border-radius:50% !important;'; |
||
| 109 | $eventLink = '<a href="' . \WGEVENTS_URL . '/event.php?op=show&id=' . $event->getVar('id') .'" title="' . $event->getVar('name') .'">'; |
||
| 110 | $eventLink .= '<span class="badge" style="' . $badgeStyle . '"> </span></a>'; |
||
| 111 | $calendar->addDailyHtml($eventLink, $event->getVar('datefrom'), $event->getVar('dateto')); |
||
| 112 | } |
||
| 113 | } |
||
| 114 | $GLOBALS['xoopsTpl']->assign('events_calendar', $calendar->render()); |
||
| 115 | $GLOBALS['xoopsTpl']->assign('events_calendar_header', ''); |
||
| 116 | |||
| 117 | if($limit > 0 && $eventsCount > 0) { |
||
| 118 | $counter = 0; |
||
| 119 | $eventsList = []; |
||
| 120 | // Get All Event |
||
| 121 | foreach($eventsArr['eventsAll'] as $event) { |
||
| 122 | if ($counter < $limit) { |
||
| 123 | $eventsList[$counter] = $event->getValuesEvents(); |
||
| 124 | } |
||
| 125 | $counter++; |
||
| 126 | } |
||
| 127 | $GLOBALS['xoopsTpl']->assign('events_list', $eventsList); |
||
| 128 | unset($eventsList); |
||
| 129 | } |
||
| 130 | |||
| 131 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_catlogos_url', \WGEVENTS_UPLOAD_CATLOGOS_URL); |
||
| 132 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_eventlogos_url', \WGEVENTS_UPLOAD_EVENTLOGOS_URL); |
||
| 133 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL . '/'); |
||
| 134 | |||
| 135 | //create dummy return in order to show block |
||
| 136 | return ['dummy']; |
||
| 137 | } |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Function edit block |
||
| 141 | * @param $options |
||
| 142 | * @return string |
||
| 143 | */ |
||
| 144 | function b_wgevents_calendar_edit($options) |
||
| 145 | { |
||
| 146 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||
| 147 | $form = "<input type='hidden' name='options[0]' value='".$options[0]."' >"; |
||
| 148 | $form .= \_MB_WGEVENTS_CAL_DISPLAY_DESC . '<br>'; |
||
| 149 | $form .= \_MB_WGEVENTS_CAL_DISPLAY . " : <input type='text' name='options[1]' size='5' maxlength='255' value='" . $options[1] . "' > <br>"; |
||
| 150 | \array_shift($options); |
||
| 151 | \array_shift($options); |
||
| 152 | |||
| 153 | $crEvent = new \CriteriaCompo(); |
||
| 154 | $crEvent->add(new \Criteria('id', 0, '!=')); |
||
| 155 | $crEvent->setSort('id'); |
||
| 156 | $crEvent->setOrder('ASC'); |
||
| 157 | |||
| 158 | /** |
||
| 159 | * If you want to filter your results by e.g. a category used in yourevents |
||
| 160 | * then you can activate the following code, but you have to change it according your category |
||
| 161 | */ |
||
| 162 | /* |
||
| 163 | $helper = Helper::getInstance(); |
||
| 164 | $eventHandler = $helper->getHandler('Event'); |
||
| 165 | $eventsAll = $eventHandler->getAll($crEvent); |
||
| 166 | unset($crEvent); |
||
| 167 | $form .= \_MB_WGEVENTS_EVENTS_TO_DISPLAY . "<br><select name='options[]' multiple='multiple' size='5'>"; |
||
| 168 | $form .= "<option value='0' " . (!\in_array(0, $options) && !\in_array('0', $options) ? '' : "selected='selected'") . '>' . \_MB_WGEVENTS_ALL_EVENTS . '</option>'; |
||
| 169 | foreach (\array_keys($eventsAll) as $i) { |
||
| 170 | $id = $eventsAll[$i]->getVar('id'); |
||
| 171 | $form .= "<option value='" . $id . "' " . (!\in_array($id, $options) ? '' : "selected='selected'") . '>' . $eventsAll[$i]->getVar('name') . '</option>'; |
||
| 172 | } |
||
| 173 | $form .= '</select>'; |
||
| 174 | */ |
||
| 175 | |||
| 176 | return $form; |
||
| 177 | |||
| 178 | } |
||
| 179 |