Exemple #1
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);
    }
Exemple #2
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(ChatHelper.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"), ChatHelper.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);
    }
    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);
    }
Exemple #4
0
    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 = ChatHelper.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;
            }
        }
    }
Exemple #5
0
    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(ChatHelper.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);
    }