SuiteCRM-Core/include/Smarty/plugins/function.suite_check_access.php
Dillon-Brown 8e4cc94994 Squashed 'public/legacy/' content from commit 817a12dc0
git-subtree-dir: public/legacy
git-subtree-split: 817a12dc0c30c189f56d5cb1f7dc37a9631bdbe3
2021-03-31 15:37:32 +01:00

42 lines
1 KiB
PHP

<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty {suite_check_access} function plugin
*
* Type: function<br>
* Name: suite_check_access<br>
* Purpose: Check if the current user has access to a record
*
* @author Jose C. Massón <jose AT gcoop DOT coop>
* @param array
* @param Smarty
*/
function smarty_function_suite_check_access($params, &$smarty)
{
if (empty($params['module'])) {
$smarty->trigger_error("sugar_check_access: missing 'module' parameter");
return;
}
if (empty($params['record'])) {
$smarty->trigger_error("sugar_check_access: missing 'record' parameter");
return;
}
if (empty($params['action'])) {
$smarty->trigger_error("sugar_check_access: missing 'module' parameter");
return;
}
$ret = false;
$bean = BeanFactory::getBean($params['module'], $params['record']);
if (is_subclass_of($bean, 'SugarBean')) {
$ret = (bool) $bean->ACLAccess($params['action']);
}
return $ret;
}