protected void btnTranslate_Click(object sender, EventArgs e) { // Check if data are correct var error = translationElem.ValidateData(); if (!String.IsNullOrEmpty(error) || !allowTranslate) { plcMessages.AddError(error); return; } if (isSelect) { // If in select mode, prepare node IDs now TreeProvider tree = new TreeProvider(); DataSet ds = tree.SelectNodes(CurrentSiteName, pathElem.Value.ToString(), TreeProvider.ALL_CULTURES, true, TreeProvider.ALL_CLASSNAMES, null, null, TreeProvider.ALL_LEVELS, false, 0, DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath"); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataTable table in ds.Tables) { foreach (DataRow dr in table.Rows) { TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr); if (TranslationServiceHelper.IsAuthorizedToTranslateDocument(node, currentUser, translationElem.TargetLanguages)) { nodeIds.Add(ValidationHelper.GetInteger(dr["NodeID"], 0)); } else { HideUI(); plcMessages.AddError(String.Format(GetString("cmsdesk.notauthorizedtotranslatedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath))); return; } } } } else { ShowError(GetString("translationservice.nodocumentstotranslate")); return; } targetCultures = translationElem.TargetLanguages; } pnlLog.Visible = true; pnlContent.Visible = false; CurrentError = string.Empty; ctlAsyncLog.RunAsync(p => Translate(AllLevels), WindowsIdentity.GetCurrent()); }
protected void btnOk_Click(object sender, EventArgs e) { // Check permissions string errMsg = CheckNodePermissions(); // If validation succeeded if (errMsg == string.Empty) { try { // Validate form entry errMsg = ValidateForm(); if (errMsg == string.Empty) { if (ParentNode != null) { // Initialize and create new folder node TreeNode newFolder = TreeNode.New("CMS.folder", TreeProvider); // Set properties newFolder.DocumentName = txtFolderName.Text.Trim(); newFolder.DocumentCulture = ParentCulture; newFolder.SetValue("NodeOwner", CMSContext.CurrentUser.UserID); // Create new folder DocumentHelper.InsertDocument(newFolder, ParentNode, TreeProvider); // Reload parent content if (OnFolderChange != null) { OnFolderChange(newFolder.NodeID); } } } else { // Display an error to the user ShowError(errMsg); } } catch (Exception ex) { // Display an error to the user ShowError(GetString("general.erroroccurred") + " " + ex.Message); } } else { // Display an error to the user ShowError(errMsg); } }
protected void btnCreateDocument_Click(object sender, EventArgs e) { if (radCopy.Checked) { string sourceCulture = copyCulturesElem.Value.ToString(); TreeNode sourceNode = DocumentHelper.GetDocument(NodeID, sourceCulture, Tree); if (sourceNode != null) { if (chkSaveBeforeEditing.Checked && (node != null)) { // Create the version first TreeNode newCulture = TreeNode.New(node.ClassName); DocumentHelper.CopyNodeData(sourceNode, newCulture, new CopyNodeDataSettings(true, null)); NewCultureDocumentSettings settings = new NewCultureDocumentSettings { Node = newCulture, CultureCode = RequiredCulture, CopyAttachments = true, CopyCategories = true }; DocumentHelper.InsertNewCultureVersion(settings); // Refresh page if (RequiresDialog) { string url = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(newCulture.NodeAliasPath) + "?" + URLHelper.LanguageParameterName + "=" + RequiredCulture); ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript(" wopener.location = " + ScriptHelper.GetString(url) + "; CloseDialog();")); } else { ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript("if (FramesRefresh) { FramesRefresh(" + node.NodeID + "); }")); } } else { var url = GetEditUrl(node); url = URLHelper.AddParameterToUrl(url, "sourcedocumentid", sourceNode.DocumentID.ToString()); Response.Redirect(url); } } else { ShowError(GetString("transman.notallowedcreate")); } } else { var url = GetEditUrl(node); Response.Redirect(url); } }
/// <summary> /// Initializes filter form. /// </summary> private void InitializeFilterForm() { // If ClassID is not used don't initialize if (ClassID != UniSelector.US_NONE_RECORD) { if (ClassID > 0) { var className = DataClassInfoProvider.GetClassName(ClassID); var formName = className + ".filter"; var form = AlternativeFormInfoProvider.GetAlternativeFormInfo(formName); formName += (form != null) ? "+cms.document.simplefilter" : "+cms.document.filter"; gridDocuments.FilterFormName = formName; gridDocuments.FilterFormData = TreeNode.New(className); } else { gridDocuments.FilterFormName = "cms.document.filter"; gridDocuments.FilterFormData = TreeNode.New(); } } }
protected object gridBlogs_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "edit": case "newpost": GridViewRow gvr = (parameter as GridViewRow); if (gvr != null) { DataRowView dr = (gvr.DataItem as DataRowView); if (dr != null) { TreeNode blogNode = TreeNode.New(dr.Row, ValidationHelper.GetString(dr.Row["ClassName"], "")); if (blogNode != null) { isAuthorized = isAuthorized || BlogHelper.IsUserBlogOwner(currentUser.UserID, blogNode); if (!isAuthorized) { ImageButton button = ((ImageButton)sender); if (sourceName.ToLowerCSafe() == "edit") { button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/editdisabled.png"); } else { button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/addpostdisabled.png"); } button.Enabled = false; } } } } break; } return(parameter); }
protected void Page_Load(object sender, EventArgs e) { // Register script files ScriptHelper.RegisterCMS(this); ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js"); if (!QueryHelper.ValidateHash("hash")) { pnlContent.Visible = false; ShowError(GetString("dialogs.badhashtext")); return; } // Setup page title text and image PageTitle.TitleText = GetString("Content.TranslateTitle"); EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText); if (IsDialog) { RegisterModalPageScripts(); RegisterEscScript(); plcInfo.Visible = false; pnlButtons.Visible = false; } if (!TranslationServiceHelper.IsTranslationAllowed(CurrentSiteName)) { pnlContent.Visible = false; ShowError(GetString("translations.translationnotallowed")); return; } // Initialize current user currentUser = MembershipContext.AuthenticatedUser; // Initialize events ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished; ctlAsyncLog.OnError += ctlAsyncLog_OnError; ctlAsyncLog.OnCancel += ctlAsyncLog_OnCancel; isSelect = QueryHelper.GetBoolean("select", false); if (isSelect) { pnlDocList.Visible = false; pnlDocSelector.Visible = true; translationElem.DisplayMachineServices = false; } var currentCulture = LocalizationContext.CurrentCulture.CultureCode; var displayTargetLanguage = !IsDialog || isSelect; translationElem.DisplayTargetlanguage = displayTargetLanguage; // Get target culture(s) targetCultures = displayTargetLanguage ? translationElem.TargetLanguages : new HashSet <string>(new[] { QueryHelper.GetString("targetculture", currentCulture) }); // Set the target settings var settings = new TranslationSettings(); settings.TargetLanguages.AddRange(targetCultures); var useCurrentAsDefault = QueryHelper.GetBoolean("currentastargetdefault", false); if (!currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && currentUser.UserHasAllowedCultures && !currentUser.IsCultureAllowed(currentCulture, CurrentSiteName)) { // Do not use current culture as default if user has no permissions to edit it useCurrentAsDefault = false; } translationElem.UseCurrentCultureAsDefaultTarget = useCurrentAsDefault; // Do not include default culture if it is current one string defaultCulture = CultureHelper.GetDefaultCultureCode(CurrentSiteName); if (useCurrentAsDefault && !string.Equals(currentCulture, defaultCulture, StringComparison.InvariantCultureIgnoreCase) && !RequestHelper.IsPostBack()) { settings.TargetLanguages.Add(currentCulture); } translationElem.TranslationSettings = settings; allowTranslate = true; if (RequestHelper.IsCallback()) { return; } // If not in select mode, load all the document IDs and check permissions // In select mode, documents are checked when the button is clicked if (!isSelect) { DataSet allDocs = null; TreeProvider tree = new TreeProvider(); // Current Node ID to translate string parentAliasPath = string.Empty; if (Parameters != null) { parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty); nodeIdsArr = ValidationHelper.GetString(Parameters["nodeids"], string.Empty).Trim('|').Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } if (string.IsNullOrEmpty(parentAliasPath)) { if (nodeIdsArr == null) { // One document translation is requested string nodeIdQuery = QueryHelper.GetString("nodeid", ""); if (nodeIdQuery != "") { // Mode of single node translation pnlList.Visible = false; chkSkipTranslated.Checked = false; translationElem.NodeID = ValidationHelper.GetInteger(nodeIdQuery, 0); nodeIdsArr = new[] { nodeIdQuery }; } else { nodeIdsArr = new string[] { }; } } foreach (string nodeId in nodeIdsArr) { int id = ValidationHelper.GetInteger(nodeId, 0); if (id != 0) { nodeIds.Add(id); } } } else { // Exclude root of the website from multiple translation requested by document listing bulk action var where = new WhereCondition(WhereCondition) .WhereNotEquals("ClassName", SystemDocumentTypes.Root); allDocs = tree.SelectNodes(CurrentSiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%", TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where.ToString(true), "DocumentName", AllLevels ? TreeProvider.ALL_LEVELS : 1, false, 0, DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath"); if (!DataHelper.DataSourceIsEmpty(allDocs)) { foreach (DataTable table in allDocs.Tables) { foreach (DataRow row in table.Rows) { nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0)); } } } } if (nodeIds.Count > 0) { var where = new WhereCondition().WhereIn("NodeID", nodeIds).ToString(true); DataSet ds = allDocs ?? tree.SelectNodes(CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", TreeProvider.ALL_LEVELS, false); if (!DataHelper.DataSourceIsEmpty(ds)) { string docList = null; cancelNodeId = string.IsNullOrEmpty(parentAliasPath) ? DataHelper.GetIntValue(ds.Tables[0].Rows[0], "NodeParentID") : TreePathUtils.GetNodeIdByAliasPath(CurrentSiteName, parentAliasPath); foreach (DataTable table in ds.Tables) { foreach (DataRow dr in table.Rows) { bool isLink = (dr["NodeLinkedNodeID"] != DBNull.Value); string name = (string)dr["DocumentName"]; docList += HTMLHelper.HTMLEncode(name); if (isLink) { docList += DocumentUIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link); } docList += "<br />"; lblDocuments.Text = docList; // Set visibility of checkboxes TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr); if (!TranslationServiceHelper.IsAuthorizedToTranslateDocument(node, currentUser, targetCultures)) { allowTranslate = false; plcMessages.AddError(String.Format(GetString("cmsdesk.notauthorizedtotranslatedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath))); } } } if (!allowTranslate && !RequestHelper.IsPostBack()) { // Hide UI only when security check is performed within first load, if postback used user may loose some setting HideUI(); } } // Display check box for separate submissions for each document if there is more than one document translationElem.DisplaySeparateSubmissionOption = (nodeIds.Count > 1); } else { // Hide everything pnlContent.Visible = false; } } // Register the dialog script ScriptHelper.RegisterDialogScript(this); ctlAsyncLog.TitleText = GetString("contentrequest.starttranslate"); // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; }
protected void Page_Load(object sender, EventArgs e) { // Register script files ScriptHelper.RegisterCMS(this); ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js"); // Set current UI culture currentCulture = CultureHelper.PreferredUICultureCode; // Initialize current user currentUser = MembershipContext.AuthenticatedUser; // Initialize current site currentSite = SiteContext.CurrentSite; // Initialize events 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[] { '|' }, 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 = SqlHelper.AddWhereCondition(where, WhereCondition); } allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%", TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where, "DocumentName", TreeProvider.ALL_LEVELS, false, 0, TreeProvider.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath,NodeSKUID"); if (!DataHelper.DataSourceIsEmpty(allDocs)) { foreach (DataTable table in allDocs.Tables) { foreach (DataRow row in table.Rows) { nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0)); } } } } // Setup page title text and image PageTitle.TitleText = GetString("Content.DeleteTitle"); EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText); btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); // Register the dialog script ScriptHelper.RegisterDialogScript(this); titleElemAsync.TitleText = GetString("ContentDelete.DeletingDocuments"); // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; bool isMultilingual = CultureSiteInfoProvider.IsSiteMultilingual(currentSite.SiteName); if (!isMultilingual) { // Set all cultures checkbox chkAllCultures.Checked = true; chkAllCultures.Visible = false; } if (nodeIds.Count > 0) { if (nodeIds.Count == 1) { // Single document deletion int nodeId = ValidationHelper.GetInteger(nodeIds[0], 0); TreeNode node = null; if (string.IsNullOrEmpty(parentAliasPath)) { // Get any culture if current not found node = tree.SelectSingleNode(nodeId, CultureCode) ?? tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); } else { if (allDocs != null) { DataRow dr = allDocs.Tables[0].Rows[0]; node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr, tree); } } if (node != null) { bool rootDeleteDisabled = false; if (IsProductsMode) { string startingPath = SettingsKeyInfoProvider.GetStringValue(CurrentSiteName + ".CMSStoreProductsStartingPath"); if (node.NodeAliasPath.CompareToCSafe(startingPath) == 0) { string closeLink = "<a href=\"#\"><span style=\"cursor: pointer;\" " + "onclick=\"SelectNode(" + node.NodeID + "); return false;\">" + GetString("general.back") + "</span></a>"; ShowError(string.Format(GetString("com.productsection.deleteroot"), closeLink, "")); pnlDelete.Visible = false; rootDeleteDisabled = true; } } if (node.IsRoot() && isMultilingual) { // Hide 'Delete all cultures' checkbox chkAllCultures.Visible = false; if (!URLHelper.IsPostback()) { // Check if there are any documents in another culture or current culture has some documents pnlDeleteRoot.Visible = IsAnyDocumentInAnotherCulture(node) && (tree.SelectNodesCount(SiteContext.CurrentSiteName, "/%", LocalizationContext.PreferredCultureCode, false, null, null, null, TreeProvider.ALL_LEVELS, false) > 0); if (pnlDeleteRoot.Visible) { // Insert 'Delete current root' option if current root node is translated to current culture if (node.DocumentCulture == LocalizationContext.PreferredCultureCode) { rblRoot.Items.Add(new ListItem(GetString("rootdeletion.currentroot"), "current")); } rblRoot.Items.Add(new ListItem(GetString("rootdeletion.currentculture"), "allculturepages")); rblRoot.Items.Add(new ListItem(GetString("rootdeletion.allpages"), "allpages")); } else { rblRoot.Items.Add(new ListItem(GetString("rootdeletion.allpages"), "allpages")); } if (rblRoot.SelectedIndex < 0) { rblRoot.SelectedIndex = 0; } } } // Display warning for root node if (!rootDeleteDisabled && node.IsRoot()) { if (!currentUser.IsGlobalAdministrator) { pnlDelete.Visible = false; ShowInformation(GetString("delete.rootonlyglobaladmin")); } else { if ((rblRoot.SelectedValue == "allpages") || !isMultilingual || ((rblRoot.SelectedValue == "allculturepages") && !IsAnyDocumentInAnotherCulture(node))) { messagesPlaceholder.ShowWarning(GetString("Delete.RootWarning")); plcDeleteRoot.Visible = true; } else { plcDeleteRoot.Visible = false; } } } hasChildren = node.NodeHasChildren; bool authorizedToDeleteSKU = !node.HasSKU || IsUserAuthorizedToModifySKU(node); if (!RequestHelper.IsPostBack()) { bool authorizedToDeleteDocument = IsUserAuthorizedToDeleteDocument(node); if (!authorizedToDeleteDocument || !authorizedToDeleteSKU) { pnlDelete.Visible = false; RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath))); } } if (node.IsLink) { PageTitle.TitleText = GetString("Content.DeleteTitleLink") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(node.GetDocumentName())) + "\""; headQuestion.Text = GetString("ContentDelete.QuestionLink"); chkAllCultures.Checked = true; plcCheck.Visible = false; } else { string nodeName = HTMLHelper.HTMLEncode(node.GetDocumentName()); // Get name for root document if (node.NodeClassName.ToLowerCSafe() == "cms.root") { nodeName = HTMLHelper.HTMLEncode(currentSite.DisplayName); } PageTitle.TitleText = GetString("Content.DeleteTitle") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(nodeName)) + "\""; bool showSKUGroup = false; if (NodeHasChildWithProduct(tree, node)) { // Deleting product section lblSKUActionInfo.Text = GetString("ContentDelete.SectionAssignedSKUInfo"); headDeleteSKU.Text = GetString("ContentDelete.AssignedSKUs"); showSKUGroup = true; } else if (node.HasSKU && authorizedToDeleteSKU) { // Deleting product if (!NodeSharesSKUWithOtherNode(tree, node)) { lblSKUActionInfo.Text = GetString("contentdelete.assignedskuinfo"); headDeleteSKU.Text = GetString("ContentDelete.AssignedSKU"); showSKUGroup = true; } } pnlDeleteSKU.Visible = showSKUGroup; rblSKUAction.Visible = showSKUGroup; } // Show or hide checkbox chkDestroy.Visible = CanDestroy(node); cancelNodeId = IsMultipleAction ? node.NodeParentID : node.NodeID; if (node.IsRoot()) { // Change SEO panel if root is selected pnlSeo.Visible = false; } } else { if (!RequestHelper.IsPostBack()) { URLHelper.Redirect(UIHelper.GetInformationUrl("editeddocument.notexists")); } else { // Hide everything pnlContent.Visible = false; } } headQuestion.Text = GetString("ContentDelete.Question"); chkAllCultures.Text = GetString("ContentDelete.AllCultures"); chkDestroy.Text = GetString("ContentDelete.Destroy"); headDeleteDocument.Text = GetString("ContentDelete.Document"); } 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)) { 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; bool permissions = true; foreach (DataTable table in ds.Tables) { foreach (DataRow dr in table.Rows) { bool isLink = (dr["NodeLinkedNodeID"] != DBNull.Value); string name = (string)dr["DocumentName"]; docList += HTMLHelper.HTMLEncode(name); if (isLink) { docList += DocumentHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link); } docList += "<br />"; lblDocuments.Text = docList; // Set visibility of checkboxes TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr); if (!IsUserAuthorizedToDeleteDocument(node)) { permissions = false; AddError(String.Format( GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)), null); } // Can destroy if "can destroy all previous AND current" canDestroy = CanDestroy(node) && canDestroy; if (!hasChildren) { hasChildren = node.NodeHasChildren; } if ((node.HasSKU && IsUserAuthorizedToModifySKU(node)) || NodeHasChildWithProduct(tree, node)) { pnlDeleteSKU.Visible = true; rblSKUAction.Visible = true; } } } pnlDelete.Visible = permissions; chkDestroy.Visible = canDestroy; } else { if (!RequestHelper.IsPostBack()) { URLHelper.Redirect(UIHelper.GetInformationUrl("editeddocument.notexists")); } else { // Hide everything pnlContent.Visible = false; } } headQuestion.Text = GetString("ContentDelete.QuestionMultiple"); PageTitle.TitleText = GetString("Content.DeleteTitleMultiple"); chkAllCultures.Text = GetString("ContentDelete.AllCulturesMultiple"); chkDestroy.Text = GetString("ContentDelete.DestroyMultiple"); headDeleteDocument.Text = GetString("global.pages"); headDeleteSKU.Text = GetString("ContentDelete.AssignedSKUs"); lblSKUActionInfo.Text = GetString("ContentDelete.AssignedSKUsInfo"); } // Init product actions if (!RequestHelper.IsPostBack()) { rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.deleteordisable"), "deleteordisable")); rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.delete"), "delete")); rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.disable"), "disable")); rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.noaction"), "noaction")); rblSKUAction.SelectedValue = "deleteordisable"; } lblAltPath.AssociatedControlClientID = selAltPath.PathTextBox.ClientID; chkUseDeletedPath.CheckedChanged += chkUseDeletedPath_CheckedChanged; if (!RequestHelper.IsPostBack()) { selAltPath.Enabled = false; chkAltSubNodes.Enabled = false; chkAltAliases.Enabled = false; // Set default path if is defined selAltPath.Value = SettingsKeyInfoProvider.GetStringValue(CurrentSiteName + ".CMSDefaultDeletedNodePath"); if (!hasChildren) { chkAltSubNodes.Checked = false; chkAltSubNodes.Enabled = false; } } // If user has allowed cultures specified if (currentUser.UserHasAllowedCultures) { // Get all site cultures DataSet siteCultures = CultureSiteInfoProvider.GetSiteCultures(currentSite.SiteName); bool denyAllCulturesDeletion = false; // Check that user can edit all site cultures foreach (DataRow culture in siteCultures.Tables[0].Rows) { string cultureCode = 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; } } pnlDeleteDocument.Visible = chkAllCultures.Visible || chkDestroy.Visible; } else { // Hide everything pnlContent.Visible = false; } } }
/// <summary> /// Updates the current Group or creates new if no GroupID is present. /// </summary> public void SaveData() { if (!CheckPermissions("cms.groups", PERMISSION_MANAGE, GroupID)) { return; } // Trim display name and code name string displayName = txtDisplayName.Text.Trim(); string codeName = txtCodeName.Text.Trim(); // Validate form entries string errorMessage = ValidateForm(displayName, codeName); if (errorMessage == "") { GroupInfo group = null; try { bool newGroup = false; // Update existing item if ((GroupID > 0) && (gi != null)) { group = gi; } else { group = new GroupInfo(); newGroup = true; } if (group != null) { if (displayName != group.GroupDisplayName) { // Refresh a breadcrumb if used in the tabs layout ScriptHelper.RefreshTabHeader(Page, displayName); } if (DisplayAdvanceOptions) { // Update Group fields group.GroupDisplayName = displayName; group.GroupName = codeName; group.GroupNodeGUID = ValidationHelper.GetGuid(groupPageURLElem.Value, Guid.Empty); } if (AllowChangeGroupDisplayName && IsLiveSite) { group.GroupDisplayName = displayName; } group.GroupDescription = txtDescription.Text; group.GroupAccess = GetGroupAccess(); group.GroupSiteID = SiteID; group.GroupApproveMembers = GetGroupApproveMembers(); group.GroupSendJoinLeaveNotification = chkJoinLeave.Checked; group.GroupSendWaitingForApprovalNotification = chkWaitingForApproval.Checked; groupPictureEdit.UpdateGroupPicture(group); // If new group was created if (newGroup) { // Set columns GroupCreatedByUserID and GroupApprovedByUserID to current user var user = MembershipContext.AuthenticatedUser; if (user != null) { group.GroupCreatedByUserID = user.UserID; group.GroupApprovedByUserID = user.UserID; group.GroupApproved = true; } } if (!IsLiveSite && (group.GroupNodeGUID == Guid.Empty)) { plcStyleSheetSelector.Visible = false; } // Save theme int selectedSheetID = ValidationHelper.GetInteger(ctrlSiteSelectStyleSheet.Value, 0); if (plcStyleSheetSelector.Visible) { if (group.GroupNodeGUID != Guid.Empty) { // Save theme for every site culture var cultures = CultureSiteInfoProvider.GetSiteCultureCodes(SiteContext.CurrentSiteName); if (cultures != null) { TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Return class name of selected tree node TreeNode treeNode = tree.SelectSingleNode(group.GroupNodeGUID, TreeProvider.ALL_CULTURES, SiteContext.CurrentSiteName); if (treeNode != null) { // Return all culture version of node DataSet ds = tree.SelectNodes(SiteContext.CurrentSiteName, null, TreeProvider.ALL_CULTURES, false, treeNode.NodeClassName, "NodeGUID ='" + group.GroupNodeGUID + "'", String.Empty, -1, false); if (!DataHelper.DataSourceIsEmpty(ds)) { // Loop through all nodes foreach (DataRow dr in ds.Tables[0].Rows) { // Create node and set tree provider for user validation TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["className"], String.Empty), dr); node.TreeProvider = tree; // Update stylesheet id if set if (selectedSheetID == 0) { node.DocumentStylesheetID = 0; node.DocumentInheritsStylesheet = true; } else { node.DocumentStylesheetID = selectedSheetID; } node.Update(); } } } } } } if (!IsLiveSite && (group.GroupNodeGUID != Guid.Empty)) { plcStyleSheetSelector.Visible = true; } if (plcOnline.Visible) { // On-line marketing setting is visible => set flag according to checkbox group.GroupLogActivity = chkLogActivity.Checked; } else { // On-line marketing setting is not visible => set flag to TRUE as default value group.GroupLogActivity = true; } // Save Group in the database GroupInfoProvider.SetGroupInfo(group); groupPictureEdit.GroupInfo = group; txtDisplayName.Text = group.GroupDisplayName; txtCodeName.Text = group.GroupName; // Flush cached information DocumentContext.CurrentDocument = null; DocumentContext.CurrentPageInfo = null; DocumentContext.CurrentDocumentStylesheet = null; // Display information on success ShowChangesSaved(); // If new group was created if (newGroup) { GroupID = group.GroupID; RaiseOnSaved(); } } } catch (Exception ex) { // Display error message ShowError(GetString("general.saveerror"), ex.Message, null); } } else { // Display error message ShowError(errorMessage); } }
private void btnOk_Click(object sender, EventArgs e) { // Validate all required data for new blog string errorMessage = ValidateData(); if (!LicenseHelper.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Blogs, VersionActionEnum.Insert)) { errorMessage = GetString("cmsdesk.bloglicenselimits"); } // Get current user CurrentUserInfo user = CMSContext.CurrentUser; if (errorMessage == "") { // Get parent node for new blog TreeProvider tree = new TreeProvider(user); TreeNode parent = tree.SelectSingleNode(CMSContext.CurrentSiteName, BlogParentPath.TrimEnd('%'), TreeProvider.ALL_CULTURES); if (parent != null) { if (!CheckPermissions || user.IsAuthorizedToCreateNewDocument(parent, "cms.blog")) { bool useParentNodeGroupID = tree.UseParentNodeGroupID; TreeNode blogNode = null; try { // Reflect group document tree.UseParentNodeGroupID = true; // Initialize and create new blog node blogNode = TreeNode.New("cms.blog", tree); blogNode.SetValue("BlogName", txtName.Text.Trim()); blogNode.SetValue("BlogDescription", txtDescription.Text.Trim()); blogNode.SetValue("BlogAllowAnonymousComments", BlogAllowAnonymousComments); blogNode.SetValue("BlogModerateComments", BlogModerateComments); blogNode.SetValue("BlogOpenCommentsFor", BlogOpenCommentsFor); blogNode.SetValue("BlogSendCommentsToEmail", BlogSendCommentsToEmail); blogNode.SetValue("BlogSideColumnText", BlogSideColumnText); blogNode.SetValue("BlogUseCAPTCHAForComments", BlogUseCAPTCHAForComments); blogNode.SetValue("BlogModerators", BlogModerators); if (BlogTeaser == Guid.Empty) { blogNode.SetValue("BlogTeaser", null); } else { blogNode.SetValue("BlogTeaser", BlogTeaser); } blogNode.SetValue("NodeOwner", user.UserID); if (NewBlogTemplate != null) { // Get the BlogMonth class to set the default page template if (NewBlogTemplate == "") { DataClassInfo blogClass = DataClassInfoProvider.GetDataClass("CMS.Blog"); if (blogClass != null) { blogNode.SetDefaultPageTemplateID(blogClass.ClassDefaultPageTemplateID); } } else { // Set the selected template PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(NewBlogTemplate); if (pti != null) { blogNode.NodeTemplateForAllCultures = true; blogNode.NodeTemplateID = pti.PageTemplateId; } } } // Trackbacks are denied by default blogNode.SetValue("BlogEnableTrackbacks", false); blogNode.DocumentName = txtName.Text.Trim(); blogNode.DocumentCulture = CMSContext.CurrentUser.PreferredCultureCode; DocumentHelper.InsertDocument(blogNode, parent, tree); } finally { tree.UseParentNodeGroupID = useParentNodeGroupID; } if (RedirectToNewBlog) { // Redirect to the new blog URLHelper.Redirect(CMSContext.GetUrl(blogNode.NodeAliasPath)); } else { // Display info message lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } } else { // Not authorized to create blog errorMessage = GetString("blogs.notallowedtocreate"); } } else { // Parent node was not found errorMessage = GetString("Blogs.NewBlog.PathNotFound"); } } if (errorMessage != "") { // Display error message lblError.Visible = true; lblError.Text = errorMessage; } }
private void btnOk_Click(object sender, EventArgs e) { // Validate all required data for new blog string errorMessage = ValidateData(); if (!LicenseHelper.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Blogs, ObjectActionEnum.Insert)) { errorMessage = GetString("cmsdesk.bloglicenselimits"); } // Get current user var user = MembershipContext.AuthenticatedUser; if (errorMessage == "") { // Get parent node for new blog TreeProvider tree = new TreeProvider(user); TreeNode parent = tree.SelectSingleNode(SiteContext.CurrentSiteName, BlogParentPath.TrimEnd('%'), TreeProvider.ALL_CULTURES); if (parent != null) { DataClassInfo blogClass = DataClassInfoProvider.GetDataClassInfo("CMS.Blog"); if (blogClass == null) { return; } // Check if blog is allowed in selected location if (!DocumentHelper.IsDocumentTypeAllowed(parent, blogClass.ClassID)) { lblError.Visible = true; lblError.Text = GetString("Content.ChildClassNotAllowed"); return; } if (!CheckPermissions || user.IsAuthorizedToCreateNewDocument(parent, "cms.blog")) { // Check if blog description allows empty value FormInfo formInfo = new FormInfo(blogClass.ClassFormDefinition); FormFieldInfo fieldInfo = formInfo.GetFormField("BlogDescription"); if ((fieldInfo != null) && !fieldInfo.AllowEmpty && String.IsNullOrWhiteSpace(txtDescription.Text)) { lblError.Visible = true; lblError.Text = GetString("blogs.newblog.descriptionempty"); return; } bool useParentNodeGroupID = tree.UseParentNodeGroupID; TreeNode blogNode; try { // Reflect group document tree.UseParentNodeGroupID = true; // Initialize and create new blog node blogNode = TreeNode.New("cms.blog", tree); blogNode.SetValue("BlogName", txtName.Text.Trim()); blogNode.SetValue("BlogDescription", txtDescription.Text.Trim()); blogNode.SetValue("BlogAllowAnonymousComments", BlogAllowAnonymousComments); blogNode.SetValue("BlogModerateComments", BlogModerateComments); blogNode.SetValue("BlogOpenCommentsFor", BlogOpenCommentsFor); blogNode.SetValue("BlogSendCommentsToEmail", BlogSendCommentsToEmail); blogNode.SetValue("BlogSideColumnText", BlogSideColumnText); blogNode.SetValue("BlogUseCAPTCHAForComments", BlogUseCAPTCHAForComments); blogNode.SetValue("BlogModerators", BlogModerators); if (BlogTeaser == Guid.Empty) { blogNode.SetValue("BlogTeaser", null); } else { blogNode.SetValue("BlogTeaser", BlogTeaser); } blogNode.SetValue("NodeOwner", user.UserID); if (NewBlogTemplate != null) { // Set the default page template if (NewBlogTemplate == "") { blogNode.SetDefaultPageTemplateID(blogClass.ClassDefaultPageTemplateID); } else { // Set the selected template PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(NewBlogTemplate); if (pti != null) { blogNode.NodeTemplateForAllCultures = true; blogNode.NodeTemplateID = pti.PageTemplateId; } } } blogNode.DocumentName = txtName.Text.Trim(); blogNode.DocumentCulture = LocalizationContext.PreferredCultureCode; DocumentHelper.InsertDocument(blogNode, parent, tree); } finally { tree.UseParentNodeGroupID = useParentNodeGroupID; } if (RedirectToNewBlog) { // Redirect to the new blog URLHelper.Redirect(DocumentURLProvider.GetUrl(blogNode)); } else { // Display info message lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } } else { // Not authorized to create blog errorMessage = GetString("blogs.notallowedtocreate"); } } else { // Parent node was not found errorMessage = GetString("Blogs.NewBlog.PathNotFound"); } } if (errorMessage == "") { return; } // Display error message lblError.Visible = true; lblError.Text = errorMessage; }
protected void btnCreateDocument_Click(object sender, EventArgs e) { if (radCopy.Checked) { string sourceCulture = copyCulturesElem.Value.ToString(); TreeNode actualSourceNode = DocumentHelper.GetDocument(NodeID, sourceCulture, Tree); TreeNode sourceNode = actualSourceNode.IsLink ? DocumentHelper.GetDocument(Tree.GetOriginalNode(actualSourceNode), Tree) : actualSourceNode; if (sourceNode != null) { if (chkSaveBeforeEditing.Checked && (node != null)) { // Create the version first TreeNode newCulture = TreeNode.New(node.ClassName); DocumentHelper.CopyNodeData(sourceNode, newCulture, new CopyNodeDataSettings(true, null)); NewCultureDocumentSettings settings = new NewCultureDocumentSettings { Node = newCulture, CultureCode = RequiredCulture, CopyAttachments = true, CopyCategories = true }; DocumentHelper.InsertNewCultureVersion(settings); // Refresh page if (RequiresDialog) { string url = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(newCulture.NodeAliasPath) + "?" + URLHelper.LanguageParameterName + "=" + RequiredCulture); ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript(" wopener.location = " + ScriptHelper.GetString(url) + "; CloseDialog();")); } else { ViewModeEnum mode = ViewModeEnum.Edit; if (!TreePathUtils.IsMenuItemType(node.NodeClassName) && (CMSContext.ViewMode != ViewModeEnum.EditLive)) { mode = ViewModeEnum.EditForm; } ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript("if (FramesRefresh) { FramesRefresh(" + node.NodeID + ", '" + mode + "'); }")); } } else { var url = GetEditUrl(node); url = URLHelper.AddParameterToUrl(url, "sourcedocumentid", sourceNode.DocumentID.ToString()); // Provide information about actual node if ((actualSourceNode != null) && actualSourceNode.IsLink) { url = URLHelper.AddParameterToUrl(url, "sourcenodeid", actualSourceNode.NodeID.ToString()); } Response.Redirect(url); } } else { ShowError(GetString("transman.notallowedcreate")); } } else { var url = GetEditUrl(node); Response.Redirect(url); } }