#19533: Fixing home page loss if user doesn't have enough rights

Work Item: 19533

--HG--
branch : 1.x
extra : rebase_source : 4355f81fc65c6f362e972059edca6497233eb5c4
This commit is contained in:
Sebastien Ros
2013-04-18 14:52:20 -07:00
parent 5612ddc4f3
commit 6dd3989c40
3 changed files with 33 additions and 24 deletions

View File

@@ -105,7 +105,7 @@ namespace Orchard.Autoroute.Drivers {
// but instead keep the value
// if home page is requested, use "/" to have the handler create a homepage alias
if(_authorizer.Authorize(Permissions.SetHomePage) && viewModel.PromoteToHomePage) {
if(viewModel.PromoteToHomePage) {
part.DisplayAlias = "/";
}
}

View File

@@ -81,7 +81,13 @@ namespace Orchard.Autoroute.Handlers {
}
// should it become the home page ?
if (part.DisplayAlias != "/") {
if (part.DisplayAlias != "/" && _orchardServices.Authorizer.Authorize(Permissions.SetHomePage)) {
// if it's the current home page, do nothing
var currentHomePages = _orchardServices.ContentManager.Query<AutoroutePart, AutoroutePartRecord>().Where(x => x.DisplayAlias == "").List();
if (currentHomePages.Any(x => x.Id == part.Id)) {
return;
}
var previous = part.Path;
if (!_autorouteService.Value.ProcessPath(part))
_orchardServices.Notifier.Warning(T("Permalinks in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",

View File

@@ -11,27 +11,30 @@
var defaultPattern = Model.Settings.Patterns[Model.Settings.DefaultPatternIndex];
}
<fieldset class="permalink">
<label>@T("Permalink")</label>
@if (Model.Settings.AllowCustomPattern) {
<span>@ViewContext.RequestContext.HttpContext.Request.ToApplicationRootUrlString()/</span>
<span>@Html.TextBoxFor(m => m.CurrentUrl, new { @class = "text" })</span>
}
else {
<span>@ViewContext.RequestContext.HttpContext.Request.ToApplicationRootUrlString()/@Model.CurrentUrl</span>
}
@if (!Model.PromoteToHomePage) {
<fieldset class="permalink">
<label>@T("Permalink")</label>
@if (Model.Settings.AllowCustomPattern) {
<span>@ViewContext.RequestContext.HttpContext.Request.ToApplicationRootUrlString()/</span>
<span>@Html.TextBoxFor(m => m.CurrentUrl, new {@class = "text"})</span>
}
else {
<span>@ViewContext.RequestContext.HttpContext.Request.ToApplicationRootUrlString()/@Model.CurrentUrl</span>
}
<span class="hint">@T("Save the current item and leave the input empty to have it automatically generated using the pattern {0} e.g., {1}", defaultPattern.Name, defaultPattern.Description)</span>
<span class="hint">@T("Save the current item and leave the input empty to have it automatically generated using the pattern {0} e.g., {1}", defaultPattern.Name, defaultPattern.Description)</span>
</fieldset>
<fieldset>
@if (AuthorizedFor(Permissions.SetHomePage) && !Model.PromoteToHomePage) {
<span class="checkbox-and-label">
@Html.EditorFor(m => m.PromoteToHomePage)
<label for="@Html.FieldIdFor(m => m.PromoteToHomePage)" class="forcheckbox">@T("Set as home page")</label>
</span>
<span class="hint">@T("Check to promote this content as the home page")</span>
}
</fieldset>
</fieldset>
if (AuthorizedFor(Permissions.SetHomePage)) {
<fieldset>
<span class="checkbox-and-label">
@Html.EditorFor(m => m.PromoteToHomePage)
<label for="@Html.FieldIdFor(m => m.PromoteToHomePage)" class="forcheckbox">@T("Set as home page")</label>
</span>
<span class="hint">@T("Check to promote this content as the home page")</span>
</fieldset>
}
}
else {
<span>@T("This content is the current home page")</span>
}