1 | <?php |
||
2 | /* |
||
3 | * SPDX-License-Identifier: AGPL-3.0-only |
||
4 | * SPDX-FileCopyrightText: Copyright 2005-2016 Zarafa Deutschland GmbH |
||
5 | * SPDX-FileCopyrightText: Copyright 2020-2024 grommunio GmbH |
||
6 | */ |
||
7 | |||
8 | define('NOERROR', 0); |
||
9 | |||
10 | // Load all mapi defs |
||
11 | mapi_load_mapidefs(1); |
||
12 | |||
13 | /** |
||
14 | * Function to make a MAPIGUID from a php string. |
||
15 | * The C++ definition for the GUID is: |
||
16 | * typedef struct _GUID |
||
17 | * { |
||
18 | * unsigned long Data1; |
||
19 | * unsigned short Data2; |
||
20 | * unsigned short Data3; |
||
21 | * unsigned char Data4[8]; |
||
22 | * } GUID;. |
||
23 | * |
||
24 | * A GUID is normally represented in the following form: |
||
25 | * {00062008-0000-0000-C000-000000000046} |
||
26 | * |
||
27 | * @param string $guid |
||
28 | */ |
||
29 | function makeGuid($guid): string { |
||
30 | return pack("vvvv", hexdec(substr($guid, 5, 4)), hexdec(substr($guid, 1, 4)), hexdec(substr($guid, 10, 4)), hexdec(substr($guid, 15, 4))) . hex2bin(substr($guid, 20, 4)) . hex2bin(substr($guid, 25, 12)); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Function to get a human readable string from a MAPI error code. |
||
35 | * |
||
36 | * @param mixed $errcode the MAPI error code, if not given, we use mapi_last_hresult |
||
37 | * |
||
38 | * @return string The defined name for the MAPI error code |
||
39 | */ |
||
40 | function get_mapi_error_name($errcode = null) { |
||
41 | if ($errcode === null) { |
||
42 | $errcode = mapi_last_hresult(); |
||
43 | } |
||
44 | |||
45 | if (strcasecmp(substr($errcode, 0, 2), '0x') === 0) { |
||
46 | $errcode = hexdec($errcode); |
||
47 | } |
||
48 | |||
49 | if ($errcode !== 0) { |
||
50 | // Retrieve constants categories, MAPI error names are defined in gromox. |
||
51 | foreach (get_defined_constants(true)['Core'] as $key => $value) { |
||
52 | /* |
||
53 | * If PHP encounters a number beyond the bounds of the integer type, |
||
54 | * it will be interpreted as a float instead, so when comparing these error codes |
||
55 | * we have to manually typecast value to integer, so float will be converted in integer, |
||
56 | * but still its out of bound for integer limit so it will be auto adjusted to minus value |
||
57 | */ |
||
58 | if ($errcode == (int) $value) { |
||
59 | // Check that we have an actual MAPI error or warning definition |
||
60 | $prefix = substr($key, 0, 7); |
||
61 | if ($prefix == "MAPI_E_" || $prefix == "MAPI_W_") { |
||
62 | return $key; |
||
63 | } |
||
64 | $prefix = substr($key, 0, 2); |
||
65 | if ($prefix == "ec") { |
||
66 | return $key; |
||
67 | } |
||
68 | } |
||
69 | } |
||
70 | } |
||
71 | else { |
||
72 | return "NOERROR"; |
||
73 | } |
||
74 | |||
75 | // error code not found, return hex value (this is a fix for 64-bit systems, we can't use the dechex() function for this) |
||
76 | $result = unpack("H*", pack("N", $errcode)); |
||
77 | |||
78 | return "0x" . $result[1]; |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Parses properties from an array of strings. Each "string" may be either an ULONG, which is a direct property ID, |
||
83 | * or a string with format "PT_TYPE:{GUID}:StringId" or "PT_TYPE:{GUID}:0xXXXX" for named |
||
84 | * properties. |
||
85 | * |
||
86 | * @param mixed $store |
||
87 | * @param mixed $mapping |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | function getPropIdsFromStrings($store, $mapping) { |
||
92 | $props = []; |
||
93 | |||
94 | $ids = ["name" => [], "id" => [], "guid" => [], "type" => []]; // this array stores all the information needed to retrieve a named property |
||
95 | $num = 0; |
||
96 | |||
97 | // caching |
||
98 | $guids = []; |
||
99 | |||
100 | foreach ($mapping as $name => $val) { |
||
101 | if (is_string($val)) { |
||
102 | $split = explode(":", $val); |
||
103 | |||
104 | if (count($split) != 3) { // invalid string, ignore |
||
105 | trigger_error(sprintf("Invalid property: %s \"%s\"", $name, $val), E_USER_NOTICE); |
||
106 | |||
107 | continue; |
||
108 | } |
||
109 | |||
110 | if (substr($split[2], 0, 2) == "0x") { |
||
111 | $id = hexdec(substr($split[2], 2)); |
||
112 | } |
||
113 | elseif (preg_match('/^[1-9][0-9]{0,12}$/', $split[2])) { |
||
114 | $id = (int) $split[2]; |
||
115 | } |
||
116 | else { |
||
117 | $id = $split[2]; |
||
118 | } |
||
119 | |||
120 | // have we used this guid before? |
||
121 | if (!defined($split[1])) { |
||
122 | if (!array_key_exists($split[1], $guids)) { |
||
123 | $guids[$split[1]] = makeguid($split[1]); |
||
124 | } |
||
125 | $guid = $guids[$split[1]]; |
||
126 | } |
||
127 | else { |
||
128 | $guid = constant($split[1]); |
||
129 | } |
||
130 | |||
131 | // temp store info about named prop, so we have to call mapi_getidsfromnames just one time |
||
132 | $ids["name"][$num] = $name; |
||
133 | $ids["id"][$num] = $id; |
||
134 | $ids["guid"][$num] = $guid; |
||
135 | $ids["type"][$num] = $split[0]; |
||
136 | ++$num; |
||
137 | } |
||
138 | else { |
||
139 | // not a named property |
||
140 | $props[$name] = $val; |
||
141 | } |
||
142 | } |
||
143 | |||
144 | if (empty($ids["id"])) { |
||
145 | return $props; |
||
146 | } |
||
147 | |||
148 | // get the ids |
||
149 | $named = mapi_getidsfromnames($store, $ids["id"], $ids["guid"]); |
||
150 | foreach ($named as $num => $prop) { |
||
151 | $props[$ids["name"][$num]] = mapi_prop_tag(constant($ids["type"][$num]), mapi_prop_id($prop)); |
||
152 | } |
||
153 | |||
154 | return $props; |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * Check whether a call to mapi_getprops returned errors for some properties. |
||
159 | * mapi_getprops function tries to get values of properties requested but somehow if |
||
160 | * if a property value can not be fetched then it changes type of property tag as PT_ERROR |
||
161 | * and returns error for that particular property, probable errors |
||
162 | * that can be returned as value can be MAPI_E_NOT_FOUND, MAPI_E_NOT_ENOUGH_MEMORY. |
||
163 | * |
||
164 | * @param int $property Property to check for error |
||
165 | * @param array $propArray An array of properties |
||
166 | * |
||
167 | * @return bool|mixed Gives back false when there is no error, if there is, gives the error |
||
168 | */ |
||
169 | function propIsError($property, $propArray) { |
||
170 | if (array_key_exists(mapi_prop_tag(PT_ERROR, mapi_prop_id($property)), $propArray)) { |
||
171 | return $propArray[mapi_prop_tag(PT_ERROR, mapi_prop_id($property))]; |
||
172 | } |
||
173 | |||
174 | return false; |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * Note: Static function, more like a utility function. |
||
179 | * |
||
180 | * Gets all the items (including recurring items) in the specified calendar in the given timeframe. Items are |
||
181 | * included as a whole if they overlap the interval <$start, $end> (non-inclusive). This means that if the interval |
||
182 | * is <08:00 - 14:00>, the item [6:00 - 8:00> is NOT included, nor is the item [14:00 - 16:00>. However, the item |
||
183 | * [7:00 - 9:00> is included as a whole, and is NOT capped to [8:00 - 9:00>. |
||
184 | * |
||
185 | * @param resource $store The store in which the calendar resides |
||
186 | * @param resource $calendar The calendar to get the items from |
||
187 | * @param int $viewstart Timestamp of beginning of view window |
||
188 | * @param int $viewend Timestamp of end of view window |
||
189 | * @param array $propsrequested Array of properties to return |
||
190 | * |
||
191 | * @psalm-return list<mixed> |
||
192 | */ |
||
193 | function getCalendarItems($store, $calendar, $viewstart, $viewend, $propsrequested): array { |
||
194 | $result = []; |
||
195 | $properties = getPropIdsFromStrings($store, [ |
||
196 | "duedate" => "PT_SYSTIME:PSETID_Appointment:" . PidLidAppointmentEndWhole, |
||
197 | "startdate" => "PT_SYSTIME:PSETID_Appointment:" . PidLidAppointmentStartWhole, |
||
198 | "enddate_recurring" => "PT_SYSTIME:PSETID_Appointment:" . PidLidClipEnd, |
||
199 | "recurring" => "PT_BOOLEAN:PSETID_Appointment:" . PidLidRecurring, |
||
200 | "recurring_data" => "PT_BINARY:PSETID_Appointment:" . PidLidAppointmentRecur, |
||
201 | "timezone_data" => "PT_BINARY:PSETID_Appointment:" . PidLidTimeZoneStruct, |
||
202 | "label" => "PT_LONG:PSETID_Appointment:0x8214", |
||
203 | ]); |
||
204 | |||
205 | // Create a restriction that will discard rows of appointments that are definitely not in our |
||
206 | // requested time frame |
||
207 | |||
208 | $table = mapi_folder_getcontentstable($calendar); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
209 | |||
210 | $restriction = |
||
211 | // OR |
||
212 | [ |
||
213 | RES_OR, |
||
214 | [ |
||
215 | [RES_AND, // Normal items: itemEnd must be after viewStart, itemStart must be before viewEnd |
||
216 | [ |
||
217 | [ |
||
218 | RES_PROPERTY, |
||
219 | [ |
||
220 | RELOP => RELOP_GT, |
||
221 | ULPROPTAG => $properties["duedate"], |
||
222 | VALUE => $viewstart, |
||
223 | ], |
||
224 | ], |
||
225 | [ |
||
226 | RES_PROPERTY, |
||
227 | [ |
||
228 | RELOP => RELOP_LT, |
||
229 | ULPROPTAG => $properties["startdate"], |
||
230 | VALUE => $viewend, |
||
231 | ], |
||
232 | ], |
||
233 | ], |
||
234 | ], |
||
235 | // OR |
||
236 | [ |
||
237 | RES_PROPERTY, |
||
238 | [ |
||
239 | RELOP => RELOP_EQ, |
||
240 | ULPROPTAG => $properties["recurring"], |
||
241 | VALUE => true, |
||
242 | ], |
||
243 | ], |
||
244 | ], // EXISTS OR |
||
245 | ]; // global OR |
||
246 | |||
247 | // Get requested properties, plus whatever we need |
||
248 | $proplist = [PR_ENTRYID, $properties["recurring"], $properties["recurring_data"], $properties["timezone_data"]]; |
||
249 | $proplist = array_merge($proplist, $propsrequested); |
||
250 | |||
251 | $rows = mapi_table_queryallrows($table, $proplist, $restriction); |
||
252 | |||
253 | // $rows now contains all the items that MAY be in the window; a recurring item needs expansion before including in the output. |
||
254 | |||
255 | foreach ($rows as $row) { |
||
256 | $items = []; |
||
257 | |||
258 | if (isset($row[$properties["recurring"]]) && $row[$properties["recurring"]]) { |
||
259 | // Recurring item |
||
260 | $rec = new Recurrence($store, $row); |
||
261 | |||
262 | // GetItems guarantees that the item overlaps the interval <$viewstart, $viewend> |
||
263 | $occurrences = $rec->getItems($viewstart, $viewend); |
||
264 | foreach ($occurrences as $occurrence) { |
||
265 | // The occurrence takes all properties from the main row, but overrides some properties (like start and end obviously) |
||
266 | $item = $occurrence + $row; |
||
267 | array_push($items, $item); |
||
268 | } |
||
269 | } |
||
270 | else { |
||
271 | // Normal item, it matched the search criteria and therefore overlaps the interval <$viewstart, $viewend> |
||
272 | array_push($items, $row); |
||
273 | } |
||
274 | |||
275 | $result = array_merge($result, $items); |
||
276 | } |
||
277 | |||
278 | // All items are guaranteed to overlap the interval <$viewstart, $viewend>. Note that we may be returning a few extra |
||
279 | // properties that the caller did not request (recurring, etc). This shouldn't be a problem though. |
||
280 | return $result; |
||
281 | } |
||
282 | |||
283 | /** |
||
284 | * Compares two entryIds. It is possible to have two different entryIds that should match as they |
||
285 | * represent the same object (in multiserver environments). |
||
286 | * |
||
287 | * @param mixed $entryId1 EntryID |
||
288 | * @param mixed $entryId2 EntryID |
||
289 | * |
||
290 | * @return bool Result of the comparison |
||
291 | */ |
||
292 | function compareEntryIds($entryId1, $entryId2) { |
||
293 | if (!is_string($entryId1) || !is_string($entryId2)) { |
||
294 | return false; |
||
295 | } |
||
296 | |||
297 | if ($entryId1 === $entryId2) { |
||
298 | // if normal comparison succeeds then we can directly say that entryids are same |
||
299 | return true; |
||
300 | } |
||
301 | |||
302 | return false; |
||
303 | } |
||
304 | |||
305 | /** |
||
306 | * Creates a goid from an ical uuid. |
||
307 | * |
||
308 | * @param string $uid |
||
309 | * |
||
310 | * @return string binary string representation of goid |
||
311 | */ |
||
312 | function getGoidFromUid($uid) { |
||
313 | return hex2bin("040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000" . |
||
314 | bin2hex(pack("V", 12 + strlen($uid)) . "vCal-Uid" . pack("V", 1) . $uid)); |
||
315 | } |
||
316 | |||
317 | /** |
||
318 | * Returns zero terminated goid. It is required for backwards compatibility. |
||
319 | * |
||
320 | * @param mixed $uid |
||
321 | * |
||
322 | * @return string an OL compatible GlobalObjectID |
||
323 | */ |
||
324 | function getGoidFromUidZero($uid) { |
||
325 | if (strlen($uid) <= 64) { |
||
326 | return hex2bin("040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000" . |
||
327 | bin2hex(pack("V", 13 + strlen($uid)) . "vCal-Uid" . pack("V", 1) . $uid) . "00"); |
||
328 | } |
||
329 | |||
330 | return hex2bin($uid); |
||
331 | } |
||
332 | |||
333 | /** |
||
334 | * Creates an ical uuid from a goid. |
||
335 | * |
||
336 | * @param string $goid |
||
337 | * |
||
338 | * @return null|string ical uuid |
||
339 | */ |
||
340 | function getUidFromGoid($goid) { |
||
341 | // check if "vCal-Uid" is somewhere in outlookid case-insensitive |
||
342 | $uid = stristr($goid, "vCal-Uid"); |
||
343 | if ($uid !== false) { |
||
344 | // get the length of the ical id - go back 4 position from where "vCal-Uid" was found |
||
345 | $begin = unpack("V", substr($goid, strlen($uid) * (-1) - 4, 4)); |
||
346 | |||
347 | // remove "vCal-Uid" and packed "1" and use the ical id length |
||
348 | return trim(substr($uid, 12, $begin[1] - 12)); |
||
349 | } |
||
350 | |||
351 | return null; |
||
352 | } |
||
353 | |||
354 | /** |
||
355 | * Converts a MAPI property tag into a human readable value. |
||
356 | * |
||
357 | * This depends on the definition of the property tag in core |
||
358 | * |
||
359 | * @example prop2Str(0x0037001e) => 'PR_SUBJECT' |
||
360 | * |
||
361 | * @param mixed $property |
||
362 | * |
||
363 | * @return string the symbolic name of the property tag |
||
364 | */ |
||
365 | function prop2Str($property) { |
||
366 | if (is_integer($property)) { |
||
367 | // Retrieve constants categories, zcore provides them in 'Core' |
||
368 | foreach (get_defined_constants(true)['Core'] as $key => $value) { |
||
369 | if ($property == $value && substr($key, 0, 3) == 'PR_') { |
||
370 | return $key; |
||
371 | } |
||
372 | } |
||
373 | |||
374 | return sprintf("0x%08X", $property); |
||
375 | } |
||
376 | |||
377 | return $property; |
||
378 | } |
||
379 | |||
380 | /** |
||
381 | * Converts all constants of restriction into a human readable strings. |
||
382 | * |
||
383 | * @param mixed $restriction |
||
384 | */ |
||
385 | function simplifyRestriction($restriction) { |
||
386 | if (!is_array($restriction)) { |
||
387 | return $restriction; |
||
388 | } |
||
389 | |||
390 | switch ($restriction[0]) { |
||
391 | case RES_AND: |
||
392 | $restriction[0] = "RES_AND"; |
||
393 | if (isset($restriction[1][0]) && is_array($restriction[1][0])) { |
||
394 | foreach ($restriction[1] as &$res) { |
||
395 | $res = simplifyRestriction($res); |
||
396 | } |
||
397 | unset($res); |
||
398 | } |
||
399 | elseif (isset($restriction[1]) && $restriction[1]) { |
||
400 | $restriction[1] = simplifyRestriction($restriction[1]); |
||
401 | } |
||
402 | break; |
||
403 | |||
404 | case RES_OR: |
||
405 | $restriction[0] = "RES_OR"; |
||
406 | if (isset($restriction[1][0]) && is_array($restriction[1][0])) { |
||
407 | foreach ($restriction[1] as &$res) { |
||
408 | $res = simplifyRestriction($res); |
||
409 | } |
||
410 | unset($res); |
||
411 | } |
||
412 | elseif (isset($restriction[1]) && $restriction[1]) { |
||
413 | $restriction[1] = simplifyRestriction($restriction[1]); |
||
414 | } |
||
415 | break; |
||
416 | |||
417 | case RES_NOT: |
||
418 | $restriction[0] = "RES_NOT"; |
||
419 | $restriction[1][0] = simplifyRestriction($restriction[1][0]); |
||
420 | break; |
||
421 | |||
422 | case RES_COMMENT: |
||
423 | $restriction[0] = "RES_COMMENT"; |
||
424 | $res = simplifyRestriction($restriction[1][RESTRICTION]); |
||
425 | $props = $restriction[1][PROPS]; |
||
426 | |||
427 | foreach ($props as &$prop) { |
||
428 | $propTag = $prop[ULPROPTAG]; |
||
429 | $propValue = $prop[VALUE]; |
||
430 | |||
431 | unset($prop); |
||
432 | |||
433 | $prop["ULPROPTAG"] = is_string($propTag) ? $propTag : prop2Str($propTag); |
||
434 | $prop["VALUE"] = is_array($propValue) ? $propValue[$propTag] : $propValue; |
||
435 | } |
||
436 | unset($prop, $restriction[1]); |
||
437 | |||
438 | $restriction[1]["RESTRICTION"] = $res; |
||
439 | $restriction[1]["PROPS"] = $props; |
||
440 | break; |
||
441 | |||
442 | case RES_PROPERTY: |
||
443 | $restriction[0] = "RES_PROPERTY"; |
||
444 | $propTag = $restriction[1][ULPROPTAG]; |
||
445 | $propValue = $restriction[1][VALUE]; |
||
446 | $relOp = $restriction[1][RELOP]; |
||
447 | |||
448 | unset($restriction[1]); |
||
449 | |||
450 | // relop flags |
||
451 | $relOpFlags = ""; |
||
452 | if ($relOp == RELOP_LT) { |
||
453 | $relOpFlags = "RELOP_LT"; |
||
454 | } |
||
455 | elseif ($relOp == RELOP_LE) { |
||
456 | $relOpFlags = "RELOP_LE"; |
||
457 | } |
||
458 | elseif ($relOp == RELOP_GT) { |
||
459 | $relOpFlags = "RELOP_GT"; |
||
460 | } |
||
461 | elseif ($relOp == RELOP_GE) { |
||
462 | $relOpFlags = "RELOP_GE"; |
||
463 | } |
||
464 | elseif ($relOp == RELOP_EQ) { |
||
465 | $relOpFlags = "RELOP_EQ"; |
||
466 | } |
||
467 | elseif ($relOp == RELOP_NE) { |
||
468 | $relOpFlags = "RELOP_NE"; |
||
469 | } |
||
470 | elseif ($relOp == RELOP_RE) { |
||
471 | $relOpFlags = "RELOP_RE"; |
||
472 | } |
||
473 | |||
474 | $restriction[1]["RELOP"] = $relOpFlags; |
||
475 | $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : prop2Str($propTag); |
||
476 | $restriction[1]["VALUE"] = is_array($propValue) ? $propValue[$propTag] : $propValue; |
||
477 | break; |
||
478 | |||
479 | case RES_CONTENT: |
||
480 | $restriction[0] = "RES_CONTENT"; |
||
481 | $propTag = $restriction[1][ULPROPTAG]; |
||
482 | $propValue = $restriction[1][VALUE]; |
||
483 | $fuzzyLevel = $restriction[1][FUZZYLEVEL]; |
||
484 | |||
485 | unset($restriction[1]); |
||
486 | |||
487 | // fuzzy level flags |
||
488 | $levels = []; |
||
489 | |||
490 | if (($fuzzyLevel & FL_SUBSTRING) == FL_SUBSTRING) { |
||
491 | $levels[] = "FL_SUBSTRING"; |
||
492 | } |
||
493 | elseif (($fuzzyLevel & FL_PREFIX) == FL_PREFIX) { |
||
494 | $levels[] = "FL_PREFIX"; |
||
495 | } |
||
496 | else { |
||
497 | $levels[] = "FL_FULLSTRING"; |
||
498 | } |
||
499 | |||
500 | if (($fuzzyLevel & FL_IGNORECASE) == FL_IGNORECASE) { |
||
501 | $levels[] = "FL_IGNORECASE"; |
||
502 | } |
||
503 | |||
504 | if (($fuzzyLevel & FL_IGNORENONSPACE) == FL_IGNORENONSPACE) { |
||
505 | $levels[] = "FL_IGNORENONSPACE"; |
||
506 | } |
||
507 | |||
508 | if (($fuzzyLevel & FL_LOOSE) == FL_LOOSE) { |
||
509 | $levels[] = "FL_LOOSE"; |
||
510 | } |
||
511 | |||
512 | $fuzzyLevelFlags = implode(" | ", $levels); |
||
513 | |||
514 | $restriction[1]["FUZZYLEVEL"] = $fuzzyLevelFlags; |
||
515 | $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : prop2Str($propTag); |
||
516 | $restriction[1]["VALUE"] = is_array($propValue) ? $propValue[$propTag] : $propValue; |
||
517 | break; |
||
518 | |||
519 | case RES_COMPAREPROPS: |
||
520 | $propTag1 = $restriction[1][ULPROPTAG1]; |
||
521 | $propTag2 = $restriction[1][ULPROPTAG2]; |
||
522 | |||
523 | unset($restriction[1]); |
||
524 | |||
525 | $restriction[1]["ULPROPTAG1"] = is_string($propTag1) ? $proptag1 : prop2Str($proptag1); |
||
526 | $restriction[1]["ULPROPTAG2"] = is_string($propTag2) ? $propTag2 : prop2Str($propTag2); |
||
527 | break; |
||
528 | |||
529 | case RES_BITMASK: |
||
530 | $restriction[0] = "RES_BITMASK"; |
||
531 | $propTag = $restriction[1][ULPROPTAG]; |
||
532 | $maskType = $restriction[1][ULTYPE]; |
||
533 | $maskValue = $restriction[1][ULMASK]; |
||
534 | |||
535 | unset($restriction[1]); |
||
536 | |||
537 | // relop flags |
||
538 | $maskTypeFlags = ""; |
||
539 | if ($maskType == BMR_EQZ) { |
||
540 | $maskTypeFlags = "BMR_EQZ"; |
||
541 | } |
||
542 | elseif ($maskType == BMR_NEZ) { |
||
543 | $maskTypeFlags = "BMR_NEZ"; |
||
544 | } |
||
545 | |||
546 | $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : prop2Str($propTag); |
||
547 | $restriction[1]["ULTYPE"] = $maskTypeFlags; |
||
548 | $restriction[1]["ULMASK"] = $maskValue; |
||
549 | break; |
||
550 | |||
551 | case RES_SIZE: |
||
552 | $restriction[0] = "RES_SIZE"; |
||
553 | $propTag = $restriction[1][ULPROPTAG]; |
||
554 | $propValue = $restriction[1][CB]; |
||
555 | $relOp = $restriction[1][RELOP]; |
||
556 | |||
557 | unset($restriction[1]); |
||
558 | |||
559 | // relop flags |
||
560 | $relOpFlags = ""; |
||
561 | if ($relOp == RELOP_LT) { |
||
562 | $relOpFlags = "RELOP_LT"; |
||
563 | } |
||
564 | elseif ($relOp == RELOP_LE) { |
||
565 | $relOpFlags = "RELOP_LE"; |
||
566 | } |
||
567 | elseif ($relOp == RELOP_GT) { |
||
568 | $relOpFlags = "RELOP_GT"; |
||
569 | } |
||
570 | elseif ($relOp == RELOP_GE) { |
||
571 | $relOpFlags = "RELOP_GE"; |
||
572 | } |
||
573 | elseif ($relOp == RELOP_EQ) { |
||
574 | $relOpFlags = "RELOP_EQ"; |
||
575 | } |
||
576 | elseif ($relOp == RELOP_NE) { |
||
577 | $relOpFlags = "RELOP_NE"; |
||
578 | } |
||
579 | elseif ($relOp == RELOP_RE) { |
||
580 | $relOpFlags = "RELOP_RE"; |
||
581 | } |
||
582 | |||
583 | $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : prop2Str($propTag); |
||
584 | $restriction[1]["RELOP"] = $relOpFlags; |
||
585 | $restriction[1]["CB"] = $propValue; |
||
586 | break; |
||
587 | |||
588 | case RES_EXIST: |
||
589 | $propTag = $restriction[1][ULPROPTAG]; |
||
590 | |||
591 | unset($restriction[1]); |
||
592 | |||
593 | $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : prop2Str($propTag); |
||
594 | break; |
||
595 | |||
596 | case RES_SUBRESTRICTION: |
||
597 | $propTag = $restriction[1][ULPROPTAG]; |
||
598 | $res = simplifyRestriction($restriction[1][RESTRICTION]); |
||
599 | |||
600 | unset($restriction[1]); |
||
601 | |||
602 | $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : prop2Str($propTag); |
||
603 | $restriction[1]["RESTRICTION"] = $res; |
||
604 | break; |
||
605 | } |
||
606 | |||
607 | return $restriction; |
||
608 | } |
||
609 |