Apply permission fixes and cleanups

This commit is contained in:
Chris 2017-01-17 16:33:12 +00:00
parent 067a6f58e5
commit 6962f6ef40
2 changed files with 22 additions and 15 deletions

View File

@ -24,6 +24,7 @@ use parent qw(ORB); # This class extends the ORB block class
use experimental qw(smartmatch);
use v5.14;
## @method private % _build_tag($tag)
# Given a reference to a hash containing tag data, generate HTML to
# represent the tag
@ -65,10 +66,10 @@ sub _build_recipe {
# Access to recipe controls is managed by metadata contexts
my $controls = "";
if($self -> check_permission("recipe.edit", $recipe -> {"metadata_id"})) {
$controls .= $self -> {"template"} -> load_template("list/recipe.tem",
$controls .= $self -> {"template"} -> load_template("list/controls.tem",
{ "%(url-edit)s" => $self -> build_url(block => "edit", pathinfo => [ $recipe -> {"id"} ]),
"%(url-edit)s" => $self -> build_url(block => "edit", pathinfo => [ "clone", $recipe -> {"id"} ]),
"%(url-edit)s" => $self -> build_url(block => "edit", pathinfo => [ "delete", $recipe -> {"id"}]),
"%(url-clone)s" => $self -> build_url(block => "edit", pathinfo => [ "clone", $recipe -> {"id"} ]),
"%(url-delete)s" => $self -> build_url(block => "edit", pathinfo => [ "delete", $recipe -> {"id"}]),
});
}
@ -127,6 +128,8 @@ sub _dispatch_ui {
# We need to determine what the page title should be, and the content to shove in it...
my ($title, $body, $extrahead, $extrajs) = ("", "", "", "");
if($self -> check_permission("recipe.view")) {
my @pathinfo = $self -> {"cgi"} -> multi_param("pathinfo");
# If the pathinfo contains a recognised page character, use that
@ -142,6 +145,10 @@ sub _dispatch_ui {
($title, $body, $extrahead, $extrajs) = $self -> _generate_list('A');
}
} else {
($title, $body) = $self -> generate_errorbox(message => "{L_PERMISSION_FAILED_SUMMARY}");
}
# Done generating the page content, return the filled in page template
return $self -> generate_orb_page(title => $title,
content => $body,

View File

@ -65,7 +65,7 @@ sub _generate_summaries {
my $self = shift;
return ("{L_SUMMARY_TITLE}",
$self -> {"template"} -> load_template("summary/content.tem", {"%(pagemenu)s" => $self -> pagemenu(),
$self -> {"template"} -> load_template("summary/content.tem", {"%(pagemenu)s" => $self -> pagemenu("-"),
"%(added)s" => $self -> _build_summary_list("added"),
"%(viewed)s" => $self -> _build_summary_list("viewed"),
"%(updated)s" => $self -> _build_summary_list("updated"),