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  * @see Zend_Gdata_Gapps_Query
0026  */
0027 // require_once('Zend/Gdata/Gapps/Query.php');
0028 
0029 /**
0030  * Assists in constructing queries for Google Apps nickname entries.
0031  * Instances of this class can be provided in many places where a URL is
0032  * required.
0033  *
0034  * For information on submitting queries to a server, see the Google Apps
0035  * service class, Zend_Gdata_Gapps.
0036  *
0037  * @category   Zend
0038  * @package    Zend_Gdata
0039  * @subpackage Gapps
0040  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0041  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0042  */
0043 class Zend_Gdata_Gapps_NicknameQuery extends Zend_Gdata_Gapps_Query
0044 {
0045 
0046     /**
0047      * If not null, indicates the name of the nickname entry which
0048      * should be returned by this query.
0049      *
0050      * @var string
0051      */
0052     protected $_nickname = null;
0053 
0054     /**
0055      * Create a new instance.
0056      *
0057      * @param string $domain (optional) The Google Apps-hosted domain to use
0058      *          when constructing query URIs.
0059      * @param string $nickname (optional) Value for the nickname
0060      *          property.
0061      * @param string $username (optional) Value for the username
0062      *          property.
0063      * @param string $startNickname (optional) Value for the
0064      *          startNickname property.
0065      */
0066     public function __construct($domain = null, $nickname = null,
0067             $username = null, $startNickname = null)
0068     {
0069         parent::__construct($domain);
0070         $this->setNickname($nickname);
0071         $this->setUsername($username);
0072         $this->setStartNickname($startNickname);
0073     }
0074 
0075     /**
0076      * Set the nickname to query for. When set, only users with a nickname
0077      * matching this value will be returned in search results. Set to
0078      * null to disable filtering by username.
0079      *
0080      * @param string $value The nickname to filter search results by, or null
0081      *          to  disable.
0082      */
0083      public function setNickname($value)
0084      {
0085          $this->_nickname = $value;
0086      }
0087 
0088     /**
0089      * Get the nickname to query for. If no nickname is set, null will be
0090      * returned.
0091      *
0092      * @see setNickname
0093      * @return string The nickname to filter search results by, or null if
0094      *              disabled.
0095      */
0096     public function getNickname()
0097     {
0098         return $this->_nickname;
0099     }
0100 
0101     /**
0102      * Set the username to query for. When set, only users with a username
0103      * matching this value will be returned in search results. Set to
0104      * null to disable filtering by username.
0105      *
0106      * @param string $value The username to filter search results by, or null
0107      *          to disable.
0108      */
0109     public function setUsername($value)
0110     {
0111         if ($value !== null) {
0112             $this->_params['username'] = $value;
0113         }
0114         else {
0115             unset($this->_params['username']);
0116         }
0117     }
0118 
0119     /**
0120      * Get the username to query for. If no username is set, null will be
0121      * returned.
0122      *
0123      * @see setUsername
0124      * @return string The username to filter search results by, or null if
0125      *              disabled.
0126      */
0127     public function getUsername()
0128     {
0129         if (array_key_exists('username', $this->_params)) {
0130             return $this->_params['username'];
0131         } else {
0132             return null;
0133         }
0134     }
0135 
0136     /**
0137      * Set the first nickname which should be displayed when retrieving
0138      * a list of nicknames.
0139      *
0140      * @param string $value The first nickname to be returned, or null to
0141      *              disable.
0142      */
0143     public function setStartNickname($value)
0144     {
0145         if ($value !== null) {
0146             $this->_params['startNickname'] = $value;
0147         } else {
0148             unset($this->_params['startNickname']);
0149         }
0150     }
0151 
0152     /**
0153      * Get the first nickname which should be displayed when retrieving
0154      * a list of nicknames.
0155      *
0156      * @return string The first nickname to be returned, or null to
0157      *              disable.
0158      */
0159     public function getStartNickname()
0160     {
0161         if (array_key_exists('startNickname', $this->_params)) {
0162             return $this->_params['startNickname'];
0163         } else {
0164             return null;
0165         }
0166     }
0167 
0168     /**
0169      * Returns the URL generated for this query, based on it's current
0170      * parameters.
0171      *
0172      * @return string A URL generated based on the state of this query.
0173      */
0174     public function getQueryUrl()
0175     {
0176 
0177         $uri = $this->getBaseUrl();
0178         $uri .= Zend_Gdata_Gapps::APPS_NICKNAME_PATH;
0179         if ($this->_nickname !== null) {
0180             $uri .= '/' . $this->_nickname;
0181         }
0182         $uri .= $this->getQueryString();
0183         return $uri;
0184     }
0185 
0186 }