Bug 28553: (QA follow-up) default to auto renew email when cron switched used
[srvgit] / misc / cronjobs / build_browser_and_cloud.pl
index e1873c8..c8b1261 100755 (executable)
@@ -2,23 +2,21 @@
 # small script that builds the tag cloud
 
 use strict;
-BEGIN {
-    # find Koha's Perl modules
-    # test carefully before changing this
-    use FindBin;
-    eval { require "$FindBin::Bin/../kohalib.pl" };
-}
+#use warnings; FIXME - Bug 2505
 
+use Koha::Script -cron;
 use C4::Koha;
 use C4::Context;
-use C4::Biblio;
 use Date::Calc;
 use Time::HiRes qw(gettimeofday);
 use ZOOM;
 use MARC::File::USMARC;
 use Getopt::Long;
+use C4::Log;
+use Koha::Biblios;
+
 my ( $input_marc_file, $number) = ('',0);
-my ($version, $confirm,$test_parameter,$field,$batch,$max_digits,$cloud_tag);
+my ($version, $confirm,$field,$batch,$max_digits,$cloud_tag);
 GetOptions(
        'c' => \$confirm,
        'h' => \$version,
@@ -59,6 +57,8 @@ my $browser_subfield = $2;
 warn "browser : $browser_tag / $browser_subfield" unless $batch;
 die "no cloud or browser field/subfield defined : nothing to do !" unless $browser_tag or $cloud_tag;
 
+cronlogaction();
+
 my $dbh = C4::Context->dbh;
 
 my $i=0;
@@ -85,8 +85,9 @@ while ((my ($biblionumber)= $sth->fetchrow)) {
     print "." unless $batch;
     #now, parse the record, extract the item fields, and store them in somewhere else.
     my $Koharecord;
+    my $biblio = Koha::Biblios->find($biblionumber);
     eval{
-           $Koharecord = GetMarcBiblio($biblionumber);
+        $Koharecord = $biblio->metadata->record
     };
     if($@){
            warn 'pb when getting biblio '.$i.' : '.$@;
@@ -129,7 +130,7 @@ if ($browser_tag) {
     print "inserting datas in browser table\n" unless $batch;
     # read existing classification table is possible
     my $classification;
-    if (C4::Context->preference('opaclanguages') =~ m/^fr/i && $browser_tag eq '676' & $browser_subfield eq 'a') {
+    if (C4::Context->preference('OPACLanguages') =~ m/^fr/i && $browser_tag eq '676' & $browser_subfield eq 'a') {
         $classification = dewey_french();
     }