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  * Zend_Gdata_Query
0026  */
0027 // require_once('Zend/Gdata/Query.php');
0028 
0029 /**
0030  * Zend_Gdata_Gapps
0031  */
0032 // require_once('Zend/Gdata/Gapps.php');
0033 
0034 /**
0035  * Assists in constructing queries for Google Apps entries. This class
0036  * provides common methods used by all other Google Apps query classes.
0037  *
0038  * This class should never be instantiated directly. Instead, instantiate a
0039  * class which inherits from this class.
0040   *
0041  * @category   Zend
0042  * @package    Zend_Gdata
0043  * @subpackage Gapps
0044  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0045  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0046  */
0047 abstract class Zend_Gdata_Gapps_Query extends Zend_Gdata_Query
0048 {
0049 
0050     /**
0051      * The domain which is being administered via the Provisioning API.
0052      *
0053      * @var string
0054      */
0055     protected $_domain = null;
0056 
0057     /**
0058      * Create a new instance.
0059      *
0060      * @param string $domain (optional) The Google Apps-hosted domain to use
0061      *          when constructing query URIs.
0062      */
0063     public function __construct($domain = null)
0064     {
0065         parent::__construct();
0066         $this->_domain = $domain;
0067     }
0068 
0069     /**
0070      * Set domain for this service instance. This should be a fully qualified
0071      * domain, such as 'foo.example.com'.
0072      *
0073      * This value is used when calculating URLs for retrieving and posting
0074      * entries. If no value is specified, a URL will have to be manually
0075      * constructed prior to using any methods which interact with the Google
0076      * Apps provisioning service.
0077      *
0078      * @param string $value The domain to be used for this session.
0079      */
0080     public function setDomain($value)
0081     {
0082         $this->_domain = $value;
0083     }
0084 
0085     /**
0086      * Get domain for this service instance. This should be a fully qualified
0087      * domain, such as 'foo.example.com'. If no domain is set, null will be
0088      * returned.
0089      *
0090      * @see setDomain
0091      * @return string The domain to be used for this session, or null if not
0092      *          set.
0093      */
0094     public function getDomain()
0095     {
0096         return $this->_domain;
0097     }
0098 
0099     /**
0100      * Returns the base URL used to access the Google Apps service, based
0101      * on the current domain. The current domain can be temporarily
0102      * overridden by providing a fully qualified domain as $domain.
0103      *
0104      * @see setDomain
0105      * @param string $domain (optional) A fully-qualified domain to use
0106      *          instead of the default domain for this service instance.
0107      */
0108      public function getBaseUrl($domain = null)
0109      {
0110          if ($domain !== null) {
0111              return Zend_Gdata_Gapps::APPS_BASE_FEED_URI . '/' . $domain;
0112          }
0113          else if ($this->_domain !== null) {
0114              return Zend_Gdata_Gapps::APPS_BASE_FEED_URI . '/' . $this->_domain;
0115          }
0116          else {
0117              // require_once 'Zend/Gdata/App/InvalidArgumentException.php';
0118              throw new Zend_Gdata_App_InvalidArgumentException(
0119                  'Domain must be specified.');
0120          }
0121      }
0122 
0123 }