@@ -, +, @@ $ kshell k$ prove t/db_dependent/UsageStats.t --- C4/UsageStats.pm | 83 ++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 35 deletions(-) --- a/C4/UsageStats.pm +++ a/C4/UsageStats.pm @@ -87,8 +87,52 @@ sub BuildReport { } # Get systempreferences. - foreach ( - qw/ + foreach ( @{ _shared_preferences() } ) + { + $report->{systempreferences}{$_} = C4::Context->preference($_); + } + return $report; +} + +=head2 ReportToCommunity + + ReportToCommunity; + +Send to hea.koha-community.org database informations + +=cut + +sub ReportToCommunity { + my $data = shift; + my $json = encode_json($data); + + my $url = "https://hea.koha-community.org/upload.pl"; + my $ua = LWP::UserAgent->new; + my $res = $ua->post( + $url, + 'Content-type' => 'application/json;charset=utf-8', + Content => $json, + ); + my $content = decode_json( $res->decoded_content ); + if ( $content->{koha_id} ) { + C4::Context->set_preference( 'UsageStatsID', $content->{koha_id} ); + } + if ( $content->{id} ) { + C4::Context->set_preference( 'UsageStatsPublicID', $content->{id} ); + } +} + +=head2 _shared_preferences + + my $preferences = C4::UsageStats::_shared_preferences + +Returns an I with the system preferences to be shared. + +=cut + +sub _shared_preferences { + + my @preferences = qw/ AcqCreateItem AcqWarnOnDuplicateInvoice AcqViewBaskets @@ -324,40 +368,9 @@ sub BuildReport { ILS-DI OAI-PMH version - / - ) - { - $report->{systempreferences}{$_} = C4::Context->preference($_); - } - return $report; -} - -=head2 ReportToCommunity - - ReportToCommunity; - -Send to hea.koha-community.org database informations - -=cut + /; -sub ReportToCommunity { - my $data = shift; - my $json = encode_json($data); - - my $url = "https://hea.koha-community.org/upload.pl"; - my $ua = LWP::UserAgent->new; - my $res = $ua->post( - $url, - 'Content-type' => 'application/json;charset=utf-8', - Content => $json, - ); - my $content = decode_json( $res->decoded_content ); - if ( $content->{koha_id} ) { - C4::Context->set_preference( 'UsageStatsID', $content->{koha_id} ); - } - if ( $content->{id} ) { - C4::Context->set_preference( 'UsageStatsPublicID', $content->{id} ); - } + return \@preferences; } =head2 _count --