Browse Source

#842 Internal: recode the notifications page to allow several types of actions

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2981 a333f486-631f-4898-b8df-5754b55c2be0
romainq 11 years ago
parent
commit
5c00dd860c

+ 0 - 20
application/templates/notifications_menu.html

@@ -1,20 +0,0 @@
-<div class="page_header" style="padding:0.5em;">
-<h1><itopstring>UI:NotificationsMenu:Title</itopstring></h1>
-</div>
-<itoptoggle name="UI:NotificationsMenu:Help" open="true">
-<div style="padding: 1em; font-size:10pt;background:#E8F3CF;margin-top: 0.25em;">
-<img src="../images/bell.png" style="margin-top: -60px; margin-right: 10px; float: right;">
-<itopstring>UI:NotificationsMenu:HelpContent</itopstring>
-</div>
-</itoptoggle>
-<p>&nbsp;</p>
-<itoptabs>
-	<itoptab name="UI:NotificationsMenu:Triggers">
-		<h2><itopstring>UI:NotificationsMenu:AvailableTriggers</itopstring></h2>
-		<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql">SELECT Trigger</itopblock>
-	</itoptab>
-	<itoptab name="UI:NotificationsMenu:Actions">
-		<h2><itopstring>UI:NotificationsMenu:AvailableActions</itopstring></h2>
-		<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql">SELECT Action</itopblock>
-	</itoptab>
-</itoptabs>

+ 1 - 1
datamodels/1.x/itop-welcome-itil/main.itop-welcome-itil.php

@@ -53,7 +53,7 @@ class ItopWelcome extends ModuleHandlerAPI
 			$oAdminMenu = new MenuGroup('AdminTools', 80 /* fRank */);
 			$oAdminMenu = new MenuGroup('AdminTools', 80 /* fRank */);
 			new OQLMenuNode('UserAccountsMenu', 'SELECT User', $oAdminMenu->GetIndex(), 1 /* fRank */);
 			new OQLMenuNode('UserAccountsMenu', 'SELECT User', $oAdminMenu->GetIndex(), 1 /* fRank */);
 			new OQLMenuNode('ProfilesMenu', 'SELECT URP_Profiles', $oAdminMenu->GetIndex(), 2 /* fRank */);
 			new OQLMenuNode('ProfilesMenu', 'SELECT URP_Profiles', $oAdminMenu->GetIndex(), 2 /* fRank */);
-			new TemplateMenuNode('NotificationsMenu', APPROOT.'application/templates/notifications_menu.html', $oAdminMenu->GetIndex(), 3 /* fRank */);
+			new WebPageMenuNode('NotificationsMenu', utils::GetAbsoluteUrlAppRoot().'pages/notifications.php', $oAdminMenu->GetIndex(), 3 /* fRank */);
 			new OQLMenuNode('AuditCategories', 'SELECT AuditCategory', $oAdminMenu->GetIndex(), 4 /* fRank */);
 			new OQLMenuNode('AuditCategories', 'SELECT AuditCategory', $oAdminMenu->GetIndex(), 4 /* fRank */);
 			new WebPageMenuNode('RunQueriesMenu', utils::GetAbsoluteUrlAppRoot().'pages/run_query.php', $oAdminMenu->GetIndex(), 8 /* fRank */);
 			new WebPageMenuNode('RunQueriesMenu', utils::GetAbsoluteUrlAppRoot().'pages/run_query.php', $oAdminMenu->GetIndex(), 8 /* fRank */);
 			new OQLMenuNode('QueryMenu', 'SELECT Query', $oAdminMenu->GetIndex(), 8.5 /* fRank */);
 			new OQLMenuNode('QueryMenu', 'SELECT Query', $oAdminMenu->GetIndex(), 8.5 /* fRank */);

+ 1 - 1
datamodels/2.x/itop-welcome-itil/main.itop-welcome-itil.php

@@ -56,7 +56,7 @@ class ItopWelcome extends ModuleHandlerAPI
 			$oAdminMenu = new MenuGroup('AdminTools', 80 /* fRank */);
 			$oAdminMenu = new MenuGroup('AdminTools', 80 /* fRank */);
 			new OQLMenuNode('UserAccountsMenu', 'SELECT User', $oAdminMenu->GetIndex(), 1 /* fRank */,true);
 			new OQLMenuNode('UserAccountsMenu', 'SELECT User', $oAdminMenu->GetIndex(), 1 /* fRank */,true);
 			new OQLMenuNode('ProfilesMenu', 'SELECT URP_Profiles', $oAdminMenu->GetIndex(), 2 /* fRank */);
 			new OQLMenuNode('ProfilesMenu', 'SELECT URP_Profiles', $oAdminMenu->GetIndex(), 2 /* fRank */);
-			new TemplateMenuNode('NotificationsMenu', APPROOT.'application/templates/notifications_menu.html', $oAdminMenu->GetIndex(), 3 /* fRank */);
+			new WebPageMenuNode('NotificationsMenu', utils::GetAbsoluteUrlAppRoot().'pages/notifications.php', $oAdminMenu->GetIndex(), 3 /* fRank */);
 			new OQLMenuNode('AuditCategories', 'SELECT AuditCategory', $oAdminMenu->GetIndex(), 4 /* fRank */);
 			new OQLMenuNode('AuditCategories', 'SELECT AuditCategory', $oAdminMenu->GetIndex(), 4 /* fRank */);
 			new WebPageMenuNode('RunQueriesMenu', utils::GetAbsoluteUrlAppRoot().'pages/run_query.php', $oAdminMenu->GetIndex(), 8 /* fRank */);
 			new WebPageMenuNode('RunQueriesMenu', utils::GetAbsoluteUrlAppRoot().'pages/run_query.php', $oAdminMenu->GetIndex(), 8 /* fRank */);
 			new OQLMenuNode('QueryMenu', 'SELECT Query', $oAdminMenu->GetIndex(), 8.5 /* fRank */);
 			new OQLMenuNode('QueryMenu', 'SELECT Query', $oAdminMenu->GetIndex(), 8.5 /* fRank */);

+ 104 - 0
pages/notifications.php

@@ -0,0 +1,104 @@
+<?php
+// Copyright (C) 2013 Combodo SARL
+//
+//   This file is part of iTop.
+//
+//   iTop is free software; you can redistribute it and/or modify	
+//   it under the terms of the GNU Affero General Public License as published by
+//   the Free Software Foundation, either version 3 of the License, or
+//   (at your option) any later version.
+//
+//   iTop is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//   GNU Affero General Public License for more details.
+//
+//   You should have received a copy of the GNU Affero General Public License
+//   along with iTop. If not, see <http://www.gnu.org/licenses/>
+
+
+/**
+ * Page to configuration the notifications (triggers and actions)
+ *
+ * @copyright   Copyright (C) 2013 Combodo SARL
+ * @license     http://opensource.org/licenses/AGPL-3.0
+ */
+
+require_once('../approot.inc.php');
+require_once(APPROOT.'/application/application.inc.php');
+require_once(APPROOT.'/application/itopwebpage.class.inc.php');
+
+require_once(APPROOT.'/application/startup.inc.php');
+
+require_once(APPROOT.'/application/loginwebpage.class.inc.php');
+LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
+
+
+
+// Main program
+//
+$oP = new iTopWebPage(Dict::S('Menu:NotificationsMenu+'));
+
+$oP->add('<div class="page_header" style="padding:0.5em;">');
+$oP->add('<h1>'.dict::S('UI:NotificationsMenu:Title').'</h1>');
+$oP->add('</div>');
+
+$oP->StartCollapsibleSection(Dict::S('UI:NotificationsMenu:Help'), true);
+$oP->add('<div style="padding: 1em; font-size:10pt;background:#E8F3CF;margin-top: 0.25em;">');
+$oP->add('<img src="../images/bell.png" style="margin-top: -60px; margin-right: 10px; float: right;">');
+$oP->add(Dict::S('UI:NotificationsMenu:HelpContent'));
+$oP->add('</div>');
+$oP->add('');
+$oP->add('');
+$oP->EndCollapsibleSection();
+
+$oP->add('<p>&nbsp;</p>');
+
+
+$oP->AddTabContainer('Tabs_0');
+$oP->SetCurrentTabContainer('Tabs_0');
+
+$oP->SetCurrentTab(Dict::S('UI:NotificationsMenu:Triggers'));
+$oP->add('<h2>'.Dict::S('UI:NotificationsMenu:AvailableTriggers').'</h2>');
+$oFilter = new DBObjectSearch('Trigger');
+$aParams = array();
+$oBlock = new DisplayBlock($oFilter, 'list', false, $aParams);
+$oBlock->Display($oP, 'block_0', $aParams);
+
+
+$aActionClasses = array();
+foreach(MetaModel::EnumChildClasses('Action', ENUM_CHILD_CLASSES_EXCLUDETOP) as $sActionClass)
+{
+	if (!MetaModel::IsAbstract($sActionClass))
+	{
+		$aActionClasses[] = $sActionClass;
+	}
+}
+
+$oP->SetCurrentTab(Dict::S('UI:NotificationsMenu:Actions'));
+
+if (count($aActionClasses) == 1)
+{
+	// Preserve old style
+	$oP->add('<h2>'.Dict::S('UI:NotificationsMenu:AvailableActions').'</h2>');
+}
+
+$iBlock = 0;
+foreach($aActionClasses as $sActionClass)
+{
+	if (count($aActionClasses) > 1)
+	{
+		// New style
+		$oP->add('<h2>'.MetaModel::GetName($sActionClass).'</h2>');
+	}
+	$oFilter = new DBObjectSearch($sActionClass);
+	$aParams = array();
+	$oBlock = new DisplayBlock($oFilter, 'list', false, $aParams);
+	$oBlock->Display($oP, 'block_'.$iBlock, $aParams);
+	$iBlock++;
+}
+
+$oP->SetCurrentTab('');
+$oP->SetCurrentTabContainer('');
+
+$oP->output();