add disable_settings_changes conf for the demo
authorivan <ivan>
Sun, 6 Jun 2010 05:58:16 +0000 (05:58 +0000)
committerivan <ivan>
Sun, 6 Jun 2010 05:58:16 +0000 (05:58 +0000)
FS/FS/Conf.pm
httemplate/config/config-delete.cgi
httemplate/config/config-process.cgi

index a1ee23c..472320d 100644 (file)
@@ -717,6 +717,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'business-onlinepayment-test_transaction',
+    'section'     => 'billing',
+    'description' => 'Turns on the Business::OnlinePayment test_transaction flag.  Note that not all gateway modules support this flag; if yours does not, transactions will still be sent live.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'countrydefault',
     'section'     => 'UI',
     'description' => 'Default two-letter country code (if not supplied, the default is `US\')',
@@ -3008,6 +3015,13 @@ worry that config_items is freeside-specific and icky.
   },
 
   {
+    'key'         => 'disable_settings_changes',
+    'section'     => '',
+    'description' => 'Disable all settings changes, for demos, except for the usernames given in the comma-separated list.',
+    'type'        => [qw( checkbox text )],
+  },
+
+  {
     'key'         => 'cust_main-edit_agent_custid',
     'section'     => 'UI',
     'description' => 'Enable editing of the agent_custid field.',
index a05cb1e..4888868 100644 (file)
@@ -1,6 +1,17 @@
 <%init>
-die "access denied\n"
-  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+die "access denied\n" unless $curuser->access_right('Configuration');
+
+my $fsconf = new FS::Conf;
+if ( $fsconf->exists('disable_settings_changes') ) {
+  my @changers = split(/\s*,\s*/, $fsconf->config('disable_settings_changes'));
+  my %changers = map { $_=>1 } @changers;
+  unless ( $changers{$curuser->username} ) {
+    errorpage("Disabled in web demo");
+    die "shouldn't be reached";
+  }
+}
 
 $cgi->param('confnum') =~ /^(\d+)$/ or die "illegal or missing confnum";
 my $confnum = $1;
index 788d901..c96f8d4 100644 (file)
@@ -70,10 +70,21 @@ my %namecol = (
 );
 </%once>
 <%init>
-die "access denied\n"
-  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+die "access denied\n" unless $curuser->access_right('Configuration');
 
 my $conf = new FS::Conf;
+
+if ( $conf->exists('disable_settings_changes') ) {
+  my @changers = split(/\s*,\s*/, $conf->config('disable_settings_changes'));
+  my %changers = map { $_=>1 } @changers;
+  unless ( $changers{$curuser->username} ) {
+    errorpage("Disabled in web demo");
+    die "shouldn't be reached";
+  }
+}
+
 $FS::Conf::DEBUG = 1;
 my @config_items = grep { $_->key != ~/^invoice_(html|latex|template)/ }
                         $conf->config_items;