X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FUser.php;h=af7a81a15dccc4a2ad22879d68beae7cb5eea192;hb=f2c1ecd19bb344137a91faab58d9a2524e0c8893;hp=854961154b5dfe56772dc11c70c7d4314a1eaae0;hpb=d2b02d07b43ff43cc2f3875f6ddb16f76f525bc2;p=friendica.git diff --git a/src/Model/User.php b/src/Model/User.php index 854961154b..af7a81a15d 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -37,6 +37,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Module; use Friendica\Network\HTTPClient\Client\HttpClientAccept; +use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Security\TwoFactor\Model\AppSpecificPassword; use Friendica\Network\HTTPException; use Friendica\Object\Image; @@ -132,6 +133,17 @@ class User return null; } + /** + * Get the Uri-Id of the system account + * + * @return integer + */ + public static function getSystemUriId(): int + { + $system = self::getSystemAccount(); + return $system['uri-id'] ?? 0; + } + /** * Fetch the system account * @@ -869,6 +881,20 @@ class User ]); } + /** + * Returns if the given uid is valid and a moderator + * + * @param int $uid + * + * @return bool + * @throws Exception + */ + public static function isModerator(int $uid): bool + { + // @todo Replace with a moderator check in the future + return self::isSiteAdmin($uid); + } + /** * Checks if a nickname is in the list of the forbidden nicknames * @@ -1303,33 +1329,18 @@ class User /** * Update a user entry and distribute the changes if needed * - * @param array $fields + * @param array $fields * @param integer $uid * @return boolean + * @throws Exception */ public static function update(array $fields, int $uid): bool { - $old_owner = self::getOwnerDataById($uid); - if (empty($old_owner)) { - return false; - } - if (!DBA::update('user', $fields, ['uid' => $uid])) { return false; } - $update = Contact::updateSelfFromUserID($uid); - - $owner = self::getOwnerDataById($uid); - if (empty($owner)) { - return false; - } - - if ($old_owner['name'] != $owner['name']) { - Profile::update(['name' => $owner['name']], $uid); - } - - if ($update) { + if (Contact::updateSelfFromUserID($uid)) { Profile::publishUpdate($uid); }