Re: User class(es)
| From: | Benjamin R. Webb | Date: | Sun, 29 Apr 2001 05:03:45 +0000 |
| Subject: | Re: User class(es) | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-334@lists.php.net to get a copy of this message | ||
Erik Hjortsberg <azatoth@hem.passagen.se> wrote:
> At 06:46 2001-04-26 +0000, you wrote:
>>For a portal project I'm working on I'm going to
......... deleted for clarity
>>
>>Once I have this done, I'll submit it for discussion. Does anybody have any
>>thoughts/critisisms (other than my spelling :-)) about this idea/architecture?
> Some thoughts...
> I've done a user management system for a websystem (www.ostgota.lu.se).
> I used serialized objects in sessionsdata.
> In prepend.php:
> <code>
> include(APPLICATION_PATH.'session.class.php');
> session_start();
> session_register('SESSION');
> if (empty($SESSION)) {
> $SESSION = &new OG_Session;
> } else {
> $SESSION->updateVisit();
> }
> </code>
> The OG_Session-object (subclassing Session) contains info about the
> connection and session such as client's browser, ip, stylsheet to use,
> number of pages visited, logging and so on. These values are generic for
> all sites. Methods for things such as updating number of visits are also
> provided.
> It also contains a OG_User-object, which is unique for every system. In my
> case it contains the user's name, number, clearance and so on. This object
> also contains methods for authorizing pages.
> In this way I can do things like
> <php>
> <?= ($SESSION->user->auth('adminNews.php')) ? '<a
> href="/adminNews.php?newsId='.$news[$i]->newsId().'">change
> newsitem</a>' :
> '' ?>
> </php>
> or
> <code>
> if ($SESSION->user->authThisPage()) {
> stuff to do if user is allowed on the current page...
> }
> </code>
> Simpler stuff:
> <php>
> Logged in as: <?= $SESSION->user->userName() ?>
> </php>
> And when a user log off:
> <code>
> $SESSION->user = &new OG_User;
> </code>
> Log on...
> <code>
> $SESSION->user->logOn($person->personName(),
> $person->personStatus() ..... );
> </code>
> /erik hjortsberg
Erik,
cool idea. Right now I'm going to work on the user portion.
Is there anything you suggest (member vars or methods) that
I should add so that it fits well into this session
architecture?
Ben