/// <summary> /// Gets and bulk updates relationship names. Called when the "Get and bulk update names" button is pressed. /// Expects the CreateRelationshipName method to be run first. /// </summary> private bool GetAndBulkUpdateRelationshipNames() { // Prepare the parameters string where = "RelationshipName LIKE N'MyNewRelationshipName%'"; // Get the data DataSet names = RelationshipNameInfoProvider.GetRelationshipNames(where, null); if (!DataHelper.DataSourceIsEmpty(names)) { // Loop through the individual items foreach (DataRow nameDr in names.Tables[0].Rows) { // Create object from DataRow RelationshipNameInfo modifyName = new RelationshipNameInfo(nameDr); // Update the properties modifyName.RelationshipDisplayName = modifyName.RelationshipDisplayName.ToUpper(); // Save the changes RelationshipNameInfoProvider.SetRelationshipNameInfo(modifyName); } return(true); } return(false); }
/// <summary> /// Saves new relationship name's data and redirects to RelationshipName_Edit.aspx. /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event arguments</param> protected void ButtonOK_Click(object sender, EventArgs e) { // finds whether required fields are not empty string result = new Validator().NotEmpty(txtRelationshipNameDisplayName.Text, GetString("General.RequiresDisplayName")).NotEmpty(txtRelationshipNameCodeName.Text, GetString("General.RequiresCodeName")) .IsCodeName(txtRelationshipNameCodeName.Text, GetString("general.invalidcodename")) .Result; if (result == string.Empty) { RelationshipNameInfo rni = RelationshipNameInfoProvider.GetRelationshipNameInfo(txtRelationshipNameCodeName.Text); if (rni == null) { int relationshipNameId = SaveNewRelationshipName(); if (relationshipNameId > 0) { URLHelper.Redirect("RelationshipName_Edit.aspx?relationshipnameid=" + relationshipNameId + "&saved=1"); } } else { ShowError(GetString("RelationshipNames.RelationshipNameAlreadyExists")); } } else { ShowError(result); } }
protected void Page_Load(object sender, EventArgs e) { // Get ID of relationship name relationshipNameId = QueryHelper.GetInteger("relationshipnameid", 0); // Initialize menu if (!RequestHelper.IsPostBack()) { InitalizeMenu(); } // Get info object RelationshipNameInfo relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipNameId); // Initializes page title string[,] pageTitleTabs = new string[2, 3]; pageTitleTabs[0, 0] = GetString("RelationshipNames.RelationshipNames"); pageTitleTabs[0, 1] = "~/CMSModules/RelationshipNames/RelationshipName_List.aspx"; pageTitleTabs[0, 2] = "_parent"; pageTitleTabs[1, 0] = (relationshipNameInfo != null) ? relationshipNameInfo.RelationshipDisplayName : string.Empty; pageTitleTabs[1, 1] = string.Empty; pageTitleTabs[1, 2] = string.Empty; CurrentMaster.Title.Breadcrumbs = pageTitleTabs; CurrentMaster.Title.TitleText = GetString("RelationshipNames.RelationshipNameProperties"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_RelationshipName/object.png"); CurrentMaster.Title.HelpTopicName = "new_namegeneral_tab"; CurrentMaster.Title.HelpName = "helpTopic"; }
/// <summary> /// Custom Staging Task generation /// </summary> /// <param name="RelationshipSiteObj"></param> /// <param name="TaskType"></param> private void RelationshipNameSite_CreateStagingTask(RelationshipNameSiteInfo RelationshipSiteObj, TaskTypeEnum TaskType) { List <ServerInfo> ActiveServers = ServerInfo.Provider.Get().WhereEquals("ServerSiteID", SiteContext.CurrentSiteID).WhereEquals("ServerEnabled", true).ToList(); RelationshipNameInfo RelationshipObj = RelationshipNameInfo.Provider.Get(RelationshipSiteObj.RelationshipNameID); // If relationship obj is already gone, then the Site deletion thing is already handled with the deletion of the relationship name. if (RelationshipObj == null) { return; } if (IsCustomAdhocRelationshipName(RelationshipObj) && ActiveServers.Count > 0) { string Data = "<NewDataSet>" + RelationshipObj.ToXML("CMS_RelationshipName", false) + "</NewDataSet>"; string TaskTitle = ""; string TaskTitleEnd = ""; switch (TaskType) { case TaskTypeEnum.AddToSite: TaskTitle = "Add"; TaskTitleEnd = "to"; break; case TaskTypeEnum.RemoveFromSite: TaskTitle = "Remove"; TaskTitleEnd = "from"; break; } StagingTaskInfo SiteTask = new CMS.Synchronization.StagingTaskInfo() { TaskTitle = string.Format("{0} Relationship name '{1}' {2} site", TaskTitle, RelationshipObj.RelationshipDisplayName, TaskTitleEnd), TaskType = TaskType, TaskObjectType = RelationshipNameInfo.OBJECT_TYPE, TaskObjectID = RelationshipObj.RelationshipNameId, TaskData = Data, TaskTime = DateTime.Now, TaskSiteID = SiteContext.CurrentSiteID }; StagingTaskInfo.Provider.Set(SiteTask); foreach (ServerInfo ServerObj in ActiveServers) { // Create synchronization SynchronizationInfo SyncSiteInfo = new SynchronizationInfo() { SynchronizationTaskID = SiteTask.TaskID, SynchronizationServerID = ServerObj.ServerID }; SynchronizationInfo.Provider.Set(SyncSiteInfo); } TaskGroupInfo TaskGroup = TaskGroupInfoProvider.GetUserTaskGroupInfo(MembershipContext.AuthenticatedUser.UserID); if (TaskGroup != null) { TaskGroupTaskInfo.Provider.Add(TaskGroup.TaskGroupID, SiteTask.TaskID); } } }
/// <summary> /// Deletes relationship name. Called when the "Delete name" button is pressed. /// Expects the CreateRelationshipName method to be run first. /// </summary> private bool DeleteRelationshipName() { // Get the relationship name RelationshipNameInfo deleteName = RelationshipNameInfoProvider.GetRelationshipNameInfo("MyNewRelationshipName"); // Delete the relationship name RelationshipNameInfoProvider.DeleteRelationshipName(deleteName); return(deleteName != null); }
/// <summary> /// Determines if the RelationshipName is a custom AdHoc relationship or if it's a PageType generated adhoc one based on the Guid at the end of the code name /// </summary> /// <param name="RelationshipNameObj">The Relationship Name Info Obj</param> /// <returns>If it's a custom Ad Hoc or not</returns> private bool IsCustomAdhocRelationshipName(RelationshipNameInfo RelationshipNameObj) { if (!RelationshipNameObj.RelationshipNameIsAdHoc) { return(false); } if (!RelationshipNameObj.RelationshipName.Contains("_")) { return(true); } return(ValidationHelper.GetGuid(RelationshipNameObj.RelationshipName.Split('_')[1], Guid.Empty) == Guid.Empty); }
/// <summary> /// Saves data of edited relationship name from TextBoxes into DB. /// </summary> protected void btnOk_Click(object sender, EventArgs e) { // Finds whether required fields are not empty string result = new Validator().NotEmpty(txtRelationshipNameDisplayName.Text, GetString("General.RequiresDisplayName")).NotEmpty(txtRelationshipNameCodeName.Text, GetString("General.RequiresCodeName")) .IsCodeName(txtRelationshipNameCodeName.Text, GetString("general.invalidcodename")) .Result; if (result == string.Empty) { if (relationshipNameId > 0) { // Check the uniqueness of code name RelationshipNameInfo rni = RelationshipNameInfoProvider.GetRelationshipNameInfo(txtRelationshipNameCodeName.Text); if (rni == null || rni.RelationshipNameId == relationshipNameId) { // Get relationshipname info by ID rni = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipNameId); if (rni != null) { if (rni.RelationshipDisplayName != txtRelationshipNameDisplayName.Text) { // Refresh header ScriptHelper.RefreshTabHeader(Page, null); } rni.RelationshipDisplayName = txtRelationshipNameDisplayName.Text; rni.RelationshipName = txtRelationshipNameCodeName.Text; rni.RelationshipAllowedObjects = drpRelType.SelectedValue; // Save changes RelationshipNameInfoProvider.SetRelationshipNameInfo(rni); lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } else { lblError.Visible = true; lblError.Text = GetString("RelationshipNames.RelationshipNameDoesNotExists"); } } else { lblError.Visible = true; lblError.Text = GetString("RelationshipNames.RelationshipNameAlreadyExists"); } } } else { lblError.Visible = true; lblError.Text = result; } }
/// <summary> /// Creates the Staging Task manually /// </summary> /// <param name="RelationshipObj"></param> /// <param name="TaskType"></param> private void RelationshipName_CreateStagingTask(RelationshipNameInfo RelationshipObj, TaskTypeEnum TaskType) { List <ServerInfo> ActiveServers = ServerInfo.Provider.Get().WhereEquals("ServerSiteID", SiteContext.CurrentSiteID).WhereEquals("ServerEnabled", true).ToList(); if (IsCustomAdhocRelationshipName(RelationshipObj) && ActiveServers.Count > 0) { string Data = "<NewDataSet>" + RelationshipObj.ToXML("CMS_RelationshipName", false) + "</NewDataSet>"; string TaskTitle = ""; switch (TaskType) { case TaskTypeEnum.CreateObject: TaskTitle = "Create"; break; case TaskTypeEnum.UpdateObject: TaskTitle = "Update"; break; case TaskTypeEnum.DeleteObject: TaskTitle = "Delete"; break; } StagingTaskInfo Task = new StagingTaskInfo() { TaskTitle = string.Format("{0} Relationship name '{1}'", TaskTitle, RelationshipObj.RelationshipDisplayName), TaskType = TaskType, TaskObjectType = RelationshipNameInfo.OBJECT_TYPE, TaskObjectID = RelationshipObj.RelationshipNameId, TaskData = Data, TaskTime = DateTime.Now }; StagingTaskInfo.Provider.Set(Task); foreach (ServerInfo ServerObj in ActiveServers) { // Create synchronization SynchronizationInfo SyncInfo = new SynchronizationInfo() { SynchronizationTaskID = Task.TaskID, SynchronizationServerID = ServerObj.ServerID }; SynchronizationInfo.Provider.Set(SyncInfo); } TaskGroupInfo TaskGroup = TaskGroupInfoProvider.GetUserTaskGroupInfo(MembershipContext.AuthenticatedUser.UserID); if (TaskGroup != null) { TaskGroupTaskInfo.Provider.Add(TaskGroup.TaskGroupID, Task.TaskID); } } }
/// <summary> /// Saves relationship. /// </summary> public void SaveRelationship() { if (TreeNode != null) { // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { return; } bool currentNodeIsOnLeftSide = !DefaultSide; // Selected node Id int selectedNodeId = ValidationHelper.GetInteger(hdnSelectedNodeId.Value, 0); // Get relatioshipname RelationshipNameInfo relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(RelationshipName); int relationshipNameId = 0; if (relationshipNameInfo != null) { relationshipNameId = relationshipNameInfo.RelationshipNameId; } if ((selectedNodeId > 0) && (relationshipNameId > 0)) { try { // Left side if (currentNodeIsOnLeftSide) { RelationshipProvider.AddRelationship(TreeNode.NodeID, selectedNodeId, relationshipNameId); } // Right side else { RelationshipProvider.AddRelationship(selectedNodeId, TreeNode.NodeID, relationshipNameId); } // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(CMSContext.CurrentSiteName, TreeNode.NodeAliasPath, TaskTypeEnum.UpdateDocument, TreeProvider); lblInfo.Text = GetString("relationship.wasadded"); } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } } } }
/// <summary> /// Saves new relationship name's data into DB. /// </summary> /// <returns>Returns ID of created relationship name</returns> protected int SaveNewRelationshipName() { RelationshipNameInfo rni = new RelationshipNameInfo(); rni.RelationshipDisplayName = txtRelationshipNameDisplayName.Text; rni.RelationshipName = txtRelationshipNameCodeName.Text; rni.RelationshipAllowedObjects = objectTypeSelector.ObjectType; RelationshipNameInfoProvider.SetRelationshipNameInfo(rni); if (chkAssign.Visible && chkAssign.Checked && (CMSContext.CurrentSite != null) && (rni.RelationshipNameId > 0)) { // Add new relationship name to the actual site RelationshipNameSiteInfoProvider.AddRelationshipNameToSite(rni.RelationshipNameId, CMSContext.CurrentSite.SiteID); } return rni.RelationshipNameId; }
private void Relationship_Insert_Or_Delete_After(object sender, ObjectEventArgs e) { RelationshipInfo RelationshipObj = (RelationshipInfo)e.Object; RelationshipNameInfo RelationshipNameObj = RelationshipNameInfo.Provider.Get(RelationshipObj.RelationshipNameId); if (IsCustomAdhocRelationshipName(RelationshipNameObj)) { TreeNode LeftNode = new DocumentQuery().WhereEquals("NodeID", RelationshipObj.LeftNodeId).FirstOrDefault(); if (RelHelper.IsStagingEnabled(LeftNode.NodeSiteID)) { DocumentSynchronizationHelper.LogDocumentChange(LeftNode.NodeSiteName, LeftNode.NodeAliasPath, TaskTypeEnum.UpdateDocument, LeftNode.TreeProvider); } } }
/// <summary> /// Creates relationship name. Called when the "Create name" button is pressed. /// </summary> private bool CreateRelationshipName() { // Create new relationship name object RelationshipNameInfo newName = new RelationshipNameInfo(); // Set the properties newName.RelationshipDisplayName = "My new relationship name"; newName.RelationshipName = "MyNewRelationshipName"; // Save the relationship name RelationshipNameInfoProvider.SetRelationshipNameInfo(newName); return(true); }
/// <summary> /// Determines if the current relationship is an AdHoc relationship based on the UI Property RelationshipName /// </summary> /// <returns>True if the current relationship is an ad hoc relationship</returns> private static bool IsAdHocRelationship() { string RelationshipName = ValidationHelper.GetString(UIContext.Current.Data.GetValue("RelationshipName"), ""); return(CacheHelper.Cache <bool>(cs => { RelationshipNameInfo relationshipObj = RelationshipNameInfoProvider.GetRelationshipNameInfo(RelationshipName); if (relationshipObj != null && cs.Cached) { cs.CacheDependency = CacheHelper.GetCacheDependency("cms.relationshipname|byid|" + relationshipObj.RelationshipNameId); } return relationshipObj != null ? relationshipObj.RelationshipNameIsAdHoc : false; }, new CacheSettings(CacheHelper.CacheMinutes(SiteContext.CurrentSiteName), "RelationshipMacro", "IsAdHocRelationship", RelationshipName))); }
/// <summary> /// Loads data of edited relationship name from DB into TextBoxes. /// </summary> protected void LoadData() { RelationshipNameInfo rni = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipNameId); if (rni != null) { txtRelationshipNameCodeName.Text = rni.RelationshipName; txtRelationshipNameDisplayName.Text = rni.RelationshipDisplayName; if (!DataHelper.IsEmpty(rni.RelationshipAllowedObjects)) { objectTypeSelector.ObjectType = rni.RelationshipAllowedObjects; } } }
/// <summary> /// Saves new relationship name's data into DB. /// </summary> /// <returns>Returns ID of created relationship name</returns> protected int SaveNewRelationshipName() { RelationshipNameInfo rni = new RelationshipNameInfo(); rni.RelationshipDisplayName = txtRelationshipNameDisplayName.Text; rni.RelationshipName = txtRelationshipNameCodeName.Text; rni.RelationshipAllowedObjects = objectTypeSelector.ObjectType; RelationshipNameInfoProvider.SetRelationshipNameInfo(rni); if (chkAssign.Visible && chkAssign.Checked && (CMSContext.CurrentSite != null) && (rni.RelationshipNameId > 0)) { // Add new relationship name to the actual site RelationshipNameSiteInfoProvider.AddRelationshipNameToSite(rni.RelationshipNameId, CMSContext.CurrentSite.SiteID); } return(rni.RelationshipNameId); }
/// <summary> /// Adds relationship name to site. Called when the "Add name to site" button is pressed. /// Expects the CreateRelationshipName method to be run first. /// </summary> private bool AddRelationshipNameToSite() { // Get the relationship name RelationshipNameInfo name = RelationshipNameInfoProvider.GetRelationshipNameInfo("MyNewRelationshipName"); if (name != null) { int nameId = name.RelationshipNameId; int siteId = SiteContext.CurrentSiteID; // Save the binding RelationshipNameSiteInfoProvider.AddRelationshipNameToSite(nameId, siteId); return(true); } return(false); }
/// <summary> /// Gets and updates relationship name. Called when the "Get and update name" button is pressed. /// Expects the CreateRelationshipName method to be run first. /// </summary> private bool GetAndUpdateRelationshipName() { // Get the relationship name RelationshipNameInfo updateName = RelationshipNameInfoProvider.GetRelationshipNameInfo("MyNewRelationshipName"); if (updateName != null) { // Update the properties updateName.RelationshipDisplayName = updateName.RelationshipDisplayName.ToLower(); // Save the changes RelationshipNameInfoProvider.SetRelationshipNameInfo(updateName); return(true); } return(false); }
/// <summary> /// Removes relationship name from site. Called when the "Remove name from site" button is pressed. /// Expects the AddRelationshipNameToSite method to be run first. /// </summary> private bool RemoveRelationshipNameFromSite() { // Get the relationship name RelationshipNameInfo removeName = RelationshipNameInfoProvider.GetRelationshipNameInfo("MyNewRelationshipName"); if (removeName != null) { int siteId = SiteContext.CurrentSiteID; // Get the binding RelationshipNameSiteInfo nameSite = RelationshipNameSiteInfoProvider.GetRelationshipNameSiteInfo(removeName.RelationshipNameId, siteId); // Delete the binding RelationshipNameSiteInfoProvider.DeleteRelationshipNameSiteInfo(nameSite); return(true); } return(false); }
/// <summary> /// Deletes relationship between documents. Called when the "Delete relationship" button is pressed. /// Expects the CreateRelationshipName and the CreateRelationship methods to be run first. /// </summary> private bool DeleteRelationship() { // Get the relationship name RelationshipNameInfo relationshipName = RelationshipNameInfoProvider.GetRelationshipNameInfo("MyNewRelationshipName"); if (relationshipName != null) { // Get the tree structure TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Get documents which are in relationship (the Root document is used for both in this example) TreeNode root = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/", null, true); // Delete the relationship between documents RelationshipInfoProvider.RemoveRelationship(root.NodeID, root.NodeID, relationshipName.RelationshipNameId); return(true); } return(false); }
/// <summary> /// Creates relationship between documents. Called when the "Create relationship" button is pressed. /// Expects the CreateRelationshipName method to be run first. /// </summary> private bool CreateRelationship() { // Get the relationship name RelationshipNameInfo relationshipName = RelationshipNameInfoProvider.GetRelationshipNameInfo("MyNewRelationshipName"); if (relationshipName != null) { // Get the tree structure TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); // Get documents for relationship (the Root document is used for both in this example) TreeNode root = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", null, true); // Create the relationship between documents RelationshipProvider.AddRelationship(root.NodeID, root.NodeID, relationshipName.RelationshipNameId); return(true); } return(false); }
/// <summary> /// Get related pages for a Pages field specified on a component. /// </summary> /// <param name="component">The component that has the Pages field.</param> /// <param name="fieldName">The code name of the Pages field on the component.</param> /// <returns>The related pages for the specified component field.</returns> public static IEnumerable <TreeNode> GetRelatedDocumentsForComponent(this IContentComponent component, string fieldName) { TreeNode parent = component.Parent; if (parent == null) { return(Enumerable.Empty <TreeNode>()); } FormInfo form = FormHelper.GetFormInfo(component.NodeClassName, false); FormFieldInfo formField = form.GetFormField(fieldName); if (formField == null) { return(Enumerable.Empty <TreeNode>()); } string relationshipNameCodeName = RelationshipNameInfoProvider.GetAdHocRelationshipNameCodeName(parent.NodeClassName, formField); RelationshipNameInfo relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipNameCodeName); var relationshipQuery = DocumentHelper.GetDocuments() .Culture(parent.DocumentCulture) .CombineWithDefaultCulture(parent.TreeProvider.GetCombineWithDefaultCulture(parent.Site.SiteName)) .Published(!parent.IsLastVersion) .PublishedVersion(!parent.IsLastVersion) .WithCoupledColumns() .InRelationWith( parent.NodeGUID, relationshipNameCodeName, RelationshipSideEnum.Left ); return(RelationshipInfoProvider.ApplyRelationshipOrderData( relationshipQuery, parent.NodeID, relationshipNameInfo.RelationshipNameId )); }
/// <summary> /// Returns true if document is in specified relationship with with selected document. /// </summary> /// <param name="document">Document to be checked</param> /// <param name="side">Relationship side</param> /// <param name="relationship">Relationship name</param> /// <param name="relatedDocumentPath">Alias path to selected document</param> /// <param name="relatedDocumentSite">Selected document site name</param> public static bool IsInRelationship(object document, string side, string relationship, string relatedDocumentPath, string relatedDocumentSite) { TreeNode doc = document as TreeNode; if (doc != null) { int leftNodeID = 0; int rightNodeID = 0; // Use site of the checked document when no other is specified if (String.IsNullOrEmpty(relatedDocumentSite)) { relatedDocumentSite = doc.NodeSiteName; } // Prepare left and right document for relationship side = side.ToLowerCSafe(); if (side == "left") { leftNodeID = doc.NodeID; rightNodeID = TreePathUtils.GetNodeIdByAliasPath(relatedDocumentSite, relatedDocumentPath); } else if (side == "right") { leftNodeID = TreePathUtils.GetNodeIdByAliasPath(relatedDocumentSite, relatedDocumentPath); rightNodeID = doc.NodeID; } // Get relationship ID from relationship name RelationshipNameInfo relationshipName = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationship); if (relationshipName != null) { // Check whether relationship between the two documents exists return(RelationshipProvider.GetRelationshipInfo(leftNodeID, rightNodeID, relationshipName.RelationshipNameId) != null); } } return(false); }
/// <summary> /// Loads data of edited relationship name from DB into TextBoxes. /// </summary> protected void LoadData() { RelationshipNameInfo rni = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipNameId); if (rni != null) { txtRelationshipNameCodeName.Text = rni.RelationshipName; txtRelationshipNameDisplayName.Text = rni.RelationshipDisplayName; // Initialize drop down list with relationship type drpRelType.Items.Clear(); drpRelType.Items.Add(new ListItem(GetString("RelationshipNames.Documents"), ";" + CMSObjectHelper.GROUP_DOCUMENTS + ";")); drpRelType.Items.Add(new ListItem(GetString("RelationshipNames.Objects"), ";" + CMSObjectHelper.GROUP_OBJECTS + ";")); if (DataHelper.IsEmpty(rni.RelationshipAllowedObjects)) { drpRelType.SelectedIndex = 0; } else { drpRelType.SelectedValue = rni.RelationshipAllowedObjects; } } }
protected object gridItems_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView dr = null; switch (sourceName.ToLower()) { case "leftobject": { dr = (DataRowView)parameter; string objectType = ValidationHelper.GetString(dr["RelationshipLeftObjectType"], ""); int objectId = ValidationHelper.GetInteger(dr["RelationshipLeftObjectID"], 0); return(GetObjectString(objectId, objectType)); } case "rightobject": { dr = (DataRowView)parameter; string objectType = ValidationHelper.GetString(dr["RelationshipRightObjectType"], ""); int objectId = ValidationHelper.GetInteger(dr["RelationshipRightObjectID"], 0); return(GetObjectString(objectId, objectType)); } case "relationshipname": // Relationship name int relationshipId = ValidationHelper.GetInteger(parameter, 0); RelationshipNameInfo ri = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipId); if (ri != null) { return(ri.RelationshipDisplayName); } break; } return(parameter); }
public bool IsAtSynchronizedSite(RelationshipNameInfo relationshipName) { var siteId = SiteInfoProvider.GetSiteID(Settings.Sitename); return(RelationshipNameSiteInfo.Provider.Get(relationshipName.RelationshipNameId, siteId) != null); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); EditedDocument = Node; // Get default relationship name from settings string defaultRelName = ECommerceSettings.RelatedProductsRelationshipName(SiteContext.CurrentSiteName); // Check if relationship exists bool anyRelationshipsFound = true; RelationshipNameInfo defaultRelNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(defaultRelName); if (defaultRelNameInfo != null) { relatedDocuments.RelationshipName = defaultRelName; } else { // Check if any relationship exists DataSet dsRel = RelationshipNameInfoProvider.GetRelationshipNames("RelationshipAllowedObjects LIKE '%" + ObjectHelper.GROUP_DOCUMENTS + "%' AND RelationshipNameID IN (SELECT RelationshipNameID FROM CMS_RelationshipNameSite WHERE SiteID = " + SiteContext.CurrentSiteID + ")", null, 1, "RelationshipNameID"); if (DataHelper.DataSourceIsEmpty(dsRel)) { relatedDocuments.Visible = false; ShowInformation(GetString("relationship.norelationship")); anyRelationshipsFound = false; } } if (anyRelationshipsFound && (Node != null)) { // Check read permissions if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(string.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), Node.NodeAliasPath)); } // Check modify permissions else if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { pnlDocInfo.Label.Text = string.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), Node.DocumentName); relatedDocuments.Enabled = false; CurrentMaster.HeaderActions.Enabled = false; } } // Set tree node relatedDocuments.TreeNode = Node; // Set starting path if (!string.IsNullOrEmpty(ProductsStartingPath)) { relatedDocuments.StartingPath = ProductsStartingPath; } CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction { Text = GetString("relationship.addrelateddocs"), OnClientClick = relatedDocuments.GetAddRelatedDocumentScript() }); }
protected void Page_Load(object sender, EventArgs e) { // Register the dialog script ScriptHelper.RegisterDialogScript(Page); DefaultSide = QueryHelper.GetBoolean("defaultside", DefaultSide); AllowSwitchSides = QueryHelper.GetBoolean("allowswitchsides", AllowSwitchSides); RelationshipName = QueryHelper.GetString("relationshipname", RelationshipName); relNameSelector.IsLiveSite = false; btnSwitchSides.Visible = AllowSwitchSides; btnOk.Visible = ShowButtons; // Initialize dialog scripts Config.EditorClientID = txtLeftNode.ClientID + ";" + hdnSelectedNodeId.ClientID; string url = CMSDialogHelper.GetDialogUrl(Config, IsLiveSite, false, null, false); btnLeftNode.OnClientClick = "modalDialog('" + url + "', 'contentselectnode', '90%', '85%'); return false;"; Config.EditorClientID = txtRightNode.ClientID + ";" + hdnSelectedNodeId.ClientID; url = CMSDialogHelper.GetDialogUrl(Config, IsLiveSite, false, null, false); btnRightNode.OnClientClick = "modalDialog('" + url + "', 'contentselectnode', '90%', '85%'); return false;"; leftCell.Text = GetString("Relationship.leftSideDoc"); middleCell.Text = GetString("Relationship.RelationshipName"); rightCell.Text = GetString("Relationship.rightSideDoc"); if (TreeNode != null) { currentNodeId = TreeNode.NodeID; // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { Enabled = false; lblInfo.Visible = true; lblInfo.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), TreeNode.NodeAliasPath); } string nodeDocumentName = TreeNode.DocumentName; lblRightNode.Text = lblLeftNode.Text = (string.IsNullOrEmpty(nodeDocumentName)) ? "/" : HTMLHelper.HTMLEncode(nodeDocumentName); } else { Enabled = false; } // All relationship names for current site if (string.IsNullOrEmpty(RelationshipName)) { relNameSelector.Visible = true; lblRelName.Visible = false; } else { relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(RelationshipName); if (relationshipNameInfo != null) { lblRelName.Text = relationshipNameInfo.RelationshipDisplayName; } relNameSelector.Visible = false; lblRelName.Visible = true; } // Register switching js if (btnSwitchSides.Enabled) { RegisterScript(); } if (!RequestHelper.IsPostBack()) { hdnCurrentOnLeft.Value = !DefaultSide ? "true" : "false"; } bool isLeftSide = ValidationHelper.GetBoolean(hdnCurrentOnLeft.Value, false); // Left side if (isLeftSide) { pnlLeftCurrentNode.Style.Add("display", "block"); pnlLeftSelectedNode.Style.Add("display", "none"); pnlLeftSelectButton.Style.Add("display", "none"); pnlRightCurrentNode.Style.Add("display", "none"); pnlRightSelectedNode.Style.Add("display", "block"); pnlRightSelectButton.Style.Add("display", "block"); } // Right side else { pnlLeftCurrentNode.Style.Add("display", "none"); pnlLeftSelectedNode.Style.Add("display", "block"); pnlLeftSelectButton.Style.Add("display", "block"); pnlRightCurrentNode.Style.Add("display", "block"); pnlRightSelectedNode.Style.Add("display", "none"); pnlRightSelectButton.Style.Add("display", "none"); } }
/// <summary> /// Creates relationship name. Called when the "Create name" button is pressed. /// </summary> private bool CreateRelationshipName() { // Create new relationship name object RelationshipNameInfo newName = new RelationshipNameInfo(); // Set the properties newName.RelationshipDisplayName = "My new relationship name"; newName.RelationshipName = "MyNewRelationshipName"; // Save the relationship name RelationshipNameInfoProvider.SetRelationshipNameInfo(newName); return true; }
/// <summary> /// Gets and bulk updates relationship names. Called when the "Get and bulk update names" button is pressed. /// Expects the CreateRelationshipName method to be run first. /// </summary> private bool GetAndBulkUpdateRelationshipNames() { // Prepare the parameters string where = "RelationshipName LIKE N'MyNewRelationshipName%'"; // Get the data DataSet names = RelationshipNameInfoProvider.GetRelationshipNames(where, null); if (!DataHelper.DataSourceIsEmpty(names)) { // Loop through the individual items foreach (DataRow nameDr in names.Tables[0].Rows) { // Create object from DataRow RelationshipNameInfo modifyName = new RelationshipNameInfo(nameDr); // Update the properties modifyName.RelationshipDisplayName = modifyName.RelationshipDisplayName.ToUpper(); // Save the changes RelationshipNameInfoProvider.SetRelationshipNameInfo(modifyName); } return true; } return false; }
protected void Page_Load(object sender, EventArgs e) { // Register the dialog script ScriptHelper.RegisterDialogScript(Page); DefaultSide = QueryHelper.GetBoolean("defaultside", DefaultSide); AllowSwitchSides = QueryHelper.GetBoolean("allowswitchsides", AllowSwitchSides); RelationshipName = QueryHelper.GetString("relationshipname", RelationshipName); Config.ContentStartingPath = QueryHelper.GetString("startingpath", Config.ContentStartingPath); relNameSelector.IsLiveSite = false; btnSwitchSides.Visible = AllowSwitchSides; btnOk.Visible = ShowButtons; // Initialize dialog scripts Config.EditorClientID = txtLeftNode.ClientID + ";" + hdnSelectedNodeId.ClientID; string url = CMSDialogHelper.GetDialogUrl(Config, false, null, false); btnLeftNode.OnClientClick = "modalDialog('" + url + "', 'contentselectnode', '90%', '85%'); return false;"; Config.EditorClientID = txtRightNode.ClientID + ";" + hdnSelectedNodeId.ClientID; url = CMSDialogHelper.GetDialogUrl(Config, false, null, false); btnRightNode.OnClientClick = "modalDialog('" + url + "', 'contentselectnode', '90%', '85%'); return false;"; if (TreeNode != null) { currentNodeId = TreeNode.NodeID; var documentName = HTMLHelper.HTMLEncode(TreeNode.GetDocumentName()); // Check modify permissions if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { Enabled = false; ShowInformation(String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), documentName)); } lblRightNode.Text = lblLeftNode.Text = documentName; } else { Enabled = false; } // All relationship names for current site if (string.IsNullOrEmpty(RelationshipName)) { relNameSelector.Visible = true; lblRelName.Visible = false; } else { relationshipNameInfo = RelationshipNameInfo.Provider.Get(RelationshipName); if (relationshipNameInfo != null) { lblRelName.Text = relationshipNameInfo.RelationshipDisplayName; } relNameSelector.Visible = false; lblRelName.Visible = true; } // Register switching js if (btnSwitchSides.Enabled && btnSwitchSides.Visible) { RegisterScript(); } if (!RequestHelper.IsPostBack()) { hdnCurrentOnLeft.Value = !DefaultSide ? "true" : "false"; } bool isLeftSide = ValidationHelper.GetBoolean(hdnCurrentOnLeft.Value, false); // Left side if (isLeftSide) { pnlLeftSelectedNode.AddCssClass("hidden"); lblRightNode.AddCssClass("hidden"); pnlRightSelectedNode.RemoveCssClass("hidden"); lblLeftNode.RemoveCssClass("hidden"); } // Right side else { lblLeftNode.AddCssClass("hidden"); pnlRightSelectedNode.AddCssClass("hidden"); pnlLeftSelectedNode.RemoveCssClass("hidden"); lblRightNode.RemoveCssClass("hidden"); } // Clear breadcrumbs suffix (we don't want it when creating new object) UIHelper.SetBreadcrumbsSuffix(""); }
protected void Page_Load(object sender, EventArgs e) { // Register the dialog script ScriptHelper.RegisterDialogScript(Page); DefaultSide = QueryHelper.GetBoolean("defaultside", DefaultSide); AllowSwitchSides = QueryHelper.GetBoolean("allowswitchsides", AllowSwitchSides); RelationshipName = QueryHelper.GetString("relationshipname", RelationshipName); Config.ContentStartingPath = QueryHelper.GetString("startingpath", Config.ContentStartingPath); relNameSelector.IsLiveSite = false; btnSwitchSides.Visible = AllowSwitchSides; btnOk.Visible = ShowButtons; // Initialize dialog scripts Config.EditorClientID = txtLeftNode.ClientID + ";" + hdnSelectedNodeId.ClientID; string url = CMSDialogHelper.GetDialogUrl(Config, IsLiveSite, false, null, false); btnLeftNode.OnClientClick = "modalDialog('" + url + "', 'contentselectnode', '90%', '85%'); return false;"; Config.EditorClientID = txtRightNode.ClientID + ";" + hdnSelectedNodeId.ClientID; url = CMSDialogHelper.GetDialogUrl(Config, IsLiveSite, false, null, false); btnRightNode.OnClientClick = "modalDialog('" + url + "', 'contentselectnode', '90%', '85%'); return false;"; if (TreeNode != null) { currentNodeId = TreeNode.NodeID; // Check modify permissions if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { Enabled = false; ShowInformation(String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), TreeNode.NodeAliasPath)); } string nodeDocumentName = TreeNode.GetDocumentName(); lblRightNode.Text = lblLeftNode.Text = HTMLHelper.HTMLEncode(nodeDocumentName); } else { Enabled = false; } // All relationship names for current site if (string.IsNullOrEmpty(RelationshipName)) { relNameSelector.Visible = true; lblRelName.Visible = false; } else { relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(RelationshipName); if (relationshipNameInfo != null) { lblRelName.Text = relationshipNameInfo.RelationshipDisplayName; } relNameSelector.Visible = false; lblRelName.Visible = true; } // Register switching js if (btnSwitchSides.Enabled && btnSwitchSides.Visible) { RegisterScript(); } if (!RequestHelper.IsPostBack()) { hdnCurrentOnLeft.Value = !DefaultSide ? "true" : "false"; } bool isLeftSide = ValidationHelper.GetBoolean(hdnCurrentOnLeft.Value, false); // Left side if (isLeftSide) { pnlLeftSelectedNode.AddCssClass("hidden"); lblRightNode.AddCssClass("hidden"); pnlRightSelectedNode.RemoveCssClass("hidden"); lblLeftNode.RemoveCssClass("hidden"); } // Right side else { lblLeftNode.AddCssClass("hidden"); pnlRightSelectedNode.AddCssClass("hidden"); pnlLeftSelectedNode.RemoveCssClass("hidden"); lblRightNode.RemoveCssClass("hidden"); } // Clear breadcrumbs suffix (we don't want it when creating new object) UIHelper.SetBreadcrumbsSuffix(""); }