2
0

MemberQuery.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 member 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_MemberQuery extends Zend_Gdata_Gapps_Query
  41. {
  42. /**
  43. * If not null, specifies the group id
  44. *
  45. * @var string
  46. */
  47. protected $_groupId = null;
  48. /**
  49. * If not null, specifies the member id of the user who should be
  50. * retrieved by this query.
  51. *
  52. * @var string
  53. */
  54. protected $_memberId = null;
  55. /**
  56. * Create a new instance.
  57. *
  58. * @param string $domain (optional) The Google Apps-hosted domain to use
  59. * when constructing query URIs.
  60. * @param string $groupId (optional) Value for the groupId property.
  61. * @param string $memberId (optional) Value for the memberId property.
  62. * @param string $startMemberId (optional) Value for the
  63. * startMemberId property.
  64. */
  65. public function __construct($domain = null, $groupId = null, $memberId = null,
  66. $startMemberId = null)
  67. {
  68. parent::__construct($domain);
  69. $this->setGroupId($groupId);
  70. $this->setMemberId($memberId);
  71. $this->setStartMemberId($startMemberId);
  72. }
  73. /**
  74. * Set the group id to query for.
  75. *
  76. * @see getGroupId
  77. * @param string $value The group id to filter search results by, or null to
  78. * disable.
  79. */
  80. public function setGroupId($value)
  81. {
  82. $this->_groupId = $value;
  83. }
  84. /**
  85. * Get the group id to query for. If no group id is set, null will be
  86. * returned.
  87. *
  88. * @param string $value The group id to filter search results by, or
  89. * null if disabled.
  90. * @return string The group id
  91. */
  92. public function getGroupId()
  93. {
  94. return $this->_groupId;
  95. }
  96. /**
  97. * Set the member id to query for. When set, only users with a member id
  98. * matching this value will be returned in search results. Set to
  99. * null to disable filtering by member id.
  100. *
  101. * @see getMemberId
  102. * @param string $value The member id to filter search results by, or null to
  103. * disable.
  104. */
  105. public function setMemberId($value)
  106. {
  107. $this->_memberId = $value;
  108. }
  109. /**
  110. * Get the member id to query for. If no member id is set, null will be
  111. * returned.
  112. *
  113. * @param string $value The member id to filter search results by, or
  114. * null if disabled.
  115. * @return The member id
  116. */
  117. public function getMemberId()
  118. {
  119. return $this->_memberId;
  120. }
  121. /**
  122. * Set the first member id which should be displayed when retrieving
  123. * a list of members.
  124. *
  125. * @param string $value The first member id to be returned, or null to
  126. * disable.
  127. */
  128. public function setStartMemberId($value)
  129. {
  130. if ($value !== null) {
  131. $this->_params['start'] = $value;
  132. } else {
  133. unset($this->_params['start']);
  134. }
  135. }
  136. /**
  137. * Get the first username which should be displayed when retrieving
  138. * a list of users.
  139. *
  140. * @see setStartUsername
  141. * @return string The first username to be returned, or null if
  142. * disabled.
  143. */
  144. public function getStartMemberId()
  145. {
  146. if (array_key_exists('start', $this->_params)) {
  147. return $this->_params['start'];
  148. } else {
  149. return null;
  150. }
  151. }
  152. /**
  153. * Returns the query URL generated by this query instance.
  154. *
  155. * @return string The query URL for this instance.
  156. */
  157. public function getQueryUrl()
  158. {
  159. $uri = Zend_Gdata_Gapps::APPS_BASE_FEED_URI;
  160. $uri .= Zend_Gdata_Gapps::APPS_GROUP_PATH;
  161. $uri .= '/' . $this->_domain;
  162. if ($this->_groupId !== null) {
  163. $uri .= '/' . $this->_groupId;
  164. } else {
  165. require_once 'Zend/Gdata/App/InvalidArgumentException.php';
  166. throw new Zend_Gdata_App_InvalidArgumentException(
  167. 'groupId must not be null');
  168. }
  169. $uri .= '/member';
  170. if ($this->_memberId !== null) {
  171. $uri .= '/' . $this->_memberId;
  172. }
  173. $uri .= $this->getQueryString();
  174. return $uri;
  175. }
  176. }