mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
PERF: Fix for Dispel CurrentUser/CurrentSite magic
http://orchard.codeplex.com/workitem/16718 --HG-- branch : perf
This commit is contained in:
@@ -147,50 +147,5 @@ namespace Orchard.Core.Common.Handlers {
|
||||
if (part.ContainerField.Value != null)
|
||||
part.ContainerField.Value = part.ContainerField.Value;
|
||||
}
|
||||
|
||||
|
||||
//private void GetEditor(BuildEditorContext context, CommonPart instance) {
|
||||
// var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||
// if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, instance)) {
|
||||
// return;
|
||||
// }
|
||||
// var viewModel = new OwnerEditorViewModel();
|
||||
// if (instance.Owner != null)
|
||||
// viewModel.Owner = instance.Owner.UserName;
|
||||
|
||||
// context.AddEditor(new TemplateViewModel(viewModel, "CommonPart") { TemplateName = "Parts/Common.Owner", ZoneName = "primary", Position = "999" });
|
||||
//}
|
||||
|
||||
|
||||
//private void UpdateEditor(UpdateEditorContext context, CommonPart instance) {
|
||||
// // this event is hooked so the modified timestamp is changed when an edit-post occurs.
|
||||
// // kind of a loose rule of thumb. may not be sufficient
|
||||
// instance.ModifiedUtc = _clock.UtcNow;
|
||||
// instance.VersionModifiedUtc = _clock.UtcNow;
|
||||
|
||||
// var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||
// if (!_authorizationService.TryCheckAccess(Permissions.ChangeOwner, currentUser, instance)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var viewModel = new OwnerEditorViewModel();
|
||||
// if (instance.Owner != null)
|
||||
// viewModel.Owner = instance.Owner.UserName;
|
||||
|
||||
// var priorOwner = viewModel.Owner;
|
||||
// context.Updater.TryUpdateModel(viewModel, "CommonPart", null, null);
|
||||
|
||||
// if (viewModel.Owner != null && viewModel.Owner != priorOwner) {
|
||||
// var newOwner = _membershipService.GetUser(viewModel.Owner);
|
||||
// if (newOwner == null) {
|
||||
// context.Updater.AddModelError("CommonPart.Owner", T("Invalid user name"));
|
||||
// }
|
||||
// else {
|
||||
// instance.Owner = newOwner;
|
||||
// }
|
||||
// }
|
||||
|
||||
// context.AddEditor(new TemplateViewModel(viewModel, "CommonPart") { TemplateName = "Parts/Common.Owner", ZoneName = "primary", Position = "999" });
|
||||
//}
|
||||
}
|
||||
}
|
@@ -1,29 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Themes;
|
||||
|
||||
namespace Orchard.Core.HomePage.Controllers {
|
||||
[HandleError]
|
||||
public class HomeController : Controller {
|
||||
private readonly IEnumerable<IHomePageProvider> _homePageProviders;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public HomeController(IEnumerable<IHomePageProvider> homePageProviders) {
|
||||
public HomeController(IEnumerable<IHomePageProvider> homePageProviders, IOrchardServices orchardServices) {
|
||||
_homePageProviders = homePageProviders;
|
||||
_orchardServices = orchardServices;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
[Themed]
|
||||
public ActionResult Index() {
|
||||
try {
|
||||
var homepage = CurrentSite.HomePage;
|
||||
var homepage = _orchardServices.WorkContext.CurrentSite.HomePage;
|
||||
if (String.IsNullOrEmpty(homepage))
|
||||
return View();
|
||||
|
||||
|
@@ -1,36 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Messaging.Models;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Messaging.Events;
|
||||
using Orchard.Messaging.Models;
|
||||
using Orchard.Messaging.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Core.Messaging.Services {
|
||||
public class DefaultMessageManager : IMessageManager {
|
||||
private readonly IMessageEventHandler _messageEventHandler;
|
||||
private readonly IEnumerable<IMessagingChannel> _channels;
|
||||
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public DefaultMessageManager(
|
||||
IMessageEventHandler messageEventHandler,
|
||||
IEnumerable<IMessagingChannel> channels) {
|
||||
IEnumerable<IMessagingChannel> channels,
|
||||
IOrchardServices orchardServices) {
|
||||
_messageEventHandler = messageEventHandler;
|
||||
_channels = channels;
|
||||
_orchardServices = orchardServices;
|
||||
}
|
||||
|
||||
public void Send(ContentItemRecord recipient, string type, string service = null, Dictionary<string, string> properties = null) {
|
||||
if ( !HasChannels() )
|
||||
return;
|
||||
|
||||
var messageSettings = CurrentSite.As<MessageSettingsPart>().Record;
|
||||
var messageSettings = _orchardServices.WorkContext.CurrentSite.As<MessageSettingsPart>().Record;
|
||||
|
||||
if ( messageSettings == null || String.IsNullOrWhiteSpace(messageSettings.DefaultChannelService) ) {
|
||||
return;
|
||||
|
@@ -12,18 +12,19 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
public class MenuPartDriver : ContentPartDriver<MenuPart> {
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly INavigationManager _navigationManager;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public MenuPartDriver(IAuthorizationService authorizationService, INavigationManager navigationManager) {
|
||||
public MenuPartDriver(IAuthorizationService authorizationService, INavigationManager navigationManager, IOrchardServices orchardServices) {
|
||||
_authorizationService = authorizationService;
|
||||
_navigationManager = navigationManager;
|
||||
_orchardServices = orchardServices;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public virtual IUser CurrentUser { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(MenuPart part, dynamic shapeHelper) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part))
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, _orchardServices.WorkContext.CurrentUser, part))
|
||||
return null;
|
||||
|
||||
return ContentShape("Parts_Navigation_Menu_Edit",
|
||||
@@ -31,7 +32,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(MenuPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, part))
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, _orchardServices.WorkContext.CurrentUser, part))
|
||||
return null;
|
||||
|
||||
if (string.IsNullOrEmpty(part.MenuPosition))
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
@@ -10,7 +9,6 @@ using Orchard.Core.Routable.Services;
|
||||
using Orchard.Core.Routable.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Core.Routable.Drivers {
|
||||
@@ -29,7 +27,6 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
private const string TemplateName = "Parts/Routable.RoutePart";
|
||||
|
||||
public Localizer T { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
protected override string Prefix {
|
||||
get { return "Routable"; }
|
||||
@@ -70,7 +67,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
: "";
|
||||
}
|
||||
|
||||
model.PromoteToHomePage = model.Id != 0 && part.Path != null && _routableHomePageProvider != null && CurrentSite.HomePage == _routableHomePageProvider.GetSettingValue(model.Id);
|
||||
model.PromoteToHomePage = model.Id != 0 && part.Path != null && _routableHomePageProvider != null && _services.WorkContext.CurrentSite.HomePage == _routableHomePageProvider.GetSettingValue(model.Id);
|
||||
return ContentShape("Parts_Routable_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
|
||||
}
|
||||
@@ -102,7 +99,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
part.Path = part.GetPathWithSlug(part.Slug);
|
||||
|
||||
if (part.ContentItem.Id != 0 && model.PromoteToHomePage && _routableHomePageProvider != null) {
|
||||
CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);
|
||||
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);
|
||||
}
|
||||
|
||||
return Editor(part, shapeHelper);
|
||||
|
@@ -3,14 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Security;
|
||||
using Orchard.Comments.ViewModels;
|
||||
using Orchard.Comments.Services;
|
||||
|
||||
@@ -26,9 +22,6 @@ namespace Orchard.Comments.Controllers {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
@@ -1,37 +1,26 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.Comments.Services;
|
||||
using Orchard.Comments.ViewModels;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Comments.Controllers {
|
||||
public class CommentController : Controller {
|
||||
public IOrchardServices Services { get; set; }
|
||||
private readonly IAuthorizer _authorizer;
|
||||
private readonly ICommentService _commentService;
|
||||
private readonly INotifier _notifier;
|
||||
|
||||
public CommentController(IOrchardServices services, ICommentService commentService, INotifier notifier, IAuthorizer authorizer) {
|
||||
public CommentController(IOrchardServices services, ICommentService commentService, INotifier notifier) {
|
||||
Services = services;
|
||||
_commentService = commentService;
|
||||
_notifier = notifier;
|
||||
_authorizer = authorizer;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
protected virtual IUser CurrentUser { get; [UsedImplicitly]
|
||||
private set; }
|
||||
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly]
|
||||
private set; }
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
[HttpPost]
|
||||
@@ -61,7 +50,7 @@ namespace Orchard.Comments.Controllers {
|
||||
CommentedOn = viewModel.CommentedOn
|
||||
};
|
||||
|
||||
CommentPart commentPart = _commentService.CreateComment(context, CurrentSite.As<CommentSettingsPart>().Record.ModerateComments);
|
||||
CommentPart commentPart = _commentService.CreateComment(context, Services.WorkContext.CurrentSite.As<CommentSettingsPart>().Record.ModerateComments);
|
||||
|
||||
if (commentPart.Record.Status == CommentStatus.Pending)
|
||||
Services.Notifier.Information(T("Your comment will appear after the site administrator approves it."));
|
||||
|
@@ -1,13 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Comments.Drivers;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Data;
|
||||
using Orchard.Logging;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Security;
|
||||
using Orchard.Services;
|
||||
|
||||
namespace Orchard.Comments.Services {
|
||||
@@ -16,44 +14,43 @@ namespace Orchard.Comments.Services {
|
||||
private readonly IRepository<ClosedCommentsRecord> _closedCommentsRepository;
|
||||
private readonly IClock _clock;
|
||||
private readonly ICommentValidator _commentValidator;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public CommentService(IRepository<ClosedCommentsRecord> closedCommentsRepository,
|
||||
IClock clock,
|
||||
ICommentValidator commentValidator,
|
||||
IContentManager contentManager) {
|
||||
IOrchardServices orchardServices) {
|
||||
_closedCommentsRepository = closedCommentsRepository;
|
||||
_clock = clock;
|
||||
_commentValidator = commentValidator;
|
||||
_contentManager = contentManager;
|
||||
_orchardServices = orchardServices;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
|
||||
|
||||
public IEnumerable<CommentPart> GetComments() {
|
||||
return _contentManager
|
||||
return _orchardServices.ContentManager
|
||||
.Query<CommentPart, CommentPartRecord>()
|
||||
.List();
|
||||
}
|
||||
|
||||
public IEnumerable<CommentPart> GetComments(CommentStatus status) {
|
||||
return _contentManager
|
||||
return _orchardServices.ContentManager
|
||||
.Query<CommentPart, CommentPartRecord>()
|
||||
.Where(c => c.Status == status)
|
||||
.List();
|
||||
}
|
||||
|
||||
public IEnumerable<CommentPart> GetCommentsForCommentedContent(int id) {
|
||||
return _contentManager
|
||||
return _orchardServices.ContentManager
|
||||
.Query<CommentPart, CommentPartRecord>()
|
||||
.Where(c => c.CommentedOn == id || c.CommentedOnContainer == id)
|
||||
.List();
|
||||
}
|
||||
|
||||
public IEnumerable<CommentPart> GetCommentsForCommentedContent(int id, CommentStatus status) {
|
||||
return _contentManager
|
||||
return _orchardServices.ContentManager
|
||||
.Query<CommentPart, CommentPartRecord>()
|
||||
.Where(c => c.CommentedOn == id || c.CommentedOnContainer == id)
|
||||
.Where(ctx => ctx.Status == status)
|
||||
@@ -61,25 +58,25 @@ namespace Orchard.Comments.Services {
|
||||
}
|
||||
|
||||
public CommentPart GetComment(int id) {
|
||||
return _contentManager.Get<CommentPart>(id);
|
||||
return _orchardServices.ContentManager.Get<CommentPart>(id);
|
||||
}
|
||||
|
||||
public ContentItemMetadata GetDisplayForCommentedContent(int id) {
|
||||
var content = _contentManager.Get(id);
|
||||
var content = _orchardServices.ContentManager.Get(id);
|
||||
if (content == null)
|
||||
return null;
|
||||
return _contentManager.GetItemMetadata(content);
|
||||
return _orchardServices.ContentManager.GetItemMetadata(content);
|
||||
}
|
||||
|
||||
public CommentPart CreateComment(CreateCommentContext context, bool moderateComments) {
|
||||
var comment = _contentManager.Create<CommentPart>("Comment");
|
||||
var comment = _orchardServices.ContentManager.Create<CommentPart>("Comment");
|
||||
|
||||
comment.Record.Author = context.Author;
|
||||
comment.Record.CommentDateUtc = _clock.UtcNow;
|
||||
comment.Record.CommentText = context.CommentText;
|
||||
comment.Record.Email = context.Email;
|
||||
comment.Record.SiteName = context.SiteName;
|
||||
comment.Record.UserName = (CurrentUser == null ? context.Author : CurrentUser.UserName);
|
||||
comment.Record.UserName = (_orchardServices.WorkContext.CurrentUser == null ? context.Author : _orchardServices.WorkContext.CurrentUser.UserName);
|
||||
comment.Record.CommentedOn = context.CommentedOn;
|
||||
|
||||
comment.Record.Status = _commentValidator.ValidateComment(comment)
|
||||
@@ -88,7 +85,7 @@ namespace Orchard.Comments.Services {
|
||||
|
||||
// store id of the next layer for large-grained operations, e.g. rss on blog
|
||||
//TODO:(rpaquay) Get rid of this (comment aspect takes care of container)
|
||||
var commentedOn = _contentManager.Get<ICommonPart>(comment.Record.CommentedOn);
|
||||
var commentedOn = _orchardServices.ContentManager.Get<ICommonPart>(comment.Record.CommentedOn);
|
||||
if (commentedOn != null && commentedOn.Container != null) {
|
||||
comment.Record.CommentedOnContainer = commentedOn.Container.ContentItem.Id;
|
||||
}
|
||||
@@ -121,7 +118,7 @@ namespace Orchard.Comments.Services {
|
||||
}
|
||||
|
||||
public void DeleteComment(int commentId) {
|
||||
_contentManager.Remove(_contentManager.Get(commentId));
|
||||
_orchardServices.ContentManager.Remove(_orchardServices.ContentManager.Get(commentId));
|
||||
}
|
||||
|
||||
public bool CommentsClosedForCommentedContent(int id) {
|
||||
|
@@ -2,10 +2,9 @@
|
||||
using System.Web;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Notify;
|
||||
using Joel.Net;
|
||||
|
||||
@@ -15,18 +14,20 @@ namespace Orchard.Comments.Services {
|
||||
[UsedImplicitly]
|
||||
public class AkismetCommentValidator : ICommentValidator {
|
||||
private readonly INotifier _notifer;
|
||||
public AkismetCommentValidator(INotifier notifier) {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public AkismetCommentValidator(INotifier notifier, IOrchardServices orchardServices) {
|
||||
_notifer = notifier;
|
||||
_orchardServices = orchardServices;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public bool ValidateComment(CommentPart commentPart) {
|
||||
CommentSettingsPartRecord commentSettingsPartRecord = CurrentSite.As<CommentSettingsPart>().Record;
|
||||
CommentSettingsPartRecord commentSettingsPartRecord = _orchardServices.WorkContext.CurrentSite.As<CommentSettingsPart>().Record;
|
||||
string akismetKey = commentSettingsPartRecord.AkismetKey;
|
||||
string akismetUrl = commentSettingsPartRecord.AkismetUrl;
|
||||
bool enableSpamProtection = commentSettingsPartRecord.EnableSpamProtection;
|
||||
|
@@ -2,25 +2,24 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Email.Models;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Messaging.Services;
|
||||
using Orchard.Messaging.Models;
|
||||
|
||||
namespace Orchard.Email.Services {
|
||||
public class EmailMessagingChannel : IMessagingChannel {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public const string EmailService = "Email";
|
||||
|
||||
public EmailMessagingChannel() {
|
||||
public EmailMessagingChannel(IOrchardServices orchardServices) {
|
||||
_orchardServices = orchardServices;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
@@ -28,7 +27,7 @@ namespace Orchard.Email.Services {
|
||||
if ( !context.Service.Equals(EmailService, StringComparison.InvariantCultureIgnoreCase) )
|
||||
return;
|
||||
|
||||
var smtpSettings = CurrentSite.As<SmtpSettingsPart>();
|
||||
var smtpSettings = _orchardServices.WorkContext.CurrentSite.As<SmtpSettingsPart>();
|
||||
|
||||
// can't process emails if the Smtp settings have not yet been set
|
||||
if ( smtpSettings == null || !smtpSettings.IsValid() ) {
|
||||
|
@@ -1,33 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Messaging.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Email.Models;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Admin.Notification;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Email.Services {
|
||||
public class MissingSettingsBanner: INotificationProvider {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public MissingSettingsBanner() {
|
||||
public MissingSettingsBanner(IOrchardServices orchardServices) {
|
||||
_orchardServices = orchardServices;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public IEnumerable<NotifyEntry> GetNotifications() {
|
||||
|
||||
var smtpSettings = CurrentSite.As<SmtpSettingsPart>();
|
||||
var smtpSettings = _orchardServices.WorkContext.CurrentSite.As<SmtpSettingsPart>();
|
||||
|
||||
if ( smtpSettings == null || !smtpSettings.IsValid() ) {
|
||||
yield return new NotifyEntry { Message = T("The SMTP settings needs to be configured." ), Type = NotifyType.Warning};
|
||||
}
|
||||
|
||||
var messageSettings = CurrentSite.As<MessageSettingsPart>().Record;
|
||||
var messageSettings = _orchardServices.WorkContext.CurrentSite.As<MessageSettingsPart>().Record;
|
||||
|
||||
if ( messageSettings == null || String.IsNullOrWhiteSpace(messageSettings.DefaultChannelService) ) {
|
||||
yield return new NotifyEntry { Message = T("The default channel service needs to be configured."), Type = NotifyType.Warning };
|
||||
|
@@ -8,18 +8,19 @@ using Orchard.ContentManagement;
|
||||
using Orchard.Roles.Models;
|
||||
using Orchard.Security;
|
||||
using Orchard.Security.Permissions;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Roles.Services {
|
||||
[UsedImplicitly]
|
||||
public class RolesBasedAuthorizationService : IAuthorizationService {
|
||||
private readonly IRoleService _roleService;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
private readonly IAuthorizationServiceEventHandler _authorizationServiceEventHandler;
|
||||
private static readonly string[] AnonymousRole = new[] { "Anonymous" };
|
||||
private static readonly string[] AuthenticatedRole = new[] { "Authenticated" };
|
||||
|
||||
public RolesBasedAuthorizationService(IRoleService roleService, IAuthorizationServiceEventHandler authorizationServiceEventHandler) {
|
||||
public RolesBasedAuthorizationService(IRoleService roleService, IWorkContextAccessor workContextAccessor, IAuthorizationServiceEventHandler authorizationServiceEventHandler) {
|
||||
_roleService = roleService;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_authorizationServiceEventHandler = authorizationServiceEventHandler;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -28,7 +29,6 @@ namespace Orchard.Roles.Services {
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
|
||||
public void CheckAccess(Permission permission, IUser user, IContent content) {
|
||||
@@ -47,8 +47,8 @@ namespace Orchard.Roles.Services {
|
||||
|
||||
for (var adjustmentLimiter = 0; adjustmentLimiter != 3; ++adjustmentLimiter) {
|
||||
if (!context.Granted && context.User != null) {
|
||||
if (!String.IsNullOrEmpty(CurrentSite.SuperUser) &&
|
||||
String.Equals(context.User.UserName, CurrentSite.SuperUser, StringComparison.OrdinalIgnoreCase)) {
|
||||
if (!String.IsNullOrEmpty(_workContextAccessor.GetContext().CurrentSite.SuperUser) &&
|
||||
String.Equals(context.User.UserName, _workContextAccessor.GetContext().CurrentSite.SuperUser, StringComparison.OrdinalIgnoreCase)) {
|
||||
context.Granted = true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,9 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Query.Dynamic;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Indexing;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Search.Services;
|
||||
using Orchard.Search.ViewModels;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Search.Models;
|
||||
using Orchard.UI.Notify;
|
||||
using System.Collections.Generic;
|
||||
@@ -34,10 +31,8 @@ namespace Orchard.Search.Controllers {
|
||||
private IOrchardServices Services { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public ActionResult Index(string q, int page = 1, int pageSize = 10) {
|
||||
var searchFields = CurrentSite.As<SearchSettingsPart>().SearchedFields;
|
||||
var searchFields = Services.WorkContext.CurrentSite.As<SearchSettingsPart>().SearchedFields;
|
||||
|
||||
IPageOfItems<ISearchHit> searchHits;
|
||||
|
||||
@@ -47,7 +42,7 @@ namespace Orchard.Search.Controllers {
|
||||
}
|
||||
else {
|
||||
searchHits = _searchService.Query(q, page, pageSize,
|
||||
CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
|
||||
Services.WorkContext.CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
|
||||
searchFields,
|
||||
searchHit => searchHit);
|
||||
}
|
||||
|
@@ -2,10 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Localization;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Tags.Models;
|
||||
using Orchard.Tags.ViewModels;
|
||||
using Orchard.Tags.Services;
|
||||
@@ -22,7 +20,6 @@ namespace Orchard.Tags.Controllers {
|
||||
}
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
|
@@ -1,13 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Tags.Services;
|
||||
using Orchard.Tags.ViewModels;
|
||||
using Orchard.Themes;
|
||||
@@ -28,8 +24,6 @@ namespace Orchard.Tags.Controllers {
|
||||
_shapeFactory = shapeFactory;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
@@ -14,15 +14,16 @@ namespace Orchard.Tags.Drivers {
|
||||
private const string TemplateName = "Parts/Tags";
|
||||
private readonly ITagService _tagService;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public TagsPartDriver(ITagService tagService,
|
||||
IAuthorizationService authorizationService) {
|
||||
IAuthorizationService authorizationService,
|
||||
IOrchardServices orchardServices) {
|
||||
_tagService = tagService;
|
||||
_authorizationService = authorizationService;
|
||||
_orchardServices = orchardServices;
|
||||
}
|
||||
|
||||
public virtual IUser CurrentUser { get; set; }
|
||||
|
||||
protected override string Prefix {
|
||||
get { return "Tags"; }
|
||||
}
|
||||
@@ -33,7 +34,7 @@ namespace Orchard.Tags.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(TagsPart part, dynamic shapeHelper) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, _orchardServices.WorkContext.CurrentUser, part))
|
||||
return null;
|
||||
|
||||
return ContentShape("Parts_Tags_Edit",
|
||||
@@ -41,7 +42,7 @@ namespace Orchard.Tags.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(TagsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, _orchardServices.WorkContext.CurrentUser, part))
|
||||
return null;
|
||||
|
||||
var model = new EditTagsViewModel();
|
||||
|
@@ -7,7 +7,6 @@ using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Tags.Models;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
@@ -16,27 +15,25 @@ namespace Orchard.Tags.Services {
|
||||
public class TagService : ITagService {
|
||||
private readonly IRepository<Tag> _tagRepository;
|
||||
private readonly IRepository<TagsContentItems> _tagsContentItemsRepository;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly INotifier _notifier;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public TagService(IRepository<Tag> tagRepository,
|
||||
IRepository<TagsContentItems> tagsContentItemsRepository,
|
||||
IContentManager contentManager,
|
||||
INotifier notifier,
|
||||
IAuthorizationService authorizationService) {
|
||||
IAuthorizationService authorizationService,
|
||||
IOrchardServices orchardServices) {
|
||||
_tagRepository = tagRepository;
|
||||
_tagsContentItemsRepository = tagsContentItemsRepository;
|
||||
_contentManager = contentManager;
|
||||
_notifier = notifier;
|
||||
_authorizationService = authorizationService;
|
||||
_orchardServices = orchardServices;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public virtual ISite CurrentSite { get; set; }
|
||||
public virtual IUser CurrentUser { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public IEnumerable<Tag> GetTags() {
|
||||
@@ -53,7 +50,7 @@ namespace Orchard.Tags.Services {
|
||||
|
||||
public void CreateTag(string tagName) {
|
||||
if (_tagRepository.Get(x => x.TagName == tagName) == null) {
|
||||
_authorizationService.CheckAccess(Permissions.CreateTag, CurrentUser, null);
|
||||
_authorizationService.CheckAccess(Permissions.CreateTag, _orchardServices.WorkContext.CurrentUser, null);
|
||||
|
||||
Tag tag = new Tag { TagName = tagName };
|
||||
_tagRepository.Create(tag);
|
||||
@@ -104,7 +101,7 @@ namespace Orchard.Tags.Services {
|
||||
public IEnumerable<IContent> GetTaggedContentItems(int id) {
|
||||
return _tagsContentItemsRepository
|
||||
.Fetch(x => x.TagId == id)
|
||||
.Select(t =>_contentManager.Get(t.ContentItemId))
|
||||
.Select(t =>_orchardServices.ContentManager.Get(t.ContentItemId))
|
||||
.Where(c => c!= null);
|
||||
}
|
||||
|
||||
@@ -133,7 +130,7 @@ namespace Orchard.Tags.Services {
|
||||
|
||||
foreach (var tagContentItem in currentTagsForContentItem) {
|
||||
if (!newTagsForContentItem.Contains(tagContentItem.TagId)) {
|
||||
_authorizationService.CheckAccess(Permissions.ApplyTag, CurrentUser, null);
|
||||
_authorizationService.CheckAccess(Permissions.ApplyTag, _orchardServices.WorkContext.CurrentUser, null);
|
||||
|
||||
_tagsContentItemsRepository.Delete(tagContentItem);
|
||||
}
|
||||
@@ -143,7 +140,7 @@ namespace Orchard.Tags.Services {
|
||||
}
|
||||
|
||||
foreach (var newTagForContentItem in newTagsForContentItem) {
|
||||
_authorizationService.CheckAccess(Permissions.ApplyTag, CurrentUser, null);
|
||||
_authorizationService.CheckAccess(Permissions.ApplyTag, _orchardServices.WorkContext.CurrentUser, null);
|
||||
|
||||
_tagsContentItemsRepository.Create(new TagsContentItems { ContentItemId = contentItemId, TagId = newTagForContentItem });
|
||||
}
|
||||
|
@@ -2,17 +2,19 @@
|
||||
using System.Web.Routing;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Themes.Models;
|
||||
|
||||
namespace Orchard.Themes.Services {
|
||||
[UsedImplicitly]
|
||||
public class SiteThemeSelector : IThemeSelector {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
public SiteThemeSelector(IOrchardServices orchardServices) {
|
||||
_orchardServices = orchardServices;
|
||||
}
|
||||
|
||||
public ThemeSelectorResult GetTheme(RequestContext context) {
|
||||
string currentThemeName = CurrentSite.As<ThemeSiteSettingsPart>().Record.CurrentThemeName;
|
||||
string currentThemeName = _orchardServices.WorkContext.CurrentSite.As<ThemeSiteSettingsPart>().Record.CurrentThemeName;
|
||||
|
||||
if (String.IsNullOrEmpty(currentThemeName)) {
|
||||
return null;
|
||||
|
@@ -12,7 +12,6 @@ using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Modules;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Themes.Models;
|
||||
|
||||
namespace Orchard.Themes.Services {
|
||||
@@ -23,6 +22,7 @@ namespace Orchard.Themes.Services {
|
||||
private readonly IModuleService _moduleService;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
private readonly ShellDescriptor _shellDescriptor;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly IShellDescriptorManager _shellDescriptorManager;
|
||||
|
||||
public ThemeService(
|
||||
@@ -31,23 +31,24 @@ namespace Orchard.Themes.Services {
|
||||
IEnumerable<IThemeSelector> themeSelectors,
|
||||
IModuleService moduleService,
|
||||
IWorkContextAccessor workContextAccessor,
|
||||
ShellDescriptor shellDescriptor) {
|
||||
ShellDescriptor shellDescriptor,
|
||||
IOrchardServices orchardServices) {
|
||||
_shellDescriptorManager = shellDescriptorManager;
|
||||
_extensionManager = extensionManager;
|
||||
_themeSelectors = themeSelectors;
|
||||
_moduleService = moduleService;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_shellDescriptor = shellDescriptor;
|
||||
_orchardServices = orchardServices;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public ITheme GetSiteTheme() {
|
||||
string currentThemeName = CurrentSite.As<ThemeSiteSettingsPart>().CurrentThemeName;
|
||||
string currentThemeName = _orchardServices.WorkContext.CurrentSite.As<ThemeSiteSettingsPart>().CurrentThemeName;
|
||||
|
||||
if (string.IsNullOrEmpty(currentThemeName)) {
|
||||
return null;
|
||||
@@ -58,7 +59,7 @@ namespace Orchard.Themes.Services {
|
||||
|
||||
public void SetSiteTheme(string themeName) {
|
||||
if (DoEnableTheme(themeName)) {
|
||||
CurrentSite.As<ThemeSiteSettingsPart>().Record.CurrentThemeName = themeName;
|
||||
_orchardServices.WorkContext.CurrentSite.As<ThemeSiteSettingsPart>().Record.CurrentThemeName = themeName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,6 @@ using Orchard.Security;
|
||||
using Orchard.Themes;
|
||||
using Orchard.Users.Services;
|
||||
using Orchard.Users.ViewModels;
|
||||
using Orchard.Settings;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Users.Models;
|
||||
|
||||
@@ -21,21 +19,23 @@ namespace Orchard.Users.Controllers {
|
||||
private readonly IAuthenticationService _authenticationService;
|
||||
private readonly IMembershipService _membershipService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
|
||||
public AccountController(
|
||||
IAuthenticationService authenticationService,
|
||||
IMembershipService membershipService,
|
||||
IUserService userService) {
|
||||
IUserService userService,
|
||||
IOrchardServices orchardServices) {
|
||||
_authenticationService = authenticationService;
|
||||
_membershipService = membershipService;
|
||||
_userService = userService;
|
||||
_orchardServices = orchardServices;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public ActionResult AccessDenied() {
|
||||
var returnUrl = Request.QueryString["ReturnUrl"];
|
||||
@@ -93,7 +93,7 @@ namespace Orchard.Users.Controllers {
|
||||
|
||||
public ActionResult Register() {
|
||||
// ensure users can register
|
||||
var registrationSettings = CurrentSite.As<RegistrationSettingsPart>();
|
||||
var registrationSettings = _orchardServices.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
|
||||
if ( !registrationSettings.UsersCanRegister ) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
@@ -106,7 +106,7 @@ namespace Orchard.Users.Controllers {
|
||||
[HttpPost]
|
||||
public ActionResult Register(string userName, string email, string password, string confirmPassword) {
|
||||
// ensure users can register
|
||||
var registrationSettings = CurrentSite.As<RegistrationSettingsPart>();
|
||||
var registrationSettings = _orchardServices.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
|
||||
if ( !registrationSettings.UsersCanRegister ) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Users.Services;
|
||||
@@ -33,7 +31,6 @@ namespace Orchard.Users.Controllers {
|
||||
dynamic Shape { get; set; }
|
||||
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")))
|
||||
@@ -192,7 +189,7 @@ namespace Orchard.Users.Controllers {
|
||||
var user = Services.ContentManager.Get(id);
|
||||
|
||||
if ( user != null ) {
|
||||
if ( CurrentSite.SuperUser.Equals(user.As<UserPart>().UserName) ) {
|
||||
if (Services.WorkContext.CurrentSite.SuperUser.Equals(user.As<UserPart>().UserName) ) {
|
||||
Services.Notifier.Error(T("Super user can't be moderated"));
|
||||
}
|
||||
else {
|
||||
|
@@ -11,7 +11,6 @@ using Orchard.ContentManagement;
|
||||
using Orchard.Security;
|
||||
using Orchard.Users.Events;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Messaging.Services;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -19,19 +18,18 @@ namespace Orchard.Users.Services {
|
||||
[UsedImplicitly]
|
||||
public class MembershipService : IMembershipService {
|
||||
private static readonly TimeSpan DelayToValidate = new TimeSpan(7, 0, 0, 0); // one week to validate email
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly IMessageManager _messageManager;
|
||||
private readonly IEnumerable<IUserEventHandler> _userEventHandlers;
|
||||
|
||||
public MembershipService(IContentManager contentManager, IMessageManager messageManager, IEnumerable<IUserEventHandler> userEventHandlers) {
|
||||
_contentManager = contentManager;
|
||||
public MembershipService(IOrchardServices orchardServices, IMessageManager messageManager, IEnumerable<IUserEventHandler> userEventHandlers) {
|
||||
_orchardServices = orchardServices;
|
||||
_messageManager = messageManager;
|
||||
_userEventHandlers = userEventHandlers;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
public MembershipSettings GetSettings() {
|
||||
var settings = new MembershipSettings();
|
||||
@@ -42,9 +40,9 @@ namespace Orchard.Users.Services {
|
||||
public IUser CreateUser(CreateUserParams createUserParams) {
|
||||
Logger.Information("CreateUser {0} {1}", createUserParams.Username, createUserParams.Email);
|
||||
|
||||
var registrationSettings = CurrentSite.As<RegistrationSettingsPart>();
|
||||
var registrationSettings = _orchardServices.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
|
||||
|
||||
var user = _contentManager.New<UserPart>("User");
|
||||
var user = _orchardServices.ContentManager.New<UserPart>("User");
|
||||
|
||||
user.Record.UserName = createUserParams.Username;
|
||||
user.Record.Email = createUserParams.Email;
|
||||
@@ -71,14 +69,14 @@ namespace Orchard.Users.Services {
|
||||
return null;
|
||||
}
|
||||
|
||||
_contentManager.Create(user);
|
||||
_orchardServices.ContentManager.Create(user);
|
||||
|
||||
foreach ( var userEventHandler in _userEventHandlers ) {
|
||||
userEventHandler.Created(userContext);
|
||||
}
|
||||
|
||||
if ( registrationSettings != null && registrationSettings.UsersAreModerated && registrationSettings.NotifyModeration && !createUserParams.IsApproved ) {
|
||||
var superUser = GetUser(CurrentSite.SuperUser);
|
||||
var superUser = GetUser(_orchardServices.WorkContext.CurrentSite.SuperUser);
|
||||
if(superUser != null)
|
||||
_messageManager.Send(superUser.ContentItem.Record, MessageTypes.Moderation);
|
||||
}
|
||||
@@ -137,16 +135,16 @@ namespace Orchard.Users.Services {
|
||||
public IUser GetUser(string username) {
|
||||
var lowerName = username == null ? "" : username.ToLower();
|
||||
|
||||
return _contentManager.Query<UserPart, UserPartRecord>().Where(u => u.NormalizedUserName == lowerName).List().FirstOrDefault();
|
||||
return _orchardServices.ContentManager.Query<UserPart, UserPartRecord>().Where(u => u.NormalizedUserName == lowerName).List().FirstOrDefault();
|
||||
}
|
||||
|
||||
public IUser ValidateUser(string userNameOrEmail, string password) {
|
||||
var lowerName = userNameOrEmail == null ? "" : userNameOrEmail.ToLower();
|
||||
|
||||
var user = _contentManager.Query<UserPart, UserPartRecord>().Where(u => u.NormalizedUserName == lowerName).List().FirstOrDefault();
|
||||
var user = _orchardServices.ContentManager.Query<UserPart, UserPartRecord>().Where(u => u.NormalizedUserName == lowerName).List().FirstOrDefault();
|
||||
|
||||
if(user == null)
|
||||
user = _contentManager.Query<UserPart, UserPartRecord>().Where(u => u.Email == lowerName).List().FirstOrDefault();
|
||||
user = _orchardServices.ContentManager.Query<UserPart, UserPartRecord>().Where(u => u.Email == lowerName).List().FirstOrDefault();
|
||||
|
||||
if ( user == null || ValidatePassword(user.As<UserPart>().Record, password) == false )
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user