Ejemplo n.º 1
0
    private void ReloadData()
    {
        if (node != null)
        {
            bool isRoot = (node.NodeAliasPath == "/");

            // 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)
            {
                hasModifyPermission     = false;
                pnlForm.Enabled         = false;
                tagSelectorElem.Enabled = false;
            }

            TreeNode tmpNode = node.Clone();

            // If values are inherited set nulls
            tmpNode.SetValue("DocumentPageTitle", DBNull.Value);
            tmpNode.SetValue("DocumentPageKeyWords", DBNull.Value);
            tmpNode.SetValue("DocumentPageDescription", DBNull.Value);
            tmpNode.SetValue("DocumentTagGroupID", DBNull.Value);

            // Load the inherited values
            SiteInfo si = SiteInfoProvider.GetSiteInfo(node.NodeSiteID);
            if (si != null)
            {
                tmpNode.LoadInheritedValues(new string[] { "DocumentPageTitle", "DocumentPageKeyWords", "DocumentPageDescription", "DocumentTagGroupID" }, SiteInfoProvider.CombineWithDefaultCulture(si.SiteName));
            }

            if (!pnlUIPage.IsHidden)
            {
                // Page title
                if (node.GetValue("DocumentPageTitle") != null)
                {
                    txtTitle.Text = node.GetValue("DocumentPageTitle").ToString();
                }
                else
                {
                    if (!isRoot)
                    {
                        txtTitle.Enabled = false;
                        chkTitle.Checked = true;
                        txtTitle.Text    = ValidationHelper.GetString(tmpNode.GetValue("DocumentPageTitle"), "");
                    }
                }

                // Page key words
                if (node.GetValue("DocumentPageKeyWords") != null)
                {
                    txtKeywords.Text = node.GetValue("DocumentPageKeyWords").ToString();
                }
                else
                {
                    if (!isRoot)
                    {
                        txtKeywords.Enabled = false;
                        chkKeyWords.Checked = true;
                        txtKeywords.Text    = ValidationHelper.GetString(tmpNode.GetValue("DocumentPageKeyWords"), "");
                    }
                }

                // Page description
                if (node.GetValue("DocumentPageDescription") != null)
                {
                    txtDescription.Text = node.GetValue("DocumentPageDescription").ToString();
                }
                else
                {
                    if (!isRoot)
                    {
                        txtDescription.Enabled = false;
                        chkDescription.Checked = true;
                        txtDescription.Text    = ValidationHelper.GetString(tmpNode.GetValue("DocumentPageDescription"), "");
                    }
                }
            }

            if (!pnlUITags.IsHidden)
            {
                // Tag group
                if (node.GetValue("DocumentTagGroupID") != null)
                {
                    object tagGroupId = node.GetValue("DocumentTagGroupID");
                    tagGroupSelectorElem.Value = tagGroupId;
                }
                else
                {
                    if (!isRoot)
                    {
                        // Get the inherited tag group
                        int tagGroup = ValidationHelper.GetInteger(tmpNode.GetValue("DocumentTagGroupID"), 0);
                        if (tagGroup > 0)
                        {
                            tagGroupSelectorElem.Value = tagGroup;
                        }
                        else
                        {
                            tagGroupSelectorElem.AddNoneItemsRecord = true;
                        }
                        tagGroupSelectorElem.Enabled = false;
                        chkTagGroupSelector.Checked  = true;
                    }
                    else
                    {
                        // Add 'none' option to Root document
                        tagGroupSelectorElem.AddNoneItemsRecord = true;
                    }
                }

                // Tags
                tagSelectorElem.Value = node.DocumentTags;
            }
        }
    }