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

(-)a/C4/UsageStats.pm (-5 / +21 lines)
Lines 23-28 use POSIX qw(strftime); Link Here
23
use LWP::UserAgent;
23
use LWP::UserAgent;
24
use JSON;
24
use JSON;
25
25
26
use Koha::Libraries;
27
26
=head1 NAME
28
=head1 NAME
27
29
28
C4::UsageStats
30
C4::UsageStats
Lines 56-69 sub NeedUpdate { Link Here
56
}
58
}
57
59
58
sub BuildReport {
60
sub BuildReport {
59
    my $report = {
61
    my $report;
60
        library => {
62
    my @libraries;
61
            id      => C4::Context->preference('UsageStatsID')          || 0,
63
    if( C4::Context->preference('UsageStatsLibrariesInfo') ) {
64
        my $libraries = Koha::Libraries->search;
65
        while ( my $library = $libraries->next ) {
66
            push @libraries, { name => $library->branchname, url => $library->branchurl, country => $library->branchcountry, geolocation => $library->geolocation, };
67
        }
68
    }
69
    $report = {
70
        installation => {
71
            koha_id => C4::Context->preference('UsageStatsID')          || 0,
62
            name    => C4::Context->preference('UsageStatsLibraryName') || q||,
72
            name    => C4::Context->preference('UsageStatsLibraryName') || q||,
63
            url     => C4::Context->preference('UsageStatsLibraryUrl')  || q||,
73
            url     => C4::Context->preference('UsageStatsLibraryUrl')  || q||,
64
            type    => C4::Context->preference('UsageStatsLibraryType') || q||,
74
            type    => C4::Context->preference('UsageStatsLibraryType') || q||,
65
            country => C4::Context->preference('UsageStatsCountry')     || q||,
75
            country => C4::Context->preference('UsageStatsCountry')     || q||,
76
            geolocation => C4::Context->preference('UsageStatsGeolocation') || q||,
66
        },
77
        },
78
        libraries => \@libraries,
67
    };
79
    };
68
80
69
    # Get database volumetry.
81
    # Get database volumetry.
Lines 351-358 sub ReportToCommunity { Link Here
351
        Content => $json,
363
        Content => $json,
352
    );
364
    );
353
    my $content = decode_json( $res->decoded_content );
365
    my $content = decode_json( $res->decoded_content );
354
    C4::Context->set_preference( 'UsageStatsID',
366
    if ( $content->{koha_id} ) {
355
        $content->{library}{id} );
367
        C4::Context->set_preference( 'UsageStatsID', $content->{koha_id} );
368
    }
369
    if ( $content->{id} ) {
370
        C4::Context->set_preference( 'UsageStatsPublicID', $content->{id} );
371
    }
356
}
372
}
357
373
358
=head2 _count
374
=head2 _count
(-)a/Koha/Schema/Result/Branch.pm (-2 / +10 lines)
Lines 128-133 __PACKAGE__->table("branches"); Link Here
128
  data_type: 'text'
128
  data_type: 'text'
129
  is_nullable: 1
129
  is_nullable: 1
130
130
131
=head2 geolocation
132
133
  data_type: 'varchar'
134
  is_nullable: 1
135
  size: 255
136
131
=cut
137
=cut
132
138
133
__PACKAGE__->add_columns(
139
__PACKAGE__->add_columns(
Lines 171-176 __PACKAGE__->add_columns( Link Here
171
  { data_type => "mediumtext", is_nullable => 1 },
177
  { data_type => "mediumtext", is_nullable => 1 },
172
  "opac_info",
178
  "opac_info",
173
  { data_type => "text", is_nullable => 1 },
179
  { data_type => "text", is_nullable => 1 },
180
  "geolocation",
181
  { data_type => "varchar", is_nullable => 1, size => 255 },
174
);
182
);
175
183
176
=head1 PRIMARY KEY
184
=head1 PRIMARY KEY
Lines 543-550 Composing rels: L</branchrelations> -> categorycode Link Here
543
__PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode");
551
__PACKAGE__->many_to_many("categorycodes", "branchrelations", "categorycode");
544
552
545
553
546
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-10-24 13:56:21
554
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-02-06 10:07:25
547
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/9YwsU+GXK+fzc6IX2Tj5g
555
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aq4mf5Dwbd8ps9ANLy8DuQ
548
556
549
557
550
# You can replace this text with custom code or comments, and it will be preserved on regeneration
558
# You can replace this text with custom code or comments, and it will be preserved on regeneration
(-)a/admin/usage_statistics.pl (-1 / +16 lines)
Lines 21-26 use CGI qw ( -utf8 ); Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Output;
22
use C4::Output;
23
use Koha::DateUtils qw( dt_from_string output_pref );
23
use Koha::DateUtils qw( dt_from_string output_pref );
24
use Koha::Libraries;
24
25
25
my $query = new CGI;
26
my $query = new CGI;
26
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
27
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 42-53 if ( $op eq 'update' ) { Link Here
42
    my $UsageStatsLibraryName = $query->param('UsageStatsLibraryName');
43
    my $UsageStatsLibraryName = $query->param('UsageStatsLibraryName');
43
    my $UsageStatsLibraryType = $query->param('UsageStatsLibraryType');
44
    my $UsageStatsLibraryType = $query->param('UsageStatsLibraryType');
44
    my $UsageStatsLibraryUrl = $query->param('UsageStatsLibraryUrl');
45
    my $UsageStatsLibraryUrl = $query->param('UsageStatsLibraryUrl');
46
    my $UsageStatsLibrariesInfo = $query->param('UsageStatsLibrariesInfo');
47
    my $UsageStatsGeolocation = $query->param('UsageStatsGeolocation');
45
    C4::Context->set_preference('UsageStats', $UsageStats);
48
    C4::Context->set_preference('UsageStats', $UsageStats);
46
    C4::Context->set_preference('UsageStatsCountry', $UsageStatsCountry);
49
    C4::Context->set_preference('UsageStatsCountry', $UsageStatsCountry);
47
    C4::Context->set_preference('UsageStatsLibraryName', $UsageStatsLibraryName);
50
    C4::Context->set_preference('UsageStatsLibraryName', $UsageStatsLibraryName);
48
    C4::Context->set_preference('UsageStatsLibraryType', $UsageStatsLibraryType);
51
    C4::Context->set_preference('UsageStatsLibraryType', $UsageStatsLibraryType);
49
    C4::Context->set_preference('UsageStatsLibraryUrl', $UsageStatsLibraryUrl);
52
    C4::Context->set_preference('UsageStatsLibraryUrl', $UsageStatsLibraryUrl);
50
53
    C4::Context->set_preference('UsageStatsLibrariesInfo', $UsageStatsLibrariesInfo);
54
    C4::Context->set_preference('UsageStatsGeolocation', $UsageStatsGeolocation);
55
    my $libraries = Koha::Libraries->search;
56
    while ( my $library = $libraries->next ) {
57
        if ( my $latlng = $query->param('geolocation_' . $library->branchcode) ) {
58
            $library->geolocation( $latlng )->store;
59
        }
60
    }
51
}
61
}
52
62
53
if ( C4::Context->preference('UsageStatsLastUpdateTime') ) {
63
if ( C4::Context->preference('UsageStatsLastUpdateTime') ) {
Lines 55-58 if ( C4::Context->preference('UsageStatsLastUpdateTime') ) { Link Here
55
    $template->param(UsageStatsLastUpdateTime => output_pref($dt) );
65
    $template->param(UsageStatsLastUpdateTime => output_pref($dt) );
56
}
66
}
57
67
68
my $libraries = Koha::Libraries->search;
69
$template->param(
70
    libraries => $libraries,
71
);
72
58
output_html_with_http_headers $query, $cookie, $template->output;
73
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/installer/data/mysql/atomicupdate/bug_18066.perl (+21 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    unless( column_exists( 'branches', 'geolocation' ) ) {
4
        $dbh->do(q|
5
            ALTER TABLE branches ADD COLUMN geolocation VARCHAR(255) DEFAULT NULL after opac_info
6
        |);
7
    }
8
9
    $dbh->do(q|
10
        INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type ) VALUES ('UsageStatsGeolocation', '', NULL, 'Geolocation of the main library', 'Free');
11
    |);
12
    $dbh->do(q|
13
        INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type ) VALUES ('UsageStatsLibrariesInfo', '', NULL, 'Share libraries information', 'YesNo');
14
    |);
15
    $dbh->do(q|
16
        INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type ) VALUES ('UsageStatsPublicID', '', NULL, 'Public ID for Hea website', 'Free');
17
    |);
18
19
    SetVersion( $DBversion );
20
    print "Upgrade to $DBversion done (Bug 18066 - Hea version 2)\n";
21
}
(-)a/installer/data/mysql/sysprefs.sql (+3 lines)
Lines 534-543 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
534
('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo'),
534
('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo'),
535
('UsageStatsCountry', '', NULL, 'The country where your library is located, to be shown on the Hea Koha community website', 'Choice'),
535
('UsageStatsCountry', '', NULL, 'The country where your library is located, to be shown on the Hea Koha community website', 'Choice'),
536
('UsageStatsID', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.',  'Free'),
536
('UsageStatsID', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.',  'Free'),
537
('UsageStatsGeolocation', '', NULL, 'Geolocation of the main library.', 'Free'),
537
('UsageStatsLastUpdateTime', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
538
('UsageStatsLastUpdateTime', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
539
('UsageStatsLibrariesInfo', '', NULL, 'Share libraries information', 'YesNo'),
538
('UsageStatsLibraryName', '', NULL, 'The library name to be shown on Hea Koha community website', 'Free'),
540
('UsageStatsLibraryName', '', NULL, 'The library name to be shown on Hea Koha community website', 'Free'),
539
('UsageStatsLibraryType', '', 'public|school|academic|research|private|societyAssociation|corporate|government|religiousOrg|subscription', 'The library type to be shown on the Hea Koha community website', 'Choice'),
541
('UsageStatsLibraryType', '', 'public|school|academic|research|private|societyAssociation|corporate|government|religiousOrg|subscription', 'The library type to be shown on the Hea Koha community website', 'Choice'),
540
('UsageStatsLibraryUrl', '', NULL, 'The library URL to be shown on Hea Koha community website', 'Free'),
542
('UsageStatsLibraryUrl', '', NULL, 'The library URL to be shown on Hea Koha community website', 'Free'),
543
('UsageStatsPublicID', '', NULL, 'Public ID for Hea website', 'Free'),
541
('UseAuthoritiesForTracings','1','0','Use authority record numbers for subject tracings instead of heading strings.','YesNo'),
544
('UseAuthoritiesForTracings','1','0','Use authority record numbers for subject tracings instead of heading strings.','YesNo'),
542
('UseBranchTransferLimits','0','','If ON, Koha will will use the rules defined in branch_transfer_limits to decide if an item transfer should be allowed.','YesNo'),
545
('UseBranchTransferLimits','0','','If ON, Koha will will use the rules defined in branch_transfer_limits to decide if an item transfer should be allowed.','YesNo'),
543
('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'),
546
('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt (+3 lines)
Lines 820-825 Link Here
820
820
821
            <h2>jquery.tablednd.js</h2>
821
            <h2>jquery.tablednd.js</h2>
822
            <p>The <a href="https://github.com/isocra/TableDnD">TableDnD plug-in for jQuery</a> by Denis Howlett is licensed under the <a href="http://opensource.org/licenses/mit-license.php">MIT License</a>.</p>
822
            <p>The <a href="https://github.com/isocra/TableDnD">TableDnD plug-in for jQuery</a> by Denis Howlett is licensed under the <a href="http://opensource.org/licenses/mit-license.php">MIT License</a>.</p>
823
824
            <h2>Leaflet</h2>
825
            <p>The <a href="http://leafletjs.com">Leaflet</a> JavaScript library by Vladimir Agafonkinis licensed under the <a href="https://github.com/Leaflet/Leaflet/blob/master/LICENSE">BSD License</a>.</p>
823
        </div>
826
        </div>
824
827
825
        <div id="translations">
828
        <div id="translations">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+11 lines)
Lines 394-399 Administration: Link Here
394
                  religiousOrg: "religious organization"
394
                  religiousOrg: "religious organization"
395
                  subscription: "subscription"
395
                  subscription: "subscription"
396
            - Note that this value has no effect if the UsageStats system preference is set to "Don't share"
396
            - Note that this value has no effect if the UsageStats system preference is set to "Don't share"
397
        -
398
            - pref: UsageStatsLibrariesInfo
399
              choices:
400
                  yes: "Share"
401
                  no: "Do not Share"
402
            - "libraries information (name, url, country)"
403
            - Note that this value has no effect if the UsageStats system preference is set to "Don't share"
404
        -
405
            - Geolocation of the main library:
406
            - pref: UsageStatsGeolocation
407
            - Note that this value has no effect if the UsageStats system preference is set to "Don't share"
397
    Search Engine:
408
    Search Engine:
398
        -
409
        -
399
            - "Use following search engine: "
410
            - "Use following search engine: "
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/usage_statistics.tt (-3 / +160 lines)
Lines 5-10 Link Here
5
<title>Koha &rsaquo; Administration &rsaquo; Koha usage statistics</title>
5
<title>Koha &rsaquo; Administration &rsaquo; Koha usage statistics</title>
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'calendar.inc' %]
7
[% INCLUDE 'calendar.inc' %]
8
<link rel="stylesheet" href="[% interface %]/lib/leaflet/leaflet.css" />
9
<script src="[% interface %]/lib/leaflet/leaflet.js"></script>
10
11
<script type="text/javascript">
12
//<![CDATA[
13
    var originalOffset;
14
    $(window).scroll(function () {
15
        var tbh = $("#mapid");
16
        var offsetTop = tbh.offset().top;
17
        var s = parseInt($(window).scrollTop(), 10);
18
        var fixMe = (s > offsetTop);
19
        if ( !originalOffset ) originalOffset = tbh.position().top;
20
        var repositionMe = (s < originalOffset);
21
        if (fixMe) {
22
            tbh.css({
23
                'position': 'fixed',
24
                    'top': '0',
25
                'margin-left': '40%'
26
            });
27
        }
28
        if (repositionMe) {
29
            tbh.css({
30
                'position': 'absolute',
31
                    'top': originalOffset,
32
                'margin-left': '40%'
33
            });
34
        }
35
    });
36
//]]>
37
</script>
8
</head>
38
</head>
9
39
10
<body id="admin_usage_statistics" class="admin">
40
<body id="admin_usage_statistics" class="admin">
Lines 48-54 Link Here
48
    <form id="category_form" action="/cgi-bin/koha/admin/usage_statistics.pl" method="post">
78
    <form id="category_form" action="/cgi-bin/koha/admin/usage_statistics.pl" method="post">
49
        <h1>Modify the statistics you share with the Koha community</h1>
79
        <h1>Modify the statistics you share with the Koha community</h1>
50
        <fieldset class="rows">
80
        <fieldset class="rows">
51
            <ol>
81
            <ol style="float:left;">
52
                <li>
82
                <li>
53
                    <label for="UsageStats">Share my Koha usage statistics: </label>
83
                    <label for="UsageStats">Share my Koha usage statistics: </label>
54
                    <select name="UsageStats" id="UsageStats">
84
                    <select name="UsageStats" id="UsageStats">
Lines 281-287 Link Here
281
                </li>
311
                </li>
282
                <li>
312
                <li>
283
                    <label for="UsageStatsLibraryName">Library name: </label>
313
                    <label for="UsageStatsLibraryName">Library name: </label>
284
                    <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
314
                    <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') | html %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
285
                </li>
315
                </li>
286
                <li>
316
                <li>
287
                    <label for="UsageStatsLibraryType">Library type: </label>
317
                    <label for="UsageStatsLibraryType">Library type: </label>
Lines 353-360 Link Here
353
                        Your data have never been shared
383
                        Your data have never been shared
354
                    [% END %]
384
                    [% END %]
355
                </li>
385
                </li>
386
                <li>
387
                    <label for="UsageStatsGeolocation">Geolocation: </label>
388
                    <input id="UsageStatsGeolocation" name="UsageStatsGeolocation" value="[% Koha.Preference('UsageStatsGeolocation') %]" type="text" value="[% Koha.Preference('UsageStatsLibrariesInfo') %]" size="35" readonly="readonly" />
389
                    <a href="#" class="change_geolocation" data-branchname="" data-id="UsageStatsGeolocation"><img src="[% interface %]/lib/leaflet/images/marker-icon.png" title="Set geolocation" style="max-height: 2em;" /></a>
390
                </li>
391
                <li>
392
                    <label for="UsageStatsLibrariesInfo">Libraries informations: </label>
393
                    <select name="UsageStatsLibrariesInfo" id="UsageStatsLibrariesInfo">
394
                        [% IF Koha.Preference('UsageStatsLibrariesInfo') %]
395
                            <option value="1" selected="selected">Yes</option>
396
                            <option value="0">No</option>
397
                        [% ELSE %]
398
                            <option value="1">Yes</option>
399
                            <option value="0" selected="selected">No</option>
400
                        [% END %]
401
                    </select>
402
                </li>
403
404
                <li id="libraries_info">
405
                    <fieldset class="rows">
406
                    <legend>Libraries</legend>
407
                    <ol>
408
                        [% FOR l IN libraries %]
409
                        <li>
410
                            <label for="[% l.branchcode %]">[% l.branchname %]: </label>
411
                            <div style="float:left;">
412
                                <div>Country: [% l.branchcountry %]</div>
413
                                <div>Url: [% l.branchurl %]</div>
414
                                <div>
415
                                    Geolocation: <input type="text" id="geolocation_[% l.branchcode %]" name="geolocation_[% l.branchcode %]" value="[% l.geolocation %]" size="35" readonly="readonly" />
416
                                    <a href="#" class="change_geolocation" data-branchname="[% l.branchname %]" data-id="geolocation_[% l.branchcode %]"><img src="[% interface %]/lib/leaflet/images/marker-icon.png" title="Set geolocation for [% l.branchname %]" style="max-height: 2em;" /></a>
417
                                </div>
418
                            </div>
419
                        </li>
420
                        [% END %]
421
                    </ol>
422
                    </fieldset>
423
                </li>
424
                <li>
425
                    <label for="MyPublicLink">See your public page: </label>
426
                    [% IF Koha.Preference('UsageStatsPublicID') %]
427
                        [% SET my_url = 'http://hea.koha-community.org/libraries/' _  Koha.Preference('UsageStatsPublicID') %]
428
                        <a href="[% my_url %]">[% my_url %]</a>
429
                    [% ELSE %]
430
                        You do not have anything public yet.
431
                    [% END %]
432
                </li>
433
356
            </ol>
434
            </ol>
357
        </fieldset>
435
            <div style="clear:right"></div>
436
        <div id="mapid" style="width: 600px; height: 400px; margin-left: 40%:"></div>
437
    </fieldset>
358
438
359
        <fieldset class="action">
439
        <fieldset class="action">
360
            <input type="hidden" name="op" value="update" />
440
            <input type="hidden" name="op" value="update" />
Lines 363-368 Link Here
363
        </fieldset>
443
        </fieldset>
364
    </form>
444
    </form>
365
445
446
    <script>
447
        var map = L.map('mapid').setView([0,0], 1);
448
        L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpandmbXliNDBjZWd2M2x6bDk3c2ZtOTkifQ._QA7i5Mpkd_m30IGElHziw', {
449
            maxZoom: 18,
450
            attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
451
                '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
452
                'Imagery © <a href="http://mapbox.com">Mapbox</a>',
453
            id: 'mapbox.streets'
454
        }).addTo(map);
455
456
        var default_elt = { 'text': _("Main library"), 'id': 'UsageStatsGeolocation' };
457
        var current_elt = default_elt;
458
459
        // Add the title
460
        var title = L.control({position: 'topright'});
461
        title.onAdd = function (map) {
462
            this._div = L.DomUtil.create('div', 'title');
463
            this.update();
464
            return this._div;
465
        };
466
        title.update = function (props) {
467
            this._div.innerHTML = '<h4>' + _("Click on the map to set the geolocation for %s").format(current_elt.text) + '</h4>';
468
        };
469
        title.addTo(map);
470
471
        var markers = {};
472
        function add_to_map(elt, latlng) {
473
            var marker = markers[elt.id];
474
            if (marker) map.removeLayer(marker);
475
            marker = L.marker(latlng).addTo(map);
476
            marker.bindPopup(elt.text);
477
            marker.on('mouseover', function (e) {this.openPopup(); });
478
            marker.on('mouseout',  function (e) {this.closePopup();});
479
            markers[elt.id] = marker;
480
        }
481
482
        // Init the map
483
        [% IF Koha.Preference('UsageStatsGeolocation') %]
484
            var latlng = [ [% Koha.Preference('UsageStatsGeolocation') %] ];
485
            add_to_map( current_elt, latlng );
486
        [% END %]
487
        [% FOR l IN libraries %]
488
            [% NEXT UNLESS l.geolocation %]
489
            add_to_map( { 'text': "[% l.branchname %]", 'id': "geolocation_[% l.branchcode %]" }, [ [% l.geolocation %] ] );
490
        [% END %]
491
492
        // On click, update the geolocation and the marker
493
        map.on('click', function(e){
494
            add_to_map( current_elt, e.latlng );
495
            $("#" + current_elt.id).val(e.latlng.lat + ',' + e.latlng.lng);
496
        });
497
498
        // Auto zoom
499
        var group = new L.featureGroup(Object.keys(markers).map(function(key){return markers[key]}));
500
        if ( group.getBounds().isValid() ) map.fitBounds(group.getBounds());
501
502
        // On click on the marker icons, update the title of the map
503
        $(document).ready(function(){
504
            $(".change_geolocation").on('click', function(e){
505
                e.preventDefault();
506
                if ( $(this).data('branchname') ) {
507
                    current_elt = { 'text': $(this).data('branchname'), 'id': $(this).data('id') };
508
                } else {
509
                    current_elt = default_elt;
510
                }
511
                title.update();
512
            });
513
            $("#UsageStatsLibrariesInfo").change();
514
        });
515
516
        $("#UsageStatsLibrariesInfo").on('change', function(){
517
            if ( $(this).val() == 1 ) $("#libraries_info").show()
518
            else $("#libraries_info").hide();
519
        });
520
521
    </script>
522
366
</div>
523
</div>
367
</div>
524
</div>
368
<div class="yui-b">
525
<div class="yui-b">
(-)a/misc/cronjobs/share_usage_with_koha_community.pl (-1 / +1 lines)
Lines 70-76 Only the total number is retrieved. In no case will private data be shared! Link Here
70
70
71
In order to know which parts of Koha modules are used, this script will collect some system preference values.
71
In order to know which parts of Koha modules are used, this script will collect some system preference values.
72
72
73
If you want to tell us who you are, you can fill the UsageStatsLibraryName system preference with your library name, UsageStatsLibraryUrl, UsageStatsLibraryType and/or UsageStatsCountry.
73
If you want to tell us who you are, you can fill the UsageStatsLibraryName system preference with your library name, UsageStatsLibraryUrl, UsageStatsLibraryType and/or UsageStatsCountry, UsageStatsLibrariesInfo.
74
74
75
All these data will be analyzed on the http://hea.koha-community.org Koha community website.
75
All these data will be analyzed on the http://hea.koha-community.org Koha community website.
76
76
(-)a/t/db_dependent/UsageStats.t (-5 / +11 lines)
Lines 15-25 Link Here
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
16
16
17
use Modern::Perl;
17
use Modern::Perl;
18
use Test::More tests => 57;
18
use Test::More tests => 59;
19
use t::lib::Mocks qw(mock_preference);
19
use t::lib::Mocks qw(mock_preference);
20
use POSIX qw(strftime);
20
use POSIX qw(strftime);
21
use Data::Dumper;
21
use Data::Dumper;
22
22
23
use Koha::Libraries;
24
23
BEGIN {
25
BEGIN {
24
    use_ok('C4::UsageStats');
26
    use_ok('C4::UsageStats');
25
    use_ok('C4::Context');
27
    use_ok('C4::Context');
Lines 78-97 is( $update, 0, "Last update just be done, no update needed " ); Link Here
78
#mock to 0
80
#mock to 0
79
t::lib::Mocks::mock_preference( "UsageStatsID",          0 );
81
t::lib::Mocks::mock_preference( "UsageStatsID",          0 );
80
t::lib::Mocks::mock_preference( "UsageStatsLibraryName", 0 );
82
t::lib::Mocks::mock_preference( "UsageStatsLibraryName", 0 );
81
t::lib::Mocks::mock_preference( "UsageStatsLibraryUrl",  0 );
83
t::lib::Mocks::mock_preference( "UsageStatsLibrariesInfo",  0 );
82
t::lib::Mocks::mock_preference( "UsageStatsLibraryType", 0 );
84
t::lib::Mocks::mock_preference( "UsageStatsLibraryType", 0 );
83
t::lib::Mocks::mock_preference( "UsageStatsCountry",     0 );
85
t::lib::Mocks::mock_preference( "UsageStatsCountry",     0 );
86
t::lib::Mocks::mock_preference( "UsageStatsLibraryUrl",  0 );
84
87
85
my $report = C4::UsageStats->BuildReport();
88
my $report = C4::UsageStats->BuildReport();
86
89
87
isa_ok( $report,            'HASH', '$report is a HASH' );
90
isa_ok( $report,            'HASH', '$report is a HASH' );
88
isa_ok( $report->{library}, 'HASH', '$report->{library} is a HASH' );
91
isa_ok( $report->{library}, 'HASH', '$report->{library} is a HASH' );
89
is( scalar( keys %{$report->{library}} ), 5,  "There are 5 fields in $report->{library}" );
92
is( scalar( keys %{$report->{library}} ), 6,  "There are 6 fields in $report->{library}" );
90
is( $report->{library}->{id},             0,  "UsageStatsID           is good" );
93
is( $report->{library}->{id},             0,  "UsageStatsID           is good" );
91
is( $report->{library}->{name},           '', "UsageStatsLibraryName  is good" );
94
is( $report->{library}->{name},           '', "UsageStatsLibraryName  is good" );
92
is( $report->{library}->{url},            '', "UsageStatsLibraryUrl   is good" );
95
is( $report->{library}->{url},            '', "UsageStatsLibraryUrl   is good" );
93
is( $report->{library}->{type},           '', "UsageStatsLibraryType  is good" );
96
is( $report->{library}->{type},           '', "UsageStatsLibraryType  is good" );
94
is( $report->{library}->{country},        '', "UsageStatsCountry      is good" );
97
is( $report->{library}->{country},        '', "UsageStatsCountry      is good" );
98
is( $report->{library}->{number_of_libraries}, undef, "UsageStatsLibrariesInfo is good" );
95
99
96
#mock with values
100
#mock with values
97
t::lib::Mocks::mock_preference( "UsageStatsID",          1 );
101
t::lib::Mocks::mock_preference( "UsageStatsID",          1 );
Lines 99-115 t::lib::Mocks::mock_preference( "UsageStatsLibraryName", 'NAME' ); Link Here
99
t::lib::Mocks::mock_preference( "UsageStatsLibraryUrl",  'URL' );
103
t::lib::Mocks::mock_preference( "UsageStatsLibraryUrl",  'URL' );
100
t::lib::Mocks::mock_preference( "UsageStatsLibraryType", 'TYPE' );
104
t::lib::Mocks::mock_preference( "UsageStatsLibraryType", 'TYPE' );
101
t::lib::Mocks::mock_preference( "UsageStatsCountry",     'COUNTRY' );
105
t::lib::Mocks::mock_preference( "UsageStatsCountry",     'COUNTRY' );
106
t::lib::Mocks::mock_preference( "UsageStatsLibrariesInfo", 1 );
102
107
103
$report = C4::UsageStats->BuildReport();
108
$report = C4::UsageStats->BuildReport();
104
109
105
isa_ok( $report,            'HASH', '$report is a HASH' );
110
isa_ok( $report,            'HASH', '$report is a HASH' );
106
isa_ok( $report->{library}, 'HASH', '$report->{library} is a HASH' );
111
isa_ok( $report->{library}, 'HASH', '$report->{library} is a HASH' );
107
is( scalar( keys %{$report->{library}} ), 5,         "There are 5 fields in $report->{library}" );
112
is( scalar( keys %{$report->{library}} ), 6,         "There are 6 fields in $report->{library}" );
108
is( $report->{library}->{id},             1,         "UsageStatsID            is good" );
113
is( $report->{library}->{id},             1,         "UsageStatsID            is good" );
109
is( $report->{library}->{name},           'NAME',    "UsageStatsLibraryName   is good" );
114
is( $report->{library}->{name},           'NAME',    "UsageStatsLibraryName   is good" );
110
is( $report->{library}->{url},            'URL',     "UsageStatsLibraryUrl    is good" );
115
is( $report->{library}->{url},            'URL',     "UsageStatsLibraryUrl    is good" );
111
is( $report->{library}->{type},           'TYPE',    "UsageStatsLibraryType   is good" );
116
is( $report->{library}->{type},           'TYPE',    "UsageStatsLibraryType   is good" );
112
is( $report->{library}->{country},        'COUNTRY', "UsageStatsCountry       is good" );
117
is( $report->{library}->{country},        'COUNTRY', "UsageStatsCountry       is good" );
118
my $nb_of_libraries = Koha::Libraries->count;
119
is( $report->{library}->{number_of_libraries}, $nb_of_libraries, "UsageStatsLibrariesInfo is good" );
113
120
114
#Test report->volumetry ---------------
121
#Test report->volumetry ---------------
115
#with original values
122
#with original values
116
- 

Return to bug 18066