mirror of
https://github.com/friendica/friendica
synced 2025-04-26 07:50:15 +00:00
Centzralized functionality to update and publish profile changes
This commit is contained in:
parent
c9ec2e21b3
commit
0ab24510ef
8 changed files with 125 additions and 69 deletions
|
@ -1133,6 +1133,42 @@ class User
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a user entry and distribute the changes if needed
|
||||
*
|
||||
* @param array $fields
|
||||
* @param integer $uid
|
||||
* @return boolean
|
||||
*/
|
||||
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) {
|
||||
Profile::publishUpdate($uid);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets block state for a given user
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue