GroupQuery.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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 group 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_GroupQuery extends Zend_Gdata_Gapps_Query
  41. {
  42. /**
  43. * If not null, specifies the group id of the group who should be
  44. * retrieved by this query.
  45. *
  46. * @var string
  47. */
  48. protected $_groupId = 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 $groupId (optional) Value for the groupId property.
  55. * @param string $startGroupName (optional) Value for the
  56. * startGroupName property.
  57. */
  58. public function __construct($domain = null, $groupId = null,
  59. $startGroupId = null)
  60. {
  61. parent::__construct($domain);
  62. $this->setGroupId($groupId);
  63. $this->setStartGroupId($startGroupId);
  64. }
  65. /**
  66. * Set the group id to query for. When set, only groups with a group id
  67. * matching this value will be returned in search results. Set to
  68. * null to disable filtering by group id.
  69. *
  70. * @see getGroupId
  71. * @param string $value The group id to filter search results by, or null to
  72. * disable.
  73. */
  74. public function setGroupId($value)
  75. {
  76. $this->_groupId = $value;
  77. }
  78. /**
  79. * Get the group id to query for. If no group id is set, null will be
  80. * returned.
  81. *
  82. * @param string $value The group id to filter search results by, or
  83. * null if disabled.
  84. */
  85. public function getGroupId()
  86. {
  87. return $this->_groupId;
  88. }
  89. /**
  90. * Set the member to query for. When set, only subscribers with an
  91. * email address matching this value will be returned in search results.
  92. * Set to null to disable filtering by username.
  93. *
  94. * @param string $value The member email address to filter search
  95. * results by, or null to disable.
  96. */
  97. public function setMember($value)
  98. {
  99. if ($value !== null) {
  100. $this->_params['member'] = $value;
  101. }
  102. else {
  103. unset($this->_params['member']);
  104. }
  105. }
  106. /**
  107. * Get the member email address to query for. If no member is set,
  108. * null will be returned.
  109. *
  110. * @see setMember
  111. * @return string The member email address to filter search
  112. * results by, or null if disabled.
  113. */
  114. public function getMember()
  115. {
  116. if (array_key_exists('member', $this->_params)) {
  117. return $this->_params['member'];
  118. } else {
  119. return null;
  120. }
  121. }
  122. /**
  123. * Sets the query parameter directOnly
  124. * @param bool $value
  125. */
  126. public function setDirectOnly($value)
  127. {
  128. if ($value !== null) {
  129. if($value == true) {
  130. $this->_params['directOnly'] = 'true';
  131. } else {
  132. $this->_params['directOnly'] = 'false';
  133. }
  134. } else {
  135. unset($this->_params['directOnly']);
  136. }
  137. }
  138. /**
  139. *
  140. * @see setDirectOnly
  141. * @return bool
  142. */
  143. public function getDirectOnly()
  144. {
  145. if (array_key_exists('directOnly', $this->_params)) {
  146. if($this->_params['directOnly'] == 'true') {
  147. return true;
  148. } else {
  149. return false;
  150. }
  151. } else {
  152. return null;
  153. }
  154. }
  155. /**
  156. * Set the first group id which should be displayed when retrieving
  157. * a list of groups.
  158. *
  159. * @param string $value The first group id to be returned, or null to
  160. * disable.
  161. */
  162. public function setStartGroupId($value)
  163. {
  164. if ($value !== null) {
  165. $this->_params['start'] = $value;
  166. } else {
  167. unset($this->_params['start']);
  168. }
  169. }
  170. /**
  171. * Get the first group id which should be displayed when retrieving
  172. * a list of groups.
  173. *
  174. * @see setStartGroupId
  175. * @return string The first group id to be returned, or null if
  176. * disabled.
  177. */
  178. public function getStartGroupId()
  179. {
  180. if (array_key_exists('start', $this->_params)) {
  181. return $this->_params['start'];
  182. } else {
  183. return null;
  184. }
  185. }
  186. /**
  187. * Returns the query URL generated by this query instance.
  188. *
  189. * @return string The query URL for this instance.
  190. */
  191. public function getQueryUrl()
  192. {
  193. $uri = Zend_Gdata_Gapps::APPS_BASE_FEED_URI;
  194. $uri .= Zend_Gdata_Gapps::APPS_GROUP_PATH;
  195. $uri .= '/' . $this->_domain;
  196. if ($this->_groupId !== null) {
  197. $uri .= '/' . $this->_groupId;
  198. }
  199. if(array_key_exists('member', $this->_params)) {
  200. $uri .= '/';
  201. }
  202. $uri .= $this->getQueryString();
  203. return $uri;
  204. }
  205. }