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

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