mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
4ccbf6a967
[ci skip] [skip ci]
103 lines
3.4 KiB
PHP
103 lines
3.4 KiB
PHP
<?php
|
|
|
|
use nntmux\NZBGet;
|
|
use nntmux\SABnzbd;
|
|
use App\Models\User;
|
|
use App\Models\Settings;
|
|
use App\Models\UserRequest;
|
|
use nntmux\ReleaseComments;
|
|
use App\Models\UserDownload;
|
|
use App\Models\UserExcludedCategory;
|
|
|
|
if (! User::isLoggedIn()) {
|
|
$page->show403();
|
|
}
|
|
|
|
$rc = new ReleaseComments;
|
|
$sab = new SABnzbd($page);
|
|
$nzbget = new NZBGet($page);
|
|
|
|
$userID = User::currentUserId();
|
|
$privileged = User::isAdmin($userID) || User::isModerator($userID);
|
|
$privateProfiles = (int) Settings::settingValue('..privateprofiles') === 1;
|
|
$publicView = false;
|
|
|
|
if ($privileged || ! $privateProfiles) {
|
|
$altID = (isset($_GET['id']) && (int) $_GET['id'] >= 0) ? (int) $_GET['id'] : false;
|
|
$altUsername = (isset($_GET['name']) && strlen($_GET['name']) > 0) ? $_GET['name'] : false;
|
|
|
|
// If both 'id' and 'name' are specified, 'id' should take precedence.
|
|
if ($altID === false && $altUsername !== false) {
|
|
$user = User::getByUsername($altUsername);
|
|
if ($user) {
|
|
$altID = $user['id'];
|
|
$userID = $altID;
|
|
}
|
|
} elseif ($altID !== false) {
|
|
$userID = $altID;
|
|
$publicView = true;
|
|
}
|
|
}
|
|
|
|
$downloadlist = UserDownload::getDownloadRequestsForUser($userID);
|
|
$page->smarty->assign('downloadlist', $downloadlist);
|
|
|
|
$data = User::getById($userID);
|
|
if (! $data) {
|
|
$page->show404();
|
|
}
|
|
|
|
// Check if the user selected a theme.
|
|
if (! isset($data['style']) || $data['style'] === 'None') {
|
|
$data['style'] = 'Using the admin selected theme.';
|
|
}
|
|
|
|
$offset = $_REQUEST['offset'] ?? 0;
|
|
$page->smarty->assign(
|
|
[
|
|
'apirequests' => UserRequest::getApiRequests($userID),
|
|
'grabstoday' => UserDownload::getDownloadRequests($userID),
|
|
'userinvitedby' => $data['invitedby'] !== '' ? User::getById($data['invitedby']) : '',
|
|
'user' => $data,
|
|
'privateprofiles' => $privateProfiles,
|
|
'publicview' => $publicView,
|
|
'privileged' => $privileged,
|
|
'pagertotalitems' => $rc->getCommentCountForUser($userID),
|
|
'pageroffset' => $offset,
|
|
'pageritemsperpage' => ITEMS_PER_PAGE,
|
|
'pagerquerybase' => '/profile?id='.$userID.'&offset=',
|
|
'pagerquerysuffix' => '#comments',
|
|
]
|
|
);
|
|
|
|
$sabApiKeyTypes = [
|
|
SABnzbd::API_TYPE_NZB => 'Nzb Api Key',
|
|
SABnzbd::API_TYPE_FULL => 'Full Api Key',
|
|
];
|
|
$sabPriorities = [
|
|
SABnzbd::PRIORITY_FORCE => 'Force', SABnzbd::PRIORITY_HIGH => 'High',
|
|
SABnzbd::PRIORITY_NORMAL => 'Normal', SABnzbd::PRIORITY_LOW => 'Low',
|
|
];
|
|
$sabSettings = [1 => 'Site', 2 => 'Cookie'];
|
|
|
|
// Pager must be fetched after the variables are assigned to smarty.
|
|
$page->smarty->assign(
|
|
[
|
|
'pager' => $page->smarty->fetch('pager.tpl'),
|
|
'commentslist' => $rc->getCommentsForUserRange($userID, $offset, ITEMS_PER_PAGE),
|
|
'exccats' => implode(',', UserExcludedCategory::getCategoryExclusionNames($userID)),
|
|
'saburl' => $sab->url,
|
|
'sabapikey' => $sab->apikey,
|
|
'sabapikeytype' => $sab->apikeytype !== '' ? $sabApiKeyTypes[$sab->apikeytype] : '',
|
|
'sabpriority' => $sab->priority !== '' ? $sabPriorities[$sab->priority] : '',
|
|
'sabsetting' => $sabSettings[$sab->checkCookie() === true ? 2 : 1],
|
|
]
|
|
);
|
|
|
|
$page->meta_title = 'View User Profile';
|
|
$page->meta_keywords = 'view,profile,user,details';
|
|
$page->meta_description = 'View User Profile for '.$data['username'];
|
|
|
|
$page->content = $page->smarty->fetch('profile.tpl');
|
|
$page->render();
|