コード例 #1
0
        public virtual async Task <IActionResult> SearchModal(
            Guid?siteId,
            string query   = "",
            int sortMode   = 0, //sortMode: 0 = DisplayName asc, 1 = JoinDate desc, 2 = Last, First
            int pageNumber = 1,
            int pageSize   = -1,
            bool ajaxGrid  = false
            )
        {
            var selectedSite = await SiteManager.GetSiteForDataOperations(siteId);

            var itemsPerPage = UIOptions.DefaultPageSize_UserList;

            if (pageSize > 0)
            {
                itemsPerPage = pageSize;
            }

            if (query == null)
            {
                query = string.Empty;
            }

            var siteMembers = await UserManager.GetUserAdminSearchPage(
                selectedSite.Id,
                pageNumber,
                itemsPerPage,
                query,
                sortMode);

            var model = new UserListViewModel
            {
                SiteId      = selectedSite.Id,
                UserList    = siteMembers,
                SearchQuery = query,
                SortMode    = sortMode,
                ActionName  = "SearchModal",
                TimeZoneId  = await TimeZoneIdResolver.GetUserTimeZoneId()
            };


            if (ajaxGrid)
            {
                return(PartialView("UserModalGridPartial", model));
            }

            return(PartialView("UserLookupModal", model));
        }
コード例 #2
0
        public virtual async Task <IActionResult> Index(
            Guid?siteId,
            string query   = "",
            int sortMode   = 1,  //sortMode: 0 = DisplayName asc, 1 = JoinDate desc, 2 = Last, First
            int pageNumber = 1,
            int pageSize   = -1
            )
        {
            var selectedSite = await SiteManager.GetSiteForDataOperations(siteId);

            // only server admin site can edit other sites settings
            if (selectedSite.Id != SiteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["{0} - User Management"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = StringLocalizer["User Management"];
            }

            var itemsPerPage = UIOptions.DefaultPageSize_UserList;

            if (pageSize > 0)
            {
                itemsPerPage = pageSize;
            }

            var siteMembers = await UserManager.GetPage(
                selectedSite.Id,
                pageNumber,
                itemsPerPage,
                query,
                sortMode);

            var model = new UserListViewModel
            {
                SiteId     = selectedSite.Id,
                UserList   = siteMembers,
                SortMode   = sortMode,
                AlphaQuery = query,
                TimeZoneId = await TimeZoneIdResolver.GetUserTimeZoneId()
            };

            var viewName = await CustomUserInfo.GetUserListViewName(UserManager.Site, HttpContext);

            return(View(viewName, model));
        }
コード例 #3
0
        public virtual async Task <IActionResult> IpSearch(
            Guid?siteId,
            string ipQuery = "")
        {
            var selectedSite = await SiteManager.GetSiteForDataOperations(siteId);

            // only server admin site can edit other sites settings
            if (selectedSite.Id != SiteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["{0} - User Management"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = StringLocalizer["User Management"];
            }

            var siteMembers = await UserManager.GetByIPAddress(
                selectedSite.Id,
                ipQuery);

            // not really paged in UI but re-using the ViewModel which needs a PagedResult
            var data = new PagedResult <IUserInfo>
            {
                Data       = siteMembers,
                PageNumber = 1,
                PageSize   = 2000,
                TotalItems = siteMembers.Count()
            };

            var model = new UserListViewModel
            {
                SiteId         = selectedSite.Id,
                UserList       = data,
                IpQuery        = ipQuery, //TODO: sanitize
                ShowAlphaPager = false,
                TimeZoneId     = await TimeZoneIdResolver.GetUserTimeZoneId(),
                ActionName     = "IpSearch"
            };

            return(View("Index", model));
        }
コード例 #4
0
        public virtual async Task <IActionResult> UnApprovedUsers(
            Guid?siteId,
            int pageNumber = 1,
            int pageSize   = -1)
        {
            var selectedSite = await SiteManager.GetSiteForDataOperations(siteId);

            // only server admin site can edit other sites settings
            if (selectedSite.Id != SiteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["{0} - User Accounts Pending Approval"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = StringLocalizer["User Accounts Pending Approval"];
            }

            var itemsPerPage = UIOptions.DefaultPageSize_UserList;

            if (pageSize > 0)
            {
                itemsPerPage = pageSize;
            }

            var siteMembers = await UserManager.GetNotApprovedUsers(
                selectedSite.Id,
                pageNumber,
                itemsPerPage);

            var model = new UserListViewModel
            {
                SiteId         = selectedSite.Id,
                UserList       = siteMembers,
                ShowAlphaPager = false,
                TimeZoneId     = await TimeZoneIdResolver.GetUserTimeZoneId(),
                ActionName     = "UnApprovedUsers"
            };

            return(View(model));
        }
コード例 #5
0
        public virtual async Task <ActionResult> UserActivity(
            Guid userId,
            Guid?siteId,
            int pageNumber = 1,
            int pageSize   = 10
            )
        {
            if (userId == Guid.Empty)
            {
                return(RedirectToAction("Index"));
            }

            var selectedSite = await SiteManager.GetSiteForDataOperations(siteId);

            var user = await UserManager.Fetch(selectedSite.Id, userId);

            if (user == null)
            {
                return(RedirectToAction("Index"));
            }

            // only server admin site can edit other sites settings
            if (selectedSite.Id != SiteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["{0} - User Activity - {1}"], selectedSite.SiteName, user.Email);
            }
            else
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["User Activity - {0}"], user.Email);
            }

            var model = new UserActivityViewModel
            {
                SiteId                  = selectedSite.Id,
                UserId                  = user.Id,
                CreatedUtc              = user.CreatedUtc,
                DisplayName             = user.DisplayName,
                Email                   = user.Email,
                AvatarUrl               = user.AvatarUrl,
                FirstName               = user.FirstName,
                LastLoginUtc            = user.LastLoginUtc,
                LastName                = user.LastName,
                LastPassswordChangenUtc = user.LastPasswordChangeUtc,
                TimeZoneId              = await TimeZoneIdResolver.GetUserTimeZoneId(),
                Locations               = await UserManager.GetUserLocations(
                    selectedSite.Id,
                    userId,
                    pageNumber,
                    pageSize
                    ),

                TwoFactor = user.TwoFactorEnabled,
                Logins    = await UserManager.GetLoginsAsync(user as SiteUser)
            };

            if (!string.IsNullOrWhiteSpace(user.TimeZoneId))
            {
                model.UserTimeZone = user.TimeZoneId;
            }
            else
            {
                model.UserTimeZone = UserManager.Site.TimeZoneId;
            }


            var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
            {
                KeyToAdjust    = "UserActivity",
                AdjustedText   = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["Activity - {0}"], user.Email),
                ViewFilterName = NamedNavigationFilters.Breadcrumbs // this is default but showing here for readers of code
            };

            currentCrumbAdjuster.AddToContext();

            return(View(model));
        }
コード例 #6
0
        public virtual async Task <IActionResult> Search(
            Guid?siteId,
            string query   = "",
            int sortMode   = 2,
            int pageNumber = 1,
            int pageSize   = -1,
            bool ajaxGrid  = false
            )
        {
            var selectedSite = await SiteManager.GetSiteForDataOperations(siteId);

            // only server admin site can edit other sites settings
            if (selectedSite.Id != SiteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["{0} - User Management"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = StringLocalizer["User Management"];
            }

            var itemsPerPage = UIOptions.DefaultPageSize_UserList;

            if (pageSize > 0)
            {
                itemsPerPage = pageSize;
            }

            if (query == null)
            {
                query = string.Empty;
            }

            var siteMembers = await UserManager.GetUserAdminSearchPage(
                selectedSite.Id,
                pageNumber,
                itemsPerPage,
                query,
                sortMode);

            var model = new UserListViewModel
            {
                SiteId      = selectedSite.Id,
                UserList    = siteMembers,
                SearchQuery = query,
                SortMode    = sortMode,
                ActionName  = "Search",
                TimeZoneId  = await TimeZoneIdResolver.GetUserTimeZoneId()
            };

            if (Request.IsAjaxRequest())
            {
                if (ajaxGrid)
                {
                    return(PartialView("UserModalGridPartial", model));
                }
                else
                {
                    return(PartialView("UserLookupModal", model));
                }
            }

            return(View("Index", model));
        }