notifications.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. // Copyright (C) 2013-2016 Combodo SARL
  3. //
  4. // This file is part of iTop.
  5. //
  6. // iTop is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // iTop is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with iTop. If not, see <http://www.gnu.org/licenses/>
  18. /**
  19. * Page to configuration the notifications (triggers and actions)
  20. *
  21. * @copyright Copyright (C) 2013-2016 Combodo SARL
  22. * @license http://opensource.org/licenses/AGPL-3.0
  23. */
  24. require_once('../approot.inc.php');
  25. require_once(APPROOT.'/application/application.inc.php');
  26. require_once(APPROOT.'/application/itopwebpage.class.inc.php');
  27. require_once(APPROOT.'/application/startup.inc.php');
  28. require_once(APPROOT.'/application/loginwebpage.class.inc.php');
  29. LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
  30. // Main program
  31. //
  32. $oP = new iTopWebPage(Dict::S('Menu:NotificationsMenu+'));
  33. $oP->add('<div class="page_header" style="padding:0.5em;">');
  34. $oP->add('<h1>'.dict::S('UI:NotificationsMenu:Title').'</h1>');
  35. $oP->add('</div>');
  36. $oP->SetBreadCrumbEntry('ui-tool-notifications', Dict::S('Menu:NotificationsMenu'), Dict::S('Menu:NotificationsMenu+'), '', '../images/bell.png');
  37. $oP->StartCollapsibleSection(Dict::S('UI:NotificationsMenu:Help'), true);
  38. $oP->add('<div style="padding: 1em; font-size:10pt;background:#E8F3CF;margin-top: 0.25em;">');
  39. $oP->add('<img src="../images/bell.png" style="margin-top: -60px; margin-right: 10px; float: right;">');
  40. $oP->add(Dict::S('UI:NotificationsMenu:HelpContent'));
  41. $oP->add('</div>');
  42. $oP->add('');
  43. $oP->add('');
  44. $oP->EndCollapsibleSection();
  45. $oP->add('<p>&nbsp;</p>');
  46. $oP->AddTabContainer('Tabs_0');
  47. $oP->SetCurrentTabContainer('Tabs_0');
  48. $oP->SetCurrentTab(Dict::S('UI:NotificationsMenu:Triggers'));
  49. $oP->add('<h2>'.Dict::S('UI:NotificationsMenu:AvailableTriggers').'</h2>');
  50. $oFilter = new DBObjectSearch('Trigger');
  51. $aParams = array();
  52. $oBlock = new DisplayBlock($oFilter, 'list', false, $aParams);
  53. $oBlock->Display($oP, 'block_0', $aParams);
  54. $aActionClasses = array();
  55. foreach(MetaModel::EnumChildClasses('Action', ENUM_CHILD_CLASSES_EXCLUDETOP) as $sActionClass)
  56. {
  57. if (!MetaModel::IsAbstract($sActionClass))
  58. {
  59. $aActionClasses[] = $sActionClass;
  60. }
  61. }
  62. $oP->SetCurrentTab(Dict::S('UI:NotificationsMenu:Actions'));
  63. if (count($aActionClasses) == 1)
  64. {
  65. // Preserve old style
  66. $oP->add('<h2>'.Dict::S('UI:NotificationsMenu:AvailableActions').'</h2>');
  67. }
  68. $iBlock = 0;
  69. foreach($aActionClasses as $sActionClass)
  70. {
  71. if (count($aActionClasses) > 1)
  72. {
  73. // New style
  74. $oP->add('<h2>'.MetaModel::GetName($sActionClass).'</h2>');
  75. }
  76. $oFilter = new DBObjectSearch($sActionClass);
  77. $oFilter->AddCondition('finalclass', $sActionClass); // derived classes will be further processed
  78. $aParams = array();
  79. $oBlock = new DisplayBlock($oFilter, 'list', false, $aParams);
  80. $oBlock->Display($oP, 'block_action_'.$iBlock, $aParams);
  81. $iBlock++;
  82. }
  83. $oP->SetCurrentTab('');
  84. $oP->SetCurrentTabContainer('');
  85. $oP->output();