Changed page privileges to a more intuitive system.
This commit is contained in:
parent
f234b63317
commit
5a218e3feb
6 changed files with 55 additions and 90 deletions
|
|
@ -16,6 +16,7 @@ package WebGUI::Privilege;
|
|||
|
||||
use strict;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Operation::Account ();
|
||||
use WebGUI::Session;
|
||||
|
|
@ -96,21 +97,16 @@ The unique identifier for the page that you wish to check the privileges on. Def
|
|||
=cut
|
||||
|
||||
sub canEditPage {
|
||||
my ($isContentManager,%page);
|
||||
my (%page);
|
||||
tie %page, 'Tie::CPHash';
|
||||
if ($_[0] ne "") {
|
||||
%page = WebGUI::SQL->quickHash("select ownerId,ownerEdit,worldEdit,groupId,groupEdit from page where pageId=$_[0]");
|
||||
%page = WebGUI::SQL->quickHash("select ownerId,groupIdEdit from page where pageId=$_[0]");
|
||||
} else {
|
||||
%page = %{$session{page}};
|
||||
}
|
||||
$isContentManager = isInGroup(4);
|
||||
if ($page{worldEdit} && $isContentManager) {
|
||||
if ($session{user}{userId} == $page{ownerId}) {
|
||||
return 1;
|
||||
} elsif ($session{user}{userId} eq $page{ownerId} && $page{ownerEdit} && $isContentManager) {
|
||||
return 1;
|
||||
} elsif (isInGroup($page{groupId}) && $page{groupEdit} && $isContentManager) {
|
||||
return 1;
|
||||
} elsif (isInGroup(3)) { # admin check
|
||||
} elsif (isInGroup($page{groupIdEdit})) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
|
@ -139,20 +135,15 @@ sub canViewPage {
|
|||
if ($_[0] eq "") {
|
||||
%page = %{$session{page}};
|
||||
} else {
|
||||
%page = WebGUI::SQL->quickHash("select ownerId,ownerView,groupId,groupView,worldView,startDate,endDate
|
||||
from page where pageId=$_[0]");
|
||||
%page = WebGUI::SQL->quickHash("select ownerId,groupIdView,startDate,endDate from page where pageId=$_[0]");
|
||||
}
|
||||
if ($page{startDate} < time() && $page{endDate} > time()) {
|
||||
$inDateRange = 1;
|
||||
}
|
||||
if ($page{worldView} && $inDateRange) {
|
||||
if ($session{user}{userId} == $page{ownerId}) {
|
||||
return 1;
|
||||
} elsif ($session{user}{userId} eq $page{ownerId} && $page{ownerView} && $inDateRange) {
|
||||
} elsif (isInGroup($page{groupIdView}) && $inDateRange) {
|
||||
return 1;
|
||||
} elsif (isInGroup($page{groupId}) && $page{groupView} && $inDateRange) {
|
||||
return 1;
|
||||
} elsif (isInGroup(3)) { # admin check
|
||||
return 1;
|
||||
} elsif (canEditPage($_[0])) {
|
||||
return 1;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue