/// <summary> /// Saves roles data /// </summary> private void SaveRolesData() { Guid stepSourcePointGuid = (SourcePointGuid == null) ? Guid.Empty : SourcePointGuid.Value; // Remove old items string newValues = ValidationHelper.GetString(usRoles.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentRoles); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to site foreach (string item in newItems) { int roleId = ValidationHelper.GetInteger(item, 0); // If role is authorized, remove it WorkflowStepRoleInfo wsr = WorkflowStepRoleInfoProvider.GetWorkflowStepRoleInfo(WorkflowStepID, roleId, stepSourcePointGuid); if (wsr != null) { wsr.Delete(); } } } } // Add new items items = DataHelper.GetNewItemsInList(currentRoles, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to site foreach (string item in newItems) { int roleId = ValidationHelper.GetInteger(item, 0); // If role is not authorized, authorize it if (WorkflowStepRoleInfoProvider.GetWorkflowStepRoleInfo(WorkflowStepID, roleId, stepSourcePointGuid) == null) { WorkflowStepRoleInfoProvider.AddRoleToWorkflowStep(WorkflowStepID, roleId, stepSourcePointGuid); } } } } ShowChangesSaved(); }
private void SaveData() { // Remove old items string newValues = ValidationHelper.GetString(usRoles.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to site foreach (string item in newItems) { int roleID = ValidationHelper.GetInteger(item, 0); // If role is authorized, unauthorize it if (IsRoleAuthorized(roleID.ToString(), workflowStepId)) { WorkflowStepRoleInfoProvider.RemoveRoleFromWorkflowStep(workflowStepId, roleID); } } } } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to site foreach (string item in newItems) { int roleID = ValidationHelper.GetInteger(item, 0); // If role is not authorized, authorize it if (!IsRoleAuthorized(roleID.ToString(), workflowStepId)) { WorkflowStepRoleInfoProvider.AddRoleToWorkflowStep(workflowStepId, roleID); } } } } lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); }
/// <summary> /// Assings the CMS Editors role to a workflow step. Called when the "Add role to step" button is pressed. /// Expects the CreateWorkflow and CreateWorkflowStep methods to be run first. /// </summary> private bool AddRoleToStep() { // Get the workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow"); if (workflow != null) { // Get the custom step WorkflowStepInfo step = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewWorkflowStep", workflow.WorkflowID); if (step != null) { // Get the role to be assigned to the step RoleInfo role = RoleInfoProvider.GetRoleInfo("CMSEditor", SiteContext.CurrentSiteID); if (role != null) { // Make the assignment WorkflowStepRoleInfoProvider.AddRoleToWorkflowStep(step.StepID, role.RoleID); return(true); } else { // Role was not found apiAddRoleToStep.ErrorMessage = "Role 'CMS Editors' was not found."; } } else { // Step was not found apiAddRoleToStep.ErrorMessage = "Step 'My new workflow step' was not found."; } } return(false); }