@@ -117,10 +117,22 @@ public function save()
117117 {
118118 $ value = array ();
119119 $ type = explode ('| ' , $ type );
120+
121+ // Basically updates existing config data with form input
120122 foreach ($ this ->ext_config ->__get ($ config ) as $ key => $ current )
121123 {
122124 $ value [$ key ] = $ this ->request ->variable ($ config . '_ ' . $ key , $ this ->get_default ($ type [1 ]));
123125 }
126+
127+ // Saves new config data from newly added phpBB branches
128+ foreach (array_keys ($ this ->ext_config ->__get ('phpbb_versions ' )) as $ branch )
129+ {
130+ if ($ this ->request ->is_set ($ config . '_ ' . $ branch ) && !isset ($ value [$ branch ]))
131+ {
132+ $ value [$ branch ] = $ this ->request ->variable ($ config . '_ ' . $ branch , $ this ->get_default ($ type [1 ]));
133+ }
134+ }
135+
124136 $ this ->config_text ->set (ext::TITANIA_CONFIG_PREFIX . $ config , json_encode ($ value ));
125137 $ this ->config ->delete (ext::TITANIA_CONFIG_PREFIX . $ config ); // delete it from config if its still there for any reason
126138 }
@@ -151,6 +163,7 @@ protected function parse_configs()
151163 if (null !== $ this ->ext_config ->__get ($ config ))
152164 {
153165 $ configurable [$ config ] = array ('NAME ' => $ config , 'TYPE ' => $ type , 'VALUE ' => $ this ->ext_config ->{$ config });
166+ $ configurable [$ config ] = $ this ->check_for_phpbb_branches ($ configurable [$ config ]);
154167 continue ;
155168 }
156169 }
@@ -165,6 +178,36 @@ protected function parse_configs()
165178 return $ configurable ;
166179 }
167180
181+ protected function check_for_phpbb_branches ($ config )
182+ {
183+ if ($ config ['TYPE ' ] !== 'array|string ' && $ config ['TYPE ' ] !== 'array|forums ' )
184+ {
185+ return $ config ;
186+ }
187+
188+ $ phpbb_branches = array_fill_keys (array_keys ($ this ->ext_config ->__get ('phpbb_versions ' )), '' );
189+
190+ switch ($ config ['NAME ' ])
191+ {
192+ // Show phpbb branches >= 3.1
193+ case 'forum_extension_database ' :
194+ unset($ phpbb_branches ['20 ' ], $ phpbb_branches ['30 ' ]);
195+ $ config ['VALUE ' ] = array_replace ($ phpbb_branches , $ config ['VALUE ' ]);
196+ break ;
197+
198+ // Show phpbb branches >= 3.0
199+ case 'forum_style_database ' :
200+ case 'demo_style_path ' :
201+ case 'demo_style_url ' :
202+ case 'demo_style_hook ' :
203+ unset($ phpbb_branches ['20 ' ]);
204+ $ config ['VALUE ' ] = array_replace ($ phpbb_branches , $ config ['VALUE ' ]);
205+ break ;
206+ }
207+
208+ return $ config ;
209+ }
210+
168211 /**
169212 * Get all user groups (except bots and guests) and return
170213 * an array of their IDs and translated group names.
0 commit comments