2
0

NicknameEntry.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @see Zend_Gdata_Entry
  23. */
  24. require_once 'Zend/Gdata/Entry.php';
  25. /**
  26. * @see Zend_Gdata_Gapps_Extension_Login
  27. */
  28. require_once 'Zend/Gdata/Gapps/Extension/Login.php';
  29. /**
  30. * @see Zend_Gdata_Gapps_Extension_Nickname
  31. */
  32. require_once 'Zend/Gdata/Gapps/Extension/Nickname.php';
  33. /**
  34. * Data model class for a Google Apps Nickname Entry.
  35. *
  36. * Each nickname entry describes a single nickname within a Google Apps
  37. * hosted domain. Each user may own several nicknames, but each nickname may
  38. * only belong to one user. Multiple entries are contained within instances
  39. * of Zend_Gdata_Gapps_NicknameFeed.
  40. *
  41. * To transfer nickname entries to and from the Google Apps servers,
  42. * including creating new entries, refer to the Google Apps service class,
  43. * Zend_Gdata_Gapps.
  44. *
  45. * This class represents <atom:entry> in the Google Data protocol.
  46. *
  47. * @category Zend
  48. * @package Zend_Gdata
  49. * @subpackage Gapps
  50. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  51. * @license http://framework.zend.com/license/new-bsd New BSD License
  52. */
  53. class Zend_Gdata_Gapps_NicknameEntry extends Zend_Gdata_Entry
  54. {
  55. protected $_entryClassName = 'Zend_Gdata_Gapps_NicknameEntry';
  56. /**
  57. * <apps:login> element used to hold information about the owner
  58. * of this nickname, including their username.
  59. *
  60. * @var Zend_Gdata_Gapps_Extension_Login
  61. */
  62. protected $_login = null;
  63. /**
  64. * <apps:nickname> element used to hold the name of this nickname.
  65. *
  66. * @var Zend_Gdata_Gapps_Extension_Nickname
  67. */
  68. protected $_nickname = null;
  69. /**
  70. * Create a new instance.
  71. *
  72. * @param DOMElement $element (optional) DOMElement from which this
  73. * object should be constructed.
  74. */
  75. public function __construct($element = null)
  76. {
  77. $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
  78. parent::__construct($element);
  79. }
  80. /**
  81. * Retrieves a DOMElement which corresponds to this element and all
  82. * child properties. This is used to build an entry back into a DOM
  83. * and eventually XML text for application storage/persistence.
  84. *
  85. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  86. * @return DOMElement The DOMElement representing this element and all
  87. * child properties.
  88. */
  89. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  90. {
  91. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  92. if ($this->_login !== null) {
  93. $element->appendChild($this->_login->getDOM($element->ownerDocument));
  94. }
  95. if ($this->_nickname !== null) {
  96. $element->appendChild($this->_nickname->getDOM($element->ownerDocument));
  97. }
  98. return $element;
  99. }
  100. /**
  101. * Creates individual Entry objects of the appropriate type and
  102. * stores them as members of this entry based upon DOM data.
  103. *
  104. * @param DOMNode $child The DOMNode to process
  105. */
  106. protected function takeChildFromDOM($child)
  107. {
  108. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  109. switch ($absoluteNodeName) {
  110. case $this->lookupNamespace('apps') . ':' . 'login';
  111. $login = new Zend_Gdata_Gapps_Extension_Login();
  112. $login->transferFromDOM($child);
  113. $this->_login = $login;
  114. break;
  115. case $this->lookupNamespace('apps') . ':' . 'nickname';
  116. $nickname = new Zend_Gdata_Gapps_Extension_Nickname();
  117. $nickname->transferFromDOM($child);
  118. $this->_nickname = $nickname;
  119. break;
  120. default:
  121. parent::takeChildFromDOM($child);
  122. break;
  123. }
  124. }
  125. /**
  126. * Get the value of the login property for this object.
  127. *
  128. * @see setLogin
  129. * @return Zend_Gdata_Gapps_Extension_Login The requested object.
  130. */
  131. public function getLogin()
  132. {
  133. return $this->_login;
  134. }
  135. /**
  136. * Set the value of the login property for this object. This property
  137. * is used to store the username address of the current user.
  138. *
  139. * @param Zend_Gdata_Gapps_Extension_Login $value The desired value for
  140. * this instance's login property.
  141. * @return Zend_Gdata_Gapps_NicknameEntry Provides a fluent interface.
  142. */
  143. public function setLogin($value)
  144. {
  145. $this->_login = $value;
  146. return $this;
  147. }
  148. /**
  149. * Get the value of the nickname property for this object.
  150. *
  151. * @see setNickname
  152. * @return Zend_Gdata_Gapps_Extension_Nickname The requested object.
  153. */
  154. public function getNickname()
  155. {
  156. return $this->_nickname;
  157. }
  158. /**
  159. * Set the value of the nickname property for this object. This property
  160. * is used to store the the name of the current nickname.
  161. *
  162. * @param Zend_Gdata_Gapps_Extension_Nickname $value The desired value for
  163. * this instance's nickname property.
  164. * @return Zend_Gdata_Gapps_NicknameEntry Provides a fluent interface.
  165. */
  166. public function setNickname($value)
  167. {
  168. $this->_nickname = $value;
  169. return $this;
  170. }
  171. }