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 |
||||||||
2 | |||||||||
3 | namespace XoopsModules\Extcal; |
||||||||
4 | |||||||||
5 | /* |
||||||||
6 | * You may not change or alter any portion of this comment or credits |
||||||||
7 | * of supporting developers from this source code or any supporting source code |
||||||||
8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||||||
9 | * |
||||||||
10 | * This program is distributed in the hope that it will be useful, |
||||||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||||
13 | */ |
||||||||
14 | |||||||||
15 | /** |
||||||||
16 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||||||
17 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||||||||
18 | * @package extcal |
||||||||
19 | * @since |
||||||||
20 | * @author XOOPS Development Team, |
||||||||
21 | */ |
||||||||
22 | |||||||||
23 | //use Punic\Exception; |
||||||||
24 | use Xmf\Request; |
||||||||
25 | use XoopsModules\Extcal\{Helper, |
||||||||
0 ignored issues
–
show
|
|||||||||
26 | Event, |
||||||||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
XoopsModules\Extcal\Event . Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||||||||
27 | Perm, |
||||||||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
XoopsModules\Extcal\Perm . Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||||||||
28 | Time, |
||||||||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
XoopsModules\Extcal\Time . Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||||||||
29 | Form |
||||||||
30 | }; |
||||||||
31 | |||||||||
32 | require_once \dirname(__DIR__) . '/include/constantes.php'; |
||||||||
33 | |||||||||
34 | /** |
||||||||
35 | * Class EventHandler. |
||||||||
36 | */ |
||||||||
37 | class EventHandler extends ExtcalPersistableObjectHandler |
||||||||
38 | { |
||||||||
39 | private $extcalPerm; |
||||||||
40 | private $extcalTime; |
||||||||
41 | |||||||||
42 | /** |
||||||||
43 | * @param \XoopsDatabase|null $db |
||||||||
44 | */ |
||||||||
45 | public function __construct(\XoopsDatabase $db = null) |
||||||||
46 | { |
||||||||
47 | if (null === $db) { |
||||||||
48 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||||
49 | } |
||||||||
50 | $this->extcalPerm = Perm::getHandler(); |
||||||||
51 | $this->extcalTime = Time::getHandler(); |
||||||||
52 | parent::__construct($db, 'extcal_event', Event::class, 'event_id'); |
||||||||
53 | } |
||||||||
54 | |||||||||
55 | /** |
||||||||
56 | * @param $data |
||||||||
57 | * |
||||||||
58 | * @return bool |
||||||||
59 | */ |
||||||||
60 | public function createEvent($data) |
||||||||
61 | { |
||||||||
62 | $event = $this->create(); |
||||||||
63 | $this->checkDate($data); |
||||||||
64 | $this->userTimeToServerTime($data); |
||||||||
65 | $this->addRecurValue($data); |
||||||||
66 | $event->setVars($data); |
||||||||
67 | |||||||||
68 | return $this->insert($event, true); |
||||||||
69 | } |
||||||||
70 | |||||||||
71 | /** |
||||||||
72 | * @param $data |
||||||||
73 | * |
||||||||
74 | * @return \XoopsObject |
||||||||
75 | */ |
||||||||
76 | public function createEventForPreview($data) |
||||||||
77 | { |
||||||||
78 | $event = $this->create(); |
||||||||
79 | $this->checkDate($data); |
||||||||
80 | $this->addRecurValue($data); |
||||||||
81 | $event->setVars($data); |
||||||||
82 | |||||||||
83 | return $event; |
||||||||
84 | } |
||||||||
85 | |||||||||
86 | /** |
||||||||
87 | * @param $eventId |
||||||||
88 | * @param $data |
||||||||
89 | * |
||||||||
90 | * @return bool |
||||||||
91 | */ |
||||||||
92 | public function modifyEvent($eventId, $data) |
||||||||
93 | { |
||||||||
94 | $event = $this->get($eventId); |
||||||||
95 | $this->checkDate($data); |
||||||||
96 | $this->userTimeToServerTime($data); |
||||||||
97 | $this->addRecurValue($data); |
||||||||
98 | $event->setVars($data); |
||||||||
99 | |||||||||
100 | return $this->insert($event); |
||||||||
101 | } |
||||||||
102 | |||||||||
103 | /** |
||||||||
104 | * @param $eventId |
||||||||
105 | */ |
||||||||
106 | public function deleteEvent($eventId) |
||||||||
107 | { |
||||||||
108 | /* TODO : |
||||||||
109 | - Delete who's going |
||||||||
110 | - Delete who's not going |
||||||||
111 | - Delete comment |
||||||||
112 | - Delete notifications |
||||||||
113 | */ |
||||||||
114 | $this->deleteById($eventId, true); |
||||||||
115 | } |
||||||||
116 | |||||||||
117 | /** |
||||||||
118 | * @param null $criteria |
||||||||
0 ignored issues
–
show
|
|||||||||
119 | * @param bool $force |
||||||||
120 | * @param bool $asObject |
||||||||
121 | */ |
||||||||
122 | public function deleteAllEvents($criteria = null, $force = true, $asObject = false) |
||||||||
123 | { |
||||||||
124 | /* TODO : |
||||||||
125 | - Delete who's going |
||||||||
126 | - Delete who's not going |
||||||||
127 | - Delete comment |
||||||||
128 | - Delete notifications |
||||||||
129 | */ |
||||||||
130 | $this->deleteAll($criteria, $force, $asObject); |
||||||||
131 | } |
||||||||
132 | |||||||||
133 | /** |
||||||||
134 | * @param null $criteria |
||||||||
0 ignored issues
–
show
|
|||||||||
135 | * @param bool $asObject |
||||||||
136 | * |
||||||||
137 | * @return array |
||||||||
138 | */ |
||||||||
139 | public function getAllEvents($criteria = null, $asObject = false) |
||||||||
140 | { |
||||||||
141 | $rst = $this->getObjects($criteria, $asObject); |
||||||||
142 | if ($asObject) { |
||||||||
143 | return $rst; |
||||||||
144 | } |
||||||||
145 | |||||||||
146 | return $this->objectToArray($rst); |
||||||||
147 | } |
||||||||
148 | |||||||||
149 | // Return one approved event selected by his id |
||||||||
150 | |||||||||
151 | /** |
||||||||
152 | * @param $eventId |
||||||||
153 | * @param bool $skipPerm |
||||||||
154 | * |
||||||||
155 | * @return bool |
||||||||
156 | */ |
||||||||
157 | public function getEvent($eventId, $skipPerm = false) |
||||||||
158 | { |
||||||||
159 | $user = $GLOBALS['xoopsUser']; |
||||||||
160 | |||||||||
161 | $criteriaCompo = new \CriteriaCompo(); |
||||||||
162 | $criteriaCompo->add(new \Criteria('event_id', $eventId)); |
||||||||
163 | $criteriaCompo->add(new \Criteria('event_approved', 1)); |
||||||||
164 | if (!$skipPerm) { |
||||||||
165 | $this->addCatPermCriteria($criteriaCompo, $user); |
||||||||
166 | } |
||||||||
167 | $ret = $this->getObjects($criteriaCompo); |
||||||||
168 | return $ret[0] ?? false; |
||||||||
169 | } |
||||||||
170 | |||||||||
171 | // Return one event selected by his id (approve or not) |
||||||||
172 | |||||||||
173 | /** |
||||||||
174 | * @param $eventId |
||||||||
175 | * @param bool $skipPerm |
||||||||
176 | * |
||||||||
177 | * @return bool |
||||||||
178 | */ |
||||||||
179 | public function getEventWithNotApprove($eventId, $skipPerm = false) |
||||||||
180 | { |
||||||||
181 | $user = $GLOBALS['xoopsUser']; |
||||||||
182 | |||||||||
183 | $criteriaCompo = new \CriteriaCompo(); |
||||||||
184 | $criteriaCompo->add(new \Criteria('event_id', $eventId)); |
||||||||
185 | if (!$skipPerm) { |
||||||||
186 | $this->addCatPermCriteria($criteriaCompo, $user); |
||||||||
187 | } |
||||||||
188 | $ret = $this->getObjects($criteriaCompo); |
||||||||
189 | return $ret[0] ?? false; |
||||||||
190 | } |
||||||||
191 | |||||||||
192 | /** |
||||||||
193 | * @param $events |
||||||||
194 | * @param $pattern |
||||||||
195 | */ |
||||||||
196 | public function formatEventsDate(&$events, $pattern) |
||||||||
197 | { |
||||||||
198 | // $max = count($events); |
||||||||
199 | // for ($i = 0; $i < $max; ++$i) { |
||||||||
200 | // $this->formatEventDate($events[$i], $pattern); |
||||||||
201 | // } |
||||||||
202 | foreach ($events as $i => $iValue) { |
||||||||
203 | $this->formatEventDate($events[$i], $pattern); |
||||||||
204 | } |
||||||||
205 | } |
||||||||
206 | |||||||||
207 | // function getPicture1(&$event) { |
||||||||
208 | // return $event['event_picture1']; |
||||||||
209 | // } |
||||||||
210 | // function getPicture2(&$event) { |
||||||||
211 | // return $event['event_picture2']; |
||||||||
212 | // } |
||||||||
213 | // function getDesc(&$event) { |
||||||||
214 | // return $event['event_desc']; |
||||||||
215 | // } |
||||||||
216 | |||||||||
217 | /** |
||||||||
218 | * @param $event |
||||||||
219 | * @param $pattern |
||||||||
220 | */ |
||||||||
221 | public function formatEventDate(&$event, $pattern) |
||||||||
222 | { |
||||||||
223 | //TODO switch to using XOOPS function formatTimeStamp() |
||||||||
224 | if (!$event['event_isrecur']) { |
||||||||
225 | $event['formated_event_start'] = $this->extcalTime->getFormatedDate($pattern, $event['event_start']); |
||||||||
226 | $event['formated_event_end'] = $this->extcalTime->getFormatedDate($pattern, $event['event_end']); |
||||||||
227 | } else { |
||||||||
228 | $event['formated_event_start'] = $this->extcalTime->getFormatedDate($pattern, $event['event_start']); |
||||||||
229 | $event['formated_event_end'] = $this->extcalTime->getFormatedDate($pattern, $event['event_end']); |
||||||||
230 | $event['formated_reccur_rule'] = $this->extcalTime->getFormatedReccurRule($event['event_recur_rules']); |
||||||||
231 | } |
||||||||
232 | $event['formated_event_submitdate'] = $this->extcalTime->getFormatedDate($pattern, $event['event_submitdate']); |
||||||||
233 | } |
||||||||
234 | |||||||||
235 | //JJD - to valid modif |
||||||||
236 | // function checkDate(&$data) |
||||||||
237 | // { |
||||||||
238 | // |
||||||||
239 | // list($year, $month, $day) = explode("-", $data['event_start']['date']); |
||||||||
240 | // $data['event_start'] |
||||||||
241 | // = |
||||||||
242 | // mktime(0, 0, 0, $month, $day, $year) + $data['event_start']['time']; |
||||||||
243 | // list($year, $month, $day) = explode("-", $data['event_end']['date']); |
||||||||
244 | // $data['event_end'] |
||||||||
245 | // = mktime(0, 0, 0, $month, $day, $year) + $data['event_end']['time']; |
||||||||
246 | // |
||||||||
247 | // if ($data['have_end'] == 0 || $data['event_start'] > $data['event_end'] |
||||||||
248 | //) { |
||||||||
249 | // $data['event_end'] = $data['event_start']; |
||||||||
250 | // } |
||||||||
251 | // |
||||||||
252 | // } |
||||||||
253 | |||||||||
254 | /** |
||||||||
255 | * @param $data |
||||||||
256 | */ |
||||||||
257 | public function checkDate(&$data) |
||||||||
258 | { |
||||||||
259 | $data['event_start'] = \strtotime($data['event_start']['date']) + $data['event_start']['time']; |
||||||||
260 | $data['event_end'] = \strtotime($data['event_end']['date']) + $data['event_end']['time']; |
||||||||
261 | |||||||||
262 | if (0 == $data['have_end'] || $data['event_start'] > $data['event_end']) { |
||||||||
263 | $data['event_end'] = $data['event_start']; |
||||||||
264 | } |
||||||||
265 | } |
||||||||
266 | |||||||||
267 | /** |
||||||||
268 | * @param $data |
||||||||
269 | */ |
||||||||
270 | private function userTimeToServerTime(&$data) |
||||||||
271 | { |
||||||||
272 | $user = $GLOBALS['xoopsUser']; |
||||||||
273 | |||||||||
274 | $data['event_start'] = \userTimeToServerTime($data['event_start'], $this->extcalTime->getUserTimeZone($user)); |
||||||||
275 | $data['event_end'] = \userTimeToServerTime($data['event_end'], $this->extcalTime->getUserTimeZone($user)); |
||||||||
276 | } |
||||||||
277 | |||||||||
278 | /** |
||||||||
279 | * @param $data |
||||||||
280 | */ |
||||||||
281 | public function serverTimeToUserTime(&$data) |
||||||||
282 | { |
||||||||
283 | $user = $GLOBALS['xoopsUser']; |
||||||||
284 | |||||||||
285 | $data['event_start'] = \xoops_getUserTimestamp($data['event_start'], $this->extcalTime->getUserTimeZone($user)); |
||||||||
286 | $data['event_end'] = \xoops_getUserTimestamp($data['event_end'], $this->extcalTime->getUserTimeZone($user)); |
||||||||
287 | $data['event_submitdate'] = \xoops_getUserTimestamp($data['event_submitdate'], $this->extcalTime->getUserTimeZone($user)); |
||||||||
288 | } |
||||||||
289 | |||||||||
290 | /** |
||||||||
291 | * @param $events |
||||||||
292 | */ |
||||||||
293 | public function serverTimeToUserTimes(&$events) |
||||||||
294 | { |
||||||||
295 | foreach ($events as $i => $iValue) { |
||||||||
296 | $this->serverTimeToUserTime($events[$i]); |
||||||||
297 | } |
||||||||
298 | } |
||||||||
299 | |||||||||
300 | /** |
||||||||
301 | * @param $data |
||||||||
302 | */ |
||||||||
303 | public function addRecurValue(&$data) |
||||||||
304 | { |
||||||||
305 | $data['event_isrecur'] = $this->getIsRecur($_POST); |
||||||||
306 | $data['event_recur_rules'] = $this->getRecurRules($_POST); |
||||||||
307 | $data['event_recur_start'] = $this->getRecurStart($data, $_POST); |
||||||||
308 | $data['event_recur_end'] = $this->getRecurEnd($data, $_POST); |
||||||||
309 | } |
||||||||
310 | |||||||||
311 | /*************************************************************** |
||||||||
312 | * Return events on perioe |
||||||||
313 | ************************************************************** |
||||||||
314 | * |
||||||||
315 | * @param $criteres |
||||||||
316 | * |
||||||||
317 | * @return array |
||||||||
318 | */ |
||||||||
319 | public function getEventsOnPeriode($criteres) |
||||||||
320 | { |
||||||||
321 | //Utility::echoArray($criteres); |
||||||||
322 | $myts = \MyTextSanitizer::getInstance(); // MyTextSanitizer object |
||||||||
323 | |||||||||
324 | $eventsU = $this->getEventsUniques($criteres); |
||||||||
325 | $eventsR = $this->getEventsRecurents($criteres); |
||||||||
326 | $events = \array_merge($eventsU, $eventsR); |
||||||||
327 | |||||||||
328 | // $events = $eventsU; |
||||||||
329 | |||||||||
330 | //Utility::echoArray($events); |
||||||||
331 | |||||||||
332 | //Tri des evennement par date ascendante |
||||||||
333 | $ordre = []; |
||||||||
334 | $eventArray = []; |
||||||||
335 | |||||||||
336 | // while (list($k, $v) = each($events)) { |
||||||||
337 | foreach ($events as $k => $v) { |
||||||||
338 | $ordre[] = (int)$v['event_start']; |
||||||||
339 | $this->formatEventDate($v, Helper::getInstance()->getConfig('event_date_week')); |
||||||||
340 | //$v['cat']['cat_light_color'] = $v['cat']['cat_color']; |
||||||||
341 | $v['cat']['cat_light_color'] = Utility::getLighterColor($v['cat']['cat_color'], \_EXTCAL_INFOBULLE_RGB_MIN, \_EXTCAL_INFOBULLE_RGB_MAX); |
||||||||
342 | if ('' == $v['event_icone']) { |
||||||||
343 | $v['event_icone'] = $v['cat']['cat_icone']; |
||||||||
344 | } |
||||||||
345 | $v['event_desc'] = \html_entity_decode($v['event_desc']); |
||||||||
346 | $eventArray[] = $v; |
||||||||
347 | } |
||||||||
348 | \array_multisort($eventArray, \SORT_ASC, \SORT_NUMERIC, $ordre, \SORT_ASC, \SORT_NUMERIC); |
||||||||
0 ignored issues
–
show
SORT_NUMERIC cannot be passed to array_multisort() as the parameter $rest expects a reference.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() SORT_ASC cannot be passed to array_multisort() as the parameter $rest expects a reference.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
349 | |||||||||
350 | return $eventArray; |
||||||||
351 | } |
||||||||
352 | |||||||||
353 | /***************************************************************** |
||||||||
354 | * |
||||||||
355 | **************************************************************** |
||||||||
356 | * @param $criteres |
||||||||
357 | * @return array |
||||||||
358 | */ |
||||||||
359 | public function getEventsUniques($criteres) |
||||||||
360 | { |
||||||||
361 | $cat = 0; |
||||||||
362 | // while (list($k, $v) = each($criteres)) { |
||||||||
363 | foreach ($criteres as $k => $v) { |
||||||||
364 | ${$k} = $v; |
||||||||
365 | } |
||||||||
366 | if (!isset($nbDays)) { |
||||||||
367 | $nbDays = 7; |
||||||||
368 | } |
||||||||
369 | if (!isset($sens)) { |
||||||||
370 | $sens = 'ASC'; |
||||||||
371 | } |
||||||||
372 | if (!isset($externalKeys)) { |
||||||||
373 | $externalKeys = ['cat_id']; |
||||||||
374 | } |
||||||||
375 | //------------------------------------------------------ |
||||||||
376 | switch ($periode) { |
||||||||
377 | case \_EXTCAL_EVENTS_CALENDAR_WEEK: |
||||||||
378 | $criteriaCompo = $this->getEventWeekCriteria($day, $month, $year, $cat, $nbDays); |
||||||||
379 | if (!Helper::getInstance()->getConfig('diplay_past_event_cal')) { |
||||||||
380 | $criteriaCompo->add(new \Criteria('event_end', \time(), '>')); |
||||||||
381 | } |
||||||||
382 | break; |
||||||||
383 | case \_EXTCAL_EVENTS_WEEK: |
||||||||
384 | case \_EXTCAL_EVENTS_AGENDA_WEEK: |
||||||||
385 | $criteriaCompo = $this->getEventWeekCriteria($day, $month, $year, $cat, $nbDays); |
||||||||
386 | if (!Helper::getInstance()->getConfig('diplay_past_event_list')) { |
||||||||
387 | $criteriaCompo->add(new \Criteria('event_end', \time(), '>')); |
||||||||
388 | } |
||||||||
389 | break; |
||||||||
390 | case \_EXTCAL_EVENTS_CALENDAR_MONTH: |
||||||||
391 | $criteriaCompo = $this->getEventMonthCriteria($month, $year, $cat); |
||||||||
392 | |||||||||
393 | if (!Helper::getInstance()->getConfig('diplay_past_event_cal')) { |
||||||||
394 | $criteriaCompo->add(new \Criteria('event_end', \time(), '>')); |
||||||||
395 | } |
||||||||
396 | break; |
||||||||
397 | case \_EXTCAL_EVENTS_MONTH: |
||||||||
398 | $criteriaCompo = $this->getEventMonthCriteria($month, $year, $cat); |
||||||||
399 | |||||||||
400 | if (!Helper::getInstance()->getConfig('diplay_past_event_list')) { |
||||||||
401 | $criteriaCompo->add(new \Criteria('event_end', \time(), '>')); |
||||||||
402 | } |
||||||||
403 | break; |
||||||||
404 | case \_EXTCAL_EVENTS_DAY: |
||||||||
405 | $criteriaCompo = $this->getEventDayCriteria($day, $month, $year, $cat); |
||||||||
406 | |||||||||
407 | break; |
||||||||
408 | case \_EXTCAL_EVENTS_YEAR: |
||||||||
409 | $criteriaCompo = $this->getEventYearCriteria($year, $cat); |
||||||||
410 | break; |
||||||||
411 | case \_EXTCAL_EVENTS_UPCOMING: |
||||||||
412 | $criteriaCompo = $this->getEventWeekCriteria($day, $month, $year, $cat, $nbDays); |
||||||||
413 | break; |
||||||||
414 | } |
||||||||
415 | //-------------------------------------------------------------------------- |
||||||||
416 | $criteriaCompo->add(new \Criteria('event_isrecur', 0, '=')); |
||||||||
417 | $criteriaCompo->setOrder($sens); |
||||||||
418 | |||||||||
419 | $result = $this->getObjects($criteriaCompo); |
||||||||
420 | $events = $this->objectToArray($result, $externalKeys); |
||||||||
421 | $this->serverTimeToUserTimes($events); |
||||||||
422 | |||||||||
423 | return $events; |
||||||||
424 | } |
||||||||
425 | |||||||||
426 | /***************************************************************** |
||||||||
427 | * evennement récurents |
||||||||
428 | **************************************************************** |
||||||||
429 | * @param $criteres |
||||||||
430 | * @return array |
||||||||
431 | */ |
||||||||
432 | |||||||||
433 | public function getEventsRecurents($criteres) |
||||||||
434 | { |
||||||||
435 | // while (list($k, $v) = each($criteres)) { |
||||||||
436 | foreach ($criteres as $k => $v) { |
||||||||
437 | ${$k} = $v; |
||||||||
438 | } |
||||||||
439 | if (!isset($nbDays)) { |
||||||||
440 | $nbDays = 7; |
||||||||
441 | } |
||||||||
442 | if (!isset($sens)) { |
||||||||
443 | $sens = 'ASC'; |
||||||||
444 | } |
||||||||
445 | if (!isset($externalKeys)) { |
||||||||
446 | $externalKeys = ['cat_id']; |
||||||||
447 | } |
||||||||
448 | $user = $GLOBALS['xoopsUser']; |
||||||||
449 | //------------------------------------------------------ |
||||||||
450 | |||||||||
451 | $criteriaCompo = new \CriteriaCompo(); |
||||||||
452 | |||||||||
453 | switch ($periode) { |
||||||||
454 | case \_EXTCAL_EVENTS_WEEK: |
||||||||
455 | case \_EXTCAL_EVENTS_CALENDAR_WEEK: |
||||||||
456 | case \_EXTCAL_EVENTS_AGENDA_WEEK: |
||||||||
457 | case \_EXTCAL_EVENTS_UPCOMING: |
||||||||
458 | $start = \userTimeToServerTime(\mktime(0, 0, 0, $month, $day, $year), $this->extcalTime->getUserTimeZone($user)); |
||||||||
459 | $end = \userTimeToServerTime(\mktime(0, 0, 0, $month, $day + $nbDays + 1, $year), $this->extcalTime->getUserTimeZone($user)); |
||||||||
460 | //$end = $start + (($nbDays + 1 )* _EXTCAL_TS_DAY); |
||||||||
461 | //$end = userTimeToServerTime(mktime(0, 0, 0, $month, $day+(($nbJours)+1 * _EXTCAL_TS_DAY), $year), $this->extcalTime->getUserTimeZone($user));; |
||||||||
462 | break; |
||||||||
463 | case \_EXTCAL_EVENTS_MONTH: |
||||||||
464 | case \_EXTCAL_EVENTS_CALENDAR_MONTH: |
||||||||
465 | $start = \userTimeToServerTime(\mktime(0, 0, 0, $month, 1, $year), $this->extcalTime->getUserTimeZone($user)); |
||||||||
466 | $end = \userTimeToServerTime(\mktime(23, 59, 59, $month + 1, 1, $year) - \_EXTCAL_TS_DAY, $this->extcalTime->getUserTimeZone($user)); |
||||||||
467 | |||||||||
468 | $criteriaCompo->add(new \Criteria('event_start', $end, '<=')); |
||||||||
469 | //$criteriaCompo->add( new \Criteria('event_end', $start, '>=')); |
||||||||
470 | |||||||||
471 | break; |
||||||||
472 | case \_EXTCAL_EVENTS_DAY: |
||||||||
473 | $start = \userTimeToServerTime(\mktime(0, 0, 0, $month, $day, $year), $this->extcalTime->getUserTimeZone($user)); |
||||||||
474 | $end = \userTimeToServerTime(\mktime(0, 0, 0, $month, $day + 1, $year), $this->extcalTime->getUserTimeZone($user)); |
||||||||
475 | //$criteriaCompo->add( new \Criteria('event_start', $end, '<=')); |
||||||||
476 | |||||||||
477 | break; |
||||||||
478 | case \_EXTCAL_EVENTS_YEAR: |
||||||||
479 | $start = \userTimeToServerTime(\mktime(0, 0, 0, 1, 1, $year), $this->extcalTime->getUserTimeZone($user)); |
||||||||
480 | $end = \userTimeToServerTime(\mktime(0, 0, 0, 12, 31, $year), $this->extcalTime->getUserTimeZone($user)); |
||||||||
481 | break; |
||||||||
482 | } |
||||||||
483 | $formatDate = Helper::getInstance()->getConfig('event_date_week'); |
||||||||
484 | //-------------------------------------------------------------------------- |
||||||||
485 | $criteriaCompo->add(new \Criteria('event_isrecur', 1, '=')); |
||||||||
486 | $criteriaCompo->setOrder($sens); |
||||||||
487 | |||||||||
488 | $result = $this->getObjects($criteriaCompo); |
||||||||
489 | $events = $this->objectToArray($result, $externalKeys); |
||||||||
490 | $this->serverTimeToUserTimes($events); |
||||||||
491 | |||||||||
492 | //Scanning of all recurring events and creation of all events |
||||||||
493 | $eventsR = []; |
||||||||
494 | // while (list($k, $event) = each($events)) { |
||||||||
495 | foreach ($events as $k => $event) { |
||||||||
496 | //$te = $this->GetInterval($event, $start, $end); |
||||||||
497 | //$eventsR = array_merge($eventsR, $te); |
||||||||
498 | //echo 'event : ' . $event['event_id'] . '<br>'; |
||||||||
499 | //Utility::echoArray($event); |
||||||||
500 | $recurEvents = $this->getRecurEventToDisplay($event, $start, $end); |
||||||||
501 | |||||||||
502 | if (\count($recurEvents) > 0) { |
||||||||
503 | $eventsR = \array_merge($eventsR, $recurEvents); |
||||||||
504 | } |
||||||||
505 | |||||||||
506 | // Formating date |
||||||||
507 | //$eventsR = array_merge($eventsArray, $recurEvents); |
||||||||
508 | } |
||||||||
509 | |||||||||
510 | return $eventsR; |
||||||||
511 | } |
||||||||
512 | |||||||||
513 | /***************************************************************** |
||||||||
514 | * |
||||||||
515 | **************************************************************** |
||||||||
516 | * @param $period |
||||||||
517 | * @param string $caption |
||||||||
518 | */ |
||||||||
519 | public function echoDateArray($period, $caption = '') |
||||||||
520 | { |
||||||||
521 | if ('' != $caption) { |
||||||||
522 | echo "<hr>echoDateArray -> {$caption}<br>"; |
||||||||
523 | } else { |
||||||||
524 | echo '<hr>echoDateArray<br>'; |
||||||||
525 | } |
||||||||
526 | |||||||||
527 | \reset($period); |
||||||||
528 | foreach ($period as $dt) { |
||||||||
529 | echo $dt->format("l d-m-Y H:i:s\n") . '<br>'; |
||||||||
530 | } |
||||||||
531 | } |
||||||||
532 | |||||||||
533 | /***************************************************************** |
||||||||
534 | * Criteria |
||||||||
535 | **************************************************************** |
||||||||
536 | * @param $day |
||||||||
537 | * @param $month |
||||||||
538 | * @param $year |
||||||||
539 | * @param int $cat |
||||||||
540 | * @return \CriteriaCompo |
||||||||
541 | */ |
||||||||
542 | // Return the criteria compo object for a day |
||||||||
543 | public function getEventDayCriteria($day, $month, $year, $cat = 0) |
||||||||
544 | { |
||||||||
545 | $user = $GLOBALS['xoopsUser']; |
||||||||
546 | |||||||||
547 | $dayStart = \userTimeToServerTime(\mktime(0, 0, 0, $month, $day, $year), $this->extcalTime->getUserTimeZone($user)); |
||||||||
548 | $dayEnd = \userTimeToServerTime(\mktime(23, 59, 59, $month, $day, $year), $this->extcalTime->getUserTimeZone($user)); |
||||||||
549 | $criteriaCompo = $this->getListCriteriaCompo($dayStart, $dayEnd, $cat, $user); |
||||||||
550 | |||||||||
551 | return $criteriaCompo; |
||||||||
552 | } |
||||||||
553 | |||||||||
554 | // Return the criteria compo object for a week |
||||||||
555 | |||||||||
556 | /** |
||||||||
557 | * @param $day |
||||||||
558 | * @param $month |
||||||||
559 | * @param $year |
||||||||
560 | * @param int $cat |
||||||||
561 | * @param int $nbDays |
||||||||
562 | * |
||||||||
563 | * @return \CriteriaCompo |
||||||||
564 | */ |
||||||||
565 | public function getEventWeekCriteria($day, $month, $year, $cat = 0, $nbDays = 7) |
||||||||
566 | { |
||||||||
567 | $user = $GLOBALS['xoopsUser']; |
||||||||
568 | |||||||||
569 | $userStartTime = \mktime(0, 0, 0, $month, $day, $year); |
||||||||
570 | $userEndTime = $userStartTime + (\_EXTCAL_TS_DAY * $nbDays); |
||||||||
571 | $weekStart = \userTimeToServerTime($userStartTime, $this->extcalTime->getUserTimeZone($user)); |
||||||||
572 | $weekEnd = \userTimeToServerTime($userEndTime, $this->extcalTime->getUserTimeZone($user)); |
||||||||
573 | $criteriaCompo = $this->getCriteriaCompo($weekStart, $weekEnd, $cat, $user); |
||||||||
574 | |||||||||
575 | return $criteriaCompo; |
||||||||
576 | } |
||||||||
577 | |||||||||
578 | // Return the criteria compo object for a month |
||||||||
579 | |||||||||
580 | /** |
||||||||
581 | * @param $month |
||||||||
582 | * @param $year |
||||||||
583 | * @param int $cat |
||||||||
584 | * |
||||||||
585 | * @return \CriteriaCompo |
||||||||
586 | */ |
||||||||
587 | public function getEventMonthCriteria($month, $year, $cat = 0) |
||||||||
588 | { |
||||||||
589 | $user = $GLOBALS['xoopsUser']; |
||||||||
590 | |||||||||
591 | $userStartTime = \mktime(0, 0, 0, $month, 1, $year); |
||||||||
592 | $userEndTime = \mktime(23, 59, 59, $month + 1, 0, $year); |
||||||||
593 | $monthStart = \userTimeToServerTime($userStartTime, $this->extcalTime->getUserTimeZone($user)); |
||||||||
594 | $monthEnd = \userTimeToServerTime($userEndTime, $this->extcalTime->getUserTimeZone($user)); |
||||||||
595 | $criteriaCompo = $this->getCriteriaCompo($monthStart, $monthEnd, $cat, $user); |
||||||||
596 | |||||||||
597 | return $criteriaCompo; |
||||||||
598 | } |
||||||||
599 | |||||||||
600 | // Return the criteria compo object for event occuring on a given year |
||||||||
601 | |||||||||
602 | /** |
||||||||
603 | * @param $year |
||||||||
604 | * @param int $cat |
||||||||
605 | * |
||||||||
606 | * @return \CriteriaCompo |
||||||||
607 | */ |
||||||||
608 | public function getEventYearCriteria($year, $cat = 0) |
||||||||
609 | { |
||||||||
610 | $user = $GLOBALS['xoopsUser']; |
||||||||
611 | |||||||||
612 | $userStartTime = \mktime(0, 0, 0, 1, 1, $year); |
||||||||
613 | $userEndTime = \mktime(23, 59, 59, 12, 31, $year); |
||||||||
614 | $yearStart = \userTimeToServerTime($userStartTime, $this->extcalTime->getUserTimeZone($user)); |
||||||||
615 | $yearEnd = \userTimeToServerTime($userEndTime, $this->extcalTime->getUserTimeZone($user)); |
||||||||
616 | $criteriaCompo = $this->getListCriteriaCompo($yearStart, $yearEnd, $cat, $user); |
||||||||
617 | |||||||||
618 | return $criteriaCompo; |
||||||||
619 | } |
||||||||
620 | |||||||||
621 | /********************************************************************** |
||||||||
622 | * Debut de - A virer in fine |
||||||||
623 | **********************************************************************/ |
||||||||
624 | |||||||||
625 | /********************************************************************** |
||||||||
626 | * FIN de - A virer in fine |
||||||||
627 | **********************************************************************/ |
||||||||
628 | |||||||||
629 | /********************************************************************** |
||||||||
630 | * Construction of criteria according to the period |
||||||||
631 | ********************************************************************* |
||||||||
632 | * @param int $start |
||||||||
633 | * @param int $end |
||||||||
634 | * @param int $cat |
||||||||
635 | * @param int|null $user |
||||||||
636 | * @return \CriteriaCompo |
||||||||
637 | */ |
||||||||
638 | |||||||||
639 | public function getCriteriaCompo($start, $end, $cat = 0, $user = null) |
||||||||
640 | { |
||||||||
641 | $criteriaNoRecur = new \CriteriaCompo(); |
||||||||
642 | $criteriaNoRecur->add(new \Criteria('event_start', $end, '<=')); |
||||||||
643 | $criteriaNoRecur->add(new \Criteria('event_end', $start, '>=')); |
||||||||
644 | $criteriaNoRecur->add(new \Criteria('event_isrecur', 0)); |
||||||||
645 | |||||||||
646 | $criteriaRecur = new \CriteriaCompo(); |
||||||||
647 | $criteriaRecur->add(new \Criteria('event_recur_start', $end, '<=')); |
||||||||
648 | $criteriaRecur->add(new \Criteria('event_recur_end', $start, '>=')); |
||||||||
649 | $criteriaRecur->add(new \Criteria('event_isrecur', 1)); |
||||||||
650 | |||||||||
651 | $criteriaCompoDate = new \CriteriaCompo(); |
||||||||
652 | $criteriaCompoDate->add($criteriaNoRecur, 'OR'); |
||||||||
653 | $criteriaCompoDate->add($criteriaRecur, 'OR'); |
||||||||
654 | |||||||||
655 | $criteriaCompo = new \CriteriaCompo(); |
||||||||
656 | $criteriaCompo->add($criteriaCompoDate); |
||||||||
657 | |||||||||
658 | $criteriaCompo->add(new \Criteria('event_approved', 1)); |
||||||||
659 | $this->addCatSelectCriteria($criteriaCompo, $cat); |
||||||||
660 | $this->addCatPermCriteria($criteriaCompo, $user); |
||||||||
661 | $criteriaCompo->setSort('event_start'); |
||||||||
662 | |||||||||
663 | return $criteriaCompo; |
||||||||
664 | } |
||||||||
665 | |||||||||
666 | /** |
||||||||
667 | * @param int $start |
||||||||
668 | * @param int $end |
||||||||
669 | * @param int $cat |
||||||||
670 | * @param \XoopsUser|null $user |
||||||||
671 | * |
||||||||
672 | * @return \CriteriaCompo |
||||||||
673 | */ |
||||||||
674 | public function getCalendarCriteriaCompo($start, $end, $cat = 0, $user = null) |
||||||||
675 | { |
||||||||
676 | $criteriaCompo = $this->getCriteriaCompo($start, $end, $cat, $user); |
||||||||
0 ignored issues
–
show
It seems like
$user can also be of type XoopsUser ; however, parameter $user of XoopsModules\Extcal\Even...ler::getCriteriaCompo() does only seem to accept integer|null , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
677 | if (!Helper::getInstance()->getConfig('diplay_past_event_cal')) { |
||||||||
678 | $criteriaCompo->add(new \Criteria('event_end', \time(), '>')); |
||||||||
679 | } |
||||||||
680 | |||||||||
681 | return $criteriaCompo; |
||||||||
682 | } |
||||||||
683 | |||||||||
684 | /** |
||||||||
685 | * @param $start |
||||||||
686 | * @param $end |
||||||||
687 | * @param int $cat |
||||||||
688 | * @param \XoopsUser|null $user |
||||||||
689 | * |
||||||||
690 | * @return \CriteriaCompo |
||||||||
691 | */ |
||||||||
692 | public function getListCriteriaCompo($start, $end, $cat = 0, $user = null) |
||||||||
693 | { |
||||||||
694 | $criteriaCompo = $this->getCriteriaCompo($start, $end, $cat, $user); |
||||||||
0 ignored issues
–
show
It seems like
$user can also be of type XoopsUser ; however, parameter $user of XoopsModules\Extcal\Even...ler::getCriteriaCompo() does only seem to accept integer|null , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
695 | if (!Helper::getInstance()->getConfig('diplay_past_event_list')) { |
||||||||
696 | $criteriaCompo->add(new \Criteria('event_end', \time(), '>')); |
||||||||
697 | } |
||||||||
698 | |||||||||
699 | return $criteriaCompo; |
||||||||
700 | } |
||||||||
701 | |||||||||
702 | // Return upcomming event |
||||||||
703 | |||||||||
704 | /** |
||||||||
705 | * @param $nbEvent |
||||||||
706 | * @param int $cat |
||||||||
707 | * |
||||||||
708 | * @return array |
||||||||
709 | */ |
||||||||
710 | public function getUpcommingEvent($nbEvent, $cat = 0) |
||||||||
711 | { |
||||||||
712 | $now = \time(); |
||||||||
713 | |||||||||
714 | $criteriaNoRecur = new \CriteriaCompo(); |
||||||||
715 | $criteriaNoRecur->add(new \Criteria('event_start', $now, '>=')); |
||||||||
716 | $criteriaNoRecur->add(new \Criteria('event_isrecur', 0)); |
||||||||
717 | |||||||||
718 | $criteriaRecur = new \CriteriaCompo(); |
||||||||
719 | $criteriaRecur->add(new \Criteria('event_recur_start', $now, '>=')); |
||||||||
720 | $criteriaRecur->add(new \Criteria('event_isrecur', 1)); |
||||||||
721 | |||||||||
722 | $criteriaCompoDate = new \CriteriaCompo(); |
||||||||
723 | $criteriaCompoDate->add($criteriaNoRecur, 'OR'); |
||||||||
724 | $criteriaCompoDate->add($criteriaRecur, 'OR'); |
||||||||
725 | |||||||||
726 | $criteriaCompo = new \CriteriaCompo(); |
||||||||
727 | $criteriaCompo->add($criteriaCompoDate); |
||||||||
728 | |||||||||
729 | $criteriaCompo->add(new \Criteria('event_approved', 1)); |
||||||||
730 | $this->addCatSelectCriteria($criteriaCompo, $cat); |
||||||||
731 | $this->addCatPermCriteria($criteriaCompo, $GLOBALS['xoopsUser']); |
||||||||
732 | |||||||||
733 | //mb ---------- TESTING --------------------------- |
||||||||
734 | // $eventsU = $this->getEventsUniques($criteriaNoRecur); |
||||||||
735 | // $eventsR = $this->getEventsRecurents($criteriaRecur); |
||||||||
736 | // $events = array_merge($eventsU, $eventsR); |
||||||||
737 | |||||||||
738 | //var_dump($events); |
||||||||
739 | |||||||||
740 | $criteriaCompo->setSort('event_start'); |
||||||||
741 | $criteriaCompo->setLimit($nbEvent); |
||||||||
742 | |||||||||
743 | //var_dump($this->getObjects($criteriaCompo)); |
||||||||
744 | //mb ------------------------------------- |
||||||||
745 | return $this->getObjects($criteriaCompo); |
||||||||
746 | } |
||||||||
747 | |||||||||
748 | // Return event occuring this day |
||||||||
749 | |||||||||
750 | /** |
||||||||
751 | * @param $nbEvent |
||||||||
752 | * @param int $cat |
||||||||
753 | * |
||||||||
754 | * @return array |
||||||||
755 | */ |
||||||||
756 | public function getThisDayEvent($nbEvent, $cat = 0) |
||||||||
757 | { |
||||||||
758 | $day = \date('j'); |
||||||||
759 | $month = \date('n'); |
||||||||
760 | $year = \date('Y'); |
||||||||
761 | |||||||||
762 | $dayStart = \mktime(0, 0, 0, $month, $day, $year); |
||||||||
0 ignored issues
–
show
$day of type string is incompatible with the type integer expected by parameter $day of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() $year of type string is incompatible with the type integer expected by parameter $year of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() $month of type string is incompatible with the type integer expected by parameter $month of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
763 | $dayEnd = \mktime(0, 0, 0, $month, $day + 1, $year); |
||||||||
764 | |||||||||
765 | $criteriaCompo = new \CriteriaCompo(); |
||||||||
766 | $this->addCatSelectCriteria($criteriaCompo, $cat); |
||||||||
767 | $this->addCatPermCriteria($criteriaCompo, $GLOBALS['xoopsUser']); |
||||||||
768 | $criteriaCompo->add(new \Criteria('event_end', $dayStart, '>=')); |
||||||||
769 | $criteriaCompo->add(new \Criteria('event_start', $dayEnd, '<')); |
||||||||
770 | $criteriaCompo->add(new \Criteria('event_approved', 1)); |
||||||||
771 | $criteriaCompo->setSort('event_start'); |
||||||||
772 | $criteriaCompo->setLimit($nbEvent); |
||||||||
773 | |||||||||
774 | return $this->getObjects($criteriaCompo); |
||||||||
775 | } |
||||||||
776 | |||||||||
777 | // Return last added event |
||||||||
778 | |||||||||
779 | /** |
||||||||
780 | * @param $start |
||||||||
781 | * @param $limit |
||||||||
782 | * @param int $cat |
||||||||
783 | * @param bool $skipPerm |
||||||||
784 | * |
||||||||
785 | * @return array |
||||||||
786 | */ |
||||||||
787 | public function getNewEvent($start, $limit, $cat = 0, $skipPerm = false) |
||||||||
788 | { |
||||||||
789 | $criteriaCompo = new \CriteriaCompo(); |
||||||||
790 | $this->addCatSelectCriteria($criteriaCompo, $cat); |
||||||||
791 | if (!$skipPerm) { |
||||||||
792 | $this->addCatPermCriteria($criteriaCompo, $GLOBALS['xoopsUser']); |
||||||||
793 | } |
||||||||
794 | $criteriaCompo->add(new \Criteria('event_approved', 1)); |
||||||||
795 | $criteriaCompo->setSort('event_id'); |
||||||||
796 | $criteriaCompo->setOrder('DESC'); |
||||||||
797 | $criteriaCompo->setStart($start); |
||||||||
798 | $criteriaCompo->setLimit($limit); |
||||||||
799 | |||||||||
800 | return $this->getObjects($criteriaCompo); |
||||||||
801 | } |
||||||||
802 | |||||||||
803 | /** |
||||||||
804 | * @return int |
||||||||
805 | */ |
||||||||
806 | public function getCountNewEvent() |
||||||||
807 | { |
||||||||
808 | $criteriaCompo = new \CriteriaCompo(); |
||||||||
809 | $this->addCatSelectCriteria($criteriaCompo, 0); |
||||||||
810 | $criteriaCompo->add(new \Criteria('event_approved', 1)); |
||||||||
811 | $criteriaCompo->setSort('event_id'); |
||||||||
812 | |||||||||
813 | return $this->getCount($criteriaCompo); |
||||||||
0 ignored issues
–
show
|
|||||||||
814 | } |
||||||||
815 | |||||||||
816 | // Return random upcomming event |
||||||||
817 | |||||||||
818 | /** |
||||||||
819 | * @param $nbEvent |
||||||||
820 | * @param int $cat |
||||||||
821 | * |
||||||||
822 | * @return array |
||||||||
823 | */ |
||||||||
824 | public function getRandomEvent($nbEvent, $cat = 0) |
||||||||
825 | { |
||||||||
826 | $criteriaCompo = new \CriteriaCompo(); |
||||||||
827 | $this->addCatSelectCriteria($criteriaCompo, $cat); |
||||||||
828 | $this->addCatPermCriteria($criteriaCompo, $GLOBALS['xoopsUser']); |
||||||||
829 | $criteriaCompo->add(new \Criteria('event_start', \time(), '>=')); |
||||||||
830 | $criteriaCompo->add(new \Criteria('event_approved', 1)); |
||||||||
831 | $criteriaCompo->setSort('RAND()'); |
||||||||
832 | $criteriaCompo->setLimit($nbEvent); |
||||||||
833 | |||||||||
834 | return $this->getObjects($criteriaCompo); |
||||||||
835 | } |
||||||||
836 | |||||||||
837 | /** |
||||||||
838 | * @return array |
||||||||
839 | */ |
||||||||
840 | public function getPendingEvent() |
||||||||
841 | { |
||||||||
842 | $criteriaCompo = new \CriteriaCompo(); |
||||||||
843 | $criteriaCompo->add(new \Criteria('event_approved', 0)); |
||||||||
844 | $criteriaCompo->setSort('event_start'); |
||||||||
845 | |||||||||
846 | return $this->getObjects($criteriaCompo); |
||||||||
847 | } |
||||||||
848 | |||||||||
849 | /** |
||||||||
850 | * @param \CriteriaCompo $criteria |
||||||||
851 | * @param $user |
||||||||
852 | */ |
||||||||
853 | public function addCatPermCriteria(\CriteriaCompo $criteria, $user) |
||||||||
854 | { |
||||||||
855 | $authorizedAccessCats = $this->extcalPerm->getAuthorizedCat($user, 'extcal_cat_view'); |
||||||||
856 | $count = \count($authorizedAccessCats); |
||||||||
0 ignored issues
–
show
$authorizedAccessCats of type boolean is incompatible with the type Countable|array expected by parameter $value of count() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
857 | if ($count > 0) { |
||||||||
858 | $in = '(' . $authorizedAccessCats[0]; |
||||||||
859 | \array_shift($authorizedAccessCats); |
||||||||
0 ignored issues
–
show
$authorizedAccessCats of type boolean is incompatible with the type array expected by parameter $array of array_shift() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
860 | foreach ($authorizedAccessCats as $authorizedAccessCat) { |
||||||||
861 | $in .= ',' . $authorizedAccessCat; |
||||||||
862 | } |
||||||||
863 | $in .= ')'; |
||||||||
864 | $criteria->add(new \Criteria('cat_id', $in, 'IN')); |
||||||||
865 | } else { |
||||||||
866 | $criteria->add(new \Criteria('cat_id', '(0)', 'IN')); |
||||||||
867 | } |
||||||||
868 | } |
||||||||
869 | |||||||||
870 | /** |
||||||||
871 | * @param $criteria |
||||||||
872 | * @param $cats |
||||||||
873 | */ |
||||||||
874 | public function addCatSelectCriteria($criteria, $cats = null) |
||||||||
875 | { |
||||||||
876 | if (!\is_array($cats) && $cats > 0) { |
||||||||
877 | $criteria->add(new \Criteria('cat_id', $cats)); |
||||||||
878 | } |
||||||||
879 | if (\is_array($cats)) { |
||||||||
880 | if (false === \array_search(0, $cats, true)) { |
||||||||
881 | $in = '(' . \current($cats); |
||||||||
882 | \array_shift($cats); |
||||||||
883 | foreach ($cats as $cat) { |
||||||||
884 | $in .= ',' . $cat; |
||||||||
885 | } |
||||||||
886 | $in .= ')'; |
||||||||
887 | $criteria->add(new \Criteria('cat_id', $in, 'IN')); |
||||||||
888 | } |
||||||||
889 | } |
||||||||
890 | } |
||||||||
891 | |||||||||
892 | /********************************************************************** |
||||||||
893 | * formulaire d'edition des evennements* |
||||||||
894 | ********************************************************************* |
||||||||
895 | * @param string $siteSide |
||||||||
896 | * @param string $mode |
||||||||
897 | * @param null $data |
||||||||
0 ignored issues
–
show
|
|||||||||
898 | * @return Form\ThemeForm |
||||||||
899 | */ |
||||||||
900 | public function getEventForm($siteSide = 'user', $mode = 'new', $data = null) |
||||||||
901 | { |
||||||||
902 | /** @var Helper $helper */ |
||||||||
903 | $helper = Helper::getInstance(); |
||||||||
904 | $categoryHandler = $helper->getHandler(\_EXTCAL_CLN_CAT); |
||||||||
905 | $fileHandler = $helper->getHandler(\_EXTCAL_CLN_FILE); |
||||||||
906 | |||||||||
907 | /***************************************************/ |
||||||||
908 | if ('admin' === $siteSide) { |
||||||||
909 | $action = 'event.php?op=enreg'; |
||||||||
910 | $cats = $categoryHandler->getAllCat($GLOBALS['xoopsUser'], 'all'); |
||||||||
0 ignored issues
–
show
The method
getAllCat() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
911 | } else { |
||||||||
912 | $action = 'post.php'; |
||||||||
913 | $cats = $categoryHandler->getAllCat($GLOBALS['xoopsUser']); |
||||||||
914 | } |
||||||||
915 | /***************************************************/ |
||||||||
916 | $reccurOptions = []; |
||||||||
917 | |||||||||
918 | if ('edit' === $mode || 'clone' === $mode) { |
||||||||
919 | /** @var Event $event */ |
||||||||
920 | if (!$event = $this->getEventWithNotApprove($data['event_id'])) { |
||||||||
921 | return false; |
||||||||
0 ignored issues
–
show
|
|||||||||
922 | } |
||||||||
923 | if ('clone' === $mode) { |
||||||||
924 | $data['event_id'] = 0; |
||||||||
925 | $event->setVar('event_id', 0); |
||||||||
926 | $newTitle = $event->getVar('event_title') . ' (' . \_MD_EXTCAL_CLONE_OF . $data['event_id'] . ')'; |
||||||||
927 | $event->setVar('event_title', $newTitle); |
||||||||
928 | } |
||||||||
929 | |||||||||
930 | $formTitle = \_MD_EXTCAL_EDIT_EVENT; |
||||||||
931 | $formName = 'modify_event'; |
||||||||
932 | $title = $event->getVar('event_title', 'e'); |
||||||||
933 | $cat = $event->getVar('cat_id'); |
||||||||
934 | $desc = $event->getVar('event_desc', 'e'); |
||||||||
935 | $nbMember = $event->getVar('event_nbmember', 'e'); |
||||||||
936 | $organisateur = $event->getVar('event_organisateur'); |
||||||||
937 | $contact = $event->getVar('event_contact', 'e'); |
||||||||
938 | $url = $event->getVar('event_url', 'e'); |
||||||||
939 | $email = $event->getVar('event_email', 'e'); |
||||||||
940 | $event_address = $event->getVar('event_address', 'e'); |
||||||||
941 | $startDateValue = \xoops_getUserTimestamp($event->getVar('event_start'), $this->extcalTime->getUserTimeZone($GLOBALS['xoopsUser'])); |
||||||||
942 | $endDateValue = \xoops_getUserTimestamp($event->getVar('event_end'), $this->extcalTime->getUserTimeZone($GLOBALS['xoopsUser'])); |
||||||||
943 | $event_picture1 = $event->getVar('event_picture1'); |
||||||||
944 | $event_picture2 = $event->getVar('event_picture2'); |
||||||||
945 | $event_price = $event->getVar('event_price'); |
||||||||
946 | $event_location = $event->getVar('event_location'); |
||||||||
947 | $event_icone = $event->getVar('event_icone'); |
||||||||
948 | |||||||||
949 | // Configuring recurring form |
||||||||
950 | $eventOptions = \explode('|', $event->getVar('event_recur_rules')); |
||||||||
951 | $reccurMode = $eventOptions[0]; |
||||||||
952 | \array_shift($eventOptions); |
||||||||
953 | switch ($reccurMode) { |
||||||||
954 | case 'daily': |
||||||||
955 | |||||||||
956 | $reccurOptions['rrule_freq'] = 'daily'; |
||||||||
957 | $reccurOptions['rrule_daily_interval'] = $eventOptions[0]; |
||||||||
958 | |||||||||
959 | break; |
||||||||
960 | case 'weekly': |
||||||||
961 | |||||||||
962 | $reccurOptions['rrule_freq'] = 'weekly'; |
||||||||
963 | $reccurOptions['rrule_weekly_interval'] = $eventOptions[0]; |
||||||||
964 | \array_shift($eventOptions); |
||||||||
965 | $reccurOptions['rrule_weekly_bydays'] = $eventOptions; |
||||||||
966 | |||||||||
967 | break; |
||||||||
968 | case 'monthly': |
||||||||
969 | |||||||||
970 | $reccurOptions['rrule_freq'] = 'monthly'; |
||||||||
971 | $reccurOptions['rrule_monthly_interval'] = $eventOptions[0]; |
||||||||
972 | \array_shift($eventOptions); |
||||||||
973 | if (0 !== mb_strpos($eventOptions[0], 'MD')) { |
||||||||
974 | $reccurOptions['rrule_monthly_byday'] = $eventOptions[0]; |
||||||||
975 | } else { |
||||||||
976 | $reccurOptions['rrule_bymonthday'] = mb_substr($eventOptions[0], 2); |
||||||||
977 | } |
||||||||
978 | |||||||||
979 | break; |
||||||||
980 | case 'yearly': |
||||||||
981 | |||||||||
982 | $reccurOptions['rrule_freq'] = 'yearly'; |
||||||||
983 | $reccurOptions['rrule_yearly_interval'] = $eventOptions[0]; |
||||||||
984 | \array_shift($eventOptions); |
||||||||
985 | $reccurOptions['rrule_yearly_byday'] = $eventOptions[0]; |
||||||||
986 | \array_shift($eventOptions); |
||||||||
987 | $reccurOptions['rrule_yearly_bymonths'] = $eventOptions; |
||||||||
988 | |||||||||
989 | break; |
||||||||
990 | } |
||||||||
991 | |||||||||
992 | $files = $fileHandler->objectToArray($fileHandler->getEventFiles($data['event_id'])); |
||||||||
0 ignored issues
–
show
The method
getEventFiles() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The method
objectToArray() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
993 | $fileHandler->formatFilesSize($files); |
||||||||
0 ignored issues
–
show
The method
formatFilesSize() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
994 | } elseif ('preview' === $mode) { |
||||||||
995 | $formTitle = \_MD_EXTCAL_SUBMIT_EVENT; |
||||||||
996 | $formName = 'submit_event'; |
||||||||
997 | $title = $data['event_title']; |
||||||||
998 | $cat = $data['cat_id']; |
||||||||
999 | $desc = $data['event_desc']; |
||||||||
1000 | $nbMember = $data['event_nbmember']; |
||||||||
1001 | $organisateur = $data['event_organisateur']; |
||||||||
1002 | $contact = $data['event_contact']; |
||||||||
1003 | $url = $data['event_url']; |
||||||||
1004 | $email = $data['event_email']; |
||||||||
1005 | $event_address = $data['event_address']; |
||||||||
1006 | $startDateValue = $data['event_start']; |
||||||||
1007 | $endDateValue = $data['event_end']; |
||||||||
1008 | $eventEndOk = $data['have_end']; |
||||||||
1009 | $event_picture1 = $data['event_picture1']; |
||||||||
1010 | $event_picture2 = $data['event_picture2']; |
||||||||
1011 | $event_price = $data['event_price']; |
||||||||
1012 | $event_location = $data['event_location']; |
||||||||
1013 | $event_icone = $data['event_icone']; |
||||||||
1014 | |||||||||
1015 | // Configuring recurring form |
||||||||
1016 | $eventOptions = \explode('|', $this->getRecurRules($_POST)); |
||||||||
1017 | $reccurMode = $eventOptions[0]; |
||||||||
1018 | \array_shift($eventOptions); |
||||||||
1019 | switch ($reccurMode) { |
||||||||
1020 | case 'daily': |
||||||||
1021 | |||||||||
1022 | $reccurOptions['rrule_freq'] = 'daily'; |
||||||||
1023 | $reccurOptions['rrule_daily_interval'] = $eventOptions[0]; |
||||||||
1024 | |||||||||
1025 | break; |
||||||||
1026 | case 'weekly': |
||||||||
1027 | |||||||||
1028 | $reccurOptions['rrule_freq'] = 'weekly'; |
||||||||
1029 | $reccurOptions['rrule_weekly_interval'] = $eventOptions[0]; |
||||||||
1030 | \array_shift($eventOptions); |
||||||||
1031 | $reccurOptions['rrule_weekly_bydays'] = $eventOptions; |
||||||||
1032 | |||||||||
1033 | break; |
||||||||
1034 | case 'monthly': |
||||||||
1035 | |||||||||
1036 | $reccurOptions['rrule_freq'] = 'monthly'; |
||||||||
1037 | $reccurOptions['rrule_monthly_interval'] = $eventOptions[0]; |
||||||||
1038 | \array_shift($eventOptions); |
||||||||
1039 | if (0 !== mb_strpos($eventOptions[0], 'MD')) { |
||||||||
1040 | $reccurOptions['rrule_monthly_byday'] = $eventOptions[0]; |
||||||||
1041 | } else { |
||||||||
1042 | $reccurOptions['rrule_bymonthday'] = mb_substr($eventOptions[0], 2); |
||||||||
1043 | } |
||||||||
1044 | |||||||||
1045 | break; |
||||||||
1046 | case 'yearly': |
||||||||
1047 | |||||||||
1048 | $reccurOptions['rrule_freq'] = 'yearly'; |
||||||||
1049 | $reccurOptions['rrule_yearly_interval'] = $eventOptions[0]; |
||||||||
1050 | \array_shift($eventOptions); |
||||||||
1051 | $reccurOptions['rrule_yearly_byday'] = $eventOptions[0]; |
||||||||
1052 | \array_shift($eventOptions); |
||||||||
1053 | $reccurOptions['rrule_yearly_bymonths'] = $eventOptions; |
||||||||
1054 | |||||||||
1055 | break; |
||||||||
1056 | } |
||||||||
1057 | |||||||||
1058 | $files = $fileHandler->objectToArray($fileHandler->getEventFiles($data['event_id'])); |
||||||||
1059 | $fileHandler->formatFilesSize($files); |
||||||||
1060 | } else { |
||||||||
1061 | $formTitle = \_MD_EXTCAL_SUBMIT_EVENT; |
||||||||
1062 | $formName = 'submit_event'; |
||||||||
1063 | $title = ''; |
||||||||
1064 | $cat = ''; |
||||||||
1065 | $desc = ''; |
||||||||
1066 | $nbMember = 0; |
||||||||
1067 | $organisateur = ''; |
||||||||
1068 | $contact = ''; |
||||||||
1069 | $url = ''; |
||||||||
1070 | $email = ''; |
||||||||
1071 | $event_address = ''; |
||||||||
1072 | $startDateValue = 0; |
||||||||
1073 | $endDateValue = 0; |
||||||||
1074 | $eventEndOk = 0; |
||||||||
1075 | $event_picture1 = ''; |
||||||||
1076 | $event_picture2 = ''; |
||||||||
1077 | $event_price = ''; |
||||||||
1078 | $event_location = ''; |
||||||||
1079 | $files = []; |
||||||||
1080 | $event_icone = ''; |
||||||||
1081 | } |
||||||||
1082 | |||||||||
1083 | // Create XoopsForm Object |
||||||||
1084 | $form = new Form\ThemeForm($formTitle, 'event_form', $action, 'post', true); |
||||||||
1085 | // Add this extra to allow file upload |
||||||||
1086 | $form->setExtra('enctype="multipart/form-data"'); |
||||||||
1087 | |||||||||
1088 | //----------------------------------------------- |
||||||||
1089 | // Title |
||||||||
1090 | $form->addElement(new \XoopsFormText(\_MD_EXTCAL_TITLE, 'event_title', 80, 255, $title), true); |
||||||||
1091 | //----------------------------------------------- |
||||||||
1092 | // Category select |
||||||||
1093 | $catSelect = new \XoopsFormSelect(\_MD_EXTCAL_CATEGORY, 'cat_id', $cat); |
||||||||
1094 | foreach ($cats as $cat) { |
||||||||
1095 | $catSelect->addOption($cat->getVar('cat_id'), $cat->getVar('cat_name')); |
||||||||
1096 | } |
||||||||
1097 | $form->addElement($catSelect, true); |
||||||||
1098 | // Icon |
||||||||
1099 | if (1 == $helper->getConfig('formShowIcon', 1)) { |
||||||||
1100 | $file_path = \dirname(__DIR__) . '/assets/css/images'; |
||||||||
1101 | $tf = \XoopsLists::getImgListAsArray($file_path); |
||||||||
1102 | \array_unshift($tf, \_MD_EXTCAL_NONE); |
||||||||
1103 | $xfIcones = new \XoopsFormSelect(\_MD_EXTCAL_ICONE, 'event_icone', $event_icone, ''); |
||||||||
0 ignored issues
–
show
'' of type string is incompatible with the type integer expected by parameter $size of XoopsFormSelect::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
1104 | $xfIcones->addOptionArray($tf); |
||||||||
1105 | $form->addElement($xfIcones, false); |
||||||||
1106 | } else { |
||||||||
1107 | $form->addElement(new \XoopsFormHidden('event_icone', $event_icone), false); |
||||||||
1108 | } |
||||||||
1109 | //location |
||||||||
1110 | if (1 == $helper->getConfig('formShowLocation', 1)) { |
||||||||
1111 | $locationHandler = Helper::getInstance()->getHandler(\_EXTCAL_CLN_LOCATION); |
||||||||
1112 | $location_select = new \XoopsFormSelect(\_MD_EXTCAL_LOCATION, 'event_location', $event_location); |
||||||||
1113 | $criteria = new \CriteriaCompo(); |
||||||||
1114 | $criteria->setSort('nom'); |
||||||||
1115 | $criteria->setOrder('ASC'); |
||||||||
1116 | |||||||||
1117 | //$lstLocation = $locationHandler->getList($criteria); |
||||||||
1118 | $location_arr = $locationHandler->getAll($criteria); |
||||||||
0 ignored issues
–
show
The method
getAll() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoUserHandler or XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
1119 | $tEts = []; |
||||||||
1120 | $tEts[0] = \_MD_EXTCAL_NONE; |
||||||||
1121 | foreach (\array_keys($location_arr) as $i) { |
||||||||
1122 | $tEts[$location_arr[$i]->getVar('id')] = $location_arr[$i]->getVar('nom'); |
||||||||
1123 | // $tEts[$location_arr[$i]['id']] = $location_arr[$i]['nom']; |
||||||||
1124 | } |
||||||||
1125 | //array_unshift($tEts, _MD_EXTCAL_NONE); |
||||||||
1126 | |||||||||
1127 | $location_select->addOptionArray($tEts); |
||||||||
1128 | $form->addElement($location_select, true); |
||||||||
1129 | } else { |
||||||||
1130 | $form->addElement(new \XoopsFormHidden('event_location', $event_location), false); |
||||||||
1131 | } |
||||||||
1132 | |||||||||
1133 | //----------------------------------------------------------- |
||||||||
1134 | |||||||||
1135 | // Start and end |
||||||||
1136 | new Form\FormDateTime($form, $startDateValue, $endDateValue); //mb |
||||||||
1137 | |||||||||
1138 | global $xoopsUser, $xoopsModule; |
||||||||
1139 | $isAdmin = false; |
||||||||
1140 | if (\is_object($xoopsUser)) { |
||||||||
1141 | $isAdmin = $xoopsUser->isAdmin($helper->getModule()->getVar('mid')); |
||||||||
1142 | } |
||||||||
1143 | |||||||||
1144 | // Description |
||||||||
1145 | if (\class_exists('XoopsFormEditor')) { |
||||||||
1146 | $options['name'] = 'event_desc'; |
||||||||
1147 | $options['value'] = $desc; |
||||||||
1148 | $options['rows'] = 5; |
||||||||
1149 | $options['cols'] = '100%'; |
||||||||
1150 | $options['width'] = '100%'; |
||||||||
1151 | $options['height'] = '200px'; |
||||||||
1152 | if ($isAdmin) { |
||||||||
1153 | $descEditor = new \XoopsFormEditor(\_MD_EXTCAL_DESCRIPTION, $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea'); |
||||||||
1154 | } else { |
||||||||
1155 | $descEditor = new \XoopsFormEditor(\_MD_EXTCAL_DESCRIPTION, $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea'); |
||||||||
1156 | } |
||||||||
1157 | } else { |
||||||||
1158 | $descEditor = new \XoopsFormDhtmlTextArea(\_MD_EXTCAL_DESCRIPTION, 'event_desc', $desc, '100%', '100%'); |
||||||||
0 ignored issues
–
show
'100%' of type string is incompatible with the type integer expected by parameter $rows of XoopsFormDhtmlTextArea::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() '100%' of type string is incompatible with the type integer expected by parameter $cols of XoopsFormDhtmlTextArea::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
1159 | } |
||||||||
1160 | $form->addElement($descEditor); |
||||||||
1161 | |||||||||
1162 | // Max registered member for this event |
||||||||
1163 | $nbMemberElement = new \XoopsFormText(\_MD_EXTCAL_NBMEMBER, 'event_nbmember', 4, 4, $nbMember); |
||||||||
1164 | $nbMemberElement->setDescription(\_MD_EXTCAL_NBMEMBER_DESC); |
||||||||
1165 | $form->addElement($nbMemberElement, false); |
||||||||
1166 | |||||||||
1167 | //Price and monnaie |
||||||||
1168 | if (1 == $helper->getConfig('formShowPrice', 1)) { |
||||||||
1169 | $monnaie_price = new \XoopsFormElementTray(\_MD_EXTCAL_PRICE, ''); |
||||||||
1170 | //price |
||||||||
1171 | $monnaie_price->addElement(new \XoopsFormText('', 'event_price', 20, 255, $event_price)); |
||||||||
1172 | //monnaie |
||||||||
1173 | $monnaie = new \XoopsFormLabel(\_MD_EXTCAL_DEVISE2, ''); |
||||||||
1174 | $monnaie_price->addElement($monnaie); |
||||||||
1175 | $form->addElement($monnaie_price); |
||||||||
1176 | } else { |
||||||||
1177 | $form->addElement(new \XoopsFormHidden('event_price', $event_price), false); |
||||||||
1178 | } |
||||||||
1179 | //---------------------------------------------------------------- |
||||||||
1180 | if (1 == $helper->getConfig('formShowOrganizer', 1)) { |
||||||||
1181 | $form->addElement(new \XoopsFormText(\_MD_EXTCAL_ORGANISATEUR, 'event_organisateur', 80, 255, $organisateur), false); |
||||||||
1182 | } else { |
||||||||
1183 | $form->addElement(new \XoopsFormHidden('event_organisateur', $organisateur), false); |
||||||||
1184 | } |
||||||||
1185 | // Contact |
||||||||
1186 | if (1 == $helper->getConfig('formShowContact', 1)) { |
||||||||
1187 | $form->addElement(new \XoopsFormText(\_MD_EXTCAL_CONTACT, 'event_contact', 80, 255, $contact), false); |
||||||||
1188 | } else { |
||||||||
1189 | $form->addElement(new \XoopsFormHidden('event_contact', $contact), false); |
||||||||
1190 | } |
||||||||
1191 | // Url |
||||||||
1192 | if (1 == $helper->getConfig('formShowUrl', 1)) { |
||||||||
1193 | $form->addElement(new \XoopsFormText(\_MD_EXTCAL_URL, 'event_url', 80, 255, $url), false); |
||||||||
1194 | } else { |
||||||||
1195 | $form->addElement(new \XoopsFormHidden('event_url', $url), false); |
||||||||
1196 | } |
||||||||
1197 | |||||||||
1198 | if (1 == $helper->getConfig('formShowEmail', 1)) { |
||||||||
1199 | $form->addElement(new \XoopsFormText(\_MD_EXTCAL_EMAIL, 'event_email', 80, 255, $email), false); |
||||||||
1200 | } else { |
||||||||
1201 | $form->addElement(new \XoopsFormHidden('event_email', $email), false); |
||||||||
1202 | } |
||||||||
1203 | |||||||||
1204 | // Address |
||||||||
1205 | if (1 == $helper->getConfig('formShowAddress', 1)) { |
||||||||
1206 | if (\class_exists('XoopsFormEditor')) { |
||||||||
1207 | $options['name'] = 'event_address'; |
||||||||
1208 | $options['value'] = $event_address; |
||||||||
1209 | $options['rows'] = 5; |
||||||||
1210 | $options['cols'] = '100%'; |
||||||||
1211 | $options['width'] = '100%'; |
||||||||
1212 | $options['height'] = '200px'; |
||||||||
1213 | if ($isAdmin) { |
||||||||
1214 | $addressEditor = new \XoopsFormEditor(\_MD_EXTCAL_ADDRESS, $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea'); |
||||||||
1215 | } else { |
||||||||
1216 | $addressEditor = new \XoopsFormEditor(\_MD_EXTCAL_ADDRESS, $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea'); |
||||||||
1217 | } |
||||||||
1218 | } else { |
||||||||
1219 | $addressEditor = new \XoopsFormDhtmlTextArea(\_MD_EXTCAL_ADDRESS, 'event_address', $event_address, '100%', '100%'); |
||||||||
1220 | } |
||||||||
1221 | $form->addElement($addressEditor); |
||||||||
1222 | } else { |
||||||||
1223 | $form->addElement(new \XoopsFormHidden('event_address', $event_address), false); |
||||||||
1224 | } |
||||||||
1225 | |||||||||
1226 | // Recurence form |
||||||||
1227 | if (1 == $helper->getConfig('formShowRecurence', 1)) { |
||||||||
1228 | $form->addElement(new Form\FormRecurRules($reccurOptions)); |
||||||||
1229 | } |
||||||||
1230 | // File attachement |
||||||||
1231 | if (1 == $helper->getConfig('formShowFile', 1)) { |
||||||||
1232 | $fileElmtTray = new \XoopsFormElementTray(\_MD_EXTCAL_FILE_ATTACHEMENT, '<br>'); |
||||||||
1233 | |||||||||
1234 | // If they are attached file to this event |
||||||||
1235 | if (\count($files) > 0) { |
||||||||
0 ignored issues
–
show
It seems like
$files can also be of type null ; however, parameter $value of count() does only seem to accept Countable|array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
1236 | $eventFiles = new Form\FormFileCheckBox('', 'filetokeep'); |
||||||||
1237 | foreach ($files as $file) { |
||||||||
1238 | $name = $file['file_nicename'] . ' (<i>' . $file['file_mimetype'] . '</i>) ' . $file['formated_file_size']; |
||||||||
1239 | $eventFiles->addOption($file['file_id'], $name); |
||||||||
1240 | } |
||||||||
1241 | $fileElmtTray->addElement($eventFiles); |
||||||||
1242 | } |
||||||||
1243 | $fileElmtTray->addElement(new \XoopsFormFile('', 'event_file', 3145728)); |
||||||||
1244 | $form->addElement($fileElmtTray); |
||||||||
1245 | } |
||||||||
1246 | if (isset($data['event_id'])) { |
||||||||
1247 | $form->addElement(new \XoopsFormHidden('event_id', $data['event_id']), false); |
||||||||
1248 | } |
||||||||
1249 | //Hack Kraven0 |
||||||||
1250 | /////////////////////////////////////////////////////////////////////////////// |
||||||||
1251 | if (1 == $helper->getConfig('formShowPicture', 1)) { |
||||||||
1252 | //Picture1 |
||||||||
1253 | $file_tray = new \XoopsFormElementTray(\sprintf(\_MD_EXTCAL_FORM_IMG, 1), ''); |
||||||||
1254 | if (!empty($event_picture1)) { |
||||||||
1255 | $file_tray->addElement(new \XoopsFormLabel('', "<img src='" . XOOPS_URL . '/uploads/extcal/' . $event_picture1 . "' name='image' id='image' alt=''><br><br>")); |
||||||||
1256 | $check_del_img = new \XoopsFormCheckBox('', 'delimg_1'); |
||||||||
1257 | $check_del_img->addOption(1, \_MD_EXTCAL_DEL_IMG); |
||||||||
1258 | $file_tray->addElement($check_del_img); |
||||||||
1259 | $file_img = new \XoopsFormFile(\_MD_EXTCAL_IMG, 'attachedimage1', 2145728); |
||||||||
1260 | unset($check_del_img); |
||||||||
1261 | } else { |
||||||||
1262 | $file_img = new \XoopsFormFile('', 'attachedimage1', 2145728); |
||||||||
1263 | } |
||||||||
1264 | $file_img->setExtra("size ='40'"); |
||||||||
1265 | $file_tray->addElement($file_img); |
||||||||
1266 | $msg = \sprintf(\_MD_EXTCAL_IMG_CONFIG, (int)(400728 / 1000), 500); |
||||||||
1267 | $file_label = new \XoopsFormLabel('', '<br>' . $msg); |
||||||||
1268 | $file_tray->addElement($file_label); |
||||||||
1269 | $form->addElement($file_tray); |
||||||||
1270 | $form->addElement(new \XoopsFormHidden('file1', $event_picture1)); |
||||||||
1271 | unset($file_img, $file_tray); |
||||||||
1272 | //Picture2 |
||||||||
1273 | $file_tray = new \XoopsFormElementTray(\sprintf(\_MD_EXTCAL_FORM_IMG, 2), ''); |
||||||||
1274 | if (!empty($event_picture2)) { |
||||||||
1275 | $file_tray->addElement(new \XoopsFormLabel('', "<img src='" . XOOPS_URL . '/uploads/extcal/' . $event_picture2 . "' name='image' id='image' alt=''><br><br>")); |
||||||||
1276 | $check_del_img = new \XoopsFormCheckBox('', 'delimg_2'); |
||||||||
1277 | $check_del_img->addOption(1, \_MD_EXTCAL_DEL_IMG); |
||||||||
1278 | $file_tray->addElement($check_del_img); |
||||||||
1279 | $file_img = new \XoopsFormFile(\_MD_EXTCAL_IMG, 'attachedimage2', 2145728); |
||||||||
1280 | unset($check_del_img); |
||||||||
1281 | } else { |
||||||||
1282 | $file_img = new \XoopsFormFile('', 'attachedimage2', 2145728); |
||||||||
1283 | } |
||||||||
1284 | $file_img->setExtra("size ='40'"); |
||||||||
1285 | $file_tray->addElement($file_img); |
||||||||
1286 | $msg = \sprintf(\_MD_EXTCAL_IMG_CONFIG, (int)(400728 / 1000), 500); |
||||||||
1287 | $file_label = new \XoopsFormLabel('', '<br>' . $msg); |
||||||||
1288 | $file_tray->addElement($file_label); |
||||||||
1289 | $form->addElement($file_tray); |
||||||||
1290 | $form->addElement(new \XoopsFormHidden('file2', $event_picture2)); |
||||||||
1291 | unset($file_img, $file_tray); |
||||||||
1292 | } |
||||||||
1293 | /////////////////////////////////////////////////////////////////////////////// |
||||||||
1294 | |||||||||
1295 | $buttonElmtTray = new \XoopsFormElementTray('', ' '); |
||||||||
1296 | $buttonElmtTray->addElement(new \XoopsFormButton('', 'form_submit', \_SUBMIT, 'submit'), false); |
||||||||
1297 | if ('user' === $siteSide) { |
||||||||
1298 | $buttonElmtTray->addElement(new \XoopsFormButton('', 'form_preview', \_MD_EXTCAL_PREVIEW, 'submit'), false); |
||||||||
1299 | } |
||||||||
1300 | $form->addElement($buttonElmtTray); |
||||||||
1301 | |||||||||
1302 | return $form; |
||||||||
1303 | } |
||||||||
1304 | |||||||||
1305 | /********************************************************************/ |
||||||||
1306 | |||||||||
1307 | /** |
||||||||
1308 | * @param $parm |
||||||||
1309 | * |
||||||||
1310 | * @return bool |
||||||||
1311 | */ |
||||||||
1312 | public function getIsRecur($parm) |
||||||||
1313 | { |
||||||||
1314 | $recurFreq = ['daily', 'weekly', 'monthly', 'yearly']; |
||||||||
1315 | |||||||||
1316 | return \in_array($parm['rrule_freq'], $recurFreq); |
||||||||
1317 | } |
||||||||
1318 | |||||||||
1319 | /** |
||||||||
1320 | * @param $parm |
||||||||
1321 | * |
||||||||
1322 | * @return string |
||||||||
1323 | */ |
||||||||
1324 | public function getRecurRules($parm) |
||||||||
1325 | { |
||||||||
1326 | //Utility::echoArray($parm);exit; |
||||||||
1327 | |||||||||
1328 | // If this isn't a reccuring event |
||||||||
1329 | if (!$this->getIsRecur($parm)) { |
||||||||
1330 | return ''; |
||||||||
1331 | } |
||||||||
1332 | |||||||||
1333 | $recurRules = ''; |
||||||||
1334 | |||||||||
1335 | $recurFreq = $parm['rrule_freq']; |
||||||||
1336 | |||||||||
1337 | switch ($recurFreq) { |
||||||||
1338 | case 'daily': |
||||||||
1339 | if (!isset($parm['rrule_daily_interval'])) { |
||||||||
1340 | $parm['rrule_daily_interval'] = 0; |
||||||||
1341 | } |
||||||||
1342 | $recurRules = 'daily|'; |
||||||||
1343 | $recurRules .= $parm['rrule_daily_interval']; |
||||||||
1344 | |||||||||
1345 | break; |
||||||||
1346 | case 'weekly': |
||||||||
1347 | if (!isset($parm['rrule_weekly_interval'])) { |
||||||||
1348 | $parm['rrule_weekly_interval'] = 0; |
||||||||
1349 | } |
||||||||
1350 | $recurRules = 'weekly|'; |
||||||||
1351 | $recurRules .= $parm['rrule_weekly_interval']; |
||||||||
1352 | foreach ($parm['rrule_weekly_bydays'] as $day) { |
||||||||
1353 | $recurRules .= '|' . $day; |
||||||||
1354 | } |
||||||||
1355 | |||||||||
1356 | break; |
||||||||
1357 | case 'monthly': |
||||||||
1358 | if (!isset($parm['rrule_monthly_interval'])) { |
||||||||
1359 | $parm['rrule_monthly_interval'] = 0; |
||||||||
1360 | } |
||||||||
1361 | $recurRules = 'monthly|'; |
||||||||
1362 | $recurRules .= $parm['rrule_monthly_interval'] . '|'; |
||||||||
1363 | if ('' != $parm['rrule_monthly_byday']) { |
||||||||
1364 | $recurRules .= $parm['rrule_monthly_byday']; |
||||||||
1365 | } else { |
||||||||
1366 | $recurRules .= 'MD' . $parm['rrule_bymonthday']; |
||||||||
1367 | } |
||||||||
1368 | |||||||||
1369 | break; |
||||||||
1370 | case 'yearly': |
||||||||
1371 | //JJD - to valid modif |
||||||||
1372 | // |
||||||||
1373 | // if ($parm['rrule_yearly_byday'] == "") { |
||||||||
1374 | // list($year, $month, $day) = explode("-", $parm['event_start']['date']); |
||||||||
1375 | // $parm['rrule_yearly_byday'] = date("j", mktime(0, 0, 0, $month, $day, $year)); |
||||||||
1376 | // } |
||||||||
1377 | // |
||||||||
1378 | // $recurRules = 'yearly|'; |
||||||||
1379 | // $recurRules .= $parm['rrule_yearly_interval']; |
||||||||
1380 | // $recurRules .= '|' . $parm['rrule_yearly_byday']; |
||||||||
1381 | // foreach ( |
||||||||
1382 | // $parm['rrule_yearly_bymonths'] as $month |
||||||||
1383 | //) { |
||||||||
1384 | // $recurRules .= '|' . $month; |
||||||||
1385 | // } |
||||||||
1386 | // |
||||||||
1387 | // break; |
||||||||
1388 | |||||||||
1389 | if (!isset($parm['rrule_yearly_interval'])) { |
||||||||
1390 | $parm['rrule_yearly_interval'] = 0; |
||||||||
1391 | } |
||||||||
1392 | if ('' == $parm['rrule_yearly_byday']) { |
||||||||
1393 | $time = \strtotime($parm['event_start']['date']); |
||||||||
1394 | $parm['rrule_yearly_byday'] = \date('j', \mktime(0, 0, 0, \date('m', $time), \date('d', $time), \date('Y', $time))); |
||||||||
0 ignored issues
–
show
date('Y', $time) of type string is incompatible with the type integer expected by parameter $year of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() date('m', $time) of type string is incompatible with the type integer expected by parameter $month of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() date('d', $time) of type string is incompatible with the type integer expected by parameter $day of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
1395 | } |
||||||||
1396 | |||||||||
1397 | $recurRules = 'yearly|'; |
||||||||
1398 | $recurRules .= $parm['rrule_yearly_interval']; |
||||||||
1399 | $recurRules .= '|' . $parm['rrule_yearly_byday']; |
||||||||
1400 | foreach ($parm['rrule_yearly_bymonths'] as $month) { |
||||||||
1401 | $recurRules .= '|' . $month; |
||||||||
1402 | } |
||||||||
1403 | |||||||||
1404 | break; |
||||||||
1405 | } |
||||||||
1406 | |||||||||
1407 | return $recurRules; |
||||||||
1408 | } |
||||||||
1409 | |||||||||
1410 | /** |
||||||||
1411 | * @param $data |
||||||||
1412 | * @param $parm |
||||||||
1413 | * |
||||||||
1414 | * @return int |
||||||||
1415 | */ |
||||||||
1416 | public function getRecurStart($data, $parm) |
||||||||
1417 | { |
||||||||
1418 | // If this isn't a reccuring event |
||||||||
1419 | if (!$this->getIsRecur($parm)) { |
||||||||
1420 | return 0; |
||||||||
1421 | } |
||||||||
1422 | |||||||||
1423 | return $data['event_start']; |
||||||||
1424 | } |
||||||||
1425 | |||||||||
1426 | /** |
||||||||
1427 | * @param $data |
||||||||
1428 | * @param $parm |
||||||||
1429 | * |
||||||||
1430 | * @return int |
||||||||
1431 | */ |
||||||||
1432 | public function getRecurEnd($data, $parm) |
||||||||
1433 | { |
||||||||
1434 | if (!$this->getIsRecur($parm)) { |
||||||||
1435 | return 0; |
||||||||
1436 | } |
||||||||
1437 | |||||||||
1438 | $recurFreq = $parm['rrule_freq']; |
||||||||
1439 | |||||||||
1440 | $recurStart = $this->getRecurStart($data, $parm); |
||||||||
1441 | |||||||||
1442 | switch ($recurFreq) { |
||||||||
1443 | case 'daily': |
||||||||
1444 | $interval = $parm['rrule_daily_interval']; |
||||||||
1445 | $recurEnd = $recurStart + ($interval * \_EXTCAL_TS_DAY) - 1; |
||||||||
1446 | |||||||||
1447 | break; |
||||||||
1448 | case 'weekly': |
||||||||
1449 | // Getting the first weekday TS |
||||||||
1450 | $startWeekTS = \mktime(0, 0, 0, \date('n', $data['event_recur_start']), \date('j', $data['event_recur_start']), \date('Y', $data['event_recur_start'])); |
||||||||
0 ignored issues
–
show
date('j', $data['event_recur_start']) of type string is incompatible with the type integer expected by parameter $day of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() date('Y', $data['event_recur_start']) of type string is incompatible with the type integer expected by parameter $year of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() date('n', $data['event_recur_start']) of type string is incompatible with the type integer expected by parameter $month of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
1451 | $offset = \date('w', $startWeekTS) - Helper::getInstance()->getConfig('week_start_day'); |
||||||||
1452 | $startWeekTS -= ($offset * \_EXTCAL_TS_DAY); |
||||||||
1453 | |||||||||
1454 | $recurEnd = $startWeekTS + ($parm['rrule_weekly_interval'] * \_EXTCAL_TS_WEEK) - 1; |
||||||||
1455 | |||||||||
1456 | break; |
||||||||
1457 | case 'monthly': |
||||||||
1458 | $recurEnd = $recurStart + ($parm['rrule_monthly_interval'] * 2678400) - 1; |
||||||||
1459 | |||||||||
1460 | break; |
||||||||
1461 | case 'yearly': |
||||||||
1462 | $recurEnd = $recurStart + ($parm['rrule_yearly_interval'] * 32140800) - 1; |
||||||||
1463 | |||||||||
1464 | break; |
||||||||
1465 | } |
||||||||
1466 | |||||||||
1467 | return $recurEnd; |
||||||||
1468 | } |
||||||||
1469 | |||||||||
1470 | /******************************************************************* |
||||||||
1471 | * |
||||||||
1472 | ****************************************************************** |
||||||||
1473 | * @param $event |
||||||||
1474 | * @param $periodStart |
||||||||
1475 | * @param $periodEnd |
||||||||
1476 | * @return array |
||||||||
1477 | */ |
||||||||
1478 | public function getRecurEventToDisplay($event, $periodStart, $periodEnd) |
||||||||
1479 | { |
||||||||
1480 | $recuEvents = []; |
||||||||
1481 | $eventOptions = \explode('|', $event['event_recur_rules']); |
||||||||
1482 | |||||||||
1483 | switch ($eventOptions[0]) { |
||||||||
1484 | case 'daily': |
||||||||
1485 | \array_shift($eventOptions); |
||||||||
1486 | $rRuleInterval = $eventOptions[0]; |
||||||||
1487 | if ('' == $rRuleInterval || 0 == $rRuleInterval) { |
||||||||
1488 | $rRuleInterval = 54; |
||||||||
1489 | } |
||||||||
1490 | |||||||||
1491 | $occurEventStart = $event['event_recur_start']; |
||||||||
1492 | $occurEventEnd = $event['event_recur_start'] + ($event['event_end'] - $event['event_start']); |
||||||||
1493 | |||||||||
1494 | $nbOccur = 0; |
||||||||
1495 | // This variable is used to stop the loop after we add all occur on the view to keep good performance |
||||||||
1496 | $isOccurOnPeriod = false; |
||||||||
1497 | // Parse all occurence of this event |
||||||||
1498 | while ($nbOccur < $rRuleInterval) { |
||||||||
1499 | // Add this event occurence only if it's on the period view |
||||||||
1500 | if // Event start falls within search period |
||||||||
1501 | ($occurEventStart <= $periodEnd |
||||||||
1502 | && // Event end falls within search period |
||||||||
1503 | $occurEventEnd >= $periodStart) { |
||||||||
1504 | $event['event_start'] = $occurEventStart; |
||||||||
1505 | $event['event_end'] = $occurEventEnd; |
||||||||
1506 | |||||||||
1507 | $recuEvents[] = $event; |
||||||||
1508 | $isOccurOnPeriod = true; |
||||||||
1509 | } elseif ($isOccurOnPeriod) { |
||||||||
1510 | break; |
||||||||
1511 | } |
||||||||
1512 | |||||||||
1513 | $occurEventStart += \_EXTCAL_TS_DAY; |
||||||||
1514 | $occurEventEnd += \_EXTCAL_TS_DAY; |
||||||||
1515 | |||||||||
1516 | ++$nbOccur; |
||||||||
1517 | } |
||||||||
1518 | |||||||||
1519 | break; |
||||||||
1520 | case 'weekly': |
||||||||
1521 | |||||||||
1522 | \array_shift($eventOptions); |
||||||||
1523 | $rRuleInterval = $eventOptions[0]; |
||||||||
1524 | if ('' == $rRuleInterval || 0 == $rRuleInterval) { |
||||||||
1525 | $rRuleInterval = 54; |
||||||||
1526 | } |
||||||||
1527 | \array_shift($eventOptions); |
||||||||
1528 | |||||||||
1529 | // Getting the first weekday TS |
||||||||
1530 | $startWeekTS = \mktime(0, 0, 0, \date('n', $event['event_recur_start']), \date('j', $event['event_recur_start']), \date('Y', $event['event_recur_start'])); |
||||||||
0 ignored issues
–
show
date('Y', $event['event_recur_start']) of type string is incompatible with the type integer expected by parameter $year of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() date('n', $event['event_recur_start']) of type string is incompatible with the type integer expected by parameter $month of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() date('j', $event['event_recur_start']) of type string is incompatible with the type integer expected by parameter $day of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
1531 | $offset = \date('w', $startWeekTS) - Helper::getInstance()->getConfig('week_start_day'); |
||||||||
1532 | $startWeekTS = $startWeekTS - ($offset * \_EXTCAL_TS_DAY) + \_EXTCAL_TS_WEEK; |
||||||||
1533 | |||||||||
1534 | $occurEventStart = $event['event_recur_start']; |
||||||||
1535 | $occurEventEnd = $event['event_recur_start'] + ($event['event_end'] - $event['event_start']); |
||||||||
1536 | |||||||||
1537 | $dayArray = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']; |
||||||||
1538 | |||||||||
1539 | $nbOccur = 0; |
||||||||
1540 | |||||||||
1541 | // Parse all occurence of this event |
||||||||
1542 | while ($nbOccur < $rRuleInterval) { |
||||||||
1543 | // Add this event occurence only if it's on the period view and according to day |
||||||||
1544 | if ($occurEventStart <= $periodEnd // Event start falls within search period |
||||||||
1545 | && $occurEventEnd >= $periodStart // Event end falls within search period |
||||||||
1546 | && \in_array($dayArray[\date('w', $occurEventStart)], $eventOptions)) { |
||||||||
1547 | // This week day is selected |
||||||||
1548 | |||||||||
1549 | $event['event_start'] = $occurEventStart; |
||||||||
1550 | $event['event_end'] = $occurEventEnd; |
||||||||
1551 | |||||||||
1552 | $recuEvents[] = $event; |
||||||||
1553 | } |
||||||||
1554 | |||||||||
1555 | $occurEventStart += \_EXTCAL_TS_DAY; |
||||||||
1556 | $occurEventEnd += \_EXTCAL_TS_DAY; |
||||||||
1557 | |||||||||
1558 | if ($occurEventStart >= $startWeekTS) { |
||||||||
1559 | ++$nbOccur; |
||||||||
1560 | $startWeekTS += \_EXTCAL_TS_WEEK; |
||||||||
1561 | } |
||||||||
1562 | } |
||||||||
1563 | |||||||||
1564 | break; |
||||||||
1565 | case 'monthly': |
||||||||
1566 | \array_shift($eventOptions); |
||||||||
1567 | $rRuleInterval = $eventOptions[0]; |
||||||||
1568 | if ('' == $rRuleInterval || 0 == $rRuleInterval) { |
||||||||
1569 | $rRuleInterval = 100; |
||||||||
1570 | } |
||||||||
1571 | \array_shift($eventOptions); |
||||||||
1572 | |||||||||
1573 | $day = \date('j', $event['event_recur_start']); |
||||||||
1574 | $month = \date('n', $event['event_recur_start']); |
||||||||
1575 | $year = \date('Y', $event['event_recur_start']); |
||||||||
1576 | |||||||||
1577 | $nbOccur = 0; |
||||||||
1578 | |||||||||
1579 | $eventHourOccurStart = $event['event_recur_start'] - \mktime(0, 0, 0, $month, $day, $year); |
||||||||
1580 | $eventHourOccurEnd = $event['event_end'] - $event['event_start']; |
||||||||
1581 | |||||||||
1582 | // Parse all occurence of this event |
||||||||
1583 | while ($nbOccur < $rRuleInterval) { |
||||||||
1584 | $eventDayOccurStart = $this->getOccurTS($month, $year, $eventOptions[0]); |
||||||||
1585 | if (!$eventDayOccurStart) { |
||||||||
1586 | $eventDayOccurStart = \mktime(0, 0, 0, $month, $day, $year); |
||||||||
1587 | } |
||||||||
1588 | |||||||||
1589 | $occurEventStart = $eventDayOccurStart + $eventHourOccurStart; |
||||||||
1590 | $occurEventEnd = $occurEventStart + $eventHourOccurEnd; |
||||||||
1591 | |||||||||
1592 | if // Event start falls within search period |
||||||||
1593 | ($occurEventStart <= $periodEnd |
||||||||
1594 | && // Event end falls within search period |
||||||||
1595 | $occurEventEnd >= $periodStart |
||||||||
1596 | && // This occur is after start reccur date |
||||||||
1597 | $occurEventStart >= $event['event_recur_start']) { |
||||||||
1598 | $event['event_start'] = $occurEventStart; |
||||||||
1599 | $event['event_end'] = $occurEventEnd; |
||||||||
1600 | |||||||||
1601 | $recuEvents[] = $event; |
||||||||
1602 | } elseif ($occurEventStart > $periodEnd) { |
||||||||
1603 | break; |
||||||||
1604 | } |
||||||||
1605 | |||||||||
1606 | if (13 == ++$month) { |
||||||||
1607 | $month = 1; |
||||||||
1608 | ++$year; |
||||||||
1609 | } |
||||||||
1610 | |||||||||
1611 | ++$nbOccur; |
||||||||
1612 | } |
||||||||
1613 | |||||||||
1614 | break; |
||||||||
1615 | case 'yearly': |
||||||||
1616 | \array_shift($eventOptions); |
||||||||
1617 | $rRuleInterval = $eventOptions[0]; |
||||||||
1618 | if ('' == $rRuleInterval || 0 == $rRuleInterval) { |
||||||||
1619 | $rRuleInterval = 10; |
||||||||
1620 | } |
||||||||
1621 | \array_shift($eventOptions); |
||||||||
1622 | $dayCode = $eventOptions[0]; |
||||||||
1623 | \array_shift($eventOptions); |
||||||||
1624 | |||||||||
1625 | $day = \date('j', $event['event_recur_start']); |
||||||||
1626 | $month = \date('n', $event['event_recur_start']); |
||||||||
1627 | $year = \date('Y', $event['event_recur_start']); |
||||||||
1628 | |||||||||
1629 | $nbOccur = 0; |
||||||||
1630 | |||||||||
1631 | $eventHourOccurStart = $event['event_recur_start'] - \mktime(0, 0, 0, $month, $day, $year); |
||||||||
1632 | $eventHourOccurEnd = $event['event_end'] - $event['event_start']; |
||||||||
1633 | |||||||||
1634 | // If recurring month not specified, make it starting month |
||||||||
1635 | if (!\count($eventOptions)) { |
||||||||
1636 | $eventOptions[] = $month; |
||||||||
1637 | } |
||||||||
1638 | |||||||||
1639 | // Parse all occurence of this event |
||||||||
1640 | while ($nbOccur < $rRuleInterval) { |
||||||||
1641 | $eventDayOccurStart = $this->getOccurTS($month, $year, $dayCode); |
||||||||
1642 | if (!$eventDayOccurStart) { |
||||||||
1643 | $eventDayOccurStart = \mktime(0, 0, 0, $month, $day, $year); |
||||||||
1644 | } |
||||||||
1645 | |||||||||
1646 | $occurEventStart = $eventDayOccurStart + $eventHourOccurStart; |
||||||||
1647 | $occurEventEnd = $eventDayOccurStart + $eventHourOccurEnd; |
||||||||
1648 | |||||||||
1649 | if // Event start falls within search period |
||||||||
1650 | (($occurEventStart <= $periodEnd) |
||||||||
1651 | && // Event end falls within search period |
||||||||
1652 | ($occurEventEnd >= $periodStart) |
||||||||
1653 | && // This week day is selected |
||||||||
1654 | \in_array($month, $eventOptions)) { |
||||||||
1655 | $event['event_start'] = $occurEventStart; |
||||||||
1656 | $event['event_end'] = $occurEventEnd; |
||||||||
1657 | |||||||||
1658 | $recuEvents[] = $event; |
||||||||
1659 | } elseif ($occurEventStart > $periodEnd) { |
||||||||
1660 | break; |
||||||||
1661 | } |
||||||||
1662 | |||||||||
1663 | if (13 == ++$month) { |
||||||||
1664 | $month = 1; |
||||||||
1665 | ++$year; |
||||||||
1666 | ++$nbOccur; |
||||||||
1667 | } |
||||||||
1668 | } |
||||||||
1669 | |||||||||
1670 | break; |
||||||||
1671 | } |
||||||||
1672 | |||||||||
1673 | return $recuEvents; |
||||||||
1674 | } |
||||||||
1675 | |||||||||
1676 | //----------------------------------------------------------------- |
||||||||
1677 | |||||||||
1678 | /** |
||||||||
1679 | * @param $month |
||||||||
1680 | * @param $year |
||||||||
1681 | * @param $dayCode |
||||||||
1682 | * |
||||||||
1683 | * @return int |
||||||||
1684 | */ |
||||||||
1685 | public function getOccurTS($month, $year, $dayCode) |
||||||||
1686 | { |
||||||||
1687 | if (0 === mb_strpos($dayCode, 'MD')) { |
||||||||
1688 | if ('' != mb_substr($dayCode, 2)) { |
||||||||
1689 | return \mktime(0, 0, 0, $month, mb_substr($dayCode, 2), $year); |
||||||||
0 ignored issues
–
show
mb_substr($dayCode, 2) of type string is incompatible with the type integer expected by parameter $day of mktime() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
1690 | } |
||||||||
1691 | |||||||||
1692 | return 0; |
||||||||
1693 | } |
||||||||
1694 | switch ($dayCode) { |
||||||||
1695 | case '1SU': |
||||||||
1696 | |||||||||
1697 | $ts = \mktime(0, 0, 0, $month, 1, $year); |
||||||||
1698 | $dayOfWeek = \date('w', $ts); |
||||||||
1699 | $ts = (0 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1700 | $i = 0; |
||||||||
1701 | while (0 != $dayOfWeek % 7) { |
||||||||
1702 | ++$dayOfWeek; |
||||||||
1703 | ++$i; |
||||||||
1704 | } |
||||||||
1705 | |||||||||
1706 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1707 | break; |
||||||||
1708 | case '1MO': |
||||||||
1709 | |||||||||
1710 | $ts = \mktime(0, 0, 0, $month, 1, $year); |
||||||||
1711 | $dayOfWeek = \date('w', $ts); |
||||||||
1712 | $ts = (1 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1713 | $i = 0; |
||||||||
1714 | while (1 != $dayOfWeek % 7) { |
||||||||
1715 | ++$dayOfWeek; |
||||||||
1716 | ++$i; |
||||||||
1717 | } |
||||||||
1718 | |||||||||
1719 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1720 | break; |
||||||||
1721 | case '1TU': |
||||||||
1722 | |||||||||
1723 | $ts = \mktime(0, 0, 0, $month, 1, $year); |
||||||||
1724 | $dayOfWeek = \date('w', $ts); |
||||||||
1725 | $ts = (2 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1726 | $i = 0; |
||||||||
1727 | while (2 != $dayOfWeek % 7) { |
||||||||
1728 | ++$dayOfWeek; |
||||||||
1729 | ++$i; |
||||||||
1730 | } |
||||||||
1731 | |||||||||
1732 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1733 | break; |
||||||||
1734 | case '1WE': |
||||||||
1735 | |||||||||
1736 | $ts = \mktime(0, 0, 0, $month, 1, $year); |
||||||||
1737 | $dayOfWeek = \date('w', $ts); |
||||||||
1738 | $ts = (3 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1739 | $i = 0; |
||||||||
1740 | while (3 != $dayOfWeek % 7) { |
||||||||
1741 | ++$dayOfWeek; |
||||||||
1742 | ++$i; |
||||||||
1743 | } |
||||||||
1744 | |||||||||
1745 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1746 | break; |
||||||||
1747 | case '1TH': |
||||||||
1748 | |||||||||
1749 | $ts = \mktime(0, 0, 0, $month, 1, $year); |
||||||||
1750 | $dayOfWeek = \date('w', $ts); |
||||||||
1751 | $ts = (4 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1752 | $i = 0; |
||||||||
1753 | while (4 != $dayOfWeek % 7) { |
||||||||
1754 | ++$dayOfWeek; |
||||||||
1755 | ++$i; |
||||||||
1756 | } |
||||||||
1757 | |||||||||
1758 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1759 | break; |
||||||||
1760 | case '1FR': |
||||||||
1761 | |||||||||
1762 | $ts = \mktime(0, 0, 0, $month, 1, $year); |
||||||||
1763 | $dayOfWeek = \date('w', $ts); |
||||||||
1764 | $ts = (5 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1765 | $i = 0; |
||||||||
1766 | while (5 != $dayOfWeek % 7) { |
||||||||
1767 | ++$dayOfWeek; |
||||||||
1768 | ++$i; |
||||||||
1769 | } |
||||||||
1770 | |||||||||
1771 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1772 | break; |
||||||||
1773 | case '1SA': |
||||||||
1774 | |||||||||
1775 | $ts = \mktime(0, 0, 0, $month, 1, $year); |
||||||||
1776 | $dayOfWeek = \date('w', $ts); |
||||||||
1777 | $ts = (6 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1778 | $i = 0; |
||||||||
1779 | while (6 != $dayOfWeek % 7) { |
||||||||
1780 | ++$dayOfWeek; |
||||||||
1781 | ++$i; |
||||||||
1782 | } |
||||||||
1783 | |||||||||
1784 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1785 | break; |
||||||||
1786 | case '2SU': |
||||||||
1787 | |||||||||
1788 | $ts = \mktime(0, 0, 0, $month, 7, $year); |
||||||||
1789 | $dayOfWeek = \date('w', $ts); |
||||||||
1790 | $ts = (0 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1791 | $i = 0; |
||||||||
1792 | while (0 != $dayOfWeek % 7) { |
||||||||
1793 | ++$dayOfWeek; |
||||||||
1794 | ++$i; |
||||||||
1795 | } |
||||||||
1796 | |||||||||
1797 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1798 | break; |
||||||||
1799 | case '2MO': |
||||||||
1800 | |||||||||
1801 | $ts = \mktime(0, 0, 0, $month, 7, $year); |
||||||||
1802 | $dayOfWeek = \date('w', $ts); |
||||||||
1803 | $ts = (1 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1804 | $i = 0; |
||||||||
1805 | while (1 != $dayOfWeek % 7) { |
||||||||
1806 | ++$dayOfWeek; |
||||||||
1807 | ++$i; |
||||||||
1808 | } |
||||||||
1809 | |||||||||
1810 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1811 | break; |
||||||||
1812 | case '2TU': |
||||||||
1813 | |||||||||
1814 | $ts = \mktime(0, 0, 0, $month, 7, $year); |
||||||||
1815 | $dayOfWeek = \date('w', $ts); |
||||||||
1816 | $ts = (2 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1817 | $i = 0; |
||||||||
1818 | while (2 != $dayOfWeek % 7) { |
||||||||
1819 | ++$dayOfWeek; |
||||||||
1820 | ++$i; |
||||||||
1821 | } |
||||||||
1822 | |||||||||
1823 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1824 | break; |
||||||||
1825 | case '2WE': |
||||||||
1826 | |||||||||
1827 | $ts = \mktime(0, 0, 0, $month, 7, $year); |
||||||||
1828 | $dayOfWeek = \date('w', $ts); |
||||||||
1829 | $ts = (3 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1830 | $i = 0; |
||||||||
1831 | while (3 != $dayOfWeek % 7) { |
||||||||
1832 | ++$dayOfWeek; |
||||||||
1833 | ++$i; |
||||||||
1834 | } |
||||||||
1835 | |||||||||
1836 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1837 | break; |
||||||||
1838 | case '2TH': |
||||||||
1839 | |||||||||
1840 | $ts = \mktime(0, 0, 0, $month, 7, $year); |
||||||||
1841 | $dayOfWeek = \date('w', $ts); |
||||||||
1842 | $ts = (4 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1843 | $i = 0; |
||||||||
1844 | while (4 != $dayOfWeek % 7) { |
||||||||
1845 | ++$dayOfWeek; |
||||||||
1846 | ++$i; |
||||||||
1847 | } |
||||||||
1848 | |||||||||
1849 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1850 | break; |
||||||||
1851 | case '2FR': |
||||||||
1852 | |||||||||
1853 | $ts = \mktime(0, 0, 0, $month, 7, $year); |
||||||||
1854 | $dayOfWeek = \date('w', $ts); |
||||||||
1855 | $ts = (5 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1856 | $i = 0; |
||||||||
1857 | while (5 != $dayOfWeek % 7) { |
||||||||
1858 | ++$dayOfWeek; |
||||||||
1859 | ++$i; |
||||||||
1860 | } |
||||||||
1861 | |||||||||
1862 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1863 | break; |
||||||||
1864 | case '2SA': |
||||||||
1865 | |||||||||
1866 | $ts = \mktime(0, 0, 0, $month, 7, $year); |
||||||||
1867 | $dayOfWeek = \date('w', $ts); |
||||||||
1868 | $ts = (6 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1869 | $i = 0; |
||||||||
1870 | while (6 != $dayOfWeek % 7) { |
||||||||
1871 | ++$dayOfWeek; |
||||||||
1872 | ++$i; |
||||||||
1873 | } |
||||||||
1874 | |||||||||
1875 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1876 | break; |
||||||||
1877 | case '3SU': |
||||||||
1878 | |||||||||
1879 | $ts = \mktime(0, 0, 0, $month, 14, $year); |
||||||||
1880 | $dayOfWeek = \date('w', $ts); |
||||||||
1881 | $ts = (0 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1882 | $i = 0; |
||||||||
1883 | while (0 != $dayOfWeek % 7) { |
||||||||
1884 | ++$dayOfWeek; |
||||||||
1885 | ++$i; |
||||||||
1886 | } |
||||||||
1887 | |||||||||
1888 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1889 | break; |
||||||||
1890 | case '3MO': |
||||||||
1891 | |||||||||
1892 | $ts = \mktime(0, 0, 0, $month, 14, $year); |
||||||||
1893 | $dayOfWeek = \date('w', $ts); |
||||||||
1894 | $ts = (1 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1895 | $i = 0; |
||||||||
1896 | while (1 != $dayOfWeek % 7) { |
||||||||
1897 | ++$dayOfWeek; |
||||||||
1898 | ++$i; |
||||||||
1899 | } |
||||||||
1900 | |||||||||
1901 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1902 | break; |
||||||||
1903 | case '3TU': |
||||||||
1904 | |||||||||
1905 | $ts = \mktime(0, 0, 0, $month, 14, $year); |
||||||||
1906 | $dayOfWeek = \date('w', $ts); |
||||||||
1907 | $ts = (2 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1908 | $i = 0; |
||||||||
1909 | while (2 != $dayOfWeek % 7) { |
||||||||
1910 | ++$dayOfWeek; |
||||||||
1911 | ++$i; |
||||||||
1912 | } |
||||||||
1913 | |||||||||
1914 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1915 | break; |
||||||||
1916 | case '3WE': |
||||||||
1917 | |||||||||
1918 | $ts = \mktime(0, 0, 0, $month, 14, $year); |
||||||||
1919 | $dayOfWeek = \date('w', $ts); |
||||||||
1920 | $ts = (3 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1921 | $i = 0; |
||||||||
1922 | while (3 != $dayOfWeek % 7) { |
||||||||
1923 | ++$dayOfWeek; |
||||||||
1924 | ++$i; |
||||||||
1925 | } |
||||||||
1926 | |||||||||
1927 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1928 | break; |
||||||||
1929 | case '3TH': |
||||||||
1930 | |||||||||
1931 | $ts = \mktime(0, 0, 0, $month, 14, $year); |
||||||||
1932 | $dayOfWeek = \date('w', $ts); |
||||||||
1933 | $ts = (4 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1934 | $i = 0; |
||||||||
1935 | while (4 != $dayOfWeek % 7) { |
||||||||
1936 | ++$dayOfWeek; |
||||||||
1937 | ++$i; |
||||||||
1938 | } |
||||||||
1939 | |||||||||
1940 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1941 | break; |
||||||||
1942 | case '3FR': |
||||||||
1943 | |||||||||
1944 | $ts = \mktime(0, 0, 0, $month, 14, $year); |
||||||||
1945 | $dayOfWeek = \date('w', $ts); |
||||||||
1946 | $ts = (5 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1947 | $i = 0; |
||||||||
1948 | while (5 != $dayOfWeek % 7) { |
||||||||
1949 | ++$dayOfWeek; |
||||||||
1950 | ++$i; |
||||||||
1951 | } |
||||||||
1952 | |||||||||
1953 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1954 | break; |
||||||||
1955 | case '3SA': |
||||||||
1956 | |||||||||
1957 | $ts = \mktime(0, 0, 0, $month, 14, $year); |
||||||||
1958 | $dayOfWeek = \date('w', $ts); |
||||||||
1959 | $ts = (6 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1960 | $i = 0; |
||||||||
1961 | while (6 != $dayOfWeek % 7) { |
||||||||
1962 | ++$dayOfWeek; |
||||||||
1963 | ++$i; |
||||||||
1964 | } |
||||||||
1965 | |||||||||
1966 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1967 | break; |
||||||||
1968 | case '4SU': |
||||||||
1969 | |||||||||
1970 | $ts = \mktime(0, 0, 0, $month, 21, $year); |
||||||||
1971 | $dayOfWeek = \date('w', $ts); |
||||||||
1972 | $ts = (0 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1973 | $i = 0; |
||||||||
1974 | while (0 != $dayOfWeek % 7) { |
||||||||
1975 | ++$dayOfWeek; |
||||||||
1976 | ++$i; |
||||||||
1977 | } |
||||||||
1978 | |||||||||
1979 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1980 | break; |
||||||||
1981 | case '4MO': |
||||||||
1982 | |||||||||
1983 | $ts = \mktime(0, 0, 0, $month, 21, $year); |
||||||||
1984 | $dayOfWeek = \date('w', $ts); |
||||||||
1985 | $ts = (1 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1986 | $i = 0; |
||||||||
1987 | while (1 != $dayOfWeek % 7) { |
||||||||
1988 | ++$dayOfWeek; |
||||||||
1989 | ++$i; |
||||||||
1990 | } |
||||||||
1991 | |||||||||
1992 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
1993 | break; |
||||||||
1994 | case '4TU': |
||||||||
1995 | |||||||||
1996 | $ts = \mktime(0, 0, 0, $month, 21, $year); |
||||||||
1997 | $dayOfWeek = \date('w', $ts); |
||||||||
1998 | $ts = (2 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
1999 | $i = 0; |
||||||||
2000 | while (2 != $dayOfWeek % 7) { |
||||||||
2001 | ++$dayOfWeek; |
||||||||
2002 | ++$i; |
||||||||
2003 | } |
||||||||
2004 | |||||||||
2005 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
2006 | break; |
||||||||
2007 | case '4WE': |
||||||||
2008 | |||||||||
2009 | $ts = \mktime(0, 0, 0, $month, 21, $year); |
||||||||
2010 | $dayOfWeek = \date('w', $ts); |
||||||||
2011 | $ts = (3 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
2012 | $i = 0; |
||||||||
2013 | while (3 != $dayOfWeek % 7) { |
||||||||
2014 | ++$dayOfWeek; |
||||||||
2015 | ++$i; |
||||||||
2016 | } |
||||||||
2017 | |||||||||
2018 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
2019 | break; |
||||||||
2020 | case '4TH': |
||||||||
2021 | |||||||||
2022 | $ts = \mktime(0, 0, 0, $month, 21, $year); |
||||||||
2023 | $dayOfWeek = \date('w', $ts); |
||||||||
2024 | $ts = (4 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
2025 | $i = 0; |
||||||||
2026 | while (4 != $dayOfWeek % 7) { |
||||||||
2027 | ++$dayOfWeek; |
||||||||
2028 | ++$i; |
||||||||
2029 | } |
||||||||
2030 | |||||||||
2031 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
2032 | break; |
||||||||
2033 | case '4FR': |
||||||||
2034 | |||||||||
2035 | $ts = \mktime(0, 0, 0, $month, 21, $year); |
||||||||
2036 | $dayOfWeek = \date('w', $ts); |
||||||||
2037 | $ts = (5 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
2038 | $i = 0; |
||||||||
2039 | while (5 != $dayOfWeek % 7) { |
||||||||
2040 | ++$dayOfWeek; |
||||||||
2041 | ++$i; |
||||||||
2042 | } |
||||||||
2043 | |||||||||
2044 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
2045 | break; |
||||||||
2046 | case '4SA': |
||||||||
2047 | |||||||||
2048 | $ts = \mktime(0, 0, 0, $month, 21, $year); |
||||||||
2049 | $dayOfWeek = \date('w', $ts); |
||||||||
2050 | $ts = (6 == \date('w', $ts)) ? $ts + (\_EXTCAL_TS_DAY * 7) : $ts; |
||||||||
2051 | $i = 0; |
||||||||
2052 | while (6 != $dayOfWeek % 7) { |
||||||||
2053 | ++$dayOfWeek; |
||||||||
2054 | ++$i; |
||||||||
2055 | } |
||||||||
2056 | |||||||||
2057 | return $ts + (\_EXTCAL_TS_DAY * $i); |
||||||||
2058 | break; |
||||||||
2059 | case '-1SU': |
||||||||
2060 | |||||||||
2061 | $ts = \mktime(0, 0, 0, $month, \date('t', \mktime(0, 0, 0, $month, 1, $year)), $year); |
||||||||
2062 | $dayOfWeek = \date('w', $ts); |
||||||||
2063 | $i = 0; |
||||||||
2064 | while (0 != $dayOfWeek % 7) { |
||||||||
2065 | ++$dayOfWeek; |
||||||||
2066 | ++$i; |
||||||||
2067 | } |
||||||||
2068 | if (0 == $i) { |
||||||||
2069 | return $ts; |
||||||||
2070 | } |
||||||||
2071 | |||||||||
2072 | return $ts + (\_EXTCAL_TS_DAY * ($i - 7)); |
||||||||
2073 | break; |
||||||||
2074 | case '-1MO': |
||||||||
2075 | |||||||||
2076 | $ts = \mktime(0, 0, 0, $month, \date('t', \mktime(0, 0, 0, $month, 1, $year)), $year); |
||||||||
2077 | $dayOfWeek = \date('w', $ts); |
||||||||
2078 | $i = 0; |
||||||||
2079 | while (1 != $dayOfWeek % 7) { |
||||||||
2080 | ++$dayOfWeek; |
||||||||
2081 | ++$i; |
||||||||
2082 | } |
||||||||
2083 | if (0 == $i) { |
||||||||
2084 | return $ts; |
||||||||
2085 | } |
||||||||
2086 | |||||||||
2087 | return $ts + (\_EXTCAL_TS_DAY * ($i - 7)); |
||||||||
2088 | break; |
||||||||
2089 | case '-1TU': |
||||||||
2090 | |||||||||
2091 | $ts = \mktime(0, 0, 0, $month, \date('t', \mktime(0, 0, 0, $month, 1, $year)), $year); |
||||||||
2092 | $dayOfWeek = \date('w', $ts); |
||||||||
2093 | $i = 0; |
||||||||
2094 | while (2 != $dayOfWeek % 7) { |
||||||||
2095 | ++$dayOfWeek; |
||||||||
2096 | ++$i; |
||||||||
2097 | } |
||||||||
2098 | if (0 == $i) { |
||||||||
2099 | return $ts; |
||||||||
2100 | } |
||||||||
2101 | |||||||||
2102 | return $ts + (\_EXTCAL_TS_DAY * ($i - 7)); |
||||||||
2103 | break; |
||||||||
2104 | case '-1WE': |
||||||||
2105 | |||||||||
2106 | $ts = \mktime(0, 0, 0, $month, \date('t', \mktime(0, 0, 0, $month, 1, $year)), $year); |
||||||||
2107 | $dayOfWeek = \date('w', $ts); |
||||||||
2108 | $i = 0; |
||||||||
2109 | while (3 != $dayOfWeek % 7) { |
||||||||
2110 | ++$dayOfWeek; |
||||||||
2111 | ++$i; |
||||||||
2112 | } |
||||||||
2113 | if (0 == $i) { |
||||||||
2114 | return $ts; |
||||||||
2115 | } |
||||||||
2116 | |||||||||
2117 | return $ts + (\_EXTCAL_TS_DAY * ($i - 7)); |
||||||||
2118 | break; |
||||||||
2119 | case '-1TH': |
||||||||
2120 | |||||||||
2121 | $ts = \mktime(0, 0, 0, $month, \date('t', \mktime(0, 0, 0, $month, 1, $year)), $year); |
||||||||
2122 | $dayOfWeek = \date('w', $ts); |
||||||||
2123 | $i = 0; |
||||||||
2124 | while (4 != $dayOfWeek % 7) { |
||||||||
2125 | ++$dayOfWeek; |
||||||||
2126 | ++$i; |
||||||||
2127 | } |
||||||||
2128 | if (0 == $i) { |
||||||||
2129 | return $ts; |
||||||||
2130 | } |
||||||||
2131 | |||||||||
2132 | return $ts + (\_EXTCAL_TS_DAY * ($i - 7)); |
||||||||
2133 | break; |
||||||||
2134 | case '-1FR': |
||||||||
2135 | |||||||||
2136 | $ts = \mktime(0, 0, 0, $month, \date('t', \mktime(0, 0, 0, $month, 1, $year)), $year); |
||||||||
2137 | $dayOfWeek = \date('w', $ts); |
||||||||
2138 | $i = 0; |
||||||||
2139 | while (5 != $dayOfWeek % 7) { |
||||||||
2140 | ++$dayOfWeek; |
||||||||
2141 | ++$i; |
||||||||
2142 | } |
||||||||
2143 | if (0 == $i) { |
||||||||
2144 | return $ts; |
||||||||
2145 | } |
||||||||
2146 | |||||||||
2147 | return $ts + (\_EXTCAL_TS_DAY * ($i - 7)); |
||||||||
2148 | break; |
||||||||
2149 | case '-1SA': |
||||||||
2150 | |||||||||
2151 | $ts = \mktime(0, 0, 0, $month, \date('t', \mktime(0, 0, 0, $month, 1, $year)), $year); |
||||||||
2152 | $dayOfWeek = \date('w', $ts); |
||||||||
2153 | $i = 0; |
||||||||
2154 | while (6 != $dayOfWeek % 7) { |
||||||||
2155 | ++$dayOfWeek; |
||||||||
2156 | ++$i; |
||||||||
2157 | } |
||||||||
2158 | if (0 == $i) { |
||||||||
2159 | return $ts; |
||||||||
2160 | } |
||||||||
2161 | |||||||||
2162 | return $ts + (\_EXTCAL_TS_DAY * ($i - 7)); |
||||||||
2163 | break; |
||||||||
2164 | default: |
||||||||
2165 | return 0; |
||||||||
2166 | break; |
||||||||
2167 | } |
||||||||
2168 | } |
||||||||
2169 | |||||||||
2170 | /************************************************************************* |
||||||||
2171 | * |
||||||||
2172 | ************************************************************************ |
||||||||
2173 | * @param $year |
||||||||
2174 | * @param $month |
||||||||
2175 | * @param $day |
||||||||
2176 | * @param $cat |
||||||||
2177 | * @param $searchExp |
||||||||
2178 | * @param $andor |
||||||||
2179 | * @param $orderBy |
||||||||
2180 | * @return array |
||||||||
2181 | */ |
||||||||
2182 | public function getSearchEvent2($year, $month, $day, $cat, $searchExp, $andor, $orderBy) |
||||||||
2183 | { |
||||||||
2184 | global $xoopsDB, $xoopsUser; |
||||||||
2185 | |||||||||
2186 | if (isset($xoopsUser)) { |
||||||||
2187 | $userId = $xoopsUser->getVar('uid'); |
||||||||
2188 | $result = $this->getSearchEvents($year, $month, $day, $cat, $searchExp, $andor, $orderBy, 0, 0, $userId, $xoopsUser); |
||||||||
2189 | } else { |
||||||||
2190 | $result = $this->getSearchEvents($year, $month, $day, $cat, $searchExp, $andor, $orderBy, 0, 0); |
||||||||
2191 | } |
||||||||
2192 | |||||||||
2193 | $ret = []; |
||||||||
2194 | if ($result) { |
||||||||
2195 | while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
||||||||
2196 | $myrow['cat']['cat_name'] = $myrow['cat_name']; |
||||||||
2197 | $myrow['cat']['cat_color'] = $myrow['cat_color']; |
||||||||
2198 | $myrow['cat']['cat_light_color'] = Utility::getLighterColor($myrow['cat']['cat_color'], \_EXTCAL_INFOBULLE_RGB_MIN, \_EXTCAL_INFOBULLE_RGB_MAX); |
||||||||
2199 | if ('' == $myrow['event_icone']) { |
||||||||
2200 | $myrow['event_icone'] = $myrow['cat']['cat_icone']; |
||||||||
2201 | } |
||||||||
2202 | $ret[] = $myrow; |
||||||||
2203 | } |
||||||||
2204 | } |
||||||||
2205 | return $ret; |
||||||||
2206 | } |
||||||||
2207 | |||||||||
2208 | //----------------------------------------------------------- |
||||||||
2209 | |||||||||
2210 | /** |
||||||||
2211 | * @param int $year |
||||||||
2212 | * @param int $month |
||||||||
2213 | * @param int $day |
||||||||
2214 | * @param int $cat |
||||||||
2215 | * @param array|null $queryarray |
||||||||
2216 | * @param bool|null $andor |
||||||||
2217 | * @param string|null $orderBy |
||||||||
2218 | * @param int $limit |
||||||||
2219 | * @param int $offset |
||||||||
2220 | * @param int $userId |
||||||||
2221 | * @param string $user |
||||||||
2222 | * |
||||||||
2223 | * @return mixed |
||||||||
2224 | */ |
||||||||
2225 | public function getSearchEvents( |
||||||||
2226 | $year = 0, |
||||||||
2227 | $month = 0, |
||||||||
2228 | $day = 0, |
||||||||
2229 | $cat = 0, |
||||||||
2230 | $queryarray = null, |
||||||||
2231 | $andor = null, |
||||||||
2232 | $orderBy = null, |
||||||||
2233 | $limit = 0, |
||||||||
2234 | $offset = 0, |
||||||||
2235 | $userId = 0, |
||||||||
2236 | $user = '' |
||||||||
2237 | ) { |
||||||||
2238 | global $xoopsDB; |
||||||||
2239 | |||||||||
2240 | //echo "<hr>{$andor}-{$limit}-{$offset}-{$userId}-{$user}<br>{$criteresPlus}"; |
||||||||
2241 | $tEvent = $xoopsDB->prefix('extcal_event') . ' AS te'; |
||||||||
2242 | $tCat = $xoopsDB->prefix('extcal_cat') . ' AS tc'; |
||||||||
2243 | |||||||||
2244 | $sql = 'SELECT te.*, tc.cat_name , tc.cat_color, ' . 'year(FROM_UNIXTIME(event_start)) AS year,' . 'month(FROM_UNIXTIME(event_start)) AS month,' . 'day(FROM_UNIXTIME(event_start)) AS day' . " FROM {$tEvent}, {$tCat}"; |
||||||||
2245 | //--------------------------------------------------- |
||||||||
2246 | $tw = []; |
||||||||
2247 | $tw[] = 'te.cat_id = tc.cat_id'; |
||||||||
2248 | $tw[] = 'event_approved = 1'; |
||||||||
2249 | |||||||||
2250 | $authorizedAccessCats = $this->extcalPerm->getAuthorizedCat($user, 'extcal_cat_view'); |
||||||||
2251 | $inCat = 'te.cat_id IN (0)'; |
||||||||
2252 | if (\count($authorizedAccessCats) > 0) { |
||||||||
0 ignored issues
–
show
$authorizedAccessCats of type boolean is incompatible with the type Countable|array expected by parameter $value of count() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
2253 | $inCat = 'te.cat_id IN (' . \implode(',', $authorizedAccessCats) . ')'; |
||||||||
0 ignored issues
–
show
$authorizedAccessCats of type boolean is incompatible with the type array expected by parameter $pieces of implode() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
2254 | } |
||||||||
2255 | //echo $tw[count($tw)-1]; |
||||||||
2256 | |||||||||
2257 | if (0 != $userId) { |
||||||||
2258 | $tw[] .= "({$inCat} OR event_submitter = {$userId} )"; |
||||||||
2259 | } else { |
||||||||
2260 | $tw[] = $inCat; |
||||||||
2261 | } |
||||||||
2262 | //-------------------------------------------------------- |
||||||||
2263 | if ($cat > 0) { |
||||||||
2264 | $tw[] .= "te.cat_id = {$cat}"; |
||||||||
2265 | } |
||||||||
2266 | if ($year > 0) { |
||||||||
2267 | $tw[] .= "year(FROM_UNIXTIME(event_start)) = {$year}"; |
||||||||
2268 | } |
||||||||
2269 | if ($month > 0) { |
||||||||
2270 | $tw[] .= "month(FROM_UNIXTIME(event_start)) = {$month}"; |
||||||||
2271 | } |
||||||||
2272 | if ($day > 0) { |
||||||||
2273 | $tw[] .= "day(FROM_UNIXTIME(event_start)) = {$day}"; |
||||||||
2274 | } |
||||||||
2275 | |||||||||
2276 | //echoArray($queryarray,false); |
||||||||
2277 | if (!\is_array($queryarray)) { |
||||||||
2278 | $queryarray = (('' != $queryarray) ? \explode(' ', $queryarray) : ''); |
||||||||
0 ignored issues
–
show
$queryarray of type null is incompatible with the type string expected by parameter $string of explode() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
2279 | } |
||||||||
2280 | |||||||||
2281 | if (\is_array($queryarray)) { |
||||||||
2282 | $tFields = [ |
||||||||
2283 | 'te.event_title', |
||||||||
2284 | 'te.event_desc', |
||||||||
2285 | 'te.event_contact', |
||||||||
2286 | 'te.event_address', |
||||||||
2287 | 'tc.cat_name', |
||||||||
2288 | ]; |
||||||||
2289 | $t = []; |
||||||||
2290 | foreach ($queryarray as $i => $iValue) { |
||||||||
2291 | $t1[] = " %1\$s LIKE '#{$queryarray[$i]}#' "; |
||||||||
2292 | } |
||||||||
2293 | |||||||||
2294 | $flt = '(' . \implode(" {$andor} ", $t1) . ')'; |
||||||||
2295 | |||||||||
2296 | $t = []; |
||||||||
2297 | foreach ($tFields as $h => $hValue) { |
||||||||
2298 | $t[] = \sprintf($flt, $tFields[$h]); |
||||||||
2299 | } |
||||||||
2300 | |||||||||
2301 | $filtre = \implode(' OR ', $t); |
||||||||
2302 | $filtre = \str_replace('#', '%', $filtre); |
||||||||
2303 | $tw[] = '(' . $filtre . ')'; |
||||||||
2304 | } |
||||||||
2305 | |||||||||
2306 | $sql .= ' WHERE ' . \implode(' AND ', $tw); |
||||||||
2307 | //------------------------------------------------------------ |
||||||||
2308 | if (\count($orderBy) > 0) { |
||||||||
0 ignored issues
–
show
$orderBy of type null|string is incompatible with the type Countable|array expected by parameter $value of count() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
2309 | $t = []; |
||||||||
2310 | foreach ($orderBy as $hValue) { |
||||||||
0 ignored issues
–
show
|
|||||||||
2311 | if ('' != $hValue) { |
||||||||
2312 | $t[] = $hValue; |
||||||||
2313 | } |
||||||||
2314 | } |
||||||||
2315 | if (\count($t) > 0) { |
||||||||
2316 | $sql .= ' ORDER BY ' . \implode(',', $t); |
||||||||
2317 | } |
||||||||
2318 | } |
||||||||
2319 | |||||||||
2320 | //---------------------------------------------------------------- |
||||||||
2321 | |||||||||
2322 | $result = $xoopsDB->query($sql, $limit, $offset); |
||||||||
2323 | |||||||||
2324 | // echo "<hr>{$sql}<hr>"; |
||||||||
2325 | return $result; |
||||||||
2326 | } |
||||||||
2327 | |||||||||
2328 | //----------------------------------------------------------- |
||||||||
2329 | |||||||||
2330 | /** |
||||||||
2331 | * @param $queryarray |
||||||||
2332 | * @param $andor |
||||||||
2333 | * @param $limit |
||||||||
2334 | * @param $offset |
||||||||
2335 | * @param $userId |
||||||||
2336 | * @param $user |
||||||||
2337 | * |
||||||||
2338 | * @return mixed |
||||||||
2339 | */ |
||||||||
2340 | public function getSearchEvent($queryarray, $andor, $limit, $offset, $userId, $user) |
||||||||
2341 | { |
||||||||
2342 | global $xoopsDB; |
||||||||
2343 | |||||||||
2344 | $result = $this->getSearchEvents(0, 0, 0, 0, $queryarray, $andor, ['event_id DESC']); |
||||||||
0 ignored issues
–
show
array('event_id DESC') of type array<integer,string> is incompatible with the type null|string expected by parameter $orderBy of XoopsModules\Extcal\Even...dler::getSearchEvents() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
2345 | |||||||||
2346 | $i = 0; |
||||||||
2347 | while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
||||||||
2348 | $ret[$i]['image'] = 'assets/images/icons/extcal.gif'; |
||||||||
2349 | $ret[$i]['link'] = 'event.php?event=' . $myrow['event_id']; |
||||||||
2350 | $ret[$i]['title'] = $myrow['event_title']; |
||||||||
2351 | $ret[$i]['time'] = $myrow['event_submitdate']; |
||||||||
2352 | $ret[$i]['uid'] = $myrow['event_submitter']; |
||||||||
2353 | ++$i; |
||||||||
2354 | } |
||||||||
2355 | |||||||||
2356 | return $ret; |
||||||||
2357 | } |
||||||||
2358 | |||||||||
2359 | /** |
||||||||
2360 | * @param $queryarray |
||||||||
2361 | * @param $andor |
||||||||
2362 | * @param $limit |
||||||||
2363 | * @param $offset |
||||||||
2364 | * @param $userId |
||||||||
2365 | * @param $user |
||||||||
2366 | * @param string $criteresPlus |
||||||||
2367 | * @param bool $xoopsSearch |
||||||||
2368 | * |
||||||||
2369 | * @return array |
||||||||
2370 | */ |
||||||||
2371 | public function getSearchEvent3( |
||||||||
2372 | $queryarray, |
||||||||
2373 | $andor, |
||||||||
2374 | $limit, |
||||||||
2375 | $offset, |
||||||||
2376 | $userId, |
||||||||
2377 | $user, |
||||||||
2378 | $criteresPlus = '', |
||||||||
2379 | $xoopsSearch = true |
||||||||
2380 | ) { |
||||||||
2381 | global $xoopsDB; |
||||||||
2382 | //echo "<hr>{$andor}-{$limit}-{$offset}-{$userId}-{$user}<br>{$criteresPlus}"; |
||||||||
2383 | |||||||||
2384 | // if ($cols == '') { |
||||||||
2385 | // $cols = 'event_id, event_title, event_submitter, event_submitdate'; |
||||||||
2386 | // } |
||||||||
2387 | $tEvent = $xoopsDB->prefix('extcal_event'); |
||||||||
2388 | $tCat = $xoopsDB->prefix('extcal_cat'); |
||||||||
2389 | $sql = "SELECT {$tEvent}.*, {$tCat}.cat_name AS categorie, {$tCat}.cat_color " . " FROM {$tEvent}, {$tCat}" . " WHERE {$tEvent}.cat_id = {$tCat}.cat_id AND event_approved = '1'"; |
||||||||
2390 | |||||||||
2391 | $authorizedAccessCats = $this->extcalPerm->getAuthorizedCat($user, 'extcal_cat_view'); |
||||||||
2392 | $count = \count($authorizedAccessCats); |
||||||||
0 ignored issues
–
show
$authorizedAccessCats of type boolean is incompatible with the type Countable|array expected by parameter $value of count() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
2393 | if ($count > 0) { |
||||||||
2394 | $in = '(' . $authorizedAccessCats[0]; |
||||||||
2395 | \array_shift($authorizedAccessCats); |
||||||||
0 ignored issues
–
show
$authorizedAccessCats of type boolean is incompatible with the type array expected by parameter $array of array_shift() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
2396 | foreach ($authorizedAccessCats as $authorizedAccessCat) { |
||||||||
2397 | $in .= ',' . $authorizedAccessCat; |
||||||||
2398 | } |
||||||||
2399 | $in .= ')'; |
||||||||
2400 | } else { |
||||||||
2401 | $in = '(0)'; |
||||||||
2402 | } |
||||||||
2403 | $sql .= " AND {$tEvent}.cat_id IN " . $in . ''; |
||||||||
2404 | if (0 != $userId) { |
||||||||
2405 | $sql .= " AND event_submitter = '" . $userId . "'"; |
||||||||
2406 | } |
||||||||
2407 | |||||||||
2408 | //echoArray($queryarray,false); |
||||||||
2409 | if (\is_array($queryarray)) { |
||||||||
2410 | /* |
||||||||
2411 | $sql .= " AND ((event_title LIKE '%$queryarray[0]%' OR event_desc LIKE '%$queryarray[0]%' OR event_contact LIKE '%$queryarray[0]%' OR event_address LIKE '%$queryarray[0]%')"; |
||||||||
2412 | for ($i = 1; $i < $count; ++$i) { |
||||||||
2413 | $sql .= " $andor "; |
||||||||
2414 | $sql .= "(event_title LIKE '%$queryarray[0]%' OR event_desc LIKE '%$queryarray[0]%' OR event_contact LIKE '%$queryarray[0]%' OR event_address LIKE '%$queryarray[0]%')"; |
||||||||
2415 | } |
||||||||
2416 | $sql .= ") "; |
||||||||
2417 | */ |
||||||||
2418 | |||||||||
2419 | $tFields = ['event_title', 'event_desc', 'event_contact', 'event_address', 'cat_name']; |
||||||||
2420 | $t = []; |
||||||||
2421 | foreach ($queryarray as $i => $iValue) { |
||||||||
2422 | $t1[] = " %1\$s LIKE '#{$queryarray[$i]}#' "; |
||||||||
2423 | } |
||||||||
2424 | |||||||||
2425 | $flt = '(' . \implode(" {$andor} ", $t1) . ')'; |
||||||||
2426 | |||||||||
2427 | $t = []; |
||||||||
2428 | foreach ($tFields as $h => $hValue) { |
||||||||
2429 | $t[] = \sprintf($flt, $tFields[$h]); |
||||||||
2430 | } |
||||||||
2431 | |||||||||
2432 | $filtre = \implode(' OR ', $t); |
||||||||
2433 | $filtre = \str_replace('#', '%', $filtre); |
||||||||
2434 | $sql .= " AND ($filtre)"; |
||||||||
2435 | } |
||||||||
2436 | |||||||||
2437 | if ('' != $criteresPlus) { |
||||||||
2438 | $sql .= ' AND ' . $criteresPlus; |
||||||||
2439 | } |
||||||||
2440 | $sql .= ' ORDER BY event_id DESC'; |
||||||||
2441 | |||||||||
2442 | $result = $xoopsDB->query($sql, $limit, $offset); |
||||||||
2443 | $ret = []; |
||||||||
2444 | $i = 0; |
||||||||
2445 | if ($xoopsSearch) { |
||||||||
2446 | while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
||||||||
2447 | $ret[$i]['image'] = 'assets/images/icons/extcal.gif'; |
||||||||
2448 | $ret[$i]['link'] = 'event.php?event=' . $myrow['event_id']; |
||||||||
2449 | $ret[$i]['title'] = $myrow['event_title']; |
||||||||
2450 | $ret[$i]['time'] = $myrow['event_submitdate']; |
||||||||
2451 | $ret[$i]['uid'] = $myrow['event_submitter']; |
||||||||
2452 | ++$i; |
||||||||
2453 | } |
||||||||
2454 | } else { |
||||||||
2455 | while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
||||||||
2456 | $myrow['cat']['cat_name'] = $myrow['cat_name']; |
||||||||
2457 | $myrow['cat']['cat_color'] = $myrow['cat_color']; |
||||||||
2458 | $ret[] = $myrow; |
||||||||
2459 | ++$i; |
||||||||
2460 | } |
||||||||
2461 | } |
||||||||
2462 | |||||||||
2463 | return $ret; |
||||||||
2464 | } |
||||||||
2465 | |||||||||
2466 | /** |
||||||||
2467 | * @param $event |
||||||||
2468 | * @param $eventsArray |
||||||||
2469 | * @param $startPeriod |
||||||||
2470 | * @param $endPeriod |
||||||||
2471 | */ |
||||||||
2472 | public function addEventToCalArray(&$event, &$eventsArray, $startPeriod, $endPeriod) |
||||||||
2473 | { |
||||||||
2474 | global $timeHandler, $xoopsUser, $month, $year; |
||||||||
2475 | |||||||||
2476 | // Calculating the start and the end of the event |
||||||||
2477 | $startEvent = $event['event_start']; |
||||||||
2478 | $endEvent = $event['event_end']; |
||||||||
2479 | |||||||||
2480 | // This event start before this month and finish after |
||||||||
2481 | if ($startEvent < $startPeriod && $endEvent > $endPeriod) { |
||||||||
2482 | $endFor = \date('t', \mktime(0, 0, 0, $month, 1, $year)); |
||||||||
2483 | for ($i = 1; $i <= $endFor; ++$i) { |
||||||||
2484 | $event['status'] = 'middle'; |
||||||||
2485 | $eventsArray[$i][] = $event; |
||||||||
2486 | } |
||||||||
2487 | // This event start before this month and finish during |
||||||||
2488 | } else { |
||||||||
2489 | if ($startEvent < $startPeriod) { |
||||||||
2490 | $endFor = \date('j', $endEvent); |
||||||||
2491 | for ($i = 1; $i <= $endFor; ++$i) { |
||||||||
2492 | $event['status'] = ($i != $endFor) ? 'middle' : 'end'; |
||||||||
2493 | $eventsArray[$i][] = $event; |
||||||||
2494 | } |
||||||||
2495 | // This event start during this month and finish after |
||||||||
2496 | } else { |
||||||||
2497 | if ($endEvent > $endPeriod) { |
||||||||
2498 | $startFor = \date('j', $startEvent); |
||||||||
2499 | $endFor = \date('t', \mktime(0, 0, 0, $month, 1, $year)); |
||||||||
2500 | for ($i = $startFor; $i <= $endFor; ++$i) { |
||||||||
2501 | $event['status'] = ($i == $startFor) ? 'start' : 'middle'; |
||||||||
2502 | $eventsArray[$i][] = $event; |
||||||||
2503 | } |
||||||||
2504 | // This event start and finish during this month |
||||||||
2505 | } else { |
||||||||
2506 | $startFor = \date('j', $startEvent); |
||||||||
2507 | $endFor = \date('j', $endEvent); |
||||||||
2508 | for ($i = $startFor; $i <= $endFor; ++$i) { |
||||||||
2509 | if ($startFor == $endFor) { |
||||||||
2510 | $event['status'] = 'single'; |
||||||||
2511 | } else { |
||||||||
2512 | if ($i == $startFor) { |
||||||||
2513 | $event['status'] = 'start'; |
||||||||
2514 | } else { |
||||||||
2515 | if ($i == $endFor) { |
||||||||
2516 | $event['status'] = 'end'; |
||||||||
2517 | } else { |
||||||||
2518 | $event['status'] = 'middle'; |
||||||||
2519 | } |
||||||||
2520 | } |
||||||||
2521 | } |
||||||||
2522 | $eventsArray[$i][] = $event; |
||||||||
2523 | } |
||||||||
2524 | } |
||||||||
2525 | } |
||||||||
2526 | } |
||||||||
2527 | } |
||||||||
2528 | //------------------------------------------------- |
||||||||
2529 | } // -------- Fin e la classe --------------------- |
||||||||
2530 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: