mainpage.pl 2.7 KB
Newer Older
rych's avatar
rych committed
1 2
#!/usr/bin/perl

3 4
# This file is part of Koha.
#
5 6
# Copyright Paul Poulain 2002
# Parts Copyright Liblime 2007
7
# Copyright (C) 2013  Mark Tompsett
8
#
9 10 11 12
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
rych's avatar
rych committed
13
#
14 15 16 17
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
rych's avatar
rych committed
18
#
19 20
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
rych's avatar
rych committed
21

22
use Modern::Perl;
23
use CGI qw ( -utf8 );
hdl's avatar
hdl committed
24
use C4::Output;
rych's avatar
rych committed
25 26
use C4::Auth;
use C4::Koha;
27
use C4::NewsChannels; # GetNewsToDisplay
28 29 30
use C4::Review qw/numberofreviews/;
use C4::Suggestions qw/CountSuggestion/;
use C4::Tags qw/get_count_by_tag_status/;
31 32
use Koha::Patron::Modifications;
use Koha::Patron::Discharge;
rych's avatar
rych committed
33

34 35 36
my $query = new CGI;

my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
rych's avatar
rych committed
37
    {
38
        template_name   => "intranet-main.tt",
rych's avatar
rych committed
39 40 41
        query           => $query,
        type            => "intranet",
        authnotrequired => 0,
42
        flagsrequired   => { catalogue => 1, },
rych's avatar
rych committed
43 44 45
    }
);

46 47 48 49 50
my $homebranch;
if (C4::Context->userenv) {
    $homebranch = C4::Context->userenv->{'branch'};
}
my $all_koha_news   = &GetNewsToDisplay("koha",$homebranch);
rych's avatar
rych committed
51 52 53 54 55 56 57
my $koha_news_count = scalar @$all_koha_news;

$template->param(
    koha_news       => $all_koha_news,
    koha_news_count => $koha_news_count
);

58
my $branch =
59 60
  (      C4::Context->preference("IndependentBranchesPatronModifications")
      || C4::Context->preference("IndependentBranches") )
61 62 63
  && !$flags->{'superlibrarian'}
  ? C4::Context->userenv()->{'branch'}
  : undef;
64 65 66 67 68

my $pendingcomments    = numberofreviews(0);
my $pendingtags        = get_count_by_tag_status(0);
my $pendingsuggestions = CountSuggestion("ASKED");
my $pending_borrower_modifications =
69 70
  Koha::Patron::Modifications->GetPendingModificationsCount( $branch );
my $pending_discharge_requests = Koha::Patron::Discharge::count({ pending => 1 });
71 72

$template->param(
73 74 75 76
    pendingcomments                => $pendingcomments,
    pendingtags                    => $pendingtags,
    pendingsuggestions             => $pendingsuggestions,
    pending_borrower_modifications => $pending_borrower_modifications,
Yohann Dufour's avatar
Yohann Dufour committed
77
    pending_discharge_requests     => $pending_discharge_requests,
78 79
);

80 81 82 83 84 85 86
#
# warn user if he is using mysql/admin login
#
unless ($loggedinuser) {
    $template->param(adminWarning => 1);
}

rych's avatar
rych committed
87
output_html_with_http_headers $query, $cookie, $template->output;