GetGroupRight("sender"); if($POST_RIGHT=="D") $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); $sTableID = "tbl_sender_mailing_chain"; $MAILING_ID = intval($_REQUEST["MAILING_ID"]); $ID = intval($_REQUEST["ID"]); if($_REQUEST["action"]=="copy" && check_bitrix_sessid() && $POST_RIGHT>="W") { $copiedId = \Bitrix\Sender\MailingChainTable::copy($ID); if ($copiedId) { \Bitrix\Sender\MailingChainTable::update(array('ID' => $copiedId), array('CREATED_BY' => $USER->GetID())); LocalRedirect("sender_mailing_chain_edit.php?MAILING_ID=" . $MAILING_ID . "&ID=" . $copiedId . "&mess=copied"); } } if($_REQUEST["action"]=="send_to_me" && check_bitrix_sessid() && $POST_RIGHT>="W") { $arResult = array(); $isChainNotFound = true; $sendException = null; $filter = array(); if(isset($_REQUEST["IS_TRIGGER"]) && $_REQUEST["IS_TRIGGER"] == 'Y') { $filter['=MAILING_ID'] = $MAILING_ID; $filter['=IS_TRIGGER'] = 'Y'; } else { $filter['=ID'] = $ID; } require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php"); $adminMessage = new CAdminMessage(''); $sendToMeAddr = $_POST["send_to_me_addr"]; $sendToMeAddr = explode(",", $sendToMeAddr); try { $mailingChainDb = MailingChainTable::getList(array( 'select' => array('ID'), 'filter' => $filter, 'order' => array('TIME_SHIFT' => 'ASC', 'ID' => 'ASC') )); while($mailingChain = $mailingChainDb->fetch()) { $isChainNotFound = false; foreach($sendToMeAddr as $address) { $address = trim($address); if(!empty($address)) { $sendResult = \Bitrix\Sender\PostingManager::sendToAddress($mailingChain['ID'], $address); if ($sendResult == \Bitrix\Sender\PostingManager::SEND_RESULT_SENT) { $arResult[] = $address; MailingChainTable::setEmailToMeList($address); } } } } } catch(Exception $e) { $sendException = $e; } if($isChainNotFound) { $adminMessage->ShowMessage(GetMessage("MAILING_ADM_POST_NOT_FOUND")); } elseif($sendException) { $adminMessage->ShowMessage($sendException->getMessage()); } else { $arResult = array_unique($arResult); if(!empty($arResult)) $adminMessage->ShowNote(GetMessage("sender_mailing_chain_adm_test_send_success").implode(', ', $arResult)); else $adminMessage->ShowMessage(GetMessage("sender_mailing_chain_adm_test_send_empty")); } require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php"); } if(check_bitrix_sessid() && $POST_RIGHT>="W" && isset($_REQUEST["action"]) && in_array($_REQUEST["action"], array('js_pause', 'js_stop', 'js_send_error'))) { require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php"); $message = null; $mailingChain = MailingChainTable::getRowById(array('ID' => $ID)); if($_REQUEST["action"] == "js_pause" && in_array($mailingChain['STATUS'], array(MailingChainTable::STATUS_SEND, MailingChainTable::STATUS_WAIT))) { MailingChainTable::update(array('ID' => $ID), array('STATUS' => MailingChainTable::STATUS_PAUSE)); $message = GetMessage("MAILING_ADM_SENDING_PAUSE"); } elseif($_REQUEST["action"] == "js_stop" && $mailingChain['STATUS'] == MailingChainTable::STATUS_PAUSE) { MailingChainTable::update(array('ID' => $ID), array('STATUS' => MailingChainTable::STATUS_END)); $message = GetMessage("MAILING_ADM_SENDING_STOP"); } elseif($_REQUEST["action"] == "js_send_error" && MailingChainTable::canReSendErrorRecipients($ID)) { MailingChainTable::prepareReSendErrorRecipients($ID); $message = GetMessage("MAILING_ADM_SENDING_PLANING"); } if($message) { $adminMessage = new CAdminMessage(array("MESSAGE"=>$message, "TYPE"=>"OK")); echo $adminMessage->show(); } ?>