2
0

UserQuery.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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_Gapps_Query
  24. */
  25. require_once('Zend/Gdata/Gapps/Query.php');
  26. /**
  27. * Assists in constructing queries for Google Apps user entries.
  28. * Instances of this class can be provided in many places where a URL is
  29. * required.
  30. *
  31. * For information on submitting queries to a server, see the Google Apps
  32. * service class, Zend_Gdata_Gapps.
  33. *
  34. * @category Zend
  35. * @package Zend_Gdata
  36. * @subpackage Gapps
  37. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  38. * @license http://framework.zend.com/license/new-bsd New BSD License
  39. */
  40. class Zend_Gdata_Gapps_UserQuery extends Zend_Gdata_Gapps_Query
  41. {
  42. /**
  43. * If not null, specifies the username of the user who should be
  44. * retrieved by this query.
  45. *
  46. * @var string
  47. */
  48. protected $_username = null;
  49. /**
  50. * Create a new instance.
  51. *
  52. * @param string $domain (optional) The Google Apps-hosted domain to use
  53. * when constructing query URIs.
  54. * @param string $username (optional) Value for the username
  55. * property.
  56. * @param string $startUsername (optional) Value for the
  57. * startUsername property.
  58. */
  59. public function __construct($domain = null, $username = null,
  60. $startUsername = null)
  61. {
  62. parent::__construct($domain);
  63. $this->setUsername($username);
  64. $this->setStartUsername($startUsername);
  65. }
  66. /**
  67. * Set the username to query for. When set, only users with a username
  68. * matching this value will be returned in search results. Set to
  69. * null to disable filtering by username.
  70. *
  71. * @see getUsername
  72. * @param string $value The username to filter search results by, or null to
  73. * disable.
  74. */
  75. public function setUsername($value)
  76. {
  77. $this->_username = $value;
  78. }
  79. /**
  80. * Get the username to query for. If no username is set, null will be
  81. * returned.
  82. *
  83. * @param string $value The username to filter search results by, or
  84. * null if disabled.
  85. */
  86. public function getUsername()
  87. {
  88. return $this->_username;
  89. }
  90. /**
  91. * Set the first username which should be displayed when retrieving
  92. * a list of users.
  93. *
  94. * @param string $value The first username to be returned, or null to
  95. * disable.
  96. */
  97. public function setStartUsername($value)
  98. {
  99. if ($value !== null) {
  100. $this->_params['startUsername'] = $value;
  101. } else {
  102. unset($this->_params['startUsername']);
  103. }
  104. }
  105. /**
  106. * Get the first username which should be displayed when retrieving
  107. * a list of users.
  108. *
  109. * @see setStartUsername
  110. * @return string The first username to be returned, or null if
  111. * disabled.
  112. */
  113. public function getStartUsername()
  114. {
  115. if (array_key_exists('startUsername', $this->_params)) {
  116. return $this->_params['startUsername'];
  117. } else {
  118. return null;
  119. }
  120. }
  121. /**
  122. * Returns the query URL generated by this query instance.
  123. *
  124. * @return string The query URL for this instance.
  125. */
  126. public function getQueryUrl()
  127. {
  128. $uri = $this->getBaseUrl();
  129. $uri .= Zend_Gdata_Gapps::APPS_USER_PATH;
  130. if ($this->_username !== null) {
  131. $uri .= '/' . $this->_username;
  132. }
  133. $uri .= $this->getQueryString();
  134. return $uri;
  135. }
  136. }