permissions for photo

This commit is contained in:
themohooks 2024-10-09 21:45:05 +03:00
parent 3135464f7a
commit 9d9b47309a
5 changed files with 35 additions and 10 deletions

View file

@ -16,6 +16,10 @@ class Upload
static $photourl; static $photourl;
static $vidpreview; static $vidpreview;
static $videourl; static $videourl;
static $comments = 'allowed';
static $rating = 'allowed';
static $showtop = 'allowed';
static $subsnotify = 'allowed';
public static function create($postbody, $content, $exif) public static function create($postbody, $content, $exif)
{ {
@ -30,7 +34,7 @@ class Upload
$moderated = 1; $moderated = 1;
} }
DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :exif, 0, :moderated, :place, 0, :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)); DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :exif, 0, :moderated, :place, 0, :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));
if ($moderated === 1) { if (($moderated === 1) && (self::$subsnotify != 'disabled')) {
$followers = DB::query('SELECT * FROM followers WHERE user_id=:uid', array(':uid' => Auth::userid())); $followers = DB::query('SELECT * FROM followers WHERE user_id=:uid', array(':uid' => Auth::userid()));
foreach ($followers as $f) { foreach ($followers as $f) {
DB::query('INSERT INTO followers_notifications VALUES (\'0\', :uid, :fid, :pid, 0)', array(':uid' => Auth::userid(), ':fid' => $f['follower_id'], ':pid' => DB::query('SELECT * FROM photos ORDER BY id DESC LIMIT 1')[0]['id'])); DB::query('INSERT INTO followers_notifications VALUES (\'0\', :uid, :fid, :pid, 0)', array(':uid' => Auth::userid(), ':fid' => $f['follower_id'], ':pid' => DB::query('SELECT * FROM photos ORDER BY id DESC LIMIT 1')[0]['id']));
@ -130,6 +134,18 @@ class Upload
$_POST['lat'] = null; $_POST['lat'] = null;
$_POST['lng'] = null; $_POST['lng'] = null;
} }
if ($_POST['disablecomments'] === 1) {
self::$comments = 'disabled';
}
if ($_POST['disablerating'] === 1) {
self::$rating = 'disabled';
}
if ($_POST['disableshowtop'] === 1) {
self::$showtop = 'disabled';
}
if ($_POST['disablesubsnotify'] === 1) {
self::$subsnotify = 'disabled';
}
if ($upload->getType() !== null) { if ($upload->getType() !== null) {
$content = Json::return( $content = Json::return(
array( array(
@ -138,7 +154,10 @@ class Upload
'copyright' => $_POST['license'], 'copyright' => $_POST['license'],
'comment' => $_POST['descr'], 'comment' => $_POST['descr'],
'lat' => $_POST['lat'], 'lat' => $_POST['lat'],
'lng' => $_POST['lng'] 'lng' => $_POST['lng'],
'comments' => self::$comments,
'rating' => self::$rating,
'showtop' => self::$showtop,
) )
); );
if (explode('/', $type)[0] === 'video') { if (explode('/', $type)[0] === 'video') {

View file

View file

@ -225,7 +225,7 @@ if ($photo->i('id') !== null) {
</div> </div>
</div> </div>
</div> </div>
<?php if ($photo->i('moderated') === 1) { ?> <?php if ($photo->i('moderated') === 1 && json_decode($c['content'], true)['rating'] != 'disabled') { ?>
<div class="p20a" id="pp-item-vote"> <div class="p20a" id="pp-item-vote">
<h4 class="pp-item-header">Оценка</h4> <h4 class="pp-item-header">Оценка</h4>
<div class="sm"> <div class="sm">
@ -369,7 +369,7 @@ if ($photo->i('id') !== null) {
$commcount++; $commcount++;
} }
} }
?> if (json_decode($c['content'], true)['comments'] != 'disabled') { ?>
<div class="p0" id="pp-item-comments"> <div class="p0" id="pp-item-comments">
<?php <?php
if ($commcount > 0) { ?> if ($commcount > 0) { ?>
@ -410,7 +410,13 @@ if ($photo->i('id') !== null) {
</div> </div>
</div> </div>
<?php } ?> <?php } else { ?>
<div class="p0" id="pp-item-comments">
<center><p>Комментарии отключены пользователем или по усмотрению Администрации.</p></center></div>
<?php } } ?>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View file

@ -24,6 +24,7 @@ $user = new User(Auth::userid());
<p> <p>
Количество ваших фотографий на сайте: <b><?=DB::query('SELECT COUNT(*) FROM photos WHERE user_id=:uid AND moderated=1', array(':uid'=>Auth::userid()))[0]['COUNT(*)']?></b></p> Количество ваших фотографий на сайте: <b><?=DB::query('SELECT COUNT(*) FROM photos WHERE user_id=:uid AND moderated=1', array(':uid'=>Auth::userid()))[0]['COUNT(*)']?></b></p>
<p> <p>
<p>Всего фотографий в очереди на публикацию: <b><?=DB::query('SELECT COUNT(*) FROM photos WHERE moderated=0')[0]['COUNT(*)']?></b></p><br>
<?php <?php
if (NGALLERY['root']['photo']['uploadindex']['enabled'] === true) { if (NGALLERY['root']['photo']['uploadindex']['enabled'] === true) {

View file

@ -860,8 +860,7 @@ $user = new User(Auth::userid());
<tr> <tr>
<td class="lcol"></td> <td class="lcol"></td>
<td style="padding:7px 2px"> <td style="padding:7px 2px">
<input type="checkbox" name="nomap" id="nomap" value="1" onclick="switchMap()"> <label for="nomap">Отключить комментарии</label> <input type="checkbox" name="disablecomments" id="nomap" value="1" onclick="switchMap()"> <label for="nomap">Отключить комментарии</label>
</td> </td>
</tr> </tr>
@ -874,7 +873,7 @@ $user = new User(Auth::userid());
<tr> <tr>
<td class="lcol"></td> <td class="lcol"></td>
<td style="padding:7px 2px"> <td style="padding:7px 2px">
<input type="checkbox" name="nomap" id="nomap" value="1" onclick="switchMap()"> <label for="nomap">Отключить оценку фотографии</label> <input type="checkbox" name="disablerating" id="nomap" value="1" onclick="switchMap()"> <label for="nomap">Отключить оценку фотографии</label>
</td> </td>
</tr> </tr>
@ -886,7 +885,7 @@ $user = new User(Auth::userid());
<tr> <tr>
<td class="lcol"></td> <td class="lcol"></td>
<td style="padding:7px 2px"> <td style="padding:7px 2px">
<input type="checkbox" name="nomap" id="nomap" value="1" onclick="switchMap()"> <label for="nomap">Не продвигать в общем топе</label> <input type="checkbox" name="disableshowtop" id="nomap" value="1" onclick="switchMap()"> <label for="nomap">Не продвигать в общем топе</label>
</td> </td>
</tr> </tr>
@ -898,7 +897,7 @@ $user = new User(Auth::userid());
<tr> <tr>
<td class="lcol"></td> <td class="lcol"></td>
<td style="padding:7px 2px"> <td style="padding:7px 2px">
<input type="checkbox" name="nomap" id="nomap" value="1" onclick="switchMap()"> <label for="nomap">Не уведомлять подписчиков о новом медиа</label> <input type="checkbox" name="disablesubsnotify" id="nomap" value="1" onclick="switchMap()"> <label for="nomap">Не уведомлять подписчиков о новом медиа</label>
</td> </td>
</tr> </tr>
<tr> <tr>