PluginProbe
ShiftController Employee Shift Scheduling / 4.9.26
ShiftController Employee Shift Scheduling v4.9.26
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / sh4 / schedule / html / view / common.php

common.php in ShiftController Employee Shift Scheduling 4.9.26, at sh4/schedule/html/view/common.php

768 lines 19.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 interface SH4_Schedule_Html_View_ICommon
3 {
4 public function getShifts();
5 public function getCalendars();
6 public function getEmployees();
7
8 public function findAllCalendars();
9 public function findAllEmployees();
10 public function filterShifts( $shifts );
11 public function filterViewTypes( $types );
12
13 public function renderReport( $shiftsDuration, $alignRight = TRUE );
14 }
15
16 class SH4_Schedule_Html_View_Common implements SH4_Schedule_Html_View_ICommon
17 {
18 public function __construct(
19 HC3_Hooks $hooks,
20
21 HC3_Auth $auth,
22 HC3_Settings $settings,
23
24 HC3_Ui $ui,
25 HC3_Request $request,
26 HC3_Time $t,
27
28 SH4_App_Query $appQuery,
29
30 SH4_Shifts_Conflicts $conflicts,
31
32 SH4_Calendars_Permissions $calendarsPermissions,
33 SH4_Employees_Query $employeesQuery,
34 SH4_Calendars_Query $calendarsQuery,
35 SH4_Shifts_Query $shiftsQuery
36 )
37 {
38 $this->self = $hooks->wrap( $this );
39
40 $this->auth = $auth;
41
42 $this->ui = $ui;
43 $this->t = $t;
44 $this->request = $request;
45 $this->settings = $settings;
46
47 $this->appQuery = $hooks->wrap( $appQuery );
48
49 $this->conflicts = $hooks->wrap( $conflicts );
50
51 $this->calendarsPermissions = $hooks->wrap( $calendarsPermissions );
52 $this->employeesQuery = $hooks->wrap( $employeesQuery );
53 $this->calendarsQuery = $hooks->wrap( $calendarsQuery );
54 $this->shiftsQuery = $hooks->wrap( $shiftsQuery );
55 }
56
57 public function employeeRowLabel( $employeeView, $employeeId, $range, $dates, $shifts )
58 {
59 return $employeeView;
60 }
61
62 public function renderReport( $shiftsDuration, $alignRight = TRUE )
63 {
64 $return = NULL;
65
66 $hide = $this->settings->get('datetime_hide_schedule_reports');
67 if( $hide ){
68 return $return;
69 }
70
71 $currentUser = $this->auth->getCurrentUser();
72 $currentUserId = $currentUser->getId();
73
74 if( ! $currentUserId ){
75 return $return;
76 }
77
78 $qty = $shiftsDuration->getQty();
79 $duration = $shiftsDuration->getDuration();
80
81 $qtyTimeoff = $shiftsDuration->getQtyTimeoff();
82 $durationTimeoff = $shiftsDuration->getDurationTimeoff();
83
84 if( $qtyTimeoff ){
85 $qty = $qty - $qtyTimeoff;
86 $duration = $duration - $durationTimeoff;
87 }
88
89 $return = array();
90 // $return[] = $this->ui->makeBlockInline( $shiftsDuration->getQty() )
91 // ->addAttr( 'title', '__Number Of Shifts__' )
92 // ;
93 $return[] = $this->ui->makeSpan( $shiftsDuration->formatDuration($duration) )
94 ->addAttr( 'title', '__Hours__' )
95 ;
96 $return[] = $this->ui->makeBlockInline( '(' . $qty . ')' )
97 ->addAttr( 'title', '__Shifts__' )
98 ->tag('muted')
99 ->tag('font-size', 2)
100 ;
101 $return = $this->ui->makeListInline( $return )
102 ->gutter(1)
103 ;
104
105 if( $qtyTimeoff ){
106 $timeoffReturn = array();
107 $timeoffReturn[] = $this->ui->makeSpan( $shiftsDuration->formatDuration($durationTimeoff) )
108 ->addAttr( 'title', '__Hours__' )
109 ;
110 $timeoffReturn[] = $this->ui->makeBlockInline( '(' . $qtyTimeoff . ')' )
111 ->addAttr( 'title', '__Time Off__' )
112 ->tag('muted')
113 ->tag('font-size', 2)
114 ;
115 $timeoffReturn = $this->ui->makeListInline( $timeoffReturn )
116 ->gutter(1)
117 ;
118
119 $return = $this->ui->makeListInline( array($return, $timeoffReturn) )
120 ->gutter(1)
121 ;
122 }
123
124 $return = $this->ui->makeBlockInline( $return )
125 ->tag('border')
126 ->tag('padding', 1 )
127 ;
128 if( $alignRight ){
129 $return = $this->ui->makeBlock( $return )
130 ->tag('align', 'right')
131 ;
132 }
133
134 return $return;
135 }
136
137 public function filterShifts( $return )
138 {
139 $currentUser = $this->auth->getCurrentUser();
140 $currentUserId = $currentUser->getId();
141
142 $meEmployeeId = NULL;
143 $meEmployeeCalendars = array();
144
145 $meEmployee = $this->appQuery->findEmployeeByUser( $currentUser );
146 if( $meEmployee ){
147 $meEmployeeId = $meEmployee->getId();
148 $meEmployeeCalendars = $this->appQuery->findCalendarsForEmployee( $meEmployee );
149 }
150
151 $myManagedCalendars = array();
152 $myViewedCalendars = array();
153 if( $currentUserId ){
154 $myManagedCalendars = $this->appQuery->findCalendarsManagedByUser( $currentUser );
155 $myViewedCalendars = $this->appQuery->findCalendarsViewedByUser( $currentUser );
156 }
157
158 $ids = array_keys( $return );
159 foreach( $ids as $id ){
160 $shift = $return[$id];
161
162 $shiftCalendar = $shift->getCalendar();
163 $shiftCalendarId = $shiftCalendar->getId();
164 $shiftEmployee = $shift->getEmployee();
165 $shiftEmployeeId = $shiftEmployee->getId();
166
167 // is manager?
168 if( isset($myManagedCalendars[$shiftCalendarId]) ){
169 continue;
170 }
171
172 // is viewer?
173 if( isset($myViewedCalendars[$shiftCalendarId]) ){
174 continue;
175 }
176
177 // is visitor
178 if( ! $meEmployeeId ){
179 if( $shift->isOpen() ){
180 $permName = $shift->isPublished() ? 'visitor_view_open_publish' : 'visitor_view_open_draft';
181 }
182 else {
183 $permName = $shift->isPublished() ? 'visitor_view_others_publish' : 'visitor_view_others_draft';
184 }
185 $perm = $this->calendarsPermissions->get( $shiftCalendar, $permName );
186 if( ! $perm ){
187 unset( $return[$id] );
188 }
189 continue;
190 }
191
192 // is shift employee
193 if( $meEmployeeId == $shiftEmployeeId ){
194 $permName = $shift->isPublished() ? 'employee_view_own_publish' : 'employee_view_own_draft';
195 $perm = $this->calendarsPermissions->get( $shiftCalendar, $permName );
196 if( ! $perm ){
197 unset( $return[$id] );
198 }
199 continue;
200 }
201
202 // is other employee
203 if( $meEmployeeId != $shiftEmployeeId ){
204 // calendar employees
205 if( isset($meEmployeeCalendars[$shiftCalendarId]) ){
206 if( $shift->isOpen() ){
207 $permName = $shift->isPublished() ? 'employee_view_open_publish' : 'employee_view_open_draft';
208 }
209 else {
210 $permName = $shift->isPublished() ? 'employee_view_others_publish' : 'employee_view_others_draft';
211 }
212 }
213 // other employees
214 else {
215 if( $shift->isOpen() ){
216 $permName = $shift->isPublished() ? 'employee2_view_open_publish' : 'employee2_view_open_draft';
217 }
218 else {
219 $permName = $shift->isPublished() ? 'employee2_view_others_publish' : 'employee2_view_others_draft';
220 }
221 }
222
223 $perm = $this->calendarsPermissions->get( $shiftCalendar, $permName );
224 if( ! $perm ){
225 unset( $return[$id] );
226 }
227
228 continue;
229 }
230 }
231
232 // sort
233 uasort( $return, array($this, '_sortShifts') );
234
235 return $return;
236 }
237
238 public function _sortShifts( $a, $b )
239 {
240 $compare1 = $a->getStart();
241 $compare2 = $b->getStart();
242 if( $compare1 != $compare2 ){
243 return ( $compare1 > $compare2 ) ? 1 : -1;
244 }
245
246 $compare1 = $a->getEnd();
247 $compare2 = $b->getEnd();
248 if( $compare1 != $compare2 ){
249 return ( $compare1 > $compare2 ) ? 1 : -1;
250 }
251
252 $cal1 = $a->getCalendar();
253 $cal2 = $b->getCalendar();
254 if( ! ($cal1 && $cal2) ){
255 return 0;
256 }
257
258 $compare1 = $cal1->getSortOrder();
259 $compare2 = $cal2->getSortOrder();
260 if( $compare1 != $compare2 ){
261 return ( $compare1 > $compare2 ) ? 1 : -1;
262 }
263
264 $compare1 = $cal1->getTitle();
265 $compare2 = $cal2->getTitle();
266 if( $compare1 != $compare2 ){
267 return strcmp( $compare1, $compare2 );
268 }
269
270 $emp1 = $a->getEmployee();
271 $emp2 = $b->getEmployee();
272 if( ! ($emp1 && $emp2) ){
273 return 0;
274 }
275
276 $compare1 = $emp1->getSortOrder();
277 $compare2 = $emp2->getSortOrder();
278 if( $compare1 != $compare2 ){
279 return ( $compare1 > $compare2 ) ? 1 : -1;
280 }
281
282 $compare1 = $emp1->getTitle();
283 $compare2 = $emp2->getTitle();
284 if( $compare1 != $compare2 ){
285 return strcmp( $compare1, $compare2 );
286 }
287 }
288
289 public function filterViewTypes( $return )
290 {
291 $currentUser = $this->auth->getCurrentUser();
292 $currentUserId = $currentUser->getId();
293 if( ! $currentUserId ){
294 unset( $return['report'] );
295 }
296 return $return;
297 }
298
299 public function findAllEmployees()
300 {
301 $return = $this->employeesQuery->findActive();
302
303 $currentUser = $this->auth->getCurrentUser();
304 $currentUserId = $currentUser->getId();
305
306 $employee = $this->appQuery->findEmployeeByUser( $currentUser );
307 $managedCalendars = $this->appQuery->findCalendarsManagedByUser( $currentUser );
308 $viewedCalendars = $this->appQuery->findCalendarsViewedByUser( $currentUser );
309
310 $allowed = array();
311 if( $employee ){
312 $allowed[ $employee->getId() ] = $employee;
313 }
314
315 $calendars = $this->self->findAllCalendars();
316 foreach( $calendars as $calendar ){
317 $thisCalendarId = $calendar->getId();
318
319 $thisAllowed = $this->appQuery->findEmployeesForCalendar( $calendar );
320
321 if( isset($managedCalendars[$thisCalendarId]) ){
322 $allowed = $allowed + $thisAllowed;
323 continue;
324 }
325
326 if( isset($viewedCalendars[$thisCalendarId]) ){
327 $allowed = $allowed + $thisAllowed;
328 continue;
329 }
330
331 // OPEN?
332 if( isset($thisAllowed[0]) ){
333 $permNames = array();
334 $permNames[] = 'visitor_view_open_publish';
335 $permNames[] = 'visitor_view_open_draft';
336 if( $employee ){
337 $permNames[] = 'employee_view_open_publish';
338 $permNames[] = 'employee_view_open_draft';
339 }
340
341 reset( $permNames );
342 foreach( $permNames as $permName ){
343 $perm = $this->calendarsPermissions->get( $calendar, $permName );
344 if( $perm ){
345 $allowed[0] = $thisAllowed[0];
346 break;
347 }
348 }
349
350 unset( $thisAllowed[0] );
351 }
352
353 $permNames = array();
354 $permNames[] = 'visitor_view_others_publish';
355 $permNames[] = 'visitor_view_others_draft';
356 if( $employee ){
357 $permNames[] = 'employee_view_others_publish';
358 $permNames[] = 'employee_view_others_draft';
359 }
360
361 reset( $permNames );
362 foreach( $permNames as $permName ){
363 $perm = $this->calendarsPermissions->get( $calendar, $permName );
364 if( $perm ){
365 $allowed = $allowed + $thisAllowed;
366 break;
367 }
368 }
369
370 // PICKUP?
371 if( $employee ){
372 $permNames = array();
373 $permNames[] = 'employee_pickup_others';
374
375 reset( $permNames );
376 foreach( $permNames as $permName ){
377 $perm = $this->calendarsPermissions->get( $calendar, $permName );
378 if( $perm ){
379 $allowed = $allowed + $thisAllowed;
380 break;
381 }
382 }
383 }
384
385 // $allowed = $allowed + $thisReturn;
386 }
387
388 $ids = array_keys( $return );
389 foreach( $ids as $id ){
390 if( ! array_key_exists($id, $allowed) ){
391 unset( $return[$id] );
392 }
393 }
394
395 return $return;
396 }
397
398 public function findAllCalendars()
399 {
400 $return = $this->calendarsQuery->findActive();
401
402 $allowed = array();
403
404 $currentUser = $this->auth->getCurrentUser();
405 $currentUserId = $currentUser->getId();
406 $employee = $this->appQuery->findEmployeeByUser( $currentUser );
407
408 if( $currentUserId ){
409 $thisReturn = $this->appQuery->findCalendarsManagedByUser( $currentUser );
410 $allowed = $allowed + $thisReturn;
411
412 $thisReturn = $this->appQuery->findCalendarsViewedByUser( $currentUser );
413 $allowed = $allowed + $thisReturn;
414 }
415
416 $calendarsForEmployee = array();
417 if( $employee ){
418 $calendarsForEmployee = $this->appQuery->findCalendarsForEmployee( $employee );
419 $allowed = $allowed + $calendarsForEmployee;
420 }
421
422 foreach( $return as $calendar ){
423 $calendarId = $calendar->getId();
424
425 $permNames = array();
426 $permNames[] = 'visitor_view_others_publish';
427 $permNames[] = 'visitor_view_others_draft';
428 $permNames[] = 'visitor_view_open_publish';
429 $permNames[] = 'visitor_view_open_draft';
430
431 if( $currentUserId ){
432 // if( ! isset($calendarsForEmployee[$currentUserId]) ){
433 // continue;
434 // }
435
436 if( isset($calendarsForEmployee[$currentUserId]) ){
437 $permNames[] = 'employee_view_others_publish';
438 $permNames[] = 'employee_view_others_draft';
439 }
440 else {
441 $permNames[] = 'employee2_view_others_publish';
442 $permNames[] = 'employee2_view_others_draft';
443 }
444 }
445
446 reset( $permNames );
447 foreach( $permNames as $permName ){
448 $perm = $this->calendarsPermissions->get( $calendar, $permName );
449 if( $perm ){
450 $allowed[ $calendarId ] = $calendar;
451 break;
452 }
453 }
454 }
455
456 $ids = array_keys( $return );
457 foreach( $ids as $id ){
458 // if( ! array_key_exists($id, $allowed) ){
459 if( ! isset($allowed[$id]) ){
460 unset( $return[$id] );
461 }
462 }
463
464 return $return;
465 }
466
467 public function getShifts()
468 {
469 static $cache = null;
470 if( null !== $cache ) return $cache;
471
472 // init params
473 $params = $this->request->getParams();
474 if( isset($params['time']) && ('now' == $params['time']) ){
475 $params['time'] = $this->t->setNow()->formatDateTimeDb();
476 }
477
478 $type = $params['type'];
479 $startDate = $params['start'];
480 $endDate = $params['end'];
481
482 if( (FALSE !== strpos($startDate, '+')) OR (FALSE !== strpos($startDate, '-')) ){
483 $this->t->setNow()->setStartDay()->modify($startDate);
484 $startDate = $this->t->formatDateDb();
485 }
486
487 if( FALSE !== strpos($endDate, '+') ){
488 $this->t->setDateDb($startDate)->modify($endDate);
489 $endDate = $this->t->formatDateDb();
490 }
491
492 $exactDateTime = isset( $params['time'] ) ? $params['time'] : NULL;
493 if( $exactDateTime ){
494 $startDate = $this->t->setDateTimeDb( $exactDateTime )->formatDateDb();
495 $endDate = $startDate;
496 }
497
498 switch( $type ){
499 case 'day':
500 $this->t->setDateDb($startDate);
501 $start = $this->t->formatDateTimeDb();
502
503 $startDate = $this->t->formatDateDb();
504 $this->request->setParam('start', $startDate);
505 $endDate = $this->t->formatDateDb();
506 $this->request->setParam('end', $endDate);
507
508 $daysToShow = isset( SH4_Schedule_Html_View_Day::$daysToShow ) ? SH4_Schedule_Html_View_Day::$daysToShow : 7;
509 if( $daysToShow ){
510 $this->t->modify( '+' . $daysToShow . ' days' );
511 }
512 $end = $this->t->setEndDay()->formatDateTimeDb();
513 break;
514
515 case 'week':
516 $this->t->setDateDb($startDate)->setStartWeek();
517 $startDate = $this->t->formatDateDb();
518 $this->request->setParam('start', $startDate);
519
520 $start = $this->t->formatDateTimeDb();
521 $this->t->setEndWeek();
522 // $this->t->modify('+1 week')
523 // ->modify('-1 day')
524 // ;
525 $endDate = $this->t->formatDateDb();
526
527 $this->request->setParam('end', $endDate);
528 $end = $this->t->setEndDay()->formatDateTimeDb();
529 break;
530
531 case '4weeks':
532 $nWeeks = $this->settings->get( 'datetime_n_weeks' );
533 if( ! $nWeeks ) $nWeeks = 4;
534
535 $this->t->setDateDb($startDate)->setStartWeek();
536 $startDate = $this->t->formatDateDb();
537 $this->request->setParam('start', $startDate);
538
539 $start = $this->t->formatDateTimeDb();
540 $this->t->modify('+' . $nWeeks . ' weeks')
541 ->modify('-1 day')
542 ;
543 $endDate = $this->t->formatDateDb();
544 $this->request->setParam('end', $endDate);
545
546 $end = $this->t->setEndDay()->formatDateTimeDb();
547 break;
548
549 case '2weeks':
550 $this->t->setDateDb($startDate)->setStartWeek();
551 $startDate = $this->t->formatDateDb();
552 $this->request->setParam('start', $startDate);
553
554 $start = $this->t->formatDateTimeDb();
555 $this->t->modify('+2 weeks')
556 ->modify('-1 day')
557 ;
558 $endDate = $this->t->formatDateDb();
559 $this->request->setParam('end', $endDate);
560
561 $end = $this->t->setEndDay()->formatDateTimeDb();
562 break;
563
564 case 'month':
565 $this->t->setDateDb($startDate)->setStartMonth();
566 $startDate = $this->t->formatDateDb();
567 $this->request->setParam('start', $startDate);
568
569 $start = $this->t->formatDateTimeDb();
570 $this->t->setEndMonth();
571 // $this->t->modify('+1 month')
572 // ->modify('-1 day')
573 // ;
574 $endDate = $this->t->formatDateDb();
575 $this->request->setParam('end', $endDate);
576
577 $end = $this->t->setEndDay()->formatDateTimeDb();
578 break;
579
580 default:
581 if( $exactDateTime ){
582 $start = $exactDateTime;
583 $end = $exactDateTime;
584 }
585 else {
586 $this->t->setDateDb($startDate);
587 $start = $this->t->formatDateTimeDb();
588
589 // $this->t->setDateDb($endDate)->modify('+1 day');
590 $this->t->setDateDb($endDate);
591 $end = $this->t->setEndDay()->formatDateTimeDb();
592 }
593
594 break;
595 }
596
597 $this->shiftsQuery
598 ->setStart( $start )
599 ->setEnd( $end )
600 ;
601
602 $return = $this->shiftsQuery->find();
603
604 // filter
605 $employees = $this->getEmployees();
606 $calendars = $this->getCalendars();
607
608 foreach( array_keys($return) as $id ){
609 $shift = $return[$id];
610
611 $calendar = $shift->getCalendar();
612 if( ! array_key_exists($calendar->getId(), $calendars) ){
613 unset( $return[$id] );
614 continue;
615 }
616
617 $employee = $shift->getEmployee();
618 if( ! array_key_exists($employee->getId(), $employees) ){
619 unset( $return[$id] );
620 continue;
621 }
622
623 $shiftStart = $shift->getStart();
624 $shiftEnd = $shift->getEnd();
625
626 if( $shiftEnd <= $start ){
627 unset( $return[$id] );
628 continue;
629 }
630
631 if( $shiftStart >= $end ){
632 unset( $return[$id] );
633 continue;
634 }
635
636 // if( $shiftStart < $start ){
637 // unset( $return[$id] );
638 // continue;
639 // }
640 }
641
642 $params = $this->request->getParams();
643
644 // skip those shifts that start before period and end during the first day
645 // $when = array( 'report', 'list' );
646 // if( in_array('report', $when) ){
647 if( 1 ){
648 $startRange = $this->t->setDateDb( $params['start'] )->formatDateTimeDb();
649 $endFirstDay = $this->t->setDateDb( $params['start'] )->modify('+1 day')->formatDateTimeDb();
650
651 $ids = array_keys( $return );
652 foreach( $ids as $id ){
653 $shift = $return[ $id ];
654 if( $shift->getStart() >= $startRange ) continue;
655 if( $shift->getEnd() >= $endFirstDay ) continue;
656 unset( $return[$id] );
657 }
658 }
659
660 // filter conflicts?
661 if( isset($params['conflict']) && $params['conflict'] ){
662 $withConflicts = ( $params['conflict'] > 0 ) ? true : false;
663
664 $ids = array_keys( $return );
665 foreach( $ids as $id ){
666 $shift = $return[ $id ];
667 $conflicts = $this->conflicts->get( $shift );
668 if( $withConflicts && (! $conflicts) ){
669 unset( $return[$id] );
670 }
671
672 if( (! $withConflicts) && $conflicts ){
673 unset( $return[$id] );
674 }
675 }
676 }
677
678 $return = $this->self->filterShifts( $return );
679 $cache = $return;
680 return $return;
681 }
682
683 public function getCalendars()
684 {
685 $return = $this->self->findAllCalendars();
686 $params = $this->request->getParams();
687
688 if( $params['calendar'] ){
689 $filterIds = $params['calendar'];
690
691 $ids = array_keys($return);
692 foreach( $ids as $id ){
693 if( ! in_array($id, $filterIds) ){
694 unset( $return[$id] );
695 }
696 }
697 }
698
699 if( $params['employee'] ){
700 $employees = $this->self->findAllEmployees();
701
702 $filterEmployeeIds = $params['employee'];
703 $filter = array();
704 foreach( $employees as $employee ){
705 $employeeId = $employee->getId();
706 if( ! (in_array(-1, $filterEmployeeIds) && ($employeeId > 0)) ){
707 if( ! in_array($employeeId, $filterEmployeeIds) ){
708 continue;
709 }
710 }
711 $filter = $filter + $this->appQuery->findCalendarsForEmployee( $employee );
712 }
713 $filterIds = array_keys( $filter );
714
715 $ids = array_keys($return);
716 foreach( $ids as $id ){
717 if( ! in_array($id, $filterIds) ){
718 unset( $return[$id] );
719 }
720 }
721 }
722
723 return $return;
724 }
725
726 public function getEmployees()
727 {
728 $return = $this->self->findAllEmployees();
729 $params = $this->request->getParams();
730
731 if( $params['employee'] ){
732 $filterIds = $params['employee'];
733
734 $ids = array_keys($return);
735 foreach( $ids as $id ){
736 if( in_array(-1, $filterIds) && ($id > 0) ){
737 continue;
738 }
739
740 if( ! in_array($id, $filterIds) ){
741 unset( $return[$id] );
742 }
743 }
744 }
745
746 if( $params['calendar'] ){
747 $calendars = $this->self->findAllCalendars();
748
749 $filter = array();
750 foreach( $calendars as $calendar ){
751 if( ! in_array($calendar->getId(), $params['calendar']) ){
752 continue;
753 }
754 $filter = $filter + $this->appQuery->findEmployeesForCalendar( $calendar );
755 }
756 $filterIds = array_keys( $filter );
757
758 $ids = array_keys($return);
759 foreach( $ids as $id ){
760 if( ! in_array($id, $filterIds) ){
761 unset( $return[$id] );
762 }
763 }
764 }
765
766 return $return;
767 }
768 }