I applied the following patch on the pmdev server,
--- NodeBase.pm.orig 2005-08-21 11:22:05.250000000 +0200 +++ NodeBase.pm 2005-08-21 18:33:38.859375000 +0200 @@ -2031,9 +2031,18 @@ #you're always approved if it's yourself... - foreach my $approveduser (@{ $this->selectNodegroupFlat($NODE) }) + foreach my $node (@{ $this->selectNodegroupFlat($NODE) }) { - return 1 if ($user_id == $this->getId($approveduser)); + return 1 if ($user_id == $this->getId($node)); + if ($node->{rulecode}) { + my $res=eval $node->{rulecode}; + if ($@) { + #logit danno + Everything::printLog("Rule error in $node->{node_id}: +$@"); + # return 0; # should this happen? + } + return $res if defined $res; + } } return 0;
and created a new dbtable and nodetype 'rule', with the following structure:
CREATE TABLE rule ( rule_id int(11) NOT NULL auto_increment, rulecode text, PRIMARY KEY (rule_id) ) TYPE=MyISAM
An 'edit' display page and a 'display' display page cribbed from htmlcode, along with a tweak of patachable fields completed my modifications. All together they allow arbitrary rules to be added to usergroups, which when encountered by isApproved() will be executed and used to control the access.
Advantages: Very simple change to code with far reaching effects, very flexible. Disadvantages: requires usergroup wrapper even if you only want a rule. Requires added table.
IMO this would be a good addition to PM. I was thinking that the documentation for the nodes would be provided by the 'display' page showing a sitedoclet if one existed, possibly via a generalized 'add a sitedoclet to this' mechanism that could be reused elsewhere.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Adding a 'rule' system to isApproved() (fewer tables)
by tye (Sage) on Aug 21, 2005 at 17:58 UTC | |
by demerphq (Chancellor) on Aug 21, 2005 at 18:45 UTC | |
by demerphq (Chancellor) on Aug 22, 2005 at 08:32 UTC | |
by demerphq (Chancellor) on Aug 22, 2005 at 19:32 UTC | |
by ysth (Canon) on Aug 22, 2005 at 23:23 UTC | |
by demerphq (Chancellor) on Aug 23, 2005 at 07:27 UTC | |
by tye (Sage) on Aug 23, 2005 at 15:19 UTC | |
|