Add Rafal Kopaczka to the history
[koha.git] / C4 / Koha.pm
index db71fe7..3648dcc 100644 (file)
@@ -57,12 +57,14 @@ BEGIN {
                &getitemtypeimagelocation
                &GetAuthorisedValues
                &GetAuthorisedValueCategories
+                &IsAuthorisedValueCategory
                &GetKohaAuthorisedValues
                &GetKohaAuthorisedValuesFromField
     &GetKohaAuthorisedValueLib
     &GetAuthorisedValueByCode
     &GetKohaImageurlFromAuthorisedValues
                &GetAuthValCode
+        &AddAuthorisedValue
                &GetNormalizedUPC
                &GetNormalizedISBN
                &GetNormalizedEAN
@@ -708,7 +710,7 @@ sub getFacets {
                 idx   => 'au',
                 label => 'Authors',
                 tags  => [ qw/ 700ab 701ab 702ab / ],
-                sep   => ', ',
+                sep   => C4::Context->preference("UNIMARCAuthorsFacetsSeparator"),
             },
             {
                 idx   => 'se',
@@ -1104,6 +1106,28 @@ sub GetAuthorisedValueCategories {
     return \@results;
 }
 
+=head2 IsAuthorisedValueCategory
+
+    $is_auth_val_category = IsAuthorisedValueCategory($category);
+
+Returns whether a given category name is a valid one
+
+=cut
+
+sub IsAuthorisedValueCategory {
+    my $category = shift;
+    my $query = '
+        SELECT category
+        FROM authorised_values
+        WHERE BINARY category=?
+        LIMIT 1
+    ';
+    my $sth = C4::Context->dbh->prepare($query);
+    $sth->execute($category);
+    $sth->fetchrow ? return 1
+                   : return 0;
+}
+
 =head2 GetAuthorisedValueByCode
 
 $authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode );
@@ -1226,6 +1250,26 @@ sub GetKohaAuthorisedValueLib {
   return $value;
 }
 
+=head2 AddAuthorisedValue
+
+    AddAuthorisedValue($category, $authorised_value, $lib, $lib_opac, $imageurl);
+
+Create a new authorised value.
+
+=cut
+
+sub AddAuthorisedValue {
+    my ($category, $authorised_value, $lib, $lib_opac, $imageurl) = @_;
+
+    my $dbh = C4::Context->dbh;
+    my $query = qq{
+        INSERT INTO authorised_values (category, authorised_value, lib, lib_opac, imageurl)
+        VALUES (?,?,?,?,?)
+    };
+    my $sth = $dbh->prepare($query);
+    $sth->execute($category, $authorised_value, $lib, $lib_opac, $imageurl);
+}
+
 =head2 display_marc_indicators
 
   my $display_form = C4::Koha::display_marc_indicators($field);