Exemplo n.º 1
0
    void UIFormControl_OnBeforeDataRetrieval(object sender, EventArgs e)
    {
        // Set site id and other data if the room is new
        if ((UIContext.EditedObject == null) || (((ChatRoomInfo)UIContext.EditedObject).ChatRoomID <= 0))
        {
            IDataContainer data = UIFormControl.Data;
            data["ChatRoomCreatedByChatUserID"] = ChatUserHelper.GetChatUserFromCMSUser().ChatUserID;
            data["ChatRoomCreatedWhen"]         = DateTime.Now; // GETDATE() will be used on SQL Server side
            data["ChatRoomSiteID"] = SiteID;

            Guid guid = Guid.NewGuid();
            data["ChatRoomGUID"] = guid;

            EditingFormControl passwordEditingControl = UIFormControl.FieldEditingControls["chatroompassword"];
            string             password = passwordEditingControl.Value.ToString();
            passwordEditingControl.Value = ChatRoomHelper.GetRoomPasswordHash(password, guid);
        }
        else
        {
            ChatRoomInfo       room           = UIContext.EditedObject as ChatRoomInfo;
            EditingFormControl enabledControl = UIFormControl.FieldEditingControls["chatroomenabled"];
            bool enabled = (bool)enabledControl.Value;
            if (room.ChatRoomEnabled != enabled)
            {
                if (enabled)
                {
                    ChatRoomHelper.EnableChatRoom(room.ChatRoomID);
                }
                else
                {
                    ChatRoomHelper.DisableChatRoom(room.ChatRoomID);
                }
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Sets password of current room.
    /// </summary>
    protected void ButtonSetPassword_Click(object sender, EventArgs e)
    {
        // Check modify permission
        ((CMSChatPage)Page).CheckModifyPermission(SiteID);

        string result = "";

        if (TypedEditedObject != null)
        {
            if (TextBoxConfirmPassword.Text == passStrength.Text)
            {
                //password has been changed
                if (passStrength.Text != hiddenPassword)
                {
                    TypedEditedObject.ChatRoomPassword = ChatRoomHelper.GetRoomPasswordHash(passStrength.Text, TypedEditedObject.ChatRoomGUID);
                    TypedEditedObject.Update();

                    // Show actual information to the user
                    if (passStrength.Text != String.Empty)
                    {
                        InformAboutPassword(true);
                    }
                    else
                    {
                        InformAboutPassword(false);
                    }

                    ShowChangesSaved();
                }
            }
            else
            {
                result = GetString("chat.passwordsdonotmatch");
            }
        }

        if (!String.IsNullOrEmpty(result))
        {
            ShowError(result);
        }
    }