/// <summary> /// Moves a document up in the content tree. Called when the "Move document up" button is pressed. /// Expects the "CreateDocumentStructure" method to be run first. /// </summary> private bool MoveDocumentUp() { // Create an instance of the Tree provider TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); // Select a node TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example/Document-2", "en-us"); if (node != null) { // Move the node up tree.MoveNodeUp(node.NodeID); return(true); } return(false); }
/// <summary> /// Moves a document up in the content tree. Called when the "Move document up" button is pressed. /// Expects the "CreateDocumentStructure" method to be run first. /// </summary> private bool MoveDocumentUp() { // Create an instance of the Tree provider TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); // Select a node TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example/Document-2", "en-us"); if (node != null) { // Move the node up tree.MoveNodeUp(node.NodeID); return true; } return false; }
public void RaisePostBackEvent(string eventArgument) { CurrentUserInfo currentUser = CMSContext.CurrentUser; // Current Node ID int nodeId = ValidationHelper.GetInteger(Param1, 0); TreeProvider tree = new TreeProvider(currentUser); EventLogProvider log = new EventLogProvider(); string documentName = string.Empty; string action = Action.ToLower(); string siteName = CMSContext.CurrentSiteName; // Process the request switch (action) { case "refresh": treeContent.NodeID = nodeId; AddScript("currentNodeId = " + nodeId + ";\n"); break; case "moveup": case "movedown": case "movetop": case "movebottom": // Move the document up (document order) try { if (nodeId == 0) { AddAlert(GetString("ContentRequest.ErrorMissingSource")); return; } // Get document to move TreeNode node = tree.SelectSingleNode(nodeId); // Check the permissions for document if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { switch (action) { case "moveup": node = tree.MoveNodeUp(nodeId); break; case "movedown": node = tree.MoveNodeDown(nodeId); break; case "movetop": node = tree.SelectSingleNode(nodeId); tree.SetNodeOrder(nodeId, DocumentOrderEnum.First); break; case "movebottom": node = tree.SelectSingleNode(nodeId); tree.SetNodeOrder(nodeId, DocumentOrderEnum.Last); break; } if (node != null) { // Log the synchronization tasks for the entire tree level if (SettingsKeyProvider.GetBoolValue(siteName + ".CMSStagingLogChanges")) { // Log the synchronization tasks for the entire tree level DocumentSynchronizationHelper.LogDocumentChangeOrder(siteName, node.NodeAliasPath, tree); } // Select the document in the tree documentName = node.DocumentName; treeContent.ExpandNodeID = node.NodeParentID; treeContent.NodeID = node.NodeID; AddScript("currentNodeId = " + node.NodeID + ";\n"); } else { AddAlert(GetString("ContentRequest.MoveFailed")); } } else { // Select the document in the tree treeContent.NodeID = nodeId; AddAlert(GetString("ContentRequest.MoveDenied")); } } catch (Exception ex) { log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "MOVE", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.GetUserHostAddress(), EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri()); AddAlert(GetString("ContentRequest.MoveFailed") + " : " + ex.Message); } break; case "setculture": // Set the preferred culture code try { // Set the culture code string language = ValidationHelper.GetString(Param2, ""); if (!string.IsNullOrEmpty(language)) { CMSContext.PreferredCultureCode = language; } // Refresh the document if (nodeId > 0) { treeContent.NodeID = nodeId; AddScript("SelectNode(" + nodeId + "); \n"); } } catch (Exception ex) { log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "SETCULTURE", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.GetUserHostAddress(), EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri()); AddAlert(GetString("ContentRequest.ErrorChangeLanguage")); } break; // Sorting case "sortalphaasc": case "sortalphadesc": case "sortdateasc": case "sortdatedesc": // Set the preferred culture code try { // Get document to sort TreeNode node = tree.SelectSingleNode(nodeId); // Check the permissions for document if ((currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) && (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.ExploreTree) == AuthorizationResultEnum.Allowed)) { switch (action) { case "sortalphaasc": tree.OrderNodesAlphabetically(nodeId, true); break; case "sortalphadesc": tree.OrderNodesAlphabetically(nodeId, false); break; case "sortdateasc": tree.OrderNodesByDate(nodeId, true); break; case "sortdatedesc": tree.OrderNodesByDate(nodeId, false); break; } // Log the synchronization tasks for the entire tree level if (SettingsKeyProvider.GetBoolValue(siteName + ".CMSStagingLogChanges")) { // Log the synchronization tasks for the entire tree level string fakeAlias = node.NodeAliasPath.TrimEnd('/') + "/child"; DocumentSynchronizationHelper.LogDocumentChangeOrder(siteName, fakeAlias, tree); } } else { AddAlert(GetString("ContentRequest.SortDenied")); } // Refresh the tree if (nodeId > 0) { treeContent.ExpandNodeID = nodeId; treeContent.NodeID = nodeId; AddScript("SelectNode(" + nodeId + "); \n"); } } catch (Exception ex) { log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "SORT", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.GetUserHostAddress(), EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri()); AddAlert(GetString("ContentRequest.ErrorSort")); } break; } // Maintain scrollbar position string script = @"var elm = jQuery('#handle_" + nodeId + @"'); var pnl = jQuery('#" + pnlTreeArea.ClientID + @"'); var origScroll = " + ScrollPosition + @"; var elmOff = elm.offset(); var elmPos = (elmOff == null) ? 0 : elmOff.top; var scroll = ((elmPos < origScroll) || (elmPos > (origScroll + pnl.height()))); pnl.scrollTop(origScroll); if(scroll){pnl.animate({ scrollTop: elmPos - 20 }, 300);};"; ScriptHelper.RegisterStartupScript(Page, typeof(string), "MaintainScrollbar", script, true); }
public void RaisePostBackEvent(string eventArgument) { if (eventArgument == "move") { // Keep current user object CurrentUserInfo cu = CMSContext.CurrentUser; // Parse input value string[] values = hdnMoveId.Value.Split(';'); // Create tree provider TreeProvider tree = new TreeProvider(cu); // Get tree node object int nodeId = ValidationHelper.GetInteger(values[1], 0); TreeNode node = tree.SelectSingleNode(nodeId); // Check whether node exists if (node == null) { ShowError(GetString("ContentRequest.ErrorMissingSource")); return; } try { // Check permissions if (cu.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { // Switch by action switch (values[0]) { case "up": node = tree.MoveNodeUp(nodeId); break; case "down": node = tree.MoveNodeDown(nodeId); break; case "top": node = tree.SelectSingleNode(nodeId); tree.SetNodeOrder(nodeId, DocumentOrderEnum.First); break; case "bottom": node = tree.SelectSingleNode(nodeId); tree.SetNodeOrder(nodeId, DocumentOrderEnum.Last); break; } if (node != null) { if (!RequiresDialog) { ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshAfterMove", ScriptHelper.GetScript("parent.RefreshTree(" + node.NodeParentID + ", " + node.NodeParentID + ");")); } // Log the synchronization tasks for the entire tree level if (SettingsKeyProvider.GetBoolValue(node.NodeSiteName + ".CMSStagingLogChanges")) { // Log the synchronization tasks for the entire tree level DocumentSynchronizationHelper.LogDocumentChangeOrder(node.NodeSiteName, node.NodeAliasPath, tree); } } else { ShowError(GetString("ContentRequest.MoveFailed")); } } else { ShowError(GetString("ContentRequest.MoveDenied")); } } catch (Exception ex) { EventLogProvider log = new EventLogProvider(); log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "MOVE", cu.UserID, cu.UserName, nodeId, node.DocumentName, HTTPHelper.UserHostAddress, EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri()); ShowError(GetString("ContentRequest.MoveFailed") + " : " + ex.Message); } } else if (eventArgument == "refresh") { // Register the refresh script after the 'move' action is performed Hashtable parameters = WindowHelper.GetItem(Identifier) as Hashtable; if ((parameters != null) && (parameters.Count > 0)) { int refreshNodeId = ValidationHelper.GetInteger(parameters["refreshnodeid"], 0); string refreshScript = "parent.RefreshTree(" + refreshNodeId + ", " + refreshNodeId + ")"; ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshAfterMove", refreshScript, true); } else { // If node id not found refresh whole content tree ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshAllAfterMove", "parent.RefreshTree(" + NodeID + ", " + NodeID + ")", true); } } }
public void RaisePostBackEvent(string eventArgument) { CurrentUserInfo currentUser = CMSContext.CurrentUser; // Current Node ID int nodeId = ValidationHelper.GetInteger(Param1, 0); TreeProvider tree = new TreeProvider(currentUser); EventLogProvider log = new EventLogProvider(); string documentName = ""; string action = Action.ToLower(); // Process the request switch (action) { case "moveup": case "movedown": // Move the document up (document order) try { if (nodeId == 0) { AddAlert(GetString("ContentRequest.ErrorMissingSource")); return; } // Get document to move TreeNode node = tree.SelectSingleNode(nodeId); // Check the permissions for document if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { switch (action) { case "moveup": node = tree.MoveNodeUp(nodeId); break; case "movedown": node = tree.MoveNodeDown(nodeId); break; } string siteName = CMSContext.CurrentSiteName; if (SettingsKeyProvider.GetBoolValue(siteName + ".CMSStagingLogChanges")) { // Load all nodes under parent node if (node != null) { string parentPath = TreePathUtils.GetParentPath(node.NodeAliasPath); DataSet ds = tree.SelectNodes(siteName, parentPath.TrimEnd('/') + "/%", TreeProvider.ALL_CULTURES, true, null, null, null, 1); // Check if data source is not empty if (!DataHelper.DataSourceIsEmpty(ds)) { // Go through all nodes foreach (DataRow dr in ds.Tables[0].Rows) { // Update child nodes int logNodeId = ValidationHelper.GetInteger(dr["NodeID"], 0); string culture = ValidationHelper.GetString(dr["DocumentCulture"], ""); string className = ValidationHelper.GetString(dr["ClassName"], ""); TreeNode tn = tree.SelectSingleNode(logNodeId, culture, className); DocumentSynchronizationHelper.LogDocumentChange(tn, TaskTypeEnum.UpdateDocument, tree); } } } } // Move the node if (node != null) { documentName = node.DocumentName; treeContent.ExpandNodeID = node.NodeParentID; treeContent.NodeID = node.NodeID; } else { AddAlert(GetString("ContentRequest.MoveFailed")); } } else { AddAlert(GetString("ContentRequest.MoveDenied")); } } catch (Exception ex) { log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "MOVE", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.UserHostAddress, EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri()); AddAlert(GetString("ContentRequest.MoveFailed") + " : " + ex.Message); } break; case "delete": // Delete the document try { if (nodeId == 0) { AddAlert(GetString("DefineSiteStructure.ErrorMissingSource")); return; } // Get the node TreeNode node = tree.SelectSingleNode(nodeId); // Delete the node if (node != null) { treeContent.NodeID = node.NodeParentID; node.Delete(); // Delete search index for given node if (SearchIndexInfoProvider.SearchEnabled) { SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Delete, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID()); } if (node.NodeAliasPath == "/") { // Refresh root document treeContent.NodeID = node.NodeID; AddScript("SelectNode(" + node.NodeID + "); \n"); } else { AddScript("SelectNode(" + node.NodeParentID + "); \n"); } } } catch (Exception ex) { AddAlert(GetString("DefineSiteStructure.DeleteFailed") + " : " + ex.Message); } break; } }
public void RaisePostBackEvent(string eventArgument) { var currentUser = MembershipContext.AuthenticatedUser; // Current Node ID int nodeId = ValidationHelper.GetInteger(Param1, 0); TreeProvider tree = new TreeProvider(currentUser); string documentName = string.Empty; string action = Action.ToLowerCSafe(); string siteName = SiteContext.CurrentSiteName; // Process the request switch (action) { case "refresh": treeElem.SelectedNodeID = nodeId; AddScript("currentNodeId = " + nodeId + ";"); break; case "moveup": case "movedown": case "movetop": case "movebottom": // Move the document up (document order) try { if (nodeId == 0) { AddAlert(GetString("ContentRequest.ErrorMissingSource")); return; } // Get document to move TreeNode node = tree.SelectSingleNode(nodeId); // Check whether node exists if (node == null) { ShowError(GetString("ContentRequest.ErrorMissingSource")); return; } // Check the permissions for document if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { // Root of products tree can not be moved if (!IsProductTree || (node.NodeAliasPath.CompareToCSafe(StartingAliasPath, true) != 0)) { switch (action) { case "moveup": tree.MoveNodeUp(node); break; case "movedown": tree.MoveNodeDown(node); break; case "movetop": tree.SetNodeOrder(node, DocumentOrderEnum.First); break; case "movebottom": tree.SetNodeOrder(node, DocumentOrderEnum.Last); break; } // Log the synchronization tasks for the entire tree level DocumentSynchronizationHelper.LogDocumentChangeOrder(siteName, node.NodeAliasPath, tree); // Select the document in the tree documentName = node.GetDocumentName(); treeElem.ExpandNodeID = node.NodeParentID; treeElem.SelectedNodeID = node.NodeID; AddScript("currentNodeId = " + node.NodeID + ";"); } } else { // Select the document in the tree treeElem.SelectedNodeID = nodeId; AddAlert(GetString("ContentRequest.MoveDenied")); } } catch (Exception ex) { EventLogProvider.LogEvent(EventType.ERROR, "Content", "MOVE", EventLogProvider.GetExceptionLogMessage(ex), RequestContext.RawURL, currentUser.UserID, currentUser.UserName, nodeId, documentName, RequestContext.UserHostAddress, SiteContext.CurrentSite.SiteID); AddAlert(GetString("ContentRequest.MoveFailed") + " : " + ex.Message); } break; case "setculture": // Set the preferred culture code try { // Set the culture code string language = ValidationHelper.GetString(Param2, string.Empty); if (!string.IsNullOrEmpty(language)) { LocalizationContext.PreferredCultureCode = language; treeElem.Culture = language; } // Refresh the document if (nodeId > 0) { treeElem.SelectedNodeID = nodeId; AddScript("SelectNode(" + nodeId + ");"); } } catch (Exception ex) { EventLogProvider.LogEvent(EventType.ERROR, "Content", "SETCULTURE", EventLogProvider.GetExceptionLogMessage(ex), RequestContext.RawURL, currentUser.UserID, currentUser.UserName, nodeId, documentName, RequestContext.UserHostAddress, SiteContext.CurrentSite.SiteID); AddAlert(GetString("ContentRequest.ErrorChangeLanguage")); } break; case "setdevice": // Set the device profile try { // Set the device name string deviceName = ValidationHelper.GetString(Param2, string.Empty); DeviceContext.CurrentDeviceProfileName = deviceName; // Refresh the document if (nodeId > 0) { treeElem.SelectedNodeID = nodeId; AddScript("SelectNode(" + nodeId + ");"); } } catch (Exception ex) { EventLogProvider.LogEvent(EventType.ERROR, "Content", "SETDEVICE", EventLogProvider.GetExceptionLogMessage(ex), RequestContext.RawURL, currentUser.UserID, currentUser.UserName, nodeId, documentName, RequestContext.UserHostAddress, SiteContext.CurrentSite.SiteID); AddAlert(GetString("ContentRequest.ErrorChangeLanguage")); } break; // Sorting case "sortalphaasc": case "sortalphadesc": case "sortdateasc": case "sortdatedesc": int siteId = SiteContext.CurrentSite.SiteID; try { // Get document to sort TreeNode node = tree.SelectSingleNode(nodeId); // Check the permissions for document if ((node != null) && (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) && (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.ExploreTree) == AuthorizationResultEnum.Allowed)) { siteId = node.NodeSiteID; switch (action) { case "sortalphaasc": tree.SortNodesAlphabetically(nodeId, siteId, true); break; case "sortalphadesc": tree.SortNodesAlphabetically(nodeId, siteId, false); break; case "sortdateasc": tree.SortNodesByDate(nodeId, siteId, true); break; case "sortdatedesc": tree.SortNodesByDate(nodeId, siteId, false); break; } // Log the synchronization tasks for the entire tree level string fakeAlias = node.NodeAliasPath.TrimEnd('/') + "/child"; DocumentSynchronizationHelper.LogDocumentChangeOrder(siteName, fakeAlias, tree); } else { AddAlert(GetString("ContentRequest.SortDenied")); } // Refresh the tree if (nodeId > 0) { treeElem.ExpandNodeID = nodeId; treeElem.SelectedNodeID = nodeId; if (IsProductTree) { AddScript("window.frames['contentview'].location.replace(window.frames['contentview'].location);"); } else { AddScript("SelectNode(" + nodeId + ");"); } } } catch (Exception ex) { EventLogProvider.LogEvent(EventType.ERROR, "Content", "SORT", EventLogProvider.GetExceptionLogMessage(ex), RequestContext.RawURL, currentUser.UserID, currentUser.UserName, nodeId, documentName, RequestContext.UserHostAddress, siteId); AddAlert(GetString("ContentRequest.ErrorSort")); } break; } // Maintain scrollbar position string script = @" SetSelectedNodeId(currentNodeId); MaintainScroll('" + nodeId + @"','" + pnlTreeArea.ClientID + @"', " + ScrollPosition + @"); HideAllContextMenus(); "; ScriptHelper.RegisterStartupScript(Page, typeof(string), "MaintainScrollbar", script, true); }
public void RaisePostBackEvent(string eventArgument) { if (eventArgument == "move") { // Keep current user object var cu = MembershipContext.AuthenticatedUser; // Parse input value string[] values = hdnMoveId.Value.Split(';'); // Create tree provider TreeProvider tree = new TreeProvider(cu); // Get tree node object int nodeId = ValidationHelper.GetInteger(values[1], 0); TreeNode node = tree.SelectSingleNode(nodeId); // Check whether node exists if (node == null) { ShowError(GetString("ContentRequest.ErrorMissingSource")); return; } try { // Check permissions if (cu.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { // Switch by action switch (values[0]) { case "up": tree.MoveNodeUp(node); break; case "down": tree.MoveNodeDown(node); break; case "top": tree.SetNodeOrder(node, DocumentOrderEnum.First); break; case "bottom": tree.SetNodeOrder(node, DocumentOrderEnum.Last); break; } if (!RequiresDialog) { ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshAfterMove", ScriptHelper.GetScript("parent.RefreshTree(" + node.NodeParentID + ", " + node.NodeParentID + ");")); } // Log the synchronization tasks for the entire tree level DocumentSynchronizationHelper.LogDocumentChangeOrder(node.NodeSiteName, node.NodeAliasPath, tree); } else { ShowError(GetString("ContentRequest.MoveDenied")); } } catch (Exception ex) { var logData = new EventLogData(EventTypeEnum.Error, "Content", "MOVE") { EventDescription = EventLogProvider.GetExceptionLogMessage(ex), EventUrl = RequestContext.RawURL, UserID = cu.UserID, UserName = cu.UserName, NodeID = nodeId, DocumentName = node.DocumentName, IPAddress = RequestContext.UserHostAddress, SiteID = SiteContext.CurrentSite.SiteID }; Service.Resolve <IEventLogService>().LogEvent(logData); ShowError(GetString("ContentRequest.MoveFailed") + " : " + ex.Message); } } else if (eventArgument == "refresh") { // Register the refresh script after the 'move' action is performed Hashtable parameters = WindowHelper.GetItem(Identifier) as Hashtable; if ((parameters == null) || (parameters.Count <= 0)) { return; } int refreshNodeId = ValidationHelper.GetInteger(parameters["refreshnodeid"], 0); string refreshScript = "parent.RefreshTree(" + refreshNodeId + ", " + refreshNodeId + ")"; ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshAfterMove", refreshScript, true); } }
public void RaisePostBackEvent(string eventArgument) { CurrentUserInfo currentUser = CMSContext.CurrentUser; // Current Node ID int nodeId = ValidationHelper.GetInteger(Param1, 0); TreeProvider tree = new TreeProvider(currentUser); EventLogProvider log = new EventLogProvider(); string documentName = ""; string action = Action.ToLower(); // Process the request switch (action) { case "moveup": case "movedown": // Move the document up (document order) try { if (nodeId == 0) { AddAlert(GetString("ContentRequest.ErrorMissingSource")); return; } // Get document to move TreeNode node = tree.SelectSingleNode(nodeId); // Check the permissions for document if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { switch (action) { case "moveup": node = tree.MoveNodeUp(nodeId); break; case "movedown": node = tree.MoveNodeDown(nodeId); break; } string siteName = CMSContext.CurrentSiteName; if (SettingsKeyProvider.GetBoolValue(siteName + ".CMSStagingLogChanges")) { // Load all nodes under parent node if (node != null) { string parentPath = TreePathUtils.GetParentPath(node.NodeAliasPath); DataSet ds = tree.SelectNodes(siteName, parentPath.TrimEnd('/') + "/%", TreeProvider.ALL_CULTURES, true, null, null, null, 1); // Check if data source is not empty if (!DataHelper.DataSourceIsEmpty(ds)) { // Go through all nodes foreach (DataRow dr in ds.Tables[0].Rows) { // Update child nodes int logNodeId = ValidationHelper.GetInteger(dr["NodeID"], 0); string culture = ValidationHelper.GetString(dr["DocumentCulture"], ""); string className = ValidationHelper.GetString(dr["ClassName"], ""); TreeNode tn = tree.SelectSingleNode(logNodeId, culture, className); DocumentSynchronizationHelper.LogDocumentChange(tn, TaskTypeEnum.UpdateDocument, tree); } } } } // Move the node if (node != null) { documentName = node.DocumentName; treeContent.ExpandNodeID = node.NodeParentID; treeContent.NodeID = node.NodeID; } else { AddAlert(GetString("ContentRequest.MoveFailed")); } } else { AddAlert(GetString("ContentRequest.MoveDenied")); } } catch (Exception ex) { log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "MOVE", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.GetUserHostAddress(), EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri()); AddAlert(GetString("ContentRequest.MoveFailed") + " : " + ex.Message); } break; case "delete": // Delete the document try { if (nodeId == 0) { AddAlert(GetString("DefineSiteStructure.ErrorMissingSource")); return; } // Get the node TreeNode node = tree.SelectSingleNode(nodeId); // Delete the node if (node != null) { treeContent.NodeID = node.NodeParentID; node.Delete(); // Delete search index for given node if (SearchIndexInfoProvider.SearchEnabled) { SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Delete, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID()); } if (node.NodeAliasPath == "/") { // Refresh root document treeContent.NodeID = node.NodeID; AddScript("SelectNode(" + node.NodeID + "); \n"); } else { AddScript("SelectNode(" + node.NodeParentID + "); \n"); } } } catch (Exception ex) { AddAlert(GetString("DefineSiteStructure.DeleteFailed") + " : " + ex.Message); } break; } }
public void RaisePostBackEvent(string eventArgument) { CurrentUserInfo currentUser = CMSContext.CurrentUser; // Current Node ID int nodeId = ValidationHelper.GetInteger(Param1, 0); TreeProvider tree = new TreeProvider(currentUser); EventLogProvider log = new EventLogProvider(); string documentName = string.Empty; string action = Action.ToLower(); string siteName = CMSContext.CurrentSiteName; // Process the request switch (action) { case "refresh": treeContent.NodeID = nodeId; AddScript("currentNodeId = " + nodeId + ";\n"); break; case "moveup": case "movedown": case "movetop": case "movebottom": // Move the document up (document order) try { if (nodeId == 0) { AddAlert(GetString("ContentRequest.ErrorMissingSource")); return; } // Get document to move TreeNode node = tree.SelectSingleNode(nodeId); // Check the permissions for document if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { switch (action) { case "moveup": node = tree.MoveNodeUp(nodeId); break; case "movedown": node = tree.MoveNodeDown(nodeId); break; case "movetop": node = tree.SelectSingleNode(nodeId); tree.SetNodeOrder(nodeId, DocumentOrderEnum.First); break; case "movebottom": node = tree.SelectSingleNode(nodeId); tree.SetNodeOrder(nodeId, DocumentOrderEnum.Last); break; } if (node != null) { // Log the synchronization tasks for the entire tree level if (SettingsKeyProvider.GetBoolValue(siteName + ".CMSStagingLogChanges")) { // Log the synchronization tasks for the entire tree level DocumentSynchronizationHelper.LogDocumentChangeOrder(siteName, node.NodeAliasPath, tree); } // Select the document in the tree documentName = node.DocumentName; treeContent.ExpandNodeID = node.NodeParentID; treeContent.NodeID = node.NodeID; AddScript("currentNodeId = " + node.NodeID + ";\n"); } else { AddAlert(GetString("ContentRequest.MoveFailed")); } } else { // Select the document in the tree treeContent.NodeID = nodeId; AddAlert(GetString("ContentRequest.MoveDenied")); } } catch (Exception ex) { log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "MOVE", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.UserHostAddress, EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri()); AddAlert(GetString("ContentRequest.MoveFailed") + " : " + ex.Message); } break; case "setculture": // Set the preferred culture code try { // Set the culture code string language = ValidationHelper.GetString(Param2, ""); if (!string.IsNullOrEmpty(language)) { CMSContext.PreferredCultureCode = language; } // Refresh the document if (nodeId > 0) { treeContent.NodeID = nodeId; AddScript("SelectNode(" + nodeId + "); \n"); } } catch (Exception ex) { log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "SETCULTURE", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.UserHostAddress, EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri()); AddAlert(GetString("ContentRequest.ErrorChangeLanguage")); } break; // Sorting case "sortalphaasc": case "sortalphadesc": case "sortdateasc": case "sortdatedesc": // Set the preferred culture code try { // Get document to sort TreeNode node = tree.SelectSingleNode(nodeId); // Check the permissions for document if ((currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) && (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.ExploreTree) == AuthorizationResultEnum.Allowed)) { switch (action) { case "sortalphaasc": tree.OrderNodesAlphabetically(nodeId, true); break; case "sortalphadesc": tree.OrderNodesAlphabetically(nodeId, false); break; case "sortdateasc": tree.OrderNodesByDate(nodeId, true); break; case "sortdatedesc": tree.OrderNodesByDate(nodeId, false); break; } // Log the synchronization tasks for the entire tree level if (SettingsKeyProvider.GetBoolValue(siteName + ".CMSStagingLogChanges")) { // Log the synchronization tasks for the entire tree level string fakeAlias = node.NodeAliasPath.TrimEnd('/') + "/child"; DocumentSynchronizationHelper.LogDocumentChangeOrder(siteName, fakeAlias, tree); } } else { AddAlert(GetString("ContentRequest.SortDenied")); } // Refresh the tree if (nodeId > 0) { treeContent.ExpandNodeID = nodeId; treeContent.NodeID = nodeId; AddScript("SelectNode(" + nodeId + "); \n"); } } catch (Exception ex) { log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "SORT", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.UserHostAddress, EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri()); AddAlert(GetString("ContentRequest.ErrorSort")); } break; } // Maintain scrollbar position string script = @"var elm = jQuery('#handle_" + nodeId + @"'); var pnl = jQuery('#" + pnlTreeArea.ClientID + @"'); var origScroll = " + ScrollPosition + @"; var elmOff = elm.offset(); var elmPos = (elmOff == null) ? 0 : elmOff.top; var scroll = ((elmPos < origScroll) || (elmPos > (origScroll + pnl.height()))); pnl.scrollTop(origScroll); if(scroll){pnl.animate({ scrollTop: elmPos - 20 }, 300);};"; ScriptHelper.RegisterStartupScript(Page, typeof(string), "MaintainScrollbar", script, true); }