示例#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);
    }
示例#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);
    }
示例#3
0
        private void Document_Update_After(object sender, DocumentEventArgs e)
        {
            if (e.Node.ClassName.Equals("PbcLinear.Product"))
            {
                TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
                var          relatedProductCategories = tree.SelectNodes(SiteContext.CurrentSiteName, "/Products/%",
                                                                         e.Node.DocumentCulture,
                                                                         false, "PbcLinear.ProductSubCategory", string.Empty, "NodeOrder", -1, true, e.Node.NodeGUID,
                                                                         ProductCategoryRelationshipName,
                                                                         true).ToList();

                DocumentAliasInfoProvider.DeleteNodeAliases(e.Node.NodeID);
                foreach (var category in relatedProductCategories)
                {
                    DocumentAliasInfoProvider.SetDocumentAliasInfo(new DocumentAliasInfo
                    {
                        AliasNodeID     = e.Node.NodeID,
                        AliasURLPath    = TreePathUtils.GetSafeNodeAliasPath(string.Format("{0}/{1}", category.NodeAliasPath, e.Node.DocumentName), "PbcLinear"),
                        AliasSiteID     = SiteContext.CurrentSiteID,
                        AliasCulture    = "",
                        AliasExtensions = ""
                    }, SiteContext.CurrentSiteName);
                }
            }
        }
示例#4
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);
    }
示例#5
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);
        }
    }
    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;
        }

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

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

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

            DocumentAlias.AliasCampaign   = ValidationHelper.GetString(usSelectCampaign.Value, String.Empty).Trim();
            DocumentAlias.AliasExtensions = txtURLExtensions.Text.Trim();
            DocumentAlias.AliasCulture    = ValidationHelper.GetString(cultureSelector.Value, "");
            DocumentAlias.AliasSiteID     = SiteContext.CurrentSite.SiteID;
            DocumentAlias.AliasActionMode = drpAction.SelectedValue.ToEnum <AliasActionModeEnum>();
            DocumentAlias.AliasNodeID     = NodeID;

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

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

            aliasId = DocumentAlias.AliasID;

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

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