瀏覽代碼

Added support of different (sub)classes of notifications in the "Notifications" tab on an object.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2884 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 11 年之前
父節點
當前提交
d181897e45
共有 1 個文件被更改,包括 19 次插入6 次删除
  1. 19 6
      application/cmdbabstract.class.inc.php

+ 19 - 6
application/cmdbabstract.class.inc.php

@@ -431,15 +431,28 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
 			}
 			if (count($aTriggers) > 0)
 			{
-				// Display notifications regarding the object
 				$iId = $this->GetKey();
 				$sTriggersList = implode(',', $aTriggers);
-				$oNotifSearch = DBObjectSearch::FromOQL("SELECT EventNotificationEmail AS Ev JOIN Trigger AS T ON Ev.trigger_id = T.id WHERE T.id IN ($sTriggersList) AND Ev.object_id = $iId");
-				$oNotifSet = new DBObjectSet($oNotifSearch);
-				$sCount = ($oNotifSet->Count() > 0) ? ' ('.$oNotifSet->Count().')' : '';
+				$aNotifSearches = array();
+				$iNotifsCount = 0;
+				$aNotificationClasses = MetaModel::EnumChildClasses('EventNotification', ENUM_CHILD_CLASSES_EXCLUDETOP);
+				foreach($aNotificationClasses as $sNotifClass)
+				{
+					$aNotifSearches[$sNotifClass] = DBObjectSearch::FromOQL("SELECT $sNotifClass AS Ev JOIN Trigger AS T ON Ev.trigger_id = T.id WHERE T.id IN ($sTriggersList) AND Ev.object_id = $iId");
+					$oNotifSet = new DBObjectSet($aNotifSearches[$sNotifClass]);
+					$iNotifsCount += $oNotifSet->Count();	
+				}
+				// Display notifications regarding the object: on block per subclass to have the intersting columns
+				$sCount = ($iNotifsCount > 0) ? ' ('.$iNotifsCount.')' : '';
 				$oPage->SetCurrentTab(Dict::S('UI:NotificationsTab').$sCount);
-				$oBlock = new DisplayBlock($oNotifSearch, 'list', false);
-				$oBlock->Display($oPage, 'notifications', array('menu' => false));
+				
+				foreach($aNotificationClasses as $sNotifClass)
+				{
+					
+					$oPage->p(MetaModel::GetClassIcon($sNotifClass, true).' '.MetaModel::GetName($sNotifClass));
+					$oBlock = new DisplayBlock($aNotifSearches[$sNotifClass], 'list', false);
+					$oBlock->Display($oPage, 'notifications_'.$sNotifClass, array('menu' => false));
+				}
 			}
 		}
 	}