protected void Page_Load(object sender, EventArgs e) { // Current Node ID int nodeId = 0; if (Request.QueryString["nodeid"] != null) { nodeId = ValidationHelper.GetInteger(Request.QueryString["nodeid"], 0); } switch (QueryHelper.GetString("action", "edit").ToLower()) { case "delete": // Do not include title upon delete this.titleElem.SetWindowTitle = false; break; } // Get the node string aliasPath = TreePathUtils.GetAliasPathByNodeId(nodeId); if (aliasPath == "/") { // Set path as site name if empty SiteInfo si = CMSContext.CurrentSite; if (si != null) { this.titleElem.CreateStaticBreadCrumbs(HttpUtility.HtmlEncode(si.DisplayName)); } } else { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); // Get the DataSet of nodes string where = TreeProvider.GetNodesOnPathWhereCondition(aliasPath, true, true); DataSet ds = DocumentHelper.GetDocuments(CMSContext.CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "NodeLevel ASC", -1, false, tree); if (!DataHelper.DataSourceIsEmpty(ds)) { string[,] bc = new string[ds.Tables[0].Rows.Count, 3]; int index = 0; // Build the path foreach (DataRow dr in ds.Tables[0].Rows) { string documentName = ValidationHelper.GetString(dr["DocumentName"], ""); bc[index, 0] = documentName; bc[index, 1] = string.Empty; bc[index, 2] = string.Empty; index++; } this.titleElem.Breadcrumbs = bc; } } }
/// <summary> /// Checks whether node with given node ID is contained in a products tree, /// considering the ProductsStartingPath setting. /// </summary> /// <param name="nodeId">NodeID of a node to be checked on.</param> private bool IsAllowedInProductsStartingPath(int nodeId) { var nodePath = TreePathUtils.GetAliasPathByNodeId(nodeId); var nodeSite = TreePathUtils.GetNodeSite(nodeId); if (String.IsNullOrEmpty(nodePath)) { return(false); } if (!String.IsNullOrEmpty(ProductsStartingPath)) { if ((TreePathUtils.GetNodeIdByAliasPath(nodeSite.SiteName, ProductsStartingPath) > 0) && !nodePath.StartsWithCSafe(ProductsStartingPath, true)) { // Products starting path is defined and node on that path exists, // but our node is not contained within that path return(false); } } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!QueryHelper.ValidateHash("hash")) { return; } // Initialize events ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished; ctlAsyncLog.OnError += ctlAsyncLog_OnError; ctlAsyncLog.OnCancel += ctlAsyncLog_OnCancel; // Check if hashtable containing dialog parameters is not empty if ((Parameters == null) || (Parameters.Count == 0)) { return; } // Register CopyMove.js script file ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Content/Controls/Dialogs/Properties/CopyMove.js"); IsDialogAction = true; // Setup tree provider TreeProvider.AllowAsyncActions = false; if (!RequestHelper.IsCallback()) { ClassID = ValidationHelper.GetInteger(Parameters["classid"], 0); // Get whether action is multiple multiple = ValidationHelper.GetBoolean(Parameters["multiple"], false); // Get the source node string nodeIdsString = ValidationHelper.GetString(Parameters["sourcenodeids"], string.Empty); ParseIds(nodeIdsString, nodeIds); // Get target node id targetId = ValidationHelper.GetInteger(Parameters["targetid"], 0); using (TreeNode tn = TreeProvider.SelectSingleNode(targetId)) { if ((tn != null) && (tn.NodeSiteID != CurrentSite.SiteID)) { SiteInfo si = SiteInfo.Provider.Get(tn.NodeSiteID); if (si != null) { targetSite = si; } } else { targetSite = CurrentSite; } } // Set if operation take place on same site sameSite = (CurrentSite == targetSite); // Set introducing text if (targetId == 0) { switch (CurrentAction) { case Action.Move: case Action.Copy: case Action.Link: lblEmpty.Text = GetString("dialogs.copymove.select"); break; case Action.LinkDoc: lblEmpty.Text = GetString("dialogs.linkdoc.select"); break; } } // Check if target of action is another site if (!sameSite) { plcCopyPermissions.Visible = false; plcPreservePermissions.Visible = false; } if (!RequestHelper.IsPostBack()) { object check; // Preset checkbox value switch (CurrentAction) { case Action.Copy: // Ensure underlying items checkbox check = WindowHelper.GetItem(Action.Copy + underlying); if (check == null) { WindowHelper.Add(Action.Copy + underlying, true); } chkUnderlying.Checked = ValidationHelper.GetBoolean(check, true); if (sameSite) { chkCopyPermissions.Checked = CopyPermissions; } break; case Action.Link: case Action.LinkDoc: if (sameSite) { chkCopyPermissions.Checked = CopyPermissions; } break; case Action.Move: if (sameSite) { chkPreservePermissions.Checked = CopyPermissions; } break; } } string listInfoString = string.Empty; // Set up layout and strings depending on selected action switch (CurrentAction) { case Action.Move: listInfoString = "dialogs.move.listinfo"; canceledString = "ContentRequest.MoveCanceled"; plcUnderlying.Visible = false; plcCopyPermissions.Visible = false; break; case Action.Copy: listInfoString = "dialogs.copy.listinfo"; canceledString = "ContentRequest.CopyingCanceled"; lblUnderlying.ResourceString = "contentrequest.copyunderlying"; plcUnderlying.Visible = true; plcPreservePermissions.Visible = false; break; case Action.Link: case Action.LinkDoc: listInfoString = "dialogs.link.listinfo"; canceledString = "ContentRequest.LinkCanceled"; plcUnderlying.Visible = false; plcPreservePermissions.Visible = false; break; } // Localize string canceledString = GetString(canceledString); // Get alias path of document selected in tree string selectedAliasPath = TreePathUtils.GetAliasPathByNodeId(targetId); // Set target alias path if ((CurrentAction == Action.Copy) || (CurrentAction == Action.Move) || (CurrentAction == Action.Link)) { lblAliasPath.Text = selectedAliasPath; // Get source node if (nodeIds.Count == 1) { TreeNode sourceNode = null; int nodeId = ValidationHelper.GetInteger(nodeIds[0], 0); sourceNode = TreeProvider.SelectSingleNode(nodeId); // Hide checkbox if document has no children if ((sourceNode != null) && !sourceNode.NodeHasChildren) { plcUnderlying.Visible = false; } } } if (CurrentAction == Action.LinkDoc) { targetIds.AddRange(MultipleSelectionDialogHelper.GetSelectedPageIds()); string aliasPaths = SessionHelper.GetValue("CopyMoveDocAliasPaths").ToString(); lblDocToCopyList.Text = aliasPaths; } // Set visibility of panels pnlGeneralTab.Visible = true; pnlLog.Visible = false; // Get where condition for multiple operation whereCondition = ValidationHelper.GetString(Parameters["where"], string.Empty); // Get the alias paths of the documents to copy/move/link parentAlias = ValidationHelper.GetString(Parameters["parentalias"], string.Empty); if (!String.IsNullOrEmpty(parentAlias)) { lblDocToCopy.Text = GetString(listInfoString + "all") + ResHelper.Colon; lblDocToCopyList.Text = HTMLHelper.HTMLEncode(parentAlias); } else { lblDocToCopy.Text = GetString(listInfoString) + ResHelper.Colon; // Get the list of alias paths if (!String.IsNullOrEmpty(nodeIdsString)) { // Set alias paths if ((CurrentAction == Action.Copy) || (CurrentAction == Action.Move) || (CurrentAction == Action.Link)) { // Get alias paths from session string aliasPaths = SessionHelper.GetValue("CopyMoveDocAliasPaths").ToString(); // As source paths lblDocToCopyList.Text = aliasPaths; } else { int nodeId = ValidationHelper.GetInteger(nodeIds[0], 0); var aliasPaths = TreePathUtils.GetAliasPathByNodeId(nodeId); // As target path lblAliasPath.Text = aliasPaths; } } } if (!RequestHelper.IsPostBack() && DoAction) { // Perform Move / Copy / Link action PerformAction(); } pnlEmpty.Visible = (targetId <= 0); pnlGeneralTab.Visible = (targetId > 0); } }
/// <summary> /// Saves relationship. /// </summary> /// <returns>True, if relatioship was successfully saved.</returns> public bool SaveRelationship() { bool saved = false; // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { return(saved); } bool currentNodeIsOnLeftSide = ValidationHelper.GetBoolean(Request.Params[hdnCurrentOnLeft.UniqueID], false); int selectedNodeId = ValidationHelper.GetInteger(hdnSelectedNodeId.Value, 0); // Try to get by path if not selected if (selectedNodeId <= 0) { string aliaspath = currentNodeIsOnLeftSide ? txtRightNode.Text.Trim() : txtLeftNode.Text.Trim(); if (aliaspath != string.Empty) { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); node = tree.SelectSingleNode(CMSContext.CurrentSiteName, aliaspath, TreeProvider.ALL_CULTURES); if (node != null) { selectedNodeId = node.NodeID; } else { lblError.Visible = true; lblError.Text = GetString("relationship.selectcorrectrelateddoc"); } } else { lblError.Visible = true; lblError.Text = GetString("relationship.selectrelateddoc"); } } int selectedValue = 0; // Only one reletionship name in textbox if ((relationshipNameInfo != null) && (lblRelName.Visible)) { selectedValue = relationshipNameInfo.RelationshipNameId; } // Value from relationship name selector else if (relNameSelector.Visible) { selectedValue = ValidationHelper.GetInteger(relNameSelector.Value, 0); } if ((currentNodeId > 0) && (selectedNodeId > 0) && (selectedValue > 0)) { int relationshipNameId = selectedValue; try { // Left side if (currentNodeIsOnLeftSide) { RelationshipProvider.AddRelationship(currentNodeId, selectedNodeId, relationshipNameId); } // Right side else { RelationshipProvider.AddRelationship(selectedNodeId, currentNodeId, relationshipNameId); } string aliasPath = (node == null) ? TreePathUtils.GetAliasPathByNodeId(currentNodeId) : node.NodeAliasPath; // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(CMSContext.CurrentSiteName, aliasPath, TaskTypeEnum.UpdateDocument, null); saved = true; lblInfo.Text = GetString("general.changessaved"); lblInfo.Visible = true; } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } } return(saved); }