replica.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. // Copyright (C) 2010-2017 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. * Display and search synchro replicas
  20. *
  21. * @copyright Copyright (C) 2010-2017 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, admins only here !
  30. $sOperation = utils::ReadParam('operation', 'menu');
  31. $oAppContext = new ApplicationContext();
  32. $oP = new iTopWebPage("iTop - Synchro Replicas");
  33. // Main program
  34. $sOperation = utils::ReadParam('operation', 'details');
  35. try
  36. {
  37. switch($sOperation)
  38. {
  39. case 'details':
  40. $iId = utils::ReadParam('id', null);
  41. if ($iId == null)
  42. {
  43. throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'id'));
  44. }
  45. $oReplica = MetaModel::GetObject('SynchroReplica', $iId);
  46. $oReplica->DisplayDetails($oP);
  47. break;
  48. case 'oql':
  49. $sOQL = utils::ReadParam('oql', null, false, 'raw_data');
  50. if ($sOQL == null)
  51. {
  52. throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'oql'));
  53. }
  54. $oFilter = DBObjectSearch::FromOQL($sOQL);
  55. $oBlock1 = new DisplayBlock($oFilter, 'search', false, array('menu'=>false));
  56. $oBlock1->Display($oP, 0);
  57. $oP->add('<p class="page-header">'.MetaModel::GetClassIcon('SynchroReplica').Dict::S('Core:SynchroReplica:ListOfReplicas').'</p>');
  58. $iSourceId = utils::ReadParam('datasource', null);
  59. if ($iSourceId != null)
  60. {
  61. $oSource = MetaModel::GetObject('SynchroDataSource', $iSourceId);
  62. $oP->p(Dict::Format('Core:SynchroReplica:BackToDataSource', $oSource->GetHyperlink()).'</a>');
  63. }
  64. $oBlock = new DisplayBlock($oFilter, 'list', false, array('menu'=>false));
  65. $oBlock->Display($oP, 1);
  66. break;
  67. case 'select_for_deletion':
  68. // Redirect to the page that implements bulk delete
  69. $sDelete = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?'.$_SERVER['QUERY_STRING'];
  70. header("Location: $sDelete");
  71. break;
  72. }
  73. }
  74. catch(CoreException $e)
  75. {
  76. $oP->p('<b>An error occured while running the query:</b>');
  77. $oP->p($e->getHtmlDesc());
  78. }
  79. catch(Exception $e)
  80. {
  81. $oP->p('<b>An error occured while running the query:</b>');
  82. $oP->p($e->getMessage());
  83. }
  84. $oP->output();