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