mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 14:40:09 +01:00
Userpage when logged in now working
Favorite list and pastes on userpage fixed.
This commit is contained in:
parent
c59e2e747b
commit
cd4bb33439
3 changed files with 18 additions and 16 deletions
|
@ -13,9 +13,9 @@
|
||||||
* GNU General Public License in GPL.txt for more details.
|
* GNU General Public License in GPL.txt for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getUserFavs(DatabaseHandle $conn, string $user_id) : array {
|
function getUserFavs(DatabaseHandle $conn, int $user_id) : array {
|
||||||
$query = $conn->prepare(
|
$query = $conn->prepare(
|
||||||
"SELECT pins.f_time, pastes.id, pastes.title, pastes.created_at, pastes.tagsys
|
"SELECT pins.f_time, pastes.id, pins.paste_id, pastes.title, pastes.created_at, pastes.tagsys, pastes.updated_at
|
||||||
FROM pins
|
FROM pins
|
||||||
INNER JOIN pastes ON pastes.id = pins.paste_id
|
INNER JOIN pastes ON pastes.id = pins.paste_id
|
||||||
WHERE pins.user_id = ?");
|
WHERE pins.user_id = ?");
|
||||||
|
@ -28,9 +28,9 @@ function checkFavorite(DatabaseHandle $conn, int $paste_id, int $user_id) : stri
|
||||||
$query->execute([$user_id, $paste_id]);
|
$query->execute([$user_id, $paste_id]);
|
||||||
|
|
||||||
if ($query->fetch()) {
|
if ($query->fetch()) {
|
||||||
return "<a href='#' id='favorite' class='iconn tool-iconn' data-fid='" . $paste_id . "'><i class='far fa-star fa-lg has-text-grey' title='Favourite'></i></a>";
|
return "<a href='#' id='favorite' class='icon tool-icon' data-fid='" . $paste_id . "'><i class='fas fa-star fa-lg has-text-grey' title='Favourite'></i></a>";
|
||||||
} else {
|
} else {
|
||||||
return "<a href='#' id='favorite' class='iconn tool-iconn' data-fid='" . $paste_id . "'><i class='fas fa-star fa-lg has-text-grey' title='Favourite'></i></a>";
|
return "<a href='#' id='favorite' class='icon tool-icon' data-fid='" . $paste_id . "'><i class='far fa-star fa-lg has-text-grey' title='Favourite'></i></a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ $protocol = paste_protocol();
|
||||||
<td>
|
<td>
|
||||||
<a href="' . $protocol . $baseurl . '/' . $p_link . '" title="' . $title . '">' . ($title) . '</a>
|
<a href="' . $protocol . $baseurl . '/' . $p_link . '" title="' . $title . '">' . ($title) . '</a>
|
||||||
</td>
|
</td>
|
||||||
<td data-sort="' . $p_date . '" class="td-center">
|
<td data-sort="' . $p_date->format('U') . '" class="td-center">
|
||||||
<span>' . $p_dateui . '</span>
|
<span>' . $p_dateui . '</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="td-center">
|
<td class="td-center">
|
||||||
|
@ -264,21 +264,22 @@ $protocol = paste_protocol();
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$res = getUserFavs($conn, $profile_username);
|
foreach ($profile_favs as $index => $row) {
|
||||||
foreach ($res as $index => $row) {
|
|
||||||
$ftitle = Trim($row['title']);
|
$ftitle = Trim($row['title']);
|
||||||
$f_id = Trim($row['f_paste']);
|
$f_id = Trim($row['paste_id']);
|
||||||
$f_date = Trim($row['f_time']);
|
$f_date = new DateTime($row['f_time']);
|
||||||
$Recent_update = Trim($row['now_time']);
|
$f_dateui = $f_date->format("d F Y");
|
||||||
|
$Recent_update = new DateTime($row['updated_at']);
|
||||||
|
$Recent_update_u = date_format($Recent_update,'U');
|
||||||
$f_tags = Trim($row['tagsys']);
|
$f_tags = Trim($row['tagsys']);
|
||||||
$ftagArray = explode(',', $f_tags);
|
$ftagArray = explode(',', $f_tags);
|
||||||
$ftagArray = array_filter($ftagArray);
|
$ftagArray = array_filter($ftagArray);
|
||||||
$p_link = ($mod_rewrite == '1') ? "$f_id" : "paste.php?favdel=$fu_id";
|
//$p_link = ($mod_rewrite == '1') ? "$f_id" : "paste.php?favdel=$fu_id";
|
||||||
$f_delete_link = ($mod_rewrite == '1') ? "user.php?favdel&user=$profile_username&fid=$fu_id" : "user.php?favdel&user=$profile_username&fid=$fu_id";
|
//$f_delete_link = ($mod_rewrite == '1') ? "user.php?favdel&user=$profile_username&fid=$f_id" : "user.php?favdel&user=$profile_username&fid=$f_id";
|
||||||
$title = truncate($title, 20, 50);
|
$title = truncate($title, 20, 50);
|
||||||
$current_time = time();
|
$current_time = time();
|
||||||
$past = strtotime('-2 day', $current_time);
|
$past = strtotime('-2 day', $current_time);
|
||||||
if ($past <= $Recent_update && $Recent_update <= $current_time) {
|
if ($past <= $Recent_update_u && $Recent_update_u <= $current_time) {
|
||||||
$updatenote = "<i class='far fa-check-square fa-lg' aria-hidden='true'></i>";
|
$updatenote = "<i class='far fa-check-square fa-lg' aria-hidden='true'></i>";
|
||||||
} else {
|
} else {
|
||||||
$updatenote = "<i class='far fa-minus-square fa-lg' aria-hidden='true'></i>";
|
$updatenote = "<i class='far fa-minus-square fa-lg' aria-hidden='true'></i>";
|
||||||
|
@ -288,11 +289,11 @@ $protocol = paste_protocol();
|
||||||
<td>
|
<td>
|
||||||
<a href="' . $protocol . $baseurl . '/' . $p_link . '" title="' . $ftitle . '">' . ($ftitle) . '</a>
|
<a href="' . $protocol . $baseurl . '/' . $p_link . '" title="' . $ftitle . '">' . ($ftitle) . '</a>
|
||||||
</td>
|
</td>
|
||||||
<td data-sort="' . $f_date . '" class="td-left">
|
<td data-sort="' . $f_dateui . '" class="td-left">
|
||||||
<span>' . date("d F Y", $f_date) . '</span>
|
<span>' . date_format($f_date,'U') . '</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="td-center">
|
<td class="td-center">
|
||||||
<span style="display:none;">' . $Recent_update . '</span>
|
<span style="display:none;">' . $Recent_update_u . '</span>
|
||||||
' . $updatenote . '
|
' . $updatenote . '
|
||||||
</td>
|
</td>
|
||||||
<td class="td-left">';
|
<td class="td-left">';
|
||||||
|
|
1
user.php
1
user.php
|
@ -90,6 +90,7 @@ $profile_total_paste_views = intval($query->fetch(PDO::FETCH_NUM)[0]);
|
||||||
$profile_join_date = $profile_info['date'];
|
$profile_join_date = $profile_info['date'];
|
||||||
|
|
||||||
$profile_pastes = getUserPastes($conn, $profile_info['id']);
|
$profile_pastes = getUserPastes($conn, $profile_info['id']);
|
||||||
|
$profile_favs = getUserFavs($conn, $profile_info['id']);
|
||||||
$is_current_user = ($current_user !== null) && ($profile_info['id'] == $current_user->user_id);
|
$is_current_user = ($current_user !== null) && ($profile_info['id'] == $current_user->user_id);
|
||||||
|
|
||||||
updatePageViews($conn);
|
updatePageViews($conn);
|
||||||
|
|
Loading…
Add table
Reference in a new issue