class UserSingle7

  1. 8.0.x lib/Drush/User/UserSingle7.php UserSingle7
  2. 7.x lib/Drush/User/UserSingle7.php UserSingle7
  3. master lib/Drush/User/UserSingle7.php UserSingle7

Namespace

Drush\User

Hierarchy

Expanded class hierarchy of UserSingle7

Members

Contains filters are case sensitive
Name Modifierssort descending Type Description
UserSingle7::info function A flatter and simpler array presentation of a Drupal $user object. Overrides UserSingleBase::info
UserSingle7::password function Change a user's password. Overrides UserSingleBase::password
UserSingle7::block public function Block a user from login. Overrides UserSingleBase::block
UserSingle7::unblock public function Unblock a user from login. Overrides UserSingleBase::unblock
UserSingle7::addRole public function Add a role to the current user. Overrides UserSingleBase::addRole
UserSingle7::removeRole public function Remove a role from the current user. Overrides UserSingleBase::removeRole
UserSingle7::passResetUrl public function Build a one time login link. Overrides UserSingleBase::passResetUrl
UserSingle7::getUsername public function Get a user's name. Overrides UserSingleBase::getUsername
UserSingle7::id public function Return an id from a Drupal user account. Overrides UserSingleBase::id
UserSingleBase::__construct public function
UserSingleBase::cancel public function Block a user and remove or reassign their content.
UserSingleBase::$account public property

File

lib/Drush/User/UserSingle7.php, line 5

View source
class UserSingle7 extends UserSingleBase {

  public function block() {
    user_user_operations_block(array($this->account->uid));
  }

  public function unblock() {
    user_user_operations_unblock(array($this->account->uid));
  }

  public function addRole($rid) {
    user_multiple_role_edit(array($this->account->uid), 'add_role', $rid);
  }

  public function removeRole($rid) {
    user_multiple_role_edit(array($this->account->uid), 'remove_role', $rid);
  }

  function info() {
    $userinfo = (array) $this->account;
    unset($userinfo['data']);
    unset($userinfo['block']);
    unset($userinfo['form_build_id']);
    foreach (array('created', 'access', 'login') as $key) {
      $userinfo['user_' . $key] = format_date($userinfo[$key]);
    }
    $userinfo['user_status'] = $userinfo['status'] ? 'active' : 'blocked';
    return $userinfo;
  }

  public function passResetUrl($path = '') {
    $options = array();
    if ($path) {
      $options['query']['destination'] = $path;
    }
    // D6,D7 append a /login. Otherwise identical to D8+.
    return drush_url(user_pass_reset_url($this->account) . '/login', $options);
  }

  function password($pass) {
    user_save($this->account, array('pass' => $pass));
  }

  public function getUsername() {
    return $this->account->name;
  }

  public function id() {
    return $this->account->uid;
  }
}