本文整理汇总了PHP中Docebo::User方法的典型用法代码示例。如果您正苦于以下问题:PHP Docebo::User方法的具体用法?PHP Docebo::User怎么用?PHP Docebo::User使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Docebo
的用法示例。
在下文中一共展示了Docebo::User方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkPerm
/**
* @package admin-library
* @subpackage user
* @author Fabio Pirovano <fabio@docebo.com>
* @version $Id:$
*/
function checkPerm($token, $return_value = false, $use_custom_name = false, $use_custom_platform = false)
{
if ($use_custom_name !== false) {
$mod_name = $use_custom_name;
} else {
$mod_name = $GLOBALS['modname'];
}
if ($use_custom_platform !== false) {
$platform_name = $use_custom_platform;
} else {
$platform_name = $_SESSION['current_action_platform'];
}
switch ($token) {
case "OP":
$suff = 'view';
break;
case "NEW":
$suff = 'add';
break;
case "MOD":
$suff = 'mod';
break;
case "REM":
$suff = 'del';
break;
default:
$suff = $token;
}
$role = '/' . ($platform_name != '' ? $platform_name . '/' : '') . 'admin/' . ($mod_name != '' ? $mod_name . '/' : '') . $suff;
// we return true if the user is a godadmin requesting a permission in the framework platform
if (Docebo::User()->getUserLevelId() == ADMIN_GROUP_GODADMIN && (strpos($role, '/admin/') !== false || $platform_name == 'framework')) {
return true;
}
// if alredy asked
if (isset($GLOBALS['role_asked'][$role])) {
if ($GLOBALS['role_asked'][$role]) {
return true;
} elseif ($return_value) {
return false;
} else {
die("You can't access");
}
}
if (Docebo::user()->matchUserRole($role)) {
$GLOBALS['role_asked'][$role] = true;
return true;
} else {
$GLOBALS['role_asked'][$role] = false;
if ($return_value) {
return false;
} else {
die("You can't access");
}
}
}