Enhancements to group handling

This commit is contained in:
Deon George
2011-09-24 23:13:38 +10:00
parent 7180e01dcf
commit cea949a2c4
6 changed files with 70 additions and 96 deletions

View File

@@ -67,12 +67,11 @@ class Auth_OSB extends Auth_ORM {
foreach ($gmo->find_all() as $gm) {
$roles .= ($roles ? '|' : '').$gm->group->name;
$ro = ORM::factory('group', array('name' => $gm->group->name));
// $ro->id == 0 means all users.
if ($ro->id == 0 OR $user->has('group', $ro)) {
// $gm->group->id == 0 means all users.
if ($gm->group->id == 0 OR $user->has_any('group',$gm->group->list_childgrps(TRUE))) {
$status = TRUE;
$roles = '';
break;
}
}

View File

@@ -66,18 +66,14 @@ class Model_Account extends Model_Auth_UserDefault {
* Get the groups that an account belongs to
*/
public function groups() {
return $this->group->find_all()->as_array();
return $this->group->find_all();
}
public function admin() {
// @todo Define admins in the config file or DB
$admins = array('Root');
foreach ($this->groups() as $go)
if (in_array($go->name,$admins))
return TRUE;
return FALSE;
return $this->has($admins);
}
/**