mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 02:44:52 +08:00
Improving users management
--HG-- branch : dev extra : transplant_source : %AA%18%27%A6%83%7B%E7o%24%CF%11%81%D7%84%9D%0C%FB%D11%FB
This commit is contained in:
@@ -166,7 +166,6 @@
|
|||||||
<Compile Include="Users\Services\UserServiceTests.cs" />
|
<Compile Include="Users\Services\UserServiceTests.cs" />
|
||||||
<Compile Include="Users\ShellSettingsUtility.cs" />
|
<Compile Include="Users\ShellSettingsUtility.cs" />
|
||||||
<Compile Include="Values.cs" />
|
<Compile Include="Values.cs" />
|
||||||
<Compile Include="Users\Controllers\AdminControllerTests.cs" />
|
|
||||||
<Compile Include="Users\Services\MembershipServiceTests.cs" />
|
<Compile Include="Users\Services\MembershipServiceTests.cs" />
|
||||||
<Compile Include="Widgets\RuleEngine\UrlRuleProviderTest.cs" />
|
<Compile Include="Widgets\RuleEngine\UrlRuleProviderTest.cs" />
|
||||||
<Compile Include="Widgets\Services\WidgetsServiceTest.cs" />
|
<Compile Include="Widgets\Services\WidgetsServiceTest.cs" />
|
||||||
|
@@ -1,170 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Web;
|
|
||||||
using System.Web.Mvc;
|
|
||||||
using System.Web.Routing;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
using Autofac;
|
|
||||||
using Moq;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using Orchard.Caching;
|
|
||||||
using Orchard.ContentManagement.MetaData;
|
|
||||||
using Orchard.ContentManagement.MetaData.Models;
|
|
||||||
using Orchard.ContentManagement.MetaData.Services;
|
|
||||||
using Orchard.Core.Settings.Metadata;
|
|
||||||
using Orchard.Data;
|
|
||||||
using Orchard.DisplayManagement;
|
|
||||||
using Orchard.DisplayManagement.Descriptors;
|
|
||||||
using Orchard.DisplayManagement.Implementation;
|
|
||||||
using Orchard.Environment;
|
|
||||||
using Orchard.ContentManagement;
|
|
||||||
using Orchard.ContentManagement.Handlers;
|
|
||||||
using Orchard.ContentManagement.Records;
|
|
||||||
using Orchard.Environment.Extensions;
|
|
||||||
using Orchard.Localization;
|
|
||||||
using Orchard.Messaging.Events;
|
|
||||||
using Orchard.Messaging.Services;
|
|
||||||
using Orchard.Security;
|
|
||||||
using Orchard.Security.Permissions;
|
|
||||||
using Orchard.Security.Providers;
|
|
||||||
using Orchard.Tests.Stubs;
|
|
||||||
using Orchard.UI.Notify;
|
|
||||||
using Orchard.Users.Controllers;
|
|
||||||
using Orchard.Users.Handlers;
|
|
||||||
using Orchard.Users.Models;
|
|
||||||
using Orchard.Users.Services;
|
|
||||||
using Orchard.Users.ViewModels;
|
|
||||||
using Orchard.Settings;
|
|
||||||
using Orchard.Core.Settings.Services;
|
|
||||||
|
|
||||||
namespace Orchard.Tests.Modules.Users.Controllers {
|
|
||||||
[TestFixture]
|
|
||||||
public class AdminControllerTests : DatabaseEnabledTestsBase {
|
|
||||||
private AdminController _controller;
|
|
||||||
private Mock<IAuthorizer> _authorizer;
|
|
||||||
|
|
||||||
public override void Register(ContainerBuilder builder) {
|
|
||||||
builder.RegisterType<AdminController>().SingleInstance();
|
|
||||||
builder.RegisterType<SiteService>().As<ISiteService>();
|
|
||||||
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
|
|
||||||
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
|
|
||||||
builder.RegisterType(typeof(SettingsFormatter))
|
|
||||||
.As(typeof(IMapper<XElement, SettingsDictionary>))
|
|
||||||
.As(typeof(IMapper<SettingsDictionary, XElement>));
|
|
||||||
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
|
|
||||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
|
||||||
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>().InstancePerDependency();
|
|
||||||
builder.RegisterType<DefaultMessageManager>().As<IMessageManager>();
|
|
||||||
builder.RegisterInstance(new Mock<IMessageEventHandler>().Object);
|
|
||||||
builder.RegisterType<MembershipService>().As<IMembershipService>();
|
|
||||||
builder.RegisterType<UserService>().As<IUserService>();
|
|
||||||
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
|
|
||||||
builder.RegisterType<StubWorkContextAccessor>().As<IWorkContextAccessor>();
|
|
||||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
|
||||||
builder.RegisterType<TransactionManager>().As<ITransactionManager>();
|
|
||||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
|
||||||
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
|
||||||
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
|
|
||||||
builder.RegisterInstance(new Mock<INotifier>().Object);
|
|
||||||
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
|
||||||
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
|
|
||||||
builder.RegisterType<Signals>().As<ISignals>();
|
|
||||||
builder.RegisterType<DefaultEncryptionService>().As<IEncryptionService>();
|
|
||||||
builder.RegisterInstance(ShellSettingsUtility.CreateEncryptionEnabled());
|
|
||||||
|
|
||||||
_authorizer = new Mock<IAuthorizer>();
|
|
||||||
builder.RegisterInstance(_authorizer.Object);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IEnumerable<Type> DatabaseTypes {
|
|
||||||
get {
|
|
||||||
return new[] { typeof(UserPartRecord),
|
|
||||||
typeof(ContentTypeRecord),
|
|
||||||
typeof(ContentItemRecord),
|
|
||||||
typeof(ContentItemVersionRecord),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Init() {
|
|
||||||
base.Init();
|
|
||||||
|
|
||||||
var manager = _container.Resolve<IContentManager>();
|
|
||||||
|
|
||||||
var userOne = manager.New<UserPart>("User");
|
|
||||||
userOne.Record = new UserPartRecord { UserName = "one" };
|
|
||||||
manager.Create(userOne.ContentItem);
|
|
||||||
|
|
||||||
var userTwo = manager.New<UserPart>("User");
|
|
||||||
userTwo.Record = new UserPartRecord { UserName = "two" };
|
|
||||||
manager.Create(userTwo.ContentItem);
|
|
||||||
|
|
||||||
var userThree = manager.New<UserPart>("User");
|
|
||||||
userThree.Record = new UserPartRecord { UserName = "three" };
|
|
||||||
manager.Create(userThree.ContentItem);
|
|
||||||
|
|
||||||
_controller = _container.Resolve<AdminController>();
|
|
||||||
|
|
||||||
var mockHttpContext = new Mock<HttpContextBase>();
|
|
||||||
_controller.ControllerContext = new ControllerContext(
|
|
||||||
mockHttpContext.Object,
|
|
||||||
new RouteData(
|
|
||||||
new Route("foo", new MvcRouteHandler()),
|
|
||||||
new MvcRouteHandler()),
|
|
||||||
_controller);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IndexShouldReturnRowsForUsers() {
|
|
||||||
_authorizer.Setup(x => x.Authorize(It.IsAny<Permission>(), It.IsAny<LocalizedString>())).Returns(true);
|
|
||||||
|
|
||||||
var controller = _container.Resolve<AdminController>();
|
|
||||||
var result = (ViewResult)controller.Index();
|
|
||||||
var model = (UsersIndexViewModel)result.ViewData.Model;
|
|
||||||
|
|
||||||
Assert.That(model.Rows, Is.Not.Null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
[Ignore("Needs to instead be a specflow test.")]
|
|
||||||
public void CreateShouldAddUserAndRedirect() {
|
|
||||||
_authorizer.Setup(x => x.Authorize(It.IsAny<Permission>(), It.IsAny<LocalizedString>())).Returns(true);
|
|
||||||
|
|
||||||
var controller = _container.Resolve<AdminController>();
|
|
||||||
ActionResult result = null; // controller.CreatePOST(new UserCreateViewModel {
|
|
||||||
// UserName = "four",
|
|
||||||
// Email = "six@example.org",
|
|
||||||
// Password = "five",
|
|
||||||
// ConfirmPassword = "five"
|
|
||||||
//});
|
|
||||||
Assert.That(result, Is.TypeOf<RedirectToRouteResult>());
|
|
||||||
|
|
||||||
var redirect = (RedirectToRouteResult)result;
|
|
||||||
var id = Convert.ToInt32(redirect.RouteValues["id"]);
|
|
||||||
var manager = _container.Resolve<IContentManager>();
|
|
||||||
var user = manager.Get(id).As<IUser>();
|
|
||||||
Assert.That(user.UserName, Is.EqualTo("four"));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
[Ignore("Needs fixing. Needs to instead be a specflow test.")]
|
|
||||||
public void EditShouldDisplayUserAndStoreChanges() {
|
|
||||||
_authorizer.Setup(x => x.Authorize(It.IsAny<Permission>(), It.IsAny<LocalizedString>())).Returns(true);
|
|
||||||
|
|
||||||
var repository = _container.Resolve<IRepository<UserPartRecord>>();
|
|
||||||
var id = repository.Get(x => x.UserName == "two").Id;
|
|
||||||
var result = (ViewResult)_container.Resolve<AdminController>().Edit(id);
|
|
||||||
var model = (UserEditViewModel)result.ViewData.Model;
|
|
||||||
//Assert.That(model.UserName, Is.EqualTo("two"));
|
|
||||||
|
|
||||||
var controller = _container.Resolve<AdminController>();
|
|
||||||
controller.ValueProvider = Values.From(new {
|
|
||||||
UserName = "bubba",
|
|
||||||
Email = "hotep",
|
|
||||||
});
|
|
||||||
var result2 = controller.EditPOST(id);
|
|
||||||
Assert.That(result2, Is.TypeOf<RedirectToRouteResult>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,6 +1,9 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.Core.Common.Models;
|
||||||
|
using Orchard.Core.Contents.Controllers;
|
||||||
using Orchard.Core.Settings.Models;
|
using Orchard.Core.Settings.Models;
|
||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
@@ -12,6 +15,7 @@ using Orchard.Users.ViewModels;
|
|||||||
using Orchard.Mvc.Extensions;
|
using Orchard.Mvc.Extensions;
|
||||||
using System;
|
using System;
|
||||||
using Orchard.Settings;
|
using Orchard.Settings;
|
||||||
|
using Orchard.UI.Navigation;
|
||||||
|
|
||||||
namespace Orchard.Users.Controllers {
|
namespace Orchard.Users.Controllers {
|
||||||
[ValidateInput(false)]
|
[ValidateInput(false)]
|
||||||
@@ -39,24 +43,99 @@ namespace Orchard.Users.Controllers {
|
|||||||
public IOrchardServices Services { get; set; }
|
public IOrchardServices Services { get; set; }
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
public ActionResult Index() {
|
public ActionResult Index(UserIndexOptions options, PagerParameters pagerParameters) {
|
||||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list users")))
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list users")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
|
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
|
||||||
|
|
||||||
|
// default options
|
||||||
|
if (options == null)
|
||||||
|
options = new UserIndexOptions();
|
||||||
|
|
||||||
var users = Services.ContentManager
|
var users = Services.ContentManager
|
||||||
.Query<UserPart, UserPartRecord>()
|
.Query<UserPart, UserPartRecord>();
|
||||||
.Where(x => x.UserName != null)
|
|
||||||
.List();
|
switch (options.Filter) {
|
||||||
|
case UsersFilter.Approved:
|
||||||
|
users = users.Where(u => u.RegistrationStatus == UserStatus.Approved);
|
||||||
|
break;
|
||||||
|
case UsersFilter.Pending:
|
||||||
|
users = users.Where(u => u.RegistrationStatus == UserStatus.Pending);
|
||||||
|
break;
|
||||||
|
case UsersFilter.EmailPending:
|
||||||
|
users = users.Where(u => u.EmailStatus == UserStatus.Approved);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!String.IsNullOrWhiteSpace(options.Search)) {
|
||||||
|
users = users.Where(u => u.UserName.Contains(options.Search) || u.Email.Contains(options.Search));
|
||||||
|
}
|
||||||
|
|
||||||
|
var pagerShape = Shape.Pager(pager).TotalItemCount(users.Count());
|
||||||
|
|
||||||
|
switch (options.Order) {
|
||||||
|
case UsersOrder.Name:
|
||||||
|
users = users.OrderBy(u => u.UserName);
|
||||||
|
break;
|
||||||
|
case UsersOrder.Email:
|
||||||
|
users = users.OrderBy(u => u.Email);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var results = users
|
||||||
|
.Slice(pager.GetStartIndex(), pager.PageSize)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
var model = new UsersIndexViewModel {
|
var model = new UsersIndexViewModel {
|
||||||
Rows = users
|
Users = results
|
||||||
.Select(x => new UsersIndexViewModel.Row { UserPart = x })
|
.Select(x => new UserEntry { User = x.Record })
|
||||||
.ToList()
|
.ToList(),
|
||||||
|
Options = options,
|
||||||
|
Pager = pagerShape
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[FormValueRequired("submit.BulkEdit")]
|
||||||
|
public ActionResult Index(FormCollection input) {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage users")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
|
var viewModel = new UsersIndexViewModel {Users = new List<UserEntry>(), Options = new UserIndexOptions()};
|
||||||
|
UpdateModel(viewModel);
|
||||||
|
|
||||||
|
var checkedEntries = viewModel.Users.Where(c => c.IsChecked);
|
||||||
|
switch (viewModel.Options.BulkAction) {
|
||||||
|
case UsersBulkAction.None:
|
||||||
|
break;
|
||||||
|
case UsersBulkAction.Approve:
|
||||||
|
foreach (var entry in checkedEntries) {
|
||||||
|
Approve(entry.User.Id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case UsersBulkAction.Disable:
|
||||||
|
foreach (var entry in checkedEntries) {
|
||||||
|
Moderate(entry.User.Id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case UsersBulkAction.ChallengeEmail:
|
||||||
|
foreach (var entry in checkedEntries) {
|
||||||
|
SendChallengeEmail(entry.User.Id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case UsersBulkAction.Delete:
|
||||||
|
foreach (var entry in checkedEntries) {
|
||||||
|
Delete(entry.User.Id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
|
||||||
public ActionResult Create() {
|
public ActionResult Create() {
|
||||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage users")))
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage users")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
@@ -109,7 +188,7 @@ namespace Orchard.Users.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Services.Notifier.Information(T("User created"));
|
Services.Notifier.Information(T("User created"));
|
||||||
return RedirectToAction("edit", new { user.Id });
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Edit(int id) {
|
public ActionResult Edit(int id) {
|
||||||
@@ -163,7 +242,7 @@ namespace Orchard.Users.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Services.Notifier.Information(T("User information updated"));
|
Services.Notifier.Information(T("User information updated"));
|
||||||
return RedirectToAction("Edit", new { id });
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Delete(int id) {
|
public ActionResult Delete(int id) {
|
||||||
@@ -181,7 +260,7 @@ namespace Orchard.Users.Controllers {
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Services.ContentManager.Remove(user.ContentItem);
|
Services.ContentManager.Remove(user.ContentItem);
|
||||||
Services.Notifier.Information(T("User deleted"));
|
Services.Notifier.Information(T("User {0} deleted", user.UserName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,13 +271,13 @@ namespace Orchard.Users.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage users")))
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage users")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var user = Services.ContentManager.Get(id);
|
var user = Services.ContentManager.Get<IUser>(id);
|
||||||
|
|
||||||
if ( user != null ) {
|
if ( user != null ) {
|
||||||
_userService.SendChallengeEmail(user.As<UserPart>(), nonce => Url.AbsoluteAction(() => Url.Action("ChallengeEmail", "Account", new {Area = "Orchard.Users", nonce = nonce})));
|
_userService.SendChallengeEmail(user.As<UserPart>(), nonce => Url.AbsoluteAction(() => Url.Action("ChallengeEmail", "Account", new {Area = "Orchard.Users", nonce = nonce})));
|
||||||
|
Services.Notifier.Information(T("Challenge email sent to {0}", user.UserName));
|
||||||
}
|
}
|
||||||
|
|
||||||
Services.Notifier.Information(T("Challenge email sent"));
|
|
||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
@@ -207,11 +286,11 @@ namespace Orchard.Users.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage users")))
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage users")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var user = Services.ContentManager.Get(id);
|
var user = Services.ContentManager.Get<IUser>(id);
|
||||||
|
|
||||||
if ( user != null ) {
|
if ( user != null ) {
|
||||||
user.As<UserPart>().RegistrationStatus = UserStatus.Approved;
|
user.As<UserPart>().RegistrationStatus = UserStatus.Approved;
|
||||||
Services.Notifier.Information(T("User approved"));
|
Services.Notifier.Information(T("User {0} approved", user.UserName));
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
|
@@ -4,10 +4,40 @@ using Orchard.Users.Models;
|
|||||||
namespace Orchard.Users.ViewModels {
|
namespace Orchard.Users.ViewModels {
|
||||||
|
|
||||||
public class UsersIndexViewModel {
|
public class UsersIndexViewModel {
|
||||||
public class Row {
|
public IList<UserEntry> Users { get; set; }
|
||||||
public UserPart UserPart { get; set; }
|
public UserIndexOptions Options { get; set; }
|
||||||
}
|
public dynamic Pager { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public IList<Row> Rows { get; set; }
|
public class UserEntry {
|
||||||
|
public UserPartRecord User { get; set; }
|
||||||
|
public bool IsChecked { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UserIndexOptions {
|
||||||
|
public string Search { get; set; }
|
||||||
|
public UsersOrder Order { get; set; }
|
||||||
|
public UsersFilter Filter { get; set; }
|
||||||
|
public UsersBulkAction BulkAction { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum UsersOrder {
|
||||||
|
Name,
|
||||||
|
Email
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum UsersFilter {
|
||||||
|
All,
|
||||||
|
Approved,
|
||||||
|
Pending,
|
||||||
|
EmailPending
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum UsersBulkAction {
|
||||||
|
None,
|
||||||
|
Delete,
|
||||||
|
Disable,
|
||||||
|
Approve,
|
||||||
|
ChallengeEmail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,52 +1,88 @@
|
|||||||
@model Orchard.Users.ViewModels.UsersIndexViewModel
|
@model Orchard.Users.ViewModels.UsersIndexViewModel
|
||||||
@using Orchard.Users.Models;
|
@using Orchard.Users.Models;
|
||||||
|
@using Orchard.Users.ViewModels;
|
||||||
|
|
||||||
|
@{
|
||||||
|
var userIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
<h1>@Html.TitleForPage(T("Manage Users").ToString()) </h1>
|
<h1>@Html.TitleForPage(T("Manage Users").ToString()) </h1>
|
||||||
@using (Html.BeginFormAntiForgeryPost()) {
|
@using (Html.BeginFormAntiForgeryPost()) {
|
||||||
@Html.ValidationSummary()
|
@Html.ValidationSummary()
|
||||||
<div class="manage">@Html.ActionLink(T("Add a new user").ToString(), "Create", new { }, new { @class = "button primaryAction" })</div>
|
<div class="manage">@Html.ActionLink(T("Add a new user").ToString(), "Create", new { }, new { @class = "button primaryAction" })</div>
|
||||||
<fieldset>
|
|
||||||
|
<fieldset class="bulk-actions">
|
||||||
|
<label for="publishActions">@T("Actions:")</label>
|
||||||
|
<select id="publishActions" name="@Html.NameOf(m => m.Options.BulkAction)">
|
||||||
|
@Html.SelectOption(Model.Options.BulkAction, UsersBulkAction.None, T("Choose action...").ToString())
|
||||||
|
@Html.SelectOption(Model.Options.BulkAction, UsersBulkAction.Approve, T("Approve").ToString())
|
||||||
|
@Html.SelectOption(Model.Options.BulkAction, UsersBulkAction.Disable, T("Disable").ToString())
|
||||||
|
@Html.SelectOption(Model.Options.BulkAction, UsersBulkAction.ChallengeEmail, T("Send challenge E-mail").ToString())
|
||||||
|
@Html.SelectOption(Model.Options.BulkAction, UsersBulkAction.Delete, T("Remove").ToString())
|
||||||
|
</select>
|
||||||
|
<button type="submit" name="submit.BulkEdit" value="@T("Apply")">@T("Apply")</button>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset class="bulk-actions">
|
||||||
|
@Html.TextBoxFor(m => m.Options.Search, new { @class = "text"})
|
||||||
|
<label for="filterResults">@T("Filter:")</label>
|
||||||
|
<select id="filterResults" name="@Html.NameOf(m => m.Options.Filter)">
|
||||||
|
@Html.SelectOption(Model.Options.Filter, UsersFilter.All, T("All Users").ToString())
|
||||||
|
@Html.SelectOption(Model.Options.Filter, UsersFilter.Approved, T("Approved Users").ToString())
|
||||||
|
@Html.SelectOption(Model.Options.Filter, UsersFilter.Pending, T("Pending Users").ToString())
|
||||||
|
@Html.SelectOption(Model.Options.Filter, UsersFilter.EmailPending, T("Pending Emails").ToString())
|
||||||
|
</select>
|
||||||
|
<label for="filterResults">@T("Sort by:")</label>
|
||||||
|
<select id="filterResults" name="@Html.NameOf(m => m.Options.Order)">
|
||||||
|
@Html.SelectOption(Model.Options.Order, UsersOrder.Name, T("Name").ToString())
|
||||||
|
@Html.SelectOption(Model.Options.Order, UsersOrder.Email, T("Email").ToString())
|
||||||
|
</select>
|
||||||
|
<button type="submit" name="submit.Filter" value="@T("Apply")">@T("Apply")</button>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
<table class="items">
|
<table class="items">
|
||||||
<colgroup>
|
|
||||||
<col id="Name" />
|
|
||||||
<col id="Email" />
|
|
||||||
<col id="Edit" />
|
|
||||||
</colgroup>
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th scope="col"> ↓</th>
|
||||||
<th scope="col">@T("Name")</th>
|
<th scope="col">@T("Name")</th>
|
||||||
<th scope="col">@T("Email")</th>
|
<th scope="col">@T("Email")</th>
|
||||||
<th scope="col">@T("") </th>
|
<th scope="col">@T("Actions")</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@foreach (var row in Model.Rows) {
|
@foreach (var entry in Model.Users) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@if(row.UserPart.RegistrationStatus == UserStatus.Approved && row.UserPart.EmailStatus == UserStatus.Approved) {
|
<input type="hidden" value="@Model.Users[userIndex].User.Id" name="@Html.NameOf(m => m.Users[userIndex].User.Id)"/>
|
||||||
|
<input type="checkbox" value="true" name="@Html.NameOf(m => m.Users[userIndex].IsChecked)"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@if(entry.User.RegistrationStatus == UserStatus.Approved && entry.User.EmailStatus == UserStatus.Approved) {
|
||||||
<img class="icon" src="@Href("~/Modules/Orchard.Users/Content/Admin/images/online.gif") " alt="@T("Approved") " title="@T("User is approved") " />
|
<img class="icon" src="@Href("~/Modules/Orchard.Users/Content/Admin/images/online.gif") " alt="@T("Approved") " title="@T("User is approved") " />
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
<img class="icon" src="@Href("~/Modules/Orchard.Users/Content/Admin/images/offline.gif") " alt="@T("Moderated") " title="@if(row.UserPart.EmailStatus == UserStatus.Approved) { @T("User is moderated") } else { @T("E-mail validation is pending") }" />
|
<img class="icon" src="@Href("~/Modules/Orchard.Users/Content/Admin/images/offline.gif") " alt="@T("Moderated") " title="@if(entry.User.EmailStatus == UserStatus.Approved) { @T("User is moderated") } else { @T("E-mail validation is pending") }" />
|
||||||
}
|
}
|
||||||
@Html.ActionLink(row.UserPart.UserName, "Edit", new { row.UserPart.Id })
|
@Html.ActionLink(entry.User.UserName, "Edit", new { entry.User.Id })
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@row.UserPart.Email
|
@entry.User.Email
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.ActionLink(T("Edit").ToString(), "Edit", new { row.UserPart.Id }) |
|
@Html.ActionLink(T("Edit").ToString(), "Edit", new { entry.User.Id }) |
|
||||||
@Html.ActionLink(T("Remove").ToString(), "Delete", new { row.UserPart.Id }) |
|
@Html.ActionLink(T("Remove").ToString(), "Delete", new { entry.User.Id }) |
|
||||||
@if(row.UserPart.RegistrationStatus == UserStatus.Pending) {
|
@if(entry.User.RegistrationStatus == UserStatus.Pending) {
|
||||||
@Html.ActionLink(T("Approve").ToString(), "Approve", new { row.UserPart.Id })
|
@Html.ActionLink(T("Approve").ToString(), "Approve", new { entry.User.Id })
|
||||||
} else {
|
} else {
|
||||||
@Html.ActionLink(T("Disable").ToString(), "Moderate", new { row.UserPart.Id })
|
@Html.ActionLink(T("Disable").ToString(), "Moderate", new { entry.User.Id })
|
||||||
}
|
}
|
||||||
@if ( row.UserPart.EmailStatus == UserStatus.Pending ) { <text>|</text>
|
@if ( entry.User.EmailStatus == UserStatus.Pending ) { <text>|</text>
|
||||||
@Html.ActionLink(T("Send challenge E-mail").ToString(), "SendChallengeEmail", new { row.UserPart.Id })
|
@Html.ActionLink(T("Send challenge E-mail").ToString(), "SendChallengeEmail", new { entry.User.Id })
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
userIndex++;
|
||||||
|
}
|
||||||
</table>
|
</table>
|
||||||
|
<span class="hint">@T.Plural("No user found", "{1} users found", (int)Model.Pager.TotalItemCount + 1, (int)Model.Pager.TotalItemCount)</span>
|
||||||
|
@Display(Model.Pager)
|
||||||
</fieldset>
|
</fieldset>
|
||||||
}
|
}
|
Reference in New Issue
Block a user