protected void SetupControl() { // Check permissions CurrentUserInfo currentUser = CMSContext.CurrentUser; bool siteAccountsAllowed = currentUser.IsAuthorizedPerResource(ModuleEntry.CONTACTMANAGEMENT, "ReadAccounts"); bool globalAccountsAllowed = currentUser.IsAuthorizedPerResource(ModuleEntry.CONTACTMANAGEMENT, "ReadGlobalAccounts") && SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSCMGlobalAccounts"); if (!siteAccountsAllowed && !globalAccountsAllowed) { lblInfo.Visible = true; lblInfo.Text = GetString("om.myaccounts.notallowedtoreadaccounts"); return; } // Create additional restriction if only site or global objects are allowed string where = null; if (!globalAccountsAllowed) { where = SqlHelperClass.AddWhereCondition(where, "AccountSiteID IS NOT NULL"); } if (!siteAccountsAllowed) { where = SqlHelperClass.AddWhereCondition(where, "AccountSiteID IS NULL"); } // Display accounts on current site or global site (if one of those shouldn't be displayed, it's filtered above) where = SqlHelperClass.AddWhereCondition(where, "AccountSiteID = " + CMSContext.CurrentSiteID + " OR AccountSiteID IS NULL"); gridElem.Visible = true; gridElem.WhereCondition = SqlHelperClass.AddWhereCondition("AccountOwnerUserID=" + currentUser.UserID + " AND AccountMergedWithAccountID IS NULL", where); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); gridElem.Pager.DefaultPageSize = PageSize; RegisterScripts(); SetVisibleColumns(); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { CurrentUserInfo ui = CMSContext.CurrentUser; if (!ui.IsAuthorizedPerUIElement("CMS.Content", "WebPartProperties.Variant")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "WebPartProperties.Variant"); } // Check permissions (based on variant type) if (variantMode == VariantModeEnum.MVT) { if (!ui.IsAuthorizedPerResource("CMS.MVTest", "Read")) { // Not authorized for MV test - Read. RedirectToInformation(String.Format(GetString("general.permissionresource"), "Read", "CMS.MVTest")); } } else if (variantMode == VariantModeEnum.ContentPersonalization) { if (!ui.IsAuthorizedPerResource("CMS.ContentPersonalization", "Read")) { // Not authorized for Content personalization - Read. RedirectToInformation(String.Format(GetString("general.permissionresource"), "Read", "CMS.ContentPersonalization")); } } // Setup the control SetupControl(); }
protected void Page_Load(object sender, EventArgs e) { currentUser = MembershipContext.AuthenticatedUser; if (currentUser == null) { return; } // No cms.blog doc. type if (DataClassInfoProvider.GetDataClassInfo("cms.blog") == null) { RedirectToInformation(GetString("blog.noblogdoctype")); } // Prepare permissions for external data bound contentExploreTreePermission = currentUser.IsAuthorizedPerResource("cms.content", "exploretree"); contentReadPermission = currentUser.IsAuthorizedPerResource("cms.content", "read"); contentCreatePermission = currentUser.IsAuthorizedPerResource("cms.content", "create"); // Register grid events gridBlogs.OnExternalDataBound += gridBlogs_OnExternalDataBound; gridBlogs.OnDataReload += gridBlogs_OnDataReload; gridBlogs.ShowActionsMenu = true; gridBlogs.Columns = "BlogID, ClassName, BlogName, NodeID, DocumentCulture, NodeOwner, BlogModerators"; // Get all possible columns to retrieve gridBlogs.AllColumns = SqlHelper.JoinColumnList(ObjectTypeManager.GetColumnNames(BlogInfo.OBJECT_TYPE, PredefinedObjectType.NODE, PredefinedObjectType.DOCUMENTLOCALIZATION)); }
protected void Page_Load(object sender, EventArgs e) { // Get PollID from querystring int pollId = QueryHelper.GetInteger("pollid", 0); // Get poll object PollInfo pi = PollInfoProvider.GetPollInfo(pollId); EditedObject = pi; // Check global and site read permmision this.CheckPollsReadPermission(pi.PollSiteID); if (pi != null) { // Check permissions during voting if user hasn't got 'Modify' permission CurrentUserInfo user = CMSContext.CurrentUser; bool checkPermission = (pi.PollSiteID > 0) && !user.IsAuthorizedPerResource("cms.polls", CMSAdminControl.PERMISSION_MODIFY) || (pi.PollSiteID <= 0) && !user.IsAuthorizedPerResource("cms.polls", CMSAdminControl.PERMISSION_GLOBALMODIFY); pollElem.PollCodeName = pi.PollCodeName; pollElem.PollSiteID = pi.PollSiteID; pollElem.PollGroupID = pi.PollGroupID; pollElem.CountType = CountTypeEnum.Percentage; pollElem.ShowGraph = true; pollElem.ShowResultsAfterVote = true; // Check permissions during voting if user hasn't got 'Modify' permission pollElem.CheckPermissions = checkPermission; pollElem.CheckVoted = false; pollElem.HideWhenNotAuthorized = false; pollElem.CheckOpen = false; pollElem.IsLiveSite = false; } }
void gridElem_OnAction(string actionName, object actionArgument) { if (actionName == "delete") { int id = ValidationHelper.GetInteger(actionArgument, 0); CurrentUserInfo cui = CMSContext.CurrentUser; bool haveModify = cui.IsAuthorizedPerResource("cms.reporting", "modify"); if (!(cui.IsAuthorizedPerResource("cms.reporting", "subscribe") || haveModify)) { RedirectToAccessDenied("cms.reporting", "Subscribe"); } if (!cui.IsAuthorizedPerResource("cms.reporting", "modify")) { ReportSubscriptionInfo rsi = ReportSubscriptionInfoProvider.GetReportSubscriptionInfo(id); if ((rsi != null) && (rsi.ReportSubscriptionUserID != cui.UserID)) { RedirectToAccessDenied(GetString("reportsubscription.onlymodifyusersallowed")); } } ReportSubscriptionInfoProvider.DeleteReportSubscriptionInfo(id); } }
protected void Page_Load(object sender, EventArgs e) { CurrentUserInfo cu = CMSContext.CurrentUser; // Check permissions if ((cu == null) || (!cu.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceRead") && !cu.IsAuthorizedPerResource("CMS.Ecommerce", "ReadReports"))) { CMSMyDeskPage.RedirectToCMSDeskAccessDenied("CMS.Ecommerce", "EcommerceRead OR ReadReports"); } // Check UIProfile if (!cu.IsAuthorizedPerUIElement("CMS.Desk", "Ecommerce")) { CMSMyDeskPage.RedirectToCMSDeskUIElementAccessDenied("CMS.Desk", "Ecommerce"); } if (!cu.IsAuthorizedPerUIElement("CMS.Ecommerce", "ReportsGroup")) { CMSMyDeskPage.RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "ReportsGroup"); } if (!cu.IsAuthorizedPerUIElement("CMS.Ecommerce", "ECReports")) { CMSMyDeskPage.RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "ECReports"); } if (!cu.IsAuthorizedPerUIElement("CMS.Ecommerce", "ReportsDashboard")) { CMSMyDeskPage.RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "ReportsDashboard"); } }
protected void Page_Load(object sender, EventArgs e) { userId = QueryHelper.GetInteger("userId", 0); currentUser = MembershipContext.AuthenticatedUser; if (userId <= 0 && currentUser != null) { userId = currentUser.UserID; } // Check 'read' permissions if (!currentUser.IsAuthorizedPerResource("CMS.Friends", "Read") && (currentUser.UserID != userId)) { RedirectToAccessDenied("CMS.Friends", "Read"); } // Check 'manage' permission bool friendsManagePermission = currentUser.IsAuthorizedPerResource("CMS.Friends", "Manage") || (currentUser.UserID == userId); // Check license if (DataHelper.GetNotEmpty(RequestContext.CurrentDomain, string.Empty) != string.Empty) { LicenseHelper.CheckFeatureAndRedirect(RequestContext.CurrentDomain, FeatureEnum.Friends); } // Check that only global administrator can edit global administrator's accounts if (userId > 0) { UserInfo ui = UserInfoProvider.GetUserInfo(userId); EditedObject = ui; if (!CheckGlobalAdminEdit(ui)) { plcTable.Visible = false; lblError.Text = GetString("Administration-User_List.ErrorGlobalAdmin"); lblError.Visible = true; } else { ScriptHelper.RegisterDialogScript(this); FriendsList.UserID = userId; FriendsList.OnCheckPermissions += CheckPermissions; FriendsList.ZeroRowsText = GetString("friends.nouserfriends"); // Request friend link string script = "function displayRequest(){ \n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Friends/Dialogs/Friends_Request.aspx") + "?userid=" + userId + "&siteid=" + SiteID + "', 'rejectDialog', 810, 460);}"; ScriptHelper.RegisterStartupScript(this, GetType(), "displayModalRequest", ScriptHelper.GetScript(script)); HeaderAction action = new HeaderAction(); action.Text = GetString("Friends_List.NewItemCaption"); action.OnClientClick = "displayRequest();"; action.RedirectUrl = null; action.Enabled = friendsManagePermission; CurrentMaster.HeaderActions.AddAction(action); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { CurrentUserInfo ui = CMSContext.CurrentUser; if (!ui.IsAuthorizedPerUIElement("CMS.Content", "WebPartProperties.Variant")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "WebPartProperties.Variant"); } // Check permissions (based on variant type) if (variantMode == VariantModeEnum.MVT) { if (!ui.IsAuthorizedPerResource("CMS.MVTest", "Read")) { // Not authorised for MV test - Read. RedirectToInformation(String.Format(GetString("general.permissionresource"), "Read", "CMS.MVTest")); } } else if (variantMode == VariantModeEnum.ContentPersonalization) { if (!ui.IsAuthorizedPerResource("CMS.ContentPersonalization", "Read")) { // Not authorised for Content personalization - Read. RedirectToInformation(String.Format(GetString("general.permissionresource"), "Read", "CMS.ContentPersonalization")); } } if (!SettingsKeyProvider.UsingVirtualPathProvider) { this.lblInfo.Text = GetString("WebPartCode.ProviderNotRunning"); this.lblInfo.CssClass = "ErrorLabel"; } else { // Setup the buttons btnOnOK.Click += new EventHandler(btnOnOK_Click); btnOnApply.Click += new EventHandler(btnOnApply_Click); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ApplyButton", ScriptHelper.GetScript( "function SetRefresh(refreshpage) { document.getElementById('" + this.hidRefresh.ClientID + "').value = refreshpage; } \n" + "function OnApplyButton(refreshpage) { SetRefresh(refreshpage); " + Page.ClientScript.GetPostBackEventReference(btnOnApply, "") + "} \n" + "function OnOKButton(refreshpage) { SetRefresh(refreshpage); " + Page.ClientScript.GetPostBackEventReference(btnOnOK, "") + "} \n" )); } if (variantMode == VariantModeEnum.MVT) { // Display MVT edit dialog mvtEditElem.Visible = true; mvtEditElem.UIFormControl.SubmitButton.Visible = false; } else if (variantMode == VariantModeEnum.ContentPersonalization) { // Display Content personalization edit dialog cpEditElem.Visible = true; cpEditElem.UIFormControl.SubmitButton.Visible = false; } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); bool editingEnabled = true; bool isAscx = (drpType.SelectedValue.ToLower() == "ascx"); // Disable items when virtual path provider is disabled if (!SettingsKeyProvider.UsingVirtualPathProvider && (ti != null)) { if (isAscx) { lblVirtualInfo.Text = string.Format(GetString("Transformation.VirtualPathProviderNotRunning"), TransformationInfoProvider.GetTransformationUrl(ti.TransformationFullName, null, TransformationTypeEnum.Ascx)); plcVirtualInfo.Visible = true; editingEnabled = false; txtCSS.Enabled = false; } tbWysiwyg.Enabled = !isAscx; pnlCheckOutInfo.Visible = false; } string info = null; // Setup the information and code type if (isAscx) { txtCode.Editor.Language = LanguageEnum.ASPNET; txtCode.UseAutoComplete = false; // Check the edit code permission if (!user.IsAuthorizedPerResource("CMS.Design", "EditCode")) { editingEnabled = false; info = ResHelper.GetString("EditCode.NotAllowed"); ltlDirectives.Visible = false; } } else { txtCode.Editor.Language = LanguageEnum.HTMLMixed; txtCode.UseAutoComplete = true; } if (!String.IsNullOrEmpty(info)) { lblTransformationInfo.Text = info; } lblTransformationInfo.Visible = !String.IsNullOrEmpty(lblTransformationInfo.Text); this.plcInfo.Visible = isAscx; this.txtCode.ReadOnly = !editingEnabled; }
/// <summary> /// Handles the OnReloadData event of the menuWebPartVariants control. /// </summary> protected void menuZoneMVTVariants_OnReloadData(object sender, EventArgs e) { // Check permissions if ((currentUser == null) || (!currentUser.IsAuthorizedPerResource("CMS.MVTest", "Read"))) { return; } SetColumnNames(VariantModeEnum.MVT); string zoneId = ValidationHelper.GetString(menuZoneMVTVariants.Parameter, string.Empty); if ((DocumentContext.CurrentPageInfo != null) && (DocumentContext.CurrentPageInfo.TemplateInstance != null)) { int templateId = DocumentContext.CurrentPageInfo.UsedPageTemplateInfo.PageTemplateId; // Get all MVT zone variants of the current web part DataSet ds = VariantHelper.GetVariants(VariantModeEnum.MVT, templateId, zoneId, Guid.Empty, 0); DataTable resultTable = null; if (!DataHelper.DataSourceIsEmpty(ds)) { DataTable table = ds.Tables[0].Copy(); table.DefaultView.Sort = columnVariantID; // Add the original web part as the first item in the variant list DataRow originalVariant = table.NewRow(); originalVariant[columnVariantID] = 0; originalVariant[columnVariantDisplayName] = ResHelper.GetString("WebPartMenu.OriginalWebPart", UICulture); originalVariant[columnVariantZoneID] = zoneId; originalVariant[columnVariantPageTemplateID] = templateId; originalVariant[columnVariantInstanceGUID] = Guid.Empty; table.Rows.InsertAt(originalVariant, 0); resultTable = table.DefaultView.ToTable(); if (DataHelper.DataSourceIsEmpty(resultTable)) { pnlNoZoneMVTVariants.Visible = true; lblNoZoneMVTVariants.Text = ResHelper.GetString("Content.NoPermissions", UICulture); } } else { pnlNoZoneMVTVariants.Visible = true; } repZoneMVTVariants.DataSource = resultTable; repZoneMVTVariants.DataBind(); } }
/// <summary> /// Raises the <see cref="E:PreRender"/> event. /// </summary> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); bool editingEnabled = true; // Disable items when virtual path provider is disabled if (!SettingsKeyProvider.UsingVirtualPathProvider && (pti != null)) { this.lblVirtualInfo.Text = String.Format(GetString("TemplateLayout.VirtualPathProviderNotRunning"), PageTemplateInfoProvider.GetLayoutUrl(pti.CodeName, null)); this.plcVirtualInfo.Visible = true; this.pnlCheckOutInfo.Visible = false; editingEnabled = false; this.txtCustomCSS.ReadOnly = true; this.drpType.Enabled = false; } string info = null; // Setup the information and code type bool isAscx = (this.drpType.SelectedValue.ToLower() == "ascx"); if (isAscx) { txtCustom.Editor.Language = LanguageEnum.ASPNET; txtCustom.UseAutoComplete = false; info = GetString("Administration-PageLayout_New.Hint"); // Check the edit code permission if (!user.IsAuthorizedPerResource("CMS.Design", "EditCode")) { editingEnabled = false; info = ResHelper.GetString("EditCode.NotAllowed"); } } else { txtCustom.Editor.Language = LanguageEnum.HTMLMixed; txtCustom.UseAutoComplete = true; info = GetString("EditLayout.HintHtml"); } this.ltlHint.Text = info; this.txtCustom.ReadOnly = !editingEnabled; this.plcDirectives.Visible = isAscx; this.plcCssLink.Visible = String.IsNullOrEmpty(txtCustomCSS.Text.Trim()); this.lnkStyles.Visible = radCustom.Checked; }
protected void Page_Init(object sender, EventArgs e) { // Check license if (DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), "") != "") { LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.Polls); } // Check site availability if (!ResourceSiteInfoProvider.IsResourceOnSite("CMS.Polls", CMSContext.CurrentSiteName)) { RedirectToResourceNotAvailableOnSite("CMS.Polls"); } // Check site availability if (!ResourceSiteInfoProvider.IsResourceOnSite("CMS.Form", CMSContext.CurrentSiteName)) { RedirectToResourceNotAvailableOnSite("CMS.Form"); } CurrentUserInfo user = CMSContext.CurrentUser; // Check permissions for CMS Desk -> Tools -> Polls if (!user.IsAuthorizedPerUIElement("CMS.Tools", "Tools.Content") || !user.IsAuthorizedPerUIElement("CMS.Tools", "Polls")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Tools", "Polls"); } // Check permissions for site polls if (!user.IsAuthorizedPerResource("CMS.Polls", CMSAdminControl.PERMISSION_READ)) { RedirectToCMSDeskAccessDenied("CMS.Polls", "Read"); } // Check permissions for forms if (!user.IsAuthorizedPerResource("CMS.Form", "ReadData")) { RedirectToCMSDeskAccessDenied("CMS.Form", "ReadData"); } // Load BizForm selector if BizForms module is available if (ModuleEntry.IsModuleLoaded(ModuleEntry.BIZFORM) && ResourceSiteInfoProvider.IsResourceOnSite(ModuleEntry.BIZFORM, CMSContext.CurrentSiteName)) { bizFormData = this.LoadUserControl("~/CMSModules/BizForms/Controls/BizFormEditData.ascx") as CMSAdminControl; bizFormData.ShortID = "bizFormData"; bizFormData.SetValue("ShowNewRecordButton", false); plcBizForm.Controls.Add(bizFormData); bizFormData.Visible = true; } }
/// <summary> /// OnLoad override, setup access denied page with dependence on current usage. /// </summary> protected override void OnLoad(EventArgs e) { if (ShowPreview) { previewState = GetPreviewStateFromCookies(WEBPARTLAYOUT); } if (!RequestHelper.IsPostBack() && IsChecked) { ShowMessage(); } if (previewState != 0) { etaCode.TopOffset = 40; } // Add preview action if (!isNew) { HeaderAction preview = new HeaderAction() { ControlType = HeaderActionTypeEnum.LinkButton, Text = GetString("general.preview"), OnClientClick = "performToolbarAction('split');return false;", ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/Preview.png"), SmallImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/Preview.png"), Visible = (previewState == 0), Tooltip = GetString("preview.tooltip") }; editMenuElem.ObjectEditMenu.AddExtraAction(preview); } editMenuElem.ObjectEditMenu.PreviewMode = true; editMenuElem.MenuPanel.CssClass = "PreviewMenu"; editMenuElem.ObjectManager.OnBeforeAction += ObjectManager_OnBeforeAction; editMenuElem.ObjectManager.OnAfterAction += ObjectManager_OnAfterAction; editMenuElem.ObjectManager.OnSaveData += ObjectManager_OnSaveData; if (!currentUser.IsAuthorizedPerResource("CMS.Design", "EditCode")) { editMenuElem.MessagesPlaceHolder.WrapperControlClientID = pnlBody.ClientID; etaCode.Editor.ReadOnly = true; } base.OnLoad(e); }
/// <summary> /// OnLoad override, setup access denied page with dependence on current usage. /// </summary> protected override void OnLoad(EventArgs e) { if (ShowPreview) { previewIsActive = (GetPreviewStateFromCookies(WEBPARTLAYOUT) > 0); } if (!RequestHelper.IsPostBack() && IsChecked) { ShowMessage(); } if (previewIsActive) { etaCode.TopOffset = 40; } // Add preview action if (!isNew) { HeaderAction preview = new HeaderAction { Text = GetString("general.preview"), OnClientClick = "performToolbarAction('split');return false;", Visible = !previewIsActive, Tooltip = GetString("preview.tooltip"), Index = 1, }; editMenuElem.ObjectEditMenu.AddExtraAction(preview); } editMenuElem.ObjectEditMenu.PreviewMode = true; editMenuElem.MenuPanel.CssClass = "PreviewMenu"; editMenuElem.ObjectManager.OnBeforeAction += ObjectManager_OnBeforeAction; editMenuElem.ObjectManager.OnAfterAction += ObjectManager_OnAfterAction; editMenuElem.ObjectManager.OnSaveData += ObjectManager_OnSaveData; if (!currentUser.IsAuthorizedPerResource("CMS.Design", "EditCode")) { editMenuElem.MessagesPlaceHolder.WrapperControlClientID = pnlBody.ClientID; etaCode.Editor.ReadOnly = true; } // Hide submit button of the form EditForm.SubmitButton.Visible = false; base.OnLoad(e); }
protected void Page_Load(object sender, EventArgs e) { // Check hash if (!QueryHelper.ValidateHash("hash")) { RedirectToAccessDenied(ResHelper.GetString("dialogs.badhashtitle")); } userId = QueryHelper.GetInteger("userId", 0); currentUser = CMSContext.CurrentUser; // Check 'read' permissions if (!currentUser.IsAuthorizedPerResource("CMS.Friends", "Read") && (currentUser.UserID != userId)) { RedirectToAccessDenied("CMS.Friends", "Read"); } // Check license if (DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), string.Empty) != string.Empty) { LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.Friends); } if (userId > 0) { // Check that only global administrator can edit global administrator's accounts UserInfo ui = UserInfoProvider.GetUserInfo(userId); EditedObject = ui; if (!CheckGlobalAdminEdit(ui)) { plcTable.Visible = false; lblError.Text = GetString("Administration-User_List.ErrorGlobalAdmin"); lblError.Visible = true; } else { string imagePath = GetImageUrl("Objects/CMS_Friend/"); ScriptHelper.RegisterDialogScript(this); FriendsListRequested.UserID = userId; FriendsListRequested.OnCheckPermissions += CheckPermissions; FriendsListRequested.ZeroRowsText = GetString("friends.nouserrequestedfriends"); // Request friend link string script = "function displayRequest(){ \n" + "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Friends/Dialogs/Friends_Request.aspx") + "?userid=" + userId + "&siteid=" + SiteID + "', 'rejectDialog', 480, 350);}"; ScriptHelper.RegisterStartupScript(this, GetType(), "displayModalRequest", ScriptHelper.GetScript(script)); string[,] actions = new string[1, 6]; actions[0, 0] = HeaderActions.TYPE_HYPERLINK; actions[0, 1] = GetString("Friends_List.NewItemCaption"); actions[0, 2] = null; actions[0, 3] = "javascript:displayRequest();"; actions[0, 4] = null; actions[0, 5] = imagePath + "add.png"; CurrentMaster.HeaderActions.Actions = actions; } } }
protected void Page_Load(object sender, EventArgs e) { userId = QueryHelper.GetInteger("userId", 0); currentUser = CMSContext.CurrentUser; // Check 'read' permissions if (!currentUser.IsAuthorizedPerResource("CMS.Friends", "Read") && (currentUser.UserID != userId)) { RedirectToAccessDenied("CMS.Friends", "Read"); } // Check license if (DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), string.Empty) != string.Empty) { LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.Friends); } // initializes breadcrumbs string[,] pageTitleTabs = new string[1, 3]; pageTitleTabs[0, 0] = GetString("friends.friends"); pageTitleTabs[0, 1] = ""; pageTitleTabs[0, 2] = ""; CurrentMaster.Title.Breadcrumbs = pageTitleTabs; CurrentMaster.Title.HelpTopicName = "friends_myfriends"; CurrentMaster.Title.HelpName = "helpTopic"; if (!RequestHelper.IsPostBack()) { InitalizeMenu(); } }
/// <summary> /// Loads member's groups control. /// </summary> protected void InitializeGroupControl() { InvitationButton.Enabled = true; groupSelector.CurrentSelector.ReturnColumnName = "GroupID"; if (CMSContext.CurrentSite != null) { CurrentUserInfo ui = CMSContext.CurrentUser; bool isAdmin = (ui.IsGlobalAdministrator || ui.IsAuthorizedPerResource("CMS.Groups", CMSAdminControl.PERMISSION_MANAGE)); // Get dataset with members string where = "GroupSiteID = " + CMSContext.CurrentSite.SiteID.ToString(); if (!isAdmin) { where += " AND GroupID IN (SELECT MemberGroupID FROM Community_GroupMember WHERE MemberUserID = " + ui.UserID + ")"; } groupSelector.CurrentSelector.WhereCondition = where; if (!groupSelector.CurrentSelector.HasData) { // User is not member of any group lblInfo.Text = GetString("groupinvitation.nogroup"); DisableAfterSuccess(); CancelButton.ResourceString = "general.close"; return; } } }
private void ReloadData() { if (node != null) { if (node.IsRoot()) { // Hide inheritance options for root node pnlInherits.Visible = false; } else { inheritElem.Value = node.NodeWireframeInheritPageLevels; } CurrentUserInfo currentUser = CMSContext.CurrentUser; // Check read permissions if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath)); } // Check modify permissions else if (!currentUser.IsAuthorizedPerResource("CMS.Design", "Wireframing") || (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)) { hasModifyPermission = false; txtComment.Enabled = false; EditMenu.Enabled = false; } txtComment.Text = node.GetStringValue("NodeWireframeComment", ""); } }
protected void Page_Load(object sender, EventArgs e) { currentUser = CMSContext.CurrentUser; if (currentUser == null) { return; } // Check 'ReadForm' permission if (!currentUser.IsAuthorizedPerResource("cms.form", "ReadForm")) { RedirectToCMSDeskAccessDenied("cms.form", "ReadForm"); } UniGridBizForms.OnAction += new OnActionEventHandler(UniGridBizForms_OnAction); UniGridBizForms.OnAfterRetrieveData += new OnAfterRetrieveData(uniGrid_OnAfterRetrieveData); UniGridBizForms.HideControlForZeroRows = false; UniGridBizForms.ZeroRowsText = GetString("general.nodatafound"); UniGridBizForms.WhereCondition = "FormSiteID = " + CMSContext.CurrentSiteID; // New item link string[,] actions = new string[1,6]; actions[0, 0] = HeaderActions.TYPE_HYPERLINK; actions[0, 1] = GetString("BizFormList.lnkNewBizForm"); actions[0, 2] = null; actions[0, 3] = ResolveUrl("BizForm_New.aspx"); actions[0, 4] = null; actions[0, 5] = GetImageUrl("Objects/CMS_Form/add.png"); CurrentMaster.HeaderActions.Actions = actions; CurrentMaster.Title.TitleText = GetString("BizFormList.TitleText"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Form/object.png"); CurrentMaster.Title.HelpTopicName = "bizforms"; }
protected void Page_Load(object sender, EventArgs e) { currentUser = CMSContext.CurrentUser; if (currentUser == null) { return; } // Check 'ReadForm' permission if (!currentUser.IsAuthorizedPerResource("cms.form", "ReadForm")) { RedirectToCMSDeskAccessDenied("cms.form", "ReadForm"); } UniGridBizForms.OnAction += new OnActionEventHandler(UniGridBizForms_OnAction); UniGridBizForms.OnAfterRetrieveData += new OnAfterRetrieveData(uniGrid_OnAfterRetrieveData); UniGridBizForms.HideControlForZeroRows = false; UniGridBizForms.ZeroRowsText = GetString("general.nodatafound"); UniGridBizForms.WhereCondition = "FormSiteID = " + CMSContext.CurrentSiteID; // New item link string[,] actions = new string[1, 6]; actions[0, 0] = HeaderActions.TYPE_HYPERLINK; actions[0, 1] = GetString("BizFormList.lnkNewBizForm"); actions[0, 2] = null; actions[0, 3] = ResolveUrl("BizForm_New.aspx"); actions[0, 4] = null; actions[0, 5] = GetImageUrl("Objects/CMS_Form/add.png"); CurrentMaster.HeaderActions.Actions = actions; CurrentMaster.Title.TitleText = GetString("BizFormList.TitleText"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Form/object.png"); CurrentMaster.Title.HelpTopicName = "bizforms"; }
protected void Page_Load(object sender, EventArgs e) { // Check the current user currentUser = CMSContext.CurrentUser; if (currentUser == null) { return; } // Check 'Read' permission if (currentUser.IsAuthorizedPerResource("cms.blog", "Read")) { readBlogs = true; } if (!RequestHelper.IsPostBack()) { this.drpBlogs.Items.Add(new ListItem(GetString("general.selectall"), "##ALL##")); this.drpBlogs.Items.Add(new ListItem(GetString("blog.selectmyblogs"), "##MYBLOGS##")); } // No cms.blog doc. type if (DataClassInfoProvider.GetDataClass("cms.blog") == null) { RedirectToInformation(GetString("blog.noblogdoctype")); } this.CurrentMaster.DisplaySiteSelectorPanel = true; gridBlogs.OnDataReload += gridBlogs_OnDataReload; gridBlogs.ZeroRowsText = GetString("general.nodatafound"); gridBlogs.ShowActionsMenu = true; gridBlogs.Columns = "BlogID, BlogName, NodeID, DocumentCulture"; // Get all possible columns to retrieve IDataClass nodeClass = DataClassFactory.NewDataClass("CMS.Tree"); DocumentInfo di = new DocumentInfo(); BlogInfo bi = new BlogInfo(); gridBlogs.AllColumns = SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(bi.ColumnNames.ToArray()), SqlHelperClass.MergeColumns(di.ColumnNames.ToArray())), SqlHelperClass.MergeColumns(nodeClass.ColumnNames.ToArray())); DataClassInfo dci = DataClassInfoProvider.GetDataClass("cms.blogpost"); string classId = ""; StringBuilder script = new StringBuilder(); if (dci != null) { classId = dci.ClassID.ToString(); } // Get script to redirect to new blog post page script.Append("function NewPost(parentId, culture) {", " if (parentId != 0) {", " parent.parent.parent.location.href = \"", ResolveUrl("~/CMSDesk/default.aspx"), "?section=content&action=new&nodeid=\" + parentId + \"&classid=", classId, " &culture=\" + culture;", "}}"); // Generate javascript code ltlScript.Text = ScriptHelper.GetScript(script.ToString()); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { CurrentUserInfo cui = CMSContext.CurrentUser; // Check UI Permissions if (!cui.IsAuthorizedPerUIElement("CMS.Content", "OnlineMarketing.MVTVariants")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "OnlineMarketing.MVTVariants"); } if (!cui.IsAuthorizedPerResource("cms.mvtest", "Read")) { RedirectToAccessDenied(String.Format(GetString("general.permissionresource"), "Read", "MVT testing")); } // Set disabled module info ucDisabledModule.SettingsKeys = "CMSAnalyticsEnabled;CMSMVTEnabled"; ucDisabledModule.InfoTexts.Add(GetString("WebAnalytics.Disabled") + "</br>"); ucDisabledModule.InfoTexts.Add(GetString("mvt.disabled")); ucDisabledModule.ParentPanel = pnlDisabled; // Get the PageTemplateID of the current node if (Node != null) { // Set NodeID in order to check the access to the document listElem.NodeID = Node.NodeID; listElem.PageTemplateID = Node.GetUsedPageTemplateId(); } EditedObject = Node; }
protected override void OnInit(EventArgs e) { base.OnInit(e); CurrentUserInfo user = CMSContext.CurrentUser; // Check 'read' permissions if (!user.IsAuthorizedPerResource("CMS.Content", "Read")) { RedirectToAccessDenied("CMS.Content", "Read"); } // Check UIProfile if (!user.IsAuthorizedPerUIElement("CMS.Content", "Properties.General")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Properties.General"); } if (!user.IsAuthorizedPerUIElement("CMS.Content", "General.Advanced")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "General.Advanced"); } // Init document manager events DocumentManager.OnSaveData += DocumentManager_OnSaveData; DocumentManager.OnAfterAction += DocumentManager_OnAfterAction; DocumentManager.OnValidateData += DocumentManager_OnValidateData; // Initialize node node = DocumentManager.Node; }
protected void Page_Load(object sender, EventArgs e) { currentUser = MembershipContext.AuthenticatedUser; if (currentUser == null) { return; } // Check 'ReadForm' permission if (!currentUser.IsAuthorizedPerResource("cms.form", "ReadForm")) { RedirectToAccessDenied("cms.form", "ReadForm"); } UniGridBizForms.OnAction += UniGridBizForms_OnAction; UniGridBizForms.OnAfterRetrieveData += uniGrid_OnAfterRetrieveData; UniGridBizForms.HideControlForZeroRows = false; UniGridBizForms.ZeroRowsText = GetString("general.nodatafound"); UniGridBizForms.WhereCondition = "FormSiteID = " + SiteContext.CurrentSiteID; PageTitle.TitleText = GetString("BizFormList.TitleText"); InitHeaderActions(); }
protected override void CreateChildControls() { base.CreateChildControls(); selectContainer.DropDownSingleSelect.CssClass = "SelectorDropDown"; selectContainer.WhereCondition = string.Format("ContainerID IN (SELECT ContainerID FROM CMS_WebPartContainerSite WHERE SiteID = {0})", CMSContext.CurrentSiteID); // Add none value string[,] noneValue = new string[1, 2]; noneValue[0, 0] = GetString("general.empty"); noneValue[0, 1] = string.Empty; selectContainer.SpecialFields = noneValue; CurrentUserInfo currentUser = CMSContext.CurrentUser; string siteName = CMSContext.CurrentSiteName; // Check user permissions bool design = currentUser.IsAuthorizedPerResource("CMS.Design", "Design"); bool deskAuthorized = currentUser.IsAuthorizedPerUIElement("CMS.Desk", "Content"); bool contentAuthorized = currentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "Design", "Design.WebPartProperties", "WebPartProperties.General" }, siteName); if (!IsLiveSite && design && deskAuthorized && contentAuthorized) { // Check UI permissions for editing/creating container bool editAuthorized = currentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "WebPartProperties.EditContainers" }, siteName); bool createAuthorized = currentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "WebPartProperties.NewContainers" }, siteName); // Initialize selector SetDialog(editAuthorized, createAuthorized); } }
/// <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"); } } }
protected void CheckPermissions(string permissionType, CMSAdminControl sender) { if ((!currentUser.IsAuthorizedPerResource("CMS.Friends", permissionType)) && (currentUser.UserID != userId)) { RedirectToAccessDenied("CMS.Friends", permissionType); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); DocumentManager.LocalMessagesPlaceHolder = plcMess; DocumentManager.OnSaveData += DocumentManager_OnSaveData; CurrentUserInfo user = CMSContext.CurrentUser; // Check 'read' permissions if (!user.IsAuthorizedPerResource("CMS.Content", "Read")) { RedirectToAccessDenied("CMS.Content", "Read"); } // Check UIProfile if (!user.IsAuthorizedPerUIElement("CMS.Content", "Properties.General")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Properties.General"); } if (!user.IsAuthorizedPerUIElement("CMS.Content", "General.Advanced")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "General.Advanced"); } }
/// <summary> /// Creates where condition for SKUs listing. /// </summary> private string GetWhereCondition() { // Display ONLY products - not product options string where = "SKUOptionCategoryID IS NULL"; // Select only products without documents if ((NodeID <= 0) && DisplayTreeInProducts) { where = SqlHelperClass.AddWhereCondition(where, "SKUID NOT IN (SELECT NodeSKUID FROM View_CMS_Tree_Joined WHERE NodeSKUID IS NOT NULL AND NodeSiteID = " + CMSContext.CurrentSiteID + ")"); } // Ordinary user can see only product from departments he can access CurrentUserInfo cui = CMSContext.CurrentUser; if (!cui.IsGlobalAdministrator && !cui.IsAuthorizedPerResource("CMS.Ecommerce", "AccessAllDepartments")) { where = SqlHelperClass.AddWhereCondition(where, "(SKUDepartmentID IS NULL) OR SKUDepartmentID IN (SELECT DepartmentID FROM COM_UserDepartment WHERE UserID=" + cui.UserID + ")"); } // Reflect "Allow global products" setting string siteWhere = "SKUSiteID = " + CMSContext.CurrentSiteID; if (AllowGlobalObjects) { siteWhere += " OR SKUSiteID IS NULL"; } return(SqlHelperClass.AddWhereCondition(where, siteWhere)); }
protected void Page_Init(object sender, EventArgs e) { // Check the license if (!string.IsNullOrEmpty(DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), string.Empty))) { LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.Newsletters); } // Check site availability if (!ResourceSiteInfoProvider.IsResourceOnSite("CMS.Newsletter", CMSContext.CurrentSiteName)) { RedirectToResourceNotAvailableOnSite("CMS.Newsletter"); } CurrentUserInfo user = CMSContext.CurrentUser; // Check permissions for CMS Desk -> Tools -> Newsletter if (!user.IsAuthorizedPerUIElement("CMS.Tools", "Newsletter")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Tools", "Newsletter"); } // Check 'NewsletterRead' permission if (!user.IsAuthorizedPerResource("CMS.Newsletter", "Read")) { RedirectToCMSDeskAccessDenied("CMS.Newsletter", "Read"); } }
void UIFormControl_OnCheckPermissions(object sender, EventArgs e) { if (Personal) { CurrentUserInfo currentUser = CMSContext.CurrentUser; if (!currentUser.IsAuthorizedPerResource("CMS.Chat", "EnterSupport")) { RedirectToAccessDenied("CMS.Chat", "EnterSupport"); } if ((TypedEditedObject != null) && (TypedEditedObject.ChatSupportCannedResponseChatUserID.Value != ChatUserHelper.GetChatUserFromCMSUser().ChatUserID)) { RedirectToAccessDenied(GetString("general.modifynotallowed")); } } else { int?siteIDToCheck; // Editing existing canned response if (TypedEditedObject != null) { siteIDToCheck = TypedEditedObject.ChatSupportCannedResponseSiteID; } // Creating new else { siteIDToCheck = SiteID; } ((CMSChatPage)Page).CheckModifyPermission(siteIDToCheck); } }
/// <summary> /// Returns number of comments of given blog. /// </summary> /// <param name="postId">Post document id</param> /// <param name="postAliasPath">Post alias path</param> /// <param name="includingTrackbacks">Indicates if trackback comments should be included</param> public static int GetBlogCommentsCount(object postId, object postAliasPath, bool includingTrackbacks) { int docId = ValidationHelper.GetInteger(postId, 0); string aliasPath = ValidationHelper.GetString(postAliasPath, ""); CurrentUserInfo currentUser = MembershipContext.AuthenticatedUser; // There has to be the current site if (SiteContext.CurrentSite == null) { throw new Exception("[BlogFunctions.GetBlogCommentsCount]: There is no current site!"); } bool isOwner = false; // Is user authorized to manage comments? bool selectOnlyPublished = (PortalContext.ViewMode == ViewModeEnum.LiveSite); TreeNode blogNode = BlogHelper.GetParentBlog(aliasPath, SiteContext.CurrentSiteName, selectOnlyPublished); if (blogNode != null) { isOwner = (currentUser.UserID == ValidationHelper.GetInteger(blogNode.GetValue("NodeOwner"), 0)); } bool isUserAuthorized = (currentUser.IsAuthorizedPerResource("cms.blog", "Manage") || isOwner || BlogHelper.IsUserBlogModerator(currentUser.UserName, blogNode)); // Get post comments return(BlogCommentInfoProvider.GetPostCommentsCount(docId, !isUserAuthorized, isUserAuthorized, includingTrackbacks)); }
protected void Page_Load(object sender, EventArgs e) { // Check the current user currentUser = MembershipContext.AuthenticatedUser; if (currentUser == null) { return; } // Check 'Read' permission if (currentUser.IsAuthorizedPerResource("cms.blog", "Read")) { readBlogs = true; } // Prepare permissions for external data bound contentExploreTreePermission = currentUser.IsAuthorizedPerResource("cms.content", "exploretree"); contentReadPermission = currentUser.IsAuthorizedPerResource("cms.content", "read"); contentCreatePermission = currentUser.IsAuthorizedPerResource("cms.content", "create"); if (!RequestHelper.IsPostBack()) { drpBlogs.Items.Add(new ListItem(GetString("general.selectall"), "##ALL##")); drpBlogs.Items.Add(new ListItem(GetString("blog.selectmyblogs"), "##MYBLOGS##")); } // No cms.blog doc. type if (DataClassInfoProvider.GetDataClassInfo("cms.blog") == null) { RedirectToInformation(GetString("blog.noblogdoctype")); } CurrentMaster.DisplaySiteSelectorPanel = true; gridBlogs.OnDataReload += gridBlogs_OnDataReload; gridBlogs.ZeroRowsText = GetString("general.nodatafound"); gridBlogs.ShowActionsMenu = true; gridBlogs.Columns = "BlogID, BlogName, NodeID, DocumentCulture"; gridBlogs.OnExternalDataBound += gridBlogs_OnExternalDataBound; // Get all possible columns to retrieve gridBlogs.AllColumns = SqlHelper.JoinColumnList(ObjectTypeManager.GetColumnNames(BlogInfo.OBJECT_TYPE, PredefinedObjectType.NODE, PredefinedObjectType.DOCUMENTLOCALIZATION)); }
protected void Page_Load(object sender, EventArgs e) { // Check the current user currentUser = CMSContext.CurrentUser; if (currentUser == null) { return; } // Check 'Read' permission if (currentUser.IsAuthorizedPerResource("cms.blog", "Read")) { readBlogs = true; } if (!RequestHelper.IsPostBack()) { this.drpBlogs.Items.Add(new ListItem(GetString("general.selectall"), "##ALL##")); this.drpBlogs.Items.Add(new ListItem(GetString("blog.selectmyblogs"), "##MYBLOGS##")); } // No cms.blog doc. type if (DataClassInfoProvider.GetDataClass("cms.blog") == null) { RedirectToInformation(GetString("blog.noblogdoctype")); } this.CurrentMaster.DisplaySiteSelectorPanel = true; this.gridBlogs.OnDataReload += new OnDataReloadEventHandler(gridBlogs_OnDataReload); this.gridBlogs.ZeroRowsText = GetString("general.nodatafound"); DataClassInfo dci = DataClassInfoProvider.GetDataClass("cms.blogpost"); string classId = ""; string script = ""; if (dci != null) { classId = dci.ClassID.ToString(); } // Get script to redirect to new blog post page script += "function NewPost(parentId, culture) { \n"; script += " if (parentId != 0) { \n"; script += " parent.parent.parent.location.href = \"" + ResolveUrl("~/CMSDesk/default.aspx") + "?section=content&action=new&nodeid=\" + parentId + \"&classid=" + classId + "&culture=\" + culture;"; script += "}} \n"; // Generate javascript code ltlScript.Text = ScriptHelper.GetScript(script); }
protected void Page_Load(object sender, EventArgs e) { userId = QueryHelper.GetInteger("userId", 0); currentUser = CMSContext.CurrentUser; // Check 'read' permissions if (!currentUser.IsAuthorizedPerResource("CMS.Friends", "Read") && (currentUser.UserID != userId)) { RedirectToAccessDenied("CMS.Friends", "Read"); } // Check license if (DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), string.Empty) != string.Empty) { LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.Friends); } }
protected void Page_Load(object sender, EventArgs e) { // Check hash if (!QueryHelper.ValidateHash("hash")) { RedirectToAccessDenied(ResHelper.GetString("dialogs.badhashtitle")); } userId = QueryHelper.GetInteger("userId", 0); currentUser = CMSContext.CurrentUser; // Check 'read' permissions if (!currentUser.IsAuthorizedPerResource("CMS.Friends", "Read") && (currentUser.UserID != userId)) { RedirectToAccessDenied("CMS.Friends", "Read"); } // Check license if (DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), string.Empty) != string.Empty) { LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.Friends); } if (userId > 0) { // Check that only global administrator can edit global administrator's accounts UserInfo ui = UserInfoProvider.GetUserInfo(userId); EditedObject = ui; if (!CheckGlobalAdminEdit(ui)) { plcTable.Visible = false; lblError.Text = GetString("Administration-User_List.ErrorGlobalAdmin"); lblError.Visible = true; } else { ScriptHelper.RegisterDialogScript(this); FriendsListRejected.UserID = userId; FriendsListRejected.UseEncapsulation = false; FriendsListRejected.OnCheckPermissions += CheckPermissions; FriendsListRejected.ZeroRowsText = GetString("friends.nouserrejectedfriends"); } } }
protected void Page_Load(object sender, EventArgs e) { userId = QueryHelper.GetInteger("userId", 0); currentUser = MembershipContext.AuthenticatedUser; if (userId <= 0 && currentUser != null) { userId = currentUser.UserID; } // Check 'read' permissions if (!currentUser.IsAuthorizedPerResource("CMS.Friends", "Read") && (currentUser.UserID != userId)) { RedirectToAccessDenied("CMS.Friends", "Read"); } // Check license if (DataHelper.GetNotEmpty(RequestContext.CurrentDomain, string.Empty) != string.Empty) { LicenseHelper.CheckFeatureAndRedirect(RequestContext.CurrentDomain, FeatureEnum.Friends); } if (userId > 0) { // Check that only global administrator can edit global administrator's accounts UserInfo ui = UserInfoProvider.GetUserInfo(userId); EditedObject = ui; if (!CheckGlobalAdminEdit(ui)) { plcTable.Visible = false; lblError.Text = GetString("Administration-User_List.ErrorGlobalAdmin"); lblError.Visible = true; } else { ScriptHelper.RegisterDialogScript(this); FriendsListToApprove.UserID = userId; FriendsListToApprove.OnCheckPermissions += CheckPermissions; FriendsListToApprove.ZeroRowsText = GetString("friends.nouserwaitingfriends"); } } }
protected void Page_Load(object sender, EventArgs e) { // Check license if (DataHelper.GetNotEmpty(RequestContext.CurrentDomain, string.Empty) != string.Empty) { LicenseHelper.CheckFeatureAndRedirect(RequestContext.CurrentDomain, FeatureEnum.Friends); } userId = QueryHelper.GetInteger("userid", 0); currentUser = MembershipContext.AuthenticatedUser; // Check if request is for current user or another user with permission to manage it if (currentUser.IsPublic() || ((currentUser.UserID != userId) && !currentUser.IsAuthorizedPerResource("CMS.Friends", "Manage"))) { RedirectToAccessDenied("CMS.Friends", "Manage"); } int requestedUserId = QueryHelper.GetInteger("requestid", 0); PageTitle.TitleText = GetString("friends.addnewfriend"); FriendsRequest.UserID = userId; FriendsRequest.RequestedUserID = requestedUserId; FriendsRequest.IsLiveSite = true; if (requestedUserId != 0) { string fullUserName = String.Empty; UserInfo requestedUser = UserInfoProvider.GetUserInfo(requestedUserId); if (requestedUser != null) { fullUserName = Functions.GetFormattedUserName(requestedUser.UserName, requestedUser.FullName, requestedUser.UserNickName, true); } Page.Title = string.Format(GetString("friends.requestfriendshipwith"), HTMLHelper.HTMLEncode(fullUserName)); PageTitle.TitleText = Page.Title; } }
protected void Page_Load(object sender, EventArgs e) { if (StopProcessing) { // Do nothing return; } gridElem.IsLiveSite = IsLiveSite; gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; gridElem.HideControlForZeroRows = false; currentUserInfo = CMSContext.CurrentUser; // Initialize strings string strDays = GetString("MyDesk.OutdatedDocuments.Days"); string strWeeks = GetString("MyDesk.OutdatedDocuments.Weeks"); string strMonths = GetString("MyDesk.OutdatedDocuments.Months"); string strYears = GetString("MyDesk.OutdatedDocuments.Years"); // Set proper XML for control type switch (ListingType) { case ListingTypeEnum.CheckedOut: gridElem.ZeroRowsText = GetString("mydesk.ui.nochecked"); gridElem.WhereCondition = "View_CMS_Tree_Joined.DocumentCheckedOutByUserID = @UserID"; break; case ListingTypeEnum.MyDocuments: gridElem.ZeroRowsText = GetString("general.nodatafound"); gridElem.WhereCondition = "View_CMS_Tree_Joined.NodeOwner = @UserID"; break; case ListingTypeEnum.RecentDocuments: gridElem.ZeroRowsText = GetString("general.nodatafound"); gridElem.WhereCondition = "((View_CMS_Tree_Joined.DocumentCreatedByUserID = @UserID OR View_CMS_Tree_Joined.DocumentModifiedByUserID = @UserID OR View_CMS_Tree_Joined.DocumentCheckedOutByUserID = @UserID))"; break; case ListingTypeEnum.PendingDocuments: gridElem.ZeroRowsText = GetString("mydesk.ui.nowaitingdocs"); gridElem.WhereCondition = "CMS_WorkflowStep.StepName <> 'edit' AND CMS_WorkflowStep.StepName <> 'published' AND CMS_WorkflowStep.StepName <> 'archived' AND (View_CMS_Tree_Joined.DocumentWorkflowStepID IN ( SELECT StepID FROM CMS_Workflowsteproles LEFT JOIN View_CMS_UserRole_MembershipRole_ValidOnly_Joined ON View_CMS_UserRole_MembershipRole_ValidOnly_Joined.RoleID = CMS_WorkflowStepRoles.RoleID WHERE View_CMS_UserRole_MembershipRole_ValidOnly_Joined.UserID = @UserID ) OR @UserID = -1)"; break; case ListingTypeEnum.OutdatedDocuments: // Initialize controls if (!RequestHelper.IsPostBack()) { // Fill the dropdown list drpFilter.Items.Add(strDays); drpFilter.Items.Add(strWeeks); drpFilter.Items.Add(strMonths); drpFilter.Items.Add(strYears); // Load default value txtFilter.Text = "1"; drpFilter.SelectedValue = strYears; // Bind dropdown lists BindDropDowns(); } gridElem.WhereCondition = "((DocumentCreatedByUserID = @UserID OR DocumentModifiedByUserID = @UserID OR DocumentCheckedOutByUserID = @UserID) AND " + SOURCE_MODIFIEDWHEN + "<=@OlderThan AND " + SOURCE_NODESITEID + "=@SiteID)"; // Add where condition if (!string.IsNullOrEmpty(txtDocumentName.Text)) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, GetOutdatedWhereCondition(SOURCE_DOCUMENTNAME, drpDocumentName, txtDocumentName)); } if (!string.IsNullOrEmpty(txtDocumentType.Text)) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, GetOutdatedWhereCondition(SOURCE_CLASSDISPLAYNAME, drpDocumentType, txtDocumentType)); } gridElem.ZeroRowsText = GetString("mydesk.ui.nooutdated"); // Show custom filter plcOutdatedFilter.Visible = true; break; case ListingTypeEnum.WorkflowDocuments: break; case ListingTypeEnum.PageTemplateDocuments: gridElem.ZeroRowsText = GetString("Administration-PageTemplate_Header.Documents.nodata"); break; case ListingTypeEnum.CategoryDocuments: gridElem.ZeroRowsText = GetString("Category_Edit.Documents.nodata"); break; case ListingTypeEnum.ProductDocuments: break; case ListingTypeEnum.TagDocuments: gridElem.ZeroRowsText = GetString("taggroup_edit.documents.nodata"); break; case ListingTypeEnum.DocTypeDocuments: gridElem.ZeroRowsText = GetString("DocumentType_Edit_General.Documents.nodata"); break; case ListingTypeEnum.All: gridElem.ZeroRowsText = GetString("mydesk.ui.nodata"); break; } // Page Size if (!RequestHelper.IsPostBack() && !String.IsNullOrEmpty(ItemsPerPage)) { gridElem.Pager.DefaultPageSize = ValidationHelper.GetInteger(ItemsPerPage, -1); } // Order switch (ListingType) { case ListingTypeEnum.WorkflowDocuments: case ListingTypeEnum.OutdatedDocuments: case ListingTypeEnum.PageTemplateDocuments: case ListingTypeEnum.CategoryDocuments: case ListingTypeEnum.TagDocuments: case ListingTypeEnum.ProductDocuments: case ListingTypeEnum.DocTypeDocuments: gridElem.OrderBy = SOURCE_DOCUMENTNAME; break; default: gridElem.OrderBy = OrderBy; break; } if (ListingType == ListingTypeEnum.All) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, String.Format("(UserID1 = {0} OR UserID2 = {0} OR UserID3 = {0})", currentUserInfo.UserID)); } // Create query parameters QueryDataParameters parameters = new QueryDataParameters(); if (ListingType == ListingTypeEnum.OutdatedDocuments) { parameters.Add("@SiteID", CMSContext.CurrentSite.SiteID); DateTime olderThan = DateTime.Now; int dateTimeValue = ValidationHelper.GetInteger(txtFilter.Text, 0); if (drpFilter.SelectedValue == strDays) { olderThan = olderThan.AddDays(-dateTimeValue); } else if (drpFilter.SelectedValue == strWeeks) { olderThan = olderThan.AddDays(-dateTimeValue * 7); } else if (drpFilter.SelectedValue == strMonths) { olderThan = olderThan.AddMonths(-dateTimeValue); } else if (drpFilter.SelectedValue == strYears) { olderThan = olderThan.AddYears(-dateTimeValue); } parameters.Add("@OlderThan", olderThan); } // Initialize UserID query parameter int userID = currentUserInfo.UserID; if (ListingType == ListingTypeEnum.PendingDocuments) { if ((currentUserInfo.IsGlobalAdministrator) || (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 = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_MODIFIEDWHEN + " >= @FROM"); parameters.Add("@FROM", DateTime.Now.AddDays((-1) * from)); } if (to > 0) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_MODIFIEDWHEN + " <= @TO"); parameters.Add("@TO", DateTime.Now.AddDays((-1) * to)); } } } // Site name if (!String.IsNullOrEmpty(SiteName) && (SiteName != UniGrid.ALL)) { SiteInfo site = SiteInfoProvider.GetSiteInfo(SiteName); if (site != null) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_NODESITEID + " = " + site.SiteID); UniGrid.GridColumns.Columns.RemoveAll(c => (c.Source == SOURCE_SITENAME || c.Source == SOURCE_NODESITEID)); } } // Path filter if (Path != String.Empty) { if (ListingType == ListingTypeEnum.All) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_DOCUMENTNAMEPATH + " LIKE N'" + CMSContext.ResolveCurrentPath(Path).Replace("'", "''") + "'"); } else { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_NODEALIASPATH + " LIKE N'" + CMSContext.ResolveCurrentPath(Path).Replace("'", "''") + "'"); } } // Document type filer if (!String.IsNullOrEmpty(DocumentType)) { string[] types = DocumentType.Split(';'); gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SqlHelperClass.GetWhereCondition<string>(SOURCE_CLASSNAME, types, true)); } // Document name filter if (DocumentName != String.Empty) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_DOCUMENTNAME + " LIKE N'%" + SqlHelperClass.GetSafeQueryString(DocumentName, false) + "%'"); } // Site running filter if ((SiteName == UniGrid.ALL) && DisplayOnlyRunningSites) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "SiteName IN (SELECT SiteName FROM CMS_Site WHERE SiteStatus = 'RUNNING')"); } // Set parameters gridElem.QueryParameters = parameters; }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Initialize current user for the async actions currentUser = MembershipContext.AuthenticatedUser; if (!RequestHelper.IsCallback()) { // Check 'Manage object tasks' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageAllTasks")) { RedirectToAccessDenied("cms.staging", "ManageAllTasks"); } currentSiteId = SiteContext.CurrentSiteID; currentSiteName = SiteContext.CurrentSiteName; ucDisabledModule.SettingsKeys = "CMSStagingLogObjectChanges;CMSStagingLogDataChanges;CMSStagingLogChanges"; ucDisabledModule.InfoText = GetString("AllTasks.TaskSeparator"); ucDisabledModule.AtLeastOne = true; ucDisabledModule.ShowButtons = false; ucDisabledModule.SiteOrGlobal = true; ucDisabledModule.ParentPanel = pnlNotLogged; if (!ucDisabledModule.Check()) { pnlFooter.Visible = false; plcContent.Visible = false; return; } // Register the dialog script ScriptHelper.RegisterDialogScript(this); serverId = QueryHelper.GetInteger("serverid", 0); // Setup title if (!ControlsHelper.CausedPostBack(btnSyncSelected, btnSyncAll)) { plcContent.Visible = true; // Initialize buttons btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); btnCancel.Text = GetString("General.Cancel"); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; btnSyncSelected.OnClientClick = "return !" + gridTasks.GetCheckSelectionScript(); // Initialize grid gridTasks.ZeroRowsText = GetString("Tasks.NoTasks"); gridTasks.OnAction += gridTasks_OnAction; gridTasks.OnDataReload += gridTasks_OnDataReload; gridTasks.OnExternalDataBound += gridTasks_OnExternalDataBound; gridTasks.ShowActionsMenu = true; gridTasks.Columns = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount"; StagingTaskInfo ti = new StagingTaskInfo(); gridTasks.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames); pnlLog.Visible = false; } } ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Initialize current user for the async actions currentUser = CMSContext.CurrentUser; if (!RequestHelper.IsCallback()) { // Check 'Manage object tasks' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageAllTasks")) { RedirectToAccessDenied("cms.staging", "ManageAllTasks"); } currentSiteId = CMSContext.CurrentSiteID; currentSiteName = CMSContext.CurrentSiteName; // Register the dialog script ScriptHelper.RegisterDialogScript(this); serverId = QueryHelper.GetInteger("serverid", 0); // Get the selected types ObjectTypeTreeNode selectedNode = TaskInfoProvider.ObjectTree.FindNode(objectType, (siteId > 0)); objectType = (selectedNode != null) ? selectedNode.GetObjectTypes(true) : string.Empty; // Setup title titleElem.TitleImage = GetImageUrl("/CMSModules/CMS_Staging/synchronization.png"); if (!RequestHelper.CausedPostback(btnSyncSelected, btnSyncAll)) { // Initialize images viewImage = GetImageUrl("Design/Controls/UniGrid/Actions/View.png"); deleteImage = GetImageUrl("Design/Controls/UniGrid/Actions/Delete.png"); syncImage = GetImageUrl("Design/Controls/UniGrid/Actions/Synchronize.png"); // Initialize tooltips syncTooltip = GetString("general.synchronize"); deleteTooltip = GetString("general.delete"); viewTooltip = GetString("general.view"); syncCurrent = GetString("ObjectTasks.SyncCurrent"); plcContent.Visible = true; // Initialize buttons btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); btnCancel.Text = GetString("General.Cancel"); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; btnSyncSelected.OnClientClick = "return !" + gridTasks.GetCheckSelectionScript(); // Initialize grid gridTasks.ZeroRowsText = GetString("Tasks.NoTasks"); gridTasks.OnAction += gridTasks_OnAction; gridTasks.OnDataReload += gridTasks_OnDataReload; gridTasks.OnExternalDataBound += gridTasks_OnExternalDataBound; gridTasks.ShowActionsMenu = true; gridTasks.Columns = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount"; TaskInfo ti = new TaskInfo(); gridTasks.AllColumns = SqlHelperClass.MergeColumns(ti.ColumnNames.ToArray()); pnlLog.Visible = false; } } ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; }
/// <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.IsGlobalAdministrator && !currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceGlobalModify"))) { 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 void Page_Load(object sender, EventArgs e) { currentUser = CMSContext.CurrentUser; if (currentUser == null) { return; } // No cms.blog doc. type if (DataClassInfoProvider.GetDataClass("cms.blog") == null) { RedirectToInformation(GetString("blog.noblogdoctype")); } // Check if user is authorized to manage isAuthorized = currentUser.IsAuthorizedPerResource("CMS.Blog", "Manage") || (currentUser.IsAuthorizedPerClassName("cms.blog", "Manage", CMSContext.CurrentSiteName) && currentUser.IsAuthorizedPerClassName("cms.blogpost", "Manage", CMSContext.CurrentSiteName)); // Register grid events this.gridBlogs.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridBlogs_OnExternalDataBound); this.gridBlogs.OnDataReload += new OnDataReloadEventHandler(gridBlogs_OnDataReload); // Get ClassID of the 'cms.blogpost' class DataClassInfo dci = DataClassInfoProvider.GetDataClass("cms.blogpost"); string classId = ""; string script = ""; if (dci != null) { classId = dci.ClassID.ToString(); } // Get scritp to redirect to new blog post page script += "function NewPost(parentId, culture) { \n"; script += " if (parentId != 0) { \n"; script += " parent.parent.parent.location.href = \"" + ResolveUrl("~/CMSDesk/default.aspx") + "?section=content&action=new&nodeid=\" + parentId + \"&classid=" + classId + "&culture=\" + culture;"; script += "}} \n"; // Generate javascript code ltlScript.Text = ScriptHelper.GetScript(script); }
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")) { // Set current UI culture currentCulture = CultureHelper.PreferredUICulture; // Initialize current user currentUser = CMSContext.CurrentUser; // Initialize current site currentSite = CMSContext.CurrentSite; // Initialize events ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; if (!RequestHelper.IsCallback()) { DataSet allDocs = null; TreeProvider tree = new TreeProvider(currentUser); btnCancel.Text = GetString("general.cancel"); // 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 char[] { '|' }, StringSplitOptions. RemoveEmptyEntries); foreach (string nodeId in nodeIdsArr) { int id = ValidationHelper.GetInteger(nodeId, 0); if (id != 0) { nodeIds.Add(id); } } } else { string where = "ClassName <> 'CMS.Root'"; if (!string.IsNullOrEmpty(WhereCondition)) { where = SqlHelperClass.AddWhereCondition(where, WhereCondition); } allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new char[] { '/' }) + "/%", TreeProvider.ALL_CULTURES, true, TreeProvider.ALL_CLASSNAMES, where, "DocumentName", TreeProvider.ALL_LEVELS, false, 0, TreeProvider.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID"); 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 CurrentMaster.Title.TitleText = GetString("Content.DeleteTitle"); CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/delete.png"); btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); // Register the dialog script ScriptHelper.RegisterDialogScript(this); titleElemAsync.TitleText = GetString("ContentDelete.DeletingDocuments"); titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/delete.png"); // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; // Set all cultures checkbox if (!CultureInfoProvider.IsSiteMultilignual(currentSite.SiteName)) { chkAllCultures.Checked = true; chkAllCultures.Visible = false; } if (nodeIds.Count > 0) { if (nodeIds.Count == 1) { 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, currentUser.PreferredCultureCode) ?? tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); } else { if (allDocs != null) { DataRow dr = allDocs.Tables[0].Rows[0]; node = TreeNode.New(dr, ValidationHelper.GetString(dr["ClassName"], string.Empty), tree); } } if (node != null) { if (!IsUserAuthorizedToDeleteDocument(node)) { pnlDelete.Visible = false; lblError.Text = String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)); } if (node.IsLink) { CurrentMaster.Title.TitleText = GetString("Content.DeleteTitleLink") + " \"" + HTMLHelper.HTMLEncode(node.DocumentName) + "\""; lblQuestion.Text = GetString("ContentDelete.QuestionLink"); chkAllCultures.Checked = true; plcCheck.Visible = false; } else { string nodeName = HTMLHelper.HTMLEncode(node.DocumentName); // Get name for root document if (node.NodeClassName.ToLower() == "cms.root") { nodeName = HTMLHelper.HTMLEncode(currentSite.DisplayName); } CurrentMaster.Title.TitleText = GetString("Content.DeleteTitle") + " \"" + nodeName + "\""; // If there is SKU if (node.HasSKU) { GeneralizedInfo product = ModuleCommands.ECommerceGetSKUInfo(node.NodeSKUID); if (product != null) { bool authorized = false; // Check if product is global if (product.GetValue("SKUSiteID") == null) { // Check EcommerceGlobalModify permission authorized = currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceGlobalModify"); } else { // Check ModifyProducts/EcommerceModify permission authorized = currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "ModifyProducts") || currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceModify"); } if (authorized) { pnlDeleteSKU.Visible = true; chkDeleteSKU.Visible = true; } } } } // Show or hide checkbox chkDestroy.Visible = CanDestroy(node); cancelNodeId = IsMultipleAction ? node.NodeParentID : node.NodeID; } lblQuestion.Text = GetString("ContentDelete.Question"); chkAllCultures.Text = GetString("ContentDelete.AllCultures"); chkDestroy.Text = GetString("ContentDelete.Destroy"); chkDeleteSKU.Text = GetString("ContentDelete.SKU"); } else if (nodeIds.Count > 1) { pnlDocList.Visible = true; 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)) { TreeNode node = null; string docList = null; if (string.IsNullOrEmpty(parentAliasPath)) { cancelNodeId = ValidationHelper.GetInteger( DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0); } else { cancelNodeId = TreePathUtils.GetNodeIdByAliasPath(currentSite.SiteName, parentAliasPath); } bool canDestroy = 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 += UIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link); } docList += "<br />"; lblDocuments.Text = docList; // Set visibility of checkboxes node = TreeNode.New(dr, ValidationHelper.GetString(dr["ClassName"], string.Empty)); if (!IsUserAuthorizedToDeleteDocument(node)) { pnlDelete.Visible = false; lblError.Text = String.Format( GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)); break; } // Can destroy if "can destroy all previous AND current" canDestroy = CanDestroy(node) && canDestroy; if ((currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "ModifyProducts") || currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceModify")) && (node.HasSKU)) { pnlDeleteSKU.Visible = true; chkDeleteSKU.Visible = true; } } } chkDestroy.Visible = canDestroy; } lblQuestion.Text = GetString("ContentDelete.QuestionMultiple"); CurrentMaster.Title.TitleText = GetString("Content.DeleteTitleMultiple"); chkAllCultures.Text = GetString("ContentDelete.AllCulturesMultiple"); chkDestroy.Text = GetString("ContentDelete.DestroyMultiple"); chkDeleteSKU.Text = GetString("ContentDelete.SKUMultiple"); } // If user has allowed cultures specified if (currentUser.UserHasAllowedCultures) { // Get all site cultures DataSet siteCultures = CultureInfoProvider.GetSiteCultures(currentSite.SiteName); bool denyAllCulturesDeletion = false; // Check that user can edit all site cultures foreach (DataRow culture in siteCultures.Tables[0].Rows) { string cultureCode = ValidationHelper.GetString(DataHelper.GetDataRowValue(culture, "CultureCode"), string.Empty); if (!currentUser.IsCultureAllowed(cultureCode, currentSite.SiteName)) { denyAllCulturesDeletion = true; } } // If user can't edit all site cultures if (denyAllCulturesDeletion) { // Hide all cultures selector chkAllCultures.Visible = false; chkAllCultures.Checked = false; } } } else { // Hide everything pnlContent.Visible = false; } } } else { pnlDelete.Visible = false; lblError.Text = GetString("dialogs.badhashtext"); } }
/// <summary> /// Init event handler. /// </summary> protected override void OnInit(EventArgs e) { combinationSelector.UniSelector.UseUniSelectorAutocomplete = false; currentUser = MembershipContext.AuthenticatedUser; // Set the selected combination (from cookie by default) MVTestInfo mvTestInfo = MVTestInfoProvider.GetRunningTest(DocumentContext.CurrentAliasPath, SiteContext.CurrentSiteID, DocumentContext.CurrentDocumentCulture.CultureCode); // Get the cookie name if (mvTestInfo != null) { // Get a cookie name for the mvt test cookieTestName = CookieName.GetMVTCookieName(mvTestInfo.MVTestName); } else { // Get a template cookie name (used just in CMSDesk when no test is running) cookieTestName = CookieName.GetNoMVTCookieName(DocumentContext.CurrentDocument.GetUsedPageTemplateId()); } // Move cookies expiration to next 30 days HttpCookie cookieMVTTest = CookieHelper.GetExistingCookie(cookieTestName); if (cookieMVTTest != null) { CookieHelper.SetValue(cookieMVTTest.Name, cookieMVTTest.Value, cookieMVTTest.Path, DateTime.Now.AddDays(30), false); } base.OnInit(e); viewMode = PortalContext.ViewMode; // Check permissions if ((currentUser == null) || (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design") && PortalContext.IsDesignMode(viewMode)) || (!currentUser.IsAuthorizedPerResource("CMS.MVTest", "Read"))) { stopProcessing = true; } }
protected void Page_Load(object sender, EventArgs e) { // Register the scripts ScriptHelper.RegisterProgress(this); ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Properties/template.js"); inheritElem.DocumentSettings = true; int documentId = 0; UIContext.PropertyTab = PropertyTabEnum.Template; currentUser = CMSContext.CurrentUser; nodeId = QueryHelper.GetInteger("nodeid", 0); tree = new TreeProvider(currentUser); node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode, false); // Redirect to page 'New culture version' in split mode. It must be before setting EditedDocument. if ((node == null) && displaySplitMode) { URLHelper.Redirect("~/CMSModules/Content/CMSDesk/New/NewCultureVersion.aspx" + URLHelper.Url.Query); } // Set edited document EditedDocument = node; if (node != null) { siteid = node.NodeSiteID; documentId = node.DocumentID; } imgSaveDoc.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png"); imgSaveDoc.DisabledImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/savedisabled.png"); mSaveDoc = GetString("general.save"); pnlInherits.GroupingText = GetString("PageProperties.InheritLevels"); ltlScript.Text = ""; string initScript = null; hasDesign = currentUser.IsAuthorizedPerResource("CMS.Design", "Design"); if (hasDesign) { btnEditTemplateProperties.Attributes.Add("onclick", "modalDialog('" + ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Edit.aspx") + "?templateid=' + document.getElementById('SelectedTemplateId').value + '&dialog=1', 'TemplateSelection', 850, 680);return false;"); bool allowEditShared = currentUser.IsAuthorizedPerUIElement("CMS.Content", "Template.ModifySharedTemplates"); // Define GetCurrentTemplateId() used for specifing teplateId in the SaveAsNewTemplate onClick handler initScript = @" var allowEditShared = " + allowEditShared.ToString().ToLower() + @"; function GetCurrentTemplateId() { if (document.getElementById('SelectedTemplateId').value > 0) { return document.getElementById('SelectedTemplateId').value; } else { return document.getElementById('InheritedTemplateId').value; } };" ; ltlPreInitScript.Text = ScriptHelper.GetScript(initScript); btnSelect.Text = GetString("PageProperties.Select"); btnSelect.Attributes.Add("onclick", "modalDialog('" + ResolveUrl(PORTALENGINE_UI_LAYOUTPATH + "PageTemplateSelector.aspx") + "?documentid=" + documentId + "', 'PageTemplateSelection', '90%', '85%'); return false;"); // Register the dialog script ScriptHelper.RegisterDialogScript(this); ltlElemScript.Text += ScriptHelper.GetScript( @" var cloneElem = document.getElementById('" + btnClone.ClientID + @"'); if (cloneElem != null) var cloneElemStyle = (cloneElem.style != null) ? cloneElem.style : cloneElem; var inheritElem = document.getElementById('" + btnInherit.ClientID + @"'); if (inheritElem != null) var inheritElemStyle = (inheritElem.style != null) ? inheritElem.style : inheritElem; var saveElem = document.getElementById('" + btnSave.ClientID + @"'); if (saveElem != null) var saveElemStyle = (saveElem.style != null) ? saveElem.style : saveElem; var editTemplatePropertiesElem = document.getElementById('" + btnEditTemplateProperties.ClientID + @"'); if (editTemplatePropertiesElem != null) var editTemplatePropertiesElemStyle = (editTemplatePropertiesElem.style != null) ? editTemplatePropertiesElem.style : editTemplatePropertiesElem; " ); txtTemplate.Text = ValidationHelper.GetString(Request.Params["txtTemplate"], ""); pnlActions.GroupingText = GetString("PageProperties.Template"); mClone = GetString("PageProperties.Clone"); mSave = GetString("PageProperties.Save"); mInherit = GetString("PageProperties.Inherit"); mEditTemplateProperties = GetString("PageProperties.EditTemplateProperties"); imgClone.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Template/clone.png"); imgInherit.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Template/inherit.png"); imgSave.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Template/save.png"); imgEditTemplateProperties.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Template/edit.png"); imgClone.DisabledImageUrl = GetImageUrl("CMSModules/CMS_Content/Template/clonedisabled.png"); imgInherit.DisabledImageUrl = GetImageUrl("CMSModules/CMS_Content/Template/inheritdisabled.png"); imgSave.DisabledImageUrl = GetImageUrl("CMSModules/CMS_Content/Template/savedisabled.png"); imgEditTemplateProperties.DisabledImageUrl = GetImageUrl("CMSModules/CMS_Content/Template/editdisabled.png"); } else { RedirectToUINotAvailable(); } if (!RequestHelper.IsPostBack()) { ReloadData(); // Modal dialog for save btnSaveOnClickScript = "modalDialog('" + ResolveUrl(PORTALENGINE_UI_LAYOUTPATH + "SaveNewPageTemplate.aspx") + "?templateId=' + GetCurrentTemplateId() + '&siteid=" + siteid + "', 'SaveNewTemplate', 480, 360);return false;"; if (node != null) { if (node.NodeAliasPath != "/") { inheritElem.Value = node.NodeInheritPageLevels; // Try get info whether exist linked document in path DataSet ds = tree.SelectNodes(CMSContext.CurrentSiteName, "/%", node.DocumentCulture, false, null, "NodeLinkedNodeID IS NOT NULL AND (N'" + SqlHelperClass.GetSafeQueryString(node.NodeAliasPath) + "' LIKE NodeAliasPath + '%')", null, -1, false, 1, "Count(*) AS NumOfDocs"); // If node is not link or none of parent documents is not linked document use document name path if (!node.IsLink && ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NumOfDocs"), 0) == 0) { inheritElem.TreePath = TreePathUtils.GetParentPath("/" + node.DocumentNamePath); } // otherwise use alias path else { inheritElem.TreePath = TreePathUtils.GetParentPath("/" + node.NodeAliasPath); } } else { pnlInherits.Visible = false; } } } else if (hasDesign) { initScript = "document.getElementById('SelectedTemplateId').value = " + ValidationHelper.GetInteger(Request.Params["SelectedTemplateId"], 0) + "; \n " + "document.getElementById('InheritedTemplateId').value = " + ValidationHelper.GetInteger(Request.Params["InheritedTemplateId"], 0) + "; \n " + "document.getElementById('Saved').value = " + ValidationHelper.GetBoolean(Request.Params["Saved"], false).ToString().ToLower() + "; \n" + "document.getElementById('TemplateDisplayName').value = '" + ValidationHelper.GetString(Request.Params["TemplateDisplayName"], "") + "'; \n " + "document.getElementById('TemplateDescription').value = '" + ValidationHelper.GetString(Request.Params["TemplateDescription"], "") + "'; \n " + "document.getElementById('TemplateCategory').value = '" + ValidationHelper.GetString(Request.Params["TemplateCategory"], "") + "'; \n " + "document.getElementById('isPortal').value = " + ValidationHelper.GetBoolean(Request.Params["isPortal"], false).ToString().ToLower() + "; \n " + "document.getElementById('isReusable').value = " + ValidationHelper.GetBoolean(Request.Params["isReusable"], false).ToString().ToLower() + "; \n " + "document.getElementById('isAdHoc').value = " + ValidationHelper.GetBoolean(Request.Params["isAdHoc"], false).ToString().ToLower() + "; \n "; string textTemplate = ValidationHelper.GetString(Request.Params["txtTemplate"], ""); if (textTemplate == "") { textTemplate = ValidationHelper.GetString(Request.Params["TextTemplate"], ""); } initScript += "document.getElementById('TextTemplate').value = " + ScriptHelper.GetString(textTemplate) + "; \n "; ltlInitScript.Text = ScriptHelper.GetScript(initScript); ltlScript.Text += ScriptHelper.GetScript("ShowButtons(document.getElementById('isPortal').value, document.getElementById('isReusable').value, document.getElementById('isAdHoc').value); \n"); ltlScript.Text += ScriptHelper.GetScript("if (document.getElementById('SelectedTemplateId').value == 0) { if (inheritElemStyle != null) inheritElemStyle.display = 'none'; if (editTemplatePropertiesElemStyle != null) editTemplatePropertiesElemStyle.display = 'none'; }"); txtTemplate.Text = textTemplate; btnSaveOnClickScript = "modalDialog('" + ResolveUrl(PORTALENGINE_UI_LAYOUTPATH + "SaveNewPageTemplate.aspx") + "?templateId=' + GetCurrentTemplateId() + '&siteid=" + siteid + "', 'SaveNewTemplate', 480, 360);return false;"; } // Javascript function for updating template name string updateTemplateName = ScriptHelper.GetScript(@"function SetTemplateName(templateName) { var txtTemplate = document.getElementById('" + txtTemplate.ClientID + "'); txtTemplate.value = templateName;}"); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SetTemplateName", updateTemplateName); }
/// <summary> /// Check user permissions for document. /// </summary> /// <param name="document">Document</param> /// <param name="permission">Permissions</param> /// <param name="user">User</param> /// <returns>TreeNode if authorized, null otherwise</returns> public bool IsAuthorizedPerDocument(TreeNode document, string permission, CurrentUserInfo user) { // Initialize variables string className = null; // Check global permission bool userHasGlobalPerm = user.IsAuthorizedPerResource("CMS.Content", permission); // Get node properties try { // Get the values form deleted node className = document.NodeClassName; } catch (ThreadAbortException) { throw; } catch (Exception ex) { CurrentError = "Error occurred: " + ex.Message; AddLog(CurrentError); } bool additionalPermission = false; if (permission.ToLower() == "create") { additionalPermission = user.IsAuthorizedPerClassName(className, "CreateSpecific"); } // Check permissions if (userHasGlobalPerm || user.IsAuthorizedPerClassName(className, permission) || additionalPermission) { return true; } return false; }
protected void Page_Load(object sender, EventArgs e) { // Check license if (DataHelper.GetNotEmpty(RequestContext.CurrentDomain, string.Empty) != string.Empty) { LicenseHelper.CheckFeatureAndRedirect(RequestContext.CurrentDomain, FeatureEnum.Friends); } userId = QueryHelper.GetInteger("userid", 0); currentUser = MembershipContext.AuthenticatedUser; int requestedId = QueryHelper.GetInteger("requestid", 0); int friendshipId = 0; // Check if request is for current user or another user with permission to manage it if (currentUser.IsPublic() || ((currentUser.UserID != userId) && !currentUser.IsAuthorizedPerResource("CMS.Friends", "Manage"))) { RedirectToAccessDenied("CMS.Friends", "Manage"); } FriendsReject.SelectedFriends = null; FriendsReject.IsLiveSite = true; PageTitle.TitleText = GetString("friends.rejectfriendship"); // Multiple selection if (Request["ids"] != null) { string[] items = Request["ids"].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (items.Length > 0) { ArrayList friends = new ArrayList(); foreach (string item in items) { friends.Add(ValidationHelper.GetInteger(item, 0)); } FriendsReject.SelectedFriends = friends; if (friends.Count == 1) { friendshipId = Convert.ToInt32(friends[0]); } } } // For one user else { FriendsReject.RequestedUserID = requestedId; } FriendInfo fi = null; if (friendshipId != 0) { fi = FriendInfoProvider.GetFriendInfo(friendshipId); // Set edited object EditedObject = fi; } else if (requestedId != 0) { fi = FriendInfoProvider.GetFriendInfo(userId, requestedId); // Set edited object EditedObject = fi; } if (fi != null) { UserInfo requestedUser = (userId == fi.FriendRequestedUserID) ? UserInfoProvider.GetFullUserInfo(fi.FriendUserID) : UserInfoProvider.GetFullUserInfo(fi.FriendRequestedUserID); string fullUserName = Functions.GetFormattedUserName(requestedUser.UserName, requestedUser.FullName, requestedUser.UserNickName, true); Page.Title = GetString("friends.rejectfriendshipwith") + " " + HTMLHelper.HTMLEncode(fullUserName); PageTitle.TitleText = Page.Title; } // Set current user FriendsReject.UserID = userId; }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Initialize current user for the async actions currentUser = MembershipContext.AuthenticatedUser; currentSiteId = SiteContext.CurrentSiteID; serverId = QueryHelper.GetInteger("serverid", 0); HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (ControlsHelper.CausedPostBack(btnSyncComplete)) { SyncComplete(); } else { if (!RequestHelper.IsCallback()) { // Check 'Manage object tasks' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageDataTasks")) { RedirectToAccessDenied("cms.staging", "ManageDataTasks"); } ucDisabledModule.SettingsKeys = "CMSStagingLogDataChanges"; ucDisabledModule.InfoTexts.Add(GetString("DataStaging.TaskSeparator") + "<br />"); ucDisabledModule.InfoTexts.Add(GetString("stagingchanges.notlogged")); ucDisabledModule.ParentPanel = pnlNotLogged; // Check logging if (!ucDisabledModule.Check()) { pnlFooter.Visible = false; plcContent.Visible = false; return; } // Register the dialog script ScriptHelper.RegisterDialogScript(this); // Get object type objectType = QueryHelper.GetString("objecttype", string.Empty); if (!String.IsNullOrEmpty(objectType)) { // Create header action HeaderActions.AddAction(new HeaderAction { Text = GetString("ObjectTasks.SyncCurrent"), EventName = SYNCHRONIZE_CURRENT }); } // Setup title titleElem.TitleText = GetString("Synchronization.Title"); if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll)) { plcContent.Visible = true; // Initialize buttons btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); btnCancel.Text = GetString("General.Cancel"); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; btnSyncSelected.OnClientClick = "return !" + gridTasks.GetCheckSelectionScript(); ltlScript.Text += ScriptHelper.GetScript("function CompleteSync(){" + Page.ClientScript.GetPostBackEventReference(btnSyncComplete, null) + "}"); // Initialize grid gridTasks.OrderBy = "TaskTime"; gridTasks.ZeroRowsText = GetString("Tasks.NoTasks"); gridTasks.OnAction += gridTasks_OnAction; gridTasks.OnDataReload += gridTasks_OnDataReload; gridTasks.OnExternalDataBound += gridTasks_OnExternalDataBound; gridTasks.ShowActionsMenu = true; gridTasks.Columns = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount"; StagingTaskInfo ti = new StagingTaskInfo(); gridTasks.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames); pnlLog.Visible = false; } } } ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; }
protected void Page_Load(object sender, EventArgs e) { // Register main CMS script file ScriptHelper.RegisterCMS(this); // Fix messages position MessagesPlaceHolder.WrapperControlClientID = pnlContent.ClientID; if (QueryHelper.ValidateHash("hash") && (Parameters != null)) { // Initialize current user currentUser = CMSContext.CurrentUser; // Check permissions if (!currentUser.IsGlobalAdministrator && !currentUser.IsAuthorizedPerResource("CMS.Content", "manageworkflow")) { RedirectToAccessDenied("CMS.Content", "manageworkflow"); } // Set current UI culture currentCulture = CultureHelper.PreferredUICulture; // Initialize current site currentSiteName = CMSContext.CurrentSiteName; currentSiteId = CMSContext.CurrentSiteID; // Initialize events ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; if (!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 char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string nodeId in nodeIdsArr) { int id = ValidationHelper.GetInteger(nodeId, 0); if (id != 0) { nodeIds.Add(id); } } } else { string where = "ClassName <> 'CMS.Root'"; if (!string.IsNullOrEmpty(WhereCondition)) { where = SqlHelperClass.AddWhereCondition(where, WhereCondition); } string columns = SqlHelperClass.MergeColumns(TreeProvider.SELECTNODES_REQUIRED_COLUMNS, "NodeParentID, DocumentName,DocumentCheckedOutByUserID"); allDocs = tree.SelectNodes(currentSiteName, parentAliasPath.TrimEnd('/') + "/%", TreeProvider.ALL_CULTURES, true, null, where, "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 switch (CurrentAction) { case WorkflowAction.Archive: lblQuestion.ResourceString = "content.archivequestion"; chkAllCultures.ResourceString = "content.archiveallcultures"; chkUnderlying.ResourceString = "content.archiveunderlying"; canceledString = GetString("content.archivecanceled"); // Setup title of log titleElemAsync.TitleText = GetString("content.archivingdocuments"); titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/archive.png"); // Setup page title text and image CurrentMaster.Title.TitleText = GetString("Content.ArchiveTitle"); CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/archive.png"); break; case WorkflowAction.Publish: lblQuestion.ResourceString = "content.publishquestion"; chkAllCultures.ResourceString = "content.publishallcultures"; chkUnderlying.ResourceString = "content.publishunderlying"; canceledString = GetString("content.publishcanceled"); // Setup title of log titleElemAsync.TitleText = GetString("content.publishingdocuments"); titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/publish.png"); // Setup page title text and image CurrentMaster.Title.TitleText = GetString("Content.PublishTitle"); CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/publish.png"); break; } if (nodeIds.Count == 0) { // Hide if no node was specified pnlContent.Visible = false; return; } btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); // Register the dialog script ScriptHelper.RegisterDialogScript(this); // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; // Set all cultures checkbox DataSet culturesDS = CultureInfoProvider.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 = SqlHelperClass.GetWhereCondition("NodeID", nodeIds.ToArray()); string columns = SqlHelperClass.MergeColumns(TreeProvider.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 = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0); 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 imgUrl = "CMSModules/CMS_Content/Dialogs/publish.png"; string title = GetString("general.publish"); if (CurrentAction == WorkflowAction.Archive) { imgUrl = "CMSModules/CMS_Content/Dialogs/archive.png"; title = GetString("general.archive"); } SetTitle(imgUrl, title, null, null); } else { pnlPublish.Visible = false; ShowError(GetString("dialogs.badhashtext")); } }
protected void Page_Load(object sender, EventArgs e) { currentUser = CMSContext.CurrentUser; currentCulture = CultureHelper.PreferredUICulture; // Initialize events ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; if (!RequestHelper.IsCallback()) { // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; // Get current page template ID workflowId = QueryHelper.GetInteger("workflowid", 0); // 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 = '" + GetString("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 = '" + GetString("workflowdocuments.confrimpublish") + "';"); actionScript.AppendLine(" break;"); actionScript.AppendLine(" case '" + (int)Action.RemoveWorkflow + "':"); actionScript.AppendLine(" confMessage = '" + GetString("workflowdocuments.confirmremove") + "';"); actionScript.AppendLine(" break;"); actionScript.AppendLine(" }"); actionScript.AppendLine(" return confirm(confMessage);"); actionScript.AppendLine(" }"); actionScript.AppendLine(" else"); actionScript.AppendLine(" {"); actionScript.AppendLine(" label.innerHTML = '" + GetString("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 + "');"; btnCancel.Text = GetString("general.cancel"); btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); // Initialize dropdown list with actions if (!RequestHelper.IsPostBack()) { if (currentUser.IsGlobalAdministrator || 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; }
/// <summary> /// Return partial where condition reflecting only product from departments that user can access. /// </summary> /// <param name="currentUser">Current user.</param> private string GetDepartmentWhereCondition(CurrentUserInfo currentUser) { if (!currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "AccessAllDepartments")) { return "(SKUDepartmentID IS NULL) OR SKUDepartmentID IN (SELECT DepartmentID FROM COM_UserDepartment WHERE UserID = " + currentUser.UserID + ")"; } return string.Empty; }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Get site info currentSiteId = CMSContext.CurrentSiteID; currentSiteName = CMSContext.CurrentSiteName; // Initialize current user for the async actions currentUser = CMSContext.CurrentUser; serverId = QueryHelper.GetInteger("serverid", 0); HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (RequestHelper.CausedPostback(btnSyncComplete)) { SyncComplete(); } else { if (!RequestHelper.IsCallback()) { int nodeId = QueryHelper.GetInteger("nodeid", 0); aliasPath = "/"; // Get the document node if (nodeId > 0) { TreeProvider tree = new TreeProvider(currentUser); TreeNode node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); if (node != null) { aliasPath = node.NodeAliasPath; } } // Setup title titleElem.TitleText = GetString("Synchronization.Title"); titleElem.TitleImage = GetImageUrl("CMSModules/CMS_Staging/synchronization.png"); ucDisabledModule.SettingsKeys = "CMSStagingLogChanges;CMSStagingLogStagingChanges;"; ucDisabledModule.InfoTexts.Add(GetString("ContentStaging.TaskSeparator") + "<br/>"); ucDisabledModule.InfoTexts.Add(GetString("StagingChanges.NotLogged")); ucDisabledModule.ParentPanel = pnlNotLogged; // Check logging if (!ucDisabledModule.Check()) { plcContent.Visible = false; pnlFooter.Visible = false; return; } // Create header actions HeaderActions.AddAction(new HeaderAction() { Text = GetString("Tasks.SyncCurrent"), ImageUrl = GetImageUrl("CMSModules/CMS_Staging/synccurrent_16.png"), EventName = SYNCHRONIZE_CURRENT }); HeaderActions.AddAction(new HeaderAction() { Text = GetString("Tasks.SyncSubtree"), ImageUrl = GetImageUrl("CMSModules/CMS_Staging/syncsubtree.png"), EventName = SYNCHRONIZE_SUBTREE }); if (!RequestHelper.CausedPostback(HeaderActions, btnSyncSelected, btnSyncAll)) { // Check 'Manage servers' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks")) { RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks"); } // Register the dialog script ScriptHelper.RegisterDialogScript(this); ltlScript.Text += ScriptHelper.GetScript("function ConfirmDeleteTask(taskId) { return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDelete")) + "); }"); ltlScript.Text += ScriptHelper.GetScript("function CompleteSync(){" + Page.ClientScript.GetPostBackEventReference(btnSyncComplete, null) + "}"); // Initialize grid tasksUniGrid.OnExternalDataBound += tasksUniGrid_OnExternalDataBound; tasksUniGrid.OnAction += tasksUniGrid_OnAction; tasksUniGrid.OnDataReload += tasksUniGrid_OnDataReload; tasksUniGrid.ShowActionsMenu = true; tasksUniGrid.Columns = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount"; TaskInfo ti = new TaskInfo(); tasksUniGrid.AllColumns = SqlHelperClass.MergeColumns(ti.ColumnNames); // Initialize images viewImage = GetImageUrl("Design/Controls/UniGrid/Actions/View.png"); deleteImage = GetImageUrl("Design/Controls/UniGrid/Actions/Delete.png"); syncImage = GetImageUrl("Design/Controls/UniGrid/Actions/Synchronize.png"); // Initialize tooltips syncTooltip = GetString("general.synchronize"); deleteTooltip = GetString("general.delete"); viewTooltip = GetString("general.view"); plcContent.Visible = true; // Initialize buttons btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); btnCancel.Text = GetString("General.Cancel"); btnDeleteAll.Text = GetString("Tasks.DeleteAll"); btnDeleteSelected.Text = GetString("Tasks.DeleteSelected"); btnSyncAll.Text = GetString("Tasks.SyncAll"); btnSyncSelected.Text = GetString("Tasks.SyncSelected"); btnSyncSelected.OnClientClick = "return !" + tasksUniGrid.GetCheckSelectionScript(); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; pnlLog.Visible = false; } } } ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Initialize current user for the async actions currentUser = CMSContext.CurrentUser; HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (!RequestHelper.IsCallback()) { // Check 'Manage object tasks' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageObjectsTasks")) { RedirectToAccessDenied("cms.staging", "ManageObjectsTasks"); } siteId = QueryHelper.GetInteger("siteid", 0); currentSiteId = CMSContext.CurrentSiteID; currentSiteName = CMSContext.CurrentSiteName; serverId = QueryHelper.GetInteger("serverid", 0); ucDisabledModule.SettingsKeys = "CMSStagingLogStagingChanges;CMSStagingLogObjectChanges"; ucDisabledModule.InfoTexts.Add(GetString("StagingChanges.NotLogged") + "<br/>"); ucDisabledModule.ParentPanel = pnlNotLogged; if (siteId == -1) { ucDisabledModule.InfoTexts.Add(GetString("objectstaging.globalandsitenotlogged")); ucDisabledModule.SiteObjects = "CMSStagingLogObjectChanges"; ucDisabledModule.GlobalObjects = "CMSStagingLogObjectChanges"; } else if (siteId == 0) { ucDisabledModule.InfoTexts.Add(GetString("objectstaging.globalnotlogged")); ucDisabledModule.GlobalObjects = "CMSStagingLogObjectChanges"; } else { ucDisabledModule.InfoTexts.Add(GetString("ObjectStaging.SiteNotLogged")); ucDisabledModule.SiteObjects = "CMSStagingLogObjectChanges"; } // Check logging if (!ucDisabledModule.Check()) { plcContent.Visible = false; return; } // Get object type objectType = QueryHelper.GetString("objecttype", string.Empty); if (!String.IsNullOrEmpty(objectType) && (objectType != PredefinedObjectType.MEDIAFOLDER)) { // Create "synchronize current" header action HeaderActions.AddAction(new HeaderAction() { Text = GetString("ObjectTasks.SyncCurrent"), ImageUrl = GetImageUrl("CMSModules/CMS_Staging/syncsubtree.png"), EventName = SYNCHRONIZE_CURRENT }); } // Setup title titleElem.TitleText = GetString("Synchronization.Title"); titleElem.TitleImage = GetImageUrl("/CMSModules/CMS_Staging/synchronization.png"); // Get the selected types ObjectTypeTreeNode selectedNode = TaskInfoProvider.ObjectTree.FindNode(objectType, (siteId > 0)); objectType = (selectedNode != null) ? selectedNode.GetObjectTypes(true) : string.Empty; if (!RequestHelper.CausedPostback(HeaderActions, btnSyncSelected, btnSyncAll)) { // Register the dialog script ScriptHelper.RegisterDialogScript(this); // Initialize images viewImage = GetImageUrl("Design/Controls/UniGrid/Actions/View.png"); deleteImage = GetImageUrl("Design/Controls/UniGrid/Actions/Delete.png"); syncImage = GetImageUrl("Design/Controls/UniGrid/Actions/Synchronize.png"); // Initialize tooltips syncTooltip = GetString("general.synchronize"); deleteTooltip = GetString("general.delete"); viewTooltip = GetString("general.view"); plcContent.Visible = true; // Initialize buttons btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); btnCancel.Text = GetString("General.Cancel"); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; btnSyncSelected.OnClientClick = "return !" + gridTasks.GetCheckSelectionScript(); // Initialize grid gridTasks.ZeroRowsText = GetString("Tasks.NoTasks"); gridTasks.OnAction += gridTasks_OnAction; gridTasks.OnDataReload += gridTasks_OnDataReload; gridTasks.OnExternalDataBound += gridTasks_OnExternalDataBound; gridTasks.ShowActionsMenu = true; gridTasks.Columns = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount"; TaskInfo ti = new TaskInfo(); gridTasks.AllColumns = SqlHelperClass.MergeColumns(ti.ColumnNames); pnlLog.Visible = false; } } ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; }
protected void Page_Load(object sender, EventArgs e) { currentUser = CMSContext.CurrentUser; // Use UI culture for strings string culture = currentUser.PreferredUICultureCode; // Hide the add MVT/CP variant when Manage permission is not allowed if (!currentUser.IsAuthorizedPerResource("cms.mvtest", "Manage")) { plcAddMVTVariant.Visible = false; } if (!currentUser.IsAuthorizedPerResource("cms.contentpersonalization", "Manage")) { plcAddCPVariant.Visible = false; } if (CMSContext.ViewMode == ViewModeEnum.Wireframe) { pnlUIClone.AlwaysVisible = true; pnlUIDelete.AlwaysVisible = true; pnlUIProperties.AlwaysVisible = true; } string click = null; // Main menu iProperties.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Properties.png"); iProperties.Text = ResHelper.GetString("WebPartMenu.IconProperties", culture); iProperties.Attributes.Add("onclick", "ContextConfigureWebPart(GetContextMenuParameter('webPartMenu'));"); // Up menu - Bottom iTop.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Top.png"); iTop.Text = ResHelper.GetString("UpMenu.IconTop", culture); iForwardAll.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/forward.png"); iForwardAll.Text = ResHelper.GetString("WebPartMenu.IconForward", culture); click = "ContextMoveWebPartTop(GetContextMenuParameter('webPartMenu'));"; iForwardAll.Attributes.Add("onclick", click); iTop.Attributes.Add("onclick", click); // Up iUp.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Up.png"); iUp.Text = ResHelper.GetString("WebPartMenu.IconUp", culture); click = "ContextMoveWebPartUp(GetContextMenuParameter('webPartMenu'));"; iUp.Attributes.Add("onclick", click); // Down iDown.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Down.png"); iDown.Text = ResHelper.GetString("WebPartMenu.IconDown", culture); click = "ContextMoveWebPartDown(GetContextMenuParameter('webPartMenu'));"; iDown.Attributes.Add("onclick", click); // Down menu - Bottom iBottom.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Bottom.png"); iBottom.Text = ResHelper.GetString("DownMenu.IconBottom", culture); iBackwardAll.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/backward.png"); iBackwardAll.Text = ResHelper.GetString("WebPartMenu.IconBackward", culture); click = "ContextMoveWebPartBottom(GetContextMenuParameter('webPartMenu'));"; iBackwardAll.Attributes.Add("onclick", click); iBottom.Attributes.Add("onclick", click); // Move to iMoveTo.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/MoveTo.png"); iMoveTo.Text = ResHelper.GetString("WebPartMenu.IconMoveTo", culture); // Clone iClone.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Clonewebpart.png"); iClone.Text = ResHelper.GetString("WebPartMenu.IconClone", culture); iClone.Attributes.Add("onclick", "ContextCloneWebPart(GetContextMenuParameter('webPartMenu'));"); // Delete iDelete.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Delete.png"); iDelete.Text = ResHelper.GetString("general.remove", culture); iDelete.Attributes.Add("onclick", "ContextRemoveWebPart(GetContextMenuParameter('webPartMenu'));"); // Add new MVT variant lblAddMVTVariant.Text = ResHelper.GetString("WebPartMenu.AddWebPartVariant", culture); imgAddMVTVariant.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Variants/addWebPart.png"); imgAddMVTVariant.AlternateText = lblAddMVTVariant.Text; pnlAddMVTVariant.Attributes.Add("onclick", "ContextAddWebPartMVTVariant(GetContextMenuParameter('webPartMenu'));"); // Add new Content personalization variant lblAddCPVariant.Text = ResHelper.GetString("WebPartMenu.AddWebPartVariant", culture); imgAddCPVariant.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Variants/addWebPart.png"); imgAddCPVariant.AlternateText = lblAddCPVariant.Text; pnlAddCPVariant.Attributes.Add("onclick", "ContextAddWebPartCPVariant(GetContextMenuParameter('webPartMenu'));"); // List all variants lblMVTVariants.Text = ResHelper.GetString("WebPartMenu.WebPartMVTVariants", culture); lblCPVariants.Text = ResHelper.GetString("WebPartMenu.WebPartPersonalizationVariants", culture); // No MVT variants lblNoWebPartMVTVariants.Text = ResHelper.GetString("ZoneMenu.NoVariants"); imgNoWebPartMVTVariants.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Variants/novariant.png"); // No CP variants lblNoWebPartCPVariants.Text = ResHelper.GetString("ZoneMenu.NoVariants"); imgNoWebPartCPVariants.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Variants/novariant.png"); imgMVTVariants.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Variants/webPartList.png"); imgMVTVariants.AlternateText = lblMVTVariants.Text; imgCPVariants.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/ContextMenu/Variants/webPartList.png"); imgCPVariants.AlternateText = lblCPVariants.Text; if (PortalManager.CurrentPlaceholder != null) { // Build the list of web part zones ArrayList webPartZones = new ArrayList(); if (PortalManager.CurrentPlaceholder.WebPartZones != null) { foreach (CMSWebPartZone zone in PortalManager.CurrentPlaceholder.WebPartZones) { // Add only standard zones to the list if (zone.ZoneInstance.WidgetZoneType == WidgetZoneTypeEnum.None) { webPartZones.Add(zone); } } } repZones.DataSource = webPartZones; repZones.DataBind(); } if (PortalContext.MVTVariantsEnabled || PortalContext.ContentPersonalizationEnabled) { menuMoveToZoneVariants.LoadingContent = "<div class=\"PortalContextMenu WebPartContextMenu\"><div class=\"ItemPadding\">" + ResHelper.GetString("ContextMenu.Loading") + "</div></div>"; menuMoveToZoneVariants.OnReloadData += menuMoveToZoneVariants_OnReloadData; repMoveToZoneVariants.ItemDataBound += repMoveToZoneVariants_ItemDataBound; // Display the MVT menu part in the CMSDesk->Design only. Hide the context menu in the SM->PageTemplates->Design if (PortalContext.MVTVariantsEnabled && (CMSContext.CurrentPageInfo != null) && (CMSContext.CurrentPageInfo.DocumentID > 0)) { // Set Display='none' for the MVT panel. Show dynamically only if required. pnlContextMenuMVTVariants.Visible = true; pnlContextMenuMVTVariants.Style.Add("display", "none"); menuWebPartMVTVariants.LoadingContent = "<div class=\"PortalContextMenu WebPartContextMenu\"><div class=\"ItemPadding\">" + ResHelper.GetString("ContextMenu.Loading", CultureHelper.GetPreferredUICulture()) + "</div></div>"; menuWebPartMVTVariants.OnReloadData += menuWebPartMVTVariants_OnReloadData; repWebPartMVTVariants.ItemDataBound += repWebPartVariants_ItemDataBound; string script = "webPartMVTVariantContextMenuId = '" + pnlContextMenuMVTVariants.ClientID + "';"; ScriptHelper.RegisterStartupScript(this, typeof(string), "webPartMVTVariantContextMenuId", ScriptHelper.GetScript(script)); } else { // Hide the MVT variant context menu items when MVT is not enabled for the current document pnlUIMVTVariants.Visible = false; } // Display the Content personalization menu part in the CMSDesk->Design only. Hide the context menu in the SM->PageTemplates->Design if ((PortalContext.ContentPersonalizationEnabled) && (CMSContext.CurrentPageInfo != null) && (CMSContext.CurrentPageInfo.DocumentID > 0)) { // Set Display='none' for the MVT panel. Show dynamically only if required. pnlContextMenuCPVariants.Visible = true; pnlContextMenuCPVariants.Style.Add("display", "none"); menuWebPartCPVariants.LoadingContent = "<div class=\"PortalContextMenu WebPartContextMenu\"><div class=\"ItemPadding\">" + ResHelper.GetString("ContextMenu.Loading", CultureHelper.GetPreferredUICulture()) + "</div></div>"; menuWebPartCPVariants.OnReloadData += menuWebPartCPVariants_OnReloadData; repWebPartCPVariants.ItemDataBound += repWebPartVariants_ItemDataBound; string script = "webPartCPVariantContextMenuId = '" + pnlContextMenuCPVariants.ClientID + "';"; ScriptHelper.RegisterStartupScript(this, typeof(string), "webPartCPVariantContextMenuId", ScriptHelper.GetScript(script)); } else { // Hide the Content personalization variant context menu items when the Content Personalization is not enabled. pnlUICPVariants.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { currentUser = MembershipContext.AuthenticatedUser; // Hide the add MVT/CP variant when Manage permission is not allowed if (!currentUser.IsAuthorizedPerResource("cms.contentpersonalization", "Manage")) { plcAddCPVariant.Visible = false; } if (!currentUser.IsAuthorizedPerResource("cms.mvtest", "Manage")) { plcAddMVTVariant.Visible = false; } // Main menu lblNewWebPart.Text = ResHelper.GetString("ZoneMenu.IconNewWebPart", UICulture); pnlNewWebPart.Attributes.Add("onclick", "ContextNewWebPart();"); // Configure lblConfigureZone.Text = ResHelper.GetString("ZoneMenu.IconConfigureWebpartZone", UICulture); pnlConfigureZone.Attributes.Add("onclick", "ContextConfigureWebPartZone();"); // Move to lblMoveTo.Text = ResHelper.GetString("ZoneMenu.IconMoveTo", UICulture); // Copy all web parts lblCopy.Text = ResHelper.GetString("ZoneMenu.CopyAll", UICulture); pnlCopyAllItem.Attributes.Add("onclick", "ContextCopyAllWebParts();"); // Paste web part(s) lblPaste.Text = ResHelper.GetString("ZoneMenu.paste", UICulture); pnlPaste.Attributes.Add("onclick", "ContextPasteWebPartZone();"); pnlPaste.ToolTip = ResHelper.GetString("ZoneMenu.pasteTooltip", UICulture); // Delete all web parts lblDelete.Text = ResHelper.GetString("ZoneMenu.RemoveAll", UICulture); pnlDelete.Attributes.Add("onclick", "ContextRemoveAllWebParts();"); // Add new MVT variants lblAddMVTVariant.Text = ResHelper.GetString("ZoneMenu.AddZoneVariant", UICulture); // Add new Content personalization variant lblAddCPVariant.Text = ResHelper.GetString("ZoneMenu.AddZoneVariant", UICulture); // Add new variant pnlAddMVTVariant.Attributes.Add("onclick", "ContextAddWebPartZoneMVTVariant();"); pnlAddCPVariant.Attributes.Add("onclick", "ContextAddWebPartZoneCPVariant();"); // List all variants lblMVTVariants.Text = ResHelper.GetString("ZoneMenu.ZoneMVTVariants", UICulture); lblCPVariants.Text = ResHelper.GetString("ZoneMenu.ZonePersonalizationVariants", UICulture); // No MVT variants lblNoZoneMVTVariants.Text = ResHelper.GetString("ZoneMenu.NoVariants", UICulture); // No CP variants lblNoZoneCPVariants.Text = ResHelper.GetString("ZoneMenu.NoVariants", UICulture); if (PortalManager.CurrentPlaceholder != null) { // Build the list of web part zones var webPartZones = new List<CMSWebPartZone>(); if (PortalManager.CurrentPlaceholder.WebPartZones != null) { foreach (CMSWebPartZone zone in PortalManager.CurrentPlaceholder.WebPartZones) { // Add only standard zones to the list if ((zone.ZoneInstance.WidgetZoneType == WidgetZoneTypeEnum.None) && zone.AllowModifyWebPartCollection) { webPartZones.Add(zone); } } } repZones.DataSource = webPartZones; repZones.DataBind(); } if (PortalContext.MVTVariantsEnabled || PortalContext.ContentPersonalizationEnabled) { var loadingMenu = new ContextMenuItem { ResourceString = "ContextMenu.Loading" }.GetRenderedHTML(); menuMoveToZoneVariants.LoadingContent = loadingMenu; menuMoveToZoneVariants.OnReloadData += menuMoveToZoneVariants_OnReloadData; repMoveToZoneVariants.ItemDataBound += repZoneVariants_ItemDataBound; // Display the MVT menu part in the CMSDesk->Design only. Hide the context menu in the SM->PageTemplates->Design if (PortalContext.MVTVariantsEnabled && (DocumentContext.CurrentPageInfo != null) && (DocumentContext.CurrentPageInfo.DocumentID > 0) && currentUser.IsAuthorizedPerResource("cms.mvtest", "read")) { // Set Display='none' for the MVT panel. Show dynamically only if required. pnlContextMenuMVTVariants.Visible = true; pnlContextMenuMVTVariants.Style.Add("display", "none"); menuZoneMVTVariants.LoadingContent = loadingMenu; menuZoneMVTVariants.OnReloadData += menuZoneMVTVariants_OnReloadData; repZoneMVTVariants.ItemDataBound += repVariants_ItemDataBound; string script = "zoneMVTVariantContextMenuId = '" + pnlContextMenuMVTVariants.ClientID + "';"; ScriptHelper.RegisterStartupScript(this, typeof(string), "zoneMVTVariantContextMenuId", ScriptHelper.GetScript(script)); } else { // Hide the MVT variant context menu items when MVT is not enabled for the current document pnlUIMVTVariants.Visible = false; } // Display the Content personalization menu part in the CMSDesk->Design only. Hide the context menu in the SM->PageTemplates->Design if ((PortalContext.ContentPersonalizationEnabled) && (DocumentContext.CurrentPageInfo != null) && (DocumentContext.CurrentPageInfo.DocumentID > 0) && currentUser.IsAuthorizedPerResource("cms.contentpersonalization", "read")) { // Set Display='none' for the MVT panel. Show dynamically only if required. pnlContextMenuCPVariants.Visible = true; pnlContextMenuCPVariants.Style.Add("display", "none"); menuZoneCPVariants.LoadingContent = loadingMenu; menuZoneCPVariants.OnReloadData += menuZoneCPVariants_OnReloadData; repZoneCPVariants.ItemDataBound += repVariants_ItemDataBound; string script = "zoneCPVariantContextMenuId = '" + pnlContextMenuCPVariants.ClientID + "';"; ScriptHelper.RegisterStartupScript(this, typeof(string), "zoneCPVariantContextMenuId", ScriptHelper.GetScript(script)); } else { // Hide the Content personalization variant context menu items when the Content Personalization is not enabled. pnlUICPVariants.Visible = false; } } }