protected override void OnInit(EventArgs e) { base.OnInit(e); // Get user ID from query string userId = ValidationHelper.GetInteger(Request.QueryString["userID"], 0); if (userId > 0) { // Check that only global administrator can edit global administrator's accounts UserInfo ui = UserInfoProvider.GetUserInfo(userId); CheckUserAvaibleOnSite(ui); EditedObject = ui; if (!CheckGlobalAdminEdit(ui)) { plcUserCustomFields.Visible = false; plcUserSettingsCustomFields.Visible = false; ShowError(GetString("Administration-User_List.ErrorGlobalAdmin")); return; } } // Setup user info for user custom fields dataform formUserCustomFields.Info = UserInfoProvider.GetUserInfo(userId); // If table has not any custom field hide custom field placeholder if ((formUserCustomFields.Info == null) || !formUserCustomFields.BasicForm.FormInformation.GetFormElements(true, false, true).Any()) { plcUserCustomFields.Visible = false; } else { // Setup the User DataForm formUserCustomFields.BasicForm.HideSystemFields = true; formUserCustomFields.BasicForm.CssClass = "ContentDataFormButton"; formUserCustomFields.BasicForm.SubmitButton.Visible = false; } // Setup user settings info for user settings custom fields dataform formUserSettingsCustomFields.Info = UserSettingsInfoProvider.GetUserSettingsInfoByUser(userId); if ((formUserSettingsCustomFields.Info == null) || !formUserSettingsCustomFields.BasicForm.FormInformation.GetFormElements(true, false, true).Any()) { plcUserSettingsCustomFields.Visible = false; } else { // Setup the UserSettings DataForm formUserSettingsCustomFields.BasicForm.HideSystemFields = true; formUserSettingsCustomFields.BasicForm.CssClass = "ContentDataFormButton"; formUserSettingsCustomFields.BasicForm.SubmitButton.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { CopyValues(forumEdit); if (IsAdHocForum) { plcHeader.Visible = false; } forumEdit.OnPreview += forumEdit_OnPreview; forumEdit.OnModerationRequired += new EventHandler(forumEdit_OnModerationRequired); // Check whether subscription is for forum or post if (ForumContext.CurrentReplyThread == null) { ltrTitle.Text = GetString("Forums_ForumNewPost_Header.NewThread"); if (ForumContext.CurrentPost != null && ForumContext.CurrentMode == ForumMode.Edit) { ltrTitle.Text = GetString("Forums_ForumNewPost_Header.EditPost"); } } else { plcPreview.Visible = true; ltrTitle.Text = GetString("Forums_ForumNewPost_Header.Reply"); ltrAvatar.Text = AvatarImage(ForumContext.CurrentReplyThread); ltrSubject.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostSubject); ltrText.Text = ResolvePostText(ForumContext.CurrentReplyThread.PostText); ltrUserName.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostUserName); ltrTime.Text = CMSContext.ConvertDateTime(ForumContext.CurrentReplyThread.PostTime, this).ToString(); UserSettingsInfo usi = UserSettingsInfoProvider.GetUserSettingsInfoByUser(ForumContext.CurrentReplyThread.PostUserID); BadgeInfo bi = null; string badgeName = null; string badgeImageUrl = null; if (usi != null) { bi = BadgeInfoProvider.GetBadgeInfo(usi.UserBadgeID); if (bi != null) { badgeName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(bi.BadgeDisplayName)); badgeImageUrl = HTMLHelper.HTMLEncode(bi.BadgeImageURL); } } ltrBadge.Text = GetNotEmpty(badgeName, "<div class=\"Badge\">" + badgeName + "</div>", "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>", ForumActionType.Badge) + GetNotEmpty(badgeImageUrl, "<div class=\"BadgeImage\"><img alt=\"" + badgeName + "\" src=\"" + GetImageUrl(ValidationHelper.GetString(badgeImageUrl, "")) + "\" /></div>", "", ForumActionType.Badge); } }
/// <summary> /// Handles the Click event of the btnPopupOK control. /// </summary> protected void btnPopupOK_Click(object sender, EventArgs e) { Position = WebPartToolbarPositionEnumFunctions.GetWebPartToolbarPositionEnum(drpPosition.SelectedValue); // Set the position currentUser.UserSettings.UserWebPartToolbarEnabled = chkWptEnabled.Checked; currentUser.UserSettings.UserWebPartToolbarPosition = Position; UserSettingsInfoProvider.SetUserSettingsInfo(currentUser.UserSettings); if (!chkWptEnabled.Checked) { // Hide the toolbar Visible = false; } }
protected void SetupControls() { // If current control context is widget or livesite hide site selector if (ControlsHelper.CheckControlContext(this, ControlContext.WIDGET_PROPERTIES) || ControlsHelper.CheckControlContext(this, ControlContext.LIVE_SITE)) { ShowSiteFilter = false; } // Set prefix if not set if (ResourcePrefix == String.Empty) { // Set resource prefix based on mode if ((SelectionMode == SelectionModeEnum.Multiple) || (SelectionMode == SelectionModeEnum.MultipleButton) || (SelectionMode == SelectionModeEnum.MultipleTextBox)) { usUsers.ResourcePrefix = "selectusers"; } } // Add sites filter if (ShowSiteFilter) { usUsers.FilterControl = "~/CMSFormControls/Filters/SiteFilter.ascx"; usUsers.SetValue("DefaultFilterValue", (SiteID > 0) ? SiteID : SiteContext.CurrentSiteID); usUsers.SetValue("FilterMode", "user"); } // Generate WhereCondtion based on SelectUser's properties var usersWhereCondition = new WhereCondition(); var userTypeInfo = ObjectTypeManager.GetTypeInfo(UserInfo.OBJECT_TYPE); // Hide hidden users if (HideHiddenUsers) { var apparentUsersCondition = new WhereCondition().WhereEqualsOrNull("UserIsHidden", 0); usersWhereCondition.And(apparentUsersCondition); } // Hide disabled users if (HideDisabledUsers) { var enabledUsersCondition = new WhereCondition(UserInfoProvider.USER_ENABLED_WHERE_CONDITION); usersWhereCondition.And(enabledUsersCondition); } // Hide non-approved users if (HideNonApprovedUsers) { var approvedUserIDs = UserSettingsInfoProvider .GetUserSettings() .WhereEqualsOrNull("UserWaitingForApproval", 0) .Column("UserSettingsUserID"); var approvedUsersCondition = new WhereCondition().WhereIn(userTypeInfo.IDColumn, approvedUserIDs); usersWhereCondition.And(approvedUsersCondition); } // Select group users if (GroupID > 0) { var groupUserIDs = new ObjectQuery(PredefinedObjectType.GROUPMEMBER) .WhereEquals("MemberGroupID", GroupID) .Column("MemberUserID"); // Hide non-approved group users if (HideNonApprovedUsers) { groupUserIDs.WhereNull("MemberRejectedWhen"); } var usersInGroupCondition = new WhereCondition().WhereIn(userTypeInfo.IDColumn, groupUserIDs); usersWhereCondition.And(usersInGroupCondition); } // Select users in role if (RoleID > 0) { var usersInRoleIDs = UserRoleInfoProvider .GetUserRoles() .WhereEquals("RoleID", RoleID) .Column("UserID"); var usersInRoleCondition = new WhereCondition().WhereIn(userTypeInfo.IDColumn, usersInRoleIDs); usersWhereCondition.And(usersInRoleCondition); } // Select users depending on site; if filter enabled, where condition is added from filter itself if (!ShowSiteFilter && (SiteID >= 0) && !DisplayUsersFromAllSites) { int siteID = (SiteID == 0) ? SiteContext.CurrentSiteID : SiteID; var siteUserIDs = UserSiteInfoProvider .GetUserSites() .WhereEquals("SiteID", siteID) .Column("UserID"); var siteUsersCondition = new WhereCondition().WhereIn(userTypeInfo.IDColumn, siteUserIDs); if (TreatGlobalAdminsAsSiteUsers) { siteUsersCondition.Or(GetPrivilegeLevelCondition()); } usersWhereCondition.And(siteUsersCondition); } if (AlwaysShowGlobalAdministrators) { // New instance has to be created in order to produce brackets usersWhereCondition = new WhereCondition(usersWhereCondition).Or(GetPrivilegeLevelCondition()); } // Add additional users if ((AdditionalUsers != null) && (AdditionalUsers.Length > 0)) { var additionalUsersCondition = new WhereCondition().WhereIn(userTypeInfo.IDColumn, AdditionalUsers); new WhereCondition(usersWhereCondition).Or(additionalUsersCondition); } // Control where condition if (!String.IsNullOrEmpty(WhereCondition)) { usersWhereCondition = new WhereCondition(usersWhereCondition).And(new WhereCondition(WhereCondition)); } // Append generated where condition usUsers.WhereCondition = SqlHelper.AddWhereCondition(usUsers.WhereCondition, usersWhereCondition.ToString(expand: true)); pnlUpdate.ShowProgress = (SelectionMode == SelectionModeEnum.Multiple); }