Esempio n. 1
0
 function checkFields($aData, $zData = false)
 {
     // Checks fields before submission of data.
     global $_AUTH, $_DB;
     $bImport = lovd_getProjectFile() == '/import.php';
     $bCreate = ACTION && ACTION == 'create' || $bImport && !$zData;
     // Mandatory fields.
     $this->aCheckMandatory = array('symbol', 'name');
     $aData = parent::checkFields($aData);
     if (!empty($aData['id_omim']) && !preg_match('/^[1-9]\\d{5}$/', $aData['id_omim'])) {
         lovd_errorAdd('id_omim', 'The OMIM ID has to be six digits long and cannot start with a \'0\'.');
     }
     // Two diseases with the same OMIM ID are not allowed.
     if (!empty($aData['id_omim']) && ($bCreate || $aData['id_omim'] != $zData['id_omim'])) {
         $bExists = $_DB->query('SELECT id FROM ' . TABLE_DISEASES . ' WHERE id_omim = ?', array($aData['id_omim']))->fetchColumn();
         if ($bExists) {
             // IMPORTANT: when you change this message, also change the array_search argument in import.php in the Disease section.
             lovd_errorAdd('id_omim', 'Another disease already exists with this OMIM ID!');
         }
     }
     // We don't like two diseases with the exact same name, either.
     if (!empty($aData['name']) && ($bCreate || $aData['name'] != $zData['name'])) {
         $bExists = $_DB->query('SELECT id FROM ' . TABLE_DISEASES . ' WHERE name = ?', array($aData['name']))->fetchColumn();
         if ($bExists && ($bCreate || $zData['id'] != $bExists)) {
             // IMPORTANT: when you change this message, also change the array_search argument in import.php in the Disease section.
             lovd_errorAdd('name', 'Another disease already exists with the same name!');
         }
     }
     if (!$bImport && $_AUTH['level'] < LEVEL_MANAGER && empty($aData['genes'])) {
         lovd_errorAdd('genes', 'You should at least select one of the genes you are curator of.');
     }
     $_POST['genes'] = array();
     if (is_array($aData['genes'])) {
         foreach ($aData['genes'] as $sGene) {
             if (!lovd_isAuthorized('gene', $sGene, false) && $bCreate) {
                 lovd_errorAdd('genes', 'You are not authorized to add this disease to gene ' . htmlspecialchars($sGene) . '.');
             } else {
                 $_POST['genes'][] = $sGene;
             }
         }
     }
     if (!$bCreate) {
         if (is_array($aData['genes']) && isset($zData['genes']) && is_array($zData['genes'])) {
             foreach ($zData['genes'] as $sGene) {
                 if ($sGene && !in_array($sGene, $aData['genes']) && !lovd_isAuthorized('gene', $sGene, false)) {
                     lovd_errorAdd('genes', 'You are not authorized to remove this disease from gene ' . htmlspecialchars($sGene) . '.');
                     $_POST['genes'][] = $sGene;
                 }
             }
         }
     }
     // XSS attack prevention. Deny input of HTML.
     lovd_checkXSS();
 }
Esempio n. 2
0
    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;
    }
Esempio n. 3
0
 *
 *
 * 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/>.
 *
 *************/
if (!defined('ROOT_PATH')) {
    define('ROOT_PATH', '../');
    require ROOT_PATH . 'inc-init.php';
    lovd_requireAUTH(LEVEL_MANAGER);
}
// Country list, taken from http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm at 2009-10-05
// Updated 2014-09-10 with information from http://en.wikipedia.org/wiki/ISO_3166-1
// NOTE: Do not change these queries without verifying that object_users.php still collects the country data correctly. It parses these queries for the DB admin registration form.
$aCountrySQL = array('INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AF", "Afghanistan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AX", "Åland Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AL", "Albania")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("DZ", "Algeria")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AS", "American Samoa")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AD", "Andorra")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AO", "Angola")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AI", "Anguilla")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AQ", "Antarctica")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AG", "Antigua and Barbuda")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AR", "Argentina")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AM", "Armenia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AW", "Aruba")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AU", "Australia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AT", "Austria")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AZ", "Azerbaijan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BS", "Bahamas")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BH", "Bahrain")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BD", "Bangladesh")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BB", "Barbados")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BY", "Belarus")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BE", "Belgium")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BZ", "Belize")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BJ", "Benin")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BM", "Bermuda")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BT", "Bhutan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BO", "Bolivia (Plurinational State of)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BA", "Bosnia and Herzegovina")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BW", "Botswana")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BV", "Bouvet Island")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BR", "Brazil")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("IO", "British Indian Ocean Territory")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BN", "Brunei Darussalam")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BG", "Bulgaria")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BF", "Burkina Faso")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BI", "Burundi")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KH", "Cambodia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CM", "Cameroon")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CA", "Canada")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CV", "Cape Verde")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KY", "Cayman Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CF", "Central African Republic")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TD", "Chad")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CL", "Chile")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CN", "China")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CX", "Christmas Island")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CC", "Cocos (Keeling) Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CO", "Colombia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KM", "Comoros")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CG", "Congo")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CD", "Congo (Democratic Republic of the)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CK", "Cook Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CR", "Costa Rica")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CI", "Côte D\'Ivoire (Ivory Coast)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("HR", "Croatia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CU", "Cuba")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CY", "Cyprus")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CZ", "Czech Republic")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("DK", "Denmark")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("DJ", "Djibouti")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("DM", "Dominica")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("DO", "Dominican Republic")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("EC", "Ecuador")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("EG", "Egypt")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SV", "El Salvador")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GQ", "Equatorial Guinea")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("ER", "Eritrea")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("EE", "Estonia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("ET", "Ethiopia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("FK", "Falkland Islands (Malvinas)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("FO", "Faroe Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("FJ", "Fiji")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("FI", "Finland")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("FR", "France")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GF", "French Guiana")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PF", "French Polynesia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TF", "French Southern Territories")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GA", "Gabon")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GM", "Gambia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GE", "Georgia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("DE", "Germany")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GH", "Ghana")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GI", "Gibraltar")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GR", "Greece")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GL", "Greenland")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GD", "Grenada")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GP", "Guadeloupe")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GU", "Guam")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GT", "Guatemala")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GG", "Guernsey")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GN", "Guinea")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GW", "Guinea-Bissau")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GY", "Guyana")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("HT", "Haiti")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("HM", "Heard Island and McDonald Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("VA", "Holy See (Vatican City State)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("HN", "Honduras")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("HK", "Hong Kong")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("HU", "Hungary")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("IS", "Iceland")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("IN", "India")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("ID", "Indonesia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("IR", "Iran (Islamic Republic of)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("IQ", "Iraq")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("IE", "Ireland")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("IM", "Isle of Man")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("IL", "Israel")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("IT", "Italy")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("JM", "Jamaica")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("JP", "Japan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("JE", "Jersey")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("JO", "Jordan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KZ", "Kazakhstan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KE", "Kenya")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KI", "Kiribati")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KP", "Korea (North) (Democratic People\'s Republic of)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KR", "Korea (South) (Republic of)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KW", "Kuwait")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KG", "Kyrgyzstan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LA", "Lao People\'s Democratic Republic")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LV", "Latvia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LB", "Lebanon")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LS", "Lesotho")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LR", "Liberia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LY", "Libya")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LI", "Liechtenstein")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LT", "Lithuania")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LU", "Luxembourg")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MO", "Macao")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MK", "Macedonia (the former Yugoslav Republic of)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MG", "Madagascar")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MW", "Malawi")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MY", "Malaysia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MV", "Maldives")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("ML", "Mali")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MT", "Malta")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MH", "Marshall Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MQ", "Martinique")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MR", "Mauritania")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MU", "Mauritius")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("YT", "Mayotte")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MX", "Mexico")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("FM", "Micronesia (Federated States of)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MD", "Moldova (Republic of)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MC", "Monaco")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MN", "Mongolia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("ME", "Montenegro")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MS", "Montserrat")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MA", "Morocco")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MZ", "Mozambique")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MM", "Myanmar")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NA", "Namibia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NR", "Nauru")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NP", "Nepal")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NL", "Netherlands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AN", "Netherlands Antilles")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NC", "New Caledonia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NZ", "New Zealand")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NI", "Nicaragua")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NE", "Niger")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NG", "Nigeria")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NU", "Niue")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NF", "Norfolk Island")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MP", "Northern Mariana Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("NO", "Norway")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("OM", "Oman")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PK", "Pakistan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PW", "Palau")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PS", "Palestinian Territory")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PA", "Panama")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PG", "Papua New Guinea")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PY", "Paraguay")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PE", "Peru")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PH", "Philippines")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PN", "Pitcairn")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PL", "Poland")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PT", "Portugal")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PR", "Puerto Rico")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("QA", "Qatar")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("RE", "Réunion")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("RO", "Romania")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("RU", "Russian Federation")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("RW", "Rwanda")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("BL", "Saint Barthélemy")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SH", "Saint Helena, Ascension and Tristan da Cunha")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("KN", "Saint Kitts and Nevis")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LC", "Saint Lucia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("MF", "Saint Martin")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("PM", "Saint Pierre and Miquelon")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("VC", "Saint Vincent and The Grenadines")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("WS", "Samoa")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SM", "San Marino")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("ST", "Sao Tome and Principe")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SA", "Saudi Arabia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SN", "Senegal")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("RS", "Serbia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SC", "Seychelles")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SL", "Sierra Leone")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SG", "Singapore")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SK", "Slovakia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SI", "Slovenia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SB", "Solomon Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SO", "Somalia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("ZA", "South Africa")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GS", "South Georgia and The South Sandwich Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SS", "South Sudan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("ES", "Spain")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("LK", "Sri Lanka")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SD", "Sudan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SR", "Suriname")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SJ", "Svalbard and Jan Mayen")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SZ", "Swaziland")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SE", "Sweden")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("CH", "Switzerland")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("SY", "Syrian Arab Republic")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TW", "Taiwan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TJ", "Tajikistan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TZ", "Tanzania (United Republic of)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TH", "Thailand")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TL", "Timor-Leste")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TG", "Togo")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TK", "Tokelau")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TO", "Tonga")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TT", "Trinidad and Tobago")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TN", "Tunisia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TR", "Turkey")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TM", "Turkmenistan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TC", "Turks and Caicos Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("TV", "Tuvalu")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("UG", "Uganda")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("UA", "Ukraine")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("AE", "United Arab Emirates")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("GB", "United Kingdom (Great Britain)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("US", "United States")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("UM", "United States Minor Outlying Islands")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("UY", "Uruguay")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("UZ", "Uzbekistan")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("VU", "Vanuatu")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("VE", "Venezuela (Bolivarian Republic of)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("VN", "Viet Nam")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("VG", "Virgin Islands (British)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("VI", "Virgin Islands (U.S.)")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("WF", "Wallis and Futuna")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("EH", "Western Sahara")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("YE", "Yemen")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("ZM", "Zambia")', 'INSERT INTO ' . TABLE_COUNTRIES . ' VALUES ("ZW", "Zimbabwe")');
if (lovd_getProjectFile() == '/install/inc-sql-countries.php') {
    header('Content-type: text/plain; charset=UTF-8');
    var_dump(implode(";\n", $aCountrySQL) . ';');
}
Esempio n. 4
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 $_SETT;
     $aHumanBuilds = array();
     foreach ($_SETT['human_builds'] as $sCode => $aBuild) {
         $aHumanBuilds[$sCode] = $sCode . ' / ' . $aBuild['ncbi_name'];
     }
     // No more hg18! We'll support LOVDs having this setting, but we won't allow new installations to pick this setting.
     unset($aHumanBuilds['hg18']);
     $aFeedHistory = array('Not available');
     for ($i = 1; $i <= 12; $i++) {
         $aFeedHistory[$i] = $i . ' month' . ($i == 1 ? '' : 's');
     }
     $this->aFormData = array(array('POST', '', '', '', '335', '14', ''), array('', '', 'print', '<B>General system settings</B>'), 'hr', array('Title of this LOVD installation', 'This will be shown on the top of every page.', 'text', 'system_title', 45), array('Institute (optional)', 'The institute which runs this database is displayed in the public area and in emails sent by LOVD. It\'s commonly set to a laboratory name or a website name.', 'text', 'institute', 45), array('Database URL (optional)', 'This is the URL with which the database can be accessed by the outside world, including "http://" or "https://". It will also be used in emails sent by LOVD. This field is mandatory if you select the "Include in the global LOVD listing" option.<BR>If you click the "check" link, LOVD will verify or try to predict the value.', 'print', '<INPUT type="text" name="location_url" size="40" id="location_url" value="' . (empty($_POST['location_url']) ? '' : htmlspecialchars($_POST['location_url'])) . '"' . (!lovd_errorFindField('location_url') ? '' : ' class="err"') . '>&nbsp;<SPAN id="location_url_check">(<A href="#" onclick="javascript:lovd_checkURL(); return false;">check</A>)</SPAN>'), array('LOVD email address', 'This email address will be used to send emails from LOVD to users. We need this address to make sure that emails from LOVD arrive. Please note that although strictly speaking this email address does not need to exist, we recommend that you use a valid address.', 'text', 'email_address', 40), array('Forward messages to database admin?', 'This will forward messages to the database administrator about submitter registrations and submissions.', 'checkbox', 'send_admin_submissions'), 'refseq_build' => array('Human Build to map to (UCSC/NCBI)', 'We need to know which version of the Human Build we need to map the variants in this LOVD to.', 'select', 'refseq_build', 1, $aHumanBuilds, false, false, false), array('List database changes in feed for how long?', 'LOVD includes a "newsfeed" that allows users to get a list of changes recently made in the database. Select here how many months back you want changes to appear on this list. Set to "Not available" to disable the newsfeed.', 'print', '&nbsp;<I style="color : #666666;">Not yet implemented</I>'), 'hr', 'skip', 'skip', array('', '', 'print', '<B>Connection settings (optional)</B>'), array('', '', 'note', 'The following settings apply to how LOVD connects to other resources.<BR>Some networks have no access to the outside world except through a proxy. If this applies to the network this server is installed on, please fill in the proxy server information here.'), 'hr', array('Proxy server host name', 'The host name of the proxy server, such as www-cache.institution.edu.', 'text', 'proxy_host', 20), array('Proxy server port number', 'The port number of the proxy server, such as 3128.', 'text', 'proxy_port', 4), 'skip', array('', '', 'note', 'The following two fields only apply if the proxy server requires authentication.'), array('Proxy server username', 'In case the proxy server requires authentication, please enter the required username here.', 'text', 'proxy_username', 20), array('Proxy server password', 'In case the proxy server requires authentication, please enter the required password here.', 'password', 'proxy_password', 20, true), 'hr', 'skip', 'skip', array('', '', 'print', '<B>Customize LOVD</B>'), array('', '', 'note', 'Here you can customize the way LOVD looks. We will add more options here later.'), 'hr', array('System logo', 'If you wish to have your custom logo on the top left of every page instead of the default LOVD logo, enter the path to the image here, relative to the LOVD installation path.', 'text', 'logo_uri', 40), array('', '', 'note', 'Currently, only images already uploaded to the LOVD server are allowed here.'), 'hr', 'skip', 'skip', array('', '', 'print', '<B>Global LOVD statistics</B>'), array('', '', 'note', 'The following settings apply to the kind of information your LOVD install sends to the development team to gather statistics about global LOVD usage.'), 'hr', array('Send statistics?', 'This sends <I>anonymous</I> statistics about the number of submitters, genes, individuals and variants in your installation of LOVD.', 'checkbox', 'send_stats'), array('Include in the global LOVD listing?', 'We keep a public listing of LOVD installations, their genes and their URLs. Deselect this checkbox if you do not want to be included in this public listing.', 'checkbox', 'include_in_listing'), 'hr', 'skip', 'skip', array('', '', 'print', '<B>Security settings</B>'), array('', '', 'note', 'Using the following settings you can control some security settings of LOVD.'), 'hr', array('Allow submitter registration?', 'Enabling this setting allows submitters to create their own accounts in your LOVD installation. Having it enabled is the default setting, and this could not be disabled prior to LOVD 3.0-17.<BR>Note, that submitters can never register when your LOVD installation is set to read-only because of an active announcement with the read-only setting enabled. See the Announcements section in the Setup area for more information.', 'checkbox', 'allow_submitter_registration'), array('Lock users after 3rd failed login?', 'Do you want to lock users (submitters, curators and managers) after three failed attempts to log in using their username?<BR>(This does <I>not</I> affect the database administrator account)', 'checkbox', 'lock_users'), array('Allow (locked) users to retrieve a new password?', 'Do you want to enable an "I forgot my password" option that allows users who forgot their password to retrieve a new one?', 'checkbox', 'allow_unlock_accounts'), array('Enable submitters to change data?', 'Enabling this setting allows submitters to make changes to data previously submitted by them or assigned to them.', 'checkbox', 'allow_submitter_mods'), array('Enable getting counts of hidden entries?', 'Enabling this feature allows the public to find the number of entries in the database (including hidden entries) matching one or more search terms on a specified set of columns. This feature will only mention the number of variant entries matched, without showing them.', 'print', '&nbsp;<I style="color : #666666;">Not yet implemented</I>'), array('Force SSL-only access to LOVD?', 'SSL is a secure protocol allowing for encryption of data sent between you and LOVD. When you will record sensitive individual information in LOVD, you <B>should</B> enable this setting, as the individual information can otherwise be \'sniffed\' off the network. If you do not record sensitive information, enabling SSL is <I>recommended</I>.', 'checkbox', 'use_ssl'), array('Use data versioning of biological data?', 'Versioning allows you to see all previous versions of a certain data entry (individuals, variants, phenotype information, etc) and allows you to return the entry to a previous state. Please note that this feature requires quite a lot of space in the database. Disabling this feature later will not free any space, just prevent more space from being used.', 'print', '&nbsp;<I style="color : #666666;">Not yet implemented</I>'), 'uninstall' => array('Disable LOVD uninstall?', 'Select this to disable the "Uninstall LOVD" option in the Setup area. Please note that this uninstall lock can only be removed by directly accessing the MySQL database.', 'checkbox', 'lock_uninstall'), 'uninstall_hr' => 'hr');
     if (lovd_getProjectFile() != '/install/index.php') {
         unset($this->aFormData['uninstall'], $this->aFormData['uninstall_hr']);
         global $_CONF;
         $this->aFormData['refseq_build'] = array('Human Build to map to (UCSC/NCBI)', '', 'print', '&nbsp;' . $_CONF['refseq_build']);
     }
     return parent::getForm();
 }
Esempio n. 5
0
 function checkFields($aData, $zData = false)
 {
     // Checks fields before submission of data.
     global $_DB;
     // Mandatory fields.
     $this->aCheckMandatory = array('category', 'colid', 'head_column', 'description_legend_short', 'description_legend_full', 'mysql_type', 'form_type', 'width');
     if (ACTION == 'edit') {
         unset($this->aCheckMandatory['colid']);
     } elseif (!empty($aData['active_links']) && !preg_match('/^TEXT|VARCHAR/', $aData['mysql_type'])) {
         lovd_errorAdd('active_links', 'Only VARCHAR or TEXT columns can have custom links activated for it!');
     }
     parent::checkFields($aData);
     // Category; not chosen on this form, but we want to make sure it's correct anyways.
     if (!empty($aData['category']) && !in_array($aData['category'], array('Individual', 'Phenotype', 'Screening', 'VariantOnGenome', 'VariantOnTranscript'))) {
         lovd_errorAdd('category', 'The category is not correct. Please choose one of the following: Individual, Phenotype, Screening, VariantOnGenome or VariantOnTranscript.');
     }
     // ColID format.
     if (!empty($aData['colid']) && !preg_match('/^[A-Za-z0-9_]+(\\/[A-Za-z0-9_]+)*$/', $aData['colid'])) {
         lovd_errorAdd('colid', 'The column ID is not of the correct format. It can contain only letters, numbers and underscores. Subcategories must be divided by a slash (/).');
     }
     // During an import ColID that exist in the database do not give a hard error. Error is handled in import.php
     if (lovd_getProjectFile() != '/import.php') {
         // ColID must not exist in the database.
         if (!empty($aData['category']) && !empty($aData['colid'])) {
             if ($_DB->query('SELECT COUNT(*) FROM ' . TABLE_COLS . ' WHERE id = ?', array($aData['category'] . '/' . $aData['colid']))->fetchColumn()) {
                 lovd_errorAdd('colid', 'There is already a ' . $aData['category'] . ' column with this column ID. Please verify that you\'re not trying to create a column that already exists!');
             }
         }
     }
     // Width can not be less than 20 or more than 500.
     // These numbers are also defined in object_shared_columns.php and inc-js-columns.php.
     if (isset($aData['width']) && strlen($aData['width']) > 0) {
         if ($aData['width'] > 500) {
             lovd_errorAdd('width', 'The width can not be more than 500 pixels!');
         } elseif ($aData['width'] < 20) {
             lovd_errorAdd('width', 'The width can not be less than 20 pixels!');
         }
     }
     // MySQL type format.
     if ($aData['mysql_type'] && !preg_match('/^(TEXT|VARCHAR\\([0-9]{1,3}\\)|DATE(TIME)?|((TINY|SMALL|MEDIUM|BIG)?INT\\([0-9]{1,2}\\)|DECIMAL\\([0-9]{1,2}\\,[0-9]{1,2}\\)|FLOAT)( UNSIGNED)?)( DEFAULT ([0-9]+|"[^"]+"))?$/i', $aData['mysql_type'])) {
         lovd_errorAdd('mysql_type', 'The MySQL data type is not recognized. Please use the data type wizard to generate a proper MySQL data type.');
     }
     // Form type.
     if ($aData['form_type'] && !preg_match('/^[^|]+\\|[^|]*\\|(checkbox|text\\|[0-9]+|textarea\\|[0-9]+\\|[0-9]+|select\\|[0-9]+\\|[^|]*\\|(false|true)\\|(false|true))$/i', $aData['form_type'])) {
         lovd_errorAdd('form_type', 'The form type is not recognized. Please use the data type wizard to generate a proper form type.');
     }
     // XSS attack prevention. Deny input of HTML.
     // Ignore some fields that are allowed to contain HTML, or that might cause false positives.
     unset($aData['description_form'], $aData['preg_pattern'], $aData['description_legend_short'], $aData['description_legend_full']);
     lovd_checkXSS($aData);
 }
Esempio n. 6
0
function lovd_requireAUTH($nLevel = 0)
{
    // Creates friendly output message if $_AUTH does not exist (or level too
    // low), and exits.
    // $_AUTH is for authorization; $_SETT is needed for the user levels.
    global $_AUTH, $_DB, $_SETT, $_T;
    $aKeys = array_keys($_SETT['user_levels']);
    if ($nLevel !== 0 && !in_array($nLevel, $aKeys)) {
        $nLevel = max($aKeys);
    }
    // $nLevel is now 0 (just existence of $_AUTH required) or taken from the levels list.
    if (!$_AUTH || $nLevel && $_AUTH['level'] < $nLevel) {
        $_T->printHeader();
        if (defined('PAGE_TITLE')) {
            $_T->printTitle();
        }
        $sMessage = 'To access this area, you need ' . (!$nLevel ? 'to <A href="login">log in</A>.' : ($nLevel == max($aKeys) ? '' : 'at least ') . $_SETT['user_levels'][$nLevel] . ' clearance.');
        // FIXME; extend this list?
        if (lovd_getProjectFile() == '/submit.php') {
            $sMessage .= '<BR>If you are not registered as a submitter, please <A href="users?register">do so here</A>.';
        }
        lovd_showInfoTable($sMessage, 'stop');
        $_T->printFooter();
        exit;
    }
}
 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 $_SETT, $_AUTH;
     // Create form per gene.
     foreach ($this->aTranscripts as $nTranscriptID => $aTranscript) {
         list($sTranscriptNM, $sGene) = $aTranscript;
         if ($sGene != $this->sObjectID) {
             continue;
         }
         $sPrefix = lovd_getProjectFile() == '/import.php' ? '' : $nTranscriptID . '_';
         $aEffectForm = array(array('Affects function (reported)', '', 'select', $sPrefix . 'effect_reported', 1, $_SETT['var_effect'], false, false, false));
         if ($_AUTH['level'] >= LEVEL_CURATOR) {
             $aEffectForm[] = array('Affects function (concluded)', '', 'select', $sPrefix . 'effect_concluded', 1, $_SETT['var_effect'], false, false, false);
         }
         $this->aFormData = array_merge($this->aFormData, array(array('', '', 'print', '<B class="transcript" transcriptid="' . $nTranscriptID . '">Transcript variant on ' . $sTranscriptNM . ' (' . $sGene . ')</B>'), 'hr'), $this->buildForm($sPrefix), $aEffectForm, array('hr', 'skip'));
     }
     return parent::getForm();
 }
Esempio n. 8
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 $_AUTH, $_DB, $_SETT;
     if (ACTION == 'edit') {
         global $zData;
         $_POST['diseaseid'] = $zData['diseaseid'];
     }
     if (!empty($_POST['diseaseid'])) {
         $sDisease = $_DB->query('SELECT name FROM ' . TABLE_DISEASES . ' WHERE id = ?', array($_POST['diseaseid']))->fetchColumn();
     } else {
         $sDisease = 'all diseases';
     }
     if ($_AUTH['level'] >= LEVEL_CURATOR) {
         $aSelectOwner = $_DB->query('SELECT id, CONCAT(name, " (#", id, ")") as name_id FROM ' . TABLE_USERS . ' ORDER BY name')->fetchAllCombine();
         $aFormOwner = array('Owner of this data', '', 'select', 'owned_by', 1, $aSelectOwner, false, false, false);
         $aSelectStatus = $_SETT['data_status'];
         if (lovd_getProjectFile() == '/import.php') {
             // During an import the status pending is allowed, therefore only status in progress is unset.
             unset($aSelectStatus[STATUS_IN_PROGRESS]);
         } else {
             unset($aSelectStatus[STATUS_PENDING], $aSelectStatus[STATUS_IN_PROGRESS]);
         }
         $aFormStatus = array('Status of this data', '', 'select', 'statusid', 1, $aSelectStatus, false, false, false);
     } else {
         $aFormOwner = array();
         $aFormStatus = array();
     }
     // FIXME; right now two blocks in this array are put in, and optionally removed later. However, the if() above can build an entire block, such that one of the two big unset()s can be removed.
     // A similar if() to create the "authorization" block, or possibly an if() in the building of this form array, is easier to understand and more efficient.
     // Array which will make up the form table.
     $this->aFormData = array_merge(array(array('POST', '', '', '', '35%', '14', '65%'), array('', '', 'print', '<B>Phenotype information related to ' . $sDisease . '</B>'), 'hr'), $this->buildForm(), array('hr', 'general_skip' => 'skip', 'general' => array('', '', 'print', '<B>General information</B>'), 'general_hr1' => 'hr', 'owner' => $aFormOwner, 'status' => $aFormStatus, 'general_hr2' => 'hr', 'skip', 'authorization' => array('Enter your password for authorization', '', 'password', 'password', 20)));
     if (ACTION == 'create' || ACTION == 'publish' && GET) {
         // When creating, or when publishing without any changes, unset the authorization.
         unset($this->aFormData['authorization']);
     }
     if ($_AUTH['level'] < LEVEL_CURATOR) {
         unset($this->aFormData['general_skip'], $this->aFormData['general'], $this->aFormData['general_hr1'], $this->aFormData['owner'], $this->aFormData['status'], $this->aFormData['general_hr2']);
     }
     return parent::getForm();
 }
Esempio n. 9
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 $_AUTH, $_DB, $_SETT;
     // Get list of diseases.
     $aDiseasesForm = $_DB->query('SELECT id, IF(CASE symbol WHEN "-" THEN "" ELSE symbol END = "", name, CONCAT(symbol, " (", name, ")")) FROM ' . TABLE_DISEASES . ' ORDER BY (id > 0), (symbol != "" AND symbol != "-") DESC, symbol, name')->fetchAllCombine();
     $nDiseases = count($aDiseasesForm);
     foreach ($aDiseasesForm as $nID => $sDisease) {
         $aDiseasesForm[$nID] = lovd_shortenString($sDisease, 75);
     }
     $nFieldSize = $nDiseases < 15 ? $nDiseases : 15;
     if (!$nDiseases) {
         $aDiseasesForm = array('' => 'No disease entries available');
         $nFieldSize = 1;
     }
     if ($_AUTH['level'] >= LEVEL_CURATOR) {
         $aSelectOwner = $_DB->query('SELECT id, CONCAT(name, " (#", id, ")") as name_id FROM ' . TABLE_USERS . ' ORDER BY name')->fetchAllCombine();
         $aFormOwner = array('Owner of this data', '', 'select', 'owned_by', 1, $aSelectOwner, false, false, false);
         $aSelectStatus = $_SETT['data_status'];
         if (lovd_getProjectFile() == '/import.php') {
             // During an import the status pending is allowed, therefore only status in progress is unset.
             unset($aSelectStatus[STATUS_IN_PROGRESS]);
         } else {
             unset($aSelectStatus[STATUS_PENDING], $aSelectStatus[STATUS_IN_PROGRESS]);
         }
         $aFormStatus = array('Status of this data', '', 'select', 'statusid', 1, $aSelectStatus, false, false, false);
     } else {
         $aFormOwner = array();
         $aFormStatus = array();
     }
     // FIXME; right now two blocks in this array are put in, and optionally removed later. However, the if() above can build an entire block, such that one of the two big unset()s can be removed.
     // A similar if() to create the "authorization" block, or possibly an if() in the building of this form array, is easier to understand and more efficient.
     // Array which will make up the form table.
     $this->aFormData = array_merge(array(array('POST', '', '', '', '35%', '14', '65%'), array('', '', 'print', '<B>Individual information</B>'), 'hr'), $this->buildForm(), array(array('Panel size', '', 'text', 'panel_size', 10), array('', '', 'note', 'Fill in how many individuals this entry represents (default: 1).'), array('ID of panel this entry belongs to (optional)', 'Fill in LOVD\'s individual ID of the group to which this individual or group of individuals belong to (Optional).', 'text', 'panelid', 10), 'hr', 'skip', array('', '', 'print', '<B>Relation to diseases</B>'), 'hr', 'aDiseases' => array('This individual has been diagnosed with these diseases', '', 'select', 'active_diseases', $nFieldSize, $aDiseasesForm, false, true, false), 'diseases_info' => array('', '', 'note', ($nDiseases < 25 ? '' : '<A href="#" onclick="lovd_openWindow(\'' . lovd_getInstallURL() . 'diseases?&amp;no_links&amp;in_window\', \'Diseases\', 1000, 550); return false;">Find the used disease abbreviation in the list of diseases</A>.<BR>') . 'Diseases not in this list are not yet configured in this LOVD. If any disease you would like to select is not in here, please mention this in the remarks, preferably including the omim number. This way, a manager can configure this disease in this LOVD.'), 'diseases_create' => array('', '', 'note', ($nDiseases < 25 ? '' : '<A href="#" onclick="lovd_openWindow(\'' . lovd_getInstallURL() . 'diseases?&amp;no_links&amp;in_window\', \'Diseases\', 1000, 550); return false;">Find the used disease abbreviation in the list of diseases</A>.<BR>') . 'Diseases not in this list are not yet configured in this LOVD.<BR>Do you want to <A href="#" onclick="lovd_openWindow(\'' . lovd_getInstallURL() . 'diseases?create&amp;in_window\', \'DiseasesCreate\', 800, 550); return false;">configure more diseases</A>?'), 'hr', 'general_skip' => 'skip', 'general' => array('', '', 'print', '<B>General information</B>'), 'general_hr1' => 'hr', 'owner' => $aFormOwner, 'status' => $aFormStatus, 'general_hr2' => 'hr', 'skip', 'authorization' => array('Enter your password for authorization', '', 'password', 'password', 20)));
     if (ACTION == 'create' || ACTION == 'publish' && GET) {
         unset($this->aFormData['authorization']);
     }
     if ($_AUTH['level'] < LEVEL_CURATOR) {
         unset($this->aFormData['general_skip'], $this->aFormData['general'], $this->aFormData['general_hr1'], $this->aFormData['owner'], $this->aFormData['status'], $this->aFormData['general_hr2']);
     }
     if ($_AUTH['level'] < LEVEL_MANAGER) {
         unset($this->aFormData['diseases_create']);
     } else {
         unset($this->aFormData['diseases_info']);
     }
     return parent::getForm();
 }
Esempio n. 10
0
             // Not checking capitalization here yet.
         }
     }
     // Simply so that we can build somewhat correct email headers.
     if (empty($_CONF['institute'])) {
         $_CONF['institute'] = $_SERVER['HTTP_HOST'];
     }
     if (empty($_CONF['email_address'])) {
         $_CONF['email_address'] = 'noreply@' . (substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.' ? substr($_SERVER['HTTP_HOST'], 4) : $_SERVER['HTTP_HOST']);
     }
     // Set email headers.
     $_SETT['email_mime_boundary'] = md5('PHP_MIME');
     $_SETT['email_headers'] = 'MIME-Version: 1.0' . PHP_EOL . 'Content-Type: text/plain; charset=UTF-8' . PHP_EOL . 'X-Priority: 3' . PHP_EOL . 'X-Mailer: PHP/' . phpversion() . PHP_EOL . 'From: ' . (ON_WINDOWS ? '' : '"LOVD (' . lovd_shortenString($_CONF['system_title'], 50) . ')" ') . '<' . $_CONF['email_address'] . '>';
     $_SETT['email_mime_headers'] = preg_replace('/^Content-Type.+$/m', 'Content-Type: multipart/mixed; boundary="' . $_SETT['email_mime_boundary'] . '"' . PHP_EOL . 'Content-Transfer-Encoding: 7bit', $_SETT['email_headers']);
 }
 if (!in_array(lovd_getProjectFile(), array('/check_update.php'))) {
     // Load gene data.
     if (!empty($_SESSION['currdb'])) {
         $_SETT['currdb'] = @$_DB->query('SELECT * FROM ' . TABLE_GENES . ' WHERE id = ?', array($_SESSION['currdb']))->fetchAssoc();
         if (!$_SETT['currdb']) {
             $_SESSION['currdb'] = false;
         } else {
             // Replace with what we have in the database, so we won't run into issues on other pages when CurrDB is used for navigation to other tabs.
             $_SESSION['currdb'] = $_SETT['currdb']['id'];
         }
     } else {
         $_SESSION['currdb'] = false;
     }
 }
 /*
     // Load LOVD modules!
Esempio n. 11
0
 * Copyright   : 2004-2016 Leiden University Medical Center; http://www.LUMC.nl/
 * Programmers : Ing. Ivo F.A.C. Fokkema <*****@*****.**>
 *               Ing. Ivar C. Lugtenburg <*****@*****.**>
 *
 *
 * 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/>.
 *
 *************/
if (!defined('ROOT_PATH')) {
    define('ROOT_PATH', '../');
    require ROOT_PATH . 'inc-init.php';
    lovd_requireAUTH(LEVEL_MANAGER);
}
$aColSQL = array('INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Age_of_death",                    248, 100, 0, 0, 0, "Age of death",         "Type 35y for 35 years, 04y08m for 4 years and 8 months, 18y? for around 18 years, >54y for still alive at 55, ? for unknown.", "The age at which the individual deceased, if known and applicable. 04y08m = 4 years and 8 months.", "The age at which the individual deceased, if known and applicable.\\r\\n<UL style=\\"margin-top:0px;\\">\\r\\n  <LI>35y = 35 years</LI>\\r\\n  <LI>04y08m = 4 years and 8 months</LI>\\r\\n  <LI>18y? = around 18 years</LI>\\r\\n  <LI>&gt;54y = still alive at 55</LI>\\r\\n  <LI>? = unknown</LI>\\r\\n</UL>", "VARCHAR(12)", "Age of death|The age at which the individual deceased, if known and applicable. Numbers lower than 10 should be prefixed by a zero and the field should always begin with years, to facilitate sorting on this column.|text|10", "", "/^([<>]?\\\\d{2,3}y(\\\\d{2}m(\\\\d{2}d)?)?)?\\\\??$/", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Consanguinity",                   240,  40, 0, 0, 0, "Consanguinity",        "Indicates whether the parents are related (consanguineous), not related (non-consanguineous) or whether consanguinity is not known (unknown)", "Indicates whether the parents are related (consanguineous), not related (non-consanguineous) or whether consanguinity is not known (unknown)", "Indicates whether the parents are related (consanguineous), not related (non-consanguineous) or whether consanguinity is not known (unknown)", "VARCHAR(100)", "Consanguinity||select|1|--Not specified--|false|false", "? = Unknown\\r\\nno = Non-consanguineous parents\\r\\nyes = Consanguineous parents", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Death/Cause",                     249, 150, 0, 0, 0, "Cause of death",       "", "The cause of the individual\'s death, if known and applicable.", "The cause of the individual\'s death, if known and applicable.", "VARCHAR(255)", "Cause of death|The cause of the individual\'s death, if known and applicable.|text|30", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Gender",                            3,  70, 0, 0, 0, "Gender",               "", "Individual\'s gender.", "The gender of the reported individual.", "VARCHAR(100)", "Gender||select|1|--Not specified--|false|false", "? = Unknown\\r\\nF = Female\\r\\nM = Male\\r\\nrF = Raised as female\\r\\nrM = Raised as male", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Lab_ID",                            1,  80, 1, 1, 1, "Lab-ID",               "", "The individual\'s ID in the hospital, diagnostic laboratory or in the publication.", "The individual\'s ID in the hospital, diagnostic laboratory or in the publication.", "VARCHAR(15)", "Lab ID||text|15", "", "", 0, 1, 0, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Origin/Ethnic",                   201, 200, 0, 0, 0, "Ethnic origin",        "Ethnic origin of individual; e.g. African, Caucasian, gypsy, jew (Ashkenazi).", "Ethnic origin of individual; e.g. African, Caucasian, gypsy, jew (Ashkenazi).", "The ethnic origin of the individual; e.g. African, Caucasian, gypsy, jew (Ashkenazi).", "VARCHAR(50)", "Ethnic origin|If mixed, please indicate origin of father and mother, if known.|text|20", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Origin/Geographic",               200, 200, 0, 0, 0, "Geographic origin",    "Geographic origin of individual; Belgium = individual\'s origin is Belgium, (France) = reported by laboratory in France, individual\'s origin not sure.", "Geographic origin of individual; Belgium = individual\'s origin is Belgium, (France) = reported by laboratory in France, individual\'s origin not sure.", "The geographic origin of the individual (country and/or region); Belgium = individual\'s origin is Belgium, (France) = reported by laboratory in France, individual\'s origin not sure.", "VARCHAR(50)", "Geographic origin|If mixed, please indicate origin of father and mother, if known.|text|30", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Origin/Population",               202, 200, 0, 0, 0, "Population",           "", "Individual population.", "Additional information on the individual\'s population.", "VARCHAR(50)", "Individual population||text|30", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Reference",                         2, 200, 1, 1, 0, "Reference",            "", "Reference to publication describing the individual/family.", "Reference to publication describing the individual/family, possibly giving more phenotypic details than listed in this database entry, including link to PubMed or other source, e.g. \\"den Dunnen ASHG2003 P2346\\". References in the &quot;Country:City&quot; format indicate that the variant was submitted directly to this database by the laboratory indicated.", "VARCHAR(200)", "Reference||text|50", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Remarks",                         250, 200, 0, 1, 0, "Remarks",              "", "Remarks about the individual.", "Remarks about the individual.", "TEXT", "Remarks|Only provide data that do not belong in any other field.|textarea|50|3", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Individual/Remarks_Non_Public",              251, 200, 0, 1, 0, "Remarks (non public)", "", "Non-public remarks about the individual.", "Non-public remarks about the individual.", "TEXT", "Remarks (non public)||textarea|50|3", "", "", 0, 0, 0, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Phenotype/Additional",                       250, 200, 0, 1, 0, "Phenotype details",    "Additional information on the phenotype of the individual.", "Additional information on the phenotype of the individual.", "Additional information on the phenotype of the individual.", "TEXT", "Additional phenotype details||textarea|40|4", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Phenotype/Age",                               10, 100, 0, 0, 0, "Age examined",         "Type 35y for 35 years, 04y08m for 4 years and 8 months, 18y? for around 18 years, >54y for older than 54, ? for unknown.", "The age at which the individual was examined, if known. 04y08m = 4 years and 8 months.", "The age at which the individual was examined, if known.\\r\\n<UL style=\\"margin-top:0px;\\">\\r\\n  <LI>35y = 35 years</LI>\\r\\n  <LI>04y08m = 4 years and 8 months</LI>\\r\\n  <LI>18y? = around 18 years</LI>\\r\\n  <LI>&gt;54y = older than 54</LI>\\r\\n  <LI>? = unknown</LI>\\r\\n</UL>", "VARCHAR(12)", "Age at examination|The age at which the individual was examined, if known. Numbers lower than 10 should be prefixed by a zero and the field should always begin with years, to facilitate sorting on this column.|text|10", "", "/^([<>]?\\\\d{2,3}y(\\\\d{2}m(\\\\d{2}d)?)?)?\\\\??$/", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Phenotype/Age/Onset",                          1, 100, 0, 0, 0, "Age of onset",         "Type 35y for 35 years, 04y08m for 4 years and 8 months, 18y? for around 18 years, >54y for older than 54, ? for unknown.", "The age at which the first symptoms of the disease appeared in the individual, if known. 04y08m = 4 years and 8 months.", "The age at which the first symptoms appeared in the individual, if known.\\r\\n<UL style=\\"margin-top:0px;\\">\\r\\n  <LI>35y = 35 years</LI>\\r\\n  <LI>04y08m = 4 years and 8 months</LI>\\r\\n  <LI>18y? = around 18 years</LI>\\r\\n  <LI>&gt;54y = older than 54</LI>\\r\\n  <LI>? = unknown</LI>\\r\\n</UL>", "VARCHAR(12)", "Age of onset|The age at which the first symptoms appeared in the individual, if known. Numbers lower than 10 should be prefixed by a zero and the field should always begin with years, to facilitate sorting on this column.|text|10", "", "/^([<>]?\\\\d{2,3}y(\\\\d{2}m(\\\\d{2}d)?)?)?\\\\??$/", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Phenotype/Date",                               5,  80, 0, 0, 0, "Date",                 "Format: YYYY-MM-DD.", "Date the phenotype was observed.", "Date the phenotype was observed, in YYYY-MM-DD format.", "DATE", "Date||text|10", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Phenotype/Inheritance",                      254, 200, 1, 1, 0, "Inheritance",          "Indicates the inheritance of the phenotype in the family; unknown, familial (autosomal/X-linked, dominant/ recessive), paternal (Y-linked), maternal (mitochondrial), isolated (sporadic) or complex", "Indicates the inheritance of the phenotype in the family; unknown, familial (autosomal/X-linked, dominant/ recessive), paternal (Y-linked), maternal (mitochondrial), isolated (sporadic) or complex", "Indicates the inheritance of the phenotype in the family; unknown, familial (autosomal/X-linked, dominant/ recessive), paternal (Y-linked), maternal (mitochondrial), isolated (sporadic) or complex", "VARCHAR(50)", "Inheritance||select|1|--Not specified--|false|false", "Unknown\\r\\nFamilial\\r\\nFamilial, autosomal dominant\\r\\nFamilial, autosomal recessive\\r\\nFamilial, X-linked dominant\\r\\nFamilial, X-linked dominant, male sparing\\r\\nFamilial, X-linked recessive\\r\\nPaternal, Y-linked\\r\\nMaternal, mitochondrial\\r\\nIsolated (sporadic)\\r\\nComplex", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Phenotype/Length",                           200, 100, 0, 0, 0, "Length",               "", "Length of the individual, in cm.", "Length of the individual, in centimeters (cm).", "SMALLINT(3) UNSIGNED", "Length of individual (cm)|Length of individual, in centimeters.|text|3", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Screening/Date",                               1,  80, 0, 0, 0, "Date",                 "Format: YYYY-MM-DD.", "Date the detection technique was performed.", "Date the detection technique was performed, in YYYY-MM-DD format.", "DATE", "Date||text|10", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Screening/Technique",                          3, 200, 1, 1, 1, "Technique",            "Technique(s) used to identify the sequence variant; select multiple when more were used. For SEQ-NG, please indicate in the variant\'s remarks field the number of reads showing the variant (e.g. 47/96 reads, 123/123 reads), and create a second screening if you confirmed a variant using another method (e.g. SEQ).", "Technique(s) used to identify the sequence variant.", "Technique(s) used to identify the sequence variant.", "TEXT", "Technique(s) used||select|5|false|true|false", "? = Unknown\\r\\narrayCGH = array for Comparative Genomic Hybridisation\\r\\narraySEQ = array for resequencing\\r\\narraySNP = array for SNP typing\\r\\narrayCNV = array for Copy Number Variation (SNP and CNV probes)\\r\\nBESS = Base Excision Sequence Scanning\\r\\nCMC = Chemical Mismatch Cleavage\\r\\nCSCE = Conformation Sensitive Capillary Electrophoresis\\r\\nDGGE = Denaturing-Gradient Gel-Electrophoresis\\r\\nDHPLC = Denaturing High-Performance Liquid Chromatography\\r\\nDOVAM = Detection Of Virtually All Mutations (SSCA variant)\\r\\nddF = dideoxy Fingerprinting\\r\\nDSCA = Double-Strand DNA Conformation Analysis\\r\\nEMC = Enzymatic Mismatch Cleavage\\r\\nHD = HeteroDuplex analysis\\r\\nMCA = high-resolution Melting Curve Analysis (hrMCA)\\r\\nIHC = Immuno-Histo-Chemistry\\r\\nMAPH = Multiplex Amplifiable Probe Hybridisation\\r\\nMLPA = Multiplex Ligation-dependent Probe Amplification\\r\\nSEQ-NG = Next-Generation Sequencing\\r\\nSEQ-NG-H = Next-Generation Sequencing - Helicos\\r\\nSEQ-NG-I = Next-Generation Sequencing - Illumina/Solexa\\r\\nSEQ-NG-R = Next-Generation Sequencing - Roche/454\\r\\nSEQ-NG-S = Next-Generation Sequencing - SOLiD\\r\\nNorthern = Northern blotting\\r\\nPCR = Polymerase Chain Reaction\\r\\nPCRdig = PCR + restriction enzyme digestion\\r\\nPCRlr = PCR, long-range\\r\\nPCRm = PCR, multiplex\\r\\nPCRq = PCR, quantitative\\r\\nPAGE = Poly-Acrylamide Gel-Electrophoresis\\r\\nPTT = Protein Truncation Test\\r\\nPFGE = Pulsed-Field Gel-Electrophoresis (+Southern)\\r\\nRT-PCR = Reverse Transcription and PCR\\r\\nSEQ = SEQuencing\\r\\nSBE = Single Base Extension\\r\\nSSCA = Single-Strand DNA Conformation polymorphism Analysis (SSCP)\\r\\nSSCAf = SSCA, fluorescent (SSCP)\\r\\nSouthern = Southern blotting\\r\\nTaqMan = TaqMan assay\\r\\nWestern = Western Blotting", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Screening/Template",                           2,  80, 1, 1, 1, "Template",             "", "Template(s) used to detect the sequence variant; DNA = genomic DNA, RNA = RNA (cDNA).", "Template(s) used to detect the sequence variant; DNA = genomic DNA, RNA = RNA (cDNA).", "TEXT", "Detection template||select|3|false|true|false", "DNA\\r\\nRNA = RNA (cDNA)\\r\\nProtein\\r\\n? = unknown", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("Screening/Tissue",                             4, 100, 0, 0, 1, "Tissue",               "", "Tissue type used for the detection of sequence variants.", "Tissue type used for the detection of sequence variants.", "VARCHAR(25)", "Tissue||text|20", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/Conservation_score/GERP",      4, 100, 0, 0, 0, "GERP conservation",    "", "Conservation score as calculated by GERP.", "The Conservation score as calculated by GERP.", "DECIMAL(5,3)", "GERP conservation score||text|6", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/DBID",                         7, 120, 1, 1, 1, "DB-ID",                "NOTE: This field will be predicted and filled in by LOVD, if left empty.", "Database ID of variant starting with the HGNC gene symbol, followed by an underscore (_) and a six digit number (e.g. DMD_012345). _000000 is used for variants where DNA was not analysed (change predicted from RNA analysis), variants seen in animal models or variants not seen in humans but functionally tested in vitro.", "Database ID of variant, grouping multiple observations of the same variant together, starting with the HGNC gene symbol, followed by an underscore (_) and a six digit number (e.g. DMD_012345). _000000 is used for variants where DNA was not analysed (change predicted from RNA analysis), variants seen in animal models or variants not seen in humans but functionally tested in vitro.", "VARCHAR(50)", "ID|This ID is used to group multiple observations of the same variant together. This field will be predicted and filled in by LOVD when left empty. The ID starts with the HGNC gene symbol of the transcript most influenced by the variant or otherwise the closest gene, followed by an underscore (_) and a six digit number (e.g. DMD_012345). _000000 is used for variants where DNA was not analysed (change predicted from RNA analysis), variants seen in animal models or variants not seen in humans but functionally tested in vitro.|text|20", "", "/^(chr(\\\\d{1,2}|[XYM])|(C(\\\\d{1,2}|[XYM])orf[\\\\d][\\\\dA-Z]*-|[A-Z][A-Z0-9]+-)?(C(\\\\d{1,2}|[XYM])orf[\\\\d][\\\\dA-Z]*|[A-Z][A-Z0-9-]+))_\\\\d{6}$/", 1, 0, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/dbSNP",                        8, 120, 0, 0, 0, "dbSNP ID",             "", "The dbSNP ID.", "The dbSNP ID.", "VARCHAR(15)", "dbSNP ID|If available, please fill in the dbSNP ID, such as rs12345678.|text|10", "", "/^[rs]s\\\\d+$/", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/DNA",                          2, 200, 1, 1, 1, "DNA change (genomic)", "", "Description of variant at DNA level, based on the genomic DNA reference sequence (following HGVS recommendations).", "Description of variant at DNA level, based on the genomic DNA reference sequence (following HGVS recommendations).<BR>\\r\\n<UL style=\\"margin-top : 0px;\\">\\r\\n  <LI>g.12345678C>T</LI>\\r\\n  <LI>g.12345678_12345890del</LI>\\r\\n  <LI>g.12345678_12345890dup</LI>\\r\\n</UL>", "VARCHAR(100)", "Genomic DNA change (HGVS format)|Description of variant at DNA level, based on the genomic DNA reference sequence (following HGVS recommendations); e.g. g.12345678C>T, g.12345678_12345890del, g.12345678_12345890dup.|text|30", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/Frequency",                    9,  90, 0, 1, 0, "Frequency",            "", "Frequency in which the variant was found; e.g 5/760 chromosomes (in 5 of 760 chromosomes tested), 1/33 patients (in 1 of 33 patients analysed in study), 0.05 controls (in 5% of control cases tested).", "Frequency in which the variant was found; e.g 5/760 chromosomes (in 5 of 760 chromosomes tested), 1/33 patients (in 1 of 33 patients analysed in study), 0.05 controls (in 5% of control cases tested).", "VARCHAR(15)", "Frequency|Frequency in which the variant was found; e.g 5/760 chromosomes (in 5 of 760 chromosomes tested), 1/33 patients (in 1 of 33 patients analysed in study), 0.05 controls (in 5% of control cases tested). Preferred format is 3/75, not 0.04.|text|10", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/Genetic_origin",              11, 200, 0, 0, 1, "Genetic origin",       "", "Origin of variant; unknown, germline, somatic, de novo, from parental disomy (maternal or paternal) or in vitro (cloned) when tested for functional consequences.", "Origin of variant; unknown, germline, somatic, de novo, from parental disomy (maternal or paternal) or in vitro (cloned) when tested for functional consequences.", "VARCHAR(100)", "Genetic origin||select|1|--Not specified--|false|false", "Unknown\\r\\nGermline\\r\\nSomatic\\r\\nDe novo\\r\\nUniparental disomy\\r\\nUniparental disomy, maternal allele\\r\\nUniparental disomy, paternal allele\\r\\nIn vitro (cloned)", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/Published_as",                 3, 200, 0, 0, 0, "Published as",         "Variant as originally reported (e.g. 521delT); provide only when different from \\"DNA change\\".", "Variant as originally reported (e.g. 521delT); listed only when different from \\"DNA change\\". Variants seen in animal models, tested in vitro, predicted from RNA analysis, etc. are described between brackets like c.(456C>G).", "Variant as originally reported (e.g. 521delT); listed only when different from \\"DNA change\\". Variants seen in animal models, tested in vitro, predicted from RNA analysis, etc. are described between brackets like c.(456C>G).", "VARCHAR(100)", "Published as|Variants seen in animal models, tested in vitro, predicted from RNA analysis, etc. are described between brackets like c.(456C>G).|text|30", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/Reference",                    6, 200, 1, 1, 0, "Reference",            "", "Reference to publication describing the variant.", "Reference to publication describing the variant, including links to OMIM (when available), PubMed or or other source, e.g. \\"den Dunnen ASHG2003 P2346\\".", "VARCHAR(255)", "Reference||text|50", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/Remarks",                     10, 200, 0, 0, 0, "Variant remarks",      "Remarks regarding the variant described, e.g. germline mosaicism in mother, 345 kb deletion, muscle RNA analysed, not in 200 control chromosomes tested, on founder haplotype, etc.", "Remarks regarding the variant described.", "Remarks regarding the variant described, e.g. germline mosaicism in mother, 345 kb deletion, muscle RNA analysed, not in 200 control chromosomes tested, on founder haplotype, etc.", "TEXT", "Remarks||textarea|50|3", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/Restriction_site",             5,  75, 0, 0, 0, "Re-site",              "", "Restriction enzyme recognition site created (+) or destroyed (-).", "Restriction enzyme recognition site created (+) or destroyed (-); e.g. BglII+, BamHI-.", "VARCHAR(25)", "Re-site|Restriction enzyme recognition site created (+) or destroyed (-); e.g. BglII+, BamHI-|text|10", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/Segregation",                 12,  40, 0, 0, 0, "Segregation",          "Indicates whether the variant segregates with the phenotype (yes), does not segregate with the phenotype (no) or segregation is unknown (?)", "Indicates whether the variant segregates with the phenotype (yes), does not segregate with the phenotype (no) or segregation is unknown (?)", "Indicates whether the variant segregates with the phenotype (yes), does not segregate with the phenotype (no) or segregation is unknown (?)", "VARCHAR(100)", "Segregation||select|1|--Not specified--|false|false", "? = Unknown\\r\\nyes = Segregates with phenotype\\r\\nno = Does not segregate with phenotype", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnGenome/Type",                         1, 200, 0, 0, 1, "Type",                 "", "Type of variant at DNA level.", "Type of variant at DNA level; note that the variant type can also be derived from the variant description (for all levels).", "VARCHAR(100)", "Type of variant (DNA level)|Type of variant at DNA level; note that the variant type can also be derived from the variant description (for all levels).|select|1|true|false|false", "Substitution\\r\\nDeletion\\r\\nDuplication\\r\\nInsertion\\r\\nInversion\\r\\nInsertion/Deletion\\r\\nTranslocation\\r\\nOther/Complex", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnTranscript/Distance_to_splice_site", 10, 150, 0, 0, 0, "Splice distance",      "", "The distance to the nearest splice site.", "The distance to the nearest splice site.", "MEDIUMINT(8) UNSIGNED", "Distance to splice site||text|8", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnTranscript/DNA",                      3, 200, 1, 1, 1, "DNA change (cDNA)",    "", "Description of variant at DNA level, based on a coding DNA reference sequence (following HGVS recommendations).", "Description of variant at DNA level, based on a coding DNA reference sequence (following HGVS recommendations); e.g. c.123C>T, c.123_145del, c.123_126dup.", "VARCHAR(100)", "DNA change (HGVS format)|Description of variant at DNA level, based on a coding DNA reference sequence (following HGVS recommendations); e.g. c.123C>T, c.123_145del, c.123_126dup.|text|30", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnTranscript/Exon",                     2,  50, 0, 1, 1, "Exon",                 "", "Number of exon/intron containing the variant.", "Number of exon/intron containing variant; 2 = exon 2, 12i = intron 12, 2i_7i = exons 3 to 7, 8i_9 = border intron 8/exon 9.", "VARCHAR(7)", "Exon|Format: 2 = exon 2, 12i = intron 12, 2i_7i = exons 3 to 7, 8i_9 = border intron 8/exon 9.|text|7", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnTranscript/GVS/Function",             9, 200, 0, 0, 0, "GVS function",         "", "Functional annotation of this position from the Genome Variation Server.", "The functional annotation of this position from the Genome Variation Server.", "VARCHAR(100)", "GVS function||select|1|true|false|false", "intergenic\\r\\nnear-gene-5\\r\\nutr-5\\r\\ncoding\\r\\ncoding-near-splice\\r\\ncoding-synonymous\\r\\ncoding-synonymous-near-splice\\r\\ncodingComplex\\r\\ncodingComplex-near-splice\\r\\nframeshift\\r\\nframeshift-near-splice\\r\\nmissense\\r\\nmissense-near-splice\\r\\nsplice-5\\r\\nintron\\r\\nsplice-3\\r\\nstop-gained\\r\\nstop-gained-near-splice\\r\\nstop-lost\\r\\nstop-lost-near-splice\\r\\nutr-3\\r\\nnear-gene-3", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnTranscript/Location",                 1, 200, 0, 0, 1, "Location",             "", "Location of variant at DNA level.", "Location of variant at DNA level; note that the variant location can also be derived from the variant description.", "VARCHAR(100)", "Location of variant|The variant location can also be derived from the variant description|select|1|true|false|false", "5\' gene flanking\\r\\n5\' UTR\\r\\nExon\\r\\nIntron\\r\\n3\' UTR\\r\\n3\' gene flanking", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnTranscript/PolyPhen",                 8, 200, 0, 0, 0, "PolyPhen prediction",  "", "Effect of variant, predicted by PolyPhen.", "Effect of variant, predicted by PolyPhen.", "VARCHAR(100)", "PolyPhen prediction|Effect of variant, predicted by PolyPhen|select|1|true|false|false", "benign = Benign\\r\\npossiblyDamaging = Possibly damaging\\r\\nprobablyDamaging = Probably damaging\\r\\nnoPrediction = No prediction", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnTranscript/Position",                 5, 100, 0, 0, 0, "Position",             "", "Position of variant in coding DNA sequence.", "Position of variant in coding DNA sequence; note that coding DNA position can also be derived from the variant description.", "MEDIUMINT(6)", "cDNA position|Note that cDNA position can be derived from the variant description.|text|5", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnTranscript/Protein",                  7, 200, 1, 1, 1, "Protein",              "", "Description of variant at protein level (following HGVS recommendations).", "Description of variant at protein level (following HGVS recommendations).<BR>\\r\\n<UL style=\\"margin-top : 0px;\\">\\r\\n  <LI>p.(Arg345Pro) = change predicted from DNA (RNA not analysed)</LI>\\r\\n  <LI>p.Arg345Pro = change derived from RNA analysis</LI>\\r\\n  <LI>p.? = unknown effect</LI>\\r\\n  <LI>p.0? = probably no protein produced</LI>\\r\\n</UL>", "VARCHAR(100)", "Protein change (HGVS format)|Description of variant at protein level (following HGVS recommendations); e.g. p.(Arg345Pro) = change predicted from DNA (RNA not analysed), p.Arg345Pro = change derived from RNA analysis, p.0 (no protein produced), p.? (unknown effect).|text|30", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnTranscript/Published_as",             4, 200, 0, 0, 0, "Published as",         "Variant as originally reported (e.g. 521delT); provide only when different from \\"DNA change\\".", "Variant as originally reported (e.g. 521delT); listed only when different from \\"DNA change\\". Variants seen in animal models, tested in vitro, predicted from RNA analysis, etc. are described between brackets like c.(456C>G).", "Variant as originally reported (e.g. 521delT); listed only when different from \\"DNA change\\". Variants seen in animal models, tested in vitro, predicted from RNA analysis, etc. are described between brackets like c.(456C>G).", "VARCHAR(100)", "Published as|Variants seen in animal models, tested in vitro, predicted from RNA analysis, etc. are described between brackets like c.(456C>G).|text|30", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)', 'INSERT INTO ' . TABLE_COLS . ' VALUES ("VariantOnTranscript/RNA",                      6, 200, 1, 1, 1, "RNA change",           "", "Description of variant at RNA level (following HGVS recommendations).", "Description of variant at RNA level (following HGVS recommendations).<BR>\\r\\n<UL style=\\"margin-top : 0px;\\">\\r\\n  <LI>r.123c>u</LI>\\r\\n  <LI>r.? = unknown</LI>\\r\\n  <LI>r.(?) = RNA not analysed but probably transcribed copy of DNA variant</LI>\\r\\n  <LI>r.spl? = RNA not analysed but variant probably affects splicing</LI>\\r\\n  <LI>r.(spl?) = RNA not analysed but variant may affect splicing</LI>\\r\\n  <LI>r.0? = change expected to abolish transcription</LI>\\r\\n</UL>", "VARCHAR(100)", "RNA change (HGVS format)|Description of variant at RNA level (following HGVS recommendations); e.g. r.123c>u, r.? = unknown, r.(?) = RNA not analysed but probably transcribed copy of DNA variant, r.spl? = RNA not analysed but variant probably affects splicing, r.(spl?) = RNA not analysed but variant may affect splicing.|text|30", "", "", 1, 1, 1, 0, NOW(), NULL, NULL)');
if (lovd_getProjectFile() == '/install/inc-sql-columns.php') {
    header('Content-type: text/plain; charset=UTF-8');
    var_dump($aColSQL);
}
Esempio n. 12
0
    CONSTRAINT ' . TABLE_ANNOUNCEMENTS . '_fk_created_by FOREIGN KEY (created_by) REFERENCES ' . TABLE_USERS . ' (id) ON DELETE SET NULL ON UPDATE CASCADE,
    CONSTRAINT ' . TABLE_ANNOUNCEMENTS . '_fk_edited_by FOREIGN KEY (edited_by) REFERENCES ' . TABLE_USERS . ' (id) ON DELETE SET NULL ON UPDATE CASCADE)
    ' . $sSettings, 'TABLE_SOURCES' => 'CREATE TABLE ' . TABLE_SOURCES . ' (
    id VARCHAR(15) NOT NULL,
    url VARCHAR(255) NOT NULL,
    PRIMARY KEY (id))
    ' . $sSettings, 'TABLE_LOGS' => 'CREATE TABLE ' . TABLE_LOGS . ' (
    name VARCHAR(10) NOT NULL,
    date DATETIME NOT NULL,
    mtime MEDIUMINT(6) UNSIGNED ZEROFILL NOT NULL,
    userid SMALLINT(5) UNSIGNED ZEROFILL,
    event VARCHAR(20) NOT NULL,
    log TEXT NOT NULL,
    PRIMARY KEY (name, date, mtime),
    INDEX (userid),
    CONSTRAINT ' . TABLE_LOGS . '_fk_userid FOREIGN KEY (userid) REFERENCES ' . TABLE_USERS . ' (id) ON DELETE CASCADE ON UPDATE CASCADE)
    ' . $sSettings, 'TABLE_MODULES' => 'CREATE TABLE ' . TABLE_MODULES . ' (
    id VARCHAR(15) NOT NULL,
    name VARCHAR(50) NOT NULL,
    version VARCHAR(15) NOT NULL,
    description VARCHAR(255) NOT NULL,
    active BOOLEAN NOT NULL,
    settings TEXT NOT NULL,
    installed_date DATE NOT NULL,
    updated_date DATE,
    PRIMARY KEY (id))
    ' . $sSettings);
if (lovd_getProjectFile() == '/install/inc-sql-tables.php') {
    header('Content-type: text/plain; charset=UTF-8');
    var_dump($aTableSQL);
}
Esempio n. 13
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)) {
         if (lovd_getProjectFile() == '/import.php') {
             // During import the refseq_genomic is required, else the import
             // starts complaining that the selected refseq_genomic is not valid
             // Therefore we set the refseq_genomic in the aFormData property
             // before the getForm() is returned.
             global $zData;
             $aSelectRefseqGenomic = array_combine(array($zData['refseq_genomic']), array($zData['refseq_genomic']));
             $this->aFormData['refseq_genomic'] = array('Genomic reference sequence', '', 'select', 'refseq_genomic', 1, $aSelectRefseqGenomic, false, false, false);
         }
         return parent::getForm();
     }
     global $_DB, $zData, $_SETT;
     // Get list of diseases.
     $aDiseasesForm = $_DB->query('SELECT id, IF(CASE symbol WHEN "-" THEN "" ELSE symbol END = "", name, CONCAT(symbol, " (", name, ")")) FROM ' . TABLE_DISEASES . ' WHERE id > 0 ORDER BY (symbol != "" AND symbol != "-") DESC, symbol, name')->fetchAllCombine();
     $nDiseases = count($aDiseasesForm);
     if (!$nDiseases) {
         $aDiseasesForm = array('' => 'No disease entries available');
         $nDiseasesFormSize = 1;
     } else {
         $aDiseasesForm = array_combine(array_keys($aDiseasesForm), array_map('lovd_shortenString', $aDiseasesForm, array_fill(0, $nDiseases, 75)));
         $nDiseasesFormSize = $nDiseases < 15 ? $nDiseases : 15;
     }
     // References sequences (genomic and transcripts).
     if (lovd_getProjectFile() == '/import.php') {
         $aSelectRefseqGenomic = array_combine(array($zData['refseq_genomic']), array($zData['refseq_genomic']));
     } else {
         $aSelectRefseqGenomic = array_combine($zData['genomic_references'], $zData['genomic_references']);
     }
     $aTranscriptNames = array();
     $aTranscriptsForm = array();
     if (!empty($zData['transcripts'])) {
         foreach ($zData['transcripts'] as $sTranscript) {
             // Until revision 679 the transcript version was not used in the index and removed with preg_replace.
             // Can not figure out why version is not included. Therefore, for now we will do without preg_replace.
             if (!isset($aTranscriptNames[$sTranscript])) {
                 $aTranscriptsForm[$sTranscript] = lovd_shortenString($zData['transcriptNames'][$sTranscript], 50);
                 $aTranscriptsForm[$sTranscript] .= str_repeat(')', substr_count($aTranscriptsForm[$sTranscript], '(')) . ' (' . $sTranscript . ')';
             }
         }
         asort($aTranscriptsForm);
     } else {
         $aTranscriptsForm = array('' => 'No transcripts available');
     }
     $nTranscriptsFormSize = count($aTranscriptsForm);
     $nTranscriptsFormSize = $nTranscriptsFormSize < 10 ? $nTranscriptsFormSize : 10;
     $aSelectRefseq = array('c' => 'Coding DNA', 'g' => 'Genomic');
     $aSelectDisclaimer = array(0 => 'No', 1 => 'Use standard LOVD disclaimer', 2 => 'Use own disclaimer (enter below)');
     $aSelectHeaderFooter = array(-1 => 'Left', 0 => 'Center', 1 => 'Right');
     // Array which will make up the form table.
     $this->aFormData = array(array('POST', '', '', '', '35%', '14', '65%'), array('', '', 'print', '<B>General information</B>'), 'hr', array('Full gene name', '', 'print', $zData['name'], 50), array('Official gene symbol', '', 'print', $zData['id']), array('Chromosome', '', 'print', $zData['chromosome']), array('Chromosomal band', '', 'text', 'chrom_band', 10), array('Imprinting', 'Please note:<BR>Maternally imprinted (expressed from the paternal allele)<BR>Paternally imprinted (expressed from the maternal allele)', 'select', 'imprinting', 1, $_SETT['gene_imprinting'], false, false, false), array('Date of creation (optional)', 'Format: YYYY-MM-DD. If left empty, today\'s date will be used.', 'text', 'created_date', 10), 'hr', 'skip', array('', '', 'print', '<B>Relation to diseases (optional)</B>'), 'hr', array('This gene has been linked to these diseases', 'Listed are all disease entries currently configured in LOVD.', 'select', 'active_diseases', $nDiseasesFormSize, $aDiseasesForm, false, true, false), array('', '', 'note', 'Diseases not in this list are not yet configured in this LOVD.<BR>Do you want to <A href="#" onclick="lovd_openWindow(\'' . lovd_getInstallURL() . 'diseases?create&amp;in_window\', \'DiseasesCreate\', 800, 550); return false;">configure more diseases</A>?'), 'hr', 'skip', array('', '', 'print', '<B>Reference sequences (mandatory)</B>'), array('', '', 'note', 'Collecting variants requires a proper reference sequence. Without a genomic and a transcript reference sequence the variants in this LOVD database cannot be interpreted properly or mapped to the genome.'), 'hr', 'refseq_genomic' => array('Genomic reference sequence', '', 'select', 'refseq_genomic', 1, $aSelectRefseqGenomic, false, false, false), array('', '', 'note', 'Select the genomic reference sequence (NG, NC, LRG accession number). Only the references that are available to LOVD are shown.'), 'transcripts' => array('Transcript reference sequence(s)', 'Select transcript references (NM accession numbers).', 'select', 'active_transcripts', $nTranscriptsFormSize, $aTranscriptsForm, false, true, false), 'hr', 'skip', array('', '', 'print', '<B>Links to information sources (optional)</B>'), array('', '', 'note', 'Here you can add links that will be displayed on the gene\'s LOVD gene homepage.'), 'hr', array('Homepage URL', '', 'text', 'url_homepage', 40), array('', '', 'note', 'If you have a separate homepage about this gene, you can specify the URL here. Format: complete URL, including "http://".'), array('External links', '', 'textarea', 'url_external', 55, 3), array('', '', 'note', 'Here you can provide links to other resources on the internet that you would like to link to. One link per line, format: complete URLs or "Description &lt;URL&gt;".'), array('HGNC ID', '', 'print', $zData['id_hgnc']), array('Entrez Gene (Locuslink) ID', '', 'print', $zData['id_entrez'] ? $zData['id_entrez'] : 'Not Available'), array('OMIM Gene ID', '', 'print', $zData['id_omim'] ? $zData['id_omim'] : 'Not Available'), array('Provide link to HGMD', 'Do you want a link to this gene\'s entry in the Human Gene Mutation Database added to the homepage?', 'checkbox', 'show_hgmd'), array('Provide link to GeneCards', 'Do you want a link to this gene\'s entry in the GeneCards database added to the homepage?', 'checkbox', 'show_genecards'), array('Provide link to GeneTests', 'Do you want a link to this gene\'s entry in the GeneTests database added to the homepage?', 'checkbox', 'show_genetests'), array('This gene has a human-readable reference sequence', '', 'select', 'refseq', 1, $aSelectRefseq, 'No', false, false), array('', '', 'note', 'Although GenBank files are the official reference sequence, they are not very readable for humans. If you have a human-readable format of your reference sequence online, please select the type here.'), array('Human-readable reference sequence location', '', 'text', 'refseq_url', 40), 'refseqparse_new' => array('', '', 'note', 'If you are going to use our <A href="#" onclick="lovd_openWindow(\'' . lovd_getInstallURL() . 'scripts/refseq_parser.php\', \'RefSeqParser\', 800, 500); return false;">Reference Sequence Parser</A> to create a human-readable reference sequence, the result will be located at "' . lovd_getInstallURL() . 'refseq/' . $zData['id'] . '_codingDNA.html".'), 'refseqparse_edit' => array('', '', 'note', 'If you used our <A href="#" onclick="lovd_openWindow(\'' . lovd_getInstallURL() . 'scripts/refseq_parser.php?symbol=' . $zData['id'] . '\', \'RefSeqParser\', 800, 500); return false;">Reference Sequence Parser</A> to create a human-readable reference sequence, the result is located at "' . lovd_getInstallURL() . 'refseq/' . $zData['id'] . '_codingDNA.html".'), 'hr', 'skip', array('', '', 'print', '<B>Customizations (optional)</B>'), array('', '', 'note', 'You can use the following fields to customize the gene\'s LOVD gene homepage.'), 'hr', array('Citation reference(s)', '', 'textarea', 'reference', 30, 3), array('', '', 'note', '(Active custom link : <A href="#" onmouseover="lovd_showToolTip(\'Click to insert:<BR>{PMID:[1]:[2]}<BR><BR>Links to abstracts in the PubMed database.<BR>[1] = The name of the author(s).<BR>[2] = The PubMed ID.\');" onmouseout="lovd_hideToolTip();" onclick="lovd_insertCustomLink(this, \'{PMID:[1]:[2]}\'); return false">Pubmed</A>)'), array('Include disclaimer', '', 'select', 'disclaimer', 1, $aSelectDisclaimer, false, false, false), array('', '', 'note', 'If you want a disclaimer added to the gene\'s LOVD gene homepage, select your preferred option here.'), array('Text for own disclaimer<BR>(HTML enabled)', '', 'textarea', 'disclaimer_text', 55, 3), array('', '', 'note', 'Only applicable if you choose to use your own disclaimer (see option above).'), array('Page header<BR>(HTML enabled)', '', 'textarea', 'header', 55, 3), array('', '', 'note', 'Text entered here will appear above all public gene-specific pages.'), array('Header aligned to', '', 'select', 'header_align', 1, $aSelectHeaderFooter, false, false, false), array('Page footer<BR>(HTML enabled)', '', 'textarea', 'footer', 55, 3), array('', '', 'note', 'Text entered here will appear below all public gene-specific pages.'), array('Footer aligned to', '', 'select', 'footer_align', 1, $aSelectHeaderFooter, false, false, false), array('Notes for the LOVD gene homepage<BR>(HTML enabled)', '', 'textarea', 'note_index', 55, 3), array('', '', 'note', 'Text entered here will appear in the General Information box on the gene\'s LOVD gene homepage.'), array('Notes for the variant listings<BR>(HTML enabled)', '', 'textarea', 'note_listing', 55, 3), array('', '', 'note', 'Text entered here will appear below the gene\'s variant listings.'), 'hr', 'skip', array('', '', 'print', '<B>Security settings</B>'), array('', '', 'note', 'Using the following settings you can control some security settings of LOVD.'), 'hr', array('Allow public to download variant entries', '', 'checkbox', 'allow_download'), array('Allow my public variant and individual data to be indexed by WikiProfessional', '', 'checkbox', 'allow_index_wiki'), 'hr', 'skip');
     if (ACTION == 'edit') {
         $this->aFormData['transcripts'] = array('Transcriptomic reference sequence(s)', '', 'note', 'To add, remove or edit transcriptomic reference sequences for this gene, please see the gene\'s detailed view.');
         unset($this->aFormData['refseqparse_new']);
     } else {
         unset($this->aFormData['refseqparse_edit']);
     }
     return parent::getForm();
 }
Esempio n. 14
0
    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;
    }
Esempio n. 15
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 $_AUTH, $_CONF, $_DB, $_SETT, $zData, $_DATA;
     $aSelectAllele = $_DB->query('SELECT id, name FROM ' . TABLE_ALLELES . ' ORDER BY display_order')->fetchAllCombine();
     if (!empty($_GET['geneid'])) {
         $aFormChromosome = array('Chromosome', '', 'print', $_POST['chromosome']);
     } elseif (ACTION == 'edit') {
         $aFormChromosome = array('Chromosome', '', 'print', $zData['chromosome']);
     } else {
         $aChromosomes = array_keys($_SETT['human_builds'][$_CONF['refseq_build']]['ncbi_sequences']);
         $aSelectChromosome = array_combine($aChromosomes, $aChromosomes);
         $aFormChromosome = array('Chromosome', '', 'select', 'chromosome', 1, $aSelectChromosome, false, false, false);
     }
     if ($_AUTH['level'] >= LEVEL_CURATOR) {
         $aSelectOwner = $_DB->query('SELECT id, CONCAT(name, " (#", id, ")") as name_id FROM ' . TABLE_USERS . ' ORDER BY name')->fetchAllCombine();
         $aFormOwner = array('Owner of this data', '', 'select', 'owned_by', 1, $aSelectOwner, false, false, false);
         $aSelectStatus = $_SETT['data_status'];
         if (lovd_getProjectFile() == '/import.php') {
             // During an import the status pending is allowed, therefore only status in progress is unset.
             unset($aSelectStatus[STATUS_IN_PROGRESS]);
         } else {
             unset($aSelectStatus[STATUS_PENDING], $aSelectStatus[STATUS_IN_PROGRESS]);
         }
         $aFormStatus = array('Status of this data', '', 'select', 'statusid', 1, $aSelectStatus, false, false, false);
     } else {
         $aFormOwner = array();
         $aFormStatus = array();
     }
     $aTranscriptsForm = array();
     if (!empty($_DATA['Transcript'])) {
         foreach (array_keys($_DATA['Transcript']) as $sGene) {
             $aTranscriptsForm = array_merge($aTranscriptsForm, $_DATA['Transcript'][$sGene]->getForm());
         }
     }
     // Add genome build name to VOG/DNA field.
     $this->aColumns['VariantOnGenome/DNA']['description_form'] = '<B>Relative to ' . $_CONF['refseq_build'] . ' / ' . $_SETT['human_builds'][$_CONF['refseq_build']]['ncbi_name'] . '.</B>' . (!$this->aColumns['VariantOnGenome/DNA']['description_form'] ? '' : '<BR>' . $this->aColumns['VariantOnGenome/DNA']['description_form']);
     // FIXME; right now two blocks in this array are put in, and optionally removed later. However, the if() above can build an entire block, such that one of the two big unset()s can be removed.
     // A similar if() to create the "authorization" block, or possibly an if() in the building of this form array, is easier to understand and more efficient.
     // Array which will make up the form table.
     $this->aFormData = array_merge(array(array('POST', '', '', '', '35%', '14', '65%')), $aTranscriptsForm, array(array('', '', 'print', '<B>Genomic variant information</B>'), 'hr', array('Allele', '', 'select', 'allele', 1, $aSelectAllele, false, false, false), array('', '', 'note', 'If you wish to report an homozygous variant, please select "Both (homozygous)" here.'), $aFormChromosome), $this->buildForm(), array(array('Affects function (reported)', '', 'select', 'effect_reported', 1, $_SETT['var_effect'], false, false, false), 'effect' => array('Affects function (concluded)', '', 'select', 'effect_concluded', 1, $_SETT['var_effect'], false, false, false), 'hr', 'general_skip' => 'skip', 'general' => array('', '', 'print', '<B>General information</B>'), 'general_hr1' => 'hr', 'owner' => $aFormOwner, 'status' => $aFormStatus, 'general_hr2' => 'hr', 'skip', 'authorization' => array('Enter your password for authorization', '', 'password', 'password', 20)));
     if (ACTION == 'create' || ACTION == 'publish' && GET) {
         // When creating, or when publishing without any changes, unset the authorization.
         unset($this->aFormData['authorization']);
     }
     if ($_AUTH['level'] < LEVEL_CURATOR) {
         unset($this->aFormData['effect'], $this->aFormData['general_skip'], $this->aFormData['general'], $this->aFormData['general_hr1'], $this->aFormData['owner'], $this->aFormData['status'], $this->aFormData['general_hr2']);
     }
     return parent::getForm();
 }
Esempio n. 16
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 $_AUTH, $_DB, $nID;
     if ($_AUTH['level'] >= LEVEL_CURATOR) {
         $aSelectOwner = $_DB->query('SELECT id, CONCAT(name, " (#", id, ")") as name_id FROM ' . TABLE_USERS . ' ORDER BY name')->fetchAllCombine();
         $aFormOwner = array('Owner of this data', '', 'select', 'owned_by', 1, $aSelectOwner, false, false, false);
     } else {
         $aFormOwner = array();
     }
     // Get list of genes.
     $aGenesForm = $_DB->query('SELECT id, name FROM ' . TABLE_GENES . ' ORDER BY id')->fetchAllCombine();
     $nData = count($aGenesForm);
     foreach ($aGenesForm as $sID => $sGene) {
         $aGenesForm[$sID] = $sID . ' (' . lovd_shortenString($sGene, 50) . ')';
     }
     if (!$nData) {
         $aGenesForm = array('' => 'No gene entries available');
     }
     $nFieldSize = count($aGenesForm) < 10 ? count($aGenesForm) : 10;
     // FIXME; right now two blocks in this array are put in, and optionally removed later. However, the if() above can build an entire block, such that one of the two big unset()s can be removed.
     // A similar if() to create the "authorization" block, or possibly an if() in the building of this form array, is easier to understand and more efficient.
     // Array which will make up the form table.
     $this->aFormData = array_merge(array(array('POST', '', '', '', '35%', '14', '65%'), array('', '', 'print', '<B>Screening information</B>'), 'hr'), $this->buildForm(), array('aGenes' => array('Genes screened', '', 'select', 'genes', $nFieldSize, $aGenesForm, false, true, false), array('', '', 'note', 'Please select no more than 15 genes. For genome-wide analysis, <B>no</B> genes should be selected.'), 'variants_found' => array('Have variants been found?', 'Please uncheck this box when no variants have been found using this screening.', 'checkbox', 'variants_found'), 'hr', 'general_skip' => 'skip', 'general' => array('', '', 'print', '<B>General information</B>'), 'general_hr1' => 'hr', 'owner' => $aFormOwner, 'general_hr2' => 'hr', 'skip', 'authorization' => array('Enter your password for authorization', '', 'password', 'password', 20)));
     if (ACTION == 'create' || ACTION == 'publish' && GET) {
         // When creating, or when publishing without any changes, unset the authorization.
         unset($this->aFormData['authorization']);
     } elseif (lovd_getProjectFile() != '/import.php') {
         if ($_DB->query('SELECT COUNT(variantid) FROM ' . TABLE_SCR2VAR . ' WHERE screeningid = ?', array($nID))->fetchColumn()) {
             unset($this->aFormData['variants_found']);
         }
     }
     if ($_AUTH['level'] < LEVEL_CURATOR) {
         unset($this->aFormData['general_skip'], $this->aFormData['general'], $this->aFormData['general_hr1'], $this->aFormData['owner'], $this->aFormData['general_hr2']);
     }
     return parent::getForm();
 }
Esempio n. 17
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 $_AUTH, $_DB, $_SETT, $_PE;
     $aUserLevels = $_SETT['user_levels'];
     $bInstall = lovd_getProjectFile() == '/install/index.php';
     if ($bInstall) {
         // Very special case, we can't take it from the database, because it ain't there yet.
         require ROOT_PATH . 'install/inc-sql-countries.php';
         $aCountryList = array();
         foreach ($aCountrySQL as $sQ) {
             $aCountryList[substr($sQ, 22 + strlen(TABLE_COUNTRIES), 2)] = substr($sQ, 28 + strlen(TABLE_COUNTRIES), -2);
         }
     } else {
         // "Normal" user form; create user, edit user.
         $aCountryList = $_DB->query('SELECT id, name FROM ' . TABLE_COUNTRIES . ' ORDER BY name')->fetchAllCombine();
         if ($_AUTH) {
             // Remove user levels that are higher than or equal to the current user's level IF you are logged in.
             unset($aUserLevels[LEVEL_COLLABORATOR], $aUserLevels[LEVEL_OWNER], $aUserLevels[LEVEL_CURATOR]);
             // Aren't real user levels.
             for ($i = LEVEL_ADMIN; $i >= $_AUTH['level']; $i--) {
                 if (isset($aUserLevels[$i])) {
                     unset($aUserLevels[$i]);
                 }
             }
         }
     }
     // FIXME; this is a mess...!!!
     // Array which will make up the form table.
     $this->aFormData = array(array('POST', '', '', '', '35%', '14', '65%'), array('', '', 'print', '<B>User details</B>'), 'hr', array('Name', '', 'text', 'name', 30), array('Institute', '', 'text', 'institute', 40), array('Department (optional)', '', 'text', 'department', 40), array('Postal address', '', 'textarea', 'address', 35, 3), array('Email address(es), one per line', '', 'textarea', 'email', 30, 3), array('Telephone (optional)', '', 'text', 'telephone', 20), 'username' => array('Username', '', 'text', 'username', 20), 'passwd' => array('Password', 'A proper password is at least 4 characters long and contains at least one number or special character.', 'password', 'password_1', 20, true), 'passwd_confirm' => array('Password (confirm)', '', 'password', 'password_2', 20, true), 'passwd_change' => array('Must change password at next logon', '', 'checkbox', 'password_force_change'), 'hr', 'skip', array('', '', 'print', '<B>Referencing the lab</B>'), 'hr', array('Country', '', 'select', 'countryid', 1, $aCountryList, true, false, false), array('City', 'Please enter your city, even if it\'s included in your postal address, for sorting purposes.', 'text', 'city', 30), array('Reference (optional)', 'Your submissions will contain a reference to you in the format "Country:City" by default. You may change this to your preferred reference here.', 'text', 'reference', 30), 'hr', 'skip', array('', '', 'print', '<B>Security</B>'), 'hr', 'level' => array('Level', ($_AUTH['level'] != LEVEL_ADMIN ? '' : '<B>Managers</B> basically have the same rights as you, but can\'t uninstall LOVD nor can they create or edit other Manager accounts.<BR>') . '<B>Submitters</B> can submit, but not publish information in the database. Submitters can also create their own accounts, you don\'t need to do this for them.<BR><BR>In LOVD 3.0, <B>Curators</B> are Submitter-level users with Curator rights on certain genes. To create a Curator account, you need to create a Submitter and then grant this user rights on the necessary genes.', 'select', 'level', 1, $aUserLevels, false, false, false), array('Allowed IP address list (optional)', 'To help prevent others to try and guess the username/password combination, you can restrict access to the account to a number of IP addresses or ranges.', 'text', 'allowed_ip', 20), array('', '', 'note', 'Default value: *<BR>' . (strpos($_SERVER['REMOTE_ADDR'], ':') !== false ? '' : '<I>Your current IP address: ' . $_SERVER['REMOTE_ADDR'] . '</I><BR>') . '<B>Please be extremely careful using this setting.</B> Using this setting too strictly, can deny the user access to LOVD, even if the correct credentials have been provided.<BR>Set to \'*\' to allow all IP addresses, use \'-\' to specify a range and use \';\' to separate addresses or ranges.'), 'locked' => array('Locked', '', 'checkbox', 'locked'), 'hr', 'authorization_skip' => 'skip', 'send_email' => array('Send email with account details to user', '', 'checkbox', 'send_email'), 'authorization' => array('Enter your password for authorization', '', 'password', 'password', 20));
     if ($bInstall || ACTION != 'create') {
         unset($this->aFormData['send_email']);
     }
     if ($bInstall || ACTION == 'register') {
         // No need to ask for the user's password when the user is not created yet.
         unset($this->aFormData['authorization_skip'], $this->aFormData['authorization']);
     }
     if ($bInstall || !empty($_PE[1]) && $_PE[1] == $_AUTH['id'] || ACTION == 'register') {
         // Some fields not allowed when creating/editing your own account.
         unset($this->aFormData['passwd_change'], $this->aFormData['level'], $this->aFormData['locked']);
     }
     if (ACTION == 'edit') {
         unset($this->aFormData['username']);
         $this->aFormData['passwd'] = str_replace('Password', 'New password (optional)', $this->aFormData['passwd']);
         $this->aFormData['passwd_confirm'] = str_replace('Password (confirm)', 'New password (confirm, optional)', $this->aFormData['passwd_confirm']);
     } elseif (ACTION == 'change_password' && !$bInstall) {
         // Sorry, seems easier to just redefine the whole thing.
         $this->aFormData = array(array('POST', '', '', '', '50%', '14', '50%'), 'change_self' => array('Current password', '', 'password', 'password', 20), array('New password', '', 'password', 'password_1', 20, true), array('New password (confirm)', '', 'password', 'password_2', 20, true), 'skip', 'change_other' => array('Enter your password for authorization', '', 'password', 'password', 20));
         if ($_PE[1] == $_AUTH['id']) {
             unset($this->aFormData['change_other']);
         } else {
             unset($this->aFormData['change_self']);
         }
     }
     return parent::getForm();
 }
Esempio n. 18
0
 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);
     }
 }
Esempio n. 19
0
 function checkSelectedInput($sCol, $Val)
 {
     // Checks if the selected values are indeed from the selection list.
     global $_SETT;
     $sColClean = preg_replace('/^\\d{' . $_SETT['objectid_length']['transcripts'] . '}_/', '', $sCol);
     // Remove prefix (transcriptid) that LOVD_TranscriptVariants puts there.
     if ($this->aColumns[$sColClean]['form_type'][2] == 'select' && $this->aColumns[$sColClean]['form_type'][3] >= 1) {
         if (!empty($Val)) {
             $aOptions = preg_replace('/ *(=.*)?$/', '', $this->aColumns[$sColClean]['select_options']);
             // Trim whitespace from the options.
             if (lovd_getProjectFile() == '/import.php') {
                 $Val = explode(';', $Val);
                 // Normally the form sends an array, but from the import I need to create an array.
             } elseif (!is_array($Val)) {
                 $Val = array($Val);
             } elseif (GET) {
                 // 2013-10-15; 3.0-08; Not importing, $Val is already an array, and we're here using GET.
                 // When directly publishing an entry, not having filled in a selection list will trigger
                 // an error when an empty string is not an option in this selection list.
                 if ($Val === array('') && !in_array('', $aOptions)) {
                     // Error would be triggered wrongly.
                     $Val = array();
                 }
             }
             foreach ($Val as $sValue) {
                 $sValue = trim($sValue);
                 // Trim whitespace from $sValue to ensure match independent of whitespace.
                 if (!in_array($sValue, $aOptions)) {
                     if (lovd_getProjectFile() == '/import.php') {
                         lovd_errorAdd($sCol, 'Please select a valid entry from the \'' . $sColClean . '\' selection box, \'' . strip_tags($sValue) . '\' is not a valid value. Please choose from these options: \'' . implode('\', \'', $aOptions) . '\'.');
                     } else {
                         lovd_errorAdd($sCol, 'Please select a valid entry from the \'' . $this->aColumns[$sColClean]['form_type'][0] . '\' selection box, \'' . strip_tags($sValue) . '\' is not a valid value.');
                     }
                     break;
                 }
             }
         }
     }
 }