/** * @global CUser $USER * @global CMain $APPLICATION */ require_once(__DIR__."/../include/prolog_admin_before.php"); require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/prolog.php"); define("HELP_FILE", "utilities/log_notification_edit.php"); if(!$USER->CanDoOperation('view_event_log')) $APPLICATION->AuthForm(Loc::getMessage("ACCESS_DENIED")); use Bitrix\Main; use Bitrix\Main\Localization\Loc; use Bitrix\Main\Text\HtmlFilter; use Bitrix\Main\EventLog; $aTabs = array( array("DIV" => "edit1", "TAB" => Loc::getMessage("notification_edit_conditions"), "ICON" => "message_edit", "TITLE" => Loc::getMessage("notification_edit_conditions_title")), array("DIV" => "edit2", "TAB" => Loc::getMessage("notification_edit_actions"), "ICON" => "message_edit", "TITLE" => Loc::getMessage("notification_edit_actions_title")), ); $tabControl = new CAdminTabControl("notifyTabControl", $aTabs); $request = Main\Context::getCurrent()->getRequest(); $errors = []; $actions = []; $ID = intval($request["ID"]); $COPY_ID = intval($request["COPY_ID"]); if($request->isPost() && ($request["save"] <> '' || $request["apply"] <> '') && check_bitrix_sessid()) { if(is_array($request->getPost("ACTIONS"))) { $actions = $request->getPost("ACTIONS"); } $notification = new EventLog\Notification($ID); $notification->setFromArray($request->getPostList()->toArray()); $notification->setActionsFromArray($actions); $result = $notification->save(); if($result instanceof Main\ORM\Data\AddResult) { $ID = $result->getId(); } if($result->isSuccess()) { if($request["save"] <> '') LocalRedirect(BX_ROOT."/admin/log_notifications.php?lang=".LANGUAGE_ID); else LocalRedirect(BX_ROOT."/admin/log_notification_edit.php?lang=".LANGUAGE_ID."&ID=".$ID."&".$tabControl->ActiveTabParam()); } else { $errors = $result->getErrorMessages(); } } $notificationId = ($COPY_ID > 0? $COPY_ID : $ID); $notification = new EventLog\Notification($notificationId); $notification->fill(); $notification->fillActions(); if(!empty($errors)) { //set values from the form $notification->setFromArray($request->getPostList()->toArray()); $notification->setActionsFromArray($actions); } $APPLICATION->SetTitle(($ID > 0? Loc::getMessage("notification_edit_title_edit") : Loc::getMessage("notification_edit_title_add"))); require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/prolog_admin_after.php"); $aMenu = array( array( "TEXT" => Loc::getMessage("notification_edit_list"), "LINK" => "log_notifications.php?lang=".LANGUAGE_ID, "TITLE" => Loc::getMessage("notification_edit_list_title"), "ICON" => "btn_list" ) ); if($ID > 0) { $aMenu[] = array("SEPARATOR"=>"Y"); $aMenu[] = array( "TEXT" => Loc::getMessage("notification_edit_add"), "LINK" => "log_notification_edit.php?lang=".LANGUAGE_ID, "TITLE" => Loc::getMessage("notification_edit_add_title"), "ICON" => "btn_new" ); $aMenu[] = array( "TEXT" => Loc::getMessage("notification_edit_copy"), "LINK" => "log_notification_edit.php?lang=".LANGUAGE_ID."©_ID=".$ID, "TITLE" => Loc::getMessage("notification_edit_copy_title"), "ICON" => "btn_copy" ); $aMenu[] = array( "TEXT" => Loc::getMessage("notification_edit_delete"), "LINK" => "javascript:if(confirm('".CUtil::JSEscape(Loc::getMessage("notification_edit_delete_conf"))."')) window.location='log_notifications.php?ID=".$ID."&lang=".LANGUAGE_ID."&".bitrix_sessid_get()."&action_button=delete';", "TITLE" => Loc::getMessage("notification_edit_delete_title"), "ICON" => "btn_delete" ); } $context = new CAdminContextMenu($aMenu); $context->Show(); if(!empty($errors)) { CAdminMessage::ShowMessage(join("\n", $errors)); } ?>