EmailListRecipientQuery.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 recipient
  27. * entries. Instances of this class can be provided in many places where a
  28. * URL is 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_EmailListRecipientQuery extends Zend_Gdata_Gapps_Query
  40. {
  41. /**
  42. * If not null, specifies the name of the email list which
  43. * should be requested 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 $startRecipient (optional) Value for the
  56. * startRecipient property.
  57. */
  58. public function __construct($domain = null, $emailListName = null,
  59. $startRecipient = null)
  60. {
  61. parent::__construct($domain);
  62. $this->setEmailListName($emailListName);
  63. $this->setStartRecipient($startRecipient);
  64. }
  65. /**
  66. * Set the email list name to query for. When set, only lists with a name
  67. * matching this value will be returned in search results. Set to
  68. * null to disable filtering by list name.
  69. *
  70. * @param string $value The email list name to filter search results by,
  71. * or null to disable.
  72. */
  73. public function setEmailListName($value)
  74. {
  75. $this->_emailListName = $value;
  76. }
  77. /**
  78. * Get the email list name to query for. If no name is set, null will be
  79. * returned.
  80. *
  81. * @param string $value The email list name to filter search results by,
  82. * or null if disabled.
  83. */
  84. public function getEmailListName()
  85. {
  86. return $this->_emailListName;
  87. }
  88. /**
  89. * Set the first recipient which should be displayed when retrieving
  90. * a list of email list recipients.
  91. *
  92. * @param string $value The first recipient to be returned, or null to
  93. * disable.
  94. */
  95. public function setStartRecipient($value)
  96. {
  97. if ($value !== null) {
  98. $this->_params['startRecipient'] = $value;
  99. } else {
  100. unset($this->_params['startRecipient']);
  101. }
  102. }
  103. /**
  104. * Get the first recipient which should be displayed when retrieving
  105. * a list of email list recipients.
  106. *
  107. * @return string The first recipient to be returned, or null if
  108. * disabled.
  109. */
  110. public function getStartRecipient()
  111. {
  112. if (array_key_exists('startRecipient', $this->_params)) {
  113. return $this->_params['startRecipient'];
  114. } else {
  115. return null;
  116. }
  117. }
  118. /**
  119. * Returns the URL generated for this query, based on it's current
  120. * parameters.
  121. *
  122. * @return string A URL generated based on the state of this query.
  123. * @throws Zend_Gdata_App_InvalidArgumentException
  124. */
  125. public function getQueryUrl()
  126. {
  127. $uri = $this->getBaseUrl();
  128. $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_PATH;
  129. if ($this->_emailListName !== null) {
  130. $uri .= '/' . $this->_emailListName;
  131. } else {
  132. require_once 'Zend/Gdata/App/InvalidArgumentException.php';
  133. throw new Zend_Gdata_App_InvalidArgumentException(
  134. 'EmailListName must not be null');
  135. }
  136. $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_RECIPIENT_POSTFIX . '/';
  137. $uri .= $this->getQueryString();
  138. return $uri;
  139. }
  140. }