2
0

EmailListQuery.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 email list 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_EmailListQuery extends Zend_Gdata_Gapps_Query
  40. {
  41. /**
  42. * A string which, if not null, indicates which email list should
  43. * be retrieved by this query.
  44. *
  45. * @var string
  46. */
  47. protected $_emailListName = 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 $emailListName (optional) Value for the emailListName
  54. * property.
  55. * @param string $recipient (optional) Value for the recipient
  56. * property.
  57. * @param string $startEmailListName (optional) Value for the
  58. * startEmailListName property.
  59. */
  60. public function __construct($domain = null, $emailListName = null,
  61. $recipient = null, $startEmailListName = null)
  62. {
  63. parent::__construct($domain);
  64. $this->setEmailListName($emailListName);
  65. $this->setRecipient($recipient);
  66. $this->setStartEmailListName($startEmailListName);
  67. }
  68. /**
  69. * Set the email list name to query for. When set, only lists with a name
  70. * matching this value will be returned in search results. Set to
  71. * null to disable filtering by list name.
  72. *
  73. * @param string $value The email list name to filter search results by,
  74. * or null to disable.
  75. */
  76. public function setEmailListName($value)
  77. {
  78. $this->_emailListName = $value;
  79. }
  80. /**
  81. * Get the email list name to query for. If no name is set, null will be
  82. * returned.
  83. *
  84. * @see setEmailListName
  85. * @return string The email list name to filter search results by, or null
  86. * if disabled.
  87. */
  88. public function getEmailListName()
  89. {
  90. return $this->_emailListName;
  91. }
  92. /**
  93. * Set the recipient to query for. When set, only subscribers with an
  94. * email address matching this value will be returned in search results.
  95. * Set to null to disable filtering by username.
  96. *
  97. * @param string $value The recipient email address to filter search
  98. * results by, or null to disable.
  99. */
  100. public function setRecipient($value)
  101. {
  102. if ($value !== null) {
  103. $this->_params['recipient'] = $value;
  104. }
  105. else {
  106. unset($this->_params['recipient']);
  107. }
  108. }
  109. /**
  110. * Get the recipient email address to query for. If no recipient is set,
  111. * null will be returned.
  112. *
  113. * @see setRecipient
  114. * @return string The recipient email address to filter search results by,
  115. * or null if disabled.
  116. */
  117. public function getRecipient()
  118. {
  119. if (array_key_exists('recipient', $this->_params)) {
  120. return $this->_params['recipient'];
  121. } else {
  122. return null;
  123. }
  124. }
  125. /**
  126. * Set the first email list which should be displayed when retrieving
  127. * a list of email lists.
  128. *
  129. * @param string $value The first email list to be returned, or null to
  130. * disable.
  131. */
  132. public function setStartEmailListName($value)
  133. {
  134. if ($value !== null) {
  135. $this->_params['startEmailListName'] = $value;
  136. } else {
  137. unset($this->_params['startEmailListName']);
  138. }
  139. }
  140. /**
  141. * Get the first email list which should be displayed when retrieving
  142. * a list of email lists.
  143. *
  144. * @return string The first email list to be returned, or null to
  145. * disable.
  146. */
  147. public function getStartEmailListName()
  148. {
  149. if (array_key_exists('startEmailListName', $this->_params)) {
  150. return $this->_params['startEmailListName'];
  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. * @throws Zend_Gdata_App_InvalidArgumentException
  161. */
  162. public function getQueryUrl()
  163. {
  164. $uri = $this->getBaseUrl();
  165. $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_PATH;
  166. if ($this->_emailListName !== null) {
  167. $uri .= '/' . $this->_emailListName;
  168. }
  169. $uri .= $this->getQueryString();
  170. return $uri;
  171. }
  172. }