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

@ -62,7 +62,7 @@ class Details extends BaseAdmin
$addon = Strings::sanitizeFilePathItem($this->parameters['addon']);
if (!is_file("addon/$addon/$addon.php")) {
notice(DI::l10n()->t('Addon not found.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Addon not found.'));
Addon::uninstall($addon);
DI::baseUrl()->redirect('admin/addons');
}
@ -73,10 +73,10 @@ class Details extends BaseAdmin
// Toggle addon status
if (Addon::isEnabled($addon)) {
Addon::uninstall($addon);
info(DI::l10n()->t('Addon %s disabled.', $addon));
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s disabled.', $addon));
} else {
Addon::install($addon);
info(DI::l10n()->t('Addon %s enabled.', $addon));
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s enabled.', $addon));
}
DI::baseUrl()->redirect('admin/addons/' . $addon);

View file

@ -39,18 +39,18 @@ class Index extends BaseAdmin
switch ($_GET['action']) {
case 'reload':
Addon::reload();
info(DI::l10n()->t('Addons reloaded'));
DI::sysmsg()->addInfo(DI::l10n()->t('Addons reloaded'));
break;
case 'toggle' :
$addon = $_GET['addon'] ?? '';
if (Addon::isEnabled($addon)) {
Addon::uninstall($addon);
info(DI::l10n()->t('Addon %s disabled.', $addon));
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s disabled.', $addon));
} elseif (Addon::install($addon)) {
info(DI::l10n()->t('Addon %s enabled.', $addon));
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s enabled.', $addon));
} else {
notice(DI::l10n()->t('Addon %s failed to install.', $addon));
DI::sysmsg()->addNotice(DI::l10n()->t('Addon %s failed to install.', $addon));
}
break;

View file

@ -46,12 +46,12 @@ class Contact extends BaseAdmin
if (!empty($_POST['page_contactblock_block'])) {
$contact = Model\Contact::getByURL($contact_url, null, ['id', 'nurl']);
if (empty($contact)) {
notice(DI::l10n()->t('Could not find any contact entry for this URL (%s)', $contact_url));
DI::sysmsg()->addNotice(DI::l10n()->t('Could not find any contact entry for this URL (%s)', $contact_url));
DI::baseUrl()->redirect('admin/blocklist/contact');
}
if (Network::isLocalLink($contact['nurl'])) {
notice(DI::l10n()->t('You can\'t block a local contact, please block the user instead'));
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t block a local contact, please block the user instead'));
DI::baseUrl()->redirect('admin/blocklist/contact');
}
@ -63,14 +63,14 @@ class Contact extends BaseAdmin
}
}
info(DI::l10n()->t('The contact has been blocked from the node'));
DI::sysmsg()->addInfo(DI::l10n()->t('The contact has been blocked from the node'));
}
if (!empty($_POST['page_contactblock_unblock'])) {
foreach ($contacts as $uid) {
Model\Contact::unblock($uid);
}
info(DI::l10n()->tt('%s contact unblocked', '%s contacts unblocked', count($contacts)));
DI::sysmsg()->addInfo(DI::l10n()->tt('%s contact unblocked', '%s contacts unblocked', count($contacts)));
}
DI::baseUrl()->redirect('admin/blocklist/contact');

View file

@ -48,7 +48,7 @@ class DBSync extends BaseAdmin
DI::config()->set('system', 'build', intval($curr) + 1);
}
info(DI::l10n()->t('Update has been marked successful'));
DI::sysmsg()->addInfo(DI::l10n()->t('Update has been marked successful'));
}
break;

View file

@ -50,7 +50,7 @@ class Delete extends BaseAdmin
Item::markForDeletion(['guid' => $guid]);
}
info(DI::l10n()->t('Item marked for deletion.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Item marked for deletion.'));
DI::baseUrl()->redirect('admin/item/delete');
}

View file

@ -44,7 +44,7 @@ class Settings extends BaseAdmin
if (is_file($logfile) &&
!is_writeable($logfile)) {
notice(DI::l10n()->t('The logfile \'%s\' is not writable. No logging possible', $logfile));
DI::sysmsg()->addNotice(DI::l10n()->t('The logfile \'%s\' is not writable. No logging possible', $logfile));
return;
}

View file

@ -43,7 +43,7 @@ class Storage extends BaseAdmin
/** @var ICanConfigureStorage|false $newStorageConfig */
$newStorageConfig = DI::storageManager()->getConfigurationByName($storagebackend);
} catch (InvalidClassStorageException $storageException) {
notice(DI::l10n()->t('Storage backend, %s is invalid.', $storagebackend));
DI::sysmsg()->addNotice(DI::l10n()->t('Storage backend, %s is invalid.', $storagebackend));
DI::baseUrl()->redirect('admin/storage');
}
@ -70,7 +70,7 @@ class Storage extends BaseAdmin
$storage_form_errors = $newStorageConfig->saveOptions($storage_opts_data);
if (count($storage_form_errors)) {
foreach ($storage_form_errors as $name => $err) {
notice(DI::l10n()->t('Storage backend %s error: %s', $storage_opts[$name][1], $err));
DI::sysmsg()->addNotice(DI::l10n()->t('Storage backend %s error: %s', $storage_opts[$name][1], $err));
}
DI::baseUrl()->redirect('admin/storage');
}
@ -81,10 +81,10 @@ class Storage extends BaseAdmin
$newstorage = DI::storageManager()->getWritableStorageByName($storagebackend);
if (!DI::storageManager()->setBackend($newstorage)) {
notice(DI::l10n()->t('Invalid storage backend setting value.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Invalid storage backend setting value.'));
}
} catch (InvalidClassStorageException $storageException) {
notice(DI::l10n()->t('Invalid storage backend setting value.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Invalid storage backend setting value.'));
}
}

View file

@ -36,7 +36,7 @@ class Details extends BaseAdmin
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
if (!is_dir("view/theme/$theme")) {
notice(DI::l10n()->t("Item not found."));
DI::sysmsg()->addNotice(DI::l10n()->t("Item not found."));
return '';
}
@ -54,11 +54,11 @@ class Details extends BaseAdmin
if ($isEnabled) {
Theme::uninstall($theme);
info(DI::l10n()->t('Theme %s disabled.', $theme));
DI::sysmsg()->addInfo(DI::l10n()->t('Theme %s disabled.', $theme));
} elseif (Theme::install($theme)) {
info(DI::l10n()->t('Theme %s successfully enabled.', $theme));
DI::sysmsg()->addInfo(DI::l10n()->t('Theme %s successfully enabled.', $theme));
} else {
notice(DI::l10n()->t('Theme %s failed to install.', $theme));
DI::sysmsg()->addNotice(DI::l10n()->t('Theme %s failed to install.', $theme));
}
DI::baseUrl()->redirect('admin/themes/' . $theme);

View file

@ -77,7 +77,7 @@ class Embed extends BaseAdmin
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
if (!is_dir("view/theme/$theme")) {
notice($this->t('Unknown theme.'));
DI::sysmsg()->addNotice($this->t('Unknown theme.'));
return '';
}

View file

@ -48,7 +48,7 @@ class Index extends BaseAdmin
}
Theme::setAllowedList($allowed_themes);
info(DI::l10n()->t('Themes reloaded'));
DI::sysmsg()->addInfo(DI::l10n()->t('Themes reloaded'));
break;
case 'toggle' :
@ -56,17 +56,17 @@ class Index extends BaseAdmin
if ($theme) {
$theme = Strings::sanitizeFilePathItem($theme);
if (!is_dir("view/theme/$theme")) {
notice(DI::l10n()->t('Item not found.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Item not found.'));
return '';
}
if (in_array($theme, Theme::getAllowedList())) {
Theme::uninstall($theme);
info(DI::l10n()->t('Theme %s disabled.', $theme));
DI::sysmsg()->addInfo(DI::l10n()->t('Theme %s disabled.', $theme));
} elseif (Theme::install($theme)) {
info(DI::l10n()->t('Theme %s successfully enabled.', $theme));
DI::sysmsg()->addInfo(DI::l10n()->t('Theme %s successfully enabled.', $theme));
} else {
notice(DI::l10n()->t('Theme %s failed to install.', $theme));
DI::sysmsg()->addNotice(DI::l10n()->t('Theme %s failed to install.', $theme));
}
}

View file

@ -42,7 +42,7 @@ class Active extends BaseUsers
foreach ($users as $uid) {
User::block($uid);
}
info(DI::l10n()->tt('%s user blocked', '%s users blocked', count($users)));
DI::sysmsg()->addInfo(DI::l10n()->tt('%s user blocked', '%s users blocked', count($users)));
}
if (!empty($_POST['page_users_delete'])) {
@ -50,11 +50,11 @@ class Active extends BaseUsers
if (local_user() != $uid) {
User::remove($uid);
} else {
notice(DI::l10n()->t('You can\'t remove yourself'));
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
}
}
info(DI::l10n()->tt('%s user deleted', '%s users deleted', count($users)));
DI::sysmsg()->addInfo(DI::l10n()->tt('%s user deleted', '%s users deleted', count($users)));
}
DI::baseUrl()->redirect(DI::args()->getQueryString());
@ -70,7 +70,7 @@ class Active extends BaseUsers
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);
if (!DBA::isResult($user)) {
notice(DI::l10n()->t('User not found'));
DI::sysmsg()->addNotice(DI::l10n()->t('User not found'));
DI::baseUrl()->redirect('admin/users');
return ''; // NOTREACHED
}
@ -83,9 +83,9 @@ class Active extends BaseUsers
// delete user
User::remove($uid);
notice(DI::l10n()->t('User "%s" deleted', $user['username']));
DI::sysmsg()->addNotice(DI::l10n()->t('User "%s" deleted', $user['username']));
} else {
notice(DI::l10n()->t('You can\'t remove yourself'));
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
}
DI::baseUrl()->redirect('admin/users/active');
@ -93,7 +93,7 @@ class Active extends BaseUsers
case 'block':
self::checkFormSecurityTokenRedirectOnError('admin/users/active', 'admin_users_active', 't');
User::block($uid);
notice(DI::l10n()->t('User "%s" blocked', $user['username']));
DI::sysmsg()->addNotice(DI::l10n()->t('User "%s" blocked', $user['username']));
DI::baseUrl()->redirect('admin/users/active');
break;
}

View file

@ -43,7 +43,7 @@ class Blocked extends BaseUsers
foreach ($users as $uid) {
User::block($uid, false);
}
info(DI::l10n()->tt('%s user unblocked', '%s users unblocked', count($users)));
DI::sysmsg()->addInfo(DI::l10n()->tt('%s user unblocked', '%s users unblocked', count($users)));
}
if (!empty($_POST['page_users_delete'])) {
@ -51,11 +51,11 @@ class Blocked extends BaseUsers
if (local_user() != $uid) {
User::remove($uid);
} else {
notice(DI::l10n()->t('You can\'t remove yourself'));
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
}
}
info(DI::l10n()->tt('%s user deleted', '%s users deleted', count($users)));
DI::sysmsg()->addInfo(DI::l10n()->tt('%s user deleted', '%s users deleted', count($users)));
}
DI::baseUrl()->redirect('admin/users/blocked');
@ -71,7 +71,7 @@ class Blocked extends BaseUsers
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);
if (!DBA::isResult($user)) {
notice(DI::l10n()->t('User not found'));
DI::sysmsg()->addNotice(DI::l10n()->t('User not found'));
DI::baseUrl()->redirect('admin/users');
return ''; // NOTREACHED
}
@ -84,16 +84,16 @@ class Blocked extends BaseUsers
// delete user
User::remove($uid);
notice(DI::l10n()->t('User "%s" deleted', $user['username']));
DI::sysmsg()->addNotice(DI::l10n()->t('User "%s" deleted', $user['username']));
} else {
notice(DI::l10n()->t('You can\'t remove yourself'));
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
}
DI::baseUrl()->redirect('admin/users/blocked');
break;
case 'unblock':
self::checkFormSecurityTokenRedirectOnError('/admin/users/blocked', 'admin_users_blocked', 't');
User::block($uid, false);
notice(DI::l10n()->t('User "%s" unblocked', $user['username']));
DI::sysmsg()->addNotice(DI::l10n()->t('User "%s" unblocked', $user['username']));
DI::baseUrl()->redirect('admin/users/blocked');
break;
}

View file

@ -44,7 +44,7 @@ class Create extends BaseUsers
User::createMinimal($nu_name, $nu_email, $nu_nickname, $nu_language);
DI::baseUrl()->redirect('admin/users');
} catch (\Exception $ex) {
notice($ex->getMessage());
DI::sysmsg()->addNotice($ex->getMessage());
}
}

View file

@ -42,14 +42,14 @@ class Index extends BaseUsers
foreach ($users as $uid) {
User::block($uid);
}
info(DI::l10n()->tt('%s user blocked', '%s users blocked', count($users)));
DI::sysmsg()->addInfo(DI::l10n()->tt('%s user blocked', '%s users blocked', count($users)));
}
if (!empty($_POST['page_users_unblock'])) {
foreach ($users as $uid) {
User::block($uid, false);
}
info(DI::l10n()->tt('%s user unblocked', '%s users unblocked', count($users)));
DI::sysmsg()->addInfo(DI::l10n()->tt('%s user unblocked', '%s users unblocked', count($users)));
}
if (!empty($_POST['page_users_delete'])) {
@ -57,11 +57,11 @@ class Index extends BaseUsers
if (local_user() != $uid) {
User::remove($uid);
} else {
notice(DI::l10n()->t('You can\'t remove yourself'));
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
}
}
info(DI::l10n()->tt('%s user deleted', '%s users deleted', count($users)));
DI::sysmsg()->addInfo(DI::l10n()->tt('%s user deleted', '%s users deleted', count($users)));
}
DI::baseUrl()->redirect(DI::args()->getQueryString());
@ -77,7 +77,7 @@ class Index extends BaseUsers
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);
if (!DBA::isResult($user)) {
notice(DI::l10n()->t('User not found'));
DI::sysmsg()->addNotice(DI::l10n()->t('User not found'));
DI::baseUrl()->redirect('admin/users');
return ''; // NOTREACHED
}
@ -90,9 +90,9 @@ class Index extends BaseUsers
// delete user
User::remove($uid);
notice(DI::l10n()->t('User "%s" deleted', $user['username']));
DI::sysmsg()->addNotice(DI::l10n()->t('User "%s" deleted', $user['username']));
} else {
notice(DI::l10n()->t('You can\'t remove yourself'));
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
}
DI::baseUrl()->redirect('admin/users');
@ -100,13 +100,13 @@ class Index extends BaseUsers
case 'block':
self::checkFormSecurityTokenRedirectOnError('admin/users', 'admin_users', 't');
User::block($uid);
notice(DI::l10n()->t('User "%s" blocked', $user['username']));
DI::sysmsg()->addNotice(DI::l10n()->t('User "%s" blocked', $user['username']));
DI::baseUrl()->redirect('admin/users');
break;
case 'unblock':
self::checkFormSecurityTokenRedirectOnError('admin/users', 'admin_users', 't');
User::block($uid, false);
notice(DI::l10n()->t('User "%s" unblocked', $user['username']));
DI::sysmsg()->addNotice(DI::l10n()->t('User "%s" unblocked', $user['username']));
DI::baseUrl()->redirect('admin/users');
break;
}

View file

@ -45,14 +45,14 @@ class Pending extends BaseUsers
foreach ($pending as $hash) {
User::allow($hash);
}
info(DI::l10n()->tt('%s user approved', '%s users approved', count($pending)));
DI::sysmsg()->addInfo(DI::l10n()->tt('%s user approved', '%s users approved', count($pending)));
}
if (!empty($_POST['page_users_deny'])) {
foreach ($pending as $hash) {
User::deny($hash);
}
info(DI::l10n()->tt('%s registration revoked', '%s registrations revoked', count($pending)));
DI::sysmsg()->addInfo(DI::l10n()->tt('%s registration revoked', '%s registrations revoked', count($pending)));
}
DI::baseUrl()->redirect('admin/users/pending');
@ -68,7 +68,7 @@ class Pending extends BaseUsers
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);
if (!DBA::isResult($user)) {
notice(DI::l10n()->t('User not found'));
DI::sysmsg()->addNotice(DI::l10n()->t('User not found'));
DI::baseUrl()->redirect('admin/users');
return ''; // NOTREACHED
}
@ -78,13 +78,13 @@ class Pending extends BaseUsers
case 'allow':
self::checkFormSecurityTokenRedirectOnError('/admin/users/pending', 'admin_users_pending', 't');
User::allow(Register::getPendingForUser($uid)['hash'] ?? '');
notice(DI::l10n()->t('Account approved.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Account approved.'));
DI::baseUrl()->redirect('admin/users/pending');
break;
case 'deny':
self::checkFormSecurityTokenRedirectOnError('/admin/users/pending', 'admin_users_pending', 't');
User::deny(Register::getPendingForUser($uid)['hash'] ?? '');
notice(DI::l10n()->t('Registration revoked'));
DI::sysmsg()->addNotice(DI::l10n()->t('Registration revoked'));
DI::baseUrl()->redirect('admin/users/pending');
break;
}