mirror of
https://github.com/friendica/friendica
synced 2025-04-24 09:50:11 +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
|
@ -86,8 +86,6 @@ class Index extends BaseSettings
|
|||
return;
|
||||
}
|
||||
|
||||
$namechanged = $profile['name'] != $name;
|
||||
|
||||
$about = Strings::escapeTags(trim($_POST['about']));
|
||||
$address = Strings::escapeTags(trim($_POST['address']));
|
||||
$locality = Strings::escapeTags(trim($_POST['locality']));
|
||||
|
@ -114,8 +112,7 @@ class Index extends BaseSettings
|
|||
|
||||
DI::profileField()->saveCollection($profileFields);
|
||||
|
||||
$result = DBA::update(
|
||||
'profile',
|
||||
$result = Profile::update(
|
||||
[
|
||||
'name' => $name,
|
||||
'about' => $about,
|
||||
|
@ -130,26 +127,13 @@ class Index extends BaseSettings
|
|||
'pub_keywords' => $pub_keywords,
|
||||
'prv_keywords' => $prv_keywords,
|
||||
],
|
||||
['uid' => local_user()]
|
||||
local_user()
|
||||
);
|
||||
|
||||
if (!$result) {
|
||||
notice(DI::l10n()->t('Profile couldn\'t be updated.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($namechanged) {
|
||||
DBA::update('user', ['username' => $name], ['uid' => local_user()]);
|
||||
}
|
||||
|
||||
Contact::updateSelfFromUserID(local_user());
|
||||
|
||||
// Update global directory in background
|
||||
if (Session::get('my_url') && strlen(DI::config()->get('system', 'directory'))) {
|
||||
Worker::add(PRIORITY_LOW, 'Directory', Session::get('my_url'));
|
||||
}
|
||||
|
||||
Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
|
||||
}
|
||||
|
||||
public static function content(array $parameters = [])
|
||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Module\BaseSettings;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
|
@ -137,12 +138,9 @@ class Crop extends BaseSettings
|
|||
Contact::updateSelfFromUserID(local_user(), true);
|
||||
|
||||
info(DI::l10n()->t('Shift-reload the page or clear browser cache if the new photo does not display immediately.'));
|
||||
// Update global directory in background
|
||||
if ($path && strlen(DI::config()->get('system', 'directory'))) {
|
||||
Worker::add(PRIORITY_LOW, 'Directory', DI::baseUrl()->get() . '/' . $path);
|
||||
}
|
||||
|
||||
Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
|
||||
// Update global directory in background
|
||||
Profile::publishUpdate(local_user());
|
||||
} else {
|
||||
notice(DI::l10n()->t('Unable to process image'));
|
||||
}
|
||||
|
@ -183,9 +181,7 @@ class Crop extends BaseSettings
|
|||
Contact::updateSelfFromUserID(local_user(), true);
|
||||
|
||||
// Update global directory in background
|
||||
if (Session::get('my_url') && strlen(DI::config()->get('system', 'directory'))) {
|
||||
Worker::add(PRIORITY_LOW, 'Directory', Session::get('my_url'));
|
||||
}
|
||||
Profile::publishUpdate(local_user());
|
||||
|
||||
info(DI::l10n()->t('Profile picture successfully updated.'));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue