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.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | //------------------------------------------------------------------------- |
||
3 | // OVIDENTIA http://www.ovidentia.org |
||
4 | // Ovidentia is free software; you can redistribute it and/or modify |
||
5 | // it under the terms of the GNU General Public License as published by |
||
6 | // the Free Software Foundation; either version 2, or (at your option) |
||
7 | // any later version. |
||
8 | // |
||
9 | // This program is distributed in the hope that it will be useful, but |
||
10 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
12 | // See the GNU General Public License for more details. |
||
13 | // |
||
14 | // You should have received a copy of the GNU General Public License |
||
15 | // along with this program; if not, write to the Free Software |
||
16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
||
17 | // USA. |
||
18 | //------------------------------------------------------------------------- |
||
19 | /** |
||
20 | * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) |
||
21 | * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr}) |
||
22 | */ |
||
23 | |||
24 | include_once dirname(__FILE__).'/functions.php'; |
||
25 | |||
26 | |||
27 | function absences_onUserDeleted(bab_eventUserDeleted $event) { |
||
28 | |||
29 | require_once dirname(__FILE__).'/utilit/agent.class.php'; |
||
30 | |||
31 | $agent = absences_Agent::getFromIdUser($event->id_user); |
||
32 | $agent->delete(); |
||
33 | } |
||
34 | |||
35 | |||
36 | /** |
||
37 | * before sitemap creation |
||
38 | * registered on this event to add more nodes to core sitemap |
||
39 | * |
||
40 | * @param bab_eventBeforeSiteMapCreated $event |
||
41 | */ |
||
42 | function absences_onBeforeSiteMapCreated(bab_eventBeforeSiteMapCreated $event) { |
||
43 | |||
44 | |||
45 | require_once dirname(__FILE__).'/utilit/agent.class.php'; |
||
46 | |||
47 | $addon = bab_getAddonInfosInstance('absences'); |
||
48 | bab_functionality::includeOriginal('Icons'); |
||
0 ignored issues
–
show
|
|||
49 | |||
50 | if (bab_isUserLogged()) |
||
51 | { |
||
52 | $agent = absences_Agent::getCurrentUser(); |
||
53 | } |
||
54 | |||
55 | // add node to access sitemap editor |
||
56 | |||
57 | $delegations = bab_getUserSitemapDelegations(); |
||
58 | |||
59 | |||
60 | foreach( $delegations as $key => $deleg ) { |
||
61 | |||
62 | if (bab_isUserAdministrator()) |
||
63 | { |
||
64 | |||
65 | $position = array('root', $key, 'babAdmin', 'babAdminSection'); |
||
66 | |||
67 | $item = $event->createItem('absencesAdmin'); |
||
68 | |||
69 | $item->setLabel(absences_translate('Vacations')); |
||
70 | $item->setDescription(absences_translate('Vacations management')); |
||
71 | $item->setLink($addon->getUrl().'admvacs'); |
||
72 | $item->addIconClassname(Func_Icons::APPS_VACATIONS); |
||
73 | $item->setPosition($position); |
||
74 | |||
75 | $event->addFunction($item); |
||
76 | |||
77 | } |
||
78 | |||
79 | |||
80 | if (isset($agent) && ($agent->isInPersonnel() || $agent->isManager() || $agent->isEntityManager())) |
||
81 | { |
||
82 | |||
83 | $position = array('root', $key, 'babUser', 'babUserSection'); |
||
84 | |||
85 | $item = $event->createItem('absencesUser'); |
||
86 | |||
87 | $item->setLabel(absences_translate('Vacations')); |
||
88 | $item->setDescription(absences_translate('Vacations management')); |
||
89 | $item->setLink($addon->getUrl().'vacuser'); |
||
90 | $item->addIconClassname(Func_Icons::APPS_VACATIONS); |
||
91 | $item->setPosition($position); |
||
92 | |||
93 | $event->addFunction($item); |
||
94 | |||
95 | } |
||
96 | } |
||
97 | } |
||
98 | |||
99 | |||
100 | |||
101 | function absences_onUserModified(bab_eventUserModified $event) |
||
102 | { |
||
103 | |||
104 | } |
||
105 | |||
106 | |||
107 | |||
108 | |||
109 | function absences_onBeforeWaitingItemsDisplayed(bab_eventBeforeWaitingItemsDisplayed $event) |
||
110 | { |
||
111 | |||
112 | include_once $GLOBALS['babInstallPath']."utilit/wfincl.php"; |
||
113 | include_once dirname(__FILE__)."/utilit/vacincl.php"; |
||
114 | |||
115 | global $babDB; |
||
116 | |||
117 | $inst = bab_getWaitingIdSAInstance(bab_getUserId()); |
||
118 | |||
119 | if (!$inst) |
||
0 ignored issues
–
show
The expression
$inst of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
120 | { |
||
121 | return; |
||
122 | } |
||
123 | |||
124 | |||
125 | absences_listWaitingEntries($event, $inst); |
||
126 | absences_listWaitingWorkperiod($event, $inst); |
||
127 | absences_listWaitingDeposit($event, $inst); |
||
128 | } |
||
129 | |||
130 | |||
131 | |||
132 | |||
133 | |||
134 | function absences_onConfirmMultipleWaitingItems(bab_eventConfirmMultipleWaitingItems $event) |
||
135 | { |
||
136 | require_once dirname(__FILE__).'/utilit/entry.class.php'; |
||
137 | require_once dirname(__FILE__).'/utilit/workperiod_recover_request.class.php'; |
||
138 | require_once dirname(__FILE__).'/utilit/cet_deposit_request.class.php'; |
||
139 | require_once dirname(__FILE__).'/utilit/request.notify.php'; |
||
140 | require_once dirname(__FILE__).'/utilit/vacincl.php'; |
||
141 | |||
142 | $entries = $event->getItems('absences_listWaitingEntries'); |
||
143 | foreach($entries as $id_entry) |
||
144 | { |
||
145 | $entry = absences_Entry::getById($id_entry); |
||
146 | $entry->approbationNext(true, ''); |
||
147 | $entry->applyDynamicRight(); |
||
148 | $entry->notifyOwner(); |
||
149 | } |
||
150 | |||
151 | $workperiods = $event->getItems('absences_listWaitingWorkperiod'); |
||
152 | foreach($workperiods as $id_workperiod) |
||
153 | { |
||
154 | $workperiod = absences_WorkperiodRecoverRequest::getById($id_workperiod); |
||
155 | $workperiod->approbationNext(true, ''); |
||
156 | $workperiod->notifyOwner(); |
||
157 | } |
||
158 | |||
159 | $deposits = $event->getItems('absences_listWaitingDeposit'); |
||
160 | foreach($deposits as $id_deposit) |
||
161 | { |
||
162 | $deposit = absences_CetDepositRequest::getById($id_deposit); |
||
163 | $deposit->approbationNext(true, ''); |
||
164 | $deposit->notifyOwner(); |
||
165 | } |
||
166 | |||
167 | |||
168 | $defer = (bool) absences_getVacationOption('approb_email_defer'); |
||
169 | if (!$defer) |
||
170 | { |
||
171 | |||
172 | absences_notifyRequestApprovers(); |
||
173 | } |
||
174 | } |
||
175 | |||
176 | |||
177 | |||
178 | |||
179 | |||
180 | function absences_listWaitingEntries(bab_eventBeforeWaitingItemsDisplayed $event, Array $inst) |
||
181 | { |
||
182 | global $babDB; |
||
183 | $res = $babDB->db_query("select e.*, GROUP_CONCAT(DISTINCT t.name ORDER BY t.name ASC SEPARATOR ', ') types from ".ABSENCES_ENTRIES_TBL." e |
||
184 | LEFT JOIN absences_entries_elem ee ON ee.id_entry=e.id |
||
185 | LEFT JOIN absences_rights r ON r.id=ee.id_right |
||
186 | LEFT JOIN absences_types t ON t.id=r.id_type |
||
187 | |||
188 | where idfai IN (".$babDB->quote($inst).") GROUP BY e.id ORDER BY date_begin ASC"); |
||
189 | |||
190 | if (0 === $babDB->db_num_rows($res)) |
||
191 | { |
||
192 | return; |
||
193 | } |
||
194 | |||
195 | if ($event instanceof bab_eventWaitingItemsCount) |
||
196 | { |
||
197 | $event->addItemCount(absences_translate("Vacations requests waiting to be validated"), $babDB->db_num_rows($res)); |
||
198 | return; |
||
199 | } |
||
200 | |||
201 | $arr = array(); |
||
202 | |||
203 | while ($row = $babDB->db_fetch_assoc($res)) |
||
204 | { |
||
205 | $quantity = absences_vacEntryQuantity($row['id']); |
||
206 | $period = absences_DateTimePeriod($row['date_begin'], $row['date_end']); |
||
207 | $description = bab_toHtml(sprintf("%s (%s)\n%s", $quantity, $row['types'], $period), BAB_HTML_ALL ^ BAB_HTML_P); |
||
208 | |||
209 | View Code Duplication | if ($row['firstconfirm']) { |
|
210 | $description .= '<br /><img src="'.$GLOBALS['babInstallPath'].'skins/ovidentia/images/Puces/edit.png" align="absmiddle" /> |
||
211 | <span style="color:red">'.bab_toHtml(absences_translate('Modification of an allready confirmed request')).'</span>'; |
||
212 | } |
||
213 | |||
214 | View Code Duplication | if ($row['todelete']) { |
|
215 | $description .= '<br /><img src="'.$GLOBALS['babInstallPath'].'skins/ovidentia/images/Puces/del.gif" align="absmiddle" /> |
||
216 | <span style="color:red">'.bab_toHtml(absences_translate('Deletion request')).'</span>'; |
||
217 | } |
||
218 | |||
219 | if (!empty($row['comment'])) |
||
220 | { |
||
221 | $description .='<br /><br />'; |
||
222 | $description .=sprintf('%s : <em>%s</em>', bab_toHtml(absences_translate('Applicant comment')), bab_toHtml($row['comment'])); |
||
223 | } |
||
224 | |||
225 | $l = array( |
||
226 | 'text' => bab_getUserName($row['id_user']), |
||
227 | 'description' => $description, |
||
228 | 'url' => absences_addon()->getUrl()."approb&idx=confvac&idvac=".$row['id'], |
||
229 | 'popup' => 1, |
||
230 | 'idschi' => $row['idfai'], |
||
231 | 'id' => $row['id'] |
||
232 | ); |
||
233 | |||
234 | |||
235 | $arr[] = $l; |
||
236 | } |
||
237 | |||
238 | |||
239 | if ($arr) { |
||
0 ignored issues
–
show
The expression
$arr of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
240 | $event->addObject(absences_translate("Vacations requests waiting to be validated"), $arr, __FUNCTION__); |
||
241 | } |
||
242 | |||
243 | } |
||
244 | |||
245 | |||
246 | |||
247 | |||
248 | function absences_listWaitingWorkperiod(bab_eventBeforeWaitingItemsDisplayed $event, Array $inst) |
||
249 | { |
||
250 | global $babDB; |
||
251 | |||
252 | $res = $babDB->db_query("select r.*, t.name type from |
||
253 | absences_workperiod_recover_request r |
||
254 | LEFT JOIN absences_workperiod_type t ON t.id=r.id_type |
||
255 | where r.idfai IN (".$babDB->quote($inst).") order by r.date_begin asc"); |
||
256 | |||
257 | if (0 === $babDB->db_num_rows($res)) |
||
258 | { |
||
259 | return; |
||
260 | } |
||
261 | |||
262 | |||
263 | if ($event instanceof bab_eventWaitingItemsCount) |
||
264 | { |
||
265 | $event->addItemCount(absences_translate("Worked days entitling recovery waiting to be validated"), $babDB->db_num_rows($res)); |
||
266 | return; |
||
267 | } |
||
268 | |||
269 | $arr = array(); |
||
270 | |||
271 | while ($row = $babDB->db_fetch_assoc($res)) |
||
272 | { |
||
273 | |||
274 | |||
275 | $l = array( |
||
276 | 'text' => bab_getUserName($row['id_user']), |
||
277 | 'description' => sprintf(absences_translate('%s from %s to %s'), $row['type'], absences_shortDate(bab_mktime($row['date_begin'])), absences_shortDate(bab_mktime($row['date_end']))), |
||
278 | 'url' => absences_addon()->getUrl()."approb&idx=recover&id_workperiod=".$row['id'], |
||
279 | 'popup' => 1, |
||
280 | 'idschi' => $row['idfai'], |
||
281 | 'id' => $row['id'] |
||
282 | ); |
||
283 | |||
284 | |||
285 | $arr[] = $l; |
||
286 | } |
||
287 | |||
288 | |||
289 | if ($arr) { |
||
0 ignored issues
–
show
The expression
$arr of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
290 | $event->addObject(absences_translate("Worked days entitling recovery waiting to be validated"),$arr, __FUNCTION__); |
||
291 | } |
||
292 | |||
293 | |||
294 | } |
||
295 | |||
296 | |||
297 | |||
298 | |||
299 | function absences_listWaitingDeposit(bab_eventBeforeWaitingItemsDisplayed $event, Array $inst) |
||
300 | { |
||
301 | global $babDB; |
||
302 | |||
303 | |||
304 | $res = $babDB->db_query(" |
||
305 | SELECT cet.*, r.quantity_unit, r.description |
||
306 | FROM |
||
307 | absences_cet_deposit_request cet |
||
308 | LEFT JOIN absences_users_rights ur ON ur.id=cet.id_agent_right_source |
||
309 | LEFT JOIN absences_rights r ON r.id=ur.id_right |
||
310 | WHERE |
||
311 | cet.idfai IN (".$babDB->quote($inst).") order by cet.createdOn asc"); |
||
312 | |||
313 | if (0 === $babDB->db_num_rows($res)) |
||
314 | { |
||
315 | return; |
||
316 | } |
||
317 | |||
318 | if ($event instanceof bab_eventWaitingItemsCount) |
||
319 | { |
||
320 | $event->addItemCount(absences_translate("Deposits in the time saving account waiting to be validated"), $babDB->db_num_rows($res)); |
||
321 | return; |
||
322 | } |
||
323 | |||
324 | $arr = array(); |
||
325 | |||
326 | while ($row = $babDB->db_fetch_assoc($res)) |
||
327 | { |
||
328 | $description = isset($row['description']) ? $row['description'] : absences_translate('unknown'); |
||
329 | $quantity_unit = isset($row['quantity_unit']) ? $row['quantity_unit'] : absences_translate('unknown'); |
||
330 | |||
331 | $l = array( |
||
332 | 'text' => bab_getUserName($row['id_user']), |
||
333 | 'description' => sprintf(absences_translate('Move %s from %s'), absences_quantity($row['quantity'], $quantity_unit), $description), |
||
334 | 'url' => absences_addon()->getUrl()."approb&idx=cet&id_deposit=".$row['id'], |
||
335 | 'popup' => 1, |
||
336 | 'idschi' => $row['idfai'], |
||
337 | 'id' => $row['id'] |
||
338 | ); |
||
339 | |||
340 | |||
341 | $arr[] = $l; |
||
342 | } |
||
343 | |||
344 | |||
345 | if ($arr) { |
||
0 ignored issues
–
show
The expression
$arr of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
346 | $event->addObject(absences_translate("Deposits in the time saving account waiting to be validated"),$arr, __FUNCTION__); |
||
347 | } |
||
348 | |||
349 | } |
||
350 | |||
351 | |||
352 | |||
353 | /** |
||
354 | * Refresh calendar if modified |
||
355 | * @param bab_eventPeriodModified $event |
||
356 | */ |
||
357 | function absences_onModifyPeriod($event) { |
||
358 | global $babDB; |
||
359 | |||
360 | $vacation = (BAB_PERIOD_VACATION === ($event->types & BAB_PERIOD_VACATION)); |
||
361 | $nwday = (BAB_PERIOD_NWDAY === ($event->types & BAB_PERIOD_NWDAY)); |
||
362 | $working = (BAB_PERIOD_WORKING === ($event->types & BAB_PERIOD_WORKING)); |
||
363 | |||
364 | if (!$vacation && !$nwday && !$working) { |
||
365 | return; |
||
366 | } |
||
367 | |||
368 | if (false === $event->id_user) { |
||
369 | $babDB->db_query("TRUNCATE absences_calendar"); |
||
370 | return; |
||
371 | } |
||
372 | |||
373 | require_once dirname(__FILE__).'/utilit/vacincl.php'; |
||
374 | absences_clearUserCalendar($event->id_user); |
||
375 | return; |
||
376 | |||
377 | // le code si dessous existait pour optimiser le cache mais dans de rares cas cela ne fonctionne pas |
||
378 | // la modification d'une periode peut entrainer des changement de couleurs sur une autre periode qui n'a pas |
||
379 | // ete modifiee |
||
380 | |||
381 | /* |
||
382 | if (false === $event->begin || false === $event->end) { |
||
383 | absences_clearUserCalendar($event->id_user); |
||
384 | return; |
||
385 | } |
||
386 | |||
387 | |||
388 | include_once $GLOBALS['babInstallPath']."utilit/dateTime.php"; |
||
389 | |||
390 | $date_begin = BAB_DateTime::fromTimeStamp($event->begin); |
||
391 | $date_end = BAB_DateTime::fromTimeStamp($event->end); |
||
392 | $date_end->add(1, BAB_DATETIME_MONTH); |
||
393 | |||
394 | while ($date_begin->getTimeStamp() <= $date_end->getTimeStamp()) { |
||
395 | $month = $date_begin->getMonth(); |
||
396 | $year = $date_begin->getYear(); |
||
397 | absences_updateCalendar($event->id_user, $year, $month); |
||
398 | $date_begin->add(1, BAB_DATETIME_MONTH); |
||
399 | } |
||
400 | |||
401 | */ |
||
402 | } |
||
403 | |||
404 | |||
405 | |||
406 | |||
407 | |||
408 | function absences_onBeforePeriodsCreated(bab_eventBeforePeriodsCreated $event) |
||
409 | { |
||
410 | $userperiods = $event->periods; |
||
411 | /*@var $userperiods bab_UserPeriods */ |
||
412 | |||
413 | $users = $userperiods->getUsers(); |
||
414 | |||
415 | if ($userperiods->isPeriodCollection('bab_VacationPeriodCollection') && $users) { |
||
0 ignored issues
–
show
The expression
$users of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
416 | require_once dirname(__FILE__)."/utilit/vacincl.php"; |
||
417 | absences_setVacationPeriods($userperiods, $users); |
||
418 | } |
||
419 | } |
||
420 | |||
421 | |||
422 | |||
423 | |||
424 | function absences_onHourly(LibTimer_eventHourly $event) |
||
425 | { |
||
426 | require_once dirname(__FILE__).'/utilit/vacincl.php'; |
||
427 | require_once $GLOBALS['babInstallPath'].'utilit/dateTime.php'; |
||
428 | require_once dirname(__FILE__).'/utilit/right.class.php'; |
||
429 | require_once dirname(__FILE__).'/utilit/request.class.php'; |
||
430 | global $babDB; |
||
431 | |||
432 | $defer = (bool) absences_getVacationOption('approb_email_defer'); |
||
433 | |||
434 | // daily notification after 12:00 |
||
435 | |||
436 | if ($defer) |
||
437 | { |
||
438 | if (12 <= (int) date('G')) |
||
439 | { |
||
440 | $registry = bab_getRegistryInstance(); |
||
441 | $registry->changeDirectory('/absences/'); |
||
442 | |||
443 | // get last saved call |
||
444 | $lastcall = $registry->getValue('approb_email_defer'); |
||
445 | |||
446 | if (null === $lastcall || ((time() - bab_mktime($lastcall)) / 3600) > 12 ) |
||
447 | { |
||
448 | // pas de dernier appel ou dernier appel il y a plus de 12 heures |
||
449 | |||
450 | $registry->setKeyValue('approb_email_defer', date('Y-m-d H:i:s')); |
||
451 | |||
452 | require_once dirname(__FILE__).'/utilit/request.notify.php'; |
||
453 | absences_notifyRequestApprovers(); |
||
454 | } |
||
455 | } |
||
456 | } |
||
457 | |||
458 | |||
459 | // droit avec ajout de solde en debut de mois tant que la date de fin n'est pas connue |
||
460 | |||
461 | $I = new absences_RightIterator(); |
||
462 | $I->kind = absences_Right::INCREMENT; |
||
463 | $I->increment = true; |
||
464 | |||
465 | foreach($I as $right) |
||
466 | { |
||
467 | /*@var $right absences_Right */ |
||
468 | |||
469 | if ($right->getKind() !== absences_Right::INCREMENT) |
||
470 | { |
||
471 | throw new Exception('Error in iterator, wrong right kind'); |
||
472 | } |
||
473 | |||
474 | $right->monthlyQuantityUpdate($event); |
||
475 | } |
||
476 | |||
477 | |||
478 | // auto approbation |
||
479 | |||
480 | $auto_confirm = (int) absences_getVacationOption('auto_confirm'); |
||
481 | if (0 !== $auto_confirm) |
||
482 | { |
||
483 | $date = BAB_DateTime::now(); |
||
484 | $date->less($auto_confirm, BAB_DATETIME_DAY); |
||
485 | |||
486 | $I = new absences_RequestIterator; |
||
487 | $I->status = ''; |
||
488 | $I->modifiedOn = $date->getIsoDateTime(); |
||
489 | |||
490 | foreach($I as $request) |
||
491 | { |
||
492 | /*@var $request absences_Request */ |
||
493 | $request->autoConfirm(); |
||
494 | } |
||
495 | } |
||
496 | |||
497 | |||
498 | // synchro |
||
499 | |||
500 | $I = new absences_RightIterator(); |
||
501 | $I->sync_status = absences_Right::SYNC_CLIENT; |
||
502 | |||
503 | if (0 < $I->count()) |
||
504 | { |
||
505 | require_once dirname(__FILE__).'/utilit/client.class.php'; |
||
506 | $client = new absences_client; |
||
507 | foreach($I as $right) |
||
508 | { |
||
509 | $client->updateRight($right->uuid); |
||
510 | } |
||
511 | } |
||
512 | } |
||
513 | |||
514 | |||
515 | |||
516 | function absences_onAfterEventCategoryDeleted(bab_eventAfterEventCategoryDeleted $event) |
||
517 | { |
||
518 | global $babDB; |
||
519 | $babDB->db_query("update absences_collections SET id_cat='0' WHERE id_cat=".$babDB->quote($event->id_category)); |
||
520 | } |
||
521 | |||
522 | |||
523 | |||
524 | function absences_onOrgChartEntityAfterDeleted(bab_eventOrgChartEntityAfterDeleted $event) |
||
525 | { |
||
526 | global $babDB; |
||
527 | $babDB->db_query("DELETE from absences_planning where id_entity=".$babDB->quote($event->id_entity)); |
||
528 | } |
||
529 | |||
530 | |||
531 | |||
532 | |||
533 | /** |
||
534 | * Directory entry modification/creation/delete |
||
535 | * |
||
536 | * @param bab_eventDirectory $event |
||
537 | */ |
||
538 | function absences_onDirectory(bab_eventDirectory $event) |
||
539 | { |
||
540 | if (!($event instanceof bab_eventUserCreated || $event instanceof bab_eventUserModified)) { |
||
541 | return; |
||
542 | } |
||
543 | |||
544 | require_once dirname(__FILE__).'/utilit/vacincl.php'; |
||
545 | |||
546 | if (0 === (int) absences_getVacationOption('organization_sync')) { |
||
547 | return; |
||
548 | } |
||
549 | |||
550 | |||
551 | $id_user = (int) $event->id_user; |
||
552 | |||
553 | |||
554 | require_once dirname(__FILE__).'/utilit/agent.class.php'; |
||
555 | |||
556 | // set the associated organization |
||
557 | $agent = absences_Agent::getFromIdUser($id_user); |
||
558 | |||
559 | if (!$agent->exists()) { |
||
560 | return; |
||
561 | } |
||
562 | |||
563 | require_once dirname(__FILE__).'/utilit/organization.class.php'; |
||
564 | |||
565 | // update the organization list |
||
566 | absences_Organization::createFromDirectory(); |
||
567 | |||
568 | try { |
||
569 | $agent->setOrganizationFromDirEntry(); |
||
570 | } catch (Exception $e) { |
||
571 | // ignore error, organization is not set in dir entry |
||
572 | } |
||
573 | |||
574 | } |
||
575 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: