require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/im/include.php");
IncludeModuleLangFile(__FILE__);
if (!CModule::IncludeModule("im"))
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
$POST_RIGHT = $APPLICATION->GetGroupRight("im");
if($POST_RIGHT=="D")
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
$res=false;
if($_SERVER["REQUEST_METHOD"] == "POST" && $_REQUEST["Convert"]=="Y")
{
CUtil::JSPostUnescape();
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
$max_execution_time = intval($max_execution_time);
if($max_execution_time <= 0)
$max_execution_time = 10;
COption::SetOptionString("im", "max_execution_time", $max_execution_time);
$converted = isset($_REQUEST['converted'])? intval($_REQUEST['converted']): 0;
$maxMessage = isset($_REQUEST['maxMessage'])? intval($_REQUEST['maxMessage']): 0;
$maxMessagePerStep = isset($_REQUEST['maxMessagePerStep'])? intval($_REQUEST['maxMessagePerStep']): 100;
if ($converted == 0 && $maxMessage == 0)
$maxMessage = CIMConvert::ConvertCount();
CIMConvert::$convertPerStep = 0;
CIMConvert::$converted = $converted;
CIMConvert::DeliveredMessage($maxMessagePerStep, $max_execution_time);
if(CIMConvert::$convertPerStep > 0):
$aboutMinute = ($maxMessage-CIMConvert::$converted)/CIMConvert::$convertPerStep*$max_execution_time/60;
CAdminMessage::ShowMessage(array(
"TYPE" => "PROGRESS",
"HTML" => true,
"MESSAGE" => GetMessage("IM_CONVERT_IN_PROGRESS"),
"DETAILS" => "#PROGRESS_BAR# ".GetMessage("IM_CONVERT_TOTAL")." ".$converted." (".ceil(CIMConvert::$converted/$maxMessage*100)."%, ".GetMessage("IM_CONVERT_ABOUT_TIME")." ".($aboutMinute >= 1? ceil($aboutMinute).' '.GetMessage("IM_CONVERT_ABOUT_TIME_MINUTE") : ceil($aboutMinute*60).' '.GetMessage("IM_CONVERT_ABOUT_TIME_SEC"))." )",
"PROGRESS_TOTAL" => $maxMessage,
"PROGRESS_VALUE" => CIMConvert::$converted,
));
?>