From 5ab49e8fa673e667cd4450fc319d36e5a5a876e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Sun, 23 Apr 2017 00:22:51 +0200 Subject: [PATCH] Bug 18483 - Customised help: Enhance staff client with news based, easily editable help system Koha's staff client has a file based help system with an edit function for customising. However, the edited files have to be saved and restored with each release. Otherwise they are overwritten. As an enhancement or alternative, the existing news system can be used to implement a complementing help system. Similar to the news, the text can be created for all branches or for individual branches. Help is context sensitive (based on the existing help system), and it can be created / edited directly from the help page (based on a user permission). The display can be managed with a system preference (Bug 18472: Add system preference CustomOnlineHelpStaff to hide / select custom online help system). This patch is a first draft. It is not yet ready for testing or sign-off. Amended to resolve minor conflicts with Bug 18472 Amended to expand sysprefs from Bug 18472 --- help.pl | 34 ++++++++++++++- installer/data/mysql/sysprefs.sql | 2 +- .../intranet-tmpl/prog/en/includes/help-bottom.inc | 1 + .../intranet-tmpl/prog/en/includes/help-top.inc | 50 +++++++++++++++------- .../en/modules/admin/preferences/staff_client.pref | 2 + .../prog/en/modules/help/nohelptext.tt | 2 + .../prog/en/modules/tools/koha-news.tt | 23 ++++++++++ tools/koha-news.pl | 14 +++++- 8 files changed, 107 insertions(+), 21 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/help/nohelptext.tt diff --git a/help.pl b/help.pl index ad86a2d..be11129 100755 --- a/help.pl +++ b/help.pl @@ -21,6 +21,7 @@ use strict; use warnings; use C4::Templates; use C4::Output; +use C4::NewsChannels; # GetNewsToDisplay # use C4::Auth; use C4::Context; use CGI qw ( -utf8 ); @@ -47,24 +48,53 @@ C4::Context->interface('intranet'); our $refer = $query->param('url'); $refer = $query->referer() if !$refer || $refer eq 'undefined'; my $from = _help_template_file_of_url($refer); +my $helpkey = substr( $from, 0, rindex( $from, q{.} ) ); my $htdocs = C4::Context->config('intrahtdocs'); -# +my $helpsys = C4::Context->preference('CustomOnlineHelpStaff'); + +#Template for 'classic' Koha help text (filebased) if needed, otherwise no text + # checking that the help file exist, otherwise, display nohelp.tt page -# my ( $theme, $lang ) = C4::Templates::themelanguage( $htdocs, $from, "intranet", $query ); + unless ( -e "$htdocs/$theme/$lang/modules/$from" ) { $from = "help/nohelp.tt"; ( $theme, $lang ) = C4::Templates::themelanguage( $htdocs, $from, "intranet", $query ); } +# Classic Koha help text not used +if ( $helpsys eq 'newsbased' ) { + #Template without classic Koha help text + $from = "help/nohelptext.tt"; + ( $theme, $lang ) = C4::Templates::themelanguage( $htdocs, $from, "intranet", $query ); +} + my $template = C4::Templates::gettemplate($from, 'intranet', $query); $template->param( referer => $refer, + helpkey => $helpkey, intranetstylesheet => C4::Context->preference("intranetstylesheet"), intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), ); +$template->param( helpsys => $helpsys ); + +if ( ($helpsys eq 'newsbased') || ($helpsys eq 'newsbased-and-filebased') ) { + + my $homebranch; + if (C4::Context->userenv) { + $homebranch = C4::Context->userenv->{'branch'}; + } + my $help_from_news = &GetNewsToDisplay('staffhelp', $homebranch); + my $help_from_news_count = scalar @$help_from_news; + $template->param( + help_from_news => $help_from_news, + help_from_news_count => $help_from_news_count, + homebranch => $homebranch + ); +} + my $help_version = C4::Context->preference("Version"); if ( $help_version =~ m|^(\d+)\.(\d{2}).*$| ) { my $version = $1; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index ef65580..68685be 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -114,7 +114,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo'), ('CumulativeRestrictionPeriods',0,NULL,'Cumulate the restriction periods instead of keeping the highest','YesNo'), ('CurrencyFormat','US','US|FR|CH','Determines the display format of currencies. eg: \'36000\' is displayed as \'360 000,00\' in \'FR\' or \'360,000.00\' in \'US\'.','Choice'), -('CustomOnlineHelpStaff', 'filebased', 'none|filebased', 'Select custom online help system for staff client.', 'Choice'), +('CustomOnlineHelpStaff', 'filebased', 'none|filebased|newsbased|newsbased-and-filebased', 'Select custom online help system for staff client.', 'Choice'), ('dateformat','us','metric|us|iso|dmydot','Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd, dmydot dd.mm.yyyy)','Choice'), ('DebugLevel','2','0|1|2','Define the level of debugging information sent to the browser when errors are encountered (set to 0 in production). 0=none, 1=some, 2=most','Choice'), ('decreaseLoanHighHolds',NULL,'','Decreases the loan period for items with number of holds above the threshold specified in decreaseLoanHighHoldsValue','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/help-bottom.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/help-bottom.inc index 7424b80..b07f9e7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/help-bottom.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/help-bottom.inc @@ -6,5 +6,6 @@ [% END %] + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc index ff6aeb8..2d6326f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc @@ -1,21 +1,39 @@ [% USE Koha %] +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] Online help - - - - -[% INCLUDE intranetstylesheet.inc %] -[% IF ( bidi ) %] - -[% END %] - - - - - - - - +[% INCLUDE 'doc-head-close.inc' %] + + +
+

Help for [% Branches.GetName( homebranch ) %]

+ [% FOREACH helpitem IN help_from_news %] + [% IF (helpitem.helpkey == helpkey) || (helpitem.helpkey == 'all') %] +
+

[% helpitem.title %] [% helpitem.helpkey %]

+
[% helpitem.content %]
+
[% helpitem.newdate %]
+ +
+ [% END %] + [% END %] +
+

+ New custom help for this page + Key is: [% helpkey %]

+

+ New custom help for all pages + Key is: all

+
+
+ +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref index f1c0bb1..e774c13 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref @@ -156,6 +156,8 @@ Staff Client: choices: none: "None" filebased: "File based" + newsbased: "News based" + newsbased-and-filebased: "News based and file based combined" - - pref: IntranetCatalogSearchPulldown choices: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/help/nohelptext.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/help/nohelptext.tt new file mode 100644 index 0000000..ea6af02 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/help/nohelptext.tt @@ -0,0 +1,2 @@ +[% INCLUDE 'help-top.inc' %] +[% INCLUDE 'help-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt index dd1ae84..393e857 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt @@ -119,6 +119,11 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]
[% ELSE %] [% END %] + [% IF ( default_lang == "staffhelp" ) %] + + [% ELSE %] + + [% END %] [% FOREACH lang_lis IN lang_list %] [% IF ( lang_lis.language == default_lang ) %] @@ -161,6 +166,17 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %] [% END %] +
  • + + [% IF ( new_detail.helpkey ) %] + + [% ELSIF ( helpkey ) %] + + [% ELSE %] + + [% END %] + Used for news driven custom help system +
  • @@ -189,6 +205,11 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %] [% ELSE %] [% END %] + [% IF ( lang == "staffhelp" ) %] + + [% ELSE %] + + [% END %] [% FOREACH lang_lis IN lang_list %] [% IF ( lang_lis.language == lang ) %] @@ -240,6 +261,8 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %] Slip [% CASE "" %] All + [% CASE "staffhelp" %] + Staff help [% opac_new.helpkey %] [% CASE %] OPAC ([% opac_new.lang %]) [% END %] diff --git a/tools/koha-news.pl b/tools/koha-news.pl index 61c3ec6..9cd2adc 100755 --- a/tools/koha-news.pl +++ b/tools/koha-news.pl @@ -45,6 +45,7 @@ if ( $cgi->param('expirationdate') ) { } my $timestamp = output_pref({ dt => dt_from_string( scalar $cgi->param('timestamp') ), dateformat => 'iso', dateonly => 1 }); my $number = $cgi->param('number'); +my $helpkey = $cgi->param('helpkey'); my $lang = $cgi->param('lang'); my $branchcode = $cgi->param('branch'); my $error_message = $cgi->param('error_message'); @@ -99,11 +100,18 @@ if ( $op eq 'add_form' ) { $template->{VARS}->{'new_detail'} = $new_detail; } else { - $template->param( op => 'add' ); + $template->param( + op => 'add', + helpkey => $helpkey + ); + } } elsif ( $op eq 'add' ) { +warn "OPACADD"; if ($title) { +warn "IN TITLE"; +warn $helpkey; add_opac_new( { title => $title, @@ -112,6 +120,7 @@ elsif ( $op eq 'add' ) { expirationdate => $expirationdate, timestamp => $timestamp, number => $number, + helpkey => $helpkey, branchcode => $branchcode, borrowernumber => $borrowernumber, } @@ -131,6 +140,7 @@ elsif ( $op eq 'edit' ) { lang => $lang, expirationdate => $expirationdate, timestamp => $timestamp, + helpkey => $helpkey, number => $number, branchcode => $branchcode, } @@ -145,7 +155,7 @@ elsif ( $op eq 'del' ) { else { - my ( $opac_news_count, $opac_news ) = &get_opac_news( undef, $lang, $branchcode ); + my ( $opac_news_count, $opac_news ) = &get_opac_news( undef, 'staffhelp', $branchcode ); foreach my $new ( @$opac_news ) { next unless $new->{'expirationdate'}; -- 2.1.4