예제 #1
0
// Define the list of VariantOnTranscript columns once and for all.
$aVOTCols = array('VariantOnTranscript/Distance_to_splice_site', 'VariantOnTranscript/GVS/Function', 'VariantOnTranscript/PolyPhen', 'VariantOnTranscript/Position');
// We also need to get a list of standard VariantOnTranscript columns.
$aColsStandard = $_DB->query('SELECT id FROM ' . TABLE_COLS . ' WHERE standard = 1 AND id IN ("' . implode('", "', $aVOTCols) . '")')->fetchAllColumn();
$sColumnMessage = '';
if (!$_DB->query('SELECT colid FROM ' . TABLE_ACTIVE_COLS . ' WHERE colid = "VariantOnGenome/Conservation_score/GERP"')->fetchColumn()) {
    // Check whether the GERP column is enabled.
    $sColumnMessage = '<BR>VariantOnGenome/Conservation_score/GERP: currently not enabled (<A href="#" onclick="lovd_openWindow(\'' . lovd_getInstallURL() . 'columns/VariantOnGenome/Conservation_score/GERP?add&amp;in_window=true\', \'col\', 800, 300); return false;">enable</A>)';
}
// Check if all VariantOnTranscript columns are activated for all genes and whether they are standard.
$nGenes = $_DB->query('SELECT COUNT(*) FROM ' . TABLE_GENES)->fetchColumn();
$aColCounts = $_DB->query('SELECT colid, COUNT(*) AS count FROM ' . TABLE_SHARED_COLS . ' WHERE colid IN ("' . implode('", "', $aVOTCols) . '") GROUP BY colid')->fetchAllCombine();
foreach ($aVOTCols as $sCol) {
    $b = true;
    if (!isset($aColCounts[$sCol]) && $nGenes || isset($aColCounts[$sCol]) && $aColCounts[$sCol] != $nGenes) {
        $sColumnMessage .= '<BR>' . $sCol . ': not enabled for some existing genes (<A href="#" onclick="lovd_openWindow(\'' . lovd_getInstallURL() . 'columns/' . $sCol . '?add&amp;in_window=true\', \'col\', 800, 450); return false;">enable</A>)';
        $b = false;
    }
    if (!in_array($sCol, $aColsStandard)) {
        if ($b) {
            $sColumnMessage .= '<BR>' . $sCol . ': ';
        } else {
            $sColumnMessage .= ' and ';
        }
        $sColumnMessage .= 'not enabled for new genes (<A href="#" onclick="lovd_setStandardColumn(\'' . $sCol . '\'); return false;">make standard</A>)';
    }
}
if (!empty($sColumnMessage)) {
    // Only show the infoTable if we have found problematic columns.
    lovd_showInfoTable('SeattleSeq files may contain additional annotations that can be imported into LOVD. To import this data into existing genes, the relevant columns need to be enabled for those genes.' . "\n" . 'To import this data into genes that will be created during import, the columns need to be set to \'standard\' so that they are enabled for the new genes.' . "\n" . '(<A href="#" onclick="lovd_checkColumns(); return false;">Re-check</A>)<BR>' . $sColumnMessage);
}
예제 #2
0
                    if (objHTTP.responseText.substring(0, 1) == '1') {
                        // Object successfully deleted.
                        lovd_AJAX_viewListHideRow(sViewListID, sID);
                        document.forms['viewlistForm_' + sViewListID].total.value --;
                        lovd_AJAX_viewListUpdateEntriesString(sViewListID);
                        lovd_AJAX_viewListAddNextRow(sViewListID);
                        return true;
                    } else if (objHTTP.responseText == '8') {
                        window.alert('Lost your session. Please log in again.');
                    } else if (objHTTP.responseText == '9') {
                        window.alert('Error while sending data. Please try again.');
                    } else if (!objHTTP.responseText || objHTTP.responseText == '0') {
                        // Silent failure.
                        return false;
                    } else {
                        window.alert('Unknown response :' + objHTTP.responseText);
                    }
                } else {
                    // FIXME; Maybe we should remove this...?
                    window.alert('Server error: ' + objHTTP.status);
                }
            }
        }
        objHTTP.open('GET', '<?php 
echo lovd_getInstallURL() . 'ajax/delete_log.php?id=';
?>
' + escape(sID), true);
        objHTTP.send(null);
    }
}
예제 #3
0
파일: feeds.php 프로젝트: LOVDnl/LOVD3
 function __construct($sType = 'feed', $sFeedTitle = '', $sFeedURL = '', $sFeedID = '', $sFormat = 'atom')
 {
     global $_CONF, $_DB, $_SETT, $_STAT;
     // Feed or entry only options.
     if (!in_array($sType, array('feed', 'entry'))) {
         $sType = 'feed';
         // Silent error - we just assume Feed when we don't understand the requested type.
     }
     $this->sType = $sType;
     // So addEntry() knows what to do.
     if (preg_match($this->sAtomEntrySplit, $this->sAtomFeed, $aRegs)) {
         $this->sAtomEntry = $aRegs[1];
     } else {
         // Can't parse own $sAtomFeed, bug in LOVD (or someone has messed with the code).
         lovd_displayError('Feed', 'Couldn\'t parse AtomFeed. This is a bug in LOVD or in one of it\'s modules. Please <A href="' . $_SETT['upstream_URL'] . 'bugs/" target="_blank">file a bug</A> and include the below messages to help us solve the problem.' . "\n" . 'Debug: ' . lovd_getProjectFile() . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : ''));
     }
     if ($sType == 'feed') {
         // Fill in the feed's variables.
         $this->sAtomFeed = str_replace('{{ FEED_TITLE }}', $sFeedTitle, $this->sAtomFeed);
         $this->sAtomFeed = str_replace('{{ LOVD_URL }}', $_CONF['location_url'] ? $_CONF['location_url'] : lovd_getInstallURL(), $this->sAtomFeed);
         $this->sAtomFeed = str_replace('{{ FEED_URL }}', $sFeedURL, $this->sAtomFeed);
         $this->sAtomFeed = str_replace('{{ FEED_ID }}', $sFeedID ? $sFeedID : 'tag:' . $_SERVER['HTTP_HOST'] . ',' . $_STAT['install_date'] . ':' . $_STAT['signature'], $this->sAtomFeed);
         $this->sAtomFeed = str_replace('{{ LOVD_VERSION }}', $_SETT['system']['version'], $this->sAtomFeed);
         // Let the date of last update depend on the type of feed.
         if (preg_match('/\\/variants\\/(.+)$/', $sFeedURL, $aRegs)) {
             // Variants of a specific gene.
             $sDateUpdated = $_DB->query('SELECT MAX(updated_date) FROM ' . TABLE_GENES . ' WHERE id = ?', array($aRegs[1]))->fetchColumn();
         } else {
             // Find date of last update for all genes.
             $sDateUpdated = $_DB->query('SELECT MAX(updated_date) FROM ' . TABLE_GENES)->fetchColumn();
         }
         $this->sAtomFeed = str_replace('{{ FEED_DATE_UPDATED }}', $this->formatDate($sDateUpdated), $this->sAtomFeed);
         // For now, remove any of the entries until they are added using addEntry().
         $this->sAtomFeed = preg_replace($this->sAtomEntrySplit, '{{ ENTRY }}', $this->sAtomFeed);
     } else {
         // Only one entry requested.
         // Remove all, except the XML start entity!
         $this->sAtomFeed = preg_replace('/^(.+[\\r\\n]{1,2})(.|[\\r\\n]{1,2})+$/', "\$1{{ ENTRY }}", $this->sAtomFeed);
     }
 }
예제 #4
0
$nMaxDropDown = 10;
$qGenes = $_DB->query('SELECT id AS value, CONCAT(id, " (", name, ")") AS label FROM ' . TABLE_GENES . ' ORDER BY id');
$zGenes = $qGenes->fetchAllAssoc();
if (empty($zGenes)) {
    die(json_encode(AJAX_DATA_ERROR));
}
foreach ($zGenes as $key => $aValues) {
    // This will shorten the gene names nicely, to prevent long gene names from messing up the form.
    $zGenes[$key]['label'] = lovd_shortenString($aValues['label'], 75);
}
if (count($zGenes) < $nMaxDropDown) {
    // Create the option elements.
    // Try to determine the currently selected gene, so we can pre-select that one,
    // making it easier to select genes close alphabetically, and also ensuring the
    // onChange() to run if the first gene from the list is selected.
    // This code is similar to inc-init.php's parsing to find CurrDB.
    $sCurrDB = '';
    if (!empty($_SERVER['HTTP_REFERER']) && preg_match('/^' . preg_quote(lovd_getInstallURL(), '/') . '(configuration|genes|transcripts|variants|individuals|view)\\/([^\\/]+)/', $_SERVER['HTTP_REFERER'], $aRegs)) {
        if (!in_array($aRegs[2], array('in_gene', 'upload')) && !ctype_digit($aRegs[2])) {
            $sCurrDB = strtoupper($aRegs[2]);
            // Not checking capitalization here yet.
        }
    }
    $sOptions = '';
    foreach ($zGenes as $aGene) {
        $sOptions .= '<OPTION value="' . $aGene['value'] . '"' . (!$sCurrDB || $sCurrDB != strtoupper($aGene['value']) ? '' : ' selected') . '>' . $aGene['label'] . ' </OPTION>' . "\n";
    }
    die(json_encode(array('switchType' => 'dropdown', 'html' => '<FORM action="" id="SelectGeneDBInline" method="get" style="margin : 0px;" onsubmit="lovd_changeURL(); return false;">' . "\n" . '  <DIV id="div_gene_dropdown">' . "\n" . '    <SELECT name="select_db" id="select_gene_dropdown" onchange="$(this).parent().parent().submit();">' . "\n" . $sOptions . '    </SELECT>' . "\n" . '    <INPUT type="submit" value="Switch" id="select_gene_switch">' . "\n" . '  </DIV>' . "\n" . '</FORM>')));
} else {
    die(json_encode(array('switchType' => 'autocomplete', 'html' => '<FORM action="" id="SelectGeneDBInline" method="get" style="margin : 0px;" onsubmit="lovd_changeURL(); return false;">' . "\n" . '  <DIV id="div_gene_autocomplete">' . "\n" . '    <INPUT name="select_db" id="select_gene_autocomplete" style="width : 75ex;">' . "\n" . '    <INPUT type="submit" value="Switch" id="select_gene_switch">' . "\n" . '  </DIV>' . "\n" . '</FORM>', 'data' => $zGenes)));
}
예제 #5
0
파일: pedigree.php 프로젝트: LOVDnl/LOVD3
 function drawHTML()
 {
     // Prints the current tree in HTML format.
     if (!$this->tree) {
         return false;
     }
     // Check if all widths have been calculated already, which is needed for the HTML print.
     if (!isset($this->tree[0]['tree_width'])) {
         $this->calculateWidths($this->tree);
     }
     // Print the tree!
     $a = $this->tree;
     $aNextTree = array();
     // The next drawn line are just branches, no individuals.
     print '<DIV id="pedigreeIndividualDetail" title="Individual" style="display : none;"></DIV>' . "\n" . '<TABLE border="0" cellspacing="0" cellpadding="0" style="margin-right : 400px;">' . "\n";
     while ($a) {
         print '  <TR>' . "\n";
         // Open generation line.
         if ($aNextTree) {
             // The previous line that was drawn is a line of individuals. This line will be just connecting lines.
             foreach ($aNextTree as $sVal) {
                 if (!$sVal) {
                     // Empty set, to make space.
                     print '    <TD>&nbsp;</TD>' . "\n";
                 } else {
                     print '    <TD><IMG src="gfx/pedigree/' . ($this->sMode == 'pedigree' ? '' : '100x100/') . 'l' . $sVal . '.png"></TD>' . "\n";
                 }
             }
             print '  </TR>' . "\n";
             $aNextTree = array();
             continue;
         }
         $aNextGeneration = array();
         // For the next generation.
         foreach ($a as $i => $aIndividual) {
             // One individual, or one set of spouses.
             if (!$aIndividual) {
                 // FIXME; when does this really happen?
                 // Empty set, to make space.
                 print '    <TD>&nbsp;</TD>' . "\n";
                 continue;
             } else {
                 // We'll always put one space on the left of each individual, such that we will
                 // automatically create the "padding" we're looking for.
                 if ($i) {
                     $aNextTree[] = '';
                     print '    <TD>&nbsp;</TD>' . "\n";
                 }
                 // Space at left?
                 $nSpace = $aIndividual['tree_width'] < $aIndividual['own_width'] ? 0 : $aIndividual['tree_width'] - $aIndividual['own_width'];
                 // 0 or more.
                 for ($i = $nSpace / 2; $i > 0; $i--) {
                     print '    <TD>&nbsp;</TD>' . "\n";
                 }
                 // Print individual itself.
                 foreach ($aIndividual['ids'] as $nKey => $nID) {
                     $aI = $this->individuals[$nID];
                     if ($nKey) {
                         // Not the first.
                         print '    <TD><IMG src="gfx/pedigree/' . ($this->sMode == 'pedigree' ? '' : '100x100/') . 'l14.png"></TD>' . "\n";
                     }
                     // What kind of line should this individual have in the background?
                     $nLine = 0;
                     // No line by default.
                     if ($aI['father'] || $aI['mother']) {
                         $nLine += 1;
                         // Line to top.
                     }
                     if (!$nKey && count($aIndividual['ids']) > 1) {
                         $nLine += 2;
                         // The first, but not alone, add line to right.
                     } elseif ($nKey) {
                         $nLine += 8;
                         // Not the first, add line to left.
                     }
                     // Individual with children but without spouse, gets a line to the bottom.
                     if (count($aIndividual['ids']) == 1 && count($aIndividual['children'])) {
                         $nLine += 4;
                     }
                     // Print the individuals themselves as well.
                     if ($this->sMode == 'pedigree') {
                         // And what do we have to say about this person?
                         $sDescription = '<B>' . $aI['name'] . '</B><BR>';
                         print '    <TD><A href="#"' . "\n" . '      onmouseover="lovd_showToolTip(\'' . str_replace('"', '\\\'', $sDescription) . '\');" onmouseout="lovd_hideToolTip();"' . "\n" . '      onclick="lovd_openWindow(\'' . lovd_getInstallURL() . 'individuals/' . $nID . '\', \'pedigreeIndividualDetail\', 900, 450); return false;">' . "\n" . '        <IMG src="gfx/pedigree/u' . $aI['gender'] . ($aI['diseases'] ? 'a' : 'u') . '.png" style="background : url(\'gfx/pedigree/l0' . $nLine . '.png\');"></A></TD>' . "\n";
                     } else {
                         // Family tree style.
                         $sImage = 'gfx/individuals/' . (!is_readable(ROOT_PATH . 'gfx/individuals/' . $nID . '.jpg') ? 'unknown_' . $aI['gender'] : $nID) . '.jpg';
                         list($nWidth, $nHeight) = getimagesize(ROOT_PATH . $sImage);
                         if ($nWidth > $nHeight && $nWidth > 100) {
                             $nHeight = 100 / $nWidth * $nHeight;
                         } else {
                             $nHeight = 100;
                         }
                         // FIXME: Display the name nicely (shorten in intelligent way).
                         $sName = $aI['name'];
                         print '    <TD align="center" style="position : relative;"><A href="#"' . "\n" . '      onclick="lovd_openWindow(\'' . lovd_getInstallURL() . 'individuals/' . $nID . '\', \'pedigreeIndividualDetail\', 900, 450); return false;">' . "\n" . '        <IMG src="' . $sImage . '" alt="' . $aI['name'] . '" title="' . $aI['name'] . '" height="' . $nHeight . '" style="background : url(\'gfx/pedigree/100x100/l0' . $nLine . '.png\');"></A>' . "\n" . '      <DIV style="width : 100%; height : 10px; background : #000; color : #FFF; opacity : 0.6; position : absolute; bottom : 0px; z-index : 100; font-size:10px; text-align : center;"><B>' . $sName . '</B></DIV>' . "\n" . '    </TD>' . "\n";
                     }
                 }
                 // Space at right?
                 for ($i = $nSpace / 2; $i > 0; $i--) {
                     print '    <TD>&nbsp;</TD>' . "\n";
                 }
             }
             // Prepare the data of the children, if present.
             if (!$aIndividual['children']) {
                 // We don't know if maybe the next line is still needed or not.
                 // So we'll prepare it none the less.
                 for ($i = $aIndividual['own_width']; $i > 0; $i--) {
                     $aNextTree[] = '';
                     $aNextGeneration[] = '';
                 }
                 $aNextGeneration[] = '';
                 // We need one for the padding anyway, of course.
             } else {
                 if ($aIndividual['own_width'] == 1 && $aIndividual['tree_width'] == 1) {
                     // Single parent with one child.
                     $aNextTree[] = '05';
                 } elseif ($aIndividual['tree_width'] < $aIndividual['own_width']) {
                     // The children need space around them, if the parents are wider than the children
                     // (thus, two parents but one child which has no spouse).
                     $aNextTree[] = '';
                     $aNextTree[] = '05';
                     $aNextTree[] = '';
                     $aNextGeneration[] = '';
                 } else {
                     // To be absolutely sure we draw everything correctly, we need to loop through the children.
                     $nChildren = count($aIndividual['children']);
                     $aNextTreeChildren = array();
                     // To be merged to $aNextTree.
                     foreach ($aIndividual['children'] as $nChild => $aChild) {
                         $bSpouse = $aChild['own_width'] > 1;
                         // $nPosition indicates the position where we need to draw the line up.
                         // Does the first person in this child node have parents? If yes, then it's the child (pos: 0). Otherwise, it's the spouse and the child is at position 2.
                         $nPosition = $this->individuals[$aChild['ids'][0]]['father'] || $this->individuals[$aChild['ids'][0]]['mother'] ? 0 : 2;
                         // Space at left?
                         $nSpace = $aChild['tree_width'] < $aChild['own_width'] ? 0 : $aChild['tree_width'] - $aChild['own_width'];
                         // 0 or more.
                         for ($i = $nSpace / 2 + $nPosition + (int) ($nChild > 0); $i > 0; $i--) {
                             $aNextTreeChildren[] = !$nChild ? '' : '10';
                         }
                         // The icon connecting the child with the parent.
                         $aNextTreeChildren[] = !$nChild ? '06' : ($nChild == $nChildren - 1 ? '12' : '14');
                         // If there is a spouse on the right, fill the gap.
                         if ($bSpouse && !$nPosition) {
                             $s = $nChild == $nChildren - 1 ? '' : '10';
                             $aNextTreeChildren[] = $s;
                             $aNextTreeChildren[] = $s;
                         }
                         // Space at right?
                         for ($i = $nSpace / 2; $i > 0; $i--) {
                             $aNextTreeChildren[] = $nChild == $nChildren - 1 ? '' : '10';
                         }
                     }
                     // Now, add the line upwards to the parents, exactly in the middle.
                     $nMiddle = floor($aIndividual['tree_width'] / 2);
                     $aNextTreeChildren[$nMiddle] = sprintf('%02d', $aNextTreeChildren[$nMiddle] + 1);
                     $aNextTree = array_merge($aNextTree, $aNextTreeChildren);
                 }
                 $aNextGeneration = array_merge($aNextGeneration, $aIndividual['children']);
                 // The children need space around them, if the parents are wider than the children (thus, one child).
                 if ($aIndividual['tree_width'] < $aIndividual['own_width']) {
                     $aNextGeneration[] = '';
                 }
             }
         }
         print '  </TR>' . "\n";
         // Check if we have something to do.
         $bDone = true;
         foreach ($aNextGeneration as $sVal) {
             if ($sVal) {
                 $bDone = false;
                 break;
             }
         }
         if ($bDone) {
             break;
         }
         $a = $aNextGeneration;
     }
     print '</TABLE>' . "\n";
 }
예제 #6
0
파일: columns.php 프로젝트: LOVDnl/LOVD3
     lovd_errorClean();
     // Mandatory fields.
     if (empty($_POST['password'])) {
         lovd_errorAdd('password', 'Please fill in the \'Enter your password for authorization\' field.');
     }
     // User had to enter his/her password for authorization.
     if ($_POST['password'] && !lovd_verifyPassword($_POST['password'], $_AUTH['password'])) {
         lovd_errorAdd('password', 'Please enter your correct password for authorization.');
     }
     if (!lovd_error()) {
         // Query text.
         $_DATA->deleteEntry($sColumnID);
         // Write to log...
         lovd_writeLog('Event', LOG_EVENT, 'Deleted column ' . $sColumnID);
         // Thank the user...
         header('Refresh: 3; url=' . lovd_getInstallURL() . $_PE[0] . '/' . $sCategory);
         $_T->printHeader();
         $_T->printTitle();
         lovd_showInfoTable('Successfully deleted the column ' . $sColumnID . '!', 'success');
         $_T->printFooter();
         exit;
     } else {
         // Because we're sending the data back to the form, I need to unset the password field!
         unset($_POST['password']);
     }
 }
 $_T->printHeader();
 $_T->printTitle();
 lovd_errorPrint();
 // Table.
 print '      <FORM action="' . CURRENT_PATH . '?' . ACTION . '" method="post">' . "\n";
예제 #7
0
파일: phenotypes.php 프로젝트: LOVDnl/LOVD3
     }
     if (!lovd_error()) {
         // Get genes which are modified before we delete the entry.
         // Only when phenotype, individual and variant are marked or public.
         if ($zData['statusid'] >= STATUS_MARKED) {
             $aGenes = $_DB->query('SELECT DISTINCT t.geneid FROM ' . TABLE_TRANSCRIPTS . ' AS t ' . 'INNER JOIN ' . TABLE_VARIANTS_ON_TRANSCRIPTS . ' AS vot ON (vot.transcriptid = t.id) ' . 'INNER JOIN ' . TABLE_VARIANTS . ' AS vog ON (vog.id = vot.id) ' . 'INNER JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (s2v.variantid = vog.id) ' . 'INNER JOIN ' . TABLE_SCREENINGS . ' AS s ON (s.id = s2v.screeningid) ' . 'INNER JOIN ' . TABLE_INDIVIDUALS . ' AS i ON (i.id = s.individualid) ' . 'INNER JOIN ' . TABLE_PHENOTYPES . ' AS p ON (p.individualid = i.id) ' . 'WHERE vog.statusid >= ? AND i.statusid >= ? AND p.id = ?', array(STATUS_MARKED, STATUS_MARKED, $nID))->fetchAllColumn();
         }
         $_DATA->deleteEntry($nID);
         if ($zData['statusid'] >= STATUS_MARKED && $aGenes) {
             // Change updated date for genes.
             lovd_setUpdatedDate($aGenes);
         }
         // Write to log...
         lovd_writeLog('Event', LOG_EVENT, 'Deleted phenotype information entry ' . $nID . ' (Owner: ' . $zData['owner'] . ')');
         // Thank the user...
         header('Refresh: 3; url=' . lovd_getInstallURL() . 'individuals/' . $zData['individualid']);
         $_T->printHeader();
         $_T->printTitle();
         lovd_showInfoTable('Successfully deleted the phenotype information entry!', 'success');
         $_T->printFooter();
         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();
 lovd_errorPrint();
 // Table.
 print '      <FORM action="' . CURRENT_PATH . '?' . ACTION . '" method="post">' . "\n";
예제 #8
0
파일: index.php 프로젝트: LOVDnl/LOVD3
    lovd_errorPrint();
    // Tooltip JS code.
    lovd_includeJS('inc-js-tooltip.php');
    // Allow checking the database URL.
    lovd_includeJS('inc-js-submit-settings.php');
    // Table.
    print '      <FORM action="install/?step=' . $_GET['step'] . '&amp;sent=true" method="post">' . "\n";
    // Array which will make up the form table.
    $aForm = array_merge($_SYSSETTING->getForm(), array('skip', array('', '', 'submit', 'Continue &raquo;')));
    lovd_viewForm($aForm);
    print '</FORM>' . "\n\n";
    $_T->printFooter();
    exit;
} elseif ($_GET['step'] == 3) {
    $_GET['step']++;
}
if ($_GET['step'] == 4) {
    // Step 5: Done.
    if (!($_DB->query('SHOW TABLES LIKE "' . TABLE_CONFIG . '"')->fetchColumn() && $_DB->query('SELECT COUNT(*) FROM ' . TABLE_CONFIG)->fetchColumn())) {
        // Didn't finish previous step correctly.
        //header('Location: ' . PROTOCOL . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '?step=' . ($_GET['step'] - 2));
        header('Location: ' . PROTOCOL . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '?step=' . ($_GET['step'] - 1));
        exit;
    }
    $_T->printHeader();
    lovd_printSideBar();
    lovd_writeLog('Install', 'Installation', 'Installation of LOVD ' . $_STAT['version'] . ' complete');
    print '      <B>Done</B><BR>' . "\n" . '      <BR>' . "\n\n" . '      The installation of LOVD ' . $_STAT['version'] . ' is now complete.<BR>' . "\n" . '      <BR>' . "\n\n" . '      <BUTTON onclick="window.location.href=\'' . lovd_getInstallURL() . 'setup?newly_installed\';" style="font-weight : bold; font-size : 11px;">Continue to Setup area &gt;&gt;</BUTTON>' . "\n\n";
    $_T->printFooter();
    exit;
}
예제 #9
0
파일: submit.php 프로젝트: LOVDnl/LOVD3
    if (!empty($aSubmit['variants'])) {
        $aBody['variant_details'] = $aVariantDetails;
    }
    if (!empty($aSubmit['uploads'])) {
        $aBody['upload_details'] = $aUploadDetails;
    }
    require ROOT_PATH . 'inc-lib-form.php';
    $sBody = lovd_formatMail($aBody);
    // Set proper subject.
    $sSubject = 'LOVD submission' . (ACTION != 'edit' ? '' : ' update') . (!empty($aGenes) ? ' (' . implode(', ', array_slice($aGenes, 0, 20)) . (count($aGenes) > 20 ? ', ...' : '') . ')' : '');
    // Don't just change this; lovd_sendMail() is parsing it.
    $aCC = array();
    // Set submitter address.
    $aCC[] = array($_AUTH['name'], $_AUTH['email']);
    // Get owners address.
    if (!empty($aOwner)) {
        $aCC = array_merge($aCC, $_DB->query('SELECT name, email FROM ' . TABLE_USERS . ' WHERE id IN (?' . str_repeat(', ?', count($aOwner) - 1) . ')', $aOwner)->fetchAllRow());
    }
    // Send mail.
    $bMail = lovd_sendMail($aTo, $sSubject, $sBody, $_SETT['email_headers'], true, $_CONF['send_admin_submissions'], $aCC);
    // FIXME; When messaging system is built in, maybe queue message for curators?
    if ($bMail) {
        lovd_showInfoTable('Successfully processed your submission and sent an email notification to the relevant curator(s)!', 'success');
        // Forward only if there was no error sending the email.
        print '      <SCRIPT type="text/javascript">setTimeout("window.location.href=\'' . lovd_getInstallURL() . $sURI . $nID . '\'", 3000);</SCRIPT>' . "\n";
    } else {
        lovd_showInfoTable('Successfully processed your submission, but LOVD wasn\'t able to send an email notification to the relevant curator(s)!<BR>Please contact one of the relevant curators and notify them of your submission so that they can curate your data!', 'warning');
    }
    $_T->printFooter();
    exit;
}
예제 #10
0
파일: variants.php 프로젝트: LOVDnl/LOVD3
    $_GET['search_chromosome'] = '="' . $zData['chromosome'] . '"';
    require ROOT_PATH . 'class/object_custom_viewlists.php';
    $_DATA = new LOVD_CustomViewList(array('Gene', 'Transcript', 'DistanceToVar'), $zData['id']);
    // DistanceToVar needs the VariantID.
    $_DATA->setRowLink('VOT_map', 'javascript:lovd_addTranscript(\'{{ViewListID}}\', \'{{ID}}\', \'{{zData_geneid}}\', \'{{zData_name}}\', \'{{zData_id_ncbi}}\'); return false;');
    $_DATA->viewList('VOT_map', array(), true);
    print '      <BR><BR>' . "\n\n";
    lovd_showInfoTable('The variant entry is currently mapped to the following transcripts. Click on the cross at the right side of the transcript to remove the mapping.', 'information');
    print '      <TABLE class="sortable_head" style="width : 652px;"><TR><TH width="100">Gene</TH>' . '<TH style="text-align : left;">Name</TH><TH width="123" style="text-align : left;">Transcript ID</TH><TH width="20">&nbsp;</TH>' . '</TR></TABLE>' . "\n" . '      <FORM action="' . CURRENT_PATH . '?' . ACTION . '" method="post">' . "\n" . '        <UL id="transcript_list" class="sortable" style="margin-top : 0px; width : 650px;">' . "\n";
    // Now loop the items in the order given.
    foreach ($aVOT as $aTranscript) {
        print '          <LI id="li_' . $aTranscript['id'] . '"><INPUT type="hidden" name="transcripts[]" value="' . $aTranscript['id'] . '"><TABLE width="100%"><TR><TD width="98">' . $aTranscript['geneid'] . '</TD>' . '<TD align="left">' . $aTranscript['name'] . '</TD><TD width="120" align="left">' . $aTranscript['id_ncbi'] . '</TD><TD width="20" align="right"><A href="#" onclick="lovd_removeTranscript(\'VOT_map\', \'' . $aTranscript['id'] . '\', \'' . $aTranscript['id_ncbi'] . '\'); return false;"><IMG src="gfx/mark_0.png" alt="Remove" width="11" height="11" border="0"></A></TD>' . '</TR></TABLE></LI>' . "\n";
    }
    print '        </UL>' . "\n";
    // Array which will make up the form table.
    $aForm = array(array('POST', '', '', '', '0%', '0', '100%'), array('', '', 'print', 'Enter your password for authorization'), array('', '', 'password', 'password', 20), array('', '', 'print', '<INPUT type="submit" value="Save transcript list">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT type="submit" value="Cancel" onclick="window.location.href=\'' . lovd_getInstallURL() . CURRENT_PATH . '\'; return false;" style="border : 1px solid #FF4422;">'));
    lovd_viewForm($aForm);
    print "\n" . '      </FORM>' . "\n\n";
    ?>

      <SCRIPT type='text/javascript'>
        function lovd_addTranscript (sViewListID, nID, sGene, sName, sNM)
        {
            // Moves the transcript to the variant mapping block and removes the row from the viewList.
            var objViewListF = document.getElementById('viewlistForm_' + sViewListID);
            var objElement = document.getElementById(nID);
            objElement.style.cursor = 'progress';

            var objUsers = document.getElementById('transcript_list');
            var oLI = document.createElement('LI');
            oLI.id = 'li_' + nID;
예제 #11
0
파일: users.php 프로젝트: LOVDnl/LOVD3
    }
    list($aColleagues, $sColTable) = lovd_colleagueTableHTML($nID, $sUserListID, $aColleagues, $bAllowGrantEdit);
    $_T->printHeader();
    $_T->printTitle();
    lovd_errorPrint();
    lovd_showInfoTable('To share access with other users, find the user in the list below, click on
                       the user to add him to the selection. Then click <B>save</B> to save the
                       changes.', 'information');
    // Set number of items per page for viewlist.
    $_GET['page_size'] = 10;
    // Set filter for viewlist to hide current colleagues and the user being viewed.
    $_GET['search_userid'] = '!' . $nID;
    foreach ($aColleagues as $aColleague) {
        $_GET['search_userid'] .= ' !' . $aColleague['id'];
    }
    // Show viewlist to select new users to share access with.
    $_DATA = new LOVD_User();
    $_DATA->setRowLink('users_share_access', 'javascript:lovd_passAndRemoveViewListRow("{{ViewListID}}", "{{ID}}", {id: "{{ID}}", name: "{{zData_name}}"}, lovd_addUserShareAccess); return false;');
    // The columns hidden here are also specified (enforced) in ajax/viewlist.php to make sure Submitters can't hack their way into the users table.
    $_DATA->viewList($sUserListID, array('username', 'status_', 'last_login_', 'created_date_', 'curates', 'level_'), true);
    lovd_showInfoTable('<B>' . $zData['name'] . ' (' . $nID . ')</B> shares access to all
                       data owned by him with the users listed below.', 'information');
    print '<FORM action="users/' . $nID . '?share_access" method="post">' . "\n";
    // Array which will make up the form table.
    print $sColTable . "\n";
    $aForm = array(array('POST', '', '', '', '0%', '0', '100%'), array('', '', 'print', 'Enter your password for authorization'), array('', '', 'password', 'password', 20), array('', '', 'print', '<INPUT type="submit" value="Save access permissions">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT type="submit" value="Cancel" onclick="window.location.href=\'' . lovd_getInstallURL() . $_PE[0] . '/' . $nID . '\'; return false;" style="border : 1px solid #FF4422;">'));
    lovd_viewForm($aForm);
    print '</FORM>';
    $_T->printFooter();
    exit;
}
예제 #12
0
파일: api.php 프로젝트: LOVDnl/LOVD3
            $n--;
            // Does not really matter at this point.
            continue;
        }
        $sContent = 'symbol:' . $sSymbol . "\n" . ($bUnique ? '' : 'id:' . $zData['id'] . "\n") . 'position_mRNA:' . $sPosition_mRNA . "\n" . 'position_genomic:' . $sPosition_genomic . "\n" . 'Variant/DNA:' . htmlspecialchars($zData['VariantOnTranscript/DNA']) . "\n" . 'Variant/DBID:' . $zData['VariantOnGenome/DBID'] . "\n" . 'Times_reported:' . $zData['Times'];
        $_FEED->addEntry($sTitle, $sSelfURL, $sAltURL, $sID, $zData['created_by'], $zData['created_date'], $sContributors, $zData['updated_date'], '', 'text', $sContent);
    }
} elseif ($sDataType == 'genes') {
    foreach ($aData as $zData) {
        // Prepare other fields to be included.
        $sTitle = $zData['id'];
        if ($sFeedType == 'feed') {
            $sSelfURL = ($_CONF['location_url'] ? $_CONF['location_url'] : lovd_getInstallURL()) . 'api/rest.php/genes/' . $zData['id'];
        } else {
            $sSelfURL = '';
        }
        $sChromosome = $zData['chromosome'];
        $sAltURL = ($_CONF['location_url'] ? $_CONF['location_url'] : lovd_getInstallURL()) . 'genes/' . $zData['id'];
        $sID = 'tag:' . $_SERVER['HTTP_HOST'] . ',' . substr($zData['created_date'], 0, 10) . ':' . $zData['id'];
        $sContributors = '';
        $sContributors .= ($sContributors ? ', ' : '') . htmlspecialchars($zData['curators']);
        $sContent = 'id:' . $zData['id'] . "\n" . 'entrez_id:' . $zData['id_entrez'] . "\n" . 'symbol:' . $zData['id'] . "\n" . 'name:' . $zData['name'] . "\n" . 'chromosome_location:' . $zData['chromosome'] . $zData['chrom_band'] . "\n" . 'position_start:chr' . $sChromosome . ':' . ($zData['sense'] ? $zData['position_g_mrna_start'] : $zData['position_g_mrna_end']) . "\n" . 'position_end:chr' . $sChromosome . ':' . ($zData['sense'] ? $zData['position_g_mrna_end'] : $zData['position_g_mrna_start']) . "\n" . 'refseq_genomic:' . $zData['refseq_genomic'] . "\n" . 'refseq_mrna:' . $zData['id_ncbi'] . "\n" . 'refseq_build:' . $_CONF['refseq_build'];
        $_FEED->addEntry($sTitle, $sSelfURL, $sAltURL, $sID, $zData['created_by'], $zData['created_date'], $sContributors, $zData['updated_date'], '', 'text', $sContent);
    }
}
if (!$n) {
    // This happens if searching on position and there is a partial match. MySQL returns a false positive which has been filtered out now.
    header('HTTP/1.0 404 Not Found');
    // This will replace the previous 200 OK status!
}
$_FEED->publish();
예제 #13
0
function lovd_soapError($e, $bHalt = true)
{
    // Formats SOAP errors for the error log, and optionally halts the system.
    if (!is_object($e)) {
        return false;
    }
    // Try to detect if arguments have been passed, and isolate them from the stacktrace.
    $sMethod = '';
    $sArgs = '';
    foreach ($e->getTrace() as $aTrace) {
        if (isset($aTrace['function']) && $aTrace['function'] == '__call') {
            // This is the low level SOAP call. Isolate used method and arguments from here.
            list($sMethod, $aArgs) = $aTrace['args'];
            if ($aArgs && is_array($aArgs) && isset($aArgs[0])) {
                $aArgs = $aArgs[0];
                // Not sure why the call's argument are in a sub array, but oh, well.
                foreach ($aArgs as $sArg => $sValue) {
                    $sArgs .= (!$sArgs ? '' : "\n") . "\t\t" . $sArg . ':' . $sValue;
                }
            }
            break;
        }
    }
    // Format the error message.
    $sError = preg_replace('/^' . preg_quote(rtrim(lovd_getInstallURL(false), '/'), '/') . '/', '', $_SERVER['REQUEST_URI']) . ' returned error in module \'' . $sMethod . '\'.' . "\n" . (!$sArgs ? '' : 'Arguments:' . "\n" . $sArgs . "\n") . 'Error message:' . "\n" . str_replace("\n", "\n\t\t", $e->__toString());
    // If the system needs to be halted, send it through to lovd_displayError() who will print it on the screen,
    // write it to the system log, and halt the system. Otherwise, just log it to the database.
    if ($bHalt) {
        return lovd_displayError('SOAP', $sError);
    } else {
        return lovd_writeLog('Error', 'SOAP', $sError);
    }
}
예제 #14
0
파일: index.php 프로젝트: LOVDnl/LOVD3
 *
 * This file is part of LOVD.
 *
 * LOVD is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * LOVD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with LOVD.  If not, see <http://www.gnu.org/licenses/>.
 *
 *************/
define('ROOT_PATH', './');
require ROOT_PATH . 'inc-init.php';
// Send manager and database administrator to setup, curators to the config, with selected database to the gene homepage, the rest to the gene listing.
if ($_AUTH && $_AUTH['level'] >= LEVEL_MANAGER) {
    $sFile = 'setup';
} elseif ($_AUTH && $_SESSION['currdb'] && lovd_isAuthorized('gene', $_SESSION['currdb'], false)) {
    $sFile = 'configuration';
} elseif ($_SESSION['currdb']) {
    $sFile = 'genes/' . $_SESSION['currdb'];
} else {
    $sFile = 'genes';
}
header('Location: ' . lovd_getInstallURL() . $sFile);
exit;
예제 #15
0
파일: references.php 프로젝트: LOVDnl/LOVD3
    if (empty($aCategories['Individual'])) {
        $nActiveTab = 0;
        $nDisabledTab = 1;
    } elseif (empty($aCategories['VariantOnGenome'])) {
        $nActiveTab = 1;
        $nDisabledTab = 0;
    }
    if (!empty($aCategories['VariantOnGenome'])) {
        require ROOT_PATH . 'class/object_genome_variants.php';
        $_DATAvariants = new LOVD_GenomeVariant();
    }
    if (!empty($aCategories['Individual'])) {
        require ROOT_PATH . 'class/object_individuals.php';
        $_DATAindividuals = new LOVD_Individual();
    }
    print '   <SCRIPT type="text/javascript">' . "\n" . '       $(function() {' . "\n" . '           $("#tabs").tabs({active: ' . $nActiveTab . ', disabled: [' . $nDisabledTab . ']});' . "\n" . '       });' . "\n" . '   </SCRIPT>' . "\n" . '   <DIV id="tabs">' . "\n" . '       <UL>' . "\n" . '           <LI><A href="' . lovd_getInstallURL() . implode('/', $_PE) . '#tabs-variants">Variants</A></LI>' . "\n" . '           <LI><A href="' . lovd_getInstallURL() . implode('/', $_PE) . '#tabs-individuals">Individuals</A></LI>' . "\n" . '       </UL>' . "\n" . '       <DIV id="tabs-variants">' . "\n";
    if (!empty($_DATAvariants)) {
        $_DATAvariants->viewList('Variants_per_reference', $aColsToHide['VariantOnGenome'], true, true);
    }
    print '       </DIV>' . "\n" . '       <DIV id="tabs-individuals">' . "\n";
    if (!empty($_DATAindividuals)) {
        $_DATAindividuals->viewList('Individuals_per_reference', $aColsToHide['Individual'], true, true);
    }
    print '       </DIV>' . "\n" . '   </DIV>';
    $_T->printFooter();
    exit;
}
if ($bImage) {
    header('Content-type: image/png');
    readfile(ROOT_PATH . 'gfx/trans.png');
    exit;
예제 #16
0
    // Check if password field is empty.
    var sViewlistFormSelector = '#viewlistForm_' + sViewListID;
    if ($(sViewlistFormSelector).find(':password').val() == '') {
        alert('Please fill in your password to authorize.');
        return false;
    }

    var sFRRowsAffected = $('#FRRowsAffected_' + sViewListID).val();
    if (!window.confirm('You are about to modify ' + sFRRowsAffected +
                        ' records. Do you wish to continue?')) {
        return false;
    }

    // Submit a find & replace action for the given viewlist.
    var postResponse = $.post('<?php 
echo lovd_getInstallURL() . 'ajax/viewlist.php?applyFR';
?>
',
                              $(sViewlistFormSelector).serialize(), null, 'text');

    var sDisplayname = '';
    if (FRState.hasOwnProperty(sViewListID)) {
        sDisplayname = FRState[sViewListID]['sDisplayname'];
    }

    postResponse.done(function(sData) {
        // Fixme: consider requiring inc-init.php to use AJAX_* constants for checking response.
        if (sData === '1') {
            // Clean up F&R settings menu.
            lovd_FRCleanup(sViewListID, true, function() {
                // Show confirmation after cleanup.
예제 #17
0
파일: objects.php 프로젝트: LOVDnl/LOVD3
    function viewList($sViewListID = false, $aColsToSkip = array(), $bNoHistory = false, $bHideNav = false, $bOptions = false, $bOnlyRows = false, $bFindReplace = false)
    {
        // Show a viewlist for the current object.
        // Params:
        // bFindReplace     if true, find & replace option is shown in viewlist options menu.
        // Views list of entries in the database, allowing search.
        global $_DB, $_INI, $_SETT;
        if (!defined('LOG_EVENT')) {
            define('LOG_EVENT', $this->sObject . '::viewList()');
        }
        if (FORMAT == 'text/plain' && !defined('FORMAT_ALLOW_TEXTPLAIN')) {
            die('text/plain not allowed here');
        }
        $bAjax = substr(lovd_getProjectFile(), 0, 6) == '/ajax/';
        // ViewLists need an ID to identify the specific viewList, in case there are a few in one document.
        if (!$sViewListID || !is_string($sViewListID)) {
            $sViewListID = lovd_generateRandomID();
        } else {
            $sViewListID = preg_replace('/[^A-Z0-9._-]+/i', '', $sViewListID);
        }
        if (!is_array($aColsToSkip)) {
            $aColsToSkip = array($aColsToSkip);
        }
        foreach ($this->aColumnsViewList as $sCol => $aCol) {
            if (!$aCol['view'] && !in_array($sCol, $aColsToSkip)) {
                $aColsToSkip[] = $sCol;
            }
        }
        require_once ROOT_PATH . 'inc-lib-viewlist.php';
        // First, check if entries are in the database at all.
        $nTotal = $this->getCount();
        if (!$nTotal && FORMAT == 'text/html') {
            if ($bOnlyRows) {
                die('0');
                // Silent error.
            }
            lovd_showInfoTable('No entries in the database yet!', 'stop');
            return 0;
        }
        // Process search fields (i.e. $_GET['search_...'] values) for viewlist.
        list($WHERE, $HAVING, $aArguments, $aBadSyntaxColumns, $aColTypes) = $this->processViewListSearchArgs($_GET);
        if ($WHERE) {
            $this->aSQLViewList['WHERE'] .= ($this->aSQLViewList['WHERE'] ? ' AND ' : '') . $WHERE;
        }
        if ($HAVING) {
            $this->aSQLViewList['HAVING'] .= ($this->aSQLViewList['HAVING'] ? ' AND ' : '') . $HAVING;
        }
        // SORT: Current settings, also implementing XSS check.
        if (!empty($_GET['order']) && $_GET['order'] === strip_tags($_GET['order'])) {
            $aOrder = explode(',', $_GET['order']);
        } else {
            $aOrder = array('', '');
        }
        // SORT: Verify request and set default.
        if (empty($this->aColumnsViewList[$aOrder[0]]['db'][1])) {
            $aOrder[0] = $this->sSortDefault;
        }
        if ($aOrder[1] != 'ASC' && $aOrder[1] != 'DESC') {
            $aOrder[1] = $this->aColumnsViewList[$aOrder[0]]['db'][1];
        }
        $sSQLOrderBy = $this->aColumnsViewList[$aOrder[0]]['db'][0] . ' ' . $aOrder[1];
        if (in_array($aOrder[0], array('chromosome', 'VariantOnGenome/DNA'))) {
            // 2014-03-07; 3.0-10; We need to find the table alias of the VOG or genes table, because otherwise MySQL fails here ('chromosome' is ambiguous) if both are joined.
            // 2014-04-28; 3.0-10; Prefer the genes table, since it joins to VOG as well, but may not have results which messes up the order.
            $sAlias = '';
            if (preg_match('/' . TABLE_GENES . ' AS ([a-z]+)/i', $this->aSQLViewList['FROM'], $aRegs)) {
                $sAlias = $aRegs[1];
            } elseif (preg_match('/' . TABLE_VARIANTS . ' AS ([a-z]+)/i', $this->aSQLViewList['FROM'], $aRegs)) {
                $sAlias = $aRegs[1];
            }
            $this->aSQLViewList['FROM'] .= ' LEFT OUTER JOIN ' . TABLE_CHROMOSOMES . ' AS chr ON (' . (!$sAlias ? '' : $sAlias . '.') . 'chromosome = chr.name)';
            $sSQLOrderBy = 'chr.sort_id ' . $aOrder[1];
            if ($aOrder[0] == 'VariantOnGenome/DNA') {
                $sSQLOrderBy .= ', position_g_start ' . $aOrder[1] . ', position_g_end ' . $aOrder[1] . ', `VariantOnGenome/DNA` ' . $aOrder[1];
            }
        } elseif ($aOrder[0] == 'VariantOnTranscript/DNA') {
            $sSQLOrderBy = 'position_c_start ' . $aOrder[1] . ', position_c_start_intron ' . $aOrder[1] . ', position_c_end ' . $aOrder[1] . ', position_c_end_intron ' . $aOrder[1] . ', `VariantOnTranscript/DNA` ' . $aOrder[1];
        }
        // At this point, we're not sure if we'll actually use the ORDER BY at all.
        $this->aSQLViewList['ORDER_BY'] = $sSQLOrderBy . (empty($this->aSQLViewList['ORDER_BY']) ? '' : ', ' . $this->aSQLViewList['ORDER_BY']);
        // Only print stuff if we're not in Ajax right now.
        if (!$bAjax && FORMAT == 'text/html') {
            // Keep the URL clean; disable any fields that are not used.
            lovd_includeJS('inc-js-viewlist.php' . (!$bNoHistory ? '' : '?nohistory'));
            lovd_includeJS('inc-js-tooltip.php');
            // Print form; required for sorting and searching.
            // Because we don't want the form to submit itself while we are waiting for the Ajax response, we need to kill the native submit() functionality.
            print '      <FORM action="' . CURRENT_PATH . '" method="get" id="viewlistForm_' . $sViewListID . '" style="margin : 0px;" onsubmit="return false;">' . "\n" . '        <INPUT type="hidden" name="viewlistid" value="' . $sViewListID . '">' . "\n" . '        <INPUT type="hidden" name="object" value="' . $this->sObject . '">' . "\n" . (!isset($this->sObjectID) ? '' : '        <INPUT type="hidden" name="object_id" value="' . $this->sObjectID . '">' . "\n") . (!isset($this->nID) ? '' : '        <INPUT type="hidden" name="id" value="' . $this->nID . '">' . "\n") . (!ACTION ? '' : '        <INPUT type="hidden" name="' . ACTION . '" value="">' . "\n") . '        <INPUT type="hidden" name="order" value="' . implode(',', $aOrder) . '">' . "\n";
            // Skipping (permanently hiding) columns.
            foreach ($aColsToSkip as $sCol) {
                if (array_key_exists($sCol, $this->aColumnsViewList)) {
                    // Internet Explorer refuses to submit input with equal names. If names are different, everything works fine.
                    // Somebody please tell me it's a bug and nobody's logical thinking. Had to include $sCol to make it work.
                    print '        <INPUT type="hidden" name="skip[' . $sCol . ']" value="' . $sCol . '">' . "\n";
                    // Check if we're skipping columns, that do have a search value. If so, it needs to be sent on like this.
                    if (isset($_GET['search_' . $sCol])) {
                        print '        <INPUT type="hidden" name="search_' . $sCol . '" value="' . htmlspecialchars($_GET['search_' . $sCol]) . '">' . "\n";
                    }
                }
            }
            if ($bHideNav) {
                print '        <INPUT type="hidden" name="hidenav" value="true">' . "\n";
            }
            if ($bOptions) {
                print '        <INPUT type="hidden" name="options" value="true">' . "\n";
            }
            print "\n";
        }
        // Make a reference variable of the session for cleaner code.
        $aSessionViewList =& $_SESSION['viewlists'][$sViewListID];
        // To make row ids persist when the viewList is refreshed, we must store the row id in $_SESSION.
        if (!empty($aSessionViewList['row_id'])) {
            $this->sRowID = $aSessionViewList['row_id'];
        } else {
            $aSessionViewList['row_id'] = $this->sRowID;
            // Implies array creation.
        }
        // To make row links persist when the viewList is refreshed, we must store the row link in $_SESSION.
        if (!empty($aSessionViewList['row_link'])) {
            $this->sRowLink = $aSessionViewList['row_link'];
        } else {
            $aSessionViewList['row_link'] = $this->sRowLink;
            // Implies array creation.
        }
        // Process input values regarding find & replace.
        // User clicked preview.
        $bFRPreview = !empty($_GET['FRPreviewClicked_' . $sViewListID]);
        // Selected field name for replace.
        $sFRFieldname = isset($_GET['FRFieldname_' . $sViewListID]) ? $_GET['FRFieldname_' . $sViewListID] : null;
        // Display name of selected field.
        $sFRFieldDisplayname = isset($_GET['FRFieldDisplayname_' . $sViewListID]) ? $_GET['FRFieldDisplayname_' . $sViewListID] : null;
        // Search query for find & replace.
        $sFRSearchValue = isset($_GET['FRSearch_' . $sViewListID]) ? $_GET['FRSearch_' . $sViewListID] : null;
        // Replace value for find & replace.
        $sFRReplaceValue = isset($_GET['FRReplace_' . $sViewListID]) ? $_GET['FRReplace_' . $sViewListID] : null;
        // Type of matching.
        $sFRMatchType = isset($_GET['FRMatchType_' . $sViewListID]) ? $_GET['FRMatchType_' . $sViewListID] : null;
        // Flag stating whether all field content sould be replaced.
        $bFRReplaceAll = !empty($_GET['FRReplaceAll_' . $sViewListID]);
        // Predicted affected row count.
        $nFRRowsAffected = null;
        // Find & replace options parameter.
        $aFROptions = array('sFRMatchType' => $sFRMatchType, 'bFRReplaceAll' => $bFRReplaceAll);
        $nTotal = 0;
        // Overwrites the previous $nTotal.
        if (!count($aBadSyntaxColumns)) {
            // Build argument list.
            $aArgs = array_merge($aArguments['WHERE'], $aArguments['HAVING']);
            if ($bFRPreview) {
                // User clicked 'preview' in Find&Replace form, add F&R changes as a separate
                // column in the query.
                $nFRRowsAffected = $this->previewColumnFindAndReplace($sFRFieldname, $sFRFieldDisplayname, $sFRSearchValue, $sFRReplaceValue, $aArgs, $aFROptions);
            }
            // First find the amount of rows returned. We can use the SQL_CALC_FOUND_ROWS()
            // function, but we'll try to avoid that due to extreme slowness in some cases.
            // getRowCountForViewList() will take care of that.
            // There is talk about a possible race condition using this technique on the mysql_num_rows man page, but I could find no evidence of it's existence on InnoDB tables.
            // Just to be sure, I'm implementing a serializable transaction, which should lock the table between the two SELECT queries to ensure proper results.
            // Last checked 2010-01-25, by Ivo Fokkema.
            $_DB->query('SET TRANSACTION ISOLATION LEVEL SERIALIZABLE');
            $_DB->beginTransaction();
            // For ALL viewlists, we store the number of hits that we get, including the current filters.
            // For large tables, getting a count can take a long time (especially when using SQL_CALC_FOUND_ROWS).
            // ORDER BY is absolutely killing on large result sets.
            // So, long time to retrieve count (>1s) => don't count again, and no sort.
            // Count OK (<=1s), but big result set (250K) => no sort. ($_SETT['lists']['max_sortable_rows'])
            // 1) If we don't have a count in memory, request count separately.
            // Also if last count was >15min ago, request again.
            $bTrueCount = false;
            // Indicates whether or not we are sure about the number of results.
            $sFilterMD5 = md5($WHERE . '||' . $HAVING . '||' . implode('|', $aArgs));
            // A signature for the filters, NOTE that this depends on the column order!
            // FIXME: If this count takes longer than 1s, we don't estimate anymore like we used to (see line 1543).
            if (true || !isset($aSessionViewList['counts'][$sFilterMD5]['n'])) {
                $t = microtime(true);
                // Now, get the total number of hits if no LIMIT was used. Note that $nTotal gets overwritten here.
                $nTotal = $this->getRowCountForViewList($this->aSQLViewList, $aArgs);
                $tQ = microtime(true) - $t;
                $aSessionViewList['counts'][$sFilterMD5]['n'] = $nTotal;
                $aSessionViewList['counts'][$sFilterMD5]['t'] = $tQ;
                $aSessionViewList['counts'][$sFilterMD5]['d'] = time();
                $bTrueCount = true;
            }
            // Manipulate SELECT to include SQL_CALC_FOUND_ROWS.
            $bSQLCALCFOUNDROWS = false;
            // TODO: Remove this block. For now, this will be bypassed because $bTrueCount will always be true.
            if (!$bTrueCount && $_INI['database']['driver'] == 'mysql' && ($aSessionViewList['counts'][$sFilterMD5]['t'] < 1 || $aSessionViewList['counts'][$sFilterMD5]['d'] < time() - 60 * 15)) {
                // But only if we're using MySQL and it takes less than a second to get the correct number of results, or it's been more than 15 minutes since the last check!
                $this->aSQLViewList['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $this->aSQLViewList['SELECT'];
                $bSQLCALCFOUNDROWS = true;
            }
            if ($bOptions) {
                // If the session variable does not exist, create it!
                if (!isset($aSessionViewList['checked'])) {
                    $aSessionViewList['checked'] = array();
                }
                if (isset($_GET['ids_changed'])) {
                    if ($_GET['ids_changed'] == 'all') {
                        // If the select all button was clicked, fetch all entries and mark them as 'checked' in session.
                        // This query is the same as the viewList query, but without the ORDER BY and LIMIT, so that we can get the full result
                        // of the query.
                        $sSQL = $this->buildSQL(array('SELECT' => $this->aSQLViewList['SELECT'], 'FROM' => $this->aSQLViewList['FROM'], 'WHERE' => $this->aSQLViewList['WHERE'], 'GROUP_BY' => $this->aSQLViewList['GROUP_BY'], 'HAVING' => $this->aSQLViewList['HAVING']));
                        $q = $_DB->query($sSQL, $aArgs);
                        while ($zData = $q->fetchAssoc()) {
                            $zData = $this->generateRowID($zData);
                            // We only need the row_id here for knowing which ones we need to check.
                            // 2015-09-18; 3.0-14; We need to run rawurldecode() or else Columns are not selectable this way.
                            $aSessionViewList['checked'][] = rawurldecode($zData['row_id']);
                        }
                    } elseif ($_GET['ids_changed'] == 'none') {
                        // If the unselect all button was clicked, reset the 'checked' array.
                        $aSessionViewList['checked'] = array();
                    } else {
                        // Get the changed ids and remove them from or add them to the session.
                        $aIDsChanged = explode(';', $_GET['ids_changed']);
                        // Flip the keys & values, so that we can do a simple isset() to see if the id is already present.
                        $aSessionViewList['checked'] = array_flip($aSessionViewList['checked']);
                        // Determine the highest key number, so we can use that later when adding new values to the array.
                        $nIndex = count($aSessionViewList['checked']) ? max($aSessionViewList['checked']) + 1 : 0;
                        foreach ($aIDsChanged as $nID) {
                            if (isset($aSessionViewList['checked'][$nID])) {
                                // ID is found in the array, but is also in the 'ids_changed' array, so remove it!
                                unset($aSessionViewList['checked'][$nID]);
                            } else {
                                // ID is not found in the array, but IS in the 'ids_changed' array, so add it using the $nIndex as value we determined earlier.
                                // Also add 1 to the $nIndex so that the next id that needs to be added will not overwrite this one.
                                $aSessionViewList['checked'][$nID] = ++$nIndex;
                            }
                        }
                        // Flip the array back to its original state.
                        $aSessionViewList['checked'] = array_flip($aSessionViewList['checked']);
                    }
                }
            }
            // ORDER BY will only occur when we estimate we have time for it.
            if ($aSessionViewList['counts'][$sFilterMD5]['t'] < 1 && $aSessionViewList['counts'][$sFilterMD5]['n'] <= $_SETT['lists']['max_sortable_rows']) {
                $bSortableVL = true;
            } else {
                // Not sortable, indicate this on the VL...
                $aOrder = array('', '');
                $bSortableVL = false;
                // 2013-07-03; 3.0-07; However, we do try and sort because in principle, the order is random and this may cause confusion while paginating.
                //   So, as a result we'll try and sort on the PK. We attempt to determine this from the GROUP BY or ID col in the VL columns list.
                $sCol = '';
                if (isset($this->aSQLViewList['GROUP_BY'])) {
                    $sCol = $this->aSQLViewList['GROUP_BY'];
                } elseif ($this->aColumnsViewList['id']) {
                    $sCol = $this->aColumnsViewList['id']['db'][0];
                } elseif ($this->aColumnsViewList['id_']) {
                    $sCol = $this->aColumnsViewList['id_']['db'][0];
                }
                $this->aSQLViewList['ORDER_BY'] = $sCol;
            }
            if (!$bHideNav && FORMAT == 'text/html') {
                // Implement LIMIT only if navigation is not hidden.
                // We have a problem here, because we don't know how many hits there are,
                // because we're using SQL_CALC_FOUND_ROWS which only gives us the number
                // of hits AFTER we run the whole query. This means we should just assume
                // the page number is possible.
                $this->aSQLViewList['LIMIT'] = lovd_pagesplitInit();
                // Function requires variable names $_GET['page'] and $_GET['page_size'].
            }
            $sSQL = $this->buildSQL($this->aSQLViewList);
            // Run the viewList query.
            // FIXME; what if using AJAX? Probably we should generate a number here, if this query fails, telling the system to try once more. If that fails also, the JS should throw a general error, maybe.
            $q = $_DB->query($sSQL, $aArgs);
            // Now, get the total number of hits as if no LIMIT was used (when we have used the proper SELECT syntax). Note that $nTotal gets overwritten here.
            if ($bSQLCALCFOUNDROWS) {
                // FIXME: 't' needs to be recalculated as well!
                $nTotal = $_DB->query('SELECT FOUND_ROWS()')->fetchColumn();
                $aSessionViewList['counts'][$sFilterMD5]['n'] = $nTotal;
                $aSessionViewList['counts'][$sFilterMD5]['d'] = time();
                $bTrueCount = true;
            } else {
                // Estimate the number of results!
                $nTotal = $aSessionViewList['counts'][$sFilterMD5]['n'];
            }
            $_DB->commit();
            // To end the transaction and the locks that come with it.
        } else {
            // Set certain values that are needed for hiding notices, applicable for the "incorrect syntax" error message.
            $bTrueCount = true;
            // Yes, we're sure we have 0 results.
            $bSortableVL = false;
            // Sorting makes no sense when you have no results.
        }
        // If no results are found, try to figure out if it was because of the user's searching or not.
        if (!$nTotal) {
            $bSearched = false;
            $aHiddenSearch = array();
            foreach ($_GET as $key => $value) {
                if (substr($key, 0, 7) == 'search_') {
                    $sColumn = substr($key, 7);
                    if (!in_array($sColumn, $aColsToSkip)) {
                        $bSearched = true;
                    } elseif ($this->aColumnsViewList[$sColumn]['view']) {
                        $sColHeader = $this->aColumnsViewList[$sColumn]['view'][0];
                        // Make sure all hidden ID columns have "ID" in the header, so we can recognize them.
                        if (substr(rtrim($sColumn, '_'), -2) == 'id' && substr($sColHeader, -3) != ' ID') {
                            $sColHeader .= ' ID';
                        }
                        $aHiddenSearch[$sColHeader] = $value;
                    }
                }
            }
        }
        // FIXME; this is a temporary hack just to get the genes?authorize working when all users have been selected.
        //   There is no longer a viewList when all users have been selected, but we need one for the JS execution.
        //   Possibly, this code can be standardized a bit and, if necessary for other viewLists as well, can be kept here.
        if (!$nTotal && !$bSearched && ($this->sObject == 'User' && !empty($_GET['search_id']))) {
            // FIXME; Maybe check for JS contents of the rowlink?
            // There has been searched, but apparently the ID column is forced hidden. This must be the authorize page.
            $bSearched = true;
            // This will trigger the creation of the viewList table.
        }
        if (FORMAT == 'text/html' && ($nTotal || $bSearched)) {
            // Only print stuff if we're not just loading one entry right now.
            if (!$bOnlyRows) {
                if (!$bAjax) {
                    print '      <DIV id="viewlistDiv_' . $sViewListID . '">' . "\n";
                    // These contents will be replaced by Ajax.
                }
                // If we have a legend, create a hidden DIV that will be used for the full legend.
                print '      <DIV id="viewlistLegend_' . $sViewListID . '" title="Legend" style="display : none;">' . "\n" . '        <H2 class="LOVD">Legend</H2>' . "\n\n" . '        <I class="S11">Please note that a short description of a certain column can be displayed when you move your mouse cursor over the column\'s header and hold it still. Below, a more detailed description is shown per column.</I><BR><BR>' . "\n\n";
                $bLegend = false;
                // We need to check if we have a legend at all.
                foreach ($this->aColumnsViewList as $sField => $aCol) {
                    if (!empty($aCol['legend'])) {
                        $bLegend = true;
                        if (empty($aCol['legend'][1])) {
                            $aCol['legend'][1] = $aCol['legend'][0];
                        }
                        print '        <B>' . $aCol['view'][0] . '</B>: ' . $aCol['legend'][1];
                        if (substr($aCol['legend'][1], -5) == '</UL>') {
                            // No additional breaks, no possible listing of selection options. Column has its own UL already.
                            print "\n\n";
                            continue;
                        }
                        if (isset($this->aColumns[$sField]) && $this->aColumns[$sField]['form_type'][2] == 'select') {
                            // This is a custom column and it has a selection list with options. List the options below.
                            print '<BR>' . "\n" . '        All options:' . "\n" . '        <UL style="margin-top : 0px;">' . "\n";
                            foreach ($this->aColumns[$sField]['select_options'] as $sOption) {
                                print '          <LI>' . $sOption . '</LI>' . "\n";
                            }
                            print '      </UL>' . "\n\n";
                        } else {
                            print '<BR><BR>' . "\n\n";
                        }
                    }
                }
                print '      </DIV>' . "\n\n";
                if (!$bHideNav) {
                    lovd_pagesplitShowNav($sViewListID, $nTotal, $bTrueCount, $bSortableVL, $bLegend);
                }
                // 'checked' attribute values for find & replace menu options.
                $sFRMatchtypeCheck1 = !isset($sFRMatchType) || $sFRMatchType == '1' ? 'checked' : '';
                $sFRMatchtypeCheck2 = $sFRMatchType == '2' ? 'checked' : '';
                $sFRMatchtypeCheck3 = $sFRMatchType == '3' ? 'checked' : '';
                $sFRReplaceAllCheck = $bFRReplaceAll ? 'checked' : '';
                $sFRRowsAffected = !is_null($nFRRowsAffected) ? strval($nFRRowsAffected) : '';
                $sFRFieldname = htmlspecialchars($sFRFieldname);
                $sFRFieldDisplayname = htmlspecialchars($sFRFieldDisplayname);
                $sFRSearchValue = htmlspecialchars($sFRSearchValue);
                $sFRReplaceValue = htmlspecialchars($sFRReplaceValue);
                // Print options menu for find & replace (hidden by default).
                print <<<FROptions
<DIV id="viewlistFRFormContainer_{$sViewListID}" class="fnroptionsmenu" style="display: none;">
    <SPAN><B style="color: red">Note that find &amp; replace is still in BETA. Changes made using this feature are not checked for errors, therefore using find &amp; replace may have destructive consequences.<BR>Make a download or backup of the data you're about to edit. If uncertain, use the edit form of the data entries instead.</B><BR>
        Applying find &amp; replace to column
        &quot;<B id="viewlistFRColDisplay_{$sViewListID}">{$sFRFieldname}</B>&quot;.
        <INPUT id="FRFieldname_{$sViewListID}" type="hidden" name="FRFieldname_{$sViewListID}"
               value="{$sFRFieldname}" />
        <INPUT id="FRFieldDisplayname_{$sViewListID}" type="hidden"
               name="FRFieldDisplayname_{$sViewListID}" value="{$sFRFieldDisplayname}" />
        <INPUT id="FRRowsAffected_{$sViewListID}" type="hidden" value="{$sFRRowsAffected}" />
    </SPAN>
    <BR />
    <TABLE>
        <TR>
            <TD>Text to find</TD>
            <TD>
                <INPUT type="text" name="FRSearch_{$sViewListID}" value="{$sFRSearchValue}"
                       style="width: 110px" />
            </TD>
            <TD>
                <INPUT type="radio" name="FRMatchType_{$sViewListID}" value="1" {$sFRMatchtypeCheck1} />Match anywhere
                <INPUT type="radio" name="FRMatchType_{$sViewListID}" value="2" {$sFRMatchtypeCheck2} />Match at beginning of field
                <INPUT type="radio" name="FRMatchType_{$sViewListID}" value="3" {$sFRMatchtypeCheck3} />Match at end of field
            </TD>
        </TR>
        <TR>
            <TD>Replace with</TD>
            <TD>
                <INPUT type="text" name="FRReplace_{$sViewListID}" value="{$sFRReplaceValue}"
                       style="width: 110px" />
            </TD>
            <TD>
                <INPUT type="checkbox" name="FRReplaceAll_{$sViewListID}" value="1" {$sFRReplaceAllCheck} />Replace everything in field
            </TD>
        </TR>
    </TABLE>
    <INPUT id="FRPreview_{$sViewListID}" type="button" value="Preview" />
    <INPUT id="FRCancel_{$sViewListID}" type="button" value="Cancel" style="border : 1px solid #FF4422;" />
    <DIV id="FRSubmitDiv_{$sViewListID}">
        <BR>
        Enter your password to apply find and replace:<BR> 
        <INPUT type="password" name="password" size="20" />
        <INPUT id="FRSubmit_{$sViewListID}" type="submit" value="Submit" />
    </DIV>
</DIV>
FROptions;
                // Table and search headers (if applicable).
                print '      <TABLE border="0" cellpadding="0" cellspacing="1" class="data" id="viewlistTable_' . $sViewListID . '">' . "\n" . '        <THEAD>' . "\n" . '        <TR>' . ($bOptions ? "\n" . '          <TH valign="center" style="text-align:center;">' . "\n" . '            <IMG id="viewlistOptionsButton_' . $sViewListID . '" src="gfx/options.png" width="16" height="16" style="cursor : pointer;"></TH>' : '');
                foreach ($this->aColumnsViewList as $sField => $aCol) {
                    if (in_array($sField, $aColsToSkip)) {
                        continue;
                    }
                    $bSortable = !empty($aCol['db'][1]) && $bSortableVL;
                    // If we can't sort at all, nothing is sortable.
                    $bSearchable = !empty($aCol['db'][2]);
                    $nAllowFindAndReplace = (int) (!empty($aCol['allowfnr']));
                    // Later allow other columns as well, such as owned_by or statusid or so.
                    $sImg = '';
                    $sAlt = '';
                    if ($bSortable && $aOrder[0] == $sField) {
                        $sImg = $aOrder[1] == 'DESC' ? '_desc' : '_asc';
                        $sAlt = $aOrder[1] == 'DESC' ? 'Descending' : 'Ascending';
                    }
                    print "\n" . '          <TH valign="top"' . ($bSortable ? ' class="order' . ($aOrder[0] == $sField ? 'ed' : '') . '"' : '') . (empty($aCol['legend'][0]) ? '' : ' title="' . htmlspecialchars($aCol['legend'][0]) . '"') . ' data-allowfnr="' . $nAllowFindAndReplace . '" data-fieldname="' . $sField . '">' . "\n" . '            <IMG src="gfx/trans.png" alt="" width="' . $aCol['view'][1] . '" height="1" id="viewlistTable_' . $sViewListID . '_colwidth_' . $sField . '"><BR>' . (!$bSortable ? str_replace(' ', '&nbsp;', $aCol['view'][0]) . '<BR>' : "\n" . '            <DIV onclick="document.forms[\'viewlistForm_' . $sViewListID . '\'].order.value=\'' . $sField . ',' . ($aOrder[0] == $sField ? $aOrder[1] == 'ASC' ? 'DESC' : 'ASC' : $aCol['db'][1]) . '\'; if (document.forms[\'viewlistForm_' . $sViewListID . '\'].page) { document.forms[\'viewlistForm_' . $sViewListID . '\'].page.value=1; } lovd_AJAX_viewListSubmit(\'' . $sViewListID . '\');" style="position : relative;">' . "\n" . '              <IMG src="gfx/order_arrow' . $sImg . '.png" alt="' . $sAlt . '" title="' . $sAlt . '" width="13" height="12" style="position : absolute; top : 2px; right : 0px;">' . str_replace(' ', '&nbsp;', $aCol['view'][0]) . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</DIV>') . (!$bSearchable ? '' : "\n" . '            <INPUT type="text" name="search_' . $sField . '" value="' . (!isset($_GET['search_' . $sField]) ? '' : htmlspecialchars($_GET['search_' . $sField])) . '" title="' . $aCol['view'][0] . ' field should contain...' . (!empty($_GET['search_' . $sField]) ? "\nCurrent search:\n\n" . htmlspecialchars(lovd_formatSearchExpression($_GET['search_' . $sField], $aColTypes[$sField])) : '') . '" style="width : ' . ($aCol['view'][1] - 6) . 'px; font-weight : normal;" onkeydown="if (event.keyCode == 13) { if (document.forms[\'viewlistForm_' . $sViewListID . '\'].page) { document.forms[\'viewlistForm_' . $sViewListID . '\'].page.value=1; } setTimeout(\'lovd_AJAX_viewListSubmit(\\\'' . $sViewListID . '\\\')\', 0); return false;}">') . '</TH>';
                }
                print '</TR></THEAD>';
            }
        } elseif (FORMAT == 'text/plain') {
            // Download format: show headers.
            $sObject = $this->sObject == 'Custom_ViewList' ? $this->sObjectID : $this->sObject . 's';
            header('Content-type: text/plain; charset=UTF-8');
            header('Content-Disposition: attachment; filename="LOVD_' . $sObject . '_' . date('Y-m-d_H.i.s') . '.txt"');
            header('Pragma: public');
            print '### LOVD-version ' . lovd_calculateVersion($_SETT['system']['version']) . ' ### ' . $sObject . ' Quick Download format ### This file can not be imported ###' . "\r\n";
            // FIXME: this has to be done better, we can't see what we're filtering for, because it's in the arguments!
            $sFilter = $WHERE . ($WHERE && $HAVING ? ' AND ' : '') . $HAVING;
            if ($sFilter) {
                if (count($aArgs) == substr_count($sFilter, '?')) {
                    foreach ($aArgs as $sArg) {
                        $sFilter = preg_replace('/\\?/', ctype_digit($sArg) ? $sArg : '"' . $sArg . '"', $sFilter, 1);
                    }
                }
                print '## Filter: ' . $sFilter . "\r\n";
            }
            if (ACTION == 'downloadSelected') {
                print '## Filter: selected = ' . implode(',', $aSessionViewList['checked']) . "\r\n";
            }
            print '# charset=UTF-8' . "\r\n";
            $i = 0;
            foreach ($this->aColumnsViewList as $sField => $aCol) {
                if (in_array($sField, $aColsToSkip)) {
                    continue;
                }
                print ($i++ ? "\t" : '') . '"{{' . $sField . '}}"';
            }
            print "\r\n";
        }
        if (!$nTotal && FORMAT == 'text/html') {
            if ($bSearched) {
                // Searched, but no results. FIXME: link to the proper documentation entry about search expressions
                $sBadSyntaxColumns = implode(', ', array_unique($aBadSyntaxColumns));
                // FIXME; use an IF here.
                $sMessageNormal = 'No results have been found that match your criteria.<BR>Please redefine your search criteria.';
                $sMessageBadSyntax = 'Your search column' . (count($aBadSyntaxColumns) > 1 ? 's contain' : ' contains') . ' incorrect search expression syntax at: ' . $sBadSyntaxColumns . '.';
                $sMessage = empty($aBadSyntaxColumns) ? $sMessageNormal : $sMessageBadSyntax;
                if ($bOnlyRows) {
                    die('0');
                    // Silent error.
                }
                // FIXME; This code is sort of duplicated, some 100 lines below we also print this, *if* results are found.
                print '</TABLE><BR>' . "\n";
                // <BR> is necessary to keep the InfoTable apart from the data headers.
                if (!$bHideNav) {
                    print '        <INPUT type="hidden" name="total" value="' . $nTotal . '" disabled>' . "\n" . '        <INPUT type="hidden" name="page_size" value="' . $_GET['page_size'] . '">' . "\n" . '        <INPUT type="hidden" name="page" value="' . $_GET['page'] . '">' . "\n";
                }
                lovd_showInfoTable($sMessage, 'stop');
                print '      </DIV></FORM>' . "\n\n";
            } else {
                if ($bOnlyRows) {
                    die('0');
                    // Silent error.
                }
                print '      <DIV id="viewlistDiv_' . $sViewListID . '">' . "\n";
                // These contents will be replaced by Ajax.
                if (substr($this->sObject, -7) == 'Variant') {
                    $sUnit = 'variants' . (substr($this->sObject, 0, 10) == 'Transcript' ? ' on transcripts' : '');
                } elseif ($this->sObject == 'Custom_Viewlist') {
                    $sUnit = 'entries';
                } elseif ($this->sObject == 'Shared_Column') {
                    $sUnit = 'active columns';
                } else {
                    $sUnit = strtolower($this->sObject) . 's';
                }
                $sMessage = 'No ' . $sUnit . ' found';
                if (!empty($aHiddenSearch)) {
                    $sWhere = '';
                    foreach ($aHiddenSearch as $sCol => $sValue) {
                        // If the hidden column has "ID" in its name, it is the primary filter column.
                        if (substr($sCol, -3) == ' ID') {
                            $sWhere .= ($sWhere ? ' and ' : ' ') . 'for this ' . strtolower(substr($sCol, 0, -3));
                        } else {
                            $sWhere .= ($sWhere ? ' and ' : ' where ') . strtolower($sCol) . ' is "' . str_replace('|', '" or "', trim($sValue, '="') . '"');
                        }
                    }
                    $sMessage .= $sWhere;
                }
                lovd_showInfoTable($sMessage . '!', 'stop');
                print '      </DIV></FORM>' . "\n\n";
                return 0;
            }
        }
        // Now loop through the data and print. But check for $q to be set; if we had a bad search syntax, we end up here as well, but without an $q.
        while (isset($q) && $nTotal && ($zData = $q->fetchAssoc())) {
            // If row_id is not given by the database, but it should be created according to some format ($this->sRowID), put the data's ID in this format.
            $zData = $this->generateRowID($zData);
            // If row_link is not given by the database, but it should be created according to some format ($this->sRowLink), put the data's ID and the viewList's ID in this format.
            if (!isset($zData['row_link'])) {
                if ($this->sRowLink !== '' && $zData['row_id']) {
                    $zData['row_link'] = str_replace(array('{{ID}}', '{{ViewListID}}'), array(rawurlencode($zData['row_id']), $sViewListID), $this->sRowLink);
                    //$zData['row_link'] = preg_replace('/\{\{zData_(\w)+\}\}/', rawurlencode("$1"), $zData['row_link']);
                    //$zData['row_link'] = preg_replace_callback('/\{\{zData_(\w+)\}\}/', create_function('$aRegs', 'global $zData; return rawurlencode($zData[$aRegs[1]]);'), $zData['row_link']);
                    // FIXME; sorry, couldn't figure out how to do this in one line. Suggestions are welcome.
                    foreach ($zData as $key => $val) {
                        // Also allow data from $zData to be put into the row link & row id.
                        // FIXME; This is a temporary ugly solution, so we need to fix this later!!!!
                        $zData['row_link'] = preg_replace('/\\{\\{' . preg_quote($key, '/') . '\\}\\}/', rawurlencode($val), $zData['row_link']);
                        $zData['row_link'] = preg_replace('/\\{\\{zData_' . preg_quote($key, '/') . '\\}\\}/', rawurlencode($val), $zData['row_link']);
                    }
                } else {
                    $zData['row_link'] = '';
                }
            }
            $zData = $this->autoExplode($zData);
            // Only the CustomViewList object has this 3rd argument, but other objects' prepareData()
            // don't complain when called with this 3 argument they didn't define.
            $zData = $this->prepareData($zData, 'list', $sViewListID);
            if (FORMAT == 'text/html') {
                // FIXME; rawurldecode() in the line below should have a better solution.
                // IE (who else) refuses to respect the BASE href tag when using JS. So we have no other option than to include the full path here.
                print "\n" . '        <TR class="' . (empty($zData['class_name']) ? 'data' : $zData['class_name']) . '"' . (!$zData['row_id'] ? '' : ' id="' . $zData['row_id'] . '"') . ' valign="top"' . (!$zData['row_link'] ? '' : ' style="cursor : pointer;"') . (!$zData['row_link'] ? '' : ' onclick="' . (substr($zData['row_link'], 0, 11) == 'javascript:' ? rawurldecode(substr($zData['row_link'], 11)) : 'window.location.href = \'' . lovd_getInstallURL(false) . $zData['row_link'] . '\';') . '"') . '>';
                if ($bOptions) {
                    print "\n" . '          <TD align="center" class="checkbox" onclick="cancelParentEvent(event);"><INPUT id="check_' . $zData['row_id'] . '" class="checkbox" type="checkbox" name="check_' . $zData['row_id'] . '" onclick="lovd_recordCheckChanges(this, \'' . $sViewListID . '\');"' . (in_array($zData['row_id'], $aSessionViewList['checked']) ? ' checked' : '') . '></TD>';
                }
                foreach ($this->aColumnsViewList as $sField => $aCol) {
                    if (in_array($sField, $aColsToSkip)) {
                        continue;
                    }
                    print "\n" . '          <TD' . (!empty($aCol['view'][2]) ? ' ' . $aCol['view'][2] : '') . ($aOrder[0] == $sField ? ' class="ordered"' : '') . '>' . ($zData[$sField] === '' ? '-' : $zData[$sField]) . '</TD>';
                }
                print '</TR>';
            } elseif (FORMAT == 'text/plain') {
                // Download format: print contents.
                if (ACTION == 'downloadSelected' && !in_array($zData['row_id'], $aSessionViewList['checked'])) {
                    // Only selected entries should be downloaded. And this one is not selected.
                    continue;
                }
                $i = 0;
                foreach ($this->aColumnsViewList as $sField => $aCol) {
                    if (in_array($sField, $aColsToSkip)) {
                        continue;
                    }
                    print ($i++ ? "\t" : '') . '"' . str_replace(array("\r\n", "\r", "\n"), array('\\r\\n', '\\r', '\\n'), addslashes(html_entity_decode(strip_tags($zData[$sField])))) . '"';
                }
                print "\r\n";
            }
        }
        // Only print stuff if we're not just loading one entry right now.
        if ($nTotal && !$bOnlyRows && FORMAT == 'text/html') {
            print '</TABLE>' . "\n";
            if (!$bHideNav) {
                print '        <INPUT type="hidden" name="total" value="' . $nTotal . '" disabled>' . "\n" . '        <INPUT type="hidden" name="page_size" value="' . $_GET['page_size'] . '">' . "\n" . '        <INPUT type="hidden" name="page" value="' . $_GET['page'] . '">' . "\n\n";
                lovd_pagesplitShowNav($sViewListID, $nTotal, $bTrueCount, $bSortableVL, $bLegend);
            }
            if (!$bAjax) {
                print '      </DIV></FORM><BR>' . "\n";
                // These contents will be replaced by Ajax.
            }
        }
        if (!$bAjax && FORMAT == 'text/html') {
            // If sent using Ajax, the browser is not going to evaluate this code, anyways.
            print '      <SCRIPT type="text/javascript">' . "\n" . '        // This has to be run when the document has finished loading everything, because only then can it get the proper width from IE7 and lower!' . "\n" . '        $( function () {lovd_stretchInputs(\'' . $sViewListID . '\');});' . "\n";
            if ($bOptions) {
                $sFRMenuOption = '';
                if ($bFindReplace) {
                    // Add find & replace menu item to viewlist options menu.
                    $sFRMenuOption = <<<FRITEM
'            <LI class="icon">' +
'                <A click="lovd_FRColumnSelector(\\'{$sViewListID}\\');">' +
'                    <SPAN class="icon" style=""></SPAN>' +
'                    Find and replace text in column' +
'                </A>' +
'            </LI>' +
FRITEM;
                }
                print <<<OPMENU
        // If menu's UL doesn't exist yet, create it.
        if (\$('#viewlistMenu_{$sViewListID}').attr('id') == undefined) {
          var oUL = window.document.createElement('ul');
          oUL.setAttribute('id', 'viewlistMenu_{$sViewListID}');
          oUL.className = 'jeegoocontext jeegooviewlist';
          window.document.body.appendChild(oUL);
        }
        // Fix the top border that could not be set through jeegoo's style.css.
        \$('#viewlistMenu_{$sViewListID}').attr('style', 'border-top : 1px solid #000;');
        \$('#viewlistMenu_{$sViewListID}').prepend(
'            <LI class="icon">' +
'                <A click="check_list[\\'{$sViewListID}\\'] = \\'all\\'; lovd_AJAX_viewListSubmit(\\'{$sViewListID}\\');">' +
'                    <SPAN class="icon" style="background-image: url(gfx/check.png);"></SPAN>' +
'                    Select all <SPAN>entries</SPAN>' +
'                </A>' +
'            </LI>' +
'            <LI class="icon">' +
'                <A click="check_list[\\'{$sViewListID}\\'] = \\'none\\'; lovd_AJAX_viewListSubmit(\\'{$sViewListID}\\');">' +
'                    <SPAN class="icon" style="background-image: url(gfx/cross.png);"></SPAN>' +
'                    Unselect all' +
'                </A>' +
'            </LI>' +
{$sFRMenuOption}
'            ');
        \$('#viewlistMenu_{$sViewListID}').append(
'            <LI class="icon">' +
'                <A click="lovd_AJAX_viewListSubmit(\\'{$sViewListID}\\', function(){lovd_AJAX_viewListDownload(\\'{$sViewListID}\\', true);});">' +
'                    <SPAN class="icon" style="background-image: url(gfx/menu_save.png);"></SPAN>' +
'                    Download all entries (summary data)' +
'                </A>' +
'            </LI>' +
'            <LI class="icon">' +
'                <A click="lovd_AJAX_viewListSubmit(\\'{$sViewListID}\\', function(){lovd_AJAX_viewListDownload(\\'{$sViewListID}\\', false);});">' +
'                    <SPAN class="icon" style="background-image: url(gfx/menu_save.png);"></SPAN>' +
'                    Download selected entries (summary data)' +
'                </A>' +
'            </LI>');
        lovd_activateMenu('{$sViewListID}');
OPMENU;
            }
            print '        check_list[\'' . $sViewListID . '\'] = [];' . "\n" . '      </SCRIPT>' . "\n\n";
        }
        return $nTotal;
    }
예제 #18
0
파일: settings.php 프로젝트: LOVDnl/LOVD3
         if (empty($_POST['proxy_port'])) {
             // Empty port number, insert NULL instead of 0.
             $_POST['proxy_port'] = NULL;
         }
         // Query text.
         $sSQL = 'UPDATE ' . TABLE_CONFIG . ' SET ';
         $aSQL = array();
         foreach ($aFields as $key => $sField) {
             $sSQL .= (!$key ? '' : ', ') . $sField . ' = ?';
             $aSQL[] = $_POST[$sField];
         }
         $q = $_DB->query($sSQL, $aSQL, true, true);
         // Write to log...
         lovd_writeLog('Event', LOG_EVENT, 'Edited system configuration');
         // Thank the user...
         header('Refresh: 3; url=' . lovd_getInstallURL() . 'setup');
         $_T->printHeader();
         $_T->printTitle();
         lovd_showInfoTable('Successfully edited the system settings!', 'success');
         $_T->printFooter();
         exit;
     }
 } else {
     // Load current values.
     $_POST = array_merge($_POST, $zData);
 }
 $_T->printHeader();
 $_T->printTitle();
 lovd_errorPrint();
 // Tooltip JS code.
 lovd_includeJS('inc-js-tooltip.php');
예제 #19
0
파일: template.php 프로젝트: LOVDnl/LOVD3
    function printHeaderHTML($bFull = true)
    {
        // Print the LOVD header, including the menu (if $bFull == true).
        global $_AUTH, $_CONF, $_DB, $_SETT, $_STAT;
        // Build menu, if tabs are shown.
        if ($bFull) {
            $this->buildMenu();
        }
        ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<HTML lang="en_US">
<HEAD>
  <TITLE><?php 
        echo (!defined('PAGE_TITLE') ? '' : PAGE_TITLE . ' - ') . $_CONF['system_title'];
        ?>
</TITLE>
  <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <META name="author" content="LOVD development team, LUMC, Netherlands">
  <META name="generator" content="gPHPEdit / GIMP @ GNU/Linux (Ubuntu)">
  <BASE href="<?php 
        echo lovd_getInstallURL();
        ?>
">
  <LINK rel="stylesheet" type="text/css" href="styles.css">
  <LINK rel="stylesheet" type="text/css" href="lib/jeegoocontext/style.css">
  <LINK rel="shortcut icon" href="favicon.ico" type="image/x-icon">

<?php 
        // FIXME; later?
        /*  <LINK rel="alternate" type="application/atom+xml" title="<?php echo $_CONF['system_title']; ?> Atom 1.0 feed" href="<?php echo ROOT_PATH; ?>api/feed.php" />*/
        lovd_includeJS('inc-js-openwindow.php', 1);
        lovd_includeJS('inc-js-toggle-visibility.js', 1);
        // Used on forms and variant overviews for small info tables.
        lovd_includeJS('lib/jQuery/jquery.min.js', 1);
        lovd_includeJS('lib/jQuery/jquery-ui.custom.min.js', 1);
        lovd_includeJS('lib/jeegoocontext/jquery.jeegoocontext.min.js', 1);
        if (!$bFull) {
            ?>
</HEAD>

<BODY style="margin : 10px;">

<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
  <TR>
    <TD>










<?php 
            return true;
        }
        $sCurrSymbol = $sCurrGene = '';
        if (!empty($_SESSION['currdb'])) {
            // FIXME; Currently we don't support "=GENE" matching (for instance, on the disease tab) because changing that value will not trigger a change in CURRDB... Yet.
            $sGeneSwitchURL = preg_replace('/(\\/)' . preg_quote($_SESSION['currdb'], '/') . '\\b/', "\$1{{GENE}}", $_SERVER['REQUEST_URI']);
            // Just use currently selected database.
            $sCurrSymbol = $_SESSION['currdb'];
            $sCurrGene = $_SETT['currdb']['name'];
        }
        // FIXME; how will we handle this? (if we'll handle this)
        // During submission, show the gene we're submitting to instead of the currently selected gene.
        //if (lovd_getProjectFile() == '/submit.php' && !empty($_POST['gene']) && $_POST['gene'] != $_SESSION['currdb']) {
        //    // Fetch gene's info from db... we don't have it anywhere yet.
        //    list($sCurrSymbol, $sCurrGene) = $_DB->query('SELECT id, gene FROM ' . TABLE_DBS . ' WHERE id = ?', array($_POST['gene']))->fetchRow();
        //}
        ?>

  <SCRIPT type="text/javascript">
    var geneSwitcher = '';

    function lovd_switchGene()
    {
        // Fetches the gene switcher data from LOVD. Might be a form with a
        // dropdown, or a form with a text field for autocomplete.
        $.get('ajax/get_gene_switcher.php', function (sData, sStatus)
        {
            geneSwitcher = sData;
            if (geneSwitcher === '<?php 
        echo AJAX_DATA_ERROR;
        ?>
') {
                alert('Error when retrieving a list of genes');
                return;
            }
            $('#gene_name').hide();

            $('#gene_switcher').html(geneSwitcher['html']);
            if (geneSwitcher['switchType'] === 'autocomplete') {
                $('#select_gene_autocomplete').autocomplete({
                    source: geneSwitcher['data'],
                    minLength: 3
                }).on('autocompleteselect', function (e, ui) { $(this).val(ui['item']['value']); $(this).parent().parent().submit(); }); // Auto submit on selecting the gene from the list.
                // And set focus to the field, too.
                $('#select_gene_autocomplete').focus();
            }
        },'json'
        ).fail(function (sData, sStatus)
        {
            alert('Error when retrieving a list of genes: ' + sStatus);
        });
    }

    function lovd_changeURL ()
    {
        // Replaces the gene in the current URL with the one selected.
        var sURL = '<?php 
        if (!empty($_SESSION['currdb'])) {
            echo $sGeneSwitchURL;
        }
        ?>
';
        // FIXME; It is very very difficult to keep the hash, it should be selective since otherwise you might be loading the EXACT SAME VL, BUT ON A DIFFERENT PAGE (viewing variants belonging to gene X, on a page that says you're looking at gene Y).
        if (geneSwitcher['switchType'] === 'autocomplete') {
            document.location.href = sURL.replace('{{GENE}}', $('#select_gene_autocomplete').val());
        } else {
            document.location.href = sURL.replace('{{GENE}}', $('#select_gene_dropdown').val());
        }
    }

  </SCRIPT>
  <LINK rel="stylesheet" type="text/css" href="lib/jQuery/css/cupertino/jquery-ui.custom.css">
</HEAD>

<BODY style="margin : 0px;">

<?php 
        // Check for announcements. Ignore errors, in case the table doesn't exist yet.
        $qAnnouncements = @$_DB->query('SELECT id, type, announcement FROM ' . TABLE_ANNOUNCEMENTS . ' WHERE start_date <= NOW() AND end_date >= NOW()', array(), false);
        if ($qAnnouncements) {
            $zAnnouncements = $qAnnouncements->fetchAllAssoc();
        } else {
            $zAnnouncements = array();
        }
        foreach ($zAnnouncements as $zAnnouncement) {
            lovd_showInfoTable($zAnnouncement['announcement'], $zAnnouncement['type'], '100%', !$_AUTH || $_AUTH['level'] < LEVEL_MANAGER ? '' : 'announcements/' . $zAnnouncement['id'], false);
        }
        ?>

<TABLE border="0" cellpadding="0" cellspacing="0" width="100%"><TR><TD>

<TABLE border="0" cellpadding="0" cellspacing="0" width="100%" class="logo" style="position : fixed; z-index : 10">
  <TR>
<?php 
        if (!is_readable(ROOT_PATH . $_CONF['logo_uri'])) {
            $_CONF['logo_uri'] = 'gfx/LOVD3_logo145x50.jpg';
        }
        $aImage = @getimagesize(ROOT_PATH . $_CONF['logo_uri']);
        if (!is_array($aImage)) {
            $aImage = array('130', '50', '', 'width="130" heigth="50"');
        }
        list($nWidth, $nHeight, $sType, $sSize) = $aImage;
        print '    <TD valign="top" width="' . ($nWidth + 20) . '" height="' . ($nHeight + 5) . '">' . "\n" . '      <IMG src="' . $_CONF['logo_uri'] . '" alt="LOVD - Leiden Open Variation Database" ' . $sSize . '>' . "\n" . '    </TD>' . "\n";
        print '    <TD valign="top" style="padding-top : 2px; white-space : nowrap; width : 100%">' . "\n" . '      <H2 style="margin-bottom : 2px;">' . $_CONF['system_title'] . '</H2>';
        if ($sCurrSymbol && $sCurrGene) {
            print '      <H5 id="gene_name" style="display:inline">' . $sCurrGene . ' (' . $sCurrSymbol . ')' . "\n";
            if (strpos($sGeneSwitchURL, '{{GENE}}') !== false) {
                print '        <A href="#" onclick="lovd_switchGene(); return false;">' . "\n" . '          <IMG src="gfx/lovd_genes_switch_inline.png" width="23" height="23" alt="Switch gene" title="Switch gene database" align="top">' . "\n" . '        </A>' . "\n";
            }
            print '      </H5>' . "\n";
        }
        // With an ajax call, the H5 with ID 'gene_switcher' is filled with a dropdown or an autocomplete field.
        // This is done with function lovd_switchGene().
        print '      <H5 id="gene_switcher"></H5>' . "\n" . '    </TD>' . "\n" . '    <TD valign="top" align="right" style="padding-right : 5px; padding-top : 2px; white-space: nowrap; padding-left: 20px;">' . "\n" . '      LOVD v.' . $_STAT['tree'] . ' Build ' . $_STAT['build'] . (!defined('NOT_INSTALLED') ? ' [ <A href="status">Current LOVD status</A> ]' : '') . '<BR>' . "\n";
        if (!(defined('NOT_INSTALLED') || ROOT_PATH == '../' && substr(lovd_getProjectFile(), 0, 9) == '/install/')) {
            if ($_AUTH) {
                print '      <B>Welcome, ' . $_AUTH['name'] . '</B><BR>' . "\n" . '      <A href="users/' . $_AUTH['id'] . '"><B>Your account</B></A> | ' . (false && $_AUTH['level'] == LEVEL_SUBMITTER && $_CONF['allow_submitter_mods'] ? '<A href="variants?search_created_by=' . $_AUTH['id'] . '"><B>Your submissions</B></A> | ' : '') . (!empty($_AUTH['saved_work']['submissions']['individual']) || !empty($_AUTH['saved_work']['submissions']['screening']) ? '<A href="users/' . $_AUTH['id'] . '?submissions"><B>Unfinished submissions</B></A> | ' : '') . '<A href="logout"><B>Log out</B></A>' . "\n";
            } else {
                print '      ' . (!$_CONF['allow_submitter_registration'] || $_CONF['lovd_read_only'] ? '' : '<A href="users?register"><B>Register as submitter</B></A> | ') . '<A href="login"><B>Log in</B></A>' . "\n";
            }
        }
        print '    </TD>' . "\n" . '  </TR>' . "\n" . '</TABLE>' . "\n\n";
        $nTotalTabWidth = 0;
        // Will stretch the page at least this far, so the tabs don't "break" if the window is narrow.
        print '<TABLE border="0" cellpadding="0" cellspacing="0" width="100%" class="logo" style="margin-top:55px;' . (count($this->aMenu) ? '' : ' border-bottom : 2px solid #000000;') . '">' . "\n";
        // Add curator info to header.
        if ($sCurrSymbol && $sCurrGene) {
            $sCurators = '';
            $aCurators = $_DB->query('SELECT u.name, u.email FROM ' . TABLE_USERS . ' AS u LEFT JOIN ' . TABLE_CURATES . ' AS u2g ON (u.id = u2g.userid) WHERE u2g.geneid = ? AND u2g.allow_edit = 1 AND u2g.show_order > 0 ORDER BY u2g.show_order ASC, u.level DESC, u.name ASC', array($sCurrSymbol))->fetchAllAssoc();
            $nCurators = count($aCurators);
            foreach ($aCurators as $i => $z) {
                $i++;
                $sCurators .= ($sCurators ? $i == $nCurators ? ' and ' : ', ' : '') . '<A href="mailto:' . str_replace(array("\r\n", "\r", "\n"), ', ', trim($z['email'])) . '">' . $z['name'] . '</A>';
            }
            if ($sCurators) {
                print '  <TR>' . "\n" . '    <TD width="150">&nbsp;</TD>' . "\n" . '    <TD valign="top" colspan="2" style="padding-bottom : 2px;"><B>Curator' . ($nCurators > 1 ? 's' : '') . ': ' . $sCurators . '</B></TD>' . "\n" . '  </TR>' . "\n";
            }
        }
        // Build menu tabs...
        print '  <TR>' . "\n" . '    <TD align="left" colspan="2" style="background : url(\'gfx/tab_fill.png\'); background-repeat : repeat-x;">' . "\n";
        // Loop menu.
        $n = 0;
        $bPrevSel = false;
        $aMenus = array();
        $bCurator = $_AUTH && (count($_AUTH['curates']) || $_AUTH['level'] > LEVEL_CURATOR);
        // We can't check LEVEL_CURATOR since it may not be set.
        foreach ($this->aMenu as $sPrefix => $Title) {
            // Arrays (children links of parent tabs) can only be processed if we still have the $sFile from the previous run.
            if (is_array($Title)) {
                if (empty($sFile)) {
                    continue;
                }
                $sPrefix = substr($sFile, 4);
                // Remove 'tab_'.
                // Menu will be built in an UL, that will be transformed into a dropdown menu by using the Jeegocontext script by www.planitworks.nl.
                $sUL = '<UL id="menu_' . $sFile . '" class="jeegoocontext">' . "\n";
                $bHR = false;
                foreach ($Title as $sURL => $aItem) {
                    if (!is_array($aItem)) {
                        if ($aItem == 'hr') {
                            $bHR = true;
                        }
                        continue;
                    }
                    list($sIMG, $sName, $nRequiredLevel) = $aItem;
                    $bDisabled = false;
                    if ($nRequiredLevel && ($nRequiredLevel == LEVEL_CURATOR && !$bCurator || $nRequiredLevel != LEVEL_CURATOR && $nRequiredLevel > $_AUTH['level'])) {
                        $bDisabled = true;
                    } else {
                        if (!$sURL) {
                            // Default action of default page.
                            $sURL = $sPrefix;
                        } elseif ($sURL[0] == '/') {
                            // Direct URL.
                            $sURL = substr($sURL, 1);
                        } else {
                            // Action given.
                            $sURL = $sPrefix . '?' . $sURL;
                        }
                    }
                    if (!$bDisabled) {
                        // IE (who else) refuses to respect the BASE href tag when using JS. So we have no other option than to include the full path here.
                        // Not using the "separator" class from the original code, since it's not compatible to our changes.
                        $sUL .= ($bHR ? '  <LI class="hr disabled"><HR></LI>' . "\n" : '') . '  <LI' . (!$sIMG ? '' : ' class="icon"') . '><A href="' . lovd_getInstallURL(false) . $sURL . '">' . (!$sIMG ? '' : '<SPAN class="icon" style="background-image: url(gfx/' . $sIMG . ');"></SPAN>') . $sName . '</A></LI>' . "\n";
                        $bHR = false;
                    }
                    // class disabled, disabled. Nu gewoon maar even weggehaald.
                    //                    $sUL .= '  <LI class="disabled">' .
                    //                        (!$sIMG? '' : '<SPAN class="icon" style="background-image: url(gfx/' . preg_replace('/(\.[a-z]+)$/', '_disabled' . "$1", $sIMG) . ');"></SPAN>') . $sName .
                    //                        '</LI>' . "\n";
                }
                $sUL .= '</UL>' . "\n";
                $aMenus[$sFile] = $sUL;
                continue;
            }
            // Determine if we're the current tab.
            if (defined('TAB_SELECTED')) {
                // Hard coded exceptions...
                $bSel = TAB_SELECTED == $sPrefix;
            } else {
                $bSel = substr(lovd_getProjectFile(), 1, strrpos(lovd_getProjectFile(), '.') - 1) == $sPrefix;
            }
            $sFile = 'tab_' . $sPrefix;
            // Print transition.
            $nTotalTabWidth += 25;
            print '      <IMG src="gfx/tab_' . (!$n ? '0' : ($bPrevSel ? 'F' : 'B')) . ($bSel ? 'F' : 'B') . '.png" alt="" width="25" height="25" align="left">' . "\n";
            // Get header info.
            $sFileName = 'gfx/' . $sFile . '_' . ($bSel ? 'F' : 'B') . '.png';
            $aImage = @getimagesize(ROOT_PATH . $sFileName);
            $sSize = $aImage[3];
            // Print header.
            $sURL = $sPrefix;
            // If a gene has been selected, some of the tabs get different default URLs.
            if ($_SESSION['currdb']) {
                if (in_array($sPrefix, array('configuration', 'genes', 'transcripts', 'variants', 'screenings', 'individuals'))) {
                    $sURL = $sPrefix . '/' . $_SESSION['currdb'];
                    if ($sPrefix == 'variants') {
                        $sURL .= '/unique';
                    }
                } elseif ($sPrefix == 'diseases') {
                    $sURL = $sPrefix . '?search_genes_=' . $_SESSION['currdb'];
                }
            }
            $nTotalTabWidth += $aImage[0];
            print '      <A href="' . $sURL . '"><IMG src="' . $sFileName . '" alt="' . $Title . '" id="' . $sFile . '" ' . $sSize . ' align="left"></A>' . "\n";
            $bPrevSel = $bSel;
            $n++;
        }
        // If we've had tabs at all, close the transition.
        if (count($this->aMenu)) {
            $nTotalTabWidth += 25;
            print '      <IMG src="gfx/tab_' . ($bPrevSel ? 'F' : 'B') . '0.png" alt="" width="25" height="25" align="left">' . "\n";
        }
        // Close menu table.
        print '    </TD>' . "\n" . '  </TR>' . "\n" . '</TABLE>' . "\n\n" . '<IMG src="gfx/trans.png" alt="" width="' . $nTotalTabWidth . '" height="0">' . "\n\n";
        // Attach dropdown menus.
        print '<!-- Start drop down menu definitions -->' . "\n";
        foreach ($aMenus as $sUL) {
            print $sUL . "\n";
        }
        print '
<SCRIPT type="text/javascript">
  $(function(){
    var aMenuOptions = {
        widthOverflowOffset: 0,
        heightOverflowOffset: 1,' . '
        startLeftOffset: -20,
        event: "mouseover",
        openBelowContext: true,
        autoHide: true,
        delay: 100,
        onSelect: function(e, context){
            if($(this).hasClass("disabled"))
            {
                return false;
            } else {
                window.location = $(this).find("a").attr("href");
                return false;
            }
        }
    };' . "\n";
        foreach (array_keys($aMenus) as $sTabID) {
            print '    $(\'#' . $sTabID . '\').jeegoocontext(\'menu_' . $sTabID . '\', aMenuOptions);' . "\n";
        }
        print '  });
</SCRIPT>' . "\n" . '<!-- End drop down menu definitions -->' . "\n";
        ?>



<DIV style="padding : 0px 10px;">
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
  <TR>
    <TD style="padding-top : 10px;">







<?php 
        return true;
    }
예제 #20
0
     // The subselect options do all the calculations in MySQL, and are therefore hopefully faster and more efficient.
     // WITH UNION                         SELECT COUNT(DISTINCT v.id) FROM ' . TABLE_VARIANTS . ' AS v LEFT JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (v.id = s2v.variantid) WHERE v.statusid >= ' . STATUS_MARKED . ' AND s2v.screeningid IS NULL UNION ALL
     //                                    SELECT (IF(i.statusid < 7, 1, i.panel_size) * COUNT(DISTINCT v.id)) FROM ' . TABLE_INDIVIDUALS . ' AS i INNER JOIN ' . TABLE_SCREENINGS . ' AS s ON (i.id = s.individualid) INNER JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (s.id = s2v.screeningid) INNER JOIN ' . TABLE_VARIANTS . ' AS v ON (s2v.variantid = v.id) WHERE v.statusid >= 7 GROUP BY i.id;
     //$nVariants = array_sum($_DB->query('SELECT COUNT(DISTINCT v.id) FROM ' . TABLE_VARIANTS . ' AS v LEFT JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (v.id = s2v.variantid) WHERE v.statusid >= ' . STATUS_MARKED . ' AND s2v.screeningid IS NULL UNION ALL
     //                                    SELECT (IF(i.statusid < 7, 1, i.panel_size) * COUNT(DISTINCT v.id)) FROM ' . TABLE_INDIVIDUALS . ' AS i INNER JOIN ' . TABLE_SCREENINGS . ' AS s ON (i.id = s.individualid) INNER JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (s.id = s2v.screeningid) INNER JOIN ' . TABLE_VARIANTS . ' AS v ON (s2v.variantid = v.id) WHERE v.statusid >= 7 GROUP BY i.id')->fetchAllColumn());
     // USING SUBSELECTS                   SELECT variants_without_individuals + SUM(variants_on_individuals) FROM (SELECT (IF(i.statusid < 7, 1, i.panel_size) * COUNT(DISTINCT v.id)) AS variants_on_individuals FROM ' . TABLE_INDIVIDUALS . ' AS i INNER JOIN ' . TABLE_SCREENINGS . ' AS s ON (i.id = s.individualid) INNER JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (s.id = s2v.screeningid) INNER JOIN ' . TABLE_VARIANTS . ' AS v ON (s2v.variantid = v.id) WHERE v.statusid >= 7 GROUP BY i.id) AS sub1, (SELECT COUNT(DISTINCT v.id) AS variants_without_individuals FROM ' . TABLE_VARIANTS . ' AS v LEFT JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (v.id = s2v.variantid) WHERE v.statusid >= ' . STATUS_MARKED . ' AND s2v.screeningid IS NULL) AS sub2;
     //$nVariants = array_sum($_DB->query('SELECT variants_without_individuals + SUM(variants_on_individuals) FROM (SELECT (IF(i.statusid < 7, 1, i.panel_size) * COUNT(DISTINCT v.id)) AS variants_on_individuals FROM ' . TABLE_INDIVIDUALS . ' AS i INNER JOIN ' . TABLE_SCREENINGS . ' AS s ON (i.id = s.individualid) INNER JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (s.id = s2v.screeningid) INNER JOIN ' . TABLE_VARIANTS . ' AS v ON (s2v.variantid = v.id) WHERE v.statusid >= 7 GROUP BY i.id) AS sub1, (SELECT COUNT(DISTINCT v.id) AS variants_without_individuals FROM ' . TABLE_VARIANTS . ' AS v LEFT JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (v.id = s2v.variantid) WHERE v.statusid >= ' . STATUS_MARKED . ' AND s2v.screeningid IS NULL) AS sub2')->fetchAllColumn());
     // EVEN SHORTER                     SELECT SUM(v) FROM (SELECT (IFNULL(IF(i.statusid < 7, 1, i.panel_size), 1) * COUNT(DISTINCT v.id)) AS v FROM ' . TABLE_VARIANTS . ' AS v LEFT JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (v.id = s2v.variantid) LEFT JOIN ' . TABLE_SCREENINGS . ' AS s ON (s2v.screeningid = s.id) LEFT JOIN ' . TABLE_INDIVIDUALS . ' AS i ON (s.individualid = i.id) WHERE v.statusid >= 7 GROUP BY i.id) AS sub
     $nVariants = array_sum($_DB->query('SELECT SUM(v) FROM (SELECT (IFNULL(IF(i.statusid < ' . STATUS_MARKED . ', 1, i.panel_size), 1) * COUNT(DISTINCT v.id)) AS v FROM ' . TABLE_VARIANTS . ' AS v LEFT JOIN ' . TABLE_SCR2VAR . ' AS s2v ON (v.id = s2v.variantid) LEFT JOIN ' . TABLE_SCREENINGS . ' AS s ON (s2v.screeningid = s.id) LEFT JOIN ' . TABLE_INDIVIDUALS . ' AS i ON (s.individualid = i.id) WHERE v.statusid >= ' . STATUS_MARKED . ' GROUP BY i.id) AS sub')->fetchAllColumn());
     $sPOSTVars .= '&variant_count=' . $nVariants;
 }
 if ($_CONF['include_in_listing']) {
     // Fetch install directory and gene listings.
     $sPOSTVars .= '&install_name=' . rawurlencode($_CONF['system_title']);
     // Get the installation location from the database, if available.
     $sInstallDir = !empty($_CONF['location_url']) ? $_CONF['location_url'] : lovd_getInstallURL();
     $sPOSTVars .= '&install_dir=' . rawurlencode($sInstallDir) . '&gene_listing=' . rawurlencode($sGeneList);
     // Send gene edit dates, curator names, emails & institutes as well.
     // This is not very efficient, but for something done once a day (max) it will do.
     $aData = array('genes' => array(), 'users' => array(), 'diseases' => array());
     // First, get the gene info (we store name, diseases, date last updated and curator ids).
     $q = $_DB->query('SELECT g.id, g.name, g.updated_date, GROUP_CONCAT(DISTINCT u2g.userid ORDER BY u2g.show_order) AS users, GROUP_CONCAT(DISTINCT d.id ORDER BY d.name) AS diseases FROM ' . TABLE_GENES . ' AS g LEFT OUTER JOIN ' . TABLE_CURATES . ' AS u2g ON (g.id = u2g.geneid AND u2g.allow_edit = 1 AND u2g.show_order > 0) LEFT OUTER JOIN ' . TABLE_GEN2DIS . ' AS g2d ON (g.id = g2d.geneid) LEFT OUTER JOIN ' . TABLE_DISEASES . ' AS d ON (g2d.diseaseid = d.id) WHERE u2g.show_order > 0 GROUP BY g.id ORDER BY g.id', array());
     while ($z = $q->fetchAssoc()) {
         $aData['genes'][$z['id']] = array('gene_name' => $z['name'], 'diseases' => explode(',', $z['diseases']), 'updated_date' => $z['updated_date'], 'curators' => explode(',', $z['users']));
     }
     // Then, get the actual curator data (name, email, institute).
     $q = $_DB->query('SELECT id, name, email, institute FROM ' . TABLE_USERS . ' AS u INNER JOIN ' . TABLE_CURATES . ' AS u2g ON (u.id = u2g.userid) WHERE u2g.allow_edit = 1 AND u2g.show_order != 0 ORDER BY u.id', array(), false);
     while ($z = $q->fetchAssoc()) {
         $aData['users'][$z['id']] = array('name' => $z['name'], 'email' => $z['email'], 'institute' => $z['institute']);
     }
     // Finally, get the actual disease data (ID, symbol, name).
예제 #21
0
파일: logout.php 프로젝트: LOVDnl/LOVD3
    // 'Delete' the cookie.
}
session_destroy();
// Destroy session, delete the session file.
$_AUTH = false;
// Reinitiate... To store some information back into the array.
@session_start();
// On some Ubuntu distributions this can cause a distribution-specific error message when session cleanup is triggered.
session_regenerate_id();
// Fix weird behaviour of session_regenerate_id() - sometimes it is not sending a new cookie.
setcookie(session_name(), session_id(), ini_get('session.cookie_lifetime'));
$_SESSION['currdb'] = $sCurrDB;
// Put it back.
$_SESSION['mapping'] = $aMapping;
// Put it back.
header('Refresh: 5; url=' . lovd_getInstallURL());
define('PAGE_TITLE', 'Log out');
$_T->printHeader();
$_T->printTitle();
print '      You have been logged out successfully.<BR>' . "\n";
$aTimes = array(array(1, 'sec', 'sec'), array(60, 'min', 'min'), array(60, 'hr', 'hrs'), array(24, 'day', 'days'));
foreach ($aTimes as $n => $aTime) {
    if ($n) {
        $aTimes[$n][0] = $aTime[0] * $aTimes[$n - 1][0];
    }
}
$aTimes = array_reverse($aTimes);
$sPrint = '';
foreach ($aTimes as $n => $aTime) {
    if ($nSec >= $aTime[0]) {
        $nAmount = floor($nSec / $aTime[0]);
예제 #22
0
파일: genes.php 프로젝트: LOVDnl/LOVD3
    foreach ($aCurators as $nID => $aVal) {
        print '          <LI id="li_' . $nID . '"><INPUT type="hidden" name="curators[]" value="' . $nID . '"><TABLE width="100%"><TR><TD class="handle" width="13" align="center"><IMG src="gfx/drag_vertical.png" alt="" title="Click and drag to sort" width="5" height="13"></TD><TD>' . $aVal['name'] . ' (#' . $nID . ')</TD>';
        if (ACTION == 'authorize') {
            print '<TD width="100" align="right"><INPUT type="checkbox" name="allow_edit[]" value="' . $nID . '" onchange="if (this.checked == true) { this.parentNode.nextSibling.children[0].disabled = false; } else if (' . $aVal['level'] . ' >= ' . LEVEL_MANAGER . ') { this.checked = true; } else { this.parentNode.nextSibling.children[0].checked = false; this.parentNode.nextSibling.children[0].disabled = true; }"' . ($aVal['allow_edit'] || $aVal['level'] >= LEVEL_MANAGER ? ' checked' : '') . '></TD><TD width="75" align="right"><INPUT type="checkbox" name="shown[]" value="' . $nID . '"' . ($aVal['allow_edit'] ? $aVal['shown'] ? ' checked' : '' : ' disabled') . '></TD><TD width="30" align="right">' . ($aVal['level'] >= $_AUTH['level'] && $nID != $_AUTH['id'] ? '&nbsp;' : '<A href="#" onclick="lovd_unauthorizeUser(\'Genes_AuthorizeUser\', \'' . $nID . '\'); return false;"><IMG src="gfx/mark_0.png" alt="Remove" width="11" height="11" border="0"></A>') . '</TD>';
        } else {
            print '<TD width="75" align="right"><INPUT type="checkbox" name="shown[]" value="' . $nID . '"' . ($aVal['shown'] ? ' checked' : '') . '></TD>';
        }
        print '</TR></TABLE></LI>' . "\n";
    }
    print '        </UL>' . "\n";
    if (ACTION == 'authorize') {
        // Array which will make up the form table.
        $aForm = array(array('POST', '', '', '', '0%', '0', '100%'), array('', '', 'print', 'Enter your password for authorization'), array('', '', 'password', 'password', 20), array('', '', 'print', '<INPUT type="submit" value="Save curator list">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT type="submit" value="Cancel" onclick="window.location.href=\'' . lovd_getInstallURL() . $_PE[0] . '/' . $sID . '\'; return false;" style="border : 1px solid #FF4422;">'));
        lovd_viewForm($aForm);
    } else {
        print '        <INPUT type="submit" value="Save">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT type="submit" value="Cancel" onclick="window.location.href=\'' . lovd_getInstallURL() . $_PE[0] . '/' . $sID . '\'; return false;" style="border : 1px solid #FF4422;">' . "\n";
    }
    print "\n" . '      </FORM>' . "\n\n";
    // FIXME; disable JS functions authorize and unauthorize if not authorizing?
    ?>
      <SCRIPT type='text/javascript'>
        $(function() {
          $('#curator_list').sortable({
            containment: 'parent',
            tolerance: 'pointer',
            handle: 'TD.handle'
          });
          $('#curator_list').disableSelection();
        });

예제 #23
0
function lovd_mailNewColleagues($sUserID, $sUserFullname, $sUserInstitute, $sUserEmail, $aNewColleagues)
{
    // Send an email to users with an ID in $aNewColleagues, letting them know
    // the user denoted by $sUserID has shared access to his data with them.
    require_once ROOT_PATH . 'inc-lib-form.php';
    global $_DB, $_SETT, $_AUTH;
    if (!is_array($aNewColleagues) || !$aNewColleagues) {
        // Nothing to be done.
        return false;
    }
    // Fetch names/email addresses for new colleagues.
    $sPlaceholders = '(?' . str_repeat(',?', count($aNewColleagues) - 1) . ')';
    $sColleagueQuery = 'SELECT id, name, institute, email FROM ' . TABLE_USERS . ' WHERE id IN ' . $sPlaceholders;
    $zColleagues = $_DB->query($sColleagueQuery, $aNewColleagues)->fetchAllAssoc();
    $sApplicationURL = lovd_getInstallURL();
    $sGranterFullname = $_AUTH['name'];
    $sGranterInstitute = $_AUTH['institute'];
    $aGranterEmails = explode("\r\n", $_AUTH['email']);
    $sGranterEmail = isset($aGranterEmails[0]) ? $aGranterEmails[0] : '';
    if ($sUserID == $_AUTH['id']) {
        // User who is granting permissions is the same as who's data is being shared.
        $sResourceDescription = 'their data';
    } else {
        // Somebody else (e.g. a manager) is granting access to someone else's data.
        $sResourceDescription = 'data of ' . $sUserFullname . ' (' . $sUserInstitute . ')';
        // Send notification email to the one who's data is being shared.
        $aSharerEmails = explode("\r\n", $sUserEmail);
        $sSharerEmail = isset($aSharerEmails[0]) ? $aSharerEmails[0] : '';
        $aRecipients = array();
        foreach ($zColleagues as $zColleague) {
            $aRecipients[] = '* ' . $zColleague['name'] . ' (' . $zColleague['institute'] . ')';
        }
        $sRecipients = join("\n", $aRecipients);
        $sSharerAccountURL = $sApplicationURL . 'users/' . $sUserID;
        $sSharerMailbody = sprintf(EMAIL_SHARER_NEW_COLLEAGUE, $sUserFullname, $_AUTH['name'], $_AUTH['institute'], $sGranterEmail, $sRecipients, $sSharerAccountURL);
        lovd_sendMail(array(array($sUserFullname, $sSharerEmail)), 'LOVD access sharing', $sSharerMailbody, $_SETT['email_headers'], false, false);
    }
    // Now loop through new colleagues to send them all one email.
    foreach ($zColleagues as $zColleague) {
        $sRecipientAccountURL = $sApplicationURL . 'users/' . $zColleague['id'];
        // Setup mail text and fill placeholders.
        $sMailBody = sprintf(EMAIL_NEW_COLLEAGUE, $zColleague['name'], $sApplicationURL, $sGranterFullname, $sGranterInstitute, $sGranterEmail, $sResourceDescription, $sRecipientAccountURL);
        // Note: email field is new-line separated list of email addresses.
        lovd_sendMail(array(array($zColleague['name'], $zColleague['email'])), 'LOVD access sharing', $sMailBody, $_SETT['email_headers'], false, false);
    }
}
예제 #24
0
 function getForm()
 {
     // Build the form.
     // If we've built the form before, simply return it. Especially imports will repeatedly call checkFields(), which calls getForm().
     if (!empty($this->aFormData)) {
         return parent::getForm();
     }
     global $_PE, $_DB;
     // Get links list, to connect column to link.
     $aLinks = $_DB->query('SELECT id, name FROM ' . TABLE_LINKS . ' ORDER BY name')->fetchAllCombine();
     $nLinkSize = count($aLinks);
     $nLinkSize = $nLinkSize < 10 ? $nLinkSize : 10;
     // Array which will make up the form table.
     $this->aFormData = array(array('POST', '', '', '', '35%', '14', '65%'), array('', '', 'print', '<B>Column name and descriptions</B>'), 'hr', 'category' => array('', '', 'print', '<I>Selected category: ' . $_POST['category'] . '</I>'), 'colid' => array('Column ID', '', 'text', 'colid', 30), 'colid_note' => array('', '', 'note', 'This ID must be unique and may contain only letters, numbers and underscores. Subcategories must be divided by a slash (/), such as \'{{ EXAMPLE }}\'.'), array('Column heading', 'This will appear above the column in data tables.', 'text', 'head_column', 30), array('Description on short legend<BR>(HTML enabled)', '', 'textarea', 'description_legend_short', 40, 2), array('Description on full legend<BR>(HTML enabled)', '', 'textarea', 'description_legend_full', 40, 4), array('', '', 'note', 'The full legend description will also serve as help text. In create and edit forms where this custom column is present, the text will be shown when someone hovers their mouse over the blue question mark next to the input field.'), 'hr', 'skip', array('', '', 'print', '<B>Data and form settings</B> (Use data type wizard to change values)'), 'hr', array('', '', 'print', '<BUTTON type="button" onclick="javascript:lovd_openWindow(\'' . lovd_getInstallURL() . $_PE[0] . '?data_type_wizard&amp;workID=' . $_POST['workID'] . '\', \'DataTypeWizard\', 800, 400); return false;">Start data type wizard</BUTTON>'), array('MySQL data type', '<B>Experts only!</B> Only change this field manually when you know what you\'re doing! Otherwise, use the data type wizard by clicking the button above this field.', 'text', 'mysql_type', 30), array('Form type', '<B>Experts only!</B> Only change this field manually when you know what you\'re doing! Otherwise, use the data type wizard by clicking the button above the MySQL data type field.', 'text', 'form_type', 30), 'hr', 'skip', array('', '', 'print', '<B>Column settings</B>'), 'hr', 'settings_note' => array('', '', 'print', '<I>Please note that fields marked with * are merely default values. For each configured {{ DATATYPE }}, these values may be changed at any later time.</I>'), 'standard' => array('Include this column for newly configured ', '', 'checkbox', 'standard'), 'width' => array('Column display width in pixels', '', 'text', 'width', 5), array('', '', 'print', '<IMG src="gfx/trans.png" alt="" width="' . (int) $_POST['width'] . '" height="3" style="background : #000000;"><BR><SPAN class="form_note">(This is ' . (int) $_POST['width'] . ' pixels)</SPAN>'), 'mandatory' => array('Mandatory field', '', 'checkbox', 'mandatory'), 'public_view' => array('Show contents to public', '', 'checkbox', 'public_view'), 'public_add' => array('Show field on submission form', '', 'checkbox', 'public_add'), 'hr', 'skip', 'active_links_title' => array('', '', 'print', '<B>Link settings</B>'), 'active_links_hr1' => 'hr', 'active_links' => array('Active custom links', '', 'select', 'active_links', $nLinkSize, $aLinks, false, true, true), 'active_links_hr2' => 'hr', 'active_links_skip' => 'skip', 'apply_to_all' => array('Apply changes to all {{ UNIT }} where this column is active', '', 'checkbox', 'apply_to_all'), array('Enter your password for authorization', '', 'password', 'password', 20));
     // Change some text on the form.
     switch ($_POST['category']) {
         case 'Individual':
             unset($this->aFormData['settings_note']);
             unset($this->aFormData['standard']);
             unset($this->aFormData['apply_to_all']);
             $this->aFormData['colid_note'][3] = str_replace('{{ EXAMPLE }}', 'Geograpic_origin/Country', $this->aFormData['colid_note'][3]);
             break;
         case 'Phenotype':
             $this->aFormData['settings_note'][3] = str_replace('{{ DATATYPE }}', 'disease', $this->aFormData['settings_note'][3]);
             $this->aFormData['standard'][0] .= 'diseases';
             $this->aFormData['colid_note'][3] = str_replace('{{ EXAMPLE }}', 'Blood_pressure/Systolic', $this->aFormData['colid_note'][3]);
             $this->aFormData['width'][0] .= ' *';
             $this->aFormData['mandatory'][0] .= ' *';
             $this->aFormData['public_view'][0] .= ' *';
             $this->aFormData['public_add'][0] .= ' *';
             $this->aFormData['apply_to_all'][0] = str_replace('{{ UNIT }}', 'diseases', $this->aFormData['apply_to_all'][0]);
             break;
         case 'Screening':
             unset($this->aFormData['settings_note']);
             unset($this->aFormData['standard']);
             unset($this->aFormData['apply_to_all']);
             $this->aFormData['colid_note'][3] = str_replace('{{ EXAMPLE }}', 'Protocol/Date_updated', $this->aFormData['colid_note'][3]);
             break;
         case 'VariantOnGenome':
             unset($this->aFormData['settings_note']);
             unset($this->aFormData['standard']);
             unset($this->aFormData['apply_to_all']);
             $this->aFormData['colid_note'][3] = str_replace('{{ EXAMPLE }}', 'Frequency/dbSNP', $this->aFormData['colid_note'][3]);
             // FIXME; I think this example sucks.
             break;
         case 'VariantOnTranscript':
             $this->aFormData['settings_note'][3] = str_replace('{{ DATATYPE }}', 'gene', $this->aFormData['settings_note'][3]);
             $this->aFormData['standard'][0] .= 'genes';
             $this->aFormData['colid_note'][3] = str_replace('{{ EXAMPLE }}', 'Protein/Codon', $this->aFormData['colid_note'][3]);
             $this->aFormData['width'][0] .= ' *';
             $this->aFormData['mandatory'][0] .= ' *';
             $this->aFormData['public_view'][0] .= ' *';
             $this->aFormData['public_add'][0] .= ' *';
             $this->aFormData['apply_to_all'][0] = str_replace('{{ UNIT }}', 'genes', $this->aFormData['apply_to_all'][0]);
             break;
     }
     // Het hele formulier moet anders met het editen... het display gedeelte moet apart denk ik - "edit display settings"; variant en phenotype cols hebben "set defaults for new genes/diseases", alle hebben "edit data types" ofzo.
     if (ACTION == 'edit') {
         if (!preg_match('/^TEXT|VARCHAR/', $_POST['mysql_type']) || $_PE[2] == 'DBID') {
             unset($this->aFormData['active_links_title'], $this->aFormData['active_links_hr1'], $this->aFormData['active_links'], $this->aFormData['active_links_hr2'], $this->aFormData['active_links_skip']);
         }
         unset($this->aFormData['colid'], $this->aFormData['colid_note']);
     } elseif (ACTION == 'create') {
         unset($this->aFormData['apply_to_all']);
     }
     return parent::getForm();
 }
예제 #25
0
 if (!empty($_POST)) {
     lovd_errorClean();
     // Mandatory fields.
     if (empty($_POST['password'])) {
         lovd_errorAdd('password', 'Please fill in the \'Enter your password for authorization\' field.');
     }
     // User had to enter his/her password for authorization.
     if ($_POST['password'] && !lovd_verifyPassword($_POST['password'], $_AUTH['password'])) {
         lovd_errorAdd('password', 'Please enter your correct password for authorization.');
     }
     if (!lovd_error()) {
         $_DATA->deleteEntry($nID);
         // Write to log...
         lovd_writeLog('Event', LOG_EVENT, 'Deleted announcement ' . $nID . ' (' . $zData['type'] . ') - ' . lovd_shortenString(strip_tags($zData['announcement']), 150));
         // Thank the user...
         header('Refresh: 3; url=' . lovd_getInstallURL() . $_PE[0]);
         $_T->printHeader();
         $_T->printTitle();
         lovd_showInfoTable('Successfully deleted the announcement!', 'success');
         $_T->printFooter();
         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();
 lovd_errorPrint();
 // Table.
 print '      <FORM action="' . CURRENT_PATH . '?' . ACTION . '" method="post">' . "\n";
예제 #26
0
파일: diseases.php 프로젝트: LOVDnl/LOVD3
    $_T->printTitle();
    // Retrieve column IDs in current order.
    $aColumns = $_DB->query('SELECT SUBSTRING(colid, LOCATE("/", colid)+1) FROM ' . TABLE_SHARED_COLS . ' WHERE ' . $sUnit . 'id = ? ORDER BY col_order ASC', array($nID))->fetchAllColumn();
    if (!count($aColumns)) {
        lovd_showInfoTable('No columns found!', 'stop');
        $_T->printFooter();
        exit;
    }
    lovd_showInfoTable('Below is a sorting list of all active columns. By clicking &amp; dragging the arrow next to the column up and down you can rearrange the columns. Re-ordering them will affect listings, detailed views and data entry forms in the same way.', 'information');
    // Form & table.
    print '      <TABLE cellpadding="0" cellspacing="0" class="sortable_head" style="width : 302px;"><TR><TH width="20">&nbsp;</TH><TH>Column ID</TH></TR></TABLE>' . "\n" . '      <FORM action="' . CURRENT_PATH . '?' . ACTION . (isset($_GET['in_window']) ? '&amp;in_window' : '') . '" method="post">' . "\n" . '        <UL id="column_list" class="sortable" style="width : 300px; margin-top : 0px;">' . "\n";
    // Now loop the items in the order given.
    foreach ($aColumns as $sID) {
        print '        <LI><INPUT type="hidden" name="columns[]" value="' . $sID . '"><TABLE width="100%"><TR><TD class="handle" width="13" align="center"><IMG src="gfx/drag_vertical.png" alt="" title="Click and drag to sort" width="5" height="13"></TD><TD>' . $sID . '</TD></TR></TABLE></LI>' . "\n";
    }
    print '        </UL>' . "\n" . '        <INPUT type="submit" value="Save">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT type="submit" value="Cancel" onclick="' . (isset($_GET['in_window']) ? 'self.close(); return false;' : 'window.location.href=\'' . lovd_getInstallURL() . $_PE[0] . '/' . $_PE[1] . '\'; return false;') . '" style="border : 1px solid #FF4422;">' . "\n" . '      </FORM>' . "\n\n";
    ?>
      <SCRIPT type='text/javascript'>
        $(function() {
          $('#column_list').sortable({
            containment: 'parent',
            tolerance: 'pointer',
            handle: 'TD.handle'
          });
          $('#column_list').disableSelection();
        });
      </SCRIPT>
<?php 
    $_T->printFooter();
    exit;
}
예제 #27
0
 *
 * LOVD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with LOVD.  If not, see <http://www.gnu.org/licenses/>.
 *
 *************/
define('ROOT_PATH', './');
require ROOT_PATH . 'inc-init.php';
// Already logged in to the system.
if ($_AUTH) {
    // Send user to the index, that file will figure out where to go from there.
    header('Location: ' . lovd_getInstallURL());
    exit;
}
if (!$_AUTH && $_CONF['allow_unlock_accounts']) {
    // User forgot password - replace.
    define('PAGE_TITLE', 'Reset password');
    define('LOG_EVENT', 'ResetPassword');
    // Require form functions.
    require ROOT_PATH . 'inc-lib-form.php';
    if (POST && !empty($_POST['username'])) {
        lovd_errorClean();
        // Find account.
        $zData = $_DB->query('SELECT * FROM ' . TABLE_USERS . ' WHERE username = ?', array($_POST['username']))->fetchAssoc();
        if (!$zData) {
            // If username does not exist, we don't want to let the user know. So this message in entire incorrect.
            $_T->printHeader();
예제 #28
0
 function setDefaultValues()
 {
     // Sets default values of fields in $_POST.
     $_POST['system_title'] = 'LOVD - Leiden Open Variation Database';
     $_POST['location_url'] = $_SERVER['HTTP_HOST'] == 'localhost' || lovd_matchIPRange($_SERVER['HTTP_HOST']) ? '' : lovd_getInstallURL();
     $_POST['refseq_build'] = 'hg38';
     $_POST['api_feed_history'] = 3;
     $_POST['logo_uri'] = 'gfx/LOVD3_logo145x50.jpg';
     $_POST['mutalyzer_soap_url'] = 'https://mutalyzer.nl/services';
     $_POST['send_stats'] = 1;
     $_POST['include_in_listing'] = 1;
     $_POST['allow_submitter_registration'] = 1;
     $_POST['allow_submitter_mods'] = 1;
     if (!SSL) {
         $_POST['use_ssl'] = 0;
     } else {
         $_POST['use_ssl'] = 1;
     }
     $_POST['lock_users'] = 1;
     $_POST['allow_unlock_accounts'] = 1;
     $_POST['lock_uninstall'] = 1;
     return true;
 }
예제 #29
0
파일: uninstall.php 프로젝트: LOVDnl/LOVD3
            unset($_TABLES_cleaned['TABLE_HITS']);
            print '  Found ' . $nTables . '/' . count($_TABLES_cleaned) . ' tables.' . "\n";
            // FIXME; add more later.
            // General statistics...
            print "\n";
            // 2012-02-01; 3.0-beta-02; Exclude "LOVD" system user.
            $nUsers = $_DB->query('SELECT COUNT(*) FROM ' . TABLE_USERS . ' WHERE id > 0')->fetchColumn();
            $nIndividuals = $_DB->query('SELECT COUNT(*) FROM ' . TABLE_INDIVIDUALS)->fetchColumn();
            $nScreenings = $_DB->query('SELECT COUNT(*) FROM ' . TABLE_SCREENINGS)->fetchColumn();
            $nVars = $_DB->query('SELECT COUNT(*) FROM ' . TABLE_VARIANTS)->fetchColumn();
            $nGenes = count(lovd_getGeneList());
            print '  Found ' . $nUsers . ' user' . ($nUsers == 1 ? '' : 's') . '.' . "\n" . '  Found ' . $nIndividuals . ' individual' . ($nIndividuals == 1 ? '' : 's') . '.' . "\n" . '  Found ' . $nScreenings . ' screening' . ($nScreenings == 1 ? '' : 's') . '.' . "\n" . '  Found ' . $nVars . ' variant' . ($nVars == 1 ? '' : 's') . '.' . "\n" . '  Found ' . $nGenes . ' gene' . ($nGenes == 1 ? '' : 's') . '.' . "\n" . '      </PRE>' . "\n";
            if ($nGenes || $nIndividuals || $nVars) {
                lovd_showInfoTable('FINAL WARNING! If you did not download the variation and individual data stored in the LOVD system, everything will be lost!', 'warning');
            }
            print '      Please confirm uninstalling LOVD using your password.<BR>' . "\n" . '      <BR>' . "\n\n";
        }
        lovd_errorPrint();
        print '      <FORM action="' . $_PE[0] . '?confirm" method="post">' . "\n" . '        <TABLE border="0" cellpadding="0" cellspacing="0" width="300">' . "\n" . '          <TR align="right">' . "\n" . '            <TD width="125" style="padding-right : 5px;">Password</TD>' . "\n" . '            <TD width="175"><INPUT type="password" name="password" size="20"></TD></TR>' . "\n" . '          <TR align="right">' . "\n" . '            <TD width="125">&nbsp;</TD>' . "\n" . '            <TD width="175"><INPUT type="submit" value="Uninstall LOVD" style="font-weight : bold; font-size : 11px; width : 110px;"></TD></TR></TABLE></FORM>' . "\n\n";
        $_T->printFooter();
        exit;
    }
}
if (empty($_POST)) {
    print '      Welcome to the LOVD uninstaller. Please continue by providing your password.<BR>' . "\n" . '      <BR>' . "\n\n";
    lovd_showInfoTable('WARNING! If you did not download your data, you will lose all of it!', 'warning');
}
lovd_errorPrint();
print '      <FORM action="' . $_PE[0] . '" method="post">' . "\n" . '        <TABLE border="0" cellpadding="0" cellspacing="0" width="300">' . "\n" . '          <TR align="right">' . "\n" . '            <TD width="125" style="padding-right : 5px;">Password</TD>' . "\n" . '            <TD width="175"><INPUT type="password" name="password" size="20"></TD></TR>' . "\n" . '          <TR align="right">' . "\n" . '            <TD width="125">&nbsp;</TD>' . "\n" . '            <TD width="175">' . "\n" . '              <TABLE border="0" cellpadding="0" cellspacing="0" width="162">' . "\n" . '                <TR>' . "\n" . '                  <TD align="left"><INPUT type="button" value="&lt;&lt; Cancel" onclick="window.location.href=\'' . lovd_getInstallURL() . 'setup\';" style="font-weight : bold; font-size : 11px; width : 80px;"></TD>' . "\n" . '                  <TD align="right"><INPUT type="submit" value="Next &gt;&gt;" style="font-weight : bold; font-size : 11px; width : 70px;"></TD></TR></TABLE></TD></TR></TABLE></FORM>' . "\n\n";
$_T->printFooter();
exit;
예제 #30
0
파일: login.php 프로젝트: LOVDnl/LOVD3
                    lovd_errorAdd('password', 'Your account is now locked, since this is the third time a wrong password was provided.');
                }
                // The "Forgot my password" option.
                if ($_CONF['allow_unlock_accounts']) {
                    lovd_errorAdd('', 'Did you <A href="reset_password">forget your password</A>?');
                }
            }
        }
    }
}
if (!$_AUTH) {
    define('PAGE_TITLE', 'Log in');
    $_T->printHeader();
    $_T->printTitle();
    // Security check will be performed when actually logging in.
    if (empty($_POST['referer'])) {
        // Don't redirect a user to the logout!
        if (!empty($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != lovd_getInstallURL() . 'logout') {
            $_POST['referer'] = $_SERVER['HTTP_REFERER'];
        } else {
            $_POST['referer'] = '';
        }
    }
    if ($_CONF['lovd_read_only']) {
        lovd_showInfoTable('This installation is currently configured to be read-only. Only Managers and higher level users can log in.', 'warning');
    }
    lovd_errorPrint();
    print '      <FORM action="login" method="post" id="login">' . "\n" . (!$_POST['referer'] ? '' : '        <INPUT type="hidden" name="referer" value="' . htmlspecialchars($_POST['referer']) . '">' . "\n") . '        <TABLE border="0" cellpadding="0" cellspacing="0" width="275">' . "\n" . '          <TR align="right">' . "\n" . '            <TD width="100" style="padding-right : 5px;">Username</TD>' . "\n" . '            <TD width="175"><INPUT type="text" name="username" size="20"></TD></TR>' . "\n" . '          <TR>' . "\n" . '            <TD colspan="2"><IMG src="gfx/trans.png" alt="" width="1" height="1"></TD></TR>' . "\n" . '          <TR align="right">' . "\n" . '            <TD width="100" style="padding-right : 5px;">Password</TD>' . "\n" . '            <TD width="175"><INPUT type="password" name="password" size="20"></TD></TR>' . "\n" . '          <TR>' . "\n" . '            <TD colspan="2"><IMG src="gfx/trans.png" alt="" width="1" height="1"></TD></TR>' . "\n" . '          <TR align="right">' . "\n" . '            <TD width="100">&nbsp;</TD>' . "\n" . '            <TD width="175"><INPUT type="submit" value="Log in"></TD></TR></TABLE>' . "\n" . '      </FORM>' . "\n\n" . '      <SCRIPT type="text/javascript">' . "\n" . '        document.forms[\'login\'].username.focus();' . "\n" . '      </SCRIPT>' . "\n\n";
    $_T->printFooter();
    exit;
}