Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

It appears to me that you want to use some form of grouping. Normally group based permissions are most easily handled in a database by building a permissions table which is actually a join table. With the appropriate fields, you can give each user different accesses based upon what site/login they are using.

Something like this can be emulated with lookup hashes.

# Untested my %permissions_for = ('adam' => {'alpha' => 1, 'beta' => 1, }, 'bart' => {'alpha' => 1, 'beta' => 0, }, 'cece' => {'alpha' => 0, 'beta' => 1, ), ); { my $account = 'adam'; my $access = 'beta'; if ($permissions_for{$account}{$access}) { showcontent(1); showcontent(2); } }

In other words, you have a session so you have a user and can store some form of user state. Where you maintain that state lookup table (separate .pl code, database row, current code block) is up to you. You can also add flags for each condition so that you have full control over exactly what is shown each account.

Because this can get complex very fast, some sort of account management software should be created for the admin. You will also want tools to modify account accesses based upon session state. Say, the user wishes to turn on certain alerts, or turn them off.

Initially, you can do this by hand, but at some point you will want more options and a simple way to manage them.


In reply to Re: Hide Data based on account by snopal
in thread Hide Data based on account by grashoper

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-20 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found