Introduced is_filled_array() + added some missing array initialization
Signed-off-by: Roland Haeder <roland@mxchange.org>
This commit is contained in:
parent
0510b31b7b
commit
0c1cc0d32f
4
boot.php
4
boot.php
|
@ -2149,3 +2149,7 @@ function argv($x) {
|
|||
|
||||
return '';
|
||||
}
|
||||
|
||||
function is_filled_array ($array) {
|
||||
return (is_array($array) && count($array) > 0);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ function message_init(&$a) {
|
|||
$tabs = '';
|
||||
|
||||
if ($a->argc >1 && is_numeric($a->argv[1])) {
|
||||
$tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl');
|
||||
$tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl');
|
||||
}
|
||||
|
||||
$new = array(
|
||||
|
@ -360,11 +360,13 @@ function message_content(&$a) {
|
|||
dbesc($myprofile)
|
||||
);
|
||||
|
||||
if(count($r)) $a->set_pager_total($r[0]['total']);
|
||||
if (is_filled_array($r)) {
|
||||
$a->set_pager_total($r[0]['total']);
|
||||
}
|
||||
|
||||
$r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']);
|
||||
|
||||
if(! count($r)) {
|
||||
if(! is_filled_array($r)) {
|
||||
info( t('No messages.') . EOL);
|
||||
return $o;
|
||||
}
|
||||
|
@ -542,7 +544,7 @@ function get_messages($user, $lstart, $lend) {
|
|||
);
|
||||
}
|
||||
|
||||
function render_messages($msg, $t) {
|
||||
function render_messages(array $msg, $t) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
|
25
mod/ping.php
25
mod/ping.php
|
@ -32,6 +32,8 @@ function ping_init(&$a) {
|
|||
$dislikes = array();
|
||||
$friends = array();
|
||||
$posts = array();
|
||||
$regs = array();
|
||||
$mails = array();
|
||||
|
||||
$home = 0;
|
||||
$network = 0;
|
||||
|
@ -49,7 +51,7 @@ function ping_init(&$a) {
|
|||
intval(local_user()), intval(local_user())
|
||||
);
|
||||
|
||||
if(count($r)) {
|
||||
if(is_filled_array($r)) {
|
||||
|
||||
$arr = array('items' => $r);
|
||||
call_hooks('network_ping', $arr);
|
||||
|
@ -116,8 +118,6 @@ function ping_init(&$a) {
|
|||
$intro = count($intros1) + count($intros2);
|
||||
$intros = $intros1+$intros2;
|
||||
|
||||
|
||||
|
||||
$myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
|
||||
$mails = q("SELECT * FROM `mail`
|
||||
WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
|
||||
|
@ -150,7 +150,7 @@ function ping_init(&$a) {
|
|||
dbesc(datetime_convert('UTC','UTC','now'))
|
||||
);
|
||||
|
||||
if($ev && count($ev)) {
|
||||
if(is_filled_array($ev)) {
|
||||
$all_events = intval($ev[0]['total']);
|
||||
|
||||
if($all_events) {
|
||||
|
@ -219,7 +219,7 @@ function ping_init(&$a) {
|
|||
<home>$home</home>\r\n";
|
||||
if ($register!=0) echo "<register>$register</register>";
|
||||
|
||||
if (count($groups_unseen)) {
|
||||
if ( is_filled_array($groups_unseen) ) {
|
||||
echo '<groups>';
|
||||
foreach ($groups_unseen as $it)
|
||||
if ($it['count'] > 0)
|
||||
|
@ -228,7 +228,7 @@ function ping_init(&$a) {
|
|||
echo "</groups>";
|
||||
}
|
||||
|
||||
if (count($forums_unseen)) {
|
||||
if ( is_filled_array($forums_unseen) ) {
|
||||
echo '<forums>';
|
||||
foreach ($forums_unseen as $it)
|
||||
if ($it['count'] > 0)
|
||||
|
@ -245,8 +245,8 @@ function ping_init(&$a) {
|
|||
<birthdays-today>$birthdays_today</birthdays-today>\r\n";
|
||||
|
||||
|
||||
if(count($notifs) && (! $sysnotify)) {
|
||||
foreach($notifs as $zz) {
|
||||
if (is_filled_array($notifs) && (! $sysnotify)) {
|
||||
foreach ($notifs as $zz) {
|
||||
if($zz['seen'] == 0)
|
||||
$sysnotify ++;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ function ping_init(&$a) {
|
|||
echo ' <notif count="'. ($sysnotify + $intro + $mail + $register) .'">';
|
||||
|
||||
// merge all notification types in one array
|
||||
if ($intro>0){
|
||||
if ( is_filled_array($intros) ) {
|
||||
foreach ($intros as $i) {
|
||||
$n = array(
|
||||
'href' => $a->get_baseurl().'/notifications/intros/'.$i['id'],
|
||||
|
@ -270,7 +270,7 @@ function ping_init(&$a) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($mail>0){
|
||||
if ( is_filled_array($mails) ) {
|
||||
foreach ($mails as $i) {
|
||||
$n = array(
|
||||
'href' => $a->get_baseurl().'/message/'.$i['id'],
|
||||
|
@ -285,7 +285,7 @@ function ping_init(&$a) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($register>0){
|
||||
if ( is_filled_array($regs) ) {
|
||||
foreach ($regs as $i) {
|
||||
$n = array(
|
||||
'href' => $a->get_baseurl().'/admin/users/',
|
||||
|
@ -299,6 +299,7 @@ function ping_init(&$a) {
|
|||
$notifs[] = $n;
|
||||
}
|
||||
}
|
||||
|
||||
// sort notifications by $[]['date']
|
||||
$sort_function = function($a, $b) {
|
||||
$adate = date($a['date']);
|
||||
|
@ -310,7 +311,7 @@ function ping_init(&$a) {
|
|||
};
|
||||
usort($notifs, $sort_function);
|
||||
|
||||
if(count($notifs)) {
|
||||
if( is_filled_array($notifs) ) {
|
||||
foreach($notifs as $n) {
|
||||
echo xmlize($n);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user