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_Entry
0026  */
0027 // require_once 'Zend/Gdata/Entry.php';
0028 
0029 /**
0030  * @see Zend_Gdata_Extension_FeedLink
0031  */
0032 // require_once 'Zend/Gdata/Extension/FeedLink.php';
0033 
0034 /**
0035  * @see Zend_Gdata_Gapps_Extension_Login
0036  */
0037 // require_once 'Zend/Gdata/Gapps/Extension/Login.php';
0038 
0039 /**
0040  * @see Zend_Gdata_Gapps_Extension_Name
0041  */
0042 // require_once 'Zend/Gdata/Gapps/Extension/Name.php';
0043 
0044 /**
0045  * @see Zend_Gdata_Gapps_Extension_Quota
0046  */
0047 // require_once 'Zend/Gdata/Gapps/Extension/Quota.php';
0048 
0049 /**
0050  * Data model class for a Google Apps User Entry.
0051  *
0052  * Each user entry describes a single user within a Google Apps hosted
0053  * domain.
0054  *
0055  * To transfer user entries to and from the Google Apps servers, including
0056  * creating new entries, refer to the Google Apps service class,
0057  * Zend_Gdata_Gapps.
0058  *
0059  * This class represents <atom:entry> in the Google Data protocol.
0060  *
0061  * @category   Zend
0062  * @package    Zend_Gdata
0063  * @subpackage Gapps
0064  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0065  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0066  */
0067 class Zend_Gdata_Gapps_UserEntry extends Zend_Gdata_Entry
0068 {
0069 
0070     protected $_entryClassName = 'Zend_Gdata_Gapps_UserEntry';
0071 
0072     /**
0073      * <apps:login> element containing information about this user's
0074      * account, including their username and permissions.
0075      *
0076      * @var Zend_Gdata_Gapps_Extension_Login
0077      */
0078     protected $_login = null;
0079 
0080     /**
0081      * <apps:name> element containing the user's actual name.
0082      *
0083      * @var Zend_Gdata_Gapps_Extension_Name
0084      */
0085     protected $_name = null;
0086 
0087     /**
0088      * <apps:quotq> element describing any storage quotas in place for
0089      * this user.
0090      *
0091      * @var Zend_Gdata_Gapps_Extension_Quota
0092      */
0093     protected $_quota = null;
0094 
0095     /**
0096      * <gd:feedLink> element containing information about other feeds
0097      * relevant to this entry.
0098      *
0099      * @var Zend_Gdata_Extension_FeedLink
0100      */
0101     protected $_feedLink = array();
0102 
0103     /**
0104      * Create a new instance.
0105      *
0106      * @param DOMElement $element (optional) DOMElement from which this
0107      *          object should be constructed.
0108      */
0109     public function __construct($element = null)
0110     {
0111         $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
0112         parent::__construct($element);
0113     }
0114 
0115     /**
0116      * Retrieves a DOMElement which corresponds to this element and all
0117      * child properties.  This is used to build an entry back into a DOM
0118      * and eventually XML text for application storage/persistence.
0119      *
0120      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0121      * @return DOMElement The DOMElement representing this element and all
0122      *          child properties.
0123      */
0124     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0125     {
0126         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0127         if ($this->_login !== null) {
0128             $element->appendChild($this->_login->getDOM($element->ownerDocument));
0129         }
0130         if ($this->_name !== null) {
0131             $element->appendChild($this->_name->getDOM($element->ownerDocument));
0132         }
0133         if ($this->_quota !== null) {
0134             $element->appendChild($this->_quota->getDOM($element->ownerDocument));
0135         }
0136         foreach ($this->_feedLink as $feedLink) {
0137             $element->appendChild($feedLink->getDOM($element->ownerDocument));
0138         }
0139         return $element;
0140     }
0141 
0142     /**
0143      * Creates individual Entry objects of the appropriate type and
0144      * stores them as members of this entry based upon DOM data.
0145      *
0146      * @param DOMNode $child The DOMNode to process
0147      */
0148     protected function takeChildFromDOM($child)
0149     {
0150         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
0151 
0152         switch ($absoluteNodeName) {
0153             case $this->lookupNamespace('apps') . ':' . 'login';
0154                 $login = new Zend_Gdata_Gapps_Extension_Login();
0155                 $login->transferFromDOM($child);
0156                 $this->_login = $login;
0157                 break;
0158             case $this->lookupNamespace('apps') . ':' . 'name';
0159                 $name = new Zend_Gdata_Gapps_Extension_Name();
0160                 $name->transferFromDOM($child);
0161                 $this->_name = $name;
0162                 break;
0163             case $this->lookupNamespace('apps') . ':' . 'quota';
0164                 $quota = new Zend_Gdata_Gapps_Extension_Quota();
0165                 $quota->transferFromDOM($child);
0166                 $this->_quota = $quota;
0167                 break;
0168             case $this->lookupNamespace('gd') . ':' . 'feedLink';
0169                 $feedLink = new Zend_Gdata_Extension_FeedLink();
0170                 $feedLink->transferFromDOM($child);
0171                 $this->_feedLink[] = $feedLink;
0172                 break;
0173             default:
0174                 parent::takeChildFromDOM($child);
0175                 break;
0176         }
0177     }
0178 
0179     /**
0180      * Get the value of the login property for this object.
0181      *
0182      * @see setLogin
0183      * @return Zend_Gdata_Gapps_Extension_Login The requested object.
0184      */
0185     public function getLogin()
0186     {
0187         return $this->_login;
0188     }
0189 
0190     /**
0191      * Set the value of the login property for this object. This property
0192      * is used to store the username address of the current user.
0193      *
0194      * @param Zend_Gdata_Gapps_Extension_Login $value The desired value for
0195      *          this instance's login property.
0196      * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface.
0197      */
0198     public function setLogin($value)
0199     {
0200         $this->_login = $value;
0201         return $this;
0202     }
0203 
0204     /**
0205      * Get the value of the name property for this object.
0206      *
0207      * @see setName
0208      * @return Zend_Gdata_Gapps_Extension_Name The requested object.
0209      */
0210     public function getName()
0211     {
0212         return $this->_name;
0213     }
0214 
0215     /**
0216      * Set the value of the name property for this object. This property
0217      * is used to store the full name of the current user.
0218      *
0219      * @param Zend_Gdata_Gapps_Extension_Name $value The desired value for
0220      *          this instance's name property.
0221      * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface.
0222      */
0223     public function setName($value)
0224     {
0225         $this->_name = $value;
0226         return $this;
0227     }
0228 
0229     /**
0230      * Get the value of the quota property for this object.
0231      *
0232      * @see setQuota
0233      * @return Zend_Gdata_Gapps_Extension_Quota The requested object.
0234      */
0235     public function getQuota()
0236     {
0237         return $this->_quota;
0238     }
0239 
0240     /**
0241      * Set the value of the quota property for this object. This property
0242      * is used to store the amount of storage available for the current
0243      * user. Quotas may not be modifiable depending on the domain used.
0244      *
0245      * @param Zend_Gdata_Gapps_Extension_Quota $value The desired value for
0246      *          this instance's quota property.
0247      * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface.
0248      */
0249     public function setQuota($value)
0250     {
0251         $this->_quota = $value;
0252         return $this;
0253     }
0254 
0255     /**
0256      * Returns all feed links for this entry, or if a rel value is
0257      * specified, the feed link associated with that value is returned.
0258      *
0259      * @param string $rel The rel value of the link to be found. If null,
0260      *          the array of links is returned instead.
0261      * @return mixed Either an array of Zend_Gdata_Extension_FeedLink
0262      *          objects if $rel is null, a single
0263      *          Zend_Gdata_Extension_FeedLink object if $rel is specified
0264      *          and a matching feed link is found, or null if $rel is
0265      *          specified and no matching feed link is found.
0266      */
0267     public function getFeedLink($rel = null)
0268     {
0269         if ($rel == null) {
0270             return $this->_feedLink;
0271         } else {
0272             foreach ($this->_feedLink as $feedLink) {
0273                 if ($feedLink->rel == $rel) {
0274                     return $feedLink;
0275                 }
0276             }
0277             return null;
0278         }
0279     }
0280 
0281     /**
0282      * Set the value of the feed link property for this object. This property
0283      * is used to provide links to alternative feeds relevant to this entry.
0284      *
0285      * @param array $value A collection of
0286      *          Zend_Gdata_Gapps_Extension_FeedLink objects.
0287      * @return Zend_Gdata_Gapps_EventEntry Provides a fluent interface.
0288      */
0289     public function setFeedLink($value)
0290     {
0291         $this->_feedLink = $value;
0292         return $this;
0293     }
0294 
0295 }