web/Zend/Gdata/Gapps/MemberEntry.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:$
       
    22  */
       
    23 
       
    24 /**
       
    25  * @see Zend_Gdata_Entry
       
    26  */
       
    27 require_once 'Zend/Gdata/Entry.php';
       
    28 
       
    29 /**
       
    30  * @see Zend_Gdata_Gapps_Extension_Property
       
    31  */
       
    32 require_once 'Zend/Gdata/Gapps/Extension/Property.php';
       
    33 
       
    34 /**
       
    35  * Data model class for a Google Apps Member Entry.
       
    36  *
       
    37  * Each member entry describes a single member within a Google Apps hosted
       
    38  * domain.
       
    39  *
       
    40  * To transfer member entries to and from the Google Apps servers, including
       
    41  * creating new entries, refer to the Google Apps service class,
       
    42  * Zend_Gdata_Gapps.
       
    43  *
       
    44  * This class represents <atom:entry> in the Google Data protocol.
       
    45  *
       
    46  * @category   Zend
       
    47  * @package    Zend_Gdata
       
    48  * @subpackage Gapps
       
    49  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    50  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    51  */
       
    52 class Zend_Gdata_Gapps_MemberEntry extends Zend_Gdata_Entry
       
    53 {
       
    54 
       
    55     protected $_entryClassName = 'Zend_Gdata_Gapps_MemberEntry';
       
    56 
       
    57     /**
       
    58      * <apps:property> element containing information about other items
       
    59      * relevant to this entry.
       
    60      *
       
    61      * @var Zend_Gdata_Gapps_Extension_Property
       
    62      */
       
    63     protected $_property = array();
       
    64 
       
    65     /**
       
    66      * Create a new instance.
       
    67      *
       
    68      * @param DOMElement $element (optional) DOMElement from which this
       
    69      *          object should be constructed.
       
    70      */
       
    71     public function __construct($element = null)
       
    72     {
       
    73         $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces);
       
    74         parent::__construct($element);
       
    75     }
       
    76 
       
    77     /**
       
    78      * Retrieves a DOMElement which corresponds to this element and all
       
    79      * child properties.  This is used to build an entry back into a DOM
       
    80      * and eventually XML text for application storage/persistence.
       
    81      *
       
    82      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
       
    83      * @return DOMElement The DOMElement representing this element and all
       
    84      *          child properties.
       
    85      */
       
    86     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
       
    87     {
       
    88         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
       
    89 
       
    90         foreach ($this->_property as $p) {
       
    91             $element->appendChild($p->getDOM($element->ownerDocument));
       
    92         }
       
    93         return $element;
       
    94     }
       
    95 
       
    96     /**
       
    97      * Creates individual Entry objects of the appropriate type and
       
    98      * stores them as members of this entry based upon DOM data.
       
    99      *
       
   100      * @param DOMNode $child The DOMNode to process
       
   101      */
       
   102     protected function takeChildFromDOM($child)
       
   103     {
       
   104         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
       
   105 
       
   106         switch ($absoluteNodeName) {
       
   107 
       
   108             case $this->lookupNamespace('apps') . ':' . 'property';
       
   109                 $property = new Zend_Gdata_Gapps_Extension_Property();
       
   110                 $property->transferFromDOM($child);
       
   111                 $this->_property[] = $property;
       
   112                 break;
       
   113             default:
       
   114                 parent::takeChildFromDOM($child);
       
   115                 break;
       
   116         }
       
   117     }
       
   118 
       
   119     /**
       
   120      * Returns all property tags for this entry
       
   121      *
       
   122      * @param string $rel The rel value of the property to be found. If null,
       
   123      *          the array of properties is returned instead.
       
   124      * @return mixed Either an array of Zend_Gdata_Gapps_Extension_Property
       
   125      *          objects if $rel is null, a single
       
   126      *          Zend_Gdata_Gapps_Extension_Property object if $rel is specified
       
   127      *          and a matching feed link is found, or null if $rel is
       
   128      *          specified and no matching property is found.
       
   129      */
       
   130     public function getProperty($rel = null)
       
   131     {
       
   132         if ($rel == null) {
       
   133             return $this->_property;
       
   134         } else {
       
   135             foreach ($this->_property as $p) {
       
   136                 if ($p->rel == $rel) {
       
   137                     return $p;
       
   138                 }
       
   139             }
       
   140             return null;
       
   141         }
       
   142     }
       
   143 
       
   144     /**
       
   145      * Set the value of the  property property for this object.
       
   146      *
       
   147      * @param array $value A collection of
       
   148      *          Zend_Gdata_Gapps_Extension_Property objects.
       
   149      * @return Zend_Gdata_Gapps_MemberEntry Provides a fluent interface.
       
   150      */
       
   151     public function setProperty($value)
       
   152     {
       
   153         $this->_property = $value;
       
   154         return $this;
       
   155     }
       
   156 
       
   157 }
       
   158 
       
   159