grommunio /
grommunio-dav
| 1 | <?php |
||||
| 2 | |||||
| 3 | /* |
||||
| 4 | * SPDX-License-Identifier: AGPL-3.0-only |
||||
| 5 | * SPDX-FileCopyrightText: Copyright 2016 - 2018 Kopano b.v. |
||||
| 6 | * SPDX-FileCopyrightText: Copyright 2020-2024 grommunio GmbH |
||||
| 7 | * |
||||
| 8 | * Checks Free/Busy information of requested recipients. |
||||
| 9 | */ |
||||
| 10 | |||||
| 11 | namespace grommunio\DAV; |
||||
| 12 | |||||
| 13 | use Sabre\CalDAV\Schedule\Plugin; |
||||
| 14 | use Sabre\VObject\Component; |
||||
| 15 | use Sabre\VObject\Reader; |
||||
| 16 | |||||
| 17 | class GrommunioSchedulePlugin extends Plugin { |
||||
| 18 | private $logger; |
||||
| 19 | protected $gDavBackend; |
||||
| 20 | |||||
| 21 | /** |
||||
| 22 | * Constructor. |
||||
| 23 | */ |
||||
| 24 | public function __construct(GrommunioDavBackend $gDavBackend, GLogger $glogger) { |
||||
| 25 | $this->gDavBackend = $gDavBackend; |
||||
| 26 | $this->logger = $glogger; |
||||
| 27 | } |
||||
| 28 | |||||
| 29 | /** |
||||
| 30 | * Get the Free/Busy information for a recipient. |
||||
| 31 | * |
||||
| 32 | * Given email, start and end time the function will return |
||||
| 33 | * the freebusy blocks. |
||||
| 34 | * |
||||
| 35 | * @param string $email |
||||
| 36 | * |
||||
| 37 | * @return array |
||||
| 38 | */ |
||||
| 39 | protected function getFreeBusyForEmail($email, \DateTimeInterface $start, \DateTimeInterface $end, Component $request) { |
||||
| 40 | $this->logger->trace("email: %s - start: %d - end: %d", $email, $start->getTimestamp(), $end->getTimestamp()); |
||||
| 41 | |||||
| 42 | $addrbook = $this->gDavBackend->GetAddressBook(); |
||||
| 43 | $email = preg_replace('!^mailto:!i', '', $email); |
||||
| 44 | $search = [[PR_DISPLAY_NAME => $email]]; |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 45 | $userarr = mapi_ab_resolvename($addrbook, $search, EMS_AB_ADDRESS_LOOKUP); |
||||
|
0 ignored issues
–
show
|
|||||
| 46 | if (!empty($userarr)) { |
||||
| 47 | $result = mapi_getuserfreebusyical($this->gDavBackend->GetSession(), $userarr[0][PR_ENTRYID], $start->getTimestamp(), $end->getTimestamp()); |
||||
|
0 ignored issues
–
show
The function
mapi_getuserfreebusyical was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 48 | if ($result) { |
||||
| 49 | $vcalendar = Reader::read($result, Reader::OPTION_FORGIVING); |
||||
| 50 | |||||
| 51 | return [ |
||||
| 52 | 'calendar-data' => $vcalendar, |
||||
| 53 | 'request-status' => '2.0;Success', |
||||
| 54 | 'href' => 'mailto:' . $email, |
||||
| 55 | ]; |
||||
| 56 | } |
||||
| 57 | } |
||||
| 58 | |||||
| 59 | return [ |
||||
| 60 | 'request-status' => '3.7;Could not find principal', |
||||
| 61 | 'href' => 'mailto:' . $email, |
||||
| 62 | ]; |
||||
| 63 | } |
||||
| 64 | } |
||||
| 65 |