From 57a0ee0ca949d87f81f9070d6002f0cfd74058a9 Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Sat, 22 Oct 2011 13:26:44 +0000 Subject: [PATCH] Remove all lambda functions This is an addition to commit 65dc6ce. There was still a lamba function left in the server model. --- application/models/server.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/application/models/server.php b/application/models/server.php index de34e6b..8459163 100644 --- a/application/models/server.php +++ b/application/models/server.php @@ -27,6 +27,17 @@ */ class Server extends CI_Model { + /** + * Add a field 'available' to the server. + * + * This field will be true if the last heartbeat was received less + * than 2 minutes ago. + */ + private function addAvailability($var) { + $var['available'] = time_diff($var['last_update'], mysql_now()) < 120 ? true : false; + return $var; + } + /** * Creates a new server. * @@ -59,10 +70,7 @@ class Server extends CI_Model { */ public function getAll() { $servers = $this->db->get('servers')->result_array(); - return array_map(function($var) { - $var['available'] = time_diff($var['last_update'], mysql_now()) < 120 ? true : false; - return $var; - }, $servers); + return array_map(array($this, "addAvailability"), $servers); } /**