diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-06-20 20:00:40 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-06-20 20:00:40 +0000 |
commit | 72065fb8351b54eee5f1928c18e06ad81aa9b502 (patch) | |
tree | 59052fb790134eed81b52b69150a1e231bd44083 /includes/user.inc | |
parent | 7752dc4c7c4cffda07152d8ee89bce05f16a5d6c (diff) | |
download | brdo-72065fb8351b54eee5f1928c18e06ad81aa9b502.tar.gz brdo-72065fb8351b54eee5f1928c18e06ad81aa9b502.tar.bz2 |
- Added a brand-new access.module which allows you to manage 'roles'
(groups) and 'permissions' ... (inspired by Zope's system).
+ Once installed, click the help-link for more information.
+ See updates/2.00-to-x.xx.sql for the SQL updates.
- Modified loads of code to use our new access.module. The system
still has to mature though: new permissions have to be added and
existing permissions need stream-lining. Awaiting suggestions.
- As a direct result of the new access system, I had to rewrite the
way the top-level links in admin.php are rendered and displayed,
and xhtml-ified admin.php while I was at it.
TODO
- Home-brewed modules need updating, home-brewed themes not.
(Examples: file.module, trip_link.module)
- As soon we *finished* the refactoring of the user system (KJ has
been working on this refactoring already) we should consider to
embed this role and permission code into account.module ...
Diffstat (limited to 'includes/user.inc')
-rw-r--r-- | includes/user.inc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/includes/user.inc b/includes/user.inc index 73d3243bd..2abdf094a 100644 --- a/includes/user.inc +++ b/includes/user.inc @@ -3,14 +3,14 @@ class User { function User($userid, $passwd = 0) { if ($passwd) { - $result = db_query("SELECT * FROM users WHERE LOWER(userid) = LOWER('$userid') && passwd = PASSWORD('$passwd') && STATUS = 2"); + $result = db_query("SELECT u.*, r.perm FROM users u LEFT JOIN role r ON u.role = r.name WHERE LOWER(userid) = LOWER('$userid') && passwd = PASSWORD('$passwd') AND status = 2"); if (db_num_rows($result) == 1) { foreach (db_fetch_row($result) as $key=>$value) { $field = mysql_field_name($result, $key); $this->$field = stripslashes($value); $this->field[] = $field; } db_query("UPDATE users SET last_access = '". time() ."', last_host = '$GLOBALS[REMOTE_ADDR]' WHERE id = $this->id"); } } else { - $result = db_query("SELECT * FROM users WHERE userid = '$userid' && STATUS = 2"); + $result = db_query("SELECT u.*, r.perm FROM users u LEFT JOIN role r ON u.role = r.name WHERE u.userid = '$userid' AND u.status = 2"); if (db_num_rows($result) == 1) { foreach (db_fetch_row($result) as $key=>$value) { $field = mysql_field_name($result, $key); $this->$field = stripslashes($value); $this->field[] = $field; } db_query("UPDATE users SET last_access = '". time() ."', last_host = '$GLOBALS[REMOTE_ADDR]' WHERE id = $this->id"); @@ -52,10 +52,16 @@ function user_save($account, $array) { return user_load(($account->userid ? $account->userid : $array[userid])); } -function user_access($account, $section = 0) { - global $user; - if ($section) return (field_get($account->access, $section) || $account->id == 1); - else return ($account->access || $account->id == 1); +function user_access($account, $perm) { + if ($account->id == 1) { + return 1; + } + else if ($account->perm) { + return strstr($account->perm, $perm); + } + else { + return db_fetch_object(db_query("SELECT * FROM role WHERE name = 'anonymous user' AND perm LIKE '%$perm%'")); + } } function user_ban($mask, $type) { |