void EditForm_OnBeforeSave(object sender, EventArgs e) { int chatUserID; if (IsEditing) { chatUserID = TypedEditedObject.ChatRoomUserChatUserID; } else { int userID = ValidationHelper.GetInteger(fUserSelector.Value, 0); chatUserID = ChatUserHelper.GetChatUserFromCMSUser(UserInfoProvider.GetUserInfo(userID)).ChatUserID; } AdminLevelEnum adminLevel = ChatHelper.GetEnum(Convert.ToInt32(fdrpAdminLevel.SelectedValue), AdminLevelEnum.None); ChatRoomUserHelper.SetChatAdminLevel(ChatRoomID, chatUserID, adminLevel); URLHelper.Redirect(string.Format("List.aspx?roomid={0}&saved=1", ChatRoomID)); // Stop processing, because save was handled manually UIFormControl.StopProcessing = true; }
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); }