- Модуль: learning
- Путь к файлу: ~/bitrix/modules/learning/classes/general/clearnaccessmacroses.php
- Класс: CLearnAccessMacroses
- Вызов: CLearnAccessMacroses::ParseParamsWithUser
static function ParseParamsWithUser ($arParams, $arParserOptions)
{
if ( ! (is_array($arParams) && is_array($arParserOptions)) )
{
throw new LearnException(
'EA_LOGIC: $arParams and $arParserOptions must be arrays',
LearnException::EXC_ERR_ALL_GIVEUP
| LearnException::EXC_ERR_ALL_LOGIC
| LearnException::EXC_ERR_ALL_ACCESS_DENIED);
}
if (array_key_exists('user_id', $arParserOptions))
{
throw new LearnException(
'EA_LOGIC: unexpected user_id in $arParams',
LearnException::EXC_ERR_ALL_GIVEUP
| LearnException::EXC_ERR_ALL_LOGIC
| LearnException::EXC_ERR_ALL_ACCESS_DENIED);
}
$arParserOptions['user_id'] = array(
'type' => 'strictly_castable_to_integer',
'mandatory' => false,
'default_value' => -1 // it means, we must should use current user id
);
// Parse options
try
{
$options = CLearnSharedArgManager::StaticParser(
$arParams,
$arParserOptions
);
}
catch (Exception $e)
{
throw new LearnException(
'EA_OTHER: CLearnSharedArgManager::StaticParser() throws an exception with code: '
. $e->GetCode() . ' and message: ' . $e->GetMessage(),
LearnException::EXC_ERR_ALL_GIVEUP
| LearnException::EXC_ERR_ALL_ACCESS_DENIED);
}
if ($options['user_id'] === -1)
$options['user_id'] = self::GetCurrentUserId();
if ($options['user_id'] < 1)
$options['user_id'] = 0; // Not authorized user
return ($options);
}