3 * @file src/Model/User.php
4 * @brief This file includes the User class with user related database functions
6 namespace Friendica\Model;
8 use Friendica\Core\System;
9 use Friendica\Core\Worker;
12 require_once 'boot.php';
13 require_once 'plugin.php';
16 * @brief This class handles User related functions
21 * @param object $uid user to remove
24 public static function remove($uid)
30 logger('Removing user: ' . $uid);
32 $r = dba::select('user', array(), array('uid' => $uid), array("limit" => 1));
34 call_hooks('remove_user', $r);
36 // save username (actually the nickname as it is guaranteed
37 // unique), so it cannot be re-registered in the future.
39 dba::insert('userd', array('username' => $r['nickname']));
41 // The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
42 q("UPDATE `user` SET `account_removed` = 1, `account_expires_on` = UTC_TIMESTAMP() WHERE `uid` = %d", intval($uid));
43 Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
45 // Send an update to the directory
46 Worker::add(PRIORITY_LOW, "Directory", $r['url']);
48 if ($uid == local_user()) {
49 unset($_SESSION['authenticated']);
50 unset($_SESSION['uid']);
51 goaway(System::baseUrl());