1 | <?php
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Zend Framework
|
---|
5 | *
|
---|
6 | * LICENSE
|
---|
7 | *
|
---|
8 | * This source file is subject to the new BSD license that is bundled
|
---|
9 | * with this package in the file LICENSE.txt.
|
---|
10 | * It is also available through the world-wide-web at this URL:
|
---|
11 | * http://framework.zend.com/license/new-bsd
|
---|
12 | * If you did not receive a copy of the license and are unable to
|
---|
13 | * obtain it through the world-wide-web, please send an email
|
---|
14 | * to license@zend.com so we can send you a copy immediately.
|
---|
15 | *
|
---|
16 | * @category Zend
|
---|
17 | * @package Zend_Gdata
|
---|
18 | * @subpackage Gapps
|
---|
19 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
20 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
21 | */
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * @see Zend_Gdata_Entry
|
---|
25 | */
|
---|
26 | require_once 'Zend/Gdata/Entry.php';
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * @see Zend_Gdata_Extension_FeedLink
|
---|
30 | */
|
---|
31 | require_once 'Zend/Gdata/Extension/FeedLink.php';
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * @see Zend_Gdata_Gapps_Extension_Login
|
---|
35 | */
|
---|
36 | require_once 'Zend/Gdata/Gapps/Extension/Login.php';
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * @see Zend_Gdata_Gapps_Extension_Name
|
---|
40 | */
|
---|
41 | require_once 'Zend/Gdata/Gapps/Extension/Name.php';
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * @see Zend_Gdata_Gapps_Extension_Quota
|
---|
45 | */
|
---|
46 | require_once 'Zend/Gdata/Gapps/Extension/Quota.php';
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Data model class for a Google Apps User Entry.
|
---|
50 | *
|
---|
51 | * Each user entry describes a single user within a Google Apps hosted
|
---|
52 | * domain.
|
---|
53 | *
|
---|
54 | * To transfer user entries to and from the Google Apps servers, including
|
---|
55 | * creating new entries, refer to the Google Apps service class,
|
---|
56 | * Zend_Gdata_Gapps.
|
---|
57 | *
|
---|
58 | * This class represents <atom:entry> in the Google Data protocol.
|
---|
59 | *
|
---|
60 | * @category Zend
|
---|
61 | * @package Zend_Gdata
|
---|
62 | * @subpackage Gapps
|
---|
63 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
64 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
65 | */
|
---|
66 | class Zend_Gdata_Gapps_UserEntry extends Zend_Gdata_Entry
|
---|
67 | {
|
---|
68 |
|
---|
69 | protected $_entryClassName = 'Zend_Gdata_Gapps_UserEntry';
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * <apps:login> element containing information about this user's
|
---|
73 | * account, including their username and permissions.
|
---|
74 | *
|
---|
75 | * @var Zend_Gdata_Gapps_Extension_Login
|
---|
76 | */
|
---|
77 | protected $_login = null;
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * <apps:name> element containing the user's actual name.
|
---|
81 | *
|
---|
82 | * @var Zend_Gdata_Gapps_Extension_Name
|
---|
83 | */
|
---|
84 | protected $_name = null;
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * <apps:quotq> element describing any storage quotas in place for
|
---|
88 | * this user.
|
---|
89 | *
|
---|
90 | * @var Zend_Gdata_Gapps_Extension_Quota
|
---|
91 | */
|
---|
92 | protected $_quota = null;
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * <gd:feedLink> element containing information about other feeds
|
---|
96 | * relevant to this entry.
|
---|
97 | *
|
---|
98 | * @var Zend_Gdata_Extension_FeedLink
|
---|
99 | */
|
---|
100 | protected $_feedLink = array();
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * Create a new instance.
|
---|
104 | *
|
---|
105 | * @param DOMElement $element (optional) DOMElement from which this
|
---|
106 | * object should be constructed.
|
---|
107 | */
|
---|
108 | public function __construct($element = null)
|
---|
109 | {
|
---|
110 | $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
|
---|
111 | parent::__construct($element);
|
---|
112 | }
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * Retrieves a DOMElement which corresponds to this element and all
|
---|
116 | * child properties. This is used to build an entry back into a DOM
|
---|
117 | * and eventually XML text for application storage/persistence.
|
---|
118 | *
|
---|
119 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
120 | * @return DOMElement The DOMElement representing this element and all
|
---|
121 | * child properties.
|
---|
122 | */
|
---|
123 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
124 | {
|
---|
125 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
126 | if ($this->_login !== null) {
|
---|
127 | $element->appendChild($this->_login->getDOM($element->ownerDocument));
|
---|
128 | }
|
---|
129 | if ($this->_name !== null) {
|
---|
130 | $element->appendChild($this->_name->getDOM($element->ownerDocument));
|
---|
131 | }
|
---|
132 | if ($this->_quota !== null) {
|
---|
133 | $element->appendChild($this->_quota->getDOM($element->ownerDocument));
|
---|
134 | }
|
---|
135 | foreach ($this->_feedLink as $feedLink) {
|
---|
136 | $element->appendChild($feedLink->getDOM($element->ownerDocument));
|
---|
137 | }
|
---|
138 | return $element;
|
---|
139 | }
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * Creates individual Entry objects of the appropriate type and
|
---|
143 | * stores them as members of this entry based upon DOM data.
|
---|
144 | *
|
---|
145 | * @param DOMNode $child The DOMNode to process
|
---|
146 | */
|
---|
147 | protected function takeChildFromDOM($child)
|
---|
148 | {
|
---|
149 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
|
---|
150 |
|
---|
151 | switch ($absoluteNodeName) {
|
---|
152 | case $this->lookupNamespace('apps') . ':' . 'login';
|
---|
153 | $login = new Zend_Gdata_Gapps_Extension_Login();
|
---|
154 | $login->transferFromDOM($child);
|
---|
155 | $this->_login = $login;
|
---|
156 | break;
|
---|
157 | case $this->lookupNamespace('apps') . ':' . 'name';
|
---|
158 | $name = new Zend_Gdata_Gapps_Extension_Name();
|
---|
159 | $name->transferFromDOM($child);
|
---|
160 | $this->_name = $name;
|
---|
161 | break;
|
---|
162 | case $this->lookupNamespace('apps') . ':' . 'quota';
|
---|
163 | $quota = new Zend_Gdata_Gapps_Extension_Quota();
|
---|
164 | $quota->transferFromDOM($child);
|
---|
165 | $this->_quota = $quota;
|
---|
166 | break;
|
---|
167 | case $this->lookupNamespace('gd') . ':' . 'feedLink';
|
---|
168 | $feedLink = new Zend_Gdata_Extension_FeedLink();
|
---|
169 | $feedLink->transferFromDOM($child);
|
---|
170 | $this->_feedLink[] = $feedLink;
|
---|
171 | break;
|
---|
172 | default:
|
---|
173 | parent::takeChildFromDOM($child);
|
---|
174 | break;
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * Get the value of the login property for this object.
|
---|
180 | *
|
---|
181 | * @see setLogin
|
---|
182 | * @return Zend_Gdata_Gapps_Extension_Login The requested object.
|
---|
183 | */
|
---|
184 | public function getLogin()
|
---|
185 | {
|
---|
186 | return $this->_login;
|
---|
187 | }
|
---|
188 |
|
---|
189 | /**
|
---|
190 | * Set the value of the login property for this object. This property
|
---|
191 | * is used to store the username address of the current user.
|
---|
192 | *
|
---|
193 | * @param Zend_Gdata_Gapps_Extension_Login $value The desired value for
|
---|
194 | * this instance's login property.
|
---|
195 | * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface.
|
---|
196 | */
|
---|
197 | public function setLogin($value)
|
---|
198 | {
|
---|
199 | $this->_login = $value;
|
---|
200 | return $this;
|
---|
201 | }
|
---|
202 |
|
---|
203 | /**
|
---|
204 | * Get the value of the name property for this object.
|
---|
205 | *
|
---|
206 | * @see setName
|
---|
207 | * @return Zend_Gdata_Gapps_Extension_Name The requested object.
|
---|
208 | */
|
---|
209 | public function getName()
|
---|
210 | {
|
---|
211 | return $this->_name;
|
---|
212 | }
|
---|
213 |
|
---|
214 | /**
|
---|
215 | * Set the value of the name property for this object. This property
|
---|
216 | * is used to store the full name of the current user.
|
---|
217 | *
|
---|
218 | * @param Zend_Gdata_Gapps_Extension_Name $value The desired value for
|
---|
219 | * this instance's name property.
|
---|
220 | * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface.
|
---|
221 | */
|
---|
222 | public function setName($value)
|
---|
223 | {
|
---|
224 | $this->_name = $value;
|
---|
225 | return $this;
|
---|
226 | }
|
---|
227 |
|
---|
228 | /**
|
---|
229 | * Get the value of the quota property for this object.
|
---|
230 | *
|
---|
231 | * @see setQuota
|
---|
232 | * @return Zend_Gdata_Gapps_Extension_Quota The requested object.
|
---|
233 | */
|
---|
234 | public function getQuota()
|
---|
235 | {
|
---|
236 | return $this->_quota;
|
---|
237 | }
|
---|
238 |
|
---|
239 | /**
|
---|
240 | * Set the value of the quota property for this object. This property
|
---|
241 | * is used to store the amount of storage available for the current
|
---|
242 | * user. Quotas may not be modifiable depending on the domain used.
|
---|
243 | *
|
---|
244 | * @param Zend_Gdata_Gapps_Extension_Quota $value The desired value for
|
---|
245 | * this instance's quota property.
|
---|
246 | * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface.
|
---|
247 | */
|
---|
248 | public function setQuota($value)
|
---|
249 | {
|
---|
250 | $this->_quota = $value;
|
---|
251 | return $this;
|
---|
252 | }
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * Returns all feed links for this entry, or if a rel value is
|
---|
256 | * specified, the feed link associated with that value is returned.
|
---|
257 | *
|
---|
258 | * @param string $rel The rel value of the link to be found. If null,
|
---|
259 | * the array of links is returned instead.
|
---|
260 | * @return mixed Either an array of Zend_Gdata_Extension_FeedLink
|
---|
261 | * objects if $rel is null, a single
|
---|
262 | * Zend_Gdata_Extension_FeedLink object if $rel is specified
|
---|
263 | * and a matching feed link is found, or null if $rel is
|
---|
264 | * specified and no matching feed link is found.
|
---|
265 | */
|
---|
266 | public function getFeedLink($rel = null)
|
---|
267 | {
|
---|
268 | if ($rel == null) {
|
---|
269 | return $this->_feedLink;
|
---|
270 | } else {
|
---|
271 | foreach ($this->_feedLink as $feedLink) {
|
---|
272 | if ($feedLink->rel == $rel) {
|
---|
273 | return $feedLink;
|
---|
274 | }
|
---|
275 | }
|
---|
276 | return null;
|
---|
277 | }
|
---|
278 | }
|
---|
279 |
|
---|
280 | /**
|
---|
281 | * Set the value of the feed link property for this object. This property
|
---|
282 | * is used to provide links to alternative feeds relevant to this entry.
|
---|
283 | *
|
---|
284 | * @param array $value A collection of
|
---|
285 | * Zend_Gdata_Gapps_Extension_FeedLink objects.
|
---|
286 | * @return Zend_Gdata_Gapps_EventEntry Provides a fluent interface.
|
---|
287 | */
|
---|
288 | public function setFeedLink($value)
|
---|
289 | {
|
---|
290 | $this->_feedLink = $value;
|
---|
291 | return $this;
|
---|
292 | }
|
---|
293 |
|
---|
294 | }
|
---|