UserSession class [2] - Refactor mod/ files
This commit is contained in:
parent
a729f3255d
commit
bfe68702db
25 changed files with 201 additions and 201 deletions
|
@ -57,7 +57,7 @@ use Friendica\Network\HTTPException;
|
|||
|
||||
function photos_init(App $a)
|
||||
{
|
||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,11 +69,11 @@ function photos_init(App $a)
|
|||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
}
|
||||
|
||||
$is_owner = (Session::getLocalUser() && (Session::getLocalUser() == $owner['uid']));
|
||||
$is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner['uid']));
|
||||
|
||||
$albums = Photo::getAlbums($owner['uid']);
|
||||
|
||||
$albums_visible = ((intval($owner['hidewall']) && !Session::isAuthenticated()) ? false : true);
|
||||
$albums_visible = ((intval($owner['hidewall']) && !DI::userSession()->isAuthenticated()) ? false : true);
|
||||
|
||||
// add various encodings to the array so we can just loop through and pick them out in a template
|
||||
$ret = ['success' => false];
|
||||
|
@ -96,7 +96,7 @@ function photos_init(App $a)
|
|||
}
|
||||
}
|
||||
|
||||
if (Session::getLocalUser() && $owner['uid'] == Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId() && $owner['uid'] == DI::userSession()->getLocalUserId()) {
|
||||
$can_post = true;
|
||||
} else {
|
||||
$can_post = false;
|
||||
|
@ -148,10 +148,10 @@ function photos_post(App $a)
|
|||
$page_owner_uid = intval($user['uid']);
|
||||
$community_page = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
|
||||
|
||||
if (Session::getLocalUser() && (Session::getLocalUser() == $page_owner_uid)) {
|
||||
if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $page_owner_uid)) {
|
||||
$can_post = true;
|
||||
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
|
||||
$contact_id = Session::getRemoteContactID($page_owner_uid);
|
||||
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($page_owner_uid))) {
|
||||
$contact_id = DI::userSession()->getRemoteContactID($page_owner_uid);
|
||||
$can_post = true;
|
||||
$visitor = $contact_id;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ function photos_post(App $a)
|
|||
));
|
||||
} else {
|
||||
$r = DBA::toArray(DBA::p("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = ? AND `album` = ?",
|
||||
Session::getLocalUser(),
|
||||
DI::userSession()->getLocalUserId(),
|
||||
$album
|
||||
));
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ function photos_post(App $a)
|
|||
$condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => DI::args()->getArgv()[3]];
|
||||
|
||||
} else {
|
||||
$condition = ['uid' => Session::getLocalUser(), 'resource-id' => DI::args()->getArgv()[3]];
|
||||
$condition = ['uid' => DI::userSession()->getLocalUserId(), 'resource-id' => DI::args()->getArgv()[3]];
|
||||
}
|
||||
|
||||
$photo = DBA::selectFirst('photo', ['resource-id'], $condition);
|
||||
|
@ -794,7 +794,7 @@ function photos_content(App $a)
|
|||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
}
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Public access denied.'));
|
||||
return;
|
||||
}
|
||||
|
@ -840,10 +840,10 @@ function photos_content(App $a)
|
|||
|
||||
$community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
|
||||
|
||||
if (Session::getLocalUser() && (Session::getLocalUser() == $owner_uid)) {
|
||||
if (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner_uid)) {
|
||||
$can_post = true;
|
||||
} elseif ($community_page && !empty(Session::getRemoteContactID($owner_uid))) {
|
||||
$contact_id = Session::getRemoteContactID($owner_uid);
|
||||
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($owner_uid))) {
|
||||
$contact_id = DI::userSession()->getRemoteContactID($owner_uid);
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
|
||||
|
||||
if (DBA::isResult($contact)) {
|
||||
|
@ -854,21 +854,21 @@ function photos_content(App $a)
|
|||
}
|
||||
|
||||
// perhaps they're visiting - but not a community page, so they wouldn't have write access
|
||||
if (!empty(Session::getRemoteContactID($owner_uid)) && !$visitor) {
|
||||
$contact_id = Session::getRemoteContactID($owner_uid);
|
||||
if (!empty(DI::userSession()->getRemoteContactID($owner_uid)) && !$visitor) {
|
||||
$contact_id = DI::userSession()->getRemoteContactID($owner_uid);
|
||||
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
|
||||
|
||||
$remote_contact = DBA::isResult($contact);
|
||||
}
|
||||
|
||||
if (!$remote_contact && Session::getLocalUser()) {
|
||||
if (!$remote_contact && DI::userSession()->getLocalUserId()) {
|
||||
$contact_id = $_SESSION['cid'];
|
||||
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
|
||||
}
|
||||
|
||||
if ($user['hidewall'] && (Session::getLocalUser() != $owner_uid) && !$remote_contact) {
|
||||
if ($user['hidewall'] && (DI::userSession()->getLocalUserId() != $owner_uid) && !$remote_contact) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Access to this item is restricted.'));
|
||||
return;
|
||||
}
|
||||
|
@ -878,7 +878,7 @@ function photos_content(App $a)
|
|||
$o = "";
|
||||
|
||||
// tabs
|
||||
$is_owner = (Session::getLocalUser() && (Session::getLocalUser() == $owner_uid));
|
||||
$is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner_uid));
|
||||
$o .= BaseProfile::getTabsHTML($a, 'photos', $is_owner, $user['nickname'], $profile['hide-friends']);
|
||||
|
||||
// Display upload form
|
||||
|
@ -1197,7 +1197,7 @@ function photos_content(App $a)
|
|||
}
|
||||
|
||||
if (
|
||||
$ph[0]['uid'] == Session::getLocalUser()
|
||||
$ph[0]['uid'] == DI::userSession()->getLocalUserId()
|
||||
&& (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid']))
|
||||
) {
|
||||
$tools['lock'] = DI::l10n()->t('Private Photo');
|
||||
|
@ -1237,7 +1237,7 @@ function photos_content(App $a)
|
|||
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
$items = Post::toArray(Post::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params));
|
||||
|
||||
if (Session::getLocalUser() == $link_item['uid']) {
|
||||
if (DI::userSession()->getLocalUserId() == $link_item['uid']) {
|
||||
Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
|
||||
}
|
||||
}
|
||||
|
@ -1315,7 +1315,7 @@ function photos_content(App $a)
|
|||
*/
|
||||
$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) : [];
|
||||
}
|
||||
|
||||
|
@ -1346,7 +1346,7 @@ function photos_content(App $a)
|
|||
'attendmaybe' => []
|
||||
];
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike')) {
|
||||
unset($conv_responses['dislike']);
|
||||
}
|
||||
|
||||
|
@ -1371,7 +1371,7 @@ function photos_content(App $a)
|
|||
*/
|
||||
$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) : [];
|
||||
}
|
||||
|
||||
|
@ -1413,7 +1413,7 @@ function photos_content(App $a)
|
|||
$sparkle = '';
|
||||
}
|
||||
|
||||
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == Session::getLocalUser()));
|
||||
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == DI::userSession()->getLocalUserId()));
|
||||
$drop = [
|
||||
'dropping' => $dropping,
|
||||
'pagedrop' => false,
|
||||
|
@ -1445,7 +1445,7 @@ function photos_content(App $a)
|
|||
*/
|
||||
$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) : [];
|
||||
}
|
||||
|
||||
|
@ -1484,7 +1484,7 @@ function photos_content(App $a)
|
|||
'$dislike' => DI::l10n()->t('Dislike'),
|
||||
'$wait' => DI::l10n()->t('Please wait'),
|
||||
'$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'),
|
||||
'$hide_dislike' => DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike'),
|
||||
'$hide_dislike' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike'),
|
||||
'$responses' => $responses,
|
||||
'$return_path' => DI::args()->getQueryString(),
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue