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 | * @see Zend_Gdata_Gapps_Query
|
---|
25 | */
|
---|
26 | require_once('Zend/Gdata/Gapps/Query.php');
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Assists in constructing queries for Google Apps user entries.
|
---|
30 | * Instances of this class can be provided in many places where a URL is
|
---|
31 | * required.
|
---|
32 | *
|
---|
33 | * For information on submitting queries to a server, see the Google Apps
|
---|
34 | * service class, Zend_Gdata_Gapps.
|
---|
35 | *
|
---|
36 | * @category Zend
|
---|
37 | * @package Zend_Gdata
|
---|
38 | * @subpackage Gapps
|
---|
39 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
40 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
41 | */
|
---|
42 | class Zend_Gdata_Gapps_UserQuery extends Zend_Gdata_Gapps_Query
|
---|
43 | {
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * If not null, specifies the username of the user who should be
|
---|
47 | * retrieved by this query.
|
---|
48 | *
|
---|
49 | * @var string
|
---|
50 | */
|
---|
51 | protected $_username = null;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Create a new instance.
|
---|
55 | *
|
---|
56 | * @param string $domain (optional) The Google Apps-hosted domain to use
|
---|
57 | * when constructing query URIs.
|
---|
58 | * @param string $username (optional) Value for the username
|
---|
59 | * property.
|
---|
60 | * @param string $startUsername (optional) Value for the
|
---|
61 | * startUsername property.
|
---|
62 | */
|
---|
63 | public function __construct($domain = null, $username = null,
|
---|
64 | $startUsername = null)
|
---|
65 | {
|
---|
66 | parent::__construct($domain);
|
---|
67 | $this->setUsername($username);
|
---|
68 | $this->setStartUsername($startUsername);
|
---|
69 | }
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Set the username to query for. When set, only users with a username
|
---|
73 | * matching this value will be returned in search results. Set to
|
---|
74 | * null to disable filtering by username.
|
---|
75 | *
|
---|
76 | * @see getUsername
|
---|
77 | * @param string $value The username to filter search results by, or null to
|
---|
78 | * disable.
|
---|
79 | */
|
---|
80 | public function setUsername($value)
|
---|
81 | {
|
---|
82 | $this->_username = $value;
|
---|
83 | }
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Get the username to query for. If no username is set, null will be
|
---|
87 | * returned.
|
---|
88 | *
|
---|
89 | * @param string $value The username to filter search results by, or
|
---|
90 | * null if disabled.
|
---|
91 | */
|
---|
92 | public function getUsername()
|
---|
93 | {
|
---|
94 | return $this->_username;
|
---|
95 | }
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Set the first username which should be displayed when retrieving
|
---|
99 | * a list of users.
|
---|
100 | *
|
---|
101 | * @param string $value The first username to be returned, or null to
|
---|
102 | * disable.
|
---|
103 | */
|
---|
104 | public function setStartUsername($value)
|
---|
105 | {
|
---|
106 | if ($value !== null) {
|
---|
107 | $this->_params['startUsername'] = $value;
|
---|
108 | } else {
|
---|
109 | unset($this->_params['startUsername']);
|
---|
110 | }
|
---|
111 | }
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Get the first username which should be displayed when retrieving
|
---|
115 | * a list of users.
|
---|
116 | *
|
---|
117 | * @see setStartUsername
|
---|
118 | * @return string The first username to be returned, or null if
|
---|
119 | * disabled.
|
---|
120 | */
|
---|
121 | public function getStartUsername()
|
---|
122 | {
|
---|
123 | if (array_key_exists('startUsername', $this->_params)) {
|
---|
124 | return $this->_params['startUsername'];
|
---|
125 | } else {
|
---|
126 | return null;
|
---|
127 | }
|
---|
128 | }
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * Returns the query URL generated by this query instance.
|
---|
132 | *
|
---|
133 | * @return string The query URL for this instance.
|
---|
134 | */
|
---|
135 | public function getQueryUrl()
|
---|
136 | {
|
---|
137 | $uri = $this->getBaseUrl();
|
---|
138 | $uri .= Zend_Gdata_Gapps::APPS_USER_PATH;
|
---|
139 | if ($this->_username !== null) {
|
---|
140 | $uri .= '/' . $this->_username;
|
---|
141 | }
|
---|
142 | $uri .= $this->getQueryString();
|
---|
143 | return $uri;
|
---|
144 | }
|
---|
145 |
|
---|
146 | }
|
---|