mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-27 04:28:44 +02:00
Import feature
This commit is contained in:
@@ -23,6 +23,8 @@ use Combodo\iTop\PropertyType\Serializer\XMLSerializer;
|
||||
use Combodo\iTop\Service\DependencyInjection\ServiceLocator;
|
||||
use DBObjectSearch;
|
||||
use DBObjectSet;
|
||||
use Dict;
|
||||
use DOMException;
|
||||
use Exception;
|
||||
use IssueLog;
|
||||
use ModelReflectionRuntime;
|
||||
@@ -179,4 +181,38 @@ class DashboardController extends Controller
|
||||
|
||||
return $oPage;
|
||||
}
|
||||
|
||||
public function OperationImport()
|
||||
{
|
||||
$oPage = new JsonPage();
|
||||
$oPage->SetOutputDataOnly(true);
|
||||
|
||||
$sTransactionId = utils::ReadParam('transaction_id', '', false, 'transaction_id');
|
||||
if (!utils::IsTransactionValid($sTransactionId, true)) {
|
||||
throw new SecurityException('ajax.render.php import_dashboard : invalid transaction_id');
|
||||
}
|
||||
$sDashboardId = utils::ReadParam('id', '', false, 'raw_data');
|
||||
$sDashboardFileRelative = utils::ReadParam('file', '', false, 'raw_data');
|
||||
|
||||
$sDashboardFile = RuntimeDashboard::GetDashboardFileFromRelativePath($sDashboardFileRelative);
|
||||
|
||||
$oDashboard = RuntimeDashboard::GetDashboard($sDashboardFile, $sDashboardId);
|
||||
$aResult = ['error' => ''];
|
||||
if (!is_null($oDashboard)) {
|
||||
try {
|
||||
$oDoc = utils::ReadPostedDocument('dashboard_upload_file');
|
||||
$oDashboard->FromXml($oDoc->GetData());
|
||||
$oDashboard->PersistDashboard($oDoc->GetData());
|
||||
} catch (DOMException $e) {
|
||||
$aResult = ['error' => Dict::S('UI:Error:InvalidDashboardFile')];
|
||||
} catch (Exception $e) {
|
||||
$aResult = ['error' => $e->getMessage()];
|
||||
}
|
||||
} else {
|
||||
$aResult['error'] = 'Dashboard id="'.$sDashboardId.'" not found.';
|
||||
}
|
||||
$oPage->SetData($aResult);
|
||||
|
||||
return $oPage;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user