Skip to content
  • Marcel de Rooy's avatar
    Bug 17989: Include full path logic in _get_template_file · 8c510e1a
    Marcel de Rooy authored and joubu's avatar joubu committed
    
    
    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: default avatarMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
    
    Signed-off-by: default avatarNick Clemens <nick@bywatersolutions.com>
    
    Signed-off-by: default avatarJonathan Druart <jonathan.druart@bugs.koha-community.org>
    8c510e1a