mirror of
https://github.com/friendica/friendica
synced 2024-12-24 13:20:15 +00:00
Merge pull request #11002 from nupplaphil/feat/modules_constructor
Replace `Modules::init()` with Constructors (Retry)
This commit is contained in:
commit
7ccfbd8ef2
43 changed files with 1228 additions and 924 deletions
|
@ -40,7 +40,7 @@ use Friendica\Protocol\DFRN;
|
||||||
function display_init(App $a)
|
function display_init(App $a)
|
||||||
{
|
{
|
||||||
if (ActivityPub::isRequest()) {
|
if (ActivityPub::isRequest()) {
|
||||||
(new Objects(['guid' => DI::args()->getArgv()[1] ?? null]))->rawContent();
|
(new Objects(DI::l10n(), ['guid' => DI::args()->getArgv()[1] ?? null]))->rawContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||||
|
|
|
@ -81,7 +81,7 @@ class ModuleController
|
||||||
private $moduleName;
|
private $moduleName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ICanHandleRequests The module object
|
* @var ?ICanHandleRequests The module object
|
||||||
*/
|
*/
|
||||||
private $module;
|
private $module;
|
||||||
|
|
||||||
|
@ -104,9 +104,9 @@ class ModuleController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ICanHandleRequests The base module object
|
* @return ?ICanHandleRequests The base module object
|
||||||
*/
|
*/
|
||||||
public function getModule(): ICanHandleRequests
|
public function getModule(): ?ICanHandleRequests
|
||||||
{
|
{
|
||||||
return $this->module;
|
return $this->module;
|
||||||
}
|
}
|
||||||
|
@ -120,12 +120,10 @@ class ModuleController
|
||||||
return $this->isBackend;
|
return $this->isBackend;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(string $moduleName = self::DEFAULT, ICanHandleRequests $module = null, bool $isBackend = false, bool $printNotAllowedAddon = false)
|
public function __construct(string $moduleName = self::DEFAULT, ?ICanHandleRequests $module = null, bool $isBackend = false, bool $printNotAllowedAddon = false)
|
||||||
{
|
{
|
||||||
$defaultClass = static::DEFAULT_CLASS;
|
|
||||||
|
|
||||||
$this->moduleName = $moduleName;
|
$this->moduleName = $moduleName;
|
||||||
$this->module = $module ?? new $defaultClass();
|
$this->module = $module;
|
||||||
$this->isBackend = $isBackend;
|
$this->isBackend = $isBackend;
|
||||||
$this->printNotAllowedAddon = $printNotAllowedAddon;
|
$this->printNotAllowedAddon = $printNotAllowedAddon;
|
||||||
}
|
}
|
||||||
|
@ -297,8 +295,6 @@ class ModuleController
|
||||||
|
|
||||||
Core\Hook::callAll($this->moduleName . '_mod_init', $placeholder);
|
Core\Hook::callAll($this->moduleName . '_mod_init', $placeholder);
|
||||||
|
|
||||||
$this->module->init();
|
|
||||||
|
|
||||||
$profiler->set(microtime(true) - $timestamp, 'init');
|
$profiler->set(microtime(true) - $timestamp, 'init');
|
||||||
|
|
||||||
if ($server['REQUEST_METHOD'] === Router::DELETE) {
|
if ($server['REQUEST_METHOD'] === Router::DELETE) {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
namespace Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
use Friendica\Capabilities\ICanHandleRequests;
|
use Friendica\Capabilities\ICanHandleRequests;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
|
||||||
|
@ -39,16 +40,33 @@ abstract class BaseModule implements ICanHandleRequests
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $parameters = [];
|
protected $parameters = [];
|
||||||
|
|
||||||
public function __construct(array $parameters = [])
|
/** @var L10n */
|
||||||
|
protected $l10n;
|
||||||
|
|
||||||
|
public function __construct(L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
|
$this->l10n = $l10n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Wraps the L10n::t() function for Modules
|
||||||
|
*
|
||||||
|
* @see L10n::t()
|
||||||
*/
|
*/
|
||||||
public function init()
|
protected function t(string $s, ...$args): string
|
||||||
{
|
{
|
||||||
|
return $this->l10n->t($s, $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps the L10n::tt() function for Modules
|
||||||
|
*
|
||||||
|
* @see L10n::tt()
|
||||||
|
*/
|
||||||
|
protected function tt(string $singular, string $plurarl, int $count): string
|
||||||
|
{
|
||||||
|
return $this->l10n->tt($singular, $plurarl, $count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,14 +7,6 @@ namespace Friendica\Capabilities;
|
||||||
*/
|
*/
|
||||||
interface ICanHandleRequests
|
interface ICanHandleRequests
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Initialization method common to both content() and post()
|
|
||||||
*
|
|
||||||
* Extend this method if you need to do any shared processing before either
|
|
||||||
* content() or post()
|
|
||||||
*/
|
|
||||||
public function init();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module GET method to display raw content from technical endpoints
|
* Module GET method to display raw content from technical endpoints
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
namespace Friendica;
|
namespace Friendica;
|
||||||
|
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This mock module enable class encapsulation of legacy global function modules.
|
* This mock module enable class encapsulation of legacy global function modules.
|
||||||
* After having provided the module file name, all the methods will behave like a normal Module class.
|
* After having provided the module file name, all the methods will behave like a normal Module class.
|
||||||
|
@ -37,11 +39,13 @@ class LegacyModule extends BaseModule
|
||||||
*/
|
*/
|
||||||
private $moduleName = '';
|
private $moduleName = '';
|
||||||
|
|
||||||
public function __construct(string $file_path = '', array $parameters = [])
|
public function __construct(L10n $l10n, string $file_path = '', array $parameters = [])
|
||||||
{
|
{
|
||||||
parent::__construct($parameters);
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
$this->setModuleFile($file_path);
|
$this->setModuleFile($file_path);
|
||||||
|
|
||||||
|
$this->runModuleFunction('init');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,11 +65,6 @@ class LegacyModule extends BaseModule
|
||||||
require_once $file_path;
|
require_once $file_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init()
|
|
||||||
{
|
|
||||||
$this->runModuleFunction('init');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function content(): string
|
public function content(): string
|
||||||
{
|
{
|
||||||
return $this->runModuleFunction('content');
|
return $this->runModuleFunction('content');
|
||||||
|
@ -90,8 +89,8 @@ class LegacyModule extends BaseModule
|
||||||
if (\function_exists($function_name)) {
|
if (\function_exists($function_name)) {
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
return $function_name($a);
|
return $function_name($a);
|
||||||
} else {
|
|
||||||
return parent::{$function_suffix}();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,18 +21,32 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Admin\Themes;
|
namespace Friendica\Module\Admin\Themes;
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Module\BaseAdmin;
|
use Friendica\Module\BaseAdmin;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
class Embed extends BaseAdmin
|
class Embed extends BaseAdmin
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var App */
|
||||||
|
protected $app;
|
||||||
|
/** @var App\BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
/** @var App\Mode */
|
||||||
|
protected $mode;
|
||||||
|
|
||||||
|
public function __construct(App $app, App\BaseURL $baseUrl, App\Mode $mode, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->app = $app;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
$this->mode = $mode;
|
||||||
|
|
||||||
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
|
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
|
||||||
if (is_file("view/theme/$theme/config.php")) {
|
if (is_file("view/theme/$theme/config.php")) {
|
||||||
DI::app()->setCurrentTheme($theme);
|
$this->app->setCurrentTheme($theme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,15 +59,15 @@ class Embed extends BaseAdmin
|
||||||
require_once "view/theme/$theme/config.php";
|
require_once "view/theme/$theme/config.php";
|
||||||
if (function_exists('theme_admin_post')) {
|
if (function_exists('theme_admin_post')) {
|
||||||
self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');
|
self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');
|
||||||
theme_admin_post(DI::app());
|
theme_admin_post($this->app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::mode()->isAjax()) {
|
if ($this->mode->isAjax()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
|
$this->baseUrl->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function content(): string
|
public function content(): string
|
||||||
|
@ -62,7 +76,7 @@ class Embed extends BaseAdmin
|
||||||
|
|
||||||
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
|
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
|
||||||
if (!is_dir("view/theme/$theme")) {
|
if (!is_dir("view/theme/$theme")) {
|
||||||
notice(DI::l10n()->t('Unknown theme.'));
|
notice($this->t('Unknown theme.'));
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +85,7 @@ class Embed extends BaseAdmin
|
||||||
require_once "view/theme/$theme/config.php";
|
require_once "view/theme/$theme/config.php";
|
||||||
|
|
||||||
if (function_exists('theme_admin')) {
|
if (function_exists('theme_admin')) {
|
||||||
$admin_form = theme_admin(DI::app());
|
$admin_form = theme_admin($this->app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,30 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Admin;
|
namespace Friendica\Module\Admin;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Module\BaseAdmin;
|
use Friendica\Module\BaseAdmin;
|
||||||
|
|
||||||
class Tos extends BaseAdmin
|
class Tos extends BaseAdmin
|
||||||
{
|
{
|
||||||
|
/** @var \Friendica\Module\Tos */
|
||||||
|
protected $tos;
|
||||||
|
/** @var IManageConfigValues */
|
||||||
|
protected $config;
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
|
public function __construct(\Friendica\Module\Tos $tos, IManageConfigValues $config, BaseURL $baseUrl, L10n $l10n, array $parameters = [])
|
||||||
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->tos = $tos;
|
||||||
|
$this->config = $config;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
public function post()
|
public function post()
|
||||||
{
|
{
|
||||||
self::checkAdminAccess();
|
self::checkAdminAccess();
|
||||||
|
@ -41,29 +59,28 @@ class Tos extends BaseAdmin
|
||||||
$displayprivstatement = !empty($_POST['displayprivstatement']);
|
$displayprivstatement = !empty($_POST['displayprivstatement']);
|
||||||
$tostext = (!empty($_POST['tostext']) ? strip_tags(trim($_POST['tostext'])) : '');
|
$tostext = (!empty($_POST['tostext']) ? strip_tags(trim($_POST['tostext'])) : '');
|
||||||
|
|
||||||
DI::config()->set('system', 'tosdisplay', $displaytos);
|
$this->config->set('system', 'tosdisplay', $displaytos);
|
||||||
DI::config()->set('system', 'tosprivstatement', $displayprivstatement);
|
$this->config->set('system', 'tosprivstatement', $displayprivstatement);
|
||||||
DI::config()->set('system', 'tostext', $tostext);
|
$this->config->set('system', 'tostext', $tostext);
|
||||||
|
|
||||||
DI::baseUrl()->redirect('admin/tos');
|
$this->baseUrl->redirect('admin/tos');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function content(): string
|
public function content(): string
|
||||||
{
|
{
|
||||||
parent::content();
|
parent::content();
|
||||||
|
|
||||||
$tos = new \Friendica\Module\Tos($this->parameters);
|
|
||||||
$t = Renderer::getMarkupTemplate('admin/tos.tpl');
|
$t = Renderer::getMarkupTemplate('admin/tos.tpl');
|
||||||
return Renderer::replaceMacros($t, [
|
return Renderer::replaceMacros($t, [
|
||||||
'$title' => DI::l10n()->t('Administration'),
|
'$title' => $this->t('Administration'),
|
||||||
'$page' => DI::l10n()->t('Terms of Service'),
|
'$page' => $this->t('Terms of Service'),
|
||||||
'$displaytos' => ['displaytos', DI::l10n()->t('Display Terms of Service'), DI::config()->get('system', 'tosdisplay'), DI::l10n()->t('Enable the Terms of Service page. If this is enabled a link to the terms will be added to the registration form and the general information page.')],
|
'$displaytos' => ['displaytos', $this->t('Display Terms of Service'), $this->config->get('system', 'tosdisplay'), $this->t('Enable the Terms of Service page. If this is enabled a link to the terms will be added to the registration form and the general information page.')],
|
||||||
'$displayprivstatement' => ['displayprivstatement', DI::l10n()->t('Display Privacy Statement'), DI::config()->get('system', 'tosprivstatement'), DI::l10n()->t('Show some informations regarding the needed information to operate the node according e.g. to <a href="%s" target="_blank" rel="noopener noreferrer">EU-GDPR</a>.', 'https://en.wikipedia.org/wiki/General_Data_Protection_Regulation')],
|
'$displayprivstatement' => ['displayprivstatement', $this->t('Display Privacy Statement'), $this->config->get('system', 'tosprivstatement'), $this->t('Show some informations regarding the needed information to operate the node according e.g. to <a href="%s" target="_blank" rel="noopener noreferrer">EU-GDPR</a>.', 'https://en.wikipedia.org/wiki/General_Data_Protection_Regulation')],
|
||||||
'$preview' => DI::l10n()->t('Privacy Statement Preview'),
|
'$preview' => $this->t('Privacy Statement Preview'),
|
||||||
'$privtext' => $tos->privacy_complete,
|
'$privtext' => $this->tos->privacy_complete,
|
||||||
'$tostext' => ['tostext', DI::l10n()->t('The Terms of Service'), DI::config()->get('system', 'tostext'), DI::l10n()->t('Enter the Terms of Service for your node here. You can use BBCode. Headers of sections should be [h2] and below.')],
|
'$tostext' => ['tostext', $this->t('The Terms of Service'), $this->config->get('system', 'tostext'), $this->t('Enter the Terms of Service for your node here. You can use BBCode. Headers of sections should be [h2] and below.')],
|
||||||
'$form_security_token' => self::getFormSecurityToken('admin_tos'),
|
'$form_security_token' => self::getFormSecurityToken('admin_tos'),
|
||||||
'$submit' => DI::l10n()->t('Save Settings'),
|
'$submit' => $this->t('Save Settings'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Api\Twitter;
|
namespace Friendica\Module\Api\Twitter;
|
||||||
|
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
|
@ -35,9 +36,9 @@ abstract class ContactEndpoint extends BaseApi
|
||||||
const DEFAULT_COUNT = 20;
|
const DEFAULT_COUNT = 20;
|
||||||
const MAX_COUNT = 200;
|
const MAX_COUNT = 200;
|
||||||
|
|
||||||
public function init()
|
public function __construct(L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
self::checkAllowedScope(self::SCOPE_READ);
|
self::checkAllowedScope(self::SCOPE_READ);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,21 +21,25 @@
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the App menu
|
* Shows the App menu
|
||||||
*/
|
*/
|
||||||
class Apps extends BaseModule
|
class Apps extends BaseModule
|
||||||
{
|
{
|
||||||
public function init()
|
public function __construct(L10n $l10n, IManageConfigValues $config, BaseURL $baseUrl, array $parameters = [])
|
||||||
{
|
{
|
||||||
$privateaddons = DI::config()->get('config', 'private_addons');
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$privateaddons = $config->get('config', 'private_addons');
|
||||||
if ($privateaddons === "1" && !local_user()) {
|
if ($privateaddons === "1" && !local_user()) {
|
||||||
DI::baseUrl()->redirect();
|
$baseUrl->redirect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,12 +48,12 @@ class Apps extends BaseModule
|
||||||
$apps = Nav::getAppMenu();
|
$apps = Nav::getAppMenu();
|
||||||
|
|
||||||
if (count($apps) == 0) {
|
if (count($apps) == 0) {
|
||||||
notice(DI::l10n()->t('No installed applications.'));
|
notice($this->t('No installed applications.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('apps.tpl');
|
$tpl = Renderer::getMarkupTemplate('apps.tpl');
|
||||||
return Renderer::replaceMacros($tpl, [
|
return Renderer::replaceMacros($tpl, [
|
||||||
'$title' => DI::l10n()->t('Applications'),
|
'$title' => $this->t('Applications'),
|
||||||
'$apps' => $apps,
|
'$apps' => $apps,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,12 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Friendica\App\Arguments;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Navigation\Notifications\ValueObject\FormattedNotification;
|
use Friendica\Navigation\Notifications\ValueObject\FormattedNotification;
|
||||||
use Friendica\Network\HTTPException\ForbiddenException;
|
use Friendica\Network\HTTPException\ForbiddenException;
|
||||||
|
|
||||||
|
@ -70,9 +71,12 @@ abstract class BaseNotifications extends BaseModule
|
||||||
const DEFAULT_PAGE_LIMIT = 80;
|
const DEFAULT_PAGE_LIMIT = 80;
|
||||||
|
|
||||||
/** @var boolean True, if ALL entries should get shown */
|
/** @var boolean True, if ALL entries should get shown */
|
||||||
protected static $showAll;
|
protected $showAll;
|
||||||
/** @var int The determined start item of the current page */
|
/** @var int The determined start item of the current page */
|
||||||
protected static $firstItemNum;
|
protected $firstItemNum;
|
||||||
|
|
||||||
|
/** @var Arguments */
|
||||||
|
protected $args;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects all notifications from the backend
|
* Collects all notifications from the backend
|
||||||
|
@ -80,33 +84,37 @@ abstract class BaseNotifications extends BaseModule
|
||||||
* @return array The determined notification array
|
* @return array The determined notification array
|
||||||
* ['header', 'notifications']
|
* ['header', 'notifications']
|
||||||
*/
|
*/
|
||||||
abstract public static function getNotifications();
|
abstract public function getNotifications();
|
||||||
|
|
||||||
public function init()
|
public function __construct(Arguments $args, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
|
throw new ForbiddenException($this->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = ($_REQUEST['page'] ?? 0) ?: 1;
|
$page = ($_REQUEST['page'] ?? 0) ?: 1;
|
||||||
|
|
||||||
self::$firstItemNum = ($page * self::ITEMS_PER_PAGE) - self::ITEMS_PER_PAGE;
|
$this->firstItemNum = ($page * self::ITEMS_PER_PAGE) - self::ITEMS_PER_PAGE;
|
||||||
self::$showAll = ($_REQUEST['show'] ?? '') === 'all';
|
$this->showAll = ($_REQUEST['show'] ?? '') === 'all';
|
||||||
|
|
||||||
|
$this->args = $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rawContent()
|
public function rawContent()
|
||||||
{
|
{
|
||||||
// If the last argument of the query is NOT json, return
|
// If the last argument of the query is NOT json, return
|
||||||
if (DI::args()->get(DI::args()->getArgc() - 1) !== 'json') {
|
if ($this->args->get($this->args->getArgc() - 1) !== 'json') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the pager
|
// Set the pager
|
||||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), self::ITEMS_PER_PAGE);
|
$pager = new Pager($this->l10n, $this->args->getQueryString(), self::ITEMS_PER_PAGE);
|
||||||
|
|
||||||
// Add additional informations (needed for json output)
|
// Add additional informations (needed for json output)
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'notifications' => static::getNotifications(),
|
'notifications' => $this->getNotifications(),
|
||||||
'items_page' => $pager->getItemsPerPage(),
|
'items_page' => $pager->getItemsPerPage(),
|
||||||
'page' => $pager->getPage(),
|
'page' => $pager->getPage(),
|
||||||
];
|
];
|
||||||
|
@ -126,17 +134,17 @@ abstract class BaseNotifications extends BaseModule
|
||||||
*
|
*
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
protected static function printContent(string $header, array $notifications, string $noContent, array $showLink)
|
protected function printContent(string $header, array $notifications, string $noContent, array $showLink)
|
||||||
{
|
{
|
||||||
// Get the nav tabs for the notification pages
|
// Get the nav tabs for the notification pages
|
||||||
$tabs = self::getTabs();
|
$tabs = $this->getTabs();
|
||||||
|
|
||||||
// Set the pager
|
// Set the pager
|
||||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), self::ITEMS_PER_PAGE);
|
$pager = new Pager($this->l10n, $this->args->getQueryString(), self::ITEMS_PER_PAGE);
|
||||||
|
|
||||||
$notif_tpl = Renderer::getMarkupTemplate('notifications/notifications.tpl');
|
$notif_tpl = Renderer::getMarkupTemplate('notifications/notifications.tpl');
|
||||||
return Renderer::replaceMacros($notif_tpl, [
|
return Renderer::replaceMacros($notif_tpl, [
|
||||||
'$header' => $header ?? DI::l10n()->t('Notifications'),
|
'$header' => $header ?? $this->t('Notifications'),
|
||||||
'$tabs' => $tabs,
|
'$tabs' => $tabs,
|
||||||
'$notifications' => $notifications,
|
'$notifications' => $notifications,
|
||||||
'$noContent' => $noContent,
|
'$noContent' => $noContent,
|
||||||
|
@ -151,15 +159,15 @@ abstract class BaseNotifications extends BaseModule
|
||||||
* @return array with with notifications TabBar data
|
* @return array with with notifications TabBar data
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private static function getTabs()
|
private function getTabs()
|
||||||
{
|
{
|
||||||
$selected = DI::args()->get(1, '');
|
$selected = $this->args->get(1, '');
|
||||||
|
|
||||||
$tabs = [];
|
$tabs = [];
|
||||||
|
|
||||||
foreach (self::URL_TYPES as $type => $url) {
|
foreach (self::URL_TYPES as $type => $url) {
|
||||||
$tabs[] = [
|
$tabs[] = [
|
||||||
'label' => DI::l10n()->t(self::PRINT_TYPES[$type]),
|
'label' => $this->t(self::PRINT_TYPES[$type]),
|
||||||
'url' => 'notifications/' . $url,
|
'url' => 'notifications/' . $url,
|
||||||
'sel' => (($selected == $url) ? 'active' : ''),
|
'sel' => (($selected == $url) ? 'active' : ''),
|
||||||
'id' => $type . '-tab',
|
'id' => $type . '-tab',
|
||||||
|
|
|
@ -21,27 +21,43 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Contact;
|
namespace Friendica\Module\Contact;
|
||||||
|
|
||||||
|
use Friendica\App\Page;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\Widget;
|
use Friendica\Content\Widget;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session;
|
||||||
use Friendica\DI;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
use Friendica\Module\Contact;
|
use Friendica\Module\Contact;
|
||||||
use Friendica\Network\HTTPException\BadRequestException;
|
use Friendica\Network\HTTPException\BadRequestException;
|
||||||
use Friendica\Network\HTTPException\ForbiddenException;
|
use Friendica\Network\HTTPException\ForbiddenException;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GUI for advanced contact details manipulation
|
* GUI for advanced contact details manipulation
|
||||||
*/
|
*/
|
||||||
class Advanced extends BaseModule
|
class Advanced extends BaseModule
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var Database */
|
||||||
|
protected $dba;
|
||||||
|
/** @var LoggerInterface */
|
||||||
|
protected $logger;
|
||||||
|
/** @var Page */
|
||||||
|
protected $page;
|
||||||
|
|
||||||
|
public function __construct(Database $dba, LoggerInterface $logger, Page $page, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->dba = $dba;
|
||||||
|
$this->logger = $logger;
|
||||||
|
$this->page = $page;
|
||||||
|
|
||||||
if (!Session::isAuthenticated()) {
|
if (!Session::isAuthenticated()) {
|
||||||
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
|
throw new ForbiddenException($this->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +67,7 @@ class Advanced extends BaseModule
|
||||||
|
|
||||||
$contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]);
|
$contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]);
|
||||||
if (empty($contact)) {
|
if (empty($contact)) {
|
||||||
throw new BadRequestException(DI::l10n()->t('Contact not found.'));
|
throw new BadRequestException($this->t('Contact not found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = ($_POST['name'] ?? '') ?: $contact['name'];
|
$name = ($_POST['name'] ?? '') ?: $contact['name'];
|
||||||
|
@ -66,7 +82,7 @@ class Advanced extends BaseModule
|
||||||
$photo = $_POST['photo'] ?? '';
|
$photo = $_POST['photo'] ?? '';
|
||||||
$nurl = Strings::normaliseLink($url);
|
$nurl = Strings::normaliseLink($url);
|
||||||
|
|
||||||
$r = DI::dba()->update(
|
$r = $this->dba->update(
|
||||||
'contact',
|
'contact',
|
||||||
[
|
[
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
|
@ -84,16 +100,14 @@ class Advanced extends BaseModule
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($photo) {
|
if ($photo) {
|
||||||
DI::logger()->notice('Updating photo.', ['photo' => $photo]);
|
$this->logger->notice('Updating photo.', ['photo' => $photo]);
|
||||||
|
|
||||||
Model\Contact::updateAvatar($contact['id'], $photo, true);
|
Model\Contact::updateAvatar($contact['id'], $photo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
notice(DI::l10n()->t('Contact update failed.'));
|
notice($this->t('Contact update failed.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function content(): string
|
public function content(): string
|
||||||
|
@ -102,13 +116,13 @@ class Advanced extends BaseModule
|
||||||
|
|
||||||
$contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]);
|
$contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]);
|
||||||
if (empty($contact)) {
|
if (empty($contact)) {
|
||||||
throw new BadRequestException(DI::l10n()->t('Contact not found.'));
|
throw new BadRequestException($this->t('Contact not found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::page()['aside'] = Widget\VCard::getHTML($contact);
|
$this->page['aside'] = Widget\VCard::getHTML($contact);
|
||||||
|
|
||||||
$warning = DI::l10n()->t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
|
$warning = $this->t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
|
||||||
$info = DI::l10n()->t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
|
$info = $this->t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
|
||||||
|
|
||||||
$returnaddr = "contact/$cid";
|
$returnaddr = "contact/$cid";
|
||||||
|
|
||||||
|
@ -128,20 +142,20 @@ class Advanced extends BaseModule
|
||||||
'$warning' => $warning,
|
'$warning' => $warning,
|
||||||
'$info' => $info,
|
'$info' => $info,
|
||||||
'$returnaddr' => $returnaddr,
|
'$returnaddr' => $returnaddr,
|
||||||
'$return' => DI::l10n()->t('Return to contact editor'),
|
'$return' => $this->t('Return to contact editor'),
|
||||||
'$contact_id' => $contact['id'],
|
'$contact_id' => $contact['id'],
|
||||||
'$lbl_submit' => DI::l10n()->t('Submit'),
|
'$lbl_submit' => $this->t('Submit'),
|
||||||
|
|
||||||
'$name' => ['name', DI::l10n()->t('Name'), $contact['name'], '', '', $readonly],
|
'$name' => ['name', $this->t('Name'), $contact['name'], '', '', $readonly],
|
||||||
'$nick' => ['nick', DI::l10n()->t('Account Nickname'), $contact['nick'], '', '', $readonly],
|
'$nick' => ['nick', $this->t('Account Nickname'), $contact['nick'], '', '', $readonly],
|
||||||
'$attag' => ['attag', DI::l10n()->t('@Tagname - overrides Name/Nickname'), $contact['attag']],
|
'$attag' => ['attag', $this->t('@Tagname - overrides Name/Nickname'), $contact['attag']],
|
||||||
'$url' => ['url', DI::l10n()->t('Account URL'), $contact['url'], '', '', $readonly],
|
'$url' => ['url', $this->t('Account URL'), $contact['url'], '', '', $readonly],
|
||||||
'$alias' => ['alias', DI::l10n()->t('Account URL Alias'), $contact['alias'], '', '', $readonly],
|
'$alias' => ['alias', $this->t('Account URL Alias'), $contact['alias'], '', '', $readonly],
|
||||||
'$request' => ['request', DI::l10n()->t('Friend Request URL'), $contact['request'], '', '', $readonly],
|
'$request' => ['request', $this->t('Friend Request URL'), $contact['request'], '', '', $readonly],
|
||||||
'confirm' => ['confirm', DI::l10n()->t('Friend Confirm URL'), $contact['confirm'], '', '', $readonly],
|
'confirm' => ['confirm', $this->t('Friend Confirm URL'), $contact['confirm'], '', '', $readonly],
|
||||||
'notify' => ['notify', DI::l10n()->t('Notification Endpoint URL'), $contact['notify'], '', '', $readonly],
|
'notify' => ['notify', $this->t('Notification Endpoint URL'), $contact['notify'], '', '', $readonly],
|
||||||
'poll' => ['poll', DI::l10n()->t('Poll/Feed URL'), $contact['poll'], '', '', $readonly],
|
'poll' => ['poll', $this->t('Poll/Feed URL'), $contact['poll'], '', '', $readonly],
|
||||||
'photo' => ['photo', DI::l10n()->t('New photo from this URL'), '', '', '', $readonly],
|
'photo' => ['photo', $this->t('New photo from this URL'), '', '', '', $readonly],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,14 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Contact;
|
namespace Friendica\Module\Contact;
|
||||||
|
|
||||||
|
use Friendica\App\Arguments;
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\Database;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
use Friendica\Module\Contact;
|
use Friendica\Module\Contact;
|
||||||
use Friendica\Module\Security\Login;
|
use Friendica\Module\Security\Login;
|
||||||
|
@ -35,31 +37,44 @@ use Friendica\Network\HTTPException;
|
||||||
class Revoke extends BaseModule
|
class Revoke extends BaseModule
|
||||||
{
|
{
|
||||||
/** @var array */
|
/** @var array */
|
||||||
private static $contact;
|
protected $contact;
|
||||||
|
|
||||||
public function init()
|
/** @var Database */
|
||||||
|
protected $dba;
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
/** @var Arguments */
|
||||||
|
protected $args;
|
||||||
|
|
||||||
|
public function __construct(Database $dba, BaseURL $baseUrl, Arguments $args, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->dba = $dba;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
$this->args = $args;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], local_user());
|
$data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], local_user());
|
||||||
if (!DBA::isResult($data)) {
|
if (!$this->dba->isResult($data)) {
|
||||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Unknown contact.'));
|
throw new HTTPException\NotFoundException($this->t('Unknown contact.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($data['user'])) {
|
if (empty($data['user'])) {
|
||||||
throw new HTTPException\ForbiddenException();
|
throw new HTTPException\ForbiddenException();
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$contact = Model\Contact::getById($data['user']);
|
$this->contact = Model\Contact::getById($data['user']);
|
||||||
|
|
||||||
if (self::$contact['deleted']) {
|
if ($this->contact['deleted']) {
|
||||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact is deleted.'));
|
throw new HTTPException\NotFoundException($this->t('Contact is deleted.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty(self::$contact['network']) && self::$contact['network'] == Protocol::PHANTOM) {
|
if (!empty($this->contact['network']) && $this->contact['network'] == Protocol::PHANTOM) {
|
||||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact is being deleted.'));
|
throw new HTTPException\NotFoundException($this->t('Contact is being deleted.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,16 +86,16 @@ class Revoke extends BaseModule
|
||||||
|
|
||||||
self::checkFormSecurityTokenRedirectOnError('contact/' . $this->parameters['id'], 'contact_revoke');
|
self::checkFormSecurityTokenRedirectOnError('contact/' . $this->parameters['id'], 'contact_revoke');
|
||||||
|
|
||||||
$result = Model\Contact::revokeFollow(self::$contact);
|
$result = Model\Contact::revokeFollow($this->contact);
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
notice(DI::l10n()->t('Follow was successfully revoked.'));
|
notice($this->t('Follow was successfully revoked.'));
|
||||||
} elseif ($result === null) {
|
} elseif ($result === null) {
|
||||||
notice(DI::l10n()->t('Follow was successfully revoked, however the remote contact won\'t be aware of this revokation.'));
|
notice($this->t('Follow was successfully revoked, however the remote contact won\'t be aware of this revokation.'));
|
||||||
} else {
|
} else {
|
||||||
notice(DI::l10n()->t('Unable to revoke follow, please try again later or contact the administrator.'));
|
notice($this->t('Unable to revoke follow, please try again later or contact the administrator.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::baseUrl()->redirect('contact/' . $this->parameters['id']);
|
$this->baseUrl->redirect('contact/' . $this->parameters['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function content(): string
|
public function content(): string
|
||||||
|
@ -93,14 +108,14 @@ class Revoke extends BaseModule
|
||||||
|
|
||||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_drop_confirm.tpl'), [
|
return Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_drop_confirm.tpl'), [
|
||||||
'$l10n' => [
|
'$l10n' => [
|
||||||
'header' => DI::l10n()->t('Revoke Follow'),
|
'header' => $this->t('Revoke Follow'),
|
||||||
'message' => DI::l10n()->t('Do you really want to revoke this contact\'s follow? This cannot be undone and they will have to manually follow you back again.'),
|
'message' => $this->t('Do you really want to revoke this contact\'s follow? This cannot be undone and they will have to manually follow you back again.'),
|
||||||
'confirm' => DI::l10n()->t('Yes'),
|
'confirm' => $this->t('Yes'),
|
||||||
'cancel' => DI::l10n()->t('Cancel'),
|
'cancel' => $this->t('Cancel'),
|
||||||
],
|
],
|
||||||
'$contact' => Contact::getContactTemplateVars(self::$contact),
|
'$contact' => Contact::getContactTemplateVars($this->contact),
|
||||||
'$method' => 'post',
|
'$method' => 'post',
|
||||||
'$confirm_url' => DI::args()->getCommand(),
|
'$confirm_url' => $this->args->getCommand(),
|
||||||
'$confirm_name' => 'form_security_token',
|
'$confirm_name' => 'form_security_token',
|
||||||
'$confirm_value' => BaseModule::getFormSecurityToken('contact_revoke'),
|
'$confirm_value' => BaseModule::getFormSecurityToken('contact_revoke'),
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -21,10 +21,12 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Debug;
|
namespace Friendica\Module\Debug;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
|
use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
|
||||||
use Friendica\Protocol;
|
use Friendica\Protocol;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,11 +34,18 @@ use Friendica\Protocol;
|
||||||
*/
|
*/
|
||||||
class Feed extends BaseModule
|
class Feed extends BaseModule
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var ICanSendHttpRequests */
|
||||||
|
protected $httpClient;
|
||||||
|
|
||||||
|
public function __construct(BaseURL $baseUrl, ICanSendHttpRequests $httpClient, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->httpClient = $httpClient;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
notice(DI::l10n()->t('You must be logged in to use this module'));
|
notice($this->t('You must be logged in to use this module'));
|
||||||
DI::baseUrl()->redirect();
|
$baseUrl->redirect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +57,7 @@ class Feed extends BaseModule
|
||||||
|
|
||||||
$contact = Model\Contact::getByURLForUser($url, local_user(), null);
|
$contact = Model\Contact::getByURLForUser($url, local_user(), null);
|
||||||
|
|
||||||
$xml = DI::httpClient()->fetch($contact['poll']);
|
$xml = $this->httpClient->fetch($contact['poll']);
|
||||||
|
|
||||||
$import_result = Protocol\Feed::import($xml);
|
$import_result = Protocol\Feed::import($xml);
|
||||||
|
|
||||||
|
@ -60,7 +69,7 @@ class Feed extends BaseModule
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('feedtest.tpl');
|
$tpl = Renderer::getMarkupTemplate('feedtest.tpl');
|
||||||
return Renderer::replaceMacros($tpl, [
|
return Renderer::replaceMacros($tpl, [
|
||||||
'$url' => ['url', DI::l10n()->t('Source URL'), $_REQUEST['url'] ?? '', ''],
|
'$url' => ['url', $this->t('Source URL'), $_REQUEST['url'] ?? '', ''],
|
||||||
'$result' => $result
|
'$result' => $result
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
namespace Friendica\Module\Diaspora;
|
namespace Friendica\Module\Diaspora;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\DI;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Protocol\Diaspora;
|
use Friendica\Protocol\Diaspora;
|
||||||
|
@ -36,25 +37,30 @@ use Psr\Log\LoggerInterface;
|
||||||
class Receive extends BaseModule
|
class Receive extends BaseModule
|
||||||
{
|
{
|
||||||
/** @var LoggerInterface */
|
/** @var LoggerInterface */
|
||||||
private static $logger;
|
protected $logger;
|
||||||
|
/** @var IManageConfigValues */
|
||||||
|
protected $config;
|
||||||
|
|
||||||
public function init()
|
public function __construct(LoggerInterface $logger, IManageConfigValues $config, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
self::$logger = DI::logger();
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->logger = $logger;
|
||||||
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post()
|
public function post()
|
||||||
{
|
{
|
||||||
$enabled = DI::config()->get('system', 'diaspora_enabled', false);
|
$enabled = $this->config->get('system', 'diaspora_enabled', false);
|
||||||
if (!$enabled) {
|
if (!$enabled) {
|
||||||
self::$logger->info('Diaspora disabled.');
|
$this->logger->info('Diaspora disabled.');
|
||||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
|
throw new HTTPException\ForbiddenException($this->t('Access denied.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->parameters['type'] === 'public') {
|
if ($this->parameters['type'] === 'public') {
|
||||||
self::receivePublic();
|
$this->receivePublic();
|
||||||
} else if ($this->parameters['type'] === 'users') {
|
} else if ($this->parameters['type'] === 'users') {
|
||||||
self::receiveUser($this->parameters['guid']);
|
$this->receiveUser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,13 +70,13 @@ class Receive extends BaseModule
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
private static function receivePublic()
|
private function receivePublic()
|
||||||
{
|
{
|
||||||
self::$logger->info('Diaspora: Receiving post.');
|
$this->logger->info('Diaspora: Receiving post.');
|
||||||
|
|
||||||
$msg = self::decodePost();
|
$msg = $this->decodePost();
|
||||||
|
|
||||||
self::$logger->info('Diaspora: Dispatching.');
|
$this->logger->info('Diaspora: Dispatching.');
|
||||||
|
|
||||||
Diaspora::dispatchPublic($msg);
|
Diaspora::dispatchPublic($msg);
|
||||||
}
|
}
|
||||||
|
@ -78,20 +84,18 @@ class Receive extends BaseModule
|
||||||
/**
|
/**
|
||||||
* Receive a Diaspora posting for a user
|
* Receive a Diaspora posting for a user
|
||||||
*
|
*
|
||||||
* @param string $guid The GUID of the importer
|
|
||||||
*
|
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
private static function receiveUser(string $guid)
|
private function receiveUser()
|
||||||
{
|
{
|
||||||
self::$logger->info('Diaspora: Receiving post.');
|
$this->logger->info('Diaspora: Receiving post.');
|
||||||
|
|
||||||
$importer = User::getByGuid($guid);
|
$importer = User::getByGuid($this->parameters['guid']);
|
||||||
|
|
||||||
$msg = self::decodePost(false, $importer['prvkey'] ?? '');
|
$msg = $this->decodePost(false, $importer['prvkey'] ?? '');
|
||||||
|
|
||||||
self::$logger->info('Diaspora: Dispatching.');
|
$this->logger->info('Diaspora: Dispatching.');
|
||||||
|
|
||||||
if (Diaspora::dispatch($importer, $msg)) {
|
if (Diaspora::dispatch($importer, $msg)) {
|
||||||
throw new HTTPException\OKException();
|
throw new HTTPException\OKException();
|
||||||
|
@ -112,7 +116,7 @@ class Receive extends BaseModule
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
private static function decodePost(bool $public = true, string $privKey = '')
|
private function decodePost(bool $public = true, string $privKey = '')
|
||||||
{
|
{
|
||||||
if (empty($_POST['xml'])) {
|
if (empty($_POST['xml'])) {
|
||||||
|
|
||||||
|
@ -122,24 +126,24 @@ class Receive extends BaseModule
|
||||||
throw new HTTPException\InternalServerErrorException('Missing postdata.');
|
throw new HTTPException\InternalServerErrorException('Missing postdata.');
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$logger->info('Diaspora: Message is in the new format.');
|
$this->logger->info('Diaspora: Message is in the new format.');
|
||||||
|
|
||||||
$msg = Diaspora::decodeRaw($postdata, $privKey);
|
$msg = Diaspora::decodeRaw($postdata, $privKey);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$xml = urldecode($_POST['xml']);
|
$xml = urldecode($_POST['xml']);
|
||||||
|
|
||||||
self::$logger->info('Diaspora: Decode message in the old format.');
|
$this->logger->info('Diaspora: Decode message in the old format.');
|
||||||
$msg = Diaspora::decode($xml, $privKey);
|
$msg = Diaspora::decode($xml, $privKey);
|
||||||
|
|
||||||
if ($public && !$msg) {
|
if ($public && !$msg) {
|
||||||
self::$logger->info('Diaspora: Decode message in the new format.');
|
$this->logger->info('Diaspora: Decode message in the new format.');
|
||||||
$msg = Diaspora::decodeRaw($xml, $privKey);
|
$msg = Diaspora::decodeRaw($xml, $privKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$logger->info('Diaspora: Post decoded.');
|
$this->logger->info('Diaspora: Post decoded.');
|
||||||
self::$logger->debug('Diaspora: Decoded message.', ['msg' => $msg]);
|
$this->logger->debug('Diaspora: Decoded message.', ['msg' => $msg]);
|
||||||
|
|
||||||
if (!is_array($msg)) {
|
if (!is_array($msg)) {
|
||||||
throw new HTTPException\InternalServerErrorException('Message is not an array.');
|
throw new HTTPException\InternalServerErrorException('Message is not an array.');
|
||||||
|
|
|
@ -21,36 +21,43 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Filer;
|
namespace Friendica\Module\Filer;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Util\XML;
|
use Friendica\Util\XML;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a dialog for adding tags to a file
|
* Shows a dialog for adding tags to a file
|
||||||
*/
|
*/
|
||||||
class SaveTag extends BaseModule
|
class SaveTag extends BaseModule
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var LoggerInterface */
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
|
public function __construct(LoggerInterface $logger, BaseURL $baseUrl, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->logger = $logger;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
notice(DI::l10n()->t('You must be logged in to use this module'));
|
notice($this->t('You must be logged in to use this module'));
|
||||||
DI::baseUrl()->redirect();
|
$baseUrl->redirect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rawContent()
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$logger = DI::logger();
|
|
||||||
|
|
||||||
$term = XML::unescape(trim($_GET['term'] ?? ''));
|
$term = XML::unescape(trim($_GET['term'] ?? ''));
|
||||||
|
|
||||||
$item_id = $this->parameters['id'] ?? 0;
|
$item_id = $this->parameters['id'] ?? 0;
|
||||||
|
|
||||||
$logger->info('filer', ['tag' => $term, 'item' => $item_id]);
|
$this->logger->info('filer', ['tag' => $term, 'item' => $item_id]);
|
||||||
|
|
||||||
if ($item_id && strlen($term)) {
|
if ($item_id && strlen($term)) {
|
||||||
$item = Model\Post::selectFirst(['uri-id'], ['id' => $item_id]);
|
$item = Model\Post::selectFirst(['uri-id'], ['id' => $item_id]);
|
||||||
|
@ -65,8 +72,8 @@ class SaveTag extends BaseModule
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
|
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
|
||||||
echo Renderer::replaceMacros($tpl, [
|
echo Renderer::replaceMacros($tpl, [
|
||||||
'$field' => ['term', DI::l10n()->t("Save to Folder:"), '', '', $filetags, DI::l10n()->t('- select -')],
|
'$field' => ['term', $this->t("Save to Folder:"), '', '', $filetags, $this->t('- select -')],
|
||||||
'$submit' => DI::l10n()->t('Save'),
|
'$submit' => $this->t('Save'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -21,15 +21,16 @@
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\DI;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Model\Contact as ContactModel;
|
use Friendica\Model\Contact as ContactModel;
|
||||||
use Friendica\Network\HTTPException\ForbiddenException;
|
use Friendica\Network\HTTPException\ForbiddenException;
|
||||||
use Friendica\Network\HTTPException\NotFoundException;
|
use Friendica\Network\HTTPException\NotFoundException;
|
||||||
use Friendica\Util\DateTimeFormat;
|
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Friendica\Worker\Delivery;
|
use Friendica\Worker\Delivery;
|
||||||
|
|
||||||
|
@ -38,11 +39,27 @@ use Friendica\Worker\Delivery;
|
||||||
*/
|
*/
|
||||||
class FriendSuggest extends BaseModule
|
class FriendSuggest extends BaseModule
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
/** @var Database */
|
||||||
|
protected $dba;
|
||||||
|
/** @var \Friendica\Contact\FriendSuggest\Repository\FriendSuggest */
|
||||||
|
protected $friendSuggestRepo;
|
||||||
|
/** @var \Friendica\Contact\FriendSuggest\Factory\FriendSuggest */
|
||||||
|
protected $friendSuggestFac;
|
||||||
|
|
||||||
|
public function __construct(BaseURL $baseUrl, Database $dba, \Friendica\Contact\FriendSuggest\Repository\FriendSuggest $friendSuggestRepo, \Friendica\Contact\FriendSuggest\Factory\FriendSuggest $friendSuggestFac, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
|
throw new ForbiddenException($this->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
$this->dba = $dba;
|
||||||
|
$this->friendSuggestRepo = $friendSuggestRepo;
|
||||||
|
$this->friendSuggestFac = $friendSuggestFac;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post()
|
public function post()
|
||||||
|
@ -50,8 +67,8 @@ class FriendSuggest extends BaseModule
|
||||||
$cid = intval($this->parameters['contact']);
|
$cid = intval($this->parameters['contact']);
|
||||||
|
|
||||||
// We do query the "uid" as well to ensure that it is our contact
|
// We do query the "uid" as well to ensure that it is our contact
|
||||||
if (!DI::dba()->exists('contact', ['id' => $cid, 'uid' => local_user()])) {
|
if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => local_user()])) {
|
||||||
throw new NotFoundException(DI::l10n()->t('Contact not found.'));
|
throw new NotFoundException($this->t('Contact not found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$suggest_contact_id = intval($_POST['suggest']);
|
$suggest_contact_id = intval($_POST['suggest']);
|
||||||
|
@ -60,15 +77,15 @@ class FriendSuggest extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
// We do query the "uid" as well to ensure that it is our contact
|
// We do query the "uid" as well to ensure that it is our contact
|
||||||
$contact = DI::dba()->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => local_user()]);
|
$contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => local_user()]);
|
||||||
if (empty($contact)) {
|
if (empty($contact)) {
|
||||||
notice(DI::l10n()->t('Suggested contact not found.'));
|
notice($this->t('Suggested contact not found.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
|
$note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
|
||||||
|
|
||||||
$suggest = DI::fsuggest()->save(DI::fsuggestFactory()->createNew(
|
$suggest = $this->friendSuggestRepo->save($this->friendSuggestFac->createNew(
|
||||||
local_user(),
|
local_user(),
|
||||||
$cid,
|
$cid,
|
||||||
$contact['name'],
|
$contact['name'],
|
||||||
|
@ -80,17 +97,17 @@ class FriendSuggest extends BaseModule
|
||||||
|
|
||||||
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id);
|
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id);
|
||||||
|
|
||||||
info(DI::l10n()->t('Friend suggestion sent.'));
|
info($this->t('Friend suggestion sent.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function content(): string
|
public function content(): string
|
||||||
{
|
{
|
||||||
$cid = intval($this->parameters['contact']);
|
$cid = intval($this->parameters['contact']);
|
||||||
|
|
||||||
$contact = DI::dba()->selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
|
$contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
|
||||||
if (empty($contact)) {
|
if (empty($contact)) {
|
||||||
notice(DI::l10n()->t('Contact not found.'));
|
notice($this->t('Contact not found.'));
|
||||||
DI::baseUrl()->redirect();
|
$this->baseUrl->redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
$suggestableContacts = ContactModel::selectToArray(['id', 'name'], [
|
$suggestableContacts = ContactModel::selectToArray(['id', 'name'], [
|
||||||
|
@ -117,15 +134,15 @@ class FriendSuggest extends BaseModule
|
||||||
$tpl = Renderer::getMarkupTemplate('fsuggest.tpl');
|
$tpl = Renderer::getMarkupTemplate('fsuggest.tpl');
|
||||||
return Renderer::replaceMacros($tpl, [
|
return Renderer::replaceMacros($tpl, [
|
||||||
'$contact_id' => $cid,
|
'$contact_id' => $cid,
|
||||||
'$fsuggest_title' => DI::l10n()->t('Suggest Friends'),
|
'$fsuggest_title' => $this->t('Suggest Friends'),
|
||||||
'$fsuggest_select' => [
|
'$fsuggest_select' => [
|
||||||
'suggest',
|
'suggest',
|
||||||
DI::l10n()->t('Suggest a friend for %s', $contact['name']),
|
$this->t('Suggest a friend for %s', $contact['name']),
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
$formattedContacts,
|
$formattedContacts,
|
||||||
],
|
],
|
||||||
'$submit' => DI::l10n()->t('Submit'),
|
'$submit' => $this->t('Submit'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core;
|
use Friendica\Core;
|
||||||
use Friendica\Core\Config\ValueObject\Cache;
|
use Friendica\Core\Config\ValueObject\Cache;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -58,110 +59,119 @@ class Install extends BaseModule
|
||||||
/**
|
/**
|
||||||
* @var int The current step of the wizard
|
* @var int The current step of the wizard
|
||||||
*/
|
*/
|
||||||
private static $currentWizardStep;
|
private $currentWizardStep;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Core\Installer The installer
|
* @var Core\Installer The installer
|
||||||
*/
|
*/
|
||||||
private static $installer;
|
private $installer;
|
||||||
|
|
||||||
|
/** @var App */
|
||||||
|
protected $app;
|
||||||
|
/** @var App\Mode */
|
||||||
|
protected $mode;
|
||||||
|
/** @var App\BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
public function init()
|
public function __construct(App $app, App\Mode $mode, App\BaseURL $baseUrl, App\Arguments $args, Core\Installer $installer, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
if (!DI::mode()->isInstall()) {
|
$this->app = $app;
|
||||||
|
$this->mode = $mode;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
$this->installer = $installer;
|
||||||
|
|
||||||
|
if (!$this->mode->isInstall()) {
|
||||||
throw new HTTPException\ForbiddenException();
|
throw new HTTPException\ForbiddenException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// route: install/testrwrite
|
// route: install/testrwrite
|
||||||
// $baseurl/install/testrwrite to test if rewrite in .htaccess is working
|
// $baseurl/install/testrwrite to test if rewrite in .htaccess is working
|
||||||
if (DI::args()->get(1, '') == 'testrewrite') {
|
if ($args->get(1, '') == 'testrewrite') {
|
||||||
// Status Code 204 means that it worked without content
|
// Status Code 204 means that it worked without content
|
||||||
throw new HTTPException\NoContentException();
|
throw new HTTPException\NoContentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$installer = new Core\Installer();
|
|
||||||
|
|
||||||
// get basic installation information and save them to the config cache
|
// get basic installation information and save them to the config cache
|
||||||
$configCache = $a->getConfigCache();
|
$configCache = $this->app->getConfigCache();
|
||||||
$basePath = new BasePath($a->getBasePath());
|
$basePath = new BasePath($this->app->getBasePath());
|
||||||
self::$installer->setUpCache($configCache, $basePath->getPath());
|
$this->installer->setUpCache($configCache, $basePath->getPath());
|
||||||
|
|
||||||
// We overwrite current theme css, because during install we may not have a working mod_rewrite
|
// We overwrite current theme css, because during install we may not have a working mod_rewrite
|
||||||
// so we may not have a css at all. Here we set a static css file for the install procedure pages
|
// so we may not have a css at all. Here we set a static css file for the install procedure pages
|
||||||
Renderer::$theme['stylesheet'] = DI::baseUrl()->get() . '/view/install/style.css';
|
Renderer::$theme['stylesheet'] = $this->baseUrl->get() . '/view/install/style.css';
|
||||||
|
|
||||||
self::$currentWizardStep = ($_POST['pass'] ?? '') ?: self::SYSTEM_CHECK;
|
$this->currentWizardStep = ($_POST['pass'] ?? '') ?: self::SYSTEM_CHECK;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post()
|
public function post()
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
$configCache = $this->app->getConfigCache();
|
||||||
$configCache = $a->getConfigCache();
|
|
||||||
|
|
||||||
switch (self::$currentWizardStep) {
|
switch ($this->currentWizardStep) {
|
||||||
case self::SYSTEM_CHECK:
|
case self::SYSTEM_CHECK:
|
||||||
case self::BASE_CONFIG:
|
case self::BASE_CONFIG:
|
||||||
self::checkSetting($configCache, $_POST, 'config', 'php_path');
|
$this->checkSetting($configCache, $_POST, 'config', 'php_path');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::DATABASE_CONFIG:
|
case self::DATABASE_CONFIG:
|
||||||
self::checkSetting($configCache, $_POST, 'config', 'php_path');
|
$this->checkSetting($configCache, $_POST, 'config', 'php_path');
|
||||||
|
|
||||||
self::checkSetting($configCache, $_POST, 'config', 'hostname');
|
$this->checkSetting($configCache, $_POST, 'config', 'hostname');
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'ssl_policy');
|
$this->checkSetting($configCache, $_POST, 'system', 'ssl_policy');
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'basepath');
|
$this->checkSetting($configCache, $_POST, 'system', 'basepath');
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'urlpath');
|
$this->checkSetting($configCache, $_POST, 'system', 'urlpath');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::SITE_SETTINGS:
|
case self::SITE_SETTINGS:
|
||||||
self::checkSetting($configCache, $_POST, 'config', 'php_path');
|
$this->checkSetting($configCache, $_POST, 'config', 'php_path');
|
||||||
|
|
||||||
self::checkSetting($configCache, $_POST, 'config', 'hostname');
|
$this->checkSetting($configCache, $_POST, 'config', 'hostname');
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'ssl_policy');
|
$this->checkSetting($configCache, $_POST, 'system', 'ssl_policy');
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'basepath');
|
$this->checkSetting($configCache, $_POST, 'system', 'basepath');
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'urlpath');
|
$this->checkSetting($configCache, $_POST, 'system', 'urlpath');
|
||||||
|
|
||||||
self::checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST);
|
$this->checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST);
|
||||||
self::checkSetting($configCache, $_POST, 'database', 'username', '');
|
$this->checkSetting($configCache, $_POST, 'database', 'username', '');
|
||||||
self::checkSetting($configCache, $_POST, 'database', 'password', '');
|
$this->checkSetting($configCache, $_POST, 'database', 'password', '');
|
||||||
self::checkSetting($configCache, $_POST, 'database', 'database', '');
|
$this->checkSetting($configCache, $_POST, 'database', 'database', '');
|
||||||
|
|
||||||
// If we cannot connect to the database, return to the previous step
|
// If we cannot connect to the database, return to the previous step
|
||||||
if (!self::$installer->checkDB(DI::dba())) {
|
if (!$this->installer->checkDB(DI::dba())) {
|
||||||
self::$currentWizardStep = self::DATABASE_CONFIG;
|
$this->currentWizardStep = self::DATABASE_CONFIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::FINISHED:
|
case self::FINISHED:
|
||||||
self::checkSetting($configCache, $_POST, 'config', 'php_path');
|
$this->checkSetting($configCache, $_POST, 'config', 'php_path');
|
||||||
|
|
||||||
self::checkSetting($configCache, $_POST, 'config', 'hostname');
|
$this->checkSetting($configCache, $_POST, 'config', 'hostname');
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'ssl_policy');
|
$this->checkSetting($configCache, $_POST, 'system', 'ssl_policy');
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'basepath');
|
$this->checkSetting($configCache, $_POST, 'system', 'basepath');
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'urlpath');
|
$this->checkSetting($configCache, $_POST, 'system', 'urlpath');
|
||||||
|
|
||||||
self::checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST);
|
$this->checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST);
|
||||||
self::checkSetting($configCache, $_POST, 'database', 'username', '');
|
$this->checkSetting($configCache, $_POST, 'database', 'username', '');
|
||||||
self::checkSetting($configCache, $_POST, 'database', 'password', '');
|
$this->checkSetting($configCache, $_POST, 'database', 'password', '');
|
||||||
self::checkSetting($configCache, $_POST, 'database', 'database', '');
|
$this->checkSetting($configCache, $_POST, 'database', 'database', '');
|
||||||
|
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'default_timezone', Core\Installer::DEFAULT_TZ);
|
$this->checkSetting($configCache, $_POST, 'system', 'default_timezone', Core\Installer::DEFAULT_TZ);
|
||||||
self::checkSetting($configCache, $_POST, 'system', 'language', Core\Installer::DEFAULT_LANG);
|
$this->checkSetting($configCache, $_POST, 'system', 'language', Core\Installer::DEFAULT_LANG);
|
||||||
self::checkSetting($configCache, $_POST, 'config', 'admin_email', '');
|
$this->checkSetting($configCache, $_POST, 'config', 'admin_email', '');
|
||||||
|
|
||||||
// If we cannot connect to the database, return to the Database config wizard
|
// If we cannot connect to the database, return to the Database config wizard
|
||||||
if (!self::$installer->checkDB(DI::dba())) {
|
if (!$this->installer->checkDB(DI::dba())) {
|
||||||
self::$currentWizardStep = self::DATABASE_CONFIG;
|
$this->currentWizardStep = self::DATABASE_CONFIG;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::$installer->createConfig($configCache)) {
|
if (!$this->installer->createConfig($configCache)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$installer->installDatabase($configCache->get('system', 'basepath'));
|
$this->installer->installDatabase($configCache->get('system', 'basepath'));
|
||||||
|
|
||||||
// install allowed themes to register theme hooks
|
// install allowed themes to register theme hooks
|
||||||
// this is same as "Reload active theme" in /admin/themes
|
// this is same as "Reload active theme" in /admin/themes
|
||||||
|
@ -179,69 +189,68 @@ class Install extends BaseModule
|
||||||
|
|
||||||
public function content(): string
|
public function content(): string
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
$configCache = $this->app->getConfigCache();
|
||||||
$configCache = $a->getConfigCache();
|
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
$install_title = DI::l10n()->t('Friendica Communications Server - Setup');
|
$install_title = $this->t('Friendica Communications Server - Setup');
|
||||||
|
|
||||||
switch (self::$currentWizardStep) {
|
switch ($this->currentWizardStep) {
|
||||||
case self::SYSTEM_CHECK:
|
case self::SYSTEM_CHECK:
|
||||||
$php_path = $configCache->get('config', 'php_path');
|
$php_path = $configCache->get('config', 'php_path');
|
||||||
|
|
||||||
$status = self::$installer->checkEnvironment(DI::baseUrl()->get(), $php_path);
|
$status = $this->installer->checkEnvironment($this->baseUrl->get(), $php_path);
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('install_checks.tpl');
|
$tpl = Renderer::getMarkupTemplate('install_checks.tpl');
|
||||||
$output .= Renderer::replaceMacros($tpl, [
|
$output .= Renderer::replaceMacros($tpl, [
|
||||||
'$title' => $install_title,
|
'$title' => $install_title,
|
||||||
'$pass' => DI::l10n()->t('System check'),
|
'$pass' => $this->t('System check'),
|
||||||
'$required' => DI::l10n()->t('Required'),
|
'$required' => $this->t('Required'),
|
||||||
'$requirement_not_satisfied' => DI::l10n()->t('Requirement not satisfied'),
|
'$requirement_not_satisfied' => $this->t('Requirement not satisfied'),
|
||||||
'$optional_requirement_not_satisfied' => DI::l10n()->t('Optional requirement not satisfied'),
|
'$optional_requirement_not_satisfied' => $this->t('Optional requirement not satisfied'),
|
||||||
'$ok' => DI::l10n()->t('OK'),
|
'$ok' => $this->t('OK'),
|
||||||
'$checks' => self::$installer->getChecks(),
|
'$checks' => $this->installer->getChecks(),
|
||||||
'$passed' => $status,
|
'$passed' => $status,
|
||||||
'$see_install' => DI::l10n()->t('Please see the file "doc/INSTALL.md".'),
|
'$see_install' => $this->t('Please see the file "doc/INSTALL.md".'),
|
||||||
'$next' => DI::l10n()->t('Next'),
|
'$next' => $this->t('Next'),
|
||||||
'$reload' => DI::l10n()->t('Check again'),
|
'$reload' => $this->t('Check again'),
|
||||||
'$php_path' => $php_path,
|
'$php_path' => $php_path,
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::BASE_CONFIG:
|
case self::BASE_CONFIG:
|
||||||
$ssl_choices = [
|
$ssl_choices = [
|
||||||
App\BaseURL::SSL_POLICY_NONE => DI::l10n()->t("No SSL policy, links will track page SSL state"),
|
App\BaseURL::SSL_POLICY_NONE => $this->t("No SSL policy, links will track page SSL state"),
|
||||||
App\BaseURL::SSL_POLICY_FULL => DI::l10n()->t("Force all links to use SSL"),
|
App\BaseURL::SSL_POLICY_FULL => $this->t("Force all links to use SSL"),
|
||||||
App\BaseURL::SSL_POLICY_SELFSIGN => DI::l10n()->t("Self-signed certificate, use SSL for local links only \x28discouraged\x29")
|
App\BaseURL::SSL_POLICY_SELFSIGN => $this->t("Self-signed certificate, use SSL for local links only \x28discouraged\x29")
|
||||||
];
|
];
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('install_base.tpl');
|
$tpl = Renderer::getMarkupTemplate('install_base.tpl');
|
||||||
$output .= Renderer::replaceMacros($tpl, [
|
$output .= Renderer::replaceMacros($tpl, [
|
||||||
'$title' => $install_title,
|
'$title' => $install_title,
|
||||||
'$pass' => DI::l10n()->t('Base settings'),
|
'$pass' => $this->t('Base settings'),
|
||||||
'$ssl_policy' => ['system-ssl_policy',
|
'$ssl_policy' => ['system-ssl_policy',
|
||||||
DI::l10n()->t("SSL link policy"),
|
$this->t("SSL link policy"),
|
||||||
$configCache->get('system', 'ssl_policy'),
|
$configCache->get('system', 'ssl_policy'),
|
||||||
DI::l10n()->t("Determines whether generated links should be forced to use SSL"),
|
$this->t("Determines whether generated links should be forced to use SSL"),
|
||||||
$ssl_choices],
|
$ssl_choices],
|
||||||
'$hostname' => ['config-hostname',
|
'$hostname' => ['config-hostname',
|
||||||
DI::l10n()->t('Host name'),
|
$this->t('Host name'),
|
||||||
$configCache->get('config', 'hostname'),
|
$configCache->get('config', 'hostname'),
|
||||||
DI::l10n()->t('Overwrite this field in case the determinated hostname isn\'t right, otherweise leave it as is.'),
|
$this->t('Overwrite this field in case the determinated hostname isn\'t right, otherweise leave it as is.'),
|
||||||
DI::l10n()->t('Required')],
|
$this->t('Required')],
|
||||||
'$basepath' => ['system-basepath',
|
'$basepath' => ['system-basepath',
|
||||||
DI::l10n()->t("Base path to installation"),
|
$this->t("Base path to installation"),
|
||||||
$configCache->get('system', 'basepath'),
|
$configCache->get('system', 'basepath'),
|
||||||
DI::l10n()->t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot."),
|
$this->t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot."),
|
||||||
DI::l10n()->t('Required')],
|
$this->t('Required')],
|
||||||
'$urlpath' => ['system-urlpath',
|
'$urlpath' => ['system-urlpath',
|
||||||
DI::l10n()->t('Sub path of the URL'),
|
$this->t('Sub path of the URL'),
|
||||||
$configCache->get('system', 'urlpath'),
|
$configCache->get('system', 'urlpath'),
|
||||||
DI::l10n()->t('Overwrite this field in case the sub path determination isn\'t right, otherwise leave it as is. Leaving this field blank means the installation is at the base URL without sub path.'),
|
$this->t('Overwrite this field in case the sub path determination isn\'t right, otherwise leave it as is. Leaving this field blank means the installation is at the base URL without sub path.'),
|
||||||
''],
|
''],
|
||||||
'$php_path' => $configCache->get('config', 'php_path'),
|
'$php_path' => $configCache->get('config', 'php_path'),
|
||||||
'$submit' => DI::l10n()->t('Submit'),
|
'$submit' => $this->t('Submit'),
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -249,54 +258,54 @@ class Install extends BaseModule
|
||||||
$tpl = Renderer::getMarkupTemplate('install_db.tpl');
|
$tpl = Renderer::getMarkupTemplate('install_db.tpl');
|
||||||
$output .= Renderer::replaceMacros($tpl, [
|
$output .= Renderer::replaceMacros($tpl, [
|
||||||
'$title' => $install_title,
|
'$title' => $install_title,
|
||||||
'$pass' => DI::l10n()->t('Database connection'),
|
'$pass' => $this->t('Database connection'),
|
||||||
'$info_01' => DI::l10n()->t('In order to install Friendica we need to know how to connect to your database.'),
|
'$info_01' => $this->t('In order to install Friendica we need to know how to connect to your database.'),
|
||||||
'$info_02' => DI::l10n()->t('Please contact your hosting provider or site administrator if you have questions about these settings.'),
|
'$info_02' => $this->t('Please contact your hosting provider or site administrator if you have questions about these settings.'),
|
||||||
'$info_03' => DI::l10n()->t('The database you specify below should already exist. If it does not, please create it before continuing.'),
|
'$info_03' => $this->t('The database you specify below should already exist. If it does not, please create it before continuing.'),
|
||||||
'$required' => DI::l10n()->t('Required'),
|
'$required' => $this->t('Required'),
|
||||||
'$requirement_not_satisfied' => DI::l10n()->t('Requirement not satisfied'),
|
'$requirement_not_satisfied' => $this->t('Requirement not satisfied'),
|
||||||
'$checks' => self::$installer->getChecks(),
|
'$checks' => $this->installer->getChecks(),
|
||||||
'$hostname' => $configCache->get('config', 'hostname'),
|
'$hostname' => $configCache->get('config', 'hostname'),
|
||||||
'$ssl_policy' => $configCache->get('system', 'ssl_policy'),
|
'$ssl_policy' => $configCache->get('system', 'ssl_policy'),
|
||||||
'$basepath' => $configCache->get('system', 'basepath'),
|
'$basepath' => $configCache->get('system', 'basepath'),
|
||||||
'$urlpath' => $configCache->get('system', 'urlpath'),
|
'$urlpath' => $configCache->get('system', 'urlpath'),
|
||||||
'$dbhost' => ['database-hostname',
|
'$dbhost' => ['database-hostname',
|
||||||
DI::l10n()->t('Database Server Name'),
|
$this->t('Database Server Name'),
|
||||||
$configCache->get('database', 'hostname'),
|
$configCache->get('database', 'hostname'),
|
||||||
'',
|
'',
|
||||||
DI::l10n()->t('Required')],
|
$this->t('Required')],
|
||||||
'$dbuser' => ['database-username',
|
'$dbuser' => ['database-username',
|
||||||
DI::l10n()->t('Database Login Name'),
|
$this->t('Database Login Name'),
|
||||||
$configCache->get('database', 'username'),
|
$configCache->get('database', 'username'),
|
||||||
'',
|
'',
|
||||||
DI::l10n()->t('Required'),
|
$this->t('Required'),
|
||||||
'autofocus'],
|
'autofocus'],
|
||||||
'$dbpass' => ['database-password',
|
'$dbpass' => ['database-password',
|
||||||
DI::l10n()->t('Database Login Password'),
|
$this->t('Database Login Password'),
|
||||||
$configCache->get('database', 'password'),
|
$configCache->get('database', 'password'),
|
||||||
DI::l10n()->t("For security reasons the password must not be empty"),
|
$this->t("For security reasons the password must not be empty"),
|
||||||
DI::l10n()->t('Required')],
|
$this->t('Required')],
|
||||||
'$dbdata' => ['database-database',
|
'$dbdata' => ['database-database',
|
||||||
DI::l10n()->t('Database Name'),
|
$this->t('Database Name'),
|
||||||
$configCache->get('database', 'database'),
|
$configCache->get('database', 'database'),
|
||||||
'',
|
'',
|
||||||
DI::l10n()->t('Required')],
|
$this->t('Required')],
|
||||||
'$lbl_10' => DI::l10n()->t('Please select a default timezone for your website'),
|
'$lbl_10' => $this->t('Please select a default timezone for your website'),
|
||||||
'$php_path' => $configCache->get('config', 'php_path'),
|
'$php_path' => $configCache->get('config', 'php_path'),
|
||||||
'$submit' => DI::l10n()->t('Submit')
|
'$submit' => $this->t('Submit')
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::SITE_SETTINGS:
|
case self::SITE_SETTINGS:
|
||||||
/* Installed langs */
|
/* Installed langs */
|
||||||
$lang_choices = DI::l10n()->getAvailableLanguages();
|
$lang_choices = $this->l10n->getAvailableLanguages();
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('install_settings.tpl');
|
$tpl = Renderer::getMarkupTemplate('install_settings.tpl');
|
||||||
$output .= Renderer::replaceMacros($tpl, [
|
$output .= Renderer::replaceMacros($tpl, [
|
||||||
'$title' => $install_title,
|
'$title' => $install_title,
|
||||||
'$required' => DI::l10n()->t('Required'),
|
'$required' => $this->t('Required'),
|
||||||
'$checks' => self::$installer->getChecks(),
|
'$checks' => $this->installer->getChecks(),
|
||||||
'$pass' => DI::l10n()->t('Site settings'),
|
'$pass' => $this->t('Site settings'),
|
||||||
'$hostname' => $configCache->get('config', 'hostname'),
|
'$hostname' => $configCache->get('config', 'hostname'),
|
||||||
'$ssl_policy' => $configCache->get('system', 'ssl_policy'),
|
'$ssl_policy' => $configCache->get('system', 'ssl_policy'),
|
||||||
'$basepath' => $configCache->get('system', 'basepath'),
|
'$basepath' => $configCache->get('system', 'basepath'),
|
||||||
|
@ -306,41 +315,41 @@ class Install extends BaseModule
|
||||||
'$dbpass' => $configCache->get('database', 'password'),
|
'$dbpass' => $configCache->get('database', 'password'),
|
||||||
'$dbdata' => $configCache->get('database', 'database'),
|
'$dbdata' => $configCache->get('database', 'database'),
|
||||||
'$adminmail' => ['config-admin_email',
|
'$adminmail' => ['config-admin_email',
|
||||||
DI::l10n()->t('Site administrator email address'),
|
$this->t('Site administrator email address'),
|
||||||
$configCache->get('config', 'admin_email'),
|
$configCache->get('config', 'admin_email'),
|
||||||
DI::l10n()->t('Your account email address must match this in order to use the web admin panel.'),
|
$this->t('Your account email address must match this in order to use the web admin panel.'),
|
||||||
DI::l10n()->t('Required'), 'autofocus', 'email'],
|
$this->t('Required'), 'autofocus', 'email'],
|
||||||
'$timezone' => Temporal::getTimezoneField('system-default_timezone',
|
'$timezone' => Temporal::getTimezoneField('system-default_timezone',
|
||||||
DI::l10n()->t('Please select a default timezone for your website'),
|
$this->t('Please select a default timezone for your website'),
|
||||||
$configCache->get('system', 'default_timezone'),
|
$configCache->get('system', 'default_timezone'),
|
||||||
''),
|
''),
|
||||||
'$language' => ['system-language',
|
'$language' => ['system-language',
|
||||||
DI::l10n()->t('System Language:'),
|
$this->t('System Language:'),
|
||||||
$configCache->get('system', 'language'),
|
$configCache->get('system', 'language'),
|
||||||
DI::l10n()->t('Set the default language for your Friendica installation interface and to send emails.'),
|
$this->t('Set the default language for your Friendica installation interface and to send emails.'),
|
||||||
$lang_choices],
|
$lang_choices],
|
||||||
'$php_path' => $configCache->get('config', 'php_path'),
|
'$php_path' => $configCache->get('config', 'php_path'),
|
||||||
'$submit' => DI::l10n()->t('Submit')
|
'$submit' => $this->t('Submit')
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::FINISHED:
|
case self::FINISHED:
|
||||||
$db_return_text = "";
|
$db_return_text = "";
|
||||||
|
|
||||||
if (count(self::$installer->getChecks()) == 0) {
|
if (count($this->installer->getChecks()) == 0) {
|
||||||
$txt = '<p style="font-size: 130%;">';
|
$txt = '<p style="font-size: 130%;">';
|
||||||
$txt .= DI::l10n()->t('Your Friendica site database has been installed.') . EOL;
|
$txt .= $this->t('Your Friendica site database has been installed.') . EOL;
|
||||||
$db_return_text .= $txt;
|
$db_return_text .= $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('install_finished.tpl');
|
$tpl = Renderer::getMarkupTemplate('install_finished.tpl');
|
||||||
$output .= Renderer::replaceMacros($tpl, [
|
$output .= Renderer::replaceMacros($tpl, [
|
||||||
'$title' => $install_title,
|
'$title' => $install_title,
|
||||||
'$required' => DI::l10n()->t('Required'),
|
'$required' => $this->t('Required'),
|
||||||
'$requirement_not_satisfied' => DI::l10n()->t('Requirement not satisfied'),
|
'$requirement_not_satisfied' => $this->t('Requirement not satisfied'),
|
||||||
'$checks' => self::$installer->getChecks(),
|
'$checks' => $this->installer->getChecks(),
|
||||||
'$pass' => DI::l10n()->t('Installation finished'),
|
'$pass' => $this->t('Installation finished'),
|
||||||
'$text' => $db_return_text . self::whatNext(),
|
'$text' => $db_return_text . $this->whatNext(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -355,15 +364,15 @@ class Install extends BaseModule
|
||||||
* @return string The text for the next steps
|
* @return string The text for the next steps
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
private static function whatNext()
|
private function whatNext()
|
||||||
{
|
{
|
||||||
$baseurl = DI::baseUrl()->get();
|
$baseurl = $this->baseUrl->get();
|
||||||
return
|
return
|
||||||
DI::l10n()->t('<h1>What next</h1>')
|
$this->t('<h1>What next</h1>')
|
||||||
. "<p>" . DI::l10n()->t('IMPORTANT: You will need to [manually] setup a scheduled task for the worker.')
|
. "<p>" . $this->t('IMPORTANT: You will need to [manually] setup a scheduled task for the worker.')
|
||||||
. DI::l10n()->t('Please see the file "doc/INSTALL.md".')
|
. $this->t('Please see the file "doc/INSTALL.md".')
|
||||||
. "</p><p>"
|
. "</p><p>"
|
||||||
. DI::l10n()->t('Go to your new Friendica node <a href="%s/register">registration page</a> and register as new user. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.', $baseurl)
|
. $this->t('Go to your new Friendica node <a href="%s/register">registration page</a> and register as new user. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.', $baseurl)
|
||||||
. "</p>";
|
. "</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +385,7 @@ class Install extends BaseModule
|
||||||
* @param string $key The key of the setting
|
* @param string $key The key of the setting
|
||||||
* @param null|string $default The default value
|
* @param null|string $default The default value
|
||||||
*/
|
*/
|
||||||
private static function checkSetting(Cache $configCache, array $post, $cat, $key, $default = null)
|
private function checkSetting(Cache $configCache, array $post, $cat, $key, $default = null)
|
||||||
{
|
{
|
||||||
$configCache->set($cat, $key,
|
$configCache->set($cat, $key,
|
||||||
trim(($post[sprintf('%s-%s', $cat, $key)] ?? '') ?:
|
trim(($post[sprintf('%s-%s', $cat, $key)] ?? '') ?:
|
||||||
|
|
|
@ -21,16 +21,18 @@
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\Database;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
|
||||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Util\HTTPSignature;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic Auth (remote authentication) module.
|
* Magic Auth (remote authentication) module.
|
||||||
|
@ -39,17 +41,35 @@ use Friendica\Util\Strings;
|
||||||
*/
|
*/
|
||||||
class Magic extends BaseModule
|
class Magic extends BaseModule
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var App */
|
||||||
{
|
protected $app;
|
||||||
$a = DI::app();
|
/** @var LoggerInterface */
|
||||||
$ret = ['success' => false, 'url' => '', 'message' => ''];
|
protected $logger;
|
||||||
Logger::info('magic mdule: invoked');
|
/** @var Database */
|
||||||
|
protected $dba;
|
||||||
|
/** @var ICanSendHttpRequests */
|
||||||
|
protected $httpClient;
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
Logger::debug('args', ['request' => $_REQUEST]);
|
public function __construct(App $app, App\BaseURL $baseUrl, LoggerInterface $logger, Database $dba, ICanSendHttpRequests $httpClient, L10n $l10n, array $parameters = [])
|
||||||
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->app = $app;
|
||||||
|
$this->logger = $logger;
|
||||||
|
$this->dba = $dba;
|
||||||
|
$this->httpClient = $httpClient;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rawContent()
|
||||||
|
{
|
||||||
|
$this->logger->info('magic module: invoked');
|
||||||
|
|
||||||
|
$this->logger->debug('args', ['request' => $_REQUEST]);
|
||||||
|
|
||||||
$addr = $_REQUEST['addr'] ?? '';
|
$addr = $_REQUEST['addr'] ?? '';
|
||||||
$dest = $_REQUEST['dest'] ?? '';
|
$dest = $_REQUEST['dest'] ?? '';
|
||||||
$test = (!empty($_REQUEST['test']) ? intval($_REQUEST['test']) : 0);
|
|
||||||
$owa = (!empty($_REQUEST['owa']) ? intval($_REQUEST['owa']) : 0);
|
$owa = (!empty($_REQUEST['owa']) ? intval($_REQUEST['owa']) : 0);
|
||||||
$cid = 0;
|
$cid = 0;
|
||||||
|
|
||||||
|
@ -60,21 +80,15 @@ class Magic extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$cid) {
|
if (!$cid) {
|
||||||
Logger::info('No contact record found', $_REQUEST);
|
$this->logger->info('No contact record found', $_REQUEST);
|
||||||
// @TODO Finding a more elegant possibility to redirect to either internal or external URL
|
// @TODO Finding a more elegant possibility to redirect to either internal or external URL
|
||||||
$a->redirect($dest);
|
$this->app->redirect($dest);
|
||||||
}
|
}
|
||||||
$contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
|
$contact = $this->dba->selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
|
||||||
|
|
||||||
// Redirect if the contact is already authenticated on this site.
|
// Redirect if the contact is already authenticated on this site.
|
||||||
if ($a->getContactId() && strpos($contact['nurl'], Strings::normaliseLink(DI::baseUrl()->get())) !== false) {
|
if ($this->app->getContactId() && strpos($contact['nurl'], Strings::normaliseLink($this->baseUrl->get())) !== false) {
|
||||||
if ($test) {
|
$this->logger->info('Contact is already authenticated');
|
||||||
$ret['success'] = true;
|
|
||||||
$ret['message'] .= 'Local site - you are already authenticated.' . EOL;
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger::info('Contact is already authenticated');
|
|
||||||
System::externalRedirect($dest);
|
System::externalRedirect($dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +112,11 @@ class Magic extends BaseModule
|
||||||
$header = HTTPSignature::createSig(
|
$header = HTTPSignature::createSig(
|
||||||
$header,
|
$header,
|
||||||
$user['prvkey'],
|
$user['prvkey'],
|
||||||
'acct:' . $user['nickname'] . '@' . DI::baseUrl()->getHostname() . (DI::baseUrl()->getUrlPath() ? '/' . DI::baseUrl()->getUrlPath() : '')
|
'acct:' . $user['nickname'] . '@' . $this->baseUrl->getHostname() . ($this->baseUrl->getUrlPath() ? '/' . $this->baseUrl->getUrlPath() : '')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Try to get an authentication token from the other instance.
|
// Try to get an authentication token from the other instance.
|
||||||
$curlResult = DI::httpClient()->get($basepath . '/owa', [HttpClientOptions::HEADERS => $header]);
|
$curlResult = $this->httpClient->get($basepath . '/owa', [HttpClientOptions::HEADERS => $header]);
|
||||||
|
|
||||||
if ($curlResult->isSuccess()) {
|
if ($curlResult->isSuccess()) {
|
||||||
$j = json_decode($curlResult->getBody(), true);
|
$j = json_decode($curlResult->getBody(), true);
|
||||||
|
@ -118,19 +132,14 @@ class Magic extends BaseModule
|
||||||
}
|
}
|
||||||
$args = (strpbrk($dest, '?&') ? '&' : '?') . 'owt=' . $token;
|
$args = (strpbrk($dest, '?&') ? '&' : '?') . 'owt=' . $token;
|
||||||
|
|
||||||
Logger::info('Redirecting', ['path' => $dest . $args]);
|
$this->logger->info('Redirecting', ['path' => $dest . $args]);
|
||||||
System::externalRedirect($dest . $args);
|
System::externalRedirect($dest . $args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System::externalRedirect($dest);
|
System::externalRedirect($dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($test) {
|
|
||||||
$ret['message'] = 'Not authenticated or invalid arguments' . EOL;
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @TODO Finding a more elegant possibility to redirect to either internal or external URL
|
// @TODO Finding a more elegant possibility to redirect to either internal or external URL
|
||||||
$a->redirect($dest);
|
$this->app->redirect($dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,17 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Notifications;
|
namespace Friendica\Module\Notifications;
|
||||||
|
|
||||||
|
use Friendica\App\Arguments;
|
||||||
|
use Friendica\App\Mode;
|
||||||
use Friendica\Content\ContactSelector;
|
use Friendica\Content\ContactSelector;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Module\BaseNotifications;
|
use Friendica\Module\BaseNotifications;
|
||||||
|
use Friendica\Navigation\Notifications\Factory\Introduction as IntroductionFactory;
|
||||||
use Friendica\Navigation\Notifications\ValueObject\Introduction;
|
use Friendica\Navigation\Notifications\ValueObject\Introduction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,21 +39,34 @@ use Friendica\Navigation\Notifications\ValueObject\Introduction;
|
||||||
*/
|
*/
|
||||||
class Introductions extends BaseNotifications
|
class Introductions extends BaseNotifications
|
||||||
{
|
{
|
||||||
|
/** @var IntroductionFactory */
|
||||||
|
protected $notificationIntro;
|
||||||
|
/** @var Mode */
|
||||||
|
protected $mode;
|
||||||
|
|
||||||
|
public function __construct(Mode $mode, IntroductionFactory $notificationIntro, Arguments $args, L10n $l10n, array $parameters = [])
|
||||||
|
{
|
||||||
|
parent::__construct($args, $l10n, $parameters);
|
||||||
|
|
||||||
|
$this->notificationIntro = $notificationIntro;
|
||||||
|
$this->mode = $mode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public static function getNotifications()
|
public function getNotifications()
|
||||||
{
|
{
|
||||||
$id = (int)DI::args()->get(2, 0);
|
$id = (int)$this->args->get(2, 0);
|
||||||
$all = DI::args()->get(2) == 'all';
|
$all = $this->args->get(2) == 'all';
|
||||||
|
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'ident' => 'introductions',
|
'ident' => 'introductions',
|
||||||
'notifications' => DI::notificationIntro()->getList($all, self::$firstItemNum, self::ITEMS_PER_PAGE, $id),
|
'notifications' => $this->notificationIntro->getList($all, $this->firstItemNum, self::ITEMS_PER_PAGE, $id),
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'header' => DI::l10n()->t('Notifications'),
|
'header' => $this->t('Notifications'),
|
||||||
'notifications' => $notifications,
|
'notifications' => $notifications,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -59,12 +75,12 @@ class Introductions extends BaseNotifications
|
||||||
{
|
{
|
||||||
Nav::setSelected('introductions');
|
Nav::setSelected('introductions');
|
||||||
|
|
||||||
$all = DI::args()->get(2) == 'all';
|
$all = $this->args->get(2) == 'all';
|
||||||
|
|
||||||
$notificationContent = [];
|
$notificationContent = [];
|
||||||
$notificationNoContent = '';
|
$notificationNoContent = '';
|
||||||
|
|
||||||
$notificationResult = self::getNotifications();
|
$notificationResult = $this->getNotifications();
|
||||||
$notifications = $notificationResult['notifications'] ?? [];
|
$notifications = $notificationResult['notifications'] ?? [];
|
||||||
$notificationHeader = $notificationResult['header'] ?? '';
|
$notificationHeader = $notificationResult['header'] ?? '';
|
||||||
|
|
||||||
|
@ -74,7 +90,7 @@ class Introductions extends BaseNotifications
|
||||||
// The link to switch between ignored and normal connection requests
|
// The link to switch between ignored and normal connection requests
|
||||||
$notificationShowLink = [
|
$notificationShowLink = [
|
||||||
'href' => (!$all ? 'notifications/intros/all' : 'notifications/intros'),
|
'href' => (!$all ? 'notifications/intros/all' : 'notifications/intros'),
|
||||||
'text' => (!$all ? DI::l10n()->t('Show Ignored Requests') : DI::l10n()->t('Hide Ignored Requests')),
|
'text' => (!$all ? $this->t('Show Ignored Requests') : $this->t('Hide Ignored Requests')),
|
||||||
];
|
];
|
||||||
|
|
||||||
$owner = User::getOwnerDataById(local_user());
|
$owner = User::getOwnerDataById(local_user());
|
||||||
|
@ -90,10 +106,10 @@ class Introductions extends BaseNotifications
|
||||||
case 'friend_suggestion':
|
case 'friend_suggestion':
|
||||||
$notificationContent[] = Renderer::replaceMacros($notificationSuggestions, [
|
$notificationContent[] = Renderer::replaceMacros($notificationSuggestions, [
|
||||||
'$type' => $Introduction->getLabel(),
|
'$type' => $Introduction->getLabel(),
|
||||||
'$str_notification_type' => DI::l10n()->t('Notification type:'),
|
'$str_notification_type' => $this->t('Notification type:'),
|
||||||
'$str_type' => $Introduction->getType(),
|
'$str_type' => $Introduction->getType(),
|
||||||
'$intro_id' => $Introduction->getIntroId(),
|
'$intro_id' => $Introduction->getIntroId(),
|
||||||
'$lbl_madeby' => DI::l10n()->t('Suggested by:'),
|
'$lbl_madeby' => $this->t('Suggested by:'),
|
||||||
'$madeby' => $Introduction->getMadeBy(),
|
'$madeby' => $Introduction->getMadeBy(),
|
||||||
'$madeby_url' => $Introduction->getMadeByUrl(),
|
'$madeby_url' => $Introduction->getMadeByUrl(),
|
||||||
'$madeby_zrl' => $Introduction->getMadeByZrl(),
|
'$madeby_zrl' => $Introduction->getMadeByZrl(),
|
||||||
|
@ -104,22 +120,22 @@ class Introductions extends BaseNotifications
|
||||||
'$dfrn_url' => $owner['url'],
|
'$dfrn_url' => $owner['url'],
|
||||||
'$url' => $Introduction->getUrl(),
|
'$url' => $Introduction->getUrl(),
|
||||||
'$zrl' => $Introduction->getZrl(),
|
'$zrl' => $Introduction->getZrl(),
|
||||||
'$lbl_url' => DI::l10n()->t('Profile URL'),
|
'$lbl_url' => $this->t('Profile URL'),
|
||||||
'$addr' => $Introduction->getAddr(),
|
'$addr' => $Introduction->getAddr(),
|
||||||
'$action' => 'follow',
|
'$action' => 'follow',
|
||||||
'$approve' => DI::l10n()->t('Approve'),
|
'$approve' => $this->t('Approve'),
|
||||||
'$note' => $Introduction->getNote(),
|
'$note' => $Introduction->getNote(),
|
||||||
'$ignore' => DI::l10n()->t('Ignore'),
|
'$ignore' => $this->t('Ignore'),
|
||||||
'$discard' => DI::l10n()->t('Discard'),
|
'$discard' => $this->t('Discard'),
|
||||||
'$is_mobile' => DI::mode()->isMobile(),
|
'$is_mobile' => $this->mode->isMobile(),
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Normal connection requests
|
// Normal connection requests
|
||||||
default:
|
default:
|
||||||
if ($Introduction->getNetwork() === Protocol::DFRN) {
|
if ($Introduction->getNetwork() === Protocol::DFRN) {
|
||||||
$lbl_knowyou = DI::l10n()->t('Claims to be known to you: ');
|
$lbl_knowyou = $this->t('Claims to be known to you: ');
|
||||||
$knowyou = ($Introduction->getKnowYou() ? DI::l10n()->t('Yes') : DI::l10n()->t('No'));
|
$knowyou = ($Introduction->getKnowYou() ? $this->t('Yes') : $this->t('No'));
|
||||||
} else {
|
} else {
|
||||||
$lbl_knowyou = '';
|
$lbl_knowyou = '';
|
||||||
$knowyou = '';
|
$knowyou = '';
|
||||||
|
@ -127,12 +143,12 @@ class Introductions extends BaseNotifications
|
||||||
|
|
||||||
$convertedName = BBCode::convert($Introduction->getName());
|
$convertedName = BBCode::convert($Introduction->getName());
|
||||||
|
|
||||||
$helptext = DI::l10n()->t('Shall your connection be bidirectional or not?');
|
$helptext = $this->t('Shall your connection be bidirectional or not?');
|
||||||
$helptext2 = DI::l10n()->t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $convertedName, $convertedName);
|
$helptext2 = $this->t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $convertedName, $convertedName);
|
||||||
$helptext3 = DI::l10n()->t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $convertedName);
|
$helptext3 = $this->t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $convertedName);
|
||||||
|
|
||||||
$friend = ['duplex', DI::l10n()->t('Friend'), '1', $helptext2, true];
|
$friend = ['duplex', $this->t('Friend'), '1', $helptext2, true];
|
||||||
$follower = ['duplex', DI::l10n()->t('Subscriber'), '0', $helptext3, false];
|
$follower = ['duplex', $this->t('Subscriber'), '0', $helptext3, false];
|
||||||
|
|
||||||
$action = 'follow_confirm';
|
$action = 'follow_confirm';
|
||||||
|
|
||||||
|
@ -145,7 +161,7 @@ class Introductions extends BaseNotifications
|
||||||
$header .= ' (' . ContactSelector::networkToName($Introduction->getNetwork(), $Introduction->getUrl()) . ')';
|
$header .= ' (' . ContactSelector::networkToName($Introduction->getNetwork(), $Introduction->getUrl()) . ')';
|
||||||
|
|
||||||
if ($Introduction->getNetwork() != Protocol::DIASPORA) {
|
if ($Introduction->getNetwork() != Protocol::DIASPORA) {
|
||||||
$discard = DI::l10n()->t('Discard');
|
$discard = $this->t('Discard');
|
||||||
} else {
|
} else {
|
||||||
$discard = '';
|
$discard = '';
|
||||||
}
|
}
|
||||||
|
@ -153,7 +169,7 @@ class Introductions extends BaseNotifications
|
||||||
$notificationContent[] = Renderer::replaceMacros($notificationTemplate, [
|
$notificationContent[] = Renderer::replaceMacros($notificationTemplate, [
|
||||||
'$type' => $Introduction->getLabel(),
|
'$type' => $Introduction->getLabel(),
|
||||||
'$header' => $header,
|
'$header' => $header,
|
||||||
'$str_notification_type' => DI::l10n()->t('Notification type:'),
|
'$str_notification_type' => $this->t('Notification type:'),
|
||||||
'$str_type' => $Introduction->getType(),
|
'$str_type' => $Introduction->getType(),
|
||||||
'$dfrn_id' => $Introduction->getDfrnId(),
|
'$dfrn_id' => $Introduction->getDfrnId(),
|
||||||
'$uid' => $Introduction->getUid(),
|
'$uid' => $Introduction->getUid(),
|
||||||
|
@ -162,39 +178,39 @@ class Introductions extends BaseNotifications
|
||||||
'$photo' => $Introduction->getPhoto(),
|
'$photo' => $Introduction->getPhoto(),
|
||||||
'$fullname' => $Introduction->getName(),
|
'$fullname' => $Introduction->getName(),
|
||||||
'$location' => $Introduction->getLocation(),
|
'$location' => $Introduction->getLocation(),
|
||||||
'$lbl_location' => DI::l10n()->t('Location:'),
|
'$lbl_location' => $this->t('Location:'),
|
||||||
'$about' => $Introduction->getAbout(),
|
'$about' => $Introduction->getAbout(),
|
||||||
'$lbl_about' => DI::l10n()->t('About:'),
|
'$lbl_about' => $this->t('About:'),
|
||||||
'$keywords' => $Introduction->getKeywords(),
|
'$keywords' => $Introduction->getKeywords(),
|
||||||
'$lbl_keywords' => DI::l10n()->t('Tags:'),
|
'$lbl_keywords' => $this->t('Tags:'),
|
||||||
'$hidden' => ['hidden', DI::l10n()->t('Hide this contact from others'), $Introduction->isHidden(), ''],
|
'$hidden' => ['hidden', $this->t('Hide this contact from others'), $Introduction->isHidden(), ''],
|
||||||
'$lbl_connection_type' => $helptext,
|
'$lbl_connection_type' => $helptext,
|
||||||
'$friend' => $friend,
|
'$friend' => $friend,
|
||||||
'$follower' => $follower,
|
'$follower' => $follower,
|
||||||
'$url' => $Introduction->getUrl(),
|
'$url' => $Introduction->getUrl(),
|
||||||
'$zrl' => $Introduction->getZrl(),
|
'$zrl' => $Introduction->getZrl(),
|
||||||
'$lbl_url' => DI::l10n()->t('Profile URL'),
|
'$lbl_url' => $this->t('Profile URL'),
|
||||||
'$addr' => $Introduction->getAddr(),
|
'$addr' => $Introduction->getAddr(),
|
||||||
'$lbl_knowyou' => $lbl_knowyou,
|
'$lbl_knowyou' => $lbl_knowyou,
|
||||||
'$lbl_network' => DI::l10n()->t('Network:'),
|
'$lbl_network' => $this->t('Network:'),
|
||||||
'$network' => ContactSelector::networkToName($Introduction->getNetwork(), $Introduction->getUrl()),
|
'$network' => ContactSelector::networkToName($Introduction->getNetwork(), $Introduction->getUrl()),
|
||||||
'$knowyou' => $knowyou,
|
'$knowyou' => $knowyou,
|
||||||
'$approve' => DI::l10n()->t('Approve'),
|
'$approve' => $this->t('Approve'),
|
||||||
'$note' => $Introduction->getNote(),
|
'$note' => $Introduction->getNote(),
|
||||||
'$ignore' => DI::l10n()->t('Ignore'),
|
'$ignore' => $this->t('Ignore'),
|
||||||
'$discard' => $discard,
|
'$discard' => $discard,
|
||||||
'$action' => $action,
|
'$action' => $action,
|
||||||
'$is_mobile' => DI::mode()->isMobile(),
|
'$is_mobile' => $this->mode->isMobile(),
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($notifications['notifications']) == 0) {
|
if (count($notifications['notifications']) == 0) {
|
||||||
notice(DI::l10n()->t('No introductions.'));
|
notice($this->t('No introductions.'));
|
||||||
$notificationNoContent = DI::l10n()->t('No more %s notifications.', $notifications['ident']);
|
$notificationNoContent = $this->t('No more %s notifications.', $notifications['ident']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::printContent($notificationHeader, $notificationContent, $notificationNoContent, $notificationShowLink);
|
return $this->printContent($notificationHeader, $notificationContent, $notificationNoContent, $notificationShowLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,13 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Notifications;
|
namespace Friendica\Module\Notifications;
|
||||||
|
|
||||||
|
use Friendica\App\Arguments;
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Module\BaseNotifications;
|
use Friendica\Module\BaseNotifications;
|
||||||
use Friendica\Navigation\Notifications\Collection\FormattedNotifications;
|
|
||||||
use Friendica\Navigation\Notifications\ValueObject\FormattedNotification;
|
use Friendica\Navigation\Notifications\ValueObject\FormattedNotification;
|
||||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints all notification types except introduction:
|
* Prints all notification types except introduction:
|
||||||
|
@ -38,42 +38,56 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
*/
|
*/
|
||||||
class Notifications extends BaseNotifications
|
class Notifications extends BaseNotifications
|
||||||
{
|
{
|
||||||
|
/** @var \Friendica\Navigation\Notifications\Factory\FormattedNotification */
|
||||||
|
protected $formattedNotificationFactory;
|
||||||
|
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
|
public function __construct(BaseURL $baseUrl, \Friendica\Navigation\Notifications\Factory\FormattedNotification $formattedNotificationFactory, Arguments $args, L10n $l10n, array $parameters = [])
|
||||||
|
{
|
||||||
|
parent::__construct($args, $l10n, $parameters);
|
||||||
|
|
||||||
|
$this->formattedNotificationFactory = $formattedNotificationFactory;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public static function getNotifications()
|
public function getNotifications()
|
||||||
{
|
{
|
||||||
$notificationHeader = '';
|
$notificationHeader = '';
|
||||||
$notifications = [];
|
$notifications = [];
|
||||||
|
|
||||||
$factory = DI::formattedNotificationFactory();
|
$factory = $this->formattedNotificationFactory;
|
||||||
|
|
||||||
if ((DI::args()->get(1) == 'network')) {
|
if (($this->args->get(1) == 'network')) {
|
||||||
$notificationHeader = DI::l10n()->t('Network Notifications');
|
$notificationHeader = $this->t('Network Notifications');
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'ident' => FormattedNotification::NETWORK,
|
'ident' => FormattedNotification::NETWORK,
|
||||||
'notifications' => $factory->getNetworkList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
'notifications' => $factory->getNetworkList($this->showAll, $this->firstItemNum, self::ITEMS_PER_PAGE),
|
||||||
];
|
];
|
||||||
} elseif ((DI::args()->get(1) == 'system')) {
|
} elseif (($this->args->get(1) == 'system')) {
|
||||||
$notificationHeader = DI::l10n()->t('System Notifications');
|
$notificationHeader = $this->t('System Notifications');
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'ident' => FormattedNotification::SYSTEM,
|
'ident' => FormattedNotification::SYSTEM,
|
||||||
'notifications' => $factory->getSystemList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
'notifications' => $factory->getSystemList($this->showAll, $this->firstItemNum, self::ITEMS_PER_PAGE),
|
||||||
];
|
];
|
||||||
} elseif ((DI::args()->get(1) == 'personal')) {
|
} elseif (($this->args->get(1) == 'personal')) {
|
||||||
$notificationHeader = DI::l10n()->t('Personal Notifications');
|
$notificationHeader = $this->t('Personal Notifications');
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'ident' => FormattedNotification::PERSONAL,
|
'ident' => FormattedNotification::PERSONAL,
|
||||||
'notifications' => $factory->getPersonalList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
'notifications' => $factory->getPersonalList($this->showAll, $this->firstItemNum, self::ITEMS_PER_PAGE),
|
||||||
];
|
];
|
||||||
} elseif ((DI::args()->get(1) == 'home')) {
|
} elseif (($this->args->get(1) == 'home')) {
|
||||||
$notificationHeader = DI::l10n()->t('Home Notifications');
|
$notificationHeader = $this->t('Home Notifications');
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'ident' => FormattedNotification::HOME,
|
'ident' => FormattedNotification::HOME,
|
||||||
'notifications' => $factory->getHomeList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
'notifications' => $factory->getHomeList($this->showAll, $this->firstItemNum, self::ITEMS_PER_PAGE),
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
DI::baseUrl()->redirect('notifications');
|
$this->baseUrl->redirect('notifications');
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -89,7 +103,7 @@ class Notifications extends BaseNotifications
|
||||||
$notificationContent = [];
|
$notificationContent = [];
|
||||||
$notificationNoContent = '';
|
$notificationNoContent = '';
|
||||||
|
|
||||||
$notificationResult = self::getNotifications();
|
$notificationResult = $this->getNotifications();
|
||||||
$notifications = $notificationResult['notifications'] ?? [];
|
$notifications = $notificationResult['notifications'] ?? [];
|
||||||
$notificationHeader = $notificationResult['header'] ?? '';
|
$notificationHeader = $notificationResult['header'] ?? '';
|
||||||
|
|
||||||
|
@ -118,14 +132,14 @@ class Notifications extends BaseNotifications
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$notificationNoContent = DI::l10n()->t('No more %s notifications.', $notificationResult['ident']);
|
$notificationNoContent = $this->t('No more %s notifications.', $notificationResult['ident']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$notificationShowLink = [
|
$notificationShowLink = [
|
||||||
'href' => (self::$showAll ? 'notifications/' . $notifications['ident'] : 'notifications/' . $notifications['ident'] . '?show=all'),
|
'href' => ($this->showAll ? 'notifications/' . $notifications['ident'] : 'notifications/' . $notifications['ident'] . '?show=all'),
|
||||||
'text' => (self::$showAll ? DI::l10n()->t('Show unread') : DI::l10n()->t('Show all')),
|
'text' => ($this->showAll ? $this->t('Show unread') : $this->t('Show all')),
|
||||||
];
|
];
|
||||||
|
|
||||||
return self::printContent($notificationHeader, $notificationContent, $notificationNoContent, $notificationShowLink);
|
return $this->printContent($notificationHeader, $notificationContent, $notificationNoContent, $notificationShowLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,8 @@ use Friendica\Util\Strings;
|
||||||
*/
|
*/
|
||||||
class Owa extends BaseModule
|
class Owa extends BaseModule
|
||||||
{
|
{
|
||||||
public function init()
|
public function rawContent()
|
||||||
{
|
{
|
||||||
|
|
||||||
$ret = [ 'success' => false ];
|
$ret = [ 'success' => false ];
|
||||||
|
|
||||||
foreach (['REDIRECT_REMOTE_USER', 'HTTP_AUTHORIZATION'] as $head) {
|
foreach (['REDIRECT_REMOTE_USER', 'HTTP_AUTHORIZATION'] as $head) {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
namespace Friendica\Module\Profile;
|
namespace Friendica\Module\Profile;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Profile index router
|
* Profile index router
|
||||||
|
@ -36,11 +37,11 @@ class Index extends BaseModule
|
||||||
{
|
{
|
||||||
public function rawContent()
|
public function rawContent()
|
||||||
{
|
{
|
||||||
(new Profile($this->parameters))->rawContent();
|
(new Profile($this->l10n, $this->parameters))->rawContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function content(): string
|
public function content(): string
|
||||||
{
|
{
|
||||||
return (new Status($this->parameters))->content();
|
return (new Status($this->l10n, $this->parameters))->content();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ use Friendica\DI;
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Util\Proxy;
|
use Friendica\Util\Proxy;
|
||||||
use Friendica\Util\Strings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
||||||
|
@ -44,6 +43,16 @@ class Register extends BaseModule
|
||||||
const APPROVE = 1;
|
const APPROVE = 1;
|
||||||
const OPEN = 2;
|
const OPEN = 2;
|
||||||
|
|
||||||
|
/** @var Tos */
|
||||||
|
protected $tos;
|
||||||
|
|
||||||
|
public function __construct(Tos $tos, L10n $l10n, array $parameters = [])
|
||||||
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->tos = $tos;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module GET method to display any content
|
* Module GET method to display any content
|
||||||
*
|
*
|
||||||
|
@ -129,8 +138,6 @@ class Register extends BaseModule
|
||||||
|
|
||||||
$tpl = $arr['template'];
|
$tpl = $arr['template'];
|
||||||
|
|
||||||
$tos = new Tos($this->parameters);
|
|
||||||
|
|
||||||
$o = Renderer::replaceMacros($tpl, [
|
$o = Renderer::replaceMacros($tpl, [
|
||||||
'$invitations' => DI::config()->get('system', 'invitation_only'),
|
'$invitations' => DI::config()->get('system', 'invitation_only'),
|
||||||
'$permonly' => intval(DI::config()->get('config', 'register_policy')) === self::APPROVE,
|
'$permonly' => intval(DI::config()->get('config', 'register_policy')) === self::APPROVE,
|
||||||
|
@ -164,7 +171,7 @@ class Register extends BaseModule
|
||||||
'$showtoslink' => DI::config()->get('system', 'tosdisplay'),
|
'$showtoslink' => DI::config()->get('system', 'tosdisplay'),
|
||||||
'$tostext' => DI::l10n()->t('Terms of Service'),
|
'$tostext' => DI::l10n()->t('Terms of Service'),
|
||||||
'$showprivstatement' => DI::config()->get('system', 'tosprivstatement'),
|
'$showprivstatement' => DI::config()->get('system', 'tosprivstatement'),
|
||||||
'$privstatement'=> $tos->privacy_complete,
|
'$privstatement'=> $this->tos->privacy_complete,
|
||||||
'$form_security_token' => BaseModule::getFormSecurityToken('register'),
|
'$form_security_token' => BaseModule::getFormSecurityToken('register'),
|
||||||
'$explicit_content' => DI::config()->get('system', 'explicit_content', false),
|
'$explicit_content' => DI::config()->get('system', 'explicit_content', false),
|
||||||
'$explicit_content_note' => DI::l10n()->t('Note: This node explicitly contains adult content'),
|
'$explicit_content_note' => DI::l10n()->t('Note: This node explicitly contains adult content'),
|
||||||
|
|
|
@ -21,9 +21,11 @@
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
|
use Friendica\App\Page;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\Widget;
|
use Friendica\Content\Widget;
|
||||||
use Friendica\DI;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
@ -40,56 +42,64 @@ use Friendica\Network\Probe;
|
||||||
*/
|
*/
|
||||||
class RemoteFollow extends BaseModule
|
class RemoteFollow extends BaseModule
|
||||||
{
|
{
|
||||||
static $owner;
|
/** @var array */
|
||||||
|
protected $owner;
|
||||||
|
/** @var Page */
|
||||||
|
protected $page;
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
public function init()
|
public function __construct(L10n $l10n, Page $page, BaseURL $baseUrl, array $parameters = [])
|
||||||
{
|
{
|
||||||
self::$owner = User::getOwnerDataByNick($this->parameters['profile']);
|
parent::__construct($l10n, $parameters);
|
||||||
if (!self::$owner) {
|
|
||||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
$this->owner = User::getOwnerDataByNick($this->parameters['profile']);
|
||||||
|
if (!$this->owner) {
|
||||||
|
throw new HTTPException\NotFoundException($this->t('User not found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::page()['aside'] = Widget\VCard::getHTML(self::$owner);
|
$this->baseUrl = $baseUrl;
|
||||||
|
$this->page = $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post()
|
public function post()
|
||||||
{
|
{
|
||||||
if (!empty($_POST['cancel']) || empty($_POST['dfrn_url'])) {
|
if (!empty($_POST['cancel']) || empty($_POST['dfrn_url'])) {
|
||||||
DI::baseUrl()->redirect();
|
$this->baseUrl->redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty(self::$owner)) {
|
if (empty($this->owner)) {
|
||||||
notice(DI::l10n()->t('Profile unavailable.'));
|
notice($this->t('Profile unavailable.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = Probe::cleanURI($_POST['dfrn_url']);
|
$url = Probe::cleanURI($_POST['dfrn_url']);
|
||||||
if (!strlen($url)) {
|
if (!strlen($url)) {
|
||||||
notice(DI::l10n()->t("Invalid locator"));
|
notice($this->t("Invalid locator"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect the network, make sure the provided URL is valid
|
// Detect the network, make sure the provided URL is valid
|
||||||
$data = Contact::getByURL($url);
|
$data = Contact::getByURL($url);
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
notice(DI::l10n()->t("The provided profile link doesn't seem to be valid"));
|
notice($this->t("The provided profile link doesn't seem to be valid"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($data['subscribe'])) {
|
if (empty($data['subscribe'])) {
|
||||||
notice(DI::l10n()->t("Remote subscription can't be done for your network. Please subscribe directly on your system."));
|
notice($this->t("Remote subscription can't be done for your network. Please subscribe directly on your system."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::notice('Remote request', ['url' => $url, 'follow' => self::$owner['url'], 'remote' => $data['subscribe']]);
|
Logger::notice('Remote request', ['url' => $url, 'follow' => $this->owner['url'], 'remote' => $data['subscribe']]);
|
||||||
|
|
||||||
// Substitute our user's feed URL into $data['subscribe']
|
// Substitute our user's feed URL into $data['subscribe']
|
||||||
// Send the subscriber home to subscribe
|
// Send the subscriber home to subscribe
|
||||||
// Diaspora needs the uri in the format user@domain.tld
|
// Diaspora needs the uri in the format user@domain.tld
|
||||||
if ($data['network'] == Protocol::DIASPORA) {
|
if ($data['network'] == Protocol::DIASPORA) {
|
||||||
$uri = urlencode(self::$owner['addr']);
|
$uri = urlencode($this->owner['addr']);
|
||||||
} else {
|
} else {
|
||||||
$uri = urlencode(self::$owner['url']);
|
$uri = urlencode($this->owner['url']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$follow_link = str_replace('{uri}', $uri, $data['subscribe']);
|
$follow_link = str_replace('{uri}', $uri, $data['subscribe']);
|
||||||
|
@ -98,25 +108,27 @@ class RemoteFollow extends BaseModule
|
||||||
|
|
||||||
public function content(): string
|
public function content(): string
|
||||||
{
|
{
|
||||||
if (empty(self::$owner)) {
|
if (empty($this->owner)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$target_addr = self::$owner['addr'];
|
$this->page['aside'] = Widget\VCard::getHTML($this->owner);
|
||||||
$target_url = self::$owner['url'];
|
|
||||||
|
$target_addr = $this->owner['addr'];
|
||||||
|
$target_url = $this->owner['url'];
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('auto_request.tpl');
|
$tpl = Renderer::getMarkupTemplate('auto_request.tpl');
|
||||||
$o = Renderer::replaceMacros($tpl, [
|
$o = Renderer::replaceMacros($tpl, [
|
||||||
'$header' => DI::l10n()->t('Friend/Connection Request'),
|
'$header' => $this->t('Friend/Connection Request'),
|
||||||
'$page_desc' => DI::l10n()->t('Enter your Webfinger address (user@domain.tld) or profile URL here. If this isn\'t supported by your system, you have to subscribe to <strong>%s</strong> or <strong>%s</strong> directly on your system.', $target_addr, $target_url),
|
'$page_desc' => $this->t('Enter your Webfinger address (user@domain.tld) or profile URL here. If this isn\'t supported by your system, you have to subscribe to <strong>%s</strong> or <strong>%s</strong> directly on your system.', $target_addr, $target_url),
|
||||||
'$invite_desc' => DI::l10n()->t('If you are not yet a member of the free social web, <a href="%s">follow this link to find a public Friendica node and join us today</a>.', Search::getGlobalDirectory() . '/servers'),
|
'$invite_desc' => $this->t('If you are not yet a member of the free social web, <a href="%s">follow this link to find a public Friendica node and join us today</a>.', Search::getGlobalDirectory() . '/servers'),
|
||||||
'$your_address' => DI::l10n()->t('Your Webfinger address or profile URL:'),
|
'$your_address' => $this->t('Your Webfinger address or profile URL:'),
|
||||||
'$pls_answer' => DI::l10n()->t('Please answer the following:'),
|
'$pls_answer' => $this->t('Please answer the following:'),
|
||||||
'$submit' => DI::l10n()->t('Submit Request'),
|
'$submit' => $this->t('Submit Request'),
|
||||||
'$cancel' => DI::l10n()->t('Cancel'),
|
'$cancel' => $this->t('Cancel'),
|
||||||
|
|
||||||
'$request' => 'remote_follow/' . $this->parameters['profile'],
|
'$request' => 'remote_follow/' . $this->parameters['profile'],
|
||||||
'$name' => self::$owner['name'],
|
'$name' => $this->owner['name'],
|
||||||
'$myaddr' => Profile::getMyURL(),
|
'$myaddr' => Profile::getMyURL(),
|
||||||
]);
|
]);
|
||||||
return $o;
|
return $o;
|
||||||
|
|
|
@ -21,16 +21,34 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Search;
|
namespace Friendica\Module\Search;
|
||||||
|
|
||||||
|
use Friendica\App\Arguments;
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Search;
|
use Friendica\Core\Search;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\Database;
|
||||||
use Friendica\DI;
|
|
||||||
|
|
||||||
class Saved extends BaseModule
|
class Saved extends BaseModule
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var Arguments */
|
||||||
|
protected $args;
|
||||||
|
/** @var Database */
|
||||||
|
protected $dba;
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
|
public function __construct(BaseURL $baseUrl, Database $dba, Arguments $args, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
$action = DI::args()->get(2, 'none');
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
$this->dba = $dba;
|
||||||
|
$this->args = $args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rawContent()
|
||||||
|
{
|
||||||
|
$action = $this->args->get(2, 'none');
|
||||||
$search = trim(rawurldecode($_GET['term'] ?? ''));
|
$search = trim(rawurldecode($_GET['term'] ?? ''));
|
||||||
|
|
||||||
$return_url = $_GET['return_url'] ?? Search::getSearchPath($search);
|
$return_url = $_GET['return_url'] ?? Search::getSearchPath($search);
|
||||||
|
@ -39,23 +57,23 @@ class Saved extends BaseModule
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'add':
|
case 'add':
|
||||||
$fields = ['uid' => local_user(), 'term' => $search];
|
$fields = ['uid' => local_user(), 'term' => $search];
|
||||||
if (!DBA::exists('search', $fields)) {
|
if (!$this->dba->exists('search', $fields)) {
|
||||||
if (!DBA::insert('search', $fields)) {
|
if (!$this->dba->insert('search', $fields)) {
|
||||||
notice(DI::l10n()->t('Search term was not saved.'));
|
notice($this->t('Search term was not saved.'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
notice(DI::l10n()->t('Search term already saved.'));
|
notice($this->t('Search term already saved.'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'remove':
|
case 'remove':
|
||||||
if (!DBA::delete('search', ['uid' => local_user(), 'term' => $search])) {
|
if (!$this->dba->delete('search', ['uid' => local_user(), 'term' => $search])) {
|
||||||
notice(DI::l10n()->t('Search term was not removed.'));
|
notice($this->t('Search term was not removed.'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::baseUrl()->redirect($return_url);
|
$this->baseUrl->redirect($return_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,15 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Security;
|
namespace Friendica\Module\Security;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\Cache\Capability\ICanCache;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
|
use Friendica\Model\User\Cookie;
|
||||||
use Friendica\Security\TwoFactor;
|
use Friendica\Security\TwoFactor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,33 +37,55 @@ use Friendica\Security\TwoFactor;
|
||||||
*/
|
*/
|
||||||
class Logout extends BaseModule
|
class Logout extends BaseModule
|
||||||
{
|
{
|
||||||
|
/** @var ICanCache */
|
||||||
|
protected $cache;
|
||||||
|
/** @var Cookie */
|
||||||
|
protected $cookie;
|
||||||
|
/** @var IHandleSessions */
|
||||||
|
protected $session;
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
/** @var TwoFactor\Repository\TrustedBrowser */
|
||||||
|
protected $trustedBrowserRepo;
|
||||||
|
|
||||||
|
public function __construct(TwoFactor\Repository\TrustedBrowser $trustedBrowserRepo, ICanCache $cache, Cookie $cookie, IHandleSessions $session, BaseURL $baseUrl, L10n $l10n, array $parameters = [])
|
||||||
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->cache = $cache;
|
||||||
|
$this->cookie = $cookie;
|
||||||
|
$this->session = $session;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
$this->trustedBrowserRepo = $trustedBrowserRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process logout requests
|
* Process logout requests
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$visitor_home = null;
|
$visitor_home = null;
|
||||||
if (remote_user()) {
|
if (remote_user()) {
|
||||||
$visitor_home = Profile::getMyURL();
|
$visitor_home = Profile::getMyURL();
|
||||||
DI::cache()->delete('zrlInit:' . $visitor_home);
|
$this->cache->delete('zrlInit:' . $visitor_home);
|
||||||
}
|
}
|
||||||
|
|
||||||
Hook::callAll("logging_out");
|
Hook::callAll("logging_out");
|
||||||
|
|
||||||
// Remove this trusted browser as it won't be able to be used ever again after the cookie is cleared
|
// Remove this trusted browser as it won't be able to be used ever again after the cookie is cleared
|
||||||
if (DI::cookie()->get('trusted')) {
|
if ($this->cookie->get('trusted')) {
|
||||||
$trustedBrowserRepository = new TwoFactor\Repository\TrustedBrowser(DI::dba(), DI::logger());
|
$this->trustedBrowserRepo->removeForUser(local_user(), $this->cookie->get('trusted'));
|
||||||
$trustedBrowserRepository->removeForUser(local_user(), DI::cookie()->get('trusted'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::cookie()->clear();
|
$this->cookie->clear();
|
||||||
DI::session()->clear();
|
$this->session->clear();
|
||||||
|
|
||||||
if ($visitor_home) {
|
if ($visitor_home) {
|
||||||
System::externalRedirect($visitor_home);
|
System::externalRedirect($visitor_home);
|
||||||
} else {
|
} else {
|
||||||
info(DI::l10n()->t('Logged out.'));
|
info($this->t('Logged out.'));
|
||||||
DI::baseUrl()->redirect();
|
$this->baseUrl->redirect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,13 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Security\TwoFactor;
|
namespace Friendica\Module\Security\TwoFactor;
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
use Friendica\Security\Authentication;
|
||||||
use Friendica\Security\TwoFactor\Model\RecoveryCode;
|
use Friendica\Security\TwoFactor\Model\RecoveryCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,11 +37,23 @@ use Friendica\Security\TwoFactor\Model\RecoveryCode;
|
||||||
*/
|
*/
|
||||||
class Recovery extends BaseModule
|
class Recovery extends BaseModule
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var IHandleSessions */
|
||||||
|
protected $session;
|
||||||
|
/** @var App */
|
||||||
|
protected $app;
|
||||||
|
/** @var App\BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
/** @var Authentication */
|
||||||
|
protected $auth;
|
||||||
|
|
||||||
|
public function __construct(App $app, App\BaseURL $baseUrl, Authentication $auth, IHandleSessions $session, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
parent::__construct($l10n, $parameters);
|
||||||
return;
|
|
||||||
}
|
$this->app = $app;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
$this->auth = $auth;
|
||||||
|
$this->session = $session;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post()
|
public function post()
|
||||||
|
@ -51,18 +65,16 @@ class Recovery extends BaseModule
|
||||||
if (($_POST['action'] ?? '') == 'recover') {
|
if (($_POST['action'] ?? '') == 'recover') {
|
||||||
self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_recovery');
|
self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_recovery');
|
||||||
|
|
||||||
$a = DI::app();
|
|
||||||
|
|
||||||
$recovery_code = $_POST['recovery_code'] ?? '';
|
$recovery_code = $_POST['recovery_code'] ?? '';
|
||||||
|
|
||||||
if (RecoveryCode::existsForUser(local_user(), $recovery_code)) {
|
if (RecoveryCode::existsForUser(local_user(), $recovery_code)) {
|
||||||
RecoveryCode::markUsedForUser(local_user(), $recovery_code);
|
RecoveryCode::markUsedForUser(local_user(), $recovery_code);
|
||||||
Session::set('2fa', true);
|
$this->session->set('2fa', true);
|
||||||
info(DI::l10n()->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user())));
|
info($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user())));
|
||||||
|
|
||||||
DI::auth()->setForUser($a, User::getById($a->getLoggedInUserId()), true, true);
|
$this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
|
||||||
} else {
|
} else {
|
||||||
notice(DI::l10n()->t('Invalid code, please retry.'));
|
notice($this->t('Invalid code, please retry.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,22 +82,22 @@ class Recovery extends BaseModule
|
||||||
public function content(): string
|
public function content(): string
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
DI::baseUrl()->redirect();
|
$this->baseUrl->redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Already authenticated with 2FA token
|
// Already authenticated with 2FA token
|
||||||
if (Session::get('2fa')) {
|
if ($this->session->get('2fa')) {
|
||||||
DI::baseUrl()->redirect();
|
$this->baseUrl->redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('twofactor/recovery.tpl'), [
|
return Renderer::replaceMacros(Renderer::getMarkupTemplate('twofactor/recovery.tpl'), [
|
||||||
'$form_security_token' => self::getFormSecurityToken('twofactor_recovery'),
|
'$form_security_token' => self::getFormSecurityToken('twofactor_recovery'),
|
||||||
|
|
||||||
'$title' => DI::l10n()->t('Two-factor recovery'),
|
'$title' => $this->t('Two-factor recovery'),
|
||||||
'$message' => DI::l10n()->t('<p>You can enter one of your one-time recovery codes in case you lost access to your mobile device.</p>'),
|
'$message' => $this->t('<p>You can enter one of your one-time recovery codes in case you lost access to your mobile device.</p>'),
|
||||||
'$recovery_message' => DI::l10n()->t('Don’t have your phone? <a href="%s">Enter a two-factor recovery code</a>', '2fa/recovery'),
|
'$recovery_message' => $this->t('Don’t have your phone? <a href="%s">Enter a two-factor recovery code</a>', '2fa/recovery'),
|
||||||
'$recovery_code' => ['recovery_code', DI::l10n()->t('Please enter a recovery code'), '', '', '', 'placeholder="000000-000000"'],
|
'$recovery_code' => ['recovery_code', $this->t('Please enter a recovery code'), '', '', '', 'placeholder="000000-000000"'],
|
||||||
'$recovery_label' => DI::l10n()->t('Submit recovery code and complete login'),
|
'$recovery_label' => $this->t('Submit recovery code and complete login'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,10 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Settings\TwoFactor;
|
namespace Friendica\Module\Settings\TwoFactor;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
|
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
|
||||||
use Friendica\Module\BaseSettings;
|
use Friendica\Module\BaseSettings;
|
||||||
use Friendica\Module\Security\Login;
|
use Friendica\Module\Security\Login;
|
||||||
|
@ -34,23 +36,33 @@ use Friendica\Module\Security\Login;
|
||||||
*/
|
*/
|
||||||
class AppSpecific extends BaseSettings
|
class AppSpecific extends BaseSettings
|
||||||
{
|
{
|
||||||
private static $appSpecificPassword = null;
|
private $appSpecificPassword = null;
|
||||||
|
|
||||||
public function init()
|
/** @var IManagePersonalConfigValues */
|
||||||
|
protected $pConfig;
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
|
public function __construct(IManagePersonalConfigValues $pConfig, BaseURL $baseUrl, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->pConfig = $pConfig;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$verified = DI::pConfig()->get(local_user(), '2fa', 'verified');
|
$verified = $this->pConfig->get(local_user(), '2fa', 'verified');
|
||||||
|
|
||||||
if (!$verified) {
|
if (!$verified) {
|
||||||
DI::baseUrl()->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
|
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
|
||||||
notice(DI::l10n()->t('Please enter your password to access this page.'));
|
notice($this->t('Please enter your password to access this page.'));
|
||||||
DI::baseUrl()->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,21 +79,21 @@ class AppSpecific extends BaseSettings
|
||||||
case 'generate':
|
case 'generate':
|
||||||
$description = $_POST['description'] ?? '';
|
$description = $_POST['description'] ?? '';
|
||||||
if (empty($description)) {
|
if (empty($description)) {
|
||||||
notice(DI::l10n()->t('App-specific password generation failed: The description is empty.'));
|
notice($this->t('App-specific password generation failed: The description is empty.'));
|
||||||
DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
} elseif (AppSpecificPassword::checkDuplicateForUser(local_user(), $description)) {
|
} elseif (AppSpecificPassword::checkDuplicateForUser(local_user(), $description)) {
|
||||||
notice(DI::l10n()->t('App-specific password generation failed: This description already exists.'));
|
notice($this->t('App-specific password generation failed: This description already exists.'));
|
||||||
DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
} else {
|
} else {
|
||||||
self::$appSpecificPassword = AppSpecificPassword::generateForUser(local_user(), $_POST['description'] ?? '');
|
$this->appSpecificPassword = AppSpecificPassword::generateForUser(local_user(), $_POST['description'] ?? '');
|
||||||
info(DI::l10n()->t('New app-specific password generated.'));
|
info($this->t('New app-specific password generated.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'revoke_all' :
|
case 'revoke_all' :
|
||||||
AppSpecificPassword::deleteAllForUser(local_user());
|
AppSpecificPassword::deleteAllForUser(local_user());
|
||||||
info(DI::l10n()->t('App-specific passwords successfully revoked.'));
|
info($this->t('App-specific passwords successfully revoked.'));
|
||||||
DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,10 +102,10 @@ class AppSpecific extends BaseSettings
|
||||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa/app_specific', 'settings_2fa_app_specific');
|
self::checkFormSecurityTokenRedirectOnError('settings/2fa/app_specific', 'settings_2fa_app_specific');
|
||||||
|
|
||||||
if (AppSpecificPassword::deleteForUser(local_user(), $_POST['revoke_id'])) {
|
if (AppSpecificPassword::deleteForUser(local_user(), $_POST['revoke_id'])) {
|
||||||
info(DI::l10n()->t('App-specific password successfully revoked.'));
|
info($this->t('App-specific password successfully revoked.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,22 +123,22 @@ class AppSpecific extends BaseSettings
|
||||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa_app_specific'),
|
'$form_security_token' => self::getFormSecurityToken('settings_2fa_app_specific'),
|
||||||
'$password_security_token' => self::getFormSecurityToken('settings_2fa_password'),
|
'$password_security_token' => self::getFormSecurityToken('settings_2fa_password'),
|
||||||
|
|
||||||
'$title' => DI::l10n()->t('Two-factor app-specific passwords'),
|
'$title' => $this->t('Two-factor app-specific passwords'),
|
||||||
'$help_label' => DI::l10n()->t('Help'),
|
'$help_label' => $this->t('Help'),
|
||||||
'$message' => DI::l10n()->t('<p>App-specific passwords are randomly generated passwords used instead your regular password to authenticate your account on third-party applications that don\'t support two-factor authentication.</p>'),
|
'$message' => $this->t('<p>App-specific passwords are randomly generated passwords used instead your regular password to authenticate your account on third-party applications that don\'t support two-factor authentication.</p>'),
|
||||||
'$generated_message' => DI::l10n()->t('Make sure to copy your new app-specific password now. You won’t be able to see it again!'),
|
'$generated_message' => $this->t('Make sure to copy your new app-specific password now. You won’t be able to see it again!'),
|
||||||
'$generated_app_specific_password' => self::$appSpecificPassword,
|
'$generated_app_specific_password' => $this->appSpecificPassword,
|
||||||
|
|
||||||
'$description_label' => DI::l10n()->t('Description'),
|
'$description_label' => $this->t('Description'),
|
||||||
'$last_used_label' => DI::l10n()->t('Last Used'),
|
'$last_used_label' => $this->t('Last Used'),
|
||||||
'$revoke_label' => DI::l10n()->t('Revoke'),
|
'$revoke_label' => $this->t('Revoke'),
|
||||||
'$revoke_all_label' => DI::l10n()->t('Revoke All'),
|
'$revoke_all_label' => $this->t('Revoke All'),
|
||||||
|
|
||||||
'$app_specific_passwords' => $appSpecificPasswords,
|
'$app_specific_passwords' => $appSpecificPasswords,
|
||||||
'$generate_message' => DI::l10n()->t('When you generate a new app-specific password, you must use it right away, it will be shown to you once after you generate it.'),
|
'$generate_message' => $this->t('When you generate a new app-specific password, you must use it right away, it will be shown to you once after you generate it.'),
|
||||||
'$generate_title' => DI::l10n()->t('Generate new app-specific password'),
|
'$generate_title' => $this->t('Generate new app-specific password'),
|
||||||
'$description_placeholder_label' => DI::l10n()->t('Friendiqa on my Fairphone 2...'),
|
'$description_placeholder_label' => $this->t('Friendiqa on my Fairphone 2...'),
|
||||||
'$generate_label' => DI::l10n()->t('Generate'),
|
'$generate_label' => $this->t('Generate'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,10 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Settings\TwoFactor;
|
namespace Friendica\Module\Settings\TwoFactor;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Security\TwoFactor\Model\RecoveryCode;
|
use Friendica\Security\TwoFactor\Model\RecoveryCode;
|
||||||
use Friendica\Module\BaseSettings;
|
use Friendica\Module\BaseSettings;
|
||||||
use Friendica\Module\Security\Login;
|
use Friendica\Module\Security\Login;
|
||||||
|
@ -34,21 +36,31 @@ use Friendica\Module\Security\Login;
|
||||||
*/
|
*/
|
||||||
class Recovery extends BaseSettings
|
class Recovery extends BaseSettings
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var IManagePersonalConfigValues */
|
||||||
|
protected $pConfig;
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
|
public function __construct(IManagePersonalConfigValues $pConfig, BaseURL $baseUrl, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->pConfig = $pConfig;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$secret = DI::pConfig()->get(local_user(), '2fa', 'secret');
|
$secret = $this->pConfig->get(local_user(), '2fa', 'secret');
|
||||||
|
|
||||||
if (!$secret) {
|
if (!$secret) {
|
||||||
DI::baseUrl()->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
|
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
|
||||||
notice(DI::l10n()->t('Please enter your password to access this page.'));
|
notice($this->t('Please enter your password to access this page.'));
|
||||||
DI::baseUrl()->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +75,8 @@ class Recovery extends BaseSettings
|
||||||
|
|
||||||
if ($_POST['action'] == 'regenerate') {
|
if ($_POST['action'] == 'regenerate') {
|
||||||
RecoveryCode::regenerateForUser(local_user());
|
RecoveryCode::regenerateForUser(local_user());
|
||||||
info(DI::l10n()->t('New recovery codes successfully generated.'));
|
info($this->t('New recovery codes successfully generated.'));
|
||||||
DI::baseUrl()->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
$this->baseUrl->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,20 +95,20 @@ class Recovery extends BaseSettings
|
||||||
|
|
||||||
$recoveryCodes = RecoveryCode::getListForUser(local_user());
|
$recoveryCodes = RecoveryCode::getListForUser(local_user());
|
||||||
|
|
||||||
$verified = DI::pConfig()->get(local_user(), '2fa', 'verified');
|
$verified = $this->pConfig->get(local_user(), '2fa', 'verified');
|
||||||
|
|
||||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/recovery.tpl'), [
|
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/recovery.tpl'), [
|
||||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa_recovery'),
|
'$form_security_token' => self::getFormSecurityToken('settings_2fa_recovery'),
|
||||||
'$password_security_token' => self::getFormSecurityToken('settings_2fa_password'),
|
'$password_security_token' => self::getFormSecurityToken('settings_2fa_password'),
|
||||||
|
|
||||||
'$title' => DI::l10n()->t('Two-factor recovery codes'),
|
'$title' => $this->t('Two-factor recovery codes'),
|
||||||
'$help_label' => DI::l10n()->t('Help'),
|
'$help_label' => $this->t('Help'),
|
||||||
'$message' => DI::l10n()->t('<p>Recovery codes can be used to access your account in the event you lose access to your device and cannot receive two-factor authentication codes.</p><p><strong>Put these in a safe spot!</strong> If you lose your device and don’t have the recovery codes you will lose access to your account.</p>'),
|
'$message' => $this->t('<p>Recovery codes can be used to access your account in the event you lose access to your device and cannot receive two-factor authentication codes.</p><p><strong>Put these in a safe spot!</strong> If you lose your device and don’t have the recovery codes you will lose access to your account.</p>'),
|
||||||
'$recovery_codes' => $recoveryCodes,
|
'$recovery_codes' => $recoveryCodes,
|
||||||
'$regenerate_message' => DI::l10n()->t('When you generate new recovery codes, you must copy the new codes. Your old codes won’t work anymore.'),
|
'$regenerate_message' => $this->t('When you generate new recovery codes, you must copy the new codes. Your old codes won’t work anymore.'),
|
||||||
'$regenerate_label' => DI::l10n()->t('Generate new recovery codes'),
|
'$regenerate_label' => $this->t('Generate new recovery codes'),
|
||||||
'$verified' => $verified,
|
'$verified' => $verified,
|
||||||
'$verify_label' => DI::l10n()->t('Next: Verification'),
|
'$verify_label' => $this->t('Next: Verification'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Settings\TwoFactor;
|
namespace Friendica\Module\Settings\TwoFactor;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Module\BaseSettings;
|
use Friendica\Module\BaseSettings;
|
||||||
use Friendica\Security\TwoFactor;
|
use Friendica\Security\TwoFactor;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
|
@ -14,21 +16,34 @@ use UAParser\Parser;
|
||||||
*/
|
*/
|
||||||
class Trusted extends BaseSettings
|
class Trusted extends BaseSettings
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var IManagePersonalConfigValues */
|
||||||
|
protected $pConfig;
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
/** @var TwoFactor\Repository\TrustedBrowser */
|
||||||
|
protected $trustedBrowserRepo;
|
||||||
|
|
||||||
|
public function __construct(IManagePersonalConfigValues $pConfig, BaseURL $baseUrl, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepo, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->pConfig = $pConfig;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
$this->trustedBrowserRepo = $trustedBrowserRepo;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$verified = DI::pConfig()->get(local_user(), '2fa', 'verified');
|
$verified = $this->pConfig->get(local_user(), '2fa', 'verified');
|
||||||
|
|
||||||
if (!$verified) {
|
if (!$verified) {
|
||||||
DI::baseUrl()->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
|
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
|
||||||
notice(DI::l10n()->t('Please enter your password to access this page.'));
|
notice($this->t('Please enter your password to access this page.'));
|
||||||
DI::baseUrl()->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,16 +53,14 @@ class Trusted extends BaseSettings
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$trustedBrowserRepository = new TwoFactor\Repository\TrustedBrowser(DI::dba(), DI::logger());
|
|
||||||
|
|
||||||
if (!empty($_POST['action'])) {
|
if (!empty($_POST['action'])) {
|
||||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted');
|
self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted');
|
||||||
|
|
||||||
switch ($_POST['action']) {
|
switch ($_POST['action']) {
|
||||||
case 'remove_all' :
|
case 'remove_all' :
|
||||||
$trustedBrowserRepository->removeAllForUser(local_user());
|
$this->trustedBrowserRepo->removeAllForUser(local_user());
|
||||||
info(DI::l10n()->t('Trusted browsers successfully removed.'));
|
info($this->t('Trusted browsers successfully removed.'));
|
||||||
DI::baseUrl()->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,11 +68,11 @@ class Trusted extends BaseSettings
|
||||||
if (!empty($_POST['remove_id'])) {
|
if (!empty($_POST['remove_id'])) {
|
||||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted');
|
self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted');
|
||||||
|
|
||||||
if ($trustedBrowserRepository->removeForUser(local_user(), $_POST['remove_id'])) {
|
if ($this->trustedBrowserRepo->removeForUser(local_user(), $_POST['remove_id'])) {
|
||||||
info(DI::l10n()->t('Trusted browser successfully removed.'));
|
info($this->t('Trusted browser successfully removed.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::baseUrl()->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +81,7 @@ class Trusted extends BaseSettings
|
||||||
{
|
{
|
||||||
parent::content();
|
parent::content();
|
||||||
|
|
||||||
$trustedBrowserRepository = new TwoFactor\Repository\TrustedBrowser(DI::dba(), DI::logger());
|
$trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(local_user());
|
||||||
$trustedBrowsers = $trustedBrowserRepository->selectAllByUid(local_user());
|
|
||||||
|
|
||||||
$parser = Parser::create();
|
$parser = Parser::create();
|
||||||
|
|
||||||
|
@ -94,15 +106,15 @@ class Trusted extends BaseSettings
|
||||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa_trusted'),
|
'$form_security_token' => self::getFormSecurityToken('settings_2fa_trusted'),
|
||||||
'$password_security_token' => self::getFormSecurityToken('settings_2fa_password'),
|
'$password_security_token' => self::getFormSecurityToken('settings_2fa_password'),
|
||||||
|
|
||||||
'$title' => DI::l10n()->t('Two-factor Trusted Browsers'),
|
'$title' => $this->t('Two-factor Trusted Browsers'),
|
||||||
'$message' => DI::l10n()->t('Trusted browsers are individual browsers you chose to skip two-factor authentication to access Friendica. Please use this feature sparingly, as it can negate the benefit of two-factor authentication.'),
|
'$message' => $this->t('Trusted browsers are individual browsers you chose to skip two-factor authentication to access Friendica. Please use this feature sparingly, as it can negate the benefit of two-factor authentication.'),
|
||||||
'$device_label' => DI::l10n()->t('Device'),
|
'$device_label' => $this->t('Device'),
|
||||||
'$os_label' => DI::l10n()->t('OS'),
|
'$os_label' => $this->t('OS'),
|
||||||
'$browser_label' => DI::l10n()->t('Browser'),
|
'$browser_label' => $this->t('Browser'),
|
||||||
'$created_label' => DI::l10n()->t('Trusted'),
|
'$created_label' => $this->t('Trusted'),
|
||||||
'$last_used_label' => DI::l10n()->t('Last Use'),
|
'$last_used_label' => $this->t('Last Use'),
|
||||||
'$remove_label' => DI::l10n()->t('Remove'),
|
'$remove_label' => $this->t('Remove'),
|
||||||
'$remove_all_label' => DI::l10n()->t('Remove All'),
|
'$remove_all_label' => $this->t('Remove All'),
|
||||||
|
|
||||||
'$trusted_browsers' => $trustedBrowserDisplay,
|
'$trusted_browsers' => $trustedBrowserDisplay,
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -25,9 +25,11 @@ use BaconQrCode\Renderer\Image\SvgImageBackEnd;
|
||||||
use BaconQrCode\Renderer\ImageRenderer;
|
use BaconQrCode\Renderer\ImageRenderer;
|
||||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||||
use BaconQrCode\Writer;
|
use BaconQrCode\Writer;
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Module\BaseSettings;
|
use Friendica\Module\BaseSettings;
|
||||||
use Friendica\Module\Security\Login;
|
use Friendica\Module\Security\Login;
|
||||||
use PragmaRX\Google2FA\Google2FA;
|
use PragmaRX\Google2FA\Google2FA;
|
||||||
|
@ -39,22 +41,32 @@ use PragmaRX\Google2FA\Google2FA;
|
||||||
*/
|
*/
|
||||||
class Verify extends BaseSettings
|
class Verify extends BaseSettings
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var IManagePersonalConfigValues */
|
||||||
|
protected $pConfig;
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
|
public function __construct(IManagePersonalConfigValues $pConfig, BaseURL $baseUrl, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->pConfig = $pConfig;
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$secret = DI::pConfig()->get(local_user(), '2fa', 'secret');
|
$secret = $this->pConfig->get(local_user(), '2fa', 'secret');
|
||||||
$verified = DI::pConfig()->get(local_user(), '2fa', 'verified');
|
$verified = $this->pConfig->get(local_user(), '2fa', 'verified');
|
||||||
|
|
||||||
if ($secret && $verified) {
|
if ($secret && $verified) {
|
||||||
DI::baseUrl()->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
|
if (!self::checkFormSecurityToken('settings_2fa_password', 't')) {
|
||||||
notice(DI::l10n()->t('Please enter your password to access this page.'));
|
notice($this->t('Please enter your password to access this page.'));
|
||||||
DI::baseUrl()->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,17 +81,17 @@ class Verify extends BaseSettings
|
||||||
|
|
||||||
$google2fa = new Google2FA();
|
$google2fa = new Google2FA();
|
||||||
|
|
||||||
$valid = $google2fa->verifyKey(DI::pConfig()->get(local_user(), '2fa', 'secret'), $_POST['verify_code'] ?? '');
|
$valid = $google2fa->verifyKey($this->pConfig->get(local_user(), '2fa', 'secret'), $_POST['verify_code'] ?? '');
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
DI::pConfig()->set(local_user(), '2fa', 'verified', true);
|
$this->pConfig->set(local_user(), '2fa', 'verified', true);
|
||||||
Session::set('2fa', true);
|
Session::set('2fa', true);
|
||||||
|
|
||||||
info(DI::l10n()->t('Two-factor authentication successfully activated.'));
|
info($this->t('Two-factor authentication successfully activated.'));
|
||||||
|
|
||||||
DI::baseUrl()->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
} else {
|
} else {
|
||||||
notice(DI::l10n()->t('Invalid code, please retry.'));
|
notice($this->t('Invalid code, please retry.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +106,7 @@ class Verify extends BaseSettings
|
||||||
|
|
||||||
$company = 'Friendica';
|
$company = 'Friendica';
|
||||||
$holder = Session::get('my_address');
|
$holder = Session::get('my_address');
|
||||||
$secret = DI::pConfig()->get(local_user(), '2fa', 'secret');
|
$secret = $this->pConfig->get(local_user(), '2fa', 'secret');
|
||||||
|
|
||||||
$otpauthUrl = (new Google2FA())->getQRCodeUrl($company, $holder, $secret);
|
$otpauthUrl = (new Google2FA())->getQRCodeUrl($company, $holder, $secret);
|
||||||
|
|
||||||
|
@ -108,7 +120,7 @@ class Verify extends BaseSettings
|
||||||
|
|
||||||
$shortOtpauthUrl = explode('?', $otpauthUrl)[0];
|
$shortOtpauthUrl = explode('?', $otpauthUrl)[0];
|
||||||
|
|
||||||
$manual_message = DI::l10n()->t('<p>Or you can submit the authentication settings manually:</p>
|
$manual_message = $this->t('<p>Or you can submit the authentication settings manually:</p>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Issuer</dt>
|
<dt>Issuer</dt>
|
||||||
<dd>%s</dd>
|
<dd>%s</dd>
|
||||||
|
@ -128,18 +140,18 @@ class Verify extends BaseSettings
|
||||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa_verify'),
|
'$form_security_token' => self::getFormSecurityToken('settings_2fa_verify'),
|
||||||
'$password_security_token' => self::getFormSecurityToken('settings_2fa_password'),
|
'$password_security_token' => self::getFormSecurityToken('settings_2fa_password'),
|
||||||
|
|
||||||
'$title' => DI::l10n()->t('Two-factor code verification'),
|
'$title' => $this->t('Two-factor code verification'),
|
||||||
'$help_label' => DI::l10n()->t('Help'),
|
'$help_label' => $this->t('Help'),
|
||||||
'$message' => DI::l10n()->t('<p>Please scan this QR Code with your authenticator app and submit the provided code.</p>'),
|
'$message' => $this->t('<p>Please scan this QR Code with your authenticator app and submit the provided code.</p>'),
|
||||||
'$qrcode_image' => $qrcode_image,
|
'$qrcode_image' => $qrcode_image,
|
||||||
'$qrcode_url_message' => DI::l10n()->t('<p>Or you can open the following URL in your mobile device:</p><p><a href="%s">%s</a></p>', $otpauthUrl, $shortOtpauthUrl),
|
'$qrcode_url_message' => $this->t('<p>Or you can open the following URL in your mobile device:</p><p><a href="%s">%s</a></p>', $otpauthUrl, $shortOtpauthUrl),
|
||||||
'$manual_message' => $manual_message,
|
'$manual_message' => $manual_message,
|
||||||
'$company' => $company,
|
'$company' => $company,
|
||||||
'$holder' => $holder,
|
'$holder' => $holder,
|
||||||
'$secret' => $secret,
|
'$secret' => $secret,
|
||||||
|
|
||||||
'$verify_code' => ['verify_code', DI::l10n()->t('Please enter a code from your authentication app'), '', '', DI::l10n()->t('Required'), 'autofocus autocomplete="off" placeholder="000000"'],
|
'$verify_code' => ['verify_code', $this->t('Please enter a code from your authentication app'), '', '', $this->t('Required'), 'autofocus autocomplete="off" placeholder="000000"'],
|
||||||
'$verify_label' => DI::l10n()->t('Verify code and enable two-factor authentication'),
|
'$verify_label' => $this->t('Verify code and enable two-factor authentication'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,26 +23,35 @@ namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\DI;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Network\HTTPException\NotFoundException;
|
use Friendica\Network\HTTPException\NotFoundException;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Statistics extends BaseModule
|
class Statistics extends BaseModule
|
||||||
{
|
{
|
||||||
public function init()
|
/** @var IManageConfigValues */
|
||||||
|
protected $config;
|
||||||
|
/** @var LoggerInterface */
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
|
public function __construct(IManageConfigValues $config, LoggerInterface $logger, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
if (!DI::config()->get("system", "nodeinfo")) {
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
|
$this->logger = $logger;
|
||||||
|
$this->config = $config;
|
||||||
|
|
||||||
|
if (!$this->config->get("system", "nodeinfo")) {
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rawContent()
|
public function rawContent()
|
||||||
{
|
{
|
||||||
$config = DI::config();
|
|
||||||
$logger = DI::logger();
|
|
||||||
|
|
||||||
$registration_open =
|
$registration_open =
|
||||||
intval($config->get('config', 'register_policy')) !== Register::CLOSED
|
intval($this->config->get('config', 'register_policy')) !== Register::CLOSED
|
||||||
&& !$config->get('config', 'invitation_only');
|
&& !$this->config->get('config', 'invitation_only');
|
||||||
|
|
||||||
/// @todo mark the "service" addons and load them dynamically here
|
/// @todo mark the "service" addons and load them dynamically here
|
||||||
$services = [
|
$services = [
|
||||||
|
@ -59,20 +68,20 @@ class Statistics extends BaseModule
|
||||||
];
|
];
|
||||||
|
|
||||||
$statistics = array_merge([
|
$statistics = array_merge([
|
||||||
'name' => $config->get('config', 'sitename'),
|
'name' => $this->config->get('config', 'sitename'),
|
||||||
'network' => FRIENDICA_PLATFORM,
|
'network' => FRIENDICA_PLATFORM,
|
||||||
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
|
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
|
||||||
'registrations_open' => $registration_open,
|
'registrations_open' => $registration_open,
|
||||||
'total_users' => $config->get('nodeinfo', 'total_users'),
|
'total_users' => $this->config->get('nodeinfo', 'total_users'),
|
||||||
'active_users_halfyear' => $config->get('nodeinfo', 'active_users_halfyear'),
|
'active_users_halfyear' => $this->config->get('nodeinfo', 'active_users_halfyear'),
|
||||||
'active_users_monthly' => $config->get('nodeinfo', 'active_users_monthly'),
|
'active_users_monthly' => $this->config->get('nodeinfo', 'active_users_monthly'),
|
||||||
'local_posts' => $config->get('nodeinfo', 'local_posts'),
|
'local_posts' => $this->config->get('nodeinfo', 'local_posts'),
|
||||||
'services' => $services,
|
'services' => $services,
|
||||||
], $services);
|
], $services);
|
||||||
|
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||||
$logger->debug("statistics.", ['statistics' => $statistics]);
|
$this->logger->debug("statistics.", ['statistics' => $statistics]);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,12 @@
|
||||||
|
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\DI;
|
|
||||||
|
|
||||||
class Tos extends BaseModule
|
class Tos extends BaseModule
|
||||||
{
|
{
|
||||||
|
@ -34,6 +36,11 @@ class Tos extends BaseModule
|
||||||
public $privacy_delete;
|
public $privacy_delete;
|
||||||
public $privacy_complete;
|
public $privacy_complete;
|
||||||
|
|
||||||
|
/** @var IManageConfigValues */
|
||||||
|
protected $config;
|
||||||
|
/** @var BaseURL */
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor for the module, initializing the text variables
|
* constructor for the module, initializing the text variables
|
||||||
*
|
*
|
||||||
|
@ -41,30 +48,20 @@ class Tos extends BaseModule
|
||||||
* be properties of the class, however cannot be set directly as the property
|
* be properties of the class, however cannot be set directly as the property
|
||||||
* cannot depend on a function result when declaring the variable.
|
* cannot depend on a function result when declaring the variable.
|
||||||
**/
|
**/
|
||||||
public function __construct(array $parameters = [])
|
public function __construct(IManageConfigValues $config, BaseURL $baseUrl, L10n $l10n, array $parameters = [])
|
||||||
{
|
{
|
||||||
parent::__construct($parameters);
|
parent::__construct($l10n, $parameters);
|
||||||
|
|
||||||
$this->privacy_operate = DI::l10n()->t('At the time of registration, and for providing communications between the user account and their contacts, the user has to provide a display name (pen name), an username (nickname) and a working email address. The names will be accessible on the profile page of the account by any visitor of the page, even if other profile details are not displayed. The email address will only be used to send the user notifications about interactions, but wont be visibly displayed. The listing of an account in the node\'s user directory or the global user directory is optional and can be controlled in the user settings, it is not necessary for communication.');
|
$this->config = $config;
|
||||||
$this->privacy_distribute = DI::l10n()->t('This data is required for communication and is passed on to the nodes of the communication partners and is stored there. Users can enter additional private data that may be transmitted to the communication partners accounts.');
|
$this->baseUrl = $baseUrl;
|
||||||
$this->privacy_delete = DI::l10n()->t('At any point in time a logged in user can export their account data from the <a href="%1$s/settings/userexport">account settings</a>. If the user wants to delete their account they can do so at <a href="%1$s/removeme">%1$s/removeme</a>. The deletion of the account will be permanent. Deletion of the data will also be requested from the nodes of the communication partners.', DI::baseUrl());
|
|
||||||
|
$this->privacy_operate = $this->t('At the time of registration, and for providing communications between the user account and their contacts, the user has to provide a display name (pen name), an username (nickname) and a working email address. The names will be accessible on the profile page of the account by any visitor of the page, even if other profile details are not displayed. The email address will only be used to send the user notifications about interactions, but wont be visibly displayed. The listing of an account in the node\'s user directory or the global user directory is optional and can be controlled in the user settings, it is not necessary for communication.');
|
||||||
|
$this->privacy_distribute = $this->t('This data is required for communication and is passed on to the nodes of the communication partners and is stored there. Users can enter additional private data that may be transmitted to the communication partners accounts.');
|
||||||
|
$this->privacy_delete = $this->t('At any point in time a logged in user can export their account data from the <a href="%1$s/settings/userexport">account settings</a>. If the user wants to delete their account they can do so at <a href="%1$s/removeme">%1$s/removeme</a>. The deletion of the account will be permanent. Deletion of the data will also be requested from the nodes of the communication partners.', $this->baseUrl);
|
||||||
// In some cases we don't need every single one of the above separate, but all in one block.
|
// In some cases we don't need every single one of the above separate, but all in one block.
|
||||||
// So here is an array to look over
|
// So here is an array to look over
|
||||||
$this->privacy_complete = [DI::l10n()->t('Privacy Statement'), $this->privacy_operate, $this->privacy_distribute, $this->privacy_delete];
|
$this->privacy_complete = [$this->t('Privacy Statement'), $this->privacy_operate,
|
||||||
}
|
$this->privacy_distribute, $this->privacy_delete];
|
||||||
|
|
||||||
/**
|
|
||||||
* initialize the TOS module.
|
|
||||||
*
|
|
||||||
* If this is a single user instance, we expect the user to know their
|
|
||||||
* dealings with their own node so a TOS is not necessary.
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public function init()
|
|
||||||
{
|
|
||||||
if (strlen(DI::config()->get('system','singleuser'))) {
|
|
||||||
DI::baseUrl()->redirect('profile/' . DI::config()->get('system','singleuser'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,17 +76,22 @@ class Tos extends BaseModule
|
||||||
* @return string
|
* @return string
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function content(): string {
|
public function content(): string
|
||||||
|
{
|
||||||
|
if (strlen($this->config->get('system', 'singleuser'))) {
|
||||||
|
$this->baseUrl->redirect('profile/' . $this->config->get('system', 'singleuser'));
|
||||||
|
}
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('tos.tpl');
|
$tpl = Renderer::getMarkupTemplate('tos.tpl');
|
||||||
if (DI::config()->get('system', 'tosdisplay')) {
|
if ($this->config->get('system', 'tosdisplay')) {
|
||||||
return Renderer::replaceMacros($tpl, [
|
return Renderer::replaceMacros($tpl, [
|
||||||
'$title' => DI::l10n()->t('Terms of Service'),
|
'$title' => $this->t('Terms of Service'),
|
||||||
'$tostext' => BBCode::convert(DI::config()->get('system', 'tostext')),
|
'$tostext' => BBCode::convert($this->config->get('system', 'tostext')),
|
||||||
'$displayprivstatement' => DI::config()->get('system', 'tosprivstatement'),
|
'$displayprivstatement' => $this->config->get('system', 'tosprivstatement'),
|
||||||
'$privstatementtitle' => DI::l10n()->t('Privacy Statement'),
|
'$privstatementtitle' => $this->t('Privacy Statement'),
|
||||||
'$privacy_operate' => DI::l10n()->t('At the time of registration, and for providing communications between the user account and their contacts, the user has to provide a display name (pen name), an username (nickname) and a working email address. The names will be accessible on the profile page of the account by any visitor of the page, even if other profile details are not displayed. The email address will only be used to send the user notifications about interactions, but wont be visibly displayed. The listing of an account in the node\'s user directory or the global user directory is optional and can be controlled in the user settings, it is not necessary for communication.'),
|
'$privacy_operate' => $this->t('At the time of registration, and for providing communications between the user account and their contacts, the user has to provide a display name (pen name), an username (nickname) and a working email address. The names will be accessible on the profile page of the account by any visitor of the page, even if other profile details are not displayed. The email address will only be used to send the user notifications about interactions, but wont be visibly displayed. The listing of an account in the node\'s user directory or the global user directory is optional and can be controlled in the user settings, it is not necessary for communication.'),
|
||||||
'$privacy_distribute' => DI::l10n()->t('This data is required for communication and is passed on to the nodes of the communication partners and is stored there. Users can enter additional private data that may be transmitted to the communication partners accounts.'),
|
'$privacy_distribute' => $this->t('This data is required for communication and is passed on to the nodes of the communication partners and is stored there. Users can enter additional private data that may be transmitted to the communication partners accounts.'),
|
||||||
'$privacy_delete' => DI::l10n()->t('At any point in time a logged in user can export their account data from the <a href="%1$s/settings/userexport">account settings</a>. If the user wants to delete their account they can do so at <a href="%1$s/removeme">%1$s/removeme</a>. The deletion of the account will be permanent. Deletion of the data will also be requested from the nodes of the communication partners.', DI::baseUrl())
|
'$privacy_delete' => $this->t('At any point in time a logged in user can export their account data from the <a href="%1$s/settings/userexport">account settings</a>. If the user wants to delete their account they can do so at <a href="%1$s/removeme">%1$s/removeme</a>. The deletion of the account will be permanent. Deletion of the data will also be requested from the nodes of the communication partners.', $this->baseUrl)
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ModuleControllerTest extends DatabaseTest
|
||||||
self::assertModule([
|
self::assertModule([
|
||||||
'isBackend' => false,
|
'isBackend' => false,
|
||||||
'name' => App\ModuleController::DEFAULT,
|
'name' => App\ModuleController::DEFAULT,
|
||||||
'class' => new $defaultClass(),
|
'class' => null,
|
||||||
], $module);
|
], $module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,28 +146,28 @@ class ModuleControllerTest extends DatabaseTest
|
||||||
'name' => App\ModuleController::DEFAULT,
|
'name' => App\ModuleController::DEFAULT,
|
||||||
'command' => App\ModuleController::DEFAULT,
|
'command' => App\ModuleController::DEFAULT,
|
||||||
'privAdd' => false,
|
'privAdd' => false,
|
||||||
'args' => [],
|
'args' => [Mockery::mock(L10n::class)],
|
||||||
],
|
],
|
||||||
'legacy' => [
|
'legacy' => [
|
||||||
'assert' => LegacyModule::class,
|
'assert' => LegacyModule::class,
|
||||||
'name' => 'display',
|
'name' => 'display',
|
||||||
'command' => 'display/test/it',
|
'command' => 'display/test/it',
|
||||||
'privAdd' => false,
|
'privAdd' => false,
|
||||||
'args' => [__DIR__ . '/../../datasets/legacy/legacy.php'],
|
'args' => [Mockery::mock(L10n::class), __DIR__ . '/../../datasets/legacy/legacy.php'],
|
||||||
],
|
],
|
||||||
'new' => [
|
'new' => [
|
||||||
'assert' => HostMeta::class,
|
'assert' => HostMeta::class,
|
||||||
'not_required',
|
'not_required',
|
||||||
'command' => '.well-known/host-meta',
|
'command' => '.well-known/host-meta',
|
||||||
'privAdd' => false,
|
'privAdd' => false,
|
||||||
'args' => [],
|
'args' => [Mockery::mock(L10n::class)],
|
||||||
],
|
],
|
||||||
'404' => [
|
'404' => [
|
||||||
'assert' => PageNotFound::class,
|
'assert' => PageNotFound::class,
|
||||||
'name' => 'invalid',
|
'name' => 'invalid',
|
||||||
'command' => 'invalid',
|
'command' => 'invalid',
|
||||||
'privAdd' => false,
|
'privAdd' => false,
|
||||||
'args' => [],
|
'args' => [Mockery::mock(L10n::class)],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ class NotificationTest extends ApiTest
|
||||||
</notes>
|
</notes>
|
||||||
XML;
|
XML;
|
||||||
|
|
||||||
$notification = new Notification(['extension' => 'xml']);
|
$notification = new Notification(DI::l10n(), ['extension' => 'xml']);
|
||||||
$notification->rawContent();
|
$notification->rawContent();
|
||||||
|
|
||||||
self::assertXmlStringEqualsXmlString($assertXml, ApiResponseDouble::getOutput());
|
self::assertXmlStringEqualsXmlString($assertXml, ApiResponseDouble::getOutput());
|
||||||
|
@ -75,7 +75,7 @@ XML;
|
||||||
|
|
||||||
public function testWithJsonResult()
|
public function testWithJsonResult()
|
||||||
{
|
{
|
||||||
$notification = new Notification(['parameter' => 'json']);
|
$notification = new Notification(DI::l10n(),['parameter' => 'json']);
|
||||||
$notification->rawContent();
|
$notification->rawContent();
|
||||||
|
|
||||||
$result = json_encode(ApiResponseDouble::getOutput());
|
$result = json_encode(ApiResponseDouble::getOutput());
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\Friendica\Photo;
|
namespace Friendica\Test\src\Module\Api\Friendica\Photo;
|
||||||
|
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Module\Api\Friendica\Photo\Delete;
|
use Friendica\Module\Api\Friendica\Photo\Delete;
|
||||||
use Friendica\Network\HTTPException\BadRequestException;
|
use Friendica\Network\HTTPException\BadRequestException;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
|
@ -30,7 +31,7 @@ class DeleteTest extends ApiTest
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
$this->expectException(BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
(new Delete())->rawContent();
|
(new Delete(DI::l10n()))->rawContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithoutAuthenticatedUser()
|
public function testWithoutAuthenticatedUser()
|
||||||
|
@ -41,7 +42,7 @@ class DeleteTest extends ApiTest
|
||||||
public function testWrong()
|
public function testWrong()
|
||||||
{
|
{
|
||||||
$this->expectException(BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
(new Delete(['photo_id' => 1]))->rawContent();
|
(new Delete(DI::l10n(), ['photo_id' => 1]))->rawContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithCorrectPhotoId()
|
public function testWithCorrectPhotoId()
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\Friendica\Photoalbum;
|
namespace Friendica\Test\src\Module\Api\Friendica\Photoalbum;
|
||||||
|
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Module\Api\Friendica\Photoalbum\Delete;
|
use Friendica\Module\Api\Friendica\Photoalbum\Delete;
|
||||||
use Friendica\Network\HTTPException\BadRequestException;
|
use Friendica\Network\HTTPException\BadRequestException;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
|
@ -30,13 +31,13 @@ class DeleteTest extends ApiTest
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
$this->expectException(BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
(new Delete())->rawContent();
|
(new Delete(DI::l10n()))->rawContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWrong()
|
public function testWrong()
|
||||||
{
|
{
|
||||||
$this->expectException(BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
(new Delete(['album' => 'album_name']))->rawContent();
|
(new Delete(DI::l10n(), ['album' => 'album_name']))->rawContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValid()
|
public function testValid()
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\Friendica\Photoalbum;
|
namespace Friendica\Test\src\Module\Api\Friendica\Photoalbum;
|
||||||
|
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Module\Api\Friendica\Photoalbum\Update;
|
use Friendica\Module\Api\Friendica\Photoalbum\Update;
|
||||||
use Friendica\Network\HTTPException\BadRequestException;
|
use Friendica\Network\HTTPException\BadRequestException;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
|
@ -30,19 +31,19 @@ class UpdateTest extends ApiTest
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
$this->expectException(BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
(new Update())->rawContent();
|
(new Update(DI::l10n()))->rawContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTooFewArgs()
|
public function testTooFewArgs()
|
||||||
{
|
{
|
||||||
$this->expectException(BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
(new Update(['album' => 'album_name']))->rawContent();
|
(new Update(DI::l10n(), ['album' => 'album_name']))->rawContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWrongUpdate()
|
public function testWrongUpdate()
|
||||||
{
|
{
|
||||||
$this->expectException(BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
(new Update(['album' => 'album_name', 'album_new' => 'album_name']))->rawContent();
|
(new Update(DI::l10n(), ['album' => 'album_name', 'album_new' => 'album_name']))->rawContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithoutAuthenticatedUser()
|
public function testWithoutAuthenticatedUser()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial;
|
namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial;
|
||||||
|
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Module\Api\GNUSocial\GNUSocial\Version;
|
use Friendica\Module\Api\GNUSocial\GNUSocial\Version;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
use Friendica\Test\Util\ApiResponseDouble;
|
use Friendica\Test\Util\ApiResponseDouble;
|
||||||
|
@ -10,7 +11,7 @@ class VersionTest extends ApiTest
|
||||||
{
|
{
|
||||||
public function test()
|
public function test()
|
||||||
{
|
{
|
||||||
$version = new Version(['extension' => 'json']);
|
$version = new Version(DI::l10n(), ['extension' => 'json']);
|
||||||
$version->rawContent();
|
$version->rawContent();
|
||||||
|
|
||||||
$result = json_decode(ApiResponseDouble::getOutput());
|
$result = json_decode(ApiResponseDouble::getOutput());
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\GnuSocial\Help;
|
namespace Friendica\Test\src\Module\Api\GnuSocial\Help;
|
||||||
|
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Module\Api\GNUSocial\Help\Test;
|
use Friendica\Module\Api\GNUSocial\Help\Test;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
use Friendica\Test\Util\ApiResponseDouble;
|
use Friendica\Test\Util\ApiResponseDouble;
|
||||||
|
@ -10,7 +11,7 @@ class TestTest extends ApiTest
|
||||||
{
|
{
|
||||||
public function testJson()
|
public function testJson()
|
||||||
{
|
{
|
||||||
$test = new Test(['extension' => 'json']);
|
$test = new Test(DI::l10n(), ['extension' => 'json']);
|
||||||
$test->rawContent();
|
$test->rawContent();
|
||||||
|
|
||||||
self::assertEquals('"ok"', ApiResponseDouble::getOutput());
|
self::assertEquals('"ok"', ApiResponseDouble::getOutput());
|
||||||
|
@ -18,7 +19,7 @@ class TestTest extends ApiTest
|
||||||
|
|
||||||
public function testXml()
|
public function testXml()
|
||||||
{
|
{
|
||||||
$test = new Test(['extension' => 'xml']);
|
$test = new Test(DI::l10n(), ['extension' => 'xml']);
|
||||||
$test->rawContent();
|
$test->rawContent();
|
||||||
|
|
||||||
self::assertxml(ApiResponseDouble::getOutput(), 'ok');
|
self::assertxml(ApiResponseDouble::getOutput(), 'ok');
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\Twitter\Account;
|
namespace Friendica\Test\src\Module\Api\Twitter\Account;
|
||||||
|
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Module\Api\Twitter\Account\RateLimitStatus;
|
use Friendica\Module\Api\Twitter\Account\RateLimitStatus;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
use Friendica\Test\Util\ApiResponseDouble;
|
use Friendica\Test\Util\ApiResponseDouble;
|
||||||
|
@ -10,7 +11,7 @@ class RateLimitStatusTest extends ApiTest
|
||||||
{
|
{
|
||||||
public function testWithJson()
|
public function testWithJson()
|
||||||
{
|
{
|
||||||
$rateLimitStatus = new RateLimitStatus(['extension' => 'json']);
|
$rateLimitStatus = new RateLimitStatus(DI::l10n(), ['extension' => 'json']);
|
||||||
$rateLimitStatus->rawContent();
|
$rateLimitStatus->rawContent();
|
||||||
|
|
||||||
$result = json_decode(ApiResponseDouble::getOutput());
|
$result = json_decode(ApiResponseDouble::getOutput());
|
||||||
|
@ -22,7 +23,7 @@ class RateLimitStatusTest extends ApiTest
|
||||||
|
|
||||||
public function testWithXml()
|
public function testWithXml()
|
||||||
{
|
{
|
||||||
$rateLimitStatus = new RateLimitStatus(['extension' => 'xml']);
|
$rateLimitStatus = new RateLimitStatus(DI::l10n(),['extension' => 'xml']);
|
||||||
$rateLimitStatus->rawContent();
|
$rateLimitStatus->rawContent();
|
||||||
|
|
||||||
self::assertXml(ApiResponseDouble::getOutput(), 'hash');
|
self::assertXml(ApiResponseDouble::getOutput(), 'hash');
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\Twitter;
|
namespace Friendica\Test\src\Module\Api\Twitter;
|
||||||
|
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Module\Api\Twitter\SavedSearches;
|
use Friendica\Module\Api\Twitter\SavedSearches;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
use Friendica\Test\Util\ApiResponseDouble;
|
use Friendica\Test\Util\ApiResponseDouble;
|
||||||
|
@ -10,7 +11,7 @@ class SavedSearchesTest extends ApiTest
|
||||||
{
|
{
|
||||||
public function test()
|
public function test()
|
||||||
{
|
{
|
||||||
$savedSearch = new SavedSearches(['extension' => 'json']);
|
$savedSearch = new SavedSearches(DI::l10n(), ['extension' => 'json']);
|
||||||
$savedSearch->rawContent();
|
$savedSearch->rawContent();
|
||||||
|
|
||||||
$result = json_decode(ApiResponseDouble::getOutput());
|
$result = json_decode(ApiResponseDouble::getOutput());
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue