12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class RevokeRoleAction extends ProfileFormAction
- {
-
- function prepare(array $args = array())
- {
- if (!parent::prepare($args)) {
- return false;
- }
- $this->role = $this->arg('role');
- if (!Profile_role::isValid($this->role)) {
-
- $this->clientError(_('Invalid role.'));
- }
- if (!Profile_role::isSettable($this->role)) {
-
- $this->clientError(_('This role is reserved and cannot be set.'));
- }
- $cur = common_current_user();
- assert(!empty($cur));
- if (!$cur->hasRight(Right::REVOKEROLE)) {
-
- $this->clientError(_('You cannot revoke user roles on this site.'));
- }
- assert(!empty($this->profile));
- if (!$this->profile->hasRole($this->role)) {
-
- $this->clientError(_('User does not have this role.'));
- }
- return true;
- }
-
- function handlePost()
- {
- $this->profile->revokeRole($this->role);
- }
- }
|