示例#1
0
    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()
        });
    }