[ZF-6295] Generic:
[zend.git] / library / Zend / Gdata / Gapps / EmailListRecipientQuery.php
blob3719901bb0b00bfa474864d214d3326b3dd17252
1 <?php
3 /**
4 * Zend Framework
6 * LICENSE
8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
16 * @category Zend
17 * @package Zend_Gdata
18 * @subpackage Gapps
19 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
23 /**
24 * @see Zend_Gdata_Gapps_Query
26 require_once('Zend/Gdata/Gapps/Query.php');
28 /**
29 * Assists in constructing queries for Google Apps email list recipient
30 * entries. Instances of this class can be provided in many places where a
31 * URL is required.
33 * For information on submitting queries to a server, see the Google Apps
34 * service class, Zend_Gdata_Gapps.
36 * @category Zend
37 * @package Zend_Gdata
38 * @subpackage Gapps
39 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
40 * @license http://framework.zend.com/license/new-bsd New BSD License
42 class Zend_Gdata_Gapps_EmailListRecipientQuery extends Zend_Gdata_Gapps_Query
45 /**
46 * If not null, specifies the name of the email list which
47 * should be requested by this query.
49 * @var string
51 protected $_emailListName = null;
53 /**
54 * Create a new instance.
56 * @param string $domain (optional) The Google Apps-hosted domain to use
57 * when constructing query URIs.
58 * @param string $emailListName (optional) Value for the emailListName
59 * property.
60 * @param string $startRecipient (optional) Value for the
61 * startRecipient property.
63 public function __construct($domain = null, $emailListName = null,
64 $startRecipient = null)
66 parent::__construct($domain);
67 $this->setEmailListName($emailListName);
68 $this->setStartRecipient($startRecipient);
71 /**
72 * Set the email list name to query for. When set, only lists with a name
73 * matching this value will be returned in search results. Set to
74 * null to disable filtering by list name.
76 * @param string $value The email list name to filter search results by,
77 * or null to disable.
79 public function setEmailListName($value)
81 $this->_emailListName = $value;
84 /**
85 * Get the email list name to query for. If no name is set, null will be
86 * returned.
88 * @param string $value The email list name to filter search results by,
89 * or null if disabled.
91 public function getEmailListName()
93 return $this->_emailListName;
96 /**
97 * Set the first recipient which should be displayed when retrieving
98 * a list of email list recipients.
100 * @param string $value The first recipient to be returned, or null to
101 * disable.
103 public function setStartRecipient($value)
105 if ($value !== null) {
106 $this->_params['startRecipient'] = $value;
107 } else {
108 unset($this->_params['startRecipient']);
113 * Get the first recipient which should be displayed when retrieving
114 * a list of email list recipients.
116 * @return string The first recipient to be returned, or null if
117 * disabled.
119 public function getStartRecipient()
121 if (array_key_exists('startRecipient', $this->_params)) {
122 return $this->_params['startRecipient'];
123 } else {
124 return null;
129 * Returns the URL generated for this query, based on it's current
130 * parameters.
132 * @return string A URL generated based on the state of this query.
133 * @throws Zend_Gdata_App_InvalidArgumentException
135 public function getQueryUrl()
138 $uri = $this->getBaseUrl();
139 $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_PATH;
140 if ($this->_emailListName !== null) {
141 $uri .= '/' . $this->_emailListName;
142 } else {
143 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
144 throw new Zend_Gdata_App_InvalidArgumentException(
145 'EmailListName must not be null');
147 $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_RECIPIENT_POSTFIX . '/';
148 $uri .= $this->getQueryString();
149 return $uri;