web/Zend/Gdata/Gapps/NicknameQuery.php
changeset 0 4eba9c11703f
equal deleted inserted replaced
-1:000000000000 0:4eba9c11703f
       
     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: NicknameQuery.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 nickname 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_NicknameQuery extends Zend_Gdata_Gapps_Query
       
    44 {
       
    45 
       
    46     /**
       
    47      * If not null, indicates the name of the nickname entry which
       
    48      * should be returned by this query.
       
    49      *
       
    50      * @var string
       
    51      */
       
    52     protected $_nickname = 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 $nickname (optional) Value for the nickname
       
    60      *          property.
       
    61      * @param string $username (optional) Value for the username
       
    62      *          property.
       
    63      * @param string $startNickname (optional) Value for the
       
    64      *          startNickname property.
       
    65      */
       
    66     public function __construct($domain = null, $nickname = null,
       
    67             $username = null, $startNickname = null)
       
    68     {
       
    69         parent::__construct($domain);
       
    70         $this->setNickname($nickname);
       
    71         $this->setUsername($username);
       
    72         $this->setStartNickname($startNickname);
       
    73     }
       
    74 
       
    75     /**
       
    76      * Set the nickname to query for. When set, only users with a nickname
       
    77      * matching this value will be returned in search results. Set to
       
    78      * null to disable filtering by username.
       
    79      *
       
    80      * @param string $value The nickname to filter search results by, or null
       
    81      *          to  disable.
       
    82      */
       
    83      public function setNickname($value)
       
    84      {
       
    85          $this->_nickname = $value;
       
    86      }
       
    87 
       
    88     /**
       
    89      * Get the nickname to query for. If no nickname is set, null will be
       
    90      * returned.
       
    91      *
       
    92      * @see setNickname
       
    93      * @return string The nickname to filter search results by, or null if
       
    94      *              disabled.
       
    95      */
       
    96     public function getNickname()
       
    97     {
       
    98         return $this->_nickname;
       
    99     }
       
   100 
       
   101     /**
       
   102      * Set the username to query for. When set, only users with a username
       
   103      * matching this value will be returned in search results. Set to
       
   104      * null to disable filtering by username.
       
   105      *
       
   106      * @param string $value The username to filter search results by, or null
       
   107      *          to disable.
       
   108      */
       
   109     public function setUsername($value)
       
   110     {
       
   111         if ($value !== null) {
       
   112             $this->_params['username'] = $value;
       
   113         }
       
   114         else {
       
   115             unset($this->_params['username']);
       
   116         }
       
   117     }
       
   118 
       
   119     /**
       
   120      * Get the username to query for. If no username is set, null will be
       
   121      * returned.
       
   122      *
       
   123      * @see setUsername
       
   124      * @return string The username to filter search results by, or null if
       
   125      *              disabled.
       
   126      */
       
   127     public function getUsername()
       
   128     {
       
   129         if (array_key_exists('username', $this->_params)) {
       
   130             return $this->_params['username'];
       
   131         } else {
       
   132             return null;
       
   133         }
       
   134     }
       
   135 
       
   136     /**
       
   137      * Set the first nickname which should be displayed when retrieving
       
   138      * a list of nicknames.
       
   139      *
       
   140      * @param string $value The first nickname to be returned, or null to
       
   141      *              disable.
       
   142      */
       
   143     public function setStartNickname($value)
       
   144     {
       
   145         if ($value !== null) {
       
   146             $this->_params['startNickname'] = $value;
       
   147         } else {
       
   148             unset($this->_params['startNickname']);
       
   149         }
       
   150     }
       
   151 
       
   152     /**
       
   153      * Get the first nickname which should be displayed when retrieving
       
   154      * a list of nicknames.
       
   155      *
       
   156      * @return string The first nickname to be returned, or null to
       
   157      *              disable.
       
   158      */
       
   159     public function getStartNickname()
       
   160     {
       
   161         if (array_key_exists('startNickname', $this->_params)) {
       
   162             return $this->_params['startNickname'];
       
   163         } else {
       
   164             return null;
       
   165         }
       
   166     }
       
   167 
       
   168     /**
       
   169      * Returns the URL generated for this query, based on it's current
       
   170      * parameters.
       
   171      *
       
   172      * @return string A URL generated based on the state of this query.
       
   173      */
       
   174     public function getQueryUrl()
       
   175     {
       
   176 
       
   177         $uri = $this->getBaseUrl();
       
   178         $uri .= Zend_Gdata_Gapps::APPS_NICKNAME_PATH;
       
   179         if ($this->_nickname !== null) {
       
   180             $uri .= '/' . $this->_nickname;
       
   181         }
       
   182         $uri .= $this->getQueryString();
       
   183         return $uri;
       
   184     }
       
   185 
       
   186 }