if server setting premoderation = true, or user don't has direct upload, send photo to moderation

This commit is contained in:
themohooks 2024-07-17 03:27:03 +03:00
parent 9c2d9c622e
commit ef1aa4b9c2
2 changed files with 17 additions and 2 deletions

View file

@ -17,7 +17,17 @@ class Upload
public static function create($postbody, $content, $exif) public static function create($postbody, $content, $exif)
{ {
DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :exif, 0, :place, :content)', array(':postbody' => $postbody, ':userid' => Auth::userid(), ':time' => mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']), ':content' => $content, ':photourl' => self::$photourl, ':exif' => $exif, ':place' => $_POST['place'], ':timeup'=>time())); $user = new \App\Models\User(Auth::userid());
if (NGALLERY['root']['photo']['upload']['premoderation'] === true) {
if ($user->content('premoderation') === true) {
$moderated = 1;
} else {
$moderated = 0;
}
} else {
$moderated = 1;
}
DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :exif, 0, :moderated, :place, :content)', array(':postbody' => $postbody, ':userid' => Auth::userid(), ':time' => mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']), ':content' => $content, ':photourl' => self::$photourl, ':exif' => $exif, ':place' => $_POST['place'], ':timeup'=>time(), ':moderated'=>$moderated));
echo json_encode( echo json_encode(
array( array(
'id' => DB::query('SELECT id FROM photos ORDER BY id DESC LIMIT 1')[0]['id'], 'id' => DB::query('SELECT id FROM photos ORDER BY id DESC LIMIT 1')[0]['id'],

View file

@ -47,8 +47,13 @@ use \App\Models\User;
<?php <?php
$photos = DB::query('SELECT * FROM photos WHERE user_id=:uid ORDER BY id DESC', array(':uid'=>Auth::userid())); $photos = DB::query('SELECT * FROM photos WHERE user_id=:uid ORDER BY id DESC', array(':uid'=>Auth::userid()));
foreach ($photos as $p) { foreach ($photos as $p) {
if ($p['moderated'] === 0) {
$color = 's0';
} else {
$color = 's12';
}
$author = new User($p['user_id']); $author = new User($p['user_id']);
echo ' <tr class="s12"> echo ' <tr class="'.$color.'">
<td class="pb-photo pb_photo"> <td class="pb-photo pb_photo">
<a href="/photo/'.$p['id'].'/" target="_blank" class="prw"> <a href="/photo/'.$p['id'].'/" target="_blank" class="prw">
<img src="'.$p['photourl'].'" class="f"> <img src="'.$p['photourl'].'" class="f">