} } } if (isset($order)) { $order = $order == 'asc' ? 'ASC' : 'DESC'; } if ($lAdmin->EditAction() && $POST_RIGHT == "W") { foreach ($FIELDS as $ID => $arFields) { if (!$lAdmin->IsUpdated($ID)) { continue; } $DB->StartTransaction(); $ID = IntVal($ID); $arAllowedFieldsForUpdate = array('NAME', 'ACTIVE'); $dataPrimary = array('ID' => $ID); $arData = \Bitrix\Sender\TemplateTable::getRowById($dataPrimary); if ($arData) { foreach ($arFields as $key => $value) { if (in_array($key, $arAllowedFieldsForUpdate)) { $arData[$key] = $value; } } unset($arData['ID']); $dataUpdateDb = \Bitrix\Sender\TemplateTable::update($dataPrimary, $arData); if (!$dataUpdateDb->isSuccess()) { $LAST_ERROR = $dataUpdateDb->getErrorMessages(); $LAST_ERROR = $LAST_ERROR[0]; $lAdmin->AddGroupError(GetMessage("rub_save_error") . " " . $LAST_ERROR, $ID); $DB->Rollback(); } } else {
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); } $isUserHavePhpAccess = $USER->CanDoOperation('edit_php'); $aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("sender_tmpl_edit_tab_main"), "ICON" => "main_user_edit", "TITLE" => GetMessage("sender_tmpl_edit_tab_main_title"))); $tabControl = new CAdminTabControl("tabControl", $aTabs); $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); if (!$isUserHavePhpAccess) { $MESSAGE_OLD = false; if ($ID > 0) { $templateOld = \Bitrix\Sender\TemplateTable::getRowById(array('ID' => $ID)); if ($templateOld) { $MESSAGE_OLD = $templateOld['MESSAGE']; } } $MESSAGE = CMain::ProcessLPA($MESSAGE, $MESSAGE_OLD); } $CONTENT = ''; if (!empty($MESSAGE)) { $CONTENT = $MESSAGE; } $arFields = array("ACTIVE" => $ACTIVE != "Y" ? "N" : "Y", "CONTENT" => $CONTENT, "NAME" => $NAME); if ($ID > 0) { $mailingUpdateDb = \Bitrix\Sender\TemplateTable::update($ID, $arFields); $res = $mailingUpdateDb->isSuccess(); if (!$res) {