Page 1 of 1

implementing a different kind of rightssystem into yours

Posted: Fri Mar 04, 2005 8:59 am
by cleany
I`ve downloaded an Ideabox from phpoutsourcing.com and there`s one user table. I`ve already got a user table with a binairy rightssystem.

in this Ideabox there`s a field called $isAdmin (with values 1 or 0 or TRUE and FALSE).

In my system I`ve got a rights class which should be implemented somewhere. It looks something like this:

Code: Select all

if (($cur_session->get_rights() & (16 | 64)) > 0)
{
}
but the old value is $isAdmin...

these are scripts where it`s used: (there`s no global 'isAdmin' created at all)

Code: Select all

function hasAdminRights( &$hasRight, $base="", $method="" )
{
    global $gorumuser;
    global $gorumrecognised;
    $hasRight = ($gorumrecognised && $gorumuser->isAdm);
    return ok;
}

function hasObjectRights(&$hasRight, $method, $giveError=FALSE)
{
    global $gorumrecognised, $gorumauthlevel, $gorumuser,$lll;
    global $generalRight;
    $isAdm = ($gorumrecognised && $gorumuser->isAdm);
    $generalRight = FALSE;
    if( $method==Priv_delete && $isAdm)
    {
        $hasRight=TRUE;
        $generalRight = TRUE;
    }
    elseif($method==Priv_delete && isset($this->id) &&
           $this->id==$gorumuser->id)
    {
        $hasRight=TRUE;
        $generalRight = FALSE;
    }
    elseif( $method==Priv_load )
    {
        $hasRight=TRUE;
        $generalRight = TRUE;
    }
    elseif( $method==Priv_create )
    {
        $hasRight=TRUE;
        $generalRight = TRUE;
    }
    else if( !$gorumrecognised  )
    {
        $hasRight=FALSE;
        $generalRight = TRUE;
    }
    elseif( $isAdm )
    {
        $hasRight=TRUE;
        $generalRight = TRUE;
    }
    elseif( isset($this->id) && $this->id==$gorumuser->id)
    {
        $hasRight=TRUE;
        $generalRight = FALSE;
    }
    else
    {
        $hasRight=FALSE;
        $generalRight = FALSE;
    }
    if( !$hasRight && $giveError )
    {
        handleError($lllї"permission_denied"]);
    }
    return ok;
}

feyd | please use

Code: Select all

tags while

Code: Select all

tags are offline[/color]

Posted: Fri Mar 04, 2005 9:12 am
by feyd
what's your question?