✔️ flexible solution that can be used for any future permission
❌ the modifier format is confusing, most people would probably expect a function call instead
{if 'access CiviCRM'|permissionCheck }
<!-- Do something -->
{/if}
✔️ can use the variables easily and call the function whenever we need it
❌ anyone looking at the code might not be sure where the permission variables are coming from
❌ having a over-general init function could become messy
❌ not flexible, new permission checks require new variables
{ initGlobalVariables() }
{if $canAccessCiviCRM}
<!-- Do something -->
{/if}
These would need to be set somewhere that was always called, I thought of the config hook but it seems to be a waste to call this every time and there are problems I found with autoloading classes used in this code from the config hook.
✔️ have a single place to define global template variables
❌ bugs with autoloading
❌ variables used in CiviHR will be defined in SSP
❌ performance
❌ not flexible, new permission checks require new variables
It's possible to set some variables in CRM_Core_Session, such as $isRoot. This would probably mean setting these in civihr_employee_portal after logging in.
✔️ performance
❌ again splitting stuff used in CiviHR that is defined in SSP
❌ not flexible, new permission checks require new variables
{if $session->get('canAccessCiviCRM') }
<!-- Do something -->
{/if}
despite the cons u mentioned, I see that the first option is fine enough unlike the others which looks very messy to me