Bug 25548: Remove Apache rewrite directives that trigger redirects
[koha.git] / mainpage.pl
blob183b5e0fcd2d13e2258e28527f113843e07972d1
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Copyright Paul Poulain 2002
6 # Parts Copyright Liblime 2007
7 # Copyright (C) 2013 Mark Tompsett
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Modern::Perl;
23 use CGI qw ( -utf8 );
24 use C4::Output;
25 use C4::Auth;
26 use C4::Koha;
27 use C4::NewsChannels; # GetNewsToDisplay
28 use C4::Tags qw/get_count_by_tag_status/;
29 use Koha::Patron::Modifications;
30 use Koha::Patron::Discharge;
31 use Koha::Reviews;
32 use Koha::ArticleRequests;
33 use Koha::ProblemReports;
34 use Koha::Quotes;
35 use Koha::Suggestions;
37 my $query = CGI->new;
39 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
41 template_name => "intranet-main.tt",
42 query => $query,
43 type => "intranet",
44 flagsrequired => { catalogue => 1, },
48 my $homebranch;
49 if (C4::Context->userenv) {
50 $homebranch = C4::Context->userenv->{'branch'};
52 my $all_koha_news = &GetNewsToDisplay("koha",$homebranch);
53 my $koha_news_count = scalar @$all_koha_news;
55 $template->param(
56 koha_news => $all_koha_news,
57 koha_news_count => $koha_news_count,
58 daily_quote => Koha::Quotes->get_daily_quote(),
61 my $branch =
62 ( C4::Context->preference("IndependentBranchesPatronModifications")
63 || C4::Context->preference("IndependentBranches") )
64 && !$flags->{'superlibrarian'}
65 ? C4::Context->userenv()->{'branch'}
66 : undef;
68 my $pendingcomments = Koha::Reviews->search_limited({ approved => 0 })->count;
69 my $pendingtags = get_count_by_tag_status(0);
71 # Get current branch count and total viewable count, if they don't match then pass
72 # both to template
74 if( C4::Context->only_my_library ){
75 my $local_pendingsuggestions_count = Koha::Suggestions->search({ status => "ASKED", branchcode => C4::Context->userenv()->{'branch'} })->count();
76 $template->param( pendingsuggestions => $local_pendingsuggestions_count );
77 } else {
78 my $pendingsuggestions = Koha::Suggestions->search({ status => "ASKED" });
79 my $local_pendingsuggestions_count = $pendingsuggestions->search({ 'me.branchcode' => C4::Context->userenv()->{'branch'} })->count();
80 my $pendingsuggestions_count = $pendingsuggestions->count();
81 $template->param(
82 all_pendingsuggestions => $pendingsuggestions_count != $local_pendingsuggestions_count ? $pendingsuggestions_count : 0,
83 pendingsuggestions => $local_pendingsuggestions_count
87 my $pending_borrower_modifications = Koha::Patron::Modifications->pending_count( $branch );
88 my $pending_discharge_requests = Koha::Patron::Discharge::count({ pending => 1 });
89 my $pending_article_requests = Koha::ArticleRequests->search_limited(
91 status => Koha::ArticleRequest::Status::Pending,
92 $branch ? ( 'me.branchcode' => $branch ) : (),
94 )->count;
95 my $pending_problem_reports = Koha::ProblemReports->search({ status => 'New' });
97 $template->param(
98 pendingcomments => $pendingcomments,
99 pendingtags => $pendingtags,
100 pending_borrower_modifications => $pending_borrower_modifications,
101 pending_discharge_requests => $pending_discharge_requests,
102 pending_article_requests => $pending_article_requests,
103 pending_problem_reports => $pending_problem_reports
106 output_html_with_http_headers $query, $cookie, $template->output;