/zf/library/Zend/Gdata/Gapps/EmailListQuery.php

http://github.com/eryx/php-framework-benchmark · PHP · 187 lines · 65 code · 14 blank · 108 comment · 9 complexity · 5669018f20d8da62985b3c70c489ecaa MD5 · raw file

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