mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Checking site ownership for all gallery actions
Work Item: 16978 --HG-- branch : dev
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.UI.Navigation;
|
using Orchard.UI.Navigation;
|
||||||
|
using Orchard.Security;
|
||||||
|
|
||||||
namespace Orchard.Packaging {
|
namespace Orchard.Packaging {
|
||||||
[OrchardFeature("Gallery")]
|
[OrchardFeature("Gallery")]
|
||||||
@@ -12,11 +13,14 @@ namespace Orchard.Packaging {
|
|||||||
public void GetNavigation(NavigationBuilder builder) {
|
public void GetNavigation(NavigationBuilder builder) {
|
||||||
builder.Add(T("Gallery"), "30", menu => menu
|
builder.Add(T("Gallery"), "30", menu => menu
|
||||||
.Add(T("Modules"), "1.0", item => item
|
.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
|
.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
|
.Add(T("Feeds"), "3.0", item => item
|
||||||
.Action("Sources", "Gallery", new { area = "Orchard.Packaging" })));
|
.Action("Sources", "Gallery", new { area = "Orchard.Packaging" })
|
||||||
|
.Permission(StandardPermissions.SiteOwner)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -9,6 +9,7 @@ using Orchard.Localization;
|
|||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
using Orchard.Packaging.Services;
|
using Orchard.Packaging.Services;
|
||||||
using Orchard.Packaging.ViewModels;
|
using Orchard.Packaging.ViewModels;
|
||||||
|
using Orchard.Security;
|
||||||
using Orchard.Themes;
|
using Orchard.Themes;
|
||||||
using Orchard.UI.Admin;
|
using Orchard.UI.Admin;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
@@ -26,36 +27,51 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
public GalleryController(
|
public GalleryController(
|
||||||
IPackageManager packageManager,
|
IPackageManager packageManager,
|
||||||
IPackagingSourceManager packagingSourceManager,
|
IPackagingSourceManager packagingSourceManager,
|
||||||
INotifier notifier) {
|
INotifier notifier,
|
||||||
|
IOrchardServices services) {
|
||||||
_packageManager = packageManager;
|
_packageManager = packageManager;
|
||||||
_packagingSourceManager = packagingSourceManager;
|
_packagingSourceManager = packagingSourceManager;
|
||||||
_notifier = notifier;
|
_notifier = notifier;
|
||||||
|
Services = services;
|
||||||
|
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IOrchardServices Services { get; set; }
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
public ILogger Logger { get; set; }
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
public ActionResult Sources() {
|
public ActionResult Sources() {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list sources")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
return View(new PackagingSourcesViewModel {
|
return View(new PackagingSourcesViewModel {
|
||||||
Sources = _packagingSourceManager.GetSources(),
|
Sources = _packagingSourceManager.GetSources(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Remove(int id) {
|
public ActionResult Remove(int id) {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to remove sources")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
_packagingSourceManager.RemoveSource(id);
|
_packagingSourceManager.RemoveSource(id);
|
||||||
_notifier.Information(T("The feed has been removed successfully."));
|
_notifier.Information(T("The feed has been removed successfully."));
|
||||||
return RedirectToAction("Sources");
|
return RedirectToAction("Sources");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult AddSource() {
|
public ActionResult AddSource() {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
return View(new PackagingAddSourceViewModel());
|
return View(new PackagingAddSourceViewModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult AddSource(string url) {
|
public ActionResult AddSource(string url) {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!String.IsNullOrEmpty(url)) {
|
if (!String.IsNullOrEmpty(url)) {
|
||||||
if (!url.StartsWith("http")) {
|
if (!url.StartsWith("http")) {
|
||||||
@@ -96,6 +112,9 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Modules(int? sourceId) {
|
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 selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
||||||
|
|
||||||
var sources = selectedSource != null
|
var sources = selectedSource != null
|
||||||
@@ -123,6 +142,9 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Themes(int? sourceId) {
|
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 selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
||||||
|
|
||||||
var sources = selectedSource != null
|
var sources = selectedSource != null
|
||||||
@@ -138,6 +160,9 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Install(string packageId, string version, int sourceId, string redirectTo) {
|
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();
|
var source = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
||||||
|
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
|
@@ -8,6 +8,7 @@ using Orchard.Environment.Extensions;
|
|||||||
using Orchard.FileSystems.AppData;
|
using Orchard.FileSystems.AppData;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Packaging.Services;
|
using Orchard.Packaging.Services;
|
||||||
|
using Orchard.Security;
|
||||||
using Orchard.Themes;
|
using Orchard.Themes;
|
||||||
using Orchard.UI.Admin;
|
using Orchard.UI.Admin;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
@@ -25,7 +26,8 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
public PackagingServicesController(
|
public PackagingServicesController(
|
||||||
IPackageManager packageManager,
|
IPackageManager packageManager,
|
||||||
INotifier notifier,
|
INotifier notifier,
|
||||||
IAppDataFolderRoot appDataFolderRoot) {
|
IAppDataFolderRoot appDataFolderRoot,
|
||||||
|
IOrchardServices services) {
|
||||||
_packageManager = packageManager;
|
_packageManager = packageManager;
|
||||||
_notifier = notifier;
|
_notifier = notifier;
|
||||||
_appDataFolderRoot = appDataFolderRoot;
|
_appDataFolderRoot = appDataFolderRoot;
|
||||||
@@ -34,31 +36,50 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
public IOrchardServices Services { get; set; }
|
||||||
|
|
||||||
public ActionResult AddTheme(string returnUrl) {
|
public ActionResult AddTheme(string returnUrl) {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add themes")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("AddTheme")]
|
[HttpPost, ActionName("AddTheme")]
|
||||||
public ActionResult AddThemePOST(string returnUrl) {
|
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);
|
return InstallPackage(returnUrl, Request.RawUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("RemoveTheme")]
|
[HttpPost, ActionName("RemoveTheme")]
|
||||||
public ActionResult RemoveThemePOST(string themeId, string returnUrl, string retryUrl) {
|
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);
|
return UninstallPackage(PackagingSourceManager.ThemesPrefix + themeId, returnUrl, retryUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult AddModule(string returnUrl) {
|
public ActionResult AddModule(string returnUrl) {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add modules")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("AddModule")]
|
[HttpPost, ActionName("AddModule")]
|
||||||
public ActionResult AddModulePOST(string returnUrl) {
|
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);
|
return InstallPackage(returnUrl, Request.RawUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult InstallPackage(string returnUrl, string retryUrl) {
|
public ActionResult InstallPackage(string returnUrl, string retryUrl) {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to install packages")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Request.Files != null &&
|
if (Request.Files != null &&
|
||||||
Request.Files.Count > 0 &&
|
Request.Files.Count > 0 &&
|
||||||
@@ -90,6 +111,9 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult UninstallPackage(string id, string returnUrl, string retryUrl) {
|
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 {
|
try {
|
||||||
_packageManager.Uninstall(id, HostingEnvironment.MapPath("~/"));
|
_packageManager.Uninstall(id, HostingEnvironment.MapPath("~/"));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user