change uses of User_role to Profile_role

This commit is contained in:
Evan Prodromou 2009-11-16 16:06:52 +01:00
parent dd10e9729b
commit 3e08309826
2 changed files with 16 additions and 16 deletions

View File

@ -590,16 +590,16 @@ class Profile extends Memcached_DataObject
function hasRole($name) function hasRole($name)
{ {
$role = User_role::pkeyGet(array('user_id' => $this->id, $role = Profile_role::pkeyGet(array('profile_id' => $this->id,
'role' => $name)); 'role' => $name));
return (!empty($role)); return (!empty($role));
} }
function grantRole($name) function grantRole($name)
{ {
$role = new User_role(); $role = new Profile_role();
$role->user_id = $this->id; $role->profile_id = $this->id;
$role->role = $name; $role->role = $name;
$role->created = common_sql_now(); $role->created = common_sql_now();
@ -615,7 +615,7 @@ class Profile extends Memcached_DataObject
function revokeRole($name) function revokeRole($name)
{ {
$role = User_role::pkeyGet(array('user_id' => $this->id, $role = Profile_role::pkeyGet(array('profile_id' => $this->id,
'role' => $name)); 'role' => $name));
if (empty($role)) { if (empty($role)) {
@ -634,31 +634,31 @@ class Profile extends Memcached_DataObject
function isSandboxed() function isSandboxed()
{ {
return $this->hasRole(User_role::SANDBOXED); return $this->hasRole(Profile_role::SANDBOXED);
} }
function isSilenced() function isSilenced()
{ {
return $this->hasRole(User_role::SILENCED); return $this->hasRole(Profile_role::SILENCED);
} }
function sandbox() function sandbox()
{ {
$this->grantRole(User_role::SANDBOXED); $this->grantRole(Profile_role::SANDBOXED);
} }
function unsandbox() function unsandbox()
{ {
$this->revokeRole(User_role::SANDBOXED); $this->revokeRole(Profile_role::SANDBOXED);
} }
function silence() function silence()
{ {
$this->grantRole(User_role::SILENCED); $this->grantRole(Profile_role::SILENCED);
} }
function unsilence() function unsilence()
{ {
$this->revokeRole(User_role::SILENCED); $this->revokeRole(Profile_role::SILENCED);
} }
} }

View File

@ -679,10 +679,10 @@ class User extends Memcached_DataObject
case Right::SANDBOXUSER: case Right::SANDBOXUSER:
case Right::SILENCEUSER: case Right::SILENCEUSER:
case Right::DELETEUSER: case Right::DELETEUSER:
$result = $this->hasRole(User_role::MODERATOR); $result = $this->hasRole(Profile_role::MODERATOR);
break; break;
case Right::CONFIGURESITE: case Right::CONFIGURESITE:
$result = $this->hasRole(User_role::ADMINISTRATOR); $result = $this->hasRole(Profile_role::ADMINISTRATOR);
break; break;
default: default:
$result = false; $result = false;