From 6dce4ebbe63d1673581d7de3d2eda06207a6db68 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 23 Nov 2011 14:25:20 -0500 Subject: [PATCH] [Signed Off] Bug 7259 - Show a count of items pending approval on staff client home and tools pages Content-Type: text/plain; charset="utf-8" This patch adds count indicators on the staff client home page and the tools page for the number of items pending approval. On the home page this includes suggestions, comments, and tags. On the tools page a count of pending comments and tags is shown. Signed-off-by: Liz Rea Counts appear for all types of actionable items listed, all are clickable through to the proper place. Nice work! --- C4/Review.pm | 3 ++- C4/Tags.pm | 19 +++++++++++++++++++ .../intranet-tmpl/prog/en/css/staff-global.css | 10 +++++++++- .../intranet-tmpl/prog/en/modules/intranet-main.tt | 10 +++++++++- .../prog/en/modules/tools/tools-home.tt | 6 +++--- mainpage.pl | 13 +++++++++++++ opac/opac-showreviews.pl | 2 +- tools/tools-home.pl | 10 ++++++++++ 8 files changed, 66 insertions(+), 7 deletions(-) diff --git a/C4/Review.pm b/C4/Review.pm index f94dbc8..d74f077 100644 --- a/C4/Review.pm +++ b/C4/Review.pm @@ -91,11 +91,12 @@ sub updatereview { } sub numberofreviews { + my ($status) = @_; my $dbh = C4::Context->dbh; my $query = "SELECT count(*) FROM reviews WHERE approved=?"; my $sth = $dbh->prepare($query); - $sth->execute( 1 ); + $sth->execute( $status ); return $sth->fetchrow; } diff --git a/C4/Tags.pm b/C4/Tags.pm index a260383..06c1e1d 100644 --- a/C4/Tags.pm +++ b/C4/Tags.pm @@ -40,6 +40,7 @@ BEGIN { &whitelist &is_approved &approval_counts + &get_count_by_tag_status &get_filters ); # %EXPORT_TAGS = (); @@ -92,6 +93,24 @@ sub approval_counts () { return $result; } +=head2 get_count_by_tag_status + + get_count_by_tag_status($status); + +Takes a status and gets a count of tags with that status + +=cut + +sub get_count_by_tag_status { + my ($status) = @_; + my $dbh = C4::Context->dbh; + my $query = + "SELECT count(*) FROM tags_approval WHERE approved=?"; + my $sth = $dbh->prepare($query); + $sth->execute( $status ); + return $sth->fetchrow; +} + sub remove_tag ($;$) { my $tag_id = shift or return undef; my $user_id = (@_) ? shift : undef; diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css index 7b38062..5ffc80f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -1925,7 +1925,15 @@ ul.budget_hierarchy li:first-child:after { content: ""; } .holdcount { font-size : 105%; line-height : 200%; } -.holdcount a { border : 1px solid #a4bedd; background-color : #e4ecf5; font-weight : bold; -moz-border-radius: 4px; padding : .1em .4em; text-decoration : none; } +.holdcount a { + border : 1px solid #a4bedd; + background-color : #e4ecf5; + font-weight : bold; + -moz-border-radius: 4px; + border-radius: 4px; + padding : .1em .4em; + text-decoration : none; +} .holdcount a:hover { background-color : #ebeff7; } .container { border : 1px solid #EEE; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 0a2b20c..3eb0b21 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -82,6 +82,7 @@ [% END %] [% IF ( CAN_user_acquisition ) %]

Acquisitions

+ [% IF ( pendingsuggestions ) %][% END %] [% END %] [% IF ( CAN_user_reports ) %]

Reports

@@ -94,6 +95,12 @@ [% END %] [% IF ( CAN_user_tools ) %]

Tools

+ [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) %] + + [% END %] [% END %]

About Koha

@@ -117,6 +124,7 @@ [% END %] - + + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt index 10f1d6d..05bdb47 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -16,8 +16,8 @@

Patrons and circulation

[% IF ( CAN_user_tools_moderate_comments ) %] -
Comments
-
Moderate patron comments
+
Comments [% IF ( pendingcomments ) %][% pendingcomments %][% END %]
+
Moderate patron comments.
[% END %] [% IF ( CAN_user_tools_import_patrons ) %] @@ -46,7 +46,7 @@ [% END %] [% IF ( CAN_user_tools_moderate_tags ) %] -
Tags
+
Tags [% IF ( pendingtags ) %][% pendingtags %][% END %]
Moderate patron tags
[% END %] diff --git a/mainpage.pl b/mainpage.pl index 25ee475..ab3fce9 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -27,6 +27,9 @@ use C4::Auth; use C4::AuthoritiesMarc; use C4::Koha; use C4::NewsChannels; +use C4::Review qw/numberofreviews/; +use C4::Suggestions qw/CountSuggestion/; +use C4::Tags qw/get_count_by_tag_status/; my $query = new CGI; my $authtypes = getauthtypes; my @authtypesloop; @@ -67,4 +70,14 @@ $template->param( koha_news_count => $koha_news_count ); +my $pendingcomments = numberofreviews(0); +my $pendingtags = get_count_by_tag_status(0); +my $pendingsuggestions = CountSuggestion("ASKED"); + +$template->param( + pendingcomments => $pendingcomments, + pendingtags => $pendingtags, + pendingsuggestions => $pendingsuggestions +); + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/opac/opac-showreviews.pl b/opac/opac-showreviews.pl index 3a74270..01ac0bd 100755 --- a/opac/opac-showreviews.pl +++ b/opac/opac-showreviews.pl @@ -73,7 +73,7 @@ if (!$@ and C4::Context->preference('ShowReviewer') and C4::Context->preference( my $reviews = getallreviews(1,$offset,$results_per_page); my $marcflavour = C4::Context->preference("marcflavour"); -my $hits = numberofreviews(); +my $hits = numberofreviews(1); my $i = 0; my $latest_comment_date; for my $result (@$reviews){ diff --git a/tools/tools-home.pl b/tools/tools-home.pl index 7028358..055f7f4 100755 --- a/tools/tools-home.pl +++ b/tools/tools-home.pl @@ -21,6 +21,8 @@ use warnings; use CGI; use C4::Auth; use C4::Output; +use C4::Review qw/numberofreviews/; +use C4::Tags qw/get_count_by_tag_status/; my $query = new CGI; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -34,4 +36,12 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +my $pendingcomments = numberofreviews(0); +my $pendingtags = get_count_by_tag_status(0); + +$template->param( + pendingcomments => $pendingcomments, + pendingtags => $pendingtags +); + output_html_with_http_headers $query, $cookie, $template->output; -- 1.7.2.5