1
|
|
|
<?php |
2
|
|
|
namespace Auth; |
3
|
|
|
|
4
|
|
|
trait LDAPGettableObject |
5
|
|
|
{ |
6
|
|
|
protected function getValueWithDefault($propName) |
7
|
|
|
{ |
8
|
|
|
if(isset($this->valueDefaults[$propName])) |
|
|
|
|
9
|
|
|
{ |
10
|
|
|
$tmp = $this->getFieldSingleValue($propName); |
|
|
|
|
11
|
|
|
if($tmp === false) |
12
|
|
|
{ |
13
|
|
|
return $this->valueDefaults[$propName]; |
|
|
|
|
14
|
|
|
} |
15
|
|
|
return $tmp; |
16
|
|
|
} |
17
|
|
|
return false; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
protected function getMultiValueProp($propName) |
21
|
|
|
{ |
22
|
|
|
if(in_array($propName, $this->multiValueProps)) |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
$tmp = $this->getField($propName); |
|
|
|
|
25
|
|
|
if(isset($tmp['count'])) |
26
|
|
|
{ |
27
|
|
|
unset($tmp['count']); |
28
|
|
|
} |
29
|
|
|
return $tmp; |
30
|
|
|
} |
31
|
|
|
return false; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function __get($propName) |
35
|
|
|
{ |
36
|
|
|
if(isset($this->labeleduri)) |
37
|
|
|
{ |
38
|
|
|
//Have multiple emails |
39
|
|
|
if($propName === 'mail') |
40
|
|
|
{ |
41
|
|
|
return $this->getFieldSingleValue('labeleduri'); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
if($propName === 'allMail') |
44
|
|
|
{ |
45
|
|
|
$tmp = $this->getField('mail'); |
|
|
|
|
46
|
|
|
if(isset($tmp['count'])) |
47
|
|
|
{ |
48
|
|
|
unset($tmp['count']); |
49
|
|
|
} |
50
|
|
|
return $tmp; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
$tmp = $this->getValueWithDefault($propName); |
54
|
|
|
if($tmp !== false) |
55
|
|
|
{ |
56
|
|
|
return $tmp; |
57
|
|
|
} |
58
|
|
|
$tmp = $this->getMultiValueProp($propName); |
59
|
|
|
if($tmp !== false) |
60
|
|
|
{ |
61
|
|
|
return $tmp; |
62
|
|
|
} |
63
|
|
|
return $this->getFieldSingleValue($propName); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function __isset($propName) |
67
|
|
|
{ |
68
|
|
|
if(isset($this->valueDefaults[$propName])) |
|
|
|
|
69
|
|
|
{ |
70
|
|
|
return true; |
71
|
|
|
} |
72
|
|
|
if(in_array($propName, $this->multiValueProps)) |
|
|
|
|
73
|
|
|
{ |
74
|
|
|
return true; |
75
|
|
|
} |
76
|
|
|
if(!is_object($this->ldapObj)) |
|
|
|
|
77
|
|
|
{ |
78
|
|
|
if(isset($this->ldapObj['labeleduri'])) |
|
|
|
|
79
|
|
|
{ |
80
|
|
|
if($propName === 'allMail') |
81
|
|
|
{ |
82
|
|
|
return true; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
return isset($this->ldapObj[$propName]); |
|
|
|
|
86
|
|
|
} |
87
|
|
|
if(is_object($this->ldapObj)) |
|
|
|
|
88
|
|
|
{ |
89
|
|
|
$lowerName = strtolower($propName); |
90
|
|
|
if(isset($this->ldapObj->labeleduri)) |
|
|
|
|
91
|
|
|
{ |
92
|
|
|
if($propName === 'allMail') |
93
|
|
|
{ |
94
|
|
|
return true; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
return isset($this->ldapObj->{$lowerName}); |
|
|
|
|
98
|
|
|
} |
99
|
|
|
return false; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
104
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.