+}
+
+# Test YAML system preferences
+# FIXME: This is list of current YAML formatted prefs, should by type of preference
+my @yaml_prefs = (
+ "UpdateNotForLoanStatusOnCheckin",
+ "OpacHiddenItems",
+ "BibtexExportAdditionalFields",
+ "RisExportAdditionalFields",
+ "UpdateItemWhenLostFromHoldList",
+ "MarcFieldsToOrder",
+ "MarcItemFieldsToOrder",
+ "UpdateitemLocationOnCheckin",
+ "ItemsDeniedRenewal"
+);
+my @bad_yaml_prefs;
+foreach my $syspref (@yaml_prefs) {
+ my $yaml = C4::Context->preference( $syspref );
+ if ( $yaml ) {
+ eval { YAML::XS::Load( Encode::encode_utf8("$yaml\n\n") ); };
+ if ($@) {
+ push @bad_yaml_prefs, $syspref;
+ }
+ }
+}
+$template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs;
+
+{
+ my $dbh = C4::Context->dbh;
+ my $patrons = $dbh->selectall_arrayref(
+ q|select b.borrowernumber from borrowers b join deletedborrowers db on b.borrowernumber=db.borrowernumber|,
+ { Slice => {} }
+ );
+ my $biblios = $dbh->selectall_arrayref(
+ q|select b.biblionumber from biblio b join deletedbiblio db on b.biblionumber=db.biblionumber|,
+ { Slice => {} }
+ );
+ my $items = $dbh->selectall_arrayref(
+ q|select i.itemnumber from items i join deleteditems di on i.itemnumber=di.itemnumber|,
+ { Slice => {} }
+ );
+ my $checkouts = $dbh->selectall_arrayref(
+ q|select i.issue_id from issues i join old_issues oi on i.issue_id=oi.issue_id|,
+ { Slice => {} }
+ );
+ my $holds = $dbh->selectall_arrayref(
+ q|select r.reserve_id from reserves r join old_reserves o on r.reserve_id=o.reserve_id|,
+ { Slice => {} }
+ );
+ if ( @$patrons or @$biblios or @$items or @$checkouts or @$holds ) {
+ $template->param(
+ has_ai_issues => 1,
+ ai_patrons => $patrons,
+ ai_biblios => $biblios,
+ ai_items => $items,
+ ai_checkouts => $checkouts,
+ ai_holds => $holds,
+ );
+ }
+}
+
+# Circ rule warnings
+{
+ my $dbh = C4::Context->dbh;
+ my $units = Koha::CirculationRules->search({ rule_name => 'lengthunit', rule_value => { -not_in => ['days', 'hours'] } });
+
+ if ( $units->count ) {
+ $template->param(
+ warnIssuingRules => 1,
+ ir_units => $units,
+ );
+ }
+}
+
+# Guarantor relationships warnings
+{
+ my $dbh = C4::Context->dbh;
+ my ($bad_relationships_count) = $dbh->selectall_arrayref(q{
+ SELECT COUNT(*)
+ FROM (
+ SELECT relationship FROM borrower_relationships WHERE relationship='_bad_data'
+ UNION ALL
+ SELECT relationship FROM borrowers WHERE relationship='_bad_data') a
+ });
+
+ $bad_relationships_count = $bad_relationships_count->[0]->[0];
+
+ my $existing_relationships = $dbh->selectall_arrayref(q{
+ SELECT DISTINCT(relationship)
+ FROM (
+ SELECT relationship FROM borrower_relationships WHERE relationship IS NOT NULL
+ UNION ALL
+ SELECT relationship FROM borrowers WHERE relationship IS NOT NULL) a
+ });
+
+ my %valid_relationships = map { $_ => 1 } split( /,|\|/, C4::Context->preference('borrowerRelationship') );
+ $valid_relationships{ _bad_data } = 1; # we handle this case in another way
+
+ my $wrong_relationships = [ grep { !$valid_relationships{ $_->[0] } } @{$existing_relationships} ];
+ if ( @$wrong_relationships or $bad_relationships_count ) {
+
+ $template->param(
+ warnRelationships => 1,
+ );
+
+ if ( $wrong_relationships ) {
+ $template->param(
+ wrong_relationships => $wrong_relationships
+ );
+ }
+ if ($bad_relationships_count) {
+ $template->param(
+ bad_relationships_count => $bad_relationships_count,
+ );
+ }
+ }
+}
+
+{
+ # Test 'bcrypt_settings' config for Pseudonymization
+ $template->param( config_bcrypt_settings_no_set => 1 )
+ if C4::Context->preference('Pseudonymization')
+ and not C4::Context->config('bcrypt_settings');
+}
+
+{
+ my @frameworkcodes = Koha::BiblioFrameworks->search->get_column('frameworkcode');
+ my @hidden_biblionumbers;
+ push @frameworkcodes, ""; # it's not in the biblio_frameworks table!
+ for my $frameworkcode ( @frameworkcodes ) {
+ my $shouldhidemarc_opac = Koha::Filter::MARC::ViewPolicy->should_hide_marc(
+ {
+ frameworkcode => $frameworkcode,
+ interface => "opac"
+ }
+ );
+ push @hidden_biblionumbers, { frameworkcode => $frameworkcode, interface => 'opac' }
+ if $shouldhidemarc_opac->{biblionumber};