/// <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); } }
/// <summary> /// Saves relationship. /// </summary> public void SaveRelationship() { if (TreeNode == null) { return; } // Check modify permissions if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { return; } bool currentNodeIsOnLeftSide = !DefaultSide; // Selected node Id int selectedNodeId = ValidationHelper.GetInteger(hdnSelectedNodeId.Value, 0); var relationshipName = UseAdHocRelationshipName ? RelationshipNameInfoProvider.GetAdHocRelationshipNameCodeName(TreeNode.ClassName, FieldInfo) : RelationshipName; var relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipName); int relationshipNameId; if (relationshipNameInfo != null) { relationshipNameId = relationshipNameInfo.RelationshipNameId; } else { throw new NullReferenceException("[RelatedDocuments.SaveRelationship]: Missing relationship name to use for relation."); } if ((selectedNodeId <= 0) || (relationshipNameId <= 0)) { return; } try { // Left side if (currentNodeIsOnLeftSide) { RelationshipInfoProvider.AddRelationship(TreeNode.NodeID, selectedNodeId, relationshipNameId); } // Right side else { RelationshipInfoProvider.AddRelationship(selectedNodeId, TreeNode.NodeID, relationshipNameId); } // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(TreeNode.NodeSiteName, TreeNode.NodeAliasPath, TaskTypeEnum.UpdateDocument, TreeProvider); ShowConfirmation(GetString("relationship.wasadded")); } catch (Exception ex) { ShowError(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { SetPropertyTab(TAB_RELATEDDOCS); // 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(ResHelper.GetString("relationship.norelationship")); } else { if (Node != null) { bool enabled = true; // Check modify permissions if (!DocumentUIHelper.CheckDocumentPermissions(Node, PermissionsEnum.Modify)) { relatedDocuments.Enabled = enabled = false; } menuElem.AddExtraAction(new HeaderAction() { Enabled = enabled, Text = GetString("relationship.addrelateddocs"), RedirectUrl = "~/CMSModules/Content/CMSDesk/Properties/Relateddocs_Add.aspx?nodeid=" + NodeID }); } } pnlContent.Enabled = !DocumentManager.ProcessingAction; }
protected void CustomUniSelector_OnSelectionChanged(object sender, EventArgs e) { string SelectedItems = ValidationHelper.GetString(((UniSelector)sender).Value, ""); int RelationshipNameID = RelationshipNameInfoProvider.GetRelationshipNameInfo(RelationshipName).RelationshipNameId; int[] NodeIDs = SelectedItems.Split(";|,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(x => ValidationHelper.GetInteger(x, -1)).ToArray(); if (MaxRelationships > -1 && GetRelationshipCount() + NodeIDs.Length > MaxRelationships) { AddMessage(CMS.Base.Web.UI.MessageTypeEnum.Error, "Too many relationships, max allowed is " + MaxRelationships); return; } foreach (int NodeID in NodeIDs) { if (NodeID > 0) { if (ddlCurrentNodeDirection.SelectedValue == "LeftNode") { RelationshipInfoProvider.AddRelationship(CurrentNodeID, NodeID, RelationshipNameID); } else { RelationshipInfoProvider.AddRelationship(NodeID, CurrentNodeID, RelationshipNameID); } } } // Save direction SessionHelper.SetValue("RelatedPageTreeDirection_" + CurrentNodeID + "_" + UIContext.ElementGuid, ddlCurrentNodeDirection.SelectedValue); URLHelper.RefreshCurrentPage(); }
/// <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) { // 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(ResHelper.GetString("relationship.norelationship")); } else { if (Node != null) { bool enabled = true; // Check modify permissions if (!DocumentUIHelper.CheckDocumentPermissions(Node, PermissionsEnum.Modify)) { relatedDocuments.Enabled = enabled = false; } } } pnlContent.Enabled = !DocumentManager.ProcessingAction; }
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"; }
protected void AddPagesToRelationship(int[] SelectedNodeIDs) { int RelationshipNameID = RelationshipNameInfoProvider.GetRelationshipNameInfo(RelationshipName).RelationshipNameId; if (MaxRelationships > -1 && GetRelationshipCount() + SelectedNodeIDs.Length > MaxRelationships) { AddMessage(CMS.Base.Web.UI.MessageTypeEnum.Error, "Too many relationships, max allowed is " + MaxRelationships); return; } foreach (int NodeID in SelectedNodeIDs) { if (NodeID > 0) { if (ddlCurrentNodeDirection.SelectedValue == "LeftNode") { RelationshipInfoProvider.AddRelationship(CurrentNodeID, NodeID, RelationshipNameID); } else { RelationshipInfoProvider.AddRelationship(NodeID, CurrentNodeID, RelationshipNameID); } } } // Save direction SessionHelper.SetValue("RelatedPageTreeDirection_" + CurrentNodeID + "_" + UIContext.ElementGuid, ddlCurrentNodeDirection.SelectedValue); URLHelper.RefreshCurrentPage(); }
protected void Page_Load(object sender, EventArgs e) { UIContext.PropertyTab = PropertyTabEnum.RelatedDocs; // Check if any relationship exists DataSet dsRel = RelationshipNameInfoProvider.GetRelationshipNames("RelationshipNameID", "RelationshipAllowedObjects LIKE '%" + CMSObjectHelper.GROUP_DOCUMENTS + "%' AND RelationshipNameID IN (SELECT RelationshipNameID FROM CMS_RelationshipNameSite WHERE SiteID = " + CMSContext.CurrentSiteID + ")", null, 1); if (DataHelper.DataSourceIsEmpty(dsRel)) { pnlNewItem.Visible = false; relatedDocuments.Visible = false; ShowInformation(ResHelper.GetString("relationship.norelationship")); } else { if (Node != null) { // Check modify permissions if (!CheckDocumentPermissions(Node, PermissionsEnum.Modify)) { DisableForm(); } // Initialize controls lnkNewRelationship.NavigateUrl = "~/CMSModules/Content/CMSDesk/Properties/Relateddocs_Add.aspx?nodeid=" + NodeID; imgNewRelationship.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/addrelationship.png"); imgNewRelationship.DisabledImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/addrelationshipdisabled.png"); } } pnlContent.Enabled = !DocumentManager.ProcessingAction; }
/// <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 = ServerInfoProvider.GetServers().WhereEquals("ServerSiteID", SiteContext.CurrentSiteID).WhereEquals("ServerEnabled", true).ToList(); RelationshipNameInfo RelationshipObj = RelationshipNameInfoProvider.GetRelationshipNameInfo(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 }; StagingTaskInfoProvider.SetTaskInfo(SiteTask); foreach (ServerInfo ServerObj in ActiveServers) { // Create synchronization SynchronizationInfo SyncSiteInfo = new SynchronizationInfo() { SynchronizationTaskID = SiteTask.TaskID, SynchronizationServerID = ServerObj.ServerID }; SynchronizationInfoProvider.SetSynchronizationInfo(SyncSiteInfo); } TaskGroupInfo TaskGroup = TaskGroupInfoProvider.GetUserTaskGroupInfo(MembershipContext.AuthenticatedUser.UserID); if (TaskGroup != null) { TaskGroupTaskInfoProvider.AddTaskGroupToTask(TaskGroup.TaskGroupID, SiteTask.TaskID); } } }
protected void Page_Load(object sender, EventArgs e) { UIContext.PropertyTab = PropertyTabEnum.RelatedDocs; nodeId = QueryHelper.GetInteger("nodeid", 0); // Check if any relationship exists DataSet dsRel = RelationshipNameInfoProvider.GetRelationshipNames("RelationshipNameID", "RelationshipAllowedObjects LIKE '%" + CMSObjectHelper.GROUP_DOCUMENTS + "%' AND RelationshipNameID IN (SELECT RelationshipNameID FROM CMS_RelationshipNameSite WHERE SiteID = " + CMSContext.CurrentSiteID + ")", null, 1); if (DataHelper.DataSourceIsEmpty(dsRel)) { pnlNewItem.Visible = false; relatedDocuments.Visible = false; lblInfo.Text = ResHelper.GetString("relationship.norelationship"); lblInfo.Visible = true; } else { if (nodeId > 0) { // Get the node tree = new TreeProvider(CMSContext.CurrentUser); node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode, tree.CombineWithDefaultCulture); // Set edited document EditedDocument = node; if (node != null) { // Check read permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath)); } // Check modify permissions else if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { relatedDocuments.Enabled = false; lnkNewRelationship.Enabled = false; imgNewRelationship.Enabled = false; lblInfo.Visible = true; lblInfo.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), node.NodeAliasPath); } else { lblInfo.Visible = false; } // Set tree node relatedDocuments.TreeNode = node; // Initialize controls lnkNewRelationship.NavigateUrl = "~/CMSModules/Content/CMSDesk/Properties/Relateddocs_Add.aspx?nodeid=" + nodeId; imgNewRelationship.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/addrelationship.png"); imgNewRelationship.DisabledImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/addrelationshipdisabled.png"); } } } }
/// <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); }
private static int?GetRelationshipNameID(string RelationshipName) { return(CacheHelper.Cache(cs => { if (cs.Cached) { cs.CacheDependency = CacheHelper.GetCacheDependency($"cms.relationshipname|byname|{RelationshipName}"); } var Relationship = RelationshipNameInfoProvider.GetRelationshipNameInfo(RelationshipName); return Relationship?.RelationshipNameId; }, new CacheSettings(1440, "RelExtendedGetRelationshipNameID", RelationshipName))); }
private int GetRelationshipNameId() { var relationshipName = UseAdHocRelationshipName ? RelationshipNameInfoProvider.GetAdHocRelationshipNameCodeName(TreeNode.ClassName, FieldInfo) : RelationshipName; var relationshipNameInfo = RelationshipNameInfo.Provider.Get(relationshipName); if (relationshipNameInfo == null) { throw new NullReferenceException("Missing relationship name to use for relation."); } return(relationshipNameInfo.RelationshipNameId); }
private int GetRelationshipNameId() { var relationshipName = RelationshipName; var relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipName); if (relationshipNameInfo == null) { throw new NullReferenceException("Missing relationship name to use for relation."); } return(relationshipNameInfo.RelationshipNameId); }
/// <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; } }
public ActionResult SpeakerListingByRelationship(Guid NodeGuid, int NodeID) { // Get Relationship ID int RelationshipNameID = RelationshipNameInfoProvider.GetRelationshipNameInfo("Speakers").RelationshipNameId; var query = DocumentHelper.GetDocuments <Speaker>() // Inner join on the relationship .Source((QuerySource s) => s.InnerJoin(new QuerySourceTable("CMS_Relationship"), new WhereCondition("NodeID = RightNodeID").WhereEquals("RelationshipNameID", RelationshipNameID).WhereEquals("LeftNodeID", NodeID))) // Order by the Relationship Order .OrderBy("RelationshipOrder"); return(View("NEWCC/Speakers", query.ToList())); }
protected void Page_Load(object sender, EventArgs e) { var condition = RelationshipNameInfoProvider.GetRelationshipNamesWhereCondition(AllowedForObjects, AllowedForDocuments, SiteId, !HideAdHocRelationshipNames); uniSelector.WhereCondition = condition.ToString(true); uniSelector.UseTypeCondition = HideAdHocRelationshipNames; uniSelector.AllowAll = ValidationHelper.GetBoolean(GetValue("AllowAll"), false); uniSelector.AllowEmpty = AllowEmpty; uniSelector.ReturnColumnName = ReturnColumnName; uniSelector.OrderBy = "RelationshipDisplayName"; uniSelector.AllRecordValue = String.Empty; }
/// <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> /// 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> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that threw event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void UniGridRelationshipNames_OnAction(string actionName, object actionArgument) { int relationshipNameId = Convert.ToInt32(actionArgument); if (actionName == "edit") { URLHelper.Redirect("RelationshipName_Edit.aspx?relationshipnameid=" + relationshipNameId); } else if (actionName == "delete") { RelationshipNameInfoProvider.DeleteRelationshipName(relationshipNameId); } }
private void Relationship_Insert_Or_Delete_After(object sender, ObjectEventArgs e) { RelationshipInfo RelationshipObj = (RelationshipInfo)e.Object; RelationshipNameInfo RelationshipNameObj = RelationshipNameInfoProvider.GetRelationshipNameInfo(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> /// 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); }
private IEnumerable <object> GetRelationshipElements() { var relationshipNames = RelationshipNameInfoProvider.GetRelationshipNames() .WhereEqualsOrNull("RelationshipNameIsAdHoc", false) .OnSite(Settings.Sitename); var elements = relationshipNames.Select(relationshipName => new { external_id = GetFieldExternalId(RELATED_PAGES_GUID, relationshipName.RelationshipGUID), name = relationshipName.RelationshipDisplayName.LimitedTo(ELEMENT_MAXLENGTH), codename = relationshipName.RelationshipName.ToLower().LimitedTo(ELEMENT_MAXLENGTH), type = "modular_content", }).ToList(); return(elements); }
/// <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> /// 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); }
private int GetRelationshipCount() { int RelationshipNameID = RelationshipNameInfoProvider.GetRelationshipNameInfo(RelationshipName).RelationshipNameId; if (AllowSwitchSides) { return(RelationshipInfoProvider.GetRelationships() .WhereEquals("RelationshipNameID", RelationshipNameID) .Where(string.Format("(LeftNodeID = {0} or RightNodeID = {0})", CurrentNodeID)) .Count); } else { return(RelationshipInfoProvider.GetRelationships() .WhereEquals("RelationshipNameID", RelationshipNameID) .WhereEquals(DirectionMode == "LeftNode" ? "LeftNodeID" : "RightNodeID", CurrentNodeID) .Count); } }
/// <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); }