@@ -37,6 +37,8 @@ class Template extends xmlTemplate {
3737 private $ invalid_reason ;
3838 # The TEMPLATE structural objectclasses
3939 protected $ structural_oclass = array ();
40+ # The objectclasses for which this template is the default
41+ protected $ defaultfor_oclass = array ();
4042 protected $ description = '' ;
4143 # Is this a read-only template (only valid in modification templates)
4244 private $ readonly = false ;
@@ -124,6 +126,31 @@ protected function storeTemplate($xmldata) {
124126
125127 break ;
126128
129+ # Record our defaultFor object Classes from the Template.
130+ case ('defaultforobjectclasses ' ):
131+ if (DEBUG_ENABLED )
132+ debug_log ('Case [%s] ' ,4 ,0 ,__FILE__ ,__LINE__ ,__METHOD__ ,$ xml_key );
133+
134+ if (isset ($ xmldata ['template ' ][$ xml_key ]['defaultforobjectclass ' ]))
135+ if (is_array ($ xmldata ['template ' ][$ xml_key ]['defaultforobjectclass ' ])) {
136+ foreach ($ xmldata ['template ' ][$ xml_key ]['defaultforobjectclass ' ] as $ index => $ details ) {
137+
138+ # If we havent recorded this objectclass already, do so now.
139+ if (! in_array ($ details ,$ this ->defaultfor_oclass ))
140+ array_push ($ this ->defaultfor_oclass ,$ details );
141+ }
142+
143+ } else {
144+ # XML files with only 1 objectClass dont have a numeric index.
145+ $ soc = $ xmldata ['template ' ][$ xml_key ]['defaultforobjectclass ' ];
146+
147+ # If we havent recorded this objectclass already, do so now.
148+ if (! in_array ($ soc ,$ this ->defaultfor_oclass ))
149+ array_push ($ this ->defaultfor_oclass ,$ soc );
150+ }
151+
152+ break ;
153+
127154 # Build our attribute list from the DN and Template.
128155 case ('attributes ' ):
129156 if (DEBUG_ENABLED )
@@ -179,6 +206,7 @@ protected function storeTemplate($xmldata) {
179206
180207 if ($ xml_key == 'invalid ' && $ xml_value )
181208 $ this ->setInvalid (_ ('Disabled by XML configuration ' ),true );
209+
182210 }
183211 }
184212
@@ -924,6 +952,15 @@ public function setInvisible() {
924952 $ this ->visible = false ;
925953 }
926954
955+ /**
956+ * Get the objectclasses for which this template is the default
957+ *
958+ * @return array The objectclasses
959+ */
960+ public function getDefaultForObjectClass () {
961+ return $ this ->defaultfor_oclass ;
962+ }
963+
927964 public function getRegExp () {
928965 if (DEBUG_ENABLED && (($ fargs =func_get_args ())||$ fargs ='NOARGS ' ))
929966 debug_log ('Entered (%%) ' ,5 ,1 ,__FILE__ ,__LINE__ ,__METHOD__ ,$ fargs ,$ this ->regexp );
0 commit comments