コード例 #1
0
ファイル: DNNRoleProvider.cs プロジェクト: rrsc/Dnn.Platform
 private void AddDNNUserRole(UserRoleInfo userRole)
 {
     //Add UserRole to DNN
     userRole.UserRoleID = Convert.ToInt32(dataProvider.AddUserRole(userRole.PortalID, userRole.UserID, userRole.RoleID,
                                                         (int)userRole.Status, userRole.IsOwner,
                                                         userRole.EffectiveDate, userRole.ExpiryDate, 
                                                         UserController.GetCurrentUserInfo().UserID));
 }
コード例 #2
0
ファイル: DNNRoleProvider.cs プロジェクト: rrsc/Dnn.Platform
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Remove a User from a Role
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="portalId">Id of the portal</param>
 /// <param name="user">The user to remove.</param>
 /// <param name="userRole">The role to remove the user from.</param>
 /// <history>
 ///     [cnurse]	03/28/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 public override void RemoveUserFromRole(int portalId, UserInfo user, UserRoleInfo userRole)
 {
     dataProvider.DeleteUserRole(userRole.UserID, userRole.RoleID);
 }
コード例 #3
0
ファイル: DNNRoleProvider.cs プロジェクト: rrsc/Dnn.Platform
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Updates a User/Role
        /// </summary>
        /// <param name="userRole">The User/Role to update</param>
        /// <history>
        ///     [cnurse]	12/15/2005	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void UpdateUserRole(UserRoleInfo userRole)
        {
            dataProvider.UpdateUserRole(userRole.UserRoleID,
                                        (int)userRole.Status, userRole.IsOwner,
                                        userRole.EffectiveDate, userRole.ExpiryDate, 
                                        UserController.GetCurrentUserInfo().UserID);
		}
コード例 #4
0
        private void SetupRoleProvider()
        {
            var adminRoleInfoForAdministrators = new UserRoleInfo { RoleName = Constants.RoleName_Administrators, RoleID = Constants.RoleID_Administrators, UserID = Constants.UserID_Admin };
            var adminRoleInfoforRegisteredUsers = new UserRoleInfo { RoleName = Constants.RoleName_RegisteredUsers, RoleID = Constants.RoleID_RegisteredUsers, UserID = Constants.UserID_User12 };
            var user12RoleInfoforRegisteredUsers = new UserRoleInfo { RoleName = Constants.RoleName_RegisteredUsers, RoleID = Constants.RoleID_RegisteredUsers, UserID = Constants.UserID_User12 };
            var userFirstSocialGroupOwner = new UserRoleInfo { RoleName = Constants.RoleName_FirstSocialGroup, RoleID = Constants.RoleID_FirstSocialGroup, UserID = Constants.UserID_FirstSocialGroupOwner, IsOwner = true };

            _mockRoleProvider.Setup(rp => rp.GetUserRoles(It.Is<UserInfo>(u => u.UserID == Constants.UserID_Admin), It.IsAny<bool>())).Returns(new List<UserRoleInfo> { adminRoleInfoForAdministrators, adminRoleInfoforRegisteredUsers });
            _mockRoleProvider.Setup(rp => rp.GetUserRoles(It.Is<UserInfo>(u => u.UserID == Constants.UserID_User12), It.IsAny<bool>())).Returns(new List<UserRoleInfo> { user12RoleInfoforRegisteredUsers });
            _mockRoleProvider.Setup(rp => rp.GetUserRoles(It.Is<UserInfo>(u => u.UserID == Constants.UserID_FirstSocialGroupOwner), It.IsAny<bool>())).Returns(new List<UserRoleInfo> { userFirstSocialGroupOwner });
        }
コード例 #5
0
ファイル: DNNRoleProvider.cs プロジェクト: rrsc/Dnn.Platform
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddUserToRole adds a User to a Role
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="portalId">Id of the portal</param>
        /// <param name="user">The user to add.</param>
        /// <param name="userRole">The role to add the user to.</param>
        /// <returns>A Boolean indicating success or failure.</returns>
        /// <history>
        ///     [cnurse]	03/28/2006	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override bool AddUserToRole(int portalId, UserInfo user, UserRoleInfo userRole)
        {
            bool createStatus = true;
            try
            {
				//Add UserRole to DNN
                AddDNNUserRole(userRole);
            }
            catch (Exception exc)
            {
				//Clear User (duplicate User information)
                Logger.Error(exc);

                createStatus = false;
            }
            return createStatus;
        }
コード例 #6
0
 public abstract void RemoveUserFromRole( int portalId, UserInfo user, UserRoleInfo userRole );
コード例 #7
0
 public abstract void UpdateUserRole( UserRoleInfo userRole );
コード例 #8
0
 //User Roles
 public abstract bool AddUserToRole( int portalId, UserInfo user, UserRoleInfo userRole );
コード例 #9
0
        public void AddUserRole(int portalId, int userId, int roleId, RoleStatus status, bool isOwner, DateTime effectiveDate, DateTime expiryDate)
        {
            UserInfo user = UserController.GetUserById(portalId, userId);
            UserRoleInfo userRole = GetUserRole(portalId, userId, roleId);
            var eventLogController = new EventLogController();
            if (userRole == null)
            {
                //Create new UserRole
                userRole = new UserRoleInfo
                {
                    UserID = userId,
                    RoleID = roleId,
                    PortalID = portalId,
                    Status = status,
                    IsOwner = isOwner,
                    EffectiveDate = effectiveDate,
                    ExpiryDate = expiryDate
                };
                provider.AddUserToRole(portalId, user, userRole);
                eventLogController.AddLog(userRole, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.USER_ROLE_CREATED);
            }
            else
            {
                userRole.Status = status;
                userRole.IsOwner = isOwner;
                userRole.EffectiveDate = effectiveDate;
                userRole.ExpiryDate = expiryDate;
                provider.UpdateUserRole(userRole);
                eventLogController.AddLog(userRole, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.USER_ROLE_UPDATED);
            }

            //Remove the UserInfo and Roles from the Cache, as they have been modified
            DataCache.ClearUserCache(portalId, user.Username);
            TestableRoleController.Instance.ClearRoleCache(portalId);
        }
コード例 #10
0
        /// <summary>
        /// Adds a User to a Role
        /// </summary>
        /// <remarks>Overload adds Effective Date</remarks>
        /// <param name="PortalID">The Id of the Portal</param>
        /// <param name="UserId">The Id of the User</param>
        /// <param name="RoleId">The Id of the Role</param>
        /// <param name="EffectiveDate">The expiry Date of the Role membership</param>
        /// <param name="ExpiryDate">The expiry Date of the Role membership</param>
        public void AddUserRole(int PortalID, int UserId, int RoleId, DateTime EffectiveDate, DateTime ExpiryDate)
        {
            UserInfo objUser = UserController.GetUser(PortalID, UserId, false);
            UserRoleInfo objUserRole = GetUserRole(PortalID, UserId, RoleId);

            if (objUserRole == null)
            {
                //Create new UserRole
                objUserRole = new UserRoleInfo();
                objUserRole.UserID = UserId;
                objUserRole.RoleID = RoleId;
                objUserRole.PortalID = PortalID;
                objUserRole.EffectiveDate = EffectiveDate;
                objUserRole.ExpiryDate = ExpiryDate;
                provider.AddUserToRole(PortalID, objUser, objUserRole);
            }
            else
            {
                objUserRole.EffectiveDate = EffectiveDate;
                objUserRole.ExpiryDate = ExpiryDate;
                provider.UpdateUserRole(objUserRole);
            }
        }
コード例 #11
0
 /// <summary>
 /// Updates a User/Role
 /// </summary>
 /// <param name="userRole">The User/Role to update</param>
 /// <history>
 ///     [cnurse]	12/15/2005	created
 /// </history>
 public override void UpdateUserRole( UserRoleInfo userRole )
 {
     dataProvider.UpdateUserRole( userRole.UserRoleID, userRole.EffectiveDate, userRole.ExpiryDate );
 }
コード例 #12
0
        /// <summary>
        /// adds a DNN UserRole
        /// </summary>
        /// <param name="userRole">The role to add the user to.</param>
        /// <returns>The added UserRoleInfo object</returns>
        /// <history>
        ///     [cnurse]	03/28/2006	created
        /// </history>
        private UserRoleInfo AddDNNUserRole( UserRoleInfo userRole )
        {
            //Add UserRole to DNN
            userRole.UserRoleID = Convert.ToInt32( dataProvider.AddUserRole( userRole.PortalID, userRole.UserID, userRole.RoleID, userRole.EffectiveDate, userRole.ExpiryDate ) );
            userRole = GetUserRole( userRole.PortalID, userRole.UserID, userRole.RoleID );

            return userRole;
        }