| 56 |
bgadell |
1 |
#!/usr/bin/perl
|
|
|
2 |
|
|
|
3 |
# Redirect error messages to a log of my choosing. (it's annoying to filter for errors in the shared env)
|
|
|
4 |
my $error_log_path = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco/logs/" : "/tmp/";
|
|
|
5 |
close STDERR;
|
|
|
6 |
open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";
|
|
|
7 |
#warn "Redirecting errors to ${error_log_path}vorc_error.log";
|
|
|
8 |
|
|
|
9 |
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
|
|
|
10 |
|
| 196 |
- |
11 |
use strict;
|
| 56 |
bgadell |
12 |
use cPanelUserConfig;
|
|
|
13 |
use CGI qw/param cookie header start_html url/;
|
|
|
14 |
use HTML::Tiny;
|
|
|
15 |
use tableViewer;
|
|
|
16 |
use RollerCon;
|
|
|
17 |
our $h = HTML::Tiny->new( mode => 'html' );
|
|
|
18 |
|
|
|
19 |
my $cookie_string = authenticate (RollerCon::ADMIN) || die;
|
|
|
20 |
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
21 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
22 |
|
|
|
23 |
my $pageTitle = "VORC System Settings";
|
|
|
24 |
our $DBTABLE = 'setting';
|
|
|
25 |
my %COLUMNS = (
|
|
|
26 |
# colname => [qw(DisplayName N type status)], status -> static | default | <blank>
|
| 196 |
- |
27 |
key => [qw(Key 10 text static )],
|
|
|
28 |
value => [qw(Value 15 text default )],
|
|
|
29 |
note => [qw(Note 60 text )],
|
| 56 |
bgadell |
30 |
);
|
|
|
31 |
|
|
|
32 |
my @whereClause;
|
|
|
33 |
|
|
|
34 |
# If we need to modify line item values, create a subroutine named "modify_$columnname"
|
|
|
35 |
# It will receive a hashref to the object lineitem
|
|
|
36 |
|
|
|
37 |
sub modify_key {
|
|
|
38 |
my $hr = shift;
|
| 196 |
- |
39 |
my $clicky = "event.stopPropagation(); if (confirm('WARNING!\\nYou are modifying a system setting.')==true) {return true;} else {return false;}";
|
|
|
40 |
return join " ",
|
| 56 |
bgadell |
41 |
$h->a ({ href=>"view_setting.pl?setting.key=$hr->{'key'}&choice=Update", onClick=>$clicky }, "[Edit]"),
|
|
|
42 |
$h->a ({ href=>"view_setting.pl?setting.key=$hr->{'key'}&choice=Copy" }, "[Copy]"),
|
|
|
43 |
$h->a ({ href=>"view_setting.pl?setting.key=$hr->{'key'}&choice=Delete", onClick=>"event.stopPropagation(); if (confirm('Are you sure you want to DELETE this setting?')==true) {return true;} else {return false;}" }, "[Delete]"),
|
|
|
44 |
$hr->{key}
|
|
|
45 |
;
|
|
|
46 |
};
|
|
|
47 |
|
|
|
48 |
sub modify_time {
|
|
|
49 |
my $t = shift;
|
|
|
50 |
return convertTime $t->{time};
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
sub modify_start_time {
|
|
|
54 |
my $t = shift;
|
|
|
55 |
return convertTime $t->{start_time};
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
sub modify_end_time {
|
|
|
59 |
my $t = shift;
|
|
|
60 |
return convertTime $t->{end_time};
|
|
|
61 |
}
|
|
|
62 |
|
| 196 |
- |
63 |
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
|
|
|
64 |
# It will receive two fields, the field name and the current filter value (if any)
|
| 56 |
bgadell |
65 |
|
| 196 |
- |
66 |
# Uncomment and update if we want to enable clicking on a row to open a new page.
|
|
|
67 |
#
|
|
|
68 |
sub addRowClick {
|
|
|
69 |
my $t = shift;
|
| 56 |
bgadell |
70 |
|
| 196 |
- |
71 |
return "location.href='view_setting.pl?setting.key=$t->{key}&choice=View'";
|
| 56 |
bgadell |
72 |
}
|
|
|
73 |
|
| 196 |
- |
74 |
# Call the function to print the table view page (with available options)
|
|
|
75 |
printTablePage ({ Title => $pageTitle,
|
|
|
76 |
Table => $DBTABLE,
|
|
|
77 |
Columns => \%COLUMNS,
|
|
|
78 |
RCAuth => $RCAUTH_cookie,
|
|
|
79 |
DisplayYearSelect => 0,
|
|
|
80 |
HeaderButton => { field => "key",
|
|
|
81 |
button => $h->input ({ type=>"button", value=>"Add", onClick=>"window.location.href='view_setting.pl'" }) }
|
|
|
82 |
});
|