fixing bugs in the no longer magic groups

This commit is contained in:
JT Smith 2004-02-10 02:41:24 +00:00
parent e1aacb3a7d
commit b26ae240ff
5 changed files with 32 additions and 27 deletions

View file

@ -1053,10 +1053,8 @@ CREATE TABLE groupings (
--
INSERT INTO groupings VALUES (5,3,2114402400,0);
INSERT INTO groupings VALUES (4,3,2114402400,0);
INSERT INTO groupings VALUES (1,1,2114402400,0);
INSERT INTO groupings VALUES (3,3,2114402400,0);
INSERT INTO groupings VALUES (6,3,2114402400,0);
--
-- Table structure for table `groups`

View file

@ -348,19 +348,19 @@ INSERT INTO template VALUES (4,'Tab Form','<tmpl_if displayTitle>\r\n <h1><tm
alter table groups add column isEditable int not null default 1;
alter table groups add column showInForms int not null default 1;
update groups set isEditable=0 where groupId in (1,2,7);
insert into groupings (groupId,userId) select userId, 7 from users;
insert into groupings (groupId,userId) select userId, 2 from users where userId<>1;
delete from groupings where groupId is in (1,7,2,5);
insert into groupings (groupId,userId) values (1,1);
insert into groupings (groupId,userId) select 7, userId from users;
insert into groupings (groupId,userId) select 2, userId from users where userId<>1;
insert into groups (groupId,groupName,description,showInForms) values (5,'Turn Admin On','These users can enable admin mode.',0);
insert into groupGroupings (groupId, inGroup) values (3,5);
insert into groupGroupings (groupId, inGroup) values (4,5);
insert into groupGroupings (groupId, inGroup) values (6,5);
insert into groupGroupings (groupId, inGroup) values (8,5);
insert into groupGroupings (groupId, inGroup) values (9,5);
insert into groupGroupings (groupId, inGroup) values (10,5);
insert into groupGroupings (groupId, inGroup) values (11,5);
delete from groupGroupings where groupId = 3;
insert into groupGroupings (groupId, inGroup) select 3, groupId from groups where groupId not in (1,3);
CREATE TABLE WSClient (
wobjectId int(11) NOT NULL default '0',
call text NOT NULL,

View file

@ -70,6 +70,7 @@ sub _create {
my $groupId = getNextId("groupId");
WebGUI::SQL->write("insert into groups (groupId,dateCreated,expireOffset,karmaThreshold) values
($groupId,".time().",314496000,1000000000)");
WebGUI::Grouping::addGroupsToGroups([3],[$groupId]);
return $groupId;
}

View file

@ -264,25 +264,25 @@ sub isInGroup {
$uid = $session{user}{userId} if ($uid eq "");
#The next 3 checks are to increase performance. If this section were removed, everything would continue to work as normal.
if ($gid == 7) {
return 1;
}
if ($gid == 1) {
if ($uid == 1) {
return 1;
} else {
return 0;
}
}
if ($gid==2 && $uid != 1) {
return 1;
}
#The several checks are to increase performance. If this section were removed, everything would continue to work as normal.
# if ($gid == 7) {
# return 1;
# }
# if ($gid == 1) {
# if ($uid == 1) {
# return 1;
# } else {
# return 0;
# }
# }
# if ($gid==2 && $uid != 1) {
# return 1;
# }
### Use session to cache multiple lookups of the same group.
if ($session{isInGroup}{$gid}{$uid} || $session{isInGroup}{3}{$uid}) {
if ($session{isInGroup}{$gid}{$uid} == 1) {
return 1;
} elsif ($session{isInGroup}{$gid}{$uid} eq "0") {
return 0;
@ -292,9 +292,10 @@ sub isInGroup {
foreach (@{$groups}) {
$session{isInGroup}{$_}{$uid} = 1;
}
if ($session{isInGroup}{$gid}{$uid} || $session{isInGroup}{3}{$uid}) {
if ($session{isInGroup}{$gid}{$uid} == 1) {
return 1;
}
### Get data for auxillary checks.
tie %group, 'Tie::CPHash';
%group = WebGUI::SQL->quickHash("select karmaThreshold,ipFilter,scratchFilter,databaseLinkId,dbQuery,dbCacheTimeout from groups where groupId='$gid'");
@ -313,6 +314,7 @@ sub isInGroup {
}
}
}
### Check Scratch Variables
if ($group{scratchFilter} ne "") {
$group{scratchFilter} =~ s/\t//g;
@ -328,6 +330,7 @@ sub isInGroup {
}
}
}
### Check karma levels.
if ($session{setting}{useKarma}) {
my $karma;
@ -382,7 +385,7 @@ sub isInGroup {
foreach (@{$groups}) {
$session{isInGroup}{$_}{$uid} = isInGroup($_, $uid);
if ($session{isInGroup}{$_}{$uid}) {
$session{isInGroup}{$gid}{$uid} = 1;
$session{isInGroup}{$gid}{$uid} = 1; # cache current group also so we don't have to do the group in group check again
return 1;
}
}

View file

@ -664,7 +664,10 @@ sub new {
}
};
my %fullProperties;
my $extra = WebGUI::SQL->quickHashRef("select * from ".$properties->{namespace}." where wobjectId='".$properties->{wobjectId}."'");
my $extra;
unless ($properties->{wobjectId} eq "new") {
$extra = WebGUI::SQL->quickHashRef("select * from ".$properties->{namespace}." where wobjectId='".$properties->{wobjectId}."'");
}
tie %fullProperties, 'Tie::CPHash';
%fullProperties = (%{$properties},%{$extra});
bless({