summaryrefslogtreecommitdiff
path: root/lib/VNDB
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-12-04 14:00:35 +0100
committerYorhel <git@yorhel.nl>2008-12-04 14:00:35 +0100
commit8f6dba5b1ded646cb46e196200a8014836c1723c (patch)
tree6ae9026b855e3a2e96c0ab16a709e3d76ad2173a /lib/VNDB
parent5e6159b7dc5fa7a130ddffe6857f0db6ff360e45 (diff)
Added htmlItemMessage() for some generic messages about editing the page
Diffstat (limited to 'lib/VNDB')
-rw-r--r--lib/VNDB/Handler/Producers.pm2
-rw-r--r--lib/VNDB/Handler/Releases.pm2
-rw-r--r--lib/VNDB/Handler/VNPage.pm2
-rw-r--r--lib/VNDB/Util/CommonHTML.pm20
4 files changed, 22 insertions, 4 deletions
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index 8de27f7d..8c6775d5 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -43,7 +43,7 @@ sub page {
}
div class => 'mainbox producerpage';
- p class => 'locked', 'Locked for editing' if $p->{locked};
+ $self->htmlItemMessage('p', $p);
h1 $p->{name};
h2 class => 'alttitle', $p->{original} if $p->{original};
p class => 'center';
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index d024d6bb..3d33cf04 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -62,7 +62,7 @@ sub page {
}
div class => 'mainbox release';
- p class => 'locked', 'Locked for editing' if $r->{locked};
+ $self->htmlItemMessage('r', $r);
h1 $r->{title};
h2 class => 'alttitle', $r->{original} if $r->{original};
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 3b27579d..2d2c804b 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -51,7 +51,7 @@ sub page {
_revision($self, $v, $rev);
div class => 'mainbox';
- p class => 'locked', 'Locked for editing' if $v->{locked};
+ $self->htmlItemMessage('v', $v);
h1 $v->{title};
h2 class => 'alttitle', $v->{original} if $v->{original};
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 03fe27eb..e3b67459 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -9,7 +9,7 @@ use Algorithm::Diff::XS 'compact_diff';
use VNDB::Func;
use Encode 'encode_utf8', 'decode_utf8';
-our @EXPORT = qw|htmlMainTabs htmlDenied htmlHiddenMessage htmlBrowse htmlBrowseNavigate htmlRevision htmlEditMessage|;
+our @EXPORT = qw|htmlMainTabs htmlDenied htmlHiddenMessage htmlBrowse htmlBrowseNavigate htmlRevision htmlEditMessage htmlItemMessage|;
# generates the "main tabs". These are the commonly used tabs for
@@ -357,4 +357,22 @@ sub htmlEditMessage {
}
+# Generates a small message when the user can't edit the item,
+# or the item is locked.
+# Arguments: v/r/p, obj
+sub htmlItemMessage {
+ my($self, $type, $obj) = @_;
+
+ if($obj->{locked}) {
+ p class => 'locked', 'Locked for editing'
+ } elsif(!$self->authInfo->{id}) {
+ p class => 'locked';
+ lit 'You need to be <a href="/u/login">logged in</a> to edit this page</a>';
+ end;
+ } elsif(!$self->authCan('edit')) {
+ p class => 'locked', "You're not allowed to edit this page";
+ }
+}
+
+
1;