--HG--
branch : dev
This commit is contained in:
Jonathan Wall
2010-10-14 17:22:06 -07:00
7 changed files with 54 additions and 49 deletions

View File

@@ -59,7 +59,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AdminMenu.cs" /> <Compile Include="AdminMenu.cs" />
<Compile Include="ResourceManifest.cs" />
<Compile Include="Commands\IndexingCommands.cs" /> <Compile Include="Commands\IndexingCommands.cs" />
<Compile Include="Controllers\AdminController.cs" /> <Compile Include="Controllers\AdminController.cs" />
<Compile Include="Migrations.cs" /> <Compile Include="Migrations.cs" />
@@ -100,6 +99,7 @@
<Content Include="Views\DefinitionTemplates\FieldIndexing.cshtml" /> <Content Include="Views\DefinitionTemplates\FieldIndexing.cshtml" />
<Content Include="Views\DefinitionTemplates\TypeIndexing.cshtml" /> <Content Include="Views\DefinitionTemplates\TypeIndexing.cshtml" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<ProjectExtensions> <ProjectExtensions>

View File

@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.UI.Resources;
namespace Orchard.Indexing {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("IndexingAdmin").SetUrl("admin.css"); // todo: this does not exist
}
}
}

View File

@@ -1,5 +1,4 @@
@model Orchard.Indexing.ViewModels.IndexViewModel @model Orchard.Indexing.ViewModels.IndexViewModel
@{ Style.Require("IndexingAdmin"); }
<h1>@Html.TitleForPage(T("Search Index Management").ToString())</h1> <h1>@Html.TitleForPage(T("Search Index Management").ToString())</h1>
@using (Html.BeginForm("update", "admin", FormMethod.Post, new {area = "Orchard.Indexing"})) { @using (Html.BeginForm("update", "admin", FormMethod.Post, new {area = "Orchard.Indexing"})) {

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using Orchard.Core.Contents.Controllers;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Roles.Models; using Orchard.Roles.Models;
using Orchard.Roles.Services; using Orchard.Roles.Services;
@@ -98,9 +99,9 @@ namespace Orchard.Roles.Controllers {
var role = _roleService.GetRole(id); var role = _roleService.GetRole(id);
if (role == null) { if (role == null) {
//TODO: Error message return HttpNotFound();
throw new HttpException(404, "page with id " + id + " was not found");
} }
var model = new RoleEditViewModel { Name = role.Name, Id = role.Id, var model = new RoleEditViewModel { Name = role.Name, Id = role.Id,
RoleCategoryPermissions = _roleService.GetInstalledPermissions(), RoleCategoryPermissions = _roleService.GetInstalledPermissions(),
CurrentPermissions = _roleService.GetPermissionsForRole(id)}; CurrentPermissions = _roleService.GetPermissionsForRole(id)};
@@ -117,7 +118,8 @@ namespace Orchard.Roles.Controllers {
} }
[HttpPost, ActionName("Edit")] [HttpPost, ActionName("Edit")]
public ActionResult EditPOST() { [FormValueRequired("submit.Save")]
public ActionResult EditSavePOST(int id) {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles"))) if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
@@ -125,7 +127,6 @@ namespace Orchard.Roles.Controllers {
try { try {
UpdateModel(viewModel); UpdateModel(viewModel);
// Save // Save
if (!String.IsNullOrEmpty(HttpContext.Request.Form["submit.Save"])) {
List<string> rolePermissions = new List<string>(); List<string> rolePermissions = new List<string>();
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") {
@@ -134,15 +135,30 @@ namespace Orchard.Roles.Controllers {
} }
} }
_roleService.UpdateRole(viewModel.Id, viewModel.Name, rolePermissions); _roleService.UpdateRole(viewModel.Id, viewModel.Name, rolePermissions);
}
else if (!String.IsNullOrEmpty(HttpContext.Request.Form["submit.Delete"])) { Services.Notifier.Information(T("Your Role has been saved."));
_roleService.DeleteRole(viewModel.Id); return RedirectToAction("Edit", new { id });
}
return RedirectToAction("Edit", new { viewModel.Id });
} }
catch (Exception exception) { catch (Exception exception) {
Services.Notifier.Error(T("Editing Role failed: {0}", exception.Message)); Services.Notifier.Error(T("Editing Role failed: {0}", exception.Message));
return RedirectToAction("Edit", viewModel.Id); return RedirectToAction("Edit", id);
}
}
[HttpPost, ActionName("Edit")]
[FormValueRequired("submit.Delete")]
public ActionResult EditDeletePOST(int id) {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult();
try {
_roleService.DeleteRole(id);
Services.Notifier.Information(T("Role was successfully deleted."));
return RedirectToAction("Index");
} catch (Exception exception) {
Services.Notifier.Error(T("Editing Role failed: {0}", exception.Message));
return RedirectToAction("Edit", id);
} }
} }
} }

View File

@@ -103,6 +103,10 @@
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project> <Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name> <Name>Orchard.Framework</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@@ -34,7 +34,5 @@
</tr> </tr>
} }
</table> </table>
</fieldset> </fieldset>
} }

View File

@@ -44,9 +44,10 @@ namespace Orchard.Widgets.Controllers {
layers.First() : layers.First() :
layers.FirstOrDefault(layer => layer.Id == id); layers.FirstOrDefault(layer => layer.Id == id);
if (currentLayer == null) { if (currentLayer == null &&
id != null) {
// Incorrect layer id passed // Incorrect layer id passed
Services.Notifier.Error(T("Layer not found: {1}", id)); Services.Notifier.Error(T("Layer not found: {0}", id));
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
@@ -254,7 +255,7 @@ namespace Orchard.Widgets.Controllers {
try { try {
widgetPart = _widgetsService.GetWidget(id); widgetPart = _widgetsService.GetWidget(id);
if (widgetPart == null) { if (widgetPart == null) {
Services.Notifier.Error(T("Widget not found: {1}", id)); Services.Notifier.Error(T("Widget not found: {0}", id));
return RedirectToAction("Index"); return RedirectToAction("Index");
} }