@@ -37,6 +37,8 @@ class Template extends xmlTemplate {
37
37
private $ invalid_reason ;
38
38
# The TEMPLATE structural objectclasses
39
39
protected $ structural_oclass = array ();
40
+ # The objectclasses for which this template is the default
41
+ protected $ defaultfor_oclass = array ();
40
42
protected $ description = '' ;
41
43
# Is this a read-only template (only valid in modification templates)
42
44
private $ readonly = false ;
@@ -124,6 +126,31 @@ protected function storeTemplate($xmldata) {
124
126
125
127
break ;
126
128
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
+
127
154
# Build our attribute list from the DN and Template.
128
155
case ('attributes ' ):
129
156
if (DEBUG_ENABLED )
@@ -179,6 +206,7 @@ protected function storeTemplate($xmldata) {
179
206
180
207
if ($ xml_key == 'invalid ' && $ xml_value )
181
208
$ this ->setInvalid (_ ('Disabled by XML configuration ' ),true );
209
+
182
210
}
183
211
}
184
212
@@ -924,6 +952,15 @@ public function setInvisible() {
924
952
$ this ->visible = false ;
925
953
}
926
954
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
+
927
964
public function getRegExp () {
928
965
if (DEBUG_ENABLED && (($ fargs =func_get_args ())||$ fargs ='NOARGS ' ))
929
966
debug_log ('Entered (%%) ' ,5 ,1 ,__FILE__ ,__LINE__ ,__METHOD__ ,$ fargs ,$ this ->regexp );
0 commit comments