protected void Page_Load(object sender, EventArgs e) { currentUser = MembershipContext.AuthenticatedUser; currentObject = (ContactStatusInfo)EditedObject; // Check read permission currentObjectSiteId = currentObject.ContactStatusID != 0 ? currentObject.ContactStatusSiteID : siteID; CheckReadPermission(currentObjectSiteId); // Preserve site info passed in query PageBreadcrumbs.Items[0].RedirectUrl = AddSiteQuery(PageBreadcrumbs.Items[0].RedirectUrl, siteID); EditForm.RedirectUrlAfterSave = AddSiteQuery(EditForm.RedirectUrlAfterSave, siteID); ContactStatusInfo contactStatus = EditForm.EditedObject as ContactStatusInfo; // Set new site ID for new object if ((contactStatus == null) || (contactStatus.ContactStatusID < 1)) { if ((siteID == UniSelector.US_GLOBAL_RECORD) && ModifyGlobalConfiguration) { EditForm.Data["ContactStatusSiteID"] = null; } else if (IsSiteManager && currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { EditForm.Data["ContactStatusSiteID"] = siteID; } else { EditForm.Data["ContactStatusSiteID"] = SiteContext.CurrentSiteID; } } }
protected void Page_Load(object sender, EventArgs e) { currentUser = MembershipContext.AuthenticatedUser; currentObject = (ContactRoleInfo)EditedObject; // Check read permission currentObjectSiteId = currentObject.ContactRoleID != 0 ? currentObject.ContactRoleSiteID : siteID; CheckReadPermission(currentObjectSiteId); // Preserve site info passed in query PageBreadcrumbs.Items[0].RedirectUrl = AddSiteQuery(PageBreadcrumbs.Items[0].RedirectUrl, siteID); EditForm.RedirectUrlAfterSave = AddSiteQuery(EditForm.RedirectUrlAfterSave, siteID); ContactRoleInfo contactRole = EditForm.EditedObject as ContactRoleInfo; // Set new site ID for new object if ((contactRole == null) || (contactRole.ContactRoleID < 1)) { if ((siteID == UniSelector.US_GLOBAL_RECORD) && ModifyGlobalConfiguration) { EditForm.Data["ContactRoleSiteID"] = null; } else if (IsSiteManager && currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { EditForm.Data["ContactRoleSiteID"] = siteID; } else { EditForm.Data["ContactRoleSiteID"] = SiteContext.CurrentSiteID; } } }
protected void Page_Load(object sender, EventArgs e) { mCurrentUser = MembershipContext.AuthenticatedUser; mCurrentCulture = CultureHelper.PreferredUICultureCode; RegisterEventHandlers(); if (!RequestHelper.IsCallback()) { // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; InitializeUniGrid(); RegisterPerformActionScript(); AssignPerformActionScriptToBtnOkOnclick(); // Initialize dropdown list with actions if (!RequestHelper.IsPostBack()) { if (mCurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || mCurrentUser.IsAuthorizedPerResource("CMS.Content", "manageworkflow")) { PopulateActionDropDown(); } PopulateWhatSelectionDropDown(); } } docElem.SiteName = filterDocuments.SelectedSite; }
/// <summary> /// Init event handler /// </summary> protected override void OnInit(EventArgs e) { base.OnInit(e); SiteID = CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) ? 0 : SiteContext.CurrentSiteID; // Set site id for the control prmhdrHeader.SiteID = SiteID; CurrentUserInfo user = MembershipContext.AuthenticatedUser; if (user != null) { // Check site availability if (!user.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) { if (!ResourceSiteInfoProvider.IsResourceOnSite(ModuleName.PERMISSIONS, SiteContext.CurrentSiteName)) { RedirectToResourceNotAvailableOnSite(ModuleName.PERMISSIONS); } } // Check "read" permission if (!user.IsAuthorizedPerResource(ModuleName.PERMISSIONS, "Read")) { RedirectToAccessDenied(ModuleName.PERMISSIONS, "Read"); } } }
/// <summary> /// Reload data. /// </summary> public override void ReloadData() { requestedGroupId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0); DataTable table = new DataTable(); table.Columns.Add("ActionDisplayName"); table.Columns.Add("ActionScript"); // Add only if community is present if (CommunityPresent) { // Get resource strings prefix string resourcePrefix = ContextMenu.ResourcePrefix; // View group profile string profileUrl = ""; // Get group profile URL GeneralizedInfo infoObj = ModuleCommands.CommunityGetGroupInfo(requestedGroupId); if (infoObj != null) { profileUrl = ResolveUrl(DocumentURLProvider.GetUrl(ModuleCommands.CommunityGetGroupProfilePath(infoObj.ObjectCodeName, SiteContext.CurrentSiteName))); } table.Rows.Add(new object[] { ResHelper.GetString(resourcePrefix + ".viewgroup|group.viewgroup"), "window.location.replace('" + profileUrl + "');" }); if (!currentUser.IsGroupMember(requestedGroupId)) { table.Rows.Add(new object[] { ResHelper.GetString(resourcePrefix + ".joingroup|group.joingroup"), !currentUser.IsPublic() ? "ContextJoinTheGroup(GetContextMenuParameter('" + ContextMenu.MenuID + "'))" : "ContextRedirectToSignInUrl()" }); } else { table.Rows.Add(new object[] { ResHelper.GetString(resourcePrefix + ".leavegroup|group.leavegroup"), !currentUser.IsPublic() ? "ContextLeaveTheGroup(GetContextMenuParameter('" + ContextMenu.MenuID + "'))" : "ContextRedirectToSignInUrl()" }); } if (infoObj != null) { // Display Manage the group link if user is logged as group administrator and user is visiting a group page if (currentUser.IsGroupAdministrator(requestedGroupId) || currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) { string managementUrl = ResolveUrl(DocumentURLProvider.GetUrl(ModuleCommands.CommunityGetGroupManagementPath(infoObj.ObjectCodeName, SiteContext.CurrentSiteName))); table.Rows.Add(new object[] { ResHelper.GetString(resourcePrefix + ".managegroup|group.managegroup"), !currentUser.IsPublic() ? " window.location.replace('" + managementUrl + "');" : "ContextRedirectToSignInUrl()" }); } } } // Add count column DataColumn countColumn = new DataColumn(); countColumn.ColumnName = "Count"; countColumn.DefaultValue = table.Rows.Count; table.Columns.Add(countColumn); repItem.DataSource = table; repItem.DataBind(); }
/// <summary> /// Setups grid query parameters. /// </summary> private void SetupGridQueryParameters() { // Create query parameters QueryDataParameters parameters = new QueryDataParameters(); parameters.Add("@Now", DateTime.Now); if (ListingType == ListingTypeEnum.OutdatedDocuments) { parameters.Add("@SiteID", SiteContext.CurrentSiteID); } // Initialize UserID query parameter int userID = currentUserInfo.UserID; if (ListingType == ListingTypeEnum.PendingDocuments) { parameters.Add("@SiteID", SiteInfoProvider.GetSiteID(SiteName)); if ((currentUserInfo.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) || (currentUserInfo.IsAuthorizedPerResource("CMS.Content", "manageworkflow"))) { userID = -1; } } parameters.Add("@UserID", userID); // Document Age if (DocumentAge != String.Empty) { string[] ages = DocumentAge.Split(';'); if (ages.Length == 2) { // Add from a to values to temp parameters int from = ValidationHelper.GetInteger(ages[1], 0); int to = ValidationHelper.GetInteger(ages[0], 0); if (@from > 0) { gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, SOURCE_MODIFIEDWHEN + " >= @FROM"); parameters.Add("@FROM", DateTime.Now.AddDays((-1) * @from)); } if (to > 0) { gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, SOURCE_MODIFIEDWHEN + " <= @TO"); parameters.Add("@TO", DateTime.Now.AddDays((-1) * to)); } } } // Set parameters gridElem.QueryParameters = parameters; }
protected bool gridMatrix_CheckPermissions(object permId) { int permissionId = ValidationHelper.GetInteger(permId, 0); // Check how the permission can be edited PermissionNameInfo pni = PermissionNameInfoProvider.GetPermissionNameInfo(permissionId); if (pni != null) { return(currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) || !pni.PermissionEditableByGlobalAdmin); } return(true); }
protected override void OnInit(EventArgs e) { base.OnInit(e); currentSite = SiteContext.CurrentSite; currentUser = MembershipContext.AuthenticatedUser; // Check 'Manage' permission var manageBlogs = currentUser.IsAuthorizedPerResource("cms.blog", "Manage"); // There is no sense to display (ALL) in blogs DDL when // user does not have manage blogs permission if (!manageBlogs) { DisplayAllRecord = false; } var condition = new WhereCondition().WhereEquals("NodeSiteID", currentSite.SiteID); if (!currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && !manageBlogs) { condition.Where(BlogHelper.GetBlogsWhere(currentUser.UserID, currentUser.UserName, null)); } // Culture priority column to handle duplicities var culturePriority = new RowNumberColumn("CulturePriority", "BlogID"); culturePriority.PartitionBy = "NodeID"; // Init Blog selector uniSelector.DisplayNameFormat = "{%BlogName%}"; uniSelector.SelectionMode = SelectionModeEnum.SingleDropDownList; uniSelector.WhereCondition = condition.ToString(true); uniSelector.ReturnColumnName = "BlogID"; uniSelector.AdditionalColumns = culturePriority.ToString(); uniSelector.ObjectType = BlogHelper.BLOG_OBJECT_TYPE; uniSelector.ResourcePrefix = "unisiteselector"; uniSelector.AllowEmpty = false; uniSelector.AllowAll = false; uniSelector.OnAfterRetrieveData += uniSelector_OnAfterRetrieveData; // Preselect my blogs if (IsInMydesk && !RequestHelper.IsPostBack()) { uniSelector.Value = "##MYBLOGS##"; } }
/// <summary> /// Returns partial where condition based site/global settings and user permissions. /// </summary> /// <param name="currentUser">Current user.</param> private string GetSiteWhereCondition(CurrentUserInfo currentUser) { string where = string.Empty; // Add site specific product records if site doesn't offer global products or user doesn't have Modify global permission if (!offerGlobalProducts || categoryObj.CategorySiteID > 0 || (!currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && !currentUser.IsAuthorizedPerResource(ModuleName.ECOMMERCE, EcommercePermissions.ECOMMERCE_MODIFYGLOBAL))) { where = SqlHelper.AddWhereCondition(where, "SKUSiteID = " + SiteContext.CurrentSiteID); } // Add site specific and global product records else { where = SqlHelper.AddWhereCondition(where, "SKUSiteID = " + SiteContext.CurrentSiteID + " OR SKUSiteID IS NULL"); } return(where); }
protected DataSet gridBlogs_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords) { totalRecords = -1; if (drpBlogs.SelectedValue == "##MYBLOGS##") { // Get owned blogs return(BlogHelper.GetBlogs(SiteContext.CurrentSiteName, currentUser.UserID, null, columns, completeWhere)); } if ((currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) || (readBlogs)) { // Get all blogs return(BlogHelper.GetBlogs(SiteContext.CurrentSiteName, 0, null, columns, completeWhere)); } // Get owned or managed blogs return(BlogHelper.GetBlogs(SiteContext.CurrentSiteName, currentUser.UserID, currentUser.UserName, columns, completeWhere)); }
/// <summary> /// Preloads uniSelector and selects actual data. /// </summary> protected void PreloadUniSelector(bool offerGlobalProducts) { // Get the active products var products = SKUInfoProvider.GetSKUs().Column("SKUID") .WhereIn("SKUID", SKUTaxClassInfoProvider.GetSKUTaxClasses().Column("SKUID").WhereEquals("TaxClassID", mTaxClassId)) .WhereNull("SKUOptionCategoryID"); // Restrict site var includeGlobal = offerGlobalProducts && (cu.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || cu.IsAuthorizedPerResource(ModuleName.ECOMMERCE, EcommercePermissions.ECOMMERCE_MODIFYGLOBAL)); products.OnSite(mCurrentSiteId, includeGlobal); if (!DataHelper.DataSourceIsEmpty(products)) { mCurrentValues = TextHelper.Join(";", DataHelper.GetStringValues(products.Tables[0], "SKUID")); } if (!RequestHelper.IsPostBack()) { uniSelector.Value = mCurrentValues; } }
private string GetUniGridWhereCondition() { // Global administrators can see all forms. if (currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) { return("FormSiteID = " + SiteContext.CurrentSiteID); } var bizFormsAvailableForUser = BizFormInfo.Provider.Get() .Column("CMS_Form.FormID") .OnSite(SiteContext.CurrentSiteID) .Distinct() .Source(s => s.LeftJoin <BizFormRoleInfo>("FormID", "FormID")) .Where(new WhereCondition() .WhereIn("RoleID", UserRoleInfo.Provider.Get().Column("RoleID").WhereEquals("UserID", currentUser.UserID)) .Or() .WhereNull("FormAccess") .Or() .WhereEquals("FormAccess", (int)FormAccessEnum.AllBizFormUsers)); return(new WhereCondition().WhereIn("CMS_Form.FormID", bizFormsAvailableForUser).ToString(true)); }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData() { string where = null; bool authorizedSiteAccounts = false; bool authorizedGlobalAccounts = AccountHelper.AuthorizedReadAccount(UniSelector.US_GLOBAL_RECORD, false); currentUser = MembershipContext.AuthenticatedUser; if (SiteID > 0) { authorizedSiteAccounts = AccountHelper.AuthorizedReadAccount(SiteID, false); } else { authorizedSiteAccounts = AccountHelper.AuthorizedReadAccount(SiteContext.CurrentSiteID, false); } // Filter site objects if (SiteID > 0) { if (authorizedSiteAccounts) { where = "(AccountSiteID = " + SiteID + " AND AccountMergedWithAccountID IS NULL)"; } else { where = "(1=0)"; } } // Filter only global objects else if ((SiteID == UniSelector.US_GLOBAL_RECORD) || (SiteID == 0)) { if (authorizedGlobalAccounts) { where = "(AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL)"; } else { where = "(1=0)"; } } // Display current site and global contacts else if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD) { if (authorizedSiteAccounts && authorizedGlobalAccounts) { where = "(AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID = " + SiteContext.CurrentSiteID + " AND AccountMergedWithAccountID IS NULL)"; uniSelector.AddGlobalObjectSuffix = true; } else if (authorizedGlobalAccounts) { where = "(AccountSiteID IS NULL AND AccountMergedWithAccountID IS NULL)"; } else if (authorizedSiteAccounts) { where = "(AccountSiteID = " + SiteContext.CurrentSiteID + " AND AccountMergedWithAccountID IS NULL)"; } else { where = "(1=0)"; } } // Display all objects else if ((SiteID == UniSelector.US_ALL_RECORDS) && currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { where = "((AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID > 0 AND AccountMergedWithAccountID IS NULL))"; uniSelector.AddGlobalObjectSuffix = true; } // Not enough permissions else { where = "(1=0)"; } uniSelector.WhereCondition = SqlHelper.AddWhereCondition(WhereCondition, where); uniSelector.Reload(true); }
/// <summary> /// Creates default mass actions. Has to be called on Page_Init before MassActions extenders are initialized, so default actions will be at the beginning. /// </summary> private void CreateMassActionItems() { var urlBuilder = new DocumentListMassActionsUrlGenerator(); // Converts functions with signature as in DocumentListMassActionsUrlGenerator to CreateUrlDelegate as MassActionItem expects Func <Func <List <int>, DocumentListMassActionsParameters, string>, CreateUrlDelegate> functionConverter = generateActionFunction => { return((scope, selectedNodeIDs, parameters) => { return generateActionFunction(scope == MassActionScopeEnum.AllItems ? null : selectedNodeIDs, (DocumentListMassActionsParameters)parameters); }); }; ctrlMassActions.AddMassActions( new MassActionItem { CodeName = "action|move", DisplayNameResourceString = "general.move", CreateUrl = functionConverter(urlBuilder.GetMoveActionUrl), ActionType = MassActionTypeEnum.OpenModal, }, new MassActionItem { CodeName = "action|copy", DisplayNameResourceString = "general.copy", CreateUrl = functionConverter(urlBuilder.GetCopyActionUrl), ActionType = MassActionTypeEnum.OpenModal, }); ctrlMassActions.AddMassActions(new MassActionItem { CodeName = "action|link", DisplayNameResourceString = "general.link", CreateUrl = functionConverter(urlBuilder.GetLinkActionUrl), ActionType = MassActionTypeEnum.OpenModal, }); ctrlMassActions.AddMassActions(new MassActionItem { CodeName = "action|delete", DisplayNameResourceString = "general.delete", CreateUrl = functionConverter(urlBuilder.GetDeleteActionUrl), ActionType = MassActionTypeEnum.Redirect, }); if (CultureSiteInfoProvider.IsSiteMultilingual(currentSiteName) && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.TranslationServices) && TranslationServiceHelper.IsTranslationAllowed(currentSiteName) && TranslationServiceHelper.AnyServiceAvailable(currentSiteName)) { ctrlMassActions.AddMassActions(new MassActionItem { CodeName = "action|translate", DisplayNameResourceString = "general.translate", CreateUrl = functionConverter(urlBuilder.GetTranslateActionUrl), ActionType = MassActionTypeEnum.Redirect, }); } if (currentUserInfo.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || currentUserInfo.IsAuthorizedPerResource("CMS.Content", "ManageWorkflow")) { ctrlMassActions.AddMassActions( new MassActionItem { CodeName = "action|publish", DisplayNameResourceString = "general.publish", CreateUrl = functionConverter(urlBuilder.GetPublishActionUrl), ActionType = MassActionTypeEnum.Redirect, }, new MassActionItem { CodeName = "action|archive", DisplayNameResourceString = "general.archive", CreateUrl = functionConverter(urlBuilder.GetArchiveActionUrl), ActionType = MassActionTypeEnum.Redirect, }); } }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData() { string where = null; currentUser = MembershipContext.AuthenticatedUser; if (string.IsNullOrEmpty(uniSelector.AdditionalSearchColumns)) { uniSelector.FilterControl = "~/CMSModules/ContactManagement/FormControls/SearchContactFullName.ascx"; uniSelector.UseDefaultNameFilter = false; } bool authorizedSiteContacts = false; bool authorizedGlobalContacts = ContactHelper.AuthorizedReadContact(UniSelector.US_GLOBAL_RECORD, false); if (SiteID > 0) { authorizedSiteContacts = ContactHelper.AuthorizedReadContact(SiteID, false); } else { authorizedSiteContacts = ContactHelper.AuthorizedReadContact(SiteContext.CurrentSiteID, false); } // Filter site objects if (SiteID > 0) { if (authorizedSiteContacts) { where = "(ContactSiteID = " + SiteID + " AND ContactMergedWithContactID IS NULL)"; } else { where = "(1=0)"; } } // Filter only global objects else if ((SiteID == UniSelector.US_GLOBAL_RECORD) || (SiteID == 0)) { if (authorizedGlobalContacts) { where = "(ContactSiteID IS NULL AND ContactGlobalContactID IS NULL)"; } else { where = "(1=0)"; } } // Display current site and global contacts else if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD) { if (authorizedSiteContacts && authorizedGlobalContacts) { where = "(ContactSiteID IS NULL AND ContactGlobalContactID IS NULL) OR (ContactSiteID = " + SiteContext.CurrentSiteID + " AND ContactMergedWithContactID IS NULL)"; uniSelector.AddGlobalObjectSuffix = true; } else if (authorizedGlobalContacts) { where = "(ContactSiteID IS NULL AND ContactMergedWithContactID IS NULL)"; } else if (authorizedSiteContacts) { where = "(ContactSiteID = " + SiteContext.CurrentSiteID + " AND ContactMergedWithContactID IS NULL)"; } else { where = "(1=0)"; } } // Display all objects else if ((SiteID == UniSelector.US_ALL_RECORDS) && currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { where = "((ContactSiteID IS NULL AND ContactGlobalContactID IS NULL) OR (ContactSiteID > 0 AND ContactMergedWithContactID IS NULL))"; uniSelector.AddGlobalObjectSuffix = true; } // Not enough permissions else { where = "(1=0)"; } where = SqlHelper.AddWhereCondition(where, WhereCondition); uniSelector.WhereCondition = SqlHelper.AddWhereCondition(uniSelector.WhereCondition, where); uniSelector.Reload(true); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // Initialize properties string script = ""; // Set current user currentUser = MembershipContext.AuthenticatedUser; // Initialize strings lnkSignIn.Text = SignInText; lnkJoinCommunity.Text = JoinCommunityText; lnkMyProfile.Text = MyProfileText; lnkEditMyProfile.Text = EditMyProfileText; btnSignOut.Text = SignOutText; lnkCreateNewGroup.Text = CreateNewGroupText; lnkCreateNewBlog.Text = CreateNewBlogText; lnkJoinGroup.Text = JoinGroupText; lnkLeaveGroup.Text = LeaveGroupText; lnkInviteToGroup.Text = InviteGroupText; lnkManageGroup.Text = ManageGroupText; lnkMyInvitations.Text = MyInvitationsText; // If current user is public... if (currentUser.IsPublic()) { // Display Sign In link if set so if (DisplaySignIn) { // SignInPath returns URL - because of settings value lnkSignIn.NavigateUrl = MacroResolver.ResolveCurrentPath(SignInPath); pnlSignIn.Visible = true; pnlSignInOut.Visible = true; } // Display Join the community link if set so if (DisplayJoinCommunity) { lnkJoinCommunity.NavigateUrl = GetUrl(JoinCommunityPath); pnlJoinCommunity.Visible = true; pnlPersonalLinks.Visible = true; } } // If user is logged in else { // Display Sign out link if set so if (DisplaySignOut && !AuthenticationMode.IsWindowsAuthentication()) { pnlSignOut.Visible = true; pnlSignInOut.Visible = true; } // Display Edit my profile link if set so if (DisplayEditMyProfileLink) { lnkEditMyProfile.NavigateUrl = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(GroupMemberInfoProvider.GetMemberManagementPath(currentUser.UserName, SiteContext.CurrentSiteName))); pnlEditMyProfile.Visible = true; pnlProfileLinks.Visible = true; } // Display My profile link if set so if (DisplayMyProfileLink) { lnkMyProfile.NavigateUrl = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(GroupMemberInfoProvider.GetMemberProfilePath(currentUser.UserName, SiteContext.CurrentSiteName))); pnlMyProfile.Visible = true; pnlProfileLinks.Visible = true; } // Display Create new group link if set so if (DisplayCreateNewGroup) { lnkCreateNewGroup.NavigateUrl = GetUrl(CreateNewGroupPath); pnlCreateNewGroup.Visible = true; pnlGroupLinks.Visible = true; } // Display Create new blog link if set so if (DisplayCreateNewBlog) { // Check that Community Module is present var entry = ModuleManager.GetModule(ModuleName.BLOGS); if (entry != null) { lnkCreateNewBlog.NavigateUrl = GetUrl(CreateNewBlogPath); pnlCreateNewBlog.Visible = true; pnlBlogLinks.Visible = true; } } // Display My invitations link if (DisplayMyInvitations) { lnkMyInvitations.NavigateUrl = GetUrl(MyInvitationsPath); pnlMyInvitations.Visible = true; pnlPersonalLinks.Visible = true; } GroupMemberInfo gmi = null; if (CommunityContext.CurrentGroup != null) { // Get group info from community context GroupInfo currentGroup = CommunityContext.CurrentGroup; if (DisplayGroupLinks) { // Display Join group link if set so and user is visiting a group page gmi = GetGroupMember(MembershipContext.AuthenticatedUser.UserID, currentGroup.GroupID); if (gmi == null) { if (String.IsNullOrEmpty(JoinGroupPath)) { script += "function JoinToGroupRequest() {\n" + "modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/JoinTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestJoinToGroup', 500, 180); \n" + " } \n"; lnkJoinGroup.Attributes.Add("onclick", "JoinToGroupRequest();return false;"); lnkJoinGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkJoinGroup.NavigateUrl = GetUrl(JoinGroupPath); } pnlJoinGroup.Visible = true; pnlGroupLinks.Visible = true; } else if ((gmi.MemberStatus == GroupMemberStatus.Approved) || (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin))) // Display Leave the group link if user is the group member { if (String.IsNullOrEmpty(LeaveGroupPath)) { script += "function LeaveTheGroupRequest() {\n" + "modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/LeaveTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestLeaveThGroup', 500, 180); \n" + " } \n"; lnkLeaveGroup.Attributes.Add("onclick", "LeaveTheGroupRequest();return false;"); lnkLeaveGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkLeaveGroup.NavigateUrl = GetUrl(LeaveGroupPath); } pnlLeaveGroup.Visible = true; pnlGroupLinks.Visible = true; } } // Display Manage the group link if set so and user is logged as group administrator and user is visiting a group page if (DisplayManageGroup && (currentUser.IsGroupAdministrator(currentGroup.GroupID) || (currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)))) { lnkManageGroup.NavigateUrl = ResolveUrl(DocumentURLProvider.GetUrl(GroupInfoProvider.GetGroupManagementPath(currentGroup.GroupName, SiteContext.CurrentSiteName))); pnlManageGroup.Visible = true; pnlGroupLinks.Visible = true; } } // Get user info from site context UserInfo siteContextUser = MembershipContext.CurrentUserProfile; if (DisplayInviteToGroup) { // Get group info from community context GroupInfo currentGroup = CommunityContext.CurrentGroup; // Display invite to group link for user who is visiting a group page if (currentGroup != null) { // Get group user if (gmi == null) { gmi = GetGroupMember(MembershipContext.AuthenticatedUser.UserID, currentGroup.GroupID); } if (((gmi != null) && (gmi.MemberStatus == GroupMemberStatus.Approved)) || (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin))) { pnlInviteToGroup.Visible = true; if (String.IsNullOrEmpty(InviteGroupPath)) { script += "function InviteToGroup() {\n modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','inviteToGroup', 800, 450); \n } \n"; lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;"); lnkInviteToGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath); } } } // Display invite to group link for user who is visiting another user's page else if ((siteContextUser != null) && (siteContextUser.UserName != currentUser.UserName) && (GroupInfoProvider.GetUserGroupsCount(currentUser, SiteContext.CurrentSite) != 0)) { pnlInviteToGroup.Visible = true; if (String.IsNullOrEmpty(InviteGroupPath)) { script += "function InviteToGroup() {\n modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?invitedid=" + siteContextUser.UserID + "','inviteToGroup', 700, 400); \n } \n"; lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;"); lnkInviteToGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath); } } } } // Register menu management scripts ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Shortcuts_" + ClientID, ScriptHelper.GetScript(script)); // Register the dialog script ScriptHelper.RegisterDialogScript(Page); } }
protected void Page_Load(object sender, EventArgs e) { // Register script files ScriptHelper.RegisterCMS(this); ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js"); // Set current UI culture currentCulture = CultureHelper.PreferredUICultureCode; // Initialize current user currentUser = MembershipContext.AuthenticatedUser; // Initialize current site currentSite = SiteContext.CurrentSite; // Initialize events ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished; ctlAsyncLog.OnError += ctlAsyncLog_OnError; ctlAsyncLog.OnCancel += ctlAsyncLog_OnCancel; if (!RequestHelper.IsCallback()) { DataSet allDocs = null; TreeProvider tree = new TreeProvider(currentUser); // Current Node ID to delete string parentAliasPath = string.Empty; if (Parameters != null) { parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty); } if (string.IsNullOrEmpty(parentAliasPath)) { nodeIdsArr = QueryHelper.GetString("nodeid", string.Empty).Trim('|').Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string nodeId in nodeIdsArr) { int id = ValidationHelper.GetInteger(nodeId, 0); if (id != 0) { nodeIds.Add(id); } } } else { var where = new WhereCondition(WhereCondition) .WhereNotEquals("ClassName", SystemDocumentTypes.Root); allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%", TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where.ToString(true), "DocumentName", TreeProvider.ALL_LEVELS, false, 0, DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath,NodeSKUID"); if (!DataHelper.DataSourceIsEmpty(allDocs)) { foreach (DataTable table in allDocs.Tables) { foreach (DataRow row in table.Rows) { nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0)); } } } } // Setup page title text and image PageTitle.TitleText = GetString("Content.DeleteTitle"); EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText); // Register the dialog script ScriptHelper.RegisterDialogScript(this); ctlAsyncLog.TitleText = GetString("ContentDelete.DeletingDocuments"); // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; bool isMultilingual = CultureSiteInfoProvider.IsSiteMultilingual(currentSite.SiteName); if (!isMultilingual) { // Set all cultures checkbox chkAllCultures.Checked = true; pnlAllCultures.Visible = false; } if (nodeIds.Count > 0) { if (nodeIds.Count == 1) { // Single document deletion int nodeId = ValidationHelper.GetInteger(nodeIds[0], 0); TreeNode node = null; if (string.IsNullOrEmpty(parentAliasPath)) { // Get any culture if current not found node = tree.SelectSingleNode(nodeId, CultureCode) ?? tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); } else { if (allDocs != null) { DataRow dr = allDocs.Tables[0].Rows[0]; node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr, tree); } } if (node != null) { bool rootDeleteDisabled = false; if (IsProductsMode) { string startingPath = SettingsKeyInfoProvider.GetValue(CurrentSiteName + ".CMSStoreProductsStartingPath"); if (node.NodeAliasPath.CompareToCSafe(startingPath) == 0) { string closeLink = "<a href=\"#\"><span style=\"cursor: pointer;\" " + "onclick=\"SelectNode(" + node.NodeID + "); return false;\">" + GetString("general.back") + "</span></a>"; ShowError(string.Format(GetString("com.productsection.deleteroot"), closeLink, "")); pnlDelete.Visible = false; rootDeleteDisabled = true; } } if (node.IsRoot() && isMultilingual) { // Hide 'Delete all cultures' checkbox pnlAllCultures.Visible = false; if (!URLHelper.IsPostback()) { // Check if there are any documents in another culture or current culture has some documents pnlDeleteRoot.Visible = IsAnyDocumentInAnotherCulture(node) && (tree.SelectNodesCount(SiteContext.CurrentSiteName, "/%", LocalizationContext.PreferredCultureCode, false, null, null, null, TreeProvider.ALL_LEVELS, false) > 0); if (pnlDeleteRoot.Visible) { // Insert 'Delete current root' option if current root node is translated to current culture if (node.DocumentCulture == LocalizationContext.PreferredCultureCode) { rblRoot.Items.Add(new ListItem(GetString("rootdeletion.currentroot"), "current")); } rblRoot.Items.Add(new ListItem(GetString("rootdeletion.currentculture"), "allculturepages")); rblRoot.Items.Add(new ListItem(GetString("rootdeletion.allpages"), "allpages")); } else { rblRoot.Items.Add(new ListItem(GetString("rootdeletion.allpages"), "allpages")); } if (rblRoot.SelectedIndex < 0) { rblRoot.SelectedIndex = 0; } } } // Display warning for root node if (!rootDeleteDisabled && node.IsRoot()) { if (!currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) { pnlDelete.Visible = false; ShowInformation(GetString("delete.rootonlyglobaladmin")); } else { if ((rblRoot.SelectedValue == "allpages") || !isMultilingual || ((rblRoot.SelectedValue == "allculturepages") && !IsAnyDocumentInAnotherCulture(node))) { messagesPlaceholder.ShowWarning(GetString("Delete.RootWarning")); plcDeleteRoot.Visible = true; } else { plcDeleteRoot.Visible = false; } } } hasChildren = node.NodeHasChildren; bool authorizedToDeleteSKU = !node.HasSKU || IsUserAuthorizedToModifySKU(node); if (!RequestHelper.IsPostBack()) { bool authorizedToDeleteDocument = IsUserAuthorizedToDeleteDocument(node); if (!authorizedToDeleteDocument || !authorizedToDeleteSKU) { pnlDelete.Visible = false; RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath))); } } if (node.IsLink) { PageTitle.TitleText = GetString("Content.DeleteTitleLink") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(node.GetDocumentName())) + "\""; headQuestion.Text = GetString("ContentDelete.QuestionLink"); chkAllCultures.Checked = true; plcCheck.Visible = false; } else { string nodeName = HTMLHelper.HTMLEncode(node.GetDocumentName()); // Get name for root document if (node.IsRoot()) { nodeName = HTMLHelper.HTMLEncode(currentSite.DisplayName); } PageTitle.TitleText = GetString("Content.DeleteTitle") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(nodeName)) + "\""; } // Show or hide checkbox pnlDestroy.Visible = CanDestroy(node); cancelNodeId = IsMultipleAction ? node.NodeParentID : node.NodeID; lblDocuments.Text = HTMLHelper.HTMLEncode(node.GetDocumentName()); SetSeoPanelVisibility(node); } else { if (!RequestHelper.IsPostBack()) { URLHelper.Redirect(AdministrationUrlHelper.GetInformationUrl("editeddocument.notexists")); } else { // Hide everything pnlContent.Visible = false; } } headQuestion.Text = GetString("ContentDelete.Question"); lblAllCultures.Text = GetString("ContentDelete.AllCultures"); lblDestroy.Text = GetString("ContentDelete.Destroy"); headDeleteDocument.Text = GetString("ContentDelete.Document"); } else if (nodeIds.Count > 1) { string where = "NodeID IN ("; foreach (int nodeID in nodeIds) { where += nodeID + ","; } where = where.TrimEnd(',') + ")"; DataSet ds = allDocs ?? tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", -1, false); if (!DataHelper.DataSourceIsEmpty(ds)) { string docList = null; if (string.IsNullOrEmpty(parentAliasPath)) { cancelNodeId = DataHelper.GetIntValue(ds.Tables[0].Rows[0], "NodeParentID"); } else { cancelNodeId = TreePathUtils.GetNodeIdByAliasPath(currentSite.SiteName, parentAliasPath); } bool canDestroy = true; bool permissions = true; foreach (DataTable table in ds.Tables) { foreach (DataRow dr in table.Rows) { bool isLink = (dr["NodeLinkedNodeID"] != DBNull.Value); string name = (string)dr["DocumentName"]; docList += HTMLHelper.HTMLEncode(name); if (isLink) { docList += DocumentUIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link); } docList += "<br />"; lblDocuments.Text = docList; // Set visibility of checkboxes TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr); SetSeoPanelVisibility(node); if (!IsUserAuthorizedToDeleteDocument(node)) { permissions = false; AddError(String.Format( GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)), null); } // Can destroy if "can destroy all previous AND current" canDestroy = CanDestroy(node) && canDestroy; if (!hasChildren) { hasChildren = node.NodeHasChildren; } } } pnlDelete.Visible = permissions; pnlDestroy.Visible = canDestroy; } else { if (!RequestHelper.IsPostBack()) { URLHelper.Redirect(AdministrationUrlHelper.GetInformationUrl("editeddocument.notexists")); } else { // Hide everything pnlContent.Visible = false; } } headQuestion.Text = GetString("ContentDelete.QuestionMultiple"); PageTitle.TitleText = GetString("Content.DeleteTitleMultiple"); lblAllCultures.Text = GetString("ContentDelete.AllCulturesMultiple"); lblDestroy.Text = GetString("ContentDelete.DestroyMultiple"); headDeleteDocument.Text = GetString("global.pages"); } lblAltPath.AssociatedControlClientID = selAltPath.PathTextBox.ClientID; selAltPath.SiteID = currentSite.SiteID; chkUseDeletedPath.CheckedChanged += chkUseDeletedPath_CheckedChanged; if (!RequestHelper.IsPostBack()) { selAltPath.Enabled = false; chkAltSubNodes.Enabled = false; chkAltAliases.Enabled = false; // Set default path if is defined selAltPath.Value = SettingsKeyInfoProvider.GetValue(CurrentSiteName + ".CMSDefaultDeletedNodePath"); if (!hasChildren) { chkAltSubNodes.Checked = false; chkAltSubNodes.Enabled = false; } } // If user has allowed cultures specified if (currentUser.UserHasAllowedCultures) { // Get all site cultures DataSet siteCultures = CultureSiteInfoProvider.GetSiteCultures(currentSite.SiteName); bool denyAllCulturesDeletion = false; // Check that user can edit all site cultures foreach (DataRow culture in siteCultures.Tables[0].Rows) { string cultureCode = DataHelper.GetStringValue(culture, "CultureCode"); if (!currentUser.IsCultureAllowed(cultureCode, currentSite.SiteName)) { denyAllCulturesDeletion = true; } } // If user can't edit all site cultures if (denyAllCulturesDeletion) { // Hide all cultures selector pnlAllCultures.Visible = false; chkAllCultures.Checked = false; } } pnlDeleteDocument.Visible = pnlAllCultures.Visible || pnlDestroy.Visible; } else { // Hide everything pnlContent.Visible = false; } } // Initialize header action InitializeActionMenu(); }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData() { string where = null; bool authorizedSiteAccounts = false; bool authorizedGlobalAccounts = AccountHelper.AuthorizedReadAccount(UniSelector.US_GLOBAL_RECORD, false); currentUser = MembershipContext.AuthenticatedUser; if (SiteID > 0) { authorizedSiteAccounts = AccountHelper.AuthorizedReadAccount(SiteID, false); } else { authorizedSiteAccounts = AccountHelper.AuthorizedReadAccount(SiteContext.CurrentSiteID, false); } // Filter site objects if (SiteID > 0) { if (authorizedSiteAccounts) { where = "(AccountSiteID = " + SiteID + " AND AccountMergedWithAccountID IS NULL)"; } else { where = "(1=0)"; } } // Filter only global objects else if ((SiteID == UniSelector.US_GLOBAL_RECORD) || (SiteID == 0)) { if (authorizedGlobalAccounts) { where = "(AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL)"; } else { where = "(1=0)"; } } // Display current site and global contacts else if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD) { if (authorizedSiteAccounts && authorizedGlobalAccounts) { where = "(AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID = " + SiteContext.CurrentSiteID + " AND AccountMergedWithAccountID IS NULL)"; uniSelector.AddGlobalObjectSuffix = true; } else if (authorizedGlobalAccounts) { where = "(AccountSiteID IS NULL AND AccountMergedWithAccountID IS NULL)"; } else if (authorizedSiteAccounts) { where = "(AccountSiteID = " + SiteContext.CurrentSiteID + " AND AccountMergedWithAccountID IS NULL)"; } else { where = "(1=0)"; } } // Display all objects else if ((SiteID == UniSelector.US_ALL_RECORDS) && currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { where = "((AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID > 0 AND AccountMergedWithAccountID IS NULL))"; uniSelector.AddGlobalObjectSuffix = true; } // Not enough permissions else { where = "(1=0)"; } uniSelector.WhereCondition = SqlHelper.AddWhereCondition(WhereCondition, where); uniSelector.Reload(true); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // Initialize properties string script = ""; // Set current user currentUser = MembershipContext.AuthenticatedUser; // Get Enable Friends setting bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(SiteContext.CurrentSiteName); // Initialize strings lnkSignIn.Text = SignInText; lnkJoinCommunity.Text = JoinCommunityText; lnkMyProfile.Text = MyProfileText; lnkEditMyProfile.Text = EditMyProfileText; btnSignOut.Text = SignOutText; lnkCreateNewGroup.Text = CreateNewGroupText; lnkCreateNewBlog.Text = CreateNewBlogText; lnkJoinGroup.Text = JoinGroupText; lnkLeaveGroup.Text = LeaveGroupText; lnkRejectFriendship.Text = RejectFriendshipText; requestFriendshipElem.LinkText = RequestFriendshipText; lnkSendMessage.Text = SendMessageText; lnkAddToContactList.Text = AddToContactListText; lnkAddToIgnoreList.Text = AddToIgnoreListText; lnkInviteToGroup.Text = InviteGroupText; lnkManageGroup.Text = ManageGroupText; lnkMyMessages.Text = MyMessagesText; lnkMyFriends.Text = MyFriendsText; lnkMyInvitations.Text = MyInvitationsText; // If current user is public... if (currentUser.IsPublic()) { // Display Sign In link if set so if (DisplaySignIn) { // SignInPath returns URL - because of settings value lnkSignIn.NavigateUrl = MacroResolver.ResolveCurrentPath(SignInPath); pnlSignIn.Visible = true; pnlSignInOut.Visible = true; } // Display Join the community link if set so if (DisplayJoinCommunity) { lnkJoinCommunity.NavigateUrl = GetUrl(JoinCommunityPath); pnlJoinCommunity.Visible = true; pnlPersonalLinks.Visible = true; } } // If user is logged in else { // Display Sign out link if set so if (DisplaySignOut && !RequestHelper.IsWindowsAuthentication()) { pnlSignOut.Visible = true; pnlSignInOut.Visible = true; } // Display Edit my profile link if set so if (DisplayEditMyProfileLink) { lnkEditMyProfile.NavigateUrl = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(GroupMemberInfoProvider.GetMemberManagementPath(currentUser.UserName, SiteContext.CurrentSiteName))); pnlEditMyProfile.Visible = true; pnlProfileLinks.Visible = true; } // Display My profile link if set so if (DisplayMyProfileLink) { lnkMyProfile.NavigateUrl = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(GroupMemberInfoProvider.GetMemberProfilePath(currentUser.UserName, SiteContext.CurrentSiteName))); pnlMyProfile.Visible = true; pnlProfileLinks.Visible = true; } // Display Create new group link if set so if (DisplayCreateNewGroup) { lnkCreateNewGroup.NavigateUrl = GetUrl(CreateNewGroupPath); pnlCreateNewGroup.Visible = true; pnlGroupLinks.Visible = true; } // Display Create new blog link if set so if (DisplayCreateNewBlog) { // Check that Community Module is present var entry = ModuleManager.GetModule(ModuleName.BLOGS); if (entry != null) { lnkCreateNewBlog.NavigateUrl = GetUrl(CreateNewBlogPath); pnlCreateNewBlog.Visible = true; pnlBlogLinks.Visible = true; } } // Display My messages link if (DisplayMyMessages) { lnkMyMessages.NavigateUrl = GetUrl(MyMessagesPath); pnlMyMessages.Visible = true; pnlPersonalLinks.Visible = true; } // Display My friends link if (DisplayMyFriends && friendsEnabled) { lnkMyFriends.NavigateUrl = GetUrl(MyFriendsPath); pnlMyFriends.Visible = true; pnlPersonalLinks.Visible = true; } // Display My invitations link if (DisplayMyInvitations) { lnkMyInvitations.NavigateUrl = GetUrl(MyInvitationsPath); pnlMyInvitations.Visible = true; pnlPersonalLinks.Visible = true; } GroupMemberInfo gmi = null; if (CommunityContext.CurrentGroup != null) { // Get group info from community context GroupInfo currentGroup = CommunityContext.CurrentGroup; if (DisplayGroupLinks) { script += "function ReloadPage(){" + ControlsHelper.GetPostBackEventReference(this, "") + "}"; // Display Join group link if set so and user is visiting a group page gmi = GetGroupMember(MembershipContext.AuthenticatedUser.UserID, currentGroup.GroupID); if (gmi == null) { if (String.IsNullOrEmpty(JoinGroupPath)) { script += "function JoinToGroupRequest() {\n" + "modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/JoinTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestJoinToGroup', 500, 180); \n" + " } \n"; lnkJoinGroup.Attributes.Add("onclick", "JoinToGroupRequest();return false;"); lnkJoinGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkJoinGroup.NavigateUrl = GetUrl(JoinGroupPath); } pnlJoinGroup.Visible = true; pnlGroupLinks.Visible = true; } else if ((gmi.MemberStatus == GroupMemberStatus.Approved) || (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin))) // Display Leave the group link if user is the group member { if (String.IsNullOrEmpty(LeaveGroupPath)) { script += "function LeaveTheGroupRequest() {\n" + "modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/LeaveTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestLeaveThGroup', 500, 180); \n" + " } \n"; lnkLeaveGroup.Attributes.Add("onclick", "LeaveTheGroupRequest();return false;"); lnkLeaveGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkLeaveGroup.NavigateUrl = GetUrl(LeaveGroupPath); } pnlLeaveGroup.Visible = true; pnlGroupLinks.Visible = true; } } // Display Manage the group link if set so and user is logged as group administrator and user is visiting a group page if (DisplayManageGroup && (currentUser.IsGroupAdministrator(currentGroup.GroupID) || (currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)))) { lnkManageGroup.NavigateUrl = ResolveUrl(DocumentURLProvider.GetUrl(GroupInfoProvider.GetGroupManagementPath(currentGroup.GroupName, SiteContext.CurrentSiteName))); pnlManageGroup.Visible = true; pnlGroupLinks.Visible = true; } } // Get user info from site context UserInfo siteContextUser = MembershipContext.CurrentUserProfile; if (DisplayInviteToGroup) { // Get group info from community context GroupInfo currentGroup = CommunityContext.CurrentGroup; // Display invite to group link for user who is visiting a group page if (currentGroup != null) { // Get group user if (gmi == null) { gmi = GetGroupMember(MembershipContext.AuthenticatedUser.UserID, currentGroup.GroupID); } if (((gmi != null) && (gmi.MemberStatus == GroupMemberStatus.Approved)) || (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin))) { pnlInviteToGroup.Visible = true; if (String.IsNullOrEmpty(InviteGroupPath)) { script += "function InviteToGroup() {\n modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','inviteToGroup', 800, 450); \n } \n"; lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;"); lnkInviteToGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath); } } } // Display invite to group link for user who is visiting another user's page else if ((siteContextUser != null) && (siteContextUser.UserName != currentUser.UserName) && (GroupInfoProvider.GetUserGroupsCount(currentUser, SiteContext.CurrentSite) != 0)) { pnlInviteToGroup.Visible = true; if (String.IsNullOrEmpty(InviteGroupPath)) { script += "function InviteToGroup() {\n modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?invitedid=" + siteContextUser.UserID + "','inviteToGroup', 700, 400); \n } \n"; lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;"); lnkInviteToGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath); } } } if (siteContextUser != null) { // Display Friendship link if set so and user is visiting an user's page if (DisplayFriendshipLinks && (currentUser.UserID != siteContextUser.UserID) && friendsEnabled) { FriendshipStatusEnum status = MembershipContext.AuthenticatedUser.HasFriend(siteContextUser.UserID); switch (status) { case FriendshipStatusEnum.Approved: // Friendship rejection script += "function ShortcutFriendshipReject(id) { \n" + "modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Friends/CMSPages/Friends_Reject.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'rejectFriend', 410, 270); \n" + " } \n"; lnkRejectFriendship.Attributes.Add("onclick", "ShortcutFriendshipReject('" + siteContextUser.UserID + "');return false;"); lnkRejectFriendship.NavigateUrl = RequestContext.CurrentURL; pnlRejectFriendship.Visible = true; pnlFriendshipLinks.Visible = true; break; case FriendshipStatusEnum.None: requestFriendshipElem.UserID = currentUser.UserID; requestFriendshipElem.RequestedUserID = siteContextUser.UserID; pnlFriendshipLink.Visible = true; pnlFriendshipLinks.Visible = true; break; } } // Show messaging links if enabled if (MessagingPresent && (currentUser.UserID != siteContextUser.UserID)) { // Display Send message link if user is visiting an user's page if (DisplaySendMessage) { // Send private message script += "function ShortcutPrivateMessage(id) { \n" + "modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Messaging/CMSPages/SendMessage.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'sendMessage', 390, 390); \n" + " } \n"; lnkSendMessage.Attributes.Add("onclick", "ShortcutPrivateMessage('" + siteContextUser.UserID + "');return false;"); lnkSendMessage.NavigateUrl = RequestContext.CurrentURL; pnlSendMessage.Visible = true; pnlMessageLinks.Visible = true; } // Display Add to contact list link if user is visiting an user's page if (DisplayAddToContactList) { // Check if user is in contact list bool isInContactList = ModuleCommands.MessagingIsInContactList(currentUser.UserID, siteContextUser.UserID); // Add to actions if (!isInContactList) { lnkAddToContactList.Attributes.Add("onclick", "return ShortcutAddToContactList('" + siteContextUser.UserID + "')"); lnkAddToContactList.NavigateUrl = RequestContext.CurrentURL; pnlAddToContactList.Visible = true; pnlMessageLinks.Visible = true; // Add to contact list script += "function ShortcutAddToContactList(usertoadd) { \n" + "var confirmation = confirm(" + ScriptHelper.GetString(GetString("messaging.contactlist.addconfirmation")) + ");" + "if(confirmation)" + "{" + "selectedIdElem = document.getElementById('" + hdnSelectedId.ClientID + "'); \n" + "if (selectedIdElem != null) { selectedIdElem.value = usertoadd;}" + ControlsHelper.GetPostBackEventReference(this, "addtocontactlist", false) + "} return false;}\n"; } } // Display Add to ignore list link if user is visiting an user's page if (DisplayAddToIgnoreList) { // Check if user is in ignore list bool isInIgnoreList = ModuleCommands.MessagingIsInIgnoreList(currentUser.UserID, siteContextUser.UserID); // Add to ignore list if (!isInIgnoreList) { lnkAddToIgnoreList.Attributes.Add("onclick", "return ShortcutAddToIgnoretList('" + siteContextUser.UserID + "')"); lnkAddToIgnoreList.NavigateUrl = RequestContext.CurrentURL; pnlAddToIgnoreList.Visible = true; pnlMessageLinks.Visible = true; // Add to ignore list script += "function ShortcutAddToIgnoretList(usertoadd) { \n" + "var confirmation = confirm(" + ScriptHelper.GetString(GetString("messaging.ignorelist.addconfirmation")) + ");" + "if(confirmation)" + "{" + "selectedIdElem = document.getElementById('" + hdnSelectedId.ClientID + "'); \n" + "if (selectedIdElem != null) { selectedIdElem.value = usertoadd;}" + ControlsHelper.GetPostBackEventReference(this, "addtoignorelist", false) + "} return false; } \n"; } } } } } // Register menu management scripts ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Shortcuts_" + ClientID, ScriptHelper.GetScript(script)); // Register the dialog script ScriptHelper.RegisterDialogScript(Page); } }
protected override void OnPreInit(EventArgs e) { RequireSite = false; CurrentUserInfo currentUser = MembershipContext.AuthenticatedUser; // Check for UI permissions if (!currentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "Properties", "Properties.General", "General.Design", "Design.EditCSSStylesheets" }, SiteContext.CurrentSiteName)) { RedirectToUIElementAccessDenied("CMS.Content", "Properties;Properties.General;General.Design;Design.EditCSSStylesheets"); } // Page has been opened in CMSDesk and only stylesheet style editing is allowed isDialog = (QueryHelper.GetBoolean("dialog", false) || QueryHelper.GetBoolean("isindialog", false)); // Prevent replacing of the master page with dialog master page RequiresDialog = false; if (isDialog) { // Check hash if (!QueryHelper.ValidateHash("hash", "objectid", true, true, true)) { URLHelper.Redirect(ResolveUrl(string.Format("~/CMSMessages/Error.aspx?title={0}&text={1}", ResHelper.GetString("dialogs.badhashtitle"), ResHelper.GetString("dialogs.badhashtext")))); } // Check 'Design Web site' permission if (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design")) { RedirectToAccessDenied("CMS.Design", "Design"); } } else { CheckGlobalAdministrator(); } string stylesheet = QueryHelper.GetString("objectid", "0"); // If default stylesheet defined and selected, choose it if (stylesheet == "default") { si = PortalContext.CurrentSiteStylesheet; } // Default stylesheet not selected try to find stylesheet selected if (si != null) { cssStylesheetId = si.StylesheetID; } else { cssStylesheetId = ValidationHelper.GetInteger(stylesheet, 0); if (cssStylesheetId > 0) { // Get the stylesheet si = CssStylesheetInfoProvider.GetCssStylesheetInfo(cssStylesheetId); } } SetEditedObject(si, null); // Check site association in case that user is not admin var checkSiteAssociation = !currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin); if ((si != null) && isDialog && checkSiteAssociation) { // Check if stylesheet is under current site int siteId = (CurrentSite != null) ? CurrentSite.SiteID : 0; DataSet ds = CssStylesheetSiteInfoProvider.GetCssStylesheetSites() .WhereEquals("SiteID", siteId) .WhereEquals("StylesheetID", si.StylesheetID) .TopN(1); if (DataHelper.DataSourceIsEmpty(ds)) { URLHelper.Redirect(ResolveUrl(string.Format("~/CMSMessages/Error.aspx?title={0}&text={1}", ResHelper.GetString("cssstylesheet.errorediting"), ResHelper.GetString("cssstylesheet.notallowedtoedit")))); } } base.OnPreInit(e); }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData() { string where = null; currentUser = MembershipContext.AuthenticatedUser; if (string.IsNullOrEmpty(uniSelector.AdditionalSearchColumns)) { uniSelector.FilterControl = "~/CMSModules/ContactManagement/FormControls/SearchContactFullName.ascx"; uniSelector.UseDefaultNameFilter = false; } bool authorizedSiteContacts = false; bool authorizedGlobalContacts = ContactHelper.AuthorizedReadContact(UniSelector.US_GLOBAL_RECORD, false); if (SiteID > 0) { authorizedSiteContacts = ContactHelper.AuthorizedReadContact(SiteID, false); } else { authorizedSiteContacts = ContactHelper.AuthorizedReadContact(SiteContext.CurrentSiteID, false); } // Filter site objects if (SiteID > 0) { if (authorizedSiteContacts) { where = "(ContactSiteID = " + SiteID + " AND ContactMergedWithContactID IS NULL)"; } else { where = "(1=0)"; } } // Filter only global objects else if ((SiteID == UniSelector.US_GLOBAL_RECORD) || (SiteID == 0)) { if (authorizedGlobalContacts) { where = "(ContactSiteID IS NULL AND ContactGlobalContactID IS NULL)"; } else { where = "(1=0)"; } } // Display current site and global contacts else if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD) { if (authorizedSiteContacts && authorizedGlobalContacts) { where = "(ContactSiteID IS NULL AND ContactGlobalContactID IS NULL) OR (ContactSiteID = " + SiteContext.CurrentSiteID + " AND ContactMergedWithContactID IS NULL)"; uniSelector.AddGlobalObjectSuffix = true; } else if (authorizedGlobalContacts) { where = "(ContactSiteID IS NULL AND ContactMergedWithContactID IS NULL)"; } else if (authorizedSiteContacts) { where = "(ContactSiteID = " + SiteContext.CurrentSiteID + " AND ContactMergedWithContactID IS NULL)"; } else { where = "(1=0)"; } } // Display all objects else if ((SiteID == UniSelector.US_ALL_RECORDS) && currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { where = "((ContactSiteID IS NULL AND ContactGlobalContactID IS NULL) OR (ContactSiteID > 0 AND ContactMergedWithContactID IS NULL))"; uniSelector.AddGlobalObjectSuffix = true; } // Not enough permissions else { where = "(1=0)"; } where = SqlHelper.AddWhereCondition(where, WhereCondition); uniSelector.WhereCondition = SqlHelper.AddWhereCondition(uniSelector.WhereCondition, where); uniSelector.Reload(true); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Do not process control by default StopProcessing = true; // Keep frequent objects cui = MembershipContext.AuthenticatedUser; PageInfo pi = DocumentContext.CurrentPageInfo; if (pi == null) { IsPageNotFound = true; pi = DocumentContext.CurrentCultureInvariantPageInfo ?? new PageInfo(); checkChanges = string.Empty; } ucUIToolbar.StopProcessing = true; // Get main UI element var element = UIElementInfoProvider.GetUIElementInfo(MODULE_NAME, ELEMENT_NAME); if (element == null) { return; } // Check whether user is authorized to edit page if ((pi != null) && AuthenticationHelper.IsAuthenticated() && cui.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Editor, SiteContext.CurrentSiteName) && ((IsPageNotFound && pi.NodeID == 0) || cui.IsAuthorizedPerTreeNode(pi.NodeID, NodePermissionsEnum.Read) == AuthorizationResultEnum.Allowed) && CMSPage.CheckUIElementAccessHierarchical(element, redirectToAccessDenied: false)) { // Enable processing StopProcessing = false; // Check whether the preferred culture is RTL isRTL = CultureHelper.IsUICultureRTL(); // Add link to CSS file CSSHelper.RegisterCSSLink(Page, "Design", "OnSiteEdit.css"); CSSHelper.RegisterBootstrap(Page); // Filter UI element buttons ucUIToolbar.OnButtonFiltered += ucUIToolbar_OnButtonFiltered; ucUIToolbar.OnButtonCreated += ucUIToolbar_OnButtonCreated; ucUIToolbar.OnGroupsCreated += ucUIToolbar_OnGroupsCreated; ucUIToolbar.IsRTL = isRTL; // Register edit script file RegisterEditScripts(pi); if (ViewMode.IsEditLive()) { popupHandler.Visible = true; IsLiveSite = false; MessagesPlaceHolder.IsLiveSite = false; MessagesPlaceHolder.Opacity = 100; // Keep content of editable web parts when saving the document changes if (!IsPageNotFound) { PortalManager.PreserveContent = true; } // Display warning in the Safe mode if (PortalHelper.SafeMode) { string safeModeText = GetString("onsiteedit.safemode") + "<br/><a href=\"" + RequestContext.RawURL.Replace("safemode=1", "safemode=0") + "\">" + GetString("general.close") + "</a> " + GetString("contentedit.safemode2"); string safeModeDescription = GetString("onsiteedit.safemode") + "<br/>" + GetString("general.seeeventlog"); // Display the warning message ShowWarning(safeModeText, safeModeDescription, ""); } ucUIToolbar.StopProcessing = false; // Ensure document redirection var redirectUrl = TreePathUtils.GetRedirectionUrl(pi); if (!String.IsNullOrEmpty(redirectUrl)) { redirectUrl = URLHelper.ResolveUrl(redirectUrl); ShowInformation(GetString("onsiteedit.redirectinfo") + " <a href=\"" + redirectUrl + "\">" + redirectUrl + "</a>"); } pnlUpdateProgress.Visible = true; } // Mode menu on live site else if (ViewMode.IsLiveSite()) { // Hide the edit panel, show only slider button pnlToolbarSpace.Visible = false; pnlToolbar.Visible = false; pnlSlider.Visible = true; icon.CssClass = "cms-icon-80 icon-edit"; icon.ToolTip = GetString("onsitedit.editmode"); pnlButton.Attributes.Add("onclick", "OnSiteEdit_ChangeEditMode();"); // Hide the OnSite edit button when displayed in CMSDesk pnlSlider.Style.Add("display", "none"); } } // Hide control actions for unauthorized users else { plcEdit.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { // Register main CMS script file ScriptHelper.RegisterCMS(this); if (QueryHelper.ValidateHash("hash") && (Parameters != null)) { // Initialize current user currentUser = MembershipContext.AuthenticatedUser; // Check permissions if (!currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && !currentUser.IsAuthorizedPerResource("CMS.Content", "manageworkflow")) { RedirectToAccessDenied("CMS.Content", "manageworkflow"); } // Set current UI culture currentCulture = CultureHelper.PreferredUICultureCode; // Initialize current site currentSiteName = SiteContext.CurrentSiteName; currentSiteId = SiteContext.CurrentSiteID; // Initialize events ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished; ctlAsyncLog.OnError += ctlAsyncLog_OnError; ctlAsyncLog.OnCancel += ctlAsyncLog_OnCancel; if (!RequestHelper.IsCallback()) { DataSet allDocs = null; TreeProvider tree = new TreeProvider(currentUser); // Current Node ID to delete string parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty); if (string.IsNullOrEmpty(parentAliasPath)) { // Get IDs of nodes string nodeIdsString = ValidationHelper.GetString(Parameters["nodeids"], string.Empty); string[] nodeIdsArr = nodeIdsString.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string nodeId in nodeIdsArr) { int id = ValidationHelper.GetInteger(nodeId, 0); if (id != 0) { nodeIds.Add(id); } } } else { var where = new WhereCondition(WhereCondition) .WhereNotEquals("ClassName", SystemDocumentTypes.Root); string columns = SqlHelper.MergeColumns(DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS, "NodeParentID, DocumentName,DocumentCheckedOutByUserID"); allDocs = tree.SelectNodes(currentSiteName, parentAliasPath.TrimEnd('/') + "/%", TreeProvider.ALL_CULTURES, true, DataClassInfoProvider.GetClassName(ClassID), where.ToString(true), "DocumentName", 1, false, 0, columns); if (!DataHelper.DataSourceIsEmpty(allDocs)) { foreach (DataRow row in allDocs.Tables[0].Rows) { nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0)); } } } // Initialize strings based on current action string titleText = null; switch (CurrentAction) { case WorkflowAction.Archive: headQuestion.ResourceString = "content.archivequestion"; chkAllCultures.ResourceString = "content.archiveallcultures"; chkUnderlying.ResourceString = "content.archiveunderlying"; canceledString = GetString("content.archivecanceled"); // Setup title of log ctlAsyncLog.TitleText = GetString("content.archivingdocuments"); // Setup page title text and image titleText = GetString("Content.ArchiveTitle"); break; case WorkflowAction.Publish: headQuestion.ResourceString = "content.publishquestion"; chkAllCultures.ResourceString = "content.publishallcultures"; chkUnderlying.ResourceString = "content.publishunderlying"; canceledString = GetString("content.publishcanceled"); // Setup title of log ctlAsyncLog.TitleText = GetString("content.publishingdocuments"); // Setup page title text and image titleText = GetString("Content.PublishTitle"); break; } PageTitle.TitleText = titleText; EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText); if (nodeIds.Count == 0) { // Hide if no node was specified pnlContent.Visible = false; return; } // Register the dialog script ScriptHelper.RegisterDialogScript(this); // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; // Set all cultures checkbox DataSet culturesDS = CultureSiteInfoProvider.GetSiteCultures(currentSiteName); if ((DataHelper.DataSourceIsEmpty(culturesDS)) || (culturesDS.Tables[0].Rows.Count <= 1)) { chkAllCultures.Checked = true; plcAllCultures.Visible = false; } if (nodeIds.Count > 0) { pnlDocList.Visible = true; // Create where condition string where = new WhereCondition().WhereIn("NodeID", nodeIds).ToString(true); string columns = SqlHelper.MergeColumns(DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS, "NodeParentID, DocumentName,DocumentCheckedOutByUserID"); // Select nodes DataSet ds = allDocs ?? tree.SelectNodes(currentSiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", TreeProvider.ALL_LEVELS, false, 0, columns); // Enumerate selected documents if (!DataHelper.DataSourceIsEmpty(ds)) { cancelNodeId = DataHelper.GetIntValue(ds.Tables[0].Rows[0], "NodeParentID"); foreach (DataRow dr in ds.Tables[0].Rows) { AddToList(dr); } // Display enumeration of documents foreach (KeyValuePair <int, string> line in list) { lblDocuments.Text += line.Value; } } } } // Set title for dialog mode string title = GetString("general.publish"); if (CurrentAction == WorkflowAction.Archive) { title = GetString("general.archive"); } SetTitle(title); } else { pnlPublish.Visible = false; ShowError(GetString("dialogs.badhashtext")); } }
protected void Page_Load(object sender, EventArgs e) { // Register script files ScriptHelper.RegisterCMS(this); ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js"); if (!QueryHelper.ValidateHash("hash")) { pnlContent.Visible = false; ShowError(GetString("dialogs.badhashtext")); return; } // Setup page title text and image PageTitle.TitleText = GetString("Content.TranslateTitle"); EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText); if (IsDialog) { RegisterModalPageScripts(); RegisterEscScript(); plcInfo.Visible = false; pnlButtons.Visible = false; } if (!TranslationServiceHelper.IsTranslationAllowed(CurrentSiteName)) { pnlContent.Visible = false; ShowError(GetString("translations.translationnotallowed")); return; } // Initialize current user currentUser = MembershipContext.AuthenticatedUser; // Initialize events ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished; ctlAsyncLog.OnError += ctlAsyncLog_OnError; ctlAsyncLog.OnCancel += ctlAsyncLog_OnCancel; isSelect = QueryHelper.GetBoolean("select", false); if (isSelect) { pnlDocList.Visible = false; pnlDocSelector.Visible = true; translationElem.DisplayMachineServices = false; } var currentCulture = LocalizationContext.CurrentCulture.CultureCode; var displayTargetLanguage = !IsDialog || isSelect; translationElem.DisplayTargetlanguage = displayTargetLanguage; // Get target culture(s) targetCultures = displayTargetLanguage ? translationElem.TargetLanguages : new HashSet <string>(new[] { QueryHelper.GetString("targetculture", currentCulture) }); // Set the target settings var settings = new TranslationSettings(); settings.TargetLanguages.AddRange(targetCultures); var useCurrentAsDefault = QueryHelper.GetBoolean("currentastargetdefault", false); if (!currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && currentUser.UserHasAllowedCultures && !currentUser.IsCultureAllowed(currentCulture, CurrentSiteName)) { // Do not use current culture as default if user has no permissions to edit it useCurrentAsDefault = false; } translationElem.UseCurrentCultureAsDefaultTarget = useCurrentAsDefault; // Do not include default culture if it is current one string defaultCulture = CultureHelper.GetDefaultCultureCode(CurrentSiteName); if (useCurrentAsDefault && !string.Equals(currentCulture, defaultCulture, StringComparison.InvariantCultureIgnoreCase) && !RequestHelper.IsPostBack()) { settings.TargetLanguages.Add(currentCulture); } translationElem.TranslationSettings = settings; allowTranslate = true; if (RequestHelper.IsCallback()) { return; } // If not in select mode, load all the document IDs and check permissions // In select mode, documents are checked when the button is clicked if (!isSelect) { DataSet allDocs = null; TreeProvider tree = new TreeProvider(); // Current Node ID to translate string parentAliasPath = string.Empty; if (Parameters != null) { parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty); nodeIdsArr = ValidationHelper.GetString(Parameters["nodeids"], string.Empty).Trim('|').Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } if (string.IsNullOrEmpty(parentAliasPath)) { if (nodeIdsArr == null) { // One document translation is requested string nodeIdQuery = QueryHelper.GetString("nodeid", ""); if (nodeIdQuery != "") { // Mode of single node translation pnlList.Visible = false; chkSkipTranslated.Checked = false; translationElem.NodeID = ValidationHelper.GetInteger(nodeIdQuery, 0); nodeIdsArr = new[] { nodeIdQuery }; } else { nodeIdsArr = new string[] { }; } } foreach (string nodeId in nodeIdsArr) { int id = ValidationHelper.GetInteger(nodeId, 0); if (id != 0) { nodeIds.Add(id); } } } else { // Exclude root of the website from multiple translation requested by document listing bulk action var where = new WhereCondition(WhereCondition) .WhereNotEquals("ClassName", SystemDocumentTypes.Root); allDocs = tree.SelectNodes(CurrentSiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%", TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where.ToString(true), "DocumentName", AllLevels ? TreeProvider.ALL_LEVELS : 1, false, 0, DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath"); if (!DataHelper.DataSourceIsEmpty(allDocs)) { foreach (DataTable table in allDocs.Tables) { foreach (DataRow row in table.Rows) { nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0)); } } } } if (nodeIds.Count > 0) { var where = new WhereCondition().WhereIn("NodeID", nodeIds).ToString(true); DataSet ds = allDocs ?? tree.SelectNodes(CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", TreeProvider.ALL_LEVELS, false); if (!DataHelper.DataSourceIsEmpty(ds)) { string docList = null; cancelNodeId = string.IsNullOrEmpty(parentAliasPath) ? DataHelper.GetIntValue(ds.Tables[0].Rows[0], "NodeParentID") : TreePathUtils.GetNodeIdByAliasPath(CurrentSiteName, parentAliasPath); foreach (DataTable table in ds.Tables) { foreach (DataRow dr in table.Rows) { bool isLink = (dr["NodeLinkedNodeID"] != DBNull.Value); string name = (string)dr["DocumentName"]; docList += HTMLHelper.HTMLEncode(name); if (isLink) { docList += DocumentUIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link); } docList += "<br />"; lblDocuments.Text = docList; // Set visibility of checkboxes TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr); if (!TranslationServiceHelper.IsAuthorizedToTranslateDocument(node, currentUser, targetCultures)) { allowTranslate = false; plcMessages.AddError(String.Format(GetString("cmsdesk.notauthorizedtotranslatedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath))); } } } if (!allowTranslate && !RequestHelper.IsPostBack()) { // Hide UI only when security check is performed within first load, if postback used user may loose some setting HideUI(); } } // Display check box for separate submissions for each document if there is more than one document translationElem.DisplaySeparateSubmissionOption = (nodeIds.Count > 1); } else { // Hide everything pnlContent.Visible = false; } } // Register the dialog script ScriptHelper.RegisterDialogScript(this); ctlAsyncLog.TitleText = GetString("contentrequest.starttranslate"); // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; }
protected void Page_Load(object sender, EventArgs e) { currentUser = MembershipContext.AuthenticatedUser; currentCulture = CultureHelper.PreferredUICultureCode; // Initialize events ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished; ctlAsyncLog.OnError += ctlAsyncLog_OnError; ctlAsyncLog.OnCancel += ctlAsyncLog_OnCancel; if (!RequestHelper.IsCallback()) { // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; // Initialize unigrid docElem.ZeroRowsText = GetString(filterDocuments.FilterIsSet ? "unigrid.filteredzerorowstext" : "workflowdocuments.nodata"); docElem.UniGrid.OnAfterDataReload += UniGrid_OnAfterDataReload; docElem.UniGrid.OnBeforeDataReload += UniGrid_OnBeforeDataReload; docElem.Tree = Tree; // Create action script StringBuilder actionScript = new StringBuilder(); actionScript.AppendLine("function PerformAction(selectionFunction, selectionField, dropId)"); actionScript.AppendLine("{"); actionScript.AppendLine(" var selectionFieldElem = document.getElementById(selectionField);"); actionScript.AppendLine(" var label = document.getElementById('" + lblValidation.ClientID + "');"); actionScript.AppendLine(" var items = selectionFieldElem.value;"); actionScript.AppendLine(" var whatDrp = document.getElementById('" + drpWhat.ClientID + "');"); actionScript.AppendLine(" var action = document.getElementById(dropId).value;"); actionScript.AppendLine(" if (action == '" + (int)Action.SelectAction + "')"); actionScript.AppendLine(" {"); actionScript.AppendLine(" label.innerHTML = " + ScriptHelper.GetLocalizedString("massaction.selectsomeaction") + ";"); actionScript.AppendLine(" return false;"); actionScript.AppendLine(" }"); actionScript.AppendLine(" if(!eval(selectionFunction) || whatDrp.value == '" + (int)What.AllDocuments + "')"); actionScript.AppendLine(" {"); actionScript.AppendLine(" var confirmed = false;"); actionScript.AppendLine(" var confMessage = '';"); actionScript.AppendLine(" switch(action)"); actionScript.AppendLine(" {"); actionScript.AppendLine(" case '" + (int)Action.PublishAndFinish + "':"); actionScript.AppendLine(" confMessage = " + ScriptHelper.GetLocalizedString("workflowdocuments.confrimpublish") + ";"); actionScript.AppendLine(" break;"); actionScript.AppendLine(" case '" + (int)Action.RemoveWorkflow + "':"); actionScript.AppendLine(" confMessage = " + ScriptHelper.GetLocalizedString("workflowdocuments.confirmremove") + ";"); actionScript.AppendLine(" break;"); actionScript.AppendLine(" }"); actionScript.AppendLine(" return confirm(confMessage);"); actionScript.AppendLine(" }"); actionScript.AppendLine(" else"); actionScript.AppendLine(" {"); actionScript.AppendLine(" label.innerHTML = " + ScriptHelper.GetLocalizedString("documents.selectdocuments") + ";"); actionScript.AppendLine(" return false;"); actionScript.AppendLine(" }"); actionScript.AppendLine("}"); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "actionScript", ScriptHelper.GetScript(actionScript.ToString())); // Add action to button btnOk.OnClientClick = "return PerformAction('" + docElem.UniGrid.GetCheckSelectionScript() + "','" + docElem.UniGrid.GetSelectionFieldClientID() + "','" + drpAction.ClientID + "');"; // Initialize dropdown list with actions if (!RequestHelper.IsPostBack()) { if (currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || currentUser.IsAuthorizedPerResource("CMS.Content", "manageworkflow")) { drpAction.Items.Add(new ListItem(ResHelper.GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); drpAction.Items.Add(new ListItem(ResHelper.GetString("workflowdocuments." + Action.PublishAndFinish), Convert.ToInt32(Action.PublishAndFinish).ToString())); drpAction.Items.Add(new ListItem(ResHelper.GetString("workflowdocuments." + Action.RemoveWorkflow), Convert.ToInt32(Action.RemoveWorkflow).ToString())); } drpWhat.Items.Add(new ListItem(ResHelper.GetString("contentlisting." + What.SelectedDocuments), Convert.ToInt32(What.SelectedDocuments).ToString())); drpWhat.Items.Add(new ListItem(ResHelper.GetString("contentlisting." + What.AllDocuments), Convert.ToInt32(What.AllDocuments).ToString())); } } docElem.SiteName = filterDocuments.SelectedSite; }