$comments->setPredefinedComments($_POST['savecomments']['predefined']);
    // save all textual comments but only if there is an entry [sebas]
    foreach ($_POST['savecomments']['text'] as $comment_type_id => $comment_message) {
        if (trim($comment_message)) {
            $comments->addTextComment(trim($comment_message), $comment_type_id);
        }
    }
    // save all comment status fields
    if (is_array($_POST['saveCommentStatusField'])) {
        foreach ($_POST['saveCommentStatusField'] as $status_field => $value) {
            $comments->setMRIValue($status_field, $value);
        }
    }
}
// get the currently saved comments
$saved_comments = $comments->getComments();
/*
 * DISPLAY HTML PAGES
 */
// show identifier of subject/volume
if ($comments->objectType == 'volume') {
    $query = "SELECT c.CandID AS DCCID, c.PSCID, s.Visit_label, s.SubprojectID,\n                    f.File AS File_name, st.Scan_type\n                FROM files AS f, session AS s, candidate AS c, mri_scan_type AS st\n                WHERE f.FileID=:FID\n                    AND f.SessionID=s.ID\n                    AND s.CandID=c.CandID\n                    AND f.AcquisitionProtocolID=st.ID\n                    AND s.Active='Y'";
    $qparams = array('FID' => $comments->fileID);
} elseif ($comments->objectType == 'visit') {
    $query = "SELECT c.CandID, c.PSCID, s.Visit_label, s.SubprojectID\n                FROM session AS s, candidate AS c\n              WHERE s.ID=:SID AND s.CandID=c.CandID AND s.Active='Y'";
    $qparams = array('SID' => $comments->sessionID);
} else {
    $query = "SELECT c.CandID FROM session AS s, candidate AS c\n                WHERE s.ID=:SID AND s.CandID=c.CandID AND s.Active='Y'";
    $qparams = array('SID' => $comments->sessionID);
}
$result = $DB->pselect($query, $qparams);
 /**
  * Get Candidate Data
  *
  * @param array $ScanTypes list of scan types
  *
  * @return array
  */
 public function getCandidateData($ScanTypes)
 {
     $query = $this->_generateCandidatesQuery($ScanTypes);
     $CandidateData = $this->SQLDB->pselect($query, array());
     foreach ($CandidateData as &$row) {
         foreach ($ScanTypes as $scanType) {
             $scan_type = $scanType['ScanType'];
             if (!empty($row['Selected_' . $scan_type])) {
                 $fileID = $this->SQLDB->pselectOne("SELECT FileID FROM files WHERE File=:fname", array('fname' => $row['Selected_' . $scan_type]));
                 $FileObj = new MRIFile($fileID);
                 $mri_header_results = $this->_addMRIHeaderInfo($FileObj, $scan_type);
                 $row = array_merge($row, $mri_header_results);
                 // instantiate feedback mri object
                 $mri_feedback = new FeedbackMRI($fileID, $row['SessionID']);
                 $current_feedback = $mri_feedback->getComments();
                 $mri_qc_results = $this->_addMRIFeedback($current_feedback, $scan_type, $mri_feedback);
                 $row = array_merge($row, $mri_qc_results);
             }
         }
     }
     return $CandidateData;
 }