示例#1
0
                        }
                    }
                    $sDefaultKeys = '"' . implode('", "', array_merge($aReconciliationKeys, array_keys($aMoreReconciliationKeys))) . '"';
                } else {
                    // The reconciliation scheme is given (navigating back in the wizard)
                    //
                    $aDefaultKeys = array();
                    foreach ($aInitSearchField as $iSearchField => $void) {
                        $sAttCodeEx = $aInitFieldMapping[$iSearchField];
                        $aDefaultKeys[] = $sAttCodeEx;
                    }
                    $sDefaultKeys = '"' . implode('", "', $aDefaultKeys) . '"';
                }
                $oPage->add_ready_script(<<<EOF
\t\t\$('select[name^=field]').change( DoCheckMapping );
\t\taDefaultKeys = new Array({$sDefaultKeys});
\t\tDoCheckMapping();
EOF
);
            }
            break;
        case 'get_csv_template':
            $sClassName = utils::ReadParam('class_name');
            $sFormat = utils::ReadParam('format', 'csv');
            if (MetaModel::IsValidClass($sClassName)) {
                $oSearch = new DBObjectSearch($sClassName);
                $oSearch->AddCondition('id', 0, '=');
                // Make sure we create an empty set
                $oSet = new CMDBObjectSet($oSearch);
                $sResult = cmdbAbstractObject::GetSetAsCSV($oSet, array('showMandatoryFields' => true));
                $sClassDisplayName = MetaModel::GetName($sClassName);
                $sDisposition = utils::ReadParam('disposition', 'inline');
示例#2
0
function InteractiveShell($sExpression, $sQueryId, $sFormat, $sFileName, $sMode)
{
    if ($sMode == 'dialog') {
        $oP = new ajax_page('');
        $oP->add('<div id="interactive_export_dlg">');
        $sExportBtnLabel = json_encode(Dict::S('UI:Button:Export'));
        $sJSTitle = json_encode(htmlentities(utils::ReadParam('dialog_title', '', false, 'raw_data'), ENT_QUOTES, 'UTF-8'));
        $oP->add_ready_script(<<<EOF
\t\t\$('#interactive_export_dlg').dialog({
\t\t\tautoOpen: true,
\t\t\tmodal: true,
\t\t\twidth: '80%',
\t\t\ttitle: {$sJSTitle},
\t\t\tclose: function() { \$('#export-form').attr('data-state', 'cancelled'); \$(this).remove(); },
\t\t\tbuttons: [
\t\t\t\t{text: {$sExportBtnLabel}, id: 'export-dlg-submit', click: function() {} }
\t\t\t]
\t\t});
\t\t\t
\t\tsetTimeout(function() { \$('#interactive_export_dlg').dialog('option', { position: { my: "center", at: "center", of: window }}); \$('#export-btn').hide(); ExportInitButton('#export-dlg-submit'); }, 100);
EOF
);
    } else {
        $oP = new iTopWebPage('iTop Export');
    }
    if ($sExpression === null) {
        // No expression supplied, let's check if phrasebook entry is given
        if ($sQueryId !== null) {
            $oSearch = DBObjectSearch::FromOQL('SELECT QueryOQL WHERE id = :query_id', array('query_id' => $sQueryId));
            $oQueries = new DBObjectSet($oSearch);
            if ($oQueries->Count() > 0) {
                $oQuery = $oQueries->Fetch();
                $sExpression = $oQuery->Get('oql');
                $sFields = trim($oQuery->Get('fields'));
            } else {
                ReportErrorAndExit("Invalid query phrasebook identifier: '{$sQueryId}'");
            }
        } else {
            if (utils::IsModeCLI()) {
                Usage();
                ReportErrorAndExit("No expression or query phrasebook identifier supplied.");
            } else {
                // form to enter an OQL query or pick a query phrasebook identifier
                DisplayForm($oP, utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php', $sExpression, $sQueryId, $sFormat);
                $oP->output();
                exit;
            }
        }
    }
    if ($sFormat !== null) {
        $oExporter = BulkExport::FindExporter($sFormat);
        if ($oExporter === null) {
            $aSupportedFormats = BulkExport::FindSupportedFormats();
            ReportErrorAndExit("Invalid output format: '{$sFormat}'. The supported formats are: " . implode(', ', array_keys($aSupportedFormats)));
        } else {
            DisplayForm($oP, utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php', $sExpression, $sQueryId, $sFormat);
        }
    } else {
        DisplayForm($oP, utils::GetAbsoluteUrlAppRoot() . 'webservices/export-v2.php', $sExpression, $sQueryId, $sFormat);
    }
    if ($sMode == 'dialog') {
        $oP->add('</div>');
    }
    $oP->output();
}
示例#3
0
            require_once APPROOT . '/application/loginwebpage.class.inc.php';
            LoginWebPage::DoLogin(true);
            // Check user rights and prompt if needed (must be admin)
            $oPage = new ajax_page("");
            $oPage->no_cache();
            $oPage->SetContentType('text/html');
            $sEnvironment = utils::ReadParam('environment', 'production', false, 'raw_data');
            $oRestoreMutex = new iTopMutex('restore.' . $sEnvironment);
            if ($oRestoreMutex->TryLock()) {
                $oRestoreMutex->Unlock();
                $sFile = utils::ReadParam('file', '', false, 'raw_data');
                $sToken = str_replace(' ', '', (string) microtime());
                $sTokenFile = APPROOT . '/data/restore.' . $sToken . '.tok';
                file_put_contents($sTokenFile, $sFile);
                $oPage->add_ready_script(<<<EOF
\t\$("#restore_token").val('{$sToken}');
EOF
);
            } else {
                $oPage->p(Dict::S('bkp-restore-running'));
            }
            $oPage->output();
            break;
        case 'restore_exec':
            require_once APPROOT . "setup/runtimeenv.class.inc.php";
            require_once APPROOT . '/application/utils.inc.php';
            require_once APPROOT . '/setup/backup.class.inc.php';
            require_once dirname(__FILE__) . '/dbrestore.class.inc.php';
            IssueLog::Enable(APPROOT . 'log/error.log');
            $oPage = new ajax_page("");
            $oPage->no_cache();
            $oPage->SetContentType('text/html');