public static IHtmlControl GetAddPanel(BasketballContext context, SiteState state, LightObject user, LightObject collocutor, bool sendFromUserView) { if (user == null) { return(null); } if (user.Id == collocutor.Id) { return(null); } IHtmlControl editPanel = null; if (state.BlockHint == "messageAdd") { string commentValue = BasketballHlp.AddCommentFromCookie(); editPanel = new HPanel( new HTextArea("messageContent", commentValue).BoxSizing().Width("100%") .Height("10em").MarginTop(5).MarginBottom(5), Decor.Button("отправить") .OnClick(BasketballHlp.AddCommentToCookieScript("messageContent")) .Event("message_add_save", "messageData", delegate(JsonData json) { string content = json.GetText("messageContent"); if (StringHlp.IsEmpty(content)) { return; } DialogueHlp.SendMessage(context, user.Id, collocutor.Id, content); state.BlockHint = ""; BasketballHlp.ResetAddComment(); if (sendFromUserView) { state.Operation.Message = "Сообщение успешно отправлено"; } } ), new HElementControl( h.Script(h.type("text/javascript"), "$('.messageContent').focus();"), "" ) ).EditContainer("messageData"); } HButton moderatorButton = null; HPanel moderatorPanel = null; if (!sendFromUserView) { moderatorButton = new HButton("", std.BeforeAwesome(@"\f1e2", 0) ).PositionAbsolute().Right(5).Top(0) .Title("Модерирование личных сообщений").FontSize(14) .Color(state.BlockHint == correspondenceModeration ? Decor.redColor : Decor.disabledColor) .Event("correspondence_moderation_set", "", delegate { state.SetBlockHint(correspondenceModeration); }); if (state.BlockHint == correspondenceModeration) { bool lockedCollocutor = user.Get(BasketballUserType.LockedUserIds, collocutor.Id); moderatorPanel = new HPanel( Decor.ButtonMidi(!lockedCollocutor ? "Заблокировать собеседника" : "Разблокировать собеседника") .Event("collocutor_locked", "", delegate { LightObject editUser = DataBox.LoadObject(context.UserConnection, UserType.User, user.Id); editUser.Set(BasketballUserType.LockedUserIds, collocutor.Id, !lockedCollocutor); editUser.Box.Update(); context.UserStorage.Update(); }), new HSpoiler(Decor.ButtonMidi("Удаление переписки").Block().FontBold(false), new HPanel( Decor.ButtonMidi("Удалить? (без подтверждения)") .MarginTop(5).MarginLeft(10) .Event("correspondence_delete", "", delegate { context.ForumConnection.GetScalar("", "Delete From correspondence Where user_id = @userId and collocutor_id = @collocutorId", new DbParameter("userId", user.Id), new DbParameter("collocutorId", collocutor.Id) ); context.ForumConnection.GetScalar("", "Delete From dialogue Where user_id = @userId and collocutor_id = @collocutorId", new DbParameter("userId", user.Id), new DbParameter("collocutorId", collocutor.Id) ); context.UpdateUnreadDialogs(); }) ) ).MarginTop(10) ).MarginTop(10); } } bool locked = user.Get(BasketballUserType.LockedUserIds, collocutor.Id) || collocutor.Get(BasketballUserType.LockedUserIds, user.Id); return(new HPanel( new HPanel( Decor.ButtonMidi("Написать сообщение") .Hide(locked) .Event("message_add", "", delegate { state.SetBlockHint("messageAdd"); } ), new HLabel("Вы не можете отправить сообщение этому пользователю").Hide(!locked) .MarginLeft(10).Color(Decor.subtitleColor), moderatorButton ).PositionRelative(), editPanel, moderatorPanel ).MarginTop(10).MarginBottom(10)); }