replica.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. // Copyright (C) 2011 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * Display and search synchro replicas
  18. */
  19. require_once('../approot.inc.php');
  20. require_once(APPROOT.'/application/application.inc.php');
  21. require_once(APPROOT.'/application/itopwebpage.class.inc.php');
  22. require_once(APPROOT.'/application/startup.inc.php');
  23. require_once(APPROOT.'/application/loginwebpage.class.inc.php');
  24. LoginWebPage::DoLogin(true); // Check user rights and prompt if needed, admins only here !
  25. $sOperation = utils::ReadParam('operation', 'menu');
  26. $oAppContext = new ApplicationContext();
  27. $oP = new iTopWebPage("iTop - Synchro Replicas");
  28. // Main program
  29. $sOperation = utils::ReadParam('operation', 'details');
  30. try
  31. {
  32. switch($sOperation)
  33. {
  34. case 'details':
  35. $iId = utils::ReadParam('id', null);
  36. if ($iId == null)
  37. {
  38. throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'id'));
  39. }
  40. $oReplica = MetaModel::GetObject('SynchroReplica', $iId);
  41. $oReplica->DisplayDetails($oP);
  42. break;
  43. case 'oql':
  44. $sOQL = utils::ReadParam('oql', null, false, 'raw_data');
  45. if ($sOQL == null)
  46. {
  47. throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'oql'));
  48. }
  49. $oFilter = DBObjectSearch::FromOQL($sOQL);
  50. $oBlock1 = new DisplayBlock($oFilter, 'search', false, array('menu'=>false));
  51. $oBlock1->Display($oP, 0);
  52. $oP->add('<p class="page-header">'.MetaModel::GetClassIcon('SynchroReplica').Dict::S('Core:SynchroReplica:ListOfReplicas').'</p>');
  53. $iSourceId = utils::ReadParam('datasource', null);
  54. if ($iSourceId != null)
  55. {
  56. $oSource = MetaModel::GetObject('SynchroDataSource', $iSourceId);
  57. $oP->p(Dict::Format('Core:SynchroReplica:BackToDataSource', $oSource->GetHyperlink()).'</a>');
  58. }
  59. $oBlock = new DisplayBlock($oFilter, 'list', false, array('menu'=>false));
  60. $oBlock->Display($oP, 1);
  61. break;
  62. }
  63. }
  64. catch(CoreException $e)
  65. {
  66. $oP->p('<b>An error occured while running the query:</b>');
  67. $oP->p($e->getHtmlDesc());
  68. }
  69. catch(Exception $e)
  70. {
  71. $oP->p('<b>An error occured while running the query:</b>');
  72. $oP->p($e->getMessage());
  73. }
  74. $oP->output();
  75. ?>