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 | Utility |
||
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 | */ |
||
38 | function b_wgevents_event_show($options) |
||
39 | { |
||
40 | $helper = Helper::getInstance(); |
||
41 | $eventHandler = $helper->getHandler('Event'); |
||
42 | $permissionsHandler = $helper->getHandler('Permission'); |
||
43 | $registrationHandler = $helper->getHandler('Registration'); |
||
44 | |||
45 | $GLOBALS['xoopsTpl']->assign('user_maxchar', $helper->getConfig('user_maxchar')); |
||
46 | $eventRegprocessbar = (string)$helper->getConfig('event_regprocessbar'); |
||
47 | $GLOBALS['xoopsTpl']->assign('event_regprocessbar', $eventRegprocessbar); |
||
48 | $uidCurrent = 0; |
||
49 | if (\is_object($GLOBALS['xoopsUser'])) { |
||
50 | $uidCurrent = $GLOBALS['xoopsUser']->uid(); |
||
51 | } |
||
52 | |||
53 | $block = []; |
||
54 | $typeBlock = $options[0]; |
||
55 | $limit = (int)$options[1]; |
||
56 | $lengthTitle = (int)$options[2]; |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
57 | $blockType = '0' === (string)$options[3] ? 'simple' : (string)$options[3] ; |
||
58 | \array_shift($options); |
||
59 | \array_shift($options); |
||
60 | \array_shift($options); |
||
61 | \array_shift($options); |
||
62 | |||
63 | $GLOBALS['xoTheme']->addStylesheet(\WGEVENTS_URL . '/assets/css/style.css', null); |
||
64 | |||
65 | $dateCreated = 0; |
||
66 | switch ($typeBlock) { |
||
67 | case 'last': |
||
68 | default: |
||
69 | // For the block: events last |
||
70 | $dateFrom = 0; |
||
71 | $sortBy = 'datecreated'; |
||
72 | $orderBy = 'DESC'; |
||
73 | break; |
||
74 | case 'new': |
||
75 | // For the block: events new |
||
76 | // new since last week: 7 * 24 * 60 * 60 = 604800 |
||
77 | $dateCreated = \time() - 604800; |
||
78 | $dateFrom = 0; |
||
79 | $sortBy = 'datecreated'; |
||
80 | $orderBy = 'ASC'; |
||
81 | break; |
||
82 | case 'random': |
||
83 | // For the block: events random |
||
84 | $dateFrom = 0; |
||
85 | $sortBy = 'RAND()'; |
||
86 | $orderBy = ''; |
||
87 | break; |
||
88 | case 'coming': |
||
89 | // For the block: next events |
||
90 | $dateFrom = \time(); |
||
91 | $sortBy = 'datefrom'; |
||
92 | $orderBy = 'ASC'; |
||
93 | break; |
||
94 | } |
||
95 | |||
96 | $eventsArr = $eventHandler->getEvents(0, $limit, $dateFrom, 0, $sortBy, $orderBy, '', 0, '', [], $dateCreated); |
||
97 | $eventsCount = $eventsArr['count']; |
||
98 | |||
99 | if ($eventsCount > 0) { |
||
100 | $eventsAll = $eventsArr['eventsAll']; |
||
101 | foreach (\array_keys($eventsAll) as $i) { |
||
102 | $block[$i] = $eventsAll[$i]->getValuesEvents(); |
||
103 | //get progress of registrations |
||
104 | //currently only for wgevents_block_events_panel |
||
105 | if ('panel' === $blockType) { |
||
106 | $crRegistration = new \CriteriaCompo(); |
||
107 | $crRegistration->add(new \Criteria('evid', $i)); |
||
108 | $numberRegCurr = $registrationHandler->getCount($crRegistration); |
||
109 | $block[$i]['nb_registrations'] = $numberRegCurr; |
||
110 | $registerMax = (int)$block[$i]['register_max']; |
||
111 | if ($registerMax > 0) { |
||
112 | $block[$i]['regmax'] = $registerMax; |
||
113 | $proportion = $numberRegCurr / $registerMax; |
||
114 | if ($proportion >= 1) { |
||
115 | $block[$i]['regcurrent'] = \_MA_WGEVENTS_REGISTRATIONS_FULL; |
||
116 | } else { |
||
117 | $block[$i]['regcurrent'] = \sprintf(\_MA_WGEVENTS_REGISTRATIONS_NBCURR_INDEX, $numberRegCurr, $registerMax); |
||
118 | } |
||
119 | $block[$i]['regcurrent_text'] = $block[$i]['regcurrent']; |
||
120 | $block[$i]['regcurrent_tip'] = true; |
||
121 | if ($proportion < 0.75) { |
||
122 | $block[$i]['regcurrentstate'] = 'success'; |
||
123 | } elseif ($proportion < 1) { |
||
124 | $block[$i]['regcurrentstate'] = 'warning'; |
||
125 | } else { |
||
126 | $block[$i]['regcurrentstate'] = 'danger'; |
||
127 | $block[$i]['regcurrent_tip'] = false; |
||
128 | } |
||
129 | $block[$i]['regpercentage'] = (int)($proportion * 100); |
||
130 | } |
||
131 | } |
||
132 | $block[$i]['datefromto_text'] = $eventHandler->getDateFromToText($eventsAll[$i]->getVar('datefrom'), $eventsAll[$i]->getVar('dateto'), $eventsAll[$i]->getVar('allday')); |
||
133 | $block[$i]['permEdit'] = ($permissionsHandler->getPermEventsEdit($eventsAll[$i]->getVar('submitter'), $eventsAll[$i]->getVar('status')) || $uidCurrent == $eventsAll[$i]->getVar('submitter')); |
||
134 | } |
||
135 | } |
||
136 | $GLOBALS['xoopsTpl']->assign('wgevents_permAdd', ($uidCurrent > 0 && $permissionsHandler->getPermEventsSubmit())); |
||
137 | $GLOBALS['xoopsTpl']->assign('permRegister', $permissionsHandler->getPermRegistrationsSubmit()); |
||
138 | $GLOBALS['xoopsTpl']->assign('wgevents_blocktype', $blockType); |
||
139 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_catlogos_url', \WGEVENTS_UPLOAD_CATLOGOS_URL); |
||
140 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_eventlogos_url', \WGEVENTS_UPLOAD_EVENTLOGOS_URL); |
||
141 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
||
142 | |||
143 | return $block; |
||
144 | |||
145 | } |
||
146 | |||
147 | /** |
||
148 | * Function edit block |
||
149 | * @param $options |
||
150 | * @return string |
||
151 | */ |
||
152 | function b_wgevents_event_edit($options) |
||
153 | { |
||
154 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||
155 | $form = \_MB_WGEVENTS_DISPLAY . ' : '; |
||
156 | $form .= "<input type='hidden' name='options[0]' value='".$options[0]."' >"; |
||
157 | $form .= "<input type='text' name='options[1]' size='5' maxlength='255' value='" . $options[1] . "' > <br>"; |
||
158 | $form .= \_MB_WGEVENTS_TITLE_LENGTH . " : <input type='text' name='options[2]' size='5' maxlength='255' value='" . $options[2] . "' ><br>"; |
||
159 | $form .= \_MB_WGEVENTS_BLOCKTYPE . ": <select name='options[3]' size='4'>"; |
||
160 | $form .= "<option value='table' " . ('table' === (string)$options[3] ? "selected='selected'" : '') . '>' . \_MB_WGEVENTS_BLOCKTYPE_TABLE . '</option>'; |
||
161 | $form .= "<option value='simple' " . ('simple' === (string)$options[3] ? "selected='selected'" : '') . '>' . \_MB_WGEVENTS_BLOCKTYPE_SIMPLE . '</option>'; |
||
162 | $form .= "<option value='extended' " . ('extended' === (string)$options[3] ? "selected='selected'" : '') . '>' . \_MB_WGEVENTS_BLOCKTYPE_EXTENDED . '</option>'; |
||
163 | $form .= "<option value='panel' " . ('panel' === (string)$options[3] ? "selected='selected'" : '') . '>' . \_MB_WGEVENTS_BLOCKTYPE_PANEL . '</option>'; |
||
164 | $form .= "<option value='bcard2' " . ('bcard2' === (string)$options[3] ? "selected='selected'" : '') . '>' . \_MB_WGEVENTS_BLOCKTYPE_BCARD2 . '</option>'; |
||
165 | $form .= '</select><br>'; |
||
166 | |||
167 | /* |
||
168 | \array_shift($options); |
||
169 | \array_shift($options); |
||
170 | \array_shift($options); |
||
171 | \array_shift($options); |
||
172 | |||
173 | $crEvent = new \CriteriaCompo(); |
||
174 | $crEvent->add(new \Criteria('id', 0, '!=')); |
||
175 | $crEvent->setSort('id'); |
||
176 | $crEvent->setOrder('ASC'); |
||
177 | */ |
||
178 | /** |
||
179 | * If you want to filter your results by e.g. a category used in yourevents |
||
180 | * then you can activate the following code, but you have to change it according your category |
||
181 | */ |
||
182 | /* |
||
183 | $helper = Helper::getInstance(); |
||
184 | $eventHandler = $helper->getHandler('Event'); |
||
185 | $eventsAll = $eventHandler->getAll($crEvent); |
||
186 | unset($crEvent); |
||
187 | $form .= \_MB_WGEVENTS_EVENTS_TO_DISPLAY . "<br><select name='options[]' multiple='multiple' size='5'>"; |
||
188 | $form .= "<option value='0' " . (!\in_array(0, $options) && !\in_array('0', $options) ? '' : "selected='selected'") . '>' . \_MB_WGEVENTS_ALL_EVENTS . '</option>'; |
||
189 | foreach (\array_keys($eventsAll) as $i) { |
||
190 | $id = $eventsAll[$i]->getVar('id'); |
||
191 | $form .= "<option value='" . $id . "' " . (!\in_array($id, $options) ? '' : "selected='selected'") . '>' . $eventsAll[$i]->getVar('name') . '</option>'; |
||
192 | } |
||
193 | $form .= '</select>'; |
||
194 | |||
195 | */ |
||
196 | return $form; |
||
197 | |||
198 | } |
||
199 |