mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Cleanup & Refactoring
--HG-- branch : dev
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Orchard.Core.Common {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
ChangeOwner,
|
||||
};
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ namespace Orchard.Core.Settings {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
ManageSettings,
|
||||
ChangeSuperuser,
|
||||
};
|
||||
|
@@ -19,7 +19,7 @@ namespace Orchard.Blogs {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
ManageBlogs,
|
||||
EditBlogPost,
|
||||
EditOthersBlogPost,
|
||||
|
@@ -14,7 +14,7 @@ namespace Orchard.Comments {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
AddComment,
|
||||
EnableComment,
|
||||
CloseComment,
|
||||
|
@@ -10,7 +10,7 @@ namespace Orchard.Experimental {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
DebugShowAllMenuItems,
|
||||
};
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ namespace Orchard.Localization.Controllers {
|
||||
var model = new AddLocalizationViewModel();
|
||||
TryUpdateModel(model);
|
||||
|
||||
ContentItem contentItemTranslation = null;
|
||||
ContentItem contentItemTranslation;
|
||||
var existingTranslation = _localizationService.GetLocalizedContentItem(contentItem, model.SelectedCulture);
|
||||
if (existingTranslation != null) {
|
||||
// edit existing
|
||||
|
@@ -10,7 +10,7 @@ namespace Orchard.Media {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
ManageMediaFiles,
|
||||
UploadMediaFiles,
|
||||
};
|
||||
|
@@ -12,7 +12,7 @@ namespace Orchard.Roles {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
ManageRoles,
|
||||
ApplyRoles,
|
||||
};
|
||||
|
@@ -59,10 +59,10 @@ namespace Orchard.Scripting.Compiler {
|
||||
if (IsDigitCharacter(ch)) {
|
||||
return LexInteger();
|
||||
}
|
||||
else if (IsIdentifierCharacter(ch)) {
|
||||
if (IsIdentifierCharacter(ch)) {
|
||||
return LexIdentifierOrKeyword();
|
||||
}
|
||||
else if (IsWhitespaceCharacter(ch)) {
|
||||
if (IsWhitespaceCharacter(ch)) {
|
||||
NextCharacter();
|
||||
continue;
|
||||
}
|
||||
@@ -163,18 +163,18 @@ namespace Orchard.Scripting.Compiler {
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsWhitespaceCharacter(char character) {
|
||||
private static bool IsWhitespaceCharacter(char character) {
|
||||
return char.IsWhiteSpace(character);
|
||||
}
|
||||
|
||||
private bool IsIdentifierCharacter(char ch) {
|
||||
private static bool IsIdentifierCharacter(char ch) {
|
||||
return
|
||||
(ch >= 'a' && ch <= 'z') ||
|
||||
(ch >= 'A' && ch <= 'Z') ||
|
||||
(ch == '_');
|
||||
}
|
||||
|
||||
private bool IsDigitCharacter(char ch) {
|
||||
private static bool IsDigitCharacter(char ch) {
|
||||
return ch >= '0' && ch <= '9';
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Orchard.Scripting.Compiler {
|
||||
return CreateToken(TokenKind.SingleQuotedStringLiteral, _stringBuilder.ToString());
|
||||
}
|
||||
// backslash notation
|
||||
else if (Character() == '\\') {
|
||||
if (Character() == '\\') {
|
||||
NextCharacter();
|
||||
|
||||
if (Eof())
|
||||
@@ -210,7 +210,7 @@ namespace Orchard.Scripting.Compiler {
|
||||
_stringBuilder.Append(Character());
|
||||
}
|
||||
}
|
||||
// Regular character in string
|
||||
// Regular character in string
|
||||
else {
|
||||
_stringBuilder.Append(Character());
|
||||
}
|
||||
@@ -232,7 +232,7 @@ namespace Orchard.Scripting.Compiler {
|
||||
return CreateToken(TokenKind.StringLiteral, _stringBuilder.ToString());
|
||||
}
|
||||
// backslash notation
|
||||
else if (Character() == '\\') {
|
||||
if (Character() == '\\') {
|
||||
NextCharacter();
|
||||
|
||||
if (Eof())
|
||||
@@ -240,7 +240,7 @@ namespace Orchard.Scripting.Compiler {
|
||||
|
||||
_stringBuilder.Append(Character());
|
||||
}
|
||||
// Regular character in string
|
||||
// Regular character in string
|
||||
else {
|
||||
_stringBuilder.Append(Character());
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ namespace Orchard.Tags {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
ManageTags,
|
||||
CreateTag,
|
||||
ApplyTag,
|
||||
|
@@ -10,7 +10,7 @@ namespace Orchard.Themes {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
ManageThemes,
|
||||
ApplyTheme,
|
||||
};
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using Orchard.Commands;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Security;
|
||||
using Orchard.Users.Services;
|
||||
|
||||
@@ -9,7 +8,6 @@ namespace Orchard.Users.Commands {
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public UserCommands(
|
||||
IContentManager contentManager,
|
||||
IMembershipService membershipService,
|
||||
IUserService userService) {
|
||||
_membershipService = membershipService;
|
||||
@@ -43,8 +41,8 @@ namespace Orchard.Users.Commands {
|
||||
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();
|
||||
|
||||
return T("The authentication provider returned an error").ToString();
|
||||
}
|
||||
|
||||
int MinPasswordLength {
|
||||
|
@@ -132,9 +132,8 @@ namespace Orchard.Users.Controllers {
|
||||
_authenticationService.SignIn(user, false /* createPersistentCookie */);
|
||||
return Redirect("~/");
|
||||
}
|
||||
else {
|
||||
ModelState.AddModelError("_FORM", T(ErrorCodeToString(/*createStatus*/MembershipCreateStatus.ProviderError)));
|
||||
}
|
||||
|
||||
ModelState.AddModelError("_FORM", T(ErrorCodeToString(/*createStatus*/MembershipCreateStatus.ProviderError)));
|
||||
}
|
||||
|
||||
// If we got this far, something failed, redisplay form
|
||||
@@ -196,11 +195,10 @@ namespace Orchard.Users.Controllers {
|
||||
_membershipService.SetPassword(validated, newPassword);
|
||||
return RedirectToAction("ChangePasswordSuccess");
|
||||
}
|
||||
else {
|
||||
ModelState.AddModelError("_FORM",
|
||||
T("The current password is incorrect or the new password is invalid."));
|
||||
return ChangePassword();
|
||||
}
|
||||
|
||||
ModelState.AddModelError("_FORM",
|
||||
T("The current password is incorrect or the new password is invalid."));
|
||||
return ChangePassword();
|
||||
}
|
||||
catch {
|
||||
ModelState.AddModelError("_FORM", T("The current password is incorrect or the new password is invalid."));
|
||||
|
@@ -11,7 +11,7 @@ namespace Orchard.Users {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
ManageUsers,
|
||||
};
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ namespace Orchard.Widgets {
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
return new[] {
|
||||
ManageWidgets,
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user