use C4::Charset;
use C4::Log;
use Koha::MetadataRecord::Authority;
+use Koha::Authority::Types;
use vars qw($VERSION @ISA @EXPORT);
&get_itemtypeinfos_of
&getframeworks &getframeworkinfo
&GetFrameworksLoop
- &getauthtypes &getauthtype
&getallthemes
&getFacets
&displayServers
return get_infos_of( $query, 'itemtype', undef, \@itemtypes );
}
-=head2 getauthtypes
-
- $authtypes = &getauthtypes();
-
-Returns information about existing authtypes.
-
-build a HTML select with the following code :
-
-=head3 in PERL SCRIPT
-
- my $authtypes = getauthtypes;
- my @authtypesloop;
- foreach my $thisauthtype (keys %$authtypes) {
- my $selected = 1 if $thisauthtype eq $authtype;
- my %row =(value => $thisauthtype,
- selected => $selected,
- authtypetext => $authtypes->{$thisauthtype}->{'authtypetext'},
- );
- push @authtypesloop, \%row;
- }
- $template->param(itemtypeloop => \@itemtypesloop);
-
-=head3 in TEMPLATE
-
- <form action='<!-- TMPL_VAR name="script_name" -->' method=post>
- <select name="authtype">
- <!-- TMPL_LOOP name="authtypeloop" -->
- <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="authtypetext" --></option>
- <!-- /TMPL_LOOP -->
- </select>
- <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->">
- <input type="submit" value="OK" class="button">
- </form>
-
-
-=cut
-
-sub getauthtypes {
-
- # returns a reference to a hash of references to authtypes...
- my %authtypes;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("select * from auth_types order by authtypetext");
- $sth->execute;
- while ( my $IT = $sth->fetchrow_hashref ) {
- $authtypes{ $IT->{'authtypecode'} } = $IT;
- }
- return ( \%authtypes );
-}
-
-sub getauthtype {
- my ($authtypecode) = @_;
-
- # returns a reference to a hash of references to authtypes...
- my %authtypes;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("select * from auth_types where authtypecode=?");
- $sth->execute($authtypecode);
- my $res = $sth->fetchrow_hashref;
- return $res;
-}
-
=head2 getframework
$frameworks = &getframework();
use C4::Output;
use C4::Context;
+use Koha::Authority::Types;
# retrieve parameters
my $input = new CGI;
my $authtypecode = $input->param('authtypecode') || ''; # set to select framework
my $existingauthtypecode = $input->param('existingauthtypecode') || ''; # set when we have to create a new framework (in authtype) by copying an old one (in existingauthtype)
-# my $authtypeinfo = getauthtypeinfo($authtype);
my $searchfield = $input->param('searchfield') || 0;
my $offset = $input->param('offset') || 0;
my $op = $input->param('op') || '';
debug => 1,
});
-# get authtype list
-my $authtypes = getauthtypes;
-my @authtypesloop = ();
-foreach my $thisauthtype ( sort keys %{$authtypes} ) {
- push @authtypesloop,
- { value => $thisauthtype,
- selected => $thisauthtype eq $authtypecode,
- authtypetext => $authtypes->{$thisauthtype}->{'authtypetext'},
- };
-}
+my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
my $sth;
# check that authtype framework is defined in auth_tag_structure if we are on a default action
}
}
$template->param(script_name => $script_name);
-$template->param(authtypeloop => \@authtypesloop);
+$template->param(authority_types => $authority_types );
if ($op && $op ne 'authtype_create_confirm') {
$template->param($op => 1);
} else {
use C4::Acquisition;
use C4::Koha;
+use Koha::Authority::Types;
+
my $query = new CGI;
my $op = $query->param('op') || '';
my $authtypecode = $query->param('authtypecode') || '';
}
);
-# Authority types loop
-my $authtypes = C4::Koha::getauthtypes();
-my @authtypesloop;
-foreach my $thisauthtype ( keys %$authtypes ) {
- my %row = (
- value => $thisauthtype,
- selected => ( $thisauthtype eq $authtypecode ),
- authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
- index => $index,
- );
- push @authtypesloop, \%row;
-}
+my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypetext'] } );
# If search form posted
if ( $op eq "do_search" ) {
value_match => $query->param('value_match') || '',
tagid => $tagid,
index => $index,
- authtypesloop => \@authtypesloop,
+ authority_types => $authority_types,
authtypecode => $authtypecode,
source => $source,
relationship => $relationship,
use C4::Biblio;
use C4::Search::History;
+use Koha::Authority::Types;
+
my $query = new CGI;
my $dbh = C4::Context->dbh;
my $op = $query->param('op') || '';
my ( $template, $loggedinuser, $cookie );
-my $authtypes = getauthtypes;
-my @authtypesloop;
-foreach my $thisauthtype (
- sort {
- $authtypes->{$a}{'authtypetext'} cmp $authtypes->{$b}{'authtypetext'}
- }
- keys %$authtypes
- )
-{
- my %row = (
- value => $thisauthtype,
- selected => $thisauthtype eq $authtypecode,
- authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
- );
- push @authtypesloop, \%row;
-}
+my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypetext'] } );
if ( $op eq "delete" ) {
( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
$template->param(
- authtypesloop => \@authtypesloop,
+ authority_types => $authority_types,
op => $op,
);
use MARC::File::USMARC;
use MARC::File::XML;
use C4::Biblio;
+use Koha::Authority::Types;
use vars qw( $tagslib);
use vars qw( $authorised_values_sth);
use vars qw( $is_a_modif );
authid => $authid , authtypecode=>$authtypecode, );
}
-$template->param(authid => $authid,
- authtypecode => $authtypecode,
- linkid=>$linkid,
-);
-
-my $authtypes = getauthtypes;
-my @authtypesloop;
-foreach my $thisauthtype (keys %$authtypes) {
- my %row =(value => $thisauthtype,
- selected => $thisauthtype eq $authtypecode,
- authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
- );
- push @authtypesloop, \%row;
-}
+my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypetext'] } );
-$template->param(authtypesloop => \@authtypesloop,
- authtypetext => $authtypes->{$authtypecode}{'authtypetext'},
- hide_marc => C4::Context->preference('hide_marc'),
- );
+$template->param(
+ authority_types => $authority_types,
+ authtypecode => $authtypecode,
+ authid => $authid,
+ linkid => $linkid,
+ authtypetext => $authority_types->find($authtypecode)->authtypetext,
+ hide_marc => C4::Context->preference('hide_marc'),
+);
output_html_with_http_headers $input, $cookie, $template->output;
# use C4::Biblio;
# use C4::Catalogue;
+use Koha::Authority::Types;
my $query=new CGI;
}
$template->param("0XX" =>\@loop_data);
-my $authtypes = getauthtypes;
-my @authtypesloop;
-foreach my $thisauthtype (keys %$authtypes) {
- my %row =(value => $thisauthtype,
- selected => $thisauthtype eq $authtypecode,
- authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
- );
- push @authtypesloop, \%row;
-}
-
-$template->param(authid => $authid,
- authtypesloop => \@authtypesloop, index => $index,
- );
+my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypetext'] } );
+
+$template->param(
+ authid => $authid,
+ authority_types => $authority_types,
+ index => $index,
+);
output_html_with_http_headers $query, $cookie, $template->output;
use MARC::Record;
use C4::Koha;
+use Koha::Authority::Types;
+
our ($tagslib);
sub build_tabs {
$tagslib = &GetTagsLabels(1,$authtypecode);
# Build list of authtypes for showing them
-my $authtypes = getauthtypes;
-my @authtypesloop;
-
-foreach my $thisauthtype (sort { $authtypes->{$b} cmp $authtypes->{$a} } keys %$authtypes) {
- my %row =(value => $thisauthtype,
- selected => $thisauthtype eq $authtypecode,
- authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
- );
- push @authtypesloop, \%row;
-}
+my $authority_types = Koha::Authority::Types->search({}, { order_by => ['authtypecode']});
my $record=GetAuthority($authid);
# authid invalid
$template->param ( errauthid => $authid,
unknownauthid => 1,
- authtypesloop => \@authtypesloop );
+ authority_types => $authority_types, );
output_html_with_http_headers $query, $cookie, $template->output;
exit;
}
build_tabs ($template, $record, $dbh,"",$query);
-$template->param(authid => $authid,
- count => $count,
- biblio_fields => $biblio_fields,
- authtypetext => $authtypes->{$authtypecode}{'authtypetext'},
- authtypesloop => \@authtypesloop,
- );
+$template->param(
+ authid => $authid,
+ count => $count,
+ biblio_fields => $biblio_fields,
+ authtypetext => $authority_types->find($authtypecode)->authtypetext,
+ authtypecode => $authtypecode,
+ authority_types => $authority_types,
+);
$template->{VARS}->{marcflavour} = C4::Context->preference("marcflavour");
output_html_with_http_headers $query, $cookie, $template->output;
title2 => $recordObj2->authorized_heading,
);
if ( $recordObj1->authtype ne $recordObj2->authtype ) {
- my $frameworks = getauthtypes;
+ my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
my @frameworkselect;
- foreach my $thisframeworkcode ( keys %$frameworks ) {
+ while ( my $authority_type = $authority_types->next ) {
my %row = (
- value => $thisframeworkcode,
- frameworktext =>
- $frameworks->{$thisframeworkcode}->{'authtypetext'},
+ value => $authority_type->authtypecode,
+ frameworktext => $authority_type->authtypetext,
);
- if ( $recordObj1->authtype eq $thisframeworkcode ) {
- $row{'selected'} = 1;
- }
push @frameworkselect, \%row;
}
$template->param(
}
}
-my $authtypes = getauthtypes;
-my @authtypesloop;
-foreach my $thisauthtype (
- sort {
- $authtypes->{$a}{'authtypetext'} cmp $authtypes->{$b}{'authtypetext'}
- }
- keys %$authtypes
- )
-{
- my %row = (
- value => $thisauthtype,
- authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
- );
- push @authtypesloop, \%row;
-}
-$template->{VARS}->{authtypesloop} = \@authtypesloop;
+my $authority_types = Koha::Authority::Types->search({}, { order_by => ['authtypetext']});
+$template->param( authority_types => $authority_types );
if (@errors) {
my ($template, $loggedinuser, $cookie);
my $resultsperpage;
- my $authtypes = getauthtypes;
- my @authtypesloop;
- foreach my $thisauthtype (keys %$authtypes) {
- my $selected;
- if ($thisauthtype eq $authtypecode) {
- $selected=1;
- }
- my %row =(value => $thisauthtype,
- selected => $selected,
- authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
- index => $index,
- );
- push @authtypesloop, \%row;
- }
-
if ($op eq "do_search") {
my @marclist = $query->param('marclist');
my @and_or = $query->param('and_or');
);
}
- $template->param(authtypesloop => \@authtypesloop);
$template->param(category => $category);
# Print the page
<input type="hidden" name="type" value="intranet" />
<select name="authtypecode">
[% IF (marcflavour == 'UNIMARC' ) %]<option value="">All authority types</option>[% END %]
- [% FOREACH authtypesloo IN authtypesloop %]
- [% IF ( authtypesloo.selected ) %]
- <option value="[% authtypesloo.value %]" selected="selected">[% authtypesloo.authtypetext %]</option>
+ [% FOREACH authority_type IN authority_types %]
+ [% IF authority_type.authtypecode == authtypecode %]
+ <option value="[% authority_type.value %]" selected="selected">[% authority_type.authtypetext %]</option>
[% ELSE %]
- <option value="[% authtypesloo.value %]">[% authtypesloo.authtypetext %]</option>
+ <option value="[% authority_type.value %]">[% authority_type.authtypetext %]</option>
[% END %]
[% END %]
</select>
<input type="hidden" name="type" value="intranet" />
<select name="authtypecode">
[% IF (marcflavour == 'UNIMARC' ) %]<option value="">All authority types</option>[% END %]
- [% FOREACH authtypesloo IN authtypesloop %]
- [% IF ( authtypesloo.selected ) %]
- <option value="[% authtypesloo.value %]" selected="selected">[% authtypesloo.authtypetext %]</option>
+ [% FOREACH authority_type IN authority_types %]
+ [% IF authority_type.authtypecode == authtypecode %]
+ <option value="[% authority_type.value %]" selected="selected">[% authority_type.authtypetext %]</option>
[% ELSE %]
- <option value="[% authtypesloo.value %]">[% authtypesloo.authtypetext %]</option>
+ <option value="[% authority_type.value %]">[% authority_type.authtypetext %]</option>
[% END %]
[% END %]
</select>
<form action="/cgi-bin/koha/authorities/authorities-home.pl" method="get">
<input type="hidden" name="op" value="do_search" />
<input type="hidden" name="type" value="intranet" />
- <select name="authtypecode">
+ <select name="authtypecode">
[% IF (marcflavour == 'UNIMARC' ) %]<option value="">All authority types</option>[% END %]
- [% FOREACH authtypesloo IN authtypesloop %]
- [% IF ( authtypesloo.selected ) %]
- <option value="[% authtypesloo.value %]" selected="selected">[% authtypesloo.authtypetext %]</option>
+ [% FOREACH authority_type IN authority_types %]
+ [% IF authority_type.authtypecode == authtypecode %]
+ <option value="[% authority_type.value %]" selected="selected">[% authority_type.authtypetext %]</option>
[% ELSE %]
- <option value="[% authtypesloo.value %]">[% authtypesloo.authtypetext %]</option>
+ <option value="[% authority_type.value %]">[% authority_type.authtypetext %]</option>
[% END %]
[% END %]
</select>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
- [% FOREACH authtypesloo IN authtypesloop %]
- <li><a href="/cgi-bin/koha/authorities/authorities.pl?authtypecode=[% authtypesloo.value %]">[% authtypesloo.authtypetext %]</a></li>
+ [% FOREACH authority_type IN authority_types %]
+ <li><a href="/cgi-bin/koha/authorities/authorities.pl?authtypecode=[% authority_type.authtypecode %]">[% authority_type.authtypetext %]</a></li>
[% END %]
</ul>
</div>
<h2>Select an authority framework</h2>
<form action="[% script_name %]" method="post">
<select name="authtypecode">
- [% FOREACH authtypeloo IN authtypeloop %]
- [% IF ( authtypeloo.selected ) %]
- <option value="[% authtypeloo.value %]" selected="selected">[% authtypeloo.authtypetext %]</option>
+ [% FOREACH authority_type IN authority_types%]
+ [% IF authority_type.authtypecode == authtypecode%]
+ <option value="[% authority_type.value %]" selected="selected">[% authority_type.authtypetext %]</option>
[% ELSE %]
- <option value="[% authtypeloo.value %]">[% authtypeloo.authtypetext %]</option>
+ <option value="[% authority_type.value %]">[% authority_type.authtypetext %]</option>
[% END %]
-
[% END %]
</select>
<input type="text" name="searchfield" value="[% searchfield %]" />
<select name="frameworkcode" id="frameworkcode">
<option value="Default">Default</option>
[% FOREACH frameworkcodeloo IN frameworkselect %]
- [% IF ( frameworkcodeloo.selected ) %]
+ [% IF frameworkcodeloo.authtypecode == frameworkcode1 %]
<option value="[% frameworkcodeloo.value %]" selected="selected">
[% ELSE %]
<option value="[% frameworkcodeloo.value %]">
<label for="authtype">Authority type: </label>
<select name="authtype" id="authtype">
<option value="">-- All --</option>
- [% FOREACH authtypeloo IN authtypeloop %]
- [% IF ( authtypeloo.selected ) %]
- <option value="[% authtypeloo.value %]" selected="selected">[% authtypeloo.description %]</option>
-[% ELSE %]
- <option value="[% authtypeloo.value %]">[% authtypeloo.description %]</option>
-[% END %]
+ [% FOREACH authority_type IN authority_types %]
+ <option value="[% authtypeloo.value %]">[% authtypeloo.description %]</option>
[% END %]
</select>
</li>
use C4::Koha; # XXX subfield_is_koha_internal_p
use C4::Search::History;
+use Koha::Authority::Types;
+
my $query = new CGI;
my $op = $query->param('op') || '';
my $authtypecode = $query->param('authtypecode') || '';
my ( $template, $loggedinuser, $cookie );
my $resultsperpage;
-my $authtypes = getauthtypes();
-my @authtypesloop = ();
-foreach my $thisauthtype (
- sort {
- $authtypes->{$a}->{'authtypetext'}
- cmp $authtypes->{$b}->{'authtypetext'}
- }
- keys %{$authtypes}
- ) {
- push @authtypesloop,
- { value => $thisauthtype,
- selected => $thisauthtype eq $authtypecode,
- authtypetext => $authtypes->{$thisauthtype}->{'authtypetext'},
- };
-}
+my $authority_types = Koha::Authority::Types->search({}, { order_by => ['authtypetext']});
if ( $op eq "do_search" ) {
my @marclist = ($query->param('marclist'));
resultcount => scalar @$results,
numbers => \@numbers,
authtypecode => $authtypecode,
- authtypetext => $authtypes->{$authtypecode}{'authtypetext'},
+ authtypetext => $authority_types->find($authtypecode)->authtypetext,
isEDITORS => $authtypecode eq 'EDITORS',
);
}
-$template->param( authtypesloop => \@authtypesloop );
+$template->param(
+ authority_types => $authority_types,
+ authtypecode => $authtypecode,
+);
# Print the page
output_html_with_http_headers $query, $cookie, $template->output;
use MARC::Record;
use C4::Koha;
+use Koha::Authority::Types;
my $query = new CGI;
my $count = CountUsage($authid);
-
-my $authtypes = getauthtypes();
-my @authtypesloop = ();
-foreach my $thisauthtype ( keys %{$authtypes} ) {
- push @authtypesloop,
- { value => $thisauthtype,
- selected => $thisauthtype eq $authtypecode,
- authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
- };
-}
-$template->{VARS}->{'authtypesloop'} = \@authtypesloop;
-$template->{VARS}->{'authtypetext'} = $authtypes->{$authtypecode}{'authtypetext'};
-$template->{VARS}->{'authid'} = $authid;
-$template->{VARS}->{'count'} = $count;
+my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
+$template->param(
+ authority_types => $authority_types,
+ authtypetext => $authority_types->find($authtypecode)->authtypetext,
+ authid => $authid,
+ count => $count,
+);
# find the marc field/subfield used in biblio by this authority
if ($show_marc) {
use C4::Koha; # GetItemTypes
use C4::Output;
+use Koha::Authority::Types;
use Koha::Biblioitems;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
};
}
- my $authtypes = getauthtypes;
- my @authtypesloop;
- foreach my $thisauthtype ( sort keys %$authtypes ) {
- next unless $thisauthtype;
- my %row = (
- value => $thisauthtype,
- description => $authtypes->{$thisauthtype}->{'authtypetext'},
- );
- push @authtypesloop, \%row;
- }
+ my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
if ( $flags->{superlibrarian}
&& C4::Context->config('backup_db_via_tools')
$template->param(
branchloop => \@branchloop,
itemtypeloop => \@itemtypesloop,
- authtypeloop => \@authtypesloop,
+ authority_types => $authority_types,
export_remove_fields => C4::Context->preference("ExportRemoveFields"),
csv_profiles => C4::Csv::GetCsvProfiles('marc'),
);