本文整理匯總了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");
}
}
}