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