12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class GrantRoleAction 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::GRANTROLE)) {
-
- $this->clientError(_('You cannot grant user roles on this site.'));
- }
- assert(!empty($this->profile));
- if ($this->profile->hasRole($this->role)) {
-
- $this->clientError(_('User already has this role.'));
- }
- return true;
- }
-
- function handlePost()
- {
- $this->profile->grantRole($this->role);
- }
- }
|