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 540-549 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
540
('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo'),
540
('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo'),
541
('UsageStatsCountry', '', NULL, 'The country where your library is located, to be shown on the Hea Koha community website', 'Choice'),
541
('UsageStatsCountry', '', NULL, 'The country where your library is located, to be shown on the Hea Koha community website', 'Choice'),
542
('UsageStatsID', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.',  'Free'),
542
('UsageStatsID', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.',  'Free'),
543
('UsageStatsGeolocation', '', NULL, 'Geolocation of the main library.', 'Free'),
543
('UsageStatsLastUpdateTime', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
544
('UsageStatsLastUpdateTime', '', NULL, 'This preference is part of Koha but it should not be deleted or updated manually.', 'Free'),
545
('UsageStatsLibrariesInfo', '', NULL, 'Share libraries information', 'YesNo'),
544
('UsageStatsLibraryName', '', NULL, 'The library name to be shown on Hea Koha community website', 'Free'),
546
('UsageStatsLibraryName', '', NULL, 'The library name to be shown on Hea Koha community website', 'Free'),
545
('UsageStatsLibraryType', '', 'public|school|academic|research|private|societyAssociation|corporate|government|religiousOrg|subscription', 'The library type to be shown on the Hea Koha community website', 'Choice'),
547
('UsageStatsLibraryType', '', 'public|school|academic|research|private|societyAssociation|corporate|government|religiousOrg|subscription', 'The library type to be shown on the Hea Koha community website', 'Choice'),
546
('UsageStatsLibraryUrl', '', NULL, 'The library URL to be shown on Hea Koha community website', 'Free'),
548
('UsageStatsLibraryUrl', '', NULL, 'The library URL to be shown on Hea Koha community website', 'Free'),
549
('UsageStatsPublicID', '', NULL, 'Public ID for Hea website', 'Free'),
547
('UseAuthoritiesForTracings','1','0','Use authority record numbers for subject tracings instead of heading strings.','YesNo'),
550
('UseAuthoritiesForTracings','1','0','Use authority record numbers for subject tracings instead of heading strings.','YesNo'),
548
('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'),
551
('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'),
549
('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'),
552
('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 87-93 Link Here
87
                </li>
117
                </li>
88
                <li>
118
                <li>
89
                    <label for="UsageStatsLibraryName">Library name: </label>
119
                    <label for="UsageStatsLibraryName">Library name: </label>
90
                    <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
120
                    <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') | html %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
91
                </li>
121
                </li>
92
                <li>
122
                <li>
93
                    <label for="UsageStatsLibraryType">Library type: </label>
123
                    <label for="UsageStatsLibraryType">Library type: </label>
Lines 159-166 Link Here
159
                        Your data have never been shared
189
                        Your data have never been shared
160
                    [% END %]
190
                    [% END %]
161
                </li>
191
                </li>
192
                <li>
193
                    <label for="UsageStatsGeolocation">Geolocation: </label>
194
                    <input id="UsageStatsGeolocation" name="UsageStatsGeolocation" value="[% Koha.Preference('UsageStatsGeolocation') %]" type="text" value="[% Koha.Preference('UsageStatsLibrariesInfo') %]" size="35" readonly="readonly" />
195
                    <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>
196
                </li>
197
                <li>
198
                    <label for="UsageStatsLibrariesInfo">Libraries informations: </label>
199
                    <select name="UsageStatsLibrariesInfo" id="UsageStatsLibrariesInfo">
200
                        [% IF Koha.Preference('UsageStatsLibrariesInfo') %]
201
                            <option value="1" selected="selected">Yes</option>
202
                            <option value="0">No</option>
203
                        [% ELSE %]
204
                            <option value="1">Yes</option>
205
                            <option value="0" selected="selected">No</option>
206
                        [% END %]
207
                    </select>
208
                </li>
209
210
                <li id="libraries_info">
211
                    <fieldset class="rows">
212
                    <legend>Libraries</legend>
213
                    <ol>
214
                        [% FOR l IN libraries %]
215
                        <li>
216
                            <label for="[% l.branchcode %]">[% l.branchname %]: </label>
217
                            <div style="float:left;">
218
                                <div>Country: [% l.branchcountry %]</div>
219
                                <div>Url: [% l.branchurl %]</div>
220
                                <div>
221
                                    Geolocation: <input type="text" id="geolocation_[% l.branchcode %]" name="geolocation_[% l.branchcode %]" value="[% l.geolocation %]" size="35" readonly="readonly" />
222
                                    <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>
223
                                </div>
224
                            </div>
225
                        </li>
226
                        [% END %]
227
                    </ol>
228
                    </fieldset>
229
                </li>
230
                <li>
231
                    <label for="MyPublicLink">See your public page: </label>
232
                    [% IF Koha.Preference('UsageStatsPublicID') %]
233
                        [% SET my_url = 'http://hea.koha-community.org/libraries/' _  Koha.Preference('UsageStatsPublicID') %]
234
                        <a href="[% my_url %]">[% my_url %]</a>
235
                    [% ELSE %]
236
                        You do not have anything public yet.
237
                    [% END %]
238
                </li>
239
162
            </ol>
240
            </ol>
163
        </fieldset>
241
            <div style="clear:right"></div>
242
        <div id="mapid" style="width: 600px; height: 400px; margin-left: 40%:"></div>
243
    </fieldset>
164
244
165
        <fieldset class="action">
245
        <fieldset class="action">
166
            <input type="hidden" name="op" value="update" />
246
            <input type="hidden" name="op" value="update" />
Lines 169-174 Link Here
169
        </fieldset>
249
        </fieldset>
170
    </form>
250
    </form>
171
251
252
    <script>
253
        var map = L.map('mapid').setView([0,0], 1);
254
        L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpandmbXliNDBjZWd2M2x6bDk3c2ZtOTkifQ._QA7i5Mpkd_m30IGElHziw', {
255
            maxZoom: 18,
256
            attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
257
                '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
258
                'Imagery © <a href="http://mapbox.com">Mapbox</a>',
259
            id: 'mapbox.streets'
260
        }).addTo(map);
261
262
        var default_elt = { 'text': _("Main library"), 'id': 'UsageStatsGeolocation' };
263
        var current_elt = default_elt;
264
265
        // Add the title
266
        var title = L.control({position: 'topright'});
267
        title.onAdd = function (map) {
268
            this._div = L.DomUtil.create('div', 'title');
269
            this.update();
270
            return this._div;
271
        };
272
        title.update = function (props) {
273
            this._div.innerHTML = '<h4>' + _("Click on the map to set the geolocation for %s").format(current_elt.text) + '</h4>';
274
        };
275
        title.addTo(map);
276
277
        var markers = {};
278
        function add_to_map(elt, latlng) {
279
            var marker = markers[elt.id];
280
            if (marker) map.removeLayer(marker);
281
            marker = L.marker(latlng).addTo(map);
282
            marker.bindPopup(elt.text);
283
            marker.on('mouseover', function (e) {this.openPopup(); });
284
            marker.on('mouseout',  function (e) {this.closePopup();});
285
            markers[elt.id] = marker;
286
        }
287
288
        // Init the map
289
        [% IF Koha.Preference('UsageStatsGeolocation') %]
290
            var latlng = [ [% Koha.Preference('UsageStatsGeolocation') %] ];
291
            add_to_map( current_elt, latlng );
292
        [% END %]
293
        [% FOR l IN libraries %]
294
            [% NEXT UNLESS l.geolocation %]
295
            add_to_map( { 'text': "[% l.branchname %]", 'id': "geolocation_[% l.branchcode %]" }, [ [% l.geolocation %] ] );
296
        [% END %]
297
298
        // On click, update the geolocation and the marker
299
        map.on('click', function(e){
300
            add_to_map( current_elt, e.latlng );
301
            $("#" + current_elt.id).val(e.latlng.lat + ',' + e.latlng.lng);
302
        });
303
304
        // Auto zoom
305
        var group = new L.featureGroup(Object.keys(markers).map(function(key){return markers[key]}));
306
        if ( group.getBounds().isValid() ) map.fitBounds(group.getBounds());
307
308
        // On click on the marker icons, update the title of the map
309
        $(document).ready(function(){
310
            $(".change_geolocation").on('click', function(e){
311
                e.preventDefault();
312
                if ( $(this).data('branchname') ) {
313
                    current_elt = { 'text': $(this).data('branchname'), 'id': $(this).data('id') };
314
                } else {
315
                    current_elt = default_elt;
316
                }
317
                title.update();
318
            });
319
            $("#UsageStatsLibrariesInfo").change();
320
        });
321
322
        $("#UsageStatsLibrariesInfo").on('change', function(){
323
            if ( $(this).val() == 1 ) $("#libraries_info").show()
324
            else $("#libraries_info").hide();
325
        });
326
327
    </script>
328
172
</div>
329
</div>
173
</div>
330
</div>
174
<div class="yui-b">
331
<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