Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Control initializations
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        rfvName.ErrorMessage        = GetString("Task_Edit.EmptyName");
        lblFrom.Text           = GetString("scheduler.from");
        btnReset.OnClientClick = "if (!confirm(" + ScriptHelper.GetLocalizedString("tasks.reset") + ")) return false;";

        plcDevelopment.Visible = developmentMode;

        // Show 'Allow run in external service' check-box in development mode
        plcAllowExternalService.Visible = developmentMode;

        string currentTask = GetString("Task_Edit.NewItemCaption");

        if (TaskID > 0)
        {
            // Set edited object
            EditedObject = TaskInfo;

            if (TaskInfo != null)
            {
                // Global task and user is not global administrator and task's site id is different than current site id
                if (!MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) && ((TaskInfo.TaskSiteID == 0) || (TaskInfo.TaskSiteID != SiteID)))
                {
                    RedirectToAccessDenied(GetString("general.nopermission"));
                }

                currentTask = TaskInfo.TaskDisplayName;

                if (!RequestHelper.IsPostBack())
                {
                    ReloadData();

                    // Show that the task was created or updated successfully
                    if (Request.QueryString["saved"] == "1")
                    {
                        ShowChangesSaved();
                    }
                }
            }
        }
        else
        {
            // Check "modify" permission
            if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.ScheduledTasks", "Modify"))
            {
                RedirectToAccessDenied("CMS.ScheduledTasks", "Modify");
            }

            if (WebFarmServerInfoProvider.UseWebFarmSynchronization())
            {
                if (!RequestHelper.IsPostBack())
                {
                    chkAllServers.Visible = true;
                }
                chkAllServers.Attributes.Add("onclick", "document.getElementById('" + txtServerName.ClientID + "').disabled = document.getElementById('" + chkAllServers.ClientID + "').checked;");
            }
        }

        plcRunIndividually.Visible = (SiteID <= 0);

        // Initializes page title control
        BreadcrumbItem tasksLink = new BreadcrumbItem();

        tasksLink.Text = GetString("Task_Edit.ItemListLink");

        bool   notSystem = (TaskInfo == null) || (TaskInfo.TaskType != ScheduledTaskTypeEnum.System);
        string listUrl   = UIContextHelper.GetElementUrl("CMS.ScheduledTasks", GetElementName(notSystem ? "Tasks" : "SystemTasks"), true);

        listUrl = URLHelper.AddParameterToUrl(listUrl, "siteid", SiteID.ToString());
        tasksLink.RedirectUrl = listUrl;

        PageBreadcrumbs.Items.Add(tasksLink);
        PageBreadcrumbs.Items.Add(new BreadcrumbItem
        {
            Text = currentTask
        });
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        rfvAssembly.ErrorMessage    = GetString("Task_Edit.EmptyAssembly");
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        rfvName.ErrorMessage        = GetString("Task_Edit.EmptyName");
        rfvClass.ErrorMessage       = GetString("Task_Edit.EmptyClass");

        // Control initializations
        lblTaskAssemblyName.Text = GetString("Task_Edit.TaskAssemblyNameLabel");

        lblTaskClass.Text              = GetString("Task_Edit.TaskClassLabel");
        lblTaskData.Text               = GetString("Task_Edit.TaskDataLabel");
        lblTaskName.Text               = GetString("Task_Edit.TaskNameLabel");
        lblTaskEnabled.Text            = GetString("Task_Edit.TaskEnabledLabel");
        lblTaskInterval.Text           = GetString("Task_Edit.TaskIntervalLabel");
        lblTaskDisplayName.Text        = GetString("Task_Edit.TaskDisplayNameLabel");
        lblTaskDeleteAfterLastRun.Text = GetString("Task_Edit.TaskDeleteAfterLastRunLabel");
        lblServerName.Text             = GetString("Task_Edit.TaskServerNameLabel");
        chkAllServers.Text             = GetString("Task_Edit.TaskAllServers");

        plcDevelopment.Visible = developmentMode;
        // Show 'Allow run in external service' checkbox in development mode
        plcAllowExternalService.Visible = developmentMode;

        btnOk.Text = GetString("General.OK");

        string currentTask = GetString("Task_Edit.NewItemCaption");
        string title       = GetString("Task_Edit.HeaderCaption");

        taskId = ValidationHelper.GetInteger(Request.QueryString["taskname"], 0);
        if (taskId > 0)
        {
            taskObj = TaskInfoProvider.GetTaskInfo(taskId);
            if (taskObj != null)
            {
                // Global task and user is not global administrator and task's site id is different than current site id
                if (!CMSContext.CurrentUser.UserSiteManagerAdmin && ((taskObj.TaskSiteID == 0) || (taskObj.TaskSiteID != SiteID)))
                {
                    RedirectToAccessDenied(GetString("general.nopermission"));
                }

                currentTask = taskObj.TaskDisplayName;
                title       = GetString("Task_Edit.HeaderCaptionEdit");

                if (!RequestHelper.IsPostBack())
                {
                    ReloadData();

                    // Show that the task was created or updated successfully
                    if (Request.QueryString["saved"] == "1")
                    {
                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");
                    }
                }
            }
        }
        else
        {
            // Check "modify" permission
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.ScheduledTasks", "Modify"))
            {
                RedirectToAccessDenied("CMS.ScheduledTasks", "Modify");
            }

            if (WebFarmServerInfoProvider.UseWebFarmSynchronization())
            {
                if (!RequestHelper.IsPostBack())
                {
                    chkAllServers.Visible = true;
                }
                chkAllServers.Attributes.Add("onclick", "document.getElementById('" + txtServerName.ClientID + "').disabled = document.getElementById('" + chkAllServers.ClientID + "').checked;");
            }
        }

        siteID = 0;
        if (SiteID != 0)
        {
            cmsdesk = true;
            siteID  = SiteID;
        }

        if (SelectedSiteID != 0)
        {
            cmsdesk = false;
            if (Request.QueryString["selectedsiteid"] != "Global")
            {
                siteID = SelectedSiteID;
            }
        }

        // Get the site record
        if (siteID > 0)
        {
            si = SiteInfoProvider.GetSiteInfo(siteID);
        }

        // Initializes page title control
        string[,] tabs = new string[2, 3];
        tabs[0, 0]     = GetString("Task_Edit.ItemListLink");
        if (cmsdesk)
        {
            tabs[0, 1] = "~/CMSModules/Scheduler/Pages/Task_List.aspx?siteid=" + siteID;
        }
        else
        {
            tabs[0, 1] = "~/CMSModules/Scheduler/Pages/Task_List.aspx?selectedsiteid=" + siteID;
        }

        tabs[1, 0] = currentTask;
        tabs[1, 1] = "";
        tabs[1, 2] = "";
        this.CurrentMaster.Title.Breadcrumbs = tabs;

        // Setup page title text and image
        this.CurrentMaster.Title.TitleText     = title;
        this.CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/CMS_ScheduledTask/new.png");
        this.CurrentMaster.Title.HelpTopicName = "newedit_task";
        this.CurrentMaster.Title.HelpName      = "helpTopic";
    }