UserSingle7.php

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

Namespace

Drush\User

Classes

Namesort descending Description
UserSingle7

File

lib/Drush/User/UserSingle7.php
View source
  1. <?php
  2. namespace Drush\User;
  3. class UserSingle7 extends UserSingleBase {
  4. public function block() {
  5. user_user_operations_block(array($this->account->uid));
  6. }
  7. public function unblock() {
  8. user_user_operations_unblock(array($this->account->uid));
  9. }
  10. public function addRole($rid) {
  11. user_multiple_role_edit(array($this->account->uid), 'add_role', $rid);
  12. }
  13. public function removeRole($rid) {
  14. user_multiple_role_edit(array($this->account->uid), 'remove_role', $rid);
  15. }
  16. function info() {
  17. $userinfo = (array)$this->account;
  18. unset($userinfo['data']);
  19. unset($userinfo['block']);
  20. unset($userinfo['form_build_id']);
  21. foreach (array('created', 'access', 'login') as $key) {
  22. $userinfo['user_' . $key] = format_date($userinfo[$key]);
  23. }
  24. $userinfo['user_status'] = $userinfo['status'] ? 'active' : 'blocked';
  25. return $userinfo;
  26. }
  27. public function passResetUrl($path = '') {
  28. $options = array();
  29. if ($path) {
  30. $options['query']['destination'] = $path;
  31. }
  32. // D6,D7 append a /login. Otherwise identical to D8+.
  33. return drush_url(user_pass_reset_url($this->account) . '/login', $options);
  34. }
  35. function password($pass) {
  36. user_save($this->account, array('pass' => $pass));
  37. }
  38. public function getUsername() {
  39. return $this->account->name;
  40. }
  41. public function id() {
  42. return $this->account->uid;
  43. }
  44. }