From 9d9b47309a00fb76c5dc05194803d56a8448355d Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Wed, 9 Oct 2024 21:45:05 +0300 Subject: [PATCH] permissions for photo --- app/Controllers/Api/Images/Upload.php | 23 +++++++++++++++++++++-- views/pages/Forum/Index.php | 0 views/pages/Photo.php | 12 +++++++++--- views/pages/Profile/LK/Index.php | 1 + views/pages/Profile/UploadPhoto.php | 9 ++++----- 5 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 views/pages/Forum/Index.php diff --git a/app/Controllers/Api/Images/Upload.php b/app/Controllers/Api/Images/Upload.php index b63208c..fe4ea99 100644 --- a/app/Controllers/Api/Images/Upload.php +++ b/app/Controllers/Api/Images/Upload.php @@ -16,6 +16,10 @@ class Upload static $photourl; static $vidpreview; static $videourl; + static $comments = 'allowed'; + static $rating = 'allowed'; + static $showtop = 'allowed'; + static $subsnotify = 'allowed'; public static function create($postbody, $content, $exif) { @@ -30,7 +34,7 @@ class Upload $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)); - if ($moderated === 1) { + if (($moderated === 1) && (self::$subsnotify != 'disabled')) { $followers = DB::query('SELECT * FROM followers WHERE user_id=:uid', array(':uid' => Auth::userid())); 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'])); @@ -130,6 +134,18 @@ class Upload $_POST['lat'] = 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) { $content = Json::return( array( @@ -138,7 +154,10 @@ class Upload 'copyright' => $_POST['license'], 'comment' => $_POST['descr'], 'lat' => $_POST['lat'], - 'lng' => $_POST['lng'] + 'lng' => $_POST['lng'], + 'comments' => self::$comments, + 'rating' => self::$rating, + 'showtop' => self::$showtop, ) ); if (explode('/', $type)[0] === 'video') { diff --git a/views/pages/Forum/Index.php b/views/pages/Forum/Index.php new file mode 100644 index 0000000..e69de29 diff --git a/views/pages/Photo.php b/views/pages/Photo.php index b47c06f..31db6fa 100644 --- a/views/pages/Photo.php +++ b/views/pages/Photo.php @@ -225,7 +225,7 @@ if ($photo->i('id') !== null) { - i('moderated') === 1) { ?> + i('moderated') === 1 && json_decode($c['content'], true)['rating'] != 'disabled') { ?>

Оценка

@@ -369,7 +369,7 @@ if ($photo->i('id') !== null) { $commcount++; } } - ?> + if (json_decode($c['content'], true)['comments'] != 'disabled') { ?>
0) { ?> @@ -410,7 +410,13 @@ if ($photo->i('id') !== null) {
- + +
+ +

Комментарии отключены пользователем или по усмотрению Администрации.

+ + + diff --git a/views/pages/Profile/LK/Index.php b/views/pages/Profile/LK/Index.php index 115cc9b..13dc1b4 100644 --- a/views/pages/Profile/LK/Index.php +++ b/views/pages/Profile/LK/Index.php @@ -24,6 +24,7 @@ $user = new User(Auth::userid());

Количество ваших фотографий на сайте: Auth::userid()))[0]['COUNT(*)']?>

+

Всего фотографий в очереди на публикацию:


- - + @@ -874,7 +873,7 @@ $user = new User(Auth::userid()); - + @@ -886,7 +885,7 @@ $user = new User(Auth::userid()); - + @@ -898,7 +897,7 @@ $user = new User(Auth::userid()); - +