[icinga-checkins] icinga.org: icinga-web/r1.6: * Fixing deleting custom cronks (fixes #2155)

git at icinga.org git at icinga.org
Tue Jan 31 13:51:40 CET 2012


Module: icinga-web
Branch: r1.6
Commit: 8605243b13c4cd82afa585c1d318664529f9fcb3
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=8605243b13c4cd82afa585c1d318664529f9fcb3

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Jan 31 13:27:37 2012 +0100

* Fixing deleting custom cronks (fixes #2155)

---

 .../models/Provider/CronksDataModel.class.php      |   26 ++++++++++----------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/app/modules/Cronks/models/Provider/CronksDataModel.class.php b/app/modules/Cronks/models/Provider/CronksDataModel.class.php
index 54edbd6..d8d412a 100644
--- a/app/modules/Cronks/models/Provider/CronksDataModel.class.php
+++ b/app/modules/Cronks/models/Provider/CronksDataModel.class.php
@@ -561,7 +561,7 @@ class Cronks_Provider_CronksDataModel extends CronksBaseModel implements AgaviIS
         $q = AppKitDoctrineUtil::createQuery()
              ->select('c.*')
              ->from('Cronk c')
-             ->where('c.cronk_uid=? and c.cronk_name=?', array($cronkid, $cronkname));
+             ->where('c.cronk_uid=?', array($cronkid));
 
         if ($own==true) {
             $q->andWhere('c.cronk_user_id=?', array($this->user->user_id));
@@ -571,24 +571,24 @@ class Cronks_Provider_CronksDataModel extends CronksBaseModel implements AgaviIS
 
         if ($cronk instanceof Cronk && $cronk->cronk_id > 0) {
             AppKitDoctrineUtil::getConnection()->beginTransaction();
-            $cronk->CronkCategoryCronk->delete();
-            $cronk->CronkPrincipalCronk->delete();
-            $cronk->save();
-            AppKitDoctrineUtil::getConnection()->commit();
             
-            // bad but helps doctrine to work
-            // with oracle ;-)
-            try {
-                $cronk->CronkPrincipalCronk->delete();
-            } catch (Exception $e) {
-                // BYPASS
-            }
+            $params = array($cronk->cronk_id);
+            
+            AppKitDoctrineUtil::createQuery()->delete('CronkCategoryCronk c')
+            ->andWhere('c.ccc_cronk_id=?')
+            ->execute($params);
+            
+            AppKitDoctrineUtil::createQuery()->delete('CronkPrincipalCronk c')
+            ->andWhere('c.cpc_cronk_id=?')
+            ->execute($params);
+            
+            AppKitDoctrineUtil::getConnection()->commit();
             
             $cronk->delete();
 
             return true;
         } else {
-            throw new AppKitModelException('Cronk not found: '. $cronkid);
+            throw new AppKitModelException('Could not delete cronk: '. $cronkid);
         }
     }
 





More information about the icinga-checkins mailing list