public static bool HasEditPermissions(int ModuleId) { ModulePermissionController objModulePermissionController = new ModulePermissionController(); ModulePermissionCollection objModulePermissions = objModulePermissionController.GetModulePermissionsCollectionByModuleID(ModuleId); return(HasEditPermissions(objModulePermissions)); }
public ModuleSecurity(ModuleInfo modInfo) { ModulePermissionCollection permCollection = modInfo.ModulePermissions; //_permission1 = ModulePermissionController.HasModulePermission(permCollection, PERMISSION1); _permission2 = ModulePermissionController.HasModulePermission(permCollection, PERMISSION2); }
private static void AddModulePermission(ModulePermissionCollection permissions, string key, int roleId) { var permissionController = new PermissionController(); var permission = (PermissionInfo)permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", key)[0]; var modulePermission = new ModulePermissionInfo { PermissionID = permission.PermissionID, RoleID = roleId, AllowAccess = true }; permissions.Add(modulePermission); }
/// ----------------------------------------------------------------------------- /// <summary> /// Load the ViewState /// </summary> /// <param name="savedState">The saved state</param> /// ----------------------------------------------------------------------------- protected override void LoadViewState(object savedState) { if (savedState != null) { //Load State from the array of objects that was saved with SaveViewState. var myState = (object[])savedState; //Load Base Controls ViewState if (myState[0] != null) { base.LoadViewState(myState[0]); } //Load ModuleID if (myState[1] != null) { ModuleID = Convert.ToInt32(myState[1]); } //Load TabId if (myState[2] != null) { TabId = Convert.ToInt32(myState[2]); } //Load InheritViewPermissionsFromTab if (myState[3] != null) { InheritViewPermissionsFromTab = Convert.ToBoolean(myState[3]); } //Load ModulePermissions if (myState[4] != null) { _ModulePermissions = new ModulePermissionCollection(); string state = Convert.ToString(myState[4]); if (!String.IsNullOrEmpty(state)) { //First Break the String into individual Keys string[] permissionKeys = state.Split(new[] { "##" }, StringSplitOptions.None); foreach (string key in permissionKeys) { string[] Settings = key.Split('|'); _ModulePermissions.Add(ParseKeys(Settings)); } } } } }
public void ModulePermissionController_HasModuleAccess_SecurityLevelView_Is_False_For_User_Without_View_Role() { CreateUser(false, new List <string>() { "RoleWithoutViewPermission" }); var modulePermissionCollection = new ModulePermissionCollection(); AddModulePermission(modulePermissionCollection, "View", Convert.ToInt32(SetupPortalSettings().AdministratorRoleId)); var module = new ModuleInfo { InheritViewPermissions = false, ModulePermissions = modulePermissionCollection }; Assert.IsFalse(ModulePermissionController.HasModuleAccess(SecurityAccessLevel.View, "", module)); }
/// <summary> /// Load the ViewState /// </summary> /// <param name="savedState">The saved state</param> protected override void LoadViewState(object savedState) { if (!(savedState == null)) { // Load State from the array of objects that was saved with SaveViewState. object[] myState = (object[])savedState; //Load Base Controls ViewStte if (!(myState[0] == null)) { base.LoadViewState(myState[0]); } //Load ModuleID if (!(myState[1] == null)) { ModuleID = Convert.ToInt32(myState[1]); } //Load InheritViewPermissionsFromTab if (!(myState[2] == null)) { InheritViewPermissionsFromTab = Convert.ToBoolean(myState[2]); } //Load ModulePermissions if (!(myState[3] == null)) { ArrayList arrPermissions = new ArrayList(); string state = myState[3].ToString(); if (!String.IsNullOrEmpty(state)) { //First Break the String into individual Keys string[] permissionKeys = state.Split("##".ToCharArray()[0]); foreach (string key in permissionKeys) { string[] Settings = key.Split('|'); ParsePermissionKeys(Settings, arrPermissions); } } ModulePermissions = new ModulePermissionCollection(arrPermissions); } } }
private static List <GenericPermissionInfo> GetGenericPermissions(ModulePermissionCollection MpCollection) { List <GenericPermissionInfo> GenericPermissions = new List <GenericPermissionInfo>(); foreach (PermissionInfoBase pinfo in MpCollection.ToList()) { GenericPermissionInfo gp = new GenericPermissionInfo { AllowAccess = pinfo.AllowAccess, PermissionID = pinfo.PermissionID, RoleID = pinfo.RoleID, UserID = pinfo.UserID, DisplayName = pinfo.DisplayName }; GenericPermissions.Add(gp); } return(GenericPermissions); }
public static bool HasModulePermission(ModulePermissionCollection objModulePermissions, string permissionKey) { bool hasPermission = Null.NullBoolean; if (permissionKey.Contains(",")) { foreach (string permission in permissionKey.Split(',')) { if (provider.HasModulePermission(objModulePermissions, permission)) { hasPermission = true; break; } } } else { hasPermission = provider.HasModulePermission(objModulePermissions, permissionKey); } return(hasPermission); }
/// <param name="moduleId"></param> /// <param name="tabId"></param> /// <param name="permissionKey">You can use the constants, but for modules there are only /// those two</param> /// <returns></returns> public static bool canUserAccessModule(UserInfo user, int portalId, int tabId, ModuleInfo moduleInfo, string permissionKey) { bool retVal = false; string permissionsString = null; if (moduleInfo.InheritViewPermissions) { TabPermissionController tabPermissionController = new TabPermissionController(); TabPermissionCollection tabPermissionCollection = tabPermissionController.GetTabPermissionsCollectionByTabID(tabId, portalId); permissionsString = tabPermissionController.GetTabPermissions(tabPermissionCollection, permissionKey); } else { ModulePermissionController modulePermissionController = new ModulePermissionController(); ModulePermissionCollection permissionCollection = modulePermissionController.GetModulePermissionsCollectionByModuleID(moduleInfo.ModuleID, tabId); permissionsString = modulePermissionController.GetModulePermissions(permissionCollection, permissionKey); } char[] splitter = { ';' }; string[] roles = permissionsString.Split(splitter); foreach (string role in roles) { if (role.Length > 0) { if (user != null && user.IsInRole(role)) { retVal = true; } else if (user == null && role.ToLower().Equals("all users")) { retVal = true; } } } return(retVal); }
/// <summary> /// Gets the ModulePermissions from the Data Store /// </summary> private void GetModulePermissions() { ModulePermissionController objModulePermissionController = new ModulePermissionController(); ModulePermissions = objModulePermissionController.GetModulePermissionsCollectionByModuleID( ModuleID, TabId ); }
public static bool HasEditPermissions(ModulePermissionCollection objModulePermissions) { return(ModulePermissionController.HasModulePermission(objModulePermissions, "EDIT")); }
/// ----------------------------------------------------------------------------- /// <summary> /// Gets the ModulePermissions from the Data Store /// </summary> /// ----------------------------------------------------------------------------- private void GetModulePermissions() { _ModulePermissions = new ModulePermissionCollection(ModulePermissionController.GetModulePermissions(ModuleID, TabId)); _PermissionsList = null; }
private bool IsMod() { var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(_moduleId, -1), typeof(ModulePermissionInfo))); return(ModulePermissionController.HasModulePermission(objModulePermissions, "MODGROUP")); }
/// ----------------------------------------------------------------------------- /// <summary> /// Gets the ModulePermissions from the Data Store. /// </summary> /// ----------------------------------------------------------------------------- private void GetModulePermissions() { this._ModulePermissions = new ModulePermissionCollection(ModulePermissionController.GetModulePermissions(this.ModuleID, this.TabId)); this._PermissionsList = null; }
/// ----------------------------------------------------------------------------- /// <summary> /// Load the ViewState /// </summary> /// <param name="savedState">The saved state</param> /// <history> /// [cnurse] 01/12/2006 Created /// </history> /// ----------------------------------------------------------------------------- protected override void LoadViewState(object savedState) { if (savedState != null) { //Load State from the array of objects that was saved with SaveViewState. var myState = (object[])savedState; //Load Base Controls ViewState if (myState[0] != null) { base.LoadViewState(myState[0]); } //Load ModuleID if (myState[1] != null) { ModuleID = Convert.ToInt32(myState[1]); } //Load InheritViewPermissionsFromTab if (myState[2] != null) { InheritViewPermissionsFromTab = Convert.ToBoolean(myState[2]); } //Load ModulePermissions if (myState[3] != null) { _ModulePermissions = new ModulePermissionCollection(); string state = Convert.ToString(myState[3]); if (!String.IsNullOrEmpty(state)) { //First Break the String into individual Keys string[] permissionKeys = state.Split(new[] { "##" }, StringSplitOptions.None); foreach (string key in permissionKeys) { string[] Settings = key.Split('|'); _ModulePermissions.Add(ParseKeys(Settings)); } } } } }
public ModuleSecurityAlbum(ModuleInfo moduleInfo) { ModulePermissionCollection permCollection = moduleInfo.ModulePermissions; _permissionRead = ModulePermissionController.HasModulePermission(permCollection, PermissionRead); }
private void MakeModerator_Editor() { try { bool blEditor; var arrRoles = new ArrayList(); var arrUsers = new ArrayList(); var objPermission = default(ModulePermissionInfo); var objPermissionController = new PermissionController(); var objModules = new ModuleController(); // Get existing module permissions var objModule = objModules.GetModule(this.ModuleId, this.TabId); var objModulePermissions2 = new ModulePermissionCollection(); foreach (ModulePermissionInfo perm in objModule.ModulePermissions) { if (perm.PermissionKey == "EVENTSMOD" && perm.AllowAccess || perm.PermissionKey == "EDIT" && perm.AllowAccess) { blEditor = false; foreach (ModulePermissionInfo perm2 in objModule.ModulePermissions) { if (perm2.PermissionKey == "EVENTSEDT" && ((perm.RoleID == perm2.RoleID) & (perm.RoleID >= 0) || (perm.UserID == perm2.UserID) & (perm.UserID >= 0))) { if (perm2.AllowAccess) { blEditor = true; } else { objModulePermissions2.Add(perm2); } } } if (blEditor == false) { if (perm.UserID >= 0) { arrUsers.Add(perm.UserID); } else { arrRoles.Add(perm.RoleID); } } } } // Remove negative edit permissions where user is moderator foreach (ModulePermissionInfo perm in objModulePermissions2) { objModule.ModulePermissions.Remove(perm); } var objEditPermissions = objPermissionController.GetPermissionByCodeAndKey("EVENTS_MODULE", "EVENTSEDT"); var objEditPermission = (PermissionInfo)objEditPermissions[0]; foreach (int iRoleID in arrRoles) { // Add Edit Permission for Moderator Role objPermission = new ModulePermissionInfo(); objPermission.RoleID = iRoleID; objPermission.ModuleID = this.ModuleId; objPermission.PermissionKey = objEditPermission.PermissionKey; objPermission.PermissionName = objEditPermission.PermissionName; objPermission.PermissionCode = objEditPermission.PermissionCode; objPermission.PermissionID = objEditPermission.PermissionID; objPermission.AllowAccess = true; objModule.ModulePermissions.Add(objPermission); } foreach (int iUserID in arrUsers) { objPermission = new ModulePermissionInfo(); objPermission.UserID = iUserID; objPermission.ModuleID = this.ModuleId; objPermission.PermissionKey = objEditPermission.PermissionKey; objPermission.PermissionName = objEditPermission.PermissionName; objPermission.PermissionCode = objEditPermission.PermissionCode; objPermission.PermissionID = objEditPermission.PermissionID; objPermission.AllowAccess = true; objModule.ModulePermissions.Add(objPermission); } ModulePermissionController.SaveModulePermissions(objModule); } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
public string UpgradeModule(string version) { string[] _version = version.Split(new char[] { '.' }); int major = Convert.ToInt32(_version[0]); int minor = Convert.ToInt32(_version[1]); int maintenance = Convert.ToInt32(_version[2]); if (major == 9) { if (minor == 0) { if (maintenance == 0) { List <ModuleInfo> modulesList = ModuleController.GetAllModules().Cast <ModuleInfo>().ToList(); foreach (object m in modulesList) { ModuleInfo module = (ModuleInfo)m; if (module.DesktopModule.FriendlyName == "Survey") { ModulePermissionCollection modulePermissions = module.ModulePermissions; // Setting surveyresultstype: 0 = Public, 1 = Private // goes to Permission string surveyResultsTypeSetting = module.ModuleSettings["surveyresultstype"].ToString(); if (string.IsNullOrEmpty(surveyResultsTypeSetting)) { // if not defined: make it private to be safe... surveyResultsTypeSetting = "1"; } // If it is public: All Users (RoleID: -1) have the permission to view the results if (surveyResultsTypeSetting == "0") { List <ModulePermissionInfo> viewResultsPermissions = modulePermissions.Where(mp => mp.ModuleID == module.ModuleID && mp.PermissionCode == ModuleSecurity.PERMISSION_CODE && mp.PermissionKey == ModuleSecurity.VIEW_RESULTS_PERMISSION && mp.RoleID == -1).ToList(); if (viewResultsPermissions.Count() == 0) { ModulePermissionInfo viewResultPermission = new ModulePermissionInfo(); viewResultPermission.AllowAccess = true; viewResultPermission.RoleID = -1; viewResultPermission.PermissionID = ((PermissionInfo)PermissionController.GetPermissionByCodeAndKey(ModuleSecurity.PERMISSION_CODE, ModuleSecurity.VIEW_RESULTS_PERMISSION)[0]).PermissionID; viewResultPermission.ModuleID = module.ModuleID; modulePermissions.Add(viewResultPermission); ModulePermissionController.SaveModulePermissions(module); } } // All roles and user who have edit permissions get the View results permission as well List <ModulePermissionInfo> editModulePermissions = modulePermissions.Where(mp => mp.ModuleID == module.ModuleID && mp.PermissionCode == "SYSTEM_MODULE_DEFINITION" && mp.PermissionKey == "EDIT").ToList(); foreach (ModulePermissionInfo editModulePermission in editModulePermissions) { List <ModulePermissionInfo> viewResultsPermissions; ModulePermissionInfo viewResultPermission = new ModulePermissionInfo(); if (String.IsNullOrEmpty(editModulePermission.RoleName)) { // when the role name is empty it is a user poermission viewResultsPermissions = modulePermissions.Where(mp => mp.PermissionCode == ModuleSecurity.PERMISSION_CODE && mp.PermissionKey == ModuleSecurity.VIEW_RESULTS_PERMISSION && mp.UserID == editModulePermission.UserID).ToList(); viewResultPermission.UserID = editModulePermission.UserID; viewResultPermission.Username = editModulePermission.Username; } else { // role permission viewResultsPermissions = modulePermissions.Where(mp => mp.PermissionCode == ModuleSecurity.PERMISSION_CODE && mp.PermissionKey == ModuleSecurity.VIEW_RESULTS_PERMISSION && mp.RoleID == editModulePermission.RoleID).ToList(); viewResultPermission.RoleID = editModulePermission.RoleID; viewResultPermission.RoleName = editModulePermission.RoleName; } if (viewResultsPermissions.Count() == 0) { // if the permission for this user/role is not already set... viewResultPermission.AllowAccess = true; viewResultPermission.PermissionID = ((PermissionInfo)PermissionController.GetPermissionByCodeAndKey(ModuleSecurity.PERMISSION_CODE, ModuleSecurity.VIEW_RESULTS_PERMISSION)[0]).PermissionID; viewResultPermission.ModuleID = module.ModuleID; modulePermissions.Add(viewResultPermission); ModulePermissionController.SaveModulePermissions(module); } } // Setting surveytracking: 0 = Cookie, 1 = Registered user // goes to Permission string surveyTrackingSetting = module.ModuleSettings["surveytracking"].ToString(); if (string.IsNullOrEmpty(surveyTrackingSetting)) { // if not defined: make it per user surveyTrackingSetting = "1"; } // If it is Cookie tracking: All users (RoleId: -1) have the permissions to participate in the survey // Otherwise: Registered Users have the permission to participate in the survey // Is there a better way than using the hard coded role IDs? int permittedRoleID = (surveyTrackingSetting == "0" ? -1 : 1); List <ModulePermissionInfo> participatePermissions = modulePermissions.Where(mp => mp.ModuleID == module.ModuleID && mp.PermissionCode == ModuleSecurity.PERMISSION_CODE && mp.PermissionKey == ModuleSecurity.PARTICIPATE_PERMISSION && mp.RoleID == permittedRoleID).ToList(); if (participatePermissions.Count() == 0) { ModulePermissionInfo participatePermission = new ModulePermissionInfo(); participatePermission.AllowAccess = true; participatePermission.RoleID = permittedRoleID; participatePermission.PermissionID = ((PermissionInfo)PermissionController.GetPermissionByCodeAndKey(ModuleSecurity.PERMISSION_CODE, ModuleSecurity.PARTICIPATE_PERMISSION)[0]).PermissionID; participatePermission.ModuleID = module.ModuleID; modulePermissions.Add(participatePermission); ModulePermissionController.SaveModulePermissions(module); } // Is Module a quiz? List <SurveysInfo> surveys = SurveysController.GetAll(module.ModuleID); bool isQuiz = false; List <SurveysInfo> statisticalSurveys = new List <SurveysInfo>(); foreach (SurveysInfo survey in surveys) { List <SurveyOptionsInfo> surveyOptions = SurveyOptionsController.GetAll(survey.SurveyID); int countCorrect = surveyOptions.Where(so => so.IsCorrect).Count(); if (countCorrect > 0) { isQuiz = true; } else { statisticalSurveys.Add(survey); } } if (isQuiz) { ModuleController.Instance.UpdateModuleSetting(module.ModuleID, "SurveyType", ((int)SurveyType.Quiz).ToString()); foreach (SurveysInfo statisticalSurvey in statisticalSurveys) { statisticalSurvey.IsStatistical = true; SurveysController.AddOrChange(statisticalSurvey, XmlDataProvider.SurveyOptionsToXml(SurveyOptionsController.GetAll(statisticalSurvey.SurveyID)), -1); } } string surveyClosingDate = module.ModuleSettings["surveyclosingdate"].ToString(); if (!(string.IsNullOrEmpty(surveyClosingDate))) { ModuleController.Instance.DeleteModuleSetting(module.ModuleID, "surveyclosingdate"); ModuleController.Instance.UpdateModuleSetting(module.ModuleID, "SurveyClosingDate", surveyClosingDate); } // Remove unused old settings ModuleController.Instance.DeleteModuleSetting(module.ModuleID, "surveyresultstype"); ModuleController.Instance.DeleteModuleSetting(module.ModuleID, "surveytracking"); ModuleController.Instance.DeleteModuleSetting(module.ModuleID, "surveyresulttemplate"); ModuleController.Instance.DeleteTabModuleSetting(module.TabModuleID, "surveygraphwidth"); } } } } } return(string.Format("Upgrading to version {0}.", version)); }
/// <summary> /// Gets the ModulePermissions from the Data Store /// </summary> private void GetModulePermissions() { ModulePermissionController objModulePermissionController = new ModulePermissionController(); ModulePermissions = objModulePermissionController.GetModulePermissionsCollectionByModuleID(ModuleID, TabId); }
/// ----------------------------------------------------------------------------- /// <summary> /// Gets the ModulePermissions from the Data Store /// </summary> /// <history> /// [cnurse] 01/12/2006 Created /// </history> /// ----------------------------------------------------------------------------- private void GetModulePermissions() { _ModulePermissions = new ModulePermissionCollection(ModulePermissionController.GetModulePermissions(ModuleID, TabId)); _PermissionsList = null; }
/// <summary> /// Load the ViewState /// </summary> /// <param name="savedState">The saved state</param> protected override void LoadViewState( object savedState ) { if( !( savedState == null ) ) { // Load State from the array of objects that was saved with SaveViewState. object[] myState = (object[])savedState; //Load Base Controls ViewStte if( !( myState[0] == null ) ) { base.LoadViewState( myState[0] ); } //Load ModuleID if( !( myState[1] == null ) ) { ModuleID = Convert.ToInt32( myState[1] ); } //Load InheritViewPermissionsFromTab if( !( myState[2] == null ) ) { InheritViewPermissionsFromTab = Convert.ToBoolean( myState[2] ); } //Load ModulePermissions if( !( myState[3] == null ) ) { ArrayList arrPermissions = new ArrayList(); string state = myState[3].ToString(); if( !String.IsNullOrEmpty( state ) ) { //First Break the String into individual Keys string[] permissionKeys = state.Split( "##".ToCharArray()[0] ); foreach( string key in permissionKeys ) { string[] Settings = key.Split( '|' ); ParsePermissionKeys( Settings, arrPermissions ); } } ModulePermissions = new ModulePermissionCollection( arrPermissions ); } } }
private void Create_Click(object sender, EventArgs e) { RoleController roleController = new RoleController(); Security.PortalSecurity ps = new Security.PortalSecurity(); txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoScripting); txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoMarkup); txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting); txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup); if (roleController.GetRoleByName(PortalId, txtGroupName.Text) != null) { lblInvalidGroupName.Visible = true; return; } var modRoles = new List <RoleInfo>(); var modUsers = new List <UserInfo>(); foreach (ModulePermissionInfo modulePermissionInfo in ModulePermissionController.GetModulePermissions(ModuleId, TabId)) { if (modulePermissionInfo.PermissionKey == "MODGROUP" && modulePermissionInfo.AllowAccess) { if (modulePermissionInfo.RoleID > int.Parse(Globals.glbRoleNothing)) { modRoles.Add(roleController.GetRole(modulePermissionInfo.RoleID, PortalId)); } else if (modulePermissionInfo.UserID > Null.NullInteger) { modUsers.Add(UserController.GetUserById(PortalId, modulePermissionInfo.UserID)); } } } var roleInfo = new RoleInfo() { PortalID = PortalId, RoleName = txtGroupName.Text, Description = txtDescription.Text, SecurityMode = SecurityMode.SocialGroup, Status = RoleStatus.Approved, IsPublic = rdAccessTypePublic.Checked }; var userRoleStatus = RoleStatus.Pending; if (GroupModerationEnabled) { roleInfo.Status = RoleStatus.Pending; userRoleStatus = RoleStatus.Pending; } else { userRoleStatus = RoleStatus.Approved; } var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(ModuleId, -1), typeof(ModulePermissionInfo))); if (ModulePermissionController.HasModulePermission(objModulePermissions, "MODGROUP")) { roleInfo.Status = RoleStatus.Approved; userRoleStatus = RoleStatus.Approved; } roleInfo.RoleGroupID = DefaultRoleGroupId; roleInfo.RoleID = roleController.AddRole(roleInfo); roleInfo = roleController.GetRole(roleInfo.RoleID, PortalId); var groupUrl = Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }); if (groupUrl.StartsWith("http://") || groupUrl.StartsWith("https://")) { const int startIndex = 8; // length of https:// groupUrl = groupUrl.Substring(groupUrl.IndexOf("/", startIndex, StringComparison.InvariantCultureIgnoreCase)); } roleInfo.Settings.Add("URL", groupUrl); roleInfo.Settings.Add("GroupCreatorName", UserInfo.DisplayName); roleInfo.Settings.Add("ReviewMembers", chkMemberApproved.Checked.ToString()); TestableRoleController.Instance.UpdateRoleSettings(roleInfo, true); if (inpFile.PostedFile != null && inpFile.PostedFile.ContentLength > 0) { IFileManager _fileManager = FileManager.Instance; IFolderManager _folderManager = FolderManager.Instance; var rootFolderPath = PathUtils.Instance.FormatFolderPath(PortalSettings.HomeDirectory); IFolderInfo groupFolder = _folderManager.GetFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID); if (groupFolder == null) { groupFolder = _folderManager.AddFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID); } if (groupFolder != null) { var fileName = Path.GetFileName(inpFile.PostedFile.FileName); var fileInfo = _fileManager.AddFile(groupFolder, fileName, inpFile.PostedFile.InputStream, true); roleInfo.IconFile = "FileID=" + fileInfo.FileId; roleController.UpdateRole(roleInfo); } } var notifications = new Notifications(); roleController.AddUserRole(PortalId, UserId, roleInfo.RoleID, userRoleStatus, true, Null.NullDate, Null.NullDate); if (roleInfo.Status == RoleStatus.Pending) { //Send notification to Group Moderators to approve/reject group. notifications.AddGroupNotification(Constants.GroupPendingNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles, modUsers); } else { //Send notification to Group Moderators informing of new group. notifications.AddGroupNotification(Constants.GroupCreatedNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles, modUsers); //Add entry to journal. GroupUtilities.CreateJournalEntry(roleInfo, UserInfo); } Response.Redirect(Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() })); }
protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align) { TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions; PermissionController objPermissionController = new PermissionController(); ModuleController objModules = new ModuleController(); ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController(); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); int intIndex; try { DesktopModuleController objDesktopModules = new DesktopModuleController(); ArrayList arrDM = objDesktopModules.GetDesktopModulesByPortal(PortalSettings.PortalId); bool isSelectable = false; for (int intloop = 0; intloop < arrDM.Count; intloop++) { if (((DesktopModuleInfo)(arrDM[intloop])).DesktopModuleID == desktopModuleId) { isSelectable = true; break; } } if (isSelectable == false) { throw new Exception(); } } catch (Exception ex) { throw new Exception(ex.Message); } int UserId = -1; if (Request.IsAuthenticated) { UserInfo objUserInfo = UserController.GetCurrentUserInfo(); UserId = objUserInfo.UserID; } ArrayList arrModuleDefinitions = objModuleDefinitions.GetModuleDefinitions(desktopModuleId); for (intIndex = 0; intIndex < arrModuleDefinitions.Count; intIndex++) { ModuleDefinitionInfo objModuleDefinition = (ModuleDefinitionInfo)(arrModuleDefinitions[intIndex]); ModuleInfo objModule = new ModuleInfo(); objModule.Initialize(PortalSettings.PortalId); objModule.PortalID = PortalSettings.PortalId; objModule.TabID = PortalSettings.ActiveTab.TabID; objModule.ModuleOrder = position; if (String.IsNullOrEmpty(title)) { objModule.ModuleTitle = objModuleDefinition.FriendlyName; } else { objModule.ModuleTitle = title; } objModule.ModuleTitle = title; objModule.PaneName = paneName; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; objModule.CacheTime = objModuleDefinition.DefaultCacheTime; // initialize module permissions ModulePermissionCollection objModulePermissions = new ModulePermissionCollection(); objModule.ModulePermissions = objModulePermissions; objModule.InheritViewPermissions = false; // get the default module view permissions ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW"); // get the permissions from the page foreach (TabPermissionInfo objTabPermission in objTabPermissions) { // get the system module permissions for the permissionkey ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey); // loop through the system module permissions int j; for (j = 0; j < arrSystemModulePermissions.Count; j++) { // create the module permission PermissionInfo objSystemModulePermission = (PermissionInfo)(arrSystemModulePermissions[j]); ModulePermissionInfo objModulePermission = AddModulePermission(objModule.ModuleID, objSystemModulePermission, objTabPermission.RoleID); // add the permission to the collection if (!(objModulePermissions.Contains(objModulePermission)) & objModulePermission.AllowAccess) { objModulePermissions.Add(objModulePermission); } // ensure that every EDIT permission which allows access also provides VIEW permission if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess) { ModulePermissionInfo objModuleViewperm = new ModulePermissionInfo(); objModuleViewperm.ModuleID = objModulePermission.ModuleID; objModuleViewperm.PermissionID = ((PermissionInfo)(arrSystemModuleViewPermissions[0])).PermissionID; objModuleViewperm.RoleID = objModulePermission.RoleID; objModuleViewperm.PermissionKey = "VIEW"; objModuleViewperm.AllowAccess = true; if (!(objModulePermissions.Contains(objModuleViewperm))) { objModulePermissions.Add(objModuleViewperm); } } } //Get the custom Module Permissions, Assume that roles with Edit Tab Permissions //are automatically assigned to the Custom Module Permissions if (objTabPermission.PermissionKey == "EDIT") { ArrayList arrCustomModulePermissions = objPermissionController.GetPermissionsByModuleDefID(objModule.ModuleDefID); // loop through the custom module permissions for (j = 0; j < arrCustomModulePermissions.Count; j++) { // create the module permission PermissionInfo objCustomModulePermission = (PermissionInfo)(arrCustomModulePermissions[j]); ModulePermissionInfo objModulePermission = AddModulePermission(objModule.ModuleID, objCustomModulePermission, objTabPermission.RoleID); // add the permission to the collection if (!(objModulePermissions.Contains(objModulePermission)) & objModulePermission.AllowAccess) { objModulePermissions.Add(objModulePermission); } } } } switch (permissionType) { case ViewPermissionType.View: objModule.InheritViewPermissions = true; break; case ViewPermissionType.Edit: objModule.ModulePermissions = objModulePermissions; break; } objModule.AllTabs = false; objModule.Visibility = VisibilityState.Maximized; objModule.Alignment = align; objModules.AddModule(objModule); objEventLog.AddLog(objModule, PortalSettings, UserId, "", Services.Log.EventLog.EventLogController.EventLogType.MODULE_CREATED); } }