From d1cab2c4e4965a4e8848020126d7929b7956de7d Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 30 Mar 2014 17:53:07 -0400 Subject: [PATCH] Save settings on POST, and add support for a textarea settingType. --- admin/setting.php | 3 --- admin/settings.php | 16 ++++++++++++++++ admin/templates/admin_settings.tpl | 16 +++++++++++++++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/admin/setting.php b/admin/setting.php index 0184fef..9c77d99 100755 --- a/admin/setting.php +++ b/admin/setting.php @@ -132,9 +132,6 @@ if ($_REQUEST['do'] == 'modify') $admin->row_span(T('Default Bug Assignment'), 'thead'); $admin->row_text(T('This is the default developer new bugs will be assigned to. If a user does not have permisssion to assign bugs, this will be the default. If you don\'t want any default assignment, leave this as Not Selected.'), construct_option_select('setting[defaultassign]', Bugdar::$datastore['assignto'], $bugsys->options['defaultassign'], 'userid', 'displayname', 0)); - // defaultcomment - $admin->row_span(T('Default Comment Text'), 'thead'); - $admin->row_textarea(T('If you wish to set a template for entering the initial comment of a bug report, then you may specify this here. However, the template will only take effect on the initial report/comment. Note: the template cannot be forced on the user as there is no way to validate it.'), 'setting[defaultcomment]', $bugsys->options['defaultcomment']); $admin->table_end(); diff --git a/admin/settings.php b/admin/settings.php index ca9762c..b2a0e40 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -37,5 +37,21 @@ class SettingsAction extends http\Action implements TemplatePreCaching { $response->data['title'] = T('Settings'); $response->context['template'] = 'admin_settings'; + + // Save settings on POST. + if ($request->http_method == 'POST') { + $query_bits = array(); + $values = array(); + foreach ($request->data['_POST']['settings'] AS $varname => $value) { + $query_bits[] = '(?,?)'; + array_push($values, $varname, $value); + } + + $query = bugdar::$db->Prepare(" + REPLACE into " . TABLE_PREFIX . "setting + (varname, value) + VALUES " . implode(', ', $query_bits)); + $query->Execute($values); + } } } diff --git a/admin/templates/admin_settings.tpl b/admin/templates/admin_settings.tpl index 661506f..eb9bc69 100644 --- a/admin/templates/admin_settings.tpl +++ b/admin/templates/admin_settings.tpl @@ -1,5 +1,7 @@ {%#import 'admin_header'%} +
+
@@ -76,8 +82,16 @@ title="{%=T('Use Header Redirects')%}" description="{%=T('Instead of displaying an intermediate page informing the user that their action was a success and a redirect is occurring, just send the user to the next screen using HTTP headers. This can save bandwidth.')%}" value="{%= Bugdar::$options['redirectheaders'] %}"> + + +
-{%#import 'admin_footer'%} \ No newline at end of file +
+ +{%#import 'admin_footer'%} -- 2.22.5