Exemple #1
0
    /// <summary>
    /// Gets and updates document alias. Called when the "Get and update alias" button is pressed.
    /// Expects the CreateDocumentAlias method to be run first.
    /// </summary>
    private bool GetAndUpdateDocumentAlias()
    {
        // Prepare the parameters
        string orderBy = "";

        string where = "AliasURLPath = N'/MyNewAlias'";

        // Get the data
        DataSet aliases = DocumentAliasInfoProvider.GetDocumentAliases(where, orderBy);

        if (!DataHelper.DataSourceIsEmpty(aliases))
        {
            DocumentAliasInfo updateAlias = new DocumentAliasInfo(aliases.Tables[0].Rows[0]);

            // Update the properties
            updateAlias.AliasURLPath = updateAlias.AliasURLPath.ToLower();

            // Save the changes
            DocumentAliasInfoProvider.SetDocumentAliasInfo(updateAlias, CMSContext.CurrentSiteName);

            return(true);
        }

        return(false);
    }
Exemple #2
0
    /// <summary>
    /// Gets and bulk updates document aliases. Called when the "Get and bulk update aliases" button is pressed.
    /// Expects the CreateDocumentAlias method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateDocumentAliases()
    {
        // Prepare the parameters
        string orderBy = "";

        string where = "AliasURLPath = N'/MyNewAlias'";

        // Get the data
        DataSet aliases = DocumentAliasInfoProvider.GetDocumentAliases(where, orderBy);

        if (!DataHelper.DataSourceIsEmpty(aliases))
        {
            // Loop through the individual items
            foreach (DataRow aliasDr in aliases.Tables[0].Rows)
            {
                // Create object from DataRow
                DocumentAliasInfo modifyAlias = new DocumentAliasInfo(aliasDr);

                // Update the properties
                modifyAlias.AliasURLPath = modifyAlias.AliasURLPath.ToUpper();

                // Save the changes
                DocumentAliasInfoProvider.SetDocumentAliasInfo(modifyAlias, CMSContext.CurrentSiteName);
            }

            return(true);
        }

        return(false);
    }
    private void UniGridAlias_OnAction(string actionName, object actionArgument)
    {
        // Manage edit and delete
        int               aliasID = ValidationHelper.GetInteger(actionArgument, 0);
        string            action  = DataHelper.GetNotEmpty(actionName, String.Empty).ToLowerCSafe();
        TreeProvider      tree    = new TreeProvider(MembershipContext.AuthenticatedUser);
        DocumentAliasInfo dai     = DocumentAliasInfoProvider.GetDocumentAliasInfo(aliasID);

        if (dai != null)
        {
            // Find node
            TreeNode node = tree.SelectSingleNode(dai.AliasNodeID);

            if (node != null)
            {
                // Check modify permissions
                if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
                {
                    return;
                }

                // Edit only if node exists
                if (action == "edit")
                {
                    URLHelper.Redirect("Alias_Edit.aspx?nodeid=" + node.NodeID + "&aliasid=" + aliasID + "&defaultNodeID=" + NodeID + "&dialog=1");
                }
            }

            // Delete even if node does not exist
            if (action == "delete")
            {
                if (aliasID > 0)
                {
                    // Delete
                    DocumentAliasInfoProvider.DeleteDocumentAliasInfo(aliasID);

                    // Log synchronization
                    DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);
                }
            }
        }
    }
Exemple #4
0
    /// <summary>
    /// Deletes document alias. Called when the "Delete alias" button is pressed.
    /// Expects the CreateDocumentAlias method to be run first.
    /// </summary>
    private bool DeleteDocumentAlias()
    {
        // Prepare the parameters
        string orderBy = "";

        string where = "AliasURLPath = N'/MyNewAlias'";

        // Get the data
        DataSet aliases = DocumentAliasInfoProvider.GetDocumentAliases(where, orderBy);

        if (!DataHelper.DataSourceIsEmpty(aliases))
        {
            DocumentAliasInfo deleteAlias = new DocumentAliasInfo(aliases.Tables[0].Rows[0]);

            // Delete the document alias
            DocumentAliasInfoProvider.DeleteDocumentAliasInfo(deleteAlias);

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Creates document alias. Called when the "Create alias" button is pressed.
    /// </summary>
    private bool CreateDocumentAlias()
    {
        // Get "Home" document
        TreeNode document = TreeHelper.GetDocument(SiteContext.CurrentSiteName, "/Home", CultureHelper.GetPreferredCulture(), true, "CMS.MenuItem", false);

        if (document != null)
        {
            // Create new document alias object
            DocumentAliasInfo newAlias = new DocumentAliasInfo();

            // Set the properties
            newAlias.AliasURLPath = "/MyNewAlias";
            newAlias.AliasNodeID = document.NodeID;
            newAlias.AliasSiteID = SiteContext.CurrentSiteID;

            // Save the document alias
            DocumentAliasInfoProvider.SetDocumentAliasInfo(newAlias, SiteContext.CurrentSiteName);

            return true;
        }

        return false;
    }
Exemple #6
0
    /// <summary>
    /// Creates document alias. Called when the "Create alias" button is pressed.
    /// </summary>
    private bool CreateDocumentAlias()
    {
        // Get "Home" document
        TreeNode document = TreeHelper.GetDocument(CMSContext.CurrentSiteName, "/Home", CultureHelper.GetPreferredCulture(), true, "CMS.MenuItem", false);

        if (document != null)
        {
            // Create new document alias object
            DocumentAliasInfo newAlias = new DocumentAliasInfo();

            // Set the properties
            newAlias.AliasURLPath = "/MyNewAlias";
            newAlias.AliasNodeID  = document.NodeID;
            newAlias.AliasSiteID  = CMSContext.CurrentSiteID;

            // Save the document alias
            DocumentAliasInfoProvider.SetDocumentAliasInfo(newAlias, CMSContext.CurrentSiteName);

            return(true);
        }

        return(false);
    }
Exemple #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        nodeId = ValidationHelper.GetInteger(Request.QueryString["nodeid"], 0);

        if (nodeId > 0)
        {
            // Get the node
            tree = new TreeProvider(CMSContext.CurrentUser);
            node = tree.SelectSingleNode(nodeId);

            // 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)
                {
                    this.lblInfo.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), node.NodeAliasPath);

                    usSelectCampaign.Enabled = false;
                    txtURLExtensions.Enabled = false;

                    ctrlURL.Enabled = false;

                    cultureSelector.Enabled = false;
                }

                if (QueryHelper.GetInteger("saved", 0) == 1)
                {
                    lblInfo.Text = GetString("general.changessaved");
                }

                lblDocumentCulture.Text = GetString("general.culture") + ResHelper.Colon;
                lblTrackCampaign.Text   = GetString("doc.urls.trackcampaign") + ResHelper.Colon;
                lblURLExtensions.Text   = GetString("doc.urls.urlextensions") + ResHelper.Colon;

                btnOk.Text = GetString("general.ok");

                // Initialiaze page title
                string urls     = GetString("Properties.Urls");
                string urlsUrl  = "~/CMSModules/Content/CMSDesk/Properties/Alias_List.aspx?nodeid=" + nodeId.ToString();
                string addAlias = GetString("doc.urls.addnewalias");

                // Initializes page title
                string[,] pageTitleTabs = new string[2, 3];
                pageTitleTabs[0, 0]     = urls;
                pageTitleTabs[0, 1]     = urlsUrl;
                pageTitleTabs[0, 2]     = "";
                pageTitleTabs[1, 0]     = addAlias;
                pageTitleTabs[1, 1]     = "";
                pageTitleTabs[1, 2]     = "";
                pageAlias.Breadcrumbs   = pageTitleTabs;

                this.cultureSelector.AddDefaultRecord = false;
                this.cultureSelector.SpecialFields    = new string[, ] {
                    { GetString("general.selectall"), "" }
                };
                this.cultureSelector.CssClass = "ContentMenuLangDrop";

                aliasId = ValidationHelper.GetInteger(Request.QueryString["aliasid"], 0);

                pageAlias.HelpName      = "helpTopic";
                pageAlias.HelpTopicName = "doc_documentalias_edit";

                if (!RequestHelper.IsPostBack())
                {
                    this.cultureSelector.Value = node.DocumentCulture;

                    // Edit existing alias
                    if (aliasId > 0)
                    {
                        DocumentAliasInfo dai = DocumentAliasInfoProvider.GetDocumentAliasInfo(aliasId);

                        if (dai != null)
                        {
                            usSelectCampaign.Value = dai.AliasCampaign;

                            txtURLExtensions.Text = dai.AliasExtensions;
                            ctrlURL.URLPath       = dai.AliasURLPath;

                            cultureSelector.Value = dai.AliasCulture;
                            pageTitleTabs[1, 0]   = addAlias = dai.AliasURLPath;
                        }
                    }
                }

                pageAlias.Breadcrumbs = pageTitleTabs;

                // Register js synchronization script for split mode
                if (QueryHelper.GetBoolean("refresh", false) && CMSContext.DisplaySplitMode)
                {
                    RegisterSplitModeSync(true, false, true);
                }
            }
        }
    }
Exemple #8
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(this.ctrlURL.PlainURLPath))
        {
            lblError.Text = GetString("doc.urls.requiresurlpath");
            return;
        }

        if (!usSelectCampaign.IsValid())
        {
            lblError.Visible = true;
            lblError.Text    = GetString("campaign.validcodename");
            return;
        }

        // Get the document
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode);
        if (node != null)
        {
            // Check modify permissions
            if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
            {
                lblInfo.Text  = string.Empty;
                lblError.Text = String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath);
                return;
            }

            DocumentAliasInfo dai = null;

            // Edit existing alias
            if (aliasId > 0)
            {
                dai = DocumentAliasInfoProvider.GetDocumentAliasInfo(aliasId);
            }

            if (dai == null)
            {
                dai = new DocumentAliasInfo();
            }

            // Set object properties
            dai.AliasURLPath = ctrlURL.URLPath;

            dai.AliasCampaign   = ValidationHelper.GetString(usSelectCampaign.Value, String.Empty).Trim();
            dai.AliasExtensions = txtURLExtensions.Text.Trim();
            dai.AliasCulture    = ValidationHelper.GetString(cultureSelector.Value, "");
            dai.AliasSiteID     = CMSContext.CurrentSite.SiteID;

            if (nodeId > 0)
            {
                dai.AliasNodeID = nodeId;
            }

            // Insert into database
            DocumentAliasInfoProvider.SetDocumentAliasInfo(dai, node.NodeSiteName);

            // Log synchronization
            DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);

            nodeId  = dai.AliasNodeID;
            aliasId = dai.AliasID;

            string url = "Alias_Edit.aspx?saved=1&nodeid=" + nodeId.ToString() + "&aliasid=" + aliasId.ToString();

            // Refresh the second frame in split mode
            if (CMSContext.DisplaySplitMode)
            {
                if (string.Compare(CMSContext.PreferredCultureCode, CMSContext.SplitModeCultureCode, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    url += "&refresh=1";
                }
            }

            URLHelper.Redirect(url);
        }
    }
    /// <summary>
    /// Deletes document alias. Called when the "Delete alias" button is pressed.
    /// Expects the CreateDocumentAlias method to be run first.
    /// </summary>
    private bool DeleteDocumentAlias()
    {
        // Prepare the parameters
        string orderBy = "";
        string where = "AliasURLPath = N'/MyNewAlias'";

        // Get the data
        DataSet aliases = DocumentAliasInfoProvider.GetDocumentAliases(where, orderBy);
        if (!DataHelper.DataSourceIsEmpty(aliases))
        {
            DocumentAliasInfo deleteAlias = new DocumentAliasInfo(aliases.Tables[0].Rows[0]);

            // Delete the document alias
            DocumentAliasInfoProvider.DeleteDocumentAliasInfo(deleteAlias);

            return true;
        }

        return false;
    }
    /// <summary>
    /// Gets and updates document alias. Called when the "Get and update alias" button is pressed.
    /// Expects the CreateDocumentAlias method to be run first.
    /// </summary>
    private bool GetAndUpdateDocumentAlias()
    {
        // Prepare the parameters
        string orderBy = "";
        string where = "AliasURLPath = N'/MyNewAlias'";

        // Get the data
        DataSet aliases = DocumentAliasInfoProvider.GetDocumentAliases(where, orderBy);
        if (!DataHelper.DataSourceIsEmpty(aliases))
        {
            DocumentAliasInfo updateAlias = new DocumentAliasInfo(aliases.Tables[0].Rows[0]);

            // Update the properties
            updateAlias.AliasURLPath = updateAlias.AliasURLPath.ToLower();

            // Save the changes
            DocumentAliasInfoProvider.SetDocumentAliasInfo(updateAlias, SiteContext.CurrentSiteName);

            return true;
        }

        return false;
    }
    /// <summary>
    /// Gets and bulk updates document aliases. Called when the "Get and bulk update aliases" button is pressed.
    /// Expects the CreateDocumentAlias method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateDocumentAliases()
    {
        // Prepare the parameters
        string orderBy = "";
        string where = "AliasURLPath = N'/MyNewAlias'";

        // Get the data
        DataSet aliases = DocumentAliasInfoProvider.GetDocumentAliases(where, orderBy);
        if (!DataHelper.DataSourceIsEmpty(aliases))
        {
            // Loop through the individual items
            foreach (DataRow aliasDr in aliases.Tables[0].Rows)
            {
                // Create object from DataRow
                DocumentAliasInfo modifyAlias = new DocumentAliasInfo(aliasDr);

                // Update the properties
                modifyAlias.AliasURLPath = modifyAlias.AliasURLPath.ToUpper();

                // Save the changes
                DocumentAliasInfoProvider.SetDocumentAliasInfo(modifyAlias, SiteContext.CurrentSiteName);
            }

            return true;
        }

        return false;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterDialogScript(Page);

        if (isManagement)
        {
            CurrentMaster.PanelFooter.CssClass = "FloatRight";

            CurrentMaster.Title.TitleText  = GetString("doc.urls.aliaslist");
            CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Menu/New.png");

            // Add close button
            CurrentMaster.PanelFooter.Controls.Add(new LocalizedButton
            {
                ID              = "btnCancel",
                ResourceString  = "general.close",
                EnableViewState = false,
                OnClientClick   = "return CloseDialog();",
                CssClass        = "SubmitButton"
            });
        }
        else
        {
            HeaderActions.AddAction(new HeaderAction()
            {
                ImageUrl    = GetImageUrl("CMSModules/CMS_Content/Properties/adddocumentalias.png"),
                Text        = GetString("doc.urls.addnewalias"),
                RedirectUrl = ResolveUrl("Alias_Edit.aspx?nodeid=" + NodeID),
            });

            rightHeaderActions.AddAction(new HeaderAction()
            {
                ImageUrl      = GetImageUrl("CMSModules/CMS_Content/Properties/documentaliases.png"),
                Text          = GetString("doc.urls.viewallalias"),
                OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/Content/CMSDesk/Properties/Alias_AliasList.aspx") + "?nodeid=" + NodeID + "','AliasManagement','90%','85%');",
            });
        }

        if (Node != null)
        {
            lblUrlInfoText.Text = Node.NodeAliasPath;

            // Check modify permissions
            if (!CheckDocumentPermissions(Node, PermissionsEnum.Modify))
            {
                ShowInformation(String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), Node.NodeAliasPath));

                usSelectCampaign.Enabled = false;
                txtURLExtensions.Enabled = false;

                ctrlURL.Enabled = false;

                cultureSelector.Enabled = false;
            }

            if (!RequestHelper.IsPostBack() && QueryHelper.GetInteger("saved", 0) == 1)
            {
                ShowChangesSaved();
            }

            lblDocumentCulture.Text = GetString("general.culture") + ResHelper.Colon;
            lblTrackCampaign.Text   = GetString("doc.urls.trackcampaign") + ResHelper.Colon;
            lblURLExtensions.Text   = GetString("doc.urls.urlextensions") + ResHelper.Colon;

            // Show path of document alias only if management mode edit
            pnlUrlInfo.Visible = isManagement;

            // For management mode use DefaultNodeID
            defaultNodeID = (isManagement) ? QueryHelper.GetInteger("defaultNodeID", 0) : NodeID;

            // Initialize page title
            string urls            = GetString("Properties.Urls");
            string urlsUrl         = string.Format("~/CMSModules/Content/CMSDesk/Properties/Alias_List.aspx?nodeid={0}&compare=1", defaultNodeID.ToString());
            string addAlias        = GetString("doc.urls.addnewalias");
            string aliasManagement = GetString("doc.urls.aliaslist");
            string managementUrl   = "~/CMSModules/Content/CMSDesk/Properties/Alias_AliasList.aspx?nodeid=" + defaultNodeID.ToString();

            string[,] pageTitleTabs = null;

            pageTitleTabs = new string[2, 3];
            // Initializes page title
            pageTitleTabs[0, 0]             = isManagement ? aliasManagement : urls;
            pageTitleTabs[0, 1]             = ResolveUrl(isManagement ? managementUrl : urlsUrl);
            pageTitleTabs[0, 2]             = "";
            pageTitleTabs[1, 0]             = addAlias;
            pageTitleTabs[1, 1]             = "";
            pageTitleTabs[1, 2]             = "";
            CurrentMaster.Title.Breadcrumbs = pageTitleTabs;

            cultureSelector.AddDefaultRecord = false;
            cultureSelector.SpecialFields    = new string[, ] {
                { GetString("general.selectall"), "" }
            };
            cultureSelector.CssClass = "ContentMenuLangDrop";

            aliasId = ValidationHelper.GetInteger(Request.QueryString["aliasid"], 0);

            CurrentMaster.Title.HelpName      = "helpTopic";
            CurrentMaster.Title.HelpTopicName = "doc_documentalias_edit";

            if (!RequestHelper.IsPostBack())
            {
                cultureSelector.Value = Node.DocumentCulture;

                // Edit existing alias
                if (aliasId > 0)
                {
                    DocumentAliasInfo dai = DocumentAliasInfoProvider.GetDocumentAliasInfo(aliasId);

                    if (dai != null)
                    {
                        usSelectCampaign.Value = dai.AliasCampaign;

                        txtURLExtensions.Text = dai.AliasExtensions;
                        ctrlURL.URLPath       = dai.AliasURLPath;

                        cultureSelector.Value = dai.AliasCulture;
                        pageTitleTabs[1, 0]   = addAlias = TreePathUtils.GetURLPathDisplayName(dai.AliasURLPath);

                        drpAction.SelectedValue = DocumentAliasInfoProvider.AliasActionModeEnumString(dai.AliasActionMode);
                    }
                }
            }

            CurrentMaster.Title.Breadcrumbs = pageTitleTabs;

            // Register js synchronization script for split mode
            if (QueryHelper.GetBoolean("refresh", false) && CMSContext.DisplaySplitMode)
            {
                RegisterSplitModeSync(true, false, true);
            }
        }
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(ctrlURL.PlainURLPath))
        {
            ShowError(GetString("doc.urls.requiresurlpath"));
            return;
        }

        if (!usSelectCampaign.IsValid())
        {
            ShowError(GetString("campaign.validcodename"));
            return;
        }

        // Validate URL path
        if (!ctrlURL.IsValid())
        {
            ShowError(ctrlURL.ValidationError);
            return;
        }

        DocumentAliasInfo dai = null;

        // Edit existing alias
        if (aliasId > 0)
        {
            dai = DocumentAliasInfoProvider.GetDocumentAliasInfo(aliasId);
        }

        if (Node != null)
        {
            // Check modify permissions
            if (!CheckDocumentPermissions(Node, PermissionsEnum.Modify))
            {
                ShowError(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), Node.NodeAliasPath));
                return;
            }

            if (dai == null)
            {
                dai = new DocumentAliasInfo();
            }

            // Check whether
            if (!DocumentAliasInfoProvider.IsUnique(ctrlURL.URLPath, dai.AliasID, Convert.ToString(cultureSelector.Value), txtURLExtensions.Text.Trim(), CMSContext.CurrentSiteName, true))
            {
                ShowError(GetString("doc.urls.doacaliasnotunique"));
                return;
            }

            // Set object properties
            dai.AliasURLPath = ctrlURL.URLPath;

            dai.AliasCampaign   = ValidationHelper.GetString(usSelectCampaign.Value, String.Empty).Trim();
            dai.AliasExtensions = txtURLExtensions.Text.Trim();
            dai.AliasCulture    = ValidationHelper.GetString(cultureSelector.Value, "");
            dai.AliasSiteID     = CMSContext.CurrentSite.SiteID;
            dai.AliasActionMode = DocumentAliasInfoProvider.GetAliasActionModeEnum(drpAction.SelectedValue);
            dai.AliasNodeID     = NodeID;

            // Insert into database
            DocumentAliasInfoProvider.SetDocumentAliasInfo(dai, Node.NodeSiteName);

            // Log synchronization
            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, Tree);

            aliasId = dai.AliasID;

            string url = "Alias_Edit.aspx?saved=1&nodeid=" + NodeID + "&aliasid=" + aliasId.ToString() + "&management=" + isManagement;
            if (isManagement)
            {
                url += "&defaultNodeID=" + defaultNodeID;
            }

            // Refresh the second frame in split mode
            if (CMSContext.DisplaySplitMode)
            {
                url += "&refresh=1";
            }

            URLHelper.Redirect(url);
        }
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(ctrlURL.PlainURLPath))
        {
            ShowError(GetString("doc.urls.requiresurlpath"));
            return;
        }

        if (!usSelectCampaign.IsValid())
        {
            ShowError(GetString("campaign.validcodename"));
            return;
        }

        // Validate URL path
        if (!ctrlURL.IsValid())
        {
            ShowError(ctrlURL.ValidationError);
            return;
        }

        DocumentAliasInfo dai = null;

        // Edit existing alias
        if (aliasId > 0)
        {
            dai = DocumentAliasInfoProvider.GetDocumentAliasInfo(aliasId);
        }

        if (Node != null)
        {
            // Check modify permissions
            if (!CheckDocumentPermissions(Node, PermissionsEnum.Modify))
            {
                ShowError(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), Node.NodeAliasPath));
                return;
            }

            if (dai == null)
            {
                dai = new DocumentAliasInfo();
            }

            // Check whether
            if (!DocumentAliasInfoProvider.IsUnique(ctrlURL.URLPath, dai.AliasID, Convert.ToString(cultureSelector.Value), txtURLExtensions.Text.Trim(), CMSContext.CurrentSiteName, true))
            {
                ShowError(GetString("doc.urls.doacaliasnotunique"));
                return;
            }

            // Set object properties
            dai.AliasURLPath = ctrlURL.URLPath;

            dai.AliasCampaign = ValidationHelper.GetString(usSelectCampaign.Value, String.Empty).Trim();
            dai.AliasExtensions = txtURLExtensions.Text.Trim();
            dai.AliasCulture = ValidationHelper.GetString(cultureSelector.Value, "");
            dai.AliasSiteID = CMSContext.CurrentSite.SiteID;
            dai.AliasActionMode = DocumentAliasInfoProvider.GetAliasActionModeEnum(drpAction.SelectedValue);
            dai.AliasNodeID = NodeID;

            // Insert into database
            DocumentAliasInfoProvider.SetDocumentAliasInfo(dai, Node.NodeSiteName);

            // Log synchronization
            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, Tree);

            aliasId = dai.AliasID;

            string url = "Alias_Edit.aspx?saved=1&nodeid=" + NodeID + "&aliasid=" + aliasId.ToString() + "&management=" + isManagement;
            if (isManagement)
            {
                url += "&defaultNodeID=" + defaultNodeID;
            }

            // Refresh the second frame in split mode
            if (CMSContext.DisplaySplitMode)
            {
                url += "&refresh=1";
            }

            URLHelper.Redirect(url);
        }
    }
Exemple #15
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(this.ctrlURL.PlainURLPath))
        {
            lblError.Text = GetString("doc.urls.requiresurlpath");
            return;
        }

        if (!usSelectCampaign.IsValid())
        {
            lblError.Visible = true;
            lblError.Text = GetString("campaign.validcodename");
            return;
        }

        // Get the document
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
        node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode);
        if (node != null)
        {
            // Check modify permissions
            if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
            {
                lblInfo.Text = string.Empty;
                lblError.Text = String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath);
                return;
            }

            DocumentAliasInfo dai = null;

            // Edit existing alias
            if (aliasId > 0)
            {
                dai = DocumentAliasInfoProvider.GetDocumentAliasInfo(aliasId);
            }

            if (dai == null)
            {
                dai = new DocumentAliasInfo();
            }

            // Set object properties
            dai.AliasURLPath = ctrlURL.URLPath;

            dai.AliasCampaign = ValidationHelper.GetString(usSelectCampaign.Value, String.Empty).Trim();
            dai.AliasExtensions = txtURLExtensions.Text.Trim();
            dai.AliasCulture = ValidationHelper.GetString(cultureSelector.Value, "");
            dai.AliasSiteID = CMSContext.CurrentSite.SiteID;

            if (nodeId > 0)
            {
                dai.AliasNodeID = nodeId;
            }

            // Insert into database
            DocumentAliasInfoProvider.SetDocumentAliasInfo(dai, node.NodeSiteName);

            // Log synchronization
            DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);

            nodeId = dai.AliasNodeID;
            aliasId = dai.AliasID;

            string url = "Alias_Edit.aspx?saved=1&nodeid=" + nodeId.ToString() + "&aliasid=" + aliasId.ToString();

            // Refresh the second frame in split mode
            if (CMSContext.DisplaySplitMode)
            {
                if (string.Compare(CMSContext.PreferredCultureCode, CMSContext.SplitModeCultureCode, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    url += "&refresh=1";
                }
            }

            URLHelper.Redirect(url);
        }
    }