--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-12-10 08:33:21 -08:00
32 changed files with 332 additions and 89 deletions

View File

@@ -25,7 +25,7 @@ namespace Orchard.Blogs {
var singleBlog = blogCount == 1 ? blogs.ElementAt(0) : null;
if (blogCount > 0 && singleBlog == null) {
menu.Add(T("List"), "3",
menu.Add(T("Manage Blogs"), "3",
item => item.Action("List", "BlogAdmin", new {area = "Orchard.Blogs"}).Permission(Permissions.MetaListOwnBlogs));
}
else if (singleBlog != null)

View File

@@ -15,6 +15,8 @@ using Orchard.UI.Navigation;
using Orchard.UI.Notify;
namespace Orchard.Blogs.Controllers {
using Orchard.Settings;
[ValidateInput(false), Admin]
public class BlogAdminController : Controller, IUpdateModel {
private readonly IBlogService _blogService;
@@ -22,6 +24,7 @@ namespace Orchard.Blogs.Controllers {
private readonly IContentManager _contentManager;
private readonly ITransactionManager _transactionManager;
private readonly IBlogSlugConstraint _blogSlugConstraint;
private readonly ISiteService _siteService;
public BlogAdminController(
IOrchardServices services,
@@ -30,6 +33,7 @@ namespace Orchard.Blogs.Controllers {
IContentManager contentManager,
ITransactionManager transactionManager,
IBlogSlugConstraint blogSlugConstraint,
ISiteService siteService,
IShapeFactory shapeFactory) {
Services = services;
_blogService = blogService;
@@ -37,6 +41,7 @@ namespace Orchard.Blogs.Controllers {
_contentManager = contentManager;
_transactionManager = transactionManager;
_blogSlugConstraint = blogSlugConstraint;
_siteService = siteService;
T = NullLocalizer.Instance;
Shape = shapeFactory;
}
@@ -147,7 +152,8 @@ namespace Orchard.Blogs.Controllers {
return View((object)viewModel);
}
public ActionResult Item(int blogId, Pager pager) {
public ActionResult Item(int blogId, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
BlogPart blogPart = _blogService.Get(blogId, VersionOptions.Latest).As<BlogPart>();
if (blogPart == null)

View File

@@ -13,6 +13,8 @@ using Orchard.Themes;
using Orchard.UI.Navigation;
namespace Orchard.Blogs.Controllers {
using Orchard.Settings;
[Themed]
public class BlogController : Controller {
private readonly IOrchardServices _services;
@@ -22,6 +24,7 @@ namespace Orchard.Blogs.Controllers {
private readonly IFeedManager _feedManager;
private readonly IWorkContextAccessor _workContextAccessor;
private readonly IHomePageProvider _routableHomePageProvider;
private readonly ISiteService _siteService;
public BlogController(
IOrchardServices services,
@@ -31,13 +34,15 @@ namespace Orchard.Blogs.Controllers {
IFeedManager feedManager,
IShapeFactory shapeFactory,
IWorkContextAccessor workContextAccessor,
IEnumerable<IHomePageProvider> homePageProviders) {
IEnumerable<IHomePageProvider> homePageProviders,
ISiteService siteService) {
_services = services;
_blogService = blogService;
_blogPostService = blogPostService;
_blogSlugConstraint = blogSlugConstraint;
_feedManager = feedManager;
_workContextAccessor = workContextAccessor;
_siteService = siteService;
_routableHomePageProvider = homePageProviders.SingleOrDefault(p => p.GetProviderName() == RoutableHomePageProvider.Name);
Logger = NullLogger.Instance;
Shape = shapeFactory;
@@ -59,7 +64,8 @@ namespace Orchard.Blogs.Controllers {
return View((object)viewModel);
}
public ActionResult Item(string blogSlug, Pager pager) {
public ActionResult Item(string blogSlug, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var correctedSlug = _blogSlugConstraint.FindSlug(blogSlug);
if (correctedSlug == null)
return HttpNotFound();

View File

@@ -5,7 +5,7 @@ namespace Orchard.Blogs {
public class Migrations : DataMigrationImpl {
public int Create() {
SchemaBuilder.CreateTable("BlogPartArchiveRecord",
SchemaBuilder.CreateTable("BlogPartArchiveRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<int>("Year")
@@ -14,21 +14,21 @@ namespace Orchard.Blogs {
.Column<int>("BlogPart_id")
);
SchemaBuilder.CreateTable("BlogPartRecord",
SchemaBuilder.CreateTable("BlogPartRecord",
table => table
.ContentPartRecord()
.Column<string>("Description", c => c.Unlimited())
.Column<int>("PostCount")
);
SchemaBuilder.CreateTable("RecentBlogPostsPartRecord",
SchemaBuilder.CreateTable("RecentBlogPostsPartRecord",
table => table
.ContentPartRecord()
.Column<string>("BlogSlug")
.Column<int>("Count")
);
SchemaBuilder.CreateTable("BlogArchivesPartRecord",
SchemaBuilder.CreateTable("BlogArchivesPartRecord",
table => table
.ContentPartRecord()
.Column<string>("BlogSlug", c => c.WithLength(255))

View File

@@ -123,7 +123,7 @@ namespace Orchard.Blogs.Services {
string password) {
var user = _membershipService.ValidateUser(userName, password);
_authorizationService.CheckAccess(StandardPermissions.AccessFrontEnd, user, null);
_authorizationService.CheckAccess(Permissions.EditOthersBlogPost, user, null);
var array = new XRpcArray();
foreach (var blog in _blogService.Get()) {
@@ -144,7 +144,7 @@ namespace Orchard.Blogs.Services {
int numberOfPosts) {
var user = _membershipService.ValidateUser(userName, password);
_authorizationService.CheckAccess(StandardPermissions.AccessFrontEnd, user, null);
_authorizationService.CheckAccess(Permissions.EditOthersBlogPost, user, null);
var blog = _contentManager.Get<BlogPart>(Convert.ToInt32(blogId));
if (blog == null)
@@ -166,7 +166,7 @@ namespace Orchard.Blogs.Services {
IEnumerable<IXmlRpcDriver> drivers) {
var user = _membershipService.ValidateUser(userName, password);
_authorizationService.CheckAccess(Permissions.EditOwnBlogPost, user, null);
_authorizationService.CheckAccess(publish ? Permissions.PublishOthersBlogPost : Permissions.EditOthersBlogPost, user, null);
var blog = _contentManager.Get<BlogPart>(Convert.ToInt32(blogId));
if (blog == null)
@@ -216,7 +216,7 @@ namespace Orchard.Blogs.Services {
IEnumerable<IXmlRpcDriver> drivers) {
var user = _membershipService.ValidateUser(userName, password);
_authorizationService.CheckAccess(StandardPermissions.AccessFrontEnd, user, null);
_authorizationService.CheckAccess(Permissions.EditOthersBlogPost, user, null);
var blogPost = _blogPostService.Get(postId, VersionOptions.Latest);
if (blogPost == null)
@@ -231,15 +231,13 @@ namespace Orchard.Blogs.Services {
}
private bool MetaWeblogEditPost(int postId, string userName, string password, XRpcStruct content, bool publish, IEnumerable<IXmlRpcDriver> drivers) {
var user = _membershipService.ValidateUser(userName, password);
_authorizationService.CheckAccess(StandardPermissions.AccessFrontEnd, user, null);
_authorizationService.CheckAccess(publish ? Permissions.PublishOthersBlogPost : Permissions.EditOthersBlogPost, user, null);
var blogPost = _blogPostService.Get(postId, VersionOptions.DraftRequired);
if (blogPost == null)
throw new ArgumentException();
var title = content.Optional<string>("title");
var description = content.Optional<string>("description");
var slug = content.Optional<string>("wp_slug");
@@ -259,7 +257,7 @@ namespace Orchard.Blogs.Services {
private bool MetaWeblogDeletePost(string appkey, string postId, string userName, string password, bool publish, IEnumerable<IXmlRpcDriver> drivers) {
var user = _membershipService.ValidateUser(userName, password);
_authorizationService.CheckAccess(StandardPermissions.AccessFrontEnd, user, null);
_authorizationService.CheckAccess(Permissions.DeleteOthersBlogPost, user, null);
var blogPost = _blogPostService.Get(Convert.ToInt32(postId), VersionOptions.Latest);
if (blogPost == null)

View File

@@ -14,12 +14,20 @@ using Orchard.Comments.ViewModels;
using Orchard.Comments.Services;
namespace Orchard.Comments.Controllers {
using Orchard.Settings;
[ValidateInput(false)]
public class AdminController : Controller {
private readonly ICommentService _commentService;
private readonly ISiteService _siteService;
public AdminController(IOrchardServices services, ICommentService commentService, IShapeFactory shapeFactory) {
public AdminController(
IOrchardServices services,
ICommentService commentService,
ISiteService siteService,
IShapeFactory shapeFactory) {
_commentService = commentService;
_siteService = siteService;
Services = services;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
@@ -31,7 +39,9 @@ namespace Orchard.Comments.Controllers {
public Localizer T { get; set; }
dynamic Shape { get; set; }
public ActionResult Index(CommentIndexOptions options, Pager pager) {
public ActionResult Index(CommentIndexOptions options, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
// Default options
if (options == null)
options = new CommentIndexOptions();

View File

@@ -1,6 +1,7 @@
using Orchard.Environment.Extensions;
using Orchard.Localization;
using Orchard.UI.Navigation;
using Orchard.Security;
namespace Orchard.Packaging {
[OrchardFeature("Gallery")]
@@ -12,11 +13,14 @@ namespace Orchard.Packaging {
public void GetNavigation(NavigationBuilder builder) {
builder.Add(T("Gallery"), "30", menu => menu
.Add(T("Modules"), "1.0", item => item
.Action("Modules", "Gallery", new { area = "Orchard.Packaging" }))
.Action("Modules", "Gallery", new { area = "Orchard.Packaging" })
.Permission(StandardPermissions.SiteOwner))
.Add(T("Themes"), "2.0", item => item
.Action("Themes", "Gallery", new { area = "Orchard.Packaging" }))
.Action("Themes", "Gallery", new { area = "Orchard.Packaging" })
.Permission(StandardPermissions.SiteOwner))
.Add(T("Feeds"), "3.0", item => item
.Action("Sources", "Gallery", new { area = "Orchard.Packaging" })));
.Action("Sources", "Gallery", new { area = "Orchard.Packaging" })
.Permission(StandardPermissions.SiteOwner)));
}
}
}

View File

@@ -9,6 +9,7 @@ using Orchard.Localization;
using Orchard.Logging;
using Orchard.Packaging.Services;
using Orchard.Packaging.ViewModels;
using Orchard.Security;
using Orchard.Themes;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
@@ -26,36 +27,51 @@ namespace Orchard.Packaging.Controllers {
public GalleryController(
IPackageManager packageManager,
IPackagingSourceManager packagingSourceManager,
INotifier notifier) {
INotifier notifier,
IOrchardServices services) {
_packageManager = packageManager;
_packagingSourceManager = packagingSourceManager;
_notifier = notifier;
Services = services;
T = NullLocalizer.Instance;
Logger = NullLogger.Instance;
}
public IOrchardServices Services { get; set; }
public Localizer T { get; set; }
public ILogger Logger { get; set; }
public ActionResult Sources() {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list sources")))
return new HttpUnauthorizedResult();
return View(new PackagingSourcesViewModel {
Sources = _packagingSourceManager.GetSources(),
});
}
public ActionResult Remove(int id) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to remove sources")))
return new HttpUnauthorizedResult();
_packagingSourceManager.RemoveSource(id);
_notifier.Information(T("The feed has been removed successfully."));
return RedirectToAction("Sources");
}
public ActionResult AddSource() {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
return new HttpUnauthorizedResult();
return View(new PackagingAddSourceViewModel());
}
[HttpPost]
public ActionResult AddSource(string url) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
return new HttpUnauthorizedResult();
try {
if (!String.IsNullOrEmpty(url)) {
if (!url.StartsWith("http")) {
@@ -96,6 +112,9 @@ namespace Orchard.Packaging.Controllers {
}
public ActionResult Modules(int? sourceId) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list modules")))
return new HttpUnauthorizedResult();
var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
var sources = selectedSource != null
@@ -123,6 +142,9 @@ namespace Orchard.Packaging.Controllers {
}
public ActionResult Themes(int? sourceId) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list themes")))
return new HttpUnauthorizedResult();
var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
var sources = selectedSource != null
@@ -138,6 +160,9 @@ namespace Orchard.Packaging.Controllers {
}
public ActionResult Install(string packageId, string version, int sourceId, string redirectTo) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to install packages")))
return new HttpUnauthorizedResult();
var source = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
if (source == null) {

View File

@@ -8,6 +8,7 @@ using Orchard.Environment.Extensions;
using Orchard.FileSystems.AppData;
using Orchard.Localization;
using Orchard.Packaging.Services;
using Orchard.Security;
using Orchard.Themes;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
@@ -25,7 +26,8 @@ namespace Orchard.Packaging.Controllers {
public PackagingServicesController(
IPackageManager packageManager,
INotifier notifier,
IAppDataFolderRoot appDataFolderRoot) {
IAppDataFolderRoot appDataFolderRoot,
IOrchardServices services) {
_packageManager = packageManager;
_notifier = notifier;
_appDataFolderRoot = appDataFolderRoot;
@@ -34,31 +36,50 @@ namespace Orchard.Packaging.Controllers {
}
public Localizer T { get; set; }
public IOrchardServices Services { get; set; }
public ActionResult AddTheme(string returnUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add themes")))
return new HttpUnauthorizedResult();
return View();
}
[HttpPost, ActionName("AddTheme")]
public ActionResult AddThemePOST(string returnUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add themes")))
return new HttpUnauthorizedResult();
return InstallPackage(returnUrl, Request.RawUrl);
}
[HttpPost, ActionName("RemoveTheme")]
public ActionResult RemoveThemePOST(string themeId, string returnUrl, string retryUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to remove themes")))
return new HttpUnauthorizedResult();
return UninstallPackage(PackagingSourceManager.ThemesPrefix + themeId, returnUrl, retryUrl);
}
public ActionResult AddModule(string returnUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add modules")))
return new HttpUnauthorizedResult();
return View();
}
[HttpPost, ActionName("AddModule")]
public ActionResult AddModulePOST(string returnUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add modules")))
return new HttpUnauthorizedResult();
return InstallPackage(returnUrl, Request.RawUrl);
}
public ActionResult InstallPackage(string returnUrl, string retryUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to install packages")))
return new HttpUnauthorizedResult();
try {
if (Request.Files != null &&
Request.Files.Count > 0 &&
@@ -90,6 +111,9 @@ namespace Orchard.Packaging.Controllers {
}
public ActionResult UninstallPackage(string id, string returnUrl, string retryUrl) {
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to uninstall packages")))
return new HttpUnauthorizedResult();
try {
_packageManager.Uninstall(id, HostingEnvironment.MapPath("~/"));

View File

@@ -15,19 +15,24 @@ using Orchard.Collections;
using Orchard.Themes;
namespace Orchard.Search.Controllers {
using Orchard.Settings;
[ValidateInput(false), Themed]
public class SearchController : Controller {
private readonly ISearchService _searchService;
private readonly IContentManager _contentManager;
private readonly ISiteService _siteService;
public SearchController(
IOrchardServices services,
ISearchService searchService,
IContentManager contentManager,
ISearchService searchService,
IContentManager contentManager,
ISiteService siteService,
IShapeFactory shapeFactory) {
Services = services;
_searchService = searchService;
_contentManager = contentManager;
_siteService = siteService;
T = NullLocalizer.Instance;
Logger = NullLogger.Instance;
@@ -39,7 +44,8 @@ namespace Orchard.Search.Controllers {
public ILogger Logger { get; set; }
dynamic Shape { get; set; }
public ActionResult Index(Pager pager, string q = "") {
public ActionResult Index(PagerParameters pagerParameters, string q = "") {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var searchFields = Services.WorkContext.CurrentSite.As<SearchSettingsPart>().SearchedFields;
IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });

View File

@@ -8,6 +8,7 @@ using Orchard.Commands.Builtin;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Core.Settings.Models;
using Orchard.Data.Migration.Interpreters;
using Orchard.Data.Providers;
using Orchard.Data.Migration;
@@ -172,6 +173,11 @@ namespace Orchard.Setup {
get { return ResourceDebugMode.FromAppSetting; }
set { throw new NotImplementedException(); }
}
public int PageSize {
get { return SiteSettingsPartRecord.DefaultPageSize; }
set { throw new NotImplementedException(); }
}
}
}
}

View File

@@ -4,6 +4,7 @@ using Orchard.ContentManagement;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Settings;
using Orchard.Tags.Services;
using Orchard.Tags.ViewModels;
using Orchard.Themes;
@@ -14,14 +15,17 @@ namespace Orchard.Tags.Controllers {
public class HomeController : Controller {
private readonly ITagService _tagService;
private readonly IContentManager _contentManager;
private readonly ISiteService _siteService;
private readonly dynamic _shapeFactory;
public HomeController(
ITagService tagService,
IContentManager contentManager,
ITagService tagService,
IContentManager contentManager,
ISiteService siteService,
IShapeFactory shapeFactory) {
_tagService = tagService;
_contentManager = contentManager;
_siteService = siteService;
_shapeFactory = shapeFactory;
T = NullLocalizer.Instance;
}
@@ -35,7 +39,9 @@ namespace Orchard.Tags.Controllers {
return View(model);
}
public ActionResult Search(string tagName, Pager pager) {
public ActionResult Search(string tagName, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var tag = _tagService.GetTagByName(tagName);
if (tag == null) {