mirror of
https://github.com/friendica/friendica
synced 2025-04-19 07:10:11 +00:00
Merge remote-tracking branch 'upstream/develop' into diaspora-reshare
This commit is contained in:
commit
4db4d1843d
52 changed files with 5745 additions and 5298 deletions
|
@ -388,10 +388,6 @@ class Site extends BaseAdmin
|
|||
/* Banner */
|
||||
$banner = DI::config()->get('system', 'banner');
|
||||
|
||||
if ($banner == false) {
|
||||
$banner = '<a href="https://friendi.ca"><img id="logo-img" width="32" height="32" src="images/friendica.svg" alt="logo" /></a><span id="logo-text"><a href="https://friendi.ca">Friendica</a></span>';
|
||||
}
|
||||
|
||||
$email_banner = DI::config()->get('system', 'email_banner');
|
||||
|
||||
if ($email_banner == false) {
|
||||
|
|
|
@ -35,6 +35,7 @@ use Friendica\DI;
|
|||
use Friendica\Model;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
|
||||
/**
|
||||
|
@ -494,16 +495,18 @@ class Contact extends BaseModule
|
|||
*
|
||||
* @param array $contact Contact array
|
||||
* @return array Template fields
|
||||
* @throws InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function getContactTemplateVars(array $contact)
|
||||
public static function getContactTemplateVars(array $contact): array
|
||||
{
|
||||
$alt_text = '';
|
||||
|
||||
if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && DI::userSession()->getLocalUserId()) {
|
||||
$personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], DI::userSession()->getLocalUserId());
|
||||
if (!empty($personal)) {
|
||||
$contact['uid'] = $personal['uid'];
|
||||
$contact['rel'] = $personal['rel'];
|
||||
$contact['uid'] = $personal['uid'];
|
||||
$contact['rel'] = $personal['rel'];
|
||||
$contact['self'] = $personal['self'];
|
||||
}
|
||||
}
|
||||
|
@ -545,15 +548,15 @@ class Contact extends BaseModule
|
|||
|
||||
if ($contact['self']) {
|
||||
$alt_text = DI::l10n()->t('This is you');
|
||||
$url = $contact['url'];
|
||||
$sparkle = '';
|
||||
$url = $contact['url'];
|
||||
$sparkle = '';
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $contact['id'],
|
||||
'url' => $url,
|
||||
'img_hover' => DI::l10n()->t('Visit %s\'s profile [%s]', $contact['name'], $contact['url']),
|
||||
'photo_menu' => Model\Contact::photoMenu($contact),
|
||||
'photo_menu' => Model\Contact::photoMenu($contact, DI::userSession()->getLocalUserId()),
|
||||
'thumb' => Model\Contact::getThumb($contact, true),
|
||||
'alt_text' => $alt_text,
|
||||
'name' => $contact['name'],
|
||||
|
|
|
@ -21,54 +21,72 @@
|
|||
|
||||
namespace Friendica\Module\Contact;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Model;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Contacts extends BaseModule
|
||||
{
|
||||
/** @var IHandleUserSessions */
|
||||
private $userSession;
|
||||
/** @var App\Page */
|
||||
private $page;
|
||||
|
||||
public function __construct(App\Page $page, IHandleUserSessions $userSession, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->userSession = $userSession;
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
if (!$this->userSession->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
$cid = $this->parameters['id'];
|
||||
$type = $this->parameters['type'] ?? 'all';
|
||||
$accounttype = $_GET['accounttype'] ?? '';
|
||||
$accounttype = $request['accounttype'] ?? '';
|
||||
$accounttypeid = User::getAccountTypeByString($accounttype);
|
||||
|
||||
if (!$cid) {
|
||||
throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.'));
|
||||
throw new HTTPException\BadRequestException($this->t('Invalid contact.'));
|
||||
}
|
||||
|
||||
$contact = Model\Contact::getById($cid, []);
|
||||
if (empty($contact)) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
|
||||
throw new HTTPException\NotFoundException($this->t('Contact not found.'));
|
||||
}
|
||||
|
||||
$localContactId = Model\Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId());
|
||||
$localContactId = Model\Contact::getPublicIdByUserId($this->userSession->getLocalUserId());
|
||||
|
||||
DI::page()['aside'] = Widget\VCard::getHTML($contact);
|
||||
$this->page['aside'] = Widget\VCard::getHTML($contact);
|
||||
|
||||
$condition = [
|
||||
'blocked' => false,
|
||||
'self' => false,
|
||||
'hidden' => false,
|
||||
'failed' => false,
|
||||
'self' => false,
|
||||
'hidden' => false,
|
||||
'failed' => false,
|
||||
];
|
||||
|
||||
if (isset($accounttypeid)) {
|
||||
$condition['contact-type'] = $accounttypeid;
|
||||
}
|
||||
|
||||
$noresult_label = DI::l10n()->t('No known contacts.');
|
||||
$noresult_label = $this->t('No known contacts.');
|
||||
|
||||
switch ($type) {
|
||||
case 'followers':
|
||||
|
@ -82,50 +100,61 @@ class Contacts extends BaseModule
|
|||
break;
|
||||
case 'common':
|
||||
$total = Model\Contact\Relation::countCommon($localContactId, $cid, $condition);
|
||||
$noresult_label = DI::l10n()->t('No common contacts.');
|
||||
$noresult_label = $this->t('No common contacts.');
|
||||
break;
|
||||
default:
|
||||
$total = Model\Contact\Relation::countAll($cid, $condition);
|
||||
}
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 30);
|
||||
$pager = new Pager($this->l10n, $this->args->getQueryString(), 30);
|
||||
$desc = '';
|
||||
|
||||
switch ($type) {
|
||||
case 'followers':
|
||||
$friends = Model\Contact\Relation::listFollowers($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||
$title = DI::l10n()->tt('Follower (%s)', 'Followers (%s)', $total);
|
||||
$title = $this->tt('Follower (%s)', 'Followers (%s)', $total);
|
||||
break;
|
||||
case 'following':
|
||||
$friends = Model\Contact\Relation::listFollows($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||
$title = DI::l10n()->tt('Following (%s)', 'Following (%s)', $total);
|
||||
$title = $this->tt('Following (%s)', 'Following (%s)', $total);
|
||||
break;
|
||||
case 'mutuals':
|
||||
$friends = Model\Contact\Relation::listMutuals($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||
$title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
|
||||
$desc = DI::l10n()->t(
|
||||
$title = $this->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
|
||||
$desc = $this->t(
|
||||
'These contacts both follow and are followed by <strong>%s</strong>.',
|
||||
htmlentities($contact['name'], ENT_COMPAT, 'UTF-8')
|
||||
);
|
||||
break;
|
||||
case 'common':
|
||||
$friends = Model\Contact\Relation::listCommon($localContactId, $cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||
$title = DI::l10n()->tt('Common contact (%s)', 'Common contacts (%s)', $total);
|
||||
$desc = DI::l10n()->t(
|
||||
$title = $this->tt('Common contact (%s)', 'Common contacts (%s)', $total);
|
||||
$desc = $this->t(
|
||||
'Both <strong>%s</strong> and yourself have publicly interacted with these contacts (follow, comment or likes on public posts).',
|
||||
htmlentities($contact['name'], ENT_COMPAT, 'UTF-8')
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$friends = Model\Contact\Relation::listAll($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||
$title = DI::l10n()->tt('Contact (%s)', 'Contacts (%s)', $total);
|
||||
$title = $this->tt('Contact (%s)', 'Contacts (%s)', $total);
|
||||
}
|
||||
|
||||
$o = Module\Contact::getTabsHTML($contact, Module\Contact::TAB_CONTACTS);
|
||||
|
||||
$tabs = self::getContactFilterTabs('contact/' . $cid, $type, true);
|
||||
|
||||
$contacts = array_map([Module\Contact::class, 'getContactTemplateVars'], $friends);
|
||||
// Contact list is obtained from the visited contact, but the contact display is visitor dependent
|
||||
$contacts = array_map(
|
||||
function ($contact) {
|
||||
$contact = Model\Contact::selectFirst(
|
||||
[],
|
||||
['uri-id' => $contact['uri-id'], 'uid' => [0, $this->userSession->getLocalUserId()]],
|
||||
['order' => ['uid' => 'DESC']]
|
||||
);
|
||||
return Module\Contact::getContactTemplateVars($contact);
|
||||
},
|
||||
$friends
|
||||
);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
|
@ -139,7 +168,7 @@ class Contacts extends BaseModule
|
|||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
DI::page()['aside'] .= Widget::accountTypes($_SERVER['REQUEST_URI'], $accounttype);
|
||||
$this->page['aside'] .= Widget::accountTypes($_SERVER['REQUEST_URI'], $accounttype);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -21,26 +21,45 @@
|
|||
|
||||
namespace Friendica\Module\Contact;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Friendica\Util\Strings;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Asynchronous HTML fragment provider for frio contact hovercards
|
||||
*/
|
||||
class Hovercard extends BaseModule
|
||||
{
|
||||
/** @var IManageConfigValues */
|
||||
private $config;
|
||||
/** @var IHandleUserSessions */
|
||||
private $userSession;
|
||||
|
||||
public function __construct(IHandleUserSessions $userSession, IManageConfigValues $config, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->config = $config;
|
||||
$this->userSession = $userSession;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$contact_url = $_REQUEST['url'] ?? '';
|
||||
$contact_url = $request['url'] ?? '';
|
||||
|
||||
// Get out if the system doesn't have public access allowed
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
if ($this->config->get('system', 'block_public') && !$this->userSession->isAuthenticated()) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
|
@ -50,7 +69,7 @@ class Hovercard extends BaseModule
|
|||
*/
|
||||
if (strpos($contact_url, 'contact/') === 0 && preg_match('/(\d+)/', $contact_url, $matches)) {
|
||||
$remote_contact = Contact::selectFirst(['nurl'], ['id' => $matches[1]]);
|
||||
$contact_url = $remote_contact['nurl'] ?? '';
|
||||
$contact_url = $remote_contact['nurl'] ?? '';
|
||||
}
|
||||
|
||||
if (!$contact_url) {
|
||||
|
@ -59,8 +78,8 @@ class Hovercard extends BaseModule
|
|||
|
||||
// Search for contact data
|
||||
// Look if the local user has got the contact
|
||||
if (DI::userSession()->isAuthenticated()) {
|
||||
$contact = Contact::getByURLForUser($contact_url, DI::userSession()->getLocalUserId());
|
||||
if ($this->userSession->isAuthenticated()) {
|
||||
$contact = Contact::getByURLForUser($contact_url, $this->userSession->getLocalUserId());
|
||||
} else {
|
||||
$contact = Contact::getByURL($contact_url, false);
|
||||
}
|
||||
|
@ -70,15 +89,15 @@ class Hovercard extends BaseModule
|
|||
}
|
||||
|
||||
// Get the photo_menu - the menu if possible contact actions
|
||||
if (DI::userSession()->isAuthenticated()) {
|
||||
$actions = Contact::photoMenu($contact);
|
||||
if ($this->userSession->isAuthenticated()) {
|
||||
$actions = Contact::photoMenu($contact, $this->userSession->getLocalUserId());
|
||||
} else {
|
||||
$actions = [];
|
||||
}
|
||||
|
||||
// Move the contact data to the profile array so we can deliver it to
|
||||
$tpl = Renderer::getMarkupTemplate('hovercard.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$profile' => [
|
||||
'name' => $contact['name'],
|
||||
'nick' => $contact['nick'],
|
||||
|
@ -96,7 +115,6 @@ class Hovercard extends BaseModule
|
|||
],
|
||||
]);
|
||||
|
||||
echo $o;
|
||||
System::exit();
|
||||
System::httpExit($o);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,51 +21,71 @@
|
|||
|
||||
namespace Friendica\Module\Profile;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Module;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Module\BaseProfile;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Common extends BaseProfile
|
||||
{
|
||||
/** @var IManageConfigValues */
|
||||
private $config;
|
||||
/** @var IHandleUserSessions */
|
||||
private $userSession;
|
||||
/** @var App */
|
||||
private $app;
|
||||
|
||||
public function __construct(App $app, IHandleUserSessions $userSession, IManageConfigValues $config, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->config = $config;
|
||||
$this->userSession = $userSession;
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
if ($this->config->get('system', 'block_public') && !$this->userSession->isAuthenticated()) {
|
||||
throw new HTTPException\NotFoundException($this->t('User not found.'));
|
||||
}
|
||||
|
||||
$a = DI::app();
|
||||
|
||||
Nav::setSelected('home');
|
||||
|
||||
$nickname = $this->parameters['nickname'];
|
||||
|
||||
$profile = Profile::load($a, $nickname);
|
||||
$profile = Profile::load($this->app, $nickname);
|
||||
if (empty($profile)) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
throw new HTTPException\NotFoundException($this->t('User not found.'));
|
||||
}
|
||||
|
||||
if (!empty($profile['hide-friends'])) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
|
||||
$displayCommonTab = DI::userSession()->isAuthenticated() && $profile['uid'] != DI::userSession()->getLocalUserId();
|
||||
$displayCommonTab = $this->userSession->isAuthenticated() && $profile['uid'] != $this->userSession->getLocalUserId();
|
||||
|
||||
if (!$displayCommonTab) {
|
||||
$a->redirect('profile/' . $nickname . '/contacts');
|
||||
$this->baseUrl->redirect('profile/' . $nickname . '/contacts');
|
||||
};
|
||||
|
||||
$o = self::getTabsHTML('contacts', false, $profile['nickname'], $profile['hide-friends']);
|
||||
|
||||
$tabs = self::getContactFilterTabs('profile/' . $nickname, 'common', $displayCommonTab);
|
||||
|
||||
$sourceId = Contact::getIdForURL(Profile::getMyURL());
|
||||
$sourceId = Contact::getIdForURL($this->userSession->getMyUrl());
|
||||
$targetId = Contact::getPublicIdByUserId($profile['uid']);
|
||||
|
||||
$condition = [
|
||||
|
@ -76,14 +96,25 @@ class Common extends BaseProfile
|
|||
|
||||
$total = Contact\Relation::countCommon($sourceId, $targetId, $condition);
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 30);
|
||||
$pager = new Pager($this->l10n, $this->args->getQueryString(), 30);
|
||||
|
||||
$commonFollows = Contact\Relation::listCommon($sourceId, $targetId, $condition, $pager->getItemsPerPage(), $pager->getStart());
|
||||
|
||||
$contacts = array_map([Module\Contact::class, 'getContactTemplateVars'], $commonFollows);
|
||||
// Contact list is obtained from the visited profile user, but the contact display is visitor dependent
|
||||
$contacts = array_map(
|
||||
function ($contact) {
|
||||
$contact = Contact::selectFirst(
|
||||
[],
|
||||
['uri-id' => $contact['uri-id'], 'uid' => [0, $this->userSession->getLocalUserId()]],
|
||||
['order' => ['uid' => 'DESC']]
|
||||
);
|
||||
return Module\Contact::getContactTemplateVars($contact);
|
||||
},
|
||||
$commonFollows
|
||||
);
|
||||
|
||||
$title = DI::l10n()->tt('Common contact (%s)', 'Common contacts (%s)', $total);
|
||||
$desc = DI::l10n()->t(
|
||||
$title = $this->tt('Common contact (%s)', 'Common contacts (%s)', $total);
|
||||
$desc = $this->t(
|
||||
'Both <strong>%s</strong> and yourself have publicly interacted with these contacts (follow, comment or likes on public posts).',
|
||||
htmlentities($profile['name'], ENT_COMPAT, 'UTF-8')
|
||||
);
|
||||
|
@ -94,7 +125,7 @@ class Common extends BaseProfile
|
|||
'$desc' => $desc,
|
||||
'$tabs' => $tabs,
|
||||
|
||||
'$noresult_label' => DI::l10n()->t('No common contacts.'),
|
||||
'$noresult_label' => $this->t('No common contacts.'),
|
||||
|
||||
'$contacts' => $contacts,
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
|
|
|
@ -21,45 +21,68 @@
|
|||
|
||||
namespace Friendica\Module\Profile;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Model;
|
||||
use Friendica\Module;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Contacts extends Module\BaseProfile
|
||||
{
|
||||
/** @var IManageConfigValues */
|
||||
private $config;
|
||||
/** @var IHandleUserSessions */
|
||||
private $userSession;
|
||||
/** @var App */
|
||||
private $app;
|
||||
/** @var Database */
|
||||
private $database;
|
||||
|
||||
public function __construct(Database $database, App $app, IHandleUserSessions $userSession, IManageConfigValues $config, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->config = $config;
|
||||
$this->userSession = $userSession;
|
||||
$this->app = $app;
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
if ($this->config->get('system', 'block_public') && !$this->userSession->isAuthenticated()) {
|
||||
throw new HTTPException\NotFoundException($this->t('User not found.'));
|
||||
}
|
||||
|
||||
$a = DI::app();
|
||||
|
||||
$nickname = $this->parameters['nickname'];
|
||||
$type = $this->parameters['type'] ?? 'all';
|
||||
$type = $this->parameters['type'] ?? 'all';
|
||||
|
||||
$profile = Model\Profile::load($a, $nickname);
|
||||
$profile = Model\Profile::load($this->app, $nickname);
|
||||
if (empty($profile)) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
throw new HTTPException\NotFoundException($this->t('User not found.'));
|
||||
}
|
||||
|
||||
$is_owner = $profile['uid'] == DI::userSession()->getLocalUserId();
|
||||
$is_owner = $profile['uid'] == $this->userSession->getLocalUserId();
|
||||
|
||||
if ($profile['hide-friends'] && !$is_owner) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
|
||||
Nav::setSelected('home');
|
||||
|
||||
$o = self::getTabsHTML('contacts', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
||||
|
||||
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, DI::userSession()->isAuthenticated() && $profile['uid'] != DI::userSession()->getLocalUserId());
|
||||
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, $this->userSession->isAuthenticated() && $profile['uid'] != $this->userSession->getLocalUserId());
|
||||
|
||||
$condition = [
|
||||
'uid' => $profile['uid'],
|
||||
|
@ -73,50 +96,64 @@ class Contacts extends Module\BaseProfile
|
|||
];
|
||||
|
||||
switch ($type) {
|
||||
case 'followers': $condition['rel'] = [Model\Contact::FOLLOWER, Model\Contact::FRIEND]; break;
|
||||
case 'following': $condition['rel'] = [Model\Contact::SHARING, Model\Contact::FRIEND]; break;
|
||||
case 'mutuals': $condition['rel'] = Model\Contact::FRIEND; break;
|
||||
case 'followers':
|
||||
$condition['rel'] = [Model\Contact::FOLLOWER, Model\Contact::FRIEND];
|
||||
break;
|
||||
case 'following':
|
||||
$condition['rel'] = [Model\Contact::SHARING, Model\Contact::FRIEND];
|
||||
break;
|
||||
case 'mutuals':
|
||||
$condition['rel'] = Model\Contact::FRIEND;
|
||||
break;
|
||||
}
|
||||
|
||||
$total = DBA::count('contact', $condition);
|
||||
$total = $this->database->count('contact', $condition);
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 30);
|
||||
$pager = new Pager($this->l10n, $this->args->getQueryString(), 30);
|
||||
|
||||
$params = ['order' => ['name' => false], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
|
||||
// Contact list is obtained from the visited profile user, but the contact display is visitor dependent
|
||||
$contacts = array_map(
|
||||
[Module\Contact::class, 'getContactTemplateVars'],
|
||||
Model\Contact::selectToArray([], $condition, $params)
|
||||
function ($contact) {
|
||||
$contact = Model\Contact::selectFirst(
|
||||
[],
|
||||
['uri-id' => $contact['uri-id'], 'uid' => [0, $this->userSession->getLocalUserId()]],
|
||||
['order' => ['uid' => 'DESC']]
|
||||
);
|
||||
return Module\Contact::getContactTemplateVars($contact);
|
||||
},
|
||||
Model\Contact::selectToArray(['uri-id'], $condition, $params)
|
||||
);
|
||||
|
||||
$desc = '';
|
||||
switch ($type) {
|
||||
case 'followers':
|
||||
$title = DI::l10n()->tt('Follower (%s)', 'Followers (%s)', $total);
|
||||
$title = $this->tt('Follower (%s)', 'Followers (%s)', $total);
|
||||
break;
|
||||
case 'following':
|
||||
$title = DI::l10n()->tt('Following (%s)', 'Following (%s)', $total);
|
||||
$title = $this->tt('Following (%s)', 'Following (%s)', $total);
|
||||
break;
|
||||
case 'mutuals':
|
||||
$title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
|
||||
$desc = DI::l10n()->t(
|
||||
$title = $this->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
|
||||
$desc = $this->t(
|
||||
'These contacts both follow and are followed by <strong>%s</strong>.',
|
||||
htmlentities($profile['name'], ENT_COMPAT, 'UTF-8')
|
||||
);
|
||||
break;
|
||||
case 'all':
|
||||
default:
|
||||
$title = DI::l10n()->tt('Contact (%s)', 'Contacts (%s)', $total);
|
||||
$title = $this->tt('Contact (%s)', 'Contacts (%s)', $total);
|
||||
break;
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$title' => $title,
|
||||
'$desc' => $desc,
|
||||
'$tabs' => $tabs,
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$title' => $title,
|
||||
'$desc' => $desc,
|
||||
'$tabs' => $tabs,
|
||||
|
||||
'$noresult_label' => DI::l10n()->t('No contacts.'),
|
||||
'$noresult_label' => $this->t('No contacts.'),
|
||||
|
||||
'$contacts' => $contacts,
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
|
|
|
@ -21,8 +21,19 @@
|
|||
|
||||
namespace Friendica\Module\Profile;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Conversation;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Profile\ProfileField\Repository\ProfileField;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Profile index router
|
||||
|
@ -35,13 +46,50 @@ use Friendica\Core\L10n;
|
|||
*/
|
||||
class Index extends BaseModule
|
||||
{
|
||||
/** @var Database */
|
||||
private $database;
|
||||
/** @var App */
|
||||
private $app;
|
||||
/** @var IHandleUserSessions */
|
||||
private $session;
|
||||
/** @var IManageConfigValues */
|
||||
private $config;
|
||||
/** @var App\Page */
|
||||
private $page;
|
||||
/** @var ProfileField */
|
||||
private $profileField;
|
||||
/** @var DateTimeFormat */
|
||||
private $dateTimeFormat;
|
||||
/** @var Conversation */
|
||||
private $conversation;
|
||||
/** @var IManagePersonalConfigValues */
|
||||
private $pConfig;
|
||||
/** @var App\Mode */
|
||||
private $mode;
|
||||
|
||||
public function __construct(App\Mode $mode, IManagePersonalConfigValues $pConfig, Conversation $conversation, DateTimeFormat $dateTimeFormat, ProfileField $profileField, App\Page $page, IManageConfigValues $config, IHandleUserSessions $session, App $app, Database $database, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->database = $database;
|
||||
$this->app = $app;
|
||||
$this->session = $session;
|
||||
$this->config = $config;
|
||||
$this->page = $page;
|
||||
$this->profileField = $profileField;
|
||||
$this->dateTimeFormat = $dateTimeFormat;
|
||||
$this->conversation = $conversation;
|
||||
$this->pConfig = $pConfig;
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
(new Profile($this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->rawContent();
|
||||
(new Profile($this->profileField, $this->page, $this->config, $this->session, $this->app, $this->database, $this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->rawContent();
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
return (new Status($this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->content();
|
||||
return (new Status($this->mode, $this->pConfig, $this->conversation, $this->session, $this->config, $this->dateTimeFormat, $this->page, $this->app, $this->l10n, $this->baseUrl, $this->args, $this->logger, $this->profiler, $this->response, $this->server, $this->parameters))->content();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class Photos extends \Friendica\Module\BaseProfile
|
|||
$this->systemMessages = $systemMessages;
|
||||
$this->aclFormatter = $aclFormatter;
|
||||
|
||||
$owner = Profile::load($this->app, $this->parameters['nickname'] ?? '');
|
||||
$owner = Profile::load($this->app, $this->parameters['nickname'] ?? '', false);
|
||||
if (!$owner || $owner['account_removed'] || $owner['account_expired']) {
|
||||
throw new HTTPException\NotFoundException($this->t('User not found.'));
|
||||
}
|
||||
|
@ -318,16 +318,8 @@ class Photos extends \Friendica\Module\BaseProfile
|
|||
$owner_uid = $this->owner['uid'];
|
||||
$is_owner = $this->session->getLocalUserId() == $owner_uid;
|
||||
|
||||
$remote_contact = false;
|
||||
if ($this->session->getRemoteContactID($owner_uid)) {
|
||||
$contact_id = $this->session->getRemoteContactID($owner_uid);
|
||||
|
||||
$contact = Contact::getContactForUser($contact_id, $owner_uid, ['blocked', 'pending']);
|
||||
$remote_contact = $contact && !$contact['blocked'] && !$contact['pending'];
|
||||
}
|
||||
|
||||
if ($this->owner['hidewall'] && !$this->session->isAuthenticated()) {
|
||||
$this->baseUrl->redirect('profile/' . $owner['nickname'] . '/restricted');
|
||||
$this->baseUrl->redirect('profile/' . $this->owner['nickname'] . '/restricted');
|
||||
}
|
||||
|
||||
$this->session->set('photo_return', $this->args->getCommand());
|
||||
|
@ -412,6 +404,11 @@ class Photos extends \Friendica\Module\BaseProfile
|
|||
]);
|
||||
}
|
||||
|
||||
// Removing vCard for owner
|
||||
if ($is_owner) {
|
||||
$this->page['aside'] = '';
|
||||
}
|
||||
|
||||
if (!empty($photo_albums_widget)) {
|
||||
$this->page['aside'] .= $photo_albums_widget;
|
||||
}
|
||||
|
|
|
@ -21,35 +21,68 @@
|
|||
|
||||
namespace Friendica\Module\Profile;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Content\ForumManager;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile as ProfileModel;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseProfile;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Profile\ProfileField\Repository\ProfileField;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Profiler;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\Temporal;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Profile extends BaseProfile
|
||||
{
|
||||
/** @var Database */
|
||||
private $database;
|
||||
/** @var App */
|
||||
private $app;
|
||||
/** @var IHandleUserSessions */
|
||||
private $session;
|
||||
/** @var IManageConfigValues */
|
||||
private $config;
|
||||
/** @var App\Page */
|
||||
private $page;
|
||||
/** @var ProfileField */
|
||||
private $profileField;
|
||||
|
||||
public function __construct(ProfileField $profileField, App\Page $page, IManageConfigValues $config, IHandleUserSessions $session, App $app, Database $database, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->database = $database;
|
||||
$this->app = $app;
|
||||
$this->session = $session;
|
||||
$this->config = $config;
|
||||
$this->page = $page;
|
||||
$this->profileField = $profileField;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
if (ActivityPub::isRequest()) {
|
||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname'], 'account_removed' => false]);
|
||||
if (DBA::isResult($user)) {
|
||||
$user = $this->database->selectFirst('user', ['uid'], ['nickname' => $this->parameters['nickname'] ?? '', 'account_removed' => false]);
|
||||
if ($user) {
|
||||
try {
|
||||
$data = ActivityPub\Transmitter::getProfile($user['uid']);
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
@ -60,7 +93,7 @@ class Profile extends BaseProfile
|
|||
}
|
||||
}
|
||||
|
||||
if (DBA::exists('userd', ['username' => $this->parameters['nickname']])) {
|
||||
if ($this->database->exists('userd', ['username' => $this->parameters['nickname']])) {
|
||||
// Known deleted user
|
||||
$data = ActivityPub\Transmitter::getDeletedUser($this->parameters['nickname']);
|
||||
|
||||
|
@ -74,43 +107,41 @@ class Profile extends BaseProfile
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
$a = DI::app();
|
||||
|
||||
$profile = ProfileModel::load($a, $this->parameters['nickname'] ?? '');
|
||||
$profile = ProfileModel::load($this->app, $this->parameters['nickname'] ?? '');
|
||||
if (!$profile) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Profile not found.'));
|
||||
throw new HTTPException\NotFoundException($this->t('Profile not found.'));
|
||||
}
|
||||
|
||||
$remote_contact_id = DI::userSession()->getRemoteContactID($profile['uid']);
|
||||
$remote_contact_id = $this->session->getRemoteContactID($profile['uid']);
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
if ($this->config->get('system', 'block_public') && !$this->session->isAuthenticated()) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
if (!empty($profile['hidewall']) && !DI::userSession()->isAuthenticated()) {
|
||||
if (!empty($profile['hidewall']) && !$this->session->isAuthenticated()) {
|
||||
$this->baseUrl->redirect('profile/' . $profile['nickname'] . '/restricted');
|
||||
}
|
||||
|
||||
if (!empty($profile['page-flags']) && $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
|
||||
DI::page()['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
|
||||
$this->page['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
|
||||
}
|
||||
|
||||
DI::page()['htmlhead'] .= self::buildHtmlHead($profile, $this->parameters['nickname'], $remote_contact_id);
|
||||
$this->page['htmlhead'] .= $this->buildHtmlHead($profile, $this->parameters['nickname']);
|
||||
|
||||
Nav::setSelected('home');
|
||||
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
|
||||
$o = self::getTabsHTML('profile', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
||||
$is_owner = $this->session->getLocalUserId() == $profile['uid'];
|
||||
$o = self::getTabsHTML('profile', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
||||
|
||||
$view_as_contacts = [];
|
||||
$view_as_contact_id = 0;
|
||||
$view_as_contacts = [];
|
||||
$view_as_contact_id = 0;
|
||||
$view_as_contact_alert = '';
|
||||
if ($is_owner) {
|
||||
$view_as_contact_id = intval($_GET['viewas'] ?? 0);
|
||||
$view_as_contact_id = intval($request['viewas'] ?? 0);
|
||||
|
||||
$view_as_contacts = Contact::selectToArray(['id', 'name'], [
|
||||
'uid' => DI::userSession()->getLocalUserId(),
|
||||
'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
|
||||
'uid' => $this->session->getLocalUserId(),
|
||||
'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
|
||||
'network' => Protocol::DFRN,
|
||||
'blocked' => false,
|
||||
]);
|
||||
|
@ -123,7 +154,7 @@ class Profile extends BaseProfile
|
|||
}
|
||||
|
||||
if (($key = array_search($view_as_contact_id, $view_as_contact_ids)) !== false) {
|
||||
$view_as_contact_alert = DI::l10n()->t(
|
||||
$view_as_contact_alert = $this->t(
|
||||
'You\'re currently viewing your profile as <b>%s</b> <a href="%s" class="btn btn-sm pull-right">Cancel</a>',
|
||||
htmlentities($view_as_contacts[$key]['name'], ENT_COMPAT, 'UTF-8'),
|
||||
'profile/' . $this->parameters['nickname'] . '/profile'
|
||||
|
@ -133,47 +164,51 @@ class Profile extends BaseProfile
|
|||
|
||||
$basic_fields = [];
|
||||
|
||||
$basic_fields += self::buildField('fullname', DI::l10n()->t('Full Name:'), $profile['name']);
|
||||
$basic_fields += self::buildField('fullname', $this->t('Full Name:'), $profile['name']);
|
||||
|
||||
if (Feature::isEnabled($profile['uid'], 'profile_membersince')) {
|
||||
$basic_fields += self::buildField(
|
||||
'membersince',
|
||||
DI::l10n()->t('Member since:'),
|
||||
$this->t('Member since:'),
|
||||
DateTimeFormat::local($profile['register_date'])
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($profile['dob']) && $profile['dob'] > DBA::NULL_DATE) {
|
||||
$year_bd_format = DI::l10n()->t('j F, Y');
|
||||
$short_bd_format = DI::l10n()->t('j F');
|
||||
$year_bd_format = $this->t('j F, Y');
|
||||
$short_bd_format = $this->t('j F');
|
||||
|
||||
$dob = DI::l10n()->getDay(
|
||||
$dob = $this->l10n->getDay(
|
||||
intval($profile['dob']) ?
|
||||
DateTimeFormat::utc($profile['dob'] . ' 00:00 +00:00', $year_bd_format)
|
||||
: DateTimeFormat::utc('2001-' . substr($profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
|
||||
);
|
||||
|
||||
$basic_fields += self::buildField('dob', DI::l10n()->t('Birthday:'), $dob);
|
||||
$basic_fields += self::buildField('dob', $this->t('Birthday:'), $dob);
|
||||
|
||||
if ($age = Temporal::getAgeByTimezone($profile['dob'], $profile['timezone'])) {
|
||||
$basic_fields += self::buildField('age', DI::l10n()->t('Age: '), DI::l10n()->tt('%d year old', '%d years old', $age));
|
||||
$basic_fields += self::buildField('age', $this->t('Age: '), $this->tt('%d year old', '%d years old', $age));
|
||||
}
|
||||
}
|
||||
|
||||
if ($profile['about']) {
|
||||
$basic_fields += self::buildField('about', DI::l10n()->t('Description:'), BBCode::convertForUriId($profile['uri-id'], $profile['about']));
|
||||
$basic_fields += self::buildField('about', $this->t('Description:'), BBCode::convertForUriId($profile['uri-id'], $profile['about']));
|
||||
}
|
||||
|
||||
if ($profile['xmpp']) {
|
||||
$basic_fields += self::buildField('xmpp', DI::l10n()->t('XMPP:'), $profile['xmpp']);
|
||||
$basic_fields += self::buildField('xmpp', $this->t('XMPP:'), $profile['xmpp']);
|
||||
}
|
||||
|
||||
if ($profile['matrix']) {
|
||||
$basic_fields += self::buildField('matrix', DI::l10n()->t('Matrix:'), $profile['matrix']);
|
||||
$basic_fields += self::buildField('matrix', $this->t('Matrix:'), $profile['matrix']);
|
||||
}
|
||||
|
||||
if ($profile['homepage']) {
|
||||
$basic_fields += self::buildField('homepage', DI::l10n()->t('Homepage:'), HTML::toLink($profile['homepage']));
|
||||
$basic_fields += self::buildField(
|
||||
'homepage',
|
||||
$this->t('Homepage:'),
|
||||
$this->tryRelMe($profile['homepage']) ?: $profile['homepage']
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -183,7 +218,7 @@ class Profile extends BaseProfile
|
|||
|| $profile['region']
|
||||
|| $profile['country-name']
|
||||
) {
|
||||
$basic_fields += self::buildField('location', DI::l10n()->t('Location:'), ProfileModel::formatLocation($profile));
|
||||
$basic_fields += self::buildField('location', $this->t('Location:'), ProfileModel::formatLocation($profile));
|
||||
}
|
||||
|
||||
if ($profile['pub_keywords']) {
|
||||
|
@ -191,12 +226,12 @@ class Profile extends BaseProfile
|
|||
// Separator is defined in Module\Settings\Profile\Index::cleanKeywords
|
||||
foreach (explode(', ', $profile['pub_keywords']) as $tag_label) {
|
||||
$tags[] = [
|
||||
'url' => '/search?tag=' . $tag_label,
|
||||
'url' => '/search?tag=' . $tag_label,
|
||||
'label' => Tag::TAG_CHARACTER[Tag::HASHTAG] . $tag_label,
|
||||
];
|
||||
}
|
||||
|
||||
$basic_fields += self::buildField('pub_keywords', DI::l10n()->t('Tags:'), $tags);
|
||||
$basic_fields += self::buildField('pub_keywords', $this->t('Tags:'), $tags);
|
||||
}
|
||||
|
||||
$custom_fields = [];
|
||||
|
@ -205,54 +240,54 @@ class Profile extends BaseProfile
|
|||
$contact_id = $view_as_contact_id ?: $remote_contact_id ?: 0;
|
||||
|
||||
if ($is_owner && $contact_id === 0) {
|
||||
$profile_fields = DI::profileField()->selectByUserId($profile['uid']);
|
||||
$profile_fields = $this->profileField->selectByUserId($profile['uid']);
|
||||
} else {
|
||||
$profile_fields = DI::profileField()->selectByContactId($contact_id, $profile['uid']);
|
||||
$profile_fields = $this->profileField->selectByContactId($contact_id, $profile['uid']);
|
||||
}
|
||||
|
||||
foreach ($profile_fields as $profile_field) {
|
||||
$custom_fields += self::buildField(
|
||||
'custom_' . $profile_field->order,
|
||||
$profile_field->label,
|
||||
BBCode::convertForUriId($profile['uri-id'], $profile_field->value),
|
||||
$this->tryRelMe($profile_field->value) ?: BBCode::convertForUriId($profile['uri-id'], $profile_field->value),
|
||||
'aprofile custom'
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
//show subcribed forum if it is enabled in the usersettings
|
||||
if (Feature::isEnabled($profile['uid'], 'forumlist_profile')) {
|
||||
$custom_fields += self::buildField(
|
||||
'forumlist',
|
||||
DI::l10n()->t('Forums:'),
|
||||
$this->t('Forums:'),
|
||||
ForumManager::profileAdvanced($profile['uid'])
|
||||
);
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/profile.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$title' => DI::l10n()->t('Profile'),
|
||||
'$yourself' => DI::l10n()->t('Yourself'),
|
||||
'$view_as_contacts' => $view_as_contacts,
|
||||
'$view_as_contact_id' => $view_as_contact_id,
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$title' => $this->t('Profile'),
|
||||
'$yourself' => $this->t('Yourself'),
|
||||
'$view_as_contacts' => $view_as_contacts,
|
||||
'$view_as_contact_id' => $view_as_contact_id,
|
||||
'$view_as_contact_alert' => $view_as_contact_alert,
|
||||
'$view_as' => DI::l10n()->t('View profile as:'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$basic' => DI::l10n()->t('Basic'),
|
||||
'$advanced' => DI::l10n()->t('Advanced'),
|
||||
'$is_owner' => $profile['uid'] == DI::userSession()->getLocalUserId(),
|
||||
'$query_string' => DI::args()->getQueryString(),
|
||||
'$basic_fields' => $basic_fields,
|
||||
'$custom_fields' => $custom_fields,
|
||||
'$profile' => $profile,
|
||||
'$edit_link' => [
|
||||
'url' => DI::baseUrl() . '/settings/profile', DI::l10n()->t('Edit profile'),
|
||||
'$view_as' => $this->t('View profile as:'),
|
||||
'$submit' => $this->t('Submit'),
|
||||
'$basic' => $this->t('Basic'),
|
||||
'$advanced' => $this->t('Advanced'),
|
||||
'$is_owner' => $profile['uid'] == $this->session->getLocalUserId(),
|
||||
'$query_string' => $this->args->getQueryString(),
|
||||
'$basic_fields' => $basic_fields,
|
||||
'$custom_fields' => $custom_fields,
|
||||
'$profile' => $profile,
|
||||
'$edit_link' => [
|
||||
'url' => 'settings/profile', $this->t('Edit profile'),
|
||||
'title' => '',
|
||||
'label' => DI::l10n()->t('Edit profile')
|
||||
'label' => $this->t('Edit profile')
|
||||
],
|
||||
'$viewas_link' => [
|
||||
'url' => DI::args()->getQueryString() . '#viewas',
|
||||
'$viewas_link' => [
|
||||
'url' => $this->args->getQueryString() . '#viewas',
|
||||
'title' => '',
|
||||
'label' => DI::l10n()->t('View as')
|
||||
'label' => $this->t('View as')
|
||||
],
|
||||
]);
|
||||
|
||||
|
@ -270,20 +305,18 @@ class Profile extends BaseProfile
|
|||
* @param string $class Optional CSS class to apply to the field
|
||||
* @return array
|
||||
*/
|
||||
private static function buildField(string $name, string $label, $value, string $class = 'aprofile')
|
||||
private static function buildField(string $name, string $label, $value, string $class = 'aprofile'): array
|
||||
{
|
||||
return [$name => [
|
||||
'id' => 'aprofile-' . $name,
|
||||
'id' => 'aprofile-' . $name,
|
||||
'class' => $class,
|
||||
'label' => $label,
|
||||
'value' => $value,
|
||||
]];
|
||||
}
|
||||
|
||||
private static function buildHtmlHead(array $profile, string $nickname, int $remote_contact_id)
|
||||
private function buildHtmlHead(array $profile, string $nickname): string
|
||||
{
|
||||
$baseUrl = DI::baseUrl();
|
||||
|
||||
$htmlhead = "\n";
|
||||
|
||||
if (!empty($profile['page-flags']) && $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
|
||||
|
@ -300,8 +333,8 @@ class Profile extends BaseProfile
|
|||
}
|
||||
|
||||
// site block
|
||||
$blocked = !DI::userSession()->isAuthenticated() && DI::config()->get('system', 'block_public');
|
||||
$userblock = !DI::userSession()->isAuthenticated() && $profile['hidewall'];
|
||||
$blocked = !$this->session->isAuthenticated() && $this->config->get('system', 'block_public');
|
||||
$userblock = !$this->session->isAuthenticated() && $profile['hidewall'];
|
||||
if (!$blocked && !$userblock) {
|
||||
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $profile['pub_keywords'] ?? '');
|
||||
if (strlen($keywords)) {
|
||||
|
@ -315,19 +348,34 @@ class Profile extends BaseProfile
|
|||
$htmlhead .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
|
||||
}
|
||||
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/dfrn_poll/' . $nickname . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/feed/' . $nickname . '/" title="' . DI::l10n()->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/feed/' . $nickname . '/comments" title="' . DI::l10n()->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/feed/' . $nickname . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
||||
$uri = urlencode('acct:' . $profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : ''));
|
||||
$htmlhead .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl . '/xrd/?uri=' . $uri . '" />' . "\n";
|
||||
header('Link: <' . $baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/dfrn_poll/' . $nickname . '" title="DFRN: ' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/" title="' . $this->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/comments" title="' . $this->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/activity" title="' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
||||
$uri = urlencode('acct:' . $profile['nickname'] . '@' . $this->baseUrl->getHostname() . ($this->baseUrl->getUrlPath() ? '/' . $this->baseUrl->getUrlPath() : ''));
|
||||
$htmlhead .= '<link rel="lrdd" type="application/xrd+xml" href="' . $this->baseUrl . '/xrd/?uri=' . $uri . '" />' . "\n";
|
||||
header('Link: <' . $this->baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
|
||||
|
||||
$dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
|
||||
foreach ($dfrn_pages as $dfrn) {
|
||||
$htmlhead .= '<link rel="dfrn-' . $dfrn . '" href="' . $baseUrl . '/dfrn_' . $dfrn . '/' . $nickname . '" />' . "\n";
|
||||
$htmlhead .= '<link rel="dfrn-' . $dfrn . '" href="' . $this->baseUrl . '/dfrn_' . $dfrn . '/' . $nickname . '" />' . "\n";
|
||||
}
|
||||
|
||||
return $htmlhead;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the input is an HTTP(S) link and returns a rel="me" link if yes, empty string if not
|
||||
*
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
private function tryRelMe(string $input): string
|
||||
{
|
||||
if (preg_match(Strings::onlyLinkRegEx(), trim($input))) {
|
||||
return '<a href="' . trim($input) . '" target="_blank" rel="noopener noreferrer me">' . trim($input) . '</a>';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,13 +21,18 @@
|
|||
|
||||
namespace Friendica\Module\Profile;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Conversation;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -36,150 +41,176 @@ use Friendica\Model\Profile as ProfileModel;
|
|||
use Friendica\Model\User;
|
||||
use Friendica\Model\Verb;
|
||||
use Friendica\Module\BaseProfile;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Security\Security;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Profiler;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Status extends BaseProfile
|
||||
{
|
||||
/** @var App */
|
||||
private $app;
|
||||
/** @var App\Page */
|
||||
private $page;
|
||||
/** @var DateTimeFormat */
|
||||
private $dateTimeFormat;
|
||||
/** @var IManageConfigValues */
|
||||
private $config;
|
||||
/** @var IHandleUserSessions */
|
||||
private $session;
|
||||
/** @var Conversation */
|
||||
private $conversation;
|
||||
/** @var IManagePersonalConfigValues */
|
||||
private $pConfig;
|
||||
/** @var App\Mode */
|
||||
private $mode;
|
||||
|
||||
public function __construct(App\Mode $mode, IManagePersonalConfigValues $pConfig, Conversation $conversation, IHandleUserSessions $session, IManageConfigValues $config, DateTimeFormat $dateTimeFormat, App\Page $page, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->app = $app;
|
||||
$this->page = $page;
|
||||
$this->dateTimeFormat = $dateTimeFormat;
|
||||
$this->config = $config;
|
||||
$this->session = $session;
|
||||
$this->conversation = $conversation;
|
||||
$this->pConfig = $pConfig;
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
$args = DI::args();
|
||||
|
||||
$a = DI::app();
|
||||
|
||||
$profile = ProfileModel::load($a, $this->parameters['nickname']);
|
||||
|
||||
$profile = ProfileModel::load($this->app, $this->parameters['nickname'] ?? '');
|
||||
if (empty($profile)) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
throw new HTTPException\NotFoundException($this->t('User not found.'));
|
||||
}
|
||||
|
||||
if ($this->config->get('system', 'block_public') && !$this->session->isAuthenticated()) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
if (!empty($profile['hidewall']) && !$this->session->isAuthenticated()) {
|
||||
$this->baseUrl->redirect('profile/' . $profile['nickname'] . '/restricted');
|
||||
}
|
||||
|
||||
if (!$profile['net-publish']) {
|
||||
DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
|
||||
$this->page['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
|
||||
}
|
||||
|
||||
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/dfrn_poll/' . $this->parameters['nickname'] . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
||||
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $this->parameters['nickname'] . '/" title="' . DI::l10n()->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
|
||||
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $this->parameters['nickname'] . '/comments" title="' . DI::l10n()->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
|
||||
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $this->parameters['nickname'] . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
||||
$this->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/dfrn_poll/' . $this->parameters['nickname'] . '" title="DFRN: ' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
||||
$this->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $this->parameters['nickname'] . '/" title="' . $this->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
|
||||
$this->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $this->parameters['nickname'] . '/comments" title="' . $this->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
|
||||
$this->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $this->parameters['nickname'] . '/activity" title="' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
||||
|
||||
$category = $datequery = $datequery2 = '';
|
||||
|
||||
$dtFormat = DI::dtFormat();
|
||||
|
||||
if ($args->getArgc() > 3) {
|
||||
for ($x = 3; $x < $args->getArgc(); $x++) {
|
||||
if ($dtFormat->isYearMonthDay($args->get($x))) {
|
||||
if ($this->args->getArgc() > 3) {
|
||||
for ($x = 3; $x < $this->args->getArgc(); $x++) {
|
||||
if ($this->dateTimeFormat->isYearMonthDay($this->args->get($x))) {
|
||||
if ($datequery) {
|
||||
$datequery2 = Strings::escapeHtml($args->get($x));
|
||||
$datequery2 = $this->args->get($x);
|
||||
} else {
|
||||
$datequery = Strings::escapeHtml($args->get($x));
|
||||
$datequery = $this->args->get($x);
|
||||
}
|
||||
} else {
|
||||
$category = $args->get($x);
|
||||
$category = $this->args->get($x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($category)) {
|
||||
$category = $_GET['category'] ?? '';
|
||||
$category = $request['category'] ?? '';
|
||||
}
|
||||
|
||||
$hashtags = $_GET['tag'] ?? '';
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !DI::userSession()->getRemoteContactID($profile['uid'])) {
|
||||
return Login::form();
|
||||
}
|
||||
$hashtags = $request['tag'] ?? '';
|
||||
|
||||
$o = '';
|
||||
|
||||
if ($profile['uid'] == DI::userSession()->getLocalUserId()) {
|
||||
if ($profile['uid'] == $this->session->getLocalUserId()) {
|
||||
Nav::setSelected('home');
|
||||
}
|
||||
|
||||
$remote_contact = DI::userSession()->getRemoteContactID($profile['uid']);
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
|
||||
$last_updated_key = "profile:" . $profile['uid'] . ":" . DI::userSession()->getLocalUserId() . ":" . $remote_contact;
|
||||
|
||||
if (!empty($profile['hidewall']) && !DI::userSession()->isAuthenticated()) {
|
||||
$this->baseUrl->redirect('profile/' . $profile['nickname'] . '/restricted');
|
||||
}
|
||||
$remote_contact = $this->session->getRemoteContactID($profile['uid']);
|
||||
$is_owner = $this->session->getLocalUserId() == $profile['uid'];
|
||||
$last_updated_key = "profile:" . $profile['uid'] . ":" . $this->session->getLocalUserId() . ":" . $remote_contact;
|
||||
|
||||
$o .= self::getTabsHTML('status', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
||||
|
||||
$o .= Widget::commonFriendsVisitor($profile['uid'], $profile['nickname']);
|
||||
|
||||
$commpage = $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
|
||||
$commpage = $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
|
||||
$commvisitor = $commpage && $remote_contact;
|
||||
|
||||
DI::page()['aside'] .= Widget::postedByYear(DI::baseUrl() . '/profile/' . $profile['nickname'] . '/status', $profile['profile_uid'] ?? 0, true);
|
||||
DI::page()['aside'] .= Widget::categories($profile['uid'], DI::baseUrl() . '/profile/' . $profile['nickname'] . '/status', $category);
|
||||
DI::page()['aside'] .= Widget::tagCloud($profile['uid']);
|
||||
$this->page['aside'] .= Widget::postedByYear($this->baseUrl . '/profile/' . $profile['nickname'] . '/status', $profile['profile_uid'] ?? 0, true);
|
||||
$this->page['aside'] .= Widget::categories($profile['uid'], $this->baseUrl . '/profile/' . $profile['nickname'] . '/status', $category);
|
||||
$this->page['aside'] .= Widget::tagCloud($profile['uid']);
|
||||
|
||||
if (Security::canWriteToUserWall($profile['uid'])) {
|
||||
$x = [
|
||||
'is_owner' => $is_owner,
|
||||
'allow_location' => ($is_owner || $commvisitor) && $profile['allow_location'],
|
||||
'is_owner' => $is_owner,
|
||||
'allow_location' => ($is_owner || $commvisitor) && $profile['allow_location'],
|
||||
'default_location' => $is_owner ? $profile['default-location'] : '',
|
||||
'nickname' => $profile['nickname'],
|
||||
'acl' => $is_owner ? ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId(), true) : '',
|
||||
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
|
||||
'profile_uid' => $profile['uid'],
|
||||
'nickname' => $profile['nickname'],
|
||||
'acl' => $is_owner ? ACL::getFullSelectorHTML($this->page, $this->app->getLoggedInUserId(), true) : '',
|
||||
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
|
||||
'profile_uid' => $profile['uid'],
|
||||
];
|
||||
|
||||
$o .= DI::conversation()->statusEditor($x);
|
||||
$o .= $this->conversation->statusEditor($x);
|
||||
}
|
||||
|
||||
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
|
||||
$condition = Item::getPermissionsConditionArrayByUserId($profile['uid']);
|
||||
|
||||
$last_updated_array = DI::session()->get('last_updated', []);
|
||||
$last_updated_array = $this->session->get('last_updated', []);
|
||||
|
||||
if (!empty($category)) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `category-view` WHERE `name` = ? AND `type` = ? AND `uid` = ?)",
|
||||
$category, Category::CATEGORY, $profile['uid']]);
|
||||
$category, Category::CATEGORY, $profile['uid']]);
|
||||
}
|
||||
|
||||
if (!empty($hashtags)) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `tag-search-view` WHERE `name` = ? AND `uid` = ?)",
|
||||
$hashtags, $profile['uid']]);
|
||||
$hashtags, $profile['uid']]);
|
||||
}
|
||||
|
||||
if (!empty($datequery)) {
|
||||
$condition = DBA::mergeConditions($condition, ["`received` <= ?", DateTimeFormat::convert($datequery, 'UTC', $a->getTimeZone())]);
|
||||
$condition = DBA::mergeConditions($condition, ["`received` <= ?", DateTimeFormat::convert($datequery, 'UTC', $this->app->getTimeZone())]);
|
||||
}
|
||||
|
||||
if (!empty($datequery2)) {
|
||||
$condition = DBA::mergeConditions($condition, ["`received` >= ?", DateTimeFormat::convert($datequery2, 'UTC', $a->getTimeZone())]);
|
||||
$condition = DBA::mergeConditions($condition, ["`received` >= ?", DateTimeFormat::convert($datequery2, 'UTC', $this->app->getTimeZone())]);
|
||||
}
|
||||
|
||||
// Does the profile page belong to a forum?
|
||||
// If not then we can improve the performance with an additional condition
|
||||
$condition2 = ['uid' => $profile['uid'], 'account-type' => User::ACCOUNT_TYPE_COMMUNITY];
|
||||
if (!DBA::exists('user', $condition2)) {
|
||||
if ($profile['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
|
||||
$condition = DBA::mergeConditions($condition, ['contact-id' => $profile['id']]);
|
||||
}
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
if ($this->mode->isMobile()) {
|
||||
$itemspage_network = $this->pConfig->get($this->session->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
$this->config->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
$itemspage_network = $this->pConfig->get($this->session->getLocalUserId(), 'system', 'itemspage_network',
|
||||
$this->config->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
$condition = DBA::mergeConditions($condition, ["((`gravity` = ? AND `wall`) OR
|
||||
(`gravity` = ? AND `vid` = ? AND `origin`
|
||||
AND EXISTS(SELECT `uri-id` FROM `post` WHERE `uri-id` = `post-user-view`.`thr-parent-id` AND `gravity` = ? AND `network` IN (?, ?))))",
|
||||
Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Item::GRAVITY_PARENT, Protocol::ACTIVITYPUB, Protocol::DFRN]);
|
||||
Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Item::GRAVITY_PARENT, Protocol::ACTIVITYPUB, Protocol::DFRN]);
|
||||
|
||||
$condition = DBA::mergeConditions($condition, ['uid' => $profile['uid'], 'network' => Protocol::FEDERATED,
|
||||
'visible' => true, 'deleted' => false]);
|
||||
$condition = DBA::mergeConditions($condition, ['uid' => $profile['uid'], 'network' => Protocol::FEDERATED,
|
||||
'visible' => true, 'deleted' => false]);
|
||||
|
||||
$pager = new Pager(DI::l10n(), $args->getQueryString(), $itemspage_network);
|
||||
$pager = new Pager($this->l10n, $this->args->getQueryString(), $itemspage_network);
|
||||
$params = ['limit' => [$pager->getStart(), $pager->getItemsPerPage()], 'order' => ['received' => true]];
|
||||
|
||||
$items_stmt = Post::select(['uri-id', 'thr-parent-id', 'gravity', 'author-id', 'received'], $condition, $params);
|
||||
|
@ -187,29 +218,29 @@ class Status extends BaseProfile
|
|||
// Set a time stamp for this page. We will make use of it when we
|
||||
// search for new items (update routine)
|
||||
$last_updated_array[$last_updated_key] = time();
|
||||
DI::session()->set('last_updated', $last_updated_array);
|
||||
$this->session->set('last_updated', $last_updated_array);
|
||||
|
||||
if ($is_owner && !DI::config()->get('theme', 'hide_eventlist')) {
|
||||
if ($is_owner && !$this->config->get('theme', 'hide_eventlist')) {
|
||||
$o .= ProfileModel::getBirthdays();
|
||||
$o .= ProfileModel::getEventsReminderHTML();
|
||||
}
|
||||
|
||||
if ($is_owner) {
|
||||
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => $this->session->getLocalUserId()]);
|
||||
if ($unseen) {
|
||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => $this->session->getLocalUserId()]);
|
||||
}
|
||||
}
|
||||
|
||||
$items = Post::toArray($items_stmt);
|
||||
|
||||
if ($pager->getStart() == 0 && !empty($profile['uid'])) {
|
||||
$pcid = Contact::getPublicIdByUserId($profile['uid']);
|
||||
$pcid = Contact::getPublicIdByUserId($profile['uid']);
|
||||
$pinned = Post\Collection::selectToArrayForContact($pcid, Post\Collection::FEATURED);
|
||||
$items = array_merge($items, $pinned);
|
||||
$items = array_merge($items, $pinned);
|
||||
}
|
||||
|
||||
$o .= DI::conversation()->create($items, 'profile', false, false, 'pinned_received', $profile['uid']);
|
||||
$o .= $this->conversation->create($items, 'profile', false, false, 'pinned_received', $profile['uid']);
|
||||
|
||||
$o .= $pager->renderMinimal(count($items));
|
||||
|
||||
|
|
|
@ -21,44 +21,71 @@
|
|||
|
||||
namespace Friendica\Module\Settings;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseSettings;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Navigation\SystemMessages;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Module to update user settings
|
||||
*/
|
||||
class Display extends BaseSettings
|
||||
{
|
||||
/** @var IManageConfigValues */
|
||||
private $config;
|
||||
/** @var IManagePersonalConfigValues */
|
||||
private $pConfig;
|
||||
/** @var App */
|
||||
private $app;
|
||||
/** @var SystemMessages */
|
||||
private $systemMessages;
|
||||
|
||||
public function __construct(SystemMessages $systemMessages, App $app, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->config = $config;
|
||||
$this->pConfig = $pConfig;
|
||||
$this->app = $app;
|
||||
$this->systemMessages = $systemMessages;
|
||||
}
|
||||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!DI::app()->isLoggedIn()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
$uid = $this->session->getLocalUserId();
|
||||
if (!$uid) {
|
||||
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
|
||||
self::checkFormSecurityTokenRedirectOnError('/settings/display', 'settings_display');
|
||||
|
||||
$user = User::getById(DI::userSession()->getLocalUserId());
|
||||
$user = User::getById($uid);
|
||||
|
||||
$theme = !empty($_POST['theme']) ? trim($_POST['theme']) : $user['theme'];
|
||||
$mobile_theme = !empty($_POST['mobile_theme']) ? trim($_POST['mobile_theme']) : '';
|
||||
$enable_smile = !empty($_POST['enable_smile']) ? intval($_POST['enable_smile']) : 0;
|
||||
$first_day_of_week = !empty($_POST['first_day_of_week']) ? intval($_POST['first_day_of_week']) : 0;
|
||||
$infinite_scroll = !empty($_POST['infinite_scroll']) ? intval($_POST['infinite_scroll']) : 0;
|
||||
$no_auto_update = !empty($_POST['no_auto_update']) ? intval($_POST['no_auto_update']) : 0;
|
||||
$enable_smart_threading = !empty($_POST['enable_smart_threading']) ? intval($_POST['enable_smart_threading']) : 0;
|
||||
$enable_dislike = !empty($_POST['enable_dislike']) ? intval($_POST['enable_dislike']) : 0;
|
||||
$display_resharer = !empty($_POST['display_resharer']) ? intval($_POST['display_resharer']) : 0;
|
||||
$stay_local = !empty($_POST['stay_local']) ? intval($_POST['stay_local']) : 0;
|
||||
$preview_mode = !empty($_POST['preview_mode']) ? intval($_POST['preview_mode']) : 0;
|
||||
$browser_update = !empty($_POST['browser_update']) ? intval($_POST['browser_update']) : 0;
|
||||
$theme = !empty($request['theme']) ? trim($request['theme']) : $user['theme'];
|
||||
$mobile_theme = !empty($request['mobile_theme']) ? trim($request['mobile_theme']) : '';
|
||||
$enable_smile = !empty($request['enable_smile']) ? intval($request['enable_smile']) : 0;
|
||||
$first_day_of_week = !empty($request['first_day_of_week']) ? intval($request['first_day_of_week']) : 0;
|
||||
$calendar_default_view = !empty($request['calendar_default_view']) ? trim($request['calendar_default_view']) : 'month';
|
||||
$infinite_scroll = !empty($request['infinite_scroll']) ? intval($request['infinite_scroll']) : 0;
|
||||
$no_auto_update = !empty($request['no_auto_update']) ? intval($request['no_auto_update']) : 0;
|
||||
$enable_smart_threading = !empty($request['enable_smart_threading']) ? intval($request['enable_smart_threading']) : 0;
|
||||
$enable_dislike = !empty($request['enable_dislike']) ? intval($request['enable_dislike']) : 0;
|
||||
$display_resharer = !empty($request['display_resharer']) ? intval($request['display_resharer']) : 0;
|
||||
$stay_local = !empty($request['stay_local']) ? intval($request['stay_local']) : 0;
|
||||
$preview_mode = !empty($request['preview_mode']) ? intval($request['preview_mode']) : 0;
|
||||
$browser_update = !empty($request['browser_update']) ? intval($request['browser_update']) : 0;
|
||||
if ($browser_update != -1) {
|
||||
$browser_update = $browser_update * 1000;
|
||||
if ($browser_update < 10000) {
|
||||
|
@ -66,89 +93,92 @@ class Display extends BaseSettings
|
|||
}
|
||||
}
|
||||
|
||||
$itemspage_network = !empty($_POST['itemspage_network']) ?
|
||||
intval($_POST['itemspage_network']) :
|
||||
DI::config()->get('system', 'itemspage_network');
|
||||
$itemspage_network = !empty($request['itemspage_network']) ?
|
||||
intval($request['itemspage_network']) :
|
||||
$this->config->get('system', 'itemspage_network');
|
||||
if ($itemspage_network > 100) {
|
||||
$itemspage_network = 100;
|
||||
}
|
||||
$itemspage_mobile_network = !empty($_POST['itemspage_mobile_network']) ?
|
||||
intval($_POST['itemspage_mobile_network']) :
|
||||
DI::config()->get('system', 'itemspage_network_mobile');
|
||||
$itemspage_mobile_network = !empty($request['itemspage_mobile_network']) ?
|
||||
intval($request['itemspage_mobile_network']) :
|
||||
$this->config->get('system', 'itemspage_network_mobile');
|
||||
if ($itemspage_mobile_network > 100) {
|
||||
$itemspage_mobile_network = 100;
|
||||
}
|
||||
|
||||
if ($mobile_theme !== '') {
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'mobile_theme', $mobile_theme);
|
||||
$this->pConfig->set($uid, 'system', 'mobile_theme', $mobile_theme);
|
||||
}
|
||||
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network' , $itemspage_network);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'update_interval' , $browser_update);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update' , $no_auto_update);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_smilies' , !$enable_smile);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll' , $infinite_scroll);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_smart_threading' , !$enable_smart_threading);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike' , !$enable_dislike);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'display_resharer' , $display_resharer);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'stay_local' , $stay_local);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week' , $first_day_of_week);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'preview_mode' , $preview_mode);
|
||||
$this->pConfig->set($uid, 'system', 'itemspage_network' , $itemspage_network);
|
||||
$this->pConfig->set($uid, 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
|
||||
$this->pConfig->set($uid, 'system', 'update_interval' , $browser_update);
|
||||
$this->pConfig->set($uid, 'system', 'no_auto_update' , $no_auto_update);
|
||||
$this->pConfig->set($uid, 'system', 'no_smilies' , !$enable_smile);
|
||||
$this->pConfig->set($uid, 'system', 'infinite_scroll' , $infinite_scroll);
|
||||
$this->pConfig->set($uid, 'system', 'no_smart_threading' , !$enable_smart_threading);
|
||||
$this->pConfig->set($uid, 'system', 'hide_dislike' , !$enable_dislike);
|
||||
$this->pConfig->set($uid, 'system', 'display_resharer' , $display_resharer);
|
||||
$this->pConfig->set($uid, 'system', 'stay_local' , $stay_local);
|
||||
$this->pConfig->set($uid, 'system', 'preview_mode' , $preview_mode);
|
||||
|
||||
$this->pConfig->set($uid, 'calendar', 'first_day_of_week' , $first_day_of_week);
|
||||
$this->pConfig->set($uid, 'calendar', 'default_view' , $calendar_default_view);
|
||||
|
||||
if (in_array($theme, Theme::getAllowedList())) {
|
||||
if ($theme == $user['theme']) {
|
||||
// call theme_post only if theme has not been changed
|
||||
if (($themeconfigfile = Theme::getConfigFile($theme)) !== null) {
|
||||
if ($themeconfigfile = Theme::getConfigFile($theme)) {
|
||||
require_once $themeconfigfile;
|
||||
theme_post(DI::app());
|
||||
theme_post($this->app);
|
||||
}
|
||||
} else {
|
||||
DBA::update('user', ['theme' => $theme], ['uid' => DI::userSession()->getLocalUserId()]);
|
||||
User::update(['theme' => $theme], $uid);
|
||||
}
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('The theme you chose isn\'t available.'));
|
||||
$this->systemMessages->addNotice($this->t('The theme you chose isn\'t available.'));
|
||||
}
|
||||
|
||||
Hook::callAll('display_settings_post', $_POST);
|
||||
Hook::callAll('display_settings_post', $request);
|
||||
|
||||
DI::baseUrl()->redirect('settings/display');
|
||||
$this->baseUrl->redirect('settings/display');
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
$uid = $this->session->getLocalUserId();
|
||||
if (!$uid) {
|
||||
throw new HTTPException\ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
|
||||
$default_theme = DI::config()->get('system', 'theme');
|
||||
$default_theme = $this->config->get('system', 'theme');
|
||||
if (!$default_theme) {
|
||||
$default_theme = 'default';
|
||||
}
|
||||
|
||||
$default_mobile_theme = DI::config()->get('system', 'mobile-theme');
|
||||
$default_mobile_theme = $this->config->get('system', 'mobile-theme');
|
||||
if (!$default_mobile_theme) {
|
||||
$default_mobile_theme = 'none';
|
||||
}
|
||||
|
||||
$user = User::getById(DI::userSession()->getLocalUserId());
|
||||
$user = User::getById($uid);
|
||||
|
||||
$allowed_themes = Theme::getAllowedList();
|
||||
|
||||
$themes = [];
|
||||
$mobile_themes = ["---" => DI::l10n()->t('No special theme for mobile devices')];
|
||||
$mobile_themes = ['---' => $this->t('No special theme for mobile devices')];
|
||||
foreach ($allowed_themes as $theme) {
|
||||
$is_experimental = file_exists('view/theme/' . $theme . '/experimental');
|
||||
$is_unsupported = file_exists('view/theme/' . $theme . '/unsupported');
|
||||
$is_mobile = file_exists('view/theme/' . $theme . '/mobile');
|
||||
if (!$is_experimental || (DI::config()->get('experimentals', 'exp_themes') || is_null(DI::config()->get('experimentals', 'exp_themes')))) {
|
||||
if (!$is_experimental || $this->config->get('experimental', 'exp_themes')) {
|
||||
$theme_name = ucfirst($theme);
|
||||
if ($is_unsupported) {
|
||||
$theme_name = DI::l10n()->t('%s - (Unsupported)', $theme_name);
|
||||
$theme_name = $this->t('%s - (Unsupported)', $theme_name);
|
||||
} elseif ($is_experimental) {
|
||||
$theme_name = DI::l10n()->t('%s - (Experimental)', $theme_name);
|
||||
$theme_name = $this->t('%s - (Experimental)', $theme_name);
|
||||
}
|
||||
|
||||
if ($is_mobile) {
|
||||
|
@ -160,84 +190,92 @@ class Display extends BaseSettings
|
|||
}
|
||||
|
||||
$theme_selected = $user['theme'] ?: $default_theme;
|
||||
$mobile_theme_selected = DI::session()->get('mobile-theme', $default_mobile_theme);
|
||||
$mobile_theme_selected = $this->session->get('mobile-theme', $default_mobile_theme);
|
||||
|
||||
$itemspage_network = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network'));
|
||||
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : DI::config()->get('system', 'itemspage_network'));
|
||||
$itemspage_mobile_network = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network'));
|
||||
$itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
$itemspage_network = intval($this->pConfig->get($uid, 'system', 'itemspage_network'));
|
||||
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : $this->config->get('system', 'itemspage_network'));
|
||||
$itemspage_mobile_network = intval($this->pConfig->get($uid, 'system', 'itemspage_mobile_network'));
|
||||
$itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : $this->config->get('system', 'itemspage_network_mobile'));
|
||||
|
||||
$browser_update = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'update_interval'));
|
||||
if (intval($browser_update) != -1) {
|
||||
$browser_update = intval($this->pConfig->get($uid, 'system', 'update_interval'));
|
||||
if ($browser_update != -1) {
|
||||
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
|
||||
}
|
||||
|
||||
$no_auto_update = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update', 0);
|
||||
$enable_smile = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_smilies', 0);
|
||||
$infinite_scroll = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll', 0);
|
||||
$enable_smart_threading = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_smart_threading', 0);
|
||||
$enable_dislike = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike', 0);
|
||||
$display_resharer = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'display_resharer', 0);
|
||||
$stay_local = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'stay_local', 0);
|
||||
$preview_mode = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'preview_mode', BBCode::PREVIEW_LARGE);
|
||||
$no_auto_update = $this->pConfig->get($uid, 'system', 'no_auto_update', 0);
|
||||
$enable_smile = !$this->pConfig->get($uid, 'system', 'no_smilies', 0);
|
||||
$infinite_scroll = $this->pConfig->get($uid, 'system', 'infinite_scroll', 0);
|
||||
$enable_smart_threading = !$this->pConfig->get($uid, 'system', 'no_smart_threading', 0);
|
||||
$enable_dislike = !$this->pConfig->get($uid, 'system', 'hide_dislike', 0);
|
||||
$display_resharer = $this->pConfig->get($uid, 'system', 'display_resharer', 0);
|
||||
$stay_local = $this->pConfig->get($uid, 'system', 'stay_local', 0);
|
||||
|
||||
$first_day_of_week = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week', 0);
|
||||
$weekdays = [
|
||||
0 => DI::l10n()->t("Sunday"),
|
||||
1 => DI::l10n()->t("Monday"),
|
||||
2 => DI::l10n()->t("Tuesday"),
|
||||
3 => DI::l10n()->t("Wednesday"),
|
||||
4 => DI::l10n()->t("Thursday"),
|
||||
5 => DI::l10n()->t("Friday"),
|
||||
6 => DI::l10n()->t("Saturday")
|
||||
$preview_mode = $this->pConfig->get($uid, 'system', 'preview_mode', BBCode::PREVIEW_LARGE);
|
||||
$preview_modes = [
|
||||
BBCode::PREVIEW_NONE => $this->t('No preview'),
|
||||
BBCode::PREVIEW_NO_IMAGE => $this->t('No image'),
|
||||
BBCode::PREVIEW_SMALL => $this->t('Small Image'),
|
||||
BBCode::PREVIEW_LARGE => $this->t('Large Image'),
|
||||
];
|
||||
|
||||
$preview_modes = [
|
||||
BBCode::PREVIEW_NONE => DI::l10n()->t('No preview'),
|
||||
BBCode::PREVIEW_NO_IMAGE => DI::l10n()->t('No image'),
|
||||
BBCode::PREVIEW_SMALL => DI::l10n()->t('Small Image'),
|
||||
BBCode::PREVIEW_LARGE => DI::l10n()->t('Large Image'),
|
||||
|
||||
$first_day_of_week = $this->pConfig->get($uid, 'system', 'first_day_of_week', 0);
|
||||
$weekdays = [
|
||||
0 => $this->t('Sunday'),
|
||||
1 => $this->t('Monday'),
|
||||
2 => $this->t('Tuesday'),
|
||||
3 => $this->t('Wednesday'),
|
||||
4 => $this->t('Thursday'),
|
||||
5 => $this->t('Friday'),
|
||||
6 => $this->t('Saturday')
|
||||
];
|
||||
|
||||
$calendar_default_view = $this->pConfig->get($uid, 'calendar', 'default_view', 'month');
|
||||
$calendarViews = [
|
||||
'month' => $this->t('month'),
|
||||
'agendaWeek' => $this->t('week'),
|
||||
'agendaDay' => $this->t('day'),
|
||||
'listMonth' => $this->t('list')
|
||||
];
|
||||
|
||||
$theme_config = '';
|
||||
if ($themeconfigfile = Theme::getConfigFile($theme_selected)) {
|
||||
require_once $themeconfigfile;
|
||||
$theme_config = theme_content(DI::app());
|
||||
$theme_config = theme_content($this->app);
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('settings/display.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
'$ptitle' => DI::l10n()->t('Display Settings'),
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
'$d_tset' => DI::l10n()->t('General Theme Settings'),
|
||||
'$d_ctset' => DI::l10n()->t('Custom Theme Settings'),
|
||||
'$d_cset' => DI::l10n()->t('Content Settings'),
|
||||
'$stitle' => DI::l10n()->t('Theme settings'),
|
||||
'$calendar_title' => DI::l10n()->t('Calendar'),
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$ptitle' => $this->t('Display Settings'),
|
||||
'$submit' => $this->t('Save Settings'),
|
||||
'$d_tset' => $this->t('General Theme Settings'),
|
||||
'$d_ctset' => $this->t('Custom Theme Settings'),
|
||||
'$d_cset' => $this->t('Content Settings'),
|
||||
'$stitle' => $this->t('Theme settings'),
|
||||
'$calendar_title' => $this->t('Calendar'),
|
||||
|
||||
'$form_security_token' => self::getFormSecurityToken('settings_display'),
|
||||
'$baseurl' => DI::baseUrl()->get(true),
|
||||
'$uid' => DI::userSession()->getLocalUserId(),
|
||||
'$baseurl' => $this->baseUrl->get(true),
|
||||
'$uid' => $uid,
|
||||
|
||||
'$theme' => ['theme', DI::l10n()->t('Display Theme:'), $theme_selected, '', $themes, true],
|
||||
'$mobile_theme' => ['mobile_theme', DI::l10n()->t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false],
|
||||
'$theme' => ['theme', $this->t('Display Theme:'), $theme_selected, '', $themes, true],
|
||||
'$mobile_theme' => ['mobile_theme', $this->t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false],
|
||||
'$theme_config' => $theme_config,
|
||||
|
||||
'$itemspage_network' => ['itemspage_network' , DI::l10n()->t('Number of items to display per page:'), $itemspage_network, DI::l10n()->t('Maximum of 100 items')],
|
||||
'$itemspage_mobile_network' => ['itemspage_mobile_network', DI::l10n()->t('Number of items to display per page when viewed from mobile device:'), $itemspage_mobile_network, DI::l10n()->t('Maximum of 100 items')],
|
||||
'$ajaxint' => ['browser_update' , DI::l10n()->t('Update browser every xx seconds'), $browser_update, DI::l10n()->t('Minimum of 10 seconds. Enter -1 to disable it.')],
|
||||
'$no_auto_update' => ['no_auto_update' , DI::l10n()->t('Automatic updates only at the top of the post stream pages'), $no_auto_update, DI::l10n()->t('Auto update may add new posts at the top of the post stream pages, which can affect the scroll position and perturb normal reading if it happens anywhere else the top of the page.')],
|
||||
'$enable_smile' => ['enable_smile' , DI::l10n()->t('Display emoticons'), $enable_smile, DI::l10n()->t('When enabled, emoticons are replaced with matching symbols.')],
|
||||
'$infinite_scroll' => ['infinite_scroll' , DI::l10n()->t('Infinite scroll'), $infinite_scroll, DI::l10n()->t('Automatic fetch new items when reaching the page end.')],
|
||||
'$enable_smart_threading' => ['enable_smart_threading' , DI::l10n()->t('Enable Smart Threading'), $enable_smart_threading, DI::l10n()->t('Enable the automatic suppression of extraneous thread indentation.')],
|
||||
'$enable_dislike' => ['enable_dislike' , DI::l10n()->t('Display the Dislike feature'), $enable_dislike, DI::l10n()->t('Display the Dislike button and dislike reactions on posts and comments.')],
|
||||
'$display_resharer' => ['display_resharer' , DI::l10n()->t('Display the resharer'), $display_resharer, DI::l10n()->t('Display the first resharer as icon and text on a reshared item.')],
|
||||
'$stay_local' => ['stay_local' , DI::l10n()->t('Stay local'), $stay_local, DI::l10n()->t("Don't go to a remote system when following a contact link.")],
|
||||
'$preview_mode' => ['preview_mode' , DI::l10n()->t('Link preview mode'), $preview_mode, 'Appearance of the link preview that is added to each post with a link.', $preview_modes, false],
|
||||
'$itemspage_network' => ['itemspage_network' , $this->t('Number of items to display per page:'), $itemspage_network, $this->t('Maximum of 100 items')],
|
||||
'$itemspage_mobile_network' => ['itemspage_mobile_network', $this->t('Number of items to display per page when viewed from mobile device:'), $itemspage_mobile_network, $this->t('Maximum of 100 items')],
|
||||
'$ajaxint' => ['browser_update' , $this->t('Update browser every xx seconds'), $browser_update, $this->t('Minimum of 10 seconds. Enter -1 to disable it.')],
|
||||
'$no_auto_update' => ['no_auto_update' , $this->t('Automatic updates only at the top of the post stream pages'), $no_auto_update, $this->t('Auto update may add new posts at the top of the post stream pages, which can affect the scroll position and perturb normal reading if it happens anywhere else the top of the page.')],
|
||||
'$enable_smile' => ['enable_smile' , $this->t('Display emoticons'), $enable_smile, $this->t('When enabled, emoticons are replaced with matching symbols.')],
|
||||
'$infinite_scroll' => ['infinite_scroll' , $this->t('Infinite scroll'), $infinite_scroll, $this->t('Automatic fetch new items when reaching the page end.')],
|
||||
'$enable_smart_threading' => ['enable_smart_threading' , $this->t('Enable Smart Threading'), $enable_smart_threading, $this->t('Enable the automatic suppression of extraneous thread indentation.')],
|
||||
'$enable_dislike' => ['enable_dislike' , $this->t('Display the Dislike feature'), $enable_dislike, $this->t('Display the Dislike button and dislike reactions on posts and comments.')],
|
||||
'$display_resharer' => ['display_resharer' , $this->t('Display the resharer'), $display_resharer, $this->t('Display the first resharer as icon and text on a reshared item.')],
|
||||
'$stay_local' => ['stay_local' , $this->t('Stay local'), $stay_local, $this->t("Don't go to a remote system when following a contact link.")],
|
||||
'$preview_mode' => ['preview_mode' , $this->t('Link preview mode'), $preview_mode, $this->t('Appearance of the link preview that is added to each post with a link.'), $preview_modes, false],
|
||||
|
||||
'$first_day_of_week' => ['first_day_of_week', DI::l10n()->t('Beginning of week:'), $first_day_of_week, '', $weekdays, false],
|
||||
'$first_day_of_week' => ['first_day_of_week' , $this->t('Beginning of week:') , $first_day_of_week , '', $weekdays , false],
|
||||
'$calendar_default_view' => ['calendar_default_view', $this->t('Default calendar view:'), $calendar_default_view, '', $calendarViews, false],
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ class Index extends BaseSettings
|
|||
<p>Reorder by dragging the field title.</p>
|
||||
<p>Empty the label field to remove a custom field.</p>
|
||||
<p>Non-public fields can only be seen by the selected Friendica contacts or the Friendica contacts in the selected groups.</p>",
|
||||
'profile/' . $profile['nickname']
|
||||
'profile/' . $profile['nickname'] . '/profile'
|
||||
),
|
||||
'$custom_fields' => $custom_fields,
|
||||
]);
|
||||
|
|
|
@ -83,13 +83,15 @@ class Tos extends BaseModule
|
|||
|
||||
$tpl = Renderer::getMarkupTemplate('tos.tpl');
|
||||
if ($this->config->get('system', 'tosdisplay')) {
|
||||
$lines = $this->config->get('system', 'tosrules');
|
||||
if (!empty($lines)) {
|
||||
$rules = "[list=1]";
|
||||
$lines = trim($this->config->get('system', 'tosrules') ?: '');
|
||||
if ($lines) {
|
||||
$rules = "[ol]";
|
||||
foreach (explode("\n", $lines) as $line) {
|
||||
$rules .= "\n[*]" . $line;
|
||||
if (trim($line)) {
|
||||
$rules .= "\n[*]" . trim($line);
|
||||
}
|
||||
}
|
||||
$rules .= "\n[/list]\n";
|
||||
$rules .= "\n[/ol]\n";
|
||||
} else {
|
||||
$rules = '';
|
||||
}
|
||||
|
|
|
@ -59,9 +59,9 @@ class Display extends DisplayModule
|
|||
$parentUriId = $item['parent-uri-id'];
|
||||
|
||||
if (empty($force)) {
|
||||
$browserUpdate = $this->pConfig->get($profileUid, 'system', 'update_interval');
|
||||
if (!empty($browserUpdate)) {
|
||||
$updateDate = date(DateTimeFormat::MYSQL, time() - (intval($browserUpdate) / 500));
|
||||
$browserUpdate = intval($this->pConfig->get($profileUid, 'system', 'update_interval') ?? 40000);
|
||||
if ($browserUpdate >= 1000) {
|
||||
$updateDate = date(DateTimeFormat::MYSQL, time() - ($browserUpdate * 2 / 1000));
|
||||
if (!Post::exists([
|
||||
"`parent-uri-id` = ? AND `uid` IN (?, ?) AND `received` > ?",
|
||||
$parentUriId, 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue