mirror of
https://github.com/friendica/friendica
synced 2025-04-27 05:10:10 +00:00
UserSession class [3] - Refactor src/ files excluding Module/Model
This commit is contained in:
parent
a11c125f81
commit
b3f9cef94a
23 changed files with 120 additions and 133 deletions
|
@ -28,7 +28,6 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -87,7 +86,7 @@ class Post
|
|||
$this->setTemplate('wall');
|
||||
$this->toplevel = $this->getId() == $this->getDataValue('parent');
|
||||
|
||||
if (!empty(Session::getUserIDForVisitorContactID($this->getDataValue('contact-id')))) {
|
||||
if (!empty(DI::userSession()->getUserIDForVisitorContactID($this->getDataValue('contact-id')))) {
|
||||
$this->visiting = true;
|
||||
}
|
||||
|
||||
|
@ -104,14 +103,14 @@ class Post
|
|||
if (!empty($data['children'])) {
|
||||
foreach ($data['children'] as $item) {
|
||||
// Only add will be displayed
|
||||
if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
|
||||
if ($item['network'] === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item['uid']) {
|
||||
continue;
|
||||
} elseif (!DI::contentItem()->isVisibleActivity($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// You can always comment on Diaspora and OStatus items
|
||||
if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (Session::getLocalUser() == $item['uid'])) {
|
||||
if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (DI::userSession()->getLocalUserId() == $item['uid'])) {
|
||||
$item['writable'] = true;
|
||||
}
|
||||
|
||||
|
@ -206,7 +205,7 @@ class Post
|
|||
$lock = ($item['private'] == Item::PRIVATE) ? $privacy : false;
|
||||
$connector = !in_array($item['network'], Protocol::NATIVE_SUPPORT) ? DI::l10n()->t('Connector Message') : false;
|
||||
|
||||
$shareable = in_array($conv->getProfileOwner(), [0, Session::getLocalUser()]) && $item['private'] != Item::PRIVATE;
|
||||
$shareable = in_array($conv->getProfileOwner(), [0, DI::userSession()->getLocalUserId()]) && $item['private'] != Item::PRIVATE;
|
||||
$announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]);
|
||||
|
||||
// On Diaspora only toplevel posts can be reshared
|
||||
|
@ -216,7 +215,7 @@ class Post
|
|||
|
||||
$edpost = false;
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
if (Strings::compareLink(DI::session()->get('my_url'), $item['author-link'])) {
|
||||
if ($item['event-id'] != 0) {
|
||||
$edpost = ['events/event/' . $item['event-id'], DI::l10n()->t('Edit')];
|
||||
|
@ -224,7 +223,7 @@ class Post
|
|||
$edpost = ['editpost/' . $item['id'], DI::l10n()->t('Edit')];
|
||||
}
|
||||
}
|
||||
$dropping = in_array($item['uid'], [0, Session::getLocalUser()]);
|
||||
$dropping = in_array($item['uid'], [0, DI::userSession()->getLocalUserId()]);
|
||||
}
|
||||
|
||||
// Editing on items of not subscribed users isn't currently possible
|
||||
|
@ -234,7 +233,7 @@ class Post
|
|||
$edpost = false;
|
||||
}
|
||||
|
||||
if (($this->getDataValue('uid') == Session::getLocalUser()) || $this->isVisiting()) {
|
||||
if (($this->getDataValue('uid') == DI::userSession()->getLocalUserId()) || $this->isVisiting()) {
|
||||
$dropping = true;
|
||||
}
|
||||
|
||||
|
@ -249,7 +248,7 @@ class Post
|
|||
|
||||
$drop = false;
|
||||
$block = false;
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
$drop = [
|
||||
'dropping' => $dropping,
|
||||
'pagedrop' => $item['pagedrop'],
|
||||
|
@ -258,7 +257,7 @@ class Post
|
|||
];
|
||||
}
|
||||
|
||||
if (!$item['self'] && Session::getLocalUser()) {
|
||||
if (!$item['self'] && DI::userSession()->getLocalUserId()) {
|
||||
$block = [
|
||||
'blocking' => true,
|
||||
'block' => DI::l10n()->t('Block %s', $item['author-name']),
|
||||
|
@ -266,14 +265,14 @@ class Post
|
|||
];
|
||||
}
|
||||
|
||||
$filer = Session::getLocalUser() ? DI::l10n()->t('Save to folder') : false;
|
||||
$filer = DI::userSession()->getLocalUserId() ? DI::l10n()->t('Save to folder') : false;
|
||||
|
||||
$profile_name = $item['author-name'];
|
||||
if (!empty($item['author-link']) && empty($item['author-name'])) {
|
||||
$profile_name = $item['author-link'];
|
||||
}
|
||||
|
||||
if (Session::isAuthenticated()) {
|
||||
if (DI::userSession()->isAuthenticated()) {
|
||||
$author = ['uid' => 0, 'id' => $item['author-id'],
|
||||
'network' => $item['author-network'], 'url' => $item['author-link']];
|
||||
$profile_link = Contact::magicLinkByContact($author);
|
||||
|
@ -327,8 +326,8 @@ class Post
|
|||
$tagger = '';
|
||||
|
||||
if ($this->isToplevel()) {
|
||||
if (Session::getLocalUser()) {
|
||||
$ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], Session::getLocalUser());
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
$ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], DI::userSession()->getLocalUserId());
|
||||
if ($item['mention'] || $ignored) {
|
||||
$ignore = [
|
||||
'do' => DI::l10n()->t('Ignore thread'),
|
||||
|
@ -351,7 +350,7 @@ class Post
|
|||
'starred' => DI::l10n()->t('Starred'),
|
||||
];
|
||||
|
||||
if ($conv->getProfileOwner() == Session::getLocalUser() && ($item['uid'] != 0)) {
|
||||
if ($conv->getProfileOwner() == DI::userSession()->getLocalUserId() && ($item['uid'] != 0)) {
|
||||
if ($origin && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) {
|
||||
$ispinned = ($item['featured'] ? 'pinned' : 'unpinned');
|
||||
|
||||
|
@ -397,17 +396,17 @@ class Post
|
|||
|
||||
$body_html = Item::prepareBody($item, true);
|
||||
|
||||
list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, Session::getLocalUser());
|
||||
list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, DI::userSession()->getLocalUserId());
|
||||
|
||||
if (!empty($item['title'])) {
|
||||
$title = $item['title'];
|
||||
} elseif (!empty($item['content-warning']) && DI::pConfig()->get(Session::getLocalUser(), 'system', 'disable_cw', false)) {
|
||||
} elseif (!empty($item['content-warning']) && DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'disable_cw', false)) {
|
||||
$title = ucfirst($item['content-warning']);
|
||||
} else {
|
||||
$title = '';
|
||||
}
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike')) {
|
||||
$buttons['dislike'] = false;
|
||||
}
|
||||
|
||||
|
@ -434,7 +433,7 @@ class Post
|
|||
}
|
||||
|
||||
// Fetching of Diaspora posts doesn't always work. There are issues with reshares and possibly comments
|
||||
if (!Session::getLocalUser() && ($item['network'] != Protocol::DIASPORA) && !empty(DI::session()->get('remote_comment'))) {
|
||||
if (!DI::userSession()->getLocalUserId() && ($item['network'] != Protocol::DIASPORA) && !empty(DI::session()->get('remote_comment'))) {
|
||||
$remote_comment = [DI::l10n()->t('Comment this item on your system'), DI::l10n()->t('Remote comment'),
|
||||
str_replace('{uri}', urlencode($item['uri']), DI::session()->get('remote_comment'))];
|
||||
|
||||
|
@ -642,7 +641,7 @@ class Post
|
|||
/*
|
||||
* Only add what will be displayed
|
||||
*/
|
||||
if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) {
|
||||
if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
|
||||
return false;
|
||||
} elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
|
||||
$activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
|
||||
|
@ -850,7 +849,7 @@ class Post
|
|||
// This will allow us to comment on wall-to-wall items owned by our friends
|
||||
// and community forums even if somebody else wrote the post.
|
||||
// bug #517 - this fixes for conversation owner
|
||||
if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == Session::getLocalUser()) {
|
||||
if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == DI::userSession()->getLocalUserId()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -898,20 +897,20 @@ class Post
|
|||
{
|
||||
$a = DI::app();
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$owner = User::getOwnerDataById($a->getLoggedInUserId());
|
||||
$item = $this->getData();
|
||||
|
||||
if (!empty($item['content-warning']) && Feature::isEnabled(Session::getLocalUser(), 'add_abstract')) {
|
||||
if (!empty($item['content-warning']) && Feature::isEnabled(DI::userSession()->getLocalUserId(), 'add_abstract')) {
|
||||
$text = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $item['content-warning'] . "[/abstract]\n";
|
||||
} else {
|
||||
$text = '';
|
||||
}
|
||||
|
||||
if (!Feature::isEnabled(Session::getLocalUser(), 'explicit_mentions')) {
|
||||
if (!Feature::isEnabled(DI::userSession()->getLocalUserId(), 'explicit_mentions')) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
@ -958,7 +957,7 @@ class Post
|
|||
*/
|
||||
$qcomment = null;
|
||||
if (Addon::isEnabled('qcomment')) {
|
||||
$words = DI::pConfig()->get(Session::getLocalUser(), 'qcomment', 'words');
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
|
||||
$qcomment = $words ? explode("\n", $words) : [];
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Object;
|
|||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Security\Security;
|
||||
|
@ -76,7 +75,7 @@ class Thread
|
|||
switch ($mode) {
|
||||
case 'network':
|
||||
case 'notes':
|
||||
$this->profile_owner = Session::getLocalUser();
|
||||
$this->profile_owner = DI::userSession()->getLocalUserId();
|
||||
$this->writable = true;
|
||||
break;
|
||||
case 'profile':
|
||||
|
@ -169,7 +168,7 @@ class Thread
|
|||
/*
|
||||
* Only add will be displayed
|
||||
*/
|
||||
if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) {
|
||||
if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
|
||||
Logger::info('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').');
|
||||
return false;
|
||||
}
|
||||
|
@ -202,7 +201,7 @@ class Thread
|
|||
$result = [];
|
||||
|
||||
foreach ($this->parents as $item) {
|
||||
if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) {
|
||||
if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue