/** * This is an entry point for running any task.* rest method */ public static function __callStatic($transitMethodName, $args) { global $APPLICATION, $USER; $APPLICATION->resetException(); if (!self::$inited) { self::_init(); } $arFuncNameParts = explode(self::delimiter, $transitMethodName, 2); $className = $arFuncNameParts[0]; $methodName = $arFuncNameParts[1]; $returnValue = null; $arMessages = array(); $parsedReturnValue = null; $withoutExceptions = false; try { if (!in_array($className, self::$arAllowedClasses, true) && !isset(self::$allowedSpecialClasses[$className])) { throw new Exception('Unknown REST-method signature given'); } $methodArgs = array(); foreach ($args[0] as $value) { $methodArgs[] = $value; } /** @noinspection PhpUndefinedMethodInspection */ list($returnValue, $dbResult) = $className::runRestMethod((int) $USER->getId(), $methodName, $methodArgs, self::getNavData($args[1])); $parsedReturnValue = self::_parseReturnValue($className, $methodName, $returnValue, array('SERVER' => $args[2])); if ($dbResult !== null) { $parsedReturnValue = self::setNavData($parsedReturnValue, $dbResult); } $withoutExceptions = true; } catch (CTaskAssertException $e) { $arMessages[] = array('id' => 'TASKS_ERROR_ASSERT_EXCEPTION', 'text' => 'TASKS_ERROR_ASSERT_EXCEPTION'); } catch (TasksException $e) { $errCode = $e->getCode(); $errMsg = $e->getMessage(); if ($e->GetCode() & TasksException::TE_FLAG_SERIALIZED_ERRORS_IN_MESSAGE) { $arMessages = unserialize($errMsg); } else { $arMessages[] = array('id' => 'TASKS_ERROR_EXCEPTION_#' . $errCode, 'text' => 'TASKS_ERROR_EXCEPTION_#' . $errCode . '; ' . $errMsg . '; ' . TasksException::renderErrorCode($e)); } } catch (Exception $e) { $errMsg = $e->getMessage(); if ($errMsg !== '') { $arMessages[] = array('text' => $errMsg, 'id' => 'TASKS_ERROR'); } } if ($withoutExceptions) { return $parsedReturnValue; } else { self::_emitError($arMessages); throw new Exception(); } }
$arArgs = array($_POST['REASON']); } elseif ($action === 'delegate') { $arArgs = array($_REQUEST['USER_ID']); } call_user_func_array(array($oTask, $arMap[$action]), $arArgs); } } } catch (Exception $e) { $errCode = $e->getCode(); $strError = GetMessage('TASKS_FAILED_TO_DO_ACTION'); if ($e instanceof TasksException) { if ($errCode & TasksException::TE_ACCESS_DENIED || $errCode & TasksException::TE_ACTION_NOT_ALLOWED) { $strError .= ' (' . GetMessage('TASKS_ACTION_NOT_ALLOWED') . ')'; } } else { $strError .= ' (errCode #' . TasksException::renderErrorCode($e) . ')'; } if ($arResult["IS_IFRAME"]) { ShowInFrame($this, true, $strError); } else { ShowError($strError); } return; } if ($redirectTo) { LocalRedirect($redirectTo); } } LocalRedirect($APPLICATION->GetCurPageParam("CALLBACK=CHANGED", array("ACTION", "sessid", "ELAPSED_ID"))); } if ($arTask) {