$usr->getRight() works with MDB2 but not with DB
"Jens Hechtfisch" <[email protected]> Tue, 30 Aug 2005 10:16:55 +0200
| Newsgroups | gmane.comp.php.pear.liveuser |
|---|---|
| Message-ID | <[email protected]> |
Hello list,
strange things happens...
for testing i have
- two rights:
right_id area_id right_define_name has_implied
1 1 Operator N
2 1 Admin N
- two auth-/perm-users: '7123' with perm_user_id = 1 and 'admin' with
perm_user_id = 2
- two groups: 'operator' with group_id = 1 and 'admin' with group_id = 100
- groupusers: perm_user_id group_id
1 1
2 100
- two grouprights:
group_id right_id right_level
1 1 1
100 2 3
Means (should): user "Admin" is in group "Admin" and has right "Admin", user
"7123" is in group "Operator" and has right "Operator".
$usr->getRight('Admin') returns the right_level (3) if i use MDB2. If i
change the same config to use DB instead of MDB2 it returns false
I'm using the latest pear-versions of all packages (no cvs)
My config (is just from one example):
require_once 'MDB2.php';
//require_once 'DB.php';
require_once 'LiveUser.php';
// Plase configure the following file according to your environment
$dsn = 'mysql://user:pass@host/liveuser';
$db = MDB2::connect($dsn);
//$db = DB::connect($dsn);
if (PEAR::isError($db)) {
echo $db->getMessage() . ' ' . $db->getUserInfo();
}
//$db->setFetchMode(DB_FETCHMODE_ASSOC);
$db->setFetchMode(MDB2_FETCHMODE_ASSOC);
$conf =
array(
'autoInit' => false,
'session' => array(
'name' => 'PHPSESSION',
'varname' => 'ludata'
),
'login' => array(
'force' => false,
),
'logout' => array(
'destroy' => true,
),
'authContainers' => array(
'DB' => array(
'type' => 'MDB2', //DB
'loginTimeout' => 0,
'expireTime' => 3600,
'idleTime' => 1800,
'allowDuplicateHandles' => 0,
'storage' => array(
'dsn' => $dsn,
'alias' => array(
'lastlogin' => 'lastlogin',
'is_active' => 'is_active',
),
'fields' => array(
'lastlogin' => 'timestamp',
'is_active' => 'boolean',
),
'tables' => array(
'users' => array(
'fields' => array(
'lastlogin' => false,
'is_active' => false,
),
),
),
)
)
),
'permContainer' => array(
'type' => 'Medium',
'storage' => array('MDB2' => array('dsn' => $dsn, 'prefix' =>
'liveuser_')),
//'storage' => array('DB' => array('dsn' => $dsn, 'prefix' =>
'liveuser_')),
),
);
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$usr = LiveUser::singleton($conf);
$handle = (isset($_REQUEST['handle'])) ? $_REQUEST['handle'] : null;
$passwd = (isset($_REQUEST['passwd'])) ? $_REQUEST['passwd'] : null;
$logout = (isset($_REQUEST['logout'])) ? $_REQUEST['logout'] : false;
$remember = (isset($_REQUEST['rememberMe'])) ? $_REQUEST['rememberMe'] :
false;
if (!$usr->init($handle, $passwd, $logout, $remember)) {
var_dump($usr->getErrors());
die();
}
May be that I've done some mistakes, but it looks more like a bug(?)
Regards
Jens