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; }
/// <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) { 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; }
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"); } } } }
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> /// Fills the given drop-down list with the available relationship types. /// </summary> private void DisplayAvailableRelationships() { if (drpRelationship.Items.Count == 0) { // Get the relationships from DB DataSet ds = RelationshipNameInfoProvider.GetRelationshipNames(SiteContext.CurrentSiteID, "RelationshipAllowedObjects LIKE '%;##OBJECTS##;%'"); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { drpRelationship.Items.Add(new ListItem(dr["RelationshipDisplayName"].ToString(), dr["RelationshipNameID"].ToString())); } drpRelationship.Enabled = true; } else { drpRelationship.Items.Add(new ListItem(GetString("General.NoneAvailable"), "")); drpRelationship.Enabled = false; } } }
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() }); }