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.
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
25 * @see Zend_Gdata_Entry
27 require_once 'Zend/Gdata/Entry.php';
30 * @see Zend_Gdata_Extension_FeedLink
32 require_once 'Zend/Gdata/Extension/FeedLink.php';
35 * @see Zend_Gdata_Gapps_Extension_Login
37 require_once 'Zend/Gdata/Gapps/Extension/Login.php';
40 * @see Zend_Gdata_Gapps_Extension_Name
42 require_once 'Zend/Gdata/Gapps/Extension/Name.php';
45 * @see Zend_Gdata_Gapps_Extension_Quota
47 require_once 'Zend/Gdata/Gapps/Extension/Quota.php';
50 * Data model class for a Google Apps User Entry.
52 * Each user entry describes a single user within a Google Apps hosted
55 * To transfer user entries to and from the Google Apps servers, including
56 * creating new entries, refer to the Google Apps service class,
59 * This class represents <atom:entry> in the Google Data protocol.
64 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
65 * @license http://framework.zend.com/license/new-bsd New BSD License
67 class Zend_Gdata_Gapps_UserEntry extends Zend_Gdata_Entry
70 protected $_entryClassName = 'Zend_Gdata_Gapps_UserEntry';
73 * <apps:login> element containing information about this user's
74 * account, including their username and permissions.
76 * @var Zend_Gdata_Gapps_Extension_Login
78 protected $_login = null;
81 * <apps:name> element containing the user's actual name.
83 * @var Zend_Gdata_Gapps_Extension_Name
85 protected $_name = null;
88 * <apps:quotq> element describing any storage quotas in place for
91 * @var Zend_Gdata_Gapps_Extension_Quota
93 protected $_quota = null;
96 * <gd:feedLink> element containing information about other feeds
97 * relevant to this entry.
99 * @var Zend_Gdata_Extension_FeedLink
101 protected $_feedLink = array();
104 * Create a new instance.
106 * @param DOMElement $element (optional) DOMElement from which this
107 * object should be constructed.
109 public function __construct($element = null)
111 $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
112 parent::__construct($element);
116 * Retrieves a DOMElement which corresponds to this element and all
117 * child properties. This is used to build an entry back into a DOM
118 * and eventually XML text for application storage/persistence.
120 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
121 * @return DOMElement The DOMElement representing this element and all
124 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
126 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
127 if ($this->_login !== null) {
128 $element->appendChild($this->_login->getDOM($element->ownerDocument));
130 if ($this->_name !== null) {
131 $element->appendChild($this->_name->getDOM($element->ownerDocument));
133 if ($this->_quota !== null) {
134 $element->appendChild($this->_quota->getDOM($element->ownerDocument));
136 foreach ($this->_feedLink as $feedLink) {
137 $element->appendChild($feedLink->getDOM($element->ownerDocument));
143 * Creates individual Entry objects of the appropriate type and
144 * stores them as members of this entry based upon DOM data.
146 * @param DOMNode $child The DOMNode to process
148 protected function takeChildFromDOM($child)
150 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
152 switch ($absoluteNodeName) {
153 case $this->lookupNamespace('apps') . ':' . 'login';
154 $login = new Zend_Gdata_Gapps_Extension_Login();
155 $login->transferFromDOM($child);
156 $this->_login = $login;
158 case $this->lookupNamespace('apps') . ':' . 'name';
159 $name = new Zend_Gdata_Gapps_Extension_Name();
160 $name->transferFromDOM($child);
161 $this->_name = $name;
163 case $this->lookupNamespace('apps') . ':' . 'quota';
164 $quota = new Zend_Gdata_Gapps_Extension_Quota();
165 $quota->transferFromDOM($child);
166 $this->_quota = $quota;
168 case $this->lookupNamespace('gd') . ':' . 'feedLink';
169 $feedLink = new Zend_Gdata_Extension_FeedLink();
170 $feedLink->transferFromDOM($child);
171 $this->_feedLink[] = $feedLink;
174 parent::takeChildFromDOM($child);
180 * Get the value of the login property for this object.
183 * @return Zend_Gdata_Gapps_Extension_Login The requested object.
185 public function getLogin()
187 return $this->_login;
191 * Set the value of the login property for this object. This property
192 * is used to store the username address of the current user.
194 * @param Zend_Gdata_Gapps_Extension_Login $value The desired value for
195 * this instance's login property.
196 * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface.
198 public function setLogin($value)
200 $this->_login = $value;
205 * Get the value of the name property for this object.
208 * @return Zend_Gdata_Gapps_Extension_Name The requested object.
210 public function getName()
216 * Set the value of the name property for this object. This property
217 * is used to store the full name of the current user.
219 * @param Zend_Gdata_Gapps_Extension_Name $value The desired value for
220 * this instance's name property.
221 * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface.
223 public function setName($value)
225 $this->_name = $value;
230 * Get the value of the quota property for this object.
233 * @return Zend_Gdata_Gapps_Extension_Quota The requested object.
235 public function getQuota()
237 return $this->_quota;
241 * Set the value of the quota property for this object. This property
242 * is used to store the amount of storage available for the current
243 * user. Quotas may not be modifiable depending on the domain used.
245 * @param Zend_Gdata_Gapps_Extension_Quota $value The desired value for
246 * this instance's quota property.
247 * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface.
249 public function setQuota($value)
251 $this->_quota = $value;
256 * Returns all feed links for this entry, or if a rel value is
257 * specified, the feed link associated with that value is returned.
259 * @param string $rel The rel value of the link to be found. If null,
260 * the array of links is returned instead.
261 * @return mixed Either an array of Zend_Gdata_Extension_FeedLink
262 * objects if $rel is null, a single
263 * Zend_Gdata_Extension_FeedLink object if $rel is specified
264 * and a matching feed link is found, or null if $rel is
265 * specified and no matching feed link is found.
267 public function getFeedLink($rel = null)
270 return $this->_feedLink;
272 foreach ($this->_feedLink as $feedLink) {
273 if ($feedLink->rel == $rel) {
282 * Set the value of the feed link property for this object. This property
283 * is used to provide links to alternative feeds relevant to this entry.
285 * @param array $value A collection of
286 * Zend_Gdata_Gapps_Extension_FeedLink objects.
287 * @return Zend_Gdata_Gapps_EventEntry Provides a fluent interface.
289 public function setFeedLink($value)
291 $this->_feedLink = $value;