| 105 |
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 |
|
|
|
11 |
use strict;
|
|
|
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::SYSADMIN) || die;
|
|
|
20 |
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
21 |
my $user = getUser ($EML);
|
|
|
22 |
my $username = $h->a ({ href=>"/schedule/view_user.pl?submit=View&RCid=$user->{RCid}" }, $user->{derby_name});
|
|
|
23 |
my $RCid = $user->{RCid};
|
|
|
24 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
25 |
my $YEAR = 1900 + (localtime)[5];
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
my $pageTitle = "Class Survey Questions";
|
|
|
29 |
my $prefscookie = "class_survey_questions";
|
|
|
30 |
our $DBTABLE = 'survey_question';
|
|
|
31 |
my %COLUMNS = (
|
|
|
32 |
# colname => [qw(DisplayName N type status)], status -> static | default | <blank>
|
| 198 |
- |
33 |
qid => [qw(QID 5 number static )],
|
|
|
34 |
qorder => [qw(Order 10 number default )],
|
|
|
35 |
question => [qw(Question 20 text default )],
|
|
|
36 |
type => [qw(Type 30 select default )],
|
|
|
37 |
required => [qw(Req 40 boolean default )],
|
|
|
38 |
private => [qw(Private 45 boolean default )],
|
|
|
39 |
added => [qw(Timestamp 50 date default )],
|
| 105 |
bgadell |
40 |
);
|
|
|
41 |
my $stylesheet = "/style.css";
|
|
|
42 |
my $homeURL = '/schedule/';
|
|
|
43 |
my @pagelimitoptions = ("All", 5, 10, 25);
|
|
|
44 |
|
|
|
45 |
# Set any custom "where" DB filters here...
|
|
|
46 |
my @whereClause;
|
|
|
47 |
|
|
|
48 |
# If we need to modify line item values, create a subroutine named "modify_$columnname"
|
|
|
49 |
# It will receive a hashref to the object lineitem
|
|
|
50 |
|
|
|
51 |
sub modify_qid {
|
|
|
52 |
my $hr = shift;
|
|
|
53 |
my $clicky = $hr->{qorder} ? "event.stopPropagation(); if (confirm('WARNING!\\nYou are modifying an active question.')==true) {return true;} else {return false;}" : "return true;";
|
|
|
54 |
my $extrawarning = $hr->{count} ? "\\nWARNING! It appears someone is signed up for it." : "";
|
|
|
55 |
return join " ", #$hr->{id},
|
|
|
56 |
$h->a ({ href=>"view_class_survey_question.pl?qid=$hr->{qid}&choice=Update", onClick=>$clicky }, "[Edit]"),
|
|
|
57 |
$h->a ({ href=>"view_class_survey_question.pl?qid=$hr->{qid}&choice=Copy" }, "[Copy]"),
|
|
|
58 |
$h->a ({ href=>"view_class_survey_question.pl?qid=$hr->{qid}&choice=Delete", onClick=>"event.stopPropagation(); if (confirm('Are you sure you want to DELETE this question?$extrawarning')==true) {return true;} else {return false;}" }, "[Delete]")
|
|
|
59 |
;
|
|
|
60 |
};
|
|
|
61 |
|
|
|
62 |
sub modify_required {
|
|
|
63 |
my $thing = shift;
|
|
|
64 |
return $thing->{required} ? "True" : "False";
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
sub modify_private {
|
|
|
68 |
my $thing = shift;
|
|
|
69 |
return $thing->{private} ? "True" : "False";
|
|
|
70 |
}
|
|
|
71 |
|
| 198 |
- |
72 |
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
|
|
|
73 |
# It will receive two fields, the field name and the current filter value (if any)
|
| 105 |
bgadell |
74 |
|
| 198 |
- |
75 |
# Uncomment and update if we want to enable clicking on a row to open a new page.
|
|
|
76 |
#
|
|
|
77 |
sub addRowClick {
|
|
|
78 |
my $t = shift;
|
|
|
79 |
return "location.href='view_class_survey_question.pl?qid=$t->{qid}&choice=View'";
|
| 105 |
bgadell |
80 |
}
|
|
|
81 |
|
| 198 |
- |
82 |
# Call the function to print the table view page (with available options)
|
|
|
83 |
printTablePage ({ Title => $pageTitle,
|
|
|
84 |
Table => $DBTABLE,
|
|
|
85 |
Columns => \%COLUMNS,
|
|
|
86 |
RCAuth => $RCAUTH_cookie,
|
|
|
87 |
Where => join (" and ", @whereClause),
|
|
|
88 |
DisplayYearSelect => 0,
|
|
|
89 |
HeaderButton => { field => "qid",
|
|
|
90 |
button => $h->input ({ type=>"button", value=>"Add", onClick=>"window.location.href='view_class_survey_question.pl'" }) }
|
|
|
91 |
});
|
| 105 |
bgadell |
92 |
|