Exemplo n.º 1
0
 function checkFields($aData, $zData = false)
 {
     // Mandatory fields.
     $this->aCheckMandatory = array('owned_by', 'statusid');
     parent::checkFields($aData);
     lovd_checkXSS();
 }
Exemplo n.º 2
0
 function checkFields($aData, $zData = false)
 {
     global $_DB;
     // During import panelid, fatherid and motherid are checked in import.php.
     $bImport = lovd_getProjectFile() == '/import.php';
     // Mandatory fields.
     $this->aCheckMandatory = array('panel_size', 'owned_by', 'statusid');
     // Checks fields before submission of data.
     parent::checkFields($aData);
     foreach (array('fatherid', 'motherid') as $sParentalField) {
         // This is not yet implemented correctly. These checks are implemented correctly in import.php in section "Individuals".
         if (isset($aData[$sParentalField]) && ctype_digit($aData[$sParentalField]) && !$bImport) {
             // FIXME: Also check gender!!! Check if field is available, download value (or '' if not available), then check possible conflicts.
             // Partially, the code is already written below.
             $nParentID = $_DB->query('SELECT id FROM ' . TABLE_INDIVIDUALS . ' WHERE id = ?', array($aData[$sParentalField]))->fetchColumn();
             if (empty($nParentID)) {
                 // FIXME: Once we have this on the form, replace with form description.
                 lovd_errorAdd($sParentalField, 'No individual found with this \'' . $sParentalField . '\'.');
             } elseif ($sParentalField == 'fatherid' && false) {
                 lovd_errorAdd($sParentalField, 'The \'' . $sParentalField . '\' you entered does not refer to a male individual.');
             } elseif ($sParentalField == 'motherid' && false) {
                 lovd_errorAdd($sParentalField, 'The \'' . $sParentalField . '\' you entered does not refer to a female individual.');
             } elseif ($aData[$sParentalField] == $this->nID) {
                 lovd_errorAdd($sParentalField, 'The \'' . $sParentalField . '\' can not link to itself; this field is used to indicate which individual in the database is the parent of the given individual.');
             }
         }
     }
     // Changes in these checks should also be implemented in import.php in section "Individuals"
     if (isset($aData['panelid']) && ctype_digit($aData['panelid']) && !$bImport) {
         $nPanel = $_DB->query('SELECT panel_size FROM ' . TABLE_INDIVIDUALS . ' WHERE id = ?', array($aData['panelid']))->fetchColumn();
         if (empty($nPanel)) {
             lovd_errorAdd('panelid', 'No Panel found with this \'Panel ID\'.');
         } elseif ($nPanel == 1) {
             lovd_errorAdd('panelid', 'The \'Panel ID\' you entered refers to an individual, not a panel (group of individuals). If you want to configure that individual as a panel, set its \'Panel size\' field to a value higher than 1.');
         } elseif ($nPanel <= $aData['panel_size']) {
             lovd_errorAdd('panel_size', 'The entered \'Panel size\' must be lower than the \'Panel size\' of the panel you refer to with the entered \'Panel ID\'.');
         } elseif ($aData['panelid'] == $this->nID) {
             lovd_errorAdd('panel_size', 'The \'Panel ID\' can not link to itself; this field is used to indicate which group of individuals (\'panel\') this entry belongs to.');
         }
     }
     $aDiseases = array_keys($this->aFormData['aDiseases'][5]);
     if (!empty($aData['active_diseases'])) {
         if (count($aData['active_diseases']) > 1 && in_array('00000', $aData['active_diseases'])) {
             lovd_errorAdd('active_diseases', 'You cannot select both "Healthy/Control" and a disease for the same individual entry.');
         } else {
             foreach ($aData['active_diseases'] as $nDisease) {
                 if ($nDisease && !in_array($nDisease, $aDiseases)) {
                     lovd_errorAdd('active_diseases', htmlspecialchars($nDisease) . ' is not a valid disease.');
                 }
             }
         }
     }
     lovd_checkXSS();
 }
Exemplo n.º 3
0
 function checkFields($aData, $zData = false)
 {
     // Checks fields before submission of data.
     // Mandatory fields.
     $this->aCheckMandatory = array('owned_by');
     parent::checkFields($aData);
     if (!empty($aData['genes']) && is_array($aData['genes'])) {
         if (count($aData['genes']) > 15) {
             lovd_errorAdd('genes', 'Please select no more than 15 genes. For genome-wide analysis, <B>no</B> genes should be selected.');
         }
     }
     lovd_checkXSS();
 }
Exemplo n.º 4
0
 function checkFields($aData, $zData = false)
 {
     global $_AUTH, $_CONF, $_SETT;
     // Mandatory fields.
     $this->aCheckMandatory = array('chromosome', 'effect_reported', 'owned_by', 'statusid');
     if ($_AUTH['level'] >= LEVEL_CURATOR) {
         $this->aCheckMandatory[] = 'effect_concluded';
     } elseif (isset($aData['effect_reported']) && $aData['effect_reported'] === '0') {
         // Submitters must fill in the variant effect field; '0' is not allowed for them.
         unset($aData['effect_reported']);
     }
     // Do this before running checkFields so that we have time to predict the DBID and fill it in.
     if (!empty($aData['VariantOnGenome/DNA']) && isset($this->aColumns['VariantOnGenome/DBID']) && ($this->aColumns['VariantOnGenome/DBID']['public_add'] || $_AUTH['level'] >= LEVEL_CURATOR)) {
         // VOGs with at least one VOT, which still have a chr* DBID, will get an error. So we'll empty the DBID field, allowing the new VOT value to be autofilled in.
         if (!empty($aData['aTranscripts']) && !empty($aData['VariantOnGenome/DBID']) && strpos($aData['VariantOnGenome/DBID'], 'chr' . $aData['chromosome'] . '_') !== false) {
             $aData['VariantOnGenome/DBID'] = '';
         }
         if (empty($aData['VariantOnGenome/DBID'])) {
             if (lovd_getProjectFile() != '/import.php') {
                 // Only predict an DBID, if we're actually going to use it (which doesn't happen when we're importing).
                 $aData['VariantOnGenome/DBID'] = $_POST['VariantOnGenome/DBID'] = lovd_fetchDBID($aData);
             }
         } elseif (!lovd_checkDBID($aData)) {
             lovd_errorAdd('VariantOnGenome/DBID', 'Please enter a valid ID in the ' . (lovd_getProjectFile() == '/import.php' ? 'VariantOnGenome/DBID' : '\'ID\'') . ' field or leave it blank and LOVD will predict it. Incorrect ID: "' . htmlspecialchars($aData['VariantOnGenome/DBID']) . '".');
         }
     }
     parent::checkFields($aData);
     // Checks fields before submission of data.
     if (isset($aData['effect_reported']) && !isset($_SETT['var_effect'][$aData['effect_reported']])) {
         lovd_errorAdd('effect_reported', 'Please select a proper functional effect from the \'Affects function (reported)\' selection box.');
     }
     if (isset($aData['effect_concluded']) && !isset($_SETT['var_effect'][$aData['effect_concluded']])) {
         lovd_errorAdd('effect_concluded', 'Please select a proper functional effect from the \'Affects function (concluded)\' selection box.');
     }
     if (!empty($aData['chromosome']) && !isset($_SETT['human_builds'][$_CONF['refseq_build']]['ncbi_sequences'][$aData['chromosome']])) {
         lovd_errorAdd('chromosome', 'Please select a proper chromosome from the \'Chromosome\' selection box.');
     }
     lovd_checkXSS();
 }