UserQuery.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 user 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_UserQuery extends Zend_Gdata_Gapps_Query
  40. {
  41. /**
  42. * If not null, specifies the username of the user who should be
  43. * retrieved by this query.
  44. *
  45. * @var string
  46. */
  47. protected $_username = 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 $username (optional) Value for the username
  54. * property.
  55. * @param string $startUsername (optional) Value for the
  56. * startUsername property.
  57. */
  58. public function __construct($domain = null, $username = null,
  59. $startUsername = null)
  60. {
  61. parent::__construct($domain);
  62. $this->setUsername($username);
  63. $this->setStartUsername($startUsername);
  64. }
  65. /**
  66. * Set the username to query for. When set, only users with a username
  67. * matching this value will be returned in search results. Set to
  68. * null to disable filtering by username.
  69. *
  70. * @see getUsername
  71. * @param string $value The username to filter search results by, or null to
  72. * disable.
  73. */
  74. public function setUsername($value)
  75. {
  76. $this->_username = $value;
  77. }
  78. /**
  79. * Get the username to query for. If no username is set, null will be
  80. * returned.
  81. *
  82. * @param string $value The username to filter search results by, or
  83. * null if disabled.
  84. */
  85. public function getUsername()
  86. {
  87. return $this->_username;
  88. }
  89. /**
  90. * Set the first username which should be displayed when retrieving
  91. * a list of users.
  92. *
  93. * @param string $value The first username to be returned, or null to
  94. * disable.
  95. */
  96. public function setStartUsername($value)
  97. {
  98. if ($value !== null) {
  99. $this->_params['startUsername'] = $value;
  100. } else {
  101. unset($this->_params['startUsername']);
  102. }
  103. }
  104. /**
  105. * Get the first username which should be displayed when retrieving
  106. * a list of users.
  107. *
  108. * @see setStartUsername
  109. * @return string The first username to be returned, or null if
  110. * disabled.
  111. */
  112. public function getStartUsername()
  113. {
  114. if (array_key_exists('startUsername', $this->_params)) {
  115. return $this->_params['startUsername'];
  116. } else {
  117. return null;
  118. }
  119. }
  120. /**
  121. * Returns the query URL generated by this query instance.
  122. *
  123. * @return string The query URL for this instance.
  124. */
  125. public function getQueryUrl()
  126. {
  127. $uri = $this->getBaseUrl();
  128. $uri .= Zend_Gdata_Gapps::APPS_USER_PATH;
  129. if ($this->_username !== null) {
  130. $uri .= '/' . $this->_username;
  131. }
  132. $uri .= $this->getQueryString();
  133. return $uri;
  134. }
  135. }