1 | <?php
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Zend Framework
|
---|
5 | *
|
---|
6 | * LICENSE
|
---|
7 | *
|
---|
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.
|
---|
15 | *
|
---|
16 | * @category Zend
|
---|
17 | * @package Zend_Gdata
|
---|
18 | * @subpackage Gapps
|
---|
19 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
20 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
21 | */
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * @see Zend_Gdata_Gapps_Query
|
---|
25 | */
|
---|
26 | require_once('Zend/Gdata/Gapps/Query.php');
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Assists in constructing queries for Google Apps email list entries.
|
---|
30 | * Instances of this class can be provided in many places where a URL is
|
---|
31 | * required.
|
---|
32 | *
|
---|
33 | * For information on submitting queries to a server, see the Google Apps
|
---|
34 | * service class, Zend_Gdata_Gapps.
|
---|
35 | *
|
---|
36 | * @category Zend
|
---|
37 | * @package Zend_Gdata
|
---|
38 | * @subpackage Gapps
|
---|
39 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
40 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
41 | */
|
---|
42 | class Zend_Gdata_Gapps_EmailListQuery extends Zend_Gdata_Gapps_Query
|
---|
43 | {
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * A string which, if not null, indicates which email list should
|
---|
47 | * be retrieved by this query.
|
---|
48 | *
|
---|
49 | * @var string
|
---|
50 | */
|
---|
51 | protected $_emailListName = null;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Create a new instance.
|
---|
55 | *
|
---|
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 $recipient (optional) Value for the recipient
|
---|
61 | * property.
|
---|
62 | * @param string $startEmailListName (optional) Value for the
|
---|
63 | * startEmailListName property.
|
---|
64 | */
|
---|
65 | public function __construct($domain = null, $emailListName = null,
|
---|
66 | $recipient = null, $startEmailListName = null)
|
---|
67 | {
|
---|
68 | parent::__construct($domain);
|
---|
69 | $this->setEmailListName($emailListName);
|
---|
70 | $this->setRecipient($recipient);
|
---|
71 | $this->setStartEmailListName($startEmailListName);
|
---|
72 | }
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Set the email list name to query for. When set, only lists with a name
|
---|
76 | * matching this value will be returned in search results. Set to
|
---|
77 | * null to disable filtering by list name.
|
---|
78 | *
|
---|
79 | * @param string $value The email list name to filter search results by,
|
---|
80 | * or null to disable.
|
---|
81 | */
|
---|
82 | public function setEmailListName($value)
|
---|
83 | {
|
---|
84 | $this->_emailListName = $value;
|
---|
85 | }
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * Get the email list name to query for. If no name is set, null will be
|
---|
89 | * returned.
|
---|
90 | *
|
---|
91 | * @see setEmailListName
|
---|
92 | * @return string The email list name to filter search results by, or null
|
---|
93 | * if disabled.
|
---|
94 | */
|
---|
95 | public function getEmailListName()
|
---|
96 | {
|
---|
97 | return $this->_emailListName;
|
---|
98 | }
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * Set the recipient to query for. When set, only subscribers with an
|
---|
102 | * email address matching this value will be returned in search results.
|
---|
103 | * Set to null to disable filtering by username.
|
---|
104 | *
|
---|
105 | * @param string $value The recipient email address to filter search
|
---|
106 | * results by, or null to disable.
|
---|
107 | */
|
---|
108 | public function setRecipient($value)
|
---|
109 | {
|
---|
110 | if ($value !== null) {
|
---|
111 | $this->_params['recipient'] = $value;
|
---|
112 | }
|
---|
113 | else {
|
---|
114 | unset($this->_params['recipient']);
|
---|
115 | }
|
---|
116 | }
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * Get the recipient email address to query for. If no recipient is set,
|
---|
120 | * null will be returned.
|
---|
121 | *
|
---|
122 | * @see setRecipient
|
---|
123 | * @return string The recipient email address to filter search results by,
|
---|
124 | * or null if disabled.
|
---|
125 | */
|
---|
126 | public function getRecipient()
|
---|
127 | {
|
---|
128 | if (array_key_exists('recipient', $this->_params)) {
|
---|
129 | return $this->_params['recipient'];
|
---|
130 | } else {
|
---|
131 | return null;
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Set the first email list which should be displayed when retrieving
|
---|
137 | * a list of email lists.
|
---|
138 | *
|
---|
139 | * @param string $value The first email list to be returned, or null to
|
---|
140 | * disable.
|
---|
141 | */
|
---|
142 | public function setStartEmailListName($value)
|
---|
143 | {
|
---|
144 | if ($value !== null) {
|
---|
145 | $this->_params['startEmailListName'] = $value;
|
---|
146 | } else {
|
---|
147 | unset($this->_params['startEmailListName']);
|
---|
148 | }
|
---|
149 | }
|
---|
150 |
|
---|
151 | /**
|
---|
152 | * Get the first email list which should be displayed when retrieving
|
---|
153 | * a list of email lists.
|
---|
154 | *
|
---|
155 | * @return string The first email list to be returned, or null to
|
---|
156 | * disable.
|
---|
157 | */
|
---|
158 | public function getStartEmailListName()
|
---|
159 | {
|
---|
160 | if (array_key_exists('startEmailListName', $this->_params)) {
|
---|
161 | return $this->_params['startEmailListName'];
|
---|
162 | } else {
|
---|
163 | return null;
|
---|
164 | }
|
---|
165 | }
|
---|
166 |
|
---|
167 | /**
|
---|
168 | * Returns the URL generated for this query, based on it's current
|
---|
169 | * parameters.
|
---|
170 | *
|
---|
171 | * @return string A URL generated based on the state of this query.
|
---|
172 | * @throws Zend_Gdata_App_InvalidArgumentException
|
---|
173 | */
|
---|
174 | public function getQueryUrl()
|
---|
175 | {
|
---|
176 |
|
---|
177 | $uri = $this->getBaseUrl();
|
---|
178 | $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_PATH;
|
---|
179 | if ($this->_emailListName !== null) {
|
---|
180 | $uri .= '/' . $this->_emailListName;
|
---|
181 | }
|
---|
182 | $uri .= $this->getQueryString();
|
---|
183 | return $uri;
|
---|
184 | }
|
---|
185 |
|
---|
186 | }
|
---|