/// <summary>
    /// Shows info message to prompt the user to select the winning A/B variant after the A/B test has finished.
    /// </summary>
    private void ShowPromoteWinnerInfoMessage()
    {
        if (TestStatus != ABTestStatusEnum.Finished || !UserHasPermissions)
        {
            return;
        }

        string message;

        if (DocumentManager.AllowSave || IsDialog)
        {
            message = GetString("abtesting.finishedtest.promotewinnerpromptmessage");
        }
        else
        {
            string siteName     = SiteInfoProvider.GetSiteName(ABTest.ABTestSiteID);
            int    nodeId       = TreePathUtils.GetNodeIdByAliasPath(siteName, ABTest.ABTestOriginalPage);
            string editPageLink = ApplicationUrlHelper.GetPageEditLink(nodeId, ABTest.ABTestCulture);
            var    link         = URLHelper.GetAbsoluteUrl(editPageLink);

            message = ResHelper.GetStringFormat("abtesting.finishedtest.promotewinnerpromptmessage.warning", link);
        }

        ShowInformation(message);
    }
    /// <summary>
    /// Indicates if there is needed fallback to root document.
    /// </summary>
    /// <param name="selectedNode">Selected node</param>
    private bool UseFallbackToRoot(TreeNode selectedNode)
    {
        if (selectedNode != null)
        {
            bool   useFallback      = false;
            string currentAliasPath = selectedNode.NodeAliasPath;

            // Check user's starting path
            string userStartingPath = CurrentUser.UserStartingAliasPath;
            if (!String.IsNullOrEmpty(userStartingPath))
            {
                useFallback = !currentAliasPath.StartsWith(userStartingPath, StringComparison.InvariantCultureIgnoreCase) &&
                              (TreePathUtils.GetNodeIdByAliasPath(selectedNode.NodeSiteName, userStartingPath) > 0);
            }

            if (IsProductTree)
            {
                // Check products starting path if in Products UI
                string productsStartingPath = SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".CMSStoreProductsStartingPath");
                if (!String.IsNullOrEmpty(productsStartingPath))
                {
                    useFallback |= !currentAliasPath.StartsWith(productsStartingPath, StringComparison.InvariantCultureIgnoreCase) &&
                                   (TreePathUtils.GetNodeIdByAliasPath(selectedNode.NodeSiteName, productsStartingPath) > 0);
                }
            }

            return(useFallback);
        }

        return(true);
    }
    /// <summary>
    /// Returns Correct URL of the 'Set permissions' dialog.
    /// </summary>
    private string GetPermissionsDialogUrl(string nodeAliasPath)
    {
        string url = ResolveUrl("~/CMSModules/Content/FormControls/Documents/ChangePermissions/ChangePermissions.aspx");

        // Use current document path if not set
        if (string.IsNullOrEmpty(nodeAliasPath) && (DocumentContext.CurrentDocument != null))
        {
            nodeAliasPath = DocumentContext.CurrentDocument.NodeAliasPath;
        }
        nodeIdFromPath = TreePathUtils.GetNodeIdByAliasPath(SiteName, MacroResolver.ResolveCurrentPath(nodeAliasPath));
        url            = URLHelper.AddParameterToUrl(url, "nodeid", nodeIdFromPath.ToString());
        url            = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url));
        return(url);
    }
    /// <summary>
    /// Returns true if document is in specified relationship with with selected document.
    /// </summary>
    /// <param name="document">Document to be checked</param>
    /// <param name="side">Relationship side</param>
    /// <param name="relationship">Relationship name</param>
    /// <param name="relatedDocumentPath">Alias path to selected document</param>
    /// <param name="relatedDocumentSite">Selected document site name</param>
    public static bool IsInRelationship(object document, string side, string relationship, string relatedDocumentPath, string relatedDocumentSite)
    {
        TreeNode doc = document as TreeNode;

        if (doc != null)
        {
            int leftNodeID  = 0;
            int rightNodeID = 0;

            // Use site of the checked document when no other is specified
            if (String.IsNullOrEmpty(relatedDocumentSite))
            {
                relatedDocumentSite = doc.NodeSiteName;
            }

            // Prepare left and right document for relationship
            side = side.ToLowerCSafe();
            if (side == "left")
            {
                leftNodeID  = doc.NodeID;
                rightNodeID = TreePathUtils.GetNodeIdByAliasPath(relatedDocumentSite, relatedDocumentPath);
            }
            else if (side == "right")
            {
                leftNodeID  = TreePathUtils.GetNodeIdByAliasPath(relatedDocumentSite, relatedDocumentPath);
                rightNodeID = doc.NodeID;
            }

            // Get relationship ID from relationship name
            RelationshipNameInfo relationshipName = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationship);
            if (relationshipName != null)
            {
                // Check whether relationship between the two documents exists
                return(RelationshipProvider.GetRelationshipInfo(leftNodeID, rightNodeID, relationshipName.RelationshipNameId) != null);
            }
        }

        return(false);
    }
Beispiel #5
0
    /// <summary>
    /// Checks whether node with given node ID is contained in a products tree,
    /// considering the ProductsStartingPath setting.
    /// </summary>
    /// <param name="nodeId">NodeID of a node to be checked on.</param>
    private bool IsAllowedInProductsStartingPath(int nodeId)
    {
        var nodePath = TreePathUtils.GetAliasPathByNodeId(nodeId);
        var nodeSite = TreePathUtils.GetNodeSite(nodeId);

        if (String.IsNullOrEmpty(nodePath))
        {
            return(false);
        }

        if (!String.IsNullOrEmpty(ProductsStartingPath))
        {
            if ((TreePathUtils.GetNodeIdByAliasPath(nodeSite.SiteName, ProductsStartingPath) > 0) &&
                !nodePath.StartsWithCSafe(ProductsStartingPath, true))
            {
                // Products starting path is defined and node on that path exists,
                // but our node is not contained within that path
                return(false);
            }
        }

        return(true);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script files
        ScriptHelper.RegisterCMS(this);
        ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js");

        if (!QueryHelper.ValidateHash("hash"))
        {
            pnlContent.Visible = false;
            ShowError(GetString("dialogs.badhashtext"));
            return;
        }

        // Setup page title text and image
        PageTitle.TitleText = GetString("Content.TranslateTitle");
        EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText);

        if (IsDialog)
        {
            RegisterModalPageScripts();
            RegisterEscScript();

            plcInfo.Visible = false;

            pnlButtons.Visible = false;
        }

        if (!TranslationServiceHelper.IsTranslationAllowed(CurrentSiteName))
        {
            pnlContent.Visible = false;
            ShowError(GetString("translations.translationnotallowed"));
            return;
        }

        // Initialize current user
        currentUser = MembershipContext.AuthenticatedUser;

        // Initialize events
        ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished;
        ctlAsyncLog.OnError    += ctlAsyncLog_OnError;
        ctlAsyncLog.OnCancel   += ctlAsyncLog_OnCancel;

        isSelect = QueryHelper.GetBoolean("select", false);
        if (isSelect)
        {
            pnlDocList.Visible     = false;
            pnlDocSelector.Visible = true;
            translationElem.DisplayMachineServices = false;
        }

        var currentCulture        = LocalizationContext.CurrentCulture.CultureCode;
        var displayTargetLanguage = !IsDialog || isSelect;

        translationElem.DisplayTargetlanguage = displayTargetLanguage;

        // Get target culture(s)
        targetCultures = displayTargetLanguage ? translationElem.TargetLanguages : new HashSet <string>(new[] { QueryHelper.GetString("targetculture", currentCulture) });

        // Set the target settings
        var settings = new TranslationSettings();

        settings.TargetLanguages.AddRange(targetCultures);

        var useCurrentAsDefault = QueryHelper.GetBoolean("currentastargetdefault", false);

        if (!currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && currentUser.UserHasAllowedCultures && !currentUser.IsCultureAllowed(currentCulture, CurrentSiteName))
        {
            // Do not use current culture as default if user has no permissions to edit it
            useCurrentAsDefault = false;
        }

        translationElem.UseCurrentCultureAsDefaultTarget = useCurrentAsDefault;

        // Do not include default culture if it is current one
        string defaultCulture = CultureHelper.GetDefaultCultureCode(CurrentSiteName);

        if (useCurrentAsDefault && !string.Equals(currentCulture, defaultCulture, StringComparison.InvariantCultureIgnoreCase) && !RequestHelper.IsPostBack())
        {
            settings.TargetLanguages.Add(currentCulture);
        }

        translationElem.TranslationSettings = settings;
        allowTranslate = true;

        if (RequestHelper.IsCallback())
        {
            return;
        }

        // If not in select mode, load all the document IDs and check permissions
        // In select mode, documents are checked when the button is clicked
        if (!isSelect)
        {
            DataSet      allDocs = null;
            TreeProvider tree    = new TreeProvider();

            // Current Node ID to translate
            string parentAliasPath = string.Empty;
            if (Parameters != null)
            {
                parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty);
                nodeIdsArr      = ValidationHelper.GetString(Parameters["nodeids"], string.Empty).Trim('|').Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            }

            if (string.IsNullOrEmpty(parentAliasPath))
            {
                if (nodeIdsArr == null)
                {
                    // One document translation is requested
                    string nodeIdQuery = QueryHelper.GetString("nodeid", "");
                    if (nodeIdQuery != "")
                    {
                        // Mode of single node translation
                        pnlList.Visible           = false;
                        chkSkipTranslated.Checked = false;

                        translationElem.NodeID = ValidationHelper.GetInteger(nodeIdQuery, 0);

                        nodeIdsArr = new[] { nodeIdQuery };
                    }
                    else
                    {
                        nodeIdsArr = new string[] { };
                    }
                }

                foreach (string nodeId in nodeIdsArr)
                {
                    int id = ValidationHelper.GetInteger(nodeId, 0);
                    if (id != 0)
                    {
                        nodeIds.Add(id);
                    }
                }
            }
            else
            {
                // Exclude root of the website from multiple translation requested by document listing bulk action
                var where = new WhereCondition(WhereCondition)
                            .WhereNotEquals("ClassName", SystemDocumentTypes.Root);

                allDocs = tree.SelectNodes(CurrentSiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%",
                                           TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where.ToString(true),
                                           "DocumentName", AllLevels ? TreeProvider.ALL_LEVELS : 1, false, 0,
                                           DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath");

                if (!DataHelper.DataSourceIsEmpty(allDocs))
                {
                    foreach (DataTable table in allDocs.Tables)
                    {
                        foreach (DataRow row in table.Rows)
                        {
                            nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0));
                        }
                    }
                }
            }

            if (nodeIds.Count > 0)
            {
                var where = new WhereCondition().WhereIn("NodeID", nodeIds).ToString(true);
                DataSet ds = allDocs ?? tree.SelectNodes(CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", TreeProvider.ALL_LEVELS, false);

                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    string docList = null;

                    cancelNodeId = string.IsNullOrEmpty(parentAliasPath)
                        ? DataHelper.GetIntValue(ds.Tables[0].Rows[0], "NodeParentID")
                        : TreePathUtils.GetNodeIdByAliasPath(CurrentSiteName, parentAliasPath);

                    foreach (DataTable table in ds.Tables)
                    {
                        foreach (DataRow dr in table.Rows)
                        {
                            bool   isLink = (dr["NodeLinkedNodeID"] != DBNull.Value);
                            string name   = (string)dr["DocumentName"];
                            docList += HTMLHelper.HTMLEncode(name);
                            if (isLink)
                            {
                                docList += DocumentUIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
                            }
                            docList          += "<br />";
                            lblDocuments.Text = docList;

                            // Set visibility of checkboxes
                            TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr);

                            if (!TranslationServiceHelper.IsAuthorizedToTranslateDocument(node, currentUser, targetCultures))
                            {
                                allowTranslate = false;

                                plcMessages.AddError(String.Format(GetString("cmsdesk.notauthorizedtotranslatedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)));
                            }
                        }
                    }

                    if (!allowTranslate && !RequestHelper.IsPostBack())
                    {
                        // Hide UI only when security check is performed within first load, if postback used user may loose some setting
                        HideUI();
                    }
                }

                // Display check box for separate submissions for each document if there is more than one document
                translationElem.DisplaySeparateSubmissionOption = (nodeIds.Count > 1);
            }
            else
            {
                // Hide everything
                pnlContent.Visible = false;
            }
        }

        // Register the dialog script
        ScriptHelper.RegisterDialogScript(this);

        ctlAsyncLog.TitleText = GetString("contentrequest.starttranslate");
        // Set visibility of panels
        pnlContent.Visible = true;
        pnlLog.Visible     = false;
    }
Beispiel #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script files
        ScriptHelper.RegisterCMS(this);
        ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js");

        // Set current UI culture
        currentCulture = CultureHelper.PreferredUICultureCode;
        // Initialize current user
        currentUser = MembershipContext.AuthenticatedUser;
        // Initialize current site
        currentSite = SiteContext.CurrentSite;

        // Initialize events
        ctlAsync.OnFinished   += ctlAsync_OnFinished;
        ctlAsync.OnError      += ctlAsync_OnError;
        ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
        ctlAsync.OnCancel     += ctlAsync_OnCancel;

        if (!RequestHelper.IsCallback())
        {
            DataSet      allDocs = null;
            TreeProvider tree    = new TreeProvider(currentUser);
            btnCancel.Text = GetString("general.cancel");

            // Current Node ID to delete
            string parentAliasPath = string.Empty;
            if (Parameters != null)
            {
                parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty);
            }
            if (string.IsNullOrEmpty(parentAliasPath))
            {
                nodeIdsArr = QueryHelper.GetString("nodeid", string.Empty).Trim('|').Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string nodeId in nodeIdsArr)
                {
                    int id = ValidationHelper.GetInteger(nodeId, 0);
                    if (id != 0)
                    {
                        nodeIds.Add(id);
                    }
                }
            }
            else
            {
                string where = "ClassName <> 'CMS.Root'";
                if (!string.IsNullOrEmpty(WhereCondition))
                {
                    where = SqlHelper.AddWhereCondition(where, WhereCondition);
                }
                allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%",
                                           TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where,
                                           "DocumentName", TreeProvider.ALL_LEVELS, false, 0,
                                           TreeProvider.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath,NodeSKUID");

                if (!DataHelper.DataSourceIsEmpty(allDocs))
                {
                    foreach (DataTable table in allDocs.Tables)
                    {
                        foreach (DataRow row in table.Rows)
                        {
                            nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0));
                        }
                    }
                }
            }

            // Setup page title text and image
            PageTitle.TitleText = GetString("Content.DeleteTitle");
            EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText);

            btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;");

            // Register the dialog script
            ScriptHelper.RegisterDialogScript(this);

            titleElemAsync.TitleText = GetString("ContentDelete.DeletingDocuments");
            // Set visibility of panels
            pnlContent.Visible = true;
            pnlLog.Visible     = false;

            bool isMultilingual = CultureSiteInfoProvider.IsSiteMultilingual(currentSite.SiteName);
            if (!isMultilingual)
            {
                // Set all cultures checkbox
                chkAllCultures.Checked = true;
                chkAllCultures.Visible = false;
            }

            if (nodeIds.Count > 0)
            {
                if (nodeIds.Count == 1)
                {
                    // Single document deletion
                    int      nodeId = ValidationHelper.GetInteger(nodeIds[0], 0);
                    TreeNode node   = null;

                    if (string.IsNullOrEmpty(parentAliasPath))
                    {
                        // Get any culture if current not found
                        node = tree.SelectSingleNode(nodeId, CultureCode) ?? tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES);
                    }
                    else
                    {
                        if (allDocs != null)
                        {
                            DataRow dr = allDocs.Tables[0].Rows[0];
                            node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr, tree);
                        }
                    }

                    if (node != null)
                    {
                        bool rootDeleteDisabled = false;

                        if (IsProductsMode)
                        {
                            string startingPath = SettingsKeyInfoProvider.GetStringValue(CurrentSiteName + ".CMSStoreProductsStartingPath");
                            if (node.NodeAliasPath.CompareToCSafe(startingPath) == 0)
                            {
                                string closeLink = "<a href=\"#\"><span style=\"cursor: pointer;\" " +
                                                   "onclick=\"SelectNode(" + node.NodeID + "); return false;\">" + GetString("general.back") +
                                                   "</span></a>";

                                ShowError(string.Format(GetString("com.productsection.deleteroot"), closeLink, ""));
                                pnlDelete.Visible  = false;
                                rootDeleteDisabled = true;
                            }
                        }

                        if (node.IsRoot() && isMultilingual)
                        {
                            // Hide 'Delete all cultures' checkbox
                            chkAllCultures.Visible = false;

                            if (!URLHelper.IsPostback())
                            {
                                // Check if there are any documents in another culture or current culture has some documents
                                pnlDeleteRoot.Visible = IsAnyDocumentInAnotherCulture(node) && (tree.SelectNodesCount(SiteContext.CurrentSiteName, "/%", LocalizationContext.PreferredCultureCode, false, null, null, null, TreeProvider.ALL_LEVELS, false) > 0);

                                if (pnlDeleteRoot.Visible)
                                {
                                    // Insert 'Delete current root' option if current root node is translated to current culture
                                    if (node.DocumentCulture == LocalizationContext.PreferredCultureCode)
                                    {
                                        rblRoot.Items.Add(new ListItem(GetString("rootdeletion.currentroot"), "current"));
                                    }

                                    rblRoot.Items.Add(new ListItem(GetString("rootdeletion.currentculture"), "allculturepages"));
                                    rblRoot.Items.Add(new ListItem(GetString("rootdeletion.allpages"), "allpages"));
                                }
                                else
                                {
                                    rblRoot.Items.Add(new ListItem(GetString("rootdeletion.allpages"), "allpages"));
                                }

                                if (rblRoot.SelectedIndex < 0)
                                {
                                    rblRoot.SelectedIndex = 0;
                                }
                            }
                        }

                        // Display warning for root node
                        if (!rootDeleteDisabled && node.IsRoot())
                        {
                            if (!currentUser.IsGlobalAdministrator)
                            {
                                pnlDelete.Visible = false;

                                ShowInformation(GetString("delete.rootonlyglobaladmin"));
                            }
                            else
                            {
                                if ((rblRoot.SelectedValue == "allpages") || !isMultilingual || ((rblRoot.SelectedValue == "allculturepages") && !IsAnyDocumentInAnotherCulture(node)))
                                {
                                    messagesPlaceholder.ShowWarning(GetString("Delete.RootWarning"));

                                    plcDeleteRoot.Visible = true;
                                }
                                else
                                {
                                    plcDeleteRoot.Visible = false;
                                }
                            }
                        }

                        hasChildren = node.NodeHasChildren;

                        bool authorizedToDeleteSKU = !node.HasSKU || IsUserAuthorizedToModifySKU(node);
                        if (!RequestHelper.IsPostBack())
                        {
                            bool authorizedToDeleteDocument = IsUserAuthorizedToDeleteDocument(node);
                            if (!authorizedToDeleteDocument || !authorizedToDeleteSKU)
                            {
                                pnlDelete.Visible = false;
                                RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)));
                            }
                        }

                        if (node.IsLink)
                        {
                            PageTitle.TitleText    = GetString("Content.DeleteTitleLink") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(node.GetDocumentName())) + "\"";
                            headQuestion.Text      = GetString("ContentDelete.QuestionLink");
                            chkAllCultures.Checked = true;
                            plcCheck.Visible       = false;
                        }
                        else
                        {
                            string nodeName = HTMLHelper.HTMLEncode(node.GetDocumentName());
                            // Get name for root document
                            if (node.NodeClassName.ToLowerCSafe() == "cms.root")
                            {
                                nodeName = HTMLHelper.HTMLEncode(currentSite.DisplayName);
                            }
                            PageTitle.TitleText = GetString("Content.DeleteTitle") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(nodeName)) + "\"";

                            bool showSKUGroup = false;
                            if (NodeHasChildWithProduct(tree, node))
                            {
                                // Deleting product section
                                lblSKUActionInfo.Text = GetString("ContentDelete.SectionAssignedSKUInfo");
                                headDeleteSKU.Text    = GetString("ContentDelete.AssignedSKUs");

                                showSKUGroup = true;
                            }
                            else if (node.HasSKU && authorizedToDeleteSKU)
                            {
                                // Deleting product
                                if (!NodeSharesSKUWithOtherNode(tree, node))
                                {
                                    lblSKUActionInfo.Text = GetString("contentdelete.assignedskuinfo");
                                    headDeleteSKU.Text    = GetString("ContentDelete.AssignedSKU");

                                    showSKUGroup = true;
                                }
                            }

                            pnlDeleteSKU.Visible = showSKUGroup;
                            rblSKUAction.Visible = showSKUGroup;
                        }

                        // Show or hide checkbox
                        chkDestroy.Visible = CanDestroy(node);

                        cancelNodeId = IsMultipleAction ? node.NodeParentID : node.NodeID;

                        if (node.IsRoot())
                        {
                            // Change SEO panel if root is selected
                            pnlSeo.Visible = false;
                        }
                    }
                    else
                    {
                        if (!RequestHelper.IsPostBack())
                        {
                            URLHelper.Redirect(UIHelper.GetInformationUrl("editeddocument.notexists"));
                        }
                        else
                        {
                            // Hide everything
                            pnlContent.Visible = false;
                        }
                    }

                    headQuestion.Text       = GetString("ContentDelete.Question");
                    chkAllCultures.Text     = GetString("ContentDelete.AllCultures");
                    chkDestroy.Text         = GetString("ContentDelete.Destroy");
                    headDeleteDocument.Text = GetString("ContentDelete.Document");
                }
                else if (nodeIds.Count > 1)
                {
                    pnlDocList.Visible = true;
                    string where       = "NodeID IN (";
                    foreach (int nodeID in nodeIds)
                    {
                        where += nodeID + ",";
                    }

                    where = where.TrimEnd(',') + ")";
                    DataSet ds = allDocs ?? tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", -1, false);

                    if (!DataHelper.DataSourceIsEmpty(ds))
                    {
                        string docList = null;

                        if (string.IsNullOrEmpty(parentAliasPath))
                        {
                            cancelNodeId = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0);
                        }
                        else
                        {
                            cancelNodeId = TreePathUtils.GetNodeIdByAliasPath(currentSite.SiteName, parentAliasPath);
                        }

                        bool canDestroy  = true;
                        bool permissions = true;

                        foreach (DataTable table in ds.Tables)
                        {
                            foreach (DataRow dr in table.Rows)
                            {
                                bool   isLink = (dr["NodeLinkedNodeID"] != DBNull.Value);
                                string name   = (string)dr["DocumentName"];
                                docList += HTMLHelper.HTMLEncode(name);
                                if (isLink)
                                {
                                    docList += DocumentHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
                                }
                                docList          += "<br />";
                                lblDocuments.Text = docList;

                                // Set visibility of checkboxes
                                TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr);

                                if (!IsUserAuthorizedToDeleteDocument(node))
                                {
                                    permissions = false;
                                    AddError(String.Format(
                                                 GetString("cmsdesk.notauthorizedtodeletedocument"),
                                                 HTMLHelper.HTMLEncode(node.NodeAliasPath)), null);
                                }

                                // Can destroy if "can destroy all previous AND current"
                                canDestroy = CanDestroy(node) && canDestroy;

                                if (!hasChildren)
                                {
                                    hasChildren = node.NodeHasChildren;
                                }

                                if ((node.HasSKU && IsUserAuthorizedToModifySKU(node)) || NodeHasChildWithProduct(tree, node))
                                {
                                    pnlDeleteSKU.Visible = true;
                                    rblSKUAction.Visible = true;
                                }
                            }
                        }

                        pnlDelete.Visible  = permissions;
                        chkDestroy.Visible = canDestroy;
                    }
                    else
                    {
                        if (!RequestHelper.IsPostBack())
                        {
                            URLHelper.Redirect(UIHelper.GetInformationUrl("editeddocument.notexists"));
                        }
                        else
                        {
                            // Hide everything
                            pnlContent.Visible = false;
                        }
                    }

                    headQuestion.Text       = GetString("ContentDelete.QuestionMultiple");
                    PageTitle.TitleText     = GetString("Content.DeleteTitleMultiple");
                    chkAllCultures.Text     = GetString("ContentDelete.AllCulturesMultiple");
                    chkDestroy.Text         = GetString("ContentDelete.DestroyMultiple");
                    headDeleteDocument.Text = GetString("global.pages");
                    headDeleteSKU.Text      = GetString("ContentDelete.AssignedSKUs");
                    lblSKUActionInfo.Text   = GetString("ContentDelete.AssignedSKUsInfo");
                }

                // Init product actions
                if (!RequestHelper.IsPostBack())
                {
                    rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.deleteordisable"), "deleteordisable"));
                    rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.delete"), "delete"));
                    rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.disable"), "disable"));
                    rblSKUAction.Items.Add(new ListItem(GetString("ContentDelete.SKU.noaction"), "noaction"));

                    rblSKUAction.SelectedValue = "deleteordisable";
                }

                lblAltPath.AssociatedControlClientID = selAltPath.PathTextBox.ClientID;

                chkUseDeletedPath.CheckedChanged += chkUseDeletedPath_CheckedChanged;
                if (!RequestHelper.IsPostBack())
                {
                    selAltPath.Enabled     = false;
                    chkAltSubNodes.Enabled = false;
                    chkAltAliases.Enabled  = false;

                    // Set default path if is defined
                    selAltPath.Value = SettingsKeyInfoProvider.GetStringValue(CurrentSiteName + ".CMSDefaultDeletedNodePath");

                    if (!hasChildren)
                    {
                        chkAltSubNodes.Checked = false;
                        chkAltSubNodes.Enabled = false;
                    }
                }

                // If user has allowed cultures specified
                if (currentUser.UserHasAllowedCultures)
                {
                    // Get all site cultures
                    DataSet siteCultures            = CultureSiteInfoProvider.GetSiteCultures(currentSite.SiteName);
                    bool    denyAllCulturesDeletion = false;
                    // Check that user can edit all site cultures
                    foreach (DataRow culture in siteCultures.Tables[0].Rows)
                    {
                        string cultureCode = ValidationHelper.GetString(DataHelper.GetDataRowValue(culture, "CultureCode"), string.Empty);
                        if (!currentUser.IsCultureAllowed(cultureCode, currentSite.SiteName))
                        {
                            denyAllCulturesDeletion = true;
                        }
                    }
                    // If user can't edit all site cultures
                    if (denyAllCulturesDeletion)
                    {
                        // Hide all cultures selector
                        chkAllCultures.Visible = false;
                        chkAllCultures.Checked = false;
                    }
                }
                pnlDeleteDocument.Visible = chkAllCultures.Visible || chkDestroy.Visible;
            }
            else
            {
                // Hide everything
                pnlContent.Visible = false;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script files
        ScriptHelper.RegisterCMS(this);
        ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js");

        if (QueryHelper.ValidateHash("hash"))
        {
            // This is only to make sure that WebApplicationPhysicalPath is loaded when Async translation is started
            string appPath = URLHelper.WebApplicationPhysicalPath;

            // Set current UI culture
            currentCulture = CultureHelper.PreferredUICulture;
            // Initialize current user
            currentUser = CMSContext.CurrentUser;
            // Initialize current site
            currentSite = CMSContext.CurrentSite;

            if (!TranslationServiceHelper.IsTranslationAllowed(CurrentSiteName))
            {
                pnlContent.Visible = false;
                ShowError(GetString("translations.translationnotallowed"));
                return;
            }

            // Initialize events
            ctlAsync.OnFinished   += ctlAsync_OnFinished;
            ctlAsync.OnError      += ctlAsync_OnError;
            ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
            ctlAsync.OnCancel     += ctlAsync_OnCancel;

            targetCulture = QueryHelper.GetString("targetculture", CMSContext.PreferredCultureCode);
            isSelect      = QueryHelper.GetBoolean("select", false);

            if (isModal)
            {
                RegisterModalPageScripts();
                RegisterEscScript();

                plcInfo.Visible = false;

                pnlAsyncBody.CssClass       = "DialogPageBody";
                pnlTitleAsync.CssClass      = "DialogsPageHeader";
                pnlContent.CssClass         = "PageContent";
                pnlServiceSelector.CssClass = "TranslationSelectorBox";
                pnlButtons.CssClass         = "FloatRight PageFooterLine";
            }

            if (isSelect)
            {
                pnlDocList.Visible     = false;
                pnlDocSelector.Visible = true;
                translationElem.DisplayMachineServices = false;
                translationElem.DisplayTargetlanguage  = true;
            }

            if (!RequestHelper.IsCallback())
            {
                // If not in select mode, load all the document IDs and check permissions
                // In select mode, documents are checked when the button is clicked
                if (!isSelect)
                {
                    DataSet      allDocs = null;
                    TreeProvider tree    = new TreeProvider(currentUser);

                    // Current Node ID to translate
                    string parentAliasPath = string.Empty;
                    if (Parameters != null)
                    {
                        parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty);
                        nodeIdsArr      = ValidationHelper.GetString(Parameters["nodeids"], string.Empty).Trim('|').Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    }
                    if (string.IsNullOrEmpty(parentAliasPath))
                    {
                        if (nodeIdsArr == null)
                        {
                            string nodeIdQuery = QueryHelper.GetString("nodeid", "");
                            if (nodeIdQuery != "")
                            {
                                // Mode of single node translation
                                pnlList.Visible           = false;
                                chkSkipTranslated.Checked = false;

                                translationElem.NodeID = ValidationHelper.GetInteger(nodeIdQuery, 0);

                                nodeIdsArr = new string[] { nodeIdQuery };
                            }
                            else
                            {
                                nodeIdsArr = new string[] { };
                            }
                        }

                        foreach (string nodeId in nodeIdsArr)
                        {
                            int id = ValidationHelper.GetInteger(nodeId, 0);
                            if (id != 0)
                            {
                                nodeIds.Add(id);
                            }
                        }
                    }
                    else
                    {
                        string where = WhereCondition;
                        allDocs      = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new char[] { '/' }) + "/%",
                                                        TreeProvider.ALL_CULTURES, true, TreeProvider.ALL_CLASSNAMES, where,
                                                        "DocumentName", TreeProvider.ALL_LEVELS, false, 0,
                                                        TreeProvider.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath");

                        if (!DataHelper.DataSourceIsEmpty(allDocs))
                        {
                            foreach (DataTable table in allDocs.Tables)
                            {
                                foreach (DataRow row in table.Rows)
                                {
                                    nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0));
                                }
                            }
                        }
                    }

                    if (nodeIds.Count > 0)
                    {
                        // Set the target settings
                        translationElem.TranslationSettings = new TranslationSettings()
                        {
                            TargetLanguage = targetCulture
                        };

                        string where = "NodeID IN (";
                        foreach (int nodeID in nodeIds)
                        {
                            where += nodeID + ",";
                        }

                        where = where.TrimEnd(',') + ")";
                        DataSet ds = allDocs ?? tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", -1, false);

                        if (!DataHelper.DataSourceIsEmpty(ds))
                        {
                            TreeNode node    = null;
                            string   docList = null;

                            if (string.IsNullOrEmpty(parentAliasPath))
                            {
                                cancelNodeId = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0);
                            }
                            else
                            {
                                cancelNodeId = TreePathUtils.GetNodeIdByAliasPath(currentSite.SiteName, parentAliasPath);
                            }

                            foreach (DataTable table in ds.Tables)
                            {
                                foreach (DataRow dr in table.Rows)
                                {
                                    bool   isLink = (dr["NodeLinkedNodeID"] != DBNull.Value);
                                    string name   = (string)dr["DocumentName"];
                                    docList += HTMLHelper.HTMLEncode(name);
                                    if (isLink)
                                    {
                                        docList += UIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
                                    }
                                    docList          += "<br />";
                                    lblDocuments.Text = docList;

                                    // Set visibility of checkboxes
                                    node = TreeNode.New(dr, ValidationHelper.GetString(dr["ClassName"], string.Empty));

                                    if (!IsUserAuthorizedToTranslateDocument(node, currentSite.SiteName))
                                    {
                                        HideUI();
                                        plcMessages.AddError(String.Format(GetString("cmsdesk.notauthorizedtotranslatedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)), null);
                                    }
                                }
                            }
                        }

                        // Display check box for separate submissions for each document if there is more than one document
                        chkSeparateSubmissions.Visible = (nodeIds.Count > 1);
                    }
                    else
                    {
                        // Hide everything
                        pnlContent.Visible = false;
                    }
                }

                // Setup page title text and image
                CurrentMaster.Title.TitleText  = GetString("Content.TranslateTitle");
                CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/translate.png");

                if (isSelect)
                {
                    CurrentMaster.Title.HelpTopicName = "translationservices_translatedocuments";
                }
                else
                {
                    CurrentMaster.Title.HelpTopicName = "translationservices_createsubmission";
                }

                btnCancel.Text = GetString("general.cancel");
                btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;");

                // Register the dialog script
                ScriptHelper.RegisterDialogScript(this);

                titleElemAsync.TitleText  = GetString("ContentTranslate.TranslatingDocuments");
                titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/translate.png");

                // Set visibility of panels
                pnlContent.Visible = true;
                pnlLog.Visible     = false;
            }
        }
        else
        {
            pnlContent.Visible = false;
            ShowError(GetString("dialogs.badhashtext"));
        }
    }
Beispiel #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script files
        ScriptHelper.RegisterCMS(this);
        ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js");

        if (QueryHelper.ValidateHash("hash"))
        {
            // Setup page title text and image
            PageTitle.TitleText = GetString("Content.TranslateTitle");
            EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText);

            if (IsDialog)
            {
                RegisterModalPageScripts();
                RegisterEscScript();

                plcInfo.Visible = false;

                pnlAsyncBody.CssClass  = "DialogPageBody";
                pnlTitleAsync.CssClass = "DialogsPageHeader";
                pnlContent.CssClass    = "PageContent";
                pnlButtons.CssClass    = "FloatRight PageFooterLine";
            }

            if (!TranslationServiceHelper.IsTranslationAllowed(CurrentSiteName))
            {
                pnlContent.Visible = false;
                ShowError(GetString("translations.translationnotallowed"));
                return;
            }

            // Set current UI culture
            currentCulture = CultureHelper.PreferredUICultureCode;
            // Initialize current user
            currentUser = MembershipContext.AuthenticatedUser;
            // Initialize current site
            currentSite = SiteContext.CurrentSite;

            // Initialize events
            ctlAsync.OnFinished   += ctlAsync_OnFinished;
            ctlAsync.OnError      += ctlAsync_OnError;
            ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
            ctlAsync.OnCancel     += ctlAsync_OnCancel;

            targetCulture = QueryHelper.GetString("targetculture", LocalizationContext.PreferredCultureCode);
            isSelect      = QueryHelper.GetBoolean("select", false);

            if (isSelect)
            {
                pnlDocList.Visible     = false;
                pnlDocSelector.Visible = true;
                translationElem.DisplayMachineServices = false;
                translationElem.DisplayTargetlanguage  = true;
            }

            if (!RequestHelper.IsCallback())
            {
                // If not in select mode, load all the document IDs and check permissions
                // In select mode, documents are checked when the button is clicked
                if (!isSelect)
                {
                    DataSet      allDocs = null;
                    TreeProvider tree    = new TreeProvider(currentUser);

                    // Current Node ID to translate
                    string parentAliasPath = string.Empty;
                    if (Parameters != null)
                    {
                        parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty);
                        nodeIdsArr      = ValidationHelper.GetString(Parameters["nodeids"], string.Empty).Trim('|').Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    }

                    if (string.IsNullOrEmpty(parentAliasPath))
                    {
                        if (nodeIdsArr == null)
                        {
                            // One document translation is requested
                            string nodeIdQuery = QueryHelper.GetString("nodeid", "");
                            if (nodeIdQuery != "")
                            {
                                // Mode of single node translation
                                pnlList.Visible           = false;
                                chkSkipTranslated.Checked = false;

                                translationElem.NodeID = ValidationHelper.GetInteger(nodeIdQuery, 0);

                                nodeIdsArr = new[] { nodeIdQuery };
                            }
                            else
                            {
                                nodeIdsArr = new string[] { };
                            }
                        }

                        foreach (string nodeId in nodeIdsArr)
                        {
                            int id = ValidationHelper.GetInteger(nodeId, 0);
                            if (id != 0)
                            {
                                nodeIds.Add(id);
                            }
                        }
                    }
                    else
                    {
                        // Exclude root of the website from multiple translation requested by document listing bulk action
                        string where = "ClassName <> 'CMS.Root'";
                        if (!string.IsNullOrEmpty(WhereCondition))
                        {
                            where = SqlHelper.AddWhereCondition(where, WhereCondition);
                        }

                        allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%",
                                                   TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where,
                                                   "DocumentName", AllLevels ? TreeProvider.ALL_LEVELS : 1, false, 0,
                                                   TreeProvider.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath");

                        if (!DataHelper.DataSourceIsEmpty(allDocs))
                        {
                            foreach (DataTable table in allDocs.Tables)
                            {
                                foreach (DataRow row in table.Rows)
                                {
                                    nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0));
                                }
                            }
                        }
                    }

                    if (nodeIds.Count > 0)
                    {
                        // Set the target settings
                        translationElem.TranslationSettings = new TranslationSettings
                        {
                            TargetLanguage = targetCulture
                        };

                        var where = new WhereCondition().WhereIn("NodeID", nodeIds).ToString(true);
                        DataSet ds = allDocs ?? tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", TreeProvider.ALL_LEVELS, false);

                        if (!DataHelper.DataSourceIsEmpty(ds))
                        {
                            string docList = null;

                            if (string.IsNullOrEmpty(parentAliasPath))
                            {
                                cancelNodeId = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0);
                            }
                            else
                            {
                                cancelNodeId = TreePathUtils.GetNodeIdByAliasPath(currentSite.SiteName, parentAliasPath);
                            }

                            foreach (DataTable table in ds.Tables)
                            {
                                foreach (DataRow dr in table.Rows)
                                {
                                    bool   isLink = (dr["NodeLinkedNodeID"] != DBNull.Value);
                                    string name   = (string)dr["DocumentName"];
                                    docList += HTMLHelper.HTMLEncode(name);
                                    if (isLink)
                                    {
                                        docList += DocumentHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
                                    }
                                    docList          += "<br />";
                                    lblDocuments.Text = docList;

                                    // Set visibility of checkboxes
                                    TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr);

                                    if (!IsUserAuthorizedToTranslateDocument(node, currentSite.SiteName, targetCulture))
                                    {
                                        HideUI();
                                        plcMessages.AddError(String.Format(GetString("cmsdesk.notauthorizedtotranslatedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)));
                                    }
                                }
                            }
                        }

                        // Display check box for separate submissions for each document if there is more than one document
                        pnlSeparateSubmissions.Visible = (nodeIds.Count > 1);
                    }
                    else
                    {
                        // Hide everything
                        pnlContent.Visible = false;
                    }
                }

                btnCancel.Text = GetString("general.cancel");
                btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;");

                // Register the dialog script
                ScriptHelper.RegisterDialogScript(this);

                titleElemAsync.TitleText = GetString("contentrequest.starttranslate");
                // Set visibility of panels
                pnlContent.Visible = true;
                pnlLog.Visible     = false;
            }
        }
        else
        {
            pnlContent.Visible = false;
            ShowError(GetString("dialogs.badhashtext"));
        }
    }
Beispiel #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script files
        ScriptHelper.RegisterCMS(this);
        ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js");

        if (QueryHelper.ValidateHash("hash"))
        {
            // Set current UI culture
            currentCulture = CultureHelper.PreferredUICulture;
            // Initialize current user
            currentUser = CMSContext.CurrentUser;
            // Initialize current site
            currentSite = CMSContext.CurrentSite;

            // Initialize events
            ctlAsync.OnFinished   += ctlAsync_OnFinished;
            ctlAsync.OnError      += ctlAsync_OnError;
            ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
            ctlAsync.OnCancel     += ctlAsync_OnCancel;

            if (!RequestHelper.IsCallback())
            {
                DataSet      allDocs = null;
                TreeProvider tree    = new TreeProvider(currentUser);
                btnCancel.Text = GetString("general.cancel");

                // Current Node ID to delete
                string parentAliasPath = string.Empty;
                if (Parameters != null)
                {
                    parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty);
                }
                if (string.IsNullOrEmpty(parentAliasPath))
                {
                    nodeIdsArr = QueryHelper.GetString("nodeid", string.Empty).Trim('|').Split(new char[] { '|' },
                                                                                               StringSplitOptions.
                                                                                               RemoveEmptyEntries);
                    foreach (string nodeId in nodeIdsArr)
                    {
                        int id = ValidationHelper.GetInteger(nodeId, 0);
                        if (id != 0)
                        {
                            nodeIds.Add(id);
                        }
                    }
                }
                else
                {
                    string where = "ClassName <> 'CMS.Root'";
                    if (!string.IsNullOrEmpty(WhereCondition))
                    {
                        where = SqlHelperClass.AddWhereCondition(where, WhereCondition);
                    }
                    allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new char[] { '/' }) + "/%",
                                               TreeProvider.ALL_CULTURES, true, TreeProvider.ALL_CLASSNAMES, where,
                                               "DocumentName", TreeProvider.ALL_LEVELS, false, 0,
                                               TreeProvider.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID");

                    if (!DataHelper.DataSourceIsEmpty(allDocs))
                    {
                        foreach (DataTable table in allDocs.Tables)
                        {
                            foreach (DataRow row in table.Rows)
                            {
                                nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0));
                            }
                        }
                    }
                }

                // Setup page title text and image
                CurrentMaster.Title.TitleText  = GetString("Content.DeleteTitle");
                CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/delete.png");

                btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;");

                // Register the dialog script
                ScriptHelper.RegisterDialogScript(this);

                titleElemAsync.TitleText  = GetString("ContentDelete.DeletingDocuments");
                titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/delete.png");

                // Set visibility of panels
                pnlContent.Visible = true;
                pnlLog.Visible     = false;

                // Set all cultures checkbox

                if (!CultureInfoProvider.IsSiteMultilignual(currentSite.SiteName))
                {
                    chkAllCultures.Checked = true;
                    chkAllCultures.Visible = false;
                }

                if (nodeIds.Count > 0)
                {
                    if (nodeIds.Count == 1)
                    {
                        int      nodeId = ValidationHelper.GetInteger(nodeIds[0], 0);
                        TreeNode node   = null;
                        if (string.IsNullOrEmpty(parentAliasPath))
                        {
                            // Get any culture if current not found
                            node = tree.SelectSingleNode(nodeId, currentUser.PreferredCultureCode) ??
                                   tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES);
                        }
                        else
                        {
                            if (allDocs != null)
                            {
                                DataRow dr = allDocs.Tables[0].Rows[0];
                                node = TreeNode.New(dr, ValidationHelper.GetString(dr["ClassName"], string.Empty),
                                                    tree);
                            }
                        }

                        if (node != null)
                        {
                            if (!IsUserAuthorizedToDeleteDocument(node))
                            {
                                pnlDelete.Visible = false;
                                lblError.Text     = String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"),
                                                                  HTMLHelper.HTMLEncode(node.NodeAliasPath));
                            }

                            if (node.IsLink)
                            {
                                CurrentMaster.Title.TitleText = GetString("Content.DeleteTitleLink") + " \"" +
                                                                HTMLHelper.HTMLEncode(node.DocumentName) + "\"";
                                lblQuestion.Text       = GetString("ContentDelete.QuestionLink");
                                chkAllCultures.Checked = true;
                                plcCheck.Visible       = false;
                            }
                            else
                            {
                                string nodeName = HTMLHelper.HTMLEncode(node.DocumentName);
                                // Get name for root document
                                if (node.NodeClassName.ToLower() == "cms.root")
                                {
                                    nodeName = HTMLHelper.HTMLEncode(currentSite.DisplayName);
                                }
                                CurrentMaster.Title.TitleText = GetString("Content.DeleteTitle") + " \"" + nodeName +
                                                                "\"";
                                // If there is SKU
                                if (node.HasSKU)
                                {
                                    GeneralizedInfo product = ModuleCommands.ECommerceGetSKUInfo(node.NodeSKUID);
                                    if (product != null)
                                    {
                                        bool authorized = false;
                                        // Check if product is global
                                        if (product.GetValue("SKUSiteID") == null)
                                        {
                                            // Check EcommerceGlobalModify permission
                                            authorized = currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceGlobalModify");
                                        }
                                        else
                                        {
                                            // Check ModifyProducts/EcommerceModify permission
                                            authorized = currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "ModifyProducts") || currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceModify");
                                        }

                                        if (authorized)
                                        {
                                            pnlDeleteSKU.Visible = true;
                                            chkDeleteSKU.Visible = true;
                                        }
                                    }
                                }
                            }

                            // Show or hide checkbox
                            chkDestroy.Visible = CanDestroy(node);

                            cancelNodeId = IsMultipleAction ? node.NodeParentID : node.NodeID;
                        }
                        lblQuestion.Text    = GetString("ContentDelete.Question");
                        chkAllCultures.Text = GetString("ContentDelete.AllCultures");
                        chkDestroy.Text     = GetString("ContentDelete.Destroy");
                        chkDeleteSKU.Text   = GetString("ContentDelete.SKU");
                    }
                    else if (nodeIds.Count > 1)
                    {
                        pnlDocList.Visible = true;
                        string where       = "NodeID IN (";
                        foreach (int nodeID in nodeIds)
                        {
                            where += nodeID + ",";
                        }

                        where = where.TrimEnd(',') + ")";
                        DataSet ds = allDocs ??
                                     tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, null,
                                                      where, "DocumentName", -1, false);

                        if (!DataHelper.DataSourceIsEmpty(ds))
                        {
                            TreeNode node    = null;
                            string   docList = null;

                            if (string.IsNullOrEmpty(parentAliasPath))
                            {
                                cancelNodeId =
                                    ValidationHelper.GetInteger(
                                        DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0);
                            }
                            else
                            {
                                cancelNodeId = TreePathUtils.GetNodeIdByAliasPath(currentSite.SiteName, parentAliasPath);
                            }

                            bool canDestroy = true;

                            foreach (DataTable table in ds.Tables)
                            {
                                foreach (DataRow dr in table.Rows)
                                {
                                    bool   isLink = (dr["NodeLinkedNodeID"] != DBNull.Value);
                                    string name   = (string)dr["DocumentName"];
                                    docList += HTMLHelper.HTMLEncode(name);
                                    if (isLink)
                                    {
                                        docList += UIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link);
                                    }
                                    docList          += "<br />";
                                    lblDocuments.Text = docList;

                                    // Set visibility of checkboxes
                                    node = TreeNode.New(dr,
                                                        ValidationHelper.GetString(dr["ClassName"], string.Empty));

                                    if (!IsUserAuthorizedToDeleteDocument(node))
                                    {
                                        pnlDelete.Visible = false;
                                        lblError.Text     = String.Format(
                                            GetString("cmsdesk.notauthorizedtodeletedocument"),
                                            HTMLHelper.HTMLEncode(node.NodeAliasPath));
                                        break;
                                    }

                                    // Can destroy if "can destroy all previous AND current"
                                    canDestroy = CanDestroy(node) && canDestroy;

                                    if ((currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "ModifyProducts") || currentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceModify")) &&
                                        (node.HasSKU))
                                    {
                                        pnlDeleteSKU.Visible = true;
                                        chkDeleteSKU.Visible = true;
                                    }
                                }
                            }
                            chkDestroy.Visible = canDestroy;
                        }

                        lblQuestion.Text = GetString("ContentDelete.QuestionMultiple");
                        CurrentMaster.Title.TitleText = GetString("Content.DeleteTitleMultiple");
                        chkAllCultures.Text           = GetString("ContentDelete.AllCulturesMultiple");
                        chkDestroy.Text   = GetString("ContentDelete.DestroyMultiple");
                        chkDeleteSKU.Text = GetString("ContentDelete.SKUMultiple");
                    }
                    // If user has allowed cultures specified
                    if (currentUser.UserHasAllowedCultures)
                    {
                        // Get all site cultures
                        DataSet siteCultures            = CultureInfoProvider.GetSiteCultures(currentSite.SiteName);
                        bool    denyAllCulturesDeletion = false;
                        // Check that user can edit all site cultures
                        foreach (DataRow culture in siteCultures.Tables[0].Rows)
                        {
                            string cultureCode =
                                ValidationHelper.GetString(DataHelper.GetDataRowValue(culture, "CultureCode"),
                                                           string.Empty);
                            if (!currentUser.IsCultureAllowed(cultureCode, currentSite.SiteName))
                            {
                                denyAllCulturesDeletion = true;
                            }
                        }
                        // If user can't edit all site cultures
                        if (denyAllCulturesDeletion)
                        {
                            // Hide all cultures selector
                            chkAllCultures.Visible = false;
                            chkAllCultures.Checked = false;
                        }
                    }
                }
                else
                {
                    // Hide everything
                    pnlContent.Visible = false;
                }
            }
        }
        else
        {
            pnlDelete.Visible = false;
            lblError.Text     = GetString("dialogs.badhashtext");
        }
    }