mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 21:13:35 +08:00
Merge default => dev
--HG-- branch : dev
This commit is contained in:
@@ -126,6 +126,11 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//make sure the placeholder value is not taken as the input value when submitting forms
|
||||||
|
$("form").live("submit", function () {
|
||||||
|
$(":input[placeholder].placeholderd").val("");
|
||||||
|
});
|
||||||
|
|
||||||
return _this;
|
return _this;
|
||||||
},
|
},
|
||||||
toggleWhatYouControl: function () {
|
toggleWhatYouControl: function () {
|
||||||
|
@@ -81,6 +81,13 @@ namespace Orchard.Roles.Controllers {
|
|||||||
var viewModel = new RoleCreateViewModel();
|
var viewModel = new RoleCreateViewModel();
|
||||||
try {
|
try {
|
||||||
UpdateModel(viewModel);
|
UpdateModel(viewModel);
|
||||||
|
|
||||||
|
//check if the role name already exists
|
||||||
|
if (!_roleService.VerifyRoleUnicity(viewModel.Name)) {
|
||||||
|
Services.Notifier.Error(T("Creating Role {0} failed: Role with same name already exists", viewModel.Name));
|
||||||
|
return RedirectToAction("Create");
|
||||||
|
}
|
||||||
|
|
||||||
_roleService.CreateRole(viewModel.Name);
|
_roleService.CreateRole(viewModel.Name);
|
||||||
foreach (string key in Request.Form.Keys) {
|
foreach (string key in Request.Form.Keys) {
|
||||||
if (key.StartsWith("Checkbox.") && Request.Form[key] == "true") {
|
if (key.StartsWith("Checkbox.") && Request.Form[key] == "true") {
|
||||||
|
@@ -15,5 +15,13 @@ namespace Orchard.Roles.Services {
|
|||||||
IEnumerable<string> GetPermissionsForRole(int id);
|
IEnumerable<string> GetPermissionsForRole(int id);
|
||||||
|
|
||||||
IEnumerable<string> GetPermissionsForRoleByName(string name);
|
IEnumerable<string> GetPermissionsForRoleByName(string name);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verify if the role name is unique
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Role name</param>
|
||||||
|
/// <returns>Returns false if a role with the given name already exits</returns>
|
||||||
|
bool VerifyRoleUnicity(string name);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -151,6 +151,16 @@ namespace Orchard.Roles.Services {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verify if the role name is unique
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Role name</param>
|
||||||
|
/// <returns>Returns false if a role with the given name already exits</returns>
|
||||||
|
public bool VerifyRoleUnicity(string name) {
|
||||||
|
return (_roleRepository.Get(x => x.Name == name) == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
IEnumerable<string> GetPermissionsForRoleByNameInner(string name) {
|
IEnumerable<string> GetPermissionsForRoleByNameInner(string name) {
|
||||||
var roleRecord = GetRoleByName(name);
|
var roleRecord = GetRoleByName(name);
|
||||||
return roleRecord == null ? Enumerable.Empty<string>() : GetPermissionsForRole(roleRecord.Id);
|
return roleRecord == null ? Enumerable.Empty<string>() : GetPermissionsForRole(roleRecord.Id);
|
||||||
|
105
src/Orchard.Web/Modules/Orchard.Themes/Commands/ThemeCommands.cs
Normal file
105
src/Orchard.Web/Modules/Orchard.Themes/Commands/ThemeCommands.cs
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using Orchard.Commands;
|
||||||
|
using Orchard.Data.Migration;
|
||||||
|
using Orchard.Environment.Descriptor.Models;
|
||||||
|
using Orchard.Environment.Extensions;
|
||||||
|
using Orchard.Environment.Extensions.Models;
|
||||||
|
using Orchard.Themes.Services;
|
||||||
|
using Orchard.Themes.ViewModels;
|
||||||
|
|
||||||
|
namespace Orchard.Themes.Commands {
|
||||||
|
public class ThemeCommands : DefaultOrchardCommandHandler {
|
||||||
|
private readonly IDataMigrationManager _dataMigrationManager;
|
||||||
|
private readonly ISiteThemeService _siteThemeService;
|
||||||
|
private readonly IExtensionManager _extensionManager;
|
||||||
|
private readonly ShellDescriptor _shellDescriptor;
|
||||||
|
private readonly IThemeService _themeService;
|
||||||
|
|
||||||
|
public ThemeCommands(IDataMigrationManager dataMigrationManager,
|
||||||
|
ISiteThemeService siteThemeService,
|
||||||
|
IExtensionManager extensionManager,
|
||||||
|
ShellDescriptor shellDescriptor,
|
||||||
|
IThemeService themeService) {
|
||||||
|
_dataMigrationManager = dataMigrationManager;
|
||||||
|
_siteThemeService = siteThemeService;
|
||||||
|
_extensionManager = extensionManager;
|
||||||
|
_shellDescriptor = shellDescriptor;
|
||||||
|
_themeService = themeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[OrchardSwitch]
|
||||||
|
public bool Summary { get; set; }
|
||||||
|
|
||||||
|
[CommandName("theme list")]
|
||||||
|
[CommandHelp("theme list [/Summary:true|false]" + "\r\n\tDisplay list of available themes")]
|
||||||
|
[OrchardSwitches("Summary")]
|
||||||
|
public void List() {
|
||||||
|
var currentTheme = _siteThemeService.GetSiteTheme();
|
||||||
|
var featuresThatNeedUpdate = _dataMigrationManager.GetFeaturesThatNeedUpdate();
|
||||||
|
|
||||||
|
var themes = _extensionManager.AvailableExtensions()
|
||||||
|
.Where(d => DefaultExtensionTypes.IsTheme(d.ExtensionType))
|
||||||
|
.Where(d => d.Tags.Split(',').Any(t => t.Trim().Equals("hidden", StringComparison.OrdinalIgnoreCase)) == false)
|
||||||
|
.Select(d => new ThemeEntry {
|
||||||
|
Descriptor = d,
|
||||||
|
NeedsUpdate = featuresThatNeedUpdate.Contains(d.Id),
|
||||||
|
Enabled = _shellDescriptor.Features.Any(sf => sf.Name == d.Id)
|
||||||
|
})
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
if (Summary) {
|
||||||
|
foreach (var theme in themes) {
|
||||||
|
Context.Output.WriteLine(T("{0}", theme.Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Context.Output.WriteLine(T("Current theme"));
|
||||||
|
Context.Output.WriteLine(T("--------------------------"));
|
||||||
|
WriteThemeLines(new ThemeEntry {
|
||||||
|
Descriptor = currentTheme,
|
||||||
|
NeedsUpdate = featuresThatNeedUpdate.Contains(currentTheme.Id),
|
||||||
|
Enabled = _shellDescriptor.Features.Any(sf => sf.Name == currentTheme.Id)
|
||||||
|
});
|
||||||
|
|
||||||
|
Context.Output.WriteLine(T("List of available themes"));
|
||||||
|
Context.Output.WriteLine(T("--------------------------"));
|
||||||
|
themes.Where(t => t.Name.Trim().Equals(currentTheme.Name.Trim(), StringComparison.OrdinalIgnoreCase) == false)
|
||||||
|
.ToList()
|
||||||
|
.ForEach(t => WriteThemeLines(t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WriteThemeLines(ThemeEntry theme) {
|
||||||
|
Context.Output.WriteLine(T(" Name: {0}", theme.Name));
|
||||||
|
Context.Output.WriteLine(T(" State: {0}", theme.Enabled ? T("Enabled") : T("Disabled")));
|
||||||
|
Context.Output.WriteLine(T(" NeedsUpdate: {0}", theme.NeedsUpdate ? T("Yes") : T("No")));
|
||||||
|
Context.Output.WriteLine(T(" Author: {0}", theme.Descriptor.Author));
|
||||||
|
Context.Output.WriteLine(T(" Version: {0}", theme.Descriptor.Version));
|
||||||
|
Context.Output.WriteLine(T(" Description: {0}", theme.Descriptor.Description));
|
||||||
|
Context.Output.WriteLine(T(" Website: {0}", theme.Descriptor.WebSite));
|
||||||
|
Context.Output.WriteLine(T(" Zones: {0}", string.Join(", ", theme.Descriptor.Zones)));
|
||||||
|
Context.Output.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandName("theme activate")]
|
||||||
|
[CommandHelp("theme activate <theme-name>" + "\r\n\tEnable and activates a theme")]
|
||||||
|
public void Activate(string themeName) {
|
||||||
|
var theme = _extensionManager.AvailableExtensions().FirstOrDefault(x => x.Name.Trim().Equals(themeName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (theme == null) {
|
||||||
|
Context.Output.WriteLine(T("Could not find theme {0}", themeName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_shellDescriptor.Features.Any(sf => sf.Name == theme.Id)) {
|
||||||
|
Context.Output.WriteLine(T("Enabling theme \"{0}\"...", themeName));
|
||||||
|
_themeService.EnableThemeFeatures(themeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Context.Output.WriteLine(T("Activating theme \"{0}\"...", themeName));
|
||||||
|
_siteThemeService.SetSiteTheme(themeName);
|
||||||
|
|
||||||
|
Context.Output.WriteLine(T("Theme \"{0}\" activated", themeName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -50,6 +50,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AdminMenu.cs" />
|
<Compile Include="AdminMenu.cs" />
|
||||||
<Compile Include="Models\ThemeEntry.cs" />
|
<Compile Include="Models\ThemeEntry.cs" />
|
||||||
|
<Compile Include="Commands\ThemeCommands.cs" />
|
||||||
<Compile Include="ResourceManifest.cs" />
|
<Compile Include="ResourceManifest.cs" />
|
||||||
<Compile Include="Controllers\AdminController.cs" />
|
<Compile Include="Controllers\AdminController.cs" />
|
||||||
<Compile Include="Migrations.cs" />
|
<Compile Include="Migrations.cs" />
|
||||||
|
Reference in New Issue
Block a user