web/lib/Zend/Ldap/Node/Schema/ObjectClass/OpenLdap.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Ldap
       
    17  * @subpackage Schema
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: OpenLdap.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 /**
       
    24  * @see Zend_Ldap_Node_Schema_Item
       
    25  */
       
    26 require_once 'Zend/Ldap/Node/Schema/Item.php';
       
    27 /**
       
    28  * @see Zend_Ldap_Node_Schema_ObjectClass_Interface
       
    29  */
       
    30 require_once 'Zend/Ldap/Node/Schema/ObjectClass/Interface.php';
       
    31 
       
    32 /**
       
    33  * Zend_Ldap_Node_Schema_ObjectClass_OpenLdap provides access to the objectClass
       
    34  * schema information on an OpenLDAP server.
       
    35  *
       
    36  * @category   Zend
       
    37  * @package    Zend_Ldap
       
    38  * @subpackage Schema
       
    39  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    40  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    41  */
       
    42 class Zend_Ldap_Node_Schema_ObjectClass_OpenLdap extends Zend_Ldap_Node_Schema_Item
       
    43     implements Zend_Ldap_Node_Schema_ObjectClass_Interface
       
    44 {
       
    45     /**
       
    46      * All inherited "MUST" attributes
       
    47      *
       
    48      * @var array
       
    49      */
       
    50     protected $_inheritedMust = null;
       
    51     /**
       
    52      * All inherited "MAY" attributes
       
    53      *
       
    54      * @var array
       
    55      */
       
    56     protected $_inheritedMay = null;
       
    57 
       
    58 
       
    59     /**
       
    60      * Gets the objectClass name
       
    61      *
       
    62      * @return string
       
    63      */
       
    64     public function getName()
       
    65     {
       
    66         return $this->name;
       
    67     }
       
    68 
       
    69     /**
       
    70      * Gets the objectClass OID
       
    71      *
       
    72      * @return string
       
    73      */
       
    74     public function getOid()
       
    75     {
       
    76         return $this->oid;
       
    77     }
       
    78 
       
    79     /**
       
    80      * Gets the attributes that this objectClass must contain
       
    81      *
       
    82      * @return array
       
    83      */
       
    84     public function getMustContain()
       
    85     {
       
    86         if ($this->_inheritedMust === null) {
       
    87             $this->_resolveInheritance();
       
    88         }
       
    89         return $this->_inheritedMust;
       
    90     }
       
    91 
       
    92     /**
       
    93      * Gets the attributes that this objectClass may contain
       
    94      *
       
    95      * @return array
       
    96      */
       
    97     public function getMayContain()
       
    98     {
       
    99         if ($this->_inheritedMay === null) {
       
   100             $this->_resolveInheritance();
       
   101         }
       
   102         return $this->_inheritedMay;
       
   103     }
       
   104 
       
   105     /**
       
   106      * Resolves the inheritance tree
       
   107      *
       
   108      * @return void
       
   109      */
       
   110     protected function _resolveInheritance()
       
   111     {
       
   112         $must = $this->must;
       
   113         $may = $this->may;
       
   114         foreach ($this->getParents() as $p) {
       
   115             $must = array_merge($must, $p->getMustContain());
       
   116             $may = array_merge($may, $p->getMayContain());
       
   117         }
       
   118         $must = array_unique($must);
       
   119         $may = array_unique($may);
       
   120         $may = array_diff($may, $must);
       
   121         sort($must, SORT_STRING);
       
   122         sort($may, SORT_STRING);
       
   123         $this->_inheritedMust = $must;
       
   124         $this->_inheritedMay = $may;
       
   125     }
       
   126 
       
   127     /**
       
   128      * Gets the objectClass description
       
   129      *
       
   130      * @return string
       
   131      */
       
   132     public function getDescription()
       
   133     {
       
   134         return $this->desc;
       
   135     }
       
   136 
       
   137     /**
       
   138      * Gets the objectClass type
       
   139      *
       
   140      * @return integer
       
   141      */
       
   142     public function getType()
       
   143     {
       
   144         if ($this->structural) {
       
   145             return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_STRUCTURAL;
       
   146         } else if ($this->abstract) {
       
   147             return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_ABSTRACT;
       
   148         } else if ($this->auxiliary) {
       
   149             return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_AUXILIARY;
       
   150         } else {
       
   151             return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_UNKNOWN;
       
   152         }
       
   153     }
       
   154 
       
   155     /**
       
   156      * Returns the parent objectClasses of this class.
       
   157      * This includes structural, abstract and auxiliary objectClasses
       
   158      *
       
   159      * @return array
       
   160      */
       
   161     public function getParentClasses()
       
   162     {
       
   163         return $this->sup;
       
   164     }
       
   165 
       
   166     /**
       
   167      * Returns the parent object classes in the inhertitance tree if one exists
       
   168      *
       
   169      * @return array of Zend_Ldap_Node_Schema_ObjectClass_OpenLdap
       
   170      */
       
   171     public function getParents()
       
   172     {
       
   173         return $this->_parents;
       
   174     }
       
   175 }