Example #1
0
 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $this->role = $this->arg('role');
     if (!Profile_role::isValid($this->role)) {
         $this->clientError(_('Invalid role.'));
         return false;
     }
     if (!Profile_role::isSettable($this->role)) {
         $this->clientError(_('This role is reserved and cannot be set.'));
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::REVOKEROLE)) {
         $this->clientError(_('You cannot revoke user roles on this site.'));
         return false;
     }
     assert(!empty($this->profile));
     // checked by parent
     if (!$this->profile->hasRole($this->role)) {
         $this->clientError(_("User doesn't have this role."));
         return false;
     }
     return true;
 }
Example #2
0
 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $this->role = $this->arg('role');
     if (!Profile_role::isValid($this->role)) {
         // TRANS: Client error displayed when trying to revoke an invalid role.
         $this->clientError(_('Invalid role.'));
     }
     if (!Profile_role::isSettable($this->role)) {
         // TRANS: Client error displayed when trying to revoke a reserved role.
         $this->clientError(_('This role is reserved and cannot be set.'));
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::REVOKEROLE)) {
         // TRANS: Client error displayed when trying to revoke a role without having the right to do that.
         $this->clientError(_('You cannot revoke user roles on this site.'));
     }
     assert(!empty($this->profile));
     // checked by parent
     if (!$this->profile->hasRole($this->role)) {
         // TRANS: Client error displayed when trying to revoke a role that is not set.
         $this->clientError(_('User does not have this role.'));
     }
     return true;
 }
Example #3
0
 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $this->role = $this->arg('role');
     if (!Profile_role::isValid($this->role)) {
         // TRANS: Client error displayed when trying to assign an invalid role to a user.
         $this->clientError(_('Invalid role.'));
         return false;
     }
     if (!Profile_role::isSettable($this->role)) {
         // TRANS: Client error displayed when trying to assign an reserved role to a user.
         $this->clientError(_('This role is reserved and cannot be set.'));
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::GRANTROLE)) {
         // TRANS: Client error displayed when trying to assign a role to a user while not being allowed to set roles.
         $this->clientError(_('You cannot grant user roles on this site.'));
         return false;
     }
     assert(!empty($this->profile));
     // checked by parent
     if ($this->profile->hasRole($this->role)) {
         // TRANS: Client error displayed when trying to assign a role to a user that already has that role.
         $this->clientError(_('User already has this role.'));
         return false;
     }
     return true;
 }
Example #4
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $user = common_current_user();
     assert(!empty($user));
     // checked above
     assert(!empty($this->profile));
     // checked above
     return true;
 }
Example #5
0
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasBlocked($this->profile)) {
         $this->clientError(_("You haven't blocked that user."));
         return false;
     }
     return true;
 }
Example #6
0
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasBlocked($this->profile)) {
         // TRANS: Client error displayed when trying to unblock a non-blocked user.
         $this->clientError(_("You haven't blocked that user."));
     }
     return true;
 }
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $user = common_current_user();
     assert(!empty($user));
     // checked above
     assert(!empty($this->profile));
     // checked above
     if (User_flag_profile::exists($this->profile->id, $user->id)) {
         $this->clientError(_('Flag already exists.'));
         return false;
     }
     return true;
 }
Example #8
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $user = common_current_user();
     assert(!empty($user));
     // checked above
     assert(!empty($this->profile));
     // checked above
     if (User_flag_profile::exists($this->profile->id, $user->id)) {
         // TRANS: Client error when setting flag that has already been set for a profile.
         $this->clientError(_m('Flag already exists.'));
         return false;
     }
     return true;
 }
Example #9
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::DELETEUSER)) {
         $this->clientError(_('You cannot delete users.'));
         return false;
     }
     $this->user = User::staticGet('id', $this->profile->id);
     if (empty($this->user)) {
         $this->clientError(_('You can only delete local users.'));
         return false;
     }
     return true;
 }
Example #10
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::DELETEUSER)) {
         // TRANS: Client error displayed when trying to delete a user without having the right to delete users.
         $this->clientError(_('You cannot delete users.'));
     }
     $this->user = User::getKV('id', $this->profile->id);
     if (empty($this->user)) {
         // TRANS: Client error displayed when trying to delete a non-local user.
         $this->clientError(_('You can only delete local users.'));
     }
     return true;
 }
Example #11
0
 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::SILENCEUSER)) {
         // TRANS: Client error displayed trying to silence a user on a site where the feature is not enabled.
         $this->clientError(_('You cannot silence users on this site.'));
     }
     assert(!empty($this->profile));
     // checked by parent
     if ($this->profile->isSilenced()) {
         // TRANS: Client error displayed trying to silence an already silenced user.
         $this->clientError(_('User is already silenced.'));
     }
     return true;
 }
Example #12
0
 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::SILENCEUSER)) {
         $this->clientError(_('You cannot silence users on this site.'));
         return false;
     }
     assert(!empty($this->profile));
     // checked by parent
     if ($this->profile->isSilenced()) {
         $this->clientError(_('User is already silenced.'));
         return false;
     }
     return true;
 }
Example #13
0
 /**
  * Check parameters
  *
  * @param array $args action arguments (URL, GET, POST)
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     if (!parent::prepare($args)) {
         return false;
     }
     $cur = common_current_user();
     assert(!empty($cur));
     // checked by parent
     if (!$cur->hasRight(Right::SANDBOXUSER)) {
         // TRANS: Client error on page to unsandbox a user when the feature is not enabled.
         $this->clientError(_('You cannot sandbox users on this site.'));
     }
     assert(!empty($this->profile));
     // checked by parent
     if (!$this->profile->isSandboxed()) {
         // TRANS: Client error on page to unsilence a user when the to be unsandboxed user has not been sandboxed.
         $this->clientError(_('User is not sandboxed.'));
     }
     return true;
 }
Example #14
0
 function showScripts()
 {
     parent::showScripts();
     $this->autofocus('form_action-yes');
 }
Example #15
0
 /**
  * Override for form session token checks; on our first hit we're just
  * requesting confirmation, which doesn't need a token. We need to be
  * able to take regular GET requests from email!
  * 
  * @throws ClientException if token is bad on POST request or if we have
  *         confirmation parameters which could trigger something.
  */
 function checkSessionToken()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST' || $this->arg('yes') || $this->arg('no')) {
         return parent::checkSessionToken();
     }
 }