From aed1b4fbe6996f5bcdf569027adb44e231403e00 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Tue, 20 Oct 2020 13:31:59 -0300 Subject: [PATCH] Bug 15522: (Vue alternative) Add policy template and scripts --- Koha/Template/Plugin/Categories.pm | 4 ++ Koha/Template/Plugin/To.pm | 2 +- admin/policy.pl | 47 +++++++++++++ .../prog/en/includes/admin-menu.inc | 2 +- .../prog/en/modules/admin/admin-home.tt | 4 +- .../prog/en/modules/admin/policy.tt | 70 +++++++++++++++++++ 6 files changed, 125 insertions(+), 4 deletions(-) create mode 100755 admin/policy.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/policy.tt diff --git a/Koha/Template/Plugin/Categories.pm b/Koha/Template/Plugin/Categories.pm index 140f12a395..0ee967be8b 100644 --- a/Koha/Template/Plugin/Categories.pm +++ b/Koha/Template/Plugin/Categories.pm @@ -25,7 +25,11 @@ use Koha::Patron::Categories; sub all { my ( $self, $params ) = @_; + my $unfiltered = delete $params->{unfiltered} || 0; return Koha::Patron::Categories->search_limited($params); + return $unfiltered + ? Koha::Patron::Categories->search( $params ) + : Koha::Patron::Categories->search_limited( $params ) } sub GetName { diff --git a/Koha/Template/Plugin/To.pm b/Koha/Template/Plugin/To.pm index 67902e6ac0..d3e0f32bc1 100644 --- a/Koha/Template/Plugin/To.pm +++ b/Koha/Template/Plugin/To.pm @@ -28,7 +28,7 @@ our $DYNAMIC = 1; sub json { my ( $self, $value ) = @_; - my $json = JSON->new->allow_nonref(1); + my $json = JSON->new->allow_nonref(1)->convert_blessed(1); $json = $json->encode($value); $json =~ s/^"|"$//g; # Remove quotes around the strings $json =~ s/\\r/\\\\r/g; # Convert newlines to escaped newline characters diff --git a/admin/policy.pl b/admin/policy.pl new file mode 100755 index 0000000000..f10a12296d --- /dev/null +++ b/admin/policy.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright (C) 2017 Jesse Weaver +# +# 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. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + + +use Modern::Perl; + +use C4::Auth; +use C4::Context; +use C4::Output; + +use Koha::Patrons; + +use CGI qw( -utf8 ); + +my $query = new CGI; + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { template_name => "admin/policy.tt", + authnotrequired => 0, + flagsrequired => { parameters => 'manage_circ_rules' }, + query => $query, + type => "intranet", + debug => 1, + } +); + +my $uid = Koha::Patrons->find( $borrowernumber )->userid; +my $restricted_to_own_library = !( $uid && haspermission( $uid, { parameters => 'manage_circ_rules_from_any_libraries' } ) ); +$template->param( restricted_to_library => $restricted_to_own_library ? C4::Context::mybranch() : "" ); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc index 44d1f4cc0e..709054c41e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc @@ -36,7 +36,7 @@
  • Patron categories
  • [% END %] [% IF ( CAN_user_parameters_manage_circ_rules ) %] -
  • Circulation and fines rules
  • +
  • Circulation, fines, and holds rules
  • [% END %] [% IF ( CAN_user_parameters_manage_patron_attributes ) %]
  • Patron attribute types
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt index 1f084358fb..66dd127d5e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt @@ -83,8 +83,8 @@
    Define patron categories.
    [% END %] [% IF CAN_user_parameters_manage_circ_rules %] -
    Circulation and fines rules
    -
    Define circulation and fines rules for combinations of libraries, patron categories, and item types
    +
    Circulation, fines, and holds rules
    +
    Define circulation, fines, and holds rules for combinations of libraries, patron categories, and item types
    [% END %] [% IF ( CAN_user_parameters_manage_patron_attributes ) %]
    Patron attribute types
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/policy.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/policy.tt new file mode 100644 index 0000000000..37710bf090 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/policy.tt @@ -0,0 +1,70 @@ +[% USE raw %] +[% USE Asset %] +[% USE Branches %] +[% USE Categories %] +[% USE ItemTypes %] +[% USE Koha %] +[% USE To %] +[% SET footerjs = 1 %] + +[% INCLUDE 'doc-head-open.inc' %] +Koha › Administration › Policy +[% INCLUDE 'doc-head-close.inc' %] + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'prefs-admin-search.inc' %] + + + +
    +
    +
    +
    +
    +

    Loading, please wait...

    +
    +
    +
    +
    + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% Asset.js("js/admin-menu.js") | $raw %] + [% Asset.js("lib/hc-sticky.js") | $raw %] + [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] + [% INCLUDE 'calendar.inc' %] + + + [% Asset.js("js/built/admin/policy/main.js") | $raw %] +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] -- 2.25.0