Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Registration to chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatScriptHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Script references insertion
        ChatScriptHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatRoomName_files/ChatRoomName.js");

        // Run script
        JavaScriptSerializer sr = new JavaScriptSerializer();
        string json             = sr.Serialize(
            new
        {
            roomNameTemplate    = ChatUIHelper.GetWebpartTransformation(ChatRoomNameTransformationName, "chat.error.transformation.namewp.error"),
            contentClientID     = "#" + pnlChatRoomName.ClientID,
            clientID            = ClientID,
            conversationTitle   = ResHelper.GetString("chat.title.privateconversation"),
            groupID             = GroupID,
            displayInitialTitle = DisplayInitialTitle,
            noRoomTitle         = InitialTitle,
            loadingDiv          = ChatUIHelper.GetWebpartLoadingDiv("ChatRoomNameWPLoading", "chat.wploading.roomname"),
            envelopeID          = "#envelope_" + ClientID
        }
            );
        string startupScript = String.Format("InitChatRoomNameWebpart({0});", json);

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatRoomName_" + ClientID, startupScript, true);
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Registration to chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatScriptHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Script references insertion
        ChatScriptHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterJQueryUI(Page);
        ScriptHelper.RegisterScriptFile(Page, "jquery/jquery-a-tools.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/BBCodeParser.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatMessageSend_files/ChatMessageSend.js");

        imgInformationDialog.ImageUrl = GetImageUrl("General/Labels/Information.png");

        RoomID = ChatUIHelper.GetRoomIdFromQuery(RoomID, GroupID);

        // Register startup script
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatMessageSend_" + ClientID, BuildStartupScript(), true);

        // Set link to documentation and tooltip for canned responses
        lnkCannedRespHelp.NavigateUrl = DocumentationHelper.GetDocumentationTopicUrl(CANNED_RESPONSES_HELP_TOPIC);
        lnkCannedRespHelp.ToolTip     = ResHelper.GetString("chat.cannedresponses.helplabel");
    }
    /// <summary>
    /// Builds startup script.
    /// </summary>
    private string BuildStartupScript()
    {
        string json = JsonConvert.SerializeObject(
            new
        {
            roomID = RoomID,
            chatMessageTemplate = ChatUIHelper.GetWebpartTransformation(ChatMessageTransformationName, "chat.error.transformation.messages.message"),
            count                = (Count >= 0) ? Count : ChatSettingsProvider.FirstLoadMessagesCountSetting,
            contentClientID      = "#" + pnlChatRoomMessages.ClientID,
            displayInline        = DisplayInline,
            groupID              = GroupID,
            clientID             = ClientID,
            direction            = (int)Direction,
            enableBBCode         = (ChatSettingsProvider.EnableBBCodeSetting && EnableBBCode),
            loadingDiv           = ChatUIHelper.GetWebpartLoadingDiv("ChatMessagesWPLoading", "chat.wploading.messages"),
            envelopeID           = "#envelope_" + ClientID,
            pnlInformDialog      = "#" + pnlChatRoomMessagesInfoDialog.ClientID,
            btnInformDialogClose = "#" + btnChatMessageInformDialogClose.ClientID,
            container            = "#" + pnlChatRoomWebpart.ClientID
        },
            new JsonSerializerSettings {
            StringEscapeHandling = StringEscapeHandling.EscapeHtml
        }
            );

        return(String.Format("InitChatMessagesWebpart({0});", json));
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Registration to chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatScriptHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Script references insertion
        ChatScriptHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatErrors_files/ChatErrors.js");

        // Run script
        string startupScript = String.Format("InitErrorsWebpart({{errorTemplate:{0},contentClientID:{1}, clientID:'{2}', showDeleteAll:{3}, envelopeID: '#envelope_{2}' }});",
                                             ScriptHelper.GetString(ChatUIHelper.GetWebpartTransformation(ErrorTransformationName, "chat.error.transformation.errorwp.error")),
                                             ScriptHelper.GetString("#" + pnlChatErrors.ClientID),
                                             ClientID,
                                             ScriptHelper.GetString(ShowDeleteAllBtn ? ChatUIHelper.GetWebpartTransformation(ButtonDeleteAllTransformationName, "chat.error.transformation.errorwp.deleteallbtn") : "")
                                             );

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatErrors_" + ClientID, startupScript, true);
    }
Exemplo n.º 5
0
    /// <summary>
    /// Builds startup script.
    /// </summary>
    private string BuildStartupScript()
    {
        int id = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);

        JavaScriptSerializer sr = new JavaScriptSerializer();
        string json             = sr.Serialize(
            new
        {
            onlineUserTemplate = ChatUIHelper.GetWebpartTransformation(OnlineUserTransformationName, "chat.error.transformation.users.onlineuser"),
            chatRoomWindowUrl  = ChatUIHelper.GetChatRoomWindowURL(Page),
            clientID           = ClientID,
            GUID            = id,
            contentClientID = pnlChatSearchOnlineUsers.ClientID,
            textbox         = txtChatSearchOnlineUsers.ClientID,
            button          = btnChatSearchOnlineUsers.ClientID,
            pnlPaging       = pnlChatSearchOnlineUsersPaging.ClientID,
            pagingEnabled   = PagingEnabled,
            pagingItems     = PagingItems > 0 ? PagingItems : ChatSettingsProvider.WPPagingItems,
            groupPagesBy    = GroupPagesBy >= 0 ? GroupPagesBy : ChatSettingsProvider.WPGroupPagesBy,
            maxUsers        = ResponseMaxUsers,
            inviteMode      = InviteMode,
            loadingDiv      = ChatUIHelper.GetWebpartLoadingDiv("ChatSearchOnlineUsersWPLoading", "chat.wploading.searchonlineusers"),
            resStrMoreFound = (ResponseMaxUsers > 0) ? String.Format(ResHelper.GetString("chat.searchonlineusers.morefound"), ResponseMaxUsers) : "",
            resStrNotFound  = ResHelper.GetString("chat.searchonlineusers.notfound"),
            pnlInfo         = pnlChatSearchOnlineUsersInfo.ClientID,
            resStrFound     = ResHelper.GetString("chat.searchonlineusers.results"),
            envelopeID      = "envelope_" + ClientID,
            groupID         = GroupName,
            invitePanel     = pnlChatSearchOnlineUsersInvite.ClientID
        }
            );

        return(String.Format("InitChatSearchOnlineUsersWebpart({0});", json));
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register to chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatScriptHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Insert cript references
        ChatScriptHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/ListPaging.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/ChatDialogs.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatRoomUsers_files/ChatRoomUsers.js");

        RoomID = ChatUIHelper.GetRoomIdFromQuery(RoomID, GroupID);

        if (EnableFiltering)
        {
            pnlChatRoomUsersFiltering.Visible = true;
        }

        // Set properties to invite webpart
        ChatSearchOnlineUsers.InviteMode = ChatOnlineUsersElem.InviteMode = true;
        ChatSearchOnlineUsers.IsSupport  = ChatOnlineUsersElem.IsSupport = IsSupport;
        ChatSearchOnlineUsers.GroupName  = ChatOnlineUsersElem.GroupName = GroupID;
        ChatSearchOnlineUsers.OnlineUserTransformationName = ChatOnlineUsersElem.OnlineUserTransformationName = "Chat.Transformations.ChatOnlineUser";
        ChatSearchOnlineUsers.PagingEnabled = ChatOnlineUsersElem.EnablePaging = true;
        int invitePagingItems = (ChatSettingsProvider.WPInviteModePagingItems > 0) ? ChatSettingsProvider.WPInviteModePagingItems : ChatSettingsProvider.WPPagingItems;

        if (!(invitePagingItems > 0))
        {
            invitePagingItems = PagingItems;
        }
        ChatOnlineUsersElem.ShowFilterItems    = invitePagingItems + 1;
        ChatSearchOnlineUsers.PagingItems      = ChatOnlineUsersElem.PagingItems = invitePagingItems;
        ChatSearchOnlineUsers.ResponseMaxUsers = (InviteSearchModeMaxUsers >= 0) ? InviteSearchModeMaxUsers : ChatSettingsProvider.WPSearchModeMaxUsers;
        ChatOnlineUsersElem.EnableFiltering    = true;

        if (InviteSearchMode == true)
        {
            ChatOnlineUsersElem.Visible = false;
        }
        else
        {
            ChatSearchOnlineUsers.Visible = false;
        }

        // Run startup script
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatUsers_" + ClientID, BuildStartupScript(), true);

        imgChatRoomUsersInvitePrompt.ImageUrl = GetImageUrl("CMSModules/CMS_Chat/add24.png");
    }
 protected void Page_Prerender(object sender, EventArgs e)
 {
     ChatUIHelper.MakeWebpartEnvelope("ChatWebpartEnvelope ChatWebpartEnvelopeErrors", this, InnerContainerTitle, InnerContainerName);
     if (IsSupport)
     {
         ChatCssHelper.RegisterStylesheet(Page, true);
     }
     else
     {
         ChatCssHelper.RegisterStylesheet(Page);
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing || !ViewMode.IsOneOf(ViewModeEnum.LiveSite, ViewModeEnum.Preview))
        {
            return;
        }

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

        if (cmsPage != null)
        {
            ChatScriptHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Script references insertion
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterJQueryCookie(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/ChatSettings.ashx");

        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/AutoInitiatedChat_files/AutoInitiatedChat.js");

        int optID = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);

        // Run script
        string json = JsonConvert.SerializeObject(
            new
        {
            wpGUID        = InstanceGUID,
            clientID      = pnlInitiatedChat.ClientID,
            contentID     = pnlContent.ClientID,
            pnlErrorID    = pnlError.ClientID,
            lblErrorID    = lblError.ClientID,
            windowURL     = ChatUIHelper.GetChatRoomWindowURL(),
            trans         = ChatUIHelper.GetWebpartTransformation(TransformationName, "chat.error.transformation.initiatedchat.error"),
            guid          = optID,
            delay         = Delay * 1000,
            initiatorName = InitiatorName,
            messages      = MacroResolver.Resolve(Messages).Split('\n')
        },
            new JsonSerializerSettings {
            StringEscapeHandling = StringEscapeHandling.EscapeHtml
        }
            );
        string startupScript = string.Format("InitAutoInitiatedChat({0});", json);

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatAutoInitiatedChat_" + ClientID, startupScript, true);
    }
    /// <summary>
    /// Builds startup script.
    /// </summary>
    private string BuildStartupScript()
    {
        int id = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);

        string json = JsonConvert.SerializeObject(
            new
        {
            roomID                        = RoomID,
            chatUserTemplate              = ChatUIHelper.GetWebpartTransformation(ChatUserTransformationName, "chat.error.transformation.users.user"),
            oneToOneURL                   = ChatUIHelper.GetChatRoomWindowURL(Page),
            contentClientID               = pnlChatRoomUsers.ClientID,
            clientID                      = ClientID,
            groupID                       = GroupID,
            sortByStatus                  = SortByStatus,
            GUID                          = id,
            pnlChatRoomUsersInvitePrompt  = pnlChatRoomUsersInvitePrompt.ClientID,
            pnlChatRoomUsersInvite        = pnlChatRoomUsersInvite.ClientID,
            chatOnlineUsersElem           = ChatOnlineUsersElem.ClientID,
            chatSearchOnlineUsersElem     = ChatSearchOnlineUsers.ClientID,
            loadingDiv                    = ChatUIHelper.GetWebpartLoadingDiv("ChatRoomUsersWPLoading", "chat.wploading.roomusers"),
            btnChatRoomUsersInvite        = btnChatRoomUsersInvite.ClientID,
            btnChatRoomsDeletePromptClose = btnChatRoomsDeletePromptClose.ClientID,
            pnlFilterClientID             = pnlChatRoomUsersFiltering.ClientID,
            pnlPagingClientID             = pnlChatRoomUsersPaging.ClientID,
            pagingItems                   = PagingItems > 0 ? PagingItems : ChatSettingsProvider.WPPagingItems,
            groupPagesBy                  = GroupPagesBy >= 0 ? GroupPagesBy : ChatSettingsProvider.WPGroupPagesBy,
            pagingEnabled                 = EnablePaging,
            btnFilter                     = btnChatRoomUsersFilter.ClientID,
            txtFilter                     = txtChatRoomUsersFilter.ClientID,
            filterEnabled                 = EnableFiltering,
            pnlInfo                       = pnlChaRoomUsersInfo.ClientID,
            resStrNoFound                 = ResHelper.GetString("chat.searchonlineusers.notfound"),
            resStrResults                 = ResHelper.GetString("chat.searchonlineusers.results"),
            filterCount                   = ShowFilterItems >= 0 ? ShowFilterItems : ChatSettingsProvider.WPShowFilterLimit,
            envelopeID                    = "envelope_" + ClientID,
            inviteSearchMode              = InviteSearchMode,
            inviteEnabled                 = InviteEnabled
        },
            new JsonSerializerSettings {
            StringEscapeHandling = StringEscapeHandling.EscapeHtml
        }
            );

        return(String.Format("InitChatUsersWebpart({0});", json));
    }
Exemplo n.º 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!ViewMode.IsOneOf(ViewModeEnum.LiveSite, ViewModeEnum.Preview))
        {
            return;
        }

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

        if (cmsPage != null)
        {
            ChatScriptHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Script references insertion
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/ChatSettings.ashx");

        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/InitiatedChat_files/InitiatedChat.js");

        int optID = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);

        // Run script
        JavaScriptSerializer sr = new JavaScriptSerializer();
        string json             = sr.Serialize(
            new
        {
            clientID   = pnlInitiatedChat.ClientID,
            contentID  = pnlContent.ClientID,
            pnlErrorID = pnlError.ClientID,
            lblErrorID = lblError.ClientID,
            windowURL  = ChatUIHelper.GetChatRoomWindowURL(),
            trans      = ChatUIHelper.GetWebpartTransformation(TransformationName, "chat.error.transformation.initiatedchat.error"),
            guid       = optID,
            pingTick   = ChatSettingsProvider.GlobalPingIntervalSetting * 1000
        }
            );
        string startupScript = string.Format("InitInitiatedChatManager({0});", json);

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatInitiatedChat_" + ClientID, startupScript, true);
    }
    /// <summary>
    /// Builds startup script.
    /// </summary>
    private string BuildStartupScript()
    {
        // Set all the transformation settings for chat room window
        int  roomSettingsId = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);
        bool isLiveSite     = ViewMode.IsOneOf(ViewModeEnum.LiveSite, ViewModeEnum.Preview);

        string json = JsonConvert.SerializeObject(
            new
        {
            template                             = ChatUIHelper.GetWebpartTransformation(NotificationTransformation, "chat.error.transformation.notification"),
            clientID                             = ClientID,
            chatRoomGUID                         = roomSettingsId,
            pnlChatNotificationEmpty             = GetString(pnlChatNotificationEmpty),
            pnlChatNotificationFull              = GetString(pnlChatNotificationFull),
            btnChatNotificationFullLink          = GetString(btnChatNotificationFullLink),
            lblChatNotificationFullTextNumber    = GetString(lblChatNotificationFullTextNumber),
            pnlChatNotificationNotifications     = GetString(pnlChatNotificationNotifications),
            pnlChatNotificationNotificationsList = GetString(pnlChatNotificationNotificationsList),
            btnChatNotificationPromptClose       = GetString(btnChatNotificationPromptClose),
            wpPanelID                            = GetString(pnlWPNotifications),
            envelopeID                           = "#envelope_" + ClientID,
            bubbleBtnShow                        = GetString(btnShow),
            bubbleBtnClose                       = GetString(btnClose),
            bubbleLabel                          = GetString(lblInfoMessage),
            bubblePanel                          = GetString(pnlNotificationInfoBubble),
            strNoNotif                           = ResHelper.GetString("chat.notification.empty"),
            resNewNotif                          = ResHelper.GetString("chat.notification.youhave"),
            bubbleEnabled                        = EnableNotificationBubble && isLiveSite,
            isPreview                            = ViewMode.IsPreview(),
            notificationManagerOptions           = new
            {
                eventName   = "newnotification",
                soundFile   = ChatSettingsProvider.EnableSoundLiveChat ? ResolveUrl("~/CMSModules/Chat/CMSPages/Sound/Chat_notification.mp3") : String.Empty,
                notifyTitle = ResHelper.GetString("chat.notification.bubble.header")
            }
        },
            new JsonSerializerSettings {
            StringEscapeHandling = StringEscapeHandling.EscapeHtml
        }
            );

        return(String.Format("InitChatNotification({0});", json));
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Registration to chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;

        if (cmsPage != null)
        {
            ChatScriptHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Script references insertion

        ChatScriptHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatSupportRequest_files/ChatSupportRequest.js");

        // Create and store settings for popup chat window.
        int id = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);

        string json = JsonConvert.SerializeObject(
            new
        {
            onlineUrl            = ChatUIHelper.GetChatRoomWindowURL(),
            clientID             = pnlSupportChatRequest.ClientID,
            guid                 = id,
            trans                = ChatUIHelper.GetWebpartTransformation(string.IsNullOrEmpty(ChatSupportRequestTransformationName) ? ChatSettingsProvider.TransformationSupportRequest : ChatSupportRequestTransformationName, "chat.error.transformation.request"),
            mailEnabled          = ChatSettingsProvider.IsSupportMailEnabledAndValid,
            pnlInformDialog      = "#" + pnlChatSupportRequestInfoDialog.ClientID,
            btnInformDialogClose = "#" + btnChatSupportRequestInformDialogClose.ClientID
        },
            new JsonSerializerSettings {
            StringEscapeHandling = StringEscapeHandling.EscapeHtml
        }
            );

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

        // Run startup script
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "SupportChatRequest_" + ClientID, startupScript, true);
    }
Exemplo n.º 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register to chat webservice
        AbstractCMSPage cmsPage = Page as AbstractCMSPage;
        if (cmsPage != null)
        {
            ChatScriptHelper.RegisterChatAJAXProxy(cmsPage);
        }

        // Insert script references
        ChatScriptHelper.RegisterChatManager(Page);
        ScriptHelper.RegisterJQueryTemplates(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/BBCodeParser.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/Scripts/SmileysResolver.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/ChatRoomMessages_files/ChatRoomMessages.js");

        imgInformationDialog.ImageUrl = GetImageUrl("General/Labels/Information.png");

        RoomID = ChatUIHelper.GetRoomIdFromQuery(RoomID, GroupID);

        // Prepare and run startup script
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatMessages_" + ClientID, BuildStartupScript(), true);
    }
Exemplo n.º 14
0
    /// <summary>
    /// Builds startup script.
    /// </summary>
    private string BuildStartupScript()
    {
        int id = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);

        JavaScriptSerializer sr = new JavaScriptSerializer();
        string json             = sr.Serialize(
            new
        {
            onlineUserTemplate = ChatUIHelper.GetWebpartTransformation(OnlineUserTransformationName, "chat.error.transformation.users.onlineuser"),
            chatRoomWindowUrl  = ChatUIHelper.GetChatRoomWindowURL(Page),
            clientID           = ClientID,
            GUID                  = id,
            contentClientID       = pnlChatOnlineUsers.ClientID,
            inviteMode            = InviteMode,
            pnlFilterClientID     = pnlChatOnlineUsersFiltering.ClientID,
            pnlPagingClientID     = pnlChatOnlineUsersPaging.ClientID,
            pagingItems           = PagingItems > 0 ? PagingItems : ChatSettingsProvider.WPPagingItems,
            groupPagesBy          = GroupPagesBy >= 0 ? GroupPagesBy : ChatSettingsProvider.WPGroupPagesBy,
            pagingEnabled         = EnablePaging,
            btnFilter             = btnChatOnlineUsersFilter.ClientID,
            txtFilter             = txtChatOnlineUsersFilter.ClientID,
            filterEnabled         = EnableFiltering,
            pnlInfo               = pnlChatOnlineUsersInfo.ClientID,
            resStrNoFound         = ResHelper.GetString("chat.onlineusers.notfound"),
            resStrResults         = ResHelper.GetString("chat.onlineusers.results"),
            loadingDiv            = ChatUIHelper.GetWebpartLoadingDiv("ChatOnlineUsersWPLoading", "chat.wploading.onlineusers"),
            filterCount           = ShowFilterItems >= 0 ? ShowFilterItems : ChatSettingsProvider.WPShowFilterLimit,
            envelopeID            = "envelope_" + ClientID,
            resStrNoOneInviteMode = ResHelper.GetString("chat.onlineusers.invitemodenousers"),
            groupID               = GroupName,
            invitePanel           = pnlChatOnlineUsersInvite.ClientID
        }
            );

        return(String.Format("InitChatOnlineUsersWebpart({0});", json));
    }
    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(ChatUIHelper.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);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        UIFormControl.OnCheckPermissions += EditForm_OnCheckPermissions;
        UIFormControl.OnBeforeValidate   += EditForm_OnBeforeValidate;
        UIFormControl.OnBeforeSave       += EditForm_OnBeforeSave;

        ChatRoomInfo room = ChatRoom;

        if ((room == null) || room.IsOneToOneSupport)
        {
            RedirectToInformation(GetString("chat.error.internal"));
        }

        if (!RequestHelper.IsPostBack())
        {
            List <AdminLevelEnum> itemsToAdd = new List <AdminLevelEnum>();

            // Level can be set to None only if editing existing user in room
            if (IsEditing)
            {
                itemsToAdd.Add(AdminLevelEnum.None);
            }

            // Level can be set to Join only in private rooms
            if (room.ChatRoomPrivate)
            {
                itemsToAdd.Add(AdminLevelEnum.Join);
            }

            // Level can be set to Admin always
            itemsToAdd.Add(AdminLevelEnum.Admin);

            foreach (AdminLevelEnum enumValue in itemsToAdd)
            {
                fdrpAdminLevel.DropDownList.Items.Add(new ListItem(enumValue.ToStringValue(), ((int)enumValue).ToString()));
            }

            if (IsEditing)
            {
                fdrpAdminLevel.SelectedValue = ((int)TypedEditedObject.ChatRoomUserAdminLevel).ToString();
            }
        }


        if (IsEditing)
        {
            ChatUserInfo chatUser = ChatUserInfoProvider.GetChatUserInfo(TypedEditedObject.ChatRoomUserChatUserID);

            litChatUserLink.Text = ChatUIHelper.GetCMSDeskChatUserField(this, chatUser);

            fUserSelector.Value = chatUser.ChatUserUserID;

            litChatUserLink.Visible = true;
            fUserSelector.Visible   = false;

            // Disable user selector and set ProcessDisabledFields to false, so it won't be validated
            UIFormControl.ProcessDisabledFields = false;
            fUserSelector.Enabled = false;
        }
        else
        {
            litChatUserLink.Visible = false;
            fUserSelector.Visible   = true;

            if (room.ChatRoomSiteID.HasValue)
            {
                fUserSelector.SiteID         = room.ChatRoomSiteID.Value;
                fUserSelector.ShowSiteFilter = false;
            }
        }
    }
    object Grid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        int    chatUserID = ValidationHelper.GetInteger(parameter, 0);
        string name       = sourceName.ToLowerCSafe();

        switch (name)
        {
        case "chatroomuserchatuserid":
            ChatUserInfo user = ChatUserInfoProvider.GetChatUserInfo(chatUserID);

            return(ChatUIHelper.GetCMSDeskChatUserField(this, user));

        case "adminlevel":
            AdminLevelEnum adminLevel = (AdminLevelEnum)parameter;

            return(adminLevel.ToStringValue());

        case "onlinestatus":
            if (parameter == DBNull.Value)
            {
                parameter = null;
            }

            DateTime?joinTime = (DateTime?)parameter;

            string input = "<span class=\"{0}\">{1}</span>";

            return(String.Format(input, (joinTime.HasValue) ? "StatusEnabled" : "StatusDisabled", GetString(joinTime.HasValue ? "general.yes" : "general.no")));


        case "action_kick":
        case "action_revoke":
        case "action_edit":
            //Gets the value of the UserName column from the current data row
            DataRow row = ((DataRowView)((GridViewRow)parameter).DataItem).Row;

            bool visible = true;
            CMSGridActionButton actionButton = (CMSGridActionButton)sender;

            // Can't perform any action in one to one support room
            if (ChatRoom.IsOneToOneSupport)
            {
                visible = false;
            }
            else
            {
                if (name == "action_kick")
                {
                    if (row["ChatRoomUserJoinTime"] == DBNull.Value)
                    {
                        visible = false;
                    }
                    actionButton.IconCssClass = "icon-arrow-right-rect";
                }
                else if (name == "action_revoke")
                {
                    // Can't revoke access to the creator of the room
                    // Can't revoke access to the public room
                    if (!ChatRoom.ChatRoomPrivate || ((int)row["ChatRoomUserAdminLevel"] == (int)AdminLevelEnum.Creator))
                    {
                        visible = false;
                    }
                    actionButton.IconCssClass = "icon-times-circle color-red-70";
                }
                else if (name == "action_edit")
                {
                    actionButton.IconCssClass = "icon-edit";
                    actionButton.IconStyle    = GridIconStyle.Allow;
                }
            }

            if (!visible)
            {
                actionButton.Visible = false;
            }
            else if (!HasUserModifyPermission)
            {
                actionButton.Enabled = false;
            }

            break;
        }

        return(parameter);
    }
    /// <summary>
    /// Builds startup script.
    /// </summary>
    private string BuildStartupScript()
    {
        string redirectURL = RedirectURL.Length > 0 ? RedirectURL : ChatSettingsProvider.RedirectURLJoinSetting;

        // Set all the transformation settings for chat room window
        int roomSettingsId = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName);

        JavaScriptSerializer sr = new JavaScriptSerializer();
        string json             = sr.Serialize(
            new
        {
            guid                              = roomSettingsId,
            clientID                          = ClientID,
            groupID                           = GroupID,
            pnlChatRoomsList                  = pnlChatRoomsList.ClientID,
            pnlChatRoomsPrompt                = pnlChatRoomsPrompt.ClientID,
            btnChatRoomsPromptSubmit          = btnChatRoomsPromptSubmit.ClientID,
            pnlChatRoomsCreatePrompt          = pnlChatRoomsCreatePrompt.ClientID,
            txtChatRoomsCreateName            = txtChatRoomsCreateName.ClientID,
            chkChatRoomsCreateIsPrivate       = chkChatRoomsCreateIsPrivate.ClientID,
            txtChatRoomsCreatePassword        = txtChatRoomsCreatePassword.ClientID,
            chkChatRoomsCreateAllowAnonym     = chkChatRoomsCreateAllowAnonym.ClientID,
            btnChatRoomsCreatePromptSubmit    = btnChatRoomsCreatePromptSubmit.ClientID,
            lblChatRoomsCreateError           = lblChatRoomsCreateError.ClientID,
            txtChatRoomsPromptInput           = txtChatRoomsPromptInput.ClientID,
            btnChatRoomsCreateRoom            = btnChatRoomsCreateRoom.ClientID,
            templateListItem                  = ChatUIHelper.GetWebpartTransformation(ListItemTransformation, "chat.error.transformation.rooms"),
            loadingDiv                        = ChatUIHelper.GetWebpartLoadingDiv("ChatRoomsWPLoading", "chat.wploading.rooms"),
            txtChatRoomsCreateDescription     = txtChatRoomsCreateDescription.ClientID,
            btnChatRoomsPromptClose           = btnChatRoomsPromptClose.ClientID,
            btnChatRoomsCreatePromptClose     = btnChatRoomsCreatePromptClose.ClientID,
            btnChatRoomsDeletePromptSubmit    = btnChatRoomsDeletePromptSubmit.ClientID,
            btnChatRoomsDeletePromptClose     = btnChatRoomsDeletePromptClose.ClientID,
            pnlChatRoomsDeletePrompt          = pnlChatRoomsDeletePrompt.ClientID,
            btnChatRoomsAbandonPromptSubmit   = btnChatRoomsAbandonPromptSubmit.ClientID,
            btnChatRoomsAbandonPromptClose    = btnChatRoomsAbandonPromptClose.ClientID,
            pnlChatRoomsAbandonPrompt         = pnlChatRoomsAbandonPrompt.ClientID,
            pnlChatRoomsEditPrompt            = pnlChatRoomsEditPrompt.ClientID,
            txtChatRoomsEditName              = txtChatRoomsEditName.ClientID,
            txtChatRoomsEditDescription       = txtChatRoomsEditDescription.ClientID,
            chkChatRoomsEditIsPrivate         = chkChatRoomsEditIsPrivate.ClientID,
            txtChatRoomsEditPassword          = txtChatRoomsEditPassword.ClientID,
            chkChatRoomsEditAllowAnonym       = chkChatRoomsEditAllowAnonym.ClientID,
            btnChatRoomsEditPromptSubmit      = btnChatRoomsEditPromptSubmit.ClientID,
            btnChatRoomsEditPromptClose       = btnChatRoomsEditPromptClose.ClientID,
            txtChatRoomsEditPasswordConfirm   = txtChatRoomsEditPasswordConfirm.ClientID,
            lblChatRoomsEditError             = lblChatRoomsEditError.ClientID,
            passwordTxt                       = ResHelper.GetString("chat.password") + ":",
            passwordNewTxt                    = ResHelper.GetString("chat.passwordnew") + ":",
            lblChatRoomsEditPasswordNew       = lblChatRoomsEditPasswordNew.ClientID,
            txtChatRoomsCreatePasswordConfirm = txtChatRoomsCreatePasswordConfirm.ClientID,
            pnlChatRoomsEditError             = pnlChatRoomsEditError.ClientID,
            chkChatRoomsHasPassword           = chkChatRoomsHasPassword.ClientID,
            pnlChatRoomsCreateError           = pnlChatRoomsCreateError.ClientID,
            pnlFilterClientID                 = pnlChatRoomsFiltering.ClientID,
            pnlPagingClientID                 = pnlChatRoomsPaging.ClientID,
            pagingItems                       = PagingItems > 0 ? PagingItems : ChatSettingsProvider.WPPagingItems,
            groupPagesBy                      = GroupPagesBy >= 0 ? GroupPagesBy : ChatSettingsProvider.WPGroupPagesBy,
            pagingEnabled                     = EnablePaging,
            btnFilter                         = btnChatRoomsFilter.ClientID,
            txtFilter                         = txtChatRoomsFilter.ClientID,
            filterEnabled                     = EnableFiltering,
            pnlInfo                           = pnlChatRoomsInfo.ClientID,
            resStrNoFound                     = ResHelper.GetString("chat.rooms.notfound"),
            resStrResults                     = ResHelper.GetString("chat.rooms.results"),
            resStrTooltipPopup                = ResHelper.GetString("chat.enterwithpopup"),
            filterCount                       = ShowFilterItems >= 0 ? ShowFilterItems : ChatSettingsProvider.WPShowFilterLimit,
            passwordPromptError               = pnlChatRoomsPromptPasswordError.ClientID,
            redirectURL                       = ChatHelper.GetDocumentAbsoluteUrl(redirectURL),
            redirectGroup                     = RedirectGroup,
            envelopeID                        = "envelope_" + ClientID,
            pnlErrorCreate                    = pnlChatRoomsCreateErrorConfirm.ClientID,
            pnlErrorEdit                      = pnlChatRoomsEditErrorConfirm.ClientID,
            enablePopup                       = EnablePopup,
            passwordNotMatchStr               = ResHelper.GetString("administration-user_edit_password.passwordsdonotmatch")
        }
            );

        return(String.Format("InitChatRooms({0})", json));
    }
 protected void Page_Prerender(object sender, EventArgs e)
 {
     ChatUIHelper.MakeWebpartEnvelope("ChatWebpartEnvelope ChatWebpartEnvelopeNotification", this, InnerContainerTitle, InnerContainerName);
     ChatCssHelper.RegisterStylesheet(Page);
 }
Exemplo n.º 20
0
    object Grid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        string name = sourceName.ToLowerCSafe();

        switch (name)
        {
        case "chatmessageauthor":
        {
            DataRowView row = (DataRowView)parameter;

            if (row["AuthorNickname"] == DBNull.Value)
            {
                return("<span style=\"color: #777777; font-style: italic;\">" + GetString("chat.system") + "</span>");
            }

            int    chatUserID  = ValidationHelper.GetInteger(row["ChatMessageUserID"], 0);
            string nickname    = ValidationHelper.GetString(row["AuthorNickname"], "AuthorNickname");
            bool   isAnonymous = ValidationHelper.GetBoolean(row["AuthorIsAnonymous"], true);

            return(ChatUIHelper.GetCMSDeskChatUserField(this, chatUserID, nickname, isAnonymous));
        }

        case "edit":
        case "reject":
        case "delete":
        {
            DataRowView row = (DataRowView)((GridViewRow)parameter).DataItem;

            // Whisper message is consider as system here - it can't be rejected or edited
            ChatMessageTypeEnum msgType = (ChatMessageTypeEnum)ValidationHelper.GetInteger(row["ChatMessageSystemMessageType"], 0);
            bool isSystem = ((msgType != ChatMessageTypeEnum.ClassicMessage) && (msgType != ChatMessageTypeEnum.Announcement));

            bool enabled      = true;
            var  actionButton = (CMSGridActionButton)sender;

            if (isSystem)
            {
                if (name == "edit" || name == "reject")
                {
                    // Disable edit and reject buttons for system messages
                    enabled = false;
                }
            }
            else
            {
                if (name == "reject")
                {
                    bool isRejected = ValidationHelper.GetBoolean(row["ChatMessageRejected"], false);
                    if (isRejected)
                    {
                        actionButton.IconCssClass = "icon-check-circle";
                        actionButton.IconStyle    = GridIconStyle.Allow;
                        actionButton.ToolTip      = GetString("general.approve");
                    }
                }
            }

            if (!HasUserModifyPermission && name != "edit")
            {
                enabled = false;
            }

            actionButton.Enabled = enabled;

            break;
        }

        case "chatmessagesystemmessagetype":
        {
            DataRowView row = (DataRowView)parameter;

            ChatMessageTypeEnum messageType = (ChatMessageTypeEnum)ValidationHelper.GetInteger(row["ChatMessageSystemMessageType"], 0);

            if (messageType == ChatMessageTypeEnum.Whisper)
            {
                ChatUserInfo recipient = ChatUserInfoProvider.GetChatUserInfo(ValidationHelper.GetInteger(row["ChatMessageRecipientID"], 0));

                if (recipient != null)
                {
                    // Set text to the format "Whisper to somebody", where somebody may be link to the user if he is not anonymous

                    return(String.Format(ResHelper.GetString("chat.system.cmsdesk.whisperto"), ChatUIHelper.GetCMSDeskChatUserField(this, recipient)));
                }
            }

            return(messageType.ToStringValue((int)ChatMessageTypeStringValueUsageEnum.CMSDeskDescription));
        }

        case "chatmessagetext":
        {
            DataRowView row = (DataRowView)parameter;

            ChatMessageTypeEnum messageType = (ChatMessageTypeEnum)ValidationHelper.GetInteger(row["ChatMessageSystemMessageType"], 0);

            string messageText = ValidationHelper.GetString(row["ChatMessageText"], "");

            if (messageType.IsSystemMessage())
            {
                messageText = MacroResolver.Resolve(messageText);
            }

            return(HTMLHelper.HTMLEncode(messageText));
        }
        }

        return(parameter);
    }