public void DeleteRole(RoleInfo role)
        {
            Requires.NotNull("role", role);

            AddMessage(role, EventLogController.EventLogType.ROLE_DELETED);

            if (role.SecurityMode != SecurityMode.SecurityRole)
            {
                //remove group artifacts
                var portalSettings = PortalController.Instance.GetCurrentPortalSettings();

                IFileManager   _fileManager   = FileManager.Instance;
                IFolderManager _folderManager = FolderManager.Instance;

                IFolderInfo groupFolder = _folderManager.GetFolder(portalSettings.PortalId, "Groups/" + role.RoleID);
                if (groupFolder != null)
                {
                    _fileManager.DeleteFiles(_folderManager.GetFiles(groupFolder));
                    _folderManager.DeleteFolder(groupFolder);
                }
                JournalController.Instance.SoftDeleteJournalItemByGroupId(portalSettings.PortalId, role.RoleID);
            }

            //Get users before deleting role
            var users = role.UserCount > 0 ? GetUsersByRole(role.PortalID, role.RoleName) : Enumerable.Empty <UserInfo>();

            provider.DeleteRole(role);

            if (RoleDeleted != null)
            {
                RoleDeleted(null, new RoleEventArgs()
                {
                    Role = role
                });
            }

            //Remove the UserInfo objects of users that have been members of the group from the cache, as they have been modified
            foreach (var user in users)
            {
                DataCache.ClearUserCache(role.PortalID, user.Username);
            }

            ClearRoleCache(role.PortalID);

            // queue remove role/group from search index
            var document = new SearchDocumentToDelete
            {
                //PortalId = role.PortalID,
                RoleId = role.RoleID, // this is unique and sufficient
            };

            DataProvider.Instance().AddSearchDeletedItems(document);
        }
示例#2
0
        public void DeleteContentItem(ContentItem contentItem)
        {
            //Argument Contract
            Requires.NotNull("contentItem", contentItem);
            Requires.PropertyNotNegative("contentItem", "ContentItemId", contentItem.ContentItemId);

            var searrchDoc = new SearchDocumentToDelete
            {
                UniqueKey    = contentItem.ContentItemId.ToString("D"),
                ModuleId     = contentItem.ModuleID,
                TabId        = contentItem.TabID,
                SearchTypeId = SearchHelper.Instance.GetSearchTypeByName("module").SearchTypeId
            };

            DotNetNuke.Data.DataProvider.Instance().AddSearchDeletedItems(searrchDoc);

            _dataService.DeleteContentItem(contentItem.ContentItemId);
        }
示例#3
0
        private void DeleteJournalItem(int portalId, int currentUserId, int journalId, bool softDelete)
        {
            var ji = this.GetJournalItem(portalId, currentUserId, journalId, !softDelete);

            if (ji == null)
            {
                return;
            }

            var groupId = ji.SocialGroupId;

            if (softDelete)
            {
                this._dataService.Journal_SoftDelete(journalId);
            }
            else
            {
                this._dataService.Journal_Delete(journalId);
            }

            if (groupId > 0)
            {
                this.UpdateGroupStats(portalId, groupId);
            }

            // queue remove journal from search index
            var document = new SearchDocumentToDelete
            {
                PortalId     = portalId,
                AuthorUserId = currentUserId,
                UniqueKey    = ji.ContentItemId.ToString("D"),

                // QueryString = "journalid=" + journalId,
                SearchTypeId = SearchHelper.Instance.GetSearchTypeByName("module").SearchTypeId,
            };

            if (groupId > 0)
            {
                document.RoleId = groupId;
            }

            DataProvider.Instance().AddSearchDeletedItems(document);
        }
示例#4
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DeleteModuleDefinition deletes a Module Definition By ID
        /// </summary>
        /// <param name="moduleDefinitionId">The ID of the Module Definition to delete</param>
        /// -----------------------------------------------------------------------------
        public void DeleteModuleDefinition(int moduleDefinitionId)
        {
            //Delete associated permissions
            var permissionController = new PermissionController();

            foreach (PermissionInfo permission in permissionController.GetPermissionsByModuleDefID(moduleDefinitionId))
            {
                permissionController.DeletePermission(permission.PermissionID);
            }
            dataProvider.DeleteModuleDefinition(moduleDefinitionId);
            DataCache.ClearHostCache(true);

            // queue remove module definition from search index
            var document = new SearchDocumentToDelete
            {
                ModuleDefId = moduleDefinitionId
            };

            DataProvider.Instance().AddSearchDeletedItems(document);
        }
        private static int GetUserId(SearchDocumentToDelete searchResult)
        {
            var match = SearchResultMatchRegex.Match(searchResult.UniqueKey);

            return(match.Success ? Convert.ToInt32(match.Groups[1].Value) : Null.NullInteger);
        }