diff --git a/lib/WebGUI/Grouping.pm b/lib/WebGUI/Grouping.pm index b66249a82..efcd34e02 100755 --- a/lib/WebGUI/Grouping.pm +++ b/lib/WebGUI/Grouping.pm @@ -225,7 +225,7 @@ sub getGroupsForUser { #------------------------------------------------------------------- -=head2 getGroupsInGroup ( groupId ) +=head2 getGroupsInGroup ( groupId [, recursive ] ) Returns an array reference containing a list of groups that belong to the specified group. @@ -235,18 +235,32 @@ Returns an array reference containing a list of groups that belong to the specif A unique identifier for the group. +=item recursive + +A boolean value to determine whether the method should return the groups directly in the group, or to follow the entire groups of groups hierarchy. Defaults to "0". + =back =cut sub getGroupsInGroup { - return WebGUI::SQL->buildArrayRef("select groupId from groupGroupings where inGroup=$_[0]"); + my $groups = WebGUI::SQL->buildArrayRef("select groupId from groupGroupings where inGroup=$_[0]"); + if ($_[1]) { + my @groupsOfGroups = @$groups; + foreach my $group (@$groups) { + my $gog = getGroupsInGroup($group,1); + push(@groupsOfGroups, @$gog); + } + return \@groupsOfGroups; + } else { + return $groups; + } } #------------------------------------------------------------------- -=head2 getUsersInGroup ( groupId ) +=head2 getUsersInGroup ( groupId [, recursive ] ) Returns an array reference containing a list of users that belong to the specified group. @@ -256,12 +270,23 @@ Returns an array reference containing a list of users that belong to the specifi A unique identifier for the group. +=item recursive + +A boolean value to determine whether the method should return the users directly in the group or to follow the entire groups of groups hierarchy. Defaults to "0". + =back =cut sub getUsersInGroup { - return WebGUI::SQL->buildArrayRef("select userId from groupings where groupId=$_[0]"); + my $clause = "groupId=$_[0]"; + if ($_[1]) { + my $groups = getGroupsInGroup($_[0],1); + if ($#$groups >= 0) { + $clause = "groupId in (".join(",",@$groups).")"; + } + } + return WebGUI::SQL->buildArrayRef("select userId from groupings where $clause"); } diff --git a/lib/WebGUI/Operation/Page.pm b/lib/WebGUI/Operation/Page.pm index 1d8570339..a7d0a5403 100644 --- a/lib/WebGUI/Operation/Page.pm +++ b/lib/WebGUI/Operation/Page.pm @@ -33,10 +33,13 @@ sub _recursivelyChangePrivileges { my ($sth, $pageId); $sth = WebGUI::SQL->read("select pageId from page where parentId=$_[0]"); while (($pageId) = $sth->array) { - WebGUI::SQL->write("update page set startDate=$session{form}{startDate}, endDate=$session{form}{endDate}, - ownerId=$session{form}{ownerId}, groupIdView=$session{form}{groupIdView}, - groupIdEdit=$session{form}{groupIdEdit} where pageId=$pageId"); - _recursivelyChangePrivileges($pageId); + if (WebGUI::Privilege::canEditPage($pageId)) { + WebGUI::SQL->write("update page set startDate=$session{form}{startDate}, + endDate=$session{form}{endDate}, + ownerId=$session{form}{ownerId}, groupIdView=$session{form}{groupIdView}, + groupIdEdit=$session{form}{groupIdEdit} where pageId=$pageId"); + _recursivelyChangePrivileges($pageId); + } } $sth->finish; } @@ -46,8 +49,10 @@ sub _recursivelyChangeStyle { my ($sth, $pageId); $sth = WebGUI::SQL->read("select pageId from page where parentId=$_[0]"); while (($pageId) = $sth->array) { - WebGUI::SQL->write("update page set styleId=$session{form}{styleId} where pageId=$pageId"); - _recursivelyChangeStyle($pageId); + if (WebGUI::Privilege::canEditPage($pageId)) { + WebGUI::SQL->write("update page set styleId=$session{form}{styleId} where pageId=$pageId"); + _recursivelyChangeStyle($pageId); + } } $sth->finish; } @@ -324,19 +329,19 @@ sub www_editPage { ); $f->raw( -value=>'
'.WebGUI::International::get(107).'', - -uiLevel=>9 + -uiLevel=>6 ); $f->date( -name=>"startDate", -label=>WebGUI::International::get(497), -value=>$page{startDate}, - -uiLevel=>9 + -uiLevel=>6 ); $f->date( -name=>"endDate", -label=>WebGUI::International::get(498), -value=>$page{endDate}, - -uiLevel=>9 + -uiLevel=>6 ); if (WebGUI::Privilege::isInGroup(3)) { $subtext = '   ' @@ -346,7 +351,7 @@ sub www_editPage { } my $clause; if (WebGUI::Privilege::isInGroup(3)) { - my $contentManagers = WebGUI::Grouping::getUsersInGroup(4); + my $contentManagers = WebGUI::Grouping::getUsersInGroup(4,1); $clause = "userId in ($session{user}{userId},".join(",",@$contentManagers).")"; } else { $clause = "userId=$page{ownerId}"; @@ -358,7 +363,7 @@ sub www_editPage { -label=>WebGUI::International::get(108), -value=>[$page{ownerId}], -subtext=>$subtext, - -uiLevel=>9 + -uiLevel=>6 ); if (WebGUI::Privilege::isInGroup(3)) { $subtext = '   ' @@ -371,7 +376,7 @@ sub www_editPage { -label=>WebGUI::International::get(872), -value=>[$page{groupIdView}], -subtext=>$subtext, - -uiLevel=>9 + -uiLevel=>6 ); $f->group( -name=>"groupIdEdit", @@ -379,7 +384,7 @@ sub www_editPage { -value=>[$page{groupIdEdit}], -subtext=>$subtext, -excludeGroups=>[1,7], - -uiLevel=>9 + -uiLevel=>6 ); if ($childCount) { $f->yesNo(