The notice and info have been moved

This commit is contained in:
Michael 2022-10-17 18:55:22 +00:00
parent 20291ddc2b
commit fdfa1f8630
73 changed files with 273 additions and 284 deletions

View file

@ -75,10 +75,10 @@ class Account extends BaseSettings
throw new Exception(DI::l10n()->t('Password update failed. Please try again.'));
}
info(DI::l10n()->t('Password changed.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Password changed.'));
} catch (Exception $e) {
notice($e->getMessage());
notice(DI::l10n()->t('Password unchanged.'));
DI::sysmsg()->addNotice($e->getMessage());
DI::sysmsg()->addNotice(DI::l10n()->t('Password unchanged.'));
}
DI::baseUrl()->redirect($redirectUrl);
@ -123,7 +123,7 @@ class Account extends BaseSettings
}
if (strlen($err)) {
notice($err);
DI::sysmsg()->addNotice($err);
return;
}
@ -146,7 +146,7 @@ class Account extends BaseSettings
}
if (!User::update($fields, local_user())) {
notice(DI::l10n()->t('Settings were not updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
// clear session language
@ -198,7 +198,7 @@ class Account extends BaseSettings
];
if (!User::update($fields, local_user()) || !Profile::update($profile_fields, local_user())) {
notice(DI::l10n()->t('Settings were not updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
DI::baseUrl()->redirect($redirectUrl);
@ -218,7 +218,7 @@ class Account extends BaseSettings
DI::pConfig()->set(local_user(), 'expire', 'network_only', $expire_network_only);
if (!User::update(['expire' => $expire], local_user())) {
notice(DI::l10n()->t('Settings were not updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
DI::baseUrl()->redirect($redirectUrl);
@ -302,7 +302,7 @@ class Account extends BaseSettings
];
if (!User::update($fields, local_user())) {
notice(DI::l10n()->t('Settings were not updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
DI::baseUrl()->redirect($redirectUrl);
@ -351,7 +351,7 @@ class Account extends BaseSettings
]);
if (!User::update($fields, local_user()) || !empty($profile_fields) && !Profile::update($profile_fields, local_user())) {
notice(DI::l10n()->t('Settings were not updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
DI::baseUrl()->redirect($redirectUrl);
@ -363,7 +363,7 @@ class Account extends BaseSettings
// was there an error
if ($_FILES['importcontact-filename']['error'] > 0) {
Logger::notice('Contact CSV file upload error', ['error' => $_FILES['importcontact-filename']['error']]);
notice(DI::l10n()->t('Contact CSV file upload error'));
DI::sysmsg()->addNotice(DI::l10n()->t('Contact CSV file upload error'));
} else {
$csvArray = array_map('str_getcsv', file($_FILES['importcontact-filename']['tmp_name']));
Logger::notice('Import started', ['lines' => count($csvArray)]);
@ -382,7 +382,7 @@ class Account extends BaseSettings
}
Logger::notice('Import done');
info(DI::l10n()->t('Importing Contacts done'));
DI::sysmsg()->addInfo(DI::l10n()->t('Importing Contacts done'));
// delete temp file
unlink($_FILES['importcontact-filename']['tmp_name']);
}
@ -395,7 +395,7 @@ class Account extends BaseSettings
if (!empty($request['relocate-submit'])) {
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
info(DI::l10n()->t("Relocate message has been send to your contacts"));
DI::sysmsg()->addInfo(DI::l10n()->t("Relocate message has been send to your contacts"));
DI::baseUrl()->redirect($redirectUrl);
}
@ -412,7 +412,7 @@ class Account extends BaseSettings
$profile = DBA::selectFirst('profile', [], ['uid' => local_user()]);
if (!DBA::isResult($profile)) {
notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
return '';
}

View file

@ -50,13 +50,13 @@ class Delegation extends BaseSettings
if ($parent_uid != 0) {
try {
User::getIdFromPasswordAuthentication($parent_uid, $parent_password);
info(DI::l10n()->t('Delegation successfully granted.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Delegation successfully granted.'));
} catch (\Exception $ex) {
notice(DI::l10n()->t('Parent user not found, unavailable or password doesn\'t match.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Parent user not found, unavailable or password doesn\'t match.'));
return;
}
} else {
info(DI::l10n()->t('Delegation successfully revoked.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Delegation successfully revoked.'));
}
DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => local_user()]);
@ -78,7 +78,7 @@ class Delegation extends BaseSettings
if ($action === 'add' && $user_id) {
if (Session::get('submanage')) {
notice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.'));
DI::baseUrl()->redirect('settings/delegation');
}
@ -92,7 +92,7 @@ class Delegation extends BaseSettings
DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
}
} else {
notice(DI::l10n()->t('Delegate user not found.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Delegate user not found.'));
}
DI::baseUrl()->redirect('settings/delegation');
@ -100,7 +100,7 @@ class Delegation extends BaseSettings
if ($action === 'remove' && $user_id) {
if (Session::get('submanage')) {
notice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.'));
DI::baseUrl()->redirect('settings/delegation');
}

View file

@ -104,7 +104,7 @@ class Display extends BaseSettings
DBA::update('user', ['theme' => $theme], ['uid' => local_user()]);
}
} else {
notice(DI::l10n()->t('The theme you chose isn\'t available.'));
DI::sysmsg()->addNotice(DI::l10n()->t('The theme you chose isn\'t available.'));
}
Hook::callAll('display_settings_post', $_POST);

View file

@ -80,7 +80,7 @@ class Index extends BaseSettings
$name = trim($_POST['name'] ?? '');
if (!strlen($name)) {
notice(DI::l10n()->t('Profile Name is required.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Profile Name is required.'));
return;
}
@ -128,7 +128,7 @@ class Index extends BaseSettings
);
if (!$result) {
notice(DI::l10n()->t('Profile couldn\'t be updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Profile couldn\'t be updated.'));
return;
}
@ -138,7 +138,7 @@ class Index extends BaseSettings
protected function content(array $request = []): string
{
if (!local_user()) {
notice(DI::l10n()->t('You must be logged in to use this module'));
DI::sysmsg()->addNotice(DI::l10n()->t('You must be logged in to use this module'));
return Login::form();
}

View file

@ -105,7 +105,7 @@ class Crop extends BaseSettings
Photo::USER_AVATAR
);
if ($r === false) {
notice(DI::l10n()->t('Image size reduction [%s] failed.', '300'));
DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', '300'));
} else {
Photo::update(['profile' => true], array_merge($condition, ['scale' => 4]));
}
@ -123,7 +123,7 @@ class Crop extends BaseSettings
Photo::USER_AVATAR
);
if ($r === false) {
notice(DI::l10n()->t('Image size reduction [%s] failed.', '80'));
DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', '80'));
} else {
Photo::update(['profile' => true], array_merge($condition, ['scale' => 5]));
}
@ -141,19 +141,19 @@ class Crop extends BaseSettings
Photo::USER_AVATAR
);
if ($r === false) {
notice(DI::l10n()->t('Image size reduction [%s] failed.', '48'));
DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', '48'));
} else {
Photo::update(['profile' => true], array_merge($condition, ['scale' => 6]));
}
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.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Shift-reload the page or clear browser cache if the new photo does not display immediately.'));
// Update global directory in background
Profile::publishUpdate(local_user());
} else {
notice(DI::l10n()->t('Unable to process image'));
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image'));
}
}
@ -194,7 +194,7 @@ class Crop extends BaseSettings
// Update global directory in background
Profile::publishUpdate(local_user());
info(DI::l10n()->t('Profile picture successfully updated.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Profile picture successfully updated.'));
DI::baseUrl()->redirect('profile/' . DI::app()->getLoggedInUserNickname());
}

View file

@ -43,7 +43,7 @@ class Index extends BaseSettings
self::checkFormSecurityTokenRedirectOnError('/settings/profile/photo', 'settings_profile_photo');
if (empty($_FILES['userfile'])) {
notice(DI::l10n()->t('Missing uploaded image.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Missing uploaded image.'));
return;
}
@ -57,7 +57,7 @@ class Index extends BaseSettings
$maximagesize = DI::config()->get('system', 'maximagesize', 0);
if ($maximagesize && $filesize > $maximagesize) {
notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)));
DI::sysmsg()->addNotice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)));
@unlink($src);
return;
}
@ -66,7 +66,7 @@ class Index extends BaseSettings
$Image = new Image($imagedata, $filetype);
if (!$Image->isValid()) {
notice(DI::l10n()->t('Unable to process image.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image.'));
@unlink($src);
return;
}
@ -93,13 +93,13 @@ class Index extends BaseSettings
$filename = '';
if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) {
notice(DI::l10n()->t('Image upload failed.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.'));
}
if ($width > 640 || $height > 640) {
$Image->scaleDown(640);
if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) {
notice(DI::l10n()->t('Image size reduction [%s] failed.', '640'));
DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', '640'));
}
}

View file

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
use Friendica\Module\BaseSettings;
@ -61,7 +62,7 @@ class AppSpecific extends BaseSettings
}
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
notice($this->t('Please enter your password to access this page.'));
DI::sysmsg()->addNotice($this->t('Please enter your password to access this page.'));
$this->baseUrl->redirect('settings/2fa');
}
}
@ -79,20 +80,20 @@ class AppSpecific extends BaseSettings
case 'generate':
$description = $_POST['description'] ?? '';
if (empty($description)) {
notice($this->t('App-specific password generation failed: The description is empty.'));
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: The description is empty.'));
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
} elseif (AppSpecificPassword::checkDuplicateForUser(local_user(), $description)) {
notice($this->t('App-specific password generation failed: This description already exists.'));
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: This description already exists.'));
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
} else {
$this->appSpecificPassword = AppSpecificPassword::generateForUser(local_user(), $_POST['description'] ?? '');
info($this->t('New app-specific password generated.'));
DI::sysmsg()->addInfo($this->t('New app-specific password generated.'));
}
break;
case 'revoke_all' :
AppSpecificPassword::deleteAllForUser(local_user());
info($this->t('App-specific passwords successfully revoked.'));
DI::sysmsg()->addInfo($this->t('App-specific passwords successfully revoked.'));
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
break;
}
@ -102,7 +103,7 @@ class AppSpecific extends BaseSettings
self::checkFormSecurityTokenRedirectOnError('settings/2fa/app_specific', 'settings_2fa_app_specific');
if (AppSpecificPassword::deleteForUser(local_user(), $_POST['revoke_id'])) {
info($this->t('App-specific password successfully revoked.'));
DI::sysmsg()->addInfo($this->t('App-specific password successfully revoked.'));
}
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));

View file

@ -66,7 +66,7 @@ class Index extends BaseSettings
DI::pConfig()->delete(local_user(), '2fa', 'verified');
Session::remove('2fa');
info(DI::l10n()->t('Two-factor authentication successfully disabled.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Two-factor authentication successfully disabled.'));
DI::baseUrl()->redirect('settings/2fa');
}
break;
@ -98,7 +98,7 @@ class Index extends BaseSettings
} catch (FoundException $exception) {
// Nothing to do here
} catch (\Exception $e) {
notice(DI::l10n()->t($e->getMessage()));
DI::sysmsg()->addNotice(DI::l10n()->t($e->getMessage()));
}
}

View file

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Security\TwoFactor\Model\RecoveryCode;
use Friendica\Module\BaseSettings;
@ -59,7 +60,7 @@ class Recovery extends BaseSettings
}
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
notice($this->t('Please enter your password to access this page.'));
DI::sysmsg()->addNotice($this->t('Please enter your password to access this page.'));
$this->baseUrl->redirect('settings/2fa');
}
}
@ -75,7 +76,7 @@ class Recovery extends BaseSettings
if ($_POST['action'] == 'regenerate') {
RecoveryCode::regenerateForUser(local_user());
info($this->t('New recovery codes successfully generated.'));
DI::sysmsg()->addInfo($this->t('New recovery codes successfully generated.'));
$this->baseUrl->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
}
}

View file

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseSettings;
use Friendica\Module\Response;
use Friendica\Security\TwoFactor;
@ -62,7 +63,7 @@ class Trusted extends BaseSettings
}
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
notice($this->t('Please enter your password to access this page.'));
DI::sysmsg()->addNotice($this->t('Please enter your password to access this page.'));
$this->baseUrl->redirect('settings/2fa');
}
}
@ -79,7 +80,7 @@ class Trusted extends BaseSettings
switch ($_POST['action']) {
case 'remove_all':
$this->trustedBrowserRepo->removeAllForUser(local_user());
info($this->t('Trusted browsers successfully removed.'));
DI::sysmsg()->addInfo($this->t('Trusted browsers successfully removed.'));
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
break;
}
@ -89,7 +90,7 @@ class Trusted extends BaseSettings
self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted');
if ($this->trustedBrowserRepo->removeForUser(local_user(), $_POST['remove_id'])) {
info($this->t('Trusted browser successfully removed.'));
DI::sysmsg()->addInfo($this->t('Trusted browser successfully removed.'));
}
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));

View file

@ -30,6 +30,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\BaseSettings;
use Friendica\Module\Response;
use Friendica\Module\Security\Login;
@ -65,7 +66,7 @@ class Verify extends BaseSettings
}
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
notice($this->t('Please enter your password to access this page.'));
DI::sysmsg()->addNotice($this->t('Please enter your password to access this page.'));
$this->baseUrl->redirect('settings/2fa');
}
}
@ -87,11 +88,11 @@ class Verify extends BaseSettings
$this->pConfig->set(local_user(), '2fa', 'verified', true);
Session::set('2fa', true);
info($this->t('Two-factor authentication successfully activated.'));
DI::sysmsg()->addInfo($this->t('Two-factor authentication successfully activated.'));
$this->baseUrl->redirect('settings/2fa');
} else {
notice($this->t('Invalid code, please retry.'));
DI::sysmsg()->addNotice($this->t('Invalid code, please retry.'));
}
}
}