mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-20 02:37:55 +08:00
Manage users moderation from admin
--HG-- branch : dev
This commit is contained in:
Binary file not shown.
After Width: | Height: | Size: 603 B |
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@@ -1,8 +1,10 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Users.Drivers;
|
||||
using Orchard.Users.Models;
|
||||
@@ -27,6 +29,7 @@ namespace Orchard.Users.Controllers {
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public ActionResult Index() {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageUsers, T("Not authorized to list users")))
|
||||
@@ -145,6 +148,39 @@ namespace Orchard.Users.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public ActionResult Approve(int id) {
|
||||
if ( !Services.Authorizer.Authorize(Permissions.ManageUsers, T("Not authorized to manage users")) )
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var user = Services.ContentManager.Get(id);
|
||||
|
||||
if ( user != null ) {
|
||||
user.As<UserPart>().RegistrationStatus = UserStatus.Approved;
|
||||
Services.Notifier.Information(T("User approved"));
|
||||
}
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public ActionResult Moderate(int id) {
|
||||
if ( !Services.Authorizer.Authorize(Permissions.ManageUsers, T("Not authorized to manage users")) )
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var user = Services.ContentManager.Get(id);
|
||||
|
||||
if ( user != null ) {
|
||||
if ( CurrentSite.SuperUser.Equals(user.As<UserPart>().UserName) ) {
|
||||
Services.Notifier.Error(T("Super user can't be moderated"));
|
||||
}
|
||||
else {
|
||||
user.As<UserPart>().RegistrationStatus = UserStatus.Pending;
|
||||
Services.Notifier.Information(T("User moderated"));
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
|
||||
}
|
||||
|
@@ -90,6 +90,8 @@
|
||||
<Compile Include="ViewModels\UsersIndexViewModel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\Admin\images\offline.gif" />
|
||||
<Content Include="Content\Admin\images\online.gif" />
|
||||
<Content Include="Module.txt" />
|
||||
<Content Include="Views\Account\ChangePassword.ascx" />
|
||||
<Content Include="Views\Account\ChangePasswordSuccess.ascx" />
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<UsersIndexViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Users.Models" %>
|
||||
<%@ Import Namespace="Orchard.Users.ViewModels"%>
|
||||
<h1><%: Html.TitleForPage(T("Manage Users").ToString()) %></h1>
|
||||
<% using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
@@ -22,6 +23,12 @@
|
||||
{ %>
|
||||
<tr>
|
||||
<td>
|
||||
<% if(row.UserPart.RegistrationStatus == UserStatus.Approved) { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Users/Content/Admin/images/online.gif") %>" alt="<%:T("Approved") %>" title="<%:T("User is approved") %>" />
|
||||
<% }
|
||||
else { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Users/Content/Admin/images/offline.gif") %>" alt="<%:T("Moderated") %>" title="<%:T("User is moderated") %>" />
|
||||
<% } %>
|
||||
<%: row.UserPart.UserName %>
|
||||
</td>
|
||||
<td>
|
||||
@@ -29,7 +36,8 @@
|
||||
</td>
|
||||
<td>
|
||||
<%: Html.ActionLink(T("Edit").ToString(), "Edit", new { row.UserPart.Id })%> |
|
||||
<%: Html.ActionLink(T("Remove").ToString(), "Delete", new { row.UserPart.Id })%>
|
||||
<%: Html.ActionLink(T("Remove").ToString(), "Delete", new { row.UserPart.Id })%> |
|
||||
<%: row.UserPart.RegistrationStatus == UserStatus.Pending ? Html.ActionLink(T("Approve").ToString(), "Approve", new { row.UserPart.Id }) : Html.ActionLink(T("Moderate").ToString(), "Moderate", new { row.UserPart.Id })%>
|
||||
</td>
|
||||
</tr>
|
||||
<%}%>
|
||||
|
Reference in New Issue
Block a user