2
0

NicknameQuery.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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_Gapps_Query
  23. */
  24. require_once('Zend/Gdata/Gapps/Query.php');
  25. /**
  26. * Assists in constructing queries for Google Apps nickname entries.
  27. * Instances of this class can be provided in many places where a URL is
  28. * required.
  29. *
  30. * For information on submitting queries to a server, see the Google Apps
  31. * service class, Zend_Gdata_Gapps.
  32. *
  33. * @category Zend
  34. * @package Zend_Gdata
  35. * @subpackage Gapps
  36. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. */
  39. class Zend_Gdata_Gapps_NicknameQuery extends Zend_Gdata_Gapps_Query
  40. {
  41. /**
  42. * If not null, indicates the name of the nickname entry which
  43. * should be returned by this query.
  44. *
  45. * @var string
  46. */
  47. protected $_nickname = null;
  48. /**
  49. * Create a new instance.
  50. *
  51. * @param string $domain (optional) The Google Apps-hosted domain to use
  52. * when constructing query URIs.
  53. * @param string $nickname (optional) Value for the nickname
  54. * property.
  55. * @param string $username (optional) Value for the username
  56. * property.
  57. * @param string $startNickname (optional) Value for the
  58. * startNickname property.
  59. */
  60. public function __construct($domain = null, $nickname = null,
  61. $username = null, $startNickname = null)
  62. {
  63. parent::__construct($domain);
  64. $this->setNickname($nickname);
  65. $this->setUsername($username);
  66. $this->setStartNickname($startNickname);
  67. }
  68. /**
  69. * Set the nickname to query for. When set, only users with a nickname
  70. * matching this value will be returned in search results. Set to
  71. * null to disable filtering by username.
  72. *
  73. * @param string $value The nickname to filter search results by, or null
  74. * to disable.
  75. */
  76. public function setNickname($value)
  77. {
  78. $this->_nickname = $value;
  79. }
  80. /**
  81. * Get the nickname to query for. If no nickname is set, null will be
  82. * returned.
  83. *
  84. * @see setNickname
  85. * @return string The nickname to filter search results by, or null if
  86. * disabled.
  87. */
  88. public function getNickname()
  89. {
  90. return $this->_nickname;
  91. }
  92. /**
  93. * Set the username to query for. When set, only users with a username
  94. * matching this value will be returned in search results. Set to
  95. * null to disable filtering by username.
  96. *
  97. * @param string $value The username to filter search results by, or null
  98. * to disable.
  99. */
  100. public function setUsername($value)
  101. {
  102. if ($value !== null) {
  103. $this->_params['username'] = $value;
  104. }
  105. else {
  106. unset($this->_params['username']);
  107. }
  108. }
  109. /**
  110. * Get the username to query for. If no username is set, null will be
  111. * returned.
  112. *
  113. * @see setUsername
  114. * @return string The username to filter search results by, or null if
  115. * disabled.
  116. */
  117. public function getUsername()
  118. {
  119. if (array_key_exists('username', $this->_params)) {
  120. return $this->_params['username'];
  121. } else {
  122. return null;
  123. }
  124. }
  125. /**
  126. * Set the first nickname which should be displayed when retrieving
  127. * a list of nicknames.
  128. *
  129. * @param string $value The first nickname to be returned, or null to
  130. * disable.
  131. */
  132. public function setStartNickname($value)
  133. {
  134. if ($value !== null) {
  135. $this->_params['startNickname'] = $value;
  136. } else {
  137. unset($this->_params['startNickname']);
  138. }
  139. }
  140. /**
  141. * Get the first nickname which should be displayed when retrieving
  142. * a list of nicknames.
  143. *
  144. * @return string The first nickname to be returned, or null to
  145. * disable.
  146. */
  147. public function getStartNickname()
  148. {
  149. if (array_key_exists('startNickname', $this->_params)) {
  150. return $this->_params['startNickname'];
  151. } else {
  152. return null;
  153. }
  154. }
  155. /**
  156. * Returns the URL generated for this query, based on it's current
  157. * parameters.
  158. *
  159. * @return string A URL generated based on the state of this query.
  160. */
  161. public function getQueryUrl()
  162. {
  163. $uri = $this->getBaseUrl();
  164. $uri .= Zend_Gdata_Gapps::APPS_NICKNAME_PATH;
  165. if ($this->_nickname !== null) {
  166. $uri .= '/' . $this->_nickname;
  167. }
  168. $uri .= $this->getQueryString();
  169. return $uri;
  170. }
  171. }