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

(-)a/C4/UsageStats.pm (-36 / +48 lines)
Lines 87-94 sub BuildReport { Link Here
87
    }
87
    }
88
88
89
    # Get systempreferences.
89
    # Get systempreferences.
90
    foreach (
90
    foreach ( @{ _shared_preferences() } )
91
        qw/
91
    {
92
        $report->{systempreferences}{$_} = C4::Context->preference($_);
93
    }
94
    return $report;
95
}
96
97
=head2 ReportToCommunity
98
99
  ReportToCommunity;
100
101
Send to hea.koha-community.org database informations
102
103
=cut
104
105
sub ReportToCommunity {
106
    my $data = shift;
107
    my $json = encode_json($data);
108
109
    my $url = "https://hea.koha-community.org/upload.pl";
110
    my $ua = LWP::UserAgent->new;
111
    my $res = $ua->post(
112
        $url,
113
        'Content-type' => 'application/json;charset=utf-8',
114
        Content => $json,
115
    );
116
    my $content = decode_json( $res->decoded_content );
117
    if ( $content->{koha_id} ) {
118
        C4::Context->set_preference( 'UsageStatsID', $content->{koha_id} );
119
    }
120
    if ( $content->{id} ) {
121
        C4::Context->set_preference( 'UsageStatsPublicID', $content->{id} );
122
    }
123
}
124
125
=head2 _shared_preferences
126
127
    my $preferences = C4::UsageStats::_shared_preferences
128
129
Returns an I<arreyref> with the system preferences to be shared.
130
131
=cut
132
133
sub _shared_preferences {
134
135
    my @preferences = qw/
92
        AcqCreateItem
136
        AcqCreateItem
93
        AcqWarnOnDuplicateInvoice
137
        AcqWarnOnDuplicateInvoice
94
        AcqViewBaskets
138
        AcqViewBaskets
Lines 324-363 sub BuildReport { Link Here
324
        ILS-DI
368
        ILS-DI
325
        OAI-PMH
369
        OAI-PMH
326
        version
370
        version
327
        /
371
        /;
328
      )
329
    {
330
        $report->{systempreferences}{$_} = C4::Context->preference($_);
331
    }
332
    return $report;
333
}
334
335
=head2 ReportToCommunity
336
337
  ReportToCommunity;
338
339
Send to hea.koha-community.org database informations
340
341
=cut
342
372
343
sub ReportToCommunity {
373
    return \@preferences;
344
    my $data = shift;
345
    my $json = encode_json($data);
346
347
    my $url = "https://hea.koha-community.org/upload.pl";
348
    my $ua = LWP::UserAgent->new;
349
    my $res = $ua->post(
350
        $url,
351
        'Content-type' => 'application/json;charset=utf-8',
352
        Content => $json,
353
    );
354
    my $content = decode_json( $res->decoded_content );
355
    if ( $content->{koha_id} ) {
356
        C4::Context->set_preference( 'UsageStatsID', $content->{koha_id} );
357
    }
358
    if ( $content->{id} ) {
359
        C4::Context->set_preference( 'UsageStatsPublicID', $content->{id} );
360
    }
361
}
374
}
362
375
363
=head2 _count
376
=head2 _count
364
- 

Return to bug 28565