Can you demonstrate a use that wouldn't be better served by a separate subroutine?

Well thats a good question, and maybe is actually the right way to go.

The idea is that isApproved can handle all of our access control requirements. For instance a typical scenario is something like

if ($validtype{$NODE->{type}{title}} and $DB->isApproved($USER,getnode('sitedocclan','usergroup')) ) { .... }

Which to me should be simply a call like

if ($DB->isApproved($USER,'sitedoclan_editable',$NODE)) { ... }

where 'sitedoclan_editable' would be a user group containing an accessrule and sitedocclan. The accessrule would enforce the node level logic, by returning 0 is the $NODE's type was not appropriate, and by returning undef if the node was of the appropriate type it would allow the usergroup logic to make the final decision.

Now you might be thinking ok, well then why dont we have a routine that does this without changing the behaviour of isApproved. The answer I would offer would be that to provide the flexibility and power available from the proposed isApproved() behaviour you would essentially have to recreate the same scheme anyway, so why not just unify it in the first place.

The trick is to stop thinking that isApproved is about doing membership checks, but rather to think of isApproved as being an access control mechanism, ie SDC not being able to edit superdocs is basically the same thing as a non SDCer not being able to edit sitedoclets.

The other nice advantage of knowing the $NODE is that it makes it possible to come up with a framework for automatically providing the appropriate code for rejecting a user.

---
$world=~s/war/peace/g


In reply to Re^2: Proposed new behaviour of isGods and isApproved (per session cache) by demerphq
in thread Proposed new behaviour of isGods and isApproved (per session cache) by demerphq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.