MastodonHelp/web/site/mustard/include/notifs.php

44 lines
1.3 KiB
PHP
Raw Normal View History

2020-04-17 23:57:57 +02:00
<?php
function notifs(&$link) {
$chunksize=20; // questo deve essere settato paro-paro in notifsh.php
$i=0;
$notifs = array();
$notif_divs='<div id="notifc">'.N;
$notif_divs.='<div id="notifs" onscroll="morenotifs();">'.N;
2020-04-17 23:57:57 +02:00
$unreadnotifs=false;
$res=mysqli_query($link,'SELECT * FROM Notifications ORDER BY Microtime DESC')
or muoribene(mysqli_error($link),true);
while ($row=mysqli_fetch_assoc($res)) {
2020-05-21 16:19:13 +02:00
$notifs[]=$row;
2020-04-17 23:57:57 +02:00
if ($row['Seen']==0) {
$unreadnotifs=true;
$notifclass='notifunseen';
} else {
$notifclass='notifseen';
}
$i++;
if ($i<=$chunksize) {
if ($i==1) $lastmicrotime=$row['Microtime'];
2022-02-12 10:29:35 +01:00
$notif_divs.='<div id="notif-'.$row['ID'].'" class="'.$notifclass.'" onclick="markread(this)">'.strftime('%d/%m/%y %T',round($row['Microtime'])).': '.$row['Notification'].'</div>'.N;
2020-04-17 23:57:57 +02:00
}
}
$notif_divs.='</div>'.N;
$notif_divs.='<div id="notifa"><a href="notifs.php">Vedi tutte le notifiche</a></div>'.N;
$notif_divs.='</div>'.N;
2020-04-17 23:57:57 +02:00
if ($unreadnotifs) {
$imgoff='imgs/bell_act_off.svg';
$imgon='imgs/bell_act_on.svg';
} else {
$imgoff='imgs/bell_off.svg';
$imgon='imgs/bell_on.svg';
}
return(array(
'notifs'=>$notifs,
'div'=>$notif_divs,
2020-04-17 23:57:57 +02:00
'imgoff'=>$imgoff,
'imgon'=>$imgon,
'lastmicrotime'=>$lastmicrotime,
'chunksize'=>$chunksize));
}
?>