forked from 1afa/sabre-zarafa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.restrict.php
109 lines (99 loc) · 2.47 KB
/
function.restrict.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/*
* Copyright 2012 - 2013 Bokxing IT, http://www.bokxing-it.nl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* "Zarafa" is a registered trademark of Zarafa B.V.
*
* This software use SabreDAV, an open source software distributed
* with New BSD License. Please see <http://code.google.com/p/sabredav/>
* for more information about SabreDAV
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Project page: <http://github.com/bokxing-it/sabre-zarafa/>
*
*/
function
restrict_or ($first, $second)
{
return array(RES_OR, array($first, $second));
}
function
restrict_and ($first, $second)
{
return array(RES_AND, array($first, $second));
}
function
restrict_not ($first)
{
return array(RES_NOT, array($first));
}
function
restrict_exist ($property)
{
return array(RES_EXIST, array(ULPROPTAG => $property));
}
function
restrict_propval ($property, $value, $relop)
{
// $relop can be RELOP_EQ, RELOP_NE, etc
return restrict_and(
restrict_exist($property),
array ( RES_PROPERTY
, array ( RELOP => $relop
, ULPROPTAG => $property
, VALUE => array($property => $value)
)
)
);
}
function
restrict_propstring ($property, $value)
{
// Useful to restrict results to a string, like 'IPF.Contact'.
return restrict_and(
restrict_exist($property),
array ( RES_CONTENT
, array ( FUZZYLEVEL => FL_PREFIX | FL_IGNORECASE
, ULPROPTAG => $property
, VALUE => array($property => $value)
)
)
);
}
function
restrict_hidden ()
{
return restrict_and(
restrict_exist(PR_ATTR_HIDDEN),
restrict_propval(PR_ATTR_HIDDEN, TRUE, RELOP_EQ)
);
}
function
restrict_nonhidden ()
{
return restrict_or(
restrict_not(restrict_exist(PR_ATTR_HIDDEN)),
restrict_propval(PR_ATTR_HIDDEN, FALSE, RELOP_EQ)
);
}
function
tbl_restrict_propval ($table, $property, $value, $relop)
{
return mapi_table_restrict($table, restrict_propval($property, $value, $relop));
}
function
tbl_restrict_none ($table)
{
return mapi_table_restrict($table, array());
}