UserSession class [4] - Refactor src/Model/ files
This commit is contained in:
parent
a729f3255d
commit
b4ffb0bde0
|
@ -29,7 +29,6 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
|
@ -1129,7 +1128,7 @@ class Contact
|
||||||
$photos_link = '';
|
$photos_link = '';
|
||||||
|
|
||||||
if ($uid == 0) {
|
if ($uid == 0) {
|
||||||
$uid = Session::getLocalUser();
|
$uid = DI::userSession()->getLocalUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($contact['uid']) || ($contact['uid'] != $uid)) {
|
if (empty($contact['uid']) || ($contact['uid'] != $uid)) {
|
||||||
|
@ -1532,10 +1531,10 @@ class Contact
|
||||||
|
|
||||||
if ($thread_mode) {
|
if ($thread_mode) {
|
||||||
$condition = ["((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql,
|
$condition = ["((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql,
|
||||||
$cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Session::getLocalUser()];
|
$cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), DI::userSession()->getLocalUserId()];
|
||||||
} else {
|
} else {
|
||||||
$condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
|
$condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
|
||||||
$cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, Session::getLocalUser()];
|
$cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, DI::userSession()->getLocalUserId()];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($parent)) {
|
if (!empty($parent)) {
|
||||||
|
@ -1553,10 +1552,10 @@ class Contact
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::mode()->isMobile()) {
|
if (DI::mode()->isMobile()) {
|
||||||
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
|
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||||
} else {
|
} else {
|
||||||
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
|
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
|
||||||
DI::config()->get('system', 'itemspage_network'));
|
DI::config()->get('system', 'itemspage_network'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1564,7 +1563,7 @@ class Contact
|
||||||
|
|
||||||
$params = ['order' => ['received' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
$params = ['order' => ['received' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||||
|
|
||||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
|
||||||
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
||||||
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1573,27 +1572,27 @@ class Contact
|
||||||
|
|
||||||
if ($thread_mode) {
|
if ($thread_mode) {
|
||||||
$fields = ['uri-id', 'thr-parent-id', 'gravity', 'author-id', 'commented'];
|
$fields = ['uri-id', 'thr-parent-id', 'gravity', 'author-id', 'commented'];
|
||||||
$items = Post::toArray(Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params));
|
$items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params));
|
||||||
|
|
||||||
if ($pager->getStart() == 0) {
|
if ($pager->getStart() == 0) {
|
||||||
$cdata = self::getPublicAndUserContactID($cid, Session::getLocalUser());
|
$cdata = self::getPublicAndUserContactID($cid, DI::userSession()->getLocalUserId());
|
||||||
if (!empty($cdata['public'])) {
|
if (!empty($cdata['public'])) {
|
||||||
$pinned = Post\Collection::selectToArrayForContact($cdata['public'], Post\Collection::FEATURED, $fields);
|
$pinned = Post\Collection::selectToArrayForContact($cdata['public'], Post\Collection::FEATURED, $fields);
|
||||||
$items = array_merge($items, $pinned);
|
$items = array_merge($items, $pinned);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$o .= DI::conversation()->create($items, 'contacts', $update, false, 'pinned_commented', Session::getLocalUser());
|
$o .= DI::conversation()->create($items, 'contacts', $update, false, 'pinned_commented', DI::userSession()->getLocalUserId());
|
||||||
} else {
|
} else {
|
||||||
$fields = array_merge(Item::DISPLAY_FIELDLIST, ['featured']);
|
$fields = array_merge(Item::DISPLAY_FIELDLIST, ['featured']);
|
||||||
$items = Post::toArray(Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params));
|
$items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params));
|
||||||
|
|
||||||
if ($pager->getStart() == 0) {
|
if ($pager->getStart() == 0) {
|
||||||
$cdata = self::getPublicAndUserContactID($cid, Session::getLocalUser());
|
$cdata = self::getPublicAndUserContactID($cid, DI::userSession()->getLocalUserId());
|
||||||
if (!empty($cdata['public'])) {
|
if (!empty($cdata['public'])) {
|
||||||
$condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
|
$condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
|
||||||
$cdata['public'], Post\Collection::FEATURED];
|
$cdata['public'], Post\Collection::FEATURED];
|
||||||
$pinned = Post::toArray(Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params));
|
$pinned = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params));
|
||||||
$items = array_merge($pinned, $items);
|
$items = array_merge($pinned, $items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1602,7 +1601,7 @@ class Contact
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
|
||||||
$o .= HTML::scrollLoader();
|
$o .= HTML::scrollLoader();
|
||||||
} else {
|
} else {
|
||||||
$o .= $pager->renderMinimal(count($items));
|
$o .= $pager->renderMinimal(count($items));
|
||||||
|
@ -3257,7 +3256,7 @@ class Contact
|
||||||
*/
|
*/
|
||||||
public static function magicLink(string $contact_url, string $url = ''): string
|
public static function magicLink(string $contact_url, string $url = ''): string
|
||||||
{
|
{
|
||||||
if (!Session::isAuthenticated()) {
|
if (!DI::userSession()->isAuthenticated()) {
|
||||||
return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url;
|
return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3303,7 +3302,7 @@ class Contact
|
||||||
{
|
{
|
||||||
$destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
|
$destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
|
||||||
|
|
||||||
if (!Session::isAuthenticated()) {
|
if (!DI::userSession()->isAuthenticated()) {
|
||||||
return $destination;
|
return $destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3312,7 +3311,7 @@ class Contact
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'stay_local') && ($url == '')) {
|
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'stay_local') && ($url == '')) {
|
||||||
return 'contact/' . $contact['id'] . '/conversations';
|
return 'contact/' . $contact['id'] . '/conversations';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
namespace Friendica\Model\Contact;
|
namespace Friendica\Model\Contact;
|
||||||
|
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ class Group
|
||||||
AND NOT `contact`.`pending`
|
AND NOT `contact`.`pending`
|
||||||
ORDER BY `contact`.`name` ASC',
|
ORDER BY `contact`.`name` ASC',
|
||||||
$gid,
|
$gid,
|
||||||
Session::getLocalUser()
|
DI::userSession()->getLocalUserId()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DBA::isResult($stmt)) {
|
if (DBA::isResult($stmt)) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -411,7 +410,7 @@ class Event
|
||||||
public static function getStrings(): array
|
public static function getStrings(): array
|
||||||
{
|
{
|
||||||
// First day of the week (0 = Sunday).
|
// First day of the week (0 = Sunday).
|
||||||
$firstDay = DI::pConfig()->get(Session::getLocalUser(), 'system', 'first_day_of_week', 0);
|
$firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week', 0);
|
||||||
|
|
||||||
$i18n = [
|
$i18n = [
|
||||||
"firstDay" => $firstDay,
|
"firstDay" => $firstDay,
|
||||||
|
@ -609,7 +608,7 @@ class Event
|
||||||
$edit = null;
|
$edit = null;
|
||||||
$copy = null;
|
$copy = null;
|
||||||
$drop = null;
|
$drop = null;
|
||||||
if (Session::getLocalUser() && Session::getLocalUser() == $event['uid'] && $event['type'] == 'event') {
|
if (DI::userSession()->getLocalUserId() && DI::userSession()->getLocalUserId() == $event['uid'] && $event['type'] == 'event') {
|
||||||
$edit = !$event['cid'] ? [DI::baseUrl() . '/events/event/' . $event['id'], DI::l10n()->t('Edit event') , '', ''] : null;
|
$edit = !$event['cid'] ? [DI::baseUrl() . '/events/event/' . $event['id'], DI::l10n()->t('Edit event') , '', ''] : null;
|
||||||
$copy = !$event['cid'] ? [DI::baseUrl() . '/events/copy/' . $event['id'] , DI::l10n()->t('Duplicate event'), '', ''] : null;
|
$copy = !$event['cid'] ? [DI::baseUrl() . '/events/copy/' . $event['id'] , DI::l10n()->t('Duplicate event'), '', ''] : null;
|
||||||
$drop = [DI::baseUrl() . '/events/drop/' . $event['id'] , DI::l10n()->t('Delete event') , '', ''];
|
$drop = [DI::baseUrl() . '/events/drop/' . $event['id'] , DI::l10n()->t('Delete event') , '', ''];
|
||||||
|
@ -776,7 +775,7 @@ class Event
|
||||||
// Does the user who requests happen to be the owner of the events
|
// Does the user who requests happen to be the owner of the events
|
||||||
// requested? then show all of your events, otherwise only those that
|
// requested? then show all of your events, otherwise only those that
|
||||||
// don't have limitations set in allow_cid and allow_gid.
|
// don't have limitations set in allow_cid and allow_gid.
|
||||||
if (Session::getLocalUser() != $uid) {
|
if (DI::userSession()->getLocalUserId() != $uid) {
|
||||||
$conditions += ['allow_cid' => '', 'allow_gid' => ''];
|
$conditions += ['allow_cid' => '', 'allow_gid' => ''];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\BaseModule;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -188,8 +187,8 @@ class Group
|
||||||
) AS `count`
|
) AS `count`
|
||||||
FROM `group`
|
FROM `group`
|
||||||
WHERE `group`.`uid` = ?;",
|
WHERE `group`.`uid` = ?;",
|
||||||
Session::getLocalUser(),
|
DI::userSession()->getLocalUserId(),
|
||||||
Session::getLocalUser()
|
DI::userSession()->getLocalUserId()
|
||||||
);
|
);
|
||||||
|
|
||||||
return DBA::toArray($stmt);
|
return DBA::toArray($stmt);
|
||||||
|
@ -527,7 +526,7 @@ class Group
|
||||||
*/
|
*/
|
||||||
public static function sidebarWidget(string $every = 'contact', string $each = 'group', string $editmode = 'standard', $group_id = '', int $cid = 0)
|
public static function sidebarWidget(string $every = 'contact', string $each = 'group', string $editmode = 'standard', $group_id = '', int $cid = 0)
|
||||||
{
|
{
|
||||||
if (!Session::getLocalUser()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +544,7 @@ class Group
|
||||||
$member_of = self::getIdsByContactId($cid);
|
$member_of = self::getIdsByContactId($cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = DBA::select('group', [], ['deleted' => false, 'uid' => Session::getLocalUser(), 'cid' => null], ['order' => ['name']]);
|
$stmt = DBA::select('group', [], ['deleted' => false, 'uid' => DI::userSession()->getLocalUserId(), 'cid' => null], ['order' => ['name']]);
|
||||||
while ($group = DBA::fetch($stmt)) {
|
while ($group = DBA::fetch($stmt)) {
|
||||||
$selected = (($group_id == $group['id']) ? ' group-selected' : '');
|
$selected = (($group_id == $group['id']) ? ' group-selected' : '');
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
|
@ -1066,7 +1065,7 @@ class Item
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to tell the hooks who we are - this really should be improved
|
// We have to tell the hooks who we are - this really should be improved
|
||||||
if (!Session::getLocalUser()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
$_SESSION['authenticated'] = true;
|
$_SESSION['authenticated'] = true;
|
||||||
$_SESSION['uid'] = $uid;
|
$_SESSION['uid'] = $uid;
|
||||||
$dummy_session = true;
|
$dummy_session = true;
|
||||||
|
@ -2775,8 +2774,8 @@ class Item
|
||||||
*/
|
*/
|
||||||
public static function getPermissionsConditionArrayByUserId(int $owner_id): array
|
public static function getPermissionsConditionArrayByUserId(int $owner_id): array
|
||||||
{
|
{
|
||||||
$local_user = Session::getLocalUser();
|
$local_user = DI::userSession()->getLocalUserId();
|
||||||
$remote_user = Session::getRemoteContactID($owner_id);
|
$remote_user = DI::userSession()->getRemoteContactID($owner_id);
|
||||||
|
|
||||||
// default permissions - anonymous user
|
// default permissions - anonymous user
|
||||||
$condition = ["`private` != ?", self::PRIVATE];
|
$condition = ["`private` != ?", self::PRIVATE];
|
||||||
|
@ -2807,8 +2806,8 @@ class Item
|
||||||
*/
|
*/
|
||||||
public static function getPermissionsSQLByUserId(int $owner_id, string $table = ''): string
|
public static function getPermissionsSQLByUserId(int $owner_id, string $table = ''): string
|
||||||
{
|
{
|
||||||
$local_user = Session::getLocalUser();
|
$local_user = DI::userSession()->getLocalUserId();
|
||||||
$remote_user = Session::getRemoteContactID($owner_id);
|
$remote_user = DI::userSession()->getRemoteContactID($owner_id);
|
||||||
|
|
||||||
if (!empty($table)) {
|
if (!empty($table)) {
|
||||||
$table = DBA::quoteIdentifier($table) . '.';
|
$table = DBA::quoteIdentifier($table) . '.';
|
||||||
|
@ -3006,8 +3005,8 @@ class Item
|
||||||
|
|
||||||
// Compile eventual content filter reasons
|
// Compile eventual content filter reasons
|
||||||
$filter_reasons = [];
|
$filter_reasons = [];
|
||||||
if (!$is_preview && Session::getPublicContact() != $item['author-id']) {
|
if (!$is_preview && DI::userSession()->getPublicContactId() != $item['author-id']) {
|
||||||
if (!empty($item['content-warning']) && (!Session::getLocalUser() || !DI::pConfig()->get(Session::getLocalUser(), 'system', 'disable_cw', false))) {
|
if (!empty($item['content-warning']) && (!DI::userSession()->getLocalUserId() || !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'disable_cw', false))) {
|
||||||
$filter_reasons[] = DI::l10n()->t('Content warning: %s', $item['content-warning']);
|
$filter_reasons[] = DI::l10n()->t('Content warning: %s', $item['content-warning']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3443,7 +3442,7 @@ class Item
|
||||||
$plink = $item['uri'];
|
$plink = $item['uri'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Session::getLocalUser()) {
|
if (DI::userSession()->getLocalUserId()) {
|
||||||
$ret = [
|
$ret = [
|
||||||
'href' => "display/" . $item['guid'],
|
'href' => "display/" . $item['guid'],
|
||||||
'orig' => "display/" . $item['guid'],
|
'orig' => "display/" . $item['guid'],
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Model;
|
||||||
|
|
||||||
use Friendica\Core\ACL;
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
@ -138,12 +137,12 @@ class Mail
|
||||||
$subject = DI::l10n()->t('[no subject]');
|
$subject = DI::l10n()->t('[no subject]');
|
||||||
}
|
}
|
||||||
|
|
||||||
$me = DBA::selectFirst('contact', [], ['uid' => Session::getLocalUser(), 'self' => true]);
|
$me = DBA::selectFirst('contact', [], ['uid' => DI::userSession()->getLocalUserId(), 'self' => true]);
|
||||||
if (!DBA::isResult($me)) {
|
if (!DBA::isResult($me)) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contacts = ACL::getValidMessageRecipientsForUser(Session::getLocalUser());
|
$contacts = ACL::getValidMessageRecipientsForUser(DI::userSession()->getLocalUserId());
|
||||||
|
|
||||||
$contactIndex = array_search($recipient, array_column($contacts, 'id'));
|
$contactIndex = array_search($recipient, array_column($contacts, 'id'));
|
||||||
if ($contactIndex === false) {
|
if ($contactIndex === false) {
|
||||||
|
@ -152,7 +151,7 @@ class Mail
|
||||||
|
|
||||||
$contact = $contacts[$contactIndex];
|
$contact = $contacts[$contactIndex];
|
||||||
|
|
||||||
Photo::setPermissionFromBody($body, Session::getLocalUser(), $me['id'], '<' . $contact['id'] . '>', '', '', '');
|
Photo::setPermissionFromBody($body, DI::userSession()->getLocalUserId(), $me['id'], '<' . $contact['id'] . '>', '', '', '');
|
||||||
|
|
||||||
$guid = System::createUUID();
|
$guid = System::createUUID();
|
||||||
$uri = Item::newURI($guid);
|
$uri = Item::newURI($guid);
|
||||||
|
@ -165,7 +164,7 @@ class Mail
|
||||||
if (strlen($replyto)) {
|
if (strlen($replyto)) {
|
||||||
$reply = true;
|
$reply = true;
|
||||||
$condition = ["`uid` = ? AND (`uri` = ? OR `parent-uri` = ?)",
|
$condition = ["`uid` = ? AND (`uri` = ? OR `parent-uri` = ?)",
|
||||||
Session::getLocalUser(), $replyto, $replyto];
|
DI::userSession()->getLocalUserId(), $replyto, $replyto];
|
||||||
$mail = DBA::selectFirst('mail', ['convid'], $condition);
|
$mail = DBA::selectFirst('mail', ['convid'], $condition);
|
||||||
if (DBA::isResult($mail)) {
|
if (DBA::isResult($mail)) {
|
||||||
$convid = $mail['convid'];
|
$convid = $mail['convid'];
|
||||||
|
@ -178,7 +177,7 @@ class Mail
|
||||||
$conv_guid = System::createUUID();
|
$conv_guid = System::createUUID();
|
||||||
$convuri = $contact['addr'] . ':' . $conv_guid;
|
$convuri = $contact['addr'] . ':' . $conv_guid;
|
||||||
|
|
||||||
$fields = ['uid' => Session::getLocalUser(), 'guid' => $conv_guid, 'creator' => $me['addr'],
|
$fields = ['uid' => DI::userSession()->getLocalUserId(), 'guid' => $conv_guid, 'creator' => $me['addr'],
|
||||||
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
|
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
|
||||||
'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']];
|
'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']];
|
||||||
if (DBA::insert('conv', $fields)) {
|
if (DBA::insert('conv', $fields)) {
|
||||||
|
@ -197,7 +196,7 @@ class Mail
|
||||||
|
|
||||||
$post_id = self::insert(
|
$post_id = self::insert(
|
||||||
[
|
[
|
||||||
'uid' => Session::getLocalUser(),
|
'uid' => DI::userSession()->getLocalUserId(),
|
||||||
'guid' => $guid,
|
'guid' => $guid,
|
||||||
'convid' => $convid,
|
'convid' => $convid,
|
||||||
'from-name' => $me['name'],
|
'from-name' => $me['name'],
|
||||||
|
@ -233,7 +232,7 @@ class Mail
|
||||||
foreach ($images as $image) {
|
foreach ($images as $image) {
|
||||||
$image_rid = Photo::ridFromURI($image);
|
$image_rid = Photo::ridFromURI($image);
|
||||||
if (!empty($image_rid)) {
|
if (!empty($image_rid)) {
|
||||||
Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => Session::getLocalUser()]);
|
Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => DI::userSession()->getLocalUserId()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Model;
|
||||||
|
|
||||||
use Friendica\Core\Cache\Enum\Duration;
|
use Friendica\Core\Cache\Enum\Duration;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -639,10 +638,10 @@ class Photo
|
||||||
{
|
{
|
||||||
$sql_extra = Security::getPermissionsSQLByUserId($uid);
|
$sql_extra = Security::getPermissionsSQLByUserId($uid);
|
||||||
|
|
||||||
$avatar_type = (Session::getLocalUser() && (Session::getLocalUser() == $uid)) ? self::USER_AVATAR : self::DEFAULT;
|
$avatar_type = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $uid)) ? self::USER_AVATAR : self::DEFAULT;
|
||||||
$banner_type = (Session::getLocalUser() && (Session::getLocalUser() == $uid)) ? self::USER_BANNER : self::DEFAULT;
|
$banner_type = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $uid)) ? self::USER_BANNER : self::DEFAULT;
|
||||||
|
|
||||||
$key = 'photo_albums:' . $uid . ':' . Session::getLocalUser() . ':' . Session::getRemoteUser();
|
$key = 'photo_albums:' . $uid . ':' . DI::userSession()->getLocalUserId() . ':' . DI::userSession()->getRemoteUserId();
|
||||||
$albums = DI::cache()->get($key);
|
$albums = DI::cache()->get($key);
|
||||||
|
|
||||||
if (is_null($albums) || $update) {
|
if (is_null($albums) || $update) {
|
||||||
|
@ -681,7 +680,7 @@ class Photo
|
||||||
*/
|
*/
|
||||||
public static function clearAlbumCache(int $uid)
|
public static function clearAlbumCache(int $uid)
|
||||||
{
|
{
|
||||||
$key = 'photo_albums:' . $uid . ':' . Session::getLocalUser() . ':' . Session::getRemoteUser();
|
$key = 'photo_albums:' . $uid . ':' . DI::userSession()->getLocalUserId() . ':' . DI::userSession()->getRemoteUserId();
|
||||||
DI::cache()->set($key, null, Duration::DAY);
|
DI::cache()->set($key, null, Duration::DAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Model;
|
||||||
|
|
||||||
use BadMethodCallException;
|
use BadMethodCallException;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
@ -509,7 +508,7 @@ class Post
|
||||||
{
|
{
|
||||||
$affected = 0;
|
$affected = 0;
|
||||||
|
|
||||||
Logger::info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => Session::getLocalUser(),'callstack' => System::callstack(10)]);
|
Logger::info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => DI::userSession()->getLocalUserId(),'callstack' => System::callstack(10)]);
|
||||||
|
|
||||||
// Don't allow changes to fields that are responsible for the relation between the records
|
// Don't allow changes to fields that are responsible for the relation between the records
|
||||||
unset($fields['id']);
|
unset($fields['id']);
|
||||||
|
|
|
@ -30,7 +30,6 @@ use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Search;
|
use Friendica\Core\Search;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
@ -239,7 +238,7 @@ class Profile
|
||||||
|
|
||||||
DI::page()['title'] = $profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
|
DI::page()['title'] = $profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
|
||||||
|
|
||||||
if (!Session::getLocalUser()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
$a->setCurrentTheme($profile['theme']);
|
$a->setCurrentTheme($profile['theme']);
|
||||||
$a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme') ?? '');
|
$a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme') ?? '');
|
||||||
}
|
}
|
||||||
|
@ -255,7 +254,7 @@ class Profile
|
||||||
require_once $theme_info_file;
|
require_once $theme_info_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
$block = (DI::config()->get('system', 'block_public') && !Session::isAuthenticated());
|
$block = (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo
|
* @todo
|
||||||
|
@ -295,8 +294,8 @@ class Profile
|
||||||
|
|
||||||
$profile_contact = [];
|
$profile_contact = [];
|
||||||
|
|
||||||
if (Session::getLocalUser() && ($profile['uid'] ?? 0) != Session::getLocalUser()) {
|
if (DI::userSession()->getLocalUserId() && ($profile['uid'] ?? 0) != DI::userSession()->getLocalUserId()) {
|
||||||
$profile_contact = Contact::getByURL($profile['nurl'], null, [], Session::getLocalUser());
|
$profile_contact = Contact::getByURL($profile['nurl'], null, [], DI::userSession()->getLocalUserId());
|
||||||
}
|
}
|
||||||
if (!empty($profile['cid']) && self::getMyURL()) {
|
if (!empty($profile['cid']) && self::getMyURL()) {
|
||||||
$profile_contact = Contact::selectFirst([], ['id' => $profile['cid']]);
|
$profile_contact = Contact::selectFirst([], ['id' => $profile['cid']]);
|
||||||
|
@ -379,7 +378,7 @@ class Profile
|
||||||
$xmpp = !empty($profile['xmpp']) ? DI::l10n()->t('XMPP:') : false;
|
$xmpp = !empty($profile['xmpp']) ? DI::l10n()->t('XMPP:') : false;
|
||||||
$matrix = !empty($profile['matrix']) ? DI::l10n()->t('Matrix:') : false;
|
$matrix = !empty($profile['matrix']) ? DI::l10n()->t('Matrix:') : false;
|
||||||
|
|
||||||
if ((!empty($profile['hidewall']) || $block) && !Session::isAuthenticated()) {
|
if ((!empty($profile['hidewall']) || $block) && !DI::userSession()->isAuthenticated()) {
|
||||||
$location = $homepage = $about = false;
|
$location = $homepage = $about = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,7 +412,7 @@ class Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$block && $show_contacts) {
|
if (!$block && $show_contacts) {
|
||||||
$contact_block = ContactBlock::getHTML($profile, Session::getLocalUser());
|
$contact_block = ContactBlock::getHTML($profile, DI::userSession()->getLocalUserId());
|
||||||
|
|
||||||
if (is_array($profile) && !$profile['hide-friends']) {
|
if (is_array($profile) && !$profile['hide-friends']) {
|
||||||
$contact_count = DBA::count('contact', [
|
$contact_count = DBA::count('contact', [
|
||||||
|
@ -493,7 +492,7 @@ class Profile
|
||||||
*/
|
*/
|
||||||
public static function getBirthdays(): string
|
public static function getBirthdays(): string
|
||||||
{
|
{
|
||||||
if (!Session::getLocalUser() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
|
if (!DI::userSession()->getLocalUserId() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,7 +505,7 @@ class Profile
|
||||||
|
|
||||||
$bd_short = DI::l10n()->t('F d');
|
$bd_short = DI::l10n()->t('F d');
|
||||||
|
|
||||||
$cacheKey = 'get_birthdays:' . Session::getLocalUser();
|
$cacheKey = 'get_birthdays:' . DI::userSession()->getLocalUserId();
|
||||||
$events = DI::cache()->get($cacheKey);
|
$events = DI::cache()->get($cacheKey);
|
||||||
if (is_null($events)) {
|
if (is_null($events)) {
|
||||||
$result = DBA::p(
|
$result = DBA::p(
|
||||||
|
@ -523,7 +522,7 @@ class Profile
|
||||||
ORDER BY `start`",
|
ORDER BY `start`",
|
||||||
Contact::SHARING,
|
Contact::SHARING,
|
||||||
Contact::FRIEND,
|
Contact::FRIEND,
|
||||||
Session::getLocalUser(),
|
DI::userSession()->getLocalUserId(),
|
||||||
DateTimeFormat::utc('now + 6 days'),
|
DateTimeFormat::utc('now + 6 days'),
|
||||||
DateTimeFormat::utcNow()
|
DateTimeFormat::utcNow()
|
||||||
);
|
);
|
||||||
|
@ -595,7 +594,7 @@ class Profile
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
if (!Session::getLocalUser() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
|
if (!DI::userSession()->getLocalUserId() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,7 +609,7 @@ class Profile
|
||||||
$classtoday = '';
|
$classtoday = '';
|
||||||
|
|
||||||
$condition = ["`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ?",
|
$condition = ["`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ?",
|
||||||
Session::getLocalUser(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utc('now - 1 days')];
|
DI::userSession()->getLocalUserId(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utc('now - 1 days')];
|
||||||
$s = DBA::select('event', [], $condition, ['order' => ['start']]);
|
$s = DBA::select('event', [], $condition, ['order' => ['start']]);
|
||||||
|
|
||||||
$r = [];
|
$r = [];
|
||||||
|
@ -620,7 +619,7 @@ class Profile
|
||||||
$total = 0;
|
$total = 0;
|
||||||
|
|
||||||
while ($rr = DBA::fetch($s)) {
|
while ($rr = DBA::fetch($s)) {
|
||||||
$condition = ['parent-uri' => $rr['uri'], 'uid' => $rr['uid'], 'author-id' => Session::getPublicContact(),
|
$condition = ['parent-uri' => $rr['uri'], 'uid' => $rr['uid'], 'author-id' => DI::userSession()->getPublicContactId(),
|
||||||
'vid' => [Verb::getID(Activity::ATTEND), Verb::getID(Activity::ATTENDMAYBE)],
|
'vid' => [Verb::getID(Activity::ATTEND), Verb::getID(Activity::ATTENDMAYBE)],
|
||||||
'visible' => true, 'deleted' => false];
|
'visible' => true, 'deleted' => false];
|
||||||
if (!Post::exists($condition)) {
|
if (!Post::exists($condition)) {
|
||||||
|
@ -712,7 +711,7 @@ class Profile
|
||||||
$my_url = self::getMyURL();
|
$my_url = self::getMyURL();
|
||||||
$my_url = Network::isUrlValid($my_url);
|
$my_url = Network::isUrlValid($my_url);
|
||||||
|
|
||||||
if (empty($my_url) || Session::getLocalUser()) {
|
if (empty($my_url) || DI::userSession()->getLocalUserId()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +729,7 @@ class Profile
|
||||||
|
|
||||||
$contact = DBA::selectFirst('contact',['id', 'url'], ['id' => $cid]);
|
$contact = DBA::selectFirst('contact',['id', 'url'], ['id' => $cid]);
|
||||||
|
|
||||||
if (DBA::isResult($contact) && Session::getRemoteUser() && Session::getRemoteUser() == $contact['id']) {
|
if (DBA::isResult($contact) && DI::userSession()->getRemoteUserId() && DI::userSession()->getRemoteUserId() == $contact['id']) {
|
||||||
Logger::info('The visitor ' . $my_url . ' is already authenticated');
|
Logger::info('The visitor ' . $my_url . ' is already authenticated');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -797,7 +796,7 @@ class Profile
|
||||||
$_SESSION['my_url'] = $visitor['url'];
|
$_SESSION['my_url'] = $visitor['url'];
|
||||||
$_SESSION['remote_comment'] = $visitor['subscribe'];
|
$_SESSION['remote_comment'] = $visitor['subscribe'];
|
||||||
|
|
||||||
Session::setVisitorsContacts();
|
DI::userSession()->setVisitorsContacts();
|
||||||
|
|
||||||
$a->setContactId($visitor['id']);
|
$a->setContactId($visitor['id']);
|
||||||
|
|
||||||
|
@ -916,7 +915,7 @@ class Profile
|
||||||
*/
|
*/
|
||||||
public static function getThemeUid(App $a): int
|
public static function getThemeUid(App $a): int
|
||||||
{
|
{
|
||||||
return Session::getLocalUser() ?: $a->getProfileOwner();
|
return DI::userSession()->getLocalUserId() ?: $a->getProfileOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user