Commit 47157048 authored by Franco Fichtner's avatar Franco Fichtner

notices: properly address empty notices

parent 184b842a
...@@ -90,19 +90,22 @@ function get_notices($category = 'all') ...@@ -90,19 +90,22 @@ function get_notices($category = 'all')
{ {
if (file_exists('/tmp/notices')) { if (file_exists('/tmp/notices')) {
$queue = unserialize(file_get_contents('/tmp/notices')); $queue = unserialize(file_get_contents('/tmp/notices'));
if(!$queue) return false; if (!$queue) {
if($category != 'all') { return false;
}
if ($category != 'all') {
foreach($queue as $time => $notice) { foreach($queue as $time => $notice) {
if(strtolower($notice['category']) == strtolower($category)) if (strtolower($notice['category']) == strtolower($category)) {
$toreturn[$time] = $notice; $toreturn[$time] = $notice;
}
} }
return $toreturn; return $toreturn;
} else {
return $queue;
} }
} else {
return false; return $queue;
} }
return false;
} }
/****f* notices/close_notice /****f* notices/close_notice
...@@ -159,8 +162,14 @@ function close_notice($id) ...@@ -159,8 +162,14 @@ function close_notice($id)
* RESULT * RESULT
* prints notices to the GUI * prints notices to the GUI
******/ ******/
function print_notices($notices, $category = "all") { function print_notices($notices, $category = "all")
foreach($notices as $notice) { {
if (!is_array($notices) || count($notices) == 0) {
/* nothing to do */
return;
}
foreach ($notices as $notice) {
if($category != "all") { if($category != "all") {
if(in_array($notice['category'], $category)) $categories[] = $notice['category']; if(in_array($notice['category'], $category)) $categories[] = $notice['category'];
} else { } else {
...@@ -184,6 +193,7 @@ function print_notices($notices, $category = "all") { ...@@ -184,6 +193,7 @@ function print_notices($notices, $category = "all") {
} }
$toreturn .= "</ul></li></ul>"; $toreturn .= "</ul></li></ul>";
} }
return $toreturn; return $toreturn;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment