} } $_BAR->setProgress(100); $_BAR->setMessage('Done!'); // Write to log... if ($aTableInfo['shared']) { lovd_writeLog('Event', LOG_EVENT, 'Disabled column ' . $zData['id'] . ' (' . $zData['head_column'] . ') for ' . count($aTargets) . ' ' . $aTableInfo['unit'] . '(s): ' . implode(', ', $aTargets)); } // In case this was/were the last objects to have this column, log its removal. if (!$aTableInfo['shared'] || !$nTargets) { lovd_writeLog('Event', LOG_EVENT, 'Removed column ' . $zData['id'] . ' (' . $zData['head_column'] . ') from ' . $aTableInfo['table_name'] . ' table'); } // Thank the user... $_BAR->setMessage('Successfully removed column "' . $zData['head_column'] . '"!', 'done'); $_BAR->setMessageVisibility('done', true); $_BAR->redirectTo(lovd_getInstallURL() . $_PE[0] . '/' . $sCategory, 3); print '</BODY>' . "\n" . '</HTML>' . "\n"; exit; } else { // Because we're sending the data back to the form, I need to unset the password fields! unset($_POST['password']); } } $_T->printHeader(); $_T->printTitle(); // If ALTER time is large enough, mention something about it. if ($tAlter > $tAlterMax) { lovd_showInfoTable('Please note that the time estimated to remove this column from the ' . $aTableInfo['table_name'] . ' data table is <B>' . round($tAlter) . ' seconds</B>.<BR>During this time, no updates to the data table are possible. If other users are trying to update information in the database during this time, they will have to wait a long time, or get an error.', 'warning'); } lovd_errorPrint(); // Tooltip JS code.
$_T->printFooter(false); @set_time_limit(0); $sVariants = ' '; $nDone = 0; while ($nDone < $nToFetch && $sVariants) { $aVariants = $_DB->query('SELECT chromosome, position_g_start, position_g_end, `VariantOnGenome/DNA` AS DNA FROM ' . TABLE_VARIANTS . ' WHERE average_frequency IS NULL AND chromosome IS NOT NULL AND position_g_start IS NOT NULL AND position_g_end IS NOT NULL LIMIT ' . $nLimit)->fetchAllAssoc(); if ($aVariants === array()) { // No results. $oPB->setProgress(100); // To prevent ending up in a loop because of a programming error, or unexpected results from the database, we'll redirect with a GET variable that we'll check for, here. if (ACTION == 'done') { // We were supposedly done before. Don't reload. $oPB->setMessage('Done.'); } else { $oPB->setMessage('Done, reloading...'); $oPB->redirectTo(CURRENT_PATH . '?done', 1); } die(' </BODY>' . "\n" . '</HTML>'); } elseif (!$aVariants) { // Failed query, $oPB->setMessage('Error, did not get proper response from database.'); die(' </BODY>' . "\n" . '</HTML>'); } else { // Proceed. $sVariants = json_encode($aVariants); $aResponse = lovd_php_file($sURL, false, 'variants=' . $sVariants); if ($aResponse) { $sResponse = implode($aResponse); } if (!$aResponse || !$sResponse) { $oPB->setMessage('Error, did not get proper response from remote source.');
$_DB->commit(); $sMessage = ''; if (count($aDone)) { foreach ($aDone as $sSection => $n) { $sMessage .= (!$sMessage ? '' : ', ') . $n . ' ' . $sSection; } $sMessage = 'deleted ' . preg_replace('/, ([^,]+)/', " and \$1", $sMessage); } else { $sMessage = 'no data to delete'; } lovd_writeLog('Event', LOG_EVENT, 'Emptied gene database ' . $sID . '; ' . $sMessage . '; ran ' . $nDone . ' queries.'); lovd_setUpdatedDate($sID); // FIXME; regardless of variant status... oh, well... // Thank the user... lovd_showInfoTable('Successfully emptied the ' . $sID . ' gene database!', 'success'); $_BAR->redirectTo(lovd_getInstallURL() . 'configuration', 3); $_T->printFooter(); exit; } else { // Because we're sending the data back to the form, I need to unset the password fields! unset($_POST['password']); } } lovd_errorPrint(); lovd_includeJS('inc-js-tooltip.php'); // Table. print ' <FORM action="' . CURRENT_PATH . '?' . ACTION . '" method="post">' . "\n"; // Array which will make up the form table. $aForm = array_merge(array(array('POST', '', '', '', '40%', '14', '60%'), array('Emptying ' . $sID . ' gene database', 'All data associated to ' . $sID . ' will be deleted, as long as it\'s not associated with another gene. For instance, a variant that is mapped to ' . $sID . ' as well as another gene, will only lose the mapping to ' . $sID . '. A variant that is only described on ' . $sID . ' however, will be deleted. Also, an individual with a variant in ' . $sID . ', but also in another gene, will not be deleted, but the ' . $sID . ' variant data <I>will</I> be deleted. An individual that only has variants reported in ' . $sID . ' will be removed from the system.', 'print', 'Deleting ' . $nVariants . ' variant' . ($nVariants == 1 ? '' : 's') . ' and all associated data (screenings, individuals, phenotypes).<BR><B>All data (variants, screenings, individuals and phenotypes) only linked to ' . $sID . ' and not linked to any other gene will be deleted!</B>'), 'skip', array('Enter your password for authorization', '', 'password', 'password', 20), array('', '', 'submit', 'Empty gene database'))); lovd_viewForm($aForm); print '</FORM>' . "\n\n";
$aSubmit['uploads'] = array(); } $aSubmit['uploads'][$nUploadID] = $aUploadData; if ($aUploadData['num_variants']) { lovd_saveWork(); } } else { $_SESSION['work']['submits']['upload'][$nUploadID] = $aUploadData; } // Processing finished. $_BAR->setProgress(100); if ($aUploadData['num_variants'] && !$aUploadData['num_variants_unsupported']) { // Variants were imported, none were ignored. $_BAR->setMessage('All ' . $aUploadData['num_variants'] . ' variants have been imported successfully!'); if ($bSubmit) { $_BAR->redirectTo(lovd_getInstallURL() . 'submit/screening/' . $_POST['screeningid']); } else { $_BAR->redirectTo(lovd_getInstallURL() . 'submit/finish/upload/' . $nUploadID); } } else { $_BAR->setMessage($aUploadData['num_variants'] . ' variant' . ($aUploadData['num_variants'] == 1 ? '' : 's') . ' were imported' . (!$aUploadData['num_variants_unsupported'] ? '.' : ', ' . $aUploadData['num_variants_unsupported'] . ' variant' . ($aUploadData['num_variants_unsupported'] == 1 ? '' : 's') . ' could not be imported.') . ($bSubmit ? '<P>' . ' <INPUT type="button" value="Continue »" onclick="window.location.href=\'' . lovd_getInstallURL() . 'submit/screening/' . $_POST['screeningid'] . '\';">' . '</P>' : '<FORM action="' . ROOT_PATH . 'submit/finish/upload/' . $nUploadID . '" method="GET">' . ' <INPUT type="submit" value="Continue »">' . '</FORM>')); if ($aUploadData['num_variants_unsupported']) { $_BAR->setMessage('Below is ' . ($aUploadData['num_variants_unsupported'] > 1 ? 'a list of ' : '') . 'the ' . ($aUploadData['num_variants_unsupported'] > $nMaxListedUnsupported ? 'first ' . $nMaxListedUnsupported . ' of ' : '') . ($aUploadData['num_variants_unsupported'] == 1 ? 'variant' : $aUploadData['num_variants_unsupported'] . ' variants') . ' that could not be imported.' . '<DIV style="white-space: pre; font-family: monospace; border: 1px solid #224488; overflow: auto; max-height: 300px; max-width: 1000px">' . implode("\n", $aUnsupportedLines) . '</DIV>', 'done'); $_BAR->setMessageVisibility('done', true); } } // Log it! lovd_writeLog('Event', LOG_EVENT, 'Imported ' . $aUploadData['num_variants'] . ' variants from ' . $aUploadData['file_type'] . ' file ' . $aUploadData['file_name']); // End here, we don't want to show the upload form again after a successful import. exit(' </BODY>' . "\n" . '</HTML>'); }