From c205d9f80d4e057d45871a26ac0366ff91e4934f Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 25 May 2016 11:53:01 +0200 Subject: [PATCH] IcingaConfig: allow to loadByActivityChecksum --- library/Director/IcingaConfig/IcingaConfig.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/library/Director/IcingaConfig/IcingaConfig.php b/library/Director/IcingaConfig/IcingaConfig.php index 58a40d93..22fa7161 100644 --- a/library/Director/IcingaConfig/IcingaConfig.php +++ b/library/Director/IcingaConfig/IcingaConfig.php @@ -132,6 +132,24 @@ class IcingaConfig return $config; } + public static function loadByActivityChecksum($checksum, Db $connection) + { + $db = $connection->getDbAdapter(); + $query = $db->select()->from( + array('c' => self::$table), + array('checksum' => 'c.checksum') + )->join( + array('l' => 'director_activity_log'), + 'l.checksum = c.last_activity_checksum', + array() + )->where( + 'last_activity_checksum = ?', + $connection->quoteBinary(Util::hex2binary($checksum)) + )->order('l.id DESC')->limit(1); + + return self::load($db->fetchOne($query), $connection); + } + public static function generate(Db $connection) { $config = new static($connection);