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

(-)a/C4/UsageStats.pm (-320 / +290 lines)
Lines 1-25 Link Here
1
package UsageStats;
1
package UsageStats;
2
2
3
# Copyright 2000-2003 Katipo Communications
4
# Copyright 2010 BibLibre
5
# Parts Copyright 2010 Catalyst IT
6
#
7
# This file is part of Koha.
3
# This file is part of Koha.
8
#
4
#
9
# Koha is free software; you can redistribute it and/or modify it under the
5
# Copyright 2014 BibLibre
10
# terms of the GNU General Public License as published by the Free Software
6
#
11
# Foundation; either version 2 of the License, or (at your option) any later
7
# Koha is free software; you can redistribute it and/or modify it
12
# version.
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
13
#
11
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# Koha is distributed in the hope that it will be useful, but
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
#
16
#
18
# You should have received a copy of the GNU General Public License along
17
# You should have received a copy of the GNU General Public License
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
19
22
use strict;
20
use Modern::Perl;
23
use C4::Context;
21
use C4::Context;
24
use POSIX qw(strftime);
22
use POSIX qw(strftime);
25
use LWP::UserAgent;
23
use LWP::UserAgent;
Lines 35-47 hea.koha-community.org is the server that centralize Koha setups informations Link Here
35
Koha libraries are encouraged to provide informations about their collections,
33
Koha libraries are encouraged to provide informations about their collections,
36
their structure,...
34
their structure,...
37
35
38
This package is normally only called by a cronjob, like
39
0 3 1 * * export KOHA_CONF=/home/koha/etc/koha-conf.xml; export PERL5LIB=/home/koha/src; perl /home/koha/src/C4/UsageStats.pm
40
41
IMPORTANT : please do NOT run the cron on the 1st, but on another day. The idea is to avoid all
42
Koha libraries sending their data at the same time ! So choose any day between 1 and 28 !
43
44
45
=head2 NeedUpdate
36
=head2 NeedUpdate
46
37
47
  $needUpdateYN = C4::UsageStats::NeedUpdate;
38
  $needUpdateYN = C4::UsageStats::NeedUpdate;
Lines 59-100 sub NeedUpdate { Link Here
59
    # Need to launch cron.
50
    # Need to launch cron.
60
    return 1 if $now - $lastupdated >= 2592000;
51
    return 1 if $now - $lastupdated >= 2592000;
61
52
62
    # Cron no need to be launched.
53
    # Data don't need to be updated
63
    return 0;
54
    return 0;
64
}
55
}
65
56
66
=head2 LaunchCron
67
68
  LaunchCron();
69
70
Compute results and send them to the centralized server
71
72
=cut
73
74
sub LaunchCron {
75
    if (!C4::Context->preference('UsageStatsShare')) {
76
      die ("UsageStats is not configured");
77
    }
78
    if (NeedUpdate) {
79
        C4::Context->set_preference('UsageStatsLastUpdateTime', strftime("%s", localtime));
80
        my $data = BuildReport();
81
        ReportToCommunity($data);
82
    }
83
}
84
85
=head2 Builreport
86
87
  BuildReport();
88
89
retrieve some database volumety and systempreferences that will be sent to hea server
90
91
=cut
92
93
sub BuildReport {
57
sub BuildReport {
94
    my $report = {
58
    my $report = {
95
        'library' => {
59
        library => {
96
            'name' => C4::Context->preference('UsageStatsLibraryName'),
60
            name => C4::Context->preference('UsageStatsLibraryName') || q||,
97
            'id' => C4::Context->preference('UsageStatsID') || 0,
61
            id => C4::Context->preference('UsageStatsID') || 0,
98
        },
62
        },
99
    };
63
    };
100
64
Lines 104-360 sub BuildReport { Link Here
104
    }
68
    }
105
69
106
    # Get systempreferences.
70
    # Get systempreferences.
107
    foreach (qw/ AcqCreateItem
71
    foreach (
108
 AcqWarnOnDuplicateInvoice
72
        qw/
109
 AcqViewBaskets
73
        AcqCreateItem
110
 BasketConfirmations
74
        AcqWarnOnDuplicateInvoice
111
 OrderPdfFormat
75
        AcqViewBaskets
112
 casAuthentication
76
        BasketConfirmations
113
 casLogout
77
        OrderPdfFormat
114
 AllowPkiAuth
78
        casAuthentication
115
 DebugLevel
79
        casLogout
116
 delimiter
80
        AllowPkiAuth
117
 noItemTypeImages
81
        DebugLevel
118
 virtualshelves
82
        delimiter
119
 AutoLocation
83
        noItemTypeImages
120
 IndependentBranches
84
        virtualshelves
121
 SessionStorage
85
        AutoLocation
122
 Persona
86
        IndependentBranches
123
 AuthDisplayHierarchy
87
        SessionStorage
124
 AutoCreateAuthorities
88
        Persona
125
 BiblioAddsAuthorities
89
        AuthDisplayHierarchy
126
 dontmerge
90
        AutoCreateAuthorities
127
 UseAuthoritiesForTracings
91
        BiblioAddsAuthorities
128
 CatalogModuleRelink
92
        dontmerge
129
 hide_marc
93
        UseAuthoritiesForTracings
130
 IntranetBiblioDefaultView
94
        CatalogModuleRelink
131
 LabelMARCView
95
        hide_marc
132
 OpacSuppression
96
        IntranetBiblioDefaultView
133
 SeparateHoldings
97
        LabelMARCView
134
 UseControlNumber
98
        OpacSuppression
135
 advancedMARCeditor
99
        SeparateHoldings
136
 DefaultClassificationSource
100
        UseControlNumber
137
 EasyAnalyticalRecords
101
        advancedMARCeditor
138
 autoBarcode
102
        DefaultClassificationSource
139
 item-level_itypes
103
        EasyAnalyticalRecords
140
 marcflavour
104
        autoBarcode
141
 PrefillItem
105
        item-level_itypes
142
 z3950NormalizeAuthor
106
        marcflavour
143
 SpineLabelAutoPrint
107
        PrefillItem
144
 SpineLabelShowPrintOnBibDetails
108
        z3950NormalizeAuthor
145
 BlockReturnOfWithdrawnItems
109
        SpineLabelAutoPrint
146
 CalculateFinesOnReturn
110
        SpineLabelShowPrintOnBibDetails
147
 AgeRestrictionOverride
111
        BlockReturnOfWithdrawnItems
148
 AllFinesNeedOverride
112
        CalculateFinesOnReturn
149
 AllowFineOverride
113
        AgeRestrictionOverride
150
 AllowItemsOnHoldCheckout
114
        AllFinesNeedOverride
151
 AllowNotForLoanOverride
115
        AllowFineOverride
152
 AllowRenewalLimitOverride
116
        AllowItemsOnHoldCheckout
153
 AllowReturnToBranch
117
        AllowNotForLoanOverride
154
 AllowTooManyOverride
118
        AllowRenewalLimitOverride
155
 AutomaticItemReturn
119
        AllowReturnToBranch
156
 AutoRemoveOverduesRestrictions
120
        AllowTooManyOverride
157
 CircControl
121
        AutomaticItemReturn
158
 HomeOrHoldingBranch
122
        AutoRemoveOverduesRestrictions
159
 HomeOrHoldingBranchReturn
123
        CircControl
160
 InProcessingToShelvingCart
124
        HomeOrHoldingBranch
161
 IssueLostItem
125
        HomeOrHoldingBranchReturn
162
 IssuingInProcess
126
        InProcessingToShelvingCart
163
 ManInvInNoissuesCharge
127
        IssueLostItem
164
 OverduesBlockCirc
128
        IssuingInProcess
165
 RenewalPeriodBase
129
        ManInvInNoissuesCharge
166
 RenewalSendNotice
130
        OverduesBlockCirc
167
 RentalsInNoissuesCharge
131
        RenewalPeriodBase
168
 ReturnBeforeExpiry
132
        RenewalSendNotice
169
 ReturnToShelvingCart
133
        RentalsInNoissuesCharge
170
 TransfersMaxDaysWarning
134
        ReturnBeforeExpiry
171
 UseBranchTransferLimits
135
        ReturnToShelvingCart
172
 useDaysMode
136
        TransfersMaxDaysWarning
173
 UseTransportCostMatrix
137
        UseBranchTransferLimits
174
 UseCourseReserves
138
        useDaysMode
175
 finesCalendar
139
        UseTransportCostMatrix
176
 FinesIncludeGracePeriod
140
        UseCourseReserves
177
 finesMode
141
        finesCalendar
178
 RefundLostItemFeeOnReturn
142
        FinesIncludeGracePeriod
179
 WhenLostChargeReplacementFee
143
        finesMode
180
 WhenLostForgiveFine
144
        RefundLostItemFeeOnReturn
181
 AllowHoldDateInFuture
145
        WhenLostChargeReplacementFee
182
 AllowHoldPolicyOverride
146
        WhenLostForgiveFine
183
 AllowHoldsOnDamagedItems
147
        AllowHoldDateInFuture
184
 AllowHoldsOnPatronsPossessions
148
        AllowHoldPolicyOverride
185
 AllowOnShelfHolds
149
        AllowHoldsOnDamagedItems
186
 AutoResumeSuspendedHolds
150
        AllowHoldsOnPatronsPossessions
187
 canreservefromotherbranches
151
        AllowOnShelfHolds
188
 decreaseLoanHighHolds
152
        AutoResumeSuspendedHolds
189
 DisplayMultiPlaceHold
153
        canreservefromotherbranches
190
 emailLibrarianWhenHoldIsPlaced
154
        decreaseLoanHighHolds
191
 ExpireReservesMaxPickUpDelay
155
        DisplayMultiPlaceHold
192
 OPACAllowHoldDateInFuture
156
        emailLibrarianWhenHoldIsPlaced
193
 OPACAllowUserToChooseBranch
157
        ExpireReservesMaxPickUpDelay
194
 ReservesControlBranch
158
        OPACAllowHoldDateInFuture
195
 ReservesNeedReturns
159
        OPACAllowUserToChooseBranch
196
 SuspendHoldsIntranet
160
        ReservesControlBranch
197
 SuspendHoldsOpac
161
        ReservesNeedReturns
198
 TransferWhenCancelAllWaitingHolds
162
        SuspendHoldsIntranet
199
 AllowAllMessageDeletion
163
        SuspendHoldsOpac
200
 AllowOfflineCirculation
164
        TransferWhenCancelAllWaitingHolds
201
 CircAutocompl
165
        AllowAllMessageDeletion
202
 CircAutoPrintQuickSlip
166
        AllowOfflineCirculation
203
 DisplayClearScreenButton
167
        CircAutocompl
204
 FilterBeforeOverdueReport
168
        CircAutoPrintQuickSlip
205
 FineNotifyAtCheckin
169
        DisplayClearScreenButton
206
 itemBarcodeFallbackSearch
170
        FilterBeforeOverdueReport
207
 itemBarcodeInputFilter
171
        FineNotifyAtCheckin
208
 previousIssuesDefaultSortOrder
172
        itemBarcodeFallbackSearch
209
 RecordLocalUseOnReturn
173
        itemBarcodeInputFilter
210
 soundon
174
        previousIssuesDefaultSortOrder
211
 SpecifyDueDate
175
        RecordLocalUseOnReturn
212
 todaysIssuesDefaultSortOrder
176
        soundon
213
 UpdateTotalIssuesOnCirc
177
        SpecifyDueDate
214
 UseTablesortForCirc
178
        todaysIssuesDefaultSortOrder
215
 WaitingNotifyAtCheckin
179
        UpdateTotalIssuesOnCirc
216
 AllowSelfCheckReturns
180
        UseTablesortForCirc
217
 AutoSelfCheckAllowed
181
        WaitingNotifyAtCheckin
218
 FRBRizeEditions
182
        AllowSelfCheckReturns
219
 OPACFRBRizeEditions
183
        AutoSelfCheckAllowed
220
 AmazonCoverImages
184
        FRBRizeEditions
221
 OPACAmazonCoverImages
185
        OPACFRBRizeEditions
222
 Babeltheque
186
        AmazonCoverImages
223
 BakerTaylorEnabled
187
        OPACAmazonCoverImages
224
 GoogleJackets
188
        Babeltheque
225
 HTML5MediaEnabled
189
        BakerTaylorEnabled
226
 IDreamBooksReadometer
190
        GoogleJackets
227
 IDreamBooksResults
191
        HTML5MediaEnabled
228
 IDreamBooksReviews
192
        IDreamBooksReadometer
229
 LibraryThingForLibrariesEnabled
193
        IDreamBooksResults
230
 LocalCoverImages
194
        IDreamBooksReviews
231
 OPACLocalCoverImages
195
        LibraryThingForLibrariesEnabled
232
 NovelistSelectEnabled
196
        LocalCoverImages
233
 XISBN
197
        OPACLocalCoverImages
234
 OpenLibraryCovers
198
        NovelistSelectEnabled
235
 UseKohaPlugins
199
        XISBN
236
 SyndeticsEnabled
200
        OpenLibraryCovers
237
  TagsEnabled
201
        UseKohaPlugins
238
 CalendarFirstDayOfWeek
202
        SyndeticsEnabled
239
 opaclanguagesdisplay
203
        TagsEnabled
240
 AuthoritiesLog
204
        CalendarFirstDayOfWeek
241
 BorrowersLog
205
        opaclanguagesdisplay
242
 CataloguingLog
206
        AuthoritiesLog
243
 FinesLog
207
        BorrowersLog
244
 IssueLog
208
        CataloguingLog
245
 LetterLog
209
        FinesLog
246
 ReturnLog
210
        IssueLog
247
 SubscriptionLog
211
        LetterLog
248
 AuthorisedValueImages
212
        ReturnLog
249
 BiblioDefaultView
213
        SubscriptionLog
250
 COinSinOPACResults
214
        AuthorisedValueImages
251
 DisplayOPACiconsXSLT
215
        BiblioDefaultView
252
 hidelostitems
216
        COinSinOPACResults
253
 HighlightOwnItemsOnOPAC
217
        DisplayOPACiconsXSLT
254
 OpacAddMastheadLibraryPulldown
218
        hidelostitems
255
 OPACDisplay856uAsImage
219
        HighlightOwnItemsOnOPAC
256
 OpacHighlightedWords
220
        OpacAddMastheadLibraryPulldown
257
 OpacKohaUrl
221
        OPACDisplay856uAsImage
258
 OpacMaintenance
222
        OpacHighlightedWords
259
 OpacPublic
223
        OpacKohaUrl
260
 OpacSeparateHoldings
224
        OpacMaintenance
261
 OPACShowBarcode
225
        OpacPublic
262
 OPACShowCheckoutName
226
        OpacSeparateHoldings
263
 OpacShowFiltersPulldownMobile
227
        OPACShowBarcode
264
 OPACShowHoldQueueDetails
228
        OPACShowCheckoutName
265
 OpacShowLibrariesPulldownMobile
229
        OpacShowFiltersPulldownMobile
266
 OpacShowRecentComments
230
        OPACShowHoldQueueDetails
267
 OPACShowUnusedAuthorities
231
        OpacShowLibrariesPulldownMobile
268
 OpacStarRatings
232
        OpacShowRecentComments
269
 opacthemes
233
        OPACShowUnusedAuthorities
270
 OPACURLOpenInNewWindow
234
        OpacStarRatings
271
 OpacAuthorities
235
        opacthemes
272
 opacbookbag
236
        OPACURLOpenInNewWindow
273
 OpacBrowser
237
        OpacAuthorities
274
 OpacBrowseResults
238
        opacbookbag
275
 OpacCloud
239
        OpacBrowser
276
 OPACFinesTab
240
        OpacBrowseResults
277
 OpacHoldNotes
241
        OpacCloud
278
 OpacItemLocation
242
        OPACFinesTab
279
 OpacPasswordChange
243
        OpacHoldNotes
280
 OPACPatronDetails
244
        OpacItemLocation
281
 OPACpatronimages
245
        OpacPasswordChange
282
 OPACPopupAuthorsSearch
246
        OPACPatronDetails
283
 OpacTopissue
247
        OPACpatronimages
284
 opacuserlogin
248
        OPACPopupAuthorsSearch
285
 QuoteOfTheDay
249
        OpacTopissue
286
 RequestOnOpac
250
        opacuserlogin
287
 reviewson
251
        QuoteOfTheDay
288
 ShowReviewer
252
        RequestOnOpac
289
 ShowReviewerPhoto
253
        reviewson
290
 SocialNetworks
254
        ShowReviewer
291
 suggestion
255
        ShowReviewerPhoto
292
 AllowPurchaseSuggestionBranchChoice
256
        SocialNetworks
293
 OpacAllowPublicListCreation
257
        suggestion
294
 OpacAllowSharingPrivateLists
258
        AllowPurchaseSuggestionBranchChoice
295
 OPACItemHolds
259
        OpacAllowPublicListCreation
296
 OpacRenewalAllowed
260
        OpacAllowSharingPrivateLists
297
 OpacRenewalBranch
261
        OPACItemHolds
298
 OPACViewOthersSuggestions
262
        OpacRenewalAllowed
299
 SearchMyLibraryFirst
263
        OpacRenewalBranch
300
 singleBranchMode
264
        OPACViewOthersSuggestions
301
 AnonSuggestions
265
        SearchMyLibraryFirst
302
 EnableOpacSearchHistory
266
        singleBranchMode
303
 OPACPrivacy
267
        AnonSuggestions
304
 opacreadinghistory
268
        EnableOpacSearchHistory
305
 TrackClicks
269
        OPACPrivacy
306
 PatronSelfRegistration
270
        opacreadinghistory
307
 OPACShelfBrowser
271
        TrackClicks
308
 AddPatronLists
272
        PatronSelfRegistration
309
 AutoEmailOpacUser
273
        OPACShelfBrowser
310
 AutoEmailPrimaryAddress
274
        AddPatronLists
311
 autoMemberNum
275
        AutoEmailOpacUser
312
 BorrowerRenewalPeriodBase
276
        AutoEmailPrimaryAddress
313
 checkdigit
277
        autoMemberNum
314
 EnableBorrowerFiles
278
        BorrowerRenewalPeriodBase
315
 EnhancedMessagingPreferences
279
        checkdigit
316
 ExtendedPatronAttributes
280
        EnableBorrowerFiles
317
 intranetreadinghistory
281
        EnhancedMessagingPreferences
318
 memberofinstitution
282
        ExtendedPatronAttributes
319
 patronimages
283
        intranetreadinghistory
320
 TalkingTechItivaPhoneNotification
284
        memberofinstitution
321
 uppercasesurnames
285
        patronimages
322
 IncludeSeeFromInSearches
286
        TalkingTechItivaPhoneNotification
323
 OpacGroupResults
287
        uppercasesurnames
324
 QueryAutoTruncate
288
        IncludeSeeFromInSearches
325
 QueryFuzzy
289
        OpacGroupResults
326
 QueryStemming
290
        QueryAutoTruncate
327
 QueryWeightFields
291
        QueryFuzzy
328
 TraceCompleteSubfields
292
        QueryStemming
329
 TraceSubjectSubdivisions
293
        QueryWeightFields
330
 UseICU
294
        TraceCompleteSubfields
331
 UseQueryParser
295
        TraceSubjectSubdivisions
332
 defaultSortField
296
        UseICU
333
 displayFacetCount
297
        UseQueryParser
334
 OPACdefaultSortField
298
        defaultSortField
335
 OPACItemsResultsDisplay
299
        displayFacetCount
336
 expandedSearchOption
300
        OPACdefaultSortField
337
 IntranetNumbersPreferPhrase
301
        OPACItemsResultsDisplay
338
 OPACNumbersPreferPhrase
302
        expandedSearchOption
339
 opacSerialDefaultTab
303
        IntranetNumbersPreferPhrase
340
 RenewSerialAddsSuggestion
304
        OPACNumbersPreferPhrase
341
 RoutingListAddReserves
305
        opacSerialDefaultTab
342
 RoutingSerials
306
        RenewSerialAddsSuggestion
343
 SubscriptionHistory
307
        RoutingListAddReserves
344
 Display856uAsImage
308
        RoutingSerials
345
 DisplayIconsXSLT
309
        SubscriptionHistory
346
 StaffAuthorisedValueImages
310
        Display856uAsImage
347
 template
311
        DisplayIconsXSLT
348
 yuipath
312
        StaffAuthorisedValueImages
349
 HidePatronName
313
        template
350
 intranetbookbag
314
        yuipath
351
 StaffDetailItemSelection
315
        HidePatronName
352
 viewISBD
316
        intranetbookbag
353
 viewLabeledMARC
317
        StaffDetailItemSelection
354
 viewMARC
318
        viewISBD
355
 ILS-DI
319
        viewLabeledMARC
356
 OAI-PMH
320
        viewMARC
357
 version/) {
321
        ILS-DI
322
        OAI-PMH
323
        version
324
        /
325
      )
326
    {
358
        $report->{systempreferences}{$_} = C4::Context->preference($_);
327
        $report->{systempreferences}{$_} = C4::Context->preference($_);
359
    }
328
    }
360
    return $report;
329
    return $report;
Lines 369-384 Send to hea.koha-community.org database informations Link Here
369
=cut
338
=cut
370
339
371
sub ReportToCommunity {
340
sub ReportToCommunity {
372
    my $data = shift;
341
      my $data = shift;
373
    my $json = uri_encode(to_json($data), 1);
342
      my $json = uri_encode( to_json($data), 1 );
374
343
375
    my $ua = LWP::UserAgent->new;
344
      my $ua = LWP::UserAgent->new;
376
    my $req = HTTP::Request->new(POST => "http://hea.koha-community.org/upload.pl");
345
      my $req =
377
    $req->content_type('application/x-www-form-urlencoded');
346
        HTTP::Request->new( POST => "http://hea.koha-community.org/upload.pl" );
378
    $req->content("data=$json");
347
      $req->content_type('application/x-www-form-urlencoded');
379
    my $res = $ua->request($req);
348
      $req->content("data=$json");
380
    my $content = from_json($res->decoded_content);
349
      my $res     = $ua->request($req);
381
    C4::Context->set_preference('UsageStatsID', $content->{library}{library_id});
350
      my $content = from_json( $res->decoded_content );
351
      C4::Context->set_preference( 'UsageStatsID',
352
          $content->{library}{library_id} );
382
}
353
}
383
354
384
=head2 _count
355
=head2 _count
Lines 390-402 Count the number of records in $table tables Link Here
390
=cut
361
=cut
391
362
392
sub _count {
363
sub _count {
393
    my $table = shift;
364
      my $table = shift;
394
365
395
    my $dbh = C4::Context->dbh;
366
      my $dbh = C4::Context->dbh;
396
    my $sth = $dbh->prepare("SELECT count(*) from $table");
367
      my $sth = $dbh->prepare("SELECT count(*) from $table");
397
    $sth->execute;
368
      $sth->execute;
398
    return $sth->fetchrow_array;
369
      return $sth->fetchrow_array;
399
}
370
}
400
371
401
&LaunchCron;
402
1;
372
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (-12 / +9 lines)
Lines 115-132 Administration: Link Here
115
            - is the search engine used.
115
            - is the search engine used.
116
    Usage Stats:
116
    Usage Stats:
117
        -
117
        -
118
            - pref: UsageStatsLastUpdateTime
119
              default: 0
120
            - stores the last time when cron were launch 
121
        -
122
            - pref: UsageStatsID
123
              default: 
124
            - 
125
        -
126
            - pref: UsageStatsShare
118
            - pref: UsageStatsShare
127
              default: 
119
              default: 0
128
            - 
120
              choices:
121
                  yes: Share
122
                  no: "Don't share"
123
            - data volumetry with Koha community. You can see the data on the <a href="http://hea.koha-community.org">Hea Koha community website</a>.
129
        -
124
        -
125
            - The library name
130
            - pref: UsageStatsLibraryName
126
            - pref: UsageStatsLibraryName
131
              default: 
127
            - will be shown on <a href="http://hea.koha-community.org">Hea Koha community website</a>.
132
            - 
128
            - If this name is empty, you will sent data anonymously
129
            - Note that this value has no effect if UsageStatsShare system preference is set to "Don't share"
(-)a/misc/cronjobs/share_usage_with_koha_community.pl (-1 / +98 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use Pod::Usage;
6
use Getopt::Long;
7
8
use C4::Context;
9
use C4::UsageStats;
10
11
12
my ( $help, $verbose );
13
GetOptions(
14
    'h|help'                 => \$help,
15
    'v|verbose'              => \$verbose,
16
) || pod2usage(1);
17
18
if ($help) {
19
    pod2usage(1);
20
}
21
22
unless( C4::Context->preference('UsageStatsShare') ) {
23
  pod2usage (q|The UsageStats system preference is not set. If your library  wants to share their usage statistics with the Koha community, you have to switch on this system preference|);
24
  exit 1;
25
}
26
27
my $need_update = C4::UsageStats::NeedUpdate();
28
29
if ( $need_update ) {
30
    say "Data need to be updated" if $verbose;
31
    my $report = C4::UsageStats::BuildReport();
32
    C4::UsageStats::ReportToCommunity($report);
33
    C4::Context->set_preference('UsageStatsLastUpdateTime', strftime("%s", localtime));
34
} elsif( $verbose ) {
35
    say "Data don't need to be updated";
36
}
37
38
=head1 NAME
39
40
share_usage_with_koha_community.pl - Share your library's usage with the Koha community
41
42
=head1 SYNOPSIS
43
44
share_usage_with_koha_community.pl [-h|--help] [-v|--verbose]
45
46
If the UsageStatsShare system preference is set, you can launch this script to share your usage with the Koha community.
47
48
Collecting Koha usage statistics will help developpers to know how Koha is used across the world.
49
50
This script will sent the volumetry for the biblio and authority records, issues, reserves, orders and subscription.
51
52
Only the total number is retrieved. In no case private data will be shared!
53
54
In order to know which parts of Koha modules are used, this script will collect some system preference values.
55
56
If you want to tell us who you are, you can fill the UsageStatsLibraryName system preference with your library name.
57
58
All these data will be analysed on the http://hea.koha-community.org Koha community website.
59
60
IMPORTANT : please do NOT run the cron on the 1st, but on another day. The idea is to avoid all
61
Koha libraries sending their data at the same time ! So choose any day between 1 and 28 !
62
63
=head1 OPTIONS
64
65
=over
66
67
=item B<-h|--help>
68
69
Print a brief help message
70
71
=item B<-v|--verbose>
72
73
Verbose mode.
74
75
=back
76
77
=head1 AUTHOR
78
79
Alex Arnaud <alex.arnaud@biblibre.com>
80
81
Jonathan Druart <jonathan.druart@biblibre.com>
82
83
=head1 COPYRIGHT
84
85
Copyright 2014 BibLibre
86
87
=head1 LICENSE
88
89
This file is part of Koha.
90
91
Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
92
Foundation; either version 3 of the License, or (at your option) any later version.
93
94
You should have received a copy of the GNU General Public License along
95
with Koha; if not, write to the Free Software Foundation, Inc.,
96
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
97
98
=cut

Return to bug 11926