Bug 14391: Add granular permissions to the administration module
[koha.git] / admin / checkmarc.pl
index 432078d..3f5f61b 100755 (executable)
@@ -5,23 +5,23 @@
 #
 # This file is part of Koha.
 #
-# 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 2 of the License, or (at your option) any later
-# version.
+# 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.
+# 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, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
+use Modern::Perl;
 use C4::Output;
 use C4::Auth;
-use CGI;
+use CGI qw ( -utf8 );
 use C4::Context;
 use C4::Biblio;
 
@@ -29,11 +29,11 @@ use C4::Biblio;
 my $input = new CGI;
 
 my ($template, $borrowernumber, $cookie)
-    = get_template_and_user({template_name => "admin/checkmarc.tmpl",
+    = get_template_and_user({template_name => "admin/checkmarc.tt",
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
-                            flagsrequired => {parameters => 1},
+                 flagsrequired => { parameters => 'manage_marc_frameworks' },
                             debug => 1,
                             });
 
@@ -168,6 +168,7 @@ while (($res,$res2,$field) = $sth->fetchrow) {
     } else {
            $template->param(holdingbranch => 1);
            $total++;
+           last; #MR
     }
 }
 
@@ -242,6 +243,21 @@ if (scalar(@$invalid_authtypecodes) > 0) {
     $template->param(authtypecode_info => $invalid_authtypecodes);
 }
 
+# checks items.permanent_location is not mapped
+$sth = $dbh->prepare("SELECT frameworkcode, frameworktext, tagfield, tagsubfield
+                      FROM marc_subfield_structure
+                      LEFT JOIN biblio_framework USING (frameworkcode)
+                      WHERE kohafield='permanent_location' OR
+                            kohafield='items.permanent_location'");
+$sth->execute;
+my $permanent_location_mapped = $sth->fetchall_arrayref({});
+if (scalar(@$permanent_location_mapped) > 0) {
+    $total++;
+    $template->param(permanent_location_mapped => 1);
+    $template->param(mapped_permanent_location => $permanent_location_mapped);
+}
+
+
 $template->param(total => $total,
                );