public 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 (strlen($DB->GetErrorMessage()) > 0) { $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()) { $e = new CApplicationException(GetMessage("CTRLR_MEM_ERR2")); $APPLICATION->ThrowException($e); return false; } if ($oResponse->OK() || preg_match("/^(STP0|FIN)/", $oResponse->text)) { return $oResponse->text; } $str = strlen($oResponse->text) ? $oResponse->text : $oResponse->status; $e = new CApplicationException(GetMessage("CTRLR_MEM_ERR3") . " " . $str); $APPLICATION->ThrowException($e); return false; }