replica.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. $oP->add('<p class="page-header">'.MetaModel::GetClassIcon('SynchroReplica').Dict::S('Core:SynchroReplica:ListOfReplicas').'</p>');
  50. $iSourceId = utils::ReadParam('datasource', null);
  51. if ($iSourceId != null)
  52. {
  53. $oSource = MetaModel::GetObject('SynchroDataSource', $iSourceId);
  54. $oP->p(Dict::Format('Core:SynchroReplica:BackToDataSource', $oSource->GetHyperlink()).'</a>');
  55. }
  56. $oFilter = DBObjectSearch::FromOQL($sOQL);
  57. $oBlock = new DisplayBlock($oFilter, 'list', false, array('menu'=>false));
  58. $oBlock->Display($oP, 1);
  59. break;
  60. }
  61. }
  62. catch(CoreException $e)
  63. {
  64. $oP->p('<b>An error occured while running the query:</b>');
  65. $oP->p($e->getHtmlDesc());
  66. }
  67. catch(Exception $e)
  68. {
  69. $oP->p('<b>An error occured while running the query:</b>');
  70. $oP->p($e->getMessage());
  71. }
  72. $oP->output();
  73. ?>