$ID = intval($ID); // Id of the edited record $message = null; $bVarsFromForm = false; if ($REQUEST_METHOD == "POST" && ($save != "" || $apply != "") && $POST_RIGHT == "W" && check_bitrix_sessid()) { $arError = array(); $NAME = trim($NAME); $arFields = array("ACTIVE" => $ACTIVE != "Y" ? "N" : "Y", "TRACK_CLICK" => $TRACK_CLICK != "Y" ? "N" : "Y", "SORT" => $SORT, "IS_PUBLIC" => $IS_PUBLIC != "Y" ? "N" : "Y", "NAME" => $NAME, "DESCRIPTION" => $DESCRIPTION, "SITE_ID" => $SITE_ID); if ($ID > 0) { $mailingUpdateDb = \Bitrix\Sender\MailingTable::update($ID, $arFields); $res = $mailingUpdateDb->isSuccess(); if (!$res) { $arError = $mailingUpdateDb->getErrorMessages(); } } else { $mailingAddDb = \Bitrix\Sender\MailingTable::add($arFields); if ($mailingAddDb->isSuccess()) { $ID = $mailingAddDb->getId(); $res = $ID > 0; } else { $arError = $mailingAddDb->getErrorMessages(); } } $GROUP = array(); if (isset($GROUP_INCLUDE)) { $GROUP_INCLUDE = explode(',', $GROUP_INCLUDE); trimArr($GROUP_INCLUDE); } else { $GROUP_INCLUDE = array(); } if (isset($GROUP_EXCLUDE)) {