@@ -, +, @@ based, easily editable help system and it can be created / edited directly from the help page (based on a user permission). --- edithelp.pl | 13 +---- help.pl | 50 +++++++++++++++++-- ...dd_system_preference_CustomOnlineHelpStaff.perl | 2 +- .../bug_18483_news-driven-help-system.perl | 17 +++++++ installer/data/mysql/sysprefs.sql | 2 +- .../intranet-tmpl/prog/en/includes/header.inc | 3 +- .../intranet-tmpl/prog/en/includes/help-bottom.inc | 15 ++++-- .../intranet-tmpl/prog/en/includes/help-top.inc | 55 ++++++++++++++------- .../intranet-tmpl/prog/en/includes/permissions.inc | 1 + .../prog/en/modules/admin/preferences/admin.pref | 1 + .../intranet-tmpl/prog/en/modules/help/mainpage.tt | 5 +- .../prog/en/modules/help/nohelptext.tt | 2 + .../prog/en/modules/tools/koha-news.tt | 56 +++++++++++++++++++--- .../prog/en/modules/tools/tools-home.tt | 14 ++++-- tools/koha-news.pl | 28 +++++++++-- 15 files changed, 210 insertions(+), 54 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_18483_news-driven-help-system.perl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/help/nohelptext.tt --- a/edithelp.pl +++ a/edithelp.pl @@ -18,6 +18,7 @@ # along with Koha; if not, see . use Modern::Perl; +use C4::Koha; use C4::Output; use C4::Templates; use C4::Auth; @@ -45,17 +46,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( query => $input, type => "intranet", authnotrequired => 0, - flagsrequired => { - catalogue => 1, - circulate => 1, - parameters => 1, - borrowers => 1, - permissions => 1, - reserveforothers => 1, - reserveforself => 1, - editcatalogue => 1, - updatecharges => 1, - }, + flagsrequired => { tools => 'edit_help' }, debug => 1, } ); --- a/help.pl +++ a/help.pl @@ -21,7 +21,8 @@ use strict; use warnings; use C4::Templates; use C4::Output; -# use C4::Auth; +use C4::NewsChannels; # GetNewsToDisplay +use C4::Auth; use C4::Context; use CGI qw ( -utf8 ); @@ -47,24 +48,65 @@ 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('HelpSystem'); + +#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 ); } -my $template = C4::Templates::gettemplate($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); + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => $from, + query => $query, + type => "intranet", + authnotrequired => 0, + } +); + + + + $template->param( referer => $refer, + helpkey => $helpkey, intranetstylesheet => C4::Context->preference("intranetstylesheet"), intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + helpsystem => $helpsys, ); +if ( index($helpsys,'newsbased') != -1 || index ($helpsys,'filebased') != -1 ) { + + 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; --- a/installer/data/mysql/atomicupdate/bug_18472-Add_system_preference_CustomOnlineHelpStaff.perl +++ a/installer/data/mysql/atomicupdate/bug_18472-Add_system_preference_CustomOnlineHelpStaff.perl @@ -1,7 +1,7 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { # you can use $dbh here like: - $dbh->do("INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('HelpSystem', 'filebased', 'filebased', 'Select online help system.', 'multiple')" ); + $dbh->do("INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('HelpSystem', 'filebased', 'filebased|newsbased', 'Select online help system.', 'multiple')" ); $dbh->do("INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('EnableEditingFilebasedHelp', '1', '', 'Enable editing of file based Koha help.', 'yesno')" ); # or perform some test and warn --- a/installer/data/mysql/atomicupdate/bug_18483_news-driven-help-system.perl +++ a/installer/data/mysql/atomicupdate/bug_18483_news-driven-help-system.perl @@ -0,0 +1,17 @@ +$DBversion = 'XXXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + # you can use $dbh here like: + $dbh->do( "UPDATE systempreferences SET VALUE = 'filebased', OPTIONS = 'filebased|newsbased' where variable = 'HelpSystem'" ); + + $dbh->do( "ALTER TABLE opac_news ADD COLUMN helpkey varchar(250) AFTER lang "); + $dbh->do( "INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (13, 'edit_help', 'Edit custom help');" ); + + # or perform some test and warn + # if( !column_exists( 'biblio', 'biblionumber' ) ) { + # warn "There is something wrong"; + # } + + # Always end with this (adjust the bug info) + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 18483 - Customised help: Enhance staff client with news based, easily editable help system)\n"; +} --- a/installer/data/mysql/sysprefs.sql +++ a/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'), -('HelpSystem', 'filebased', 'filebased', 'Select online help system.', 'multiple'), +('HelpSystem', 'filebased|newsbased', 'filebased', 'Select online help system.', 'multiple'), ("INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('EnableEditingFilebasedHelp', '1', '', 'Enable editing of file based Koha help.', 'yesno')" ), ('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'), --- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc @@ -1,3 +1,4 @@ +[% USE Koha %] [% USE Branches %]