Bug 17989: Include full path logic in _get_template_file
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 25 Jan 2017 09:22:13 +0000 (10:22 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 1 Nov 2017 16:10:17 +0000 (13:10 -0300)
commit8c510e1a92a4ed76de69748bbda91a33b5edd3cf
tree6c6f34b2a7d3366ed6f6a3f50173873a69e2df0e
parent7703723508195ca116e2ea7d766ff741149d2efc
Bug 17989: Include full path logic in _get_template_file

Similar to the full path test in sub themelanguage, this patch makes a
change in _get_template_file. This allows you to pass a template
outside the modules directory to get_template_and_user. (Note: the sub
badtemplatecheck already blocks bad paths.)

Especially, this would be helpful for plugins using templates. As can be
seen in Templates.pm, a change was made earlier to overwrite the filename
for a plugin in sub gettemplate. This exception can now be removed.

Also note the small change in Koha/Plugin/Base.pm; mbf_path is already
absolute and if we pass a full path, we do not need it. This allows use of
a regular Koha template or a shared template between plugins (as long as
badtemplatecheck allows the path).

What are the side-effects of this change?
[1] We should not pass absolute paths if we mean relative ones.
    A follow-up patch deals with one occurrence in the codebase.
    No regressions for regular use.
[2] Plugins can call get_template_and_user directly or go via get_template
    in Koha/Plugin/Base (absolute paths don't go via mbf_path).

Note: replaced two single quotes in Auth.pm to show template name in test
description.

Test plan:
[1] Open some page on OPAC or staff client to trigger a template.
[2] Run t/db_dependent/Auth.t to verify not allowing some bad templates.
[3] Run t/db_dependent/Templates.t to verify an absolute path.
[4] Run t/db_dependent/Plugins.t to verify using templates in a plugin.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Auth.pm
C4/Templates.pm
Koha/Plugins/Base.pm
opac/maintenance.pl
t/db_dependent/Auth.t
t/db_dependent/Plugins.t
t/db_dependent/Templates.t