salimkanoun /
GaelO
| 1 | <?php |
||
| 2 | /** |
||
| 3 | Copyright (C) 2018-2020 KANOUN Salim |
||
| 4 | This program is free software; you can redistribute it and/or modify |
||
| 5 | it under the terms of the Affero GNU General Public v.3 License as published by |
||
| 6 | the Free Software Foundation; |
||
| 7 | This program is distributed in the hope that it will be useful, |
||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 10 | Affero GNU General Public Public for more details. |
||
| 11 | You should have received a copy of the Affero GNU General Public Public along |
||
| 12 | with this program; if not, write to the Free Software Foundation, Inc., |
||
| 13 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||
| 14 | */ |
||
| 15 | |||
| 16 | /** |
||
| 17 | * recive array of OrthancID in post, generate ZIP of DICOM and push it to the browser download |
||
| 18 | * used by supervisor (download manager) and Reviewer (download a visit dicom) |
||
| 19 | */ |
||
| 20 | |||
| 21 | require_once($_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php'); |
||
| 22 | |||
| 23 | Session::checkSession(); |
||
| 24 | $linkpdo=Session::getLinkpdo(); |
||
| 25 | |||
| 26 | isset($_POST['id_visit']) ? $logIdVisit=$_POST['id_visit'] : $logIdVisit='N/A'; |
||
| 27 | isset($_POST['json']) ? $askedJson=$_POST['json'] : $askedJson='N/A'; |
||
| 28 | |||
| 29 | @Session::logInfo('Username : '.$_SESSION['username']. |
||
|
0 ignored issues
–
show
|
|||
| 30 | ' Role: '.$_SESSION ['role'].' Study: '.$_SESSION['study'].' Visit ID: '.$logIdVisit.' Asked IDs: '.$askedJson); |
||
| 31 | |||
| 32 | $userObject=new User($_SESSION['username'], $linkpdo); |
||
| 33 | |||
| 34 | //Permission check, different level check if supervisor or reviewer |
||
| 35 | |||
| 36 | if ($_SESSION['role'] == User::SUPERVISOR) { |
||
| 37 | $permissionCheck=$userObject->isRoleAllowed($_SESSION['study'], $_SESSION['role']); |
||
| 38 | $postdata=$_POST['json']; |
||
| 39 | $json=json_decode($postdata, true); |
||
| 40 | //SK ICI VERIFIER QUE LES id SONT BIEN DE L ETUDE AVEC LES DROITS ? Securite |
||
| 41 | $ids=$json['json']; |
||
| 42 | } |
||
| 43 | else if ($_SESSION['role'] == User::REVIEWER) { |
||
| 44 | $permissionCheck=$userObject->isVisitAllowed($_POST['id_visit'], $_SESSION['role']); |
||
| 45 | $visitObject=new Visit($_POST['id_visit'], $linkpdo); |
||
| 46 | $ids=$visitObject->getSeriesOrthancID(); |
||
| 47 | |||
| 48 | }else if ($_SESSION['role'] == User::CONTROLLER) { |
||
| 49 | $permissionCheck=$userObject->isVisitAllowed($_POST['id_visit'], $_SESSION['role']); |
||
| 50 | $visitObject=new Visit($_POST['id_visit'], $linkpdo); |
||
| 51 | if (in_array($visitObject->qcStatus, array(Visit::QC_NOT_DONE, Visit::QC_WAIT_DEFINITVE_CONCLUSION))) { |
||
| 52 | $ids=$visitObject->getSeriesOrthancID(); |
||
| 53 | } |
||
| 54 | }else if ($_SESSION['role'] == User::INVESTIGATOR) { |
||
| 55 | $permissionCheck=$userObject->isVisitAllowed($_POST['id_visit'], $_SESSION['role']); |
||
| 56 | $visitObject=new Visit($_POST['id_visit'], $linkpdo); |
||
| 57 | if ($visitObject->uploadStatus == Visit::DONE) { |
||
| 58 | $ids=$visitObject->getSeriesOrthancID(); |
||
| 59 | } |
||
| 60 | |||
| 61 | } |
||
| 62 | |||
| 63 | if ($permissionCheck && count($ids) > 0) { |
||
| 64 | |||
| 65 | //Download dicom corresponding to called ID with Orthanc APIs |
||
| 66 | $orthanc=new Orthanc(); |
||
| 67 | |||
| 68 | $zipStream=$orthanc->getZipStream($ids); |
||
| 69 | |||
| 70 | header("Content-Type: application/zip"); |
||
| 71 | header("Content-Transfer-Encoding: Binary"); |
||
| 72 | |||
| 73 | //For supervisor generic file name as the zip can merge visits |
||
| 74 | if ($_SESSION['role'] == User::SUPERVISOR) { |
||
| 75 | $date=Date('Ymd_his'); |
||
| 76 | header('Content-Disposition: attachment; filename="Dicom-'.$_SESSION['study'].'_'.$date.'.zip"'); |
||
| 77 | //For reviewer file name is identified by study_visit |
||
| 78 | }else { |
||
| 79 | $name=$_SESSION['study'].$visitObject->visitType; |
||
| 80 | header('Content-Disposition: attachment; filename="Dicom'.$name.'.zip"'); |
||
| 81 | } |
||
| 82 | |||
| 83 | while (!$zipStream->eof()) { |
||
| 84 | echo $zipStream->read(512); |
||
| 85 | } |
||
| 86 | |||
| 87 | }else { |
||
| 88 | header('HTTP/1.0 403 Forbidden'); |
||
| 89 | die('You are not allowed to access this file.'); |
||
| 90 | } |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.