PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/library/Zend/Ldap/Node/Schema/ObjectClass/OpenLdap.php

http://github.com/michael-romer/zf-boilerplate
PHP | 175 lines | 71 code | 12 blank | 92 comment | 8 complexity | 2b39322a34ccb756cce5e6a090c705b7 MD5 | raw file
Possible License(s): Unlicense, Apache-2.0
  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-2011 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 23775 2011-03-01 17:25:24Z ralph $
  21. */
  22. /**
  23. * @see Zend_Ldap_Node_Schema_Item
  24. */
  25. require_once 'Zend/Ldap/Node/Schema/Item.php';
  26. /**
  27. * @see Zend_Ldap_Node_Schema_ObjectClass_Interface
  28. */
  29. require_once 'Zend/Ldap/Node/Schema/ObjectClass/Interface.php';
  30. /**
  31. * Zend_Ldap_Node_Schema_ObjectClass_OpenLdap provides access to the objectClass
  32. * schema information on an OpenLDAP server.
  33. *
  34. * @category Zend
  35. * @package Zend_Ldap
  36. * @subpackage Schema
  37. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  38. * @license http://framework.zend.com/license/new-bsd New BSD License
  39. */
  40. class Zend_Ldap_Node_Schema_ObjectClass_OpenLdap extends Zend_Ldap_Node_Schema_Item
  41. implements Zend_Ldap_Node_Schema_ObjectClass_Interface
  42. {
  43. /**
  44. * All inherited "MUST" attributes
  45. *
  46. * @var array
  47. */
  48. protected $_inheritedMust = null;
  49. /**
  50. * All inherited "MAY" attributes
  51. *
  52. * @var array
  53. */
  54. protected $_inheritedMay = null;
  55. /**
  56. * Gets the objectClass name
  57. *
  58. * @return string
  59. */
  60. public function getName()
  61. {
  62. return $this->name;
  63. }
  64. /**
  65. * Gets the objectClass OID
  66. *
  67. * @return string
  68. */
  69. public function getOid()
  70. {
  71. return $this->oid;
  72. }
  73. /**
  74. * Gets the attributes that this objectClass must contain
  75. *
  76. * @return array
  77. */
  78. public function getMustContain()
  79. {
  80. if ($this->_inheritedMust === null) {
  81. $this->_resolveInheritance();
  82. }
  83. return $this->_inheritedMust;
  84. }
  85. /**
  86. * Gets the attributes that this objectClass may contain
  87. *
  88. * @return array
  89. */
  90. public function getMayContain()
  91. {
  92. if ($this->_inheritedMay === null) {
  93. $this->_resolveInheritance();
  94. }
  95. return $this->_inheritedMay;
  96. }
  97. /**
  98. * Resolves the inheritance tree
  99. *
  100. * @return void
  101. */
  102. protected function _resolveInheritance()
  103. {
  104. $must = $this->must;
  105. $may = $this->may;
  106. foreach ($this->getParents() as $p) {
  107. $must = array_merge($must, $p->getMustContain());
  108. $may = array_merge($may, $p->getMayContain());
  109. }
  110. $must = array_unique($must);
  111. $may = array_unique($may);
  112. $may = array_diff($may, $must);
  113. sort($must, SORT_STRING);
  114. sort($may, SORT_STRING);
  115. $this->_inheritedMust = $must;
  116. $this->_inheritedMay = $may;
  117. }
  118. /**
  119. * Gets the objectClass description
  120. *
  121. * @return string
  122. */
  123. public function getDescription()
  124. {
  125. return $this->desc;
  126. }
  127. /**
  128. * Gets the objectClass type
  129. *
  130. * @return integer
  131. */
  132. public function getType()
  133. {
  134. if ($this->structural) {
  135. return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_STRUCTURAL;
  136. } else if ($this->abstract) {
  137. return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_ABSTRACT;
  138. } else if ($this->auxiliary) {
  139. return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_AUXILIARY;
  140. } else {
  141. return Zend_Ldap_Node_Schema::OBJECTCLASS_TYPE_UNKNOWN;
  142. }
  143. }
  144. /**
  145. * Returns the parent objectClasses of this class.
  146. * This includes structural, abstract and auxiliary objectClasses
  147. *
  148. * @return array
  149. */
  150. public function getParentClasses()
  151. {
  152. return $this->sup;
  153. }
  154. /**
  155. * Returns the parent object classes in the inhertitance tree if one exists
  156. *
  157. * @return array of Zend_Ldap_Node_Schema_ObjectClass_OpenLdap
  158. */
  159. public function getParents()
  160. {
  161. return $this->_parents;
  162. }
  163. }