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