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