[icinga-checkins] icinga.org: icingaweb2-module-director/fiddle/mfrosch: IcingaConfig: allow to loadByActivityChecksum

git at icinga.org git at icinga.org
Tue Jun 7 15:59:14 CEST 2016


Module: icingaweb2-module-director
Branch: fiddle/mfrosch
Commit: c205d9f80d4e057d45871a26ac0366ff91e4934f
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=c205d9f80d4e057d45871a26ac0366ff91e4934f

Author: Thomas Gelf <thomas at gelf.net>
Date:   Wed May 25 11:53:01 2016 +0200

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 58a40d9..22fa716 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);



More information about the icinga-checkins mailing list