Bug 14608 - HEA : add possibility of sharing usage statistics [squashed]

This patch set adds:
- a reference to Hea at the end of the installation process
- a link to the new page from the admin home page
- a new page to easily configure shared statistics

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Mason James <mtj@kohaaloha.com>
This commit is contained in:
Jonathan Druart 2016-12-20 22:29:53 +00:00 committed by Mason James
parent 16f7a12a90
commit 9f01cbfe65
5 changed files with 438 additions and 0 deletions

58
admin/usage_statistics.pl Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/perl
# This file is part of Koha.
#
# 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 Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth;
use C4::Output;
use Koha::DateUtils qw( dt_from_string output_pref );
my $query = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "admin/usage_statistics.tt",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { parameters => '*' },
debug => 1,
}
);
my $op = $query->param('op') || q||;
if ( $op eq 'update' ) {
my $UsageStats = $query->param('UsageStats');
my $UsageStatsCountry = $query->param('UsageStatsCountry');
my $UsageStatsLibraryName = $query->param('UsageStatsLibraryName');
my $UsageStatsLibraryType = $query->param('UsageStatsLibraryType');
my $UsageStatsLibraryUrl = $query->param('UsageStatsLibraryUrl');
C4::Context->set_preference('UsageStats', $UsageStats);
C4::Context->set_preference('UsageStatsCountry', $UsageStatsCountry);
C4::Context->set_preference('UsageStatsLibraryName', $UsageStatsLibraryName);
C4::Context->set_preference('UsageStatsLibraryType', $UsageStatsLibraryType);
C4::Context->set_preference('UsageStatsLibraryUrl', $UsageStatsLibraryUrl);
}
if ( C4::Context->preference('UsageStatsLastUpdateTime') ) {
my $dt = DateTime->from_epoch( epoch => C4::Context->preference('UsageStatsLastUpdateTime'));
$template->param(UsageStatsLastUpdateTime => output_pref($dt) );
}
output_html_with_http_headers $query, $cookie, $template->output;

View File

@ -0,0 +1,196 @@
[% SET countries = [
"Afghanistan",
"Albania",
"Algeria",
"Andorra",
"Angola",
"Antigua & Deps",
"Argentina",
"Armenia",
"Australia",
"Austria",
"Azerbaijan",
"Bahamas",
"Bahrain",
"Bangladesh",
"Barbados",
"Belarus",
"Belgium",
"Belize",
"Benin",
"Bhutan",
"Bolivia",
"Bosnia Herz.",
"Botswana",
"Brazil",
"Brunei",
"Bulgaria",
"Burkina",
"Burundi",
"Cambodia",
"Cameroon",
"Canada",
"Cape Verde",
"Centr. Afr. Rep",
"Chad",
"Chile",
"China",
"Colombia",
"Comoros",
"Congo",
"Costa Rica",
"Croatia",
"Cuba",
"Cyprus",
"Czech Republic",
"Denmark",
"Djibouti",
"Dominica",
"Dominican Rep.",
"East Timor",
"Ecuador",
"Egypt",
"El Salvador",
"Equator. Guinea",
"Eritrea",
"Estonia",
"Ethiopia",
"Fiji",
"Finland",
"France",
"Gabon",
"Gambia",
"Georgia",
"Germany",
"Ghana",
"Greece",
"Grenada",
"Guatemala",
"Guinea",
"Guinea-Bissau",
"Guyana",
"Haiti",
"Honduras",
"Hungary",
"Iceland",
"India",
"Indonesia",
"Iran",
"Iraq",
"Ireland",
"Israel",
"Italy",
"Ivory Coast",
"Jamaica",
"Japan",
"Jordan",
"Kazakhstan",
"Kenya",
"Kiribati",
"Korea North",
"Korea South",
"Kosovo",
"Kuwait",
"Kyrgyzstan",
"Laos",
"Latvia",
"Lebanon",
"Lesotho",
"Liberia",
"Libya",
"Liechtenstein",
"Lithuania",
"Luxembourg",
"Macedonia",
"Madagascar",
"Malawi",
"Malaysia",
"Maldives",
"Mali",
"Malta",
"Marshall Isl.",
"Mauritania",
"Mauritius",
"Mexico",
"Micronesia",
"Moldova",
"Monaco",
"Mongolia",
"Montenegro",
"Morocco",
"Mozambique",
"Myanmar",
"Namibia",
"Nauru",
"Nepal",
"Netherlands",
"New Zealand",
"Nicaragua",
"Niger",
"Nigeria",
"Norway",
"Oman",
"Pakistan",
"Palau",
"Panama",
"Papua N. Guinea",
"Paraguay",
"Peru",
"Philippines",
"Poland",
"Portugal",
"Qatar",
"Romania",
"Russian Fed.",
"Rwanda",
"St Kitts & Nev.",
"St Lucia",
"Saint Vincent",
"Samoa",
"San Marino",
"Sao Tome",
"Saudi Arabia",
"Senegal",
"Serbia",
"Seychelles",
"Sierra Leone",
"Singapore",
"Slovakia",
"Slovenia",
"Solomon Islands",
"Somalia",
"South Africa",
"Spain",
"Sri Lanka",
"Sudan",
"Suriname",
"Swaziland",
"Sweden",
"Switzerland",
"Syria",
"Taiwan",
"Tajikistan",
"Tanzania",
"Thailand",
"Togo",
"Tonga",
"Trinidad & Tob.",
"Tunisia",
"Turkey",
"Turkmenistan",
"Tuvalu",
"Uganda",
"Ukraine",
"UAE",
"United Kingdom",
"USA",
"Uruguay",
"Uzbekistan",
"Vanuatu",
"Vatican City",
"Venezuela",
"Vietnam",
"Yemen",
"Zambia",
"Zimbabwe",
] %]

View File

@ -120,6 +120,8 @@
<dt><a href="/cgi-bin/koha/admin/sms_providers.pl">SMS cellular providers</a></dt>
<dd>Define a list of cellular providers for sending SMS messages via email.</dd>
[% END %]
<dt><a href="/cgi-bin/koha/admin/usage_statistics.pl">Share your usage statistics</a></dt>
<dd>Share with the Koha community the usage statistics of your Koha installation.</dd>
</dl>
</div>
</div>

View File

@ -0,0 +1,178 @@
[% USE Koha %]
[% USE KohaDates %]
[% USE Price %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; Koha usage statistics</title>
[% INCLUDE 'doc-head-close.inc' %]
[% INCLUDE 'calendar.inc' %]
</head>
<body id="admin_usage_statistics" class="admin">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Usage statistics</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
[% FOR m IN messages %]
<div class="dialog [% m.type %]">
[% SWITCH m.code %]
[% CASE 'error_on_update' %]
An error occurred when updating this patron category. Perhaps it already exists.
[% CASE 'error_on_insert' %]
An error occurred when inserting this patron category. The patron category might already exist.
[% CASE 'error_on_delete' %]
An error occurred when deleting this patron category. Check the logs.
[% CASE 'success_on_update' %]
Patron category updated successfully.
[% CASE 'success_on_insert' %]
Patron category inserted successfully.
[% CASE 'success_on_delete' %]
Patron category deleted successfully.
[% CASE 'already_exists' %]
This patron category already exists.
[% CASE %]
[% m.code %]
[% END %]
</div>
[% END %]
[% IF NOT Koha.Preference('UsageStats') %]
<div class="dialog message">You are not sharing any data with the Koha community</div>
[% END %]
<form id="category_form" action="/cgi-bin/koha/admin/usage_statistics.pl" method="post">
<h1>Modify the statistics you share with the Koha community</h1>
<fieldset class="rows">
<ol>
<li>
<label for="UsageStats">Share my Koha usage statistics: </label>
<select name="UsageStats" id="UsageStats">
[% IF Koha.Preference('UsageStats') %]
<option value="1" selected="selected">Yes</option>
<option value="0">No</option>
[% ELSE %]
<option value="1">Yes</option>
<option value="0" selected="selected">No</option>
[% END %]
</select>
</li>
<li>
<label for="UsageStatsCountry">Your country: </label>
[% SET UsageStatsCountry = Koha.Preference('UsageStatsCountry') %]
[% SET IsUsageStatsCountryValid = 0 %]
[% IF NOT UsageStatsCountry %]
[% SET IsUsageStatsCountryValid = 1 %]
[% END %]
[% PROCESS 'country-list.inc' %]
<select name="UsageStatsCountry" id="UsageStatsCountry">
<option value="">&nbsp;</option>
[% FOR country IN countries %]
[% IF country == UsageStatsCountry %]
<option value="[% country %]" selected="selected">[% country %]</option>
[% SET IsUsageStatsCountryValid = 1 %]
[% ELSE %]
<option value="[% country %]">[% country %]</option>
[% END %]
[% END %]
</select>
[% UNLESS IsUsageStatsCountryValid %]
Note: The value of your system preference 'UsageStatsCountry' is not valid ([% UsageStatsCountry %]).
Please select a valid one.
[% END %]
</li>
<li>
<label for="UsageStatsLibraryName">Library name: </label>
<input type="text" value="[% Koha.Preference('UsageStatsLibraryName') %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
</li>
<li>
<label for="UsageStatsLibraryType">Library type: </label>
[% SET UsageStatsLibraryType = Koha.Preference('UsageStatsLibraryType') %]
<select name="UsageStatsLibraryType" id="UsageStatsLibraryType">
<option value="">&nbsp;</option>
[% IF UsageStatsLibraryType == 'public' %]
<option value="public" selected="selected">Public</option>
[% ELSE %]
<option value="public">Public</option>
[% END %]
[% IF UsageStatsLibraryType == 'school' %]
<option value="school" selected="selected">School</option>
[% ELSE %]
<option value="school">School</option>
[% END %]
[% IF UsageStatsLibraryType == 'academic' %]
<option value="academic" selected="selected">Academic</option>
[% ELSE %]
<option value="academic">Academic</option>
[% END %]
[% IF UsageStatsLibraryType == 'research' %]
<option value="research" selected="selected">Research</option>
[% ELSE %]
<option value="research">Research</option>
[% END %]
[% IF UsageStatsLibraryType == 'private' %]
<option value="private" selected="selected">Private</option>
[% ELSE %]
<option value="private">Private</option>
[% END %]
[% IF UsageStatsLibraryType == 'societyAssociation' %]
<option value="societyAssociation" selected="selected">Society or association</option>
[% ELSE %]
<option value="societyAssociation">Society or association</option>
[% END %]
[% IF UsageStatsLibraryType == 'corporate' %]
<option value="corporate" selected="selected">Corporate</option>
[% ELSE %]
<option value="corporate">Corporate</option>
[% END %]
[% IF UsageStatsLibraryType == 'government' %]
<option value="government" selected="selected">Government</option>
[% ELSE %]
<option value="government">Government</option>
[% END %]
[% IF UsageStatsLibraryType == 'religiousOrg' %]
<option value="religiousOrg" selected="selected">Religious organization</option>
[% ELSE %]
<option value="religiousOrg">Religious organization</option>
[% END %]
[% IF UsageStatsLibraryType == 'subscription' %]
<option value="subscription" selected="selected">Subscription</option>
[% ELSE %]
<option value="subscription">Subscription</option>
[% END %]
</select>
</li>
<li>
<label for="UsageStatsLibraryUrl">Library URL: </label>
<input type="text" name="UsageStatsLibraryUrl" value="[% Koha.Preference('UsageStatsLibraryUrl') %]" id="UsageStatsLibraryUrl" />
</li>
<li>
<span class="label">Last update: </span>
[% IF UsageStatsLastUpdateTime %]
[% UsageStatsLastUpdateTime %]
[% ELSE %]
Your data have never been shared
[% END %]
</li>
</ol>
</fieldset>
<fieldset class="action">
<input type="hidden" name="op" value="update" />
<input type="submit" value="Update your statistics usage" />
<a class="cancel" href="/cgi-bin/koha/admin/usage_statistics.pl">Cancel</a>
</fieldset>
</form>
</div>
</div>
<div class="yui-b">
[% INCLUDE 'admin-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -173,6 +173,10 @@
[% END %]
<h3>All done!</h3>
<p>Installation complete.<br />
<p>
You can help the Koha community by sharing your statistics with us.
<br>If you wish to share some of your data, please enable the functionality in the "Share your usage statistics" section of the admin module.
</p>
<p>Click on 'Finish' to complete and load the Koha Staff Interface.
<form name="finish">
<input type="hidden" name="step" value="3" />