File indexing completed on 2024-06-16 05:30:07

0001 <?php
0002 
0003 /**
0004  * Zend Framework
0005  *
0006  * LICENSE
0007  *
0008  * This source file is subject to the new BSD license that is bundled
0009  * with this package in the file LICENSE.txt.
0010  * It is also available through the world-wide-web at this URL:
0011  * http://framework.zend.com/license/new-bsd
0012  * If you did not receive a copy of the license and are unable to
0013  * obtain it through the world-wide-web, please send an email
0014  * to license@zend.com so we can send you a copy immediately.
0015  *
0016  * @category   Zend
0017  * @package    Zend_Gdata
0018  * @subpackage Gapps
0019  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  * @version    $Id$
0022  */
0023 
0024 /**
0025  * @see Zend_Gdata_Gapps_Query
0026  */
0027 // require_once('Zend/Gdata/Gapps/Query.php');
0028 
0029 /**
0030  * Assists in constructing queries for Google Apps email list entries.
0031  * Instances of this class can be provided in many places where a URL is
0032  * required.
0033  *
0034  * For information on submitting queries to a server, see the Google Apps
0035  * service class, Zend_Gdata_Gapps.
0036  *
0037  * @category   Zend
0038  * @package    Zend_Gdata
0039  * @subpackage Gapps
0040  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0041  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0042  */
0043 class Zend_Gdata_Gapps_EmailListQuery extends Zend_Gdata_Gapps_Query
0044 {
0045 
0046     /**
0047      * A string which, if not null, indicates which email list should
0048      * be retrieved by this query.
0049      *
0050      * @var string
0051      */
0052     protected $_emailListName = null;
0053 
0054     /**
0055      * Create a new instance.
0056      *
0057      * @param string $domain (optional) The Google Apps-hosted domain to use
0058      *          when constructing query URIs.
0059      * @param string $emailListName (optional) Value for the emailListName
0060      *          property.
0061      * @param string $recipient (optional) Value for the recipient
0062      *          property.
0063      * @param string $startEmailListName (optional) Value for the
0064      *          startEmailListName property.
0065      */
0066     public function __construct($domain = null, $emailListName = null,
0067             $recipient = null, $startEmailListName = null)
0068     {
0069         parent::__construct($domain);
0070         $this->setEmailListName($emailListName);
0071         $this->setRecipient($recipient);
0072         $this->setStartEmailListName($startEmailListName);
0073     }
0074 
0075     /**
0076      * Set the email list name to query for. When set, only lists with a name
0077      * matching this value will be returned in search results. Set to
0078      * null to disable filtering by list name.
0079      *
0080      * @param string $value The email list name to filter search results by,
0081      *          or null to disable.
0082      */
0083      public function setEmailListName($value)
0084      {
0085          $this->_emailListName = $value;
0086      }
0087 
0088     /**
0089      * Get the email list name to query for. If no name is set, null will be
0090      * returned.
0091      *
0092      * @see setEmailListName
0093      * @return string The email list name to filter search results by, or null
0094      *              if disabled.
0095      */
0096     public function getEmailListName()
0097     {
0098         return $this->_emailListName;
0099     }
0100 
0101     /**
0102      * Set the recipient to query for. When set, only subscribers with an
0103      * email address matching this value will be returned in search results.
0104      * Set to null to disable filtering by username.
0105      *
0106      * @param string $value The recipient email address to filter search
0107      *              results by, or null to  disable.
0108      */
0109     public function setRecipient($value)
0110     {
0111         if ($value !== null) {
0112             $this->_params['recipient'] = $value;
0113         }
0114         else {
0115             unset($this->_params['recipient']);
0116         }
0117     }
0118 
0119     /**
0120      * Get the recipient email address to query for. If no recipient is set,
0121      * null will be returned.
0122      *
0123      * @see setRecipient
0124      * @return string The recipient email address to filter search results by,
0125      *              or null if disabled.
0126      */
0127     public function getRecipient()
0128     {
0129         if (array_key_exists('recipient', $this->_params)) {
0130             return $this->_params['recipient'];
0131         } else {
0132             return null;
0133         }
0134     }
0135 
0136     /**
0137      * Set the first email list which should be displayed when retrieving
0138      * a list of email lists.
0139      *
0140      * @param string $value The first email list to be returned, or null to
0141      *              disable.
0142      */
0143     public function setStartEmailListName($value)
0144     {
0145         if ($value !== null) {
0146             $this->_params['startEmailListName'] = $value;
0147         } else {
0148             unset($this->_params['startEmailListName']);
0149         }
0150     }
0151 
0152     /**
0153      * Get the first email list which should be displayed when retrieving
0154      * a list of email lists.
0155      *
0156      * @return string The first email list to be returned, or null to
0157      *              disable.
0158      */
0159     public function getStartEmailListName()
0160     {
0161         if (array_key_exists('startEmailListName', $this->_params)) {
0162             return $this->_params['startEmailListName'];
0163         } else {
0164             return null;
0165         }
0166     }
0167 
0168     /**
0169      * Returns the URL generated for this query, based on it's current
0170      * parameters.
0171      *
0172      * @return string A URL generated based on the state of this query.
0173      * @throws Zend_Gdata_App_InvalidArgumentException
0174      */
0175     public function getQueryUrl()
0176     {
0177 
0178         $uri = $this->getBaseUrl();
0179         $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_PATH;
0180         if ($this->_emailListName !== null) {
0181             $uri .= '/' . $this->_emailListName;
0182         }
0183         $uri .= $this->getQueryString();
0184         return $uri;
0185     }
0186 
0187 }