コード例 #1
0
        /// <summary>
        /// Adds the specific newsletter to campaign. If the newsletter does not exists it is created.
        /// </summary>
        /// <param name="campaign">Campaign where the newsletter is added.</param>
        /// <param name="issueGuid">Guid of the newsletter issue.</param>
        public static void AddNewsletterAsset(CampaignInfo campaign, Guid issueGuid)
        {
            var issue = ProviderHelper.GetInfoByGuid(PredefinedObjectType.NEWSLETTERISSUE, issueGuid, campaign.CampaignSiteID);

            if (issue == null)
            {
                return;
            }

            var newsletter = ProviderHelper.GetInfoById(PredefinedObjectType.NEWSLETTER, issue.GetValue("IssueNewsletterID").ToInteger(0));

            if (newsletter == null)
            {
                return;
            }

            var source = newsletter.GetValue("NewsletterDisplayName").ToString().Replace(' ', '_').ToLowerInvariant();

            issue.SetValue("IssueUseUTM", true);
            issue.SetValue("IssueUTMCampaign", campaign.CampaignUTMCode);
            issue.SetValue("IssueUTMSource", source);
            issue.Update();

            CreateNewsletterAsset(campaign.CampaignID, issueGuid);
        }
コード例 #2
0
    void UniSelector_OnItemsSelected(object sender, EventArgs e)
    {
        try
        {
            int processId             = ValidationHelper.GetInteger(ucSelector.Value, 0);
            AutomationManager manager = AutomationManager.GetInstance(CurrentUser);
            var infoObj = ProviderHelper.GetInfoById(listElem.ObjectType, listElem.ObjectID);
            using (CMSActionContext context = new CMSActionContext())
            {
                context.AllowAsyncActions = false;

                manager.StartProcess(infoObj, processId);
            }
        }
        catch (ProcessRecurrenceException ex)
        {
            ShowError(ex.Message);
        }
        catch (Exception ex)
        {
            LogAndShowError("Automation", "STARTPROCESS", ex);
        }

        listElem.UniGrid.ReloadData();
        pnlUpdate.Update();
    }
コード例 #3
0
    protected object grid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView drv = null;

        if (parameter is DataRowView)
        {
            drv = (DataRowView)parameter;
        }
        else if (parameter is GridViewRow)
        {
            drv = (DataRowView)((GridViewRow)parameter).DataItem;
        }

        var objectSettingsId = ValidationHelper.GetInteger(drv["ObjectSettingsID"], 0);

        if ((tmpObjectSettings == null) || (tmpObjectSettings.ObjectSettingsID != objectSettingsId))
        {
            tmpObjectSettings = ObjectSettingsInfo.Provider.Get(objectSettingsId);
            if (tmpObjectSettings != null)
            {
                tmpInfo = ProviderHelper.GetInfoById(tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID);
            }
        }

        if ((tmpInfo != null) && (tmpObjectSettings != null))
        {
            contextResolver.SetNamedSourceData("EditedObject", tmpInfo);

            switch (sourceName.ToLowerCSafe())
            {
            case "checkin":
                var checkinButton = (CMSGridActionButton)sender;

                if (tmpInfo.TypeInfo.SupportsLocking)
                {
                    checkinButton.OnClientClick = GetConfirmScript(GetString("ObjectEditMenu.CheckInConfirmation"), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnCheckIn);
                }
                else
                {
                    checkinButton.Enabled = false;
                }
                break;

            case "undocheckout":
                var undoCheckoutButton = (CMSGridActionButton)sender;

                if (tmpInfo.TypeInfo.SupportsLocking)
                {
                    undoCheckoutButton.OnClientClick = GetConfirmScript(CMSObjectManager.GetUndoCheckOutConfirmation(tmpInfo, null), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnUndoCheckOut);
                }
                else
                {
                    undoCheckoutButton.Enabled = false;
                }
                break;
            }
        }

        return(parameter);
    }
    public override bool LoadData(ActivityInfo ai)
    {
        if ((ai == null) || !ModuleManager.IsModuleLoaded(ModuleName.ECOMMERCE))
        {
            return(false);
        }

        switch (ai.ActivityType)
        {
        case PredefinedActivityType.PRODUCT_ADDED_TO_WISHLIST:
        case PredefinedActivityType.PRODUCT_ADDED_TO_SHOPPINGCART:
        case PredefinedActivityType.PRODUCT_REMOVED_FROM_SHOPPINGCART:
            break;

        default:
            return(false);
        }

        GeneralizedInfo sku = ProviderHelper.GetInfoById(PredefinedObjectType.SKU, ai.ActivityItemID);

        if (sku != null)
        {
            string productName = ValidationHelper.GetString(sku.GetValue("SKUName"), null);
            ucDetails.AddRow("om.activitydetails.product", productName);

            if (ai.ActivityType != PredefinedActivityType.PRODUCT_ADDED_TO_WISHLIST)
            {
                ucDetails.AddRow("om.activitydetails.productunits", ai.ActivityValue);
            }
        }

        return(ucDetails.IsDataLoaded);
    }
    private BaseInfo GetInfoFromHiddenValues()
    {
        var objectType = ValidationHelper.GetString(hdnObjectType.Value, null);
        var objectId   = ValidationHelper.GetInteger(hdnObjectId.Value, 0);

        return(ProviderHelper.GetInfoById(objectType, objectId));
    }
コード例 #6
0
    /// <summary>
    /// Updates contact's address.
    /// </summary>
    /// <param name="addressInfo">Billing address</param>
    private void MapContactAddress(AddressInfo addressInfo)
    {
        try
        {
            if ((addressInfo == null) || !SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableOnlineMarketing"))
            {
                return;
            }

            GeneralizedInfo contactInfo = ProviderHelper.GetInfoById(PredefinedObjectType.CONTACT, ContactID);

            // Check that current contact has not yet filled in address
            if ((contactInfo != null) && String.IsNullOrEmpty(ValidationHelper.GetString(contactInfo.GetValue("ContactAddress1"), "")))
            {
                Func <int, int?> getIntIfValid = i => i > 0 ? i : (int?)null;

                contactInfo.SetValue("ContactAddress1", GetContactAddress(addressInfo));
                contactInfo.SetValue("ContactCity", addressInfo.AddressCity);
                contactInfo.SetValue("ContactZIP", addressInfo.AddressZip);
                contactInfo.SetValue("ContactMobilePhone", addressInfo.AddressPhone);
                contactInfo.SetValue("ContactCountryID", getIntIfValid(addressInfo.AddressCountryID));
                contactInfo.SetValue("ContactStateID", getIntIfValid(addressInfo.AddressStateID));
                contactInfo.SetObject();
            }
        }
        catch (Exception ex)
        {
            // Exception could happen when max length of contact parameters is exceeded
            EventLogProvider.LogException("ShoppingCartOrderAddresses.MapContactAddress", "UPDATECONTACT", ex);
        }
    }
コード例 #7
0
        public static void AddNewsletterAsset(CampaignInfo campaign, Guid issueGuid)
        {
            var infoByGuid = ProviderHelper.GetInfoByGuid("newsletter.issue", issueGuid, campaign.CampaignSiteID);

            if (infoByGuid == null)
            {
                return;
            }

            var infoById = ProviderHelper.GetInfoById("newsletter.newsletter",
                                                      infoByGuid.GetValue("IssueNewsletterID").ToInteger(0));

            if (infoById == null)
            {
                return;
            }

            var lowerInvariant = infoById.GetValue("NewsletterDisplayName").ToString().Replace(' ', '_')
                                 .ToLowerInvariant();

            infoByGuid.SetValue("IssueUseUTM", true);
            infoByGuid.SetValue("IssueUTMCampaign", campaign.CampaignUTMCode);
            infoByGuid.SetValue("IssueUTMSource", lowerInvariant);
            infoByGuid.Update();
            CreateNewsletterAsset(campaign.CampaignID, issueGuid);
        }
コード例 #8
0
    /// <summary>
    /// Gets new table header cell which contains label and rollback image.
    /// </summary>
    /// <param name="suffixID">ID suffix</param>
    /// <param name="objectVersion">VersionHistoryInfo object</param>
    private TableHeaderCell GetRollbackTableHeaderCell(string suffixID, ObjectVersionHistoryInfo objectVersion)
    {
        TableHeaderCell tblHeaderCell = new TableHeaderCell();

        // Label
        Label lblValue = new Label();

        lblValue.ID   = "lbl" + suffixID;
        lblValue.Text = HTMLHelper.HTMLEncode(GetVersionNumber(objectVersion.VersionNumber, objectVersion.VersionModifiedWhen)) + "&nbsp;";
        tblHeaderCell.Controls.Add(lblValue);

        // Add rollback controls if user authorized to modify selected object
        if (objectVersion.CheckPermissions(PermissionsEnum.Modify, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
        {
            // Rollback image
            var imgRollback = new HyperLink();
            imgRollback.ID          = "imgRollback" + suffixID;
            imgRollback.CssClass    = "table-header-action";
            imgRollback.NavigateUrl = "#";

            string tooltip     = null;
            string confirmText = null;

            var info            = ProviderHelper.GetInfoById(Version.VersionObjectType, Version.VersionObjectID);
            var rollbackEnabled = !SynchronizationHelper.IsCheckedOutByOtherUser(info);

            // Set image action and description according to roll back type
            if (chkDisplayAllData.Checked)
            {
                tooltip     = GetString("objectversioning.versionlist.versionfullrollbacktooltip");
                confirmText = GetString("objectversioning.versionlist.confirmfullrollback");
            }
            else
            {
                tooltip     = GetString("history.versionrollbacktooltip");
                confirmText = GetString("Unigrid.ObjectVersionHistory.Actions.Rollback.Confirmation");
            }

            imgRollback.Text    = tooltip;
            imgRollback.Enabled = rollbackEnabled;

            // Prepare onclick script
            if (rollbackEnabled)
            {
                var confirmScript = "if (confirm(\"" + confirmText + "\")) { ";
                confirmScript += ControlsHelper.GetPostBackEventReference(this, objectVersion.VersionID + "|" + chkDisplayAllData.Checked) + "; } return false;";
                imgRollback.Attributes.Add("onclick", confirmScript);
            }

            tblHeaderCell.Controls.Add(imgRollback);
        }

        return(tblHeaderCell);
    }
コード例 #9
0
ファイル: Delete.aspx.cs プロジェクト: shawchand/Kentico11
    /// <summary>
    /// Checks whether the user is authorized to delete SKU bound to given node.
    /// </summary>
    /// <param name="node">Node to be checked</param>
    protected bool IsUserAuthorizedToModifySKU(TreeNode node)
    {
        bool authorized = false;

        if ((node != null) && (node.HasSKU))
        {
            var product = ProviderHelper.GetInfoById(PredefinedObjectType.SKU, node.NodeSKUID);
            if (product != null)
            {
                authorized = product.CheckPermissions(PermissionsEnum.Delete, node.NodeSiteName, currentUser);
            }
        }

        return(authorized);
    }
コード例 #10
0
    /// <summary>
    /// Selects base info item
    /// </summary>
    /// <param name="bi">Base info item definition</param>
    private String SelectItem(BaseInfo bi)
    {
        String   script   = String.Empty;
        int      parentID = ValidationHelper.GetInteger(bi.GetValue(itemParentColumn), 0);
        BaseInfo biParent = ProviderHelper.GetInfoById(categoryObjectType, parentID);

        if (biParent != null)
        {
            String categoryPath = ValidationHelper.GetString(biParent.GetValue(categoryPathColumn), String.Empty);
            string path         = categoryPath + "/" + bi.Generalized.ObjectCodeName;
            script += SelectAfterLoad(path, bi.Generalized.ObjectID, "item", parentID, true, true);
        }

        return(script);
    }
    /// <summary>
    /// Init event handler
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        // Set the EditedObject attribute for the UIForm
        if (variantMode == VariantModeEnum.MVT)
        {
            mvtEditElem.UIFormControl.EditedObject = ProviderHelper.GetInfoById(MVTVariantInfo.OBJECT_TYPE, QueryHelper.GetInteger("variantid", 0));
            mvtEditElem.UIFormControl.ReloadData();
        }
        else if (variantMode == VariantModeEnum.ContentPersonalization)
        {
            cpEditElem.UIFormControl.EditedObject = ProviderHelper.GetInfoById(ContentPersonalizationVariantInfo.OBJECT_TYPE, QueryHelper.GetInteger("variantid", 0));
            cpEditElem.UIFormControl.ReloadData();
        }

        base.OnInit(e);
    }
    public override bool LoadData(ActivityInfo ai)
    {
        if ((ai == null) || !ModuleManager.IsModuleLoaded(ModuleName.BLOGS))
        {
            return(false);
        }

        switch (ai.ActivityType)
        {
        case PredefinedActivityType.BLOG_COMMENT:
        case PredefinedActivityType.SUBSCRIPTION_BLOG_POST:
            break;

        default:
            return(false);
        }

        // Link to blog post
        int nodeId = ai.ActivityNodeID;

        lblDocIDVal.Text = GetLinkForDocument(nodeId, ai.ActivityCulture);

        // Link to blog
        int blogDocumentID = ai.ActivityItemDetailID;

        if (blogDocumentID > 0)
        {
            plcBlogDocument.Visible = true;
            lblBlogVal.Text         = GetLinkForDocument(blogDocumentID, ai.ActivityCulture);
        }

        if (ai.ActivityType == PredefinedActivityType.BLOG_COMMENT)
        {
            // Get blog comment data
            GeneralizedInfo iinfo = ProviderHelper.GetInfoById(PredefinedObjectType.BLOGCOMMENT, ai.ActivityItemID);
            if (iinfo != null)
            {
                plcComment.Visible = true;
                txtComment.Text    = ValidationHelper.GetString(iinfo.GetValue("CommentText"), null);
            }
        }

        return(true);
    }
コード例 #13
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Get query string parameters
        var objectType = QueryHelper.GetString("objecttype", String.Empty);
        var objectId   = QueryHelper.GetInteger("objectid", 0);

        // Get the object
        infoToClone = ProviderHelper.GetInfoById(objectType, objectId);

        if (infoToClone != null)
        {
            objTypeName = GetString("objecttype." + TranslationHelper.GetSafeClassName(infoToClone.TypeInfo.ObjectType));
        }

        if (objTypeName.StartsWith("objecttype.", StringComparison.OrdinalIgnoreCase))
        {
            objTypeName = "";
            SetTitle(String.Format(GetString("clonning.dialog.title"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(infoToClone.Generalized.ObjectDisplayName))));
        }
        else
        {
            SetTitle(String.Format(GetString("clonning.dialog.title"), objTypeName));
        }

        if (infoToClone == null)
        {
            ShowInformation(GetString("clonning.dialog.objectdoesnotexist"));
            cloneObjectElem.Visible = false;
            return;
        }

        // Check permissions
        if (!infoToClone.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser))
        {
            RedirectToAccessDenied(infoToClone.TypeInfo.ModuleName, "read");
        }

        cloneObjectElem.InfoToClone = infoToClone;
    }
コード例 #14
0
    private void gridState_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLowerCSafe())
        {
        case "delete":
            int stateId = ValidationHelper.GetInteger(actionArgument, 0);

            var obj   = ProviderHelper.GetInfoById(ObjectType, ObjectID);
            var state = AutomationStateInfoProvider.GetAutomationStateInfo(stateId);

            if (!CurrentUser.IsAuthorizedPerResource(ModuleName.ONLINEMARKETING, "RemoveProcess", SiteContext.CurrentSiteName))
            {
                RedirectToAccessDenied(ModuleName.ONLINEMARKETING, "RemoveProcess");
            }

            AutomationManager manager = AutomationManager.GetInstance(CurrentUser);
            manager.RemoveProcess(obj, state);

            break;
        }
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        MessagesPlaceHolder = plcMess;

        string objectType  = string.Empty;
        string elementName = string.Empty;

        switch (QueryHelper.GetString("parameterName", string.Empty).ToLowerInvariant())
        {
        // It is banner
        case "bannerid":
            objectType  = BannerInfo.OBJECT_TYPE;
            elementName = "Report_1";
            break;

        // It is banner category
        case "bannercategoryid":
            objectType  = BannerCategoryInfo.OBJECT_TYPE;
            elementName = "Report";
            break;

        default:
            RedirectToInformation(GetString("bannermanagement.error.internal"));
            break;
        }


        // Check UI personalization
        var uiElement = new UIElementAttribute(ResourceName, elementName);

        uiElement.Check(this);

        // Check Reporting permissions
        CheckReportingAvailability();

        // Get the ID
        int id = QueryHelper.GetInteger("parameterValue", 0);

        SetEditedObject(ProviderHelper.GetInfoById(objectType, id), string.Empty);
    }
コード例 #16
0
    /// <summary>
    /// OnPreRender event handler
    /// </summary>
    /// <param name="e"></param>
    protected override void OnPreRender(EventArgs e)
    {
        if (SearchTaskInfo != null)
        {
            GeneralizedInfo relatedObjectInfo = ProviderHelper.GetInfoById(SearchTaskInfo.SearchTaskRelatedObjectType, SearchTaskInfo.SearchTaskRelatedObjectID);
            string          relatedObjectStr  = String.Empty;

            if (relatedObjectInfo == null)
            {
                relatedObjectStr = ResHelper.GetStringFormat(
                    "smartsearch.searchtaskrelatedobjectnotexist",
                    TypeHelper.GetNiceObjectTypeName(SearchTaskInfo.SearchTaskRelatedObjectType),
                    SearchTaskInfo.SearchTaskRelatedObjectID
                    );
            }
            else
            {
                relatedObjectStr = relatedObjectInfo.GetFullObjectName(false, true, false);
            }

            StringBuilder report = new StringBuilder();
            report.Append("<div class='form-horizontal'>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.tasktype"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(GetString("smartsearch.tasktype." + SearchTaskInfo.SearchTaskType.ToStringRepresentation())), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskobjecttype"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(TypeHelper.GetNiceObjectTypeName(SearchTaskInfo.SearchTaskObjectType)), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskfield"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(SearchTaskInfo.SearchTaskField), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskvalue"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(SearchTaskInfo.SearchTaskValue), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskrelatedobject"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(relatedObjectStr), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskservername"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(SearchTaskInfo.SearchTaskServerName), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskcreated"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(SearchTaskInfo.SearchTaskCreated.ToString()), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskstatus"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", UniGridFunctions.ColoredSpanMsg(HTMLHelper.HTMLEncode(GetString("smartsearch.searchtaskstatusenum." + SearchTaskInfo.SearchTaskStatus.ToStringRepresentation())), SearchTaskInfo.SearchTaskStatus != SearchTaskStatusEnum.Error), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskerrormessage"), ":</strong></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(SearchTaskInfo.SearchTaskErrorMessage), "</span></div></div>");
            report.Append("</div>");

            lblReport.Text = report.ToString();
        }
        else
        {
            lblReport.Text = GetString("srch.task.tasknotexist");
        }
    }
コード例 #17
0
    /// <summary>
    /// Loads and displays either the MVT or Content personalization edit form.
    /// </summary>
    /// <param name="forceReload">if true, then reloads the edit form content</param>
    private void LoadEditForm()
    {
        // Set the EditedObject attribute for the UIForm
        if (variantMode == VariantModeEnum.MVT)
        {
            mvtEditElem.UIFormControl.EditedObject = ProviderHelper.GetInfoById(MVTVariantInfo.OBJECT_TYPE, QueryHelper.GetInteger("variantid", 0));
            mvtEditElem.UIFormControl.ReloadData();

            // Display MVT edit dialog
            mvtEditElem.Visible = true;
            mvtEditElem.UIFormControl.SubmitButton.Visible = false;
        }
        else if (variantMode == VariantModeEnum.ContentPersonalization)
        {
            cpEditElem.UIFormControl.EditedObject = ProviderHelper.GetInfoById(ContentPersonalizationVariantInfo.OBJECT_TYPE, QueryHelper.GetInteger("variantid", 0));
            cpEditElem.UIFormControl.ReloadData();

            // Display Content personalization edit dialog
            cpEditElem.Visible = true;
            cpEditElem.UIFormControl.SubmitButton.Visible = false;
        }
    }
コード例 #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!QueryHelper.ValidateHash("hash"))
        {
            return;
        }

        if (!ModuleManager.IsModuleLoaded(ModuleName.ECOMMERCE))
        {
            return;
        }

        int orderId = QueryHelper.GetInteger("orderid", 0);

        // Get order object
        var order = ProviderHelper.GetInfoById(PredefinedObjectType.ORDER, orderId);

        if (order != null)
        {
            ltl.Text = order.GetStringValue("OrderInvoice", "");
        }
    }
コード例 #19
0
    /// <summary>
    /// Used for maxnodes in collapsed node.
    /// </summary>
    private TreeNode treeElem_OnNodeCreated(DataRow itemData, TreeNode defaultNode)
    {
        if (UseMaxNodeLimit && (MaxTreeNodes > 0))
        {
            //Get parentID from data row
            int    parentID       = ValidationHelper.GetInteger(itemData["ParentID"], 0);
            string dataObjectType = ValidationHelper.GetString(itemData["ObjectType"], String.Empty);

            //Dont use maxnodes limitation for categories
            if (dataObjectType.IndexOf("category", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                return(defaultNode);
            }

            //Increment index count in collapsing
            mIndex++;
            if (mIndex == MaxTreeNodes)
            {
                //Load parentid
                int      parentParentID = 0;
                BaseInfo biParent       = ProviderHelper.GetInfoById(categoryObjectType, parentID);

                if (biParent != null)
                {
                    parentParentID = ValidationHelper.GetInteger(biParent.GetValue(categoryParentColumn), 0);
                }

                TreeNode node = new TreeNode();
                node.Text = "<span class=\"ContentTreeItem\" onclick=\"SelectNode(" + parentID + " ,'category'," + parentParentID + ",true ); return false;\"><span class=\"Name\">" + GetString("general.seelisting") + "</span></span>";
                return(node);
            }
            if (mIndex > MaxTreeNodes)
            {
                return(null);
            }
        }
        return(defaultNode);
    }
    /// <summary>
    /// Init event handler.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        // When displaying an existing variant of a zone, get the variant mode for its original zone
        if (variantId > 0)
        {
            PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
            if ((pti != null) && ((pti.TemplateInstance != null)))
            {
                // Get the original zone and retrieve its variant mode
                WebPartZoneInstance zoneInstance = pti.TemplateInstance.GetZone(zoneId);
                if ((zoneInstance != null) && (zoneInstance.VariantMode != VariantModeEnum.None))
                {
                    variantMode = zoneInstance.VariantMode;
                }
            }
        }

        if (variantMode == VariantModeEnum.MVT)
        {
            // Display MVT edit dialog
            mvtEditElem.UIFormControl.EditedObject = ProviderHelper.GetInfoById(MVTVariantInfo.OBJECT_TYPE, QueryHelper.GetInteger("variantid", 0));
            mvtEditElem.UIFormControl.ParentObject = ProviderHelper.GetInfoById(PageTemplateInfo.OBJECT_TYPE, QueryHelper.GetInteger("templateid", 0));
            mvtEditElem.Visible = true;
            mvtEditElem.UIFormControl.SubmitButton.Visible = false;
            mvtEditElem.UIFormControl.ReloadData();
        }
        else if (variantMode == VariantModeEnum.ContentPersonalization)
        {
            // Display Content personalization edit dialog
            cpEditElem.UIFormControl.EditedObject = ProviderHelper.GetInfoById(ContentPersonalizationVariantInfo.OBJECT_TYPE, QueryHelper.GetInteger("variantid", 0));
            cpEditElem.UIFormControl.ParentObject = ProviderHelper.GetInfoById(PageTemplateInfo.OBJECT_TYPE, QueryHelper.GetInteger("templateid", 0));
            cpEditElem.Visible = true;
            cpEditElem.UIFormControl.SubmitButton.Visible = false;
            cpEditElem.UIFormControl.ReloadData();
        }

        base.OnInit(e);
    }
コード例 #21
0
    public override bool LoadData(ActivityInfo ai)
    {
        if ((ai == null) || !ModuleManager.IsModuleLoaded(ModuleName.EVENTMANAGER) || (ai.ActivityType != PredefinedActivityType.EVENT_BOOKING))
        {
            return(false);
        }

        int nodeId = ai.ActivityNodeID;

        ucDetails.AddRow("om.activitydetails.documenturl", GetLinkForDocument(nodeId, ai.ActivityCulture), false);

        GeneralizedInfo iinfo = ProviderHelper.GetInfoById(PredefinedObjectType.EVENTATTENDEE, ai.ActivityItemID);

        if (iinfo != null)
        {
            ucDetails.AddRow("om.activitydetails.attendee", String.Format("{0} {1} ({2})",
                                                                          ValidationHelper.GetString(iinfo.GetValue("AttendeeFirstName"), null),
                                                                          ValidationHelper.GetString(iinfo.GetValue("AttendeeLastName"), null),
                                                                          ValidationHelper.GetString(iinfo.GetValue("AttendeeEmail"), null)));
        }

        return(ucDetails.IsDataLoaded);
    }
コード例 #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get query string parameters
        objectType = QueryHelper.GetString("objecttype", String.Empty);
        int objectId = QueryHelper.GetInteger("objectid", 0);

        // Get the object
        BaseInfo info = ProviderHelper.GetInfoById(objectType, objectId);

        string objTypeName = "";

        if (info != null)
        {
            objTypeName = GetString("objecttype." + TranslationHelper.GetSafeClassName(info.TypeInfo.ObjectType));
        }

        if (objTypeName.StartsWithCSafe("objecttype."))
        {
            objTypeName = "";
            SetTitle(String.Format(GetString("clonning.dialog.title"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.Generalized.ObjectDisplayName))));
        }
        else
        {
            SetTitle(String.Format(GetString("clonning.dialog.title"), objTypeName));
        }

        btnClone.Text   = GetString("General.Clone");
        btnClone.Click += btnClone_Click;

        if (info == null)
        {
            ShowInformation(GetString("clonning.dialog.objectdoesnotexist"));
            cloneObjectElem.Visible = false;
            return;
        }

        if (cloneObjectElem.HasNoSettings())
        {
            ShowInformation(String.Format(GetString("clonning.settings.emptyinfobox"), objTypeName, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.Generalized.ObjectDisplayName))));
        }
        else
        {
            ShowInformation(String.Format(GetString("clonning.settings.infobox"), objTypeName, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.Generalized.ObjectDisplayName))));
        }

        // Check permissions
        if (!info.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser))
        {
            RedirectToAccessDenied(info.TypeInfo.ModuleName, "read");
        }

        cloneObjectElem.InfoToClone = info;

        // Register refresh script to refresh wopener
        StringBuilder script = new StringBuilder();

        script.Append(@"
function RefreshContent() {
  if (wopener != null) {
    if (wopener.RefreshWOpener)
    {
        window.refreshPageOnClose = true;
        wopener.RefreshWOpener(window);
    }
    else
    {
        wopener.window.location.replace(wopener.window.location);
    }
  }
}");
        // Register script
        ScriptHelper.RegisterWOpenerScript(Page);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "WOpenerRefresh", ScriptHelper.GetScript(script.ToString()));
    }
    protected object grid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView drv = null;

        if (parameter is DataRowView)
        {
            drv = (DataRowView)parameter;
        }
        else if (parameter is GridViewRow)
        {
            drv = (DataRowView)((GridViewRow)parameter).DataItem;
        }

        var objectSettingsId = ValidationHelper.GetInteger(drv["ObjectSettingsID"], 0);

        if ((tmpObjectSettings == null) || (tmpObjectSettings.ObjectSettingsID != objectSettingsId))
        {
            tmpObjectSettings = ObjectSettingsInfoProvider.GetObjectSettingsInfo(objectSettingsId);
            if (tmpObjectSettings != null)
            {
                tmpInfo = ProviderHelper.GetInfoById(tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID);
            }
        }

        if ((tmpInfo != null) && (tmpObjectSettings != null))
        {
            contextResolver.SetNamedSourceData("EditedObject", tmpInfo);

            switch (sourceName.ToLowerCSafe())
            {
            case "edit":
                var editButton = (CMSGridActionButton)sender;

                var url = tmpInfo.Generalized.GetEditingPageURL();

                if (!string.IsNullOrEmpty(url))
                {
                    url = contextResolver.ResolveMacros(url);

                    // Resolve dialog relative url
                    if (url.StartsWith("~/", StringComparison.Ordinal))
                    {
                        url = ApplicationUrlHelper.ResolveDialogUrl(url);
                    }

                    string queryString = URLHelper.GetQuery(url);
                    if (queryString.IndexOfCSafe("&hash=", true) < 0)
                    {
                        url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(queryString));
                    }

                    editButton.OnClientClick = string.Format("modalDialog('{0}', 'objectEdit', '85%', '85%'); return false", url);
                }
                else
                {
                    editButton.Enabled = false;
                }
                break;

            case "checkin":
                var checkinButton = (CMSGridActionButton)sender;

                if (tmpInfo.TypeInfo.SupportsLocking)
                {
                    checkinButton.OnClientClick = GetConfirmScript(GetString("ObjectEditMenu.CheckInConfirmation"), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnCheckIn);
                }
                else
                {
                    checkinButton.Enabled = false;
                }
                break;

            case "undocheckout":
                var undoCheckoutButton = (CMSGridActionButton)sender;

                if (tmpInfo.TypeInfo.SupportsLocking)
                {
                    undoCheckoutButton.OnClientClick = GetConfirmScript(CMSObjectManager.GetUndoCheckOutConfirmation(tmpInfo, null), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnUndoCheckOut);
                }
                else
                {
                    undoCheckoutButton.Enabled = false;
                }
                break;
            }
        }

        return(parameter);
    }
コード例 #24
0
    /// <summary>
    /// Reloads all data.
    /// </summary>
    public override void ReloadData(bool forceLoad)
    {
        if (CurrentReport != null)
        {
            // Load labels
            if (!RequestHelper.IsPostBack() || forceLoad)
            {
                // Create query parameters
                string query = "?ObjectID=" + CurrentReport.ReportObjectID;

                // Set link value
                string url = CurrentReport.ReportURL;
                if (CurrentReport.ReportCulture != String.Empty)
                {
                    url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, CurrentReport.ReportCulture);
                }
                lnkUrlValue.Text        = HTMLHelper.HTMLEncode(url);
                lnkUrlValue.NavigateUrl = url;
                lnkUrlValue.ToolTip     = HTMLHelper.HTMLEncode(url);
                lnkUrlValue.Target      = "_blank";

                // Set culture value
                var cultureInfo = CultureHelper.GetCultureInfo(CurrentReport.ReportCulture);
                lblCultureValue.Text = (cultureInfo != null) ? cultureInfo.DisplayName : ResHelper.Dash;

                // Set site value
                SiteInfo si = SiteInfoProvider.GetSiteInfo(CurrentReport.ReportSiteID);
                lblSiteValue.Text = (si != null) ? HTMLHelper.HTMLEncode(si.DisplayName) : ResHelper.Dash;

                // Set title
                lblTitleValue.Text = HTMLHelper.HTMLEncode(CurrentReport.ReportTitle);

                // Set labels
                if (!string.IsNullOrEmpty(CurrentReport.ReportObjectType))
                {
                    lblObjectTypeValue.Text = GetString("ObjectType." + ImportExportHelper.GetSafeObjectTypeName(CurrentReport.ReportObjectType));
                    query += "&ObjectType=" + CurrentReport.ReportObjectType;
                }
                else
                {
                    lblObjectTypeValue.Text = ResHelper.Dash;
                }

                // Get object display name
                lblObjectNameValue.Text = ResHelper.Dash;

                string objectType = CurrentReport.ReportObjectType;
                int    objectId   = CurrentReport.ReportObjectID;

                if ((objectId > 0) && !string.IsNullOrEmpty(objectType) && !DocumentHelper.IsDocumentObjectType(objectType))
                {
                    GeneralizedInfo obj = ProviderHelper.GetInfoById(objectType, objectId);
                    if ((obj != null) && !string.IsNullOrEmpty(obj.ObjectDisplayName))
                    {
                        lblObjectNameValue.Text = HTMLHelper.HTMLEncode(obj.ObjectDisplayName);
                    }
                }

                // Set Reported by label
                lblReportedByValue.Text = ResHelper.Dash;
                if (CurrentReport.ReportUserID != 0)
                {
                    UserInfo ui = UserInfoProvider.GetUserInfo(CurrentReport.ReportUserID);
                    lblReportedByValue.Text = (ui != null) ? HTMLHelper.HTMLEncode(ui.FullName) : GetString("general.NA");
                }

                // Set other parameters
                lblReportedWhenValue.Text = CurrentReport.ReportWhen.ToString();

                CMSPage page = Page as CMSPage;

                if ((CurrentReport.ReportObjectID > 0) && (!string.IsNullOrEmpty(CurrentReport.ReportObjectType)) && AbuseReportInfoProvider.IsObjectTypeSupported(CurrentReport.ReportObjectType))
                {
                    // Add Object details button
                    string detailUrl = "~/CMSModules/AbuseReport/AbuseReport_ObjectDetails.aspx" + query;
                    detailUrl = URLHelper.AddParameterToUrl(detailUrl, "hash", QueryHelper.GetHash(detailUrl));
                    var onClientClickScript = ScriptHelper.GetModalDialogScript(UrlResolver.ResolveUrl(detailUrl), "objectdetails", 960, 600);

                    if (page != null)
                    {
                        var headerActions = page.HeaderActions;
                        headerActions.AddAction(new HeaderAction
                        {
                            Text          = GetString("abuse.details"),
                            OnClientClick = onClientClickScript,
                            ButtonStyle   = ButtonStyle.Default
                        });
                        btnObjectDetails.Visible = false;
                    }
                    else
                    {
                        btnObjectDetails.OnClientClick = onClientClickScript;
                        ScriptHelper.RegisterDialogScript(Page);
                    }
                }
                else
                {
                    btnObjectDetails.Visible = false;
                }

                Control postback = ControlsHelper.GetPostBackControl(Page);

                // Not post-back not caused by OK button or Save action in header
                if ((postback != btnOk) && ((page == null) || (postback != page.HeaderActions)))
                {
                    txtCommentValue.Text = CurrentReport.ReportComment;
                    LoadStatus((int)CurrentReport.ReportStatus);
                }
            }
        }
    }
コード例 #25
0
    /// <summary>
    /// Setups controls.
    /// </summary>
    private void SetupControls()
    {
        if (FileSystemMode)
        {
            // New file button
            if (!String.IsNullOrEmpty(NewTextFileExtension))
            {
                plcNewFile.Visible = true;

                string query = "?identifier=" + Identifier;

                // New folder button
                WindowHelper.Remove(Identifier);

                Hashtable properties = new Hashtable();
                properties.Add("targetpath", TargetFolderPath);
                properties.Add("newfileextension", NewTextFileExtension);
                WindowHelper.Add(Identifier, properties);

                var url = UrlResolver.ResolveUrl("~/CMSModules/Content/Controls/Dialogs/Selectors/FileSystemSelector/EditTextFile.aspx") + query;
                url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url, false));

                btnNew.ToolTip       = GetString("dialogs.actions.newfile.desc");
                btnNew.OnClientClick = String.Format("modalDialog('{0}', 'NewFile', 905, 688, null, true); return false;", url);
                btnNew.Text          = GetString("general.create");
            }
            else
            {
                plcNewFile.Visible = false;
            }

            // Initialize file uploader
            fileUploader.SourceType          = MediaSourceEnum.PhysicalFile;
            fileUploader.TargetFolderPath    = TargetFolderPath;
            fileUploader.AllowedExtensions   = AllowedExtensions;
            fileUploader.AfterSaveJavascript = "FSS_FilesUploaded";
        }
        else
        {
            // If attachments are being displayed and no document or form is specified - hide uploader
            if (!IsCopyMoveLinkDialog && (((SourceType != MediaSourceEnum.DocumentAttachments) && (SourceType != MediaSourceEnum.MetaFile)) ||
                                          ((SourceType == MediaSourceEnum.DocumentAttachments) && (Config.AttachmentDocumentID > 0 || Config.AttachmentFormGUID != Guid.Empty)) ||
                                          ((SourceType == MediaSourceEnum.MetaFile) && ((MetaFileObjectID > 0) && !string.IsNullOrEmpty(MetaFileObjectType) && !string.IsNullOrEmpty(MetaFileCategory)))))
            {
                // Initialize file uploader
                if (SourceType == MediaSourceEnum.MetaFile)
                {
                    fileUploader.ObjectID   = MetaFileObjectID;
                    fileUploader.ObjectType = MetaFileObjectType;
                    fileUploader.Category   = MetaFileCategory;

                    BaseInfo info = ProviderHelper.GetInfoById(MetaFileObjectType, MetaFileObjectID);

                    fileUploader.SiteID = info != null ? info.Generalized.ObjectSiteID : SiteContext.CurrentSiteID;
                }
                else
                {
                    fileUploader.DocumentID          = DocumentID;
                    fileUploader.FormGUID            = FormGUID;
                    fileUploader.NodeParentNodeID    = ((NodeID > 0) ? NodeID : ParentNodeID);
                    fileUploader.NodeClassName       = SystemDocumentTypes.File;
                    fileUploader.LibraryID           = LibraryID;
                    fileUploader.LibraryFolderPath   = LibraryFolderPath;
                    fileUploader.ResizeToHeight      = ResizeToHeight;
                    fileUploader.ResizeToMaxSideSize = ResizeToMaxSideSize;
                    fileUploader.ResizeToWidth       = ResizeToWidth;
                    fileUploader.CheckPermissions    = true;
                }
                fileUploader.ParentElemID = CMSDialogHelper.GetMediaSource(SourceType);
                fileUploader.SourceType   = SourceType;
            }
            else
            {
                plcDirectFileUploader.Visible = false;
                fileUploader.StopProcessing   = true;
            }
        }

        // Initialize disabled button
        fileUploader.IsLiveSite = IsLiveSite;
        fileUploader.Text       = GetString("general.upload");
        fileUploader.UploadMode = MultifileUploaderModeEnum.DirectMultiple;

        const string disableMenuItem =
            @"function DisableNewFileBtn() {                                      
    $cmsj('#dialogsUploaderDiv').attr('style', 'display:none;');                                 
    $cmsj('#dialogsUploaderDisabledDiv').removeAttr('style');
}
";

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "disableMenuItem", ScriptHelper.GetScript(disableMenuItem));

        if (!FileSystemActionsEnabled)
        {
            // Disable file action
            ScriptHelper.RegisterStartupScript(Page, typeof(string), "disableNewFile", ScriptHelper.GetScript("DisableNewFileBtn();"));
        }
    }
コード例 #26
0
    /// <summary>
    /// Handles delete action.
    /// </summary>
    /// <param name="eventArgument">Objecttype(item or itemcategory);objectid</param>
    public void RaisePostBackEvent(string eventArgument)
    {
        string[] values = eventArgument.Split(';');
        if (values.Length == 3)
        {
            int      id       = ValidationHelper.GetInteger(values[1], 0);
            int      parentId = ValidationHelper.GetInteger(values[2], 0);
            BaseInfo biParent = ProviderHelper.GetInfoById(categoryObjectType, parentId);

            if (biParent == null)
            {
                return;
            }

            String categoryPath = ValidationHelper.GetString(biParent.GetValue(categoryPathColumn), String.Empty);
            int    parentID     = ValidationHelper.GetInteger(biParent.GetValue(categoryParentColumn), 0);

            //Test permission
            if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ResourceName, "Modify"))
            {
                String url = CMSPage.GetAccessDeniedUrl(AdministrationUrlHelper.ADMIN_ACCESSDENIED_PAGE, ResourceName, "modify", String.Empty, String.Empty);

                // Display access denied page in conent frame and select deleted item again
                String denyScript = @"$cmsj(document).ready(function(){ frames['paneContentTMain'].location = '" + ResolveUrl(url) + "';" + SelectAfterLoad(categoryPath + "/", id, values[0], parentId, false, false) + "});";

                ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "_AccessDenied", ScriptHelper.GetScript(denyScript));
                return;
            }

            switch (values[0])
            {
            case "item":
                BaseInfo bi = ProviderHelper.GetInfoById(objectType, id);
                if (bi != null)
                {
                    bi.Delete();
                }

                break;

            case "category":
                try
                {
                    BaseInfo biCate = ProviderHelper.GetInfoById(categoryObjectType, id);
                    if (biCate != null)
                    {
                        biCate.Delete();
                    }
                }
                catch (Exception ex)
                {
                    // Make alert with exception message, most probable cause is deleting category with subcategories
                    var script = $"alert('{ScriptHelper.GetString(ex.Message, false)}');\n";
                    script += SelectAfterLoad(categoryPath + "/", id, "category", parentID, true, true);

                    ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "_AfterLoad", ScriptHelper.GetScript(script));
                    return;
                }
                break;
            }

            // After delete select first tab always
            tabIndexStr = String.Empty;
            var location = UIContextHelper.GetElementUrl(UIContext.UIElement, UIContext);
            location = URLHelper.RemoveParameterFromUrl(location, "objectid");
            location = URLHelper.UpdateParameterInUrl(location, "parentobjectid", parentId.ToString());

            URLHelper.Redirect(location);
        }
    }
コード例 #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        objectType = UIContextHelper.GetObjectType(UIContext);
        CloneItemButton.Visible = DisplayCloneButton;

        if ((!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ResourceName, "Modify")) || (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ResourceName, "Create")))
        {
            CloneItemButton.ViewStateMode = ViewStateMode.Disabled;
        }

        // Pass tabindex
        int tabIndex = ValidationHelper.GetInteger(UIContext["TabIndex"], 0);

        if (tabIndex != 0)
        {
            tabIndexStr = "&tabindex=" + tabIndex;
        }

        String editElem     = ValidationHelper.GetString(UIContext["itemEdit"], String.Empty);
        String categoryElem = ValidationHelper.GetString(UIContext["categoryedit"], String.Empty);

        categoryPathColumn   = ValidationHelper.GetString(UIContext["pathColumn"], String.Empty);
        categoryParentColumn = ValidationHelper.GetString(UIContext["categoryparentcolumn"], String.Empty);
        categoryObjectType   = ValidationHelper.GetString(UIContext["parentobjecttype"], String.Empty);
        itemParentColumn     = ValidationHelper.GetString(UIContext["parentColumn"], String.Empty);
        newItem = ValidationHelper.GetString(UIContext["newitem"], String.Empty);

        if (!ValidateInput())
        {
            return;
        }

        itemLocation     = URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ResourceName, editElem), "?tabslayout=horizontal&displaytitle=false");
        categoryLocation = URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ResourceName, categoryElem), "?tabslayout=horizontal&displaytitle=false");

        RegisterExportScript();
        RegisterTreeScript();
        RegisterMenuScript();
        InitTree();

        // Setup menu action scripts
        String newItemText = newItem.StartsWith("javascript", StringComparison.InvariantCultureIgnoreCase) ? newItem : "NewItem('item'); return false;";

        AddButon.Actions.Add(new CMSButtonAction
        {
            Text          = GetString(objectType + ".newitem"),
            OnClientClick = newItemText
        });
        AddButon.Actions.Add(new CMSButtonAction
        {
            Text          = GetString("development.tree.newcategory"),
            OnClientClick = "NewItem('category'); return false;"
        });

        DeleteItemButton.OnClientClick = "DeleteItem(); return false;";
        ExportItemButton.OnClientClick = "ExportObject(); return false;";
        CloneItemButton.OnClientClick  = "if ((selectedItemId > 0) && (selectedItemType == 'item')) { modalDialog('" + UrlResolver.ResolveUrl("~/CMSModules/Objects/Dialogs/CloneObjectDialog.aspx?reloadall=1&displaytitle=" + UIContext["displaytitle"] + "&objecttype=" + objectType + "&objectid=") + "' + selectedItemId, 'Clone item', 750, 470); } return false;";

        // Tooltips
        DeleteItemButton.ToolTip = GetString("development.tree.deleteselected");
        ExportItemButton.ToolTip = GetString("exportobject.title");
        CloneItemButton.ToolTip  = GetString(objectType + ".clone");

        // URLs for menu actions
        String script = "var doNotReloadContent = false;\n";

        // Script for deleting widget or category
        string delPostback  = ControlsHelper.GetPostBackEventReference(this, "##");
        string deleteScript = @"
function DeleteItem() { 
    if ((selectedItemId > 0) && (selectedItemParent > 0) && confirm(" + ScriptHelper.GetLocalizedString("general.deleteconfirmation") + @")) {
        " + delPostback.Replace("'##'", "selectedItemType+';'+selectedItemId+';'+selectedItemParent") + @"
    }
}";

        script += deleteScript;

        // Preselect tree item
        if (!RequestHelper.IsPostBack())
        {
            int parentobjectid = QueryHelper.GetInteger("parentobjectid", 0);
            int objectID       = QueryHelper.GetInteger("objectID", 0);

            // Select category
            if (parentobjectid > 0)
            {
                BaseInfo biParent = ProviderHelper.GetInfoById(categoryObjectType, parentobjectid);
                if (biParent != null)
                {
                    String path     = ValidationHelper.GetString(biParent.GetValue(categoryPathColumn), String.Empty);
                    int    parentID = ValidationHelper.GetInteger(biParent.GetValue(categoryParentColumn), 0);
                    script += SelectAfterLoad(path + "/", parentobjectid, "category", parentID, true, true);
                }
            }
            // Select item
            else if (objectID > 0)
            {
                BaseInfo bi = ProviderHelper.GetInfoById(objectType, objectID);
                if (bi != null)
                {
                    script += SelectItem(bi);
                }
            }
            else
            {
                // Selection by hierarchy URL
                BaseInfo biSel    = UIContext.EditedObject as BaseInfo;
                BaseInfo biParent = UIContext.EditedObjectParent as BaseInfo;

                // Check for category selection
                if ((biParent != null) && (biParent.TypeInfo.ObjectType == categoryObjectType))
                {
                    String path     = ValidationHelper.GetString(biParent.GetValue(categoryPathColumn), String.Empty);
                    int    parentID = ValidationHelper.GetInteger(biParent.GetValue(categoryParentColumn), 0);
                    script += SelectAfterLoad(path, biParent.Generalized.ObjectID, "category", parentID, false, true);
                }
                // Check for item selection
                else if ((biSel != null) && (biSel.TypeInfo.ObjectType == objectType))
                {
                    script += SelectItem(biSel);
                }
                else
                {
                    // Select root by default
                    BaseInfo bi = ProviderHelper.GetInfoByName(categoryObjectType, "/");

                    if (bi != null)
                    {
                        script += SelectAfterLoad("/", bi.Generalized.ObjectID, "category", 0, true, true);
                    }
                }
            }
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "GeneralTree_" + ClientID, ScriptHelper.GetScript(script));
    }