Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3 KiB

  1. <?php
  2. /**
  3. * @file src/Model/User.php
  4. * @brief This file includes the User class with user related database functions
  5. */
  6. namespace Friendica\Model;
  7. use Friendica\Core\System;
  8. use Friendica\Core\Worker;
  9. use dba;
  10. require_once 'boot.php';
  11. require_once 'plugin.php';
  12. /**
  13. * @brief This class handles User related functions
  14. */
  15. class User
  16. {
  17. /**
  18. * @param object $uid user to remove
  19. * @return void
  20. */
  21. public static function remove($uid)
  22. {
  23. if (!$uid) {
  24. return;
  25. }
  26. logger('Removing user: ' . $uid);
  27. $r = dba::select('user', array(), array('uid' => $uid), array("limit" => 1));
  28. call_hooks('remove_user', $r);
  29. // save username (actually the nickname as it is guaranteed
  30. // unique), so it cannot be re-registered in the future.
  31. dba::insert('userd', array('username' => $r['nickname']));
  32. // The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
  33. q("UPDATE `user` SET `account_removed` = 1, `account_expires_on` = UTC_TIMESTAMP() WHERE `uid` = %d", intval($uid));
  34. Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
  35. // Send an update to the directory
  36. Worker::add(PRIORITY_LOW, "Directory", $r['url']);
  37. if ($uid == local_user()) {
  38. unset($_SESSION['authenticated']);
  39. unset($_SESSION['uid']);
  40. goaway(System::baseUrl());
  41. }
  42. }
  43. }