- Модуль: controller
- Путь к файлу: ~/bitrix/modules/controller/classes/general/controllermember.php
- Класс: CAllControllerMember
- Вызов: CAllControllerMember::RunCommand
static function RunCommand($member_id, $command, $arParameters = Array(), $task_id=false, $operation = 'run')
{
/** @global CMain $APPLICATION */
global $APPLICATION;
global $DB;
if(!($arMember = CControllerMember::GetMember($member_id)))
return false;
if($operation == "run_immediate")
{
$arVars = array("command"=>$command);
}
else
{
$command_id = CControllerMember::AddCommand($arMember["MEMBER_ID"], $command, $arParameters, $task_id);
if($command_id !== false)
$arVars = array("command_id" => $command_id);
else
$arVars = array();
}
if(empty($arVars))
{
if($DB->GetErrorMessage() <> '')
$e = new CApplicationException(GetMessage("CTRLR_MEM_ERR3")." ".$DB->GetErrorMessage());
else
$e = new CApplicationException(GetMessage("CTRLR_MEM_ERR2"));
$APPLICATION->ThrowException($e);
return false;
}
$oRequest = new CControllerServerRequestTo($arMember, $operation, $arVars);
/*@var $oResponse CControllerServerResponseFrom*/
if(($oResponse = $oRequest->Send())===false)
return false;
if(!$oResponse->Check())
{
$strError = GetMessage("CTRLR_MEM_ERR2");
if ($oResponse->httpHeaders)
{
$strError .= " ".explode("n", $oResponse->httpHeaders)[0];
}
$e = new CApplicationException($strError);
$APPLICATION->ThrowException($e);
return false;
}
if($oResponse->OK() || preg_match("/^(STP0|FIN)/", $oResponse->text))
return $oResponse->text;
$str = $oResponse->text <> ''? $oResponse->text : $oResponse->status;
$e = new CApplicationException(GetMessage("CTRLR_MEM_ERR3")." ".$str);
$APPLICATION->ThrowException($e);
return false;
}