Lines 45-50
if ( $cgi->param('expirationdate') ) {
Link Here
|
45 |
} |
45 |
} |
46 |
my $timestamp = output_pref({ dt => dt_from_string( scalar $cgi->param('timestamp') ), dateformat => 'iso', dateonly => 1 }); |
46 |
my $timestamp = output_pref({ dt => dt_from_string( scalar $cgi->param('timestamp') ), dateformat => 'iso', dateonly => 1 }); |
47 |
my $number = $cgi->param('number'); |
47 |
my $number = $cgi->param('number'); |
|
|
48 |
my $helpkey = $cgi->param('helpkey'); |
48 |
my $lang = $cgi->param('lang'); |
49 |
my $lang = $cgi->param('lang'); |
49 |
my $branchcode = $cgi->param('branch'); |
50 |
my $branchcode = $cgi->param('branch'); |
50 |
my $error_message = $cgi->param('error_message'); |
51 |
my $error_message = $cgi->param('error_message'); |
Lines 55-71
$branchcode = undef if (defined($branchcode) && $branchcode eq '');
Link Here
|
55 |
|
56 |
|
56 |
my $new_detail = get_opac_new($id); |
57 |
my $new_detail = get_opac_new($id); |
57 |
|
58 |
|
|
|
59 |
# flagsrequired checks for all flags listed, we need an 'or' |
60 |
# to work with edit_news or edit_help. |
58 |
my ( $template, $borrowernumber, $cookie ) = get_template_and_user( |
61 |
my ( $template, $borrowernumber, $cookie ) = get_template_and_user( |
59 |
{ |
62 |
{ |
60 |
template_name => "tools/koha-news.tt", |
63 |
template_name => "tools/koha-news.tt", |
61 |
query => $cgi, |
64 |
query => $cgi, |
62 |
type => "intranet", |
65 |
type => "intranet", |
63 |
authnotrequired => 0, |
66 |
authnotrequired => 1, |
64 |
flagsrequired => { tools => 'edit_news' }, |
|
|
65 |
debug => 1, |
67 |
debug => 1, |
66 |
} |
68 |
} |
67 |
); |
69 |
); |
68 |
|
70 |
|
|
|
71 |
#news based help system can call this script as a popup window |
72 |
$template->param( popup_window => 1 ) if( $cgi->param('popup_window')== 1 ); |
73 |
|
74 |
my $popupreferer = $cgi->param('popupreferer') // ''; |
75 |
if ($ popupreferer ) { |
76 |
$template->param( popupreferer => $popupreferer ); |
77 |
} |
78 |
|
79 |
#Check now the flags, user must have news or help edit permission |
80 |
if ( not (defined $template->{VARS}->{'CAN_user_tools_edit_news'} || |
81 |
defined $template->{VARS}->{'CAN_user_tools_edit_help'} ) ) { |
82 |
warn "EXIT FROM koha-news.pl "; |
83 |
print $cgi->redirect("/cgi-bin/koha/errors/403.pl"); |
84 |
} else { |
85 |
#TODO: Indent as followup to bug 18483 |
86 |
|
69 |
# Pass error message if there is one. |
87 |
# Pass error message if there is one. |
70 |
$template->param( error_message => $error_message ) if $error_message; |
88 |
$template->param( error_message => $error_message ) if $error_message; |
71 |
|
89 |
|
Lines 99-105
if ( $op eq 'add_form' ) {
Link Here
|
99 |
$template->{VARS}->{'new_detail'} = $new_detail; |
117 |
$template->{VARS}->{'new_detail'} = $new_detail; |
100 |
} |
118 |
} |
101 |
else { |
119 |
else { |
102 |
$template->param( op => 'add' ); |
120 |
$template->param( |
|
|
121 |
op => 'add', |
122 |
helpkey => $helpkey |
123 |
); |
124 |
|
103 |
} |
125 |
} |
104 |
} |
126 |
} |
105 |
elsif ( $op eq 'add' ) { |
127 |
elsif ( $op eq 'add' ) { |
Lines 112-125
elsif ( $op eq 'add' ) {
Link Here
|
112 |
expirationdate => $expirationdate, |
134 |
expirationdate => $expirationdate, |
113 |
timestamp => $timestamp, |
135 |
timestamp => $timestamp, |
114 |
number => $number, |
136 |
number => $number, |
|
|
137 |
helpkey => $helpkey, |
115 |
branchcode => $branchcode, |
138 |
branchcode => $branchcode, |
116 |
borrowernumber => $borrowernumber, |
139 |
borrowernumber => $borrowernumber, |
117 |
} |
140 |
} |
118 |
); |
141 |
); |
119 |
print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); |
142 |
|
|
|
143 |
if ( $popupreferer ) { |
144 |
print $cgi->redirect( "/cgi-bin/koha/help.pl?popupreferer=$popupreferer"); |
145 |
} else { |
146 |
print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); |
147 |
} |
120 |
} |
148 |
} |
121 |
else { |
149 |
else { |
122 |
print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl?error_message=title_missing"); |
150 |
print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl?error_message=title_missing&popupreferer=$popupreferer"); |
123 |
} |
151 |
} |
124 |
} |
152 |
} |
125 |
elsif ( $op eq 'edit' ) { |
153 |
elsif ( $op eq 'edit' ) { |
Lines 131-141
elsif ( $op eq 'edit' ) {
Link Here
|
131 |
lang => $lang, |
159 |
lang => $lang, |
132 |
expirationdate => $expirationdate, |
160 |
expirationdate => $expirationdate, |
133 |
timestamp => $timestamp, |
161 |
timestamp => $timestamp, |
|
|
162 |
helpkey => $helpkey, |
134 |
number => $number, |
163 |
number => $number, |
135 |
branchcode => $branchcode, |
164 |
branchcode => $branchcode, |
136 |
} |
165 |
} |
137 |
); |
166 |
); |
138 |
print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); |
167 |
|
|
|
168 |
if ( $popupreferer ) { |
169 |
print $cgi->redirect("/cgi-bin/koha/help.pl?popupreferer=$popupreferer"); |
170 |
} else { |
171 |
print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); |
172 |
} |
139 |
} |
173 |
} |
140 |
elsif ( $op eq 'del' ) { |
174 |
elsif ( $op eq 'del' ) { |
141 |
my @ids = $cgi->multi_param('ids'); |
175 |
my @ids = $cgi->multi_param('ids'); |
Lines 145-151
elsif ( $op eq 'del' ) {
Link Here
|
145 |
|
179 |
|
146 |
else { |
180 |
else { |
147 |
|
181 |
|
148 |
my ( $opac_news_count, $opac_news ) = &get_opac_news( undef, $lang, $branchcode ); |
182 |
my ( $opac_news_count, $opac_news ) = &get_opac_news( undef, 'staffhelp', $branchcode ); |
149 |
|
183 |
|
150 |
foreach my $new ( @$opac_news ) { |
184 |
foreach my $new ( @$opac_news ) { |
151 |
next unless $new->{'expirationdate'}; |
185 |
next unless $new->{'expirationdate'}; |
Lines 161-164
else {
Link Here
|
161 |
); |
195 |
); |
162 |
} |
196 |
} |
163 |
$template->param( lang => $lang ); |
197 |
$template->param( lang => $lang ); |
|
|
198 |
} |
164 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
199 |
output_html_with_http_headers $cgi, $cookie, $template->output; |
165 |
- |
|
|