]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - Zend/Gdata/Gapps/EmailListRecipientQuery.php
Release 6.5.0
[Github/sugarcrm.git] / Zend / Gdata / Gapps / EmailListRecipientQuery.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 recipient
31  * entries. Instances of this class can be provided in many places where a
32  * URL is 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_EmailListRecipientQuery extends Zend_Gdata_Gapps_Query
44 {
45
46     /**
47      * If not null, specifies the name of the email list which
48      * should be requested 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 $startRecipient (optional) Value for the
62      *          startRecipient property.
63      */
64     public function __construct($domain = null, $emailListName = null,
65             $startRecipient = null)
66     {
67         parent::__construct($domain);
68         $this->setEmailListName($emailListName);
69         $this->setStartRecipient($startRecipient);
70     }
71
72     /**
73      * Set the email list name to query for. When set, only lists with a name
74      * matching this value will be returned in search results. Set to
75      * null to disable filtering by list name.
76      *
77      * @param string $value The email list name to filter search results by,
78      *          or null to disable.
79      */
80      public function setEmailListName($value)
81      {
82          $this->_emailListName = $value;
83      }
84
85     /**
86      * Get the email list name to query for. If no name is set, null will be
87      * returned.
88      *
89      * @param string $value The email list name to filter search results by,
90      *          or null if disabled.
91      */
92     public function getEmailListName()
93     {
94         return $this->_emailListName;
95     }
96
97     /**
98      * Set the first recipient which should be displayed when retrieving
99      * a list of email list recipients.
100      *
101      * @param string $value The first recipient to be returned, or null to
102      *              disable.
103      */
104     public function setStartRecipient($value)
105     {
106         if ($value !== null) {
107             $this->_params['startRecipient'] = $value;
108         } else {
109             unset($this->_params['startRecipient']);
110         }
111     }
112
113     /**
114      * Get the first recipient which should be displayed when retrieving
115      * a list of email list recipients.
116      *
117      * @return string The first recipient to be returned, or null if
118      *              disabled.
119      */
120     public function getStartRecipient()
121     {
122         if (array_key_exists('startRecipient', $this->_params)) {
123             return $this->_params['startRecipient'];
124         } else {
125             return null;
126         }
127     }
128
129     /**
130      * Returns the URL generated for this query, based on it's current
131      * parameters.
132      *
133      * @return string A URL generated based on the state of this query.
134      * @throws Zend_Gdata_App_InvalidArgumentException
135      */
136     public function getQueryUrl()
137     {
138
139         $uri = $this->getBaseUrl();
140         $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_PATH;
141         if ($this->_emailListName !== null) {
142             $uri .= '/' . $this->_emailListName;
143         } else {
144             require_once 'Zend/Gdata/App/InvalidArgumentException.php';
145             throw new Zend_Gdata_App_InvalidArgumentException(
146                     'EmailListName must not be null');
147         }
148         $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_RECIPIENT_POSTFIX . '/';
149         $uri .= $this->getQueryString();
150         return $uri;
151     }
152
153 }