added a view privileges setting to each forum

This commit is contained in:
JT Smith 2004-03-04 00:25:02 +00:00
parent a6c5e1afc7
commit 3a845e9027
5 changed files with 36 additions and 2 deletions

View file

@ -93,5 +93,5 @@ webgui.
the distribution. If you need those old upgrades you can still get them
from previous distributions or th 5.5 branch in CVS.
- Added Job Listing templates to the USS.
- Added a view privileges setting to each forum.

View file

@ -681,4 +681,5 @@ INSERT INTO help VALUES (80,'WebGUI',1087,1088,'58,WebGUI;81,WebGUI;79,WebGUI;')
INSERT INTO help VALUES (81,'WebGUI',1089,1090,'58,WebGUI;79,WebGUI;80,WebGUI;50,WebGUI;');
INSERT INTO template VALUES (8,'Synopsis','<div class=\"synopsis\">\r\n<tmpl_loop page_loop>\r\n <div class=\"synopsis_title\">\r\n <a href=\"<tmpl_var page.url>\"><tmpl_var page.menuTitle></a>\r\n </div>\r\n <tmpl_if page.indent>\r\n <div class=\"synopsis_sub\">\r\n <tmpl_var page.synopsis>\r\n </div>\r\n <tmpl_else>\r\n <div class=\"synopsis_summary\">\r\n <tmpl_var page.synopsis>\r\n </div>\r\n </tmpl_if>\r\n</tmpl_loop>\r\n</div>','Navigation',1,1);
INSERT INTO Navigation VALUES (18,'Synopsis',99,'self_and_descendants','current',-1,8,0,0,0,0);
alter table forum add column groupToView int not null default 7;

View file

@ -37,6 +37,7 @@ Data management class for forums.
$forum = WebGUI::Forum->new($forumId);
$boolean = $forum->canPost;
$boolean = $forum->canView;
$scalar = $forum->get($param);
$obj = $forum->getThread($threadId);
$boolean = $forum->isModerator;
@ -79,7 +80,29 @@ Defaults to $session{user}{userId}. Specify a user ID to check privileges for.
sub canPost {
my ($self, $userId) = @_;
$userId = $session{user}{userId} unless ($userId);
return WebGUI::Privilege::isInGroup($self->get("groupToPost"));
return (WebGUI::Privilege::isInGroup($self->get("groupToPost"),$userId) || $self->isModerator);
}
#-------------------------------------------------------------------
=head2 canView ( [ userId ] )
Returns a boolean whether the user has the privileges required to view the forum.
=over
=item userId
Defaults to $session{user}{userId}. Specify a user ID to check privileges for.
=back
=cut
sub canView {
my ($self, $userId) = @_;
$userId = $session{user}{userId} unless ($userId);
return (WebGUI::Privilege::isInGroup($self->get("groupToView"),$userId) || $self->canPost);
}
#-------------------------------------------------------------------

View file

@ -916,6 +916,12 @@ sub forumProperties {
-value=>($forum->get("karmaPerPost") || 0)
);
}
$f->group(
-name=>"groupToView",
-label=>WebGUI::International::get(872),
-value=>[$forum->get("groupToView")],
-uiLevel=>5
);
$f->group(
-name=>"groupToPost",
-label=>WebGUI::International::get(564),
@ -962,6 +968,7 @@ sub forumPropertiesSave {
filterPosts=>$session{form}{filterPosts},
postsPerPage=>$session{form}{postsPerPage},
karmaPerPost=>$session{form}{karmaPerPost},
groupToView=>$session{form}{groupToView},
groupToPost=>$session{form}{groupToPost},
moderatePosts=>$session{form}{moderatePosts},
groupToModerate=>$session{form}{groupToModerate}
@ -2270,6 +2277,7 @@ sub www_viewForum {
WebGUI::Session::setScratch("forumSortBy",$session{form}{sortBy});
$forumId = $session{form}{forumId} unless ($forumId);
my $forum = WebGUI::Forum->new($forumId);
return WebGUI::Privilege::insufficient() unless ($forum->canView);
my $var = getForumTemplateVars($caller, $forum);
return WebGUI::Template::process(WebGUI::Template::get($forum->get("forumTemplateId"),"Forum"), $var);
}
@ -2299,6 +2307,7 @@ sub www_viewThread {
WebGUI::Session::setScratch("forumThreadLayout",$session{form}{layout});
$postId = $session{form}{forumPostId} unless ($postId);
my $post = WebGUI::Forum::Post->new($postId);
return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->canView);
my $var = getThreadTemplateVars($caller, $post);
if ($post->get("forumPostId") == $post->getThread->get("rootPostId") && !$post->canView) {
return www_viewForum($caller, $post->getThread->getForum->get("forumId"));

View file

@ -248,6 +248,7 @@ sub www_view {
}
} else {
my $forum = WebGUI::Forum->new($forumMeta->{forumId});
next unless ($forum->canView);
if ($count == 1) {
$var{'default.listing'} = WebGUI::Forum::UI::www_viewForum({
callback=>$callback,