mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-02-02 10:04:52 +00:00
auto-approve magnets by users approved
This commit is contained in:
parent
7b1fdc9018
commit
14c35feca6
@ -234,6 +234,13 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||
$response->message = _('Could not init user session');
|
||||
}
|
||||
|
||||
// Get user
|
||||
else if (!$user = $db->getUser($userId))
|
||||
{
|
||||
$response->success = false;
|
||||
$response->message = _('Could not init user info');
|
||||
}
|
||||
|
||||
// Validate link
|
||||
if (empty($_GET['magnet']))
|
||||
{
|
||||
@ -266,7 +273,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||
// Init magnet
|
||||
if (Yggverse\Parser\Urn::parse($magnet->xt))
|
||||
{
|
||||
if ($magnetId = $db->initMagnetId($userId,
|
||||
if ($magnetId = $db->initMagnetId($user->userId,
|
||||
strip_tags($magnet->xt),
|
||||
strip_tags($magnet->xl),
|
||||
strip_tags($magnet->dn),
|
||||
@ -274,7 +281,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||
MAGNET_DEFAULT_PUBLIC,
|
||||
MAGNET_DEFAULT_COMMENTS,
|
||||
MAGNET_DEFAULT_SENSITIVE,
|
||||
MAGNET_DEFAULT_APPROVED,
|
||||
$user->approved ? true : MAGNET_DEFAULT_APPROVED,
|
||||
time()))
|
||||
{
|
||||
foreach ($magnet as $key => $value)
|
||||
|
@ -131,6 +131,13 @@ else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROV
|
||||
$response->message = _('Could not init user session');
|
||||
}
|
||||
|
||||
// Get user
|
||||
else if (!$user = $db->getUser($userId))
|
||||
{
|
||||
$response->success = false;
|
||||
$response->message = _('Could not init user info');
|
||||
}
|
||||
|
||||
// Init magnet
|
||||
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) ? (int) $_GET['magnetId'] : 0)) {
|
||||
|
||||
@ -139,7 +146,7 @@ else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) ? (int) $_GET['magne
|
||||
}
|
||||
|
||||
// Validate access
|
||||
else if (!($_SERVER['REMOTE_ADDR'] == $db->getUser($magnet->userId)->address || in_array($_SERVER['REMOTE_ADDR'], MODERATOR_IP_LIST))) {
|
||||
else if (!($user->address == $db->getUser($magnet->userId)->address || in_array($user->address, MODERATOR_IP_LIST))) {
|
||||
|
||||
$response->success = false;
|
||||
$response->message = _('You have no permissions to edit this magnet!');
|
||||
@ -152,7 +159,7 @@ else {
|
||||
if (!empty($_POST)) {
|
||||
|
||||
// Approve by moderation request
|
||||
if (isset($_POST['approved']) && in_array($_SERVER['REMOTE_ADDR'], MODERATOR_IP_LIST))
|
||||
if ($user->approved || (isset($_POST['approved']) && in_array($user->address, MODERATOR_IP_LIST)))
|
||||
{
|
||||
$db->updateMagnetApproved($magnet->magnetId, true, time());
|
||||
}
|
||||
@ -514,7 +521,7 @@ else {
|
||||
<?php } ?>
|
||||
<label class="margin-y-8" for="sensitive"><?php echo _('Sensitive') ?></label>
|
||||
</div>
|
||||
<?php if (in_array($_SERVER['REMOTE_ADDR'], MODERATOR_IP_LIST)) { ?>
|
||||
<?php if (in_array($user->address, MODERATOR_IP_LIST)) { ?>
|
||||
<div class="margin-b-8">
|
||||
<?php if (MAGNET_DEFAULT_APPROVED) { ?>
|
||||
<input type="checkbox" id="approved" name="approved" value="1" checked="checked" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user