1
0
Fork 0

Merge branch 'develop' into rewrite/gravity-constants

This commit is contained in:
Roland Häder 2022-10-18 16:34:40 +02:00 committed by GitHub
commit 26e0469de7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
181 changed files with 2408 additions and 2405 deletions

View file

@ -58,6 +58,10 @@ use Psr\Log\LoggerInterface;
*/
class App
{
const PLATFORM = 'Friendica';
const CODENAME = 'Giant Rhubarb';
const VERSION = '2022.12-dev';
// Allow themes to control internal parameters
// by changing App values in theme.php
private $theme_info = [
@ -347,6 +351,11 @@ class App
{
set_time_limit(0);
// Normally this constant is defined - but not if "pcntl" isn't installed
if (!defined('SIGTERM')) {
define('SIGTERM', 15);
}
// Ensure that all "strtotime" operations do run timezone independent
date_default_timezone_set('UTC');

View file

@ -202,7 +202,7 @@ class Page implements ArrayAccess
*/
public function registerStylesheet(string $path, string $media = 'screen')
{
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
$path = Network::appendQueryParam($path, ['v' => App::VERSION]);
if (mb_strpos($path, $this->basePath . DIRECTORY_SEPARATOR) === 0) {
$path = mb_substr($path, mb_strlen($this->basePath . DIRECTORY_SEPARATOR));
@ -277,7 +277,7 @@ class Page implements ArrayAccess
*/
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
'$local_user' => local_user(),
'$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
'$generator' => 'Friendica' . ' ' . App::VERSION,
'$delitem' => $l10n->t('Delete this item?'),
'$blockAuthor' => $l10n->t('Block this author? They won\'t be able to follow you nor see your public posts, and you won\'t be able to see their posts and their notifications.'),
'$update_interval' => $interval,
@ -395,7 +395,7 @@ class Page implements ArrayAccess
*/
public function registerFooterScript($path)
{
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
$path = Network::appendQueryParam($path, ['v' => App::VERSION]);
$url = str_replace($this->basePath . DIRECTORY_SEPARATOR, '', $path);
@ -543,7 +543,7 @@ class Page implements ArrayAccess
$page = $this->page;
header("X-Friendica-Version: " . FRIENDICA_VERSION);
header("X-Friendica-Version: " . App::VERSION);
header("Content-type: text/html; charset=utf-8");
if ($config->get('system', 'hsts') && ($baseURL->getSSLPolicy() == BaseURL::SSL_POLICY_FULL)) {

View file

@ -389,7 +389,7 @@ abstract class BaseModule implements ICanHandleRequests
public static function getFormSecurityStandardErrorMessage(): string
{
return DI::l10n()->t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.") . EOL;
return DI::l10n()->t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.");
}
public static function checkFormSecurityTokenRedirectOnError(string $err_redirect, string $typename = '', string $formname = 'form_security_token')
@ -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);
}
}

View file

@ -197,7 +197,7 @@ HELP;
$this->out('Schedule relocation messages to remote Friendica and Diaspora hosts');
$users = $this->database->selectToArray('user', ['uid'], ['account_removed' => false, 'account_expired' => false]);
foreach ($users as $user) {
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $user['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $user['uid']);
}
return 0;

View file

@ -261,7 +261,7 @@ class Conversation
break;
}
$expanded .= "\t" . '<p class="wall-item-' . $verb . '-expanded" id="' . $verb . 'list-' . $id . '" style="display: none;" >' . $explikers . EOL . '</p>';
$expanded .= "\t" . '<p class="wall-item-' . $verb . '-expanded" id="' . $verb . 'list-' . $id . '" style="display: none;" >' . $explikers . '</p>';
}
$o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('voting_fakelink.tpl'), [
@ -328,7 +328,7 @@ class Conversation
$created_at = '';
}
$tpl = Renderer::getMarkupTemplate("jot.tpl");
$tpl = Renderer::getMarkupTemplate('jot.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$new_post' => $this->l10n->t('New Post'),
@ -393,7 +393,8 @@ class Conversation
'$message' => $this->l10n->t('Message'),
'$browser' => $this->l10n->t('Browser'),
'$compose_link_title' => $this->l10n->t('Open Compose page'),
'$compose_link_title' => $this->l10n->t('Open Compose page'),
'$always_open_compose' => $this->pConfig->get(local_user(), 'frio', 'always_open_compose', false),
]);

View file

@ -574,9 +574,10 @@ class Item
*
* @param string $url
* @param integer $uid
* @param bool $add_media
* @return string
*/
public function createSharedPostByUrl(string $url, int $uid = 0): string
public function createSharedPostByUrl(string $url, int $uid = 0, bool $add_media = false): string
{
if (!empty($uid)) {
$id = ModelItem::searchByLink($url, $uid);
@ -599,7 +600,7 @@ class Item
return '';
}
return $this->createSharedBlockByArray($shared_item);
return $this->createSharedBlockByArray($shared_item, $add_media);
}
/**
@ -607,9 +608,10 @@ class Item
*
* @param integer $UriId
* @param integer $uid
* @param bool $add_media
* @return string
*/
public function createSharedPostByUriId(int $UriId, int $uid = 0): string
public function createSharedPostByUriId(int $UriId, int $uid = 0, bool $add_media = false): string
{
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network'];
$shared_item = Post::selectFirst($fields, ['uri-id' => $UriId, 'uid' => [$uid, 0], 'private' => [ModelItem::PUBLIC, ModelItem::UNLISTED]]);
@ -618,7 +620,7 @@ class Item
return '';
}
return $this->createSharedBlockByArray($shared_item);
return $this->createSharedBlockByArray($shared_item, $add_media);
}
/**
@ -626,9 +628,10 @@ class Item
*
* @param string $guid
* @param integer $uid
* @param bool $add_media
* @return string
*/
public function createSharedPostByGuid(string $guid, int $uid = 0, string $host = ''): string
public function createSharedPostByGuid(string $guid, int $uid = 0, string $host = '', bool $add_media = false): string
{
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network'];
$shared_item = Post::selectFirst($fields, ['guid' => $guid, 'uid' => [$uid, 0], 'private' => [ModelItem::PUBLIC, ModelItem::UNLISTED]]);
@ -645,16 +648,17 @@ class Item
return '';
}
return $this->createSharedBlockByArray($shared_item);
return $this->createSharedBlockByArray($shared_item, $add_media);
}
/**
* Add a share block for the given item array
*
* @param array $item
* @param bool $add_media
* @return string
*/
public function createSharedBlockByArray(array $item): string
public function createSharedBlockByArray(array $item, bool $add_media = false): string
{
if ($item['network'] == Protocol::FEED) {
return PageInfo::getFooterFromUrl($item['plink']);
@ -662,6 +666,8 @@ class Item
$item['guid'] = '';
$item['uri'] = '';
$item['body'] = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
} elseif ($add_media) {
$item['body'] = Post\Media::addAttachmentsToBody($item['uri-id'], $item['body']);
}
$shared_content = BBCode::getShareOpeningTag($item['author-name'], $item['author-link'], $item['author-avatar'], $item['plink'], $item['created'], $item['guid'], $item['uri']);
@ -674,7 +680,7 @@ class Item
// If it is a reshared post then reformat it to avoid display problems with two share elements
if (Diaspora::isReshare($item['body'], false)) {
if (!empty($shared['guid']) && ($encaspulated_share = self::createSharedPostByGuid($shared['guid']))) {
if (!empty($shared['guid']) && ($encaspulated_share = self::createSharedPostByGuid($shared['guid'], 0, '', $add_media))) {
$item['body'] = preg_replace("/\[share.*?\](.*)\[\/share\]/ism", $encaspulated_share, $item['body']);
}

View file

@ -30,6 +30,7 @@ use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Module\Conversation\Community;
class Nav
{
@ -251,8 +252,8 @@ class Nav
}
}
if ((local_user() || DI::config()->get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) &&
!(DI::config()->get('system', 'community_page_style') == CP_NO_INTERNAL_COMMUNITY)) {
if ((local_user() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
!(DI::config()->get('system', 'community_page_style') == Community::DISABLED)) {
$nav['community'] = ['community', DI::l10n()->t('Community'), '', DI::l10n()->t('Conversations on this and other servers')];
}

View file

@ -1069,6 +1069,38 @@ class BBCode
return $attributes;
}
/**
* Replace the share block with a link
*
* @param string $body
* @return string
*/
public static function replaceSharedData(string $body): string
{
return BBCode::convertShare(
$body,
function (array $attributes) {
return '♲ ' . $attributes['link'];
}
);
}
/**
* Remove the share block
*
* @param string $body
* @return string
*/
public static function removeSharedData(string $body): string
{
return BBCode::convertShare(
$body,
function (array $attributes) {
return '';
}
);
}
/**
* This function converts a [share] block to text according to a provided callback function whose signature is:
*
@ -1118,7 +1150,7 @@ class BBCode
);
DI::profiler()->stopRecording();
return $return;
return trim($return);
}
/**

View file

@ -23,6 +23,7 @@ namespace Friendica\Core;
use Dice\Dice;
use Friendica;
use Friendica\App;
/**
* Description of Console
@ -133,7 +134,7 @@ HELP;
$command = null;
if ($this->getOption('version')) {
$this->out('Friendica Console version ' . FRIENDICA_VERSION);
$this->out('Friendica Console version ' . App::VERSION);
return 0;
} elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0

View file

@ -197,7 +197,7 @@ class Installer
$result = DBStructure::install();
if ($result) {
$txt = DI::l10n()->t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL;
$txt = DI::l10n()->t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . '<br />';
$txt .= DI::l10n()->t('Please see the file "doc/INSTALL.md".');
$this->addCheck($txt, false, true, htmlentities($result, ENT_COMPAT, 'UTF-8'));
@ -259,9 +259,9 @@ class Installer
$help = "";
if (!$passed) {
$help .= DI::l10n()->t('Could not find a command line version of PHP in the web server PATH.') . EOL;
$help .= DI::l10n()->t("If you don't have a command line version of PHP installed on your server, you will not be able to run the background processing. See <a href='https://github.com/friendica/friendica/blob/stable/doc/Install.md#set-up-the-worker'>'Setup the worker'</a>") . EOL;
$help .= EOL . EOL;
$help .= DI::l10n()->t('Could not find a command line version of PHP in the web server PATH.') . '<br />';
$help .= DI::l10n()->t("If you don't have a command line version of PHP installed on your server, you will not be able to run the background processing. See <a href='https://github.com/friendica/friendica/blob/stable/doc/Install.md#set-up-the-worker'>'Setup the worker'</a>") . '<br />';
$help .= '<br /><br />';
$tpl = Renderer::getMarkupTemplate('field_input.tpl');
/// @todo Separate backend Installer class and presentation layer/view
$help .= Renderer::replaceMacros($tpl, [
@ -279,7 +279,7 @@ class Installer
[$result] = explode("\n", $result);
$help = "";
if (!$passed2) {
$help .= DI::l10n()->t("PHP executable is not the php cli binary \x28could be cgi-fgci version\x29") . EOL;
$help .= DI::l10n()->t("PHP executable is not the php cli binary \x28could be cgi-fgci version\x29") . '<br />';
$help .= DI::l10n()->t('Found PHP version: ') . "<tt>$result</tt>";
}
$this->addCheck(DI::l10n()->t('PHP cli binary'), $passed2, true, $help);
@ -295,7 +295,7 @@ class Installer
$passed3 = $result == $str;
$help = "";
if (!$passed3) {
$help .= DI::l10n()->t('The command line version of PHP on your system does not have "register_argc_argv" enabled.') . EOL;
$help .= DI::l10n()->t('The command line version of PHP on your system does not have "register_argc_argv" enabled.') . '<br />';
$help .= DI::l10n()->t('This is required for message delivery to work.');
} else {
$this->phppath = $phppath;
@ -333,7 +333,7 @@ class Installer
// Get private key
if (!$res) {
$help .= DI::l10n()->t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys') . EOL;
$help .= DI::l10n()->t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys') . '<br />';
$help .= DI::l10n()->t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".');
$status = false;
}
@ -511,10 +511,10 @@ class Installer
(!file_exists('config/local.config.php') && !is_writable('.'))) {
$status = false;
$help = DI::l10n()->t('The web installer needs to be able to create a file called "local.config.php" in the "config" folder of your web server and it is unable to do so.') . EOL;
$help .= DI::l10n()->t('This is most often a permission setting, as the web server may not be able to write files in your folder - even if you can.') . EOL;
$help .= DI::l10n()->t('At the end of this procedure, we will give you a text to save in a file named local.config.php in your Friendica "config" folder.') . EOL;
$help .= DI::l10n()->t('You can alternatively skip this procedure and perform a manual installation. Please see the file "doc/INSTALL.md" for instructions.') . EOL;
$help = DI::l10n()->t('The web installer needs to be able to create a file called "local.config.php" in the "config" folder of your web server and it is unable to do so.') . '<br />';
$help .= DI::l10n()->t('This is most often a permission setting, as the web server may not be able to write files in your folder - even if you can.') . '<br />';
$help .= DI::l10n()->t('At the end of this procedure, we will give you a text to save in a file named local.config.php in your Friendica "config" folder.') . '<br />';
$help .= DI::l10n()->t('You can alternatively skip this procedure and perform a manual installation. Please see the file "doc/INSTALL.md" for instructions.') . '<br />';
}
$this->addCheck(DI::l10n()->t('config/local.config.php is writable'), $status, false, $help);
@ -537,10 +537,10 @@ class Installer
if (!is_writable('view/smarty3')) {
$status = false;
$help = DI::l10n()->t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') . EOL;
$help .= DI::l10n()->t('In order to store these compiled templates, the web server needs to have write access to the directory view/smarty3/ under the Friendica top level folder.') . EOL;
$help .= DI::l10n()->t("Please ensure that the user that your web server runs as \x28e.g. www-data\x29 has write access to this folder.") . EOL;
$help .= DI::l10n()->t("Note: as a security measure, you should give the web server write access to view/smarty3/ only--not the template files \x28.tpl\x29 that it contains.") . EOL;
$help = DI::l10n()->t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') . '<br />';
$help .= DI::l10n()->t('In order to store these compiled templates, the web server needs to have write access to the directory view/smarty3/ under the Friendica top level folder.') . '<br />';
$help .= DI::l10n()->t("Please ensure that the user that your web server runs as \x28e.g. www-data\x29 has write access to this folder.") . '<br />';
$help .= DI::l10n()->t("Note: as a security measure, you should give the web server write access to view/smarty3/ only--not the template files \x28.tpl\x29 that it contains.") . '<br />';
}
$this->addCheck(DI::l10n()->t('view/smarty3 is writable'), $status, true, $help);
@ -571,7 +571,7 @@ class Installer
if ($fetchResult->getReturnCode() != 204) {
$status = false;
$help = DI::l10n()->t('Url rewrite in .htaccess seems not working. Make sure you copied .htaccess-dist to .htaccess.') . EOL;
$help = DI::l10n()->t('Url rewrite in .htaccess seems not working. Make sure you copied .htaccess-dist to .htaccess.') . '<br />';
$help .= DI::l10n()->t('In some circumstances (like running inside containers), you can skip this error.');
$error_msg = [];
$error_msg['head'] = DI::l10n()->t('Error message from Curl when fetching');

View file

@ -22,19 +22,16 @@
namespace Friendica\Core\Logger\Factory;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Logger\Exception\LoggerException;
use Friendica\Core;
use Friendica\Core\Logger\Exception\LogLevelException;
use Friendica\Database\Database;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\FileSystem;
use Friendica\Core\Logger\Util\Introspection;
use Friendica\Core\Logger\Type\Monolog\DevelopHandler;
use Friendica\Core\Logger\Type\Monolog\IntrospectionProcessor;
use Friendica\Core\Logger\Type\ProfilerLogger;
use Friendica\Core\Logger\Type\StreamLogger;
use Friendica\Core\Logger\Type\SyslogLogger;
use Friendica\Util\Profiler;
use Monolog;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Psr\Log\NullLogger;
@ -60,9 +57,15 @@ class Logger
/** @var string The log-channel (app, worker, ...) */
private $channel;
public function __construct(string $channel)
public function __construct(string $channel, bool $includeAddon = true)
{
$this->channel = $channel;
/// @fixme clean solution = Making Addon & Hook dynamic and load them inside the constructor, so there's no custom load logic necessary anymore
if ($includeAddon) {
Core\Addon::loadAddons();
Core\Hook::loadHooks();
}
}
/**
@ -88,35 +91,9 @@ class Logger
$minLevel = $minLevel ?? $config->get('system', 'loglevel');
$loglevel = self::mapLegacyConfigDebugLevel((string)$minLevel);
switch ($config->get('system', 'logger_config', 'stream')) {
case 'monolog':
$loggerTimeZone = new \DateTimeZone('UTC');
Monolog\Logger::setTimezone($loggerTimeZone);
$logger = new Monolog\Logger($this->channel);
$logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor());
$logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor());
$logger->pushProcessor(new Monolog\Processor\UidProcessor());
$logger->pushProcessor(new IntrospectionProcessor($introspection, LogLevel::DEBUG));
$stream = $config->get('system', 'logfile');
// just add a stream in case it's either writable or not file
if (!is_file($stream) || is_writable($stream)) {
try {
static::addStreamHandler($logger, $stream, $loglevel);
} catch (\Throwable $e) {
// No Logger ..
try {
$logger = new SyslogLogger($this->channel, $introspection, $loglevel);
} catch (\Throwable $e) {
// No logger ...
$logger = new NullLogger();
}
}
}
break;
$name = $config->get('system', 'logger_config', 'stream');
switch ($name) {
case 'syslog':
try {
$logger = new SyslogLogger($this->channel, $introspection, $loglevel, $config->get('system', 'syslog_flags', SyslogLogger::DEFAULT_FLAGS), $config->get('system', 'syslog_facility', SyslogLogger::DEFAULT_FACILITY));
@ -132,29 +109,48 @@ class Logger
case 'stream':
default:
$stream = $config->get('system', 'logfile');
// just add a stream in case it's either writable or not file
if (!is_file($stream) || is_writable($stream)) {
try {
$logger = new StreamLogger($this->channel, $stream, $introspection, $fileSystem, $loglevel);
} catch (LogLevelException $exception) {
// If there's a wrong config value for loglevel, try again with standard
$logger = $this->create($database, $config, $profiler, $fileSystem, LogLevel::NOTICE);
$logger->warning('Invalid loglevel set in config.', ['loglevel' => $loglevel]);
} catch (\Throwable $t) {
// No logger ...
$logger = new NullLogger();
}
} else {
try {
$logger = new SyslogLogger($this->channel, $introspection, $loglevel);
} catch (LogLevelException $exception) {
// If there's a wrong config value for loglevel, try again with standard
$logger = $this->create($database, $config, $profiler, $fileSystem, LogLevel::NOTICE);
$logger->warning('Invalid loglevel set in config.', ['loglevel' => $loglevel]);
} catch (\Throwable $e) {
// No logger ...
$logger = new NullLogger();
$data = [
'name' => $name,
'channel' => $this->channel,
'introspection' => $introspection,
'loglevel' => $loglevel,
'logger' => null,
];
try {
Core\Hook::callAll('logger_instance', $data);
} catch (InternalServerErrorException $exception) {
$data['logger'] = null;
}
if (($data['logger'] ?? null) instanceof LoggerInterface) {
$logger = $data['logger'];
}
if (empty($logger)) {
$stream = $config->get('system', 'logfile');
// just add a stream in case it's either writable or not file
if (!is_file($stream) || is_writable($stream)) {
try {
$logger = new StreamLogger($this->channel, $stream, $introspection, $fileSystem, $loglevel);
} catch (LogLevelException $exception) {
// If there's a wrong config value for loglevel, try again with standard
$logger = $this->create($database, $config, $profiler, $fileSystem, LogLevel::NOTICE);
$logger->warning('Invalid loglevel set in config.', ['loglevel' => $loglevel]);
} catch (\Throwable $t) {
// No logger ...
$logger = new NullLogger();
}
} else {
try {
$logger = new SyslogLogger($this->channel, $introspection, $loglevel);
} catch (LogLevelException $exception) {
// If there's a wrong config value for loglevel, try again with standard
$logger = $this->create($database, $config, $profiler, $fileSystem, LogLevel::NOTICE);
$logger->warning('Invalid loglevel set in config.', ['loglevel' => $loglevel]);
} catch (\Throwable $e) {
// No logger ...
$logger = new NullLogger();
}
}
}
break;
@ -197,27 +193,11 @@ class Logger
return new NullLogger();
}
$loggerTimeZone = new \DateTimeZone('UTC');
Monolog\Logger::setTimezone($loggerTimeZone);
$introspection = new Introspection(self::$ignoreClassList);
switch ($config->get('system', 'logger_config', 'stream')) {
$name = $config->get('system', 'logger_config', 'stream');
case 'monolog':
$loggerTimeZone = new \DateTimeZone('UTC');
Monolog\Logger::setTimezone($loggerTimeZone);
$logger = new Monolog\Logger(self::DEV_CHANNEL);
$logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor());
$logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor());
$logger->pushProcessor(new Monolog\Processor\UidProcessor());
$logger->pushProcessor(new IntrospectionProcessor($introspection, LogLevel::DEBUG));
$logger->pushHandler(new DevelopHandler($developerIp));
static::addStreamHandler($logger, $stream, LogLevel::DEBUG);
break;
switch ($name) {
case 'syslog':
$logger = new SyslogLogger(self::DEV_CHANNEL, $introspection, LogLevel::DEBUG);
@ -225,6 +205,23 @@ class Logger
case 'stream':
default:
$data = [
'name' => $name,
'channel' => self::DEV_CHANNEL,
'introspection' => $introspection,
'loglevel' => LogLevel::DEBUG,
'logger' => null,
];
try {
Core\Hook::callAll('logger_instance', $data);
} catch (InternalServerErrorException $exception) {
$data['logger'] = null;
}
if (($data['logger'] ?? null) instanceof LoggerInterface) {
return $data['logger'];
}
$logger = new StreamLogger(self::DEV_CHANNEL, $stream, $introspection, $fileSystem, LogLevel::DEBUG);
break;
}
@ -273,38 +270,4 @@ class Logger
return $level;
}
}
/**
* Adding a handler to a given logger instance
*
* @param LoggerInterface $logger The logger instance
* @param mixed $stream The stream which handles the logger output
* @param string $level The level, for which this handler at least should handle logging
*
* @return void
*
* @throws LoggerException
*/
public static function addStreamHandler(LoggerInterface $logger, $stream, string $level = LogLevel::NOTICE)
{
if ($logger instanceof Monolog\Logger) {
$loglevel = Monolog\Logger::toMonologLevel($level);
// fallback to notice if an invalid loglevel is set
if (!is_int($loglevel)) {
$loglevel = LogLevel::NOTICE;
}
try {
$fileHandler = new Monolog\Handler\StreamHandler($stream, $loglevel);
$formatter = new Monolog\Formatter\LineFormatter("%datetime% %channel% [%level_name%]: %message% %context% %extra%\n");
$fileHandler->setFormatter($formatter);
$logger->pushHandler($fileHandler);
} catch (\Exception $exception) {
throw new LoggerException('Cannot create Monolog Logger.', $exception);
}
}
}
}

View file

@ -1,76 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Core\Logger\Type\Monolog;
use Friendica\App\Request;
use Monolog\Handler;
use Monolog\Logger;
/**
* Simple handler for Friendica developers to use for deeper logging
*
* If you want to debug only interactions from your IP or the IP of a remote server for federation debug,
* you'll use Logger::develop() for the duration of your work, and you clean it up when you're done before submitting your PR.
*/
class DevelopHandler extends Handler\AbstractHandler
{
/**
* @var string The IP of the developer who wants to debug
*/
private $developerIp;
/**
* @var string The IP of the current request
*/
private $remoteAddress;
/**
* @param Request $request The current http request
* @param string $developerIp The IP of the developer who wants to debug
* @param int $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct(Request $request, $developerIp, int $level = Logger::DEBUG, bool $bubble = true)
{
parent::__construct($level, $bubble);
$this->developerIp = $developerIp;
$this->remoteAddress = $request->getRemoteAddress();
}
/**
* {@inheritdoc}
*/
public function handle(array $record): bool
{
if (!$this->isHandling($record)) {
return false;
}
/// Just in case the remote IP is the same as the developer IP log the output
if (!is_null($this->developerIp) && $this->remoteAddress != $this->developerIp) {
return false;
}
return false === $this->bubble;
}
}

View file

@ -1,62 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Core\Logger\Type\Monolog;
use Friendica\Core\Logger\Util\Introspection;
use Monolog\Logger;
use Monolog\Processor\ProcessorInterface;
/**
* Injects line/file//function where the log message came from
*/
class IntrospectionProcessor implements ProcessorInterface
{
private $level;
private $introspection;
/**
* @param Introspection $introspection Holds the Introspection of the current call
* @param string|int $level The minimum logging level at which this Processor will be triggered
*/
public function __construct(Introspection $introspection, $level = Logger::DEBUG)
{
$this->level = Logger::toMonologLevel($level);
$introspection->addClasses(['Monolog\\']);
$this->introspection = $introspection;
}
public function __invoke(array $record): array
{
// return if the level is not high enough
if ($record['level'] < $this->level) {
return $record;
}
// we should have the call source now
$record['extra'] = array_merge(
$record['extra'],
$this->introspection->getRecord()
);
return $record;
}
}

View file

@ -5,7 +5,6 @@ This namespace contains the different implementations of a Logger.
### Configuration guideline
The following settings are possible for `logger_config`:
- `monolog`: A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)). There are just Friendica additions inside the Monolog directory
- [`stream`](StreamLogger.php): A small logger for files or streams
- [`syslog`](SyslogLogger.php): Prints the logging output into the syslog

View file

@ -192,7 +192,7 @@ class Search
}
// Add found profiles from the global directory to the local directory
Worker::add(PRIORITY_LOW, 'SearchDirectory', $search);
Worker::add(Worker::PRIORITY_LOW, 'SearchDirectory', $search);
return $resultList;
}

View file

@ -69,6 +69,68 @@ class Session
DI::session()->clear();
}
/**
* Returns the user id of locally logged in user or false.
*
* @return int|bool user id or false
*/
public static function getLocalUser()
{
$session = DI::session();
if (!empty($session->get('authenticated')) && !empty($session->get('uid'))) {
return intval($session->get('uid'));
}
return false;
}
/**
* Returns the public contact id of logged in user or false.
*
* @return int|bool public contact id or false
*/
public static function getPublicContact()
{
static $public_contact_id = false;
$session = DI::session();
if (!$public_contact_id && !empty($session->get('authenticated'))) {
if (!empty($session->get('my_address'))) {
// Local user
$public_contact_id = intval(Contact::getIdForURL($session->get('my_address'), 0, false));
} elseif (!empty($session->get('visitor_home'))) {
// Remote user
$public_contact_id = intval(Contact::getIdForURL($session->get('visitor_home'), 0, false));
}
} elseif (empty($session->get('authenticated'))) {
$public_contact_id = false;
}
return $public_contact_id;
}
/**
* Returns public contact id of authenticated site visitor or false
*
* @return int|bool visitor_id or false
*/
public static function getRemoteUser()
{
$session = DI::session();
if (empty($session->get('authenticated'))) {
return false;
}
if (!empty($session->get('visitor_id'))) {
return intval($session->get('visitor_id'));
}
return false;
}
/**
* Return the user contact ID of a visitor for the given user ID they are visiting
*

View file

@ -442,10 +442,13 @@ class System
*/
public static function getLoadAvg(): array
{
$content = @file_get_contents('/proc/loadavg');
if (empty($content)) {
$content = shell_exec('cat /proc/loadavg');
if (is_readable('/proc/loadavg')) {
$content = @file_get_contents('/proc/loadavg');
if (empty($content)) {
$content = shell_exec('cat /proc/loadavg');
}
}
if (empty($content) || !preg_match("#([.\d]+)\s([.\d]+)\s([.\d]+)\s(\d+)/(\d+)#", $content, $matches)) {
$load_arr = sys_getloadavg();
if (empty($load_arr)) {

View file

@ -35,6 +35,8 @@ class Update
const SUCCESS = 0;
const FAILED = 1;
const NEW_TABLE_STRUCTURE_VERSION = 1288;
/**
* Function to check if the Database structure needs an update.
*
@ -63,7 +65,7 @@ class Update
}
// We don't support upgrading from very old versions anymore
if ($build < NEW_TABLE_STRUCTURE_VERSION) {
if ($build < self::NEW_TABLE_STRUCTURE_VERSION) {
$error = DI::l10n()->t('Updates from version %s are not supported. Please update at least to version 2021.01 and wait until the postupdate finished version 1383.', $build);
if (DI::mode()->getExecutor() == Mode::INDEX) {
die($error);
@ -73,8 +75,8 @@ class Update
}
// The postupdate has to completed version 1288 for the new post views to take over
$postupdate = DI::config()->get('system', 'post_update_version', NEW_TABLE_STRUCTURE_VERSION);
if ($postupdate < NEW_TABLE_STRUCTURE_VERSION) {
$postupdate = DI::config()->get('system', 'post_update_version', self::NEW_TABLE_STRUCTURE_VERSION);
if ($postupdate < self::NEW_TABLE_STRUCTURE_VERSION) {
$error = DI::l10n()->t('Updates from postupdate version %s are not supported. Please update at least to version 2021.01 and wait until the postupdate finished version 1383.', $postupdate);
if (DI::mode()->getExecutor() == Mode::INDEX) {
die($error);
@ -92,7 +94,7 @@ class Update
*/
self::run($basePath);
} else {
Worker::add(PRIORITY_CRITICAL, 'DBUpdate');
Worker::add(Worker::PRIORITY_CRITICAL, 'DBUpdate');
}
}
}

View file

@ -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;
@ -322,9 +322,9 @@ class UserImport
}
// send relocate messages
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $newuid);
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');
}
}

View file

@ -31,12 +31,20 @@ use Friendica\Util\DateTimeFormat;
*/
class Worker
{
const PRIORITY_UNDEFINED = PRIORITY_UNDEFINED;
const PRIORITY_CRITICAL = PRIORITY_CRITICAL;
const PRIORITY_HIGH = PRIORITY_HIGH;
const PRIORITY_MEDIUM = PRIORITY_MEDIUM;
const PRIORITY_LOW = PRIORITY_LOW;
const PRIORITY_NEGLIGIBLE = PRIORITY_NEGLIGIBLE;
/**
* @name Priority
*
* Process priority for the worker
* @{
*/
const PRIORITY_UNDEFINED = 0;
const PRIORITY_CRITICAL = 10;
const PRIORITY_HIGH = 20;
const PRIORITY_MEDIUM = 30;
const PRIORITY_LOW = 40;
const PRIORITY_NEGLIGIBLE = 50;
const PRIORITIES = [self::PRIORITY_CRITICAL, self::PRIORITY_HIGH, self::PRIORITY_MEDIUM, self::PRIORITY_LOW, self::PRIORITY_NEGLIGIBLE];
/* @}*/
const STATE_STARTUP = 1; // Worker is in startup. This takes most time.
const STATE_LONG_LOOP = 2; // Worker is processing the whole - long - loop.
@ -807,7 +815,7 @@ class Worker
$top_priority = self::highestPriority();
$high_running = self::processWithPriorityActive($top_priority);
if (!$high_running && ($top_priority > PRIORITY_UNDEFINED) && ($top_priority < PRIORITY_NEGLIGIBLE)) {
if (!$high_running && ($top_priority > self::PRIORITY_UNDEFINED) && ($top_priority < self::PRIORITY_NEGLIGIBLE)) {
Logger::info('Jobs with a higher priority are waiting but none is executed. Open a fastlane.', ['priority' => $top_priority]);
$queues = $active + 1;
}
@ -939,7 +947,7 @@ class Worker
private static function nextPriority()
{
$waiting = [];
$priorities = [PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE];
$priorities = [self::PRIORITY_CRITICAL, self::PRIORITY_HIGH, self::PRIORITY_MEDIUM, self::PRIORITY_LOW, self::PRIORITY_NEGLIGIBLE];
foreach ($priorities as $priority) {
$stamp = (float)microtime(true);
if (DBA::exists('workerqueue', ["`priority` = ? AND `pid` = 0 AND NOT `done` AND `next_try` < ?", $priority, DateTimeFormat::utcNow()])) {
@ -948,8 +956,8 @@ class Worker
self::$db_duration += (microtime(true) - $stamp);
}
if (!empty($waiting[PRIORITY_CRITICAL])) {
return PRIORITY_CRITICAL;
if (!empty($waiting[self::PRIORITY_CRITICAL])) {
return self::PRIORITY_CRITICAL;
}
$running = [];
@ -1206,8 +1214,8 @@ class Worker
* @param (integer|array) priority or parameter array, strings are deprecated and are ignored
*
* next args are passed as $cmd command line
* or: Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::DELETION, $drop_id);
* or: Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), 'Delivery', $post_id);
* or: Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::DELETION, $drop_id);
* or: Worker::add(array('priority' => Worker::PRIORITY_HIGH, 'dont_fork' => true), 'Delivery', $post_id);
*
* @return int '0' if worker queue entry already existed or there had been an error, otherwise the ID of the worker task
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
@ -1230,7 +1238,7 @@ class Worker
return 1;
}
$priority = PRIORITY_MEDIUM;
$priority = self::PRIORITY_MEDIUM;
// Don't fork from frontend tasks by default
$dont_fork = DI::config()->get('system', 'worker_dont_fork', false) || !DI::mode()->isBackend();
$created = DateTimeFormat::utcNow();
@ -1266,9 +1274,9 @@ class Worker
$found = DBA::exists('workerqueue', ['command' => $command, 'parameter' => $parameters, 'done' => false]);
$added = 0;
if (!is_int($priority) || !in_array($priority, PRIORITIES)) {
if (!is_int($priority) || !in_array($priority, self::PRIORITIES)) {
Logger::warning('Invalid priority', ['priority' => $priority, 'command' => $command, 'callstack' => System::callstack(20)]);
$priority = PRIORITY_MEDIUM;
$priority = self::PRIORITY_MEDIUM;
}
// Quit if there was a database error - a precaution for the update process to 3.5.3
@ -1383,12 +1391,12 @@ class Worker
$delay = (($new_retrial + 2) ** 4) + (rand(1, 30) * ($new_retrial));
$next = DateTimeFormat::utc('now + ' . $delay . ' seconds');
if (($priority < PRIORITY_MEDIUM) && ($new_retrial > 3)) {
$priority = PRIORITY_MEDIUM;
} elseif (($priority < PRIORITY_LOW) && ($new_retrial > 6)) {
$priority = PRIORITY_LOW;
} elseif (($priority < PRIORITY_NEGLIGIBLE) && ($new_retrial > 8)) {
$priority = PRIORITY_NEGLIGIBLE;
if (($priority < self::PRIORITY_MEDIUM) && ($new_retrial > 3)) {
$priority = self::PRIORITY_MEDIUM;
} elseif (($priority < self::PRIORITY_LOW) && ($new_retrial > 6)) {
$priority = self::PRIORITY_LOW;
} elseif (($priority < self::PRIORITY_NEGLIGIBLE) && ($new_retrial > 8)) {
$priority = self::PRIORITY_NEGLIGIBLE;
}
Logger::info('Deferred task', ['id' => $id, 'retrial' => $new_retrial, 'created' => $queue['created'], 'next_execution' => $next, 'old_prio' => $queue['priority'], 'new_prio' => $priority]);

View file

@ -47,10 +47,10 @@ class Cron
Logger::info('Add cron entries');
// Check for spooled items
Worker::add(['priority' => PRIORITY_HIGH, 'force_priority' => true], 'SpoolPost');
Worker::add(['priority' => Worker::PRIORITY_HIGH, 'force_priority' => true], 'SpoolPost');
// Run the cron job that calls all other jobs
Worker::add(['priority' => PRIORITY_MEDIUM, 'force_priority' => true], 'Cron');
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'Cron');
// Cleaning dead processes
self::killStaleWorkers();
@ -112,12 +112,12 @@ class Cron
// To avoid a blocking situation we reschedule the process at the beginning of the queue.
// Additionally we are lowering the priority. (But not PRIORITY_CRITICAL)
$new_priority = $entry['priority'];
if ($entry['priority'] == PRIORITY_HIGH) {
$new_priority = PRIORITY_MEDIUM;
} elseif ($entry['priority'] == PRIORITY_MEDIUM) {
$new_priority = PRIORITY_LOW;
} elseif ($entry['priority'] != PRIORITY_CRITICAL) {
$new_priority = PRIORITY_NEGLIGIBLE;
if ($entry['priority'] == Worker::PRIORITY_HIGH) {
$new_priority = Worker::PRIORITY_MEDIUM;
} elseif ($entry['priority'] == Worker::PRIORITY_MEDIUM) {
$new_priority = Worker::PRIORITY_LOW;
} elseif ($entry['priority'] != Worker::PRIORITY_CRITICAL) {
$new_priority = Worker::PRIORITY_NEGLIGIBLE;
}
DBA::update('workerqueue', ['executed' => DBA::NULL_DATETIME, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0], ['id' => $entry["id"]]
);
@ -166,13 +166,13 @@ class Cron
Logger::info('Directly deliver inbox', ['inbox' => $delivery['inbox'], 'result' => $result['success']]);
continue;
} elseif ($delivery['failed'] < 3) {
$priority = PRIORITY_HIGH;
$priority = Worker::PRIORITY_HIGH;
} elseif ($delivery['failed'] < 6) {
$priority = PRIORITY_MEDIUM;
$priority = Worker::PRIORITY_MEDIUM;
} elseif ($delivery['failed'] < 8) {
$priority = PRIORITY_LOW;
$priority = Worker::PRIORITY_LOW;
} else {
$priority = PRIORITY_NEGLIGIBLE;
$priority = Worker::PRIORITY_NEGLIGIBLE;
}
if ($delivery['failed'] >= DI::config()->get('system', 'worker_defer_limit')) {

View file

@ -150,7 +150,7 @@ class DBStructure
echo DI::l10n()->t("\nError %d occurred during database update:\n%s\n",
DBA::errorNo(), DBA::errorMessage());
return DI::l10n()->t('Errors encountered performing database changes: ') . $message . EOL;
return DI::l10n()->t('Errors encountered performing database changes: ') . $message . '<br />';
}
/**

View file

@ -36,6 +36,7 @@ use PDO;
use PDOException;
use PDOStatement;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
/**
* This class is for the low level database stuff that does driver specific things.
@ -80,15 +81,17 @@ class Database
/** @var ViewDefinition */
protected $viewDefinition;
public function __construct(Cache $configCache, Profiler $profiler, DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition, LoggerInterface $logger)
public function __construct(Cache $configCache, Profiler $profiler, DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition)
{
// We are storing these values for being able to perform a reconnect
$this->configCache = $configCache;
$this->profiler = $profiler;
$this->logger = $logger;
$this->dbaDefinition = $dbaDefinition;
$this->viewDefinition = $viewDefinition;
// Temporary NullLogger until we can fetch the logger class from the config
$this->logger = new NullLogger();
$this->connect();
}

View file

@ -319,7 +319,7 @@ class Contact
// Update the contact in the background if needed
if (Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
}
// Remove the internal fields
@ -884,7 +884,7 @@ class Contact
}
// Delete it in the background
Worker::add(PRIORITY_MEDIUM, 'Contact\Remove', $id);
Worker::add(Worker::PRIORITY_MEDIUM, 'Contact\Remove', $id);
}
/**
@ -908,7 +908,7 @@ class Contact
if (in_array($contact['rel'], [self::SHARING, self::FRIEND])) {
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
if (!empty($cdata['public'])) {
Worker::add(PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
}
}
@ -938,7 +938,7 @@ class Contact
if (in_array($contact['rel'], [self::FOLLOWER, self::FRIEND])) {
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
if (!empty($cdata['public'])) {
Worker::add(PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
}
}
@ -966,11 +966,11 @@ class Contact
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
if (in_array($contact['rel'], [self::SHARING, self::FRIEND]) && !empty($cdata['public'])) {
Worker::add(PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
}
if (in_array($contact['rel'], [self::FOLLOWER, self::FRIEND]) && !empty($cdata['public'])) {
Worker::add(PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
}
self::remove($contact['id']);
@ -1248,7 +1248,7 @@ class Contact
$contact_id = $contact['id'];
if (Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
}
if (empty($update) && (!empty($contact['uri-id']) || is_bool($update))) {
@ -2365,7 +2365,7 @@ class Contact
return;
}
Logger::warning('account-user exists for a different contact id', ['account_user' => $account_user, 'id' => $id, 'uid' => $uid, 'uri-id' => $uri_id, 'url' => $url]);
Worker::add(PRIORITY_HIGH, 'MergeContact', $account_user['id'], $id, $uid);
Worker::add(Worker::PRIORITY_HIGH, 'MergeContact', $account_user['id'], $id, $uid);
} elseif (DBA::insert('account-user', ['id' => $id, 'uri-id' => $uri_id, 'uid' => $uid], Database::INSERT_IGNORE)) {
Logger::notice('account-user was added', ['id' => $id, 'uid' => $uid, 'uri-id' => $uri_id, 'url' => $url]);
} else {
@ -2406,7 +2406,7 @@ class Contact
continue;
}
Worker::add(PRIORITY_HIGH, 'MergeContact', $first, $duplicate['id'], $uid);
Worker::add(Worker::PRIORITY_HIGH, 'MergeContact', $first, $duplicate['id'], $uid);
}
DBA::close($duplicates);
Logger::info('Duplicates handled', ['uid' => $uid, 'nurl' => $nurl, 'callstack' => System::callstack(20)]);
@ -2608,7 +2608,7 @@ class Contact
if ($ret['network'] == Protocol::ACTIVITYPUB) {
$apcontact = APContact::getByURL($ret['url'], false);
if (!empty($apcontact['featured'])) {
Worker::add(PRIORITY_LOW, 'FetchFeaturedPosts', $ret['url']);
Worker::add(Worker::PRIORITY_LOW, 'FetchFeaturedPosts', $ret['url']);
}
}
@ -2649,7 +2649,7 @@ class Contact
self::updateContact($id, $uid, $uriid, $contact['url'], ['failed' => false, 'local-data' => $has_local_data, 'last-update' => $updated, 'next-update' => $success_next_update, 'success_update' => $updated]);
if (Contact\Relation::isDiscoverable($ret['url'])) {
Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
Worker::add(Worker::PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
}
// Update the public contact
@ -2693,7 +2693,7 @@ class Contact
self::updateContact($id, $uid, $ret['uri-id'], $ret['url'], $ret);
if (Contact\Relation::isDiscoverable($ret['url'])) {
Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
Worker::add(Worker::PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
}
return true;
@ -2853,30 +2853,30 @@ class Contact
// do we have enough information?
if (empty($protocol) || ($protocol == Protocol::PHANTOM) || (empty($ret['url']) && empty($ret['addr']))) {
$result['message'] .= DI::l10n()->t('The profile address specified does not provide adequate information.') . EOL;
$result['message'] .= DI::l10n()->t('The profile address specified does not provide adequate information.') . '<br />';
if (empty($ret['poll'])) {
$result['message'] .= DI::l10n()->t('No compatible communication protocols or feeds were discovered.') . EOL;
$result['message'] .= DI::l10n()->t('No compatible communication protocols or feeds were discovered.') . '<br />';
}
if (empty($ret['name'])) {
$result['message'] .= DI::l10n()->t('An author or name was not found.') . EOL;
$result['message'] .= DI::l10n()->t('An author or name was not found.') . '<br />';
}
if (empty($ret['url'])) {
$result['message'] .= DI::l10n()->t('No browser URL could be matched to this address.') . EOL;
$result['message'] .= DI::l10n()->t('No browser URL could be matched to this address.') . '<br />';
}
if (strpos($ret['url'], '@') !== false) {
$result['message'] .= DI::l10n()->t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL;
$result['message'] .= DI::l10n()->t('Use mailto: in front of address to force email check.') . EOL;
$result['message'] .= DI::l10n()->t('Unable to match @-style Identity Address with a known protocol or email contact.') . '<br />';
$result['message'] .= DI::l10n()->t('Use mailto: in front of address to force email check.') . '<br />';
}
return $result;
}
if ($protocol === Protocol::OSTATUS && DI::config()->get('system', 'ostatus_disabled')) {
$result['message'] .= DI::l10n()->t('The profile address specified belongs to a network which has been disabled on this site.') . EOL;
$result['message'] .= DI::l10n()->t('The profile address specified belongs to a network which has been disabled on this site.') . '<br />';
$ret['notify'] = '';
}
if (!$ret['notify']) {
$result['message'] .= DI::l10n()->t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL;
$result['message'] .= DI::l10n()->t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . '<br />';
}
$writeable = ((($protocol === Protocol::OSTATUS) && ($ret['notify'])) ? 1 : 0);
@ -2935,7 +2935,7 @@ class Contact
$contact = DBA::selectFirst('contact', [], ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
if (!DBA::isResult($contact)) {
$result['message'] .= DI::l10n()->t('Unable to retrieve contact information.') . EOL;
$result['message'] .= DI::l10n()->t('Unable to retrieve contact information.') . '<br />';
return $result;
}
@ -2949,13 +2949,13 @@ class Contact
// pull feed and consume it, which should subscribe to the hub.
if ($contact['network'] == Protocol::OSTATUS) {
Worker::add(PRIORITY_HIGH, 'OnePoll', $contact_id, 'force');
Worker::add(Worker::PRIORITY_HIGH, 'OnePoll', $contact_id, 'force');
}
if ($probed) {
self::updateFromProbeArray($contact_id, $ret);
} else {
Worker::add(PRIORITY_HIGH, 'UpdateContact', $contact_id);
Worker::add(Worker::PRIORITY_HIGH, 'UpdateContact', $contact_id);
}
$result['success'] = Protocol::follow($uid, $contact, $protocol);
@ -3407,10 +3407,10 @@ class Contact
}
$contact = self::getByURL($url, false, ['id', 'network', 'next-update']);
if (empty($contact['id']) && Network::isValidHttpUrl($url)) {
Worker::add(PRIORITY_LOW, 'AddContact', 0, $url);
Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $url);
++$added;
} elseif (!empty($contact['network']) && Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
++$updated;
} else {
++$unchanged;

View file

@ -59,7 +59,7 @@ class FContact
$update = empty($person['guid']) || empty($person['uri-id']) || ($person['created'] <= DBA::NULL_DATETIME);
if (GServer::getNextUpdateDate(true, $person['created'], $person['updated'], false) < DateTimeFormat::utcNow()) {
Logger::debug('Start background update', ['handle' => $handle]);
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateFContact', $handle);
Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateFContact', $handle);
}
}
} elseif (is_null($update)) {

View file

@ -102,7 +102,7 @@ class GServer
return;
}
Worker::add(PRIORITY_LOW, 'UpdateGServer', $url, $only_nodeinfo);
Worker::add(Worker::PRIORITY_LOW, 'UpdateGServer', $url, $only_nodeinfo);
}
/**
@ -2108,10 +2108,10 @@ class GServer
while ($gserver = DBA::fetch($gservers)) {
Logger::info('Update peer list', ['server' => $gserver['url'], 'id' => $gserver['id']]);
Worker::add(PRIORITY_LOW, 'UpdateServerPeers', $gserver['url']);
Worker::add(Worker::PRIORITY_LOW, 'UpdateServerPeers', $gserver['url']);
Logger::info('Update directory', ['server' => $gserver['url'], 'id' => $gserver['id']]);
Worker::add(PRIORITY_LOW, 'UpdateServerDirectory', $gserver);
Worker::add(Worker::PRIORITY_LOW, 'UpdateServerDirectory', $gserver);
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
self::update($fields, ['nurl' => $gserver['nurl']]);

View file

@ -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 <strong>may</strong> 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 <strong>may</strong> 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;
}

View file

@ -93,7 +93,7 @@ class Item
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language',
'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global',
'quote-uri', 'quote-uri-id', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global',
'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid', 'author-addr', 'author-uri-id',
'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated',
'causer-id', 'causer-link', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network',
@ -115,7 +115,7 @@ class Item
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'author-id', 'author-link', 'author-name', 'author-avatar', 'owner-id', 'owner-link', 'contact-uid',
'signed_text', 'network', 'wall', 'contact-id', 'plink', 'origin',
'thr-parent-id', 'parent-uri-id', 'postopts', 'pubmail',
'thr-parent-id', 'parent-uri-id', 'quote-uri', 'quote-uri-id', 'postopts', 'pubmail',
'event-created', 'event-edited', 'event-start', 'event-finish',
'event-summary', 'event-desc', 'event-location', 'event-type',
'event-nofinish', 'event-ignore', 'event-id'];
@ -123,7 +123,7 @@ class Item
// All fields in the item table
const ITEM_FIELDLIST = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent',
'guid', 'uri-id', 'parent-uri-id', 'thr-parent-id', 'conversation', 'vid',
'contact-id', 'wall', 'gravity', 'extid', 'psid',
'quote-uri', 'quote-uri-id', 'contact-id', 'wall', 'gravity', 'extid', 'psid',
'created', 'edited', 'commented', 'received', 'changed', 'verb',
'postopts', 'plink', 'resource-id', 'event-id', 'inform',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type', 'post-reason',
@ -238,7 +238,7 @@ class Item
foreach ($notify_items as $notify_item) {
$post = Post::selectFirst(['uri-id', 'uid'], ['id' => $notify_item]);
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::POST, (int)$post['uri-id'], (int)$post['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::POST, (int)$post['uri-id'], (int)$post['uid']);
}
return $rows;
@ -252,7 +252,7 @@ class Item
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function markForDeletion(array $condition, int $priority = PRIORITY_HIGH)
public static function markForDeletion(array $condition, int $priority = Worker::PRIORITY_HIGH)
{
$items = Post::select(['id'], $condition);
while ($item = Post::fetch($items)) {
@ -283,7 +283,7 @@ class Item
}
if ($item['uid'] == $uid) {
self::markForDeletionById($item['id'], PRIORITY_HIGH);
self::markForDeletionById($item['id'], Worker::PRIORITY_HIGH);
} elseif ($item['uid'] != 0) {
Logger::warning('Wrong ownership. Not deleting item', ['id' => $item['id']]);
}
@ -299,7 +299,7 @@ class Item
* @return boolean success
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function markForDeletionById(int $item_id, int $priority = PRIORITY_HIGH): bool
public static function markForDeletionById(int $item_id, int $priority = Worker::PRIORITY_HIGH): bool
{
Logger::info('Mark item for deletion by id', ['id' => $item_id, 'callstack' => System::callstack()]);
// locate item to be deleted
@ -822,7 +822,7 @@ class Item
{
$orig_item = $item;
$priority = PRIORITY_HIGH;
$priority = Worker::PRIORITY_HIGH;
// If it is a posting where users should get notifications, then define it as wall posting
if ($notify) {
@ -832,7 +832,7 @@ class Item
$item['protocol'] = Conversation::PARCEL_DIRECT;
$item['direction'] = Conversation::PUSH;
if (is_int($notify) && in_array($notify, PRIORITIES)) {
if (is_int($notify) && in_array($notify, Worker::PRIORITIES)) {
$priority = $notify;
}
} else {
@ -1125,6 +1125,13 @@ class Item
$item['raw-body'] = Post\Media::insertFromBody($item['uri-id'], $item['raw-body']);
$item['raw-body'] = self::setHashtags($item['raw-body']);
$quote_id = self::getQuoteUriId($item['body']);
if (!empty($quote_id) && Post::exists(['uri-id' => $quote_id, 'network' => Protocol::FEDERATED])) {
$item['quote-uri-id'] = $quote_id;
$item['raw-body'] = BBCode::removeSharedData($item['raw-body']);
}
if (!DBA::exists('contact', ['id' => $item['author-id'], 'network' => Protocol::DFRN])) {
Post\Media::insertFromRelevantUrl($item['uri-id'], $item['raw-body']);
}
@ -2945,17 +2952,44 @@ class Item
$body = $item['body'] ?? '';
$shared = BBCode::fetchShareAttributes($body);
if (!empty($shared['guid'])) {
$shared_item = Post::selectFirst(['uri-id', 'plink', 'has-media'], ['guid' => $shared['guid']]);
$shared_uri_id = $shared_item['uri-id'] ?? 0;
$shared_links = [strtolower($shared_item['plink'] ?? '')];
$shared_attachments = Post\Media::splitAttachments($shared_uri_id, $shared['guid'], [], $shared_item['has-media'] ?? false);
$shared_item = Post::selectFirst(['uri-id', 'guid', 'plink', 'has-media'], ['guid' => $shared['guid'], 'uid' => [$item['uid'], 0]]);
}
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'has-media'];
$shared_uri_id = 0;
$shared_links = [];
if (empty($shared_item['uri-id']) && !empty($item['quote-uri-id'])) {
$shared_item = Post::selectFirst($fields, ['uri-id' => $item['quote-uri-id']]);
$quote_uri_id = $item['quote-uri-id'] ?? 0;
$shared_links[] = strtolower($item['quote-uri']);
} elseif (empty($shared_item['uri-id']) && empty($item['quote-uri-id'])) {
$media = Post\Media::getByURIId($item['uri-id'], [Post\Media::ACTIVITY]);
if (!empty($media)) {
$shared_item = Post::selectFirst($fields, ['plink' => $media[0]['url'], 'uid' => [$item['uid'], 0]]);
if (empty($shared_item['uri-id'])) {
$shared_item = Post::selectFirst($fields, ['uri' => $media[0]['url'], 'uid' => [$item['uid'], 0]]);
$shared_links[] = strtolower($media[0]['url']);
}
$quote_uri_id = $shared_item['uri-id'] ?? 0;
}
}
if (!empty($quote_uri_id)) {
$item['body'] .= "\n" . DI::contentItem()->createSharedBlockByArray($shared_item);
}
if (!empty($shared_item['uri-id'])) {
$shared_uri_id = $shared_item['uri-id'];
$shared_links[] = strtolower($shared_item['plink']);
$shared_attachments = Post\Media::splitAttachments($shared_uri_id, $shared_item['guid'], [], $shared_item['has-media']);
$shared_links = array_merge($shared_links, array_column($shared_attachments['visual'], 'url'));
$shared_links = array_merge($shared_links, array_column($shared_attachments['link'], 'url'));
$shared_links = array_merge($shared_links, array_column($shared_attachments['additional'], 'url'));
$item['body'] = self::replaceVisualAttachments($shared_attachments, $item['body']);
} else {
$shared_uri_id = 0;
$shared_links = [];
}
$attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '', $shared_links, $item['has-media'] ?? false);
@ -3277,7 +3311,7 @@ class Item
}
DI::profiler()->stopRecording();
if (isset($data['url']) && !in_array($data['url'], $ignore_links)) {
if (isset($data['url']) && !in_array(strtolower($data['url']), $ignore_links)) {
if (!empty($data['description']) || !empty($data['image']) || !empty($data['preview'])) {
$parts = parse_url($data['url']);
if (!empty($parts['scheme']) && !empty($parts['host'])) {
@ -3611,9 +3645,10 @@ class Item
* Improve the data in shared posts
*
* @param array $item
* @param bool $add_media
* @return string body
*/
public static function improveSharedDataInBody(array $item): string
public static function improveSharedDataInBody(array $item, bool $add_media = false): string
{
$shared = BBCode::fetchShareAttributes($item['body']);
if (empty($shared['guid']) && empty($shared['message_id'])) {
@ -3623,7 +3658,7 @@ class Item
$link = $shared['link'] ?: $shared['message_id'];
if (empty($shared_content)) {
$shared_content = DI::contentItem()->createSharedPostByUrl($link, $item['uid'] ?? 0);
$shared_content = DI::contentItem()->createSharedPostByUrl($link, $item['uid'] ?? 0, $add_media);
}
if (empty($shared_content)) {
@ -3635,4 +3670,19 @@ class Item
Logger::debug('New shared data', ['uri-id' => $item['uri-id'], 'link' => $link, 'guid' => $item['guid']]);
return $item['body'];
}
/**
* Fetch the uri-id of a quote
*
* @param string $body
* @return integer
*/
private static function getQuoteUriId(string $body): int
{
$shared = BBCode::fetchShareAttributes($body);
if (empty($shared['message_id'])) {
return 0;
}
return ItemURI::getIdByURI($shared['message_id']);
}
}

View file

@ -239,7 +239,7 @@ class Mail
}
if ($post_id) {
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::MAIL, $post_id);
Worker::add(Worker::PRIORITY_HIGH, "Notifier", Delivery::MAIL, $post_id);
return intval($post_id);
} else {
return -3;

View file

@ -80,7 +80,7 @@ class Delayed
Logger::notice('Adding post for delayed publishing', ['uid' => $item['uid'], 'delayed' => $delayed, 'uri' => $uri]);
$wid = Worker::add(['priority' => PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $preparation_mode, $uri);
$wid = Worker::add(['priority' => Worker::PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $preparation_mode, $uri);
if (!$wid) {
return 0;
}

View file

@ -23,10 +23,12 @@ namespace Friendica\Model\Post;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Photo;
use Friendica\Model\Post;
@ -56,6 +58,7 @@ class Media
const HTML = 17;
const XML = 18;
const PLAIN = 19;
const ACTIVITY = 20;
const DOCUMENT = 128;
/**
@ -215,6 +218,10 @@ class Media
$media = self::addType($media);
}
if (in_array($media['type'], [self::TEXT, self::APPLICATION, self::HTML, self::XML, self::PLAIN])) {
$media = self::addActivity($media);
}
if ($media['type'] == self::HTML) {
$data = ParseUrl::getSiteinfoCached($media['url'], false);
$media['preview'] = $data['images'][0]['src'] ?? null;
@ -232,6 +239,65 @@ class Media
return $media;
}
/**
* Adds the activity type if the media entry is linked to an activity
*
* @param array $media
* @return array
*/
private static function addActivity(array $media): array
{
$id = Item::fetchByLink($media['url']);
if (empty($id)) {
return $media;
}
$item = Post::selectFirst([], ['id' => $id, 'network' => Protocol::FEDERATED]);
if (empty($item['id'])) {
Logger::debug('Not a federated activity', ['id' => $id, 'uri-id' => $media['uri-id'], 'url' => $media['url']]);
return $media;
}
if (!empty($item['plink']) && Strings::compareLink($item['plink'], $media['url']) &&
parse_url($item['plink'], PHP_URL_HOST) != parse_url($item['uri'], PHP_URL_HOST)) {
Logger::debug('Not a link to an activity', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
return $media;
}
if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN])) {
$media['mimetype'] = 'application/activity+json';
} elseif ($item['network'] == Protocol::DIASPORA) {
$media['mimetype'] = 'application/xml';
} else {
$media['mimetype'] = '';
}
$contact = Contact::getById($item['author-id'], ['avatar', 'gsid']);
if (!empty($contact['gsid'])) {
$gserver = DBA::selectFirst('gserver', ['url', 'site_name'], ['id' => $contact['gsid']]);
}
$media['type'] = self::ACTIVITY;
$media['media-uri-id'] = $item['uri-id'];
$media['height'] = null;
$media['width'] = null;
$media['size'] = null;
$media['preview'] = null;
$media['preview-height'] = null;
$media['preview-width'] = null;
$media['description'] = $item['body'];
$media['name'] = $item['title'];
$media['author-url'] = $item['author-link'];
$media['author-name'] = $item['author-name'];
$media['author-image'] = $contact['avatar'] ?? $item['author-avatar'];
$media['publisher-url'] = $gserver['url'] ?? null;
$media['publisher-name'] = $gserver['site_name'] ?? null;
$media['publisher-image'] = null;
Logger::debug('Activity detected', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
return $media;
}
/**
* Fetch media data from local resources
* @param array $media

View file

@ -153,11 +153,11 @@ class Profile
if ($owner['net-publish'] || $force) {
// Update global directory in background
if (Search::getGlobalDirectory()) {
Worker::add(PRIORITY_LOW, 'Directory', $owner['url']);
Worker::add(Worker::PRIORITY_LOW, 'Directory', $owner['url']);
}
}
Worker::add(PRIORITY_LOW, 'ProfileUpdate', $uid);
Worker::add(Worker::PRIORITY_LOW, 'ProfileUpdate', $uid);
}
/**
@ -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']);
}

View file

@ -37,7 +37,7 @@ class PushSubscriber
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function publishFeed(int $uid, int $default_priority = PRIORITY_HIGH)
public static function publishFeed(int $uid, int $default_priority = Worker::PRIORITY_HIGH)
{
$condition = ['push' => 0, 'uid' => $uid];
DBA::update('push_subscriber', ['push' => 1, 'next_try' => DBA::NULL_DATETIME], $condition);
@ -52,7 +52,7 @@ class PushSubscriber
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function requeue(int $default_priority = PRIORITY_HIGH)
public static function requeue(int $default_priority = Worker::PRIORITY_HIGH)
{
// We'll push to each subscriber that has push > 0,
// i.e. there has been an update (set in notifier.php).
@ -61,7 +61,7 @@ class PushSubscriber
while ($subscriber = DBA::fetch($subscribers)) {
// We always handle retries with low priority
if ($subscriber['push'] > 1) {
$priority = PRIORITY_LOW;
$priority = Worker::PRIORITY_LOW;
} else {
$priority = $default_priority;
}

View file

@ -152,7 +152,7 @@ class Subscription
$subscriptions = DBA::select('subscription', [], ['uid' => $notification->uid, $type => true]);
while ($subscription = DBA::fetch($subscriptions)) {
Logger::info('Push notification', ['id' => $subscription['id'], 'uid' => $subscription['uid'], 'type' => $type]);
Worker::add(PRIORITY_HIGH, 'PushSubscription', $subscription['id'], $notification->id);
Worker::add(Worker::PRIORITY_HIGH, 'PushSubscription', $subscription['id'], $notification->id);
}
DBA::close($subscriptions);
}

View file

@ -994,7 +994,7 @@ class User
try {
$authurl = $openid->authUrl();
} catch (Exception $e) {
throw new Exception(DI::l10n()->t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . EOL . EOL . DI::l10n()->t('The error message was:') . $e->getMessage(), 0, $e);
throw new Exception(DI::l10n()->t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . '<br />' . DI::l10n()->t('The error message was:') . $e->getMessage(), 0, $e);
}
System::externalRedirect($authurl);
// NOTREACHED
@ -1317,7 +1317,7 @@ class User
if (DBA::isResult($profile) && $profile['net-publish'] && Search::getGlobalDirectory()) {
$url = DI::baseUrl() . '/profile/' . $user['nickname'];
Worker::add(PRIORITY_LOW, "Directory", $url);
Worker::add(Worker::PRIORITY_LOW, "Directory", $url);
}
$l10n = DI::l10n()->withLang($register['language']);
@ -1567,14 +1567,14 @@ class User
// The user and related data will be deleted in Friendica\Worker\ExpireAndRemoveUsers
DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utc('now + 7 day')], ['uid' => $uid]);
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::REMOVAL, $uid);
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::REMOVAL, $uid);
// Send an update to the directory
$self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
Worker::add(PRIORITY_LOW, 'Directory', $self['url']);
Worker::add(Worker::PRIORITY_LOW, 'Directory', $self['url']);
// Remove the user relevant data
Worker::add(PRIORITY_NEGLIGIBLE, 'RemoveUser', $uid);
Worker::add(Worker::PRIORITY_NEGLIGIBLE, 'RemoveUser', $uid);
return true;
}

View file

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

View file

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

View file

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

View file

@ -82,7 +82,7 @@ class Add extends BaseAdmin
if (!empty($request['purge'])) {
$gservers = GServer::listByDomainPattern($pattern);
foreach (Contact::selectToArray(['id'], ['gsid' => array_column($gservers, 'id')]) as $contact) {
Worker::add(PRIORITY_LOW, 'Contact\RemoveContent', $contact['id']);
Worker::add(Worker::PRIORITY_LOW, 'Contact\RemoveContent', $contact['id']);
}
$this->sysmsg->addInfo($this->l10n->tt('%s server scheduled to be purged.', '%s servers scheduled to be purged.', count($gservers)));

View file

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

View file

@ -21,6 +21,7 @@
namespace Friendica\Module\Admin;
use Friendica\App;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
@ -202,7 +203,7 @@ class Federation extends BaseAdmin
'$page' => DI::l10n()->t('Federation Statistics'),
'$intro' => $intro,
'$counts' => $counts,
'$version' => FRIENDICA_VERSION,
'$version' => App::VERSION,
'$legendtext' => DI::l10n()->tt('Currently this node is aware of %2$s node (%3$s active users last month, %4$s active users last six months, %5$s registered users in total) from the following platforms:', 'Currently this node is aware of %2$s nodes (%3$s active users last month, %4$s active users last six months, %5$s registered users in total) from the following platforms:', $total, number_format($total), number_format($month), number_format($halfyear), number_format($users)),
]);
}

View file

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

View file

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

View file

@ -22,7 +22,6 @@
namespace Friendica\Module\Admin;
use Friendica\App;
use Friendica\Core\Relocate;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\Core\System;
@ -33,12 +32,11 @@ use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\User;
use Friendica\Module\BaseAdmin;
use Friendica\Module\Conversation\Community;
use Friendica\Module\Register;
use Friendica\Protocol\Relay;
use Friendica\Util\BasePath;
use Friendica\Util\EMailer\MailBuilder;
use Friendica\Util\Strings;
use Friendica\Worker\Delivery;
require_once __DIR__ . '/../../../boot.php';
@ -53,7 +51,7 @@ class Site extends BaseAdmin
$a = DI::app();
if (!empty($_POST['republish_directory'])) {
Worker::add(PRIORITY_LOW, 'Directory');
Worker::add(Worker::PRIORITY_LOW, 'Directory');
return;
}
@ -150,7 +148,7 @@ class Site extends BaseAdmin
// Has the directory url changed? If yes, then resubmit the existing profiles there
if ($global_directory != DI::config()->get('system', 'directory') && ($global_directory != '')) {
DI::config()->set('system', 'directory', $global_directory);
Worker::add(PRIORITY_LOW, 'Directory');
Worker::add(Worker::PRIORITY_LOW, 'Directory');
}
if (DI::baseUrl()->getUrlPath() != "") {
@ -364,11 +362,11 @@ class Site extends BaseAdmin
/* Community page style */
$community_page_style_choices = [
CP_NO_INTERNAL_COMMUNITY => DI::l10n()->t('No community page for local users'),
CP_NO_COMMUNITY_PAGE => DI::l10n()->t('No community page'),
CP_USERS_ON_SERVER => DI::l10n()->t('Public postings from users of this site'),
CP_GLOBAL_COMMUNITY => DI::l10n()->t('Public postings from the federated network'),
CP_USERS_AND_GLOBAL => DI::l10n()->t('Public postings from local users and the federated network')
Community::DISABLED => DI::l10n()->t('No community page'),
Community::DISABLED_VISITOR => DI::l10n()->t('No community page for visitors'),
Community::LOCAL => DI::l10n()->t('Public postings from users of this site'),
Community::GLOBAL => DI::l10n()->t('Public postings from the federated network'),
Community::LOCAL_AND_GLOBAL => DI::l10n()->t('Public postings from local users and the federated network')
];
/* get user names to make the install a personal install of X */

View file

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

View file

@ -21,6 +21,7 @@
namespace Friendica\Module\Admin;
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Logger;
@ -79,8 +80,8 @@ class Summary extends BaseAdmin
// the local version of Friendica. Check is opt-in, source may be stable or develop branch
if (DI::config()->get('system', 'check_new_version_url', 'none') != 'none') {
$gitversion = DI::config()->get('system', 'git_friendica_version');
if (version_compare(FRIENDICA_VERSION, $gitversion) < 0) {
$warningtext[] = DI::l10n()->t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s', FRIENDICA_VERSION, $gitversion);
if (version_compare(App::VERSION, $gitversion) < 0) {
$warningtext[] = DI::l10n()->t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s', App::VERSION, $gitversion);
}
}
@ -236,9 +237,9 @@ class Summary extends BaseAdmin
'$users' => [DI::l10n()->t('Registered users'), $users],
'$accounts' => $accounts,
'$pending' => [DI::l10n()->t('Pending registrations'), $pending],
'$version' => [DI::l10n()->t('Version'), FRIENDICA_VERSION],
'$platform' => FRIENDICA_PLATFORM,
'$codename' => FRIENDICA_CODENAME,
'$version' => [DI::l10n()->t('Version'), App::VERSION],
'$platform' => App::PLATFORM,
'$codename' => App::CODENAME,
'$build' => DI::config()->get('system', 'build'),
'$addons' => [DI::l10n()->t('Active addons'), Addon::getEnabledList()],
'$serversettings' => $server_settings,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -104,7 +104,7 @@ class Create extends BaseApi
$item = ['network' => Protocol::DFRN, 'protocol' => Conversation::PARCEL_DIRECT, 'direction' => Conversation::PUSH];
$item = Event::getItemArrayForId($event_id, $item);
if (Item::insert($item)) {
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$item['uri-id'], $uid);
Worker::add(Worker::PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$item['uri-id'], $uid);
}
}

View file

@ -53,9 +53,8 @@ class Config extends BaseApi
'sslserver' => null,
'ssl' => DI::config()->get('system', 'ssl_policy') == App\BaseURL::SSL_POLICY_FULL ? 'always' : '0',
'friendica' => [
'FRIENDICA_PLATFORM' => FRIENDICA_PLATFORM,
'FRIENDICA_VERSION' => FRIENDICA_VERSION,
'DFRN_PROTOCOL_VERSION' => DFRN_PROTOCOL_VERSION,
'FRIENDICA_PLATFORM' => App::PLATFORM,
'FRIENDICA_VERSION' => App::VERSION,
'DB_UPDATE_VERSION' => DB_UPDATE_VERSION,
]
],

View file

@ -25,6 +25,7 @@ use Friendica\App\Router;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
@ -204,7 +205,7 @@ class Statuses extends BaseApi
if (!empty($request['scheduled_at'])) {
$item['guid'] = Item::guid($item, true);
$item['uri'] = Item::newURI($item['guid']);
$id = Post\Delayed::add($item['uri'], $item, PRIORITY_HIGH, Post\Delayed::PREPARED, $request['scheduled_at']);
$id = Post\Delayed::add($item['uri'], $item, Worker::PRIORITY_HIGH, Post\Delayed::PREPARED, $request['scheduled_at']);
if (empty($id)) {
DI::mstdnError()->InternalError();
}

View file

@ -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');

View file

@ -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 {

View file

@ -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 '';
}

View file

@ -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);
@ -126,9 +126,9 @@ class Contact extends BaseModule
}
// pull feed and consume it, which should subscribe to the hub.
Worker::add(PRIORITY_HIGH, 'OnePoll', $contact_id, 'force');
Worker::add(Worker::PRIORITY_HIGH, 'OnePoll', $contact_id, 'force');
} else {
Worker::add(PRIORITY_HIGH, 'UpdateContact', $contact_id);
Worker::add(Worker::PRIORITY_HIGH, 'UpdateContact', $contact_id);
}
}

View file

@ -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.'));
}
}

View file

@ -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']);

View file

@ -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']);
}

View file

@ -40,6 +40,21 @@ use Friendica\Network\HTTPException;
class Community extends BaseModule
{
/**
* @name CP
*
* Type of the community page
* @{
*/
const DISABLED = -2;
const DISABLED_VISITOR = -1;
const LOCAL = 0;
const GLOBAL = 1;
const LOCAL_AND_GLOBAL = 2;
/**
* @}
*/
protected static $page_style;
protected static $content;
protected static $accountTypeString;
@ -69,7 +84,7 @@ class Community extends BaseModule
if (empty($_GET['mode']) || ($_GET['mode'] != 'raw')) {
$tabs = [];
if ((Session::isAuthenticated() || in_array(self::$page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) && empty(DI::config()->get('system', 'singleuser'))) {
if ((Session::isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::LOCAL])) && empty(DI::config()->get('system', 'singleuser'))) {
$tabs[] = [
'label' => DI::l10n()->t('Local Community'),
'url' => 'community/local',
@ -80,7 +95,7 @@ class Community extends BaseModule
];
}
if (Session::isAuthenticated() || in_array(self::$page_style, [CP_USERS_AND_GLOBAL, CP_GLOBAL_COMMUNITY])) {
if (Session::isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::GLOBAL])) {
$tabs[] = [
'label' => DI::l10n()->t('Global Community'),
'url' => 'community/global',
@ -140,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;
}
@ -177,7 +192,7 @@ class Community extends BaseModule
self::$page_style = DI::config()->get('system', 'community_page_style');
if (self::$page_style == CP_NO_INTERNAL_COMMUNITY) {
if (self::$page_style == self::DISABLED) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
@ -191,7 +206,7 @@ class Community extends BaseModule
self::$content = 'global';
} else {
// When only the global community is allowed, we use this as default
self::$content = self::$page_style == CP_GLOBAL_COMMUNITY ? 'global' : 'local';
self::$content = self::$page_style == self::GLOBAL ? 'global' : 'local';
}
}
@ -201,14 +216,14 @@ class Community extends BaseModule
// Check if we are allowed to display the content to visitors
if (!Session::isAuthenticated()) {
$available = self::$page_style == CP_USERS_AND_GLOBAL;
$available = self::$page_style == self::LOCAL_AND_GLOBAL;
if (!$available) {
$available = (self::$page_style == CP_USERS_ON_SERVER) && (self::$content == 'local');
$available = (self::$page_style == self::LOCAL) && (self::$content == 'local');
}
if (!$available) {
$available = (self::$page_style == CP_GLOBAL_COMMUNITY) && (self::$content == 'global');
$available = (self::$page_style == self::GLOBAL) && (self::$content == 'global');
}
if (!$available) {

View file

@ -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();

View file

@ -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();
}
}

View file

@ -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');
}

View file

@ -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());

View file

@ -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();
}
}

View file

@ -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;
}

View file

@ -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;
}
@ -94,9 +95,9 @@ class FriendSuggest extends BaseModule
$note
));
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id);
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();
}

View file

@ -21,6 +21,7 @@
namespace Friendica\Module;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\Addon;
use Friendica\Core\Hook;
@ -96,7 +97,7 @@ class Friendica extends BaseModule
return Renderer::replaceMacros($tpl, [
'about' => DI::l10n()->t('This is Friendica, version %s that is running at the web location %s. The database version is %s, the post update version is %s.',
'<strong>' . FRIENDICA_VERSION . '</strong>',
'<strong>' . App::VERSION . '</strong>',
DI::baseUrl()->get(),
'<strong>' . $config->get('system', 'build') . '/' . DB_UPDATE_VERSION . '</strong>',
'<strong>' . $config->get('system', 'post_update_version') . '/' . PostUpdate::VERSION . '</strong>'),
@ -169,7 +170,7 @@ class Friendica extends BaseModule
}
$data = [
'version' => FRIENDICA_VERSION,
'version' => App::VERSION,
'url' => DI::baseUrl()->get(),
'addons' => $visible_addons,
'locked_features' => $locked_features,
@ -178,7 +179,7 @@ class Friendica extends BaseModule
'register_policy' => $register_policy,
'admin' => $admin,
'site_name' => $config->get('config', 'sitename'),
'platform' => strtolower(FRIENDICA_PLATFORM),
'platform' => strtolower(App::PLATFORM),
'info' => $config->get('config', 'info'),
'no_scrape_url' => DI::baseUrl()->get() . '/noscrape',
];

View file

@ -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');
}

View file

@ -337,7 +337,7 @@ class Install extends BaseModule
if (count($this->installer->getChecks()) == 0) {
$txt = '<p style="font-size: 130%;">';
$txt .= $this->t('Your Friendica site database has been installed.') . EOL;
$txt .= $this->t('Your Friendica site database has been installed.') . '<br />';
$db_return_text .= $txt;
}

View file

@ -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

View file

@ -22,10 +22,14 @@
namespace Friendica\Module\Item;
use DateTime;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Content\Feature;
use Friendica\Core\ACL;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\Core\Theme;
use Friendica\Database\DBA;
@ -33,13 +37,44 @@ use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Module\Response;
use Friendica\Module\Security\Login;
use Friendica\Navigation\SystemMessages;
use Friendica\Network\HTTPException\NotImplementedException;
use Friendica\Util\ACLFormatter;
use Friendica\Util\Crypto;
use Friendica\Util\Profiler;
use Friendica\Util\Temporal;
use Psr\Log\LoggerInterface;
class Compose extends BaseModule
{
/** @var SystemMessages */
private $systemMessages;
/** @var ACLFormatter */
private $ACLFormatter;
/** @var App\Page */
private $page;
/** @var IManagePersonalConfigValues */
private $pConfig;
/** @var IManageConfigValues */
private $config;
public function __construct(IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, ACLFormatter $ACLFormatter, SystemMessages $systemMessages, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->systemMessages = $systemMessages;
$this->ACLFormatter = $ACLFormatter;
$this->page = $page;
$this->pConfig = $pConfig;
$this->config = $config;
}
protected function post(array $request = [])
{
if (!empty($_REQUEST['body'])) {
@ -47,23 +82,22 @@ class Compose extends BaseModule
require_once 'mod/item.php';
item_post(DI::app());
} else {
notice(DI::l10n()->t('Please enter a post body.'));
$this->systemMessages->addNotice($this->l10n->t('Please enter a post body.'));
}
}
protected function content(array $request = []): string
{
if (!local_user()) {
return Login::form('compose', false);
return Login::form('compose');
}
$a = DI::app();
if ($a->getCurrentTheme() !== 'frio') {
throw new NotImplementedException(DI::l10n()->t('This feature is only available with the frio theme.'));
throw new NotImplementedException($this->l10n->t('This feature is only available with the frio theme.'));
}
/// @TODO Retrieve parameter from router
$posttype = $this->parameters['type'] ?? Item::PT_ARTICLE;
if (!in_array($posttype, [Item::PT_ARTICLE, Item::PT_PERSONAL_NOTE])) {
switch ($posttype) {
@ -78,16 +112,14 @@ class Compose extends BaseModule
$user = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
$aclFormatter = DI::aclFormatter();
$contact_allow_list = $aclFormatter->expand($user['allow_cid']);
$group_allow_list = $aclFormatter->expand($user['allow_gid']);
$contact_deny_list = $aclFormatter->expand($user['deny_cid']);
$group_deny_list = $aclFormatter->expand($user['deny_gid']);
$contact_allow_list = $this->ACLFormatter->expand($user['allow_cid']);
$group_allow_list = $this->ACLFormatter->expand($user['allow_gid']);
$contact_deny_list = $this->ACLFormatter->expand($user['deny_cid']);
$group_deny_list = $this->ACLFormatter->expand($user['deny_gid']);
switch ($posttype) {
case Item::PT_PERSONAL_NOTE:
$compose_title = DI::l10n()->t('Compose new personal note');
$compose_title = $this->l10n->t('Compose new personal note');
$type = 'note';
$doesFederate = false;
$contact_allow_list = [$a->getContactId()];
@ -96,7 +128,7 @@ class Compose extends BaseModule
$group_deny_list = [];
break;
default:
$compose_title = DI::l10n()->t('Compose new post');
$compose_title = $this->l10n->t('Compose new post');
$type = 'post';
$doesFederate = true;
@ -129,13 +161,13 @@ class Compose extends BaseModule
Hook::callAll('jot_tool', $jotplugins);
// Output
DI::page()->registerFooterScript(Theme::getPathForFile('js/ajaxupload.js'));
DI::page()->registerFooterScript(Theme::getPathForFile('js/linkPreview.js'));
DI::page()->registerFooterScript(Theme::getPathForFile('js/compose.js'));
$this->page->registerFooterScript(Theme::getPathForFile('js/ajaxupload.js'));
$this->page->registerFooterScript(Theme::getPathForFile('js/linkPreview.js'));
$this->page->registerFooterScript(Theme::getPathForFile('js/compose.js'));
$contact = Contact::getById($a->getContactId());
if (DI::config()->get(local_user(), 'system', 'set_creation_date')) {
if ($this->pConfig->get(local_user(), 'system', 'set_creation_date')) {
$created_at = Temporal::getDateTimeField(
new \DateTime(DBA::NULL_DATETIME),
new \DateTime('now'),
@ -149,39 +181,45 @@ class Compose extends BaseModule
$tpl = Renderer::getMarkupTemplate('item/compose.tpl');
return Renderer::replaceMacros($tpl, [
'$compose_title'=> $compose_title,
'$visibility_title'=> DI::l10n()->t('Visibility'),
'$l10n' => [
'compose_title' => $compose_title,
'default' => '',
'visibility_title' => $this->l10n->t('Visibility'),
'mytitle' => $this->l10n->t('This is you'),
'submit' => $this->l10n->t('Submit'),
'edbold' => $this->l10n->t('Bold'),
'editalic' => $this->l10n->t('Italic'),
'eduline' => $this->l10n->t('Underline'),
'edquote' => $this->l10n->t('Quote'),
'edcode' => $this->l10n->t('Code'),
'edimg' => $this->l10n->t('Image'),
'edurl' => $this->l10n->t('Link'),
'edattach' => $this->l10n->t('Link or Media'),
'prompttext' => $this->l10n->t('Please enter a image/video/audio/webpage URL:'),
'preview' => $this->l10n->t('Preview'),
'location_set' => $this->l10n->t('Set your location'),
'location_clear' => $this->l10n->t('Clear the location'),
'location_unavailable' => $this->l10n->t('Location services are unavailable on your device'),
'location_disabled' => $this->l10n->t('Location services are disabled. Please check the website\'s permissions on your device'),
'wait' => $this->l10n->t('Please wait'),
'placeholdertitle' => $this->l10n->t('Set title'),
'placeholdercategory' => Feature::isEnabled(local_user(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '',
'always_open_compose' => $this->pConfig->get(local_user(), 'frio', 'always_open_compose',
$this->config->get('frio', 'always_open_compose', false)) ? '' :
$this->l10n->t('You can make this page always open when you use the New Post button in the <a href="/settings/display">Theme Customization settings</a>.'),
],
'$id' => 0,
'$posttype' => $posttype,
'$type' => $type,
'$wall' => $wall,
'$default' => '',
'$mylink' => DI::baseUrl()->remove($contact['url']),
'$mytitle' => DI::l10n()->t('This is you'),
'$myphoto' => DI::baseUrl()->remove($contact['thumb']),
'$submit' => DI::l10n()->t('Submit'),
'$edbold' => DI::l10n()->t('Bold'),
'$editalic' => DI::l10n()->t('Italic'),
'$eduline' => DI::l10n()->t('Underline'),
'$edquote' => DI::l10n()->t('Quote'),
'$edcode' => DI::l10n()->t('Code'),
'$edimg' => DI::l10n()->t('Image'),
'$edurl' => DI::l10n()->t('Link'),
'$edattach' => DI::l10n()->t('Link or Media'),
'$prompttext' => DI::l10n()->t('Please enter a image/video/audio/webpage URL:'),
'$preview' => DI::l10n()->t('Preview'),
'$location_set' => DI::l10n()->t('Set your location'),
'$location_clear' => DI::l10n()->t('Clear the location'),
'$location_unavailable' => DI::l10n()->t('Location services are unavailable on your device'),
'$location_disabled' => DI::l10n()->t('Location services are disabled. Please check the website\'s permissions on your device'),
'$wait' => DI::l10n()->t('Please wait'),
'$placeholdertitle' => DI::l10n()->t('Set title'),
'$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? DI::l10n()->t('Categories (comma-separated list)') : ''),
'$mylink' => $this->baseUrl->remove($contact['url']),
'$myphoto' => $this->baseUrl->remove($contact['thumb']),
'$scheduled_at' => Temporal::getDateTimeField(
new DateTime(),
new DateTime('now + 6 months'),
null,
DI::l10n()->t('Scheduled at'),
$this->l10n->t('Scheduled at'),
'scheduled_at'
),
'$created_at' => $created_at,
@ -197,7 +235,7 @@ class Compose extends BaseModule
'$jotplugins' => $jotplugins,
'$rand_num' => Crypto::randomDigits(12),
'$acl_selector' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), $doesFederate, [
'$acl_selector' => ACL::getFullSelectorHTML($this->page, $a->getLoggedInUserId(), $doesFederate, [
'allow_cid' => $contact_allow_list,
'allow_gid' => $group_allow_list,
'deny_cid' => $contact_deny_list,

View file

@ -53,7 +53,7 @@ class NodeInfo110 extends BaseModule
'version' => '1.0',
'software' => [
'name' => 'friendica',
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
'version' => App::VERSION . '-' . DB_UPDATE_VERSION,
],
'protocols' => [
'inbound' => [

View file

@ -53,7 +53,7 @@ class NodeInfo120 extends BaseModule
'version' => '2.0',
'software' => [
'name' => 'friendica',
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
'version' => App::VERSION . '-' . DB_UPDATE_VERSION,
],
'protocols' => ['dfrn', 'activitypub'],
'services' => Nodeinfo::getServices(),

View file

@ -55,7 +55,7 @@ class NodeInfo210 extends BaseModule
'baseUrl' => $this->baseUrl->get(),
'name' => $this->config->get('config', 'sitename'),
'software' => 'friendica',
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
'version' => App::VERSION . '-' . DB_UPDATE_VERSION,
],
'organization' => Nodeinfo::getOrganization($this->config),
'protocols' => ['dfrn', 'activitypub'],

View file

@ -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']);
}

View file

@ -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();
}

View file

@ -338,7 +338,7 @@ class Photo extends BaseModule
}
if ($update) {
Logger::info('Invalid file, contact update initiated', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
Worker::add(PRIORITY_LOW, 'UpdateContact', $id);
Worker::add(Worker::PRIORITY_LOW, 'UpdateContact', $id);
} else {
Logger::info('Invalid file', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
}

View file

@ -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 '';
}

View file

@ -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 '';
}

View file

@ -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;
}
@ -302,12 +302,12 @@ class Register extends BaseModule
if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) {
$url = $base_url . '/profile/' . $user['nickname'];
Worker::add(PRIORITY_LOW, 'Directory', $url);
Worker::add(Worker::PRIORITY_LOW, 'Directory', $url);
}
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:<br> login: %s<br> password: %s<br><br>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();
}

View file

@ -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;
}

View file

@ -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();
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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();
}
}

View file

@ -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');

View file

@ -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.'));
}
}
}

View file

@ -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();
}

View file

@ -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]);

View file

@ -75,10 +75,10 @@ class Account extends BaseSettings
throw new Exception(DI::l10n()->t('Password update failed. Please try again.'));
}
info(DI::l10n()->t('Password changed.'));
DI::sysmsg()->addInfo(DI::l10n()->t('Password changed.'));
} catch (Exception $e) {
notice($e->getMessage());
notice(DI::l10n()->t('Password unchanged.'));
DI::sysmsg()->addNotice($e->getMessage());
DI::sysmsg()->addNotice(DI::l10n()->t('Password unchanged.'));
}
DI::baseUrl()->redirect($redirectUrl);
@ -123,7 +123,7 @@ class Account extends BaseSettings
}
if (strlen($err)) {
notice($err);
DI::sysmsg()->addNotice($err);
return;
}
@ -146,7 +146,7 @@ class Account extends BaseSettings
}
if (!User::update($fields, local_user())) {
notice(DI::l10n()->t('Settings were not updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
// clear session language
@ -198,7 +198,7 @@ class Account extends BaseSettings
];
if (!User::update($fields, local_user()) || !Profile::update($profile_fields, local_user())) {
notice(DI::l10n()->t('Settings were not updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
DI::baseUrl()->redirect($redirectUrl);
@ -218,7 +218,7 @@ class Account extends BaseSettings
DI::pConfig()->set(local_user(), 'expire', 'network_only', $expire_network_only);
if (!User::update(['expire' => $expire], local_user())) {
notice(DI::l10n()->t('Settings were not updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
DI::baseUrl()->redirect($redirectUrl);
@ -302,7 +302,7 @@ class Account extends BaseSettings
];
if (!User::update($fields, local_user())) {
notice(DI::l10n()->t('Settings were not updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
DI::baseUrl()->redirect($redirectUrl);
@ -351,7 +351,7 @@ class Account extends BaseSettings
]);
if (!User::update($fields, local_user()) || !empty($profile_fields) && !Profile::update($profile_fields, local_user())) {
notice(DI::l10n()->t('Settings were not updated.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
DI::baseUrl()->redirect($redirectUrl);
@ -363,7 +363,7 @@ class Account extends BaseSettings
// was there an error
if ($_FILES['importcontact-filename']['error'] > 0) {
Logger::notice('Contact CSV file upload error', ['error' => $_FILES['importcontact-filename']['error']]);
notice(DI::l10n()->t('Contact CSV file upload error'));
DI::sysmsg()->addNotice(DI::l10n()->t('Contact CSV file upload error'));
} else {
$csvArray = array_map('str_getcsv', file($_FILES['importcontact-filename']['tmp_name']));
Logger::notice('Import started', ['lines' => count($csvArray)]);
@ -375,14 +375,14 @@ class Account extends BaseSettings
// "http" or "@" to be present in the string.
// All other fields from the row will be ignored
if ((strpos($csvRow[0], '@') !== false) || Network::isValidHttpUrl($csvRow[0])) {
Worker::add(PRIORITY_MEDIUM, 'AddContact', local_user(), $csvRow[0]);
Worker::add(Worker::PRIORITY_MEDIUM, 'AddContact', local_user(), $csvRow[0]);
} else {
Logger::notice('Invalid account', ['url' => $csvRow[0]]);
}
}
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']);
}
@ -394,8 +394,8 @@ class Account extends BaseSettings
}
if (!empty($request['relocate-submit'])) {
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
info(DI::l10n()->t("Relocate message has been send to your contacts"));
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
DI::sysmsg()->addInfo(DI::l10n()->t("Relocate message has been send to your contacts"));
DI::baseUrl()->redirect($redirectUrl);
}
@ -412,7 +412,7 @@ class Account extends BaseSettings
$profile = DBA::selectFirst('profile', [], ['uid' => local_user()]);
if (!DBA::isResult($profile)) {
notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
return '';
}

View file

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

View file

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

View file

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

View file

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

Some files were not shown because too many files have changed in this diff Show more