diff --git a/boot.php b/boot.php index 6336c2e41..24486f413 100644 --- a/boot.php +++ b/boot.php @@ -126,33 +126,3 @@ function remote_user() return false; } - -/** - * Show an error message to user. - * - * This function save text in session, to be shown to the user at next page load - * - * @param string $s - Text of notice - * - * @return void - * @deprecated since version 2022.09, use \Friendica\Navigation\SystemMessages instead - */ -function notice(string $s) -{ - \Friendica\DI::sysmsg()->addNotice($s); -} - -/** - * Show an info message to user. - * - * This function save text in session, to be shown to the user at next page load - * - * @param string $s - Text of notice - * - * @return void - * @deprecated since version 2022.09, use \Friendica\Navigation\SystemMessages instead - */ -function info(string $s) -{ - \Friendica\DI::sysmsg()->addInfo($s); -} diff --git a/mod/cal.php b/mod/cal.php index 3f249da0a..ec6df1f16 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -119,7 +119,7 @@ function cal_content(App $a) $is_owner = local_user() == $owner['uid']; if ($owner['hidewall'] && !$is_owner && !$remote_contact) { - notice(DI::l10n()->t('Access to this profile has been restricted.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Access to this profile has been restricted.')); return; } @@ -262,7 +262,7 @@ function cal_content(App $a) if ($mode == 'export') { if (!$owner_uid) { - notice(DI::l10n()->t('User not found')); + DI::sysmsg()->addNotice(DI::l10n()->t('User not found')); return; } @@ -271,9 +271,9 @@ function cal_content(App $a) if (!$evexport["success"]) { if ($evexport["content"]) { - notice(DI::l10n()->t('This calendar format is not supported')); + DI::sysmsg()->addNotice(DI::l10n()->t('This calendar format is not supported')); } else { - notice(DI::l10n()->t('No exportable data found')); + DI::sysmsg()->addNotice(DI::l10n()->t('No exportable data found')); } // If it the own calendar return to the events page diff --git a/mod/editpost.php b/mod/editpost.php index 3fb8c80ec..8d2160fde 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -35,14 +35,14 @@ function editpost_content(App $a) $o = ''; if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } $post_id = ((DI::args()->getArgc() > 1) ? intval(DI::args()->getArgv()[1]) : 0); if (!$post_id) { - notice(DI::l10n()->t('Item not found')); + DI::sysmsg()->addNotice(DI::l10n()->t('Item not found')); return; } @@ -52,7 +52,7 @@ function editpost_content(App $a) $item = Post::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]); if (!DBA::isResult($item)) { - notice(DI::l10n()->t('Item not found')); + DI::sysmsg()->addNotice(DI::l10n()->t('Item not found')); return; } diff --git a/mod/events.php b/mod/events.php index eead66c01..f1d8a7ca6 100644 --- a/mod/events.php +++ b/mod/events.php @@ -121,7 +121,7 @@ function events_post(App $a) $onerror_path = 'events/' . $action . '?' . http_build_query($params, '', '&', PHP_QUERY_RFC3986); if (strcmp($finish, $start) < 0 && !$nofinish) { - notice(DI::l10n()->t('Event can not end before it has started.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Event can not end before it has started.')); if (intval($_REQUEST['preview'])) { System::httpExit(DI::l10n()->t('Event can not end before it has started.')); } @@ -129,7 +129,7 @@ function events_post(App $a) } if (!$summary || ($start === DBA::NULL_DATETIME)) { - notice(DI::l10n()->t('Event title and start time are required.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Event title and start time are required.')); if (intval($_REQUEST['preview'])) { System::httpExit(DI::l10n()->t('Event title and start time are required.')); } @@ -214,7 +214,7 @@ function events_post(App $a) function events_content(App $a) { if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return Login::form(); } @@ -531,7 +531,7 @@ function events_content(App $a) } if (Post::exists(['id' => $ev[0]['itemid']])) { - notice(DI::l10n()->t('Failed to remove event')); + DI::sysmsg()->addNotice(DI::l10n()->t('Failed to remove event')); } DI::baseUrl()->redirect('events'); diff --git a/mod/follow.php b/mod/follow.php index 818a1ae5e..b6ffe2ef0 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -53,7 +53,7 @@ function follow_content(App $a) $return_path = 'contact'; if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::baseUrl()->redirect($return_path); // NOTREACHED } @@ -81,7 +81,7 @@ function follow_content(App $a) if (DBA::isResult($user_contact)) { if ($user_contact['pending']) { - notice(DI::l10n()->t('You already added this contact.')); + DI::sysmsg()->addNotice(DI::l10n()->t('You already added this contact.')); $submit = ''; } } @@ -97,7 +97,7 @@ function follow_content(App $a) // Possibly it is a remote item and not an account follow_remote_item($url); - notice(DI::l10n()->t("The network type couldn't be detected. Contact can't be added.")); + DI::sysmsg()->addNotice(DI::l10n()->t("The network type couldn't be detected. Contact can't be added.")); $submit = ''; $contact = ['url' => $url, 'network' => Protocol::PHANTOM, 'name' => $url, 'keywords' => '']; } @@ -105,12 +105,12 @@ function follow_content(App $a) $protocol = Contact::getProtocol($contact['url'], $contact['network']); if (($protocol == Protocol::DIASPORA) && !DI::config()->get('system', 'diaspora_enabled')) { - notice(DI::l10n()->t("Diaspora support isn't enabled. Contact can't be added.")); + DI::sysmsg()->addNotice(DI::l10n()->t("Diaspora support isn't enabled. Contact can't be added.")); $submit = ''; } if (($protocol == Protocol::OSTATUS) && DI::config()->get('system', 'ostatus_disabled')) { - notice(DI::l10n()->t("OStatus support is disabled. Contact can't be added.")); + DI::sysmsg()->addNotice(DI::l10n()->t("OStatus support is disabled. Contact can't be added.")); $submit = ''; } @@ -127,7 +127,7 @@ function follow_content(App $a) $owner = User::getOwnerDataById($uid); if (empty($owner)) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::baseUrl()->redirect($return_path); // NOTREACHED } @@ -181,14 +181,14 @@ function follow_process(App $a, string $url) follow_remote_item($url); if ($result['message']) { - notice($result['message']); + DI::sysmsg()->addNotice($result['message']); } DI::baseUrl()->redirect($return_path); } elseif ($result['cid']) { DI::baseUrl()->redirect('contact/' . $result['cid']); } - notice(DI::l10n()->t('The contact could not be added.')); + DI::sysmsg()->addNotice(DI::l10n()->t('The contact could not be added.')); DI::baseUrl()->redirect($return_path); } diff --git a/mod/item.php b/mod/item.php index 8f4494ca7..cc8e95385 100644 --- a/mod/item.php +++ b/mod/item.php @@ -129,7 +129,7 @@ function item_post(App $a) { } if (!DBA::isResult($toplevel_item)) { - notice(DI::l10n()->t('Unable to locate original post.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate original post.')); if ($return_path) { DI::baseUrl()->redirect($return_path); } @@ -179,7 +179,7 @@ function item_post(App $a) { // Now check that valid personal details have been provided if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) { Logger::warning('Permission denied.', ['local' => local_user(), 'profile_uid' => $profile_uid, 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]); - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); if ($return_path) { DI::baseUrl()->redirect($return_path); } @@ -335,7 +335,7 @@ function item_post(App $a) { System::jsonExit(['preview' => '']); } - notice(DI::l10n()->t('Empty post discarded.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Empty post discarded.')); if ($return_path) { DI::baseUrl()->redirect($return_path); } @@ -685,7 +685,7 @@ function item_post(App $a) { $post_id = Item::insert($datarray); if (!$post_id) { - notice(DI::l10n()->t('Item wasn\'t stored.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Item wasn\'t stored.')); if ($return_path) { DI::baseUrl()->redirect($return_path); } @@ -841,7 +841,7 @@ function drop_item(int $id, string $return = '') $item = Post::selectFirstForUser(local_user(), $fields, ['id' => $id]); if (!DBA::isResult($item)) { - notice(DI::l10n()->t('Item not found.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Item not found.')); DI::baseUrl()->redirect('network'); } @@ -863,7 +863,7 @@ function drop_item(int $id, string $return = '') item_redirect_after_action($item, $return); } else { Logger::warning('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]); - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::baseUrl()->redirect('display/' . $item['guid']); //NOTREACHED } diff --git a/mod/lostpass.php b/mod/lostpass.php index 6aa76e0cc..62b621b8c 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -37,7 +37,7 @@ function lostpass_post(App $a) $condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame]; $user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'email', 'language'], $condition); if (!DBA::isResult($user)) { - notice(DI::l10n()->t('No valid account found.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No valid account found.')); DI::baseUrl()->redirect(); } @@ -49,7 +49,7 @@ function lostpass_post(App $a) ]; $result = DBA::update('user', $fields, ['uid' => $user['uid']]); if ($result) { - info(DI::l10n()->t('Password reset request issued. Check your email.')); + DI::sysmsg()->addInfo(DI::l10n()->t('Password reset request issued. Check your email.')); } $sitename = DI::config()->get('config', 'sitename'); @@ -97,7 +97,7 @@ function lostpass_content(App $a) $user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'email', 'pwdreset_time', 'language'], ['pwdreset' => hash('sha256', $pwdreset_token)]); if (!DBA::isResult($user)) { - notice(DI::l10n()->t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.")); + DI::sysmsg()->addNotice(DI::l10n()->t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.")); return lostpass_form(); } @@ -110,7 +110,7 @@ function lostpass_content(App $a) ]; DBA::update('user', $fields, ['uid' => $user['uid']]); - notice(DI::l10n()->t('Request has expired, please make a new one.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Request has expired, please make a new one.')); return lostpass_form(); } @@ -152,7 +152,7 @@ function lostpass_generate_password($user) '$newpass' => $new_password, ]); - info(DI::l10n()->t("Your password has been reset.")); + DI::sysmsg()->addInfo(DI::l10n()->t("Your password has been reset.")); $sitename = DI::config()->get('config', 'sitename'); $preamble = Strings::deindent(DI::l10n()->t(' diff --git a/mod/match.php b/mod/match.php index 02ee0c333..a1f7be77c 100644 --- a/mod/match.php +++ b/mod/match.php @@ -59,7 +59,7 @@ function match_content(App $a) return ''; } if (!$profile['pub_keywords'] && (!$profile['prv_keywords'])) { - notice(DI::l10n()->t('No keywords to match. Please add keywords to your profile.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No keywords to match. Please add keywords to your profile.')); return ''; } @@ -90,7 +90,7 @@ function match_content(App $a) } if (empty($entries)) { - info(DI::l10n()->t('No matches')); + DI::sysmsg()->addInfo(DI::l10n()->t('No matches')); } $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl'); diff --git a/mod/message.php b/mod/message.php index a07c8b449..d1231b7c5 100644 --- a/mod/message.php +++ b/mod/message.php @@ -66,7 +66,7 @@ function message_init(App $a) function message_post(App $a) { if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } @@ -80,17 +80,17 @@ function message_post(App $a) switch ($ret) { case -1: - notice(DI::l10n()->t('No recipient selected.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No recipient selected.')); $norecip = true; break; case -2: - notice(DI::l10n()->t('Unable to locate contact information.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate contact information.')); break; case -3: - notice(DI::l10n()->t('Message could not be sent.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Message could not be sent.')); break; case -4: - notice(DI::l10n()->t('Message collection failure.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Message collection failure.')); break; } @@ -108,7 +108,7 @@ function message_content(App $a) Nav::setSelected('messages'); if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return Login::form(); } @@ -143,12 +143,12 @@ function message_content(App $a) if ($cmd === 'drop') { $message = DBA::selectFirst('mail', ['convid'], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]); if(!DBA::isResult($message)){ - notice(DI::l10n()->t('Conversation not found.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Conversation not found.')); DI::baseUrl()->redirect('message'); } if (!DBA::delete('mail', ['id' => DI::args()->getArgv()[2], 'uid' => local_user()])) { - notice(DI::l10n()->t('Message was not deleted.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Message was not deleted.')); } $conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]); @@ -163,7 +163,7 @@ function message_content(App $a) $parent = $parentmail['parent-uri']; if (!DBA::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) { - notice(DI::l10n()->t('Conversation was not removed.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Conversation was not removed.')); } } DI::baseUrl()->redirect('message'); @@ -219,7 +219,7 @@ function message_content(App $a) $r = get_messages(local_user(), $pager->getStart(), $pager->getItemsPerPage()); if (!DBA::isResult($r)) { - notice(DI::l10n()->t('No messages.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No messages.')); return $o; } @@ -275,7 +275,7 @@ function message_content(App $a) } if (!DBA::isResult($messages)) { - notice(DI::l10n()->t('Message not available.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Message not available.')); return $o; } diff --git a/mod/notes.php b/mod/notes.php index b5bdbf870..a30d80769 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -41,7 +41,7 @@ function notes_init(App $a) function notes_content(App $a, $update = false) { if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index 781de3493..2ecea6016 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -30,7 +30,7 @@ use Friendica\Protocol\ActivityPub; function ostatus_subscribe_content(App $a) { if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::baseUrl()->redirect('ostatus_subscribe'); // NOTREACHED } diff --git a/mod/photos.php b/mod/photos.php index 6a4596bf2..047328aa5 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -157,14 +157,14 @@ function photos_post(App $a) } if (!$can_post) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); System::exit(); } $owner_record = User::getOwnerDataById($page_owner_uid); if (!$owner_record) { - notice(DI::l10n()->t('Contact information unavailable')); + DI::sysmsg()->addNotice(DI::l10n()->t('Contact information unavailable')); DI::logger()->info('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid); System::exit(); } @@ -193,7 +193,7 @@ function photos_post(App $a) $album = hex2bin(DI::args()->getArgv()[3]); if (!DBA::exists('photo', ['album' => $album, 'uid' => $page_owner_uid, 'photo-type' => Photo::DEFAULT])) { - notice(DI::l10n()->t('Album not found.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Album not found.')); DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album'); return; // NOTREACHED } @@ -247,9 +247,9 @@ function photos_post(App $a) // Update the photo albums cache Photo::clearAlbumCache($page_owner_uid); - notice(DI::l10n()->t('Album successfully deleted')); + DI::sysmsg()->addNotice(DI::l10n()->t('Album successfully deleted')); } else { - notice(DI::l10n()->t('Album was empty.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Album was empty.')); } } @@ -281,7 +281,7 @@ function photos_post(App $a) // Update the photo albums cache Photo::clearAlbumCache($page_owner_uid); } else { - notice(DI::l10n()->t('Failed to delete the photo.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Failed to delete the photo.')); DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1] . '/image/' . DI::args()->getArgv()[3]); } @@ -633,21 +633,21 @@ function photos_post(App $a) if ($error !== UPLOAD_ERR_OK) { switch ($error) { case UPLOAD_ERR_INI_SIZE: - notice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize'))); + DI::sysmsg()->addNotice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize'))); break; case UPLOAD_ERR_FORM_SIZE: - notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0))); + DI::sysmsg()->addNotice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0))); break; case UPLOAD_ERR_PARTIAL: - notice(DI::l10n()->t('Image upload didn\'t complete, please try again')); + DI::sysmsg()->addNotice(DI::l10n()->t('Image upload didn\'t complete, please try again')); break; case UPLOAD_ERR_NO_FILE: - notice(DI::l10n()->t('Image file is missing')); + DI::sysmsg()->addNotice(DI::l10n()->t('Image file is missing')); break; case UPLOAD_ERR_NO_TMP_DIR: case UPLOAD_ERR_CANT_WRITE: case UPLOAD_ERR_EXTENSION: - notice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator')); + DI::sysmsg()->addNotice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator')); break; } @unlink($src); @@ -663,7 +663,7 @@ function photos_post(App $a) $maximagesize = DI::config()->get('system', 'maximagesize'); 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); $foo = 0; Hook::callAll('photo_post_end', $foo); @@ -671,7 +671,7 @@ function photos_post(App $a) } if (!$filesize) { - notice(DI::l10n()->t('Image file is empty.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Image file is empty.')); @unlink($src); $foo = 0; Hook::callAll('photo_post_end', $foo); @@ -686,7 +686,7 @@ function photos_post(App $a) if (!$image->isValid()) { Logger::notice('unable to process image'); - notice(DI::l10n()->t('Unable to process image.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image.')); @unlink($src); $foo = 0; Hook::callAll('photo_post_end',$foo); @@ -712,7 +712,7 @@ function photos_post(App $a) if (!$r) { Logger::warning('image store failed'); - notice(DI::l10n()->t('Image upload failed.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.')); return; } @@ -799,12 +799,12 @@ function photos_content(App $a) } if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) { - notice(DI::l10n()->t('Public access denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Public access denied.')); return; } if (empty($user)) { - notice(DI::l10n()->t('No photos selected')); + DI::sysmsg()->addNotice(DI::l10n()->t('No photos selected')); return; } @@ -873,7 +873,7 @@ function photos_content(App $a) } if ($user['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) { - notice(DI::l10n()->t('Access to this item is restricted.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Access to this item is restricted.')); return; } @@ -888,7 +888,7 @@ function photos_content(App $a) // Display upload form if ($datatype === 'upload') { if (!$can_post) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } @@ -1088,9 +1088,9 @@ function photos_content(App $a) if (!DBA::isResult($ph)) { if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) { - notice(DI::l10n()->t('Permission denied. Access to this item may be restricted.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied. Access to this item may be restricted.')); } else { - notice(DI::l10n()->t('Photo not available')); + DI::sysmsg()->addNotice(DI::l10n()->t('Photo not available')); } return; } diff --git a/mod/repair_ostatus.php b/mod/repair_ostatus.php index b2ca61218..bc2c8bba2 100644 --- a/mod/repair_ostatus.php +++ b/mod/repair_ostatus.php @@ -28,7 +28,7 @@ use Friendica\Model\Contact; function repair_ostatus_content(App $a) { if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::baseUrl()->redirect('ostatus_repair'); // NOTREACHED } diff --git a/mod/settings.php b/mod/settings.php index 2e21c2682..093572f18 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -37,7 +37,7 @@ use Friendica\Protocol\Email; function settings_init(App $a) { if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } @@ -47,7 +47,7 @@ function settings_init(App $a) function settings_post(App $a) { if (!$a->isLoggedIn()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } @@ -119,7 +119,7 @@ function settings_post(App $a) $mbox = Email::connect($mb, $mail_user, $dcrpass); unset($dcrpass); if (!$mbox) { - notice(DI::l10n()->t('Failed to connect with email account using the settings provided.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Failed to connect with email account using the settings provided.')); } } } @@ -148,12 +148,12 @@ function settings_content(App $a) Nav::setSelected('settings'); if (!local_user()) { - //notice(DI::l10n()->t('Permission denied.')); + //DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return Login::form(); } if (!empty($_SESSION['submanage'])) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return ''; } diff --git a/mod/uimport.php b/mod/uimport.php index fb1ef25c3..da024a56e 100644 --- a/mod/uimport.php +++ b/mod/uimport.php @@ -30,7 +30,7 @@ use Friendica\DI; function uimport_post(App $a) { if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !$a->isSiteAdmin()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } @@ -43,7 +43,7 @@ function uimport_post(App $a) function uimport_content(App $a) { if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !$a->isSiteAdmin()) { - notice(DI::l10n()->t('User imports on closed servers can only be done by an administrator.')); + DI::sysmsg()->addNotice(DI::l10n()->t('User imports on closed servers can only be done by an administrator.')); return; } @@ -52,7 +52,7 @@ function uimport_content(App $a) $total = DBA::count('user', ["`register_date` > UTC_TIMESTAMP - INTERVAL 1 DAY"]); if ($total >= $max_dailies) { Logger::notice('max daily registrations exceeded.'); - notice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.')); + DI::sysmsg()->addNotice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.')); return; } } diff --git a/mod/unfollow.php b/mod/unfollow.php index 10830bd10..61c88ee9e 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -32,7 +32,7 @@ use Friendica\Util\Strings; function unfollow_post(App $a) { if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::baseUrl()->redirect('login'); // NOTREACHED } @@ -47,7 +47,7 @@ function unfollow_content(App $a) $base_return_path = 'contact'; if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::baseUrl()->redirect('login'); // NOTREACHED } @@ -62,13 +62,13 @@ function unfollow_content(App $a) $contact = DBA::selectFirst('contact', ['url', 'id', 'uid', 'network', 'addr', 'name'], $condition); if (!DBA::isResult($contact)) { - notice(DI::l10n()->t("You aren't following this contact.")); + DI::sysmsg()->addNotice(DI::l10n()->t("You aren't following this contact.")); DI::baseUrl()->redirect($base_return_path); // NOTREACHED } if (!Protocol::supportsFollow($contact['network'])) { - notice(DI::l10n()->t('Unfollowing is currently not supported by your network.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Unfollowing is currently not supported by your network.')); DI::baseUrl()->redirect($base_return_path . '/' . $contact['id']); // NOTREACHED } @@ -79,7 +79,7 @@ function unfollow_content(App $a) $self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]); if (!DBA::isResult($self)) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::baseUrl()->redirect($base_return_path); // NOTREACHED } @@ -131,7 +131,7 @@ function unfollow_process(string $url) $contact = DBA::selectFirst('contact', [], $condition); if (!DBA::isResult($contact)) { - notice(DI::l10n()->t("You aren't following this contact.")); + DI::sysmsg()->addNotice(DI::l10n()->t("You aren't following this contact.")); DI::baseUrl()->redirect($base_return_path); // NOTREACHED } @@ -146,6 +146,6 @@ function unfollow_process(string $url) $notice_message = DI::l10n()->t('Unable to unfollow this contact, please contact your administrator'); } - notice($notice_message); + DI::sysmsg()->addNotice($notice_message); DI::baseUrl()->redirect($return_path); } diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 43f4681df..8341d7252 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -66,7 +66,7 @@ function wall_attach_post(App $a) { if ($r_json) { System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]); } - notice(DI::l10n()->t('Permission denied.') . EOL ); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.') . EOL ); System::exit(); } @@ -95,7 +95,7 @@ function wall_attach_post(App $a) { if ($r_json) { System::jsonExit(['error' => $msg]); } else { - notice($msg); + DI::sysmsg()->addNotice($msg); } System::exit(); } diff --git a/mod/wall_upload.php b/mod/wall_upload.php index 4554c55aa..befb0fceb 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -88,7 +88,7 @@ function wall_upload_post(App $a, $desktopmode = true) if ($r_json) { System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]); } - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); System::exit(); } @@ -147,7 +147,7 @@ function wall_upload_post(App $a, $desktopmode = true) if ($r_json) { System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]); } - notice(DI::l10n()->t('Invalid request.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Invalid request.')); System::exit(); } diff --git a/mod/wallmessage.php b/mod/wallmessage.php index e8f7d24e3..2b4b8d2a5 100644 --- a/mod/wallmessage.php +++ b/mod/wallmessage.php @@ -34,7 +34,7 @@ function wallmessage_post(App $a) { $replyto = Profile::getMyURL(); if (!$replyto) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } @@ -53,13 +53,13 @@ function wallmessage_post(App $a) { } if (!$user['unkmail']) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } $total = DBA::count('mail', ["`uid` = ? AND `created` > ? AND `unknown`", $user['uid'], DateTimeFormat::utc('now - 1 day')]); if ($total > $user['cntunkmail']) { - notice(DI::l10n()->t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])); + DI::sysmsg()->addNotice(DI::l10n()->t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])); return; } @@ -67,16 +67,16 @@ function wallmessage_post(App $a) { switch ($ret) { case -1: - notice(DI::l10n()->t('No recipient selected.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No recipient selected.')); break; case -2: - notice(DI::l10n()->t('Unable to check your home location.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Unable to check your home location.')); break; case -3: - notice(DI::l10n()->t('Message could not be sent.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Message could not be sent.')); break; case -4: - notice(DI::l10n()->t('Message collection failure.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Message collection failure.')); break; } @@ -87,33 +87,33 @@ function wallmessage_post(App $a) { function wallmessage_content(App $a) { if (!Profile::getMyURL()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } $recipient = ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : ''); if (!$recipient) { - notice(DI::l10n()->t('No recipient.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No recipient.')); return; } $user = User::getByNickname($recipient); if (empty($user)) { - notice(DI::l10n()->t('No recipient.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No recipient.')); Logger::notice('wallmessage: no recipient'); return; } if (!$user['unkmail']) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } $total = DBA::count('mail', ["`uid` = ? AND `created` > ? AND `unknown`", $user['uid'], DateTimeFormat::utc('now - 1 day')]); if ($total > $user['cntunkmail']) { - notice(DI::l10n()->t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])); + DI::sysmsg()->addNotice(DI::l10n()->t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])); return; } diff --git a/src/BaseModule.php b/src/BaseModule.php index 99c297b75..e532b9536 100644 --- a/src/BaseModule.php +++ b/src/BaseModule.php @@ -397,7 +397,7 @@ abstract class BaseModule implements ICanHandleRequests if (!self::checkFormSecurityToken($typename, $formname)) { Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename); Logger::debug('checkFormSecurityToken failed', ['request' => $_REQUEST]); - notice(self::getFormSecurityStandardErrorMessage()); + DI::sysmsg()->addNotice(self::getFormSecurityStandardErrorMessage()); DI::baseUrl()->redirect($err_redirect); } } diff --git a/src/Core/UserImport.php b/src/Core/UserImport.php index f8485fc29..be7bbf0b5 100644 --- a/src/Core/UserImport.php +++ b/src/Core/UserImport.php @@ -123,13 +123,13 @@ class UserImport $account = json_decode(file_get_contents($file['tmp_name']), true); if ($account === null) { - notice(DI::l10n()->t("Error decoding account file")); + DI::sysmsg()->addNotice(DI::l10n()->t("Error decoding account file")); return; } if (empty($account['version'])) { - notice(DI::l10n()->t("Error! No version data in file! This is not a Friendica account file?")); + DI::sysmsg()->addNotice(DI::l10n()->t("Error! No version data in file! This is not a Friendica account file?")); return; } @@ -137,7 +137,7 @@ class UserImport // check if username matches deleted account if (DBA::exists('user', ['nickname' => $account['user']['nickname']]) || DBA::exists('userd', ['username' => $account['user']['nickname']])) { - notice(DI::l10n()->t("User '%s' already exists on this server!", $account['user']['nickname'])); + DI::sysmsg()->addNotice(DI::l10n()->t("User '%s' already exists on this server!", $account['user']['nickname'])); return; } @@ -173,7 +173,7 @@ class UserImport $r = self::dbImportAssoc('user', $account['user']); if ($r === false) { Logger::warning("uimport:insert user : ERROR : " . DBA::errorMessage()); - notice(DI::l10n()->t("User creation error")); + DI::sysmsg()->addNotice(DI::l10n()->t("User creation error")); return; } $newuid = self::lastInsertId(); @@ -218,7 +218,7 @@ class UserImport } } if ($errorcount > 0) { - notice(DI::l10n()->tt("%d contact not imported", "%d contacts not imported", $errorcount)); + DI::sysmsg()->addNotice(DI::l10n()->tt("%d contact not imported", "%d contacts not imported", $errorcount)); } foreach ($account['group'] as &$group) { @@ -271,7 +271,7 @@ class UserImport if ($r === false) { Logger::warning("uimport:insert profile: ERROR : " . DBA::errorMessage()); - notice(DI::l10n()->t("User profile creation error")); + DI::sysmsg()->addNotice(DI::l10n()->t("User profile creation error")); DBA::delete('user', ['uid' => $newuid]); DBA::delete('profile_field', ['uid' => $newuid]); return; @@ -324,7 +324,7 @@ class UserImport // send relocate messages Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $newuid); - info(DI::l10n()->t("Done. You can now login with your username and password")); + DI::sysmsg()->addInfo(DI::l10n()->t("Done. You can now login with your username and password")); DI::baseUrl()->redirect('login'); } } diff --git a/src/Model/Group.php b/src/Model/Group.php index 4dec84c3a..3487ab53d 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -102,7 +102,7 @@ class Group $group = DBA::selectFirst('group', ['deleted'], ['id' => $gid]); if (DBA::isResult($group) && $group['deleted']) { DBA::update('group', ['deleted' => 0], ['id' => $gid]); - notice(DI::l10n()->t('A deleted group with this name was revived. Existing item permissions may apply to this group and any future members. If this is not what you intended, please create another group with a different name.')); + DI::sysmsg()->addNotice(DI::l10n()->t('A deleted group with this name was revived. Existing item permissions may apply to this group and any future members. If this is not what you intended, please create another group with a different name.')); } return true; } diff --git a/src/Model/Profile.php b/src/Model/Profile.php index f6d189a10..b58de4efb 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -865,7 +865,7 @@ class Profile $a->setContactId($arr['visitor']['id']); - info(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHostname(), $visitor['name'])); + DI::sysmsg()->addInfo(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHostname(), $visitor['name'])); Logger::info('OpenWebAuth: auth success from ' . $visitor['addr']); } diff --git a/src/Module/Admin/Addons/Details.php b/src/Module/Admin/Addons/Details.php index 28435c545..be0e59e32 100644 --- a/src/Module/Admin/Addons/Details.php +++ b/src/Module/Admin/Addons/Details.php @@ -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); diff --git a/src/Module/Admin/Addons/Index.php b/src/Module/Admin/Addons/Index.php index b9198ee36..8db0b70ed 100644 --- a/src/Module/Admin/Addons/Index.php +++ b/src/Module/Admin/Addons/Index.php @@ -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; diff --git a/src/Module/Admin/Blocklist/Contact.php b/src/Module/Admin/Blocklist/Contact.php index 35a8a151d..85e7f2146 100644 --- a/src/Module/Admin/Blocklist/Contact.php +++ b/src/Module/Admin/Blocklist/Contact.php @@ -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'); diff --git a/src/Module/Admin/DBSync.php b/src/Module/Admin/DBSync.php index d5a16f9be..bb1fa9033 100644 --- a/src/Module/Admin/DBSync.php +++ b/src/Module/Admin/DBSync.php @@ -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; diff --git a/src/Module/Admin/Item/Delete.php b/src/Module/Admin/Item/Delete.php index e52156051..d291e7b84 100644 --- a/src/Module/Admin/Item/Delete.php +++ b/src/Module/Admin/Item/Delete.php @@ -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'); } diff --git a/src/Module/Admin/Logs/Settings.php b/src/Module/Admin/Logs/Settings.php index 9dbc8f352..e5324e6f6 100644 --- a/src/Module/Admin/Logs/Settings.php +++ b/src/Module/Admin/Logs/Settings.php @@ -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; } diff --git a/src/Module/Admin/Storage.php b/src/Module/Admin/Storage.php index f54344f47..207553437 100644 --- a/src/Module/Admin/Storage.php +++ b/src/Module/Admin/Storage.php @@ -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.')); } } diff --git a/src/Module/Admin/Themes/Details.php b/src/Module/Admin/Themes/Details.php index dc6bf5818..45573cbe6 100644 --- a/src/Module/Admin/Themes/Details.php +++ b/src/Module/Admin/Themes/Details.php @@ -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); diff --git a/src/Module/Admin/Themes/Embed.php b/src/Module/Admin/Themes/Embed.php index 439e78e64..756b90afa 100644 --- a/src/Module/Admin/Themes/Embed.php +++ b/src/Module/Admin/Themes/Embed.php @@ -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 ''; } diff --git a/src/Module/Admin/Themes/Index.php b/src/Module/Admin/Themes/Index.php index cf0ddcfc6..4dde4f856 100644 --- a/src/Module/Admin/Themes/Index.php +++ b/src/Module/Admin/Themes/Index.php @@ -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)); } } diff --git a/src/Module/Admin/Users/Active.php b/src/Module/Admin/Users/Active.php index eac12063e..2188d4a59 100644 --- a/src/Module/Admin/Users/Active.php +++ b/src/Module/Admin/Users/Active.php @@ -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; } diff --git a/src/Module/Admin/Users/Blocked.php b/src/Module/Admin/Users/Blocked.php index 63294f17c..e8434d5e0 100644 --- a/src/Module/Admin/Users/Blocked.php +++ b/src/Module/Admin/Users/Blocked.php @@ -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; } diff --git a/src/Module/Admin/Users/Create.php b/src/Module/Admin/Users/Create.php index 5ab443b14..29dbf5d7e 100644 --- a/src/Module/Admin/Users/Create.php +++ b/src/Module/Admin/Users/Create.php @@ -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()); } } diff --git a/src/Module/Admin/Users/Index.php b/src/Module/Admin/Users/Index.php index 8dfac5057..e8356720d 100644 --- a/src/Module/Admin/Users/Index.php +++ b/src/Module/Admin/Users/Index.php @@ -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; } diff --git a/src/Module/Admin/Users/Pending.php b/src/Module/Admin/Users/Pending.php index b5b164bb5..484a128eb 100644 --- a/src/Module/Admin/Users/Pending.php +++ b/src/Module/Admin/Users/Pending.php @@ -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; } diff --git a/src/Module/Apps.php b/src/Module/Apps.php index db5636bf9..9ef4268de 100644 --- a/src/Module/Apps.php +++ b/src/Module/Apps.php @@ -28,6 +28,7 @@ use Friendica\Content\Nav; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; use Friendica\Core\Renderer; +use Friendica\DI; use Friendica\Util\Profiler; use Psr\Log\LoggerInterface; @@ -51,7 +52,7 @@ class Apps extends BaseModule $apps = Nav::getAppMenu(); if (count($apps) == 0) { - notice($this->t('No installed applications.')); + DI::sysmsg()->addNotice($this->t('No installed applications.')); } $tpl = Renderer::getMarkupTemplate('apps.tpl'); diff --git a/src/Module/BaseAdmin.php b/src/Module/BaseAdmin.php index 713c44cc2..dd4e108e7 100644 --- a/src/Module/BaseAdmin.php +++ b/src/Module/BaseAdmin.php @@ -54,7 +54,7 @@ abstract class BaseAdmin extends BaseModule { if (!local_user()) { if ($interactive) { - notice(DI::l10n()->t('Please login to continue.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Please login to continue.')); Session::set('return_path', DI::args()->getQueryString()); DI::baseUrl()->redirect('login'); } else { diff --git a/src/Module/BaseSearch.php b/src/Module/BaseSearch.php index 276598131..f14a93b0f 100644 --- a/src/Module/BaseSearch.php +++ b/src/Module/BaseSearch.php @@ -116,7 +116,7 @@ class BaseSearch extends BaseModule protected static function printResult(ResultList $results, Pager $pager, string $header = ''): string { if ($results->getTotal() == 0) { - notice(DI::l10n()->t('No matches')); + DI::sysmsg()->addNotice(DI::l10n()->t('No matches')); return ''; } diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 4f565a871..97f4b7e25 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -85,7 +85,7 @@ class Contact extends BaseModule } } if ($count_actions > 0) { - info(DI::l10n()->tt('%d contact edited.', '%d contacts edited.', $count_actions)); + DI::sysmsg()->addInfo(DI::l10n()->tt('%d contact edited.', '%d contacts edited.', $count_actions)); } DI::baseUrl()->redirect($redirectUrl); diff --git a/src/Module/Contact/Advanced.php b/src/Module/Contact/Advanced.php index bbb1d59e0..d722691ff 100644 --- a/src/Module/Contact/Advanced.php +++ b/src/Module/Contact/Advanced.php @@ -30,6 +30,7 @@ use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Session; use Friendica\Database\Database; +use Friendica\DI; use Friendica\Model; use Friendica\Module\Contact; use Friendica\Module\Response; @@ -96,7 +97,7 @@ class Advanced extends BaseModule } if (!$r) { - notice($this->t('Contact update failed.')); + DI::sysmsg()->addNotice($this->t('Contact update failed.')); } } diff --git a/src/Module/Contact/Profile.php b/src/Module/Contact/Profile.php index 793d0fa4a..3af591a06 100644 --- a/src/Module/Contact/Profile.php +++ b/src/Module/Contact/Profile.php @@ -35,6 +35,7 @@ use Friendica\Core\L10n; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Module; @@ -124,7 +125,7 @@ class Profile extends BaseModule } if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => local_user()])) { - notice($this->t('Failed to update contact record.')); + DI::sysmsg()->addNotice($this->t('Failed to update contact record.')); } } @@ -182,7 +183,7 @@ class Profile extends BaseModule } // @TODO: add $this->localRelationship->save($localRelationship); - info($message); + DI::sysmsg()->addInfo($message); } if ($cmd === 'ignore') { @@ -198,7 +199,7 @@ class Profile extends BaseModule } // @TODO: add $this->localRelationship->save($localRelationship); - info($message); + DI::sysmsg()->addInfo($message); } $this->baseUrl->redirect('contact/' . $contact['id']); diff --git a/src/Module/Contact/Revoke.php b/src/Module/Contact/Revoke.php index 35cb48149..4ade2b146 100644 --- a/src/Module/Contact/Revoke.php +++ b/src/Module/Contact/Revoke.php @@ -28,6 +28,7 @@ use Friendica\Core\L10n; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Database\Database; +use Friendica\DI; use Friendica\Model; use Friendica\Module\Contact; use Friendica\Module\Response; @@ -87,7 +88,7 @@ class Revoke extends BaseModule Model\Contact::revokeFollow($this->contact); - notice($this->t('Follow was successfully revoked.')); + DI::sysmsg()->addNotice($this->t('Follow was successfully revoked.')); $this->baseUrl->redirect('contact/' . $this->parameters['id']); } diff --git a/src/Module/Conversation/Community.php b/src/Module/Conversation/Community.php index 3ba95e1ef..a5bfe4190 100644 --- a/src/Module/Conversation/Community.php +++ b/src/Module/Conversation/Community.php @@ -155,7 +155,7 @@ class Community extends BaseModule $items = self::getItems(); if (!DBA::isResult($items)) { - notice(DI::l10n()->t('No results.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No results.')); return $o; } diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index c36876b34..cc6146a89 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -170,7 +170,7 @@ class Network extends BaseModule if (self::$groupId) { $group = DBA::selectFirst('group', ['name'], ['id' => self::$groupId, 'uid' => local_user()]); if (!DBA::isResult($group)) { - notice(DI::l10n()->t('No such group')); + DI::sysmsg()->addNotice(DI::l10n()->t('No such group')); } $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('section_title.tpl'), [ @@ -184,7 +184,7 @@ class Network extends BaseModule 'id' => DI::args()->get(0), ]) . $o; } else { - notice(DI::l10n()->t('Invalid contact.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Invalid contact.')); } } elseif (!DI::config()->get('theme', 'hide_eventlist')) { $o .= Profile::getBirthdays(); diff --git a/src/Module/Debug/Feed.php b/src/Module/Debug/Feed.php index 46ded4236..fc9f95f07 100644 --- a/src/Module/Debug/Feed.php +++ b/src/Module/Debug/Feed.php @@ -25,6 +25,7 @@ use Friendica\App; use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Renderer; +use Friendica\DI; use Friendica\Model; use Friendica\Module\Response; use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests; @@ -48,7 +49,7 @@ class Feed extends BaseModule $this->httpClient = $httpClient; if (!local_user()) { - notice($this->t('You must be logged in to use this module')); + DI::sysmsg()->addNotice($this->t('You must be logged in to use this module')); $baseUrl->redirect(); } } diff --git a/src/Module/Delegation.php b/src/Module/Delegation.php index c14573c8b..146e9382b 100644 --- a/src/Module/Delegation.php +++ b/src/Module/Delegation.php @@ -108,7 +108,7 @@ class Delegation extends BaseModule $ret = []; Hook::callAll('home_init', $ret); - notice($this->t('You are now logged in as %s', $user['username'])); + DI::sysmsg()->addNotice($this->t('You are now logged in as %s', $user['username'])); DI::baseUrl()->redirect('network'); } diff --git a/src/Module/Directory.php b/src/Module/Directory.php index 9fac9db30..f48e2bf7e 100644 --- a/src/Module/Directory.php +++ b/src/Module/Directory.php @@ -72,7 +72,7 @@ class Directory extends BaseModule $profiles = Profile::searchProfiles($pager->getStart(), $pager->getItemsPerPage(), $search); if ($profiles['total'] === 0) { - notice(DI::l10n()->t('No entries (some entries may be hidden).')); + DI::sysmsg()->addNotice(DI::l10n()->t('No entries (some entries may be hidden).')); } else { foreach ($profiles['entries'] as $entry) { $contact = Model\Contact::getByURLForUser($entry['url'], local_user()); diff --git a/src/Module/Filer/SaveTag.php b/src/Module/Filer/SaveTag.php index 3dfd7877c..c3b9acadd 100644 --- a/src/Module/Filer/SaveTag.php +++ b/src/Module/Filer/SaveTag.php @@ -26,6 +26,7 @@ use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model; use Friendica\Module\Response; use Friendica\Network\HTTPException; @@ -43,7 +44,7 @@ class SaveTag extends BaseModule parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); if (!local_user()) { - notice($this->t('You must be logged in to use this module')); + DI::sysmsg()->addNotice($this->t('You must be logged in to use this module')); $baseUrl->redirect(); } } diff --git a/src/Module/FollowConfirm.php b/src/Module/FollowConfirm.php index b61cfd432..0254bfae3 100644 --- a/src/Module/FollowConfirm.php +++ b/src/Module/FollowConfirm.php @@ -35,7 +35,7 @@ class FollowConfirm extends BaseModule parent::post($request); $uid = local_user(); if (!$uid) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } diff --git a/src/Module/FriendSuggest.php b/src/Module/FriendSuggest.php index d8a42d8de..815c4e1ec 100644 --- a/src/Module/FriendSuggest.php +++ b/src/Module/FriendSuggest.php @@ -28,6 +28,7 @@ use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Worker; use Friendica\Database\Database; +use Friendica\DI; use Friendica\Model\Contact as ContactModel; use Friendica\Network\HTTPException\ForbiddenException; use Friendica\Network\HTTPException\NotFoundException; @@ -78,7 +79,7 @@ class FriendSuggest extends BaseModule // We do query the "uid" as well to ensure that it is our contact $contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => local_user()]); if (empty($contact)) { - notice($this->t('Suggested contact not found.')); + DI::sysmsg()->addNotice($this->t('Suggested contact not found.')); return; } @@ -96,7 +97,7 @@ class FriendSuggest extends BaseModule Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id); - info($this->t('Friend suggestion sent.')); + DI::sysmsg()->addInfo($this->t('Friend suggestion sent.')); } protected function content(array $request = []): string @@ -105,7 +106,7 @@ class FriendSuggest extends BaseModule $contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]); if (empty($contact)) { - notice($this->t('Contact not found.')); + DI::sysmsg()->addNotice($this->t('Contact not found.')); $this->baseUrl->redirect(); } diff --git a/src/Module/Group.php b/src/Module/Group.php index cd07e9781..06ee555a7 100644 --- a/src/Module/Group.php +++ b/src/Module/Group.php @@ -39,7 +39,7 @@ class Group extends BaseModule } if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::baseUrl()->redirect(); } @@ -55,7 +55,7 @@ class Group extends BaseModule DI::baseUrl()->redirect('group/' . $r); } } else { - notice(DI::l10n()->t('Could not create group.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Could not create group.')); } DI::baseUrl()->redirect('group'); } @@ -66,13 +66,13 @@ class Group extends BaseModule $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => local_user()]); if (!DBA::isResult($group)) { - notice(DI::l10n()->t('Group not found.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.')); DI::baseUrl()->redirect('contact'); } $groupname = trim($_POST['groupname']); if (strlen($groupname) && ($groupname != $group['name'])) { if (!Model\Group::update($group['id'], $groupname)) { - notice(DI::l10n()->t('Group name was not changed.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Group name was not changed.')); } } } @@ -132,10 +132,10 @@ class Group extends BaseModule throw new \Exception(DI::l10n()->t('Bad request.'), 400); } - info($message); + DI::sysmsg()->addInfo($message); System::jsonExit(['status' => 'OK', 'message' => $message]); } catch (\Exception $e) { - notice($e->getMessage()); + DI::sysmsg()->addNotice($e->getMessage()); System::jsonError($e->getCode(), ['status' => 'error', 'message' => $e->getMessage()]); } } @@ -212,12 +212,12 @@ class Group extends BaseModule // @TODO: Replace with parameter from router if (intval(DI::args()->getArgv()[2])) { if (!Model\Group::exists(DI::args()->getArgv()[2], local_user())) { - notice(DI::l10n()->t('Group not found.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.')); DI::baseUrl()->redirect('contact'); } if (!Model\Group::remove(DI::args()->getArgv()[2])) { - notice(DI::l10n()->t('Unable to remove group.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Unable to remove group.')); } } DI::baseUrl()->redirect('group'); @@ -236,7 +236,7 @@ class Group extends BaseModule if ((DI::args()->getArgc() > 1) && intval(DI::args()->getArgv()[1])) { $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => local_user(), 'deleted' => false]); if (!DBA::isResult($group)) { - notice(DI::l10n()->t('Group not found.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.')); DI::baseUrl()->redirect('contact'); } diff --git a/src/Module/Invite.php b/src/Module/Invite.php index 77a7585bd..c36a8ad7d 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -79,7 +79,7 @@ class Invite extends BaseModule $recipient = trim($recipient); if (!filter_var($recipient, FILTER_VALIDATE_EMAIL)) { - notice(DI::l10n()->t('%s : Not a valid email address.', $recipient)); + DI::sysmsg()->addNotice(DI::l10n()->t('%s : Not a valid email address.', $recipient)); continue; } @@ -114,15 +114,15 @@ class Invite extends BaseModule $current_invites++; DI::pConfig()->set(local_user(), 'system', 'sent_invites', $current_invites); if ($current_invites > $max_invites) { - notice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.')); return; } } else { - notice(DI::l10n()->t('%s : Message delivery failed.', $recipient)); + DI::sysmsg()->addNotice(DI::l10n()->t('%s : Message delivery failed.', $recipient)); } } - info(DI::l10n()->tt('%d message sent.', '%d messages sent.', $total)); + DI::sysmsg()->addInfo(DI::l10n()->tt('%d message sent.', '%d messages sent.', $total)); } protected function content(array $request = []): string diff --git a/src/Module/Notifications/Introductions.php b/src/Module/Notifications/Introductions.php index 42ec3b6f7..ffe5d212f 100644 --- a/src/Module/Notifications/Introductions.php +++ b/src/Module/Notifications/Introductions.php @@ -30,6 +30,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\L10n; use Friendica\Core\Protocol; use Friendica\Core\Renderer; +use Friendica\DI; use Friendica\Model\User; use Friendica\Module\BaseNotifications; use Friendica\Module\Response; @@ -211,7 +212,7 @@ class Introductions extends BaseNotifications } if (count($notifications['notifications']) == 0) { - notice($this->t('No introductions.')); + DI::sysmsg()->addNotice($this->t('No introductions.')); $notificationNoContent = $this->t('No more %s notifications.', $notifications['ident']); } diff --git a/src/Module/Notifications/Notification.php b/src/Module/Notifications/Notification.php index a28b5d6f6..cacf57ec0 100644 --- a/src/Module/Notifications/Notification.php +++ b/src/Module/Notifications/Notification.php @@ -27,6 +27,7 @@ use Friendica\Contact\Introduction\Repository\Introduction; use Friendica\Core\L10n; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\System; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Module\Response; use Friendica\Module\Security\Login; @@ -131,7 +132,7 @@ class Notification extends BaseModule protected function content(array $request = []): string { if (!local_user()) { - notice($this->l10n->t('You must be logged in to show this page.')); + DI::sysmsg()->addNotice($this->l10n->t('You must be logged in to show this page.')); return Login::form(); } diff --git a/src/Module/Profile/Profile.php b/src/Module/Profile/Profile.php index ccc3208b6..f5e904544 100644 --- a/src/Module/Profile/Profile.php +++ b/src/Module/Profile/Profile.php @@ -106,7 +106,7 @@ class Profile extends BaseProfile $o = self::getTabsHTML($a, 'profile', $is_owner, $profile['nickname'], $profile['hide-friends']); if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) { - notice(DI::l10n()->t('Access to this profile has been restricted.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Access to this profile has been restricted.')); return ''; } diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index d851d5f47..99f5fe6ba 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -107,7 +107,7 @@ class Status extends BaseProfile $last_updated_key = "profile:" . $profile['uid'] . ":" . local_user() . ":" . $remote_contact; if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact) { - notice(DI::l10n()->t('Access to this profile has been restricted.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Access to this profile has been restricted.')); return ''; } diff --git a/src/Module/Register.php b/src/Module/Register.php index 95cea1458..35faaa7df 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -74,20 +74,20 @@ class Register extends BaseModule $block = DI::config()->get('system', 'block_extended_register'); if (local_user() && $block) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return ''; } if (local_user()) { $user = DBA::selectFirst('user', ['parent-uid'], ['uid' => local_user()]); if (!empty($user['parent-uid'])) { - notice(DI::l10n()->t('Only parent users can create additional accounts.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Only parent users can create additional accounts.')); return ''; } } if (!local_user() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return ''; } @@ -96,7 +96,7 @@ class Register extends BaseModule $count = DBA::count('user', ['`register_date` > UTC_TIMESTAMP - INTERVAL 1 day']); if ($count >= $max_dailies) { Logger::notice('max daily registrations exceeded.'); - notice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.')); + DI::sysmsg()->addNotice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.')); return ''; } } @@ -203,19 +203,19 @@ class Register extends BaseModule $additional_account = false; if (!local_user() && !empty($arr['post']['parent_password'])) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } elseif (local_user() && !empty($arr['post']['parent_password'])) { try { Model\User::getIdFromPasswordAuthentication(local_user(), $arr['post']['parent_password']); } catch (\Exception $ex) { - notice(DI::l10n()->t("Password doesn't match.")); + DI::sysmsg()->addNotice(DI::l10n()->t("Password doesn't match.")); $regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']]; DI::baseUrl()->redirect('register?' . http_build_query($regdata)); } $additional_account = true; } elseif (local_user()) { - notice(DI::l10n()->t('Please enter your password.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Please enter your password.')); $regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']]; DI::baseUrl()->redirect('register?' . http_build_query($regdata)); } @@ -242,7 +242,7 @@ class Register extends BaseModule case self::CLOSED: default: if (empty($_SESSION['authenticated']) && empty($_SESSION['administrator'])) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } $blocked = 1; @@ -257,14 +257,14 @@ class Register extends BaseModule // Is there text in the tar pit? if (!empty($arr['email'])) { Logger::info('Tar pit', $arr); - notice(DI::l10n()->t('You have entered too much information.')); + DI::sysmsg()->addNotice(DI::l10n()->t('You have entered too much information.')); DI::baseUrl()->redirect('register/'); } if ($additional_account) { $user = DBA::selectFirst('user', ['email'], ['uid' => local_user()]); if (!DBA::isResult($user)) { - notice(DI::l10n()->t('User not found.')); + DI::sysmsg()->addNotice(DI::l10n()->t('User not found.')); DI::baseUrl()->redirect('register'); } @@ -280,7 +280,7 @@ class Register extends BaseModule if ($arr['email'] != $arr['repeat']) { Logger::info('Mail mismatch', $arr); - notice(DI::l10n()->t('Please enter the identical mail address in the second field.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Please enter the identical mail address in the second field.')); $regdata = ['email' => $arr['email'], 'nickname' => $arr['nickname'], 'username' => $arr['username']]; DI::baseUrl()->redirect('register?' . http_build_query($regdata)); } @@ -292,7 +292,7 @@ class Register extends BaseModule try { $result = Model\User::create($arr); } catch (\Exception $e) { - notice($e->getMessage()); + DI::sysmsg()->addNotice($e->getMessage()); return; } @@ -307,7 +307,7 @@ class Register extends BaseModule if ($additional_account) { DBA::update('user', ['parent-uid' => local_user()], ['uid' => $user['uid']]); - info(DI::l10n()->t('The additional account was created.')); + DI::sysmsg()->addInfo(DI::l10n()->t('The additional account was created.')); DI::baseUrl()->redirect('delegation'); } @@ -332,28 +332,28 @@ class Register extends BaseModule ); if ($res) { - info(DI::l10n()->t('Registration successful. Please check your email for further instructions.')); + DI::sysmsg()->addInfo(DI::l10n()->t('Registration successful. Please check your email for further instructions.')); DI::baseUrl()->redirect(); } else { - notice( + DI::sysmsg()->addNotice( DI::l10n()->t('Failed to send email message. Here your accout details:
login: %s
password: %s

You can change your password after login.', $user['email'], $result['password']) ); } } else { - info(DI::l10n()->t('Registration successful.')); + DI::sysmsg()->addInfo(DI::l10n()->t('Registration successful.')); DI::baseUrl()->redirect(); } } elseif (intval(DI::config()->get('config', 'register_policy')) === self::APPROVE) { if (!strlen(DI::config()->get('config', 'admin_email'))) { - notice(DI::l10n()->t('Your registration can not be processed.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Your registration can not be processed.')); DI::baseUrl()->redirect(); } // Check if the note to the admin is actually filled out if (empty($_POST['permonlybox'])) { - notice(DI::l10n()->t('You have to leave a request note for the admin.') + DI::sysmsg()->addNotice(DI::l10n()->t('You have to leave a request note for the admin.') . DI::l10n()->t('Your registration can not be processed.')); DI::baseUrl()->redirect('register/'); @@ -399,7 +399,7 @@ class Register extends BaseModule $result['password'] ); - info(DI::l10n()->t('Your registration is pending approval by the site owner.')); + DI::sysmsg()->addInfo(DI::l10n()->t('Your registration is pending approval by the site owner.')); DI::baseUrl()->redirect(); } diff --git a/src/Module/RemoteFollow.php b/src/Module/RemoteFollow.php index 130c76319..05239440d 100644 --- a/src/Module/RemoteFollow.php +++ b/src/Module/RemoteFollow.php @@ -31,6 +31,7 @@ use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Search; use Friendica\Core\System; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Profile; use Friendica\Model\User; @@ -68,25 +69,25 @@ class RemoteFollow extends BaseModule } if (empty($this->owner)) { - notice($this->t('Profile unavailable.')); + DI::sysmsg()->addNotice($this->t('Profile unavailable.')); return; } $url = Probe::cleanURI($_POST['dfrn_url']); if (!strlen($url)) { - notice($this->t("Invalid locator")); + DI::sysmsg()->addNotice($this->t("Invalid locator")); return; } // Detect the network, make sure the provided URL is valid $data = Contact::getByURL($url); if (!$data) { - notice($this->t("The provided profile link doesn't seem to be valid")); + DI::sysmsg()->addNotice($this->t("The provided profile link doesn't seem to be valid")); return; } if (empty($data['subscribe'])) { - notice($this->t("Remote subscription can't be done for your network. Please subscribe directly on your system.")); + DI::sysmsg()->addNotice($this->t("Remote subscription can't be done for your network. Please subscribe directly on your system.")); return; } diff --git a/src/Module/Search/Directory.php b/src/Module/Search/Directory.php index 496a3e098..a088282cb 100644 --- a/src/Module/Search/Directory.php +++ b/src/Module/Search/Directory.php @@ -34,7 +34,7 @@ class Directory extends BaseSearch protected function content(array $request = []): string { if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return Login::form(); } diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index db20dd0a3..7dfdca39b 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -149,7 +149,7 @@ class Index extends BaseSearch // Tags don't look like an URL and the fulltext search does only work with natural words if (parse_url($search, PHP_URL_SCHEME) && parse_url($search, PHP_URL_HOST)) { Logger::info('Skipping tag and fulltext search since the search looks like a URL.', ['q' => $search]); - notice(DI::l10n()->t('No results.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No results.')); return $o; } @@ -191,7 +191,7 @@ class Index extends BaseSearch if (empty($items)) { if (empty($last_uriid)) { - notice(DI::l10n()->t('No results.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No results.')); } return $o; } diff --git a/src/Module/Search/Saved.php b/src/Module/Search/Saved.php index 4256ffcd4..cea0a9b1a 100644 --- a/src/Module/Search/Saved.php +++ b/src/Module/Search/Saved.php @@ -26,6 +26,7 @@ use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Search; use Friendica\Database\Database; +use Friendica\DI; use Friendica\Module\Response; use Friendica\Util\Profiler; use Psr\Log\LoggerInterface; @@ -55,16 +56,16 @@ class Saved extends BaseModule $fields = ['uid' => local_user(), 'term' => $search]; if (!$this->dba->exists('search', $fields)) { if (!$this->dba->insert('search', $fields)) { - notice($this->t('Search term was not saved.')); + DI::sysmsg()->addNotice($this->t('Search term was not saved.')); } } else { - notice($this->t('Search term already saved.')); + DI::sysmsg()->addNotice($this->t('Search term already saved.')); } break; case 'remove': if (!$this->dba->delete('search', ['uid' => local_user(), 'term' => $search])) { - notice($this->t('Search term was not removed.')); + DI::sysmsg()->addNotice($this->t('Search term was not removed.')); } break; } diff --git a/src/Module/Security/Logout.php b/src/Module/Security/Logout.php index 004292cb5..82c176feb 100644 --- a/src/Module/Security/Logout.php +++ b/src/Module/Security/Logout.php @@ -28,6 +28,7 @@ use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Core\System; +use Friendica\DI; use Friendica\Model\Profile; use Friendica\Model\User\Cookie; use Friendica\Module\Response; @@ -80,7 +81,7 @@ class Logout extends BaseModule if ($visitor_home) { System::externalRedirect($visitor_home); } else { - info($this->t('Logged out.')); + DI::sysmsg()->addInfo($this->t('Logged out.')); $this->baseUrl->redirect(); } } diff --git a/src/Module/Security/OpenID.php b/src/Module/Security/OpenID.php index 7dbb765c6..2675f1fec 100644 --- a/src/Module/Security/OpenID.php +++ b/src/Module/Security/OpenID.php @@ -87,9 +87,9 @@ class OpenID extends BaseModule $session->set('openid_server', $open_id_obj->discover($open_id_obj->identity)); if (intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED) { - notice($l10n->t('Account not found. Please login to your existing account to add the OpenID to it.')); + DI::sysmsg()->addNotice($l10n->t('Account not found. Please login to your existing account to add the OpenID to it.')); } else { - notice($l10n->t('Account not found. Please register a new account or login to your existing account to add the OpenID to it.')); + DI::sysmsg()->addNotice($l10n->t('Account not found. Please register a new account or login to your existing account to add the OpenID to it.')); } DI::baseUrl()->redirect('login'); diff --git a/src/Module/Security/TwoFactor/Recovery.php b/src/Module/Security/TwoFactor/Recovery.php index 6d8d91dbe..38b341dad 100644 --- a/src/Module/Security/TwoFactor/Recovery.php +++ b/src/Module/Security/TwoFactor/Recovery.php @@ -26,6 +26,7 @@ use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\Session\Capability\IHandleSessions; +use Friendica\DI; use Friendica\Model\User; use Friendica\Module\Response; use Friendica\Security\Authentication; @@ -70,13 +71,13 @@ class Recovery extends BaseModule if (RecoveryCode::existsForUser(local_user(), $recovery_code)) { RecoveryCode::markUsedForUser(local_user(), $recovery_code); $this->session->set('2fa', true); - info($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user()))); + DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user()))); $this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true); $this->baseUrl->redirect($this->session->pop('return_path', '')); } else { - notice($this->t('Invalid code, please retry.')); + DI::sysmsg()->addNotice($this->t('Invalid code, please retry.')); } } } diff --git a/src/Module/Security/TwoFactor/SignOut.php b/src/Module/Security/TwoFactor/SignOut.php index 75efc9e60..ac6e9321f 100644 --- a/src/Module/Security/TwoFactor/SignOut.php +++ b/src/Module/Security/TwoFactor/SignOut.php @@ -26,6 +26,7 @@ use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\Session\Capability\IHandleSessions; +use Friendica\DI; use Friendica\Model\User\Cookie; use Friendica\Module\Response; use Friendica\Network\HTTPException\NotFoundException; @@ -75,7 +76,7 @@ class SignOut extends BaseModule $this->cookie->reset(['2fa_cookie_hash' => $trusted]); $this->session->clear(); - info($this->t('Logged out.')); + DI::sysmsg()->addInfo($this->t('Logged out.')); $this->baseUrl->redirect(); break; case 'sign_out': @@ -83,7 +84,7 @@ class SignOut extends BaseModule $this->cookie->clear(); $this->session->clear(); - info($this->t('Logged out.')); + DI::sysmsg()->addInfo($this->t('Logged out.')); $this->baseUrl->redirect(); break; default: @@ -105,14 +106,14 @@ class SignOut extends BaseModule $this->cookie->reset(['2fa_cookie_hash' => $trusted]); $this->session->clear(); - info($this->t('Logged out.')); + DI::sysmsg()->addInfo($this->t('Logged out.')); $this->baseUrl->redirect(); } } catch (TwoFactor\Exception\TrustedBrowserNotFoundException $exception) { $this->cookie->clear(); $this->session->clear(); - info($this->t('Logged out.')); + DI::sysmsg()->addInfo($this->t('Logged out.')); $this->baseUrl->redirect(); } diff --git a/src/Module/Security/TwoFactor/Trust.php b/src/Module/Security/TwoFactor/Trust.php index 1f5fb7418..ed24c6b14 100644 --- a/src/Module/Security/TwoFactor/Trust.php +++ b/src/Module/Security/TwoFactor/Trust.php @@ -26,6 +26,7 @@ use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\Session\Capability\IHandleSessions; +use Friendica\DI; use Friendica\Model\User; use Friendica\Model\User\Cookie; use Friendica\Module\Response; @@ -92,7 +93,7 @@ class Trust extends BaseModule // The string is sent to the browser to be sent back with each request if (!$this->cookie->set('2fa_cookie_hash', $trustedBrowser->cookie_hash)) { - notice($this->t('Couldn\'t save browser to Cookie.')); + DI::sysmsg()->addNotice($this->t('Couldn\'t save browser to Cookie.')); }; } catch (TrustedBrowserPersistenceException $exception) { $this->logger->warning('Unexpected error when saving the trusted browser.', ['trustedBrowser' => $trustedBrowser, 'exception' => $exception]); diff --git a/src/Module/Settings/Account.php b/src/Module/Settings/Account.php index 62ad08a4c..bb262ab1a 100644 --- a/src/Module/Settings/Account.php +++ b/src/Module/Settings/Account.php @@ -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 ''; } diff --git a/src/Module/Settings/Delegation.php b/src/Module/Settings/Delegation.php index 75e683e60..aeada0871 100644 --- a/src/Module/Settings/Delegation.php +++ b/src/Module/Settings/Delegation.php @@ -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'); } diff --git a/src/Module/Settings/Display.php b/src/Module/Settings/Display.php index 4670bf500..fe42b8718 100644 --- a/src/Module/Settings/Display.php +++ b/src/Module/Settings/Display.php @@ -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); diff --git a/src/Module/Settings/Profile/Index.php b/src/Module/Settings/Profile/Index.php index 49130e8c5..eec7468d0 100644 --- a/src/Module/Settings/Profile/Index.php +++ b/src/Module/Settings/Profile/Index.php @@ -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(); } diff --git a/src/Module/Settings/Profile/Photo/Crop.php b/src/Module/Settings/Profile/Photo/Crop.php index ee9ac3246..5afab9503 100644 --- a/src/Module/Settings/Profile/Photo/Crop.php +++ b/src/Module/Settings/Profile/Photo/Crop.php @@ -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()); } diff --git a/src/Module/Settings/Profile/Photo/Index.php b/src/Module/Settings/Profile/Photo/Index.php index ff2a239b5..4f0b5ddad 100644 --- a/src/Module/Settings/Profile/Photo/Index.php +++ b/src/Module/Settings/Profile/Photo/Index.php @@ -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')); } } diff --git a/src/Module/Settings/TwoFactor/AppSpecific.php b/src/Module/Settings/TwoFactor/AppSpecific.php index 5fc513393..69b509131 100644 --- a/src/Module/Settings/TwoFactor/AppSpecific.php +++ b/src/Module/Settings/TwoFactor/AppSpecific.php @@ -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')); diff --git a/src/Module/Settings/TwoFactor/Index.php b/src/Module/Settings/TwoFactor/Index.php index 0da49f317..be3d8d232 100644 --- a/src/Module/Settings/TwoFactor/Index.php +++ b/src/Module/Settings/TwoFactor/Index.php @@ -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())); } } diff --git a/src/Module/Settings/TwoFactor/Recovery.php b/src/Module/Settings/TwoFactor/Recovery.php index 9d453d5a2..04749f2f8 100644 --- a/src/Module/Settings/TwoFactor/Recovery.php +++ b/src/Module/Settings/TwoFactor/Recovery.php @@ -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')); } } diff --git a/src/Module/Settings/TwoFactor/Trusted.php b/src/Module/Settings/TwoFactor/Trusted.php index 140394e07..61f97dbd1 100644 --- a/src/Module/Settings/TwoFactor/Trusted.php +++ b/src/Module/Settings/TwoFactor/Trusted.php @@ -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')); diff --git a/src/Module/Settings/TwoFactor/Verify.php b/src/Module/Settings/TwoFactor/Verify.php index 7b5bea385..3d7db0118 100644 --- a/src/Module/Settings/TwoFactor/Verify.php +++ b/src/Module/Settings/TwoFactor/Verify.php @@ -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.')); } } } diff --git a/src/Security/Authentication.php b/src/Security/Authentication.php index 42dc02340..3cd7b76bc 100644 --- a/src/Security/Authentication.php +++ b/src/Security/Authentication.php @@ -223,7 +223,7 @@ class Authentication // if it's an email address or doesn't resolve to a URL, fail. if ($noid || strpos($openid_url, '@') || !Network::isUrlValid($openid_url)) { - notice($this->l10n->t('Login failed.')); + DI::sysmsg()->addNotice($this->l10n->t('Login failed.')); $this->baseUrl->redirect(); } @@ -237,7 +237,7 @@ class Authentication $openid->optional = ['namePerson/friendly', 'contact/email', 'namePerson', 'namePerson/first', 'media/image/aspect11', 'media/image/default']; System::externalRedirect($openid->authUrl()); } catch (Exception $e) { - notice($this->l10n->t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . '

' . $this->l10n->t('The error message was:') . ' ' . $e->getMessage()); + DI::sysmsg()->addNotice($this->l10n->t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . '

' . $this->l10n->t('The error message was:') . ' ' . $e->getMessage()); } } @@ -268,7 +268,7 @@ class Authentication ); } catch (Exception $e) { $this->logger->warning('authenticate: failed login attempt', ['action' => 'login', 'username' => $username, 'ip' => $this->remoteAddress]); - notice($this->l10n->t('Login failed. Please check your credentials.')); + DI::sysmsg()->addNotice($this->l10n->t('Login failed. Please check your credentials.')); $this->baseUrl->redirect(); } @@ -379,8 +379,8 @@ class Authentication if ($interactive) { if ($user_record['login_date'] <= DBA::NULL_DATETIME) { - info($this->l10n->t('Welcome %s', $user_record['username'])); - info($this->l10n->t('Please upload a profile photo.')); + DI::sysmsg()->addInfo($this->l10n->t('Welcome %s', $user_record['username'])); + DI::sysmsg()->addInfo($this->l10n->t('Please upload a profile photo.')); $this->baseUrl->redirect('settings/profile/photo/new'); } }