protected void Page_Load(object sender, EventArgs e)
    {
        HeaderActions actions = CurrentMaster.HeaderActions;

        // Save action
        actions.ActionsList.Add(new SaveAction(this)
        {
            CommandName = "lnksave_click"
        });

        // Show "Copy from global" link when not configuring global invoice.
        if (ConfiguredSiteID != 0)
        {
            actions.ActionsList.Add(new HeaderAction()
            {
                ControlType   = HeaderActionTypeEnum.LinkButton,
                Text          = GetString("com.InvoiceFromGlobal"),
                OnClientClick = "return ConfirmCopyFromGlobal();",
                ImageUrl      = GetImageUrl("CMSModules/CMS_Ecommerce/invoicefromglobal.png"),
                CommandName   = "copyFromGlobal"
            });

            // Register javascript to confirm generate
            string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmInvoiceFromGlobal")) + ");}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
        }

        actions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed);

        lblInsertMacro.Text       = GetString("macroselector.insertmacro") + ":";
        AttachmentTitle.TitleText = GetString("general.attachments");

        macroSelectorElm.Resolver             = EmailTemplateMacros.EcommerceResolver;
        macroSelectorElm.CKEditorID           = htmlInvoiceTemplate.ClientID;
        AttachmentList.CheckObjectPermissions = false;

        if (ConfiguredSiteInfo != null)
        {
            bool allowEdit = ECommerceContext.IsUserAuthorizedForPermission("ConfigurationModify");
            if (allowEdit)
            {
                // Display attachments tab in media dialog
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileObjectID   = ConfiguredSiteID;
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileObjectType = SiteObjectType.SITE;
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileCategory   = MetaFileInfoProvider.OBJECT_CATEGORY_INVOICE;
                htmlInvoiceTemplate.MediaDialogConfig.HideAttachments    = false;
            }
            else
            {
                // Hide attachments tab in media dialog
                htmlInvoiceTemplate.MediaDialogConfig.HideAttachments = true;
            }

            // Attachment list
            AttachmentList.ObjectID   = ConfiguredSiteID;
            AttachmentList.ObjectType = SiteObjectType.SITE;
            AttachmentList.Category   = MetaFileInfoProvider.OBJECT_CATEGORY_INVOICE;
            AttachmentList.SiteID     = ConfiguredSiteID;

            // Attachment list permissions
            AttachmentList.AllowEdit = allowEdit;
        }
        else
        {
            // Disable attachments for global invoice
            plcAttachments.Visible = false;
            htmlInvoiceTemplate.MediaDialogConfig.HideAttachments = true;
        }

        DisplayHelperTable();

        if (!RequestHelper.IsPostBack())
        {
            htmlInvoiceTemplate.ResolvedValue = "";
            // Configuring global invoice
            if (ConfiguredSiteID == 0)
            {
                // Show global invoice
                htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(null);
            }
            else
            {
                // Show site-specific invoice
                if (ConfiguredSiteInfo != null)
                {
                    htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(ConfiguredSiteInfo.SiteName);
                }
            }

            InitHTMLEditor();
        }

        // Show "using global settings" info message only if showing global store settings
        if ((ConfiguredSiteID == 0) && (SiteID != 0))
        {
            ShowInformation(GetString("com.UsingGlobalInvoice"));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check UI element
        var elementName = IsMultiStoreConfiguration ? "Tools.Ecommerce.Invoice" : "Configuration.Invoice";

        CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, elementName);

        HeaderActions actions = CurrentMaster.HeaderActions;

        // Save action
        actions.ActionsList.Add(new SaveAction
        {
            CommandName = "lnksave_click"
        });

        // Show "Copy from global" link when not configuring global invoice.
        if (ConfiguredSiteID != 0)
        {
            actions.ActionsList.Add(new HeaderAction
            {
                Text          = GetString("com.InvoiceFromGlobal"),
                OnClientClick = "return ConfirmCopyFromGlobal();",
                CommandName   = "copyFromGlobal",
                ButtonStyle   = ButtonStyle.Default
            });

            // Register javascript to confirm generate
            string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmInvoiceFromGlobal")) + ");}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
        }

        actions.ActionPerformed += HeaderActions_ActionPerformed;

        htmlInvoiceTemplate.ResolverName      = "EcommerceResolver";
        macroSelectorElm.Resolver             = EcommerceResolvers.EcommerceResolver;
        macroSelectorElm.CKEditorID           = htmlInvoiceTemplate.ClientID;
        AttachmentList.CheckObjectPermissions = false;

        if (ConfiguredSiteInfo != null)
        {
            bool allowEdit = ECommerceContext.IsUserAuthorizedForPermission(EcommercePermissions.CONFIGURATION_MODIFY);
            if (allowEdit)
            {
                // Display attachments tab in media dialog
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileObjectID   = ConfiguredSiteID;
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileObjectType = SiteInfo.OBJECT_TYPE;
                htmlInvoiceTemplate.MediaDialogConfig.MetaFileCategory   = ObjectAttachmentsCategories.INVOICE;
                htmlInvoiceTemplate.MediaDialogConfig.HideAttachments    = false;
            }
            else
            {
                // Hide attachments tab in media dialog
                htmlInvoiceTemplate.MediaDialogConfig.HideAttachments = true;
            }

            // Attachment list
            AttachmentList.ObjectID   = ConfiguredSiteID;
            AttachmentList.ObjectType = SiteInfo.OBJECT_TYPE;
            AttachmentList.Category   = ObjectAttachmentsCategories.INVOICE;
            AttachmentList.SiteID     = ConfiguredSiteID;

            // Attachment list permissions
            AttachmentList.AllowEdit = allowEdit;
        }
        else
        {
            // Disable attachments for global invoice
            plcAttachments.Visible = false;
            htmlInvoiceTemplate.MediaDialogConfig.HideAttachments = true;
        }

        DisplayHelperTable();

        if (!RequestHelper.IsPostBack())
        {
            htmlInvoiceTemplate.ResolvedValue = String.Empty;
            // Configuring global invoice
            if (ConfiguredSiteID == 0)
            {
                // Show global invoice
                htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(null);
            }
            else
            {
                // Show site-specific invoice
                if (ConfiguredSiteInfo != null)
                {
                    htmlInvoiceTemplate.ResolvedValue = ECommerceSettings.InvoiceTemplate(ConfiguredSiteInfo.SiteName);
                }
            }

            InitHTMLEditor();
        }

        // Show "using global settings" info message only if showing global store settings
        if ((ConfiguredSiteID == 0) && (SiteID != 0))
        {
            ShowInformation(GetString("com.UsingGlobalInvoice"));
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Initializes all nested controls.
    /// </summary>
    private void SetupControls()
    {
        IsLiveSite = false;

        InitializeScripts();

        // Set current UI culture
        currentCulture = CultureHelper.PreferredUICultureCode;

        // Initialize current user
        mCurrentUser = MembershipContext.AuthenticatedUser;

        // Initialize events
        ctlAsyncLog.OnFinished     += ctlAsync_OnFinished;
        ctlAsyncLog.OnError        += ctlAsync_OnError;
        ctlAsyncLog.OnCancel       += ctlAsync_OnCancel;
        ctlAsyncLog.PostbackOnError = true;

        ctlAsyncLog.TitleText = GetString("validation.css.checkingcss");
        HeaderActions.ActionsList.Clear();

        // Validate action
        HeaderAction validate = new HeaderAction();

        validate.OnClientClick = "LoadHTMLToElement('" + hdnHTML.ClientID + "'," + ScriptHelper.GetString(Url) + ");";
        validate.Text          = GetString("general.validate");
        validate.Tooltip       = validate.Text;
        validate.CommandName   = "validate";

        // View HTML code
        string click = GetViewSourceActionClick();

        HeaderAction viewCode = new HeaderAction();

        viewCode.OnClientClick = click;
        viewCode.Text          = GetString("validation.viewcode");
        viewCode.Tooltip       = viewCode.Text;
        viewCode.ButtonStyle   = ButtonStyle.Default;

        // Show results in new window
        HeaderAction newWindow = new HeaderAction();

        newWindow.OnClientClick = click;
        newWindow.Text          = GetString("validation.showresultsnewwindow");
        newWindow.Tooltip       = newWindow.Text;
        newWindow.ButtonStyle   = ButtonStyle.Default;

        if (DataHelper.DataSourceIsEmpty(DataSource))
        {
            newWindow.Enabled       = false;
            newWindow.OnClientClick = null;
        }
        else
        {
            string encodedKey = ScriptHelper.GetString(HttpUtility.UrlEncode(ResultKey), false);
            newWindow.OnClientClick = String.Format("modalDialog('" + ResolveUrl("~/CMSModules/Content/CMSDesk/Validation/ValidationResults.aspx") + "?datakey={0}&docid={1}&hash={2}', 'ViewValidationResult', 800, 600);return false;", encodedKey, Node.DocumentID, QueryHelper.GetHash(String.Format("?datakey={0}&docid={1}", encodedKey, Node.DocumentID)));
        }

        // Add actions and set help topic
        HeaderActions.AddAction(validate);
        HeaderActions.AddAction(viewCode);
        HeaderActions.AddAction(newWindow);
        HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

        // Set sorting and add events
        gridValidationResult.OrderBy              = "line";
        gridValidationResult.IsLiveSite           = IsLiveSite;
        gridValidationResult.ZeroRowsText         = GetString("validation.css.notvalidated");
        gridValidationResult.OnExternalDataBound += gridValidationResult_OnExternalDataBound;
        gridValidationResult.OnDataReload        += gridValidationResult_OnDataReload;
        gridValidationResult.ShowActionsMenu      = true;
        gridValidationResult.AllColumns           = "line, context, message, source";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Query param validation
        string hash = QueryHelper.GetString("hash", null);

        string paramName = "new";
        string newView   = QueryHelper.GetString(paramName, null);

        if (String.IsNullOrEmpty(newView))
        {
            paramName = "objname";
        }

        if (!QueryHelper.ValidateHashString(QueryHelper.GetString(paramName, null), hash))
        {
            ShowError(GetString("sysdev.views.corruptedparameters"));
            editSQL.Visible = false;
            return;
        }

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

        objName = QueryHelper.GetString("objname", null);

        TableManager tm = new TableManager(null);

        if (!String.IsNullOrEmpty(objName) && !tm.StoredProcedureExists(objName))
        {
            EditedObject = null;
        }

        // Init edit area
        editSQL.ObjectName     = objName;
        editSQL.HideSaveButton = objName != null;
        editSQL.IsView         = false;
        editSQL.OnSaved       += editSQL_OnSaved;
        bool loadedCorrectly = true;

        if (!RequestHelper.IsPostBack())
        {
            loadedCorrectly = editSQL.SetupControl();
        }

        // Create breadcrumbs
        CreateBreadcrumbs();

        // Edit menu
        if (objName != null)
        {
            // Save button
            HeaderActions.AddAction(new SaveAction
            {
                Enabled = loadedCorrectly,
                RegisterShortcutScript = loadedCorrectly
            });

            // Restore button
            if (editSQL.RollbackAvailable)
            {
                HeaderActions.AddAction(new HeaderAction
                {
                    Text        = GetString("dbobjects.restoredefault"),
                    CommandName = "restoredefault"
                });
            }

            HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
        }
    }
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Check 'Manage objects tasks' permission
        if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageObjectsTasks"))
        {
            RedirectToAccessDenied("cms.staging", "ManageObjectsTasks");
        }

        CurrentMaster.DisplaySiteSelectorPanel = true;

        // Check enabled servers
        var isCallback = RequestHelper.IsCallback();

        if (!isCallback && !ServerInfoProvider.IsEnabledServer(SiteContext.CurrentSiteID))
        {
            ShowInformation(GetString("ObjectStaging.NoEnabledServer"));
            CurrentMaster.PanelHeader.Visible = false;
            plcContent.Visible = false;
            pnlFooter.Visible  = false;
            return;
        }

        // Register script for pendingCallbacks repair
        ScriptHelper.FixPendingCallbacks(Page);

        // Setup server dropdown
        selectorElem.DropDownList.AutoPostBack       = true;
        selectorElem.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged;

        // Set server ID
        SelectedServerID = ValidationHelper.GetInteger(selectorElem.Value, QueryHelper.GetInteger("serverId", 0));

        // All servers
        if (SelectedServerID == UniSelector.US_ALL_RECORDS)
        {
            SelectedServerID   = 0;
            selectorElem.Value = UniSelector.US_ALL_RECORDS;
        }
        else
        {
            selectorElem.Value = SelectedServerID.ToString();
        }

        ltlScript.Text += ScriptHelper.GetScript("var currentServerId = " + SelectedServerID + ";");

        HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

        if (!isCallback)
        {
            // Check 'Manage object tasks' permission
            if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageObjectsTasks"))
            {
                RedirectToAccessDenied("cms.staging", "ManageObjectsTasks");
            }

            synchronizedSiteId = QueryHelper.GetInteger("siteid", 0);
            CurrentSiteID      = SiteContext.CurrentSiteID;

            ucDisabledModule.TestSettingKeys = "CMSStagingLogObjectChanges";
            ucDisabledModule.ParentPanel     = pnlNotLogged;

            if (synchronizedSiteId == -1)
            {
                ucDisabledModule.InfoText         = GetString("objectstaging.globalandsitenotlogged");
                ucDisabledModule.KeyScope         = DisabledModuleScope.CurrentSiteAndGlobal;
                ucDisabledModule.GlobalButtonText = GetString("objectstaging.enableglobalandsiteobjects");
            }
            else if (synchronizedSiteId == 0)
            {
                ucDisabledModule.InfoText         = GetString("objectstaging.globalnotlogged");
                ucDisabledModule.KeyScope         = DisabledModuleScope.Global;
                ucDisabledModule.GlobalButtonText = GetString("objectstaging.enableglobalobjects");
            }
            else
            {
                ucDisabledModule.InfoText       = GetString("ObjectStaging.SiteNotLogged");
                ucDisabledModule.KeyScope       = DisabledModuleScope.Site;
                ucDisabledModule.SiteButtonText = GetString("objectstaging.enablesiteobjects");
            }

            // Check logging
            if (!ucDisabledModule.Check())
            {
                CurrentMaster.PanelHeader.Visible = false;
                plcContent.Visible = false;
                return;
            }

            // Get object type
            objectType = QueryHelper.GetString("objecttype", string.Empty);

            // Create "synchronize current" header action for tree root, nodes or objects with database representation
            if (String.IsNullOrEmpty(objectType) || objectType.StartsWith("##", StringComparison.Ordinal) || (ModuleManager.GetReadOnlyObject(objectType) != null))
            {
                HeaderActions.AddAction(new HeaderAction
                {
                    Text      = GetString("ObjectTasks.SyncCurrent"),
                    EventName = SYNCHRONIZE_CURRENT
                });
            }

            // Add CSS class to panels wrapper in order it could be stacked
            CurrentMaster.PanelHeader.AddCssClass("header-container-multiple-panels");

            // Setup title
            ctlAsyncLog.TitleText = GetString("Synchronization.Title");

            // Get the selected types
            ObjectTypeTreeNode selectedNode = StagingTaskInfoProvider.ObjectTree.FindNode(objectType, (synchronizedSiteId > 0));
            objectType = (selectedNode != null) ? selectedNode.GetObjectTypes(true) : string.Empty;
            if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll))
            {
                // Register the dialog script
                ScriptHelper.RegisterDialogScript(this);

                plcContent.Visible = true;

                // Initialize buttons
                btnDeleteAll.OnClientClick      = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");";
                btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");";
                btnSyncSelected.OnClientClick   = "return !" + gridTasks.GetCheckSelectionScript();

                // Initialize grid
                gridTasks.ZeroRowsText    = GetString("Tasks.NoTasks");
                gridTasks.OnDataReload   += gridTasks_OnDataReload;
                gridTasks.ShowActionsMenu = true;
                gridTasks.Columns         = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount";
                StagingTaskInfo ti = new StagingTaskInfo();
                gridTasks.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames);

                pnlLog.Visible     = false;
                TaskTypeCategories = TaskHelper.TASK_TYPE_CATEGORY_GENERAL + ";" + TaskHelper.TASK_TYPE_CATEGORY_OBJECTS + ";" + TaskHelper.TASK_TYPE_CATEGORY_DATA;
            }
        }
    }
Esempio n. 6
0
        public void PageInit()
        {
            #region << Init Entity >>
            var entMan = new EntityManager();
            ErpEntity = entMan.ReadEntity(RecordId ?? Guid.Empty).Object;
            if (ErpEntity != null && PageContext.HttpContext.Request.Method == "GET")
            {
                Name                = ErpEntity.Name;
                Label               = ErpEntity.Label;
                LabelPlural         = ErpEntity.LabelPlural;
                System              = ErpEntity.System;
                IconName            = ErpEntity.IconName;
                Color               = ErpEntity.Color;
                RecordScreenIdField = ErpEntity.RecordScreenIdField;

                foreach (var field in ErpEntity.Fields)
                {
                    FieldOptions.Add(new SelectOption()
                    {
                        Value = field.Id.ToString(),
                        Label = field.Name
                    });
                }
            }
            #endregion

            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = $"/sdk/objects/entity/r/{ErpEntity.Id}/";
            }


            #region << Init RecordPermissions >>
            var valueGrid = new List <KeyStringList>();
            PermissionOptions = new List <SelectOption>()
            {
                new SelectOption("create", "create"),
                new SelectOption("read", "read"),
                new SelectOption("update", "update"),
                new SelectOption("delete", "delete")
            };

            var roles = AdminPageUtils.GetUserRoles();             //Special order is applied

            foreach (var role in roles)
            {
                RoleOptions.Add(new SelectOption(role.Id.ToString(), role.Name));
                var keyValuesObj = new KeyStringList()
                {
                    Key    = role.Id.ToString(),
                    Values = new List <string>()
                };
                if (ErpEntity.RecordPermissions.CanCreate.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("create");
                }
                if (ErpEntity.RecordPermissions.CanRead.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("read");
                }
                if (ErpEntity.RecordPermissions.CanUpdate.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("update");
                }
                if (ErpEntity.RecordPermissions.CanDelete.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("delete");
                }

                valueGrid.Add(keyValuesObj);
            }
            if (HttpContext.Request.Method == "GET")
            {
                RecordPermissions = JsonConvert.SerializeObject(valueGrid);
            }

            #endregion

            #region << Actions >>
            HeaderActions.AddRange(new List <string>()
            {
                PageUtils.GetActionTemplate(PageUtilsActionType.SubmitForm, label: "Save Entity", formId: "ManageRecord"),
                PageUtils.GetActionTemplate(PageUtilsActionType.Cancel, returnUrl: ReturnUrl, btnClass: "btn btn-sm btn-outline-secondary ml-1")
            });

            HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "details"));

            #endregion
        }
Esempio n. 7
0
    /// <summary>
    /// Initializes all nested controls.
    /// </summary>
    private void SetupControls()
    {
        IsLiveSite = false;

        if (!RequestHelper.IsCallback())
        {
            InitializeScripts();
        }
        // Set current UI culture
        currentCulture = CultureHelper.PreferredUICulture;

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

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

        titleElemAsync.TitleText  = GetString("validation.link.checkingurls");
        titleElemAsync.TitleImage = GetImageUrl("Design/Controls/Validation/check.png");

        HeaderActions.ActionsList.Clear();

        // Validate action
        HeaderAction validate = new HeaderAction();

        validate.ControlType   = HeaderActionTypeEnum.Hyperlink;
        validate.OnClientClick = "LoadHTMLToElement('" + hdnHTML.ClientID + "'," + ScriptHelper.GetString(Url) + ");";
        validate.Text          = GetString("general.validate");
        validate.Tooltip       = validate.Text;
        validate.ImageUrl      = GetImageUrl("Design/Controls/Validation/checks.png");
        validate.CommandName   = "validate";

        // View HTML code
        string click = GetViewSourceActionClick();

        HeaderAction viewCode = new HeaderAction();

        viewCode.ControlType   = HeaderActionTypeEnum.Hyperlink;
        viewCode.OnClientClick = click;
        viewCode.Text          = GetString("validation.viewcode");
        viewCode.Tooltip       = viewCode.Text;
        viewCode.ImageUrl      = GetImageUrl("Design/Controls/Validation/codeview.png");

        // Show results in new window
        HeaderAction newWindow = new HeaderAction();

        newWindow.ControlType   = HeaderActionTypeEnum.Hyperlink;
        newWindow.OnClientClick = click;
        newWindow.Text          = GetString("validation.showresultsnewwindow");
        newWindow.Tooltip       = newWindow.Text;

        if (DataHelper.DataSourceIsEmpty(DataSource))
        {
            newWindow.Enabled       = false;
            newWindow.OnClientClick = null;
            newWindow.ImageUrl      = GetImageUrl("Design/Controls/Validation/windownewdisabled.png");
        }
        else
        {
            string encodedKey = ScriptHelper.GetString(HttpUtility.UrlEncode(ResultKey), false);
            newWindow.OnClientClick = String.Format("modalDialog('" + ResolveUrl("~/CMSModules/Content/CMSDesk/Validation/ValidationResults.aspx") + "?datakey={0}&docid={1}&hash={2}', 'ViewValidationResult', 800, 600);return false;", encodedKey, Node.DocumentID, QueryHelper.GetHash(String.Format("?datakey={0}&docid={1}", encodedKey, Node.DocumentID)));
            newWindow.ImageUrl      = GetImageUrl("Design/Controls/Validation/windownew.png");
        }

        // Add actions and set help topic
        HeaderActions.AddAction(validate);
        HeaderActions.AddAction(viewCode);
        HeaderActions.AddAction(newWindow);
        HeaderActions.HelpName         = "helpTopic";
        HeaderActions.HelpTopicName    = "linkchecker";
        HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

        // Set sorting and add events
        gridValidationResult.IsLiveSite             = IsLiveSite;
        gridValidationResult.ZeroRowsText           = GetString("validation.link.notvalidated");
        gridValidationResult.OnExternalDataBound   += gridValidationResult_OnExternalDataBound;
        gridValidationResult.OnDataReload          += gridValidationResult_OnDataReload;
        gridValidationResult.GridView.RowDataBound += GridView_RowDataBound;
        gridValidationResult.ShowActionsMenu        = true;
        gridValidationResult.AllColumns             = "statuscode, type, message, url, time, statuscodevalue, timeint";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string templateType = QueryHelper.GetString("templatetype", String.Empty);

        // If not in site manager - filter class selector for only site documents
        if (!IsSiteManager)
        {
            ucClassSelector.SiteID = SiteContext.CurrentSiteID;
        }

        if (!RequestHelper.IsPostBack())
        {
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.item"), "item"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.alternatingitem"), "alternatingitem"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.firstitem"), "firstitem"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.lastitem"), "lastitem"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.header"), "header"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.footer"), "footer"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.singleitem"), "singleitem"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.separator"), "separator"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.currentitem"), "currentitem"));

            //If new template type set via url
            if (!String.IsNullOrEmpty(templateType))
            {
                drpTemplateType.SelectedValue = templateType == "all" ? "item" : templateType;
            }
        }

        //First edit after save ... show info message
        if (ShowInfoLabel)
        {
            ShowChangesSaved();
        }

        //Load transformations xml
        mTransformations = new HierarchicalTransformations("ClassName");
        if (TransInfo != null)
        {
            if (!String.IsNullOrEmpty(TransInfo.TransformationHierarchicalXML))
            {
                mTransformations.LoadFromXML(TransInfo.TransformationHierarchicalXML);
            }
        }

        //Edit
        if (HierarchicalID != Guid.Empty)
        {
            mHierInfo = mTransformations.GetTransformation(HierarchicalID);
            //Load Transformation values
            if (!RequestHelper.IsPostBack())
            {
                txtLevel.Text                 = mHierInfo.ItemLevel.ToString();
                ucTransformations.Value       = mHierInfo.TransformationName;
                ucClassSelector.Value         = mHierInfo.Value;
                templateType                  = HierarchicalTransformations.UniViewItemTypeToString(mHierInfo.ItemType);
                drpTemplateType.SelectedValue = templateType;
                chkApplyToSublevels.Checked   = mHierInfo.ApplyToSublevels;
            }
        }

        // Disable class selector for separator, header and foot transformation
        ucClassSelector.Enabled = true;
        if ((drpTemplateType.SelectedValue == "header") || (drpTemplateType.SelectedValue == "footer") || (drpTemplateType.SelectedValue == "separator"))
        {
            ucClassSelector.Value   = "";
            ucClassSelector.Enabled = false;
        }

        // Add save button
        if (Visible)
        {
            HeaderActions.AddAction(new SaveAction(Page));
            HeaderActions.ActionPerformed += btnOK_Click;
        }
    }
Esempio n. 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string newItemPage = "~/CMSModules/CustomTables/Tools/CustomTable_Data_EditItem.aspx";

        // Get form ID from url
        customTableId = QueryHelper.GetInteger("objectid", 0);

        // Running in site manager?
        bool siteManager = QueryHelper.GetInteger("sm", 0) == 1;

        DataClassInfo dci = null;

        // Read data only if user is site manager global admin or table is bound to current site
        if (CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) || (ClassSiteInfo.Provider.Get(customTableId, SiteContext.CurrentSiteID) != null))
        {
            // Get CustomTable class
            dci = DataClassInfoProvider.GetDataClassInfo(customTableId);
        }

        // Set edited object
        EditedObject = dci;

        if ((dci != null) && dci.ClassIsCustomTable)
        {
            customTableDataList.CustomTableClassInfo         = dci;
            customTableDataList.EditItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty);
            customTableDataList.ViewItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty);
            // Set alternative form and data container
            customTableDataList.UniGrid.FilterFormName = dci.ClassName + ".filter";
            customTableDataList.UniGrid.FilterFormData = CustomTableItem.New(dci.ClassName);

            ScriptHelper.RegisterDialogScript(this);
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" +
                                                                                                                ResolveUrl("~/CMSModules/CustomTables/Tools/CustomTable_Data_SelectFields.aspx") + "?customtableid=" + customTableId + "'  ,'CustomTableFields', 500, 500); }"));

            if (!siteManager)
            {
                PageTitle.TitleText = GetString("customtable.edit.header");
            }

            // Check 'Read' permission
            if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                plcContent.Visible = false;
                return;
            }

            // New item link
            bool canCreate = dci.CheckPermissions(PermissionsEnum.Create, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser);
            HeaderActions.AddAction(new HeaderAction
            {
                Text        = GetString("customtable.data.newitem"),
                RedirectUrl = ResolveUrl(newItemPage + "?new=1&objectid=" + customTableId + (siteManager ? "&sm=1" : "")),
                Enabled     = canCreate,
                Tooltip     = canCreate ? String.Empty : String.Format(GetString("customtable.permissiondenied.create"), dci.ClassName)
            });

            // Select fields link
            HeaderActions.AddAction(new HeaderAction
            {
                Text          = GetString("customtable.data.selectdisplayedfields"),
                OnClientClick = "SelectFields();",
                ButtonStyle   = ButtonStyle.Default,
            });

            if (!siteManager)
            {
                // Initializes page title
                PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
                {
                    Text        = GetString("customtable.list.title"),
                    RedirectUrl = "~/CMSModules/Customtables/Tools/CustomTable_List.aspx"
                });
                PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
                {
                    Text = dci.ClassDisplayName
                });
            }
        }
        else
        {
            customTableDataList.StopProcessing = true;
            customTableDataList.Visible        = false;

            ShowError(GetString("customtable.notcustomtable"));
        }
    }
Esempio n. 10
0
    /// <summary>
    /// Initializes all nested controls.
    /// </summary>
    private void SetupControls()
    {
        IsLiveSite = false;

        InitializeScripts();

        HeaderActions.ActionsList.Clear();

        // Validate action
        HeaderAction validate = new HeaderAction();

        validate.ControlType   = HeaderActionTypeEnum.Hyperlink;
        validate.OnClientClick = "LoadHTMLToElement('" + hdnHTML.ClientID + "'," + ScriptHelper.GetString(Url) + ");";
        validate.Text          = GetString("general.validate");
        validate.Tooltip       = validate.Text;
        validate.ImageUrl      = GetImageUrl("Design/Controls/Validation/checks.png");
        validate.CommandName   = "validate";

        // View HTML code
        string click = GetViewSourceActionClick();

        HeaderAction viewCode = new HeaderAction();

        viewCode.ControlType   = HeaderActionTypeEnum.Hyperlink;
        viewCode.OnClientClick = click;
        viewCode.Text          = GetString("validation.viewcode");
        viewCode.Tooltip       = viewCode.Text;
        viewCode.ImageUrl      = GetImageUrl("Design/Controls/Validation/codeview.png");

        // Show results in new window
        HeaderAction newWindow = new HeaderAction();

        newWindow.ControlType   = HeaderActionTypeEnum.Hyperlink;
        newWindow.OnClientClick = click;
        newWindow.Text          = GetString("validation.showresultsnewwindow");
        newWindow.Tooltip       = newWindow.Text;

        if (DataHelper.DataSourceIsEmpty(DataSource))
        {
            newWindow.Enabled       = false;
            newWindow.OnClientClick = null;
            newWindow.ImageUrl      = GetImageUrl("Design/Controls/Validation/windownewdisabled.png");
        }
        else
        {
            newWindow.Enabled = true;
            string encodedKey = ScriptHelper.GetString(HttpUtility.UrlEncode(ResultKey), false);
            newWindow.OnClientClick = String.Format("modalDialog('" + ResolveUrl("~/CMSModules/Content/CMSDesk/Validation/ValidationResults.aspx") + "?datakey={0}&docid={1}&hash={2}', 'ViewValidationResult', 800, 600);return false;", encodedKey, Node.DocumentID, QueryHelper.GetHash(String.Format("?datakey={0}&docid={1}", encodedKey, Node.DocumentID)));
            newWindow.ImageUrl      = GetImageUrl("Design/Controls/Validation/windownew.png");
        }

        HeaderActions.AddAction(validate);
        HeaderActions.AddAction(viewCode);
        HeaderActions.AddAction(newWindow);
        HeaderActions.HelpName         = "helpTopic";
        HeaderActions.HelpTopicName    = "htmlvalidator";
        HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

        // Set sorting and add events
        gridValidationResult.OrderBy              = "line ASC";
        gridValidationResult.IsLiveSite           = IsLiveSite;
        gridValidationResult.OnExternalDataBound += gridValidationResult_OnExternalDataBound;
        gridValidationResult.OnDataReload        += gridValidationResult_OnDataReload;
        gridValidationResult.ZeroRowsText         = GetString("validation.html.notvalidated");
        gridValidationResult.ShowActionsMenu      = true;
        gridValidationResult.AllColumns           = "line, column, message, explanation, source";

        // Set custom validating text
        up.ProgressHTML = String.Concat("<div style=\"display: none;\" id=\"", up.ClientID, "\" class=\"UP\"><div>", String.Concat("<img src=\"", UIHelper.GetImageUrl(Page, "Design/Preloaders/preload16.gif"), "\" alt=\"", GetString("validation.validating"), "\" /><span>", GetString("validation.validating"), "</span>"), "</div></div>");
    }
Esempio n. 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Unigrid
        gridElem.HideControlForZeroRows = false;
        gridElem.OrderBy              = "KeyOrder";
        gridElem.OnAction            += new OnActionEventHandler(KeyAction);
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.ZeroRowsText         = GetString("settings.group.nokeysfound");

        if (Category != null)
        {
            string catIdStr = Category.CategoryID.ToString();

            // Header actions
            HeaderActions actions = cpCategory.HeaderActions;
            actions.UseBasicStyles = true;
            actions.IconCssClass   = string.Empty;

            // Edit action
            actions.ActionsList.Add(new HeaderAction()
            {
                Text            = "",
                Tooltip         = GetString("general.edit"),
                ImageUrl        = GetImageUrl("Objects/CMS_CustomSettings/edit.png"),
                CommandName     = "edit",
                CommandArgument = catIdStr,
                ControlType     = HeaderActionTypeEnum.LinkButton
            });

            // Delete action
            actions.ActionsList.Add(new HeaderAction()
            {
                Text            = "",
                Tooltip         = GetString("general.delete"),
                ImageUrl        = GetImageUrl("Objects/CMS_CustomSettings/delete.png"),
                OnClientClick   = string.Format("return confirm({0})", ScriptHelper.GetString(GetString("Development.CustomSettings.GroupDeleteConfirmation"))),
                CommandName     = "delete",
                CommandArgument = catIdStr,
                ControlType     = HeaderActionTypeEnum.LinkButton
            });

            // Move up action
            actions.ActionsList.Add(new HeaderAction()
            {
                Text            = "",
                Tooltip         = GetString("general.moveup"),
                ImageUrl        = GetImageUrl("Objects/CMS_CustomSettings/up.png"),
                CommandName     = "moveup",
                CommandArgument = catIdStr,
                ControlType     = HeaderActionTypeEnum.LinkButton
            });

            // Move down action
            actions.ActionsList.Add(new HeaderAction()
            {
                Text            = "",
                Tooltip         = GetString("general.movedown"),
                ImageUrl        = GetImageUrl("Objects/CMS_CustomSettings/down.png"),
                CommandName     = "movedown",
                CommandArgument = catIdStr,
                ControlType     = HeaderActionTypeEnum.LinkButton
            });

            cpCategory.HeaderActions.ActionPerformed += new CommandEventHandler(CategoryActionPerformed);

            // Panel title for group
            cpCategory.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(Category.CategoryDisplayName));

            // Filter out only records for this group
            gridElem.WhereClause = "KeyCategoryID = " + Category.CategoryID;

            // Setup "Add key" link
            lnkNewKey.Text     = ResHelper.GetString("Development.CustomSettings.NewKey");
            lnkNewKey.Click   += new EventHandler(CreateNewKey);
            imgNewKey.ImageUrl = GetImageUrl("Objects/CMS_CustomSettings/list.png");
        }

        // Apply site filter if required.
        if (!string.IsNullOrEmpty(gridElem.WhereClause))
        {
            gridElem.WhereClause += " AND ";
        }

        if (mSiteId > 0)
        {
            gridElem.WhereClause += string.Format("SiteID = {0}", mSiteId);
        }
        else
        {
            gridElem.WhereClause += "SiteID IS NULL";
        }
    }
    /// <summary>
    /// Initializes action menu in master page.
    /// </summary>
    protected void InitializeActionMenu()
    {
        bool sending = EmailHelper.Queue.SendingInProgess;

        HeaderActions actions = CurrentMaster.HeaderActions;

        actions.ActionsList.Clear();

        string confirmScript = "if (!confirm({0})) return false;";

        // Resend all failed
        actions.ActionsList.Add(new HeaderAction()
        {
            Text          = GetString("emailqueue.queue.resendfailed"),
            OnClientClick = !sending ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.ResendAllFailedConfirmation"))) : null,
            ImageUrl      = !sending ? GetImageUrl("CMSModules/CMS_EmailQueue/resendallfailed.png") : GetImageUrl("CMSModules/CMS_EmailQueue/resendallfailed_disabled.png"),
            CommandName   = "resendallfailed",
            Enabled       = !sending
        });

        // Resend selected
        actions.ActionsList.Add(new HeaderAction()
        {
            Text          = GetString("emailqueue.queue.resendselected"),
            OnClientClick = !sending ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.ResendSelectedConfirmation"))) : null,
            ImageUrl      = !sending ? GetImageUrl("CMSModules/CMS_EmailQueue/resendselected.png") : GetImageUrl("CMSModules/CMS_EmailQueue/resendselected_disabled.png"),
            CommandName   = "resendselected",
            Enabled       = !sending
        });

        // Resend all
        actions.ActionsList.Add(new HeaderAction()
        {
            Text          = GetString("emailqueue.queue.resend"),
            OnClientClick = !sending ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.ResendAllConfirmation"))) : null,
            ImageUrl      = !sending ? GetImageUrl("CMSModules/CMS_EmailQueue/resendall.png") : GetImageUrl("CMSModules/CMS_EmailQueue/resendall_disabled.png"),
            CommandName   = "resendall",
            Enabled       = !sending
        });

        // Delete all failed
        actions.ActionsList.Add(new HeaderAction()
        {
            Text          = GetString("emailqueue.queue.deletefailed"),
            OnClientClick = !sending ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.DeleteAllFailedConfirmation"))) : null,
            ImageUrl      = !sending ? GetImageUrl("CMSModules/CMS_EmailQueue/deleteallfailed.png") : GetImageUrl("CMSModules/CMS_EmailQueue/deleteallfailed_disabled.png"),
            CommandName   = "deleteallfailed",
            Enabled       = !sending
        });

        // Delete selected
        actions.ActionsList.Add(new HeaderAction()
        {
            Text          = GetString("emailqueue.queue.deleteselected"),
            OnClientClick = !sending ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.DeleteSelectedConfirmation"))) : null,
            ImageUrl      = !sending ? GetImageUrl("CMSModules/CMS_EmailQueue/deleteselected.png") : GetImageUrl("CMSModules/CMS_EmailQueue/deleteselected_disabled.png"),
            CommandName   = "deleteselected",
            Enabled       = !sending
        });

        // Delete all
        actions.ActionsList.Add(new HeaderAction()
        {
            Text          = GetString("emailqueue.queue.delete"),
            OnClientClick = !sending ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.DeleteAllConfirmation"))) : null,
            ImageUrl      = !sending ? GetImageUrl("CMSModules/CMS_EmailQueue/deleteall.png") : GetImageUrl("CMSModules/CMS_EmailQueue/deleteall_disabled.png"),
            CommandName   = "deleteall",
            Enabled       = !sending
        });

        // Stop send
        actions.ActionsList.Add(new HeaderAction()
        {
            Text          = GetString("emailqueue.queue.stop"),
            OnClientClick = sending ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.StopConfirmation"))) : null,
            ImageUrl      = sending ? GetImageUrl("CMSModules/CMS_EmailQueue/stopsend.png") : GetImageUrl("CMSModules/CMS_EmailQueue/stopsend_disabled.png"),
            CommandName   = "stop",
            Enabled       = sending
        });

        // Refresh
        actions.ActionsList.Add(new HeaderAction()
        {
            Text        = GetString("general.refresh"),
            ImageUrl    = GetImageUrl("CMSModules/CMS_EmailQueue/refresh.png"),
            CommandName = "refresh"
        });

        actions.ActionPerformed += HeaderActions_ActionPerformed;
    }
Esempio n. 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script for pendingCallbacks repair
        ScriptHelper.FixPendingCallbacks(Page);

        // Get site info
        currentSiteId   = SiteContext.CurrentSiteID;
        currentSiteName = SiteContext.CurrentSiteName;

        // Initialize current user for the async actions
        currentUser = MembershipContext.AuthenticatedUser;
        serverId    = QueryHelper.GetInteger("serverid", 0);

        HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

        if (ControlsHelper.CausedPostBack(btnSyncComplete))
        {
            SyncComplete();
        }
        else
        {
            if (!RequestHelper.IsCallback())
            {
                int nodeId = QueryHelper.GetInteger("nodeid", 0);

                aliasPath = "/";

                // Get the document node
                if (nodeId > 0)
                {
                    TreeProvider tree = new TreeProvider(currentUser);
                    TreeNode     node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES);
                    if (node != null)
                    {
                        aliasPath = node.NodeAliasPath;
                    }
                }

                // Setup title
                titleElem.TitleText           = GetString("Synchronization.Title");
                ucDisabledModule.SettingsKeys = "CMSStagingLogChanges";
                ucDisabledModule.InfoTexts.Add(GetString("ContentStaging.TaskSeparator") + "<br/>");
                ucDisabledModule.InfoTexts.Add(GetString("StagingChanges.NotLogged"));
                ucDisabledModule.ParentPanel = pnlNotLogged;

                // Check logging
                if (!ucDisabledModule.Check())
                {
                    plcContent.Visible = false;
                    pnlFooter.Visible  = false;
                    return;
                }

                // Create header actions
                HeaderActions.AddAction(new HeaderAction()
                {
                    Text      = GetString("Tasks.SyncCurrent"),
                    EventName = SYNCHRONIZE_CURRENT
                });

                HeaderActions.AddAction(new HeaderAction()
                {
                    Text      = GetString("Tasks.SyncSubtree"),
                    EventName = SYNCHRONIZE_SUBTREE
                });

                if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll))
                {
                    // Check 'Manage servers' permission
                    if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks"))
                    {
                        RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks");
                    }

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

                    ltlScript.Text +=
                        ScriptHelper.GetScript("function ConfirmDeleteTask(taskId) { return confirm(" +
                                               ScriptHelper.GetString(GetString("Tasks.ConfirmDelete")) + "); }");
                    ltlScript.Text +=
                        ScriptHelper.GetScript("function CompleteSync(){" +
                                               Page.ClientScript.GetPostBackEventReference(btnSyncComplete, null) + "}");

                    // Initialize grid
                    tasksUniGrid.OnExternalDataBound += tasksUniGrid_OnExternalDataBound;
                    tasksUniGrid.OnAction            += tasksUniGrid_OnAction;
                    tasksUniGrid.OnDataReload        += tasksUniGrid_OnDataReload;
                    tasksUniGrid.ShowActionsMenu      = true;
                    tasksUniGrid.Columns              = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount";
                    StagingTaskInfo ti = new StagingTaskInfo();
                    tasksUniGrid.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames);

                    plcContent.Visible = true;

                    // Initialize buttons
                    btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;");
                    btnCancel.Text                  = GetString("General.Cancel");
                    btnDeleteAll.Text               = GetString("Tasks.DeleteAll");
                    btnDeleteSelected.Text          = GetString("Tasks.DeleteSelected");
                    btnSyncAll.Text                 = GetString("Tasks.SyncAll");
                    btnSyncSelected.Text            = GetString("Tasks.SyncSelected");
                    btnSyncSelected.OnClientClick   = "return !" + tasksUniGrid.GetCheckSelectionScript();
                    btnDeleteAll.OnClientClick      = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");";
                    btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");";

                    pnlLog.Visible = false;
                }
            }
        }

        ctlAsync.OnFinished   += ctlAsync_OnFinished;
        ctlAsync.OnError      += ctlAsync_OnError;
        ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
        ctlAsync.OnCancel     += ctlAsync_OnCancel;
    }
Esempio n. 14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for CMS Desk -> Tools
        CurrentUserInfo user = CMSContext.CurrentUser;

        if (!user.IsAuthorizedPerUIElement("CMS.Desk", "Tools"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Desk", "Tools");
        }

        // Check permissions for CMS Desk -> Tools -> BizForms
        if (!user.IsAuthorizedPerUIElement("CMS.Tools", "Form"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Tools", "Form");
        }

        // Check 'ReadData' permission
        if (!user.IsAuthorizedPerResource("cms.form", "ReadData"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadData");
        }

        // Get form id from url
        formId = QueryHelper.GetInteger("formid", 0);

        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        EditedObject = bfi;

        if (bfi != null)
        {
            // Check authorized roles for this form
            if (!bfi.IsFormAllowedForUser(CMSContext.CurrentUser.UserName, CMSContext.CurrentSiteName))
            {
                RedirectToAccessDenied(GetString("Bizforms.FormNotAllowedForUserRoles"));
            }
        }

        List <String> columnNames  = null;
        DataClassInfo dci          = null;
        Hashtable     reportFields = new Hashtable();
        FormInfo      fi           = null;

        // Initialize controls
        CurrentMaster.Title.TitleText     = GetString("BizForm_Edit_Data_SelectFields.Title");
        CurrentMaster.Title.TitleImage    = GetImageUrl("CMSModules/CMS_Form/selectfields.png");
        CurrentMaster.DisplayActionsPanel = true;

        HeaderActions.AddAction(new HeaderAction()
        {
            ImageUrl      = GetImageUrl("Design/Controls/UI/selectall.png"),
            Text          = GetString("UniSelector.SelectAll"),
            OnClientClick = "ChangeFields(true); return false;"
        });

        HeaderActions.AddAction(new HeaderAction()
        {
            ImageUrl      = GetImageUrl("Design/Controls/UI/deselectall.png"),
            Text          = GetString("UniSelector.DeselectAll"),
            OnClientClick = "ChangeFields(false); return false;"
        });

        if (!RequestHelper.IsPostBack())
        {
            btnOk.Text     = GetString("General.OK");
            btnCancel.Text = GetString("General.Cancel");

            if (bfi != null)
            {
                // Get dataclass info
                dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);

                if (dci != null)
                {
                    // Get columns names
                    fi = FormHelper.GetFormInfo(dci.ClassName, false);

                    columnNames = fi.GetColumnNames();
                }

                // Get report fields
                if (String.IsNullOrEmpty(bfi.FormReportFields))
                {
                    reportFields = LoadReportFields(columnNames);
                }
                else
                {
                    reportFields.Clear();

                    foreach (string field in bfi.FormReportFields.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                if (columnNames != null)
                {
                    FormFieldInfo ffi  = null;
                    ListItem      item = null;
                    foreach (string name in columnNames)
                    {
                        ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        item = new ListItem(ResHelper.LocalizeString(GetFieldCaption(ffi, name)), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterTooltip(Page);

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

        ctlAsyncLog.Buttons.CssClass = "cms-edit-menu";

        HeaderActions.AddAction(new HeaderAction
        {
            Text        = GetString("srch.clearattachmentcache"),
            Tooltip     = GetString("srch.clearattachmentcache.tooltip"),
            CommandName = "clearcache"
        });

        HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

        if (RequestHelper.IsCallback())
        {
            pnlContent.Visible = false;

            gridFiles.StopProcessing    = true;
            siteSelector.StopProcessing = true;

            return;
        }


        // Setup the controls
        gridFiles.OnExternalDataBound += gridFiles_OnExternalDataBound;
        gridFiles.OnAction            += gridFiles_OnAction;

        ControlsHelper.RegisterPostbackControl(btnOk);

        currentSiteId = SiteContext.CurrentSiteID;

        CurrentMaster.DisplaySiteSelectorPanel = true;

        // Setup the site selection
        siteSelector.DropDownSingleSelect.AutoPostBack = true;

        if (!RequestHelper.IsPostBack() && (currentSiteId > 0))
        {
            siteSelector.Value = currentSiteId;
        }

        siteId = ValidationHelper.GetInteger(siteSelector.Value, 0);
        if (siteId > 0)
        {
            siteWhere = "AttachmentSiteID = " + siteId;
            gridFiles.WhereCondition = siteWhere;
            UIContext["SiteID"]      = siteId;
        }

        if (!RequestHelper.IsPostBack())
        {
            // Fill in the actions
            drpAction.Items.Add(new ListItem(GetString("general.selectaction"), ""));

            bool copyDB   = true;
            bool copyFS   = true;
            bool deleteDB = true;
            bool deleteFS = true;

            if (siteId > 0)
            {
                var filesLocationType = GetFilesLocationType(siteId);

                bool fs = filesLocationType != FilesLocationTypeEnum.Database;
                bool db = filesLocationType != FilesLocationTypeEnum.FileSystem;

                copyFS   = deleteDB = fs;
                deleteFS = db;
                copyDB   = db && fs;
            }

            if (copyDB)
            {
                drpAction.Items.Add(new ListItem("Copy to database", "copytodatabase"));
            }
            if (copyFS)
            {
                drpAction.Items.Add(new ListItem("Copy to file system", "copytofilesystem"));
            }
            if (deleteDB)
            {
                drpAction.Items.Add(new ListItem("Delete from database", "deleteindatabase"));
            }
            if (deleteFS)
            {
                drpAction.Items.Add(new ListItem("Delete from file system", "deleteinfilesystem"));
            }
        }
    }
Esempio n. 16
0
    /// <summary>
    /// Creates buttons in header actions
    /// </summary>
    private void CreateButtons()
    {
        bool allowed = CheckModifyPermissions(false);

        var processAction = new HeaderAction
        {
            ButtonStyle   = ButtonStyle.Default,
            CommandName   = PROCESS_ACTION,
            OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("translationservice.confirmprocesstranslations")) + ")) { return false; }",
            Tooltip       = GetString("translationservice.importtranslationstooltip"),
            Text          = GetString("translationservice.importtranslations"),
            Enabled       = allowed && ((SubmissionInfo.SubmissionStatus == TranslationStatusEnum.TranslationReady) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.TranslationCompleted) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.ProcessingError))
        };

        var resubmitAction = new HeaderAction
        {
            ButtonStyle = ButtonStyle.Default,
            CommandName = RESUBMIT_ACTION,
            Tooltip     = GetString("translationservice.resubmittooltip"),
            Text        = GetString("translationservice.resubmit"),
            Enabled     = allowed && ((SubmissionInfo.SubmissionStatus == TranslationStatusEnum.WaitingForTranslation) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.SubmissionError))
        };

        var updateAction = new HeaderAction
        {
            ButtonStyle = ButtonStyle.Default,
            CommandName = "updateandresubmit",
            Tooltip     = GetString("translationservice.updateandresubmittooltip"),
            Text        = GetString("translationservice.updateandresubmit"),
            Enabled     = allowed && ((SubmissionInfo.SubmissionStatus == TranslationStatusEnum.WaitingForTranslation) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.SubmissionError))
        };

        var saveAction = new SaveAction();

        saveAction.Enabled = allowed;

        var actions = HeaderActions.ActionsList;

        actions.AddRange(new[]
        {
            saveAction,
            updateAction,
            resubmitAction,
            processAction
        });

        var service = TranslationServiceInfo.Provider.Get(SubmissionInfo.SubmissionServiceID);

        if (service != null)
        {
            bool serviceSupportsCancel = service.TranslationServiceSupportsCancel;

            var cancelAction = new HeaderAction
            {
                ButtonStyle = ButtonStyle.Default,
                CommandName = "cancel",
                Tooltip     = serviceSupportsCancel ? GetString("translationservice.cancelsubmissiontooltip") : String.Format(GetString("translationservice.cancelnotsupported"), service.TranslationServiceDisplayName),
                Text        = GetString("translationservice.cancelsubmission"),
                Enabled     = allowed && (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.WaitingForTranslation) && serviceSupportsCancel
            };

            actions.Add(cancelAction);
        }

        HeaderActions.ReloadData();
    }
Esempio n. 17
0
    /// <summary>
    /// Ensures changes in UI to indicate asynchronous progress
    /// </summary>
    private void HandleAsyncProgress()
    {
        if (Grid.IsEmpty)
        {
            return;
        }

        string statusCheck = SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".CMSTranslationsLastStatusCheck");

        if (string.IsNullOrEmpty(statusCheck))
        {
            statusCheck = GetString("general.notavailable");
        }

        ShowInformation(string.Format(GetString("translationservice.laststatuscheck"), statusCheck));

        var page = Page as CMSPage;

        if (page == null)
        {
            return;
        }

        var threadRunning = IsRunningThread();

        if (threadRunning)
        {
            var label = LoadUserControl("~/CMSFormControls/Basic/LabelControl.ascx") as FormEngineUserControl;
            if (label != null)
            {
                label.ID = "lblStatus";

                string text;

                var parameter = ctlAsync.Parameter;
                if (parameter != null)
                {
                    string error;
                    string action;
                    string submissionName;

                    ParseParameter(parameter, out action, out error, out submissionName);

                    if (action == UPDATE_STATUSES_ACTION)
                    {
                        text = GetString("translationservice.updatingstatuses");
                    }
                    else
                    {
                        var status = (action == PROCESS_ACTION) ? TranslationStatusEnum.ProcessingSubmission : TranslationStatusEnum.ResubmittingSubmission;

                        text = string.Format(GetString(status.ToLocalizedString("translations.status.name")), HTMLHelper.HTMLEncode(submissionName));
                    }
                }
                else
                {
                    text = GetString("translationservice.updatingstatuses");
                }

                label.Value = ScriptHelper.GetLoaderInlineHtml(text);
                HeaderActions.AdditionalControls.Add(label);
                HeaderActions.AdditionalControlsCssClass = "header-actions-label control-group-inline";
                HeaderActions.ReloadAdditionalControls();
            }
        }

        HeaderActions.Enabled = !threadRunning;
    }
Esempio n. 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get custom table id from url
        customTableId = QueryHelper.GetInteger("customtableid", 0);

        dci = DataClassInfoProvider.GetDataClassInfo(customTableId);

        // Set edited object
        EditedObject = dci;

        // If class exists and is custom table
        if ((dci != null) && dci.ClassIsCustomTable)
        {
            // Ensure that object belongs to current site or user has access to site manager
            if (!CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) && (dci.AssignedSites[SiteContext.CurrentSiteName] == null))
            {
                RedirectToInformation(GetString("general.notassigned"));
            }

            PageTitle.TitleText = GetString("customtable.data.selectdisplayedfields");
            CurrentMaster.DisplayActionsPanel = true;

            // Check 'Read' permission
            if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                plcContent.Visible = false;
                return;
            }

            HeaderActions.AddAction(new HeaderAction
            {
                Text          = GetString("UniSelector.SelectAll"),
                OnClientClick = "ChangeFields(true); return false;",
                ButtonStyle   = ButtonStyle.Default,
            });

            HeaderActions.AddAction(new HeaderAction
            {
                Text          = GetString("UniSelector.DeselectAll"),
                OnClientClick = "ChangeFields(false); return false;",
                ButtonStyle   = ButtonStyle.Default,
            });

            if (!RequestHelper.IsPostBack())
            {
                Hashtable reportFields = new Hashtable();

                // Get report fields
                if (!String.IsNullOrEmpty(dci.ClassShowColumns))
                {
                    reportFields.Clear();

                    foreach (string field in dci.ClassShowColumns.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                // Get columns names
                FormInfo fi          = FormHelper.GetFormInfo(dci.ClassName, false);
                var      columnNames = fi.GetColumnNames(false);

                if (columnNames != null)
                {
                    MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + dci.ClassName);
                    FormFieldInfo ffi;
                    ListItem      item;
                    foreach (string name in columnNames)
                    {
                        ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        item = new ListItem(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(GetFieldCaption(ffi, name, resolver))), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
        else
        {
            ShowError(GetString("customtable.notcustomtable"));
            CurrentMaster.FooterContainer.Visible = false;
        }
    }
Esempio n. 19
0
        public void InitPage(bool isGet = true)
        {
            var entMan = new EntityManager();

            ErpEntity = entMan.ReadEntity(ParentRecordId ?? Guid.Empty).Object;

            var allCards = AdminPageUtils.GetFieldCards();

            if (FieldTypeId > 19 || FieldTypeId < 1)
            {
                throw new Exception("unsupported field type");
            }

            FieldCard = allCards.First(x => (string)x["type"] == FieldTypeId.ToString());

            if (Enum.TryParse <FieldType>(FieldTypeId.ToString(), out FieldType result))
            {
                Type = result;
            }

            if (isGet)
            {
                #region << Field Type init >>
                switch (Type)
                {
                case FieldType.AutoNumberField:
                    DisplayFormat = "{0}";
                    break;

                case FieldType.CurrencyField:
                    CurrencyOptions = Helpers.GetAllCurrency().MapTo <SelectOption>();
                    break;

                case FieldType.DateTimeField:
                    Format = "yyyy-MMM-dd HH:mm";
                    break;

                default:
                    break;
                }

                #endregion

                #region << Init RecordPermissions >>
                var valueGrid = new List <KeyStringList>();
                PermissionOptions = new List <SelectOption>()
                {
                    new SelectOption("read", "read"),
                    new SelectOption("update", "update")
                };

                var roles = AdminPageUtils.GetUserRoles();                 //Special order is applied

                foreach (var role in roles)
                {
                    RoleOptions.Add(new SelectOption(role.Id.ToString(), role.Name));
                    var keyValuesObj = new KeyStringList()
                    {
                        Key    = role.Id.ToString(),
                        Values = new List <string>()
                    };
                }

                #endregion
            }



            #region << Actions >>
            HeaderActions.AddRange(new List <string>()
            {
                PageUtils.GetActionTemplate(PageUtilsActionType.SubmitForm, label: "Create Field", formId: "CreateRecord", btnClass: "btn btn-green btn-sm", iconClass: "fa fa-plus"),
                PageUtils.GetActionTemplate(PageUtilsActionType.Cancel, returnUrl: ReturnUrl)
            });

            #endregion
        }
Esempio n. 20
0
        public void PageInit()
        {
            Init();

            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = "/sdk/objects/entity/l/list";
            }


            #region << Init Entity >>
            var entMan = new EntityManager();
            ErpEntity = entMan.ReadEntity(RecordId ?? Guid.Empty).Object;
            if (ErpEntity == null)
            {
                return;
            }

            if (ErpEntity.RecordScreenIdField != null)
            {
                var screenField = ErpEntity.Fields.FirstOrDefault(x => x.Id == ErpEntity.RecordScreenIdField);
                if (screenField != null)
                {
                    RecordScreenIdFieldName = screenField.Name;
                }
            }

            #endregion

            #region << Init RecordPermissions >>
            var valueGrid = new List <KeyStringList>();
            PermissionOptions = new List <SelectOption>()
            {
                new SelectOption("create", "create"),
                new SelectOption("read", "read"),
                new SelectOption("update", "update"),
                new SelectOption("delete", "delete")
            };

            var roles = AdminPageUtils.GetUserRoles();             //Special order is applied

            foreach (var role in roles)
            {
                RoleOptions.Add(new SelectOption(role.Id.ToString(), role.Name));
                var keyValuesObj = new KeyStringList()
                {
                    Key    = role.Id.ToString(),
                    Values = new List <string>()
                };
                if (ErpEntity.RecordPermissions.CanCreate.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("create");
                }
                if (ErpEntity.RecordPermissions.CanRead.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("read");
                }
                if (ErpEntity.RecordPermissions.CanUpdate.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("update");
                }
                if (ErpEntity.RecordPermissions.CanDelete.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("delete");
                }

                valueGrid.Add(keyValuesObj);
            }
            RecordPermissions = JsonConvert.SerializeObject(valueGrid);
            #endregion

            #region << Actions >>

            if (ErpEntity.System)
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.Disabled, label: "Delete locked", formId: "DeleteRecord", btnClass: "btn btn-white btn-sm", iconClass: "fa fa-trash-alt", titleText: "System objects cannot be deleted"));
            }
            else
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.ConfirmAndSubmitForm, label: "Delete Entity", formId: "DeleteRecord", btnClass: "btn btn-white btn-sm", iconClass: "fa fa-trash-alt go-red"));
            };

            HeaderActions.Add($"<a href='/sdk/objects/entity/m/{(ErpEntity != null ? ErpEntity.Id : Guid.Empty)}/manage?returnUrl={HttpUtility.UrlEncode(CurrentUrl)}' class='btn btn-white btn-sm'><i class='fa fa-cog go-orange'></i> Manage</a>");

            HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "details"));

            #endregion
        }
Esempio n. 21
0
        public IActionResult OnGet()
        {
            var initResult = Init();

            if (initResult != null)
            {
                return(initResult);
            }

            var entMan = new EntityManager();

            #region << InitPage >>
            int           pager     = 0;
            string        sortBy    = "";
            QuerySortType sortOrder = QuerySortType.Ascending;
            PageUtils.GetListQueryParams(PageContext.HttpContext, out pager, out sortBy, out sortOrder);
            Pager     = pager;
            SortBy    = sortBy;
            SortOrder = sortOrder;

            ErpEntity = entMan.ReadEntity(ParentRecordId ?? Guid.Empty).Object;

            if (ErpEntity == null)
            {
                return(NotFound());
            }

            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = $"/sdk/objects/entity/r/{ErpEntity.Id}/";
            }

            var allFields = ErpEntity.Fields;

            #region << Apply filters >>
            var submittedFilters = PageUtils.GetPageFiltersFromQuery(PageContext.HttpContext);
            if (submittedFilters.Count > 0)
            {
                foreach (var filter in submittedFilters)
                {
                    switch (filter.Name)
                    {
                    case "name":
                        if (filter.Type == FilterType.CONTAINS)
                        {
                            allFields = allFields.FindAll(x => x.Name.ToLowerInvariant().Contains(filter.Value.ToLowerInvariant())).ToList();
                        }
                        break;
                    }
                }
            }
            #endregion

            allFields  = allFields.OrderBy(x => x.Name).ToList();
            TotalCount = allFields.Count;

            ReturnUrlEncoded = HttpUtility.UrlEncode(PageUtils.GetCurrentUrl(PageContext.HttpContext));

            PageDescription = PageUtils.GenerateListPageDescription(PageContext.HttpContext, "", TotalCount);
            #endregion

            #region << Create Columns >>

            Columns = new List <WvGridColumnMeta>()
            {
                new WvGridColumnMeta()
                {
                    Name  = "action",
                    Width = "1%"
                },
                new WvGridColumnMeta()
                {
                    Label      = "Name",
                    Name       = "name",
                    Sortable   = true,
                    Searchable = true
                },
                new WvGridColumnMeta()
                {
                    Label = "Type",
                    Name  = "type",
                    Width = "120px"
                },
                new WvGridColumnMeta()
                {
                    Label = "System",
                    Name  = "system",
                    Width = "1%"
                },
                new WvGridColumnMeta()
                {
                    Label = "Required",
                    Name  = "required",
                    Width = "1%"
                },
                new WvGridColumnMeta()
                {
                    Label = "Unique",
                    Name  = "unique",
                    Width = "80px"
                },
                new WvGridColumnMeta()
                {
                    Label = "Searchable",
                    Name  = "searchable",
                    Width = "1%"
                },
            };

            #endregion

            #region << Records >>
            //Apply sort
            if (!String.IsNullOrWhiteSpace(SortBy))
            {
                switch (SortBy)
                {
                case "name":
                    if (SortOrder == QuerySortType.Descending)
                    {
                        allFields = allFields.OrderByDescending(x => x.Name).ToList();
                    }
                    else
                    {
                        allFields = allFields.OrderBy(x => x.Name).ToList();
                    }
                    break;

                default:
                    break;
                }
            }

            //Apply pager
            var skipPages = (Pager - 1) * PagerSize;
            allFields = allFields.Skip(skipPages).Take(PagerSize).ToList();

            foreach (var field in allFields)
            {
                var record = new EntityRecord();
                record["action"]     = $"<a class='btn btn-sm btn-outline-secondary' title='App details' href='/sdk/objects/entity/r/{ErpEntity.Id}/rl/fields/r/{field.Id}?returnUrl={ReturnUrlEncoded}'><span class='fa fa-eye'></span></a>";
                record["name"]       = field.Name;
                record["type"]       = field.GetFieldType().ToString();
                record["system"]     = field.System;
                record["required"]   = field.Required;
                record["unique"]     = field.Unique;
                record["searchable"] = field.Searchable;
                Records.Add(record);
            }
            #endregion

            #region << Actions >>
            HeaderActions.AddRange(new List <string>()
            {
                $"<a href='/sdk/objects/entity/r/{(ErpEntity != null ? ErpEntity.Id : Guid.Empty)}/rl/fields/c/select?returnUrl={ReturnUrlEncoded}' class='btn btn-white btn-sm'><span class='fa fa-plus go-green'></span> Create Field</a>",
                $"<button type='button' onclick='ErpEvent.DISPATCH(\"WebVella.Erp.Web.Components.PcDrawer\",\"open\")' class='btn btn-white btn-sm'><span class='fa fa-search'></span> Search</a>"
            });
            HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "fields"));
            #endregion


            ErpRequestContext.PageContext = PageContext;

            BeforeRender();
            return(Page());
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.Title.TitleText     = GetString("customtable.data.selectdisplayedfields");
        CurrentMaster.Title.TitleImage    = GetImageUrl("CMSModules/CMS_CustomTables/selectfields.png");
        CurrentMaster.DisplayActionsPanel = true;

        // Get custom table id from url
        customTableId = QueryHelper.GetInteger("customtableid", 0);

        dci = DataClassInfoProvider.GetDataClass(customTableId);
        // Set edited object
        EditedObject = dci;

        // If class exists
        if (dci != null)
        {
            // Check 'Read' permission
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.customtables", "Read") &&
                !CMSContext.CurrentUser.IsAuthorizedPerClassName(dci.ClassName, "Read"))
            {
                ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                plcContent.Visible = false;
                return;
            }

            HeaderActions.AddAction(new HeaderAction()
            {
                ImageUrl      = GetImageUrl("Design/Controls/UI/selectall.png"),
                Text          = GetString("UniSelector.SelectAll"),
                OnClientClick = "ChangeFields(true); return false;"
            });

            HeaderActions.AddAction(new HeaderAction()
            {
                ImageUrl      = GetImageUrl("Design/Controls/UI/deselectall.png"),
                Text          = GetString("UniSelector.DeselectAll"),
                OnClientClick = "ChangeFields(false); return false;"
            });

            Hashtable reportFields = new Hashtable();

            FormInfo fi = null;

            if (!RequestHelper.IsPostBack())
            {
                btnOk.Text     = GetString("General.OK");
                btnCancel.Text = GetString("General.Cancel");

                // Get report fields
                if (!String.IsNullOrEmpty(dci.ClassShowColumns))
                {
                    reportFields.Clear();

                    foreach (string field in dci.ClassShowColumns.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                // Get columns names
                fi = FormHelper.GetFormInfo(dci.ClassName, false);
                var columnNames = fi.GetColumnNames();

                if (columnNames != null)
                {
                    FormFieldInfo ffi  = null;
                    ListItem      item = null;
                    foreach (string name in columnNames)
                    {
                        ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        item = new ListItem(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(GetFieldCaption(ffi, name))), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
    }
Esempio n. 23
0
    /// <summary>
    /// Initializes all nested controls.
    /// </summary>
    private void SetupControls()
    {
        IsLiveSite = false;

        InitializeScripts();

        HeaderActions.ActionsList.Clear();

        // Validate action
        HeaderAction validate = new HeaderAction();

        validate.OnClientClick = "LoadHTMLToElement('" + hdnHTML.ClientID + "'," + ScriptHelper.GetString(Url) + ");";
        validate.Text          = GetString("general.validate");
        validate.Tooltip       = validate.Text;
        validate.CommandName   = "validate";

        // View HTML code
        string click = GetViewSourceActionClick();

        HeaderAction viewCode = new HeaderAction();

        viewCode.OnClientClick = click;
        viewCode.Text          = GetString("validation.viewcode");
        viewCode.Tooltip       = viewCode.Text;
        viewCode.ButtonStyle   = ButtonStyle.Default;

        // Show results in new window
        HeaderAction newWindow = new HeaderAction();

        newWindow.OnClientClick = click;
        newWindow.Text          = GetString("validation.showresultsnewwindow");
        newWindow.Tooltip       = newWindow.Text;
        newWindow.ButtonStyle   = ButtonStyle.Default;

        if (DataHelper.DataSourceIsEmpty(DataSource))
        {
            newWindow.Enabled       = false;
            newWindow.OnClientClick = null;
        }
        else
        {
            newWindow.Enabled = true;
            string encodedKey = ScriptHelper.GetString(HttpUtility.UrlEncode(ResultKey), false);
            newWindow.OnClientClick = String.Format("modalDialog('" + ResolveUrl("~/CMSModules/Content/CMSDesk/Validation/ValidationResults.aspx") + "?datakey={0}&docid={1}&hash={2}', 'ViewValidationResult', 800, 600);return false;", encodedKey, Node.DocumentID, QueryHelper.GetHash(String.Format("?datakey={0}&docid={1}", encodedKey, Node.DocumentID)));
        }

        HeaderActions.AddAction(validate);
        HeaderActions.AddAction(viewCode);
        HeaderActions.AddAction(newWindow);
        HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

        // Set sorting and add events
        gridValidationResult.OrderBy              = "line";
        gridValidationResult.IsLiveSite           = IsLiveSite;
        gridValidationResult.OnExternalDataBound += gridValidationResult_OnExternalDataBound;
        gridValidationResult.OnDataReload        += gridValidationResult_OnDataReload;
        gridValidationResult.ZeroRowsText         = GetString("validation.access.notvalidated");
        gridValidationResult.ShowActionsMenu      = true;
        gridValidationResult.AllColumns           = "line, column, accessibilityrule, error, fixsuggestion, source";

        // Set custom validating text
        up.ProgressText        = GetString("validation.validating");
        mStandardList.CssClass = "";
    }
Esempio n. 24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        Save += btnOK_Click;

        var user = MembershipContext.AuthenticatedUser;

        // Check permissions for Forms application
        if (!user.IsAuthorizedPerUIElement("cms.form", "Form"))
        {
            RedirectToUIElementAccessDenied("cms.form", "Form");
        }

        // Check 'ReadData' permission
        if (!user.IsAuthorizedPerResource("cms.form", "ReadData", SiteInfoProvider.GetSiteName(FormInfo.FormSiteID)))
        {
            RedirectToAccessDenied("cms.form", "ReadData");
        }

        // Check authorized roles for this form
        if (!FormInfo.IsFormAllowedForUser(MembershipContext.AuthenticatedUser.UserName, SiteContext.CurrentSiteName))
        {
            RedirectToAccessDenied(GetString("Bizforms.FormNotAllowedForUserRoles"));
        }

        List <String> columnNames  = null;
        DataClassInfo dci          = null;
        Hashtable     reportFields = new Hashtable();
        FormInfo      fi           = null;

        // Initialize controls
        PageTitle.TitleText = GetString("BizForm_Edit_Data_SelectFields.Title");
        CurrentMaster.DisplayActionsPanel = true;

        HeaderActions.AddAction(new HeaderAction
        {
            Text          = GetString("UniSelector.SelectAll"),
            OnClientClick = "ChangeFields(true); return false;",
            ButtonStyle   = ButtonStyle.Default,
        });

        HeaderActions.AddAction(new HeaderAction
        {
            Text          = GetString("UniSelector.DeselectAll"),
            OnClientClick = "ChangeFields(false); return false;",
            ButtonStyle   = ButtonStyle.Default,
        });

        if (!RequestHelper.IsPostBack())
        {
            if (FormInfo != null)
            {
                // Get dataclass info
                dci = DataClassInfoProvider.GetDataClassInfo(FormInfo.FormClassID);

                if (dci != null)
                {
                    // Get columns names
                    fi = FormHelper.GetFormInfo(dci.ClassName, false);

                    columnNames = fi.GetColumnNames(false, i => i.System);
                }

                // Get report fields
                if (String.IsNullOrEmpty(FormInfo.FormReportFields))
                {
                    reportFields = LoadReportFields(columnNames);
                }
                else
                {
                    reportFields.Clear();

                    foreach (string field in FormInfo.FormReportFields.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                if (columnNames != null)
                {
                    FormFieldInfo ffi  = null;
                    ListItem      item = null;

                    MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + FormInfo.ClassName);

                    foreach (string name in columnNames)
                    {
                        ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        item = new ListItem(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(GetFieldCaption(ffi, name, resolver))), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
    }
Esempio n. 25
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Check 'Manage servers' permission
        if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks"))
        {
            RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks");
        }

        CurrentMaster.DisplaySiteSelectorPanel = true;

        // Check enabled servers
        var isCallback = RequestHelper.IsCallback();

        if (!isCallback && !ServerInfoProvider.IsEnabledServer(SiteContext.CurrentSiteID))
        {
            ShowInformation(GetString("ObjectStaging.NoEnabledServer"));
            CurrentMaster.PanelHeader.Visible = false;
            plcContent.Visible = false;
            pnlFooter.Visible  = false;
            return;
        }

        // Setup server dropdown
        selectorElem.DropDownList.AutoPostBack       = true;
        selectorElem.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged;

        // Set server ID
        SelectedServerID = ValidationHelper.GetInteger(selectorElem.Value, QueryHelper.GetInteger("serverId", 0));

        // All servers
        if (SelectedServerID == UniSelector.US_ALL_RECORDS)
        {
            SelectedServerID   = 0;
            selectorElem.Value = UniSelector.US_ALL_RECORDS;
        }
        else
        {
            selectorElem.Value = SelectedServerID.ToString();
        }

        ltlScript.Text += ScriptHelper.GetScript("var currentServerId = " + SelectedServerID + ";");

        // Register script for pendingCallbacks repair
        ScriptHelper.FixPendingCallbacks(Page);

        HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

        if (!isCallback)
        {
            int nodeId = QueryHelper.GetInteger("stagingnodeid", 0);

            aliasPath = "/";

            // Get the document node
            if (nodeId > 0)
            {
                TreeProvider tree = new TreeProvider(CurrentUser);
                TreeNode     node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES);
                if (node != null)
                {
                    aliasPath = node.NodeAliasPath;
                }
            }

            // Setup title
            ucDisabledModule.TestSettingKeys = "CMSStagingLogChanges";
            ucDisabledModule.InfoText        = GetString("ContentStaging.TaskSeparator");
            ucDisabledModule.ParentPanel     = pnlNotLogged;

            // Check logging
            if (!ucDisabledModule.Check())
            {
                CurrentMaster.PanelHeader.Visible = false;
                plcContent.Visible = false;
                pnlFooter.Visible  = false;
                return;
            }

            // Create header actions
            HeaderActions.AddAction(new HeaderAction
            {
                Text      = GetString("Tasks.SyncCurrent"),
                EventName = SYNCHRONIZE_CURRENT
            });

            HeaderActions.AddAction(new HeaderAction
            {
                Text        = GetString("Tasks.SyncSubtree"),
                EventName   = SYNCHRONIZE_SUBTREE,
                ButtonStyle = ButtonStyle.Default
            });

            // Create header action
            HeaderActions.AddAction(new HeaderAction
            {
                Text        = GetString("Tasks.CompleteSync"),
                EventName   = SYNCHRONIZE_COMPLETE,
                ButtonStyle = ButtonStyle.Default
            });

            // Add CSS class to panels wrapper in order it could be stacked
            CurrentMaster.PanelHeader.AddCssClass("header-container-multiple-panels");

            if (!ControlsHelper.CausedPostBack(HeaderActions, btnSyncSelected, btnSyncAll))
            {
                // Check 'Manage servers' permission
                if (!CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks"))
                {
                    RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks");
                }

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

                ltlScript.Text +=
                    ScriptHelper.GetScript("function ConfirmDeleteTask(taskId) { return confirm(" +
                                           ScriptHelper.GetString(GetString("Tasks.ConfirmDelete")) + "); }");
                ltlScript.Text +=
                    ScriptHelper.GetScript("function CompleteSync(){" +
                                           Page.ClientScript.GetPostBackEventReference(btnSyncComplete, "") + "}");

                // Initialize grid
                tasksUniGrid.OnDataReload   += tasksUniGrid_OnDataReload;
                tasksUniGrid.ShowActionsMenu = true;
                tasksUniGrid.Columns         = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount";
                StagingTaskInfo ti = new StagingTaskInfo();
                tasksUniGrid.AllColumns = SqlHelper.MergeColumns(ti.ColumnNames);

                plcContent.Visible = true;

                // Initialize buttons
                btnSyncSelected.OnClientClick   = "return !" + tasksUniGrid.GetCheckSelectionScript();
                btnDeleteAll.OnClientClick      = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");";
                btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");";

                pnlLog.Visible     = false;
                TaskTypeCategories = TaskHelper.TASK_TYPE_CATEGORY_CONTENT + ";" + TaskHelper.TASK_TYPE_CATEGORY_GENERAL;
            }
        }

        var script = @"var currentNodeId = 0,
selectDocuments = false;

function ChangeServer(value) {
    currentServerId = value;
}

function SelectNode(serverId, nodeId) {
    currentServerId = serverId;
    currentNodeId = nodeId;
    document.location = 'Tasks.aspx?serverId=' + currentServerId + '&stagingnodeid=' + nodeId;
}

function SelectDocNode(serverId, nodeId) {
    currentNodeId = nodeId;
    document.location = 'DocumentsList.aspx?serverId=' + currentServerId + '&stagingnodeid=' + nodeId;
}";

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "HandlingTasks", ScriptHelper.GetScript(script));
    }
Esempio n. 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register script for pendingCallbacks repair
        ScriptHelper.FixPendingCallbacks(Page);

        // Initialize current user for the async actions
        currentUser   = CMSContext.CurrentUser;
        currentSiteId = CMSContext.CurrentSiteID;
        serverId      = QueryHelper.GetInteger("serverid", 0);

        HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

        if (RequestHelper.CausedPostback(btnSyncComplete))
        {
            SyncComplete();
        }
        else
        {
            if (!RequestHelper.IsCallback())
            {
                // Check 'Manage object tasks' permission
                if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageDataTasks"))
                {
                    RedirectToAccessDenied("cms.staging", "ManageDataTasks");
                }

                ucDisabledModule.SettingsKeys = "CMSStagingLogDataChanges";
                ucDisabledModule.InfoTexts.Add(GetString("DataStaging.TaskSeparator") + "<br />");
                ucDisabledModule.InfoTexts.Add(GetString("stagingchanges.notlogged"));
                ucDisabledModule.ParentPanel = pnlNotLogged;

                // Check logging
                if (!ucDisabledModule.Check())
                {
                    pnlFooter.Visible  = false;
                    plcContent.Visible = false;
                    return;
                }

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

                // Get object type
                objectType = QueryHelper.GetString("objecttype", string.Empty);
                if (!String.IsNullOrEmpty(objectType))
                {
                    // Create header action
                    HeaderActions.AddAction(new HeaderAction()
                    {
                        Text      = GetString("ObjectTasks.SyncCurrent"),
                        ImageUrl  = GetImageUrl("CMSModules/CMS_Staging/syncsubtree.png"),
                        EventName = SYNCHRONIZE_CURRENT
                    });
                }

                // Setup title
                titleElem.TitleText  = GetString("Synchronization.Title");
                titleElem.TitleImage = GetImageUrl("/CMSModules/CMS_Staging/synchronization.png");

                if (!RequestHelper.CausedPostback(HeaderActions, btnSyncSelected, btnSyncAll))
                {
                    // Initialize images
                    viewImage   = GetImageUrl("Design/Controls/UniGrid/Actions/View.png");
                    deleteImage = GetImageUrl("Design/Controls/UniGrid/Actions/Delete.png");
                    syncImage   = GetImageUrl("Design/Controls/UniGrid/Actions/Synchronize.png");

                    // Initialize tooltips
                    syncTooltip   = GetString("general.synchronize");
                    deleteTooltip = GetString("general.delete");
                    viewTooltip   = GetString("general.view");

                    plcContent.Visible = true;

                    // Initialize buttons
                    btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;");
                    btnCancel.Text                  = GetString("General.Cancel");
                    btnDeleteAll.OnClientClick      = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");";
                    btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");";
                    btnSyncSelected.OnClientClick   = "return !" + gridTasks.GetCheckSelectionScript();

                    ltlScript.Text += ScriptHelper.GetScript("function CompleteSync(){" + Page.ClientScript.GetPostBackEventReference(btnSyncComplete, null) + "}");

                    // Initialize grid
                    gridTasks.OrderBy              = "TaskTime";
                    gridTasks.ZeroRowsText         = GetString("Tasks.NoTasks");
                    gridTasks.OnAction            += gridTasks_OnAction;
                    gridTasks.OnDataReload        += gridTasks_OnDataReload;
                    gridTasks.OnExternalDataBound += gridTasks_OnExternalDataBound;
                    gridTasks.ShowActionsMenu      = true;
                    gridTasks.Columns              = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount";
                    TaskInfo ti = new TaskInfo();
                    gridTasks.AllColumns = SqlHelperClass.MergeColumns(ti.ColumnNames);

                    pnlLog.Visible = false;
                }
            }
        }

        ctlAsync.OnFinished   += ctlAsync_OnFinished;
        ctlAsync.OnError      += ctlAsync_OnError;
        ctlAsync.OnRequestLog += ctlAsync_OnRequestLog;
        ctlAsync.OnCancel     += ctlAsync_OnCancel;
    }
    /// <summary>
    /// Initializes action menu in master page.
    /// </summary>
    protected void InitializeActionMenu()
    {
        bool enabled = !EmailHelper.Queue.SendingInProgess && UserHasModify;

        HeaderActions actions = CurrentMaster.HeaderActions;

        actions.ActionsList.Clear();

        string confirmScript = "if (!confirm({0})) return false;";

        // Resend all failed
        HeaderAction resendAction = new HeaderAction
        {
            Text          = GetString("emailqueue.queue.resendfailed"),
            OnClientClick = enabled ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.ResendAllFailedConfirmation"))) : null,
            CommandName   = "resendallfailed",
            Enabled       = enabled
        };

        actions.ActionsList.Add(resendAction);

        // Resend selected
        resendAction.AlternativeActions.Add(new HeaderAction
        {
            Text          = GetString("emailqueue.queue.resendselected"),
            OnClientClick = enabled ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.ResendSelectedConfirmation"))) : null,
            CommandName   = "resendselected",
            Enabled       = enabled
        });

        // Resend all
        resendAction.AlternativeActions.Add(new HeaderAction
        {
            Text          = GetString("emailqueue.queue.resend"),
            OnClientClick = enabled ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.ResendAllConfirmation"))) : null,
            CommandName   = "resendall",
            Enabled       = enabled
        });

        // Delete all failed
        HeaderAction deleteAction = new HeaderAction
        {
            Text          = GetString("emailqueue.queue.deletefailed"),
            OnClientClick = enabled ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.DeleteAllFailedConfirmation"))) : null,
            CommandName   = "deleteallfailed",
            Enabled       = enabled
        };

        actions.ActionsList.Add(deleteAction);

        // Delete selected
        deleteAction.AlternativeActions.Add(new HeaderAction
        {
            Text          = GetString("emailqueue.queue.deleteselected"),
            OnClientClick = enabled ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.DeleteSelectedConfirmation"))) : null,
            CommandName   = "deleteselected",
            Enabled       = enabled
        });

        // Delete all
        deleteAction.AlternativeActions.Add(new HeaderAction
        {
            Text          = GetString("emailqueue.queue.delete"),
            OnClientClick = enabled ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.DeleteAllConfirmation"))) : null,
            CommandName   = "deleteall",
            Enabled       = enabled
        });

        // Stop send
        actions.ActionsList.Add(new HeaderAction
        {
            Text          = GetString("emailqueue.queue.stop"),
            OnClientClick = !enabled ? string.Format(confirmScript, ScriptHelper.GetString(GetString("EmailQueue.StopConfirmation"))) : null,
            CommandName   = "stop",
            Enabled       = !enabled
        });

        // Refresh
        actions.ActionsList.Add(new HeaderAction
        {
            Text        = GetString("general.refresh"),
            CommandName = "refresh"
        });

        actions.ActionPerformed += HeaderActions_ActionPerformed;
    }
Esempio n. 28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Keep current user object
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        // Title element settings
        titleElem.TitleImage = GetImageUrl("Objects/PM_ProjectTask/object.png");
        titleElem.TitleText  = GetString("pm.projecttask.edit");

        #region "Header actions"

        if (CMSContext.CurrentUser.IsAuthenticated())
        {
            // New task link
            string[,] actions = new string[1, 7];
            actions[0, 0]     = HeaderActions.TYPE_LINKBUTTON;
            actions[0, 1]     = GetString("pm.projecttask.newpersonal");
            actions[0, 2]     = null;
            actions[0, 4]     = null;
            actions[0, 5]     = GetImageUrl("Objects/PM_Project/add.png");
            actions[0, 6]     = "new_task";

            HeaderActions.Actions          = actions;
            HeaderActions.ActionPerformed += new CommandEventHandler(actionsElem_ActionPerformed);
            HeaderActions.ReloadData();
        }
        #endregion

        // Switch by display type and set correct list grid name
        switch (this.TasksDisplayType)
        {
        // Project tasks
        case TasksDisplayTypeEnum.ProjectTasks:
            ucTaskList.OrderByType   = ProjectTaskOrderByEnum.NotSpecified;
            ucTaskList.Grid.OrderBy  = "TaskPriorityOrder ASC,ProjectTaskDeadline DESC";
            ucTaskList.Grid.GridName = "~/CMSModules/ProjectManagement/Controls/LiveControls/ProjectTasks.xml";
            pnlListActions.Visible   = false;
            break;

        // Tasks owned by me
        case TasksDisplayTypeEnum.TasksOwnedByMe:
            ucTaskList.OrderByType   = ProjectTaskOrderByEnum.NotSpecified;
            ucTaskList.Grid.OrderBy  = "TaskPriorityOrder ASC,ProjectTaskDeadline DESC";
            ucTaskList.Grid.GridName = "~/CMSModules/ProjectManagement/Controls/LiveControls/TasksOwnedByMe.xml";
            break;

        // Tasks assigned to me
        case TasksDisplayTypeEnum.TasksAssignedToMe:
            // Set not specified order by default
            ucTaskList.OrderByType = ProjectTaskOrderByEnum.NotSpecified;
            // If sitename is not defined => display task from all sites => use user order
            if (String.IsNullOrEmpty(this.SiteName))
            {
                ucTaskList.OrderByType = ProjectTaskOrderByEnum.UserOrder;
            }
            ucTaskList.Grid.OrderBy  = "TaskPriorityOrder ASC,ProjectTaskDeadline DESC";
            ucTaskList.Grid.GridName = "~/CMSModules/ProjectManagement/Controls/LiveControls/TasksAssignedToMe.xml";
            break;
        }

        #region "Force edit by TaskID in querystring"

        // Check whether is not postback
        if (!RequestHelper.IsPostBack())
        {
            // Try get value from request stroage which indicates whether force dialog is displayed
            bool isDisplayed = ValidationHelper.GetBoolean(RequestStockHelper.GetItem("cmspmforceitemdisplayed", true), false);

            // Try get task id from querystring
            int forceTaskId = QueryHelper.GetInteger("taskid", 0);
            if ((forceTaskId > 0) && (!isDisplayed))
            {
                ProjectTaskInfo pti = ProjectTaskInfoProvider.GetProjectTaskInfo(forceTaskId);
                ProjectInfo     pi  = ProjectInfoProvider.GetProjectInfo(pti.ProjectTaskProjectID);

                // Check whether task is defined
                // and if is assigned to some project, this project is assigned to current site
                if ((pti != null) && ((pi == null) || (pi.ProjectSiteID == CMSContext.CurrentSiteID)))
                {
                    bool taskIdValid = false;

                    // Switch by display type
                    switch (this.TasksDisplayType)
                    {
                    // Tasks created by me
                    case TasksDisplayTypeEnum.TasksOwnedByMe:
                        if (pti.ProjectTaskOwnerID == currentUser.UserID)
                        {
                            taskIdValid = true;
                        }
                        break;

                    // Tasks assigned to me
                    case TasksDisplayTypeEnum.TasksAssignedToMe:
                        if (pti.ProjectTaskAssignedToUserID == currentUser.UserID)
                        {
                            taskIdValid = true;
                        }
                        break;

                    // Project task
                    case TasksDisplayTypeEnum.ProjectTasks:
                        if (!String.IsNullOrEmpty(ProjectNames) && (pi != null))
                        {
                            string projectNames = ";" + ProjectNames.ToLower() + ";";
                            if (projectNames.Contains(";" + pi.ProjectName.ToLower() + ";"))
                            {
                                // Check whether user can see private task
                                if (!pti.ProjectTaskIsPrivate ||
                                    ((pti.ProjectTaskOwnerID == currentUser.UserID) || (pti.ProjectTaskAssignedToUserID == currentUser.UserID)) ||
                                    ((pi.ProjectGroupID > 0) && currentUser.IsGroupAdministrator(pi.ProjectGroupID)) ||
                                    ((pi.ProjectGroupID == 0) && (currentUser.IsAuthorizedPerResource("CMS.ProjectManagement", CMSAdminControl.PERMISSION_MANAGE))))
                                {
                                    taskIdValid = true;
                                }
                            }
                        }
                        break;
                    }

                    bool displayValid = true;

                    // Check whether do not display finished tasks is required
                    if (!this.ShowFinishedTasks)
                    {
                        ProjectTaskStatusInfo ptsi = ProjectTaskStatusInfoProvider.GetProjectTaskStatusInfo(pti.ProjectTaskStatusID);
                        if ((ptsi != null) && (ptsi.TaskStatusIsFinished))
                        {
                            displayValid = false;
                        }
                    }

                    // Check whether private task should be edited
                    if (!this.ShowPrivateTasks)
                    {
                        if (pti.ProjectTaskProjectID == 0)
                        {
                            displayValid = false;
                        }
                    }

                    // Check whether ontime task should be edited
                    if (!this.ShowOnTimeTasks)
                    {
                        if ((pti.ProjectTaskDeadline != DateTimeHelper.ZERO_TIME) && (pti.ProjectTaskDeadline < DateTime.Now))
                        {
                            displayValid = false;
                        }
                    }

                    // Check whether overdue task should be edited
                    if (!this.ShowOverdueTasks)
                    {
                        if ((pti.ProjectTaskDeadline != DateTimeHelper.ZERO_TIME) && (pti.ProjectTaskDeadline > DateTime.Now))
                        {
                            displayValid = false;
                        }
                    }

                    // Check whether user is allowed to see project
                    if ((pi != null) && (ProjectInfoProvider.IsAuthorizedPerProject(pi.ProjectID, ProjectManagementPermissionType.READ, CMSContext.CurrentUser)))
                    {
                        displayValid = false;
                    }

                    // If task is valid and user has permissions to see this task display edit task dialog
                    if (displayValid && taskIdValid && ProjectTaskInfoProvider.IsAuthorizedPerTask(forceTaskId, ProjectManagementPermissionType.READ, CMSContext.CurrentUser, CMSContext.CurrentSiteID))
                    {
                        this.ucTaskEdit.ItemID = forceTaskId;
                        this.ucTaskEdit.ReloadData();
                        // Render dialog
                        this.ucPopupDialog.Visible = true;
                        this.ucPopupDialog.Show();
                        // Set "force dialog displayed" flag
                        RequestStockHelper.Add("cmspmforceitemdisplayed", true, true);
                    }
                }
            }
        }

        #endregion


        #region "Event handlers registration"

        // Register list action handler
        ucTaskList.OnAction += new CommandEventHandler(ucTaskList_OnAction);

        #endregion


        #region "Pager settings"

        // Paging
        if (!EnablePaging)
        {
            ucTaskList.Grid.PageSize = "##ALL##";
            ucTaskList.Grid.Pager.DefaultPageSize = -1;
        }
        else
        {
            ucTaskList.Grid.Pager.DefaultPageSize = PageSize;
            ucTaskList.Grid.PageSize    = this.PageSize.ToString();
            ucTaskList.Grid.FilterLimit = PageSize;
        }

        #endregion


        // Use postbacks on list actions
        ucTaskList.UsePostbackOnEdit = true;
        // Check delete permission
        ucTaskList.OnCheckPermissionsExtended += new CheckPermissionsExtendedEventHandler(ucTaskList_OnCheckPermissionsExtended);
        // Dont register JS edit script
        ucTaskList.RegisterEditScript = false;

        // Hide default ok button on edit
        ucTaskEdit.ShowOKButton = false;
        // Disable on site validators
        ucTaskEdit.DisableOnSiteValidators = true;
        // Check modify permission
        ucTaskEdit.OnCheckPermissionsExtended += new CheckPermissionsExtendedEventHandler(ucTaskEdit_OnCheckPermissionsExtended);
        // Build condition event
        ucTaskList.BuildCondition += new CMSModules_ProjectManagement_Controls_UI_ProjectTask_List.BuildConditionEvent(ucTaskList_BuildCondition);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterDialogScript(Page);

        btnOk.OnClientClick = DocumentManager.GetAllowSubmitScript();

        EditedObject = DocumentAlias;

        if (IsDialog)
        {
            PageTitle.TitleText = GetString("content.ui.urlsaliases");
        }
        else
        {
            HeaderActions.AddAction(new HeaderAction
            {
                Text        = GetString("doc.urls.addnewalias"),
                RedirectUrl = ResolveUrl("Alias_Edit.aspx?nodeid=" + NodeID),
                ButtonStyle = ButtonStyle.Default
            });

            HeaderActions.AddAction(new HeaderAction
            {
                Text          = GetString("doc.urls.viewallalias"),
                OnClientClick = "modalDialog('" + ResolveUrl(PROPERTIES_FOLDER + "Alias_AliasList.aspx") + "?nodeid=" + NodeID + "&dialog=1" + "','AliasManagement','90%','85%');",
                ButtonStyle   = ButtonStyle.Default
            });
        }

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

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

                txtURLExtensions.Enabled = false;

                ctrlURL.Enabled = false;

                cultureSelector.Enabled = false;
            }

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

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

            // Show path of document alias only if dialog mode edit
            pnlUrlInfo.Visible = IsDialog;

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

            CreateBreadcrumbs();

            cultureSelector.AllowDefault = false;
            cultureSelector.UniSelector.SpecialFields.Add(new SpecialField
            {
                Text  = GetString("general.selectall"),
                Value = String.Empty
            });


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

                // Edit existing alias
                if (DocumentAlias != null && DocumentAlias.AliasID > 0)
                {
                    txtURLExtensions.Text = DocumentAlias.AliasExtensions;
                    ctrlURL.URLPath       = DocumentAlias.AliasURLPath;

                    cultureSelector.Value         = DocumentAlias.AliasCulture;
                    PageBreadcrumbs.Items[1].Text = TreePathUtils.GetUrlPathDisplayName(DocumentAlias.AliasURLPath);

                    drpAction.SelectedValue = DocumentAlias.AliasActionMode.ToStringRepresentation();
                }
            }

            // Register js synchronization script for split mode
            if (QueryHelper.GetBoolean("refresh", false) && PortalUIHelper.DisplaySplitMode)
            {
                RegisterSplitModeSync(true, false, true);
            }
        }
    }
Esempio n. 30
0
        public void InitPage()
        {
            var entMan = new EntityManager();

            ErpEntity = entMan.ReadEntity(ParentRecordId ?? Guid.Empty).Object;
            if (ErpEntity == null)
            {
                return;
            }

            Field = ErpEntity.Fields.FirstOrDefault(x => x.Id == RecordId);
            if (Field == null)
            {
                return;
            }

            var allCards = AdminPageUtils.GetFieldCards();

            FieldCard = allCards.First(x => (string)x["type"] == ((int)Field.GetFieldType()).ToString());


            #region << Init RecordPermissions >>
            var valueGrid = new List <KeyStringList>();
            PermissionOptions = new List <SelectOption>()
            {
                new SelectOption("read", "read"),
                new SelectOption("update", "update")
            };

            var roles = AdminPageUtils.GetUserRoles();             //Special order is applied

            foreach (var role in roles)
            {
                RoleOptions.Add(new SelectOption(role.Id.ToString(), role.Name));
                var keyValuesObj = new KeyStringList()
                {
                    Key    = role.Id.ToString(),
                    Values = new List <string>()
                };
                if (Field.Permissions.CanRead.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("read");
                }
                if (Field.Permissions.CanUpdate.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("update");
                }
                valueGrid.Add(keyValuesObj);
            }
            FieldPermissions = JsonConvert.SerializeObject(valueGrid);
            #endregion

            #region << Actions >>
            if (Field.System)
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.Disabled, label: "Delete Locked", formId: "DeleteRecord", iconClass: "fa fa-trash-alt", titleText: "System objects cannot be deleted"));
            }
            else
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.ConfirmAndSubmitForm, label: "Delete Field", formId: "DeleteRecord", btnClass: "btn btn-white btn-sm", iconClass: "fa fa-trash-alt go-red"));
            };
            HeaderActions.Add($"<a href='/sdk/objects/entity/r/{(ErpEntity != null ? ErpEntity.Id : Guid.Empty)}/rl/fields/m/{Field.Id}' class='btn btn-white btn-sm'><i class='fa fa-cog go-orange'></i> Manage</a>");
            #endregion

            ApiUrlFieldInlineEdit = ErpSettings.ApiUrlTemplateFieldInlineEdit.Replace("{entityName}", ErpEntity.Name).Replace("{recordId}", (RecordId ?? Guid.Empty).ToString());
        }