X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FUser.php;h=278b541fa897222f24fd45165aa92aae15a2e93e;hb=531ef6e6e2a7c5968036ce1e7b8a0caaca7accea;hp=03ddb4605b8f96d02e38f3b4e9822562dc15c132;hpb=1acc5ffb38cbd0b109f0c36f6c87eb41c8b38c5f;p=friendica.git diff --git a/src/Model/User.php b/src/Model/User.php index 03ddb4605b..278b541fa8 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -34,13 +34,14 @@ use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; -use Friendica\Model\TwoFactor\AppSpecificPassword; +use Friendica\Security\TwoFactor\Model\AppSpecificPassword; use Friendica\Network\HTTPException; use Friendica\Object\Image; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; use Friendica\Util\Network; +use Friendica\Util\Proxy; use Friendica\Util\Strings; use Friendica\Worker\Delivery; use ImagickException; @@ -96,6 +97,7 @@ class User const ACCOUNT_TYPE_NEWS = 2; const ACCOUNT_TYPE_COMMUNITY = 3; const ACCOUNT_TYPE_RELAY = 4; + const ACCOUNT_TYPE_DELETED = 127; /** * @} */ @@ -192,11 +194,12 @@ class User $system['name'] = 'System Account'; $system['addr'] = $system_actor_name . '@' . DI::baseUrl()->getHostname(); $system['nick'] = $system_actor_name; - $system['avatar'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO; - $system['photo'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO; - $system['thumb'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_THUMB; - $system['micro'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_MICRO; $system['url'] = DI::baseUrl() . '/friendica'; + + $system['avatar'] = $system['photo'] = Contact::getDefaultAvatar($system, Proxy::SIZE_SMALL); + $system['thumb'] = Contact::getDefaultAvatar($system, Proxy::SIZE_THUMB); + $system['micro'] = Contact::getDefaultAvatar($system, Proxy::SIZE_MICRO); + $system['nurl'] = Strings::normaliseLink($system['url']); $system['pubkey'] = $keys['pubkey']; $system['prvkey'] = $keys['prvkey']; @@ -368,12 +371,12 @@ class User /** * Get owner data by user id * - * @param int $uid - * @param boolean $check_valid Test if data is invalid and correct it + * @param int $uid + * @param boolean $repairMissing Repair the owner data if it's missing * @return boolean|array * @throws Exception */ - public static function getOwnerDataById(int $uid, bool $check_valid = true) + public static function getOwnerDataById(int $uid, bool $repairMissing = true) { if ($uid == 0) { return self::getSystemAccount(); @@ -385,7 +388,7 @@ class User $owner = DBA::selectFirst('owner-view', [], ['uid' => $uid]); if (!DBA::isResult($owner)) { - if (!DBA::exists('user', ['uid' => $uid]) || !$check_valid) { + if (!DBA::exists('user', ['uid' => $uid]) || !$repairMissing) { return false; } Contact::createSelfFromUserId($uid); @@ -396,7 +399,7 @@ class User return false; } - if (!$check_valid) { + if (!$repairMissing || $owner['account_expired']) { return $owner; } @@ -1156,6 +1159,9 @@ class User return false; } + // Delete the avatar + Photo::delete(['uid' => $register['uid']]); + return DBA::delete('user', ['uid' => $register['uid']]) && Register::deleteByHash($register['hash']); } @@ -1347,7 +1353,7 @@ class User */ public static function remove(int $uid) { - if (!$uid) { + if (empty($uid)) { return false; } @@ -1361,6 +1367,9 @@ class User // unique), so it cannot be re-registered in the future. DBA::insert('userd', ['username' => $user['nickname']]); + // Remove all personal settings, especially connector settings + DBA::delete('pconfig', ['uid' => $uid]); + // The user and related data will be deleted in Friendica\Worker\ExpireAndRemoveUsers DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utc('now + 7 day')], ['uid' => $uid]); Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::REMOVAL, $uid);