Files
ops-Gazelle/sections/user/edit.php
Spine b06aef8b31 call constants directly from templates
move emails/ to email/ (singular naming)
2021-01-05 21:08:55 +00:00

151 lines
6.0 KiB
PHP

<?php
use Gazelle\Manager\Notification;
function display_paranoia($FieldName) {
global $Paranoia;
$Level = (in_array($FieldName . '+', $Paranoia)) ? 0 : (in_array($FieldName, $Paranoia) ? 1 : 2);
return sprintf('<label><input type="checkbox" name="p_c_%s"%s onchange="AlterParanoia()" /> Show count</label>&nbsp;&nbsp;
<label><input type="checkbox" name="p_l_%s"%s onchange="AlterParanoia()" /> Show list</label>',
$FieldName, $Level >= 1 ? ' checked="checked"' : '', $FieldName, $Level >= 2 ? ' checked="checked"' : '') . "\n";
}
$UserID = (int)$_REQUEST['userid'];
if (!$UserID) {
error(404);
}
if ($UserID != $LoggedUser['ID'] && !check_perms('users_edit_profiles')) {
error(403);
}
$User = new Gazelle\User($UserID);
[$Paranoia, $Info, $InfoTitle, $Avatar, $StyleID, $StyleURL, $SiteOptions, $DownloadAlt, $UnseededAlerts,
$NotifyOnDeleteSeeding, $NotifyOnDeleteSnatched, $NotifyOnDeleteDownloaded, $UserNavItems] = $DB->row("
SELECT
m.Paranoia,
i.Info,
i.InfoTitle,
i.Avatar,
i.StyleID,
i.StyleURL,
i.SiteOptions,
i.DownloadAlt,
i.UnseededAlerts,
i.NotifyOnDeleteSeeding,
i.NotifyOnDeleteSnatched,
i.NotifyOnDeleteDownloaded,
i.NavItems
FROM users_main AS m
INNER JOIN users_info AS i ON (i.UserID = m.ID)
LEFT JOIN permissions AS p ON (p.ID = m.PermissionID)
WHERE m.ID = ?
", $UserID
);
$options = array_merge(Users::default_site_options(), unserialize($SiteOptions) ?: []);
$Paranoia = unserialize($Paranoia) ?: [];
$NavItems = Users::get_nav_items();
$UserNavItems = array_filter(array_map('trim', explode(',', $UserNavItems)));
if (!count($UserNavItems)) {
$UserNavItems = array_keys(array_filter($NavItems, function($v) {
return $v['initial'];
}));
}
$donorMan = new Gazelle\Manager\Donation;
$enabledReward = $donorMan->enabledRewards($UserID);
$profileReward = $donorMan->profileRewards($UserID);
$profile = [
0 => [
'title' => $InfoTitle,
'textarea' => new TEXTAREA_PREVIEW('info', 'info', display_str($Info), 40, 8, false, false, true),
]
];
foreach (range(1, 4) as $level) {
if (!$enabledReward["HasProfileInfo$level"]) {
$profile[$level] = [
'enabled' => false,
];
} else {
$profile[$level] = [
'enabled' => true,
'title' => display_str($profileReward["ProfileInfoTitle$level"]),
'textarea' => new TEXTAREA_PREVIEW("profile_info_$level", "profile_info_$level", display_str($profileReward["ProfileInfo$level"]), 40, 8, false, false, true),
];
}
}
View::show_header($User->username() . " &rsaquo; Settings",
'user,jquery-ui,release_sort,password_validate,validate,cssgallery,preview_paranoia,bbcode,user_settings,donor_titles');
$Val = new Gazelle\Util\Validator;
echo $Val->generateJS('userform');
echo G::$Twig->render('user/setting.twig', [
'auth' => $LoggedUser['AuthKey'],
'avatar' => $Avatar,
'download_text' => $DownloadAlt,
'is_mod' => check_perms('users_mod'),
'logged_user' => $LoggedUser['ID'],
'nav_items' => $NavItems,
'nav_items_user' => $UserNavItems,
'option' => $options,
'profile' => $profile,
'release_order' => $User->releaseOrder($options, (new Gazelle\ReleaseType)->extendedList()),
'style_id' => $StyleID,
'style_url' => $StyleURL,
'stylesheets' => (new Gazelle\Stylesheet)->list(),
'user' => $User,
'can' => [
'advanced_search' => check_perms('site_advanced_search'),
'torrent_notify' => check_perms('site_torrents_notify'),
],
'donor' => [
'enabled' => $enabledReward,
'reward' => $donorMan->rewards($UserID),
'title' => $donorMan->titles($UserID),
],
'notify' => [
'autosub' => $options['AutoSubscribe'] ?: false,
'seeded' => $NotifyOnDeleteSeeding,
'snatched' => $NotifyOnDeleteSnatched,
'downloaded' => $NotifyOnDeleteDownloaded,
'unseeded' => $UnseededAlerts,
'settings' => (new Notification($UserID))->settings(),
],
'paranoia' => [
'donor_visible' => $donorMan->isVisible($UserID),
'artists' => !in_array('artistsadded', $Paranoia),
'bonus' => !in_array('bonuspoints', $Paranoia),
'hide_heart' => !in_array('hide_donor_heart', $Paranoia),
'download' => !in_array('downloaded', $Paranoia),
'invited' => !in_array('invitedcount', $Paranoia),
'lastseen' => !in_array('lastseen', $Paranoia),
'notify' => !in_array('notifications', $Paranoia),
'ratio' => !in_array('ratio', $Paranoia),
'ratio_req' => !in_array('requiredratio', $Paranoia),
'upload' => !in_array('uploaded', $Paranoia),
'collages' => display_paranoia('collages'),
'collages_contrib' => display_paranoia('collagecontribs'),
'leeching' => display_paranoia('leeching'),
'perfectflacs' => display_paranoia('perfectflacs'),
'seeding' => display_paranoia('seeding'),
'snatched' => display_paranoia('snatched'),
'torrentcomments' => display_paranoia('torrentcomments'),
'unique' => display_paranoia('uniquegroups'),
'uploads' => display_paranoia('uploads'),
'request_fill' => [
'bounty' => !in_array('requestsfilled_bounty', $Paranoia),
'count' => !in_array('requestsfilled_count', $Paranoia),
'list' => !in_array('requestsfilled_list', $Paranoia),
],
'request_vote' => [
'bounty' => !in_array('requestsvoted_bounty', $Paranoia),
'count' => !in_array('requestsvoted_count', $Paranoia),
'list' => !in_array('requestsvoted_list', $Paranoia),
],
],
]);
View::show_footer();