diff --git a/src/Orchard.Web/Core/Feeds/StandardQueries/ContainerFeedQuery.cs b/src/Orchard.Web/Core/Feeds/StandardQueries/ContainerFeedQuery.cs index 8e531a205..03b804718 100644 --- a/src/Orchard.Web/Core/Feeds/StandardQueries/ContainerFeedQuery.cs +++ b/src/Orchard.Web/Core/Feeds/StandardQueries/ContainerFeedQuery.cs @@ -1,10 +1,12 @@ -using System.Web.Mvc; +using System; +using System.Web.Mvc; using System.Xml.Linq; using JetBrains.Annotations; using Orchard.ContentManagement; using Orchard.Core.Common.Models; using Orchard.Core.Feeds.Models; using Orchard.Core.Feeds.StandardBuilders; +using Orchard.Utility.Extensions; namespace Orchard.Core.Feeds.StandardQueries { [UsedImplicitly] @@ -45,7 +47,8 @@ namespace Orchard.Core.Feeds.StandardQueries { context.Response.Contextualize(requestContext => { var urlHelper = new UrlHelper(requestContext); - link.Add(urlHelper.RouteUrl(inspector.Link)); + var uriBuilder = new UriBuilder(urlHelper.RequestContext.HttpContext.Request.ToRootUrlString()) { Path = urlHelper.RouteUrl(inspector.Link) }; + link.Add(uriBuilder.Uri.OriginalString); }); } else { diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/CommandsController.cs b/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/CommandsController.cs index e84d75225..910cfaf72 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/CommandsController.cs +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/CommandsController.cs @@ -1,4 +1,4 @@ -using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Web.Mvc; @@ -27,12 +27,9 @@ namespace Orchard.DevTools.Controllers { [HttpPost] public ActionResult Execute(CommandsExecuteViewModel model) { - var writer = new StringWriter(); - var parameters = new CommandParameters { - Arguments = model.CommandLine.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries), - Output = writer - }; + var commandLine = model.CommandLine.Trim(); + CommandParameters parameters = GetCommandParameters(commandLine, writer); _commandManager.Execute(parameters); model.History = (model.History ?? Enumerable.Empty()) @@ -43,6 +40,63 @@ namespace Orchard.DevTools.Controllers { return View("Execute", model); } + private static CommandParameters GetCommandParameters(string commandLine, StringWriter writer) { + var arguments = new List(); + var switches = new Dictionary(); + var current = 0; + while (current < commandLine.Length) { + var nextSpace = commandLine.IndexOf(' ', current); + if (nextSpace == -1) nextSpace = commandLine.Length; + var arg = commandLine.Substring(current, nextSpace - current).Trim(); + if (arg.Length == 0) { + current = nextSpace + 1; + continue; + } + if (arg[0] == '/') { + var colonIndex = arg.IndexOf(':'); + if (colonIndex != -1) { + var switchName = arg.Substring(1, colonIndex - 1); + if (arg.Length > colonIndex + 1) { + if (arg[colonIndex + 1] == '"') { + var beginningOfSwitchValue = commandLine.IndexOf('"', current) + 1; + if (beginningOfSwitchValue != 0) { + var endOfSwitchValue = commandLine.IndexOf('"', beginningOfSwitchValue); + if (endOfSwitchValue != -1) { + switches.Add(switchName, + commandLine.Substring(beginningOfSwitchValue, + endOfSwitchValue - beginningOfSwitchValue)); + current = endOfSwitchValue + 1; + continue; + } + } + } + else { + switches.Add(switchName, arg.Substring(colonIndex + 1)); + current = nextSpace + 1; + continue; + } + } + } + } + else if (arg[0] == '"') { + var argumentStart = commandLine.IndexOf('"', current) + 1; + var argumentEnd = commandLine.IndexOf('"', argumentStart); + if (argumentEnd != -1) { + arguments.Add(commandLine.Substring(argumentStart, argumentEnd - argumentStart)); + current = argumentEnd + 1; + continue; + } + } + arguments.Add(arg); + current = nextSpace + 1; + } + + return new CommandParameters { + Arguments = arguments, + Switches = switches, + Output = writer + }; + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs b/src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs new file mode 100644 index 000000000..0d47db6ad --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Users/Commands/UserCommands.cs @@ -0,0 +1,64 @@ +using System; +using System.Linq; +using System.Text.RegularExpressions; +using System.Xml.Linq; +using Orchard.Commands; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Aspects; +using Orchard.Security; +using Orchard.Users.Services; +using System.Web.Security; + +namespace Orchard.Users.Commands { + public class UserCommands : DefaultOrchardCommandHandler { + private readonly IContentManager _contentManager; + private readonly IMembershipService _membershipService; + private readonly IUserService _userService; + + public UserCommands( + IContentManager contentManager, + IMembershipService membershipService, + IUserService userService) { + _contentManager = contentManager; + _membershipService = membershipService; + _userService = userService; + } + + [OrchardSwitch] + public string UserName { get; set; } + + [OrchardSwitch] + public string Password { get; set; } + + [OrchardSwitch] + public string Email { get; set; } + + [OrchardSwitch] + public string FileName { get; set; } + + [CommandName("user create")] + [CommandHelp("user create /UserName: /Password: /Email:\r\n\t" + "Creates a new User")] + [OrchardSwitches("UserName,Password,Email")] + public string Create() { + string userUnicityMessage = _userService.VerifyUserUnicity(UserName, Email); + if (userUnicityMessage != null) { + return userUnicityMessage; + } + if (Password == null || Password.Length < MinPasswordLength) { + return T("You must specify a password of {0} or more characters.", MinPasswordLength).ToString(); + } + + var user = _membershipService.CreateUser(new CreateUserParams(UserName, Password, Email, null, null, true)); + if (user != null) + return T("User created successfully").ToString(); + else + return T("The authentication provider returned an error").ToString(); + } + + int MinPasswordLength { + get { + return _membershipService.GetSettings().MinRequiredPasswordLength; + } + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj index 9eec6d7fb..3f85d7552 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj +++ b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj @@ -67,6 +67,7 @@ +