include: notifs: Ritorna un array di notifiche.

* web/mustard/include/notifs.php (notifs): Rinomina a notif_divs,
(notifs): Ora è un array di notifiche.
This commit is contained in:
paul 2020-05-15 18:44:48 +02:00 committed by Giacomo Leidi
parent a33ac2d130
commit 9c1a3f4068

View file

@ -2,12 +2,14 @@
function notifs(&$link) { function notifs(&$link) {
$chunksize=20; // questo deve essere settato paro-paro in notifsh.php $chunksize=20; // questo deve essere settato paro-paro in notifsh.php
$i=0; $i=0;
$notifs='<div id="notifc">'.N; $notifs = array();
$notifs.='<div id="notifs" onscroll="morenotifs();">'.N; $notif_divs='<div id="notifc">'.N;
$notif_divs.='<div id="notifs" onscroll="morenotifs();">'.N;
$unreadnotifs=false; $unreadnotifs=false;
$res=mysqli_query($link,'SELECT * FROM Notifications ORDER BY Microtime DESC') $res=mysqli_query($link,'SELECT * FROM Notifications ORDER BY Microtime DESC')
or muoribene(mysqli_error($link),true); or muoribene(mysqli_error($link),true);
while ($row=mysqli_fetch_assoc($res)) { while ($row=mysqli_fetch_assoc($res)) {
array_push($notifs, $row);
if ($row['Seen']==0) { if ($row['Seen']==0) {
$unreadnotifs=true; $unreadnotifs=true;
$notifclass='notifunseen'; $notifclass='notifunseen';
@ -17,12 +19,12 @@ function notifs(&$link) {
$i++; $i++;
if ($i<=$chunksize) { if ($i<=$chunksize) {
if ($i==1) $lastmicrotime=$row['Microtime']; if ($i==1) $lastmicrotime=$row['Microtime'];
$notifs.='<div id="notif-'.$row['ID'].'" class="'.$notifclass.'" onclick="markread(this)">'.strftime('%d/%m/%y %T',$row['Microtime']).': '.$row['Notification'].'</div>'.N; $notif_divs.='<div id="notif-'.$row['ID'].'" class="'.$notifclass.'" onclick="markread(this)">'.strftime('%d/%m/%y %T',$row['Microtime']).': '.$row['Notification'].'</div>'.N;
} }
} }
$notifs.='</div>'.N; $notif_divs.='</div>'.N;
$notifs.='<div id="notifa"><a href="notifs.php">Vedi tutte le notifiche</a></div>'.N; $notif_divs.='<div id="notifa"><a href="notifs.php">Vedi tutte le notifiche</a></div>'.N;
$notifs.='</div>'.N; $notif_divs.='</div>'.N;
if ($unreadnotifs) { if ($unreadnotifs) {
$imgoff='imgs/bell_act_off.svg'; $imgoff='imgs/bell_act_off.svg';
$imgon='imgs/bell_act_on.svg'; $imgon='imgs/bell_act_on.svg';
@ -31,7 +33,8 @@ function notifs(&$link) {
$imgon='imgs/bell_on.svg'; $imgon='imgs/bell_on.svg';
} }
return(array( return(array(
'div'=>$notifs, 'notifs'=>$notifs,
'div'=>$notif_divs,
'imgoff'=>$imgoff, 'imgoff'=>$imgoff,
'imgon'=>$imgon, 'imgon'=>$imgon,
'lastmicrotime'=>$lastmicrotime, 'lastmicrotime'=>$lastmicrotime,