File indexing completed on 2025-03-02 05:29:27

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 recipient
0031  * entries. Instances of this class can be provided in many places where a
0032  * URL is 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_EmailListRecipientQuery extends Zend_Gdata_Gapps_Query
0044 {
0045 
0046     /**
0047      * If not null, specifies the name of the email list which
0048      * should be requested 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 $startRecipient (optional) Value for the
0062      *          startRecipient property.
0063      */
0064     public function __construct($domain = null, $emailListName = null,
0065             $startRecipient = null)
0066     {
0067         parent::__construct($domain);
0068         $this->setEmailListName($emailListName);
0069         $this->setStartRecipient($startRecipient);
0070     }
0071 
0072     /**
0073      * Set the email list name to query for. When set, only lists with a name
0074      * matching this value will be returned in search results. Set to
0075      * null to disable filtering by list name.
0076      *
0077      * @param string $value The email list name to filter search results by,
0078      *          or null to disable.
0079      */
0080      public function setEmailListName($value)
0081      {
0082          $this->_emailListName = $value;
0083      }
0084 
0085     /**
0086      * Get the email list name to query for. If no name is set, null will be
0087      * returned.
0088      *
0089      * @param string $value The email list name to filter search results by,
0090      *          or null if disabled.
0091      */
0092     public function getEmailListName()
0093     {
0094         return $this->_emailListName;
0095     }
0096 
0097     /**
0098      * Set the first recipient which should be displayed when retrieving
0099      * a list of email list recipients.
0100      *
0101      * @param string $value The first recipient to be returned, or null to
0102      *              disable.
0103      */
0104     public function setStartRecipient($value)
0105     {
0106         if ($value !== null) {
0107             $this->_params['startRecipient'] = $value;
0108         } else {
0109             unset($this->_params['startRecipient']);
0110         }
0111     }
0112 
0113     /**
0114      * Get the first recipient which should be displayed when retrieving
0115      * a list of email list recipients.
0116      *
0117      * @return string The first recipient to be returned, or null if
0118      *              disabled.
0119      */
0120     public function getStartRecipient()
0121     {
0122         if (array_key_exists('startRecipient', $this->_params)) {
0123             return $this->_params['startRecipient'];
0124         } else {
0125             return null;
0126         }
0127     }
0128 
0129     /**
0130      * Returns the URL generated for this query, based on it's current
0131      * parameters.
0132      *
0133      * @return string A URL generated based on the state of this query.
0134      * @throws Zend_Gdata_App_InvalidArgumentException
0135      */
0136     public function getQueryUrl()
0137     {
0138 
0139         $uri = $this->getBaseUrl();
0140         $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_PATH;
0141         if ($this->_emailListName !== null) {
0142             $uri .= '/' . $this->_emailListName;
0143         } else {
0144             // require_once 'Zend/Gdata/App/InvalidArgumentException.php';
0145             throw new Zend_Gdata_App_InvalidArgumentException(
0146                     'EmailListName must not be null');
0147         }
0148         $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_RECIPIENT_POSTFIX . '/';
0149         $uri .= $this->getQueryString();
0150         return $uri;
0151     }
0152 
0153 }