@@ -156,6 +156,122 @@ public function system_config_get($session_id, $section, $key) {
156156 return false ;
157157 }
158158 }
159+
160+ // config_value_* functions ---------------------------------------------------------------------------------------
161+
162+ //* Get config_value details
163+ public function config_value_get ($ session_id , $ group , $ name )
164+ {
165+ global $ app ;
166+
167+ if (!$ this ->checkPerm ($ session_id , 'config_value_get ' )) {
168+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
169+ return false ;
170+ }
171+
172+ // validate fields
173+ if ($ group == '' || $ name == '' ) {
174+ throw new SoapFault ('field_empty_error ' , 'Group and name parameter may not be empty. ' );
175+ return false ;
176+ }
177+
178+ return $ app ->db ->queryOneRecord ('SELECT * FROM sys_config WHERE `group` = ? AND `name` = ? ' , $ group , $ name );
179+ }
180+
181+ //* Add a config_value record
182+ public function config_value_add ($ session_id , $ group , $ name , $ value )
183+ {
184+ global $ app ;
185+
186+ if (!$ this ->checkPerm ($ session_id , 'config_value_add ' )) {
187+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
188+ return false ;
189+ }
190+
191+ // validate fields
192+ if ($ group == '' || $ name == '' || $ value == '' ) {
193+ throw new SoapFault ('field_empty_error ' , 'Group, name, and value parameter may not be empty. ' );
194+ return false ;
195+ }
196+
197+ if (is_array ($ app ->db ->queryOneRecord ('SELECT * FROM sys_config WHERE `group` = ? AND `name` = ? ' , $ group , $ name ))) {
198+ throw new SoapFault ('record_unique_error ' , 'Group plus name field combination is not unique. ' );
199+ return false ;
200+ }
201+
202+ return $ app ->db ->query ('INSERT INTO sys_config (`group`,`name`,`value`) VALUES (?,?,?) ' ,$ group ,$ name ,$ value );
203+ }
204+
205+ //* Update config_value record
206+ public function config_value_update ($ session_id , $ group , $ name , $ value )
207+ {
208+ global $ app ;
209+
210+ if (!$ this ->checkPerm ($ session_id , 'config_value_update ' )) {
211+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
212+ return false ;
213+ }
214+
215+ // validate fields
216+ if ($ group == '' || $ name == '' || $ value == '' ) {
217+ throw new SoapFault ('field_empty_error ' , 'Group, name, and value parameter may not be empty. ' );
218+ return false ;
219+ }
220+
221+ if (!is_array ($ app ->db ->queryOneRecord ('SELECT * FROM sys_config WHERE `group` = ? AND `name` = ? ' , $ group , $ name ))) {
222+ throw new SoapFault ('record_nonexist_error ' , 'There is no record with this group plus name field combination. ' );
223+ return false ;
224+ }
225+
226+ return $ app ->db ->query ('UPDATE sys_config SET `value` = ? WHERE `group` = ? AND `name` = ? ' ,$ value ,$ group ,$ name );
227+ }
228+
229+ //* Replace config_value record
230+ public function config_value_replace ($ session_id , $ group , $ name , $ value )
231+ {
232+ global $ app ;
233+
234+ if (!$ this ->checkPerm ($ session_id , 'config_value_replace ' )) {
235+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
236+ return false ;
237+ }
238+
239+ // validate fields
240+ if ($ group == '' || $ name == '' || $ value == '' ) {
241+ throw new SoapFault ('field_empty_error ' , 'Group, name, and value parameter may not be empty. ' );
242+ return false ;
243+ }
244+
245+ if (is_array ($ app ->db ->queryOneRecord ('SELECT * FROM sys_config WHERE `group` = ? AND `name` = ? ' , $ group , $ name ))) {
246+ return $ app ->db ->query ('UPDATE sys_config SET `value` = ? WHERE `group` = ? AND `name` = ? ' ,$ value ,$ group ,$ name );
247+ } else {
248+ return $ app ->db ->query ('INSERT INTO sys_config (`group`,`name`,`value`) VALUES (?,?,?) ' ,$ group ,$ name ,$ value );
249+ }
250+ }
251+
252+ //* Delete config_value record
253+ public function config_value_delete ($ session_id , $ group , $ name )
254+ {
255+ global $ app ;
256+
257+ if (!$ this ->checkPerm ($ session_id , 'config_value_delete ' )) {
258+ throw new SoapFault ('permission_denied ' , 'You do not have the permissions to access this function. ' );
259+ return false ;
260+ }
261+
262+ // validate fields
263+ if ($ group == '' || $ name == '' ) {
264+ throw new SoapFault ('field_empty_error ' , 'Group and name parameter may not be empty. ' );
265+ return false ;
266+ }
267+
268+ if (!is_array ($ app ->db ->queryOneRecord ('SELECT * FROM sys_config WHERE `group` = ? AND `name` = ? ' , $ group , $ name ))) {
269+ throw new SoapFault ('record_nonexist_error ' , 'There is no record with this group plus name field combination. ' );
270+ return false ;
271+ }
272+
273+ return $ app ->db ->query ('DELETE FROM sys_config WHERE `group` = ? AND `name` = ? ' ,$ group ,$ name );
274+ }
159275
160276}
161277
0 commit comments