public static function StaticParser($arOptions, $arParseParams)
 {
     try {
         $oArgManager = new CLearnSharedArgManager($arOptions, $arParseParams);
         $rc = $oArgManager->GetParsedOptions();
         unset($oArgManager);
     } catch (Exception $e) {
         throw new LearnException('EA_PARAMS: ArgManager at line: ' . $e->GetLine(), LearnException::EXC_ERR_ALL_PARAMS);
     }
     return $rc;
 }
Exemple #2
0
 protected static function _funcDelete_ParseOptions($lesson_id)
 {
     $simulate = false;
     // don't simulate by default
     $check_permissions = true;
     // check rights by default
     $user_id = -1;
     // -1 means 'current logged user'
     if (is_array($lesson_id)) {
         // Parse options
         $options = CLearnSharedArgManager::StaticParser($lesson_id, array('lesson_id' => array('type' => 'strictly_castable_to_integer', 'mandatory' => true), 'simulate' => array('type' => 'boolean', 'mandatory' => false, 'default_value' => $simulate), 'check_permissions' => array('type' => 'boolean', 'mandatory' => false, 'default_value' => $check_permissions), 'user_id' => array('type' => 'strictly_castable_to_integer', 'mandatory' => false, 'default_value' => $user_id)));
         $lesson_id = $options['lesson_id'];
         $simulate = $options['simulate'];
         $check_permissions = $options['check_permissions'];
         $user_id = $options['user_id'];
     } else {
         $lesson_id = (int) $lesson_id;
     }
     if ($check_permissions) {
         if ($user_id === -1) {
             global $USER;
             if (!(is_object($USER) && method_exists($USER, 'GetID'))) {
                 throw new LearnException('EA_OTHER: $USER isn\'t available.', LearnException::EXC_ERR_ALL_GIVEUP | LearnException::EXC_ERR_ALL_LOGIC);
             }
             $user_id = (int) $USER->GetID();
         }
     }
     return array($lesson_id, $simulate, $check_permissions, $user_id);
 }
 /**
  * Parse params throughs CLearnSharedArgManager::StaticParser(),
  * but includes shared field 'user_id' and automatically replace
  * user_id === -1 to user_id = $USER->GetID();
  */
 protected 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);
     // 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();
     }
     return $options;
 }