/// <summary> /// Creates buttons in header actions /// </summary> private void CreateButtons() { var updateAction = new HeaderAction { ButtonStyle = ButtonStyle.Default, CommandName = UPDATE_STATUSES_ACTION, Tooltip = GetString("translationservice.updatestatusestooltip"), Text = GetString("translationservice.updatestatuses"), Enabled = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.TranslationServices", "Modify") && !Grid.IsEmpty }; string translateUrl = ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Translations/Pages/TranslateDocuments.aspx") + "?select=1&dialog=1"; translateUrl = URLHelper.AddParameterToUrl(translateUrl, "hash", QueryHelper.GetHash(URLHelper.GetQuery(translateUrl))); // Check if any human translation is enabled bool enabled = TranslationServiceInfoProvider.GetTranslationServices("(TranslationServiceEnabled = 1) AND (TranslationServiceIsMachine = 0)", null, 0, "TranslationServiceID, TranslationServiceName").Any(t => TranslationServiceHelper.IsServiceAvailable(t.TranslationServiceName, SiteContext.CurrentSiteName)); var submitAction = new HeaderAction { OnClientClick = "modalDialog('" + translateUrl + "', 'SubmitTranslation', 988, 640);", Tooltip = GetString(enabled ? "translationservice.submittranslationtooltip" : "translationservice.noenabledservices"), Text = GetString("translationservice.submittranslation"), Enabled = enabled && MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Content", "SubmitForTranslation") }; AddHeaderAction(submitAction); AddHeaderAction(updateAction); HeaderActions.ReloadData(); }
/// <summary> /// Handle PreRenderComplete event of the page. /// </summary> /// <param name="sender">Sender object</param> /// <param name="e">Event argument</param> protected void Page_PreRenderComplete(object sender, EventArgs e) { if ((siteInfo != null) && !RequestHelper.IsPostBack()) { // Check version limitations if (!CultureSiteInfoProvider.LicenseVersionCheck(siteInfo.DomainName, FeatureEnum.Multilingual, ObjectActionEnum.Edit)) { Control.ShowError(ResHelper.GetString("licenselimitation.siteculturesexceeded")); // Disable culture selector FormEngineUserControl cultureSelector = Control.FieldControls["SiteDefaultVisitorCulture"]; if (cultureSelector != null) { cultureSelector.Enabled = false; } // Disable Save button HeaderActions actions = Control.ObjectManager.HeaderActions; SaveAction sa = actions.ActionsList.Where <HeaderAction>(a => (a is SaveAction)).First() as SaveAction; if (sa != null) { sa.Enabled = false; sa.BaseButton.Visible = true; actions.ReloadData(); Control.SubmitButton.Visible = false; } } } }
/// <summary> /// Initializes header action control. /// </summary> /// <param name="isActiveABTest">Indicates if the issue is A/B test and its status is not 'Finished'</param> /// <param name="allowSendingIssue">Indicates if sending is allowed</param> private void InitHeaderActions(bool isActiveABTest, bool allowSendingIssue) { HeaderActions hdrActions = CurrentMaster.HeaderActions; hdrActions.ActionsList.Clear(); // Init save button if (isActiveABTest) { hdrActions.ActionsList.Add(new SaveAction(this)); } // Init send button if (allowSendingIssue) { hdrActions.ActionsList.Add(new HeaderAction() { ControlType = HeaderActionTypeEnum.LinkButton, CommandName = ComponentEvents.SUBMIT, Text = GetString("newsletterissue_send.send"), Tooltip = GetString("newsletterissue_send.send"), ImageUrl = GetImageUrl("CMSModules/CMS_Newsletter/send.png"), Enabled = true }); } hdrActions.ActionPerformed += new CommandEventHandler(hdrActions_ActionPerformed); hdrActions.ReloadData(); CurrentMaster.DisplayActionsPanel = true; }
/// <summary> /// Initializes header action control. /// </summary> /// <param name="isActiveABTest">Indicates if the issue is A/B test and its status is not 'Finished'</param> /// <param name="allowSendingIssue">Indicates if sending is allowed</param> private void InitHeaderActions(bool isActiveABTest, bool allowSendingIssue) { HeaderActions hdrActions = CurrentMaster.HeaderActions; hdrActions.ActionsList.Clear(); // Init save button if (isActiveABTest) { hdrActions.ActionsList.Add(new SaveAction()); } // Init send button if (allowSendingIssue) { hdrActions.ActionsList.Add(new HeaderAction { CommandName = ComponentEvents.SUBMIT, Text = GetString("newsletterissue_send.send"), Tooltip = GetString("newsletterissue_send.send"), Enabled = true }); } hdrActions.ActionPerformed += hdrActions_ActionPerformed; hdrActions.ReloadData(); CurrentMaster.DisplayActionsPanel = true; }
/// <summary> /// Initializes header action control. /// </summary> private void InitHeaderActions() { HeaderActions.ActionsList.Clear(); HeaderActions.ActionsList.Add(btnSend = new HeaderAction { CommandName = ComponentEvents.SUBMIT, Text = GetString("general.send"), Tooltip = GetString("general.send"), Enabled = true }); HeaderActions.ActionPerformed += new CommandEventHandler(hdrActions_ActionPerformed); HeaderActions.ReloadData(); }
/// <summary> /// Initializes header action control. /// </summary> private void InitHeaderActions() { HeaderActions.ActionsList.Clear(); HeaderActions.ActionsList.Add(btnSend = new HeaderAction() { ControlType = HeaderActionTypeEnum.LinkButton, CommandName = ComponentEvents.SUBMIT, Text = GetString("general.send"), Tooltip = GetString("general.send"), ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/resendemail.png"), Enabled = true }); HeaderActions.ActionPerformed += new CommandEventHandler(hdrActions_ActionPerformed); HeaderActions.ReloadData(); }
/// <summary> /// Initializes header action control. /// </summary> /// <param name="isActiveABTest">Indicates if the issue is A/B test and its status is not 'Finished'</param> /// <param name="allowSendingIssue">Indicates if sending is allowed</param> /// <param name="isNewsletterSent">Indicates if newsletter was already sent</param> private void InitHeaderActions(bool isActiveABTest, bool allowSendingIssue, bool isNewsletterSent) { HeaderActions hdrActions = CurrentMaster.HeaderActions; hdrActions.ActionsList.Clear(); // Init save button if (isActiveABTest) { hdrActions.ActionsList.Add(new SaveAction()); } if (allowSendingIssue) { InitSendAndScheduleHeaderActions(hdrActions, isActiveABTest, isNewsletterSent); } hdrActions.ActionPerformed += hdrActions_ActionPerformed; hdrActions.ReloadData(); CurrentMaster.DisplayActionsPanel = true; }
/// <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 }); // Check if current service supports canceling var service = TranslationServiceInfoProvider.GetTranslationServiceInfo(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(); }
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); }