private static ModulePermissionCollection FillModulePermissionCollection( IDataReader dr )
 {
     ModulePermissionCollection arr = new ModulePermissionCollection();
     try
     {
         while( dr.Read() )
         {
             // fill business object
             ModulePermissionInfo obj = FillModulePermissionInfo( dr, false );
             // add to collection
             arr.Add( obj );
         }
     }
     catch( Exception exc )
     {
         Exceptions.LogException( exc );
     }
     finally
     {
         // close datareader
         if( dr != null )
         {
             dr.Close();
         }
     }
     return arr;
 }
Ejemplo n.º 2
0
        private static ModulePermissionCollection FillModulePermissionCollection(IDataReader dr)
        {
            ModulePermissionCollection arr = new ModulePermissionCollection();

            try
            {
                while (dr.Read())
                {
                    // fill business object
                    ModulePermissionInfo obj = FillModulePermissionInfo(dr, false);
                    // add to collection
                    arr.Add(obj);
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                // close datareader
                if (dr != null)
                {
                    dr.Close();
                }
            }
            return(arr);
        }
Ejemplo n.º 3
0
        public static bool HasModulePermission(int moduleID, int TabId, string PermissionKey)
        {
            ModulePermissionController objModulePermissionController = new ModulePermissionController();
            ModulePermissionCollection objModulePermissions          = objModulePermissionController.GetModulePermissionsCollectionByModuleID(moduleID, TabId);

            return(HasModulePermission(objModulePermissions, PermissionKey));
        }
Ejemplo n.º 4
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// SaveModulePermissions updates a Module's permissions
 /// </summary>
 /// <param name="objModule">The Module to update</param>
 /// <history>
 ///     [cnurse]	04/15/2009   Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public virtual void SaveModulePermissions(ModuleInfo objModule)
 {
     if (objModule.ModulePermissions != null)
     {
         ModulePermissionCollection modulePermissions = ModulePermissionController.GetModulePermissions(objModule.ModuleID, objModule.TabID);
         if (!modulePermissions.CompareTo(objModule.ModulePermissions))
         {
             dataProvider.DeleteModulePermissionsByModuleID(objModule.ModuleID);
             foreach (ModulePermissionInfo objModulePermission in objModule.ModulePermissions)
             {
                 if (objModule.InheritViewPermissions && objModulePermission.PermissionKey == "VIEW")
                 {
                     dataProvider.DeleteModulePermission(objModulePermission.ModulePermissionID);
                 }
                 else
                 {
                     dataProvider.AddModulePermission(objModule.ModuleID,
                                                      objModulePermission.PermissionID,
                                                      objModulePermission.RoleID,
                                                      objModulePermission.AllowAccess,
                                                      objModulePermission.UserID,
                                                      UserController.GetCurrentUserInfo().UserID);
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 public void AddRange(ModulePermissionCollection modulePermissions)
 {
     foreach (ModulePermissionInfo permission in modulePermissions)
     {
         Add(permission);
     }
 }
Ejemplo n.º 6
0
        public string GetModulePermissionsByModuleID(ModuleInfo objModule, string permissionKey)
        {
            //Create a Module Permission Collection from the ArrayList
            var modulePermissions = new ModulePermissionCollection(objModule);

            //Return the permission string for permissions with specified TabId
            return(modulePermissions.ToString(permissionKey));
        }
Ejemplo n.º 7
0
 public static bool HasModulePermission(ModulePermissionCollection objModulePermissions, string PermissionKey)
 {
     foreach (ModulePermissionInfo objPermission in objModulePermissions)
     {
         if (objPermission.PermissionKey == PermissionKey && PortalSecurity.IsInRoles(objPermission.RoleName))
         {
             return(true);
         }
     }
     return(false);
 }
 public static bool HasModulePermission( ModulePermissionCollection objModulePermissions, string PermissionKey )
 {
     foreach( ModulePermissionInfo objPermission in objModulePermissions )
     {
         if( objPermission.PermissionKey == PermissionKey && PortalSecurity.IsInRoles( objPermission.RoleName ) )
         {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 9
0
        public string GetModulePermissions(ModulePermissionCollection modulePermissions, string PermissionKey)
        {
            string strRoles = ";";

            foreach (ModulePermissionInfo objModulePermission in modulePermissions)
            {
                if (objModulePermission.AllowAccess && objModulePermission.PermissionKey == PermissionKey)
                {
                    strRoles += objModulePermission.RoleName + ";";
                }
            }
            return(strRoles);
        }
Ejemplo n.º 10
0
        public string GetModulePermissionsByModuleID(ModuleInfo objModule, string PermissionKey)
        {
            ModulePermissionCollection objModPerms = objModule.ModulePermissions;
            string strRoles = ";";

            foreach (ModulePermissionInfo objModulePermission in objModPerms)
            {
                if (objModulePermission.AllowAccess && objModulePermission.PermissionKey == PermissionKey)
                {
                    strRoles += objModulePermission.RoleName + ";";
                }
            }
            return(strRoles);
        }
Ejemplo n.º 11
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetModulePermissions gets a ModulePermissionCollection
        /// </summary>
        /// <param name="moduleID">The ID of the module</param>
        /// <param name="tabID">The ID of the tab</param>
        /// <history>
        ///     [cnurse]	04/15/2009   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public virtual ModulePermissionCollection GetModulePermissions(int moduleID, int tabID)
        {
            //Get the Tab ModulePermission Dictionary
            Dictionary <int, ModulePermissionCollection> dicModulePermissions = GetModulePermissions(tabID);

            //Get the Collection from the Dictionary
            ModulePermissionCollection modulePermissions;
            bool bFound = dicModulePermissions.TryGetValue(moduleID, out modulePermissions);

            if (!bFound)
            {
                //Return empty collection
                modulePermissions = new ModulePermissionCollection();
            }
            return(modulePermissions);
        }
Ejemplo n.º 12
0
 public bool CompareTo(ModulePermissionCollection objModulePermissionCollection)
 {
     if (objModulePermissionCollection.Count != Count)
     {
         return(false);
     }
     InnerList.Sort(new CompareModulePermissions());
     objModulePermissionCollection.InnerList.Sort(new CompareModulePermissions());
     for (int i = 0; i <= Count - 1; i++)
     {
         if (objModulePermissionCollection[i].ModulePermissionID != this[i].ModulePermissionID || objModulePermissionCollection[i].AllowAccess != this[i].AllowAccess)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 13
0
        private static Dictionary <int, ModulePermissionCollection> FillModulePermissionDictionary(IDataReader dr)
        {
            Dictionary <int, ModulePermissionCollection> dic = new Dictionary <int, ModulePermissionCollection>();

            try
            {
                while (dr.Read())
                {
                    // fill business object
                    ModulePermissionInfo obj = FillModulePermissionInfo(dr, false);

                    // add Module Permission to dictionary
                    if (dic.ContainsKey(obj.ModuleID))
                    {
                        //Add ModulePermission to ModulePermission Collection already in dictionary for TabId
                        dic[obj.ModuleID].Add(obj);
                    }
                    else
                    {
                        //Create new ModulePermission Collection for ModuleId
                        ModulePermissionCollection collection = new ModulePermissionCollection();

                        //Add Permission to Collection
                        collection.Add(obj);

                        //Add Collection to Dictionary
                        dic.Add(obj.ModuleID, collection);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                // close datareader
                if (dr != null)
                {
                    dr.Close();
                }
            }
            return(dic);
        }
Ejemplo n.º 14
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetModulePermissionsCallBack gets a Dictionary of ModulePermissionCollections by
        /// Module from the the Database.
        /// </summary>
        /// <param name="cacheItemArgs">The CacheItemArgs object that contains the parameters
        /// needed for the database call</param>
        /// <history>
        ///     [cnurse]	04/15/2009   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private object GetModulePermissionsCallBack(CacheItemArgs cacheItemArgs)
        {
            var         tabID = (int)cacheItemArgs.ParamList[0];
            IDataReader dr    = dataProvider.GetModulePermissionsByTabID(tabID);
            var         dic   = new Dictionary <int, ModulePermissionCollection>();

            try
            {
                while (dr.Read())
                {
                    //fill business object
                    var modulePermissionInfo = CBO.FillObject <ModulePermissionInfo>(dr, false);

                    //add Module Permission to dictionary
                    if (dic.ContainsKey(modulePermissionInfo.ModuleID))
                    {
                        dic[modulePermissionInfo.ModuleID].Add(modulePermissionInfo);
                    }
                    else
                    {
                        //Create new ModulePermission Collection for ModuleId
                        var collection = new ModulePermissionCollection {
                            modulePermissionInfo
                        };

                        //Add Permission to Collection

                        //Add Collection to Dictionary
                        dic.Add(modulePermissionInfo.ModuleID, collection);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                //close datareader
                CBO.CloseDataReader(dr, true);
            }
            return(dic);
        }
Ejemplo n.º 15
0
        private bool IsDeniedModulePermission(ModulePermissionCollection modulePermissions, string permissionKey)
        {
            bool isDenied = Null.NullBoolean;

            if (permissionKey.Contains(","))
            {
                foreach (string permission in permissionKey.Split(','))
                {
                    if (PortalSecurity.IsDenied(modulePermissions.ToString(permission)))
                    {
                        isDenied = true;
                        break;
                    }
                }
            }
            else
            {
                isDenied = PortalSecurity.IsDenied(modulePermissions.ToString(permissionKey));
            }
            return(isDenied);
        }
Ejemplo n.º 16
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// HasModulePermission checks whether the current user has a specific Module Permission
        /// </summary>
        /// <param name="modulePermissions">The Permissions for the Module</param>
        /// <param name="permissionKey">The Permission to check</param>
        /// -----------------------------------------------------------------------------
        public virtual bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey)
        {
            bool hasPermission = Null.NullBoolean;

            if (permissionKey.Contains(","))
            {
                foreach (string permission in permissionKey.Split(','))
                {
                    if (PortalSecurity.IsInRoles(modulePermissions.ToString(permission)))
                    {
                        hasPermission = true;
                        break;
                    }
                }
            }
            else
            {
                hasPermission = PortalSecurity.IsInRoles(modulePermissions.ToString(permissionKey));
            }
            return(hasPermission);
        }
Ejemplo n.º 17
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// HasModulePermission checks whether the current user has a specific Module Permission
        /// </summary>
        /// <remarks>If you pass in a comma delimited list of permissions (eg "ADD,DELETE", this will return
        /// true if the user has any one of the permissions.</remarks>
        /// <param name="modulePermissions">The Permissions for the Module</param>
        /// <param name="permissionKey">The Permission to check</param>
        /// <history>
        ///     [cnurse]	01/15/2008   Documented
        /// </history>
        /// -----------------------------------------------------------------------------
        public static bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey)
        {
            bool hasPermission = Null.NullBoolean;

            if (permissionKey.Contains(","))
            {
                foreach (string permission in permissionKey.Split(','))
                {
                    if (Provider.HasModulePermission(modulePermissions, permission))
                    {
                        hasPermission = true;
                        break;
                    }
                }
            }
            else
            {
                hasPermission = Provider.HasModulePermission(modulePermissions, permissionKey);
            }
            return(hasPermission);
        }
        public bool CompareTo(ModulePermissionCollection objModulePermissionCollection)
        {
            if (objModulePermissionCollection.Count != this.Count)
            {
                return false;
            }
            InnerList.Sort(new CompareModulePermissions());
            objModulePermissionCollection.InnerList.Sort(new CompareModulePermissions());

            ModulePermissionInfo objModulePermission;
            int i = 0;
            foreach (ModulePermissionInfo tempLoopVar_objModulePermission in objModulePermissionCollection)
            {
                objModulePermission = tempLoopVar_objModulePermission;
                if (objModulePermissionCollection[i].ModulePermissionID != this[i].ModulePermissionID || objModulePermissionCollection[i].AllowAccess != this[i].AllowAccess)
                {
                    return false;
                }
                i++;
            }
            return true;
        }
Ejemplo n.º 19
0
        public bool CompareTo(ModulePermissionCollection objModulePermissionCollection)
        {
            if (objModulePermissionCollection.Count != this.Count)
            {
                return(false);
            }
            InnerList.Sort(new CompareModulePermissions());
            objModulePermissionCollection.InnerList.Sort(new CompareModulePermissions());

            ModulePermissionInfo objModulePermission;
            int i = 0;

            foreach (ModulePermissionInfo tempLoopVar_objModulePermission in objModulePermissionCollection)
            {
                objModulePermission = tempLoopVar_objModulePermission;
                if (objModulePermissionCollection[i].ModulePermissionID != this[i].ModulePermissionID || objModulePermissionCollection[i].AllowAccess != this[i].AllowAccess)
                {
                    return(false);
                }
                i++;
            }
            return(true);
        }
Ejemplo n.º 20
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasModulePermission checks whether the current user has a specific Module Permission
 /// </summary>
 /// <param name="modulePermissions">The Permissions for the Module</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// -----------------------------------------------------------------------------
 public virtual bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey)
 {
     bool hasPermission = Null.NullBoolean;
     if (permissionKey.Contains(","))
     {
         foreach (string permission in permissionKey.Split(','))
         {
             if (PortalSecurity.IsInRoles(modulePermissions.ToString(permission)))
             {
                 hasPermission = true;
                 break;
             }
         }
     }
     else
     {
         hasPermission = PortalSecurity.IsInRoles(modulePermissions.ToString(permissionKey));
     }
     return hasPermission; 
 }
Ejemplo n.º 21
0
 private bool IsDeniedModulePermission(ModulePermissionCollection modulePermissions, string permissionKey)
 {
     bool isDenied = Null.NullBoolean;
     if (permissionKey.Contains(","))
     {
         foreach (string permission in permissionKey.Split(','))
         {
             if (PortalSecurity.IsDenied(modulePermissions.ToString(permission)))
             {
                 isDenied = true;
                 break;
             }
         }
     }
     else
     {
         isDenied = PortalSecurity.IsDenied(modulePermissions.ToString(permissionKey));
     }
     return isDenied;
 }
Ejemplo n.º 22
0
        private void Create_Click(object sender, EventArgs e)
        {
            var 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.Instance.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.Instance.GetRoleById(PortalId, modulePermissionInfo.RoleID));
	                }
					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.Instance.AddRole(roleInfo);
            roleInfo = RoleController.Instance.GetRoleById(PortalId, roleInfo.RoleID);

	        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());

            RoleController.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.Instance.UpdateRole(roleInfo);
                }
            }

            var notifications = new Notifications();


            RoleController.Instance.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() }));
        }
Ejemplo n.º 23
0
 public static bool HasEditPermissions(ModulePermissionCollection objModulePermissions)
 {
     return ModulePermissionController.HasModulePermission(objModulePermissions, "EDIT");
 }
Ejemplo n.º 24
0
 public ModulePermissionCollection(ModulePermissionCollection modulePermissions)
 {
     AddRange(modulePermissions);
 }
 public bool CompareTo(ModulePermissionCollection objModulePermissionCollection)
 {
     if (objModulePermissionCollection.Count != Count)
     {
         return false;
     }
     InnerList.Sort(new CompareModulePermissions());
     objModulePermissionCollection.InnerList.Sort(new CompareModulePermissions());
     for (int i = 0; i <= Count - 1; i++)
     {
         if (objModulePermissionCollection[i].ModulePermissionID != this[i].ModulePermissionID || objModulePermissionCollection[i].AllowAccess != this[i].AllowAccess)
         {
             return false;
         }
     }
     return true;
 }
        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));
        }
        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);
            }

        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasModulePermission checks whether the current user has a specific Module Permission
 /// </summary>
 /// <remarks>If you pass in a comma delimited list of permissions (eg "ADD,DELETE", this will return
 /// true if the user has any one of the permissions.</remarks>
 /// <param name="modulePermissions">The Permissions for the Module</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// <history>
 /// 	[cnurse]	01/15/2008   Documented
 /// </history>
 /// -----------------------------------------------------------------------------
 public static bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey)
 {
     bool hasPermission = Null.NullBoolean;
     if (permissionKey.Contains(","))
     {
         foreach (string permission in permissionKey.Split(','))
         {
             if (Provider.HasModulePermission(modulePermissions, permission))
             {
                 hasPermission = true;
                 break;
             }
         }
     }
     else
     {
         hasPermission = Provider.HasModulePermission(modulePermissions, permissionKey);
     }
     return hasPermission;
 }
Ejemplo n.º 29
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasModulePermission checks whether the current user has a specific Module Permission
 /// </summary>
 /// <param name="objModulePermissions">The Permissions for the Module</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// <history>
 ///     [cnurse]	04/15/2009   Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public virtual bool HasModulePermission(ModulePermissionCollection objModulePermissions, string permissionKey)
 {
     return(PortalSecurity.IsInRoles(objModulePermissions.ToString(permissionKey)));
 }
 public ModulePermissionCollection GetModulePermissionsCollectionByModuleID( ArrayList arrModulePermissions, int moduleID )
 {
     ModulePermissionCollection objModulePermissionCollection = new ModulePermissionCollection( arrModulePermissions, moduleID );
     return objModulePermissionCollection;
 }
        private static Dictionary<int, ModulePermissionCollection> FillModulePermissionDictionary( IDataReader dr )
        {
            Dictionary<int, ModulePermissionCollection> dic = new Dictionary<int, ModulePermissionCollection>();
            try
            {
                while( dr.Read() )
                {
                    // fill business object
                    ModulePermissionInfo obj = FillModulePermissionInfo( dr, false );

                    // add Module Permission to dictionary
                    if( dic.ContainsKey( obj.ModuleID ) )
                    {
                        //Add ModulePermission to ModulePermission Collection already in dictionary for TabId
                        dic[obj.ModuleID].Add( obj );
                    }
                    else
                    {
                        //Create new ModulePermission Collection for ModuleId
                        ModulePermissionCollection collection = new ModulePermissionCollection();

                        //Add Permission to Collection
                        collection.Add( obj );

                        //Add Collection to Dictionary
                        dic.Add( obj.ModuleID, collection );
                    }
                }
            }
            catch( Exception exc )
            {
                Exceptions.LogException( exc );
            }
            finally
            {
                // close datareader
                if( dr != null )
                {
                    dr.Close();
                }
            }
            return dic;
        }
Ejemplo n.º 32
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasModulePermission checks whether the current user has a specific Module Permission
 /// </summary>
 /// <param name="modulePermissions">The Permissions for the Module</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// <history>
 /// 	[cnurse]	04/15/2009   Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public virtual bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey)
 {
     return PortalSecurity.IsInRoles(modulePermissions.ToString(permissionKey));
 }
Ejemplo n.º 33
0
        public ModulePermissionCollection GetModulePermissionsCollectionByModuleID(ArrayList arrModulePermissions, int moduleID)
        {
            ModulePermissionCollection objModulePermissionCollection = new ModulePermissionCollection(arrModulePermissions, moduleID);

            return(objModulePermissionCollection);
        }
Ejemplo n.º 34
0
        public static bool HasModulePermission(int moduleID, string permissionKey)
        {
            var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(moduleID, -1), typeof(ModulePermissionInfo)));

            return(HasModulePermission(objModulePermissions, permissionKey));
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasModulePermission checks whether the current user has a specific Module Permission
 /// </summary>
 /// <remarks>If you pass in a comma delimited list of permissions (eg "ADD,DELETE", this will return
 /// true if the user has any one of the permissions.</remarks>
 /// <param name="modulePermissions">The Permissions for the Module</param>
 /// <param name="permissionKey">The Permission to check</param>
 /// -----------------------------------------------------------------------------
 public static bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey)
 {
     return _provider.HasModulePermission(modulePermissions, permissionKey);
 }
Ejemplo n.º 36
0
 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);
 }
 public string GetModulePermissions(ModulePermissionCollection modulePermissions, string permissionKey)
 {
     return modulePermissions.ToString(permissionKey);
 }
 public void AddRange(ModulePermissionCollection modulePermissions)
 {
     foreach (ModulePermissionInfo permission in modulePermissions)
     {
         Add(permission);
     }
 }
        public string GetModulePermissionsByModuleID(ModuleInfo objModule, string permissionKey)
        {
            //Create a Module Permission Collection from the ArrayList
            var modulePermissions = new ModulePermissionCollection(objModule);

            //Return the permission string for permissions with specified TabId
            return modulePermissions.ToString(permissionKey);
        }
Ejemplo n.º 40
0
        private void ParseModulePermissions( XmlNodeList nodeModulePermissions, int PortalId, int ModuleID )
        {
            RoleController objRoleController = new RoleController();
            RoleInfo objRole = null;
            ModulePermissionCollection objModulePermissions = new ModulePermissionCollection();
            ModulePermissionController objModulePermissionController = new ModulePermissionController();
            PermissionController objPermissionController = new PermissionController();
            PermissionInfo objPermission = null;
            ModulePermissionCollection objModulePermissionCollection = new ModulePermissionCollection();
            int PermissionID = 0;
            ArrayList arrPermissions = null;
            int i = 0;
            string PermissionKey = null;
            string PermissionCode = null;
            string RoleName = null;
            int RoleID = 0;
            bool AllowAccess = false;

            foreach( XmlNode node in nodeModulePermissions )
            {
                PermissionKey = XmlUtils.GetNodeValue( node, "permissionkey", "" );
                PermissionCode = XmlUtils.GetNodeValue( node, "permissioncode", "" );
                RoleName = XmlUtils.GetNodeValue( node, "rolename", "" );
                AllowAccess = XmlUtils.GetNodeValueBoolean( node, "allowaccess", false );

                RoleID = int.MinValue;
                if( RoleName == Globals.glbRoleAllUsersName )
                {
                    RoleID = Convert.ToInt32( Globals.glbRoleAllUsers );
                }
                else if( RoleName == Globals.glbRoleUnauthUserName )
                {
                    RoleID = Convert.ToInt32( Globals.glbRoleUnauthUser );
                }
                else
                {
                    objRole = objRoleController.GetRoleByName( PortalId, RoleName );
                    if( objRole != null )
                    {
                        RoleID = objRole.RoleID;
                    }
                }
                if( RoleID != int.MinValue )
                {
                    PermissionID = -1;
                    arrPermissions = objPermissionController.GetPermissionByCodeAndKey( PermissionCode, PermissionKey );

                    for( i = 0; i < arrPermissions.Count; i++ )
                    {
                        objPermission = (PermissionInfo)( arrPermissions[i] );
                        PermissionID = objPermission.PermissionID;
                    }

                    // if role was found add, otherwise ignore
                    if( PermissionID != -1 )
                    {
                        ModulePermissionInfo objModulePermission = new ModulePermissionInfo();
                        objModulePermission.ModuleID = ModuleID;
                        objModulePermission.PermissionID = PermissionID;
                        objModulePermission.RoleID = RoleID;
                        objModulePermission.AllowAccess = Convert.ToBoolean( XmlUtils.GetNodeValue( node, "allowaccess", "false" ) );
                        objModulePermissionController.AddModulePermission( objModulePermission );
                    }
                }
            }
        }
 public static bool HasModulePermission(int moduleID, string permissionKey)
 {
     var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(moduleID, -1), typeof (ModulePermissionInfo)));
     return HasModulePermission(objModulePermissions, permissionKey);
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// HasModulePermission checks whether the current user has a specific Module Permission.
 /// </summary>
 /// <remarks>If you pass in a comma delimited list of permissions (eg "ADD,DELETE", this will return
 /// true if the user has any one of the permissions.</remarks>
 /// <param name="modulePermissions">The Permissions for the Module.</param>
 /// <param name="permissionKey">The Permission to check.</param>
 /// <returns></returns>
 /// -----------------------------------------------------------------------------
 public static bool HasModulePermission(ModulePermissionCollection modulePermissions, string permissionKey)
 {
     return(_provider.HasModulePermission(modulePermissions, permissionKey));
 }
 public string GetModulePermissions( ModulePermissionCollection modulePermissions, string PermissionKey )
 {
     string strRoles = ";";
     foreach( ModulePermissionInfo objModulePermission in modulePermissions )
     {
         if( objModulePermission.AllowAccess && objModulePermission.PermissionKey == PermissionKey )
         {
             strRoles += objModulePermission.RoleName + ";";
         }
     }
     return strRoles;
 }
Ejemplo n.º 44
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetModulePermissionsCallBack gets a Dictionary of ModulePermissionCollections by
        /// Module from the the Database.
        /// </summary>
        /// <param name="cacheItemArgs">The CacheItemArgs object that contains the parameters
        /// needed for the database call</param>
        /// <history>
        /// 	[cnurse]	04/15/2009   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private object GetModulePermissionsCallBack(CacheItemArgs cacheItemArgs)
        {
            var tabID = (int)cacheItemArgs.ParamList[0];
            IDataReader dr = dataProvider.GetModulePermissionsByTabID(tabID);
            var dic = new Dictionary<int, ModulePermissionCollection>();
            try
            {
                while (dr.Read())
                {
                    //fill business object
                    var modulePermissionInfo = CBO.FillObject<ModulePermissionInfo>(dr, false);

                    //add Module Permission to dictionary
                    if (dic.ContainsKey(modulePermissionInfo.ModuleID))
                    {
                        dic[modulePermissionInfo.ModuleID].Add(modulePermissionInfo);
                    }
                    else
                    {
                        //Create new ModulePermission Collection for ModuleId
                        var collection = new ModulePermissionCollection {modulePermissionInfo};

                        //Add Permission to Collection

                        //Add Collection to Dictionary
                        dic.Add(modulePermissionInfo.ModuleID, collection);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                //close datareader
                CBO.CloseDataReader(dr, true);
            }
            return dic;
        }
Ejemplo n.º 45
0
 public string GetModulePermissions(ModulePermissionCollection modulePermissions, string permissionKey)
 {
     return(modulePermissions.ToString(permissionKey));
 }
Ejemplo n.º 46
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetModulePermissions gets a ModulePermissionCollection
        /// </summary>
        /// <param name="moduleID">The ID of the module</param>
        /// <param name="tabID">The ID of the tab</param>
        /// -----------------------------------------------------------------------------
        public virtual ModulePermissionCollection GetModulePermissions(int moduleID, int tabID)
        {
            //Get the Tab ModulePermission Dictionary
            Dictionary<int, ModulePermissionCollection> dictionary = GetModulePermissions(tabID);

            //Get the Collection from the Dictionary
            ModulePermissionCollection modulePermissions;
            bool found = dictionary.TryGetValue(moduleID, out modulePermissions);
            if (!found)
            {
                //Return empty collection
                modulePermissions = new ModulePermissionCollection();
            }
            return modulePermissions;
        }
 public ModulePermissionCollection(ModulePermissionCollection modulePermissions)
 {
     AddRange(modulePermissions);
 }
 private bool IsMod()
 {
     var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(_moduleId, -1), typeof(ModulePermissionInfo)));
     return ModulePermissionController.HasModulePermission(objModulePermissions, "MODGROUP");
 }
Ejemplo n.º 49
0
        public static bool HasModulePermission(int moduleID, string PermissionKey)
        {
            ModulePermissionCollection objModulePermissions = FillModulePermissionCollection(DataProvider.Instance().GetModulePermissionsByModuleID(moduleID, -1));

            return(HasModulePermission(objModulePermissions, PermissionKey));
        }