Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get information about chat room this window has been opened for.
        int roomId = QueryHelper.GetInteger("windowroomid", 0);

        try
        {
            ChatUserHelper.VerifyChatUserHasJoinRoomRights(roomId);
        }
        catch (ChatServiceException)
        {
            DisplayError();

            return;
        }
        ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomId);

        if (room == null)
        {
            DisplayError();

            return;
        }

        // Script references insertion
        ScriptHelper.RegisterJQuery(Page);
        ChatScriptHelper.RegisterChatManager(Page);
        ChatScriptHelper.RegisterChatNotificationManager(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/jquery/jquery-resize.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/Pages/Scripts/ChatRoomWindow.js");

        SetWebpartsUp(room.ChatRoomIsSupport);
        lblTitle.Text = HTMLHelper.HTMLEncode(room.ChatRoomDisplayName) + " – " + GetString(room.ChatRoomIsSupport ? "chat.title.support" : "chat.title.privateconversation");
        string json = JsonConvert.SerializeObject(
            new
        {
            roomId,
            pnlChatRoomWindowClientId = pnlChatRoomWindow.ClientID,
            pnlTopClientId            = pnlTop.ClientID,
            pnlBottomClientId         = pnlBottom.ClientID,
            ChatRoomMessagesClientId  = ChatRoomMessagesElem.ClientID,
            btnCloseClientId          = btnCloseWindow.ClientID,
            isSupport = room.ChatRoomIsSupport,
            notificationManagerOptions = new
            {
                eventName   = "newmessage",
                soundFile   = ChatSettingsProvider.EnableSoundSupportChat ? ResolveUrl("~/CMSModules/Chat/CMSPages/Sound/Chat_message.mp3") : String.Empty,
                notifyTitle = GetString("chat.general.newmessages")
            },
            title = lblTitle.Text
        },
            new JsonSerializerSettings {
            StringEscapeHandling = StringEscapeHandling.EscapeHtml
        }
            );
        string startupScript = String.Format("ChatSupportWindow({0});", json);

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatSupportWindow", startupScript, true);
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int roomID = QueryHelper.GetInteger("roomid", 0);

        ChatRoomMessages.RoomID = roomID;

        ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomID);

        if (room != null)
        {
            ChatOnlineUserHelper.LogInCurrentCMSUser();
            ChatRoomUserHelper.JoinUserToRoom(room.ChatRoomID, ChatUserHelper.GetChatUserFromCMSUser(), room.ChatRoomPassword, false);
        }

        ChatRoomUsers.ChatUserTransformationName = "Chat.Transformations.CMSChatRoomUser";
        ChatRoomUsers.EnableFiltering            = true;
        ChatRoomUsers.ShowFilterItems            = 20;
        ChatRoomUsers.EnablePaging = true;
        ChatRoomUsers.PagingItems  = 30;
        ChatRoomUsers.ChatErrorDeleteAllButtonTransformationName = "Chat.Transformations.CMSChatErrorDeleteAllButton";
        ChatRoomUsers.ChatErrorTransformationName    = "Chat.Transformations.CMSChatError";
        ChatRoomUsers.ChatMessageTransformationName  = "Chat.Transformations.CMSChatMessage";
        ChatRoomUsers.ChatRoomUserTransformationName = "Chat.Transformations.CMSChatRoomUser";

        RoomName.ChatRoomNameTransformationName = "Chat.Transformations.CMSRoomName";
        RoomName.DisplayInitialTitle            = false;

        ChatNotification.NotificationTransformation = "Chat.Transformations.CMSChatNotification";
        ChatNotification.ChatErrorDeleteAllButtonTransformationName = "Chat.Transformations.CMSChatErrorDeleteAllButton";
        ChatNotification.ChatErrorTransformationName    = "Chat.Transformations.CMSChatError";
        ChatNotification.ChatMessageTransformationName  = "Chat.Transformations.CMSChatMessage";
        ChatNotification.ChatRoomUserTransformationName = "Chat.Transformations.CMSChatRoomUser";
        ChatNotification.EnableNotificationBubble       = false;

        ChatErrors.ErrorTransformationName           = "Chat.Transformations.CMSChatError";
        ChatErrors.ShowDeleteAllBtn                  = true;
        ChatErrors.ButtonDeleteAllTransformationName = "Chat.Transformations.CMSChatErrorDeleteAllButton";

        ChatRoomMessages.ChatMessageTransformationName = "Chat.Transformations.CMSChatMessage";
        ChatRoomMessages.Count     = 100;
        ChatRoomMessages.Direction = ChatRoomMessagesDirectionEnum.Down;


        // Registration to chat webservice
        AbstractCMSPage cmsPage = this.Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatHelper.RegisterChatSupportAJAXProxy(cmsPage);
        }
    }
Exemplo n.º 3
0
    void Grid_OnAction(string actionName, object actionArgument)
    {
        int chatRoomID = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName)
        {
        case "edit":
            SelectedItemID = chatRoomID;

            // Parent page will handle editing
            RaiseOnEdit();

            break;

        case "safedelete":
        case "approve":
            ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(chatRoomID);

            ((CMSChatPage)Page).CheckModifyPermission(room.ChatRoomSiteID);

            if (actionName == "safedelete")
            {
                ChatRoomInfoProvider.SafeDelete(chatRoomID);
            }
            else
            {
                if (room.ChatRoomEnabled)
                {
                    ChatRoomHelper.DisableChatRoom(chatRoomID);
                }
                else
                {
                    ChatRoomHelper.EnableChatRoom(chatRoomID);
                }
            }

            break;
        }
    }
Exemplo n.º 4
0
    object Grid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        sourceName = sourceName.ToLowerCSafe();

        switch (sourceName)
        {
        case "chatroomcreatedbychatuserid":

            ChatUserInfo user = ChatUserInfoProvider.GetChatUserInfo(ValidationHelper.GetInteger(parameter, 0));
            if (user != null)
            {
                return(ChatHelper.GetCMSDeskChatUserField(this, user));
            }
            else
            {
                return(GetString("general.na"));
            }

        case "approve":
        case "safedelete":
            DataRow row = ((DataRowView)((GridViewRow)parameter).DataItem).Row;

            ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(ValidationHelper.GetInteger(row["ChatRoomID"], 0));

            if (room == null)
            {
                return(null);
            }

            bool enabled = ((CMSChatPage)Page).HasUserModifyPermission(room.ChatRoomSiteID);

            string toolTipResourceString;
            CMSGridActionButton button = ((CMSGridActionButton)sender);

            if (sourceName == "approve")
            {
                bool approve = ValidationHelper.GetBoolean(row["ChatRoomEnabled"], false);

                if (!approve)
                {
                    toolTipResourceString = "general.enable";
                    button.IconCssClass   = "icon-check-circle";
                    button.IconStyle      = GridIconStyle.Allow;
                }
                else
                {
                    toolTipResourceString = "general.disable";
                    button.IconCssClass   = "icon-times-circle";
                    button.IconStyle      = GridIconStyle.Critical;
                }

                // Disable 'approve' or 'reject' action if room is one to one support
                if (room.IsOneToOneSupport)
                {
                    enabled = false;
                }
            }
            else
            {
                toolTipResourceString = "general.delete";
            }

            if (!enabled)
            {
                button.Enabled = false;
            }

            button.ToolTip = GetString(toolTipResourceString);
            break;
        }

        return(parameter);
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageTitle title = PageTitle;

        passwordPromptElem.TitleText = ResHelper.GetString("chat.password");

        // Script references insertion
        ScriptHelper.RegisterJQuery(Page);
        ChatScriptHelper.RegisterChatNotificationManager(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/jquery/jquery-resize.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/ChatRoomWindow.js");

        // Get information about chat room this window has been opened for.
        int roomID = QueryHelper.GetInteger("windowroomid", 0);

        try
        {
            ChatUserHelper.VerifyChatUserHasJoinRoomRights(roomID);
        }
        catch (ChatServiceException)
        {
            DisplayError();

            return;
        }

        ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomID);

        if (room == null)
        {
            DisplayError();

            return;
        }

        string pnlChatRoomWindowCssClass = " ChatPopupWindow";

        // Disable irrelevant controls
        if (room.ChatRoomIsOneToOne)
        {
            ChatMessageSendElem.HideUserPicker();
            pnlChatRoomWindowCssClass += " IsOneToOne";

            // Set appropriate window title
            string pageTitle = ResHelper.GetString(room.ChatRoomIsSupport ? "chat.title.support" : "chat.title.privateconversation");
            Page.Header.Title = title.TitleText = pageTitle;
        }
        else
        {
            Page.Header.Title = title.TitleText = room.ChatRoomDisplayName;
        }

        SetWebpartsUp();

        if (room.ChatRoomIsSupport)
        {
            pnlChatRoomWindowCssClass += " IsSupport";
            if (ChatSettingsProvider.IsSupportMailEnabledAndValid)
            {
                pnlSupportSendMail.Visible     = true;
                hplSupportSendMail.NavigateUrl = ChatSettingsProvider.SupportMailDialogURL + "?roomid=" + roomID;
                hplSupportSendMail.Target      = "_blank";
            }
        }
        pnlChatRoomWindow.CssClass += pnlChatRoomWindowCssClass;
        JavaScriptSerializer sr = new JavaScriptSerializer();

        string json = sr.Serialize(
            new
        {
            roomID   = roomID,
            password = room.HasPassword,
            pnlChatRoomPasswordPrompt       = '#' + pnlChatRoomPasswordPrompt.ClientID,
            txtChatRoomPasswordPromptInput  = '#' + txtChatRoomPasswordPromptInput.ClientID,
            btnChatRoomPasswordPromptSubmit = '#' + btnChatRoomPasswordPromptSubmit.ClientID,
            isOneToOne                 = room.IsWhisperRoom,
            isCustomerSupport          = room.ChatRoomIsSupport,
            hplSupportSendMailClientID = room.ChatRoomIsSupport ? '#' + hplSupportSendMail.ClientID : "",
            pnlPasswordPromptError     = '#' + pnlChatRoomsPromptPasswordError.ClientID,
            pnlChatRoomWindow          = '#' + pnlChatRoomWindow.ClientID,
            ChatRoomMessagesClientID   = ChatRoomMessagesElem.ClientID,
            btnClose = "#" + btnCloseWindow.ClientID,
            notificationManagerOptions = new
            {
                eventName   = "newmessage",
                soundFile   = ChatSettingsProvider.EnableSoundLiveChat ? ResolveUrl("~/CMSModules/Chat/CMSPages/Sound/Chat_message.mp3") : String.Empty,
                notifyTitle = ResHelper.GetString("chat.general.newmessages")
            }
        }
            );


        string startupScript = String.Format("ChatRoomWindow({0});", json);

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatRoomWindow_" + ClientID, startupScript, true);
    }
Exemplo n.º 6
0
    object Grid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        sourceName = sourceName.ToLowerCSafe();

        switch (sourceName)
        {
        case "chatroomcreatedbychatuserid":

            ChatUserInfo user = ChatUserInfoProvider.GetChatUserInfo(ValidationHelper.GetInteger(parameter, 0));
            if (user != null)
            {
                return(ChatHelper.GetCMSDeskChatUserField(this, user));
            }
            else
            {
                return(GetString("general.na"));
            }

        case "approve":
        case "safedelete":
            DataRow row = ((DataRowView)((GridViewRow)parameter).DataItem).Row;

            ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(ValidationHelper.GetInteger(row["ChatRoomID"], 0));

            if (room == null)
            {
                return(null);
            }

            bool enabled = ((CMSChatPage)Page).HasUserModifyPermission(room.ChatRoomSiteID);

            string iconName;
            string toolTipResourceString;

            if (sourceName == "approve")
            {
                bool approve = ValidationHelper.GetBoolean(row["ChatRoomEnabled"], false);

                if (!approve)
                {
                    toolTipResourceString = "general.enable";
                    iconName = "Approve";
                }
                else
                {
                    toolTipResourceString = "general.disable";
                    iconName = "Reject";
                }

                // Disable 'approve' or 'reject' action if room is one to one support
                if (room.IsOneToOneSupport)
                {
                    enabled = false;
                }
            }
            else
            {
                toolTipResourceString = "general.delete";
                iconName = "Delete";
            }

            ImageButton button = ((ImageButton)sender);

            if (!enabled)
            {
                button.Enabled = false;
                iconName      += "disabled";
            }

            button.ToolTip  = GetString(toolTipResourceString);
            button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/" + iconName + ".png");

            break;
        }

        return(parameter);
    }
Exemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int roomID = QueryHelper.GetInteger("roomid", 0);

        ChatRoomMessages.RoomID = roomID;

        ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomID);

        if (room != null)
        {
            if (!room.ChatRoomEnabled)
            {
                CSSHelper.RegisterBootstrap(Page);
                CSSHelper.RegisterDesignMode(Page);
                ShowError(GetString("chat.errormessage.roomdisabled"));
                pnlChatView.Visible = false;

                return;
            }

            ChatOnlineUserHelper.LogInChatUser(ChatUserHelper.GetChatUserFromCMSUser(MembershipContext.AuthenticatedUser), false);
            ChatRoomUserHelper.JoinUserToRoom(room.ChatRoomID, ChatUserHelper.GetChatUserFromCMSUser(), room.ChatRoomPassword, false);
        }

        ChatRoomUsers.ChatUserTransformationName = "Chat.Transformations.CMSChatRoomUser";
        ChatRoomUsers.EnableFiltering            = true;
        ChatRoomUsers.ShowFilterItems            = ChatHelper.WPShowFilterLimit;
        ChatRoomUsers.EnablePaging = true;
        ChatRoomUsers.PagingItems  = ChatHelper.WPPagingItems;
        ChatRoomUsers.GroupPagesBy = ChatHelper.WPGroupPagesBy;
        ChatRoomUsers.ChatErrorDeleteAllButtonTransformationName = "Chat.Transformations.CMSChatErrorDeleteAllButton";
        ChatRoomUsers.ChatErrorTransformationName    = "Chat.Transformations.CMSChatError";
        ChatRoomUsers.ChatMessageTransformationName  = "Chat.Transformations.CMSChatMessage";
        ChatRoomUsers.ChatRoomUserTransformationName = "Chat.Transformations.CMSChatRoomUser";

        RoomName.ChatRoomNameTransformationName = "Chat.Transformations.CMSRoomName";
        RoomName.DisplayInitialTitle            = false;

        ChatNotification.NotificationTransformation = "Chat.Transformations.CMSChatNotification";
        ChatNotification.ChatErrorDeleteAllButtonTransformationName = "Chat.Transformations.CMSChatErrorDeleteAllButton";
        ChatNotification.ChatErrorTransformationName    = "Chat.Transformations.CMSChatError";
        ChatNotification.ChatMessageTransformationName  = "Chat.Transformations.CMSChatMessage";
        ChatNotification.ChatRoomUserTransformationName = "Chat.Transformations.CMSChatRoomUser";
        ChatNotification.EnableNotificationBubble       = false;

        ChatErrors.ErrorTransformationName           = "Chat.Transformations.CMSChatError";
        ChatErrors.ShowDeleteAllBtn                  = true;
        ChatErrors.ButtonDeleteAllTransformationName = "Chat.Transformations.CMSChatErrorDeleteAllButton";

        ChatRoomMessages.ChatMessageTransformationName = "Chat.Transformations.CMSChatMessage";
        ChatRoomMessages.Count     = 100;
        ChatRoomMessages.Direction = ChatRoomMessagesDirectionEnum.Down;


        // Registration to chat webservice
        AbstractCMSPage cmsPage = this.Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatHelper.RegisterChatSupportAJAXProxy(cmsPage);
        }
    }
Exemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageTitle title = CurrentMaster.Title;

        title.TitleImage = GetImageUrl("CMSModules/CMS_Chat/list.png");

        passwordPromptElem.TitleImage = GetImageUrl("CMSModules/CMS_Chat/password.png");
        passwordPromptElem.TitleText  = ResHelper.GetString("chat.password");

        // Script references insertion
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/jquery/jquery-resize.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/ChatRoomWindow.js");

        // Get information about chat room this window has been opened for.
        int roomID = QueryHelper.GetInteger("windowroomid", 0);

        ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomID);

        if (room == null)
        {
            lblError.Text    = ResHelper.GetString("chat.error.window.badroomid");
            lblError.Visible = true;
            return;
        }

        string pnlChatRoomWindowCssClass = " ChatPopupWindow";

        // Disable irrelevant controls
        if (room.ChatRoomIsOneToOne)
        {
            ChatMessageSendElem.HideUserPicker();
            pnlChatRoomWindowCssClass += " IsOneToOne";

            // Set appropriate window title
            string pageTitle = ResHelper.GetString(room.ChatRoomIsSupport ? "chat.title.support" : "chat.title.privateconversation");
            if (room.ChatRoomIsSupport && IsSupport)
            {
                pageTitle = room.ChatRoomDisplayName + " – " + pageTitle;
            }
            Page.Header.Title = title.TitleText = pageTitle;
        }
        else
        {
            Page.Header.Title = title.TitleText = room.ChatRoomDisplayName;
        }

        SetWebpartsUp();

        // True if this window is open by a customer in need of support (not support engineer)
        bool isCustomerSupport = room.ChatRoomIsSupport && !IsSupport;

        if (room.ChatRoomIsSupport)
        {
            pnlChatRoomWindowCssClass += " IsSupport";
        }

        if (isCustomerSupport && ChatHelper.IsSupportMailEnabledAndValid)
        {
            pnlSupportSendMail.Visible     = true;
            hplSupportSendMail.NavigateUrl = ChatHelper.SupportMailDialogURL + "?roomid=" + roomID;
            hplSupportSendMail.Target      = "_blank";
        }

        pnlChatRoomWindow.CssClass += pnlChatRoomWindowCssClass;
        JavaScriptSerializer sr = new JavaScriptSerializer();

        string json = sr.Serialize(
            new
        {
            roomID   = roomID,
            password = room.HasPassword,
            pnlChatRoomPasswordPrompt       = '#' + pnlChatRoomPasswordPrompt.ClientID,
            txtChatRoomPasswordPromptInput  = '#' + txtChatRoomPasswordPromptInput.ClientID,
            btnChatRoomPasswordPromptSubmit = '#' + btnChatRoomPasswordPromptSubmit.ClientID,
            isOneToOne                 = room.IsWhisperRoom,
            isCustomerSupport          = isCustomerSupport,
            hplSupportSendMailClientID = isCustomerSupport ? '#' + hplSupportSendMail.ClientID : "",
            pnlPasswordPromptError     = '#' + pnlChatRoomsPromptPasswordError.ClientID,
            pnlChatRoomWindow          = '#' + pnlChatRoomWindow.ClientID,
            ChatRoomMessagesClientID   = ChatRoomMessagesElem.ClientID,
            btnClose  = "#" + btnCloseWindow.ClientID,
            isSupport = IsSupport
        }
            );


        string startupScript = String.Format("ChatRoomWindow({0});", json);

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatRoomWindow_" + ClientID, startupScript, true);
    }