View | Details | Raw Unified | Return to bug 11842
Collapse All | Expand All

(-)a/C4/Biblio.pm (-24 / +8 lines)
Lines 38-43 use C4::Charset; Link Here
38
use C4::Linker;
38
use C4::Linker;
39
use C4::OAI::Sets;
39
use C4::OAI::Sets;
40
40
41
use Koha::Cache;
42
41
use vars qw($VERSION @ISA @EXPORT);
43
use vars qw($VERSION @ISA @EXPORT);
42
44
43
BEGIN {
45
BEGIN {
Lines 138-153 BEGIN { Link Here
138
    );
140
    );
139
}
141
}
140
142
141
eval {
142
    if (C4::Context->ismemcached) {
143
        require Memoize::Memcached;
144
        import Memoize::Memcached qw(memoize_memcached);
145
146
        memoize_memcached( 'GetMarcStructure',
147
                            memcached => C4::Context->memcached);
148
    }
149
};
150
151
=head1 NAME
143
=head1 NAME
152
144
153
C4::Biblio - cataloging management functions
145
C4::Biblio - cataloging management functions
Lines 1098-1121 $frameworkcode : the framework code to read Link Here
1098
1090
1099
=cut
1091
=cut
1100
1092
1101
# cache for results of GetMarcStructure -- needed
1102
# for batch jobs
1103
our $marc_structure_cache;
1104
1105
sub GetMarcStructure {
1093
sub GetMarcStructure {
1106
    my ( $forlibrarian, $frameworkcode ) = @_;
1094
    my ( $forlibrarian, $frameworkcode ) = @_;
1107
    my $dbh = C4::Context->dbh;
1095
    my $dbh = C4::Context->dbh;
1108
    $frameworkcode = "" unless $frameworkcode;
1096
    $frameworkcode = "" unless $frameworkcode;
1109
1097
1110
    if ( defined $marc_structure_cache and exists $marc_structure_cache->{$forlibrarian}->{$frameworkcode} ) {
1098
    $forlibrarian = $forlibrarian ? 1 : 0;
1111
        return $marc_structure_cache->{$forlibrarian}->{$frameworkcode};
1099
    my $cache = Koha::Cache->get_instance();
1112
    }
1100
    my $cache_key = "MarcStructure-$forlibrarian-$frameworkcode";
1101
    my $cached = $cache->get_from_cache($cache_key);
1102
    return $cached if $cached;
1113
1103
1114
    #     my $sth = $dbh->prepare(
1115
    #         "SELECT COUNT(*) FROM marc_tag_structure WHERE frameworkcode=?");
1116
    #     $sth->execute($frameworkcode);
1117
    #     my ($total) = $sth->fetchrow;
1118
    #     $frameworkcode = "" unless ( $total > 0 );
1119
    my $sth = $dbh->prepare(
1104
    my $sth = $dbh->prepare(
1120
        "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable 
1105
        "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable 
1121
        FROM marc_tag_structure 
1106
        FROM marc_tag_structure 
Lines 1177-1184 sub GetMarcStructure { Link Here
1177
        $res->{$tag}->{$subfield}->{maxlength}        = $maxlength;
1162
        $res->{$tag}->{$subfield}->{maxlength}        = $maxlength;
1178
    }
1163
    }
1179
1164
1180
    $marc_structure_cache->{$forlibrarian}->{$frameworkcode} = $res;
1165
    $cache->set_in_cache($cache_key, $res);
1181
1182
    return $res;
1166
    return $res;
1183
}
1167
}
1184
1168
(-)a/admin/biblio_framework.pl (-4 / +10 lines)
Lines 27-32 use CGI; Link Here
27
use C4::Context;
27
use C4::Context;
28
use C4::Auth;
28
use C4::Auth;
29
use C4::Output;
29
use C4::Output;
30
use Koha::Cache;
30
31
31
sub StringSearch  {
32
sub StringSearch  {
32
	my $dbh = C4::Context->dbh;
33
	my $dbh = C4::Context->dbh;
Lines 41-46 my $frameworkcode = $input->param('frameworkcode') || ''; Link Here
41
my $offset        = $input->param('offset') || 0;
42
my $offset        = $input->param('offset') || 0;
42
my $op            = $input->param('op') || '';
43
my $op            = $input->param('op') || '';
43
my $pagesize      = 20;
44
my $pagesize      = 20;
45
my $cache         = Koha::Cache->get_instance();
44
46
45
my ($template, $borrowernumber, $cookie)
47
my ($template, $borrowernumber, $cookie)
46
    = get_template_and_user({template_name => "admin/biblio_framework.tt",
48
    = get_template_and_user({template_name => "admin/biblio_framework.tt",
Lines 74-88 if ($op eq 'add_form') { Link Here
74
################## ADD_VALIDATE ##################################
76
################## ADD_VALIDATE ##################################
75
# called by add_form, used to insert/modify data in DB
77
# called by add_form, used to insert/modify data in DB
76
} elsif ($op eq 'add_validate') {
78
} elsif ($op eq 'add_validate') {
77
	my $dbh = C4::Context->dbh;
79
    my $dbh = C4::Context->dbh;
78
	if($input->param('frameworktext') and $input->param('frameworkcode')){
80
    if ( $input->param('frameworktext') and $frameworkcode ) {
79
        if ($input->param('modif')) {
81
        if ($input->param('modif')) {
80
            my $sth=$dbh->prepare("UPDATE biblio_framework SET frameworktext=? WHERE frameworkcode=?");
82
            my $sth=$dbh->prepare("UPDATE biblio_framework SET frameworktext=? WHERE frameworkcode=?");
81
            $sth->execute($input->param('frameworktext'),$input->param('frameworkcode'));
83
            $sth->execute( $input->param('frameworktext'), $frameworkcode );
82
        } else {
84
        } else {
83
            my $sth=$dbh->prepare("INSERT into biblio_framework (frameworkcode,frameworktext) values (?,?)");
85
            my $sth=$dbh->prepare("INSERT into biblio_framework (frameworkcode,frameworktext) values (?,?)");
84
            $sth->execute($input->param('frameworkcode'),$input->param('frameworktext'));
86
            $sth->execute( $frameworkcode, $input->param('frameworktext') );
85
        }
87
        }
88
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
89
        $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
86
	}
90
	}
87
	print $input->redirect($script_name);   # FIXME: unnecessary redirect
91
	print $input->redirect($script_name);   # FIXME: unnecessary redirect
88
	exit;
92
	exit;
Lines 115-120 if ($op eq 'add_form') { Link Here
115
		$sth->execute($frameworkcode);
119
		$sth->execute($frameworkcode);
116
		$sth=$dbh->prepare("delete from biblio_framework where frameworkcode=?");
120
		$sth=$dbh->prepare("delete from biblio_framework where frameworkcode=?");
117
		$sth->execute($frameworkcode);
121
		$sth->execute($frameworkcode);
122
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
123
        $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
118
	}
124
	}
119
	print $input->redirect($script_name);   # FIXME: unnecessary redirect
125
	print $input->redirect($script_name);   # FIXME: unnecessary redirect
120
	exit;
126
	exit;
(-)a/admin/koha2marclinks.pl (+4 lines)
Lines 59-64 else { Link Here
59
}
59
}
60
60
61
my $dbh = C4::Context->dbh;
61
my $dbh = C4::Context->dbh;
62
my $cache = Koha::Cache->get_instance();
62
63
63
################## ADD_FORM ##################################
64
################## ADD_FORM ##################################
64
# called by default. Used to create form to add or  modify a record
65
# called by default. Used to create form to add or  modify a record
Lines 116-121 elsif ( $op eq 'add_validate' ) { Link Here
116
    $dbh->do(
117
    $dbh->do(
117
"update marc_subfield_structure set kohafield='$tablename.$kohafield' where tagfield='$temp[0]' and tagsubfield='$temp[1]'"
118
"update marc_subfield_structure set kohafield='$tablename.$kohafield' where tagfield='$temp[0]' and tagsubfield='$temp[1]'"
118
    );
119
    );
120
    # We could get a list of all frameworks and do them one-by-one, or zap
121
    # everything.
122
    $cache->flush_all();
119
    print
123
    print
120
"Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=koha2marclinks.pl?tablename=$tablename\"></html>";
124
"Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=koha2marclinks.pl?tablename=$tablename\"></html>";
121
    exit;
125
    exit;
(-)a/admin/marc_subfields_structure.pl (+6 lines)
Lines 75-80 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
75
        debug           => 1,
75
        debug           => 1,
76
    }
76
    }
77
);
77
);
78
my $cache = Koha::Cache->get_instance();
78
79
79
my $op       = $input->param('op');
80
my $op       = $input->param('op');
80
$tagfield =~ s/\,//g;
81
$tagfield =~ s/\,//g;
Lines 483-488 elsif ( $op eq 'add_validate' ) { Link Here
483
    }
484
    }
484
    $sth_insert->finish;
485
    $sth_insert->finish;
485
    $sth_update->finish;
486
    $sth_update->finish;
487
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
488
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
489
486
    print
490
    print
487
"Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
491
"Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
488
    exit;
492
    exit;
Lines 524-529 elsif ( $op eq 'delete_confirmed' ) { Link Here
524
        $sth->execute( $tagfield, $tagsubfield, $frameworkcode );
528
        $sth->execute( $tagfield, $tagsubfield, $frameworkcode );
525
        $sth->finish;
529
        $sth->finish;
526
    }
530
    }
531
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
532
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
527
    print
533
    print
528
"Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
534
"Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
529
    exit;
535
    exit;
(-)a/admin/marctagstructure.pl (-1 / +8 lines)
Lines 27-32 use C4::Context; Link Here
27
use C4::Output;
27
use C4::Output;
28
use C4::Context;
28
use C4::Context;
29
29
30
use Koha::Cache;
30
31
31
# retrieve parameters
32
# retrieve parameters
32
my $input = new CGI;
33
my $input = new CGI;
Lines 45-50 my $pagesize = 20; Link Here
45
my $script_name = "/cgi-bin/koha/admin/marctagstructure.pl";
46
my $script_name = "/cgi-bin/koha/admin/marctagstructure.pl";
46
47
47
my $dbh = C4::Context->dbh;
48
my $dbh = C4::Context->dbh;
49
my $cache = Koha::Cache->get_instance();
48
50
49
# open template
51
# open template
50
my ($template, $loggedinuser, $cookie)
52
my ($template, $loggedinuser, $cookie)
Lines 167-172 if ($op eq 'add_form') { Link Here
167
                          $frameworkcode
169
                          $frameworkcode
168
            );
170
            );
169
        }
171
        }
172
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
173
        $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
170
	}
174
	}
171
    print $input->redirect("/cgi-bin/koha/admin/marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode");
175
    print $input->redirect("/cgi-bin/koha/admin/marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode");
172
	exit;
176
	exit;
Lines 191-196 if ($op eq 'add_form') { Link Here
191
        my $sth2 = $dbh->prepare("DELETE FROM marc_subfield_structure WHERE tagfield=? AND frameworkcode=?");
195
        my $sth2 = $dbh->prepare("DELETE FROM marc_subfield_structure WHERE tagfield=? AND frameworkcode=?");
192
        $sth1->execute($searchfield, $frameworkcode);
196
        $sth1->execute($searchfield, $frameworkcode);
193
        $sth2->execute($searchfield, $frameworkcode);
197
        $sth2->execute($searchfield, $frameworkcode);
198
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
199
        $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
194
	}
200
	}
195
	$template->param(
201
	$template->param(
196
          searchfield => $searchfield,
202
          searchfield => $searchfield,
Lines 354-358 sub duplicate_framework { Link Here
354
	while ( my ($frameworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso,$hidden) = $sth->fetchrow) {
360
	while ( my ($frameworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso,$hidden) = $sth->fetchrow) {
355
	    $sth_insert->execute($newframeworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso, $hidden);
361
	    $sth_insert->execute($newframeworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso, $hidden);
356
	}
362
	}
363
    $cache->clear_from_cache("MarcStructure-0-$newframeworkcode");
364
    $cache->clear_from_cache("MarcStructure-1-$newframeworkcode");
357
}
365
}
358
366
359
- 

Return to bug 11842