UserEntry.php 9.1 KB

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