check all photos

This commit is contained in:
themohooks 2024-07-20 23:50:52 +03:00
parent 1c2b512f55
commit 5688dc07b7
4 changed files with 44 additions and 7 deletions

View file

@ -0,0 +1,13 @@
<?php
namespace App\Controllers\Api\Images;
use \App\Services\{Auth, DB};
class CheckAll {
public function __construct() {
DB::query('UPDATE followers_notifications SET checked=1 WHERE follower_id=:id', array(':id'=>Auth::userid()));
header('Location: /fav_authors');
}
}
?>

View file

@ -9,6 +9,7 @@ use \App\Controllers\Api\Subscribe as SubscribeUser;
use \App\Controllers\Api\Images\{Upload};
use \App\Controllers\Api\Images\Rate as PhotoVote;
use \App\Controllers\Api\Images\Compress as PhotoCompress;
use \App\Controllers\Api\Images\CheckAll as PhotoCheckAll;
use \App\Controllers\Api\Images\Comments\Create as PhotoComment;
use \App\Controllers\Api\Images\Comments\Load as PhotoCommentLoad;
use \App\Controllers\Api\Images\Comments\Rate as PhotoCommentVote;
@ -51,6 +52,9 @@ class ApiController
public static function subscribeuser() {
return new SubscribeUser();
}
public static function checkallphotos() {
return new PhotoCheckAll();
}
}

View file

@ -47,6 +47,7 @@ class Routes
Router::get('/api/photo/compress', 'ApiController@photocompress');
Router::post('/api/photo/getcomments/$id', 'ApiController@photocommentload');
Router::get('/api/photo/vote', 'ApiController@photovote');
Router::get('/api/photo/checkall', 'ApiController@checkallphotos');
Router::get('/api/photo/comment/rate', 'ApiController@photocommentvote');
if ($user->i('admin') > 0) {
Router::any('/admin', 'AdminController@index');

View file

@ -22,24 +22,29 @@ use \App\Models\{User, Photo};
<td class="main">
<h1>Фотографии избранных авторов</h1>
<?php
$followimgs = DB::query('SELECT * FROM followers_notifications WHERE follower_id=:id AND checked=1', array(':id'=>Auth::userid()));
$followimgs = DB::query('SELECT * FROM followers_notifications WHERE follower_id=:id AND checked=0', array(':id'=>Auth::userid()));
if (count($followimgs) > 0) {
echo '<div class="mark-btn"><a class="button" href="#" onclick="return markAllRead(1)">Отметить все фотографии просмотренными</a></div>';
} else {
echo '<div class="p20" style="margin-bottom:15px" id="no_photos"><h4>Новых фотографий пока нет.</h4></div>';
}
foreach ($followimgs as $f) {
$author = new User($p['user_id']);
$author = new User($f['user_id']);
$p = new Photo($f['photo_id']);
echo ' <div class="p20p">
<table>
<tr>
<td class="pb_photo" id="p1941865"><a href="/photo/'.$f['photo_id'].'/" target="_blank" class="prw"><img class="f" src="'.$p['photourl'].'" alt="620 КБ">
<td class="pb_photo" id="p1941865"><a href="/photo/'.$f['photo_id'].'/" target="_blank" class="prw"><img class="f" src="'.$p->i('photourl').'" alt="620 КБ">
<div class="hpshade">
<div class="eye-icon">'.DB::query('SELECT COUNT(*) FROM photos_views WHERE photo_id=:id', array(':id'=>$p['id']))[0]['COUNT(*)'].'</div>
<div class="eye-icon">'.DB::query('SELECT COUNT(*) FROM photos_views WHERE photo_id=:id', array(':id'=>$f['photo_id']))[0]['COUNT(*)'].'</div>
</div>
</a></td>
<td class="pb_descr">
<p><b class="pw-place">'.htmlspecialchars($p['place']).'</b></p>
<span class="pw-descr">'.htmlspecialchars($p['postbody']).'</span>
<p class="sm"><b>'.Date::zmdate($p['timeupload']).'</b><br>Автор: <a href="/author/'.$author->i('user_id').'/">'.htmlspecialchars($author->i('username')).'</a></p>
<p><b class="pw-place">'.htmlspecialchars($p->i('place')).'</b></p>
<span class="pw-descr">'.htmlspecialchars($p->i('postbody')).'</span>
<p class="sm"><b>'.Date::zmdate($p->i('timeupload')).'</b><br>Автор: <a href="/author/'.$author->i('user_id').'/">'.htmlspecialchars($author->i('username')).'</a></p>
</td>
</tr>
</table>
@ -52,6 +57,20 @@ use \App\Models\{User, Photo};
</td>
</tr>
<script>
var ltime = 1721508467;
function markAllRead(force)
{
if (confirm('Действительно отметить эти фотографии просмотренными?'))
{
var ts = ltime+1;
window.location.href = '/api/photo/checkall';
}
return false;
}
</script>
<tr>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Footer.php'); ?>
</tr>