Merge branch 'develop' into introduce-phpmd
commit
7d792600b4
|
@ -7,7 +7,7 @@ echo ">>> Friendica Setup"
|
|||
|
||||
FRIENDICA_PHP_PATH=$(which php)
|
||||
export FRIENDICA_PHP_PATH
|
||||
|
||||
|
||||
envsubst < $workspaceFolder/.devcontainer/include/autoinstall.config.php > /tmp/autoinstall.config.php
|
||||
cp $workspaceFolder/.devcontainer/include/00apcu.config.php $workspaceFolder/config/00apcu.config.php
|
||||
cp $workspaceFolder/.devcontainer/include/01redis.config.php $workspaceFolder/config/01redis.config.php
|
||||
|
@ -19,7 +19,7 @@ cd $DocumentRoot
|
|||
# copy the .htaccess-dist file to .htaccess so that rewrite rules work
|
||||
cp $DocumentRoot/.htaccess-dist $DocumentRoot/.htaccess
|
||||
|
||||
bin/composer.phar --no-dev install
|
||||
bin/composer.phar install
|
||||
|
||||
# install friendica
|
||||
bin/console autoinstall -f /tmp/autoinstall.config.php
|
||||
|
|
|
@ -72,7 +72,6 @@ venv/
|
|||
/.idea
|
||||
|
||||
#ignore addons directory
|
||||
/addons
|
||||
/addon
|
||||
|
||||
#ignore base .htaccess
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
# SPDX-FileCopyrightText: 2010 - 2024 the Friendica project
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
dir=$(cd "${0%[/\\]*}" > /dev/null; pwd)
|
||||
dir=$(cd "$(dirname "$0")" > /dev/null 2>&1; pwd)
|
||||
|
||||
if [[ -d /proc/cygdrive && $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
|
||||
if [ -d /proc/cygdrive ] && [ "$(which php)" = "$(readlink -n /proc/cygdrive)/*" ]; then
|
||||
# We are in Cygwin using Windows php, so the path must be translated
|
||||
dir=$(cygpath -m "$dir");
|
||||
dir=$(cygpath -m "$dir")
|
||||
fi
|
||||
|
||||
php "${dir}/console.php" "$@"
|
||||
|
|
|
@ -24,7 +24,7 @@ chdir(dirname(__DIR__));
|
|||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
fwrite(STDOUT, '`bin/daemon.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php daemon` instead.' . \PHP_EOL);
|
||||
fwrite(STDOUT, '`bin/daemon.php` is deprecated since 2025.02 and will be removed in 5 months, please use `bin/console.php daemon` instead.' . \PHP_EOL);
|
||||
|
||||
// BC: Add console command as second argument
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
|
|
|
@ -19,7 +19,7 @@ chdir(dirname(__DIR__));
|
|||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
fwrite(STDOUT, '`bin/jetstream.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php jetstream` instead.' . \PHP_EOL);
|
||||
fwrite(STDOUT, '`bin/jetstream.php` is deprecated since 2025.02 and will be removed in 5 months, please use `bin/console.php jetstream` instead.' . \PHP_EOL);
|
||||
|
||||
// BC: Add console command as second argument
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
|
|
|
@ -1,13 +1,20 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
# SPDX-FileCopyrightText: 2010 - 2024 the Friendica project
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
set -eo pipefail
|
||||
set -e
|
||||
|
||||
function resolve {
|
||||
if [ "$(uname)" == "Darwin" ]
|
||||
# Custom function to handle pipefail behavior
|
||||
pipefail() {
|
||||
local cmd="$1"
|
||||
shift
|
||||
{ eval "$cmd"; } || exit 1
|
||||
}
|
||||
|
||||
resolve() {
|
||||
if [ "$(uname)" = "Darwin" ]
|
||||
then
|
||||
realpath "$1"
|
||||
else
|
||||
|
@ -17,26 +24,26 @@ function resolve {
|
|||
|
||||
FULLPATH=$(dirname "$(resolve "$0")")
|
||||
|
||||
if [ "$1" == "--help" ] || [ "$1" == "-h" ]
|
||||
if [ "$1" = "--help" ] || [ "$1" = "-h" ]
|
||||
then
|
||||
echo "$(basename "$(resolve "$0")") [options]"
|
||||
echo
|
||||
echo "-a | --addon <name> extract strings from addon 'name'"
|
||||
echo "-s | --single single addon mode: extract string from current folder"
|
||||
echo "-s | --single single addon mode: extract string from current folder"
|
||||
exit
|
||||
fi
|
||||
|
||||
MODE='default'
|
||||
ADDONNAME=
|
||||
if [ "$1" == "--addon" ] || [ "$1" == "-a" ]
|
||||
if [ "$1" = "--addon" ] || [ "$1" = "-a" ]
|
||||
then
|
||||
MODE='addon'
|
||||
if [ -z "$2" ]; then echo -e "ERROR: missing addon name\n\nrun_xgettext.sh -a <addonname>"; exit 1; fi
|
||||
if [ -z "$2" ]; then echo "ERROR: missing addon name\n\nrun_xgettext.sh -a <addonname>"; exit 1; fi
|
||||
ADDONNAME=$2
|
||||
if [ ! -d "$FULLPATH/../addon/$ADDONNAME" ]; then echo "ERROR: addon '$ADDONNAME' not found"; exit 2; fi
|
||||
fi
|
||||
|
||||
if [ "$1" == "--single" ] || [ "$1" == "-s" ]
|
||||
if [ "$1" = "--single" ] || [ "$1" = "-s" ]
|
||||
then
|
||||
MODE='single'
|
||||
fi
|
||||
|
@ -70,7 +77,6 @@ case "$MODE" in
|
|||
;;
|
||||
esac
|
||||
|
||||
|
||||
KEYWORDS="-k -kt -ktt:1,2"
|
||||
|
||||
echo "Extract strings to $OUTFILE.."
|
||||
|
@ -79,13 +85,13 @@ echo "Extract strings to $OUTFILE.."
|
|||
# shellcheck disable=SC2086 # $FINDOPTS is meant to be split
|
||||
find_result=$(find "$FINDSTARTDIR" $FINDOPTS -name "*.php" -type f | LC_ALL=C sort -s)
|
||||
|
||||
total_files=$(wc -l <<< "${find_result}")
|
||||
total_files=$(echo "${find_result}" | wc -l)
|
||||
|
||||
count=1
|
||||
for file in $find_result
|
||||
do
|
||||
echo -ne " \r"
|
||||
echo -ne "Reading file $count/$total_files..."
|
||||
printf " \r"
|
||||
printf "Reading file %d/%d..." "$count" "$total_files"
|
||||
|
||||
# On Windows, find still outputs the name of pruned folders
|
||||
if [ ! -d "$file" ]
|
||||
|
@ -94,9 +100,8 @@ do
|
|||
xgettext $KEYWORDS --no-wrap -j -o "$OUTFILE" --from-code=UTF-8 "$file" || exit 1
|
||||
sed -i.bkp "s/CHARSET/UTF-8/g" "$OUTFILE"
|
||||
fi
|
||||
(( count++ ))
|
||||
count=$((count + 1))
|
||||
done
|
||||
echo -ne "\n"
|
||||
|
||||
echo "Interpolate metadata.."
|
||||
|
||||
|
@ -119,7 +124,7 @@ case "$MODE" in
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ "" != "$1" ] && [ "$MODE" == "default" ]
|
||||
if [ -n "$1" ] && [ "$MODE" = "default" ]
|
||||
then
|
||||
UPDATEFILE="$(resolve "${FULLPATH}/$1")"
|
||||
echo "Merging new strings to $UPDATEFILE.."
|
||||
|
|
|
@ -21,7 +21,7 @@ chdir(dirname(__DIR__));
|
|||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
fwrite(STDOUT, '`bin/worker.php` is deprecated since 2024.02 and will be removed in 5 months, please use `bin/console.php worker` instead.' . \PHP_EOL);
|
||||
fwrite(STDOUT, '`bin/worker.php` is deprecated since 2025.02 and will be removed in 5 months, please use `bin/console.php worker` instead.' . \PHP_EOL);
|
||||
|
||||
// BC: Add console command as second argument
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
|
|
|
@ -70,10 +70,12 @@
|
|||
"pragmarx/google2fa": "^5.0",
|
||||
"pragmarx/recovery": "^0.2",
|
||||
"psr/clock": "^1.0",
|
||||
"psr/container": "^2.0",
|
||||
"psr/container": "^1.1|^2.0",
|
||||
"psr/event-dispatcher": "^1.0",
|
||||
"psr/log": "^1.1",
|
||||
"seld/cli-prompt": "^1.0",
|
||||
"smarty/smarty": "^4",
|
||||
"symfony/event-dispatcher": "^5.4",
|
||||
"textalk/websocket": "^1.6",
|
||||
"ua-parser/uap-php": "^3.9",
|
||||
"xemlock/htmlpurifier-html5": "^0.1.11"
|
||||
|
@ -114,7 +116,6 @@
|
|||
},
|
||||
"sort-packages": true,
|
||||
"autoloader-suffix": "Friendica",
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"allow-plugins": {
|
||||
"composer/installers": true,
|
||||
|
@ -174,6 +175,7 @@
|
|||
"@cs:install",
|
||||
"bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix"
|
||||
],
|
||||
"cs:fix-develop": "TARGET_BRANCH=develop COMMAND=fix bin/dev/fix-codestyle.sh"
|
||||
"cs:fix-develop": "TARGET_BRANCH=develop COMMAND=fix bin/dev/fix-codestyle.sh",
|
||||
"install:prod": "@composer install -o --no-dev"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "1398ab5832571c32982984ffe9bd810f",
|
||||
"content-hash": "b77bf714197f04022a5feb001bf07852",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asika/simple-console",
|
||||
|
@ -3139,6 +3139,9 @@
|
|||
"psr",
|
||||
"psr-6"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/cache/tree/master"
|
||||
},
|
||||
"time": "2016-08-06T20:24:11+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -3187,27 +3190,22 @@
|
|||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
"version": "2.0.2",
|
||||
"version": "1.1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/container.git",
|
||||
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
|
||||
"reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
|
||||
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
|
||||
"url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
|
||||
"reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Container\\": "src/"
|
||||
|
@ -3232,7 +3230,61 @@
|
|||
"container-interop",
|
||||
"psr"
|
||||
],
|
||||
"time": "2021-11-05T16:47:00+00:00"
|
||||
"support": {
|
||||
"issues": "https://github.com/php-fig/container/issues",
|
||||
"source": "https://github.com/php-fig/container/tree/1.1.2"
|
||||
},
|
||||
"time": "2021-11-05T16:50:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/event-dispatcher",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/event-dispatcher.git",
|
||||
"reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
|
||||
"reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\EventDispatcher\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Standard interfaces for event handling.",
|
||||
"keywords": [
|
||||
"events",
|
||||
"psr",
|
||||
"psr-14"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-fig/event-dispatcher/issues",
|
||||
"source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0"
|
||||
},
|
||||
"time": "2019-01-08T18:20:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-client",
|
||||
|
@ -3430,6 +3482,9 @@
|
|||
"psr",
|
||||
"psr-3"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/log/tree/1.1.4"
|
||||
},
|
||||
"time": "2021-05-03T11:20:27+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -3647,16 +3702,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/deprecation-contracts",
|
||||
"version": "v2.5.2",
|
||||
"version": "v2.5.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/deprecation-contracts.git",
|
||||
"reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66"
|
||||
"reference": "605389f2a7e5625f273b53960dc46aeaf9c62918"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
|
||||
"reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
|
||||
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918",
|
||||
"reference": "605389f2a7e5625f273b53960dc46aeaf9c62918",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3664,12 +3719,12 @@
|
|||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/contracts",
|
||||
"name": "symfony/contracts"
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-main": "2.5-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/contracts",
|
||||
"url": "https://github.com/symfony/contracts"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -3693,6 +3748,9 @@
|
|||
],
|
||||
"description": "A generic function and convention to trigger deprecation notices",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
|
@ -3707,7 +3765,171 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-01-02T09:53:40+00:00"
|
||||
"time": "2024-09-25T14:11:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v5.4.45",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
"reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/72982eb416f61003e9bb6e91f8b3213600dcf9e9",
|
||||
"reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/deprecation-contracts": "^2.1|^3",
|
||||
"symfony/event-dispatcher-contracts": "^2|^3",
|
||||
"symfony/polyfill-php80": "^1.16"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/dependency-injection": "<4.4"
|
||||
},
|
||||
"provide": {
|
||||
"psr/event-dispatcher-implementation": "1.0",
|
||||
"symfony/event-dispatcher-implementation": "2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "^1|^2|^3",
|
||||
"symfony/config": "^4.4|^5.0|^6.0",
|
||||
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
|
||||
"symfony/error-handler": "^4.4|^5.0|^6.0",
|
||||
"symfony/expression-language": "^4.4|^5.0|^6.0",
|
||||
"symfony/http-foundation": "^4.4|^5.0|^6.0",
|
||||
"symfony/service-contracts": "^1.1|^2|^3",
|
||||
"symfony/stopwatch": "^4.4|^5.0|^6.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/dependency-injection": "",
|
||||
"symfony/http-kernel": ""
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\EventDispatcher\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/event-dispatcher/tree/v5.4.45"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-25T14:11:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher-contracts",
|
||||
"version": "v2.5.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher-contracts.git",
|
||||
"reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f",
|
||||
"reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"psr/event-dispatcher": "^1"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/event-dispatcher-implementation": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/contracts",
|
||||
"name": "symfony/contracts"
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-main": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Contracts\\EventDispatcher\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Generic abstractions related to dispatching event",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"abstractions",
|
||||
"contracts",
|
||||
"decoupling",
|
||||
"interfaces",
|
||||
"interoperability",
|
||||
"standards"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-25T14:11:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php56",
|
||||
|
@ -3774,6 +3996,86 @@
|
|||
],
|
||||
"time": "2020-10-23T14:02:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php80",
|
||||
"version": "v1.31.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php80.git",
|
||||
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
|
||||
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/polyfill",
|
||||
"name": "symfony/polyfill"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Php80\\": ""
|
||||
},
|
||||
"classmap": [
|
||||
"Resources/stubs"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ion Bazan",
|
||||
"email": "ion.bazan@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-09T11:45:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "textalk/websocket",
|
||||
"version": "1.6.3",
|
||||
|
@ -6725,41 +7027,50 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/dependency-injection",
|
||||
"version": "v3.2.14",
|
||||
"version": "v5.4.48",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/dependency-injection.git",
|
||||
"reference": "d9f2e62e1a93d52ad4e4f6faaf66f6eef723d761"
|
||||
"reference": "e5ca16dee39ef7d63e552ff0bf0a2526a1142c92"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/d9f2e62e1a93d52ad4e4f6faaf66f6eef723d761",
|
||||
"reference": "d9f2e62e1a93d52ad4e4f6faaf66f6eef723d761",
|
||||
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e5ca16dee39ef7d63e552ff0bf0a2526a1142c92",
|
||||
"reference": "e5ca16dee39ef7d63e552ff0bf0a2526a1142c92",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
"php": ">=7.2.5",
|
||||
"psr/container": "^1.1.1",
|
||||
"symfony/deprecation-contracts": "^2.1|^3",
|
||||
"symfony/polyfill-php80": "^1.16",
|
||||
"symfony/polyfill-php81": "^1.22",
|
||||
"symfony/service-contracts": "^1.1.6|^2"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/yaml": "<3.2"
|
||||
"ext-psr": "<1.1|>=2",
|
||||
"symfony/config": "<5.3",
|
||||
"symfony/finder": "<4.4",
|
||||
"symfony/proxy-manager-bridge": "<4.4",
|
||||
"symfony/yaml": "<4.4.26"
|
||||
},
|
||||
"provide": {
|
||||
"psr/container-implementation": "1.0",
|
||||
"symfony/service-implementation": "1.0|2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/config": "~2.8|~3.0",
|
||||
"symfony/expression-language": "~2.8|~3.0",
|
||||
"symfony/yaml": "~3.2"
|
||||
"symfony/config": "^5.3|^6.0",
|
||||
"symfony/expression-language": "^4.4|^5.0|^6.0",
|
||||
"symfony/yaml": "^4.4.26|^5.0|^6.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/config": "",
|
||||
"symfony/expression-language": "For using expressions in service container configuration",
|
||||
"symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required",
|
||||
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
|
||||
"symfony/yaml": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\DependencyInjection\\": ""
|
||||
|
@ -6782,12 +7093,26 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony DependencyInjection Component",
|
||||
"description": "Allows you to standardize and centralize the way objects are constructed in your application",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/dependency-injection/tree/3.2"
|
||||
"source": "https://github.com/symfony/dependency-injection/tree/v5.4.48"
|
||||
},
|
||||
"time": "2017-07-28T15:22:55+00:00"
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-20T10:51:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
|
@ -7015,86 +7340,6 @@
|
|||
],
|
||||
"time": "2024-09-09T11:45:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php80",
|
||||
"version": "v1.31.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php80.git",
|
||||
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
|
||||
"reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/polyfill",
|
||||
"name": "symfony/polyfill"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Php80\\": ""
|
||||
},
|
||||
"classmap": [
|
||||
"Resources/stubs"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ion Bazan",
|
||||
"email": "ion.bazan@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-09T11:45:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php81",
|
||||
"version": "v1.31.0",
|
||||
|
@ -7171,6 +7416,89 @@
|
|||
],
|
||||
"time": "2024-09-09T11:45:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/service-contracts",
|
||||
"version": "v2.5.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/service-contracts.git",
|
||||
"reference": "f37b419f7aea2e9abf10abd261832cace12e3300"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/f37b419f7aea2e9abf10abd261832cace12e3300",
|
||||
"reference": "f37b419f7aea2e9abf10abd261832cace12e3300",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"psr/container": "^1.1",
|
||||
"symfony/deprecation-contracts": "^2.1|^3"
|
||||
},
|
||||
"conflict": {
|
||||
"ext-psr": "<1.1|>=2"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/service-implementation": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/contracts",
|
||||
"name": "symfony/contracts"
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-main": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Contracts\\Service\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Generic abstractions related to writing services",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"abstractions",
|
||||
"contracts",
|
||||
"decoupling",
|
||||
"interfaces",
|
||||
"interoperability",
|
||||
"standards"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/service-contracts/tree/v2.5.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-25T14:11:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "theseer/tokenizer",
|
||||
"version": "1.2.3",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2025.02-dev (Interrupted Fern)
|
||||
-- DB_UPDATE_VERSION 1576
|
||||
-- DB_UPDATE_VERSION 1577
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
@ -1609,7 +1609,7 @@ CREATE TABLE IF NOT EXISTS `post-user` (
|
|||
`psid` int unsigned COMMENT 'ID of the permission set of this post',
|
||||
PRIMARY KEY(`id`),
|
||||
UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
|
||||
INDEX `uri-id` (`uri-id`),
|
||||
INDEX `uri-id_origin_deleted` (`uri-id`,`origin`,`deleted`),
|
||||
INDEX `parent-uri-id` (`parent-uri-id`),
|
||||
INDEX `thr-parent-id` (`thr-parent-id`),
|
||||
INDEX `external-id` (`external-id`),
|
||||
|
@ -3809,7 +3809,8 @@ CREATE VIEW `pending-view` AS SELECT
|
|||
`contact`.`nick` AS `nick`
|
||||
FROM `register`
|
||||
INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
|
||||
INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;
|
||||
INNER JOIN `user` ON `register`.`uid` = `user`.`uid`
|
||||
WHERE `register`.`uid` != 0;
|
||||
|
||||
--
|
||||
-- VIEW tag-search-view
|
||||
|
|
|
@ -62,7 +62,7 @@ If you want to have git automatically update the dependencies with composer, you
|
|||
}
|
||||
# `composer install` if the `composer.lock` file gets changed
|
||||
# to update all the php dependencies
|
||||
check_run composer.lock "bin/composer.phar install --no-dev"
|
||||
check_run composer.lock "bin/composer.phar install"
|
||||
|
||||
just place it into `.git/hooks/post-merge` and make it executable.
|
||||
|
||||
|
@ -210,9 +210,9 @@ If the deprecated code is no longer used inside Friendica or the official addons
|
|||
The code MUST NOT be deleted.
|
||||
Starting from the next release, it MUST be stay for at least 5 months.
|
||||
Hard deprecated code COULD remain longer than 5 months, depending on when a release appears.
|
||||
Addon developer MUST NOT consider that they have more than 5 months to adjust their code.
|
||||
Addon developer SHOULD NOT consider that they have more than 5 months to adjust their code.
|
||||
|
||||
Hard deprecation code means that the code triggers an `E_USER_DEPRECATION` error if it is called.
|
||||
Hard deprecation code means that the code triggers a muted `E_USER_DEPRECATION` error if it is called.
|
||||
For instance with the deprecated class `Friendica\Core\Logger` the call of every method should trigger an error:
|
||||
|
||||
```php
|
||||
|
@ -224,7 +224,7 @@ For instance with the deprecated class `Friendica\Core\Logger` the call of every
|
|||
class Logger {
|
||||
public static function info(string $message, array $context = [])
|
||||
{
|
||||
trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.05 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.05 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::getInstance()->info($message, $context);
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ class Logger {
|
|||
}
|
||||
```
|
||||
|
||||
This way the maintainer or users of addons will be notified that the addon will stop working in one of the next releases.
|
||||
This way the maintainer or users of addons will be notified in the logs that the addon will stop working in one of the next releases.
|
||||
The addon maintainer now has at least 5 months or at least one release to fix the deprecations.
|
||||
|
||||
Please note that the deprecation message contains the release that will be released next.
|
||||
|
|
|
@ -76,14 +76,6 @@ This makes the software much easier to update.
|
|||
The Linux commands to clone the repository into a directory "mywebsite" would be
|
||||
|
||||
git clone https://github.com/friendica/friendica.git -b stable mywebsite
|
||||
cd mywebsite
|
||||
bin/composer.phar install --no-dev
|
||||
|
||||
Make sure the folder *view/smarty3* exists and is writable by the webserver user, in this case *www-data*
|
||||
|
||||
mkdir -p view/smarty3
|
||||
chown www-data:www-data view/smarty3
|
||||
chmod 775 view/smarty3
|
||||
|
||||
Get the addons by going into your website folder.
|
||||
|
||||
|
@ -91,12 +83,22 @@ Get the addons by going into your website folder.
|
|||
|
||||
Clone the addon repository (separately):
|
||||
|
||||
git clone https://github.com/friendica/friendica-addons.git -b stable addon
|
||||
git clone https://github.com/friendica/friendica-addons.git -b stable addon
|
||||
|
||||
Install the dependencies:
|
||||
|
||||
bin/composer.phar run install:prod
|
||||
|
||||
Make sure the folder *view/smarty3* exists and is writable by the webserver user, in this case *www-data*
|
||||
|
||||
mkdir -p view/smarty3
|
||||
chown www-data:www-data view/smarty3
|
||||
chmod 775 view/smarty3
|
||||
|
||||
If you want to use the development version of Friendica you can switch to the develop branch in the repository by running
|
||||
|
||||
git checkout develop
|
||||
bin/composer.phar install
|
||||
bin/composer.phar run install:prod
|
||||
cd addon
|
||||
git checkout develop
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ If you installed Friendica in the ``path/to/friendica`` folder:
|
|||
* ``.htaccess`` if using Apache web server
|
||||
|
||||
The following items only need to be copied if they are located inside your friendica path:
|
||||
* your storage folder as set in **Admin -> Site -> File Upload -> Storage base path**
|
||||
* your storage folder as set in **Admin -> Site -> File Upload -> Storage base path**
|
||||
* your item cache as set in **Admin -> Site -> Performance -> Path to item cache**
|
||||
* your temp folder as set in **Admin -> Site -> Advanced -> Temp path**
|
||||
3. Rename the ``path/to/friendica`` folder to ``path/to/friendica_old``.
|
||||
|
@ -30,7 +30,7 @@ You can get the latest changes at any time with
|
|||
|
||||
cd path/to/friendica
|
||||
git pull
|
||||
bin/composer.phar install --no-dev
|
||||
bin/composer.phar run install:prod
|
||||
|
||||
The addon tree has to be updated separately like so:
|
||||
|
||||
|
@ -89,7 +89,7 @@ Some of the updates include the use of foreign keys now that will bump into issu
|
|||
```
|
||||
Error 1452 occurred during database update:
|
||||
Cannot add or update a child row: a foreign key constraint fails (`friendica`.`#sql-10ea6_5a6d`, CONSTRAINT `#sql-10ea6_5a6d_ibfk_1` FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`))
|
||||
ALTER TABLE `thread` ADD FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE;
|
||||
ALTER TABLE `thread` ADD FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE;
|
||||
```
|
||||
|
||||
All current known fixes for possible items that can go wrong are as below.
|
||||
|
|
|
@ -18,7 +18,7 @@ What you need to do:
|
|||
Please use an up-to-date vagrant version from https://www.vagrantup.com/downloads.html.
|
||||
2. Git clone your Friendica repository.
|
||||
Inside, you'll find a `Vagrantfile` and some scripts in the `bin/dev` folder.
|
||||
Pull the PHP requirements with `bin/composer install`.
|
||||
Pull the PHP requirements with `bin/composer.phar install`.
|
||||
3. Run `vagrant up` from inside the friendica clone.
|
||||
This will start the virtual machine.
|
||||
Be patient: When it runs for the first time, it downloads a Debian Server image and installs Friendica.
|
||||
|
@ -60,7 +60,7 @@ Trouble Shooting
|
|||
If you see a version mis-match for the _VirtualBox Guest Additions_ between host and guest during the initial setup of the Vagrant VM, you will need to install an addon to Vagrant (ref. [Stack Overflow](https://stackoverflow.com/a/38010683)).
|
||||
Stop the Vagrant VM and run the following command:
|
||||
|
||||
$> vagrant plugin install vagrant-vbguest
|
||||
$> vagrant plugin install vagrant-vbguest
|
||||
|
||||
On the next Vagrant up, the version problem should be fixed.
|
||||
|
||||
|
|
|
@ -44,31 +44,31 @@ Fields
|
|||
Indexes
|
||||
------------
|
||||
|
||||
| Name | Fields |
|
||||
| -------------------- | ----------------------- |
|
||||
| PRIMARY | id |
|
||||
| uid_uri-id | UNIQUE, uid, uri-id |
|
||||
| uri-id | uri-id |
|
||||
| parent-uri-id | parent-uri-id |
|
||||
| thr-parent-id | thr-parent-id |
|
||||
| external-id | external-id |
|
||||
| replies-id | replies-id |
|
||||
| owner-id | owner-id |
|
||||
| author-id | author-id |
|
||||
| causer-id | causer-id |
|
||||
| vid | vid |
|
||||
| contact-id | contact-id |
|
||||
| event-id | event-id |
|
||||
| psid | psid |
|
||||
| author-id_uid | author-id, uid |
|
||||
| author-id_created | author-id, created |
|
||||
| owner-id_created | owner-id, created |
|
||||
| parent-uri-id_uid | parent-uri-id, uid |
|
||||
| uid_wall_received | uid, wall, received |
|
||||
| uid_contactid | uid, contact-id |
|
||||
| uid_unseen_contactid | uid, unseen, contact-id |
|
||||
| uid_unseen | uid, unseen |
|
||||
| uid_hidden_uri-id | uid, hidden, uri-id |
|
||||
| Name | Fields |
|
||||
|-----------------------| ----------------------- |
|
||||
| PRIMARY | id |
|
||||
| uid_uri-id | UNIQUE, uid, uri-id |
|
||||
| uri-id_origin_deleted | uri-id, origin, deleted |
|
||||
| parent-uri-id | parent-uri-id |
|
||||
| thr-parent-id | thr-parent-id |
|
||||
| external-id | external-id |
|
||||
| replies-id | replies-id |
|
||||
| owner-id | owner-id |
|
||||
| author-id | author-id |
|
||||
| causer-id | causer-id |
|
||||
| vid | vid |
|
||||
| contact-id | contact-id |
|
||||
| event-id | event-id |
|
||||
| psid | psid |
|
||||
| author-id_uid | author-id, uid |
|
||||
| author-id_created | author-id, created |
|
||||
| owner-id_created | owner-id, created |
|
||||
| parent-uri-id_uid | parent-uri-id, uid |
|
||||
| uid_wall_received | uid, wall, received |
|
||||
| uid_contactid | uid, contact-id |
|
||||
| uid_unseen_contactid | uid, unseen, contact-id |
|
||||
| uid_unseen | uid, unseen |
|
||||
| uid_hidden_uri-id | uid, hidden, uri-id |
|
||||
|
||||
Foreign Keys
|
||||
------------
|
||||
|
|
|
@ -59,7 +59,7 @@ Der Linux-Code, mit dem man die Dateien direkt in ein Verzeichnis wie "meinewebs
|
|||
|
||||
git clone https://github.com/friendica/friendica.git -b stable mywebsite
|
||||
cd mywebsite
|
||||
bin/composer.phar install
|
||||
bin/composer.phar run install:prod
|
||||
|
||||
Stelle sicher, dass der Ordner *view/smarty3* existiert and von dem Webserver-Benutzer beschreibbar ist
|
||||
|
||||
|
@ -85,7 +85,7 @@ Wenn du die Entwickler Version von Friendica verwenden möchtest kannst du auf d
|
|||
Dies tust du mit den folgenden Befehlen
|
||||
|
||||
git checkout develop
|
||||
bin/composer.phar install
|
||||
bin/composer.phar run install:prod
|
||||
cd addon
|
||||
git checkout develop
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
$start_time = microtime(true);
|
||||
|
||||
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
|
||||
die('Vendor path not found. Please execute "bin/composer.phar --no-dev install" on the command line in the web root.');
|
||||
die('Vendor path not found. Please execute "bin/composer.phar run install:prod" on the command line in the web root.');
|
||||
}
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
|
|
@ -11,7 +11,6 @@ use Friendica\Content\Nav;
|
|||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
|
@ -1067,6 +1066,7 @@ function photos_content()
|
|||
$cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
|
||||
$tpl = Renderer::getMarkupTemplate('photo_item.tpl');
|
||||
$return_path = DI::args()->getCommand();
|
||||
$addonHelper = DI::addonHelper();
|
||||
|
||||
if (!DBA::isResult($items)) {
|
||||
if (($can_post || Security::canWriteToUserWall($owner_uid))) {
|
||||
|
@ -1075,7 +1075,7 @@ function photos_content()
|
|||
* This should be better if done by a hook
|
||||
*/
|
||||
$qcomment = null;
|
||||
if (Addon::isEnabled('qcomment')) {
|
||||
if ($addonHelper->isAddonEnabled('qcomment')) {
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||
$qcomment = $words ? explode("\n", $words) : [];
|
||||
}
|
||||
|
@ -1131,7 +1131,7 @@ function photos_content()
|
|||
* This should be better if done by a hook
|
||||
*/
|
||||
$qcomment = null;
|
||||
if (Addon::isEnabled('qcomment')) {
|
||||
if ($addonHelper->isAddonEnabled('qcomment')) {
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||
$qcomment = $words ? explode("\n", $words) : [];
|
||||
}
|
||||
|
@ -1211,7 +1211,7 @@ function photos_content()
|
|||
* This should be better if done by a hook
|
||||
*/
|
||||
$qcomment = null;
|
||||
if (Addon::isEnabled('qcomment')) {
|
||||
if ($addonHelper->isAddonEnabled('qcomment')) {
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||
$qcomment = $words ? explode("\n", $words) : [];
|
||||
}
|
||||
|
|
61
src/App.php
61
src/App.php
|
@ -17,16 +17,14 @@ use Friendica\App\Router;
|
|||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\Capabilities\ICanHandleRequests;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Addon\Capability\ICanLoadAddons;
|
||||
use Friendica\Core\Config\Factory\Config;
|
||||
use Friendica\Core\Container;
|
||||
use Friendica\Core\Hooks\HookEventBridge;
|
||||
use Friendica\Core\Logger\LoggerManager;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Database\Definition\DbaDefinition;
|
||||
use Friendica\Database\Definition\ViewDefinition;
|
||||
use Friendica\Module\Maintenance;
|
||||
use Friendica\Security\Authentication;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\DiceContainer;
|
||||
use Friendica\Core\L10n;
|
||||
|
@ -35,9 +33,15 @@ use Friendica\Core\Logger\Handler\ErrorHandler;
|
|||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Update;
|
||||
use Friendica\Database\Definition\DbaDefinition;
|
||||
use Friendica\Database\Definition\ViewDefinition;
|
||||
use Friendica\Event\ConfigLoadedEvent;
|
||||
use Friendica\Event\Event;
|
||||
use Friendica\Module\Maintenance;
|
||||
use Friendica\Module\Special\HTTPException as ModuleHTTPException;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\ATProtocol\DID;
|
||||
use Friendica\Security\Authentication;
|
||||
use Friendica\Security\ExAuth;
|
||||
use Friendica\Security\OpenWebAuth;
|
||||
use Friendica\Util\BasePath;
|
||||
|
@ -45,6 +49,7 @@ use Friendica\Util\DateTimeFormat;
|
|||
use Friendica\Util\HTTPInputData;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
@ -153,6 +158,8 @@ class App
|
|||
|
||||
$this->registerErrorHandler();
|
||||
|
||||
$this->registerEventDispatcher();
|
||||
|
||||
$this->requestId = $this->container->create(Request::class)->getRequestId();
|
||||
$this->auth = $this->container->create(Authentication::class);
|
||||
$this->config = $this->container->create(IManageConfigValues::class);
|
||||
|
@ -165,6 +172,8 @@ class App
|
|||
$this->session = $this->container->create(IHandleUserSessions::class);
|
||||
$this->appHelper = $this->container->create(AppHelper::class);
|
||||
|
||||
$addonHelper = $this->container->create(AddonHelper::class);
|
||||
|
||||
$this->load(
|
||||
$request->getServerParams(),
|
||||
$this->container->create(DbaDefinition::class),
|
||||
|
@ -172,15 +181,19 @@ class App
|
|||
$this->mode,
|
||||
$this->config,
|
||||
$this->profiler,
|
||||
$this->container->create(EventDispatcherInterface::class),
|
||||
$this->appHelper,
|
||||
$addonHelper,
|
||||
);
|
||||
|
||||
$this->registerTemplateEngine();
|
||||
|
||||
$this->runFrontend(
|
||||
$this->container->create(EventDispatcherInterface::class),
|
||||
$this->container->create(IManagePersonalConfigValues::class),
|
||||
$this->container->create(Page::class),
|
||||
$this->container->create(Nav::class),
|
||||
$addonHelper,
|
||||
$this->container->create(ModuleHTTPException::class),
|
||||
$start_time,
|
||||
$request
|
||||
|
@ -202,6 +215,8 @@ class App
|
|||
|
||||
$this->registerErrorHandler();
|
||||
|
||||
$this->registerEventDispatcher();
|
||||
|
||||
$this->load(
|
||||
$serverParams,
|
||||
$this->container->create(DbaDefinition::class),
|
||||
|
@ -209,7 +224,9 @@ class App
|
|||
$this->container->create(Mode::class),
|
||||
$this->container->create(IManageConfigValues::class),
|
||||
$this->container->create(Profiler::class),
|
||||
$this->container->create(EventDispatcherInterface::class),
|
||||
$this->container->create(AppHelper::class),
|
||||
$this->container->create(AddonHelper::class),
|
||||
);
|
||||
|
||||
$this->registerTemplateEngine();
|
||||
|
@ -230,6 +247,8 @@ class App
|
|||
|
||||
$this->registerErrorHandler();
|
||||
|
||||
$this->registerEventDispatcher();
|
||||
|
||||
$this->load(
|
||||
$serverParams,
|
||||
$this->container->create(DbaDefinition::class),
|
||||
|
@ -237,7 +256,9 @@ class App
|
|||
$this->container->create(Mode::class),
|
||||
$this->container->create(IManageConfigValues::class),
|
||||
$this->container->create(Profiler::class),
|
||||
$this->container->create(EventDispatcherInterface::class),
|
||||
$this->container->create(AppHelper::class),
|
||||
$this->container->create(AddonHelper::class),
|
||||
);
|
||||
|
||||
/** @var BasePath */
|
||||
|
@ -301,6 +322,16 @@ class App
|
|||
ErrorHandler::register($this->container->create(LoggerInterface::class));
|
||||
}
|
||||
|
||||
private function registerEventDispatcher(): void
|
||||
{
|
||||
/** @var \Friendica\Event\EventDispatcher */
|
||||
$eventDispatcher = $this->container->create(EventDispatcherInterface::class);
|
||||
|
||||
foreach (HookEventBridge::getStaticSubscribedEvents() as $eventName => $methodName) {
|
||||
$eventDispatcher->addListener($eventName, [HookEventBridge::class, $methodName]);
|
||||
}
|
||||
}
|
||||
|
||||
private function registerTemplateEngine(): void
|
||||
{
|
||||
Renderer::registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine');
|
||||
|
@ -316,7 +347,9 @@ class App
|
|||
Mode $mode,
|
||||
IManageConfigValues $config,
|
||||
Profiler $profiler,
|
||||
AppHelper $appHelper
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
AppHelper $appHelper,
|
||||
AddonHelper $addonHelper
|
||||
): void {
|
||||
if ($config->get('system', 'ini_max_execution_time') !== false) {
|
||||
set_time_limit((int) $config->get('system', 'ini_max_execution_time'));
|
||||
|
@ -338,8 +371,9 @@ class App
|
|||
|
||||
if ($mode->has(Mode::DBAVAILABLE)) {
|
||||
Core\Hook::loadHooks();
|
||||
$loader = (new Config())->createConfigFileManager($appHelper->getBasePath(), $serverParams);
|
||||
Core\Hook::callAll('load_config', $loader);
|
||||
$loader = (new Config())->createConfigFileManager($appHelper->getBasePath(), $addonHelper->getAddonPath(), $serverParams);
|
||||
|
||||
$eventDispatcher->dispatch(new ConfigLoadedEvent(ConfigLoadedEvent::CONFIG_LOADED, $loader));
|
||||
|
||||
// Hooks are now working, reload the whole definitions with hook enabled
|
||||
$dbaDefinition->load(true);
|
||||
|
@ -385,9 +419,11 @@ class App
|
|||
* @throws \ImagickException
|
||||
*/
|
||||
private function runFrontend(
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
IManagePersonalConfigValues $pconfig,
|
||||
Page $page,
|
||||
Nav $nav,
|
||||
AddonHelper $addonHelper,
|
||||
ModuleHTTPException $httpException,
|
||||
float $start_time,
|
||||
ServerRequestInterface $request
|
||||
|
@ -424,7 +460,8 @@ class App
|
|||
$serverVars['REQUEST_METHOD'] === 'GET') {
|
||||
System::externalRedirect($this->baseURL . '/' . $this->args->getQueryString());
|
||||
}
|
||||
Core\Hook::callAll('init_1');
|
||||
|
||||
$eventDispatcher->dispatch(new Event(Event::INIT));
|
||||
}
|
||||
|
||||
DID::routeRequest($this->args->getCommand(), $serverVars);
|
||||
|
@ -475,12 +512,12 @@ class App
|
|||
// but we need "view" module for stylesheet
|
||||
if ($this->mode->isInstall() && $moduleName !== 'install') {
|
||||
$this->baseURL->redirect('install');
|
||||
} else {
|
||||
Core\Update::check($this->appHelper->getBasePath(), false);
|
||||
Core\Addon::loadAddons();
|
||||
Core\Hook::loadHooks();
|
||||
}
|
||||
|
||||
Core\Update::check($this->appHelper->getBasePath(), false);
|
||||
$addonHelper->loadAddons();
|
||||
Core\Hook::loadHooks();
|
||||
|
||||
// Compatibility with Hubzilla
|
||||
if ($moduleName == 'rpost') {
|
||||
$this->baseURL->redirect('compose');
|
||||
|
|
|
@ -14,7 +14,6 @@ use Friendica\App;
|
|||
use Friendica\AppHelper;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Renderer;
|
||||
|
@ -22,12 +21,14 @@ use Friendica\Core\Session\Model\UserSession;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\DI;
|
||||
use Friendica\Event\HtmlFilterEvent;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Profiler;
|
||||
use Friendica\Util\Strings;
|
||||
use GuzzleHttp\Psr7\Utils;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
|
@ -70,6 +71,8 @@ class Page implements ArrayAccess
|
|||
*/
|
||||
private $basePath;
|
||||
|
||||
private EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
private $timestamp = 0;
|
||||
private $method = '';
|
||||
private $module = '';
|
||||
|
@ -78,10 +81,11 @@ class Page implements ArrayAccess
|
|||
/**
|
||||
* @param string $basepath The Page basepath
|
||||
*/
|
||||
public function __construct(string $basepath)
|
||||
public function __construct(string $basepath, EventDispatcherInterface $eventDispatcher)
|
||||
{
|
||||
$this->timestamp = microtime(true);
|
||||
$this->basePath = $basepath;
|
||||
$this->timestamp = microtime(true);
|
||||
$this->basePath = $basepath;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
public function setLogging(string $method, string $module, string $command)
|
||||
|
@ -192,17 +196,6 @@ class Page implements ArrayAccess
|
|||
IManagePersonalConfigValues $pConfig,
|
||||
int $localUID
|
||||
) {
|
||||
$interval = ($localUID ? $pConfig->get($localUID, 'system', 'update_interval') : 40000);
|
||||
|
||||
// If the update is 'deactivated' set it to the highest integer number (~24 days)
|
||||
if ($interval < 0) {
|
||||
$interval = 2147483647;
|
||||
}
|
||||
|
||||
if ($interval < 10000) {
|
||||
$interval = 40000;
|
||||
}
|
||||
|
||||
// Default title: current module called
|
||||
if (empty($this->page['title']) && $args->getModuleName()) {
|
||||
$this->page['title'] = ucfirst($args->getModuleName());
|
||||
|
@ -229,7 +222,9 @@ class Page implements ArrayAccess
|
|||
$touch_icon = 'images/friendica-192.png';
|
||||
}
|
||||
|
||||
Hook::callAll('head', $this->page['htmlhead']);
|
||||
$this->page['htmlhead'] = $this->eventDispatcher->dispatch(
|
||||
new HtmlFilterEvent(HtmlFilterEvent::HEAD, $this->page['htmlhead'])
|
||||
)->getHtml();
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('head.tpl');
|
||||
/* put the head template at the beginning of page['htmlhead']
|
||||
|
@ -266,13 +261,13 @@ class Page implements ArrayAccess
|
|||
'dictMaxFilesExceeded' => $l10n->t("You can't upload any more files."),
|
||||
],
|
||||
|
||||
'$local_user' => $localUID,
|
||||
'$generator' => 'Friendica' . ' ' . App::VERSION,
|
||||
'$update_interval' => $interval,
|
||||
'$shortcut_icon' => $shortcut_icon,
|
||||
'$touch_icon' => $touch_icon,
|
||||
'$block_public' => intval($config->get('system', 'block_public')),
|
||||
'$stylesheets' => $this->stylesheets,
|
||||
'$local_user' => $localUID,
|
||||
'$generator' => 'Friendica' . ' ' . App::VERSION,
|
||||
'$update_content' => (int)$pConfig->get($localUID, 'system', 'update_content'),
|
||||
'$shortcut_icon' => $shortcut_icon,
|
||||
'$touch_icon' => $touch_icon,
|
||||
'$block_public' => intval($config->get('system', 'block_public')),
|
||||
'$stylesheets' => $this->stylesheets,
|
||||
|
||||
// Dropzone
|
||||
'$max_imagesize' => round(Images::getMaxUploadBytes() / 1000000, 0),
|
||||
|
@ -351,11 +346,14 @@ class Page implements ArrayAccess
|
|||
]);
|
||||
}
|
||||
|
||||
Hook::callAll('footer', $this->page['footer']);
|
||||
$this->page['footer'] = $this->eventDispatcher->dispatch(
|
||||
new HtmlFilterEvent(HtmlFilterEvent::FOOTER, $this->page['footer'])
|
||||
)->getHtml();
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('footer.tpl');
|
||||
$this->page['footer'] = Renderer::replaceMacros($tpl, [
|
||||
'$footerScripts' => array_unique($this->footerScripts),
|
||||
'$close' => $l10n->t('Close'),
|
||||
]) . $this->page['footer'];
|
||||
}
|
||||
|
||||
|
@ -375,7 +373,9 @@ class Page implements ArrayAccess
|
|||
{
|
||||
// initialise content region
|
||||
if ($mode->isNormal()) {
|
||||
Hook::callAll('page_content_top', $this->page['content']);
|
||||
$this->page['content'] = $this->eventDispatcher->dispatch(
|
||||
new HtmlFilterEvent(HtmlFilterEvent::PAGE_CONTENT_TOP, $this->page['content'])
|
||||
)->getHtml();
|
||||
}
|
||||
|
||||
$this->page['content'] .= (string)$response->getBody();
|
||||
|
@ -473,7 +473,9 @@ class Page implements ArrayAccess
|
|||
$profiler->set(microtime(true) - $timestamp, 'aftermath');
|
||||
|
||||
if (!$mode->isAjax()) {
|
||||
Hook::callAll('page_end', $this->page['content']);
|
||||
$this->page['content'] = $this->eventDispatcher->dispatch(
|
||||
new HtmlFilterEvent(HtmlFilterEvent::PAGE_END, $this->page['content'])
|
||||
)->getHtml();
|
||||
}
|
||||
|
||||
// Add the navigation (menu) template
|
||||
|
|
|
@ -7,13 +7,11 @@
|
|||
|
||||
namespace Friendica\App;
|
||||
|
||||
use Dice\Dice;
|
||||
use FastRoute\DataGenerator\GroupCountBased;
|
||||
use FastRoute\Dispatcher;
|
||||
use FastRoute\RouteCollector;
|
||||
use FastRoute\RouteParser\Std;
|
||||
use Friendica\Capabilities\ICanHandleRequests;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Cache\Enum\Duration;
|
||||
use Friendica\Core\Cache\Capability\ICanCache;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
|
@ -86,6 +84,8 @@ class Router
|
|||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
private AddonHelper $addonHelper;
|
||||
|
||||
/** @var bool */
|
||||
private $isLocalUser;
|
||||
|
||||
|
@ -110,17 +110,18 @@ class Router
|
|||
* @param IHandleUserSessions $userSession
|
||||
* @param RouteCollector|null $routeCollector
|
||||
*/
|
||||
public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, LoggerInterface $logger, IHandleUserSessions $userSession, RouteCollector $routeCollector = null)
|
||||
public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, LoggerInterface $logger, AddonHelper $addonHelper, IHandleUserSessions $userSession, RouteCollector $routeCollector = null)
|
||||
{
|
||||
$this->baseRoutesFilepath = $baseRoutesFilepath;
|
||||
$this->l10n = $l10n;
|
||||
$this->cache = $cache;
|
||||
$this->lock = $lock;
|
||||
$this->args = $args;
|
||||
$this->config = $config;
|
||||
$this->server = $server;
|
||||
$this->logger = $logger;
|
||||
$this->isLocalUser = !empty($userSession->getLocalUserId());
|
||||
$this->baseRoutesFilepath = $baseRoutesFilepath;
|
||||
$this->l10n = $l10n;
|
||||
$this->cache = $cache;
|
||||
$this->lock = $lock;
|
||||
$this->args = $args;
|
||||
$this->config = $config;
|
||||
$this->server = $server;
|
||||
$this->logger = $logger;
|
||||
$this->addonHelper = $addonHelper;
|
||||
$this->isLocalUser = !empty($userSession->getLocalUserId());
|
||||
|
||||
$this->routeCollector = $routeCollector ?? new RouteCollector(new Std(), new GroupCountBased());
|
||||
|
||||
|
@ -275,14 +276,14 @@ class Router
|
|||
try {
|
||||
// Check if the HTTP method is OPTIONS and return the special Options Module with the possible HTTP methods
|
||||
if ($this->args->getMethod() === static::OPTIONS) {
|
||||
$this->moduleClass = Options::class;
|
||||
$this->moduleClass = Options::class;
|
||||
$this->parameters[] = ['AllowedMethods' => $dispatcher->getOptions($cmd)];
|
||||
} else {
|
||||
$routeInfo = $dispatcher->dispatch($this->args->getMethod(), $cmd);
|
||||
if ($routeInfo[0] === Dispatcher::FOUND) {
|
||||
$this->moduleClass = $routeInfo[1];
|
||||
$this->moduleClass = $routeInfo[1];
|
||||
$this->parameters[] = $routeInfo[2];
|
||||
} else if ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) {
|
||||
} elseif ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) {
|
||||
throw new HTTPException\MethodNotAllowedException($this->l10n->t('Method not allowed for this module. Allowed method(s): %s', implode(', ', $routeInfo[1])));
|
||||
} else {
|
||||
throw new HTTPException\NotFoundException($this->l10n->t('Page not found.'));
|
||||
|
@ -293,7 +294,7 @@ class Router
|
|||
} catch (NotFoundException $e) {
|
||||
$moduleName = $this->args->getModuleName();
|
||||
// Then we try addon-provided modules that we wrap in the LegacyModule class
|
||||
if (Addon::isEnabled($moduleName) && file_exists("addon/{$moduleName}/{$moduleName}.php")) {
|
||||
if ($this->addonHelper->isAddonEnabled($moduleName) && file_exists("addon/{$moduleName}/{$moduleName}.php")) {
|
||||
//Check if module is an app and if public access to apps is allowed or not
|
||||
$privateapps = $this->config->get('config', 'private_addons', false);
|
||||
if (!$this->isLocalUser && Hook::isAddonApp($moduleName) && $privateapps) {
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Friendica\Console;
|
|||
use Console_Table;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Addon as AddonCore;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Util\Strings;
|
||||
use RuntimeException;
|
||||
|
@ -34,6 +34,7 @@ class Addon extends \Asika\SimpleConsole\Console
|
|||
* @var Database
|
||||
*/
|
||||
private $dba;
|
||||
private AddonHelper $addonHelper;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
|
@ -56,15 +57,16 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(Mode $appMode, L10n $l10n, Database $dba, array $argv = null)
|
||||
public function __construct(Mode $appMode, L10n $l10n, Database $dba, AddonHelper $addonHelper, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->appMode = $appMode;
|
||||
$this->l10n = $l10n;
|
||||
$this->dba = $dba;
|
||||
$this->appMode = $appMode;
|
||||
$this->l10n = $l10n;
|
||||
$this->dba = $dba;
|
||||
$this->addonHelper = $addonHelper;
|
||||
|
||||
AddonCore::loadAddons();
|
||||
$this->addonHelper->loadAddons();
|
||||
}
|
||||
|
||||
protected function doExecute(): int
|
||||
|
@ -122,23 +124,22 @@ HELP;
|
|||
return false;
|
||||
}
|
||||
|
||||
foreach (AddonCore::getAvailableList() as $addon) {
|
||||
$addon_name = $addon[0];
|
||||
$enabled = AddonCore::isEnabled($addon_name);
|
||||
foreach ($this->addonHelper->getAvailableAddons() as $addonId) {
|
||||
$enabled = $this->addonHelper->isAddonEnabled($addonId);
|
||||
|
||||
if ($subCmd === 'all') {
|
||||
$table->addRow([$addon_name, $enabled ? 'enabled' : 'disabled']);
|
||||
$table->addRow([$addonId, $enabled ? 'enabled' : 'disabled']);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($subCmd === 'enabled' && $enabled === true) {
|
||||
$table->addRow([$addon_name]);
|
||||
$table->addRow([$addonId]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($subCmd === 'disabled' && $enabled === false) {
|
||||
$table->addRow([$addon_name]);
|
||||
$table->addRow([$addonId]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -163,11 +164,11 @@ HELP;
|
|||
throw new RuntimeException($this->l10n->t('Addon not found'));
|
||||
}
|
||||
|
||||
if (AddonCore::isEnabled($addon)) {
|
||||
if ($this->addonHelper->isAddonEnabled($addon)) {
|
||||
throw new RuntimeException($this->l10n->t('Addon already enabled'));
|
||||
}
|
||||
|
||||
AddonCore::install($addon);
|
||||
$this->addonHelper->installAddon($addon);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -187,11 +188,11 @@ HELP;
|
|||
throw new RuntimeException($this->l10n->t('Addon not found'));
|
||||
}
|
||||
|
||||
if (!AddonCore::isEnabled($addon)) {
|
||||
if (!$this->addonHelper->isAddonEnabled($addon)) {
|
||||
throw new RuntimeException($this->l10n->t('Addon already disabled'));
|
||||
}
|
||||
|
||||
AddonCore::uninstall($addon);
|
||||
$this->addonHelper->uninstallAddon($addon);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Friendica\Console;
|
|||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||
|
@ -29,6 +29,7 @@ final class JetstreamDaemon extends Console
|
|||
private IManageKeyValuePairs $keyValue;
|
||||
private SysDaemon $daemon;
|
||||
private Jetstream $jetstream;
|
||||
private AddonHelper $addonHelper;
|
||||
|
||||
/**
|
||||
* @param Mode $mode
|
||||
|
@ -38,15 +39,16 @@ final class JetstreamDaemon extends Console
|
|||
* @param Jetstream $jetstream
|
||||
* @param array|null $argv
|
||||
*/
|
||||
public function __construct(Mode $mode, IManageConfigValues $config, IManageKeyValuePairs $keyValue, SysDaemon $daemon, Jetstream $jetstream, array $argv = null)
|
||||
public function __construct(Mode $mode, IManageConfigValues $config, IManageKeyValuePairs $keyValue, SysDaemon $daemon, Jetstream $jetstream, AddonHelper $addonHelper, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->mode = $mode;
|
||||
$this->config = $config;
|
||||
$this->keyValue = $keyValue;
|
||||
$this->jetstream = $jetstream;
|
||||
$this->daemon = $daemon;
|
||||
$this->mode = $mode;
|
||||
$this->config = $config;
|
||||
$this->keyValue = $keyValue;
|
||||
$this->jetstream = $jetstream;
|
||||
$this->daemon = $daemon;
|
||||
$this->addonHelper = $addonHelper;
|
||||
}
|
||||
|
||||
protected function getHelp(): string
|
||||
|
@ -95,10 +97,10 @@ HELP;
|
|||
);
|
||||
}
|
||||
|
||||
Addon::loadAddons();
|
||||
$this->addonHelper->loadAddons();
|
||||
Hook::loadHooks();
|
||||
|
||||
if (!Addon::isEnabled('bluesky')) {
|
||||
if (!$this->addonHelper->isAddonEnabled('bluesky')) {
|
||||
throw new RuntimeException("Bluesky has to be enabled.\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -42,17 +42,17 @@ console storage - manage storage backend and stored data
|
|||
Synopsis
|
||||
bin/console storage [-h|--help|-?] [-v]
|
||||
Show this help
|
||||
|
||||
|
||||
bin/console storage list
|
||||
List available storage backends
|
||||
|
||||
|
||||
bin/console storage clear
|
||||
Remove the contact avatar cache data
|
||||
|
||||
|
||||
bin/console storage set <name>
|
||||
Set current storage backend
|
||||
name storage backend to use. see "list".
|
||||
|
||||
|
||||
bin/console storage move [table] [-n 5000]
|
||||
Move stored data to current storage backend.
|
||||
table one of "photo" or "attach". default to both
|
||||
|
@ -96,7 +96,7 @@ HELP;
|
|||
|
||||
protected function doList()
|
||||
{
|
||||
$rowfmt = ' %-3s | %-20s';
|
||||
$rowfmt = ' %-3s | %-20s';
|
||||
$current = $this->storageManager->getBackend();
|
||||
$this->out(sprintf($rowfmt, 'Sel', 'Name'));
|
||||
$this->out('-----------------------');
|
||||
|
@ -104,7 +104,7 @@ HELP;
|
|||
foreach ($this->storageManager->listBackends() as $name) {
|
||||
$issel = ' ';
|
||||
if ($current && $current::getName() == $name) {
|
||||
$issel = '*';
|
||||
$issel = '*';
|
||||
$isregisterd = true;
|
||||
};
|
||||
$this->out(sprintf($rowfmt, $issel, $name));
|
||||
|
@ -176,7 +176,7 @@ HELP;
|
|||
}
|
||||
|
||||
$current = $this->storageManager->getBackend();
|
||||
$total = 0;
|
||||
$total = 0;
|
||||
|
||||
if (is_null($current)) {
|
||||
throw new StorageException(sprintf("Cannot move to legacy storage. Please select a storage backend."));
|
||||
|
@ -192,5 +192,7 @@ HELP;
|
|||
} while ($moved);
|
||||
|
||||
$this->out(sprintf(date('[Y-m-d H:i:s] ') . 'Moved %d files total', $total));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ class Conversation
|
|||
|
||||
if ($total === 0) {
|
||||
throw new InternalServerErrorException(sprintf('There has to be at least one Liker for verb "%s"', $verb));
|
||||
} else if ($total === 1) {
|
||||
} elseif ($total === 1) {
|
||||
$likerString = $likers[0];
|
||||
} else {
|
||||
if ($total < $this->config->get('system', 'max_likers')) {
|
||||
|
@ -326,7 +326,7 @@ class Conversation
|
|||
'$ispublic' => $this->l10n->t('Visible to <strong>everybody</strong>'),
|
||||
'$linkurl' => $this->l10n->t('Please enter a image/video/audio/webpage URL:'),
|
||||
'$term' => $this->l10n->t('Tag term:'),
|
||||
'$fileas' => $this->l10n->t('Save to Folder:'),
|
||||
'$fileas' => $this->l10n->t('Save to Folder'),
|
||||
'$whereareu' => $this->l10n->t('Where are you right now?'),
|
||||
'$delitems' => $this->l10n->t("Delete item\x28s\x29?"),
|
||||
'$is_mobile' => $this->mode->isMobile(),
|
||||
|
@ -976,8 +976,8 @@ class Conversation
|
|||
}
|
||||
|
||||
foreach ($items as $key => $row) {
|
||||
$items[$key]['emojis'] = $emojis[$key] ?? [];
|
||||
$items[$key]['counts'] = $counts[$key] ?? 0;
|
||||
$items[$key]['emojis'] = $emojis[$key] ?? [];
|
||||
$items[$key]['counts'] = $counts[$key] ?? 0;
|
||||
$items[$key]['quoteshares'] = $quoteshares[$key] ?? [];
|
||||
|
||||
$always_display = in_array($mode, [self::MODE_CONTACTS, self::MODE_CONTACT_POSTS]);
|
||||
|
@ -1431,7 +1431,7 @@ class Conversation
|
|||
public function getContextLessThreadList(array $items, string $mode, bool $preview, bool $pagedrop, string $formSecurityToken): array
|
||||
{
|
||||
$threads = [];
|
||||
$uriids = [];
|
||||
$uriids = [];
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (in_array($item['uri-id'], $uriids)) {
|
||||
|
@ -1456,7 +1456,7 @@ class Conversation
|
|||
|
||||
$tags = Tag::populateFromItem($item);
|
||||
|
||||
$author = [
|
||||
$author = [
|
||||
'uid' => 0,
|
||||
'id' => $item['author-id'],
|
||||
'network' => $item['author-network'],
|
||||
|
@ -1501,7 +1501,7 @@ class Conversation
|
|||
|
||||
$body_html = ItemModel::prepareBody($item, true, $preview);
|
||||
|
||||
[$categories, $folders] = $this->item->determineCategoriesTerms($item, $this->session->getLocalUserId());
|
||||
list($categories, $folders) = $this->item->determineCategoriesTerms($item, $this->session->getLocalUserId());
|
||||
|
||||
if (!empty($item['featured'])) {
|
||||
$pinned = $this->l10n->t('Pinned item');
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
namespace Friendica\Content;
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
use Friendica\Event\ArrayFilterEvent;
|
||||
|
||||
class Feature
|
||||
{
|
||||
|
@ -41,15 +41,23 @@ class Feature
|
|||
*/
|
||||
public static function isEnabled(int $uid, $feature): bool
|
||||
{
|
||||
if (!DI::config()->get('feature_lock', $feature, false)) {
|
||||
$enabled = DI::config()->get('feature', $feature) ?? self::getDefault($feature);
|
||||
$enabled = DI::pConfig()->get($uid, 'feature', $feature) ?? $enabled;
|
||||
$config = DI::config();
|
||||
$pConfig = DI::pConfig();
|
||||
$eventDispatcher = DI::eventDispatcher();
|
||||
|
||||
if (!$config->get('feature_lock', $feature, false)) {
|
||||
$enabled = $config->get('feature', $feature) ?? self::getDefault($feature);
|
||||
$enabled = $pConfig->get($uid, 'feature', $feature) ?? $enabled;
|
||||
} else {
|
||||
$enabled = true;
|
||||
}
|
||||
|
||||
$arr = ['uid' => $uid, 'feature' => $feature, 'enabled' => $enabled];
|
||||
Hook::callAll('isEnabled', $arr);
|
||||
|
||||
$arr = $eventDispatcher->dispatch(
|
||||
new ArrayFilterEvent(ArrayFilterEvent::FEATURE_ENABLED, $arr)
|
||||
)->getArray();
|
||||
|
||||
return (bool)$arr['enabled'];
|
||||
}
|
||||
|
||||
|
@ -86,55 +94,58 @@ class Feature
|
|||
*/
|
||||
public static function get($filtered = true)
|
||||
{
|
||||
$arr = [
|
||||
$l10n = DI::l10n();
|
||||
$config = DI::config();
|
||||
$eventDispatcher = DI::eventDispatcher();
|
||||
|
||||
$arr = [
|
||||
// General
|
||||
'general' => [
|
||||
DI::l10n()->t('General Features'),
|
||||
//array('expire', DI::l10n()->t('Content Expiration'), DI::l10n()->t('Remove old posts/comments after a period of time')),
|
||||
[self::PHOTO_LOCATION, DI::l10n()->t('Photo Location'), DI::l10n()->t("Photo metadata is normally stripped. This extracts the location \x28if present\x29 prior to stripping metadata and links it to a map."), false, DI::config()->get('feature_lock', self::PHOTO_LOCATION, false)],
|
||||
[self::COMMUNITY, DI::l10n()->t('Display the community in the navigation'), DI::l10n()->t('If enabled, the community can be accessed via the navigation menu. Independent from this setting, the community timelines can always be accessed via the channels.'), true, DI::config()->get('feature_lock', self::COMMUNITY, false)],
|
||||
$l10n->t('General Features'),
|
||||
//array('expire', $l10n->t('Content Expiration'), $l10n->t('Remove old posts/comments after a period of time')),
|
||||
[self::PHOTO_LOCATION, $l10n->t('Photo Location'), $l10n->t("Photo metadata is normally stripped. This extracts the location \x28if present\x29 prior to stripping metadata and links it to a map."), false, $config->get('feature_lock', self::PHOTO_LOCATION, false)],
|
||||
[self::COMMUNITY, $l10n->t('Display the community in the navigation'), $l10n->t('If enabled, the community can be accessed via the navigation menu. Independent from this setting, the community timelines can always be accessed via the channels.'), true, $config->get('feature_lock', self::COMMUNITY, false)],
|
||||
],
|
||||
|
||||
// Post composition
|
||||
'composition' => [
|
||||
DI::l10n()->t('Post Composition Features'),
|
||||
[self::EXPLICIT_MENTIONS, DI::l10n()->t('Explicit Mentions'), DI::l10n()->t('Add explicit mentions to comment box for manual control over who gets mentioned in replies.'), false, DI::config()->get('feature_lock', Feature::EXPLICIT_MENTIONS, false)],
|
||||
[self::ADD_ABSTRACT, DI::l10n()->t('Add an abstract from ActivityPub content warnings'), DI::l10n()->t('Add an abstract when commenting on ActivityPub posts with a content warning. Abstracts are displayed as content warning on systems like Mastodon or Pleroma.'), false, DI::config()->get('feature_lock', self::ADD_ABSTRACT, false)],
|
||||
$l10n->t('Post Composition Features'),
|
||||
[self::EXPLICIT_MENTIONS, $l10n->t('Explicit Mentions'), $l10n->t('Add explicit mentions to comment box for manual control over who gets mentioned in replies.'), false, $config->get('feature_lock', Feature::EXPLICIT_MENTIONS, false)],
|
||||
[self::ADD_ABSTRACT, $l10n->t('Add an abstract from ActivityPub content warnings'), $l10n->t('Add an abstract when commenting on ActivityPub posts with a content warning. Abstracts are displayed as content warning on systems like Mastodon or Pleroma.'), false, $config->get('feature_lock', self::ADD_ABSTRACT, false)],
|
||||
],
|
||||
|
||||
// Item tools
|
||||
'tools' => [
|
||||
DI::l10n()->t('Post/Comment Tools'),
|
||||
[self::CATEGORIES, DI::l10n()->t('Post Categories'), DI::l10n()->t('Add categories to your posts'), false, DI::config()->get('feature_lock', self::CATEGORIES, false)],
|
||||
$l10n->t('Post/Comment Tools'),
|
||||
[self::CATEGORIES, $l10n->t('Post Categories'), $l10n->t('Add categories to your posts'), false, $config->get('feature_lock', self::CATEGORIES, false)],
|
||||
],
|
||||
|
||||
// Widget visibility on the network stream
|
||||
'network' => [
|
||||
DI::l10n()->t('Network Widgets'),
|
||||
[self::CIRCLES, DI::l10n()->t('Circles'), DI::l10n()->t('Display posts that have been created by accounts of the selected circle.'), true, DI::config()->get('feature_lock', self::CIRCLES, false)],
|
||||
[self::GROUPS, DI::l10n()->t('Groups'), DI::l10n()->t('Display posts that have been distributed by the selected group.'), true, DI::config()->get('feature_lock', self::GROUPS, false)],
|
||||
[self::ARCHIVE, DI::l10n()->t('Archives'), DI::l10n()->t('Display an archive where posts can be selected by month and year.'), true, DI::config()->get('feature_lock', self::ARCHIVE, false)],
|
||||
[self::NETWORKS, DI::l10n()->t('Protocols'), DI::l10n()->t('Display posts with the selected protocols.'), true, DI::config()->get('feature_lock', self::NETWORKS, false)],
|
||||
[self::ACCOUNTS, DI::l10n()->t('Account Types'), DI::l10n()->t('Display posts done by accounts with the selected account type.'), true, DI::config()->get('feature_lock', self::ACCOUNTS, false)],
|
||||
[self::CHANNELS, DI::l10n()->t('Channels'), DI::l10n()->t('Display posts in the system channels and user defined channels.'), true, DI::config()->get('feature_lock', self::CHANNELS, false)],
|
||||
[self::SEARCHES, DI::l10n()->t('Saved Searches'), DI::l10n()->t('Display posts that contain subscribed hashtags.'), true, DI::config()->get('feature_lock', self::SEARCHES, false)],
|
||||
[self::FOLDERS, DI::l10n()->t('Saved Folders'), DI::l10n()->t('Display a list of folders in which posts are stored.'), true, DI::config()->get('feature_lock', self::FOLDERS, false)],
|
||||
[self::NOSHARER, DI::l10n()->t('Own Contacts'), DI::l10n()->t('Include or exclude posts from subscribed accounts. This widget is not visible on all channels.'), true, DI::config()->get('feature_lock', self::NOSHARER, false)],
|
||||
[self::TRENDING_TAGS, DI::l10n()->t('Trending Tags'), DI::l10n()->t('Display a list of the most popular tags in recent public posts.'), false, DI::config()->get('feature_lock', self::TRENDING_TAGS, false)],
|
||||
$l10n->t('Network Widgets'),
|
||||
[self::CIRCLES, $l10n->t('Circles'), $l10n->t('Display posts that have been created by accounts of the selected circle.'), true, $config->get('feature_lock', self::CIRCLES, false)],
|
||||
[self::GROUPS, $l10n->t('Groups'), $l10n->t('Display posts that have been distributed by the selected group.'), true, $config->get('feature_lock', self::GROUPS, false)],
|
||||
[self::ARCHIVE, $l10n->t('Archives'), $l10n->t('Display an archive where posts can be selected by month and year.'), true, $config->get('feature_lock', self::ARCHIVE, false)],
|
||||
[self::NETWORKS, $l10n->t('Protocols'), $l10n->t('Display posts with the selected protocols.'), true, $config->get('feature_lock', self::NETWORKS, false)],
|
||||
[self::ACCOUNTS, $l10n->t('Account Types'), $l10n->t('Display posts done by accounts with the selected account type.'), true, $config->get('feature_lock', self::ACCOUNTS, false)],
|
||||
[self::CHANNELS, $l10n->t('Channels'), $l10n->t('Display posts in the system channels and user defined channels.'), true, $config->get('feature_lock', self::CHANNELS, false)],
|
||||
[self::SEARCHES, $l10n->t('Saved Searches'), $l10n->t('Display posts that contain subscribed hashtags.'), true, $config->get('feature_lock', self::SEARCHES, false)],
|
||||
[self::FOLDERS, $l10n->t('Saved Folders'), $l10n->t('Display a list of folders in which posts are stored.'), true, $config->get('feature_lock', self::FOLDERS, false)],
|
||||
[self::NOSHARER, $l10n->t('Own Contacts'), $l10n->t('Include or exclude posts from subscribed accounts. This widget is not visible on all channels.'), true, $config->get('feature_lock', self::NOSHARER, false)],
|
||||
[self::TRENDING_TAGS, $l10n->t('Trending Tags'), $l10n->t('Display a list of the most popular tags in recent public posts.'), false, $config->get('feature_lock', self::TRENDING_TAGS, false)],
|
||||
],
|
||||
|
||||
// Advanced Profile Settings
|
||||
'advanced_profile' => [
|
||||
DI::l10n()->t('Advanced Profile Settings'),
|
||||
[self::TAGCLOUD, DI::l10n()->t('Tag Cloud'), DI::l10n()->t('Provide a personal tag cloud on your profile page'), false, DI::config()->get('feature_lock', self::TAGCLOUD, false)],
|
||||
[self::MEMBER_SINCE, DI::l10n()->t('Display Membership Date'), DI::l10n()->t('Display membership date in profile'), false, DI::config()->get('feature_lock', self::MEMBER_SINCE, false)],
|
||||
$l10n->t('Advanced Profile Settings'),
|
||||
[self::TAGCLOUD, $l10n->t('Tag Cloud'), $l10n->t('Provide a personal tag cloud on your profile page'), false, $config->get('feature_lock', self::TAGCLOUD, false)],
|
||||
[self::MEMBER_SINCE, $l10n->t('Display Membership Date'), $l10n->t('Display membership date in profile'), false, $config->get('feature_lock', self::MEMBER_SINCE, false)],
|
||||
],
|
||||
|
||||
//Advanced Calendar Settings
|
||||
'advanced_calendar' => [
|
||||
DI::l10n()->t('Advanced Calendar Settings'),
|
||||
[self::PUBLIC_CALENDAR, DI::l10n()->t('Allow anonymous access to your calendar'), DI::l10n()->t('Allows anonymous visitors to consult your calendar and your public events. Contact birthday events are private to you.'), false, DI::config()->get('feature_lock', self::PUBLIC_CALENDAR, false)],
|
||||
$l10n->t('Advanced Calendar Settings'),
|
||||
[self::PUBLIC_CALENDAR, $l10n->t('Allow anonymous access to your calendar'), $l10n->t('Allows anonymous visitors to consult your calendar and your public events. Contact birthday events are private to you.'), false, $config->get('feature_lock', self::PUBLIC_CALENDAR, false)],
|
||||
]
|
||||
];
|
||||
|
||||
|
@ -144,7 +155,7 @@ class Feature
|
|||
foreach ($arr as $k => $x) {
|
||||
$has_items = false;
|
||||
$kquantity = count($arr[$k]);
|
||||
for ($y = 0; $y < $kquantity; $y ++) {
|
||||
for ($y = 0; $y < $kquantity; $y++) {
|
||||
if (is_array($arr[$k][$y])) {
|
||||
if ($arr[$k][$y][4] === false) {
|
||||
$has_items = true;
|
||||
|
@ -159,7 +170,10 @@ class Feature
|
|||
}
|
||||
}
|
||||
|
||||
Hook::callAll('get', $arr);
|
||||
$arr = $eventDispatcher->dispatch(
|
||||
new ArrayFilterEvent(ArrayFilterEvent::FEATURE_GET, $arr)
|
||||
)->getArray();
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,8 +108,6 @@ class GroupManager
|
|||
|
||||
$entries = [];
|
||||
|
||||
$contacts = [];
|
||||
|
||||
foreach ($contacts as $contact) {
|
||||
$entry = [
|
||||
'url' => 'contact/' . $contact['id'] . '/conversations',
|
||||
|
|
|
@ -607,7 +607,7 @@ class Item
|
|||
} else {
|
||||
$owner_avatar = $item['owner-id'];
|
||||
$owner_updated = $item['owner-updated'];
|
||||
$owner_thumb = $item['owner-avatar'];
|
||||
$owner_thumb = $item['owner-avatar'] ?? '';
|
||||
}
|
||||
|
||||
if (empty($owner_thumb) || Photo::isPhotoURI($owner_thumb)) {
|
||||
|
|
|
@ -10,11 +10,12 @@ namespace Friendica\Content;
|
|||
use Friendica\App\BaseURL;
|
||||
use Friendica\App\Router;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Event\ArrayFilterEvent;
|
||||
use Friendica\Event\HtmlFilterEvent;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Conversation\Community;
|
||||
|
@ -22,6 +23,7 @@ use Friendica\Module\Home;
|
|||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Security\OpenWebAuth;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
class Nav
|
||||
{
|
||||
|
@ -63,14 +65,17 @@ class Nav
|
|||
/** @var Router */
|
||||
private $router;
|
||||
|
||||
public function __construct(BaseURL $baseUrl, L10n $l10n, IHandleUserSessions $session, Database $database, IManageConfigValues $config, Router $router)
|
||||
private EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
public function __construct(BaseURL $baseUrl, L10n $l10n, IHandleUserSessions $session, Database $database, IManageConfigValues $config, Router $router, EventDispatcherInterface $eventDispatcher)
|
||||
{
|
||||
$this->baseUrl = $baseUrl;
|
||||
$this->l10n = $l10n;
|
||||
$this->session = $session;
|
||||
$this->database = $database;
|
||||
$this->config = $config;
|
||||
$this->router = $router;
|
||||
$this->baseUrl = $baseUrl;
|
||||
$this->l10n = $l10n;
|
||||
$this->session = $session;
|
||||
$this->database = $database;
|
||||
$this->config = $config;
|
||||
$this->router = $router;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,19 +106,22 @@ class Nav
|
|||
$tpl = Renderer::getMarkupTemplate('nav.tpl');
|
||||
|
||||
$nav .= Renderer::replaceMacros($tpl, [
|
||||
'$sitelocation' => $nav_info['sitelocation'],
|
||||
'$nav' => $nav_info['nav'],
|
||||
'$banner' => $nav_info['banner'],
|
||||
'$sitelocation' => $nav_info['sitelocation'],
|
||||
'$nav' => $nav_info['nav'],
|
||||
'$banner' => $nav_info['banner'],
|
||||
'$emptynotifications' => $this->l10n->t('Nothing new here'),
|
||||
'$userinfo' => $nav_info['userinfo'],
|
||||
'$sel' => self::$selected,
|
||||
'$apps' => $this->getAppMenu(),
|
||||
'$home' => $this->l10n->t('Go back'),
|
||||
'$clear_notifs' => $this->l10n->t('Clear notifications'),
|
||||
'$search_hint' => $this->l10n->t('@name, !group, #tags, content')
|
||||
'$userinfo' => $nav_info['userinfo'],
|
||||
'$sel' => self::$selected,
|
||||
'$apps' => $this->getAppMenu(),
|
||||
'$home' => $this->l10n->t('Home'),
|
||||
'$skip' => $this->l10n->t('Skip to main content'),
|
||||
'$clear_notifs' => $this->l10n->t('Clear notifications'),
|
||||
'$search_hint' => $this->l10n->t('@name, !group, #tags, content')
|
||||
]);
|
||||
|
||||
Hook::callAll('page_header', $nav);
|
||||
$nav = $this->eventDispatcher->dispatch(
|
||||
new HtmlFilterEvent(HtmlFilterEvent::PAGE_HEADER, $nav)
|
||||
)->getHtml();
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
@ -150,9 +158,11 @@ class Nav
|
|||
) {
|
||||
$arr = ['app_menu' => $appMenu];
|
||||
|
||||
Hook::callAll('app_menu', $arr);
|
||||
$arr = $this->eventDispatcher->dispatch(
|
||||
new ArrayFilterEvent(ArrayFilterEvent::APP_MENU, $arr)
|
||||
)->getArray();
|
||||
|
||||
$appMenu = $arr['app_menu'];
|
||||
$appMenu = $arr['app_menu'] ?? [];
|
||||
}
|
||||
|
||||
return $appMenu;
|
||||
|
@ -220,7 +230,7 @@ class Nav
|
|||
$nav['usermenu'][] = ['notes/', $this->l10n->t('Personal notes'), '', $this->l10n->t('Your personal notes')];
|
||||
|
||||
// user info
|
||||
$contact = $this->database->selectFirst('contact', ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated'], ['uid' => $this->session->getLocalUserId(), 'self' => true]);
|
||||
$contact = $this->database->selectFirst('contact', ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated'], ['uid' => $this->session->getLocalUserId(), 'self' => true]);
|
||||
$userinfo = [
|
||||
'icon' => Contact::getMicro($contact),
|
||||
'name' => $contact['name'],
|
||||
|
@ -295,16 +305,16 @@ class Nav
|
|||
|
||||
// Don't show notifications for public communities
|
||||
if ($this->session->get('page_flags', '') != User::PAGE_FLAGS_COMMUNITY) {
|
||||
$nav['introductions'] = ['notifications/intros', $this->l10n->t('Introductions'), '', $this->l10n->t('Friend Requests')];
|
||||
$nav['notifications'] = ['notifications', $this->l10n->t('Notifications'), '', $this->l10n->t('Notifications')];
|
||||
$nav['notifications']['all'] = ['notifications/system', $this->l10n->t('See all notifications'), '', ''];
|
||||
$nav['introductions'] = ['notifications/intros', $this->l10n->t('Introductions'), '', $this->l10n->t('Friend Requests')];
|
||||
$nav['notifications'] = ['notifications', $this->l10n->t('Notifications'), '', $this->l10n->t('Notifications')];
|
||||
$nav['notifications']['all'] = ['notifications/system', $this->l10n->t('See all notifications'), '', ''];
|
||||
$nav['notifications']['mark'] = ['', $this->l10n->t('Mark as seen'), '', $this->l10n->t('Mark all system notifications as seen')];
|
||||
}
|
||||
|
||||
$nav['messages'] = ['message', $this->l10n->t('Messages'), '', $this->l10n->t('Private mail')];
|
||||
$nav['messages']['inbox'] = ['message', $this->l10n->t('Inbox'), '', $this->l10n->t('Inbox')];
|
||||
$nav['messages'] = ['message', $this->l10n->t('Messages'), '', $this->l10n->t('Private mail')];
|
||||
$nav['messages']['inbox'] = ['message', $this->l10n->t('Inbox'), '', $this->l10n->t('Inbox')];
|
||||
$nav['messages']['outbox'] = ['message/sent', $this->l10n->t('Outbox'), '', $this->l10n->t('Outbox')];
|
||||
$nav['messages']['new'] = ['message/new', $this->l10n->t('New Message'), '', $this->l10n->t('New Message')];
|
||||
$nav['messages']['new'] = ['message/new', $this->l10n->t('New Message'), '', $this->l10n->t('New Message')];
|
||||
|
||||
if (User::hasIdentities($this->session->getSubManagedUserId() ?: $this->session->getLocalUserId())) {
|
||||
$nav['delegation'] = ['delegation', $this->l10n->t('Accounts'), '', $this->l10n->t('Manage other pages')];
|
||||
|
@ -336,7 +346,9 @@ class Nav
|
|||
'userinfo' => $userinfo,
|
||||
];
|
||||
|
||||
Hook::callAll('nav_info', $nav_info);
|
||||
$nav_info = $this->eventDispatcher->dispatch(
|
||||
new ArrayFilterEvent(ArrayFilterEvent::NAV_INFO, $nav_info)
|
||||
)->getArray();
|
||||
|
||||
return $nav_info;
|
||||
}
|
||||
|
|
|
@ -1583,7 +1583,7 @@ class BBCode
|
|||
// Check for headers
|
||||
|
||||
if ($simple_html == self::INTERNAL) {
|
||||
//Ensure to always start with <h4> if possible
|
||||
//Ensure to always start with <h3> if possible
|
||||
$heading_count = 0;
|
||||
for ($level = 6; $level > 0; $level--) {
|
||||
if (preg_match("(\[h$level\].*?\[\/h$level\])ism", $text)) {
|
||||
|
@ -1591,7 +1591,7 @@ class BBCode
|
|||
}
|
||||
}
|
||||
if ($heading_count > 0) {
|
||||
$heading = min($heading_count + 3, 6);
|
||||
$heading = min($heading_count + 2, 6);
|
||||
for ($level = 6; $level > 0; $level--) {
|
||||
if (preg_match("(\[h$level\].*?\[\/h$level\])ism", $text)) {
|
||||
$text = preg_replace("(\[h$level\](.*?)\[\/h$level\])ism", "</p><h$heading>$1</h$heading><p>", $text);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Content;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Cache\Enum\Duration;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
|
@ -33,13 +32,13 @@ class Widget
|
|||
*/
|
||||
public static function follow(string $value = ''): string
|
||||
{
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/follow.tpl'), array(
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/follow.tpl'), [
|
||||
'$connect' => DI::l10n()->t('Add New Contact'),
|
||||
'$desc' => DI::l10n()->t('Enter address or web location'),
|
||||
'$hint' => DI::l10n()->t('Example: bob@example.com, http://example.com/barbara'),
|
||||
'$value' => $value,
|
||||
'$follow' => DI::l10n()->t('Connect')
|
||||
));
|
||||
'$desc' => DI::l10n()->t('Enter address or web location'),
|
||||
'$hint' => DI::l10n()->t('Example: bob@example.com, http://example.com/barbara'),
|
||||
'$value' => $value,
|
||||
'$follow' => DI::l10n()->t('Connect')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,21 +59,21 @@ class Widget
|
|||
}
|
||||
}
|
||||
|
||||
$nv = [];
|
||||
$nv['findpeople'] = DI::l10n()->t('Find People');
|
||||
$nv['desc'] = DI::l10n()->t('Enter name or interest');
|
||||
$nv['label'] = DI::l10n()->t('Connect/Follow');
|
||||
$nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing');
|
||||
$nv['findthem'] = DI::l10n()->t('Find');
|
||||
$nv['suggest'] = DI::l10n()->t('Friend Suggestions');
|
||||
$nv['similar'] = DI::l10n()->t('Similar Interests');
|
||||
$nv['random'] = DI::l10n()->t('Random Profile');
|
||||
$nv['inv'] = DI::l10n()->t('Invite Friends');
|
||||
$nv['directory'] = DI::l10n()->t('Global Directory');
|
||||
$nv['global_dir'] = OpenWebAuth::getZrlUrl($global_dir, true);
|
||||
$nv = [];
|
||||
$nv['findpeople'] = DI::l10n()->t('Find People');
|
||||
$nv['desc'] = DI::l10n()->t('Enter name or interest');
|
||||
$nv['label'] = DI::l10n()->t('Connect/Follow');
|
||||
$nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing');
|
||||
$nv['findthem'] = DI::l10n()->t('Find');
|
||||
$nv['suggest'] = DI::l10n()->t('Friend Suggestions');
|
||||
$nv['similar'] = DI::l10n()->t('Similar Interests');
|
||||
$nv['random'] = DI::l10n()->t('Random Profile');
|
||||
$nv['inv'] = DI::l10n()->t('Invite Friends');
|
||||
$nv['directory'] = DI::l10n()->t('Global Directory');
|
||||
$nv['global_dir'] = OpenWebAuth::getZrlUrl($global_dir, true);
|
||||
$nv['local_directory'] = DI::l10n()->t('Local Directory');
|
||||
|
||||
$aside = [];
|
||||
$aside = [];
|
||||
$aside['$nv'] = $nv;
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/peoplefind.tpl'), $aside);
|
||||
|
@ -87,19 +86,21 @@ class Widget
|
|||
*/
|
||||
public static function unavailableNetworks(): array
|
||||
{
|
||||
$addonHelper = DI::addonHelper();
|
||||
|
||||
// Always hide content from these networks
|
||||
$networks = [Protocol::PHANTOM, Protocol::FACEBOOK, Protocol::APPNET, Protocol::TWITTER, Protocol::ZOT, Protocol::OSTATUS, Protocol::STATUSNET];
|
||||
Addon::loadAddons();
|
||||
$addonHelper->loadAddons();
|
||||
|
||||
if (!Addon::isEnabled('discourse')) {
|
||||
if (!$addonHelper->isAddonEnabled('discourse')) {
|
||||
$networks[] = Protocol::DISCOURSE;
|
||||
}
|
||||
|
||||
if (!Addon::isEnabled('pumpio')) {
|
||||
if (!$addonHelper->isAddonEnabled('pumpio')) {
|
||||
$networks[] = Protocol::PUMPIO;
|
||||
}
|
||||
|
||||
if (!Addon::isEnabled('tumblr')) {
|
||||
if (!$addonHelper->isAddonEnabled('tumblr')) {
|
||||
$networks[] = Protocol::TUMBLR;
|
||||
}
|
||||
|
||||
|
@ -107,7 +108,7 @@ class Widget
|
|||
$networks[] = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (!Addon::isEnabled('pnut')) {
|
||||
if (!$addonHelper->isAddonEnabled('pnut')) {
|
||||
$networks[] = Protocol::PNUT;
|
||||
}
|
||||
return $networks;
|
||||
|
@ -120,18 +121,20 @@ class Widget
|
|||
*/
|
||||
public static function availableNetworks(): array
|
||||
{
|
||||
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::FEED];
|
||||
Addon::loadAddons();
|
||||
$addonHelper = DI::addonHelper();
|
||||
|
||||
if (Addon::isEnabled('discourse')) {
|
||||
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::FEED];
|
||||
$addonHelper->loadAddons();
|
||||
|
||||
if ($addonHelper->isAddonEnabled('discourse')) {
|
||||
$networks[] = Protocol::DISCOURSE;
|
||||
}
|
||||
|
||||
if (Addon::isEnabled('pumpio')) {
|
||||
if ($addonHelper->isAddonEnabled('pumpio')) {
|
||||
$networks[] = Protocol::PUMPIO;
|
||||
}
|
||||
|
||||
if (Addon::isEnabled('tumblr')) {
|
||||
if ($addonHelper->isAddonEnabled('tumblr')) {
|
||||
$networks[] = Protocol::TUMBLR;
|
||||
}
|
||||
|
||||
|
@ -143,7 +146,7 @@ class Widget
|
|||
$networks[] = Protocol::MAIL;
|
||||
}
|
||||
|
||||
if (Addon::isEnabled('pnut')) {
|
||||
if ($addonHelper->isAddonEnabled('pnut')) {
|
||||
$networks[] = Protocol::PNUT;
|
||||
}
|
||||
return $networks;
|
||||
|
@ -174,7 +177,7 @@ class Widget
|
|||
private static function filter(string $type, string $title, string $desc, string $all, string $baseUrl, array $options, string $selected = null): string
|
||||
{
|
||||
$queryString = parse_url($baseUrl, PHP_URL_QUERY);
|
||||
$queryArray = [];
|
||||
$queryArray = [];
|
||||
|
||||
if ($queryString) {
|
||||
parse_str($queryString, $queryArray);
|
||||
|
@ -282,8 +285,8 @@ class Widget
|
|||
return '';
|
||||
}
|
||||
|
||||
$networks = self::unavailableNetworks();
|
||||
$query = "`uid` = ? AND NOT `deleted` AND `network` != '' AND NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")";
|
||||
$networks = self::unavailableNetworks();
|
||||
$query = "`uid` = ? AND NOT `deleted` AND `network` != '' AND NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")";
|
||||
$condition = array_merge([$query], array_merge([DI::userSession()->getLocalUserId()], $networks));
|
||||
|
||||
$r = DBA::select('contact', ['network'], $condition, ['group_by' => ['network'], 'order' => ['network']]);
|
||||
|
@ -473,7 +476,7 @@ class Widget
|
|||
$ret = [];
|
||||
|
||||
$cachekey = 'Widget::postedByYear' . $uid . '-' . (int)$wall;
|
||||
$dthen = DI::cache()->get($cachekey);
|
||||
$dthen = DI::cache()->get($cachekey);
|
||||
if (empty($dthen)) {
|
||||
$dthen = Item::firstPostDate($uid, $wall);
|
||||
DI::cache()->set($cachekey, $dthen, Duration::HOUR);
|
||||
|
@ -486,30 +489,30 @@ class Widget
|
|||
if ($dthen) {
|
||||
// Set the start and end date to the beginning of the month
|
||||
$cutoffday = $dthen;
|
||||
$thisday = substr($dnow, 4);
|
||||
$nextday = date('Y-m-d', strtotime($dnow . ' + 1 day'));
|
||||
$nextday = substr($nextday, 4);
|
||||
$dnow = substr($dnow, 0, 8) . '01';
|
||||
$dthen = substr($dthen, 0, 8) . '01';
|
||||
$thisday = substr($dnow, 4);
|
||||
$nextday = date('Y-m-d', strtotime($dnow . ' + 1 day'));
|
||||
$nextday = substr($nextday, 4);
|
||||
$dnow = substr($dnow, 0, 8) . '01';
|
||||
$dthen = substr($dthen, 0, 8) . '01';
|
||||
|
||||
/*
|
||||
* Starting with the current month, get the first and last days of every
|
||||
* month down to and including the month of the first post
|
||||
*/
|
||||
while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
|
||||
$dyear = intval(substr($dnow, 0, 4));
|
||||
$dstart = substr($dnow, 0, 8) . '01';
|
||||
$dend = substr($dnow, 0, 8) . Temporal::getDaysInMonth(intval($dnow), intval(substr($dnow, 5)));
|
||||
$dyear = intval(substr($dnow, 0, 4));
|
||||
$dstart = substr($dnow, 0, 8) . '01';
|
||||
$dend = substr($dnow, 0, 8) . Temporal::getDaysInMonth(intval($dnow), intval(substr($dnow, 5)));
|
||||
$start_month = DateTimeFormat::utc($dstart, 'Y-m-d');
|
||||
$end_month = DateTimeFormat::utc($dend, 'Y-m-d');
|
||||
$str = DI::l10n()->getDay(DateTimeFormat::utc($dnow, 'F'));
|
||||
$end_month = DateTimeFormat::utc($dend, 'Y-m-d');
|
||||
$str = DI::l10n()->getDay(DateTimeFormat::utc($dnow, 'F'));
|
||||
|
||||
if (empty($ret[$dyear])) {
|
||||
$ret[$dyear] = [];
|
||||
}
|
||||
|
||||
$ret[$dyear][] = [$str, $end_month, $start_month];
|
||||
$dnow = DateTimeFormat::utc($dnow . ' -1 month', 'Y-m-d');
|
||||
$dnow = DateTimeFormat::utc($dnow . ' -1 month', 'Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,21 +521,21 @@ class Widget
|
|||
}
|
||||
|
||||
$cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years;
|
||||
$cutoff = array_key_exists($cutoff_year, $ret);
|
||||
$cutoff = array_key_exists($cutoff_year, $ret);
|
||||
|
||||
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/posted_date.tpl'), [
|
||||
'$title' => DI::l10n()->t('Archives'),
|
||||
'$size' => $visible_years,
|
||||
'$title' => DI::l10n()->t('Archives'),
|
||||
'$size' => $visible_years,
|
||||
'$cutoff_year' => $cutoff_year,
|
||||
'$cutoff' => $cutoff,
|
||||
'$url' => $url,
|
||||
'$dates' => $ret,
|
||||
'$showless' => DI::l10n()->t('show less'),
|
||||
'$showmore' => DI::l10n()->t('show more'),
|
||||
'$onthisdate' => DI::l10n()->t('On this date'),
|
||||
'$thisday' => $thisday,
|
||||
'$nextday' => $nextday,
|
||||
'$cutoffday' => $cutoffday
|
||||
'$cutoff' => $cutoff,
|
||||
'$url' => $url,
|
||||
'$dates' => $ret,
|
||||
'$showless' => DI::l10n()->t('show less'),
|
||||
'$showmore' => DI::l10n()->t('show more'),
|
||||
'$onthisdate' => DI::l10n()->t('On this date'),
|
||||
'$thisday' => $thisday,
|
||||
'$nextday' => $nextday,
|
||||
'$cutoffday' => $cutoffday
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -18,6 +18,9 @@ class Addon
|
|||
{
|
||||
/**
|
||||
* The addon sub-directory
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getAddonPath()` instead
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const DIRECTORY = 'addon';
|
||||
|
@ -34,6 +37,8 @@ class Addon
|
|||
* This list is made from scanning the addon/ folder.
|
||||
* Unsupported addons are excluded unless they already are enabled or system.show_unsupported_addon is set.
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getAvailableAddons()` instead
|
||||
*
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
@ -64,6 +69,8 @@ class Addon
|
|||
* Returns a list of addons that can be configured at the node level.
|
||||
* The list is formatted for display in the admin panel aside.
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getEnabledAddonsWithAdminSettings()` instead
|
||||
*
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
@ -88,7 +95,6 @@ class Addon
|
|||
return $addons_admin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Synchronize addons:
|
||||
*
|
||||
|
@ -100,6 +106,7 @@ class Addon
|
|||
* Then go through the config list and if we have a addon that isn't installed,
|
||||
* call the install procedure and add it to the database.
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::loadAddons()` instead
|
||||
*/
|
||||
public static function loadAddons()
|
||||
{
|
||||
|
@ -109,6 +116,8 @@ class Addon
|
|||
/**
|
||||
* uninstalls an addon.
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::uninstallAddon()` instead
|
||||
*
|
||||
* @param string $addon name of the addon
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
|
@ -135,6 +144,8 @@ class Addon
|
|||
/**
|
||||
* installs an addon.
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::installAddon()` instead
|
||||
*
|
||||
* @param string $addon name of the addon
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
|
@ -173,6 +184,8 @@ class Addon
|
|||
/**
|
||||
* reload all updated addons
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::reloadAddons()` instead
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*
|
||||
|
@ -209,6 +222,9 @@ class Addon
|
|||
* * Maintainer: Jess <email>
|
||||
* *
|
||||
* *\endcode
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getAddonInfo()` instead
|
||||
*
|
||||
* @param string $addon the name of the addon
|
||||
* @return array with the addon information
|
||||
* @throws \Exception
|
||||
|
@ -275,6 +291,8 @@ class Addon
|
|||
/**
|
||||
* Checks if the provided addon is enabled
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::isAddonEnabled()` instead
|
||||
*
|
||||
* @param string $addon
|
||||
* @return boolean
|
||||
*/
|
||||
|
@ -286,6 +304,8 @@ class Addon
|
|||
/**
|
||||
* Returns a list of the enabled addon names
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getEnabledAddons()` instead
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getEnabledList(): array
|
||||
|
@ -296,6 +316,8 @@ class Addon
|
|||
/**
|
||||
* Returns the list of non-hidden enabled addon names
|
||||
*
|
||||
* @deprecated 2025.02 Use `Friendica\Core\Addon\AddonHelper::getVisibleEnabledAddons()` instead
|
||||
*
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Core\Addon;
|
||||
|
||||
/**
|
||||
* Some functions to handle addons
|
||||
*/
|
||||
interface AddonHelper
|
||||
{
|
||||
/**
|
||||
* Returns the absolute path to the addon folder
|
||||
*
|
||||
* e.g. `/var/www/html/addon`
|
||||
*/
|
||||
public function getAddonPath(): string;
|
||||
|
||||
/**
|
||||
* Returns the list of available addons.
|
||||
*
|
||||
* This list is made from scanning the addon/ folder.
|
||||
* Unsupported addons are excluded unless they already are enabled or system.show_unsupported_addon is set.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAvailableAddons(): array;
|
||||
|
||||
/**
|
||||
* Installs an addon.
|
||||
*
|
||||
* @param string $addonId name of the addon
|
||||
*
|
||||
* @return bool true on success or false on failure
|
||||
*/
|
||||
public function installAddon(string $addonId): bool;
|
||||
|
||||
/**
|
||||
* Uninstalls an addon.
|
||||
*
|
||||
* @param string $addonId name of the addon
|
||||
*/
|
||||
public function uninstallAddon(string $addonId): void;
|
||||
|
||||
/**
|
||||
* Load addons.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function loadAddons(): void;
|
||||
|
||||
/**
|
||||
* Reload (uninstall and install) all updated addons.
|
||||
*/
|
||||
public function reloadAddons(): void;
|
||||
|
||||
/**
|
||||
* Get the comment block of an addon as value object.
|
||||
*/
|
||||
public function getAddonInfo(string $addonId): AddonInfo;
|
||||
|
||||
/**
|
||||
* Checks if the provided addon is enabled
|
||||
*/
|
||||
public function isAddonEnabled(string $addonId): bool;
|
||||
|
||||
/**
|
||||
* Returns a list with the IDs of the enabled addons
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEnabledAddons(): array;
|
||||
|
||||
/**
|
||||
* Returns a list with the IDs of the non-hidden enabled addons
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getVisibleEnabledAddons(): array;
|
||||
|
||||
/**
|
||||
* Returns a list with the IDs of the enabled addons that provides admin settings.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEnabledAddonsWithAdminSettings(): array;
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Core\Addon;
|
||||
|
||||
/**
|
||||
* Information about an addon
|
||||
*/
|
||||
final class AddonInfo
|
||||
{
|
||||
/**
|
||||
* @internal Never create this object by yourself, use `Friendica\Core\Addon\AddonHelper::getAddonInfo()` instead.
|
||||
*
|
||||
* @see Friendica\Core\Addon\AddonHelper::getAddonInfo()
|
||||
*/
|
||||
public static function fromArray(array $info): self
|
||||
{
|
||||
$id = array_key_exists('id', $info) ? (string) $info['id'] : '';
|
||||
$name = array_key_exists('name', $info) ? (string) $info['name'] : '';
|
||||
$description = array_key_exists('description', $info) ? (string) $info['description'] : '';
|
||||
$authors = array_key_exists('authors', $info) ? self::parseContributors($info['authors']) : [];
|
||||
$maintainers = array_key_exists('maintainers', $info) ? self::parseContributors($info['maintainers']) : [];
|
||||
$version = array_key_exists('version', $info) ? (string) $info['version'] : '';
|
||||
$status = array_key_exists('status', $info) ? (string) $info['status'] : '';
|
||||
|
||||
return new self(
|
||||
$id,
|
||||
$name,
|
||||
$description,
|
||||
$authors,
|
||||
$maintainers,
|
||||
$version,
|
||||
$status
|
||||
);
|
||||
}
|
||||
|
||||
private static function parseContributors($entries): array
|
||||
{
|
||||
if (!is_array($entries)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$contributors = [];
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
if (!is_array($entry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!array_key_exists('name', $entry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$contributor = [
|
||||
'name' => (string) $entry['name'],
|
||||
];
|
||||
|
||||
if (array_key_exists('link', $entry)) {
|
||||
$contributor['link'] = (string) $entry['link'];
|
||||
}
|
||||
|
||||
$contributors[] = $contributor;
|
||||
}
|
||||
|
||||
return $contributors;
|
||||
}
|
||||
|
||||
private string $id = '';
|
||||
|
||||
private string $name = '';
|
||||
|
||||
private string $description = '';
|
||||
|
||||
private array $authors = [];
|
||||
|
||||
private array $maintainers = [];
|
||||
|
||||
private string $version = '';
|
||||
|
||||
private string $status = '';
|
||||
|
||||
private function __construct(
|
||||
string $id,
|
||||
string $name,
|
||||
string $description,
|
||||
array $authors,
|
||||
array $maintainers,
|
||||
string $version,
|
||||
string $status
|
||||
) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->description = $description;
|
||||
$this->authors = $authors;
|
||||
$this->maintainers = $maintainers;
|
||||
$this->version = $version;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getAuthors(): array
|
||||
{
|
||||
return $this->authors;
|
||||
}
|
||||
|
||||
public function getMaintainers(): array
|
||||
{
|
||||
return $this->maintainers;
|
||||
}
|
||||
|
||||
public function getVersion(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Core\Addon;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
|
||||
/**
|
||||
* Proxy to the Addon class
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class AddonProxy implements AddonHelper
|
||||
{
|
||||
private string $addonPath;
|
||||
|
||||
public function __construct(string $addonPath)
|
||||
{
|
||||
$this->addonPath = $addonPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute path to the addon folder
|
||||
*
|
||||
* e.g. `/var/www/html/addon`
|
||||
*/
|
||||
public function getAddonPath(): string
|
||||
{
|
||||
return $this->addonPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of available addons.
|
||||
*
|
||||
* This list is made from scanning the addon/ folder.
|
||||
* Unsupported addons are excluded unless they already are enabled or system.show_unsupported_addon is set.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAvailableAddons(): array
|
||||
{
|
||||
return array_map(
|
||||
function (array $item) {
|
||||
return $item[0];
|
||||
},
|
||||
Addon::getAvailableList()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs an addon.
|
||||
*
|
||||
* @param string $addonId name of the addon
|
||||
*
|
||||
* @return bool true on success or false on failure
|
||||
*/
|
||||
public function installAddon(string $addonId): bool
|
||||
{
|
||||
return Addon::install($addonId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls an addon.
|
||||
*
|
||||
* @param string $addonId name of the addon
|
||||
*/
|
||||
public function uninstallAddon(string $addonId): void
|
||||
{
|
||||
Addon::uninstall($addonId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load addons.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function loadAddons(): void
|
||||
{
|
||||
Addon::loadAddons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload (uninstall and install) all updated addons.
|
||||
*/
|
||||
public function reloadAddons(): void
|
||||
{
|
||||
Addon::reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the comment block of an addon as value object.
|
||||
*/
|
||||
public function getAddonInfo(string $addonId): AddonInfo
|
||||
{
|
||||
$data = Addon::getInfo($addonId);
|
||||
|
||||
// add addon ID
|
||||
$data['id'] = $addonId;
|
||||
|
||||
// rename author to authors
|
||||
$data['authors'] = $data['author'];
|
||||
unset($data['author']);
|
||||
|
||||
// rename maintainer to maintainers
|
||||
$data['maintainers'] = $data['maintainer'];
|
||||
unset($data['maintainer']);
|
||||
|
||||
return AddonInfo::fromArray($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided addon is enabled
|
||||
*/
|
||||
public function isAddonEnabled(string $addonId): bool
|
||||
{
|
||||
return Addon::isEnabled($addonId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with the IDs of the enabled addons
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEnabledAddons(): array
|
||||
{
|
||||
return Addon::getEnabledList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with the IDs of the non-hidden enabled addons
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getVisibleEnabledAddons(): array
|
||||
{
|
||||
return Addon::getVisibleList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with the IDs of the enabled addons that provides admin settings.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEnabledAddonsWithAdminSettings(): array
|
||||
{
|
||||
return array_keys(Addon::getAdminList());
|
||||
}
|
||||
}
|
|
@ -42,7 +42,7 @@ class Config
|
|||
*
|
||||
* @return Util\ConfigFileManager
|
||||
*/
|
||||
public function createConfigFileManager(string $basePath, array $server = []): Util\ConfigFileManager
|
||||
public function createConfigFileManager(string $basePath, string $addonPath, array $server = []): Util\ConfigFileManager
|
||||
{
|
||||
if (!empty($server[self::CONFIG_DIR_ENV]) && is_dir($server[self::CONFIG_DIR_ENV])) {
|
||||
$configDir = $server[self::CONFIG_DIR_ENV];
|
||||
|
@ -51,7 +51,7 @@ class Config
|
|||
}
|
||||
$staticDir = $basePath . DIRECTORY_SEPARATOR . self::STATIC_DIR;
|
||||
|
||||
return new Util\ConfigFileManager($basePath, $configDir, $staticDir, $server);
|
||||
return new Util\ConfigFileManager($basePath, $addonPath, $configDir, $staticDir, $server);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Core\Config\Util;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config\Exception\ConfigFileException;
|
||||
use Friendica\Core\Config\ValueObject\Cache;
|
||||
|
||||
|
@ -46,6 +45,7 @@ class ConfigFileManager
|
|||
* @var string
|
||||
*/
|
||||
private $baseDir;
|
||||
private string $addonDir;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -65,9 +65,10 @@ class ConfigFileManager
|
|||
* @param string $configDir
|
||||
* @param string $staticDir
|
||||
*/
|
||||
public function __construct(string $baseDir, string $configDir, string $staticDir, array $server = [])
|
||||
public function __construct(string $baseDir, string $addonDir, string $configDir, string $staticDir, array $server = [])
|
||||
{
|
||||
$this->baseDir = $baseDir;
|
||||
$this->addonDir = $addonDir;
|
||||
$this->configDir = $configDir;
|
||||
$this->staticDir = $staticDir;
|
||||
$this->server = $server;
|
||||
|
@ -122,7 +123,7 @@ class ConfigFileManager
|
|||
|
||||
if (file_exists($configName)) {
|
||||
return $this->loadConfigFile($configName);
|
||||
} else if (file_exists($iniName)) {
|
||||
} elseif (file_exists($iniName)) {
|
||||
return $this->loadINIConfigFile($iniName);
|
||||
} else {
|
||||
return [];
|
||||
|
@ -160,17 +161,16 @@ class ConfigFileManager
|
|||
*/
|
||||
public function loadAddonConfig(string $name): array
|
||||
{
|
||||
$filepath = $this->baseDir . DIRECTORY_SEPARATOR . // /var/www/html/
|
||||
Addon::DIRECTORY . DIRECTORY_SEPARATOR . // addon/
|
||||
$name . DIRECTORY_SEPARATOR . // openstreetmap/
|
||||
'config' . DIRECTORY_SEPARATOR . // config/
|
||||
$name . ".config.php"; // openstreetmap.config.php
|
||||
$filepath = $this->addonDir . DIRECTORY_SEPARATOR . // /var/www/html/addon/
|
||||
$name . DIRECTORY_SEPARATOR . // openstreetmap/
|
||||
'config' . DIRECTORY_SEPARATOR . // config/
|
||||
$name . ".config.php"; // openstreetmap.config.php
|
||||
|
||||
if (file_exists($filepath)) {
|
||||
return $this->loadConfigFile($filepath);
|
||||
} else {
|
||||
if (!file_exists($filepath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->loadConfigFile($filepath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Core\Hooks;
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Event\ArrayFilterEvent;
|
||||
use Friendica\Event\ConfigLoadedEvent;
|
||||
use Friendica\Event\Event;
|
||||
use Friendica\Event\HtmlFilterEvent;
|
||||
use Friendica\Event\NamedEvent;
|
||||
|
||||
/**
|
||||
* Bridge between the EventDispatcher and the Hook class.
|
||||
*
|
||||
* @internal Provides BC
|
||||
*/
|
||||
final class HookEventBridge
|
||||
{
|
||||
/**
|
||||
* @internal This allows us to mock the Hook call in tests.
|
||||
*
|
||||
* @var \Closure|null
|
||||
*/
|
||||
private static $mockedCallHook = null;
|
||||
|
||||
/**
|
||||
* This maps the new event names to the legacy Hook names.
|
||||
*/
|
||||
private static array $eventMapper = [
|
||||
Event::INIT => 'init_1',
|
||||
ConfigLoadedEvent::CONFIG_LOADED => 'load_config',
|
||||
ArrayFilterEvent::APP_MENU => 'app_menu',
|
||||
ArrayFilterEvent::NAV_INFO => 'nav_info',
|
||||
ArrayFilterEvent::FEATURE_ENABLED => 'isEnabled',
|
||||
ArrayFilterEvent::FEATURE_GET => 'get',
|
||||
HtmlFilterEvent::HEAD => 'head',
|
||||
HtmlFilterEvent::FOOTER => 'footer',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'page_header',
|
||||
HtmlFilterEvent::PAGE_CONTENT_TOP => 'page_content_top',
|
||||
HtmlFilterEvent::PAGE_END => 'page_end',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getStaticSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
Event::INIT => 'onNamedEvent',
|
||||
ConfigLoadedEvent::CONFIG_LOADED => 'onConfigLoadedEvent',
|
||||
ArrayFilterEvent::APP_MENU => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::NAV_INFO => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::FEATURE_ENABLED => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::FEATURE_GET => 'onArrayFilterEvent',
|
||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_CONTENT_TOP => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent',
|
||||
];
|
||||
}
|
||||
|
||||
public static function onNamedEvent(NamedEvent $event): void
|
||||
{
|
||||
static::callHook($event->getName(), '');
|
||||
}
|
||||
|
||||
public static function onConfigLoadedEvent(ConfigLoadedEvent $event): void
|
||||
{
|
||||
static::callHook($event->getName(), $event->getConfig());
|
||||
}
|
||||
|
||||
public static function onArrayFilterEvent(ArrayFilterEvent $event): void
|
||||
{
|
||||
$event->setArray(
|
||||
static::callHook($event->getName(), $event->getArray())
|
||||
);
|
||||
}
|
||||
|
||||
public static function onHtmlFilterEvent(HtmlFilterEvent $event): void
|
||||
{
|
||||
$event->setHtml(
|
||||
static::callHook($event->getName(), $event->getHtml())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array|object $data
|
||||
*
|
||||
* @return string|array|object
|
||||
*/
|
||||
private static function callHook(string $name, $data)
|
||||
{
|
||||
// If possible, map the event name to the legacy Hook name
|
||||
$name = static::$eventMapper[$name] ?? $name;
|
||||
|
||||
// Little hack to allow mocking the Hook call in tests.
|
||||
if (static::$mockedCallHook instanceof \Closure) {
|
||||
return (static::$mockedCallHook)->__invoke($name, $data);
|
||||
}
|
||||
|
||||
Hook::callAll($name, $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Logger\Type\WorkerLogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
@ -18,10 +17,7 @@ use Psr\Log\LoggerInterface;
|
|||
*/
|
||||
class Logger
|
||||
{
|
||||
/**
|
||||
* @return LoggerInterface|WorkerLogger
|
||||
*/
|
||||
private static function getInstance()
|
||||
private static function getInstance(): LoggerInterface
|
||||
{
|
||||
return DI::logger();
|
||||
}
|
||||
|
@ -38,6 +34,8 @@ class Logger
|
|||
*/
|
||||
public static function emergency(string $message, array $context = [])
|
||||
{
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::getInstance()->emergency($message, $context);
|
||||
}
|
||||
|
||||
|
@ -55,6 +53,8 @@ class Logger
|
|||
*/
|
||||
public static function alert(string $message, array $context = [])
|
||||
{
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::getInstance()->alert($message, $context);
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,8 @@ class Logger
|
|||
*/
|
||||
public static function critical(string $message, array $context = [])
|
||||
{
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::getInstance()->critical($message, $context);
|
||||
}
|
||||
|
||||
|
@ -86,6 +88,8 @@ class Logger
|
|||
*/
|
||||
public static function error(string $message, array $context = [])
|
||||
{
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::getInstance()->error($message, $context);
|
||||
}
|
||||
|
||||
|
@ -103,6 +107,8 @@ class Logger
|
|||
*/
|
||||
public static function warning(string $message, array $context = [])
|
||||
{
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::getInstance()->warning($message, $context);
|
||||
}
|
||||
|
||||
|
@ -117,6 +123,8 @@ class Logger
|
|||
*/
|
||||
public static function notice(string $message, array $context = [])
|
||||
{
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::getInstance()->notice($message, $context);
|
||||
}
|
||||
|
||||
|
@ -134,6 +142,8 @@ class Logger
|
|||
*/
|
||||
public static function info(string $message, array $context = [])
|
||||
{
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::getInstance()->info($message, $context);
|
||||
}
|
||||
|
||||
|
@ -148,6 +158,8 @@ class Logger
|
|||
*/
|
||||
public static function debug(string $message, array $context = [])
|
||||
{
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use constructor injection or `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::getInstance()->debug($message, $context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ class ErrorHandler
|
|||
E_STRICT => LogLevel::NOTICE,
|
||||
E_RECOVERABLE_ERROR => LogLevel::ERROR,
|
||||
E_DEPRECATED => LogLevel::NOTICE,
|
||||
E_USER_DEPRECATED => LogLevel::NOTICE,
|
||||
E_USER_DEPRECATED => LogLevel::WARNING,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -248,17 +248,29 @@ class ErrorHandler
|
|||
*/
|
||||
public function handleError(int $code, string $message, string $file = '', int $line = 0, ?array $context = []): bool
|
||||
{
|
||||
if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) {
|
||||
if ($this->handleOnlyReportedErrors && !(error_reporting() & $code) && $code !== E_USER_DEPRECATED) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
|
||||
array_shift($trace); // Exclude handleError from trace
|
||||
|
||||
if ($code === E_USER_DEPRECATED && $trace[0]['function'] ?? '' === 'trigger_error') {
|
||||
$calledPlace = $trace[1] ?? [];
|
||||
|
||||
$message .= sprintf(
|
||||
' It was called in `%s`%s.',
|
||||
$calledPlace['file'],
|
||||
isset($calledPlace['line']) ? ' in line ' . $calledPlace['line'] : ''
|
||||
);
|
||||
}
|
||||
|
||||
// fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries
|
||||
if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) {
|
||||
$level = $this->errorLevelMap[$code] ?? LogLevel::CRITICAL;
|
||||
$this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]);
|
||||
} else {
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
array_shift($trace); // Exclude handleError from trace
|
||||
$this->lastFatalTrace = $trace;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Core\Storage\Repository;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
|
@ -20,6 +19,7 @@ use Friendica\Core\Storage\Capability\ICanConfigureStorage;
|
|||
use Friendica\Core\Storage\Capability\ICanWriteToStorage;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Core\Storage\Type;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
@ -84,7 +84,7 @@ class StorageManager
|
|||
/// @fixme Loading the addons & hooks here is really bad practice, but solves https://github.com/friendica/friendica/issues/11178
|
||||
/// clean solution = Making Addon & Hook dynamic and load them inside the constructor, so there's no custom load logic necessary anymore
|
||||
if ($includeAddon) {
|
||||
Addon::loadAddons();
|
||||
DI::addonHelper()->loadAddons();
|
||||
Hook::loadHooks();
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class StorageManager
|
|||
// Try the filesystem backend
|
||||
case Type\Filesystem::getName():
|
||||
return new Type\FilesystemConfig($this->config, $this->l10n);
|
||||
// try the database backend
|
||||
// try the database backend
|
||||
case Type\Database::getName():
|
||||
return false;
|
||||
default:
|
||||
|
@ -185,11 +185,11 @@ class StorageManager
|
|||
$storageConfig = new Type\FilesystemConfig($this->config, $this->l10n);
|
||||
$this->backendInstances[$name] = new Type\Filesystem($storageConfig->getStoragePath());
|
||||
break;
|
||||
// try the database backend
|
||||
// try the database backend
|
||||
case Type\Database::getName():
|
||||
$this->backendInstances[$name] = new Type\Database($this->dba);
|
||||
break;
|
||||
// at least, try if there's an addon for the backend
|
||||
// at least, try if there's an addon for the backend
|
||||
case Type\SystemResource::getName():
|
||||
$this->backendInstances[$name] = new Type\SystemResource();
|
||||
break;
|
||||
|
@ -228,11 +228,13 @@ class StorageManager
|
|||
*/
|
||||
public function isValidBackend(string $name = null, array $validBackends = null): bool
|
||||
{
|
||||
$validBackends = $validBackends ?? array_merge($this->validBackends,
|
||||
[
|
||||
Type\SystemResource::getName(),
|
||||
Type\ExternalResource::getName(),
|
||||
]);
|
||||
$validBackends = $validBackends ?? array_merge(
|
||||
$this->validBackends,
|
||||
[
|
||||
Type\SystemResource::getName(),
|
||||
Type\ExternalResource::getName(),
|
||||
]
|
||||
);
|
||||
return in_array($name, $validBackends);
|
||||
}
|
||||
|
||||
|
|
22
src/DI.php
22
src/DI.php
|
@ -8,6 +8,7 @@
|
|||
namespace Friendica;
|
||||
|
||||
use Dice\Dice;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Logger\Capability\ICheckLoggerSettings;
|
||||
use Friendica\Core\Logger\LoggerManager;
|
||||
use Friendica\Core\Logger\Util\LoggerSettingsCheck;
|
||||
|
@ -280,6 +281,11 @@ abstract class DI
|
|||
return self::$dice->create(Core\Storage\Repository\StorageManager::class);
|
||||
}
|
||||
|
||||
public static function addonHelper(): AddonHelper
|
||||
{
|
||||
return self::$dice->create(AddonHelper::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Friendica\Core\System
|
||||
*/
|
||||
|
@ -332,9 +338,16 @@ abstract class DI
|
|||
*/
|
||||
public static function workerLogger()
|
||||
{
|
||||
@trigger_error('`' . __METHOD__ . '()` is deprecated since 2025.02 and will be removed after 5 months, use `DI::logger()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
return self::$dice->create(Core\Logger\Type\WorkerLogger::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Only for use in Friendica\Core\Worker class
|
||||
*
|
||||
* @see Friendica\Core\Worker::execFunction()
|
||||
*/
|
||||
public static function loggerManager(): LoggerManager
|
||||
{
|
||||
return self::$dice->create(LoggerManager::class);
|
||||
|
@ -782,4 +795,13 @@ abstract class DI
|
|||
{
|
||||
return self::$dice->create(Content\Post\Repository\PostMedia::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal The EventDispatcher should never called outside of the core, like in addons or themes
|
||||
* @deprecated 2025.02 Use constructor injection instead
|
||||
*/
|
||||
public static function eventDispatcher(): \Psr\EventDispatcher\EventDispatcherInterface
|
||||
{
|
||||
return self::$dice->create(\Psr\EventDispatcher\EventDispatcherInterface::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Event;
|
||||
|
||||
/**
|
||||
* Allow Event listener to modify an array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class ArrayFilterEvent extends Event
|
||||
{
|
||||
public const APP_MENU = 'friendica.data.app_menu';
|
||||
|
||||
public const NAV_INFO = 'friendica.data.nav_info';
|
||||
|
||||
public const FEATURE_ENABLED = 'friendica.data.feature_enabled';
|
||||
|
||||
public const FEATURE_GET = 'friendica.data.feature_get';
|
||||
|
||||
private array $array;
|
||||
|
||||
public function __construct(string $name, array $array)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->array = $array;
|
||||
}
|
||||
|
||||
public function getArray(): array
|
||||
{
|
||||
return $this->array;
|
||||
}
|
||||
|
||||
public function setArray(array $array): void
|
||||
{
|
||||
$this->array = $array;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Event;
|
||||
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
|
||||
/**
|
||||
* Notify that the config was loaded
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class ConfigLoadedEvent extends Event
|
||||
{
|
||||
public const CONFIG_LOADED = 'friendica.config_loaded';
|
||||
|
||||
private ConfigFileManager $config;
|
||||
|
||||
public function __construct(string $name, ConfigFileManager $config)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function getConfig(): ConfigFileManager
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Event;
|
||||
|
||||
/**
|
||||
* One-way Event to inform listener about something happend.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Event implements NamedEvent
|
||||
{
|
||||
/**
|
||||
* Friendica is initialized.
|
||||
*/
|
||||
public const INIT = 'friendica.init';
|
||||
|
||||
private string $name;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Event;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyEventDispatcher;
|
||||
|
||||
/**
|
||||
* Modified Event Dispatcher.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class EventDispatcher extends SymfonyEventDispatcher
|
||||
{
|
||||
/**
|
||||
* Add support for named events.
|
||||
*
|
||||
* @template T of object
|
||||
* @param T $event
|
||||
*
|
||||
* @return T The passed $event MUST be returned
|
||||
*/
|
||||
public function dispatch(object $event, ?string $eventName = null): object
|
||||
{
|
||||
if ($eventName === null && $event instanceof NamedEvent) {
|
||||
$eventName = $event->getName();
|
||||
}
|
||||
|
||||
return parent::dispatch($event, $eventName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Event;
|
||||
|
||||
/**
|
||||
* Allow Event listener to modify HTML.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class HtmlFilterEvent extends Event
|
||||
{
|
||||
public const HEAD = 'friendica.html.head';
|
||||
|
||||
public const FOOTER = 'friendica.html.footer';
|
||||
|
||||
public const PAGE_HEADER = 'friendica.html.page_header';
|
||||
|
||||
public const PAGE_CONTENT_TOP = 'friendica.html.page_content_top';
|
||||
|
||||
public const PAGE_END = 'friendica.html.page_end';
|
||||
|
||||
private string $html;
|
||||
|
||||
public function __construct(string $name, string $html)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->html = $html;
|
||||
}
|
||||
|
||||
public function getHtml(): string
|
||||
{
|
||||
return $this->html;
|
||||
}
|
||||
|
||||
public function setHtml(string $html): void
|
||||
{
|
||||
$this->html = $html;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Event;
|
||||
|
||||
/**
|
||||
* Interface for named events.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface NamedEvent
|
||||
{
|
||||
public function getName(): string;
|
||||
}
|
|
@ -10,6 +10,7 @@ namespace Friendica\Model\Contact;
|
|||
use Exception;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -22,6 +23,7 @@ use Friendica\Protocol\Activity;
|
|||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Worker\AddContact;
|
||||
|
||||
/**
|
||||
* This class provides relationship information based on the `contact-relation` table.
|
||||
|
@ -162,20 +164,22 @@ class Relation
|
|||
$following_counter = 0;
|
||||
|
||||
DI::logger()->info('Discover contacts', ['id' => $target, 'url' => $url, 'contacts' => count($contacts)]);
|
||||
foreach ($contacts as $contact) {
|
||||
$actor = Contact::getIdForURL($contact);
|
||||
if (!empty($actor)) {
|
||||
if (in_array($contact, $followers)) {
|
||||
$fields = ['cid' => $target, 'relation-cid' => $actor, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
|
||||
foreach ($contacts as $contact_url) {
|
||||
$contact = Contact::getByURL($contact_url, false, ['id']);
|
||||
if (!empty($contact['id'])) {
|
||||
if (in_array($contact_url, $followers)) {
|
||||
$fields = ['cid' => $target, 'relation-cid' => $contact['id'], 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
|
||||
DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE);
|
||||
$follower_counter++;
|
||||
}
|
||||
|
||||
if (in_array($contact, $followings)) {
|
||||
$fields = ['cid' => $actor, 'relation-cid' => $target, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
|
||||
if (in_array($contact_url, $followings)) {
|
||||
$fields = ['cid' => $contact['id'], 'relation-cid' => $target, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
|
||||
DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE);
|
||||
$following_counter++;
|
||||
}
|
||||
} else {
|
||||
AddContact::add(Worker::PRIORITY_LOW, 0, $contact_url);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3182,6 +3182,10 @@ class Item
|
|||
}
|
||||
|
||||
if (!empty($shared_item['uri-id'])) {
|
||||
if (!$s) {
|
||||
DI::logger()->notice('Unexpected empty item HTML', ['item' => $item]);
|
||||
}
|
||||
|
||||
$s = self::replacePlatformIcon($s, $shared_item, $uid);
|
||||
}
|
||||
|
||||
|
@ -3258,6 +3262,10 @@ class Item
|
|||
*/
|
||||
private static function replacePlatformIcon(string $html, array $item, int $uid): string
|
||||
{
|
||||
if ($html === '') {
|
||||
return $html;
|
||||
}
|
||||
|
||||
$dom = new \DOMDocument();
|
||||
if (!@$dom->loadHTML($html)) {
|
||||
return $html;
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Friendica\Model\Post;
|
|||
use Friendica\Content\PageInfo;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -255,16 +256,21 @@ class Media
|
|||
|
||||
private static function isFederatedServer(string $url): bool
|
||||
{
|
||||
$baseurl = Network::getBaseUrl(new Uri($url));
|
||||
if (empty($baseurl)) {
|
||||
try {
|
||||
$baseurl = Network::getBaseUrl(new Uri($url));
|
||||
if (empty($baseurl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Strings::compareLink($baseurl, ATProtocol::WEB)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return DBA::exists('gserver', ['nurl' => Strings::normaliseLink($baseurl), 'network' => Protocol::FEDERATED]);
|
||||
} catch(\Throwable $e) {
|
||||
DI::logger()->notice('Invalid URL provided', ['url' => $url, 'exception' => $e, 'callstack' => System::callstack(10)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Strings::compareLink($baseurl, ATProtocol::WEB)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return DBA::exists('gserver', ['nurl' => Strings::normaliseLink($baseurl), 'network' => Protocol::FEDERATED]);
|
||||
}
|
||||
|
||||
private static function addPreviewData(array $media): array
|
||||
|
@ -790,7 +796,7 @@ class Media
|
|||
}
|
||||
|
||||
// Search for links with descriptions
|
||||
if (preg_match_all("/\[url\=(https?:.*?)\].*?\[\/url\]/ism", $body, $matches)) {
|
||||
if (preg_match_all("#\[url=(https?://.+?)].+?\[/url]#ism", $body, $matches)) {
|
||||
foreach ($matches[1] as $url) {
|
||||
DI::logger()->info('Got page url (link with description)', ['uri-id' => $uriid, 'url' => $url]);
|
||||
$result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Module\Admin\Addons;
|
||||
|
||||
use Friendica\Content\Text\Markdown;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseAdmin;
|
||||
|
@ -42,12 +41,12 @@ class Details extends BaseAdmin
|
|||
{
|
||||
parent::content();
|
||||
|
||||
$addons_admin = Addon::getAdminList();
|
||||
$addonHelper = DI::addonHelper();
|
||||
|
||||
$addon = Strings::sanitizeFilePathItem($this->parameters['addon']);
|
||||
if (!is_file("addon/$addon/$addon.php")) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Addon not found.'));
|
||||
Addon::uninstall($addon);
|
||||
$addonHelper->uninstallAddon($addon);
|
||||
DI::baseUrl()->redirect('admin/addons');
|
||||
}
|
||||
|
||||
|
@ -55,11 +54,11 @@ class Details extends BaseAdmin
|
|||
self::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons_details', 't');
|
||||
|
||||
// Toggle addon status
|
||||
if (Addon::isEnabled($addon)) {
|
||||
Addon::uninstall($addon);
|
||||
if ($addonHelper->isAddonEnabled($addon)) {
|
||||
$addonHelper->uninstallAddon($addon);
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s disabled.', $addon));
|
||||
} else {
|
||||
Addon::install($addon);
|
||||
$addonHelper->installAddon($addon);
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s enabled.', $addon));
|
||||
}
|
||||
|
||||
|
@ -67,7 +66,7 @@ class Details extends BaseAdmin
|
|||
}
|
||||
|
||||
// display addon details
|
||||
if (Addon::isEnabled($addon)) {
|
||||
if ($addonHelper->isAddonEnabled($addon)) {
|
||||
$status = 'on';
|
||||
$action = DI::l10n()->t('Disable');
|
||||
} else {
|
||||
|
@ -82,32 +81,42 @@ class Details extends BaseAdmin
|
|||
$readme = '<pre>' . file_get_contents("addon/$addon/README") . '</pre>';
|
||||
}
|
||||
|
||||
$addons_admin = $addonHelper->getEnabledAddonsWithAdminSettings();
|
||||
|
||||
$admin_form = '';
|
||||
if (array_key_exists($addon, $addons_admin)) {
|
||||
if (in_array($addon, $addons_admin)) {
|
||||
require_once "addon/$addon/$addon.php";
|
||||
$func = $addon . '_addon_admin';
|
||||
$func($admin_form);
|
||||
}
|
||||
|
||||
$addonInfo = $addonHelper->getAddonInfo($addon);
|
||||
|
||||
$t = Renderer::getMarkupTemplate('admin/addons/details.tpl');
|
||||
|
||||
return Renderer::replaceMacros($t, [
|
||||
'$title' => DI::l10n()->t('Administration'),
|
||||
'$page' => DI::l10n()->t('Addons'),
|
||||
'$toggle' => DI::l10n()->t('Toggle'),
|
||||
'$title' => DI::l10n()->t('Administration'),
|
||||
'$page' => DI::l10n()->t('Addons'),
|
||||
'$toggle' => DI::l10n()->t('Toggle'),
|
||||
'$settings' => DI::l10n()->t('Settings'),
|
||||
|
||||
'$addon' => $addon,
|
||||
'$addon' => $addon,
|
||||
'$status' => $status,
|
||||
'$action' => $action,
|
||||
'$info' => Addon::getInfo($addon),
|
||||
'$str_author' => DI::l10n()->t('Author: '),
|
||||
'$info' => [
|
||||
'name' => $addonInfo->getName(),
|
||||
'version' => $addonInfo->getVersion(),
|
||||
'description' => $addonInfo->getDescription(),
|
||||
'author' => $addonInfo->getAuthors(),
|
||||
'maintainer' => $addonInfo->getMaintainers(),
|
||||
],
|
||||
'$str_author' => DI::l10n()->t('Author: '),
|
||||
'$str_maintainer' => DI::l10n()->t('Maintainer: '),
|
||||
|
||||
'$admin_form' => $admin_form,
|
||||
'$function' => 'addons',
|
||||
'$function' => 'addons',
|
||||
'$screenshot' => '',
|
||||
'$readme' => $readme,
|
||||
'$readme' => $readme,
|
||||
|
||||
'$form_security_token' => self::getFormSecurityToken('admin_addons_details'),
|
||||
]);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Admin\Addons;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseAdmin;
|
||||
|
@ -24,22 +23,25 @@ class Index extends BaseAdmin
|
|||
{
|
||||
parent::content();
|
||||
|
||||
$addonHelper = DI::addonHelper();
|
||||
|
||||
// reload active themes
|
||||
if (!empty($_GET['action'])) {
|
||||
self::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons', 't');
|
||||
|
||||
switch ($_GET['action']) {
|
||||
case 'reload':
|
||||
Addon::reload();
|
||||
$addonHelper->reloadAddons();
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('Addons reloaded'));
|
||||
break;
|
||||
|
||||
case 'toggle' :
|
||||
case 'toggle':
|
||||
$addon = $_GET['addon'] ?? '';
|
||||
if (Addon::isEnabled($addon)) {
|
||||
Addon::uninstall($addon);
|
||||
|
||||
if ($addonHelper->isAddonEnabled($addon)) {
|
||||
$addonHelper->uninstallAddon($addon);
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s disabled.', $addon));
|
||||
} elseif (Addon::install($addon)) {
|
||||
} elseif ($addonHelper->installAddon($addon)) {
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('Addon %s enabled.', $addon));
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Addon %s failed to install.', $addon));
|
||||
|
@ -52,18 +54,34 @@ class Index extends BaseAdmin
|
|||
DI::baseUrl()->redirect('admin/addons');
|
||||
}
|
||||
|
||||
$addons = Addon::getAvailableList();
|
||||
$addons = [];
|
||||
|
||||
foreach ($addonHelper->getAvailableAddons() as $addonId) {
|
||||
$addonInfo = $addonHelper->getAddonInfo($addonId);
|
||||
|
||||
$info = [
|
||||
'name' => $addonInfo->getName(),
|
||||
'description' => $addonInfo->getDescription(),
|
||||
'version' => $addonInfo->getVersion(),
|
||||
];
|
||||
|
||||
$addons[] = [
|
||||
$addonId,
|
||||
($addonHelper->isAddonEnabled($addonId) ? 'on' : 'off'),
|
||||
$info,
|
||||
];
|
||||
}
|
||||
|
||||
$t = Renderer::getMarkupTemplate('admin/addons/index.tpl');
|
||||
return Renderer::replaceMacros($t, [
|
||||
'$title' => DI::l10n()->t('Administration'),
|
||||
'$page' => DI::l10n()->t('Addons'),
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
'$reload' => DI::l10n()->t('Reload active addons'),
|
||||
'$function' => 'addons',
|
||||
'$addons' => $addons,
|
||||
'$pcount' => count($addons),
|
||||
'$noplugshint' => DI::l10n()->t('There are currently no addons available on your node. You can find the official addon repository at %1$s.', 'https://git.friendi.ca/friendica/friendica-addons'),
|
||||
'$title' => DI::l10n()->t('Administration'),
|
||||
'$page' => DI::l10n()->t('Addons'),
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
'$reload' => DI::l10n()->t('Reload active addons'),
|
||||
'$function' => 'addons',
|
||||
'$addons' => $addons,
|
||||
'$pcount' => count($addons),
|
||||
'$noplugshint' => DI::l10n()->t('There are currently no addons available on your node. You can find the official addon repository at %1$s.', 'https://git.friendi.ca/friendica/friendica-addons'),
|
||||
'$form_security_token' => self::getFormSecurityToken('admin_addons'),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Module\Admin;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config\ValueObject\Cache;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Update;
|
||||
|
@ -27,13 +26,14 @@ class Summary extends BaseAdmin
|
|||
{
|
||||
parent::content();
|
||||
|
||||
$basePath = DI::appHelper()->getBasePath();
|
||||
$basePath = DI::appHelper()->getBasePath();
|
||||
$addonPath = DI::addonHelper()->getAddonPath();
|
||||
|
||||
// are there MyISAM tables in the DB? If so, trigger a warning message
|
||||
$warningtext = [];
|
||||
|
||||
$templateEngine = Renderer::getTemplateEngine();
|
||||
$errors = [];
|
||||
$errors = [];
|
||||
$templateEngine->testInstall($errors);
|
||||
foreach ($errors as $error) {
|
||||
$warningtext[] = DI::l10n()->t('Template engine (%s) error: %s', $templateEngine::$name, $error);
|
||||
|
@ -51,7 +51,7 @@ class Summary extends BaseAdmin
|
|||
// Avoid the database error 1615 "Prepared statement needs to be re-prepared", see https://github.com/friendica/friendica/issues/8550
|
||||
if (!DI::config()->get('database', 'pdo_emulate_prepares')) {
|
||||
$table_definition_cache = DBA::getVariable('table_definition_cache');
|
||||
$table_open_cache = DBA::getVariable('table_open_cache');
|
||||
$table_open_cache = DBA::getVariable('table_open_cache');
|
||||
if (!empty($table_definition_cache) && !empty($table_open_cache)) {
|
||||
$suggested_definition_cache = min(400 + round((int) $table_open_cache / 2, 1), 2000);
|
||||
if ($suggested_definition_cache > $table_definition_cache) {
|
||||
|
@ -100,9 +100,13 @@ class Summary extends BaseAdmin
|
|||
|
||||
// Check server vitality
|
||||
if (!self::checkSelfHostMeta()) {
|
||||
$well_known = DI::baseUrl() . Probe::HOST_META;
|
||||
$warningtext[] = DI::l10n()->t('<a href="%s">%s</a> is not reachable on your system. This is a severe configuration issue that prevents server to server communication. See <a href="%s">the installation page</a> for help.',
|
||||
$well_known, $well_known, DI::baseUrl() . '/help/Install');
|
||||
$well_known = DI::baseUrl() . Probe::HOST_META;
|
||||
$warningtext[] = DI::l10n()->t(
|
||||
'<a href="%s">%s</a> is not reachable on your system. This is a severe configuration issue that prevents server to server communication. See <a href="%s">the installation page</a> for help.',
|
||||
$well_known,
|
||||
$well_known,
|
||||
DI::baseUrl() . '/help/Install'
|
||||
);
|
||||
}
|
||||
|
||||
// Check logfile permission
|
||||
|
@ -114,8 +118,8 @@ class Summary extends BaseAdmin
|
|||
}
|
||||
|
||||
// check legacy basepath settings
|
||||
$configLoader = (new Config())->createConfigFileManager($basePath, $_SERVER);
|
||||
$configCache = new Cache();
|
||||
$configLoader = (new Config())->createConfigFileManager($basePath, $addonPath, $_SERVER);
|
||||
$configCache = new Cache();
|
||||
$configLoader->setupCache($configCache);
|
||||
$confBasepath = $configCache->get('system', 'basepath');
|
||||
$currBasepath = DI::config()->get('system', 'basepath');
|
||||
|
@ -125,25 +129,31 @@ class Summary extends BaseAdmin
|
|||
'from' => $currBasepath,
|
||||
'to' => $confBasepath,
|
||||
]);
|
||||
$warningtext[] = DI::l10n()->t('Friendica\'s system.basepath was updated from \'%s\' to \'%s\'. Please remove the system.basepath from your db to avoid differences.',
|
||||
$warningtext[] = DI::l10n()->t(
|
||||
'Friendica\'s system.basepath was updated from \'%s\' to \'%s\'. Please remove the system.basepath from your db to avoid differences.',
|
||||
$currBasepath,
|
||||
$confBasepath);
|
||||
$confBasepath
|
||||
);
|
||||
} elseif (!is_dir($currBasepath)) {
|
||||
DI::logger()->alert('Friendica\'s system.basepath is wrong.', [
|
||||
'from' => $currBasepath,
|
||||
'to' => $confBasepath,
|
||||
]);
|
||||
$warningtext[] = DI::l10n()->t('Friendica\'s current system.basepath \'%s\' is wrong and the config file \'%s\' isn\'t used.',
|
||||
$warningtext[] = DI::l10n()->t(
|
||||
'Friendica\'s current system.basepath \'%s\' is wrong and the config file \'%s\' isn\'t used.',
|
||||
$currBasepath,
|
||||
$confBasepath);
|
||||
$confBasepath
|
||||
);
|
||||
} else {
|
||||
DI::logger()->alert('Friendica\'s system.basepath is wrong.', [
|
||||
'from' => $currBasepath,
|
||||
'to' => $confBasepath,
|
||||
]);
|
||||
$warningtext[] = DI::l10n()->t('Friendica\'s current system.basepath \'%s\' is not equal to the config file \'%s\'. Please fix your configuration.',
|
||||
$warningtext[] = DI::l10n()->t(
|
||||
'Friendica\'s current system.basepath \'%s\' is not equal to the config file \'%s\'. Please fix your configuration.',
|
||||
$currBasepath,
|
||||
$confBasepath);
|
||||
$confBasepath
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +187,7 @@ class Summary extends BaseAdmin
|
|||
'$platform' => App::PLATFORM,
|
||||
'$codename' => App::CODENAME,
|
||||
'$build' => DI::config()->get('system', 'build'),
|
||||
'$addons' => [DI::l10n()->t('Active addons'), Addon::getEnabledList()],
|
||||
'$addons' => [DI::l10n()->t('Active addons'), DI::addonHelper()->getEnabledAddons()],
|
||||
'$serversettings' => $server_settings,
|
||||
'$warningtext' => $warningtext,
|
||||
]);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -69,43 +68,53 @@ abstract class BaseAdmin extends BaseModule
|
|||
// not part of $aside to make the template more adjustable
|
||||
$aside_sub = [
|
||||
'information' => [DI::l10n()->t('Information'), [
|
||||
'overview' => ['admin' , DI::l10n()->t('Overview') , 'overview'],
|
||||
'federation' => ['admin/federation' , DI::l10n()->t('Federation Statistics') , 'federation']
|
||||
'overview' => ['admin' , DI::l10n()->t('Overview') , 'overview'],
|
||||
'federation' => ['admin/federation' , DI::l10n()->t('Federation Statistics') , 'federation']
|
||||
]],
|
||||
'configuration' => [DI::l10n()->t('Configuration'), [
|
||||
'site' => ['admin/site' , DI::l10n()->t('Site') , 'site'],
|
||||
'storage' => ['admin/storage' , DI::l10n()->t('Storage') , 'storage'],
|
||||
'addons' => ['admin/addons' , DI::l10n()->t('Addons') , 'addons'],
|
||||
'themes' => ['admin/themes' , DI::l10n()->t('Themes') , 'themes'],
|
||||
'features' => ['admin/features' , DI::l10n()->t('Additional features') , 'features'],
|
||||
'tos' => ['admin/tos' , DI::l10n()->t('Terms of Service') , 'tos'],
|
||||
'site' => ['admin/site' , DI::l10n()->t('Site') , 'site'],
|
||||
'storage' => ['admin/storage' , DI::l10n()->t('Storage') , 'storage'],
|
||||
'addons' => ['admin/addons' , DI::l10n()->t('Addons') , 'addons'],
|
||||
'themes' => ['admin/themes' , DI::l10n()->t('Themes') , 'themes'],
|
||||
'features' => ['admin/features' , DI::l10n()->t('Additional features') , 'features'],
|
||||
'tos' => ['admin/tos' , DI::l10n()->t('Terms of Service') , 'tos'],
|
||||
]],
|
||||
'database' => [DI::l10n()->t('Database'), [
|
||||
'dbsync' => ['admin/dbsync' , DI::l10n()->t('DB updates') , 'dbsync'],
|
||||
'deferred' => ['admin/queue/deferred', DI::l10n()->t('Inspect Deferred Workers'), 'deferred'],
|
||||
'workerqueue' => ['admin/queue' , DI::l10n()->t('Inspect worker Queue') , 'workerqueue'],
|
||||
'dbsync' => ['admin/dbsync' , DI::l10n()->t('DB updates') , 'dbsync'],
|
||||
'deferred' => ['admin/queue/deferred', DI::l10n()->t('Inspect Deferred Workers'), 'deferred'],
|
||||
'workerqueue' => ['admin/queue' , DI::l10n()->t('Inspect worker Queue') , 'workerqueue'],
|
||||
]],
|
||||
'logs' => [DI::l10n()->t('Logs'), [
|
||||
'logsconfig' => ['admin/logs/', DI::l10n()->t('Logs') , 'logs'],
|
||||
'logsview' => ['admin/logs/view' , DI::l10n()->t('View Logs') , 'viewlogs'],
|
||||
'logsconfig' => ['admin/logs/', DI::l10n()->t('Logs') , 'logs'],
|
||||
'logsview' => ['admin/logs/view' , DI::l10n()->t('View Logs') , 'viewlogs'],
|
||||
]],
|
||||
'diagnostics' => [DI::l10n()->t('Diagnostics'), [
|
||||
'phpinfo' => ['admin/phpinfo?t=' . self::getFormSecurityToken('phpinfo'), DI::l10n()->t('PHP Info') , 'phpinfo'],
|
||||
'probe' => ['probe' , DI::l10n()->t('probe address') , 'probe'],
|
||||
'webfinger' => ['webfinger' , DI::l10n()->t('check webfinger') , 'webfinger'],
|
||||
'babel' => ['babel' , DI::l10n()->t('Babel') , 'babel'],
|
||||
'debug/ap' => ['debug/ap' , DI::l10n()->t('ActivityPub Conversion') , 'debug/ap'],
|
||||
'phpinfo' => ['admin/phpinfo?t=' . self::getFormSecurityToken('phpinfo'), DI::l10n()->t('PHP Info') , 'phpinfo'],
|
||||
'probe' => ['probe' , DI::l10n()->t('probe address') , 'probe'],
|
||||
'webfinger' => ['webfinger' , DI::l10n()->t('check webfinger') , 'webfinger'],
|
||||
'babel' => ['babel' , DI::l10n()->t('Babel') , 'babel'],
|
||||
'debug/ap' => ['debug/ap' , DI::l10n()->t('ActivityPub Conversion') , 'debug/ap'],
|
||||
]],
|
||||
];
|
||||
|
||||
$addons_admin = [];
|
||||
|
||||
foreach (DI::addonHelper()->getEnabledAddonsWithAdminSettings() as $addonId) {
|
||||
$addons_admin[$addonId] = [
|
||||
'url' => 'admin/addons/' . $addonId,
|
||||
'name' => $addonId,
|
||||
'class' => 'addon',
|
||||
];
|
||||
}
|
||||
|
||||
$t = Renderer::getMarkupTemplate('admin/aside.tpl');
|
||||
DI::page()['aside'] .= Renderer::replaceMacros($t, [
|
||||
'$admin' => ['addons_admin' => Addon::getAdminList()],
|
||||
'$subpages' => $aside_sub,
|
||||
'$admtxt' => DI::l10n()->t('Admin'),
|
||||
'$admin' => ['addons_admin' => $addons_admin],
|
||||
'$subpages' => $aside_sub,
|
||||
'$admtxt' => DI::l10n()->t('Admin'),
|
||||
'$plugadmtxt' => DI::l10n()->t('Addon Features'),
|
||||
'$h_pending' => DI::l10n()->t('User registrations waiting for confirmation'),
|
||||
'$admurl' => 'admin/'
|
||||
'$h_pending' => DI::l10n()->t('User registrations waiting for confirmation'),
|
||||
'$admurl' => 'admin/'
|
||||
]);
|
||||
|
||||
return '';
|
||||
|
|
|
@ -31,35 +31,35 @@ class BaseProfile extends BaseModule
|
|||
|
||||
$tabs = [
|
||||
[
|
||||
'label' => DI::l10n()->t('Profile'),
|
||||
'url' => $baseProfileUrl . '/profile',
|
||||
'sel' => $current == 'profile' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Profile Details'),
|
||||
'id' => 'profile-tab',
|
||||
'label' => DI::l10n()->t('Profile'),
|
||||
'url' => $baseProfileUrl . '/profile',
|
||||
'sel' => $current == 'profile' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Profile Details'),
|
||||
'id' => 'profile-tab',
|
||||
'accesskey' => 'r',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Conversations'),
|
||||
'url' => $baseProfileUrl . '/conversations',
|
||||
'sel' => $current == 'status' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Conversations started'),
|
||||
'id' => 'status-tab',
|
||||
'label' => DI::l10n()->t('Conversations'),
|
||||
'url' => $baseProfileUrl . '/conversations',
|
||||
'sel' => $current == 'status' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Conversations started'),
|
||||
'id' => 'status-tab',
|
||||
'accesskey' => 'm',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Photos'),
|
||||
'url' => $baseProfileUrl . '/photos',
|
||||
'sel' => $current == 'photos' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Photo Albums'),
|
||||
'id' => 'photo-tab',
|
||||
'label' => DI::l10n()->t('Photos'),
|
||||
'url' => $baseProfileUrl . '/photos',
|
||||
'sel' => $current == 'photos' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Photo Albums'),
|
||||
'id' => 'photo-tab',
|
||||
'accesskey' => 'h',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Media'),
|
||||
'url' => $baseProfileUrl . '/media',
|
||||
'sel' => $current == 'media' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Media'),
|
||||
'id' => 'media-tab',
|
||||
'label' => DI::l10n()->t('Media'),
|
||||
'url' => $baseProfileUrl . '/media',
|
||||
'sel' => $current == 'media' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Media'),
|
||||
'id' => 'media-tab',
|
||||
'accesskey' => 'd',
|
||||
],
|
||||
];
|
||||
|
@ -67,22 +67,22 @@ class BaseProfile extends BaseModule
|
|||
// the calendar link for the full-featured events calendar
|
||||
if ($is_owner) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Calendar'),
|
||||
'url' => DI::baseUrl() . '/calendar',
|
||||
'sel' => $current == 'calendar' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Calendar'),
|
||||
'id' => 'calendar-tab',
|
||||
'label' => DI::l10n()->t('Calendar'),
|
||||
'url' => DI::baseUrl() . '/calendar',
|
||||
'sel' => $current == 'calendar' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Calendar'),
|
||||
'id' => 'calendar-tab',
|
||||
'accesskey' => 'c',
|
||||
];
|
||||
} else {
|
||||
$owner = User::getByNickname($nickname, ['uid']);
|
||||
if(DI::userSession()->isAuthenticated() || $owner && Feature::isEnabled($owner['uid'], Feature::PUBLIC_CALENDAR)) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Calendar'),
|
||||
'url' => DI::baseUrl() . '/calendar/show/' . $nickname,
|
||||
'sel' => $current == 'calendar' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Calendar'),
|
||||
'id' => 'calendar-tab',
|
||||
'label' => DI::l10n()->t('Calendar'),
|
||||
'url' => DI::baseUrl() . '/calendar/show/' . $nickname,
|
||||
'sel' => $current == 'calendar' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Calendar'),
|
||||
'id' => 'calendar-tab',
|
||||
'accesskey' => 'c',
|
||||
];
|
||||
}
|
||||
|
@ -90,30 +90,30 @@ class BaseProfile extends BaseModule
|
|||
|
||||
if ($is_owner) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Personal Notes'),
|
||||
'url' => DI::baseUrl() . '/notes',
|
||||
'sel' => $current == 'notes' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only You Can See This'),
|
||||
'id' => 'notes-tab',
|
||||
'label' => DI::l10n()->t('Personal Notes'),
|
||||
'url' => DI::baseUrl() . '/notes',
|
||||
'sel' => $current == 'notes' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Only You Can See This'),
|
||||
'id' => 'notes-tab',
|
||||
'accesskey' => 't',
|
||||
];
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Scheduled Posts'),
|
||||
'url' => $baseProfileUrl . '/schedule',
|
||||
'sel' => $current == 'schedule' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Posts that are scheduled for publishing'),
|
||||
'id' => 'schedule-tab',
|
||||
'label' => DI::l10n()->t('Scheduled Posts'),
|
||||
'url' => $baseProfileUrl . '/schedule',
|
||||
'sel' => $current == 'schedule' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Posts that are scheduled for publishing'),
|
||||
'id' => 'schedule-tab',
|
||||
'accesskey' => 'o',
|
||||
];
|
||||
}
|
||||
|
||||
if (!$hide_friends) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Contacts'),
|
||||
'url' => $baseProfileUrl . '/contacts',
|
||||
'sel' => $current == 'contacts' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Contacts'),
|
||||
'id' => 'viewcontacts-tab',
|
||||
'label' => DI::l10n()->t('Contacts'),
|
||||
'url' => $baseProfileUrl . '/contacts',
|
||||
'sel' => $current == 'contacts' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Contacts'),
|
||||
'id' => 'viewcontacts-tab',
|
||||
'accesskey' => 'k',
|
||||
];
|
||||
}
|
||||
|
@ -134,6 +134,6 @@ class BaseProfile extends BaseModule
|
|||
|
||||
$tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
|
||||
return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]);
|
||||
return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs'], '$more' => DI::l10n()->t('More')]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ class BaseSettings extends BaseModule
|
|||
$tabs[] = [
|
||||
'label' => $this->t('Import Contacts'),
|
||||
'url' => 'settings/importcontacts',
|
||||
'selected' => static::class == Settings\UserExport::class ? 'active' : '',
|
||||
'selected' => static::class == Settings\ContactImport::class ? 'active' : '',
|
||||
'accesskey' => '',
|
||||
];
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ use Friendica\Core\Session\Capability\IHandleUserSessions;
|
|||
use Friendica\Core\Theme;
|
||||
use Friendica\Model\Event;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseProfile;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Module\Security\Login;
|
||||
|
@ -119,6 +118,8 @@ class Show extends BaseModule
|
|||
'$week' => $this->t('week'),
|
||||
'$day' => $this->t('day'),
|
||||
'$list' => $this->t('list'),
|
||||
'$prev' => $this->t('prev'),
|
||||
'$next' => $this->t('next'),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -387,7 +387,7 @@ class Contact extends BaseModule
|
|||
];
|
||||
|
||||
$tabs_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
$tabs_html = Renderer::replaceMacros($tabs_tpl, ['$tabs' => $tabs]);
|
||||
$tabs_html = Renderer::replaceMacros($tabs_tpl, ['$tabs' => $tabs, '$more' => DI::l10n()->t('More')]);
|
||||
|
||||
switch ($rel) {
|
||||
case 'followers':
|
||||
|
@ -534,7 +534,7 @@ class Contact extends BaseModule
|
|||
}
|
||||
|
||||
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
$tab_str = Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
|
||||
$tab_str = Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs, '$more' => DI::l10n()->t('More')]);
|
||||
|
||||
return $tab_str;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class Channel extends Timeline
|
|||
$tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'channel'));
|
||||
|
||||
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
|
||||
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs, '$more' => $this->l10n->t('More')]);
|
||||
|
||||
Nav::setSelected('channel');
|
||||
|
||||
|
@ -163,7 +163,7 @@ class Channel extends Timeline
|
|||
throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.'));
|
||||
}
|
||||
|
||||
$this->maxId = $request['last_created'] ?? $this->maxId;
|
||||
$this->maxId = $request['last_created'] ?? $this->maxId;
|
||||
$this->minId = $request['first_created'] ?? $this->minId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,10 +74,10 @@ class Community extends Timeline
|
|||
|
||||
$t = Renderer::getMarkupTemplate("community.tpl");
|
||||
$o = Renderer::replaceMacros($t, [
|
||||
'$content' => '',
|
||||
'$header' => '',
|
||||
'$content' => '',
|
||||
'$header' => '',
|
||||
'$show_global_community_hint' => ($this->selectedTab == CommunityEntity::GLOBAL) && $this->config->get('system', 'show_global_community_hint'),
|
||||
'$global_community_hint' => $this->l10n->t("This community stream shows all public posts received by this node. They may not reflect the opinions of this node’s users.")
|
||||
'$global_community_hint' => $this->l10n->t("This community stream shows all public posts received by this node. They may not reflect the opinions of this node’s users.")
|
||||
]);
|
||||
|
||||
if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll')) {
|
||||
|
@ -88,7 +88,7 @@ class Community extends Timeline
|
|||
if (!$this->raw) {
|
||||
$tabs = $this->getTabArray($this->community->getTimelines($this->session->isAuthenticated()), 'community');
|
||||
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
|
||||
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs, '$more' => $this->l10n->t('More')]);
|
||||
|
||||
Nav::setSelected('community');
|
||||
|
||||
|
@ -185,7 +185,7 @@ class Community extends Timeline
|
|||
}
|
||||
}
|
||||
|
||||
$this->maxId = $request['last_received'] ?? $this->maxId;
|
||||
$this->maxId = $request['last_received'] ?? $this->maxId;
|
||||
$this->minId = $request['first_received'] ?? $this->minId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,9 +192,9 @@ class Network extends Timeline
|
|||
|
||||
$x = [
|
||||
'lockstate' => $this->circleId || $this->network || ACL::getLockstateForUserId($this->session->getLocalUserId()) ? 'lock' : 'unlock',
|
||||
'acl' => ACL::getFullSelectorHTML($this->page, $this->session->getLocalUserId(), true, $default_permissions),
|
||||
'bang' => (($this->circleId || $this->network) ? '!' : ''),
|
||||
'content' => '',
|
||||
'acl' => ACL::getFullSelectorHTML($this->page, $this->session->getLocalUserId(), true, $default_permissions),
|
||||
'bang' => (($this->circleId || $this->network) ? '!' : ''),
|
||||
'content' => '',
|
||||
];
|
||||
|
||||
$o .= $this->conversation->statusEditor($x);
|
||||
|
@ -236,7 +236,7 @@ class Network extends Timeline
|
|||
$pager = new BoundariesPager(
|
||||
$this->l10n,
|
||||
$this->args->getQueryString(),
|
||||
$items[0][$this->order] ?? null,
|
||||
$items[0][$this->order] ?? null,
|
||||
$items[count($items) - 1][$this->order] ?? null,
|
||||
$this->itemsPerPage
|
||||
);
|
||||
|
@ -292,7 +292,7 @@ class Network extends Timeline
|
|||
|
||||
$tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
|
||||
return Renderer::replaceMacros($tpl, ['$tabs' => $tabs]);
|
||||
return Renderer::replaceMacros($tpl, ['$tabs' => $tabs, '$more' => $this->l10n->t('More')]);
|
||||
}
|
||||
|
||||
protected function parseRequest(array $request)
|
||||
|
@ -313,23 +313,23 @@ class Network extends Timeline
|
|||
|
||||
if (!empty($request['star'])) {
|
||||
$this->selectedTab = NetworkEntity::STAR;
|
||||
$this->star = true;
|
||||
$this->star = true;
|
||||
} else {
|
||||
$this->star = $this->selectedTab == NetworkEntity::STAR;
|
||||
}
|
||||
|
||||
if (!empty($request['mention'])) {
|
||||
$this->selectedTab = NetworkEntity::MENTION;
|
||||
$this->mention = true;
|
||||
$this->mention = true;
|
||||
} else {
|
||||
$this->mention = $this->selectedTab == NetworkEntity::MENTION;
|
||||
}
|
||||
|
||||
if (!empty($request['order'])) {
|
||||
$this->selectedTab = $request['order'];
|
||||
$this->order = $request['order'];
|
||||
$this->star = false;
|
||||
$this->mention = false;
|
||||
$this->order = $request['order'];
|
||||
$this->star = false;
|
||||
$this->mention = false;
|
||||
} elseif (in_array($this->selectedTab, [NetworkEntity::RECEIVED, NetworkEntity::STAR]) || $this->community->isTimeline($this->selectedTab)) {
|
||||
$this->order = 'received';
|
||||
} elseif (($this->selectedTab == NetworkEntity::CREATED) || $this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
|
||||
|
@ -344,7 +344,8 @@ class Network extends Timeline
|
|||
// since otherwise the feed will optically jump, when some already visible thread has been updated.
|
||||
if ($this->update && ($this->selectedTab == NetworkEntity::COMMENTED)) {
|
||||
$this->order = 'received';
|
||||
$request['last_received'] = $request['last_commented'] ?? null;
|
||||
|
||||
$request['last_received'] = $request['last_commented'] ?? null;
|
||||
$request['first_received'] = $request['first_commented'] ?? null;
|
||||
}
|
||||
|
||||
|
@ -361,7 +362,7 @@ class Network extends Timeline
|
|||
$this->network = $request['nets'] ?? '';
|
||||
|
||||
$this->dateFrom = $this->parameters['from'] ?? '';
|
||||
$this->dateTo = $this->parameters['to'] ?? '';
|
||||
$this->dateTo = $this->parameters['to'] ?? '';
|
||||
|
||||
$this->setMaxMinByOrder($request);
|
||||
|
||||
|
|
|
@ -150,20 +150,20 @@ class Timeline extends BaseModule
|
|||
{
|
||||
switch ($this->order) {
|
||||
case 'received':
|
||||
$this->maxId = $request['last_received'] ?? $this->maxId;
|
||||
$this->maxId = $request['last_received'] ?? $this->maxId;
|
||||
$this->minId = $request['first_received'] ?? $this->minId;
|
||||
break;
|
||||
case 'created':
|
||||
$this->maxId = $request['last_created'] ?? $this->maxId;
|
||||
$this->maxId = $request['last_created'] ?? $this->maxId;
|
||||
$this->minId = $request['first_created'] ?? $this->minId;
|
||||
break;
|
||||
case 'uri-id':
|
||||
$this->maxId = $request['last_uriid'] ?? $this->maxId;
|
||||
$this->maxId = $request['last_uriid'] ?? $this->maxId;
|
||||
$this->minId = $request['first_uriid'] ?? $this->minId;
|
||||
break;
|
||||
default:
|
||||
$this->order = 'commented';
|
||||
$this->maxId = $request['last_commented'] ?? $this->maxId;
|
||||
$this->maxId = $request['last_commented'] ?? $this->maxId;
|
||||
$this->minId = $request['first_commented'] ?? $this->minId;
|
||||
}
|
||||
}
|
||||
|
@ -256,8 +256,8 @@ class Timeline extends BaseModule
|
|||
|
||||
while (count($selected_items) < $total && ++$count < 50 && count($items) > 0) {
|
||||
$maxposts = round((count($items) / $total) * $maxpostperauthor);
|
||||
$minId = $items[array_key_first($items)][$this->order];
|
||||
$maxId = $items[array_key_last($items)][$this->order];
|
||||
$minId = $items[array_key_first($items)][$this->order];
|
||||
$maxId = $items[array_key_last($items)][$this->order];
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (!in_array($item['owner-id'], $reduced)) {
|
||||
|
@ -373,9 +373,9 @@ class Timeline extends BaseModule
|
|||
} elseif (is_numeric($this->selectedTab) && !empty($channel = $this->channelRepository->selectById($this->selectedTab, $uid))) {
|
||||
$condition = $this->getUserChannelConditions($channel, $uid);
|
||||
if (in_array($channel->circle, [-3, -4, -5])) {
|
||||
$table = SearchIndex::getSearchView();
|
||||
$condition = DBA::mergeConditions($condition, ['uid' => $uid]);
|
||||
$orders = ['-3' => 'created', '-4' => 'received', '-5' => 'commented'];
|
||||
$table = SearchIndex::getSearchView();
|
||||
$condition = DBA::mergeConditions($condition, ['uid' => $uid]);
|
||||
$orders = ['-3' => 'created', '-4' => 'received', '-5' => 'commented'];
|
||||
$this->order = $orders[$channel->circle];
|
||||
}
|
||||
}
|
||||
|
@ -421,10 +421,10 @@ class Timeline extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
$items = [];
|
||||
$fields = ['uri-id', 'owner-id', 'comments', 'activities'];
|
||||
$items = [];
|
||||
$fields = ['uri-id', 'owner-id', 'comments', 'activities'];
|
||||
$fields[] = $this->order;
|
||||
$result = $this->database->select($table, $fields, $condition, $params);
|
||||
$result = $this->database->select($table, $fields, $condition, $params);
|
||||
if ($this->database->errorNo()) {
|
||||
throw new \Exception($this->database->errorMessage(), $this->database->errorNo());
|
||||
}
|
||||
|
@ -691,16 +691,19 @@ class Timeline extends BaseModule
|
|||
$items = $this->selectItems();
|
||||
$key = '';
|
||||
|
||||
$maxpostperauthor = 0;
|
||||
if ($this->selectedTab == Community::LOCAL) {
|
||||
$maxpostperauthor = (int)$this->config->get('system', 'max_author_posts_community_page');
|
||||
$key = 'author-id';
|
||||
$key = 'author-id';
|
||||
} elseif ($this->selectedTab == Community::GLOBAL) {
|
||||
$maxpostperauthor = (int)$this->config->get('system', 'max_server_posts_community_page');
|
||||
$key = 'author-gsid';
|
||||
} else {
|
||||
$key = 'author-gsid';
|
||||
}
|
||||
|
||||
if ($maxpostperauthor === 0) {
|
||||
$this->setItemsSeenByCondition([
|
||||
'unseen' => true,
|
||||
'uid' => $this->session->getLocalUserId(),
|
||||
'unseen' => true,
|
||||
'uid' => $this->session->getLocalUserId(),
|
||||
'parent-uri-id' => array_column($items, 'uri-id')
|
||||
]);
|
||||
|
||||
|
@ -713,8 +716,8 @@ class Timeline extends BaseModule
|
|||
|
||||
while (count($selected_items) < $this->itemsPerPage && ++$count < 50 && count($items) > 0) {
|
||||
$maxposts = round((count($items) / $this->itemsPerPage) * $maxpostperauthor);
|
||||
$minId = $items[array_key_first($items)]['received'];
|
||||
$maxId = $items[array_key_last($items)]['received'];
|
||||
$minId = $items[array_key_first($items)]['received'];
|
||||
$maxId = $items[array_key_last($items)]['received'];
|
||||
|
||||
foreach ($items as $item) {
|
||||
$author_posts[$item[$key]][$item['uri-id']] = $item['received'];
|
||||
|
@ -799,7 +802,7 @@ class Timeline extends BaseModule
|
|||
}
|
||||
|
||||
$items = [];
|
||||
if ($this->selectedTab == Community::LOCAL) {
|
||||
if ($this->selectedTab == Community::LOCAL) {
|
||||
$result = Post::selectOriginThread(['uri-id', 'received', 'author-id', 'author-gsid'], $condition, $params);
|
||||
} else {
|
||||
$result = Post::selectThreadForUser($this->session->getLocalUserId() ?: 0, ['uri-id', 'received', 'author-id', 'author-gsid'], $condition, $params);
|
||||
|
|
|
@ -56,7 +56,7 @@ class SaveTag extends BaseModule
|
|||
|
||||
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
|
||||
echo Renderer::replaceMacros($tpl, [
|
||||
'$field' => ['term', $this->t("Save to Folder:"), '', '', $filetags, $this->t('- select -')],
|
||||
'$field' => ['term', $this->t("Folder:"), '', '', $filetags, $this->t('- select -')],
|
||||
'$submit' => $this->t('Save'),
|
||||
]);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use Friendica\App;
|
|||
use Friendica\App\Arguments;
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
|
||||
|
@ -31,6 +31,7 @@ use Psr\Log\LoggerInterface;
|
|||
*/
|
||||
class Friendica extends BaseModule
|
||||
{
|
||||
private AddonHelper $addonHelper;
|
||||
/** @var IManageConfigValues */
|
||||
private $config;
|
||||
/** @var IManageKeyValuePairs */
|
||||
|
@ -38,18 +39,19 @@ class Friendica extends BaseModule
|
|||
/** @var IHandleUserSessions */
|
||||
private $session;
|
||||
|
||||
public function __construct(IHandleUserSessions $session, IManageKeyValuePairs $keyValue, IManageConfigValues $config, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
public function __construct(AddonHelper $addonHelper, IHandleUserSessions $session, IManageKeyValuePairs $keyValue, IManageConfigValues $config, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->config = $config;
|
||||
$this->keyValue = $keyValue;
|
||||
$this->session = $session;
|
||||
$this->config = $config;
|
||||
$this->keyValue = $keyValue;
|
||||
$this->session = $session;
|
||||
$this->addonHelper = $addonHelper;
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
$visibleAddonList = Addon::getVisibleList();
|
||||
$visibleAddonList = $this->addonHelper->getVisibleEnabledAddons();
|
||||
if (!empty($visibleAddonList)) {
|
||||
|
||||
$sorted = $visibleAddonList;
|
||||
|
@ -83,8 +85,8 @@ class Friendica extends BaseModule
|
|||
|
||||
if (!empty($blockList) && ($this->config->get('blocklist', 'public') || $this->session->isAuthenticated())) {
|
||||
$blocked = [
|
||||
'title' => $this->t('On this server the following remote servers are blocked.'),
|
||||
'header' => [
|
||||
'title' => $this->t('On this server the following remote servers are blocked.'),
|
||||
'header' => [
|
||||
$this->t('Blocked domain'),
|
||||
$this->t('Reason for the block'),
|
||||
],
|
||||
|
@ -102,11 +104,13 @@ class Friendica extends BaseModule
|
|||
$tpl = Renderer::getMarkupTemplate('friendica.tpl');
|
||||
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'about' => $this->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.',
|
||||
'about' => $this->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>' . App::VERSION . '</strong>',
|
||||
$this->baseUrl,
|
||||
'<strong>' . $this->config->get('system', 'build') . '/' . DB_UPDATE_VERSION . '</strong>',
|
||||
'<strong>' . $this->keyValue->get('post_update_version') . '/' . PostUpdate::VERSION . '</strong>'),
|
||||
'<strong>' . $this->keyValue->get('post_update_version') . '/' . PostUpdate::VERSION . '</strong>'
|
||||
),
|
||||
'friendica' => $this->t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.'),
|
||||
'bugs' => $this->t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">' . $this->t('the bugtracker at github') . '</a>',
|
||||
'info' => $this->t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca'),
|
||||
|
@ -148,7 +152,7 @@ class Friendica extends BaseModule
|
|||
$register_policy = $register_policies[$register_policy_int];
|
||||
}
|
||||
|
||||
$admin = [];
|
||||
$admin = [];
|
||||
$administrator = User::getFirstAdmin(['username', 'nickname']);
|
||||
if (!empty($administrator)) {
|
||||
$admin = [
|
||||
|
@ -157,11 +161,11 @@ class Friendica extends BaseModule
|
|||
];
|
||||
}
|
||||
|
||||
$visible_addons = Addon::getVisibleList();
|
||||
$visible_addons = $this->addonHelper->getVisibleEnabledAddons();
|
||||
|
||||
$this->config->reload();
|
||||
$locked_features = [];
|
||||
$featureLocks = $this->config->get('config', 'feature_lock');
|
||||
$featureLocks = $this->config->get('config', 'feature_lock');
|
||||
if (isset($featureLocks)) {
|
||||
foreach ($featureLocks as $feature => $lock) {
|
||||
if ($feature === 'config_loaded') {
|
||||
|
|
|
@ -235,22 +235,22 @@ class Install extends BaseModule
|
|||
'$system_url' => $this->configCache->get('system', 'url'),
|
||||
'$dbhost' => ['database-hostname',
|
||||
$this->t('Database Server Name'),
|
||||
$this->configCache->get('database', 'hostname'),
|
||||
$this->configCache->get('database', 'hostname') ? : getenv('MYSQL_HOST') ? : 'localhost',
|
||||
'',
|
||||
$this->t('Required')],
|
||||
'$dbuser' => ['database-username',
|
||||
$this->t('Database Login Name'),
|
||||
$this->configCache->get('database', 'username'),
|
||||
$this->configCache->get('database', 'username') ? : getenv('MYSQL_USER') ? : '',
|
||||
'',
|
||||
$this->t('Required'),
|
||||
'autofocus'],
|
||||
'$dbpass' => ['database-password',
|
||||
$this->t('Database Login Password'),
|
||||
$this->configCache->get('database', 'password'),
|
||||
$this->configCache->get('database', 'password') ? : getenv('MYSQL_PASSWORD') ? : '',
|
||||
$this->t("For security reasons the password must not be empty"),
|
||||
$this->t('Required')],
|
||||
'$dbdata' => ['database-database',
|
||||
$this->t('Database Name'),
|
||||
$this->t('Database Name') ? : getenv('MYSQL_DATABASE') ? : '',
|
||||
$this->configCache->get('database', 'database'),
|
||||
'',
|
||||
$this->t('Required')],
|
||||
|
|
|
@ -99,7 +99,7 @@ abstract class BaseUsers extends BaseModeration
|
|||
Hook::callAll('moderation_users_tabs', $tabs_arr);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
return Renderer::replaceMacros($tpl, ['$tabs' => $tabs_arr['tabs']]);
|
||||
return Renderer::replaceMacros($tpl, ['$tabs' => $tabs_arr['tabs'], '$more' => $this->t('More')]);
|
||||
}
|
||||
|
||||
protected function setupUserCallback(): \Closure
|
||||
|
|
|
@ -124,8 +124,8 @@ class Active extends BaseUsers
|
|||
*/
|
||||
private function processGetActions(): void
|
||||
{
|
||||
$action = (string)$this->parameters['action'] ?? '';
|
||||
$uid = (int)$this->parameters['uid'] ?? 0;
|
||||
$action = (string) ($this->parameters['action'] ?? '');
|
||||
$uid = (int) ($this->parameters['uid'] ?? 0);
|
||||
|
||||
if ($uid === 0) {
|
||||
return;
|
||||
|
@ -150,6 +150,7 @@ class Active extends BaseUsers
|
|||
}
|
||||
|
||||
$this->baseUrl->redirect('moderation/users/active');
|
||||
// no break
|
||||
case 'block':
|
||||
self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't');
|
||||
User::block($uid);
|
||||
|
|
|
@ -123,8 +123,8 @@ class Blocked extends BaseUsers
|
|||
*/
|
||||
private function processGetActions(): void
|
||||
{
|
||||
$action = (string)$this->parameters['action'] ?? '';
|
||||
$uid = (int)$this->parameters['uid'] ?? 0;
|
||||
$action = (string) ($this->parameters['action'] ?? '');
|
||||
$uid = (int) ($this->parameters['uid'] ?? 0);
|
||||
|
||||
if ($uid === 0) {
|
||||
return;
|
||||
|
@ -148,6 +148,7 @@ class Blocked extends BaseUsers
|
|||
$this->systemMessages->addNotice($this->t('You can\'t remove yourself'));
|
||||
}
|
||||
$this->baseUrl->redirect('moderation/users/blocked');
|
||||
// no break
|
||||
case 'unblock':
|
||||
self::checkFormSecurityTokenRedirectOnError('/moderation/users/blocked', 'moderation_users_blocked', 't');
|
||||
User::block($uid, false);
|
||||
|
|
|
@ -135,8 +135,8 @@ class Index extends BaseUsers
|
|||
*/
|
||||
private function processGetActions(): void
|
||||
{
|
||||
$action = (string) $this->parameters['action'] ?? '';
|
||||
$uid = (int) $this->parameters['uid'] ?? 0;
|
||||
$action = (string) ($this->parameters['action'] ?? '');
|
||||
$uid = (int) ($this->parameters['uid'] ?? 0);
|
||||
|
||||
if ($uid === 0) {
|
||||
return;
|
||||
|
@ -161,11 +161,13 @@ class Index extends BaseUsers
|
|||
}
|
||||
|
||||
$this->baseUrl->redirect('moderation/users');
|
||||
// no break
|
||||
case 'block':
|
||||
self::checkFormSecurityTokenRedirectOnError('moderation/users', 'moderation_users', 't');
|
||||
User::block($uid);
|
||||
$this->systemMessages->addNotice($this->t('User "%s" blocked', $user['username']));
|
||||
$this->baseUrl->redirect('moderation/users');
|
||||
// no break
|
||||
case 'unblock':
|
||||
self::checkFormSecurityTokenRedirectOnError('moderation/users', 'moderation_users', 't');
|
||||
User::block($uid, false);
|
||||
|
|
|
@ -148,8 +148,8 @@ class Register extends BaseModule
|
|||
'$fillext' => $fillext,
|
||||
'$oidlabel' => $oidlabel,
|
||||
'$openid' => $openid_url,
|
||||
'$namelabel' => DI::l10n()->t('Your Display Name (as you would like it to be displayed on this system'),
|
||||
'$addrlabel' => DI::l10n()->t('Your Email Address: (Initial information will be send there, so this has to be an existing address.)'),
|
||||
'$namelabel' => DI::l10n()->t('Your Display Name (as you would like it to be displayed on this system):'),
|
||||
'$addrlabel' => DI::l10n()->t('Your Email Address (initial information will be sent there, so this must be a valid address):'),
|
||||
'$addrlabel2' => DI::l10n()->t('Please repeat your e-mail address:'),
|
||||
'$ask_password' => $ask_password,
|
||||
'$password1' => ['password1', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Leave empty for an auto generated password.')],
|
||||
|
|
|
@ -127,7 +127,7 @@ class Channels extends BaseSettings
|
|||
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
|
||||
$user = User::getById($uid, ['account-type']);
|
||||
$user = User::getById($uid, ['account-type']);
|
||||
$account_type = $user['account-type'];
|
||||
|
||||
if (in_array($account_type, [User::ACCOUNT_TYPE_COMMUNITY, User::ACCOUNT_TYPE_RELAY])) {
|
||||
|
@ -151,7 +151,7 @@ class Channels extends BaseSettings
|
|||
$circles[$circle['id']] = $circle['name'];
|
||||
}
|
||||
|
||||
$languages = $this->l10n->getLanguageCodes(true);
|
||||
$languages = $this->l10n->getLanguageCodes(true);
|
||||
$channel_languages = User::getWantedLanguages($uid);
|
||||
|
||||
$channels = [];
|
||||
|
@ -185,7 +185,7 @@ class Channels extends BaseSettings
|
|||
'image' => ["image[$channel->code]", $this->t("Images"), $channel->mediaType & 1],
|
||||
'video' => ["video[$channel->code]", $this->t("Videos"), $channel->mediaType & 2],
|
||||
'audio' => ["audio[$channel->code]", $this->t("Audio"), $channel->mediaType & 4],
|
||||
'languages' => ["languages[$channel->code][]", $this->t('Languages'), $channel->languages ?? $channel_languages, $this->t('Select all languages that you want to see in this channel.'), $languages, 'multiple'],
|
||||
'languages' => ["languages[$channel->code][]", $this->t('Languages'), $channel->languages ?? $channel_languages, $this->t('Select all languages that you want to see in this channel. "Unspecified" describes all posts for which no language information was detected (e.g. posts with just an image or too little text to be sure of the language). If you want to see all languages, you will need to select all items in the list.'), $languages, 'multiple'],
|
||||
'publish' => $publish,
|
||||
'delete' => ["delete[$channel->code]", $this->t("Delete channel") . ' (' . $channel->label . ')', false, $this->t("Check to delete this entry from the channel list")]
|
||||
];
|
||||
|
|
|
@ -103,13 +103,7 @@ class Display extends BaseSettings
|
|||
$show_page_drop = (bool)$request['show_page_drop'];
|
||||
$display_eventlist = (bool)$request['display_eventlist'];
|
||||
$preview_mode = (int)$request['preview_mode'];
|
||||
$browser_update = (int)$request['browser_update'];
|
||||
if ($browser_update != -1) {
|
||||
$browser_update = $browser_update * 1000;
|
||||
if ($browser_update < 10000) {
|
||||
$browser_update = 10000;
|
||||
}
|
||||
}
|
||||
$update_content = (int)$request['update_content'];
|
||||
|
||||
$enabled_timelines = [];
|
||||
foreach ($enable as $code => $enabled) {
|
||||
|
@ -144,7 +138,7 @@ class Display extends BaseSettings
|
|||
|
||||
$this->pConfig->set($uid, 'system', 'itemspage_network', $itemspage_network);
|
||||
$this->pConfig->set($uid, 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
|
||||
$this->pConfig->set($uid, 'system', 'update_interval', $browser_update);
|
||||
$this->pConfig->set($uid, 'system', 'update_content', $update_content);
|
||||
$this->pConfig->set($uid, 'system', 'no_smilies', !$enable_smile);
|
||||
$this->pConfig->set($uid, 'system', 'infinite_scroll', $infinite_scroll);
|
||||
$this->pConfig->set($uid, 'system', 'no_smart_threading', !$enable_smart_threading);
|
||||
|
@ -208,7 +202,7 @@ class Display extends BaseSettings
|
|||
|
||||
$allowed_themes = Theme::getAllowedList();
|
||||
|
||||
$themes = [];
|
||||
$themes = [];
|
||||
$mobile_themes = ['---' => $this->t('No special theme for mobile devices')];
|
||||
foreach ($allowed_themes as $theme) {
|
||||
$is_experimental = file_exists('view/theme/' . $theme . '/experimental');
|
||||
|
@ -233,29 +227,25 @@ class Display extends BaseSettings
|
|||
$theme_selected = $user['theme'] ?: $default_theme;
|
||||
$mobile_theme_selected = $this->session->get('mobile-theme', $default_mobile_theme);
|
||||
|
||||
$itemspage_network = intval($this->pConfig->get($uid, 'system', 'itemspage_network'));
|
||||
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : $this->config->get('system', 'itemspage_network'));
|
||||
$itemspage_network = intval($this->pConfig->get($uid, 'system', 'itemspage_network'));
|
||||
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : $this->config->get('system', 'itemspage_network'));
|
||||
$itemspage_mobile_network = intval($this->pConfig->get($uid, 'system', 'itemspage_mobile_network'));
|
||||
$itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : $this->config->get('system', 'itemspage_network_mobile'));
|
||||
|
||||
$browser_update = intval($this->pConfig->get($uid, 'system', 'update_interval'));
|
||||
if ($browser_update != -1) {
|
||||
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
|
||||
}
|
||||
|
||||
$update_content = $this->pConfig->get($uid, 'system', 'update_content') ?? false;
|
||||
$enable_smile = !$this->pConfig->get($uid, 'system', 'no_smilies', false);
|
||||
$infinite_scroll = $this->pConfig->get($uid, 'system', 'infinite_scroll', false);
|
||||
$infinite_scroll = $this->pConfig->get($uid, 'system', 'infinite_scroll', false);
|
||||
$enable_smart_threading = !$this->pConfig->get($uid, 'system', 'no_smart_threading', false);
|
||||
$enable_dislike = !$this->pConfig->get($uid, 'system', 'hide_dislike', false);
|
||||
$display_resharer = $this->pConfig->get($uid, 'system', 'display_resharer', false);
|
||||
$stay_local = $this->pConfig->get($uid, 'system', 'stay_local', false);
|
||||
$show_page_drop = $this->pConfig->get($uid, 'system', 'show_page_drop', true);
|
||||
$display_eventlist = $this->pConfig->get($uid, 'system', 'display_eventlist', true);
|
||||
$display_resharer = $this->pConfig->get($uid, 'system', 'display_resharer', false);
|
||||
$stay_local = $this->pConfig->get($uid, 'system', 'stay_local', false);
|
||||
$show_page_drop = $this->pConfig->get($uid, 'system', 'show_page_drop', true);
|
||||
$display_eventlist = $this->pConfig->get($uid, 'system', 'display_eventlist', true);
|
||||
|
||||
$hide_empty_descriptions = $this->pConfig->get($uid, 'accessibility', 'hide_empty_descriptions', false);
|
||||
$hide_custom_emojis = $this->pConfig->get($uid, 'accessibility', 'hide_custom_emojis', false);
|
||||
$platform_icon_style = $this->pConfig->get($uid, 'accessibility', 'platform_icon_style', ContactSelector::SVG_COLOR_BLACK);
|
||||
$platform_icon_styles = [
|
||||
$hide_empty_descriptions = $this->pConfig->get($uid, 'accessibility', 'hide_empty_descriptions', false);
|
||||
$hide_custom_emojis = $this->pConfig->get($uid, 'accessibility', 'hide_custom_emojis', false);
|
||||
$platform_icon_style = $this->pConfig->get($uid, 'accessibility', 'platform_icon_style', ContactSelector::SVG_COLOR_BLACK);
|
||||
$platform_icon_styles = [
|
||||
ContactSelector::SVG_DISABLED => $this->t('Disabled'),
|
||||
ContactSelector::SVG_COLOR_BLACK => $this->t('Color/Black'),
|
||||
ContactSelector::SVG_BLACK => $this->t('Black'),
|
||||
|
@ -263,7 +253,7 @@ class Display extends BaseSettings
|
|||
ContactSelector::SVG_WHITE => $this->t('White'),
|
||||
];
|
||||
|
||||
$preview_mode = $this->pConfig->get($uid, 'system', 'preview_mode', BBCode::PREVIEW_LARGE);
|
||||
$preview_mode = $this->pConfig->get($uid, 'system', 'preview_mode', BBCode::PREVIEW_LARGE);
|
||||
$preview_modes = [
|
||||
BBCode::PREVIEW_NONE => $this->t('No preview'),
|
||||
BBCode::PREVIEW_NO_IMAGE => $this->t('No image'),
|
||||
|
@ -273,16 +263,16 @@ class Display extends BaseSettings
|
|||
|
||||
$bookmarked_timelines = $this->pConfig->get($uid, 'system', 'network_timelines', $this->getAvailableTimelines($uid, true)->column('code'));
|
||||
$enabled_timelines = $this->pConfig->get($uid, 'system', 'enabled_timelines', $this->getAvailableTimelines($uid, false)->column('code'));
|
||||
$channel_languages = User::getWantedLanguages($uid);
|
||||
$languages = $this->l10n->getLanguageCodes(true);
|
||||
$channel_languages = User::getWantedLanguages($uid);
|
||||
$languages = $this->l10n->getLanguageCodes(true);
|
||||
|
||||
$timelines = [];
|
||||
foreach ($this->getAvailableTimelines($uid) as $timeline) {
|
||||
$timelines[] = [
|
||||
'label' => $timeline->label,
|
||||
'description' => $timeline->description,
|
||||
'enable' => ["enable[{$timeline->code}]", '', in_array($timeline->code, $enabled_timelines)],
|
||||
'bookmark' => ["bookmark[{$timeline->code}]", '', in_array($timeline->code, $bookmarked_timelines)],
|
||||
'label' => $timeline->label,
|
||||
'description' => $timeline->description,
|
||||
'enable' => ["enable[{$timeline->code}]", '', in_array($timeline->code, $enabled_timelines)],
|
||||
'bookmark' => ["bookmark[{$timeline->code}]", '', in_array($timeline->code, $bookmarked_timelines)],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -326,14 +316,14 @@ class Display extends BaseSettings
|
|||
'$form_security_token' => self::getFormSecurityToken('settings_display'),
|
||||
'$uid' => $uid,
|
||||
|
||||
'$theme' => ['theme', $this->t('Display Theme:'), $theme_selected, '', $themes, true],
|
||||
'$mobile_theme' => ['mobile_theme', $this->t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false],
|
||||
'$theme' => ['theme', $this->t('Display Theme:'), $theme_selected, '', $themes, true],
|
||||
'$mobile_theme' => ['mobile_theme', $this->t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false],
|
||||
'$theme_config' => $theme_config,
|
||||
|
||||
'$itemspage_network' => ['itemspage_network', $this->t('Number of items to display per page:'), $itemspage_network, $this->t('Maximum of 100 items')],
|
||||
'$itemspage_mobile_network' => ['itemspage_mobile_network', $this->t('Number of items to display per page when viewed from mobile device:'), $itemspage_mobile_network, $this->t('Maximum of 100 items')],
|
||||
'$ajaxint' => ['browser_update', $this->t('Update browser every xx seconds'), $browser_update, $this->t('Minimum of 10 seconds. Enter -1 to disable it.')],
|
||||
'$enable_smile' => ['enable_smile', $this->t('Display emoticons'), $enable_smile, $this->t('When enabled, emoticons are replaced with matching symbols.')],
|
||||
'$update_content' => ['update_content', $this->t('Regularly update the page content'), $update_content, $this->t('When enabled, new content on network, community and channels are added on top.')],
|
||||
'$enable_smile' => ['enable_smile', $this->t('Display emoticons'), $enable_smile, $this->t('When enabled, emoticons are replaced with matching symbols.')],
|
||||
'$infinite_scroll' => ['infinite_scroll', $this->t('Infinite scroll'), $infinite_scroll, $this->t('Automatic fetch new items when reaching the page end.')],
|
||||
'$enable_smart_threading' => ['enable_smart_threading', $this->t('Enable Smart Threading'), $enable_smart_threading, $this->t('Enable the automatic suppression of extraneous thread indentation.')],
|
||||
'$enable_dislike' => ['enable_dislike', $this->t('Display the Dislike feature'), $enable_dislike, $this->t('Display the Dislike button and dislike reactions on posts and comments.')],
|
||||
|
@ -353,7 +343,7 @@ class Display extends BaseSettings
|
|||
'$timelines' => $timelines,
|
||||
'$timeline_explanation' => $this->t('Enable timelines that you want to see in the channels widget. Bookmark timelines that you want to see in the top menu.'),
|
||||
|
||||
'$channel_languages' => ['channel_languages[]', $this->t('Channel languages:'), $channel_languages, $this->t('Select all languages that you want to see in your channels.'), $languages, 'multiple'],
|
||||
'$channel_languages' => ['channel_languages[]', $this->t('Channel languages:'), $channel_languages, $this->t('Select all the languages you want to see in your channels. "Unspecified" describes all posts for which no language information was detected (e.g. posts with just an image or too little text to be sure of the language). If you want to see all languages, you will need to select all items in the list.'), $languages, 'multiple'],
|
||||
|
||||
'$first_day_of_week' => ['first_day_of_week', $this->t('Beginning of week:'), $first_day_of_week, '', $weekdays, false],
|
||||
'$calendar_default_view' => ['calendar_default_view', $this->t('Default calendar view:'), $calendar_default_view, '', $calendarViews, false],
|
||||
|
|
|
@ -45,19 +45,16 @@ class Display extends DisplayModule
|
|||
$parentUriId = $item['parent-uri-id'];
|
||||
|
||||
if (empty($force)) {
|
||||
$browserUpdate = intval($this->pConfig->get($profileUid, 'system', 'update_interval') ?? 40000);
|
||||
if ($browserUpdate >= 1000) {
|
||||
$updateDate = date(DateTimeFormat::MYSQL, time() - ($browserUpdate * 2 / 1000));
|
||||
if ($this->pConfig->get($profileUid, 'system', 'update_content')) {
|
||||
$updateDate = date(DateTimeFormat::MYSQL, time() - 120);
|
||||
if (!Post::exists([
|
||||
"`parent-uri-id` = ? AND `uid` IN (?, ?) AND `received` > ?",
|
||||
$parentUriId, 0,
|
||||
$profileUid, $updateDate])) {
|
||||
$this->logger->debug('No updated content. Ending process',
|
||||
['uri-id' => $uriId, 'uid' => $profileUid, 'updated' => $updateDate]);
|
||||
$this->logger->debug('No updated content. Ending process', ['uri-id' => $uriId, 'uid' => $profileUid, 'updated' => $updateDate]);
|
||||
return '';
|
||||
} else {
|
||||
$this->logger->debug('Updated content found.',
|
||||
['uri-id' => $uriId, 'uid' => $profileUid, 'updated' => $updateDate]);
|
||||
$this->logger->debug('Updated content found.', ['uri-id' => $uriId, 'uid' => $profileUid, 'updated' => $updateDate]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -15,7 +15,6 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
|
|||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Factory\Api\Mastodon\Notification as NotificationFactory;
|
||||
|
@ -205,7 +204,7 @@ class Notify extends BaseRepository
|
|||
* @return bool
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
function createFromArray($params)
|
||||
public function createFromArray($params)
|
||||
{
|
||||
/** @var string the common prefix of a notification subject */
|
||||
$subjectPrefix = $this->l10n->t('[Friendica:Notify]');
|
||||
|
@ -217,10 +216,10 @@ class Notify extends BaseRepository
|
|||
|
||||
// Ensure that the important fields are set at any time
|
||||
$fields = ['nickname', 'account-type', 'notify-flags', 'language', 'username', 'email', 'account_removed', 'account_expired'];
|
||||
$user = DBA::selectFirst('user', $fields, ['uid' => $params['uid']]);
|
||||
$user = DBA::selectFirst('user', $fields, ['uid' => $params['uid']]);
|
||||
|
||||
if (!DBA::isResult($user)) {
|
||||
$this->logger->error('Unknown user', ['uid' => $params['uid']]);
|
||||
$this->logger->error('Unknown user', ['uid' => $params['uid']]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -244,13 +243,13 @@ class Notify extends BaseRepository
|
|||
if (!empty($params['cid'])) {
|
||||
$contact = Model\Contact::getById($params['cid'], ['url', 'name', 'photo']);
|
||||
if (DBA::isResult($contact)) {
|
||||
$params['source_link'] = $contact['url'];
|
||||
$params['source_name'] = $contact['name'];
|
||||
$params['source_link'] = $contact['url'];
|
||||
$params['source_name'] = $contact['name'];
|
||||
$params['source_photo'] = $contact['photo'];
|
||||
}
|
||||
}
|
||||
|
||||
$siteurl = (string)$this->baseUrl;
|
||||
$siteurl = (string)$this->baseUrl;
|
||||
$sitename = $this->config->get('config', 'sitename');
|
||||
|
||||
// with $params['show_in_notification_page'] == false, the notification isn't inserted into
|
||||
|
@ -259,9 +258,9 @@ class Notify extends BaseRepository
|
|||
$show_in_notification_page = isset($params['show_in_notification_page']) ? $params['show_in_notification_page'] : true;
|
||||
|
||||
$title = $params['item']['title'] ?? '';
|
||||
$body = $params['item']['body'] ?? '';
|
||||
$body = $params['item']['body'] ?? '';
|
||||
|
||||
$parent_id = $params['item']['parent'] ?? 0;
|
||||
$parent_id = $params['item']['parent'] ?? 0;
|
||||
$parent_uri_id = $params['item']['parent-uri-id'] ?? 0;
|
||||
|
||||
$epreamble = '';
|
||||
|
@ -278,10 +277,10 @@ class Notify extends BaseRepository
|
|||
|
||||
$subject = $l10n->t('%s New mail received at %s', $subjectPrefix, $sitename);
|
||||
|
||||
$preamble = $l10n->t('%1$s sent you a new private message at %2$s.', $params['source_name'], $sitename);
|
||||
$preamble = $l10n->t('%1$s sent you a new private message at %2$s.', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t('%1$s sent you %2$s.', '[url='.$params['source_link'].']'.$params['source_name'].'[/url]', '[url=' . $itemlink . ']' . $l10n->t('a private message').'[/url]');
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to view and/or reply to your private messages.');
|
||||
$sitelink = $l10n->t('Please visit %s to view and/or reply to your private messages.');
|
||||
$tsitelink = sprintf($sitelink, $itemlink);
|
||||
$hsitelink = sprintf($sitelink, '<a href="' . $itemlink . '">' . $sitename . '</a>');
|
||||
|
||||
|
@ -302,7 +301,7 @@ class Notify extends BaseRepository
|
|||
|
||||
$item_post_type = Model\Item::postType($item, $l10n);
|
||||
|
||||
$body = BBCode::toPlaintext($item['body'], false);
|
||||
$body = BBCode::toPlaintext($item['body'], false);
|
||||
$title = Plaintext::shorten($body, 70);
|
||||
if (!empty($title)) {
|
||||
$title = '"' . trim(str_replace("\n", " ", $title)) . '"';
|
||||
|
@ -311,16 +310,16 @@ class Notify extends BaseRepository
|
|||
// First go for the general message
|
||||
|
||||
// "George Bull's post"
|
||||
$message = $l10n->t('%1$s commented on %2$s\'s %3$s %4$s');
|
||||
$message = $l10n->t('%1$s commented on %2$s\'s %3$s %4$s');
|
||||
$dest_str = sprintf($message, $params['source_name'], $item['author-name'], $item_post_type, $title);
|
||||
|
||||
// "your post"
|
||||
if ($item['wall']) {
|
||||
$message = $l10n->t('%1$s commented on your %2$s %3$s');
|
||||
$message = $l10n->t('%1$s commented on your %2$s %3$s');
|
||||
$dest_str = sprintf($message, $params['source_name'], $item_post_type, $title);
|
||||
// "their post"
|
||||
// "their post"
|
||||
} elseif ($item['author-link'] == $params['source_link']) {
|
||||
$message = $l10n->t('%1$s commented on their %2$s %3$s');
|
||||
$message = $l10n->t('%1$s commented on their %2$s %3$s');
|
||||
$dest_str = sprintf($message, $params['source_name'], $item_post_type, $title);
|
||||
}
|
||||
|
||||
|
@ -330,40 +329,42 @@ class Notify extends BaseRepository
|
|||
|
||||
$epreamble = $dest_str;
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to view and/or reply to the conversation.');
|
||||
$sitelink = $l10n->t('Please visit %s to view and/or reply to the conversation.');
|
||||
$tsitelink = sprintf($sitelink, $siteurl);
|
||||
$hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
|
||||
$itemlink = $params['link'];
|
||||
$itemlink = $params['link'];
|
||||
break;
|
||||
|
||||
case Model\Notification\Type::WALL:
|
||||
$subject = $l10n->t('%s %s posted to your profile wall', $subjectPrefix, $params['source_name']);
|
||||
|
||||
$preamble = $l10n->t('%1$s posted to your profile wall at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t('%1$s posted to [url=%2$s]your wall[/url]',
|
||||
$preamble = $l10n->t('%1$s posted to your profile wall at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t(
|
||||
'%1$s posted to [url=%2$s]your wall[/url]',
|
||||
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
|
||||
$params['link']
|
||||
);
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to view and/or reply to the conversation.');
|
||||
$sitelink = $l10n->t('Please visit %s to view and/or reply to the conversation.');
|
||||
$tsitelink = sprintf($sitelink, $siteurl);
|
||||
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
|
||||
$itemlink = $params['link'];
|
||||
$itemlink = $params['link'];
|
||||
break;
|
||||
|
||||
case Model\Notification\Type::INTRO:
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('%s Introduction received', $subjectPrefix);
|
||||
$subject = $l10n->t('%s Introduction received', $subjectPrefix);
|
||||
|
||||
$preamble = $l10n->t('You\'ve received an introduction from \'%1$s\' at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.',
|
||||
$preamble = $l10n->t('You\'ve received an introduction from \'%1$s\' at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t(
|
||||
'You\'ve received [url=%1$s]an introduction[/url] from %2$s.',
|
||||
$itemlink,
|
||||
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
|
||||
);
|
||||
|
||||
$body = $l10n->t('You may visit their profile at %s', $params['source_link']);
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to approve or reject the introduction.');
|
||||
$sitelink = $l10n->t('Please visit %s to approve or reject the introduction.');
|
||||
$tsitelink = sprintf($sitelink, $siteurl);
|
||||
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
|
||||
|
||||
|
@ -372,8 +373,9 @@ class Notify extends BaseRepository
|
|||
// someone started to share with user (mostly OStatus)
|
||||
$subject = $l10n->t('%s A new person is sharing with you', $subjectPrefix);
|
||||
|
||||
$preamble = $l10n->t('%1$s is sharing with you at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t('%1$s is sharing with you at %2$s',
|
||||
$preamble = $l10n->t('%1$s is sharing with you at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t(
|
||||
'%1$s is sharing with you at %2$s',
|
||||
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
|
||||
$sitename
|
||||
);
|
||||
|
@ -382,8 +384,9 @@ class Notify extends BaseRepository
|
|||
// someone started to follow the user (mostly OStatus)
|
||||
$subject = $l10n->t('%s You have a new follower', $subjectPrefix);
|
||||
|
||||
$preamble = $l10n->t('You have a new follower at %2$s : %1$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t('You have a new follower at %2$s : %1$s',
|
||||
$preamble = $l10n->t('You have a new follower at %2$s : %1$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t(
|
||||
'You have a new follower at %2$s : %1$s',
|
||||
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
|
||||
$sitename
|
||||
);
|
||||
|
@ -395,11 +398,12 @@ class Notify extends BaseRepository
|
|||
break;
|
||||
|
||||
case Model\Notification\Type::SUGGEST:
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('%s Friend suggestion received', $subjectPrefix);
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('%s Friend suggestion received', $subjectPrefix);
|
||||
|
||||
$preamble = $l10n->t('You\'ve received a friend suggestion from \'%1$s\' at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.',
|
||||
$preamble = $l10n->t('You\'ve received a friend suggestion from \'%1$s\' at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t(
|
||||
'You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.',
|
||||
$itemlink,
|
||||
'[url='.$params['item']['url'].']'.$params['item']['name'].'[/url]',
|
||||
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
|
||||
|
@ -409,42 +413,44 @@ class Notify extends BaseRepository
|
|||
$body .= $l10n->t('Photo:').' '.$params['item']['photo']."\n";
|
||||
$body .= $l10n->t('You may visit their profile at %s', $params['item']['url']);
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to approve or reject the suggestion.');
|
||||
$sitelink = $l10n->t('Please visit %s to approve or reject the suggestion.');
|
||||
$tsitelink = sprintf($sitelink, $siteurl);
|
||||
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
|
||||
break;
|
||||
|
||||
case Model\Notification\Type::CONFIRM:
|
||||
if ($params['verb'] == Activity::FRIEND) { // mutual connection
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('%s Connection accepted', $subjectPrefix);
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('%s Connection accepted', $subjectPrefix);
|
||||
|
||||
$preamble = $l10n->t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t('%2$s has accepted your [url=%1$s]connection request[/url].',
|
||||
$preamble = $l10n->t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t(
|
||||
'%2$s has accepted your [url=%1$s]connection request[/url].',
|
||||
$itemlink,
|
||||
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
|
||||
);
|
||||
|
||||
$body = $l10n->t('You are now mutual friends and may exchange status updates, photos, and email without restriction.');
|
||||
$body = $l10n->t('You are now mutual friends and may exchange status updates, photos, and email without restriction.');
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s if you wish to make any changes to this relationship.');
|
||||
$sitelink = $l10n->t('Please visit %s if you wish to make any changes to this relationship.');
|
||||
$tsitelink = sprintf($sitelink, $siteurl);
|
||||
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
|
||||
} else { // ACTIVITY_FOLLOW
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('%s Connection accepted', $subjectPrefix);
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('%s Connection accepted', $subjectPrefix);
|
||||
|
||||
$preamble = $l10n->t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t('%2$s has accepted your [url=%1$s]connection request[/url].',
|
||||
$preamble = $l10n->t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t(
|
||||
'%2$s has accepted your [url=%1$s]connection request[/url].',
|
||||
$itemlink,
|
||||
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
|
||||
);
|
||||
|
||||
$body = $l10n->t('\'%1$s\' has chosen to accept you a fan, which restricts some forms of communication - such as private messaging and some profile interactions. If this is a celebrity or community page, these settings were applied automatically.', $params['source_name']);
|
||||
$body = $l10n->t('\'%1$s\' has chosen to accept you a fan, which restricts some forms of communication - such as private messaging and some profile interactions. If this is a celebrity or community page, these settings were applied automatically.', $params['source_name']);
|
||||
$body .= "\n\n";
|
||||
$body .= $l10n->t('\'%1$s\' may choose to extend this into a two-way or more permissive relationship in the future.', $params['source_name']);
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s if you wish to make any changes to this relationship.');
|
||||
$sitelink = $l10n->t('Please visit %s if you wish to make any changes to this relationship.');
|
||||
$tsitelink = sprintf($sitelink, $siteurl);
|
||||
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
|
||||
}
|
||||
|
@ -453,43 +459,49 @@ class Notify extends BaseRepository
|
|||
case Model\Notification\Type::SYSTEM:
|
||||
switch($params['event']) {
|
||||
case 'SYSTEM_REGISTER_REQUEST':
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('registration request');
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('registration request');
|
||||
|
||||
$preamble = $l10n->t('You\'ve received a registration request from \'%1$s\' at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.',
|
||||
$preamble = $l10n->t('You\'ve received a registration request from \'%1$s\' at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t(
|
||||
'You\'ve received a [url=%1$s]registration request[/url] from %2$s.',
|
||||
$itemlink,
|
||||
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
|
||||
);
|
||||
|
||||
$body = $l10n->t("Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)",
|
||||
$body = $l10n->t(
|
||||
"Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)",
|
||||
$params['source_name'],
|
||||
$siteurl, $params['source_mail'],
|
||||
$siteurl,
|
||||
$params['source_mail'],
|
||||
$params['source_nick']
|
||||
);
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to approve or reject the request.');
|
||||
$sitelink = $l10n->t('Please visit %s to approve or reject the request.');
|
||||
$tsitelink = sprintf($sitelink, $params['link']);
|
||||
$hsitelink = sprintf($sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
|
||||
break;
|
||||
|
||||
case 'SYSTEM_REGISTER_NEW':
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('new registration');
|
||||
$itemlink = $params['link'];
|
||||
$subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('new registration');
|
||||
|
||||
$preamble = $l10n->t('You\'ve received a new registration from \'%1$s\' at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t('You\'ve received a [url=%1$s]new registration[/url] from %2$s.',
|
||||
$preamble = $l10n->t('You\'ve received a new registration from \'%1$s\' at %2$s', $params['source_name'], $sitename);
|
||||
$epreamble = $l10n->t(
|
||||
'You\'ve received a [url=%1$s]new registration[/url] from %2$s.',
|
||||
$itemlink,
|
||||
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]'
|
||||
);
|
||||
|
||||
$body = $l10n->t("Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)",
|
||||
$body = $l10n->t(
|
||||
"Display Name: %s\nSite Location: %s\nLogin Name: %s (%s)",
|
||||
$params['source_name'],
|
||||
$siteurl, $params['source_mail'],
|
||||
$siteurl,
|
||||
$params['source_mail'],
|
||||
$params['source_nick']
|
||||
);
|
||||
|
||||
$sitelink = $l10n->t('Please visit %s to have a look at the new registration.');
|
||||
$sitelink = $l10n->t('Please visit %s to have a look at the new registration.');
|
||||
$tsitelink = sprintf($sitelink, $params['link']);
|
||||
$hsitelink = sprintf($sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
|
||||
break;
|
||||
|
@ -509,14 +521,14 @@ class Notify extends BaseRepository
|
|||
|
||||
private function storeAndSend(array $params, string $sitelink, string $tsitelink, string $hsitelink, string $title, string $subject, string $preamble, string $epreamble, string $body, string $itemlink, bool $show_in_notification_page): bool
|
||||
{
|
||||
$item_id = $params['item']['id'] ?? 0;
|
||||
$uri_id = $params['item']['uri-id'] ?? null;
|
||||
$parent_id = $params['item']['parent'] ?? 0;
|
||||
$item_id = $params['item']['id'] ?? 0;
|
||||
$uri_id = $params['item']['uri-id'] ?? null;
|
||||
$parent_id = $params['item']['parent'] ?? 0;
|
||||
$parent_uri_id = $params['item']['parent-uri-id'] ?? null;
|
||||
|
||||
// Ensure that the important fields are set at any time
|
||||
$fields = ['nickname', 'account_removed', 'account_expired'];
|
||||
$user = Model\User::getById($params['uid'], $fields);
|
||||
$user = Model\User::getById($params['uid'], $fields);
|
||||
if ($user['account_removed'] || $user['account_expired']) {
|
||||
return false;
|
||||
}
|
||||
|
@ -551,12 +563,12 @@ class Notify extends BaseRepository
|
|||
|
||||
Hook::callAll('enotify', $h);
|
||||
|
||||
$subject = $h['subject'];
|
||||
$subject = $h['subject'];
|
||||
|
||||
$preamble = $h['preamble'];
|
||||
$epreamble = $h['epreamble'];
|
||||
|
||||
$body = $h['body'];
|
||||
$body = $h['body'];
|
||||
|
||||
$tsitelink = $h['tsitelink'];
|
||||
$hsitelink = $h['hsitelink'];
|
||||
|
@ -587,7 +599,7 @@ class Notify extends BaseRepository
|
|||
$this->logger->notice('sending notification email');
|
||||
|
||||
if (isset($params['parent']) && (intval($params['parent']) != 0)) {
|
||||
$parent = Model\Post::selectFirst(['guid'], ['id' => $params['parent']]);
|
||||
$parent = Model\Post::selectFirst(['guid'], ['id' => $params['parent']]);
|
||||
$message_id = "<" . $parent['guid'] . "@" . gethostname() . ">";
|
||||
|
||||
// Is this the first email notification for this parent item and user?
|
||||
|
@ -595,13 +607,11 @@ class Notify extends BaseRepository
|
|||
$this->logger->info("notify_id:" . intval($notify_id) . ", parent: " . intval($params['parent']) . "uid: " . intval($params['uid']));
|
||||
|
||||
$fields = ['notify-id' => $notify_id, 'master-parent-uri-id' => $parent_uri_id,
|
||||
'receiver-uid' => $params['uid'], 'parent-item' => 0];
|
||||
'receiver-uid' => $params['uid'], 'parent-item' => 0];
|
||||
DBA::insert('notify-threads', $fields);
|
||||
|
||||
$emailBuilder->setHeader('Message-ID', $message_id);
|
||||
$log_msg = "No previous notification found for this parent:\n" .
|
||||
" parent: {$params['parent']}\n" . " uid : {$params['uid']}\n";
|
||||
$this->logger->info($log_msg);
|
||||
$this->logger->info('No previous notification found for this parent', ['parent' => $params['parent'], 'uid' => $params['uid']]);
|
||||
} else {
|
||||
// If not, just "follow" the thread.
|
||||
$emailBuilder->setHeader('References', $message_id);
|
||||
|
@ -614,8 +624,8 @@ class Notify extends BaseRepository
|
|||
'preamble' => $preamble,
|
||||
'type' => $params['type'],
|
||||
'parent' => $parent_id,
|
||||
'source_name' => $params['source_name'] ?? null,
|
||||
'source_link' => $params['source_link'] ?? null,
|
||||
'source_name' => $params['source_name'] ?? null,
|
||||
'source_link' => $params['source_link'] ?? null,
|
||||
'source_photo' => $params['source_photo'] ?? null,
|
||||
'uid' => $params['uid'],
|
||||
'hsitelink' => $hsitelink,
|
||||
|
@ -633,7 +643,7 @@ class Notify extends BaseRepository
|
|||
->withHeaders($datarray['headers'])
|
||||
->withRecipient($params['to_email'])
|
||||
->forUser([
|
||||
'uid' => $datarray['uid'],
|
||||
'uid' => $datarray['uid'],
|
||||
'language' => $params['language'],
|
||||
])
|
||||
->withNotification($datarray['subject'], $datarray['preamble'], $datarray['title'], $datarray['body'])
|
||||
|
@ -645,7 +655,8 @@ class Notify extends BaseRepository
|
|||
$emailBuilder->withPhoto(
|
||||
$datarray['source_photo'],
|
||||
$datarray['source_link'] ?? $sitelink,
|
||||
$datarray['source_name'] ?? $sitename);
|
||||
$datarray['source_name'] ?? $sitename
|
||||
);
|
||||
}
|
||||
|
||||
$email = $emailBuilder->build();
|
||||
|
@ -681,7 +692,7 @@ class Notify extends BaseRepository
|
|||
|
||||
// Fallback for the case when the notify type isn't set at all
|
||||
if (is_null($notify_type) && !in_array($type, [Notification::TYPE_RESHARE, Notification::TYPE_LIKE])) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!is_null($notify_type) && ($notify_type & $Notification->type)) {
|
||||
|
@ -700,7 +711,7 @@ class Notify extends BaseRepository
|
|||
return false;
|
||||
}
|
||||
|
||||
$params = [];
|
||||
$params = [];
|
||||
$params['verb'] = $Notification->verb;
|
||||
$params['uid'] = $Notification->uid;
|
||||
$params['otype'] = Model\Notification\ObjectType::ITEM;
|
||||
|
@ -725,9 +736,12 @@ class Notify extends BaseRepository
|
|||
$params['source_photo'] = $contact['photo'];
|
||||
}
|
||||
|
||||
$item = Model\Post::selectFirstForUser($Notification->uid, Model\Item::ITEM_FIELDLIST,
|
||||
['uid' => [0, $Notification->uid], 'uri-id' => $Notification->targetUriId, 'deleted' => false],
|
||||
['order' => ['uid' => true]]);
|
||||
$item = Model\Post::selectFirstForUser(
|
||||
$Notification->uid,
|
||||
Model\Item::ITEM_FIELDLIST,
|
||||
['uid' => [0, $Notification->uid], 'uri-id' => $Notification->targetUriId, 'deleted' => false],
|
||||
['order' => ['uid' => true]]
|
||||
);
|
||||
if (empty($item)) {
|
||||
$this->logger->info('Item not found', ['uri-id' => $Notification->targetUriId, 'type' => $Notification->type]);
|
||||
return false;
|
||||
|
@ -747,13 +761,13 @@ class Notify extends BaseRepository
|
|||
// Check to see if there was already a tag notify or comment notify for this post.
|
||||
// If so don't create a second notification
|
||||
$condition = ['type' => [Model\Notification\Type::TAG_SELF, Model\Notification\Type::COMMENT, Model\Notification\Type::SHARE],
|
||||
'link' => $params['link'], 'verb' => Activity::POST];
|
||||
'link' => $params['link'], 'verb' => Activity::POST];
|
||||
if ($this->existsForUser($Notification->uid, $condition)) {
|
||||
$this->logger->info('Duplicate found, quitting', $condition + ['uid' => $Notification->uid]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$body = BBCode::toPlaintext($item['body'], false);
|
||||
$body = BBCode::toPlaintext($item['body'], false);
|
||||
$title = Plaintext::shorten($body, 70);
|
||||
if (!empty($title)) {
|
||||
$title = '"' . trim(str_replace("\n", " ", $title)) . '"';
|
||||
|
|
|
@ -24,40 +24,24 @@ use Friendica\Object\Api\Mastodon\InstanceV2\Configuration;
|
|||
*/
|
||||
class Instance extends BaseDataTransferObject
|
||||
{
|
||||
/** @var string (URL) */
|
||||
protected $uri;
|
||||
/** @var string */
|
||||
protected $title;
|
||||
/** @var string */
|
||||
protected $short_description;
|
||||
/** @var string */
|
||||
protected $description;
|
||||
/** @var string */
|
||||
protected $email;
|
||||
/** @var string */
|
||||
protected $version;
|
||||
/** @var array */
|
||||
protected $urls;
|
||||
/** @var Stats */
|
||||
protected $stats;
|
||||
/** @var string|null This is meant as a server banner, default Mastodon "thumbnail" is 1600×620px */
|
||||
protected $thumbnail = null;
|
||||
/** @var array */
|
||||
protected $languages;
|
||||
/** @var int */
|
||||
protected $max_toot_chars;
|
||||
/** @var bool */
|
||||
protected $registrations;
|
||||
/** @var bool */
|
||||
protected $approval_required;
|
||||
/** @var bool */
|
||||
protected $invites_enabled;
|
||||
/** @var Configuration */
|
||||
protected $configuration;
|
||||
/** @var Account|null */
|
||||
protected $contact_account = null;
|
||||
/** @var array */
|
||||
protected $rules = [];
|
||||
protected string $uri;
|
||||
protected string $title;
|
||||
protected string $short_description;
|
||||
protected string $description;
|
||||
protected string $email;
|
||||
protected string $version;
|
||||
protected array $urls;
|
||||
protected Stats $stats;
|
||||
/** This is meant as a server banner, default Mastodon "thumbnail" is 1600×620px */
|
||||
protected ?string $thumbnail = null;
|
||||
protected array $languages;
|
||||
protected int $max_toot_chars;
|
||||
protected bool $registrations;
|
||||
protected bool $approval_required;
|
||||
protected bool $invites_enabled;
|
||||
protected Configuration $configuration;
|
||||
protected ?Account $contact_account = null;
|
||||
protected array $rules = [];
|
||||
|
||||
public function __construct(IManageConfigValues $config, BaseURL $baseUrl, Database $database, Configuration $configuration, ?Account $contact_account, array $rules)
|
||||
{
|
||||
|
@ -77,7 +61,7 @@ class Instance extends BaseDataTransferObject
|
|||
$this->approval_required = ($register_policy === Register::APPROVE);
|
||||
$this->invites_enabled = false;
|
||||
$this->configuration = $configuration;
|
||||
$this->contact_account = $contact_account ?? [];
|
||||
$this->contact_account = $contact_account;
|
||||
$this->rules = $rules;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -498,8 +498,10 @@ class Post
|
|||
}
|
||||
|
||||
$languages = [];
|
||||
$language = '';
|
||||
if (!empty($item['language'])) {
|
||||
$languages = DI::l10n()->t('Languages');
|
||||
$language = array_key_first(json_decode($item['language'], true));
|
||||
}
|
||||
|
||||
if (in_array($item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($item['network'], Protocol::FEDERATED)) {
|
||||
|
@ -553,6 +555,7 @@ class Post
|
|||
'title' => $item['title'],
|
||||
'summary' => $item['content-warning'],
|
||||
'localtime' => DateTimeFormat::local($item['created'], 'r'),
|
||||
'utc' => DateTimeFormat::utc($item['created']),
|
||||
'ago' => $item['app'] ? DI::l10n()->t('%s from %s', $ago, $item['app']) : $ago,
|
||||
'app' => $item['app'],
|
||||
'created' => $ago,
|
||||
|
@ -579,6 +582,7 @@ class Post
|
|||
'tagger' => $tagger,
|
||||
'filer' => $filer,
|
||||
'language' => $languages,
|
||||
'lang' => $language,
|
||||
'searchtext' => DI::l10n()->t('Search Text'),
|
||||
'drop' => $drop,
|
||||
'block' => $block,
|
||||
|
|
|
@ -906,15 +906,15 @@ class Processor
|
|||
if ($id) {
|
||||
$shared_item = Post::selectFirst(['uri-id'], ['id' => $id]);
|
||||
$item['quote-uri-id'] = $shared_item['uri-id'];
|
||||
DI::logger()->debug('Quote is found', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $item['quote-uri-id']]);
|
||||
DI::logger()->debug('Quote is found', ['uri' => $item['uri'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $item['quote-uri-id']]);
|
||||
} elseif ($uri_id = ItemURI::getIdByURI($activity['quote-url'], false)) {
|
||||
DI::logger()->info('Quote was not fetched but the uri-id existed', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $uri_id]);
|
||||
DI::logger()->info('Quote was not fetched but the uri-id existed', ['uri' => $item['uri'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $uri_id]);
|
||||
$item['quote-uri-id'] = $uri_id;
|
||||
} elseif (Queue::exists($activity['quote-url'], 'as:Create')) {
|
||||
$item['quote-uri-id'] = ItemURI::getIdByURI($activity['quote-url']);
|
||||
DI::logger()->info('Quote is queued but not processed yet', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $item['quote-uri-id']]);
|
||||
DI::logger()->info('Quote is queued but not processed yet', ['uri' => $item['uri'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $item['quote-uri-id']]);
|
||||
} else {
|
||||
DI::logger()->notice('Quote was not fetched', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url']]);
|
||||
DI::logger()->notice('Quote was not fetched', ['uri' => $item['uri'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -798,10 +798,12 @@ class Transmitter
|
|||
}
|
||||
|
||||
if (!empty($item['quote-uri-id']) && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) {
|
||||
$quoted = Post::selectFirst(['author-link'], ['uri-id' => $item['quote-uri-id']]);
|
||||
$profile = APContact::getByURL($quoted['author-link'], false);
|
||||
if (!empty($profile)) {
|
||||
$data['cc'][] = $profile['url'];
|
||||
$quoted = Post::selectFirst(['author-link'], ['uri-id' => $item['quote-uri-id']]);
|
||||
if (!empty($quoted['author-link'])) {
|
||||
$profile = APContact::getByURL($quoted['author-link'], false);
|
||||
if (!empty($profile)) {
|
||||
$data['cc'][] = $profile['url'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -310,7 +310,7 @@ class Delivery
|
|||
$atom = DFRN::entries($msgitems, $owner);
|
||||
}
|
||||
|
||||
DI::logger()->debug('Notifier entry: ' . $contact['url'] . ' ' . ($target_item_id ?? 'relocation') . ' entry: ' . $atom);
|
||||
DI::logger()->debug('Notifier entry', ['url' => $contact['url'], 'target_item_id' => ($target_item_id ?? 'relocation'), 'entry' => $atom]);
|
||||
|
||||
$protocol = Post\DeliveryData::DFRN;
|
||||
|
||||
|
|
|
@ -2790,7 +2790,7 @@ class Diaspora
|
|||
*/
|
||||
public static function encodePrivateData(string $msg, array $user, array $contact, string $prvkey, string $pubkey): string
|
||||
{
|
||||
DI::logger()->debug('Message: ' . $msg);
|
||||
DI::logger()->debug('Diaspora message', ['msg' => $msg]);
|
||||
|
||||
// without a public key nothing will work
|
||||
if (!$pubkey) {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Friendica\Protocol;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module;
|
||||
use Friendica\Module\Register;
|
||||
|
@ -43,6 +42,11 @@ class ZOT
|
|||
*/
|
||||
public static function getSiteInfo(): array
|
||||
{
|
||||
$baseUrl = (string) DI::baseUrl();
|
||||
$keyValue = DI::keyValue();
|
||||
$addonHelper = DI::addonHelper();
|
||||
$config = DI::config();
|
||||
|
||||
$policies = [
|
||||
Module\Register::OPEN => 'open',
|
||||
Module\Register::APPROVE => 'approve',
|
||||
|
@ -50,14 +54,14 @@ class ZOT
|
|||
];
|
||||
|
||||
return [
|
||||
'url' => (string)DI::baseUrl(),
|
||||
'openWebAuth' => (string)DI::baseUrl() . '/owa',
|
||||
'authRedirect' => (string)DI::baseUrl() . '/magic',
|
||||
'url' => $baseUrl,
|
||||
'openWebAuth' => $baseUrl . '/owa',
|
||||
'authRedirect' => $baseUrl . '/magic',
|
||||
'register_policy' => $policies[Register::getPolicy()],
|
||||
'accounts' => DI::keyValue()->get('nodeinfo_total_users'),
|
||||
'plugins' => Addon::getVisibleList(),
|
||||
'sitename' => DI::config()->get('config', 'sitename'),
|
||||
'about' => DI::config()->get('config', 'info'),
|
||||
'accounts' => $keyValue->get('nodeinfo_total_users'),
|
||||
'plugins' => $addonHelper->getVisibleEnabledAddons(),
|
||||
'sitename' => $config->get('config', 'sitename'),
|
||||
'about' => $config->get('config', 'info'),
|
||||
'project' => App::PLATFORM,
|
||||
'version' => App::VERSION,
|
||||
];
|
||||
|
|
|
@ -299,12 +299,19 @@ class Crypto
|
|||
* Creates cryptographic secure random digits
|
||||
*
|
||||
* @param string $digits The count of digits
|
||||
* @return int The random Digits
|
||||
* @return string The random Digits
|
||||
*
|
||||
* @throws \Exception In case 'random_int' isn't usable
|
||||
*/
|
||||
public static function randomDigits($digits)
|
||||
public static function randomDigits($digits): string
|
||||
{
|
||||
return random_int(0, 10 ** $digits - 1);
|
||||
$rn = '';
|
||||
|
||||
// generating cryptographically secure pseudo-random integers
|
||||
for ($i = 0; $i < $digits; $i++) {
|
||||
$rn .= random_int(0, 9);
|
||||
}
|
||||
|
||||
return $rn;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,14 +40,18 @@ class Emailer
|
|||
/** @var string */
|
||||
private $siteEmailName;
|
||||
|
||||
public function __construct(IManageConfigValues $config, IManagePersonalConfigValues $pConfig, BaseURL $baseURL, LoggerInterface $logger,
|
||||
L10n $defaultLang)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->pConfig = $pConfig;
|
||||
$this->logger = $logger;
|
||||
$this->baseUrl = $baseURL;
|
||||
$this->l10n = $defaultLang;
|
||||
public function __construct(
|
||||
IManageConfigValues $config,
|
||||
IManagePersonalConfigValues $pConfig,
|
||||
BaseURL $baseURL,
|
||||
LoggerInterface $logger,
|
||||
L10n $defaultLang
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->pConfig = $pConfig;
|
||||
$this->logger = $logger;
|
||||
$this->baseUrl = $baseURL;
|
||||
$this->l10n = $defaultLang;
|
||||
|
||||
$this->siteEmailAddress = $this->config->get('config', 'sender_email');
|
||||
if (empty($this->siteEmailAddress)) {
|
||||
|
@ -89,8 +93,14 @@ class Emailer
|
|||
*/
|
||||
public function newSystemMail()
|
||||
{
|
||||
return new SystemMailBuilder($this->l10n, $this->baseUrl, $this->config, $this->logger,
|
||||
$this->getSiteEmailAddress(), $this->getSiteEmailName());
|
||||
return new SystemMailBuilder(
|
||||
$this->l10n,
|
||||
$this->baseUrl,
|
||||
$this->config,
|
||||
$this->logger,
|
||||
$this->getSiteEmailAddress(),
|
||||
$this->getSiteEmailName()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,8 +110,14 @@ class Emailer
|
|||
*/
|
||||
public function newNotifyMail()
|
||||
{
|
||||
return new NotifyMailBuilder($this->l10n, $this->baseUrl, $this->config, $this->logger,
|
||||
$this->getSiteEmailAddress(), $this->getSiteEmailName());
|
||||
return new NotifyMailBuilder(
|
||||
$this->l10n,
|
||||
$this->baseUrl,
|
||||
$this->config,
|
||||
$this->logger,
|
||||
$this->getSiteEmailAddress(),
|
||||
$this->getSiteEmailName()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,9 +159,9 @@ class Emailer
|
|||
|
||||
// generate a mime boundary
|
||||
$mimeBoundary = rand(0, 9) . '-'
|
||||
. rand(100000000, 999999999) . '-'
|
||||
. rand(100000000, 999999999) . '=:'
|
||||
. rand(10000, 99999);
|
||||
. rand(100000000, 999999999) . '-'
|
||||
. rand(100000000, 999999999) . '=:'
|
||||
. rand(10000, 99999);
|
||||
|
||||
$messageHeader = $email->getAdditionalMailHeaderString();
|
||||
if ($countMessageId === 0) {
|
||||
|
@ -163,9 +179,9 @@ class Emailer
|
|||
$textBody = chunk_split(base64_encode($email->getMessage(true)));
|
||||
$htmlBody = chunk_split(base64_encode($email->getMessage()));
|
||||
$multipartMessageBody = "--" . $mimeBoundary . "\n" . // plain text section
|
||||
"Content-Type: text/plain; charset=UTF-8\n" .
|
||||
"Content-Transfer-Encoding: base64\n\n" .
|
||||
$textBody . "\n";
|
||||
"Content-Type: text/plain; charset=UTF-8\n" .
|
||||
"Content-Transfer-Encoding: base64\n\n" .
|
||||
$textBody . "\n";
|
||||
|
||||
if (!$email_textonly && !is_null($email->getMessage())) {
|
||||
$multipartMessageBody .=
|
||||
|
@ -207,8 +223,7 @@ class Emailer
|
|||
$hookdata['parameters']
|
||||
);
|
||||
|
||||
$this->logger->debug('header ' . 'To: ' . $email->getToAddress() . '\n' . $messageHeader);
|
||||
$this->logger->debug('return value ' . (($res) ? 'true' : 'false'));
|
||||
$this->logger->debug('Email message header', ['To' => $email->getToAddress(), 'messageHeader' => $messageHeader, 'return' => ($res) ? 'true' : 'false']);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class Temporal
|
|||
$o .= '<optgroup label="' . DI::l10n()->t($continent) . '">';
|
||||
}
|
||||
}
|
||||
$city = str_replace('_', ' ', DI::l10n()->t($city));
|
||||
$city = str_replace('_', ' ', DI::l10n()->t($city));
|
||||
$selected = (($value == $current) ? " selected=\"selected\" " : "");
|
||||
$o .= "<option value=\"$value\" $selected >$city</option>";
|
||||
}
|
||||
|
@ -137,27 +137,29 @@ class Temporal
|
|||
|
||||
if ($dob < '0000-01-01') {
|
||||
$value = '';
|
||||
$age = 0;
|
||||
$age = 0;
|
||||
} elseif ($dob < '0001-00-00') {
|
||||
$value = substr($dob, 5);
|
||||
$age = 0;
|
||||
$age = 0;
|
||||
} else {
|
||||
$value = DateTimeFormat::utc($dob, 'Y-m-d');
|
||||
$age = self::getAgeByTimezone($value, $timezone);
|
||||
$age = self::getAgeByTimezone($value, $timezone);
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate("field_input.tpl");
|
||||
$o = Renderer::replaceMacros($tpl,
|
||||
$o = Renderer::replaceMacros(
|
||||
$tpl,
|
||||
[
|
||||
'$field' => [
|
||||
'dob',
|
||||
DI::l10n()->t('Birthday:'),
|
||||
$value,
|
||||
intval($age) > 0 ? DI::l10n()->t('Age: ') . DI::l10n()->tt('%d year old', '%d years old', $age) : '',
|
||||
'',
|
||||
'placeholder="' . DI::l10n()->t('YYYY-MM-DD or MM-DD') . '"'
|
||||
'$field' => [
|
||||
'dob',
|
||||
DI::l10n()->t('Birthday:'),
|
||||
$value,
|
||||
intval($age) > 0 ? DI::l10n()->t('Age: ') . DI::l10n()->tt('%d year old', '%d years old', $age) : '',
|
||||
'',
|
||||
'placeholder="' . DI::l10n()->t('YYYY-MM-DD or MM-DD') . '"'
|
||||
]
|
||||
]
|
||||
]);
|
||||
);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
@ -218,26 +220,28 @@ class Temporal
|
|||
DateTime $maxDate,
|
||||
DateTime $defaultDate = null,
|
||||
$label,
|
||||
string $id = 'datetimepicker',
|
||||
string $id = 'datetimepicker',
|
||||
bool $pickdate = true,
|
||||
bool $picktime = true,
|
||||
string $minfrom = '',
|
||||
string $maxfrom = '',
|
||||
bool $required = false): string
|
||||
{
|
||||
string $minfrom = '',
|
||||
string $maxfrom = '',
|
||||
bool $required = false
|
||||
): string {
|
||||
// First day of the week (0 = Sunday)
|
||||
$firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week', 0);
|
||||
$firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week') ?: 0;
|
||||
|
||||
$lang = DI::l10n()->toISO6391(DI::l10n()->getCurrentLang());
|
||||
|
||||
// Check if the detected language is supported by the picker
|
||||
if (!in_array($lang,
|
||||
['ar', 'ro', 'id', 'bg', 'fa', 'ru', 'uk', 'en', 'el', 'de', 'nl', 'tr', 'fr', 'es', 'th', 'pl', 'pt', 'ch', 'se', 'kr',
|
||||
'it', 'da', 'no', 'ja', 'vi', 'sl', 'cs', 'hu'])) {
|
||||
if (!in_array(
|
||||
$lang,
|
||||
['ar', 'ro', 'id', 'bg', 'fa', 'ru', 'uk', 'en', 'el', 'de', 'nl', 'tr', 'fr', 'es', 'th', 'pl', 'pt', 'ch', 'se', 'kr',
|
||||
'it', 'da', 'no', 'ja', 'vi', 'sl', 'cs', 'hu']
|
||||
)) {
|
||||
$lang = 'en';
|
||||
}
|
||||
|
||||
$o = '';
|
||||
$o = '';
|
||||
$dateformat = '';
|
||||
|
||||
if ($pickdate) {
|
||||
|
@ -271,14 +275,14 @@ class Temporal
|
|||
'placeholder="' . $readable_format . '"'
|
||||
],
|
||||
'$datetimepicker' => [
|
||||
'minDate' => $minDate,
|
||||
'maxDate' => $maxDate,
|
||||
'minDate' => $minDate,
|
||||
'maxDate' => $maxDate,
|
||||
'defaultDate' => $defaultDate,
|
||||
'dateformat' => $dateformat,
|
||||
'firstDay' => $firstDay,
|
||||
'lang' => $lang,
|
||||
'minfrom' => $minfrom,
|
||||
'maxfrom' => $maxfrom,
|
||||
'dateformat' => $dateformat,
|
||||
'firstDay' => $firstDay,
|
||||
'lang' => $lang,
|
||||
'minfrom' => $minfrom,
|
||||
'maxfrom' => $maxfrom,
|
||||
],
|
||||
]);
|
||||
|
||||
|
@ -309,7 +313,7 @@ class Temporal
|
|||
$clock = $clock ?? new SystemClock();
|
||||
|
||||
$localtime = $posted_date . ' UTC';
|
||||
$abs = strtotime($localtime);
|
||||
$abs = strtotime($localtime);
|
||||
|
||||
if ($abs === false) {
|
||||
return DI::l10n()->t('never');
|
||||
|
@ -323,25 +327,25 @@ class Temporal
|
|||
}
|
||||
|
||||
$isfuture = false;
|
||||
$etime = $now - $abs;
|
||||
$etime = $now - $abs;
|
||||
|
||||
if ($etime >= 0 && $etime < 1) {
|
||||
return $compare_time ? DI::l10n()->t('less than a second ago') : DI::l10n()->t('today');
|
||||
}
|
||||
|
||||
if ($etime < 0){
|
||||
$etime = -$etime;
|
||||
if ($etime < 0) {
|
||||
$etime = -$etime;
|
||||
$isfuture = true;
|
||||
}
|
||||
|
||||
$a = [
|
||||
12 * 30 * 24 * 60 * 60 => [DI::l10n()->t('year'), DI::l10n()->t('years')],
|
||||
30 * 24 * 60 * 60 => [DI::l10n()->t('month'), DI::l10n()->t('months')],
|
||||
7 * 24 * 60 * 60 => [DI::l10n()->t('week'), DI::l10n()->t('weeks')],
|
||||
24 * 60 * 60 => [DI::l10n()->t('day'), DI::l10n()->t('days')],
|
||||
60 * 60 => [DI::l10n()->t('hour'), DI::l10n()->t('hours')],
|
||||
60 => [DI::l10n()->t('minute'), DI::l10n()->t('minutes')],
|
||||
1 => [DI::l10n()->t('second'), DI::l10n()->t('seconds')],
|
||||
30 * 24 * 60 * 60 => [DI::l10n()->t('month'), DI::l10n()->t('months')],
|
||||
7 * 24 * 60 * 60 => [DI::l10n()->t('week'), DI::l10n()->t('weeks')],
|
||||
24 * 60 * 60 => [DI::l10n()->t('day'), DI::l10n()->t('days')],
|
||||
60 * 60 => [DI::l10n()->t('hour'), DI::l10n()->t('hours')],
|
||||
60 => [DI::l10n()->t('minute'), DI::l10n()->t('minutes')],
|
||||
1 => [DI::l10n()->t('second'), DI::l10n()->t('seconds')],
|
||||
];
|
||||
|
||||
foreach ($a as $secs => $str) {
|
||||
|
@ -349,10 +353,9 @@ class Temporal
|
|||
if ($d >= 1) {
|
||||
$r = floor($d);
|
||||
// translators - e.g. 22 hours ago, 1 minute ago
|
||||
if($isfuture){
|
||||
if($isfuture) {
|
||||
$format = DI::l10n()->t('in %1$d %2$s');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$format = DI::l10n()->t('%1$d %2$s ago');
|
||||
}
|
||||
|
||||
|
@ -381,7 +384,7 @@ class Temporal
|
|||
return 0;
|
||||
}
|
||||
|
||||
$birthdate = new DateTime($dob . ' 00:00:00', new DateTimeZone($timezone));
|
||||
$birthdate = new DateTime($dob . ' 00:00:00', new DateTimeZone($timezone));
|
||||
$currentDate = new DateTime('now', new DateTimeZone('UTC'));
|
||||
|
||||
$interval = $birthdate->diff($currentDate);
|
||||
|
@ -451,7 +454,7 @@ class Temporal
|
|||
'October', 'November', 'December'
|
||||
];
|
||||
|
||||
$thisyear = DateTimeFormat::localNow('Y');
|
||||
$thisyear = DateTimeFormat::localNow('Y');
|
||||
$thismonth = DateTimeFormat::localNow('m');
|
||||
if (!$y) {
|
||||
$y = $thisyear;
|
||||
|
@ -461,11 +464,11 @@ class Temporal
|
|||
$m = intval($thismonth);
|
||||
}
|
||||
|
||||
$dn = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
$f = self::getFirstDayInMonth($y, $m);
|
||||
$l = self::getDaysInMonth($y, $m);
|
||||
$d = 1;
|
||||
$dow = 0;
|
||||
$dn = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
$f = self::getFirstDayInMonth($y, $m);
|
||||
$l = self::getDaysInMonth($y, $m);
|
||||
$d = 1;
|
||||
$dow = 0;
|
||||
$started = false;
|
||||
|
||||
if (($y == $thisyear) && ($m == $thismonth)) {
|
||||
|
@ -473,9 +476,9 @@ class Temporal
|
|||
}
|
||||
|
||||
$str_month = DI::l10n()->getDay($mtab[$m]);
|
||||
$o = '<table class="calendar' . $class . '">';
|
||||
$o = '<table class="calendar' . $class . '">';
|
||||
$o .= "<caption>$str_month $y</caption><tr>";
|
||||
for ($a = 0; $a < 7; $a ++) {
|
||||
for ($a = 0; $a < 7; $a++) {
|
||||
$o .= '<th>' . mb_substr(DI::l10n()->getDay($dn[$a]), 0, 3, 'UTF-8') . '</th>';
|
||||
}
|
||||
|
||||
|
@ -496,13 +499,13 @@ class Temporal
|
|||
$o .= $day;
|
||||
}
|
||||
|
||||
$d ++;
|
||||
$d++;
|
||||
} else {
|
||||
$o .= ' ';
|
||||
}
|
||||
|
||||
$o .= '</td>';
|
||||
$dow ++;
|
||||
$dow++;
|
||||
if (($dow == 7) && ($d <= $l)) {
|
||||
$dow = 0;
|
||||
$o .= '</tr><tr>';
|
||||
|
@ -510,7 +513,7 @@ class Temporal
|
|||
}
|
||||
|
||||
if ($dow) {
|
||||
for ($a = $dow; $a < 7; $a ++) {
|
||||
for ($a = $dow; $a < 7; $a++) {
|
||||
$o .= '<td> </td>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
use Friendica\Util\Network;
|
||||
|
||||
class AddContact
|
||||
{
|
||||
|
@ -39,4 +41,20 @@ class AddContact
|
|||
DI::logger()->notice('Imagick not found.', ['exception' => $e, 'uid' => $uid, 'url' => $url]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|int $run_parameters Priority constant or array of options described in Worker::add
|
||||
* @param int $uid User ID
|
||||
* @param string $url Contact link
|
||||
* @return int
|
||||
*/
|
||||
public static function add($run_parameters, int $uid, string $url): int
|
||||
{
|
||||
if (Network::isUrlBlocked($url)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
DI::logger()->debug('Add contact', ['uid' => $uid, 'url' => $url]);
|
||||
return Worker::add($run_parameters, 'AddContact', 0, $url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -145,7 +144,7 @@ class Cron
|
|||
// Update "blocked" status of servers
|
||||
Worker::add(Worker::PRIORITY_LOW, 'UpdateBlockedServers');
|
||||
|
||||
Addon::reload();
|
||||
DI::addonHelper()->reloadAddons();
|
||||
|
||||
DI::keyValue()->set('last_cron_daily', time());
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ use Friendica\Database\DBA;
|
|||
|
||||
// This file is required several times during the test in DbaDefinition which justifies this condition
|
||||
if (!defined('DB_UPDATE_VERSION')) {
|
||||
define('DB_UPDATE_VERSION', 1576);
|
||||
define('DB_UPDATE_VERSION', 1577);
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -1604,7 +1604,7 @@ return [
|
|||
"indexes" => [
|
||||
"PRIMARY" => ["id"],
|
||||
"uid_uri-id" => ["UNIQUE", "uid", "uri-id"],
|
||||
"uri-id" => ["uri-id"],
|
||||
"uri-id_origin_deleted" => ["uri-id", "origin", "deleted"],
|
||||
"parent-uri-id" => ["parent-uri-id"],
|
||||
"thr-parent-id" => ["thr-parent-id"],
|
||||
"external-id" => ["external-id"],
|
||||
|
|
|
@ -1763,7 +1763,8 @@ return [
|
|||
],
|
||||
"query" => "FROM `register`
|
||||
INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
|
||||
INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
|
||||
INNER JOIN `user` ON `register`.`uid` = `user`.`uid`
|
||||
WHERE `register`.`uid` != 0"
|
||||
],
|
||||
"tag-search-view" => [
|
||||
"fields" => [
|
||||
|
|
|
@ -42,6 +42,12 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo
|
|||
[Dice::INSTANCE => Dice::SELF],
|
||||
],
|
||||
],
|
||||
\Friendica\Core\Addon\AddonHelper::class => [
|
||||
'instanceOf' => \Friendica\Core\Addon\AddonProxy::class,
|
||||
'constructParams' => [
|
||||
$basepath . '/addon',
|
||||
],
|
||||
],
|
||||
\Friendica\Util\BasePath::class => [
|
||||
'constructParams' => [
|
||||
$basepath,
|
||||
|
@ -81,6 +87,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo
|
|||
'call' => [
|
||||
['createConfigFileManager', [
|
||||
$basepath,
|
||||
$basepath . '/addon',
|
||||
$serverVars,
|
||||
], Dice::CHAIN_CALL],
|
||||
],
|
||||
|
@ -182,6 +189,9 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo
|
|||
['create', [], Dice::CHAIN_CALL],
|
||||
],
|
||||
],
|
||||
\Psr\EventDispatcher\EventDispatcherInterface::class => [
|
||||
'instanceOf' => \Friendica\Event\EventDispatcher::class,
|
||||
],
|
||||
\Friendica\Core\Logger\Capability\IHaveCallIntrospections::class => [
|
||||
'instanceOf' => \Friendica\Core\Logger\Util\Introspection::class,
|
||||
'constructParams' => [
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Friendica\Test;
|
||||
|
||||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
@ -124,7 +124,7 @@ abstract class ApiTestCase extends FixtureTestCase
|
|||
file_put_contents(
|
||||
$tmpFile,
|
||||
base64_decode(
|
||||
// Empty 1x1 px PNG image
|
||||
// Empty 1x1 px PNG image
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='
|
||||
)
|
||||
);
|
||||
|
@ -201,7 +201,7 @@ abstract class ApiTestCase extends FixtureTestCase
|
|||
'plugin_admin' => function_exists($addon . '_addon_admin'),
|
||||
]);
|
||||
|
||||
Addon::loadAddons();
|
||||
$this->dice->create(AddonHelper::class)->loadAddons();
|
||||
Hook::loadHooks();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ trait FixtureTestTrait
|
|||
->addRules(include __DIR__ . '/../static/dependencies.config.php')
|
||||
->addRule(ConfigFileManager::class, [
|
||||
'instanceOf' => Config::class,
|
||||
'call' => [['createConfigFileManager', [$this->root->url(), $server,], Dice::CHAIN_CALL]]])
|
||||
'call' => [['createConfigFileManager', [$this->root->url(), $this->root->url() . '/addon', $server,], Dice::CHAIN_CALL]]])
|
||||
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
|
||||
->addRule(IHandleSessions::class, ['instanceOf' => Memory::class, 'shared' => true, 'call' => null])
|
||||
->addRule(Arguments::class, [
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Core\Addon;
|
||||
|
||||
use Friendica\Core\Addon\AddonInfo;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AddonInfoTest extends TestCase
|
||||
{
|
||||
public function testFromArrayCreatesObject(): void
|
||||
{
|
||||
$data = [
|
||||
'id' => '',
|
||||
'name' => '',
|
||||
'description' => '',
|
||||
'authors' => [],
|
||||
'maintainers' => [],
|
||||
'version' => '',
|
||||
'status' => '',
|
||||
];
|
||||
|
||||
$this->assertInstanceOf(AddonInfo::class, AddonInfo::fromArray($data));
|
||||
}
|
||||
|
||||
public function testGetterReturningCorrectValues(): void
|
||||
{
|
||||
$data = [
|
||||
'id' => 'test',
|
||||
'name' => 'Test-Addon',
|
||||
'description' => 'This is an addon for tests',
|
||||
'authors' => [['name' => 'Sam']],
|
||||
'maintainers' => [['name' => 'Sam', 'link' => 'https://example.com']],
|
||||
'version' => '0.1',
|
||||
'status' => 'In Development',
|
||||
];
|
||||
|
||||
$info = AddonInfo::fromArray($data);
|
||||
|
||||
$this->assertSame($data['id'], $info->getId());
|
||||
$this->assertSame($data['name'], $info->getName());
|
||||
$this->assertSame($data['description'], $info->getDescription());
|
||||
$this->assertSame($data['description'], $info->getDescription());
|
||||
$this->assertSame($data['authors'], $info->getAuthors());
|
||||
$this->assertSame($data['maintainers'], $info->getMaintainers());
|
||||
$this->assertSame($data['version'], $info->getVersion());
|
||||
$this->assertSame($data['status'], $info->getStatus());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Core\Hooks;
|
||||
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
use Friendica\Core\Hooks\HookEventBridge;
|
||||
use Friendica\Event\ArrayFilterEvent;
|
||||
use Friendica\Event\ConfigLoadedEvent;
|
||||
use Friendica\Event\Event;
|
||||
use Friendica\Event\HtmlFilterEvent;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HookEventBridgeTest extends TestCase
|
||||
{
|
||||
public function testGetStaticSubscribedEventsReturnsStaticMethods(): void
|
||||
{
|
||||
$expected = [
|
||||
Event::INIT => 'onNamedEvent',
|
||||
ConfigLoadedEvent::CONFIG_LOADED => 'onConfigLoadedEvent',
|
||||
ArrayFilterEvent::APP_MENU => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::NAV_INFO => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::FEATURE_ENABLED => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::FEATURE_GET => 'onArrayFilterEvent',
|
||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_CONTENT_TOP => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent',
|
||||
];
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
HookEventBridge::getStaticSubscribedEvents()
|
||||
);
|
||||
|
||||
foreach ($expected as $methodName) {
|
||||
$this->assertTrue(
|
||||
method_exists(HookEventBridge::class, $methodName),
|
||||
$methodName . '() is not defined'
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
(new \ReflectionMethod(HookEventBridge::class, $methodName))->isStatic(),
|
||||
$methodName . '() is not static'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getNamedEventData(): array
|
||||
{
|
||||
return [
|
||||
['test', 'test'],
|
||||
[Event::INIT, 'init_1'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNamedEventData
|
||||
*/
|
||||
public function testOnNamedEventCallsHook($name, $expected): void
|
||||
{
|
||||
$event = new Event($name);
|
||||
|
||||
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
|
||||
$reflectionProperty->setValue(null, function (string $name, $data) use ($expected) {
|
||||
$this->assertSame($expected, $name);
|
||||
$this->assertSame('', $data);
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
HookEventBridge::onNamedEvent($event);
|
||||
}
|
||||
|
||||
public static function getConfigLoadedEventData(): array
|
||||
{
|
||||
return [
|
||||
['test', 'test'],
|
||||
[ConfigLoadedEvent::CONFIG_LOADED, 'load_config'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getConfigLoadedEventData
|
||||
*/
|
||||
public function testOnConfigLoadedEventCallsHookWithCorrectValue($name, $expected): void
|
||||
{
|
||||
$config = $this->createStub(ConfigFileManager::class);
|
||||
|
||||
$event = new ConfigLoadedEvent($name, $config);
|
||||
|
||||
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
|
||||
$reflectionProperty->setValue(null, function (string $name, $data) use ($expected, $config) {
|
||||
$this->assertSame($expected, $name);
|
||||
$this->assertSame($config, $data);
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
HookEventBridge::onConfigLoadedEvent($event);
|
||||
}
|
||||
|
||||
public static function getArrayFilterEventData(): array
|
||||
{
|
||||
return [
|
||||
['test', 'test'],
|
||||
[ArrayFilterEvent::APP_MENU, 'app_menu'],
|
||||
[ArrayFilterEvent::NAV_INFO, 'nav_info'],
|
||||
[ArrayFilterEvent::FEATURE_ENABLED, 'isEnabled'],
|
||||
[ArrayFilterEvent::FEATURE_GET, 'get'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getArrayFilterEventData
|
||||
*/
|
||||
public function testOnArrayFilterEventCallsHookWithCorrectValue($name, $expected): void
|
||||
{
|
||||
$event = new ArrayFilterEvent($name, ['original']);
|
||||
|
||||
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
|
||||
$reflectionProperty->setValue(null, function (string $name, $data) use ($expected) {
|
||||
$this->assertSame($expected, $name);
|
||||
$this->assertSame(['original'], $data);
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
HookEventBridge::onArrayFilterEvent($event);
|
||||
}
|
||||
|
||||
public static function getHtmlFilterEventData(): array
|
||||
{
|
||||
return [
|
||||
['test', 'test'],
|
||||
[HtmlFilterEvent::HEAD, 'head'],
|
||||
[HtmlFilterEvent::FOOTER, 'footer'],
|
||||
[HtmlFilterEvent::PAGE_HEADER, 'page_header'],
|
||||
[HtmlFilterEvent::PAGE_CONTENT_TOP, 'page_content_top'],
|
||||
[HtmlFilterEvent::PAGE_END, 'page_end'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getHtmlFilterEventData
|
||||
*/
|
||||
public function testOnHtmlFilterEventCallsHookWithCorrectValue($name, $expected): void
|
||||
{
|
||||
$event = new HtmlFilterEvent($name, 'original');
|
||||
|
||||
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
|
||||
$reflectionProperty->setValue(null, function (string $name, $data) use ($expected) {
|
||||
$this->assertSame($expected, $name);
|
||||
$this->assertSame('original', $data);
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
HookEventBridge::onHtmlFilterEvent($event);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Event;
|
||||
|
||||
use Friendica\Event\ArrayFilterEvent;
|
||||
use Friendica\Event\NamedEvent;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ArrayFilterEventTest extends TestCase
|
||||
{
|
||||
public function testImplementationOfInstances(): void
|
||||
{
|
||||
$event = new ArrayFilterEvent('test', []);
|
||||
|
||||
$this->assertInstanceOf(NamedEvent::class, $event);
|
||||
}
|
||||
|
||||
public static function getPublicConstants(): array
|
||||
{
|
||||
return [
|
||||
[ArrayFilterEvent::APP_MENU, 'friendica.data.app_menu'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPublicConstants
|
||||
*/
|
||||
public function testPublicConstantsAreAvailable($value, $expected): void
|
||||
{
|
||||
$this->assertSame($expected, $value);
|
||||
}
|
||||
|
||||
public function testGetNameReturnsName(): void
|
||||
{
|
||||
$event = new ArrayFilterEvent('test', []);
|
||||
|
||||
$this->assertSame('test', $event->getName());
|
||||
}
|
||||
|
||||
public function testGetArrayReturnsCorrectString(): void
|
||||
{
|
||||
$data = ['original'];
|
||||
|
||||
$event = new ArrayFilterEvent('test', $data);
|
||||
|
||||
$this->assertSame($data, $event->getArray());
|
||||
}
|
||||
|
||||
public function testSetArrayUpdatesHtml(): void
|
||||
{
|
||||
$event = new ArrayFilterEvent('test', ['original']);
|
||||
|
||||
$expected = ['updated'];
|
||||
|
||||
$event->setArray($expected);
|
||||
|
||||
$this->assertSame($expected, $event->getArray());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Event;
|
||||
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
use Friendica\Event\ConfigLoadedEvent;
|
||||
use Friendica\Event\NamedEvent;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ConfigLoadedEventTest extends TestCase
|
||||
{
|
||||
public function testImplementationOfInstances(): void
|
||||
{
|
||||
$event = new ConfigLoadedEvent('test', $this->createStub(ConfigFileManager::class));
|
||||
|
||||
$this->assertInstanceOf(NamedEvent::class, $event);
|
||||
}
|
||||
|
||||
public static function getPublicConstants(): array
|
||||
{
|
||||
return [
|
||||
[ConfigLoadedEvent::CONFIG_LOADED, 'friendica.config_loaded'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPublicConstants
|
||||
*/
|
||||
public function testPublicConstantsAreAvailable($value, $expected): void
|
||||
{
|
||||
$this->assertSame($expected, $value);
|
||||
}
|
||||
|
||||
public function testGetNameReturnsName(): void
|
||||
{
|
||||
$event = new ConfigLoadedEvent('test', $this->createStub(ConfigFileManager::class));
|
||||
|
||||
$this->assertSame('test', $event->getName());
|
||||
}
|
||||
|
||||
public function testGetConfigReturnsCorrectString(): void
|
||||
{
|
||||
$config = $this->createStub(ConfigFileManager::class);
|
||||
|
||||
$event = new ConfigLoadedEvent('test', $config);
|
||||
|
||||
$this->assertSame($config, $event->getConfig());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Event;
|
||||
|
||||
use Friendica\Event\Event;
|
||||
use Friendica\Event\EventDispatcher;
|
||||
use Friendica\Event\NamedEvent;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
class EventDispatcherTest extends TestCase
|
||||
{
|
||||
public function testImplementationOfInstances(): void
|
||||
{
|
||||
$eventDispatcher = new EventDispatcher();
|
||||
|
||||
$this->assertInstanceOf(EventDispatcherInterface::class, $eventDispatcher);
|
||||
}
|
||||
|
||||
public function testDispatchANamedEventUsesNameAsEventName(): void
|
||||
{
|
||||
$eventDispatcher = new EventDispatcher();
|
||||
|
||||
$eventDispatcher->addListener('test', function (NamedEvent $event) {
|
||||
$this->assertSame('test', $event->getName());
|
||||
});
|
||||
|
||||
$eventDispatcher->dispatch(new Event('test'));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Event;
|
||||
|
||||
use Friendica\Event\Event;
|
||||
use Friendica\Event\NamedEvent;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class EventTest extends TestCase
|
||||
{
|
||||
public function testImplementationOfInstances(): void
|
||||
{
|
||||
$event = new Event('test');
|
||||
|
||||
$this->assertInstanceOf(NamedEvent::class, $event);
|
||||
}
|
||||
|
||||
public static function getPublicConstants(): array
|
||||
{
|
||||
return [
|
||||
[Event::INIT, 'friendica.init'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPublicConstants
|
||||
*/
|
||||
public function testPublicConstantsAreAvailable($value, $expected): void
|
||||
{
|
||||
$this->assertSame($expected, $value);
|
||||
}
|
||||
|
||||
public function testGetNameReturnsName(): void
|
||||
{
|
||||
$event = new Event('test');
|
||||
|
||||
$this->assertSame('test', $event->getName());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Event;
|
||||
|
||||
use Friendica\Event\HtmlFilterEvent;
|
||||
use Friendica\Event\NamedEvent;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HtmlFilterEventTest extends TestCase
|
||||
{
|
||||
public function testImplementationOfInstances(): void
|
||||
{
|
||||
$event = new HtmlFilterEvent('test', 'original');
|
||||
|
||||
$this->assertInstanceOf(NamedEvent::class, $event);
|
||||
}
|
||||
|
||||
public static function getPublicConstants(): array
|
||||
{
|
||||
return [
|
||||
[HtmlFilterEvent::HEAD, 'friendica.html.head'],
|
||||
[HtmlFilterEvent::FOOTER, 'friendica.html.footer'],
|
||||
[HtmlFilterEvent::PAGE_CONTENT_TOP, 'friendica.html.page_content_top'],
|
||||
[HtmlFilterEvent::PAGE_END, 'friendica.html.page_end'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPublicConstants
|
||||
*/
|
||||
public function testPublicConstantsAreAvailable($value, $expected): void
|
||||
{
|
||||
$this->assertSame($expected, $value);
|
||||
}
|
||||
|
||||
public function testGetNameReturnsName(): void
|
||||
{
|
||||
$event = new HtmlFilterEvent('test', '');
|
||||
|
||||
$this->assertSame('test', $event->getName());
|
||||
}
|
||||
|
||||
public function testGetHtmlReturnsCorrectString(): void
|
||||
{
|
||||
$data = 'original';
|
||||
|
||||
$event = new HtmlFilterEvent('test', $data);
|
||||
|
||||
$this->assertSame($data, $event->getHtml());
|
||||
}
|
||||
|
||||
public function testSetHtmlUpdatesHtml(): void
|
||||
{
|
||||
$event = new HtmlFilterEvent('test', 'original');
|
||||
|
||||
$expected = 'updated';
|
||||
|
||||
$event->setHtml($expected);
|
||||
|
||||
$this->assertSame($expected, $event->getHtml());
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types = 1);
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Util;
|
||||
|
||||
|
@ -16,48 +16,48 @@ class BasePathTest extends TestCase
|
|||
{
|
||||
public static function getDataPaths(): array
|
||||
{
|
||||
$basePath = dirname(__DIR__, 3);
|
||||
$basePath = dirname(__DIR__, 3);
|
||||
$configPath = $basePath . DIRECTORY_SEPARATOR . 'config';
|
||||
|
||||
return [
|
||||
'fullPath' => [
|
||||
'server' => [],
|
||||
'baseDir' => $configPath,
|
||||
'server' => [],
|
||||
'baseDir' => $configPath,
|
||||
'expected' => $configPath,
|
||||
],
|
||||
'relative' => [
|
||||
'server' => [],
|
||||
'baseDir' => 'config',
|
||||
'server' => [],
|
||||
'baseDir' => 'config',
|
||||
'expected' => $configPath,
|
||||
],
|
||||
'document_root' => [
|
||||
'server' => [
|
||||
'DOCUMENT_ROOT' => $configPath,
|
||||
],
|
||||
'baseDir' => '/noooop',
|
||||
'baseDir' => '/noooop',
|
||||
'expected' => $configPath,
|
||||
],
|
||||
'pwd' => [
|
||||
'server' => [
|
||||
'PWD' => $configPath,
|
||||
],
|
||||
'baseDir' => '/noooop',
|
||||
'baseDir' => '/noooop',
|
||||
'expected' => $configPath,
|
||||
],
|
||||
'no_overwrite' => [
|
||||
'server' => [
|
||||
'DOCUMENT_ROOT' => $basePath,
|
||||
'PWD' => $basePath,
|
||||
'PWD' => $basePath,
|
||||
],
|
||||
'baseDir' => 'config',
|
||||
'baseDir' => 'config',
|
||||
'expected' => $configPath,
|
||||
],
|
||||
'no_overwrite_if_invalid' => [
|
||||
'server' => [
|
||||
'DOCUMENT_ROOT' => '/nopopop',
|
||||
'PWD' => $configPath,
|
||||
'PWD' => $configPath,
|
||||
],
|
||||
'baseDir' => '/noatgawe22fafa',
|
||||
'baseDir' => '/noatgawe22fafa',
|
||||
'expected' => $configPath,
|
||||
]
|
||||
];
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue