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-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
20 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
21 | */
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Zend_Gdata_Query
|
---|
25 | */
|
---|
26 | require_once('Zend/Gdata/Query.php');
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Zend_Gdata_Gapps
|
---|
30 | */
|
---|
31 | require_once('Zend/Gdata/Gapps.php');
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Assists in constructing queries for Google Apps entries. This class
|
---|
35 | * provides common methods used by all other Google Apps query classes.
|
---|
36 | *
|
---|
37 | * This class should never be instantiated directly. Instead, instantiate a
|
---|
38 | * class which inherits from this class.
|
---|
39 | *
|
---|
40 | * @category Zend
|
---|
41 | * @package Zend_Gdata
|
---|
42 | * @subpackage Gapps
|
---|
43 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
44 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
45 | */
|
---|
46 | abstract class Zend_Gdata_Gapps_Query extends Zend_Gdata_Query
|
---|
47 | {
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * The domain which is being administered via the Provisioning API.
|
---|
51 | *
|
---|
52 | * @var string
|
---|
53 | */
|
---|
54 | protected $_domain = null;
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Create a new instance.
|
---|
58 | *
|
---|
59 | * @param string $domain (optional) The Google Apps-hosted domain to use
|
---|
60 | * when constructing query URIs.
|
---|
61 | */
|
---|
62 | public function __construct($domain = null)
|
---|
63 | {
|
---|
64 | parent::__construct();
|
---|
65 | $this->_domain = $domain;
|
---|
66 | }
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Set domain for this service instance. This should be a fully qualified
|
---|
70 | * domain, such as 'foo.example.com'.
|
---|
71 | *
|
---|
72 | * This value is used when calculating URLs for retrieving and posting
|
---|
73 | * entries. If no value is specified, a URL will have to be manually
|
---|
74 | * constructed prior to using any methods which interact with the Google
|
---|
75 | * Apps provisioning service.
|
---|
76 | *
|
---|
77 | * @param string $value The domain to be used for this session.
|
---|
78 | */
|
---|
79 | public function setDomain($value)
|
---|
80 | {
|
---|
81 | $this->_domain = $value;
|
---|
82 | }
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Get domain for this service instance. This should be a fully qualified
|
---|
86 | * domain, such as 'foo.example.com'. If no domain is set, null will be
|
---|
87 | * returned.
|
---|
88 | *
|
---|
89 | * @see setDomain
|
---|
90 | * @return string The domain to be used for this session, or null if not
|
---|
91 | * set.
|
---|
92 | */
|
---|
93 | public function getDomain()
|
---|
94 | {
|
---|
95 | return $this->_domain;
|
---|
96 | }
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Returns the base URL used to access the Google Apps service, based
|
---|
100 | * on the current domain. The current domain can be temporarily
|
---|
101 | * overridden by providing a fully qualified domain as $domain.
|
---|
102 | *
|
---|
103 | * @see setDomain
|
---|
104 | * @param string $domain (optional) A fully-qualified domain to use
|
---|
105 | * instead of the default domain for this service instance.
|
---|
106 | */
|
---|
107 | public function getBaseUrl($domain = null)
|
---|
108 | {
|
---|
109 | if ($domain !== null) {
|
---|
110 | return Zend_Gdata_Gapps::APPS_BASE_FEED_URI . '/' . $domain;
|
---|
111 | }
|
---|
112 | else if ($this->_domain !== null) {
|
---|
113 | return Zend_Gdata_Gapps::APPS_BASE_FEED_URI . '/' . $this->_domain;
|
---|
114 | }
|
---|
115 | else {
|
---|
116 | require_once 'Zend/Gdata/App/InvalidArgumentException.php';
|
---|
117 | throw new Zend_Gdata_App_InvalidArgumentException(
|
---|
118 | 'Domain must be specified.');
|
---|
119 | }
|
---|
120 | }
|
---|
121 |
|
---|
122 | }
|
---|