423 |
return $file_list; |
return $file_list; |
424 |
} |
} |
425 |
|
|
426 |
|
/* |
427 |
|
* Store the data recived in the request into a file on the |
428 |
|
* local filesystem. |
429 |
|
* @todo This function will need to be changed for the save to |
430 |
|
* be on GED |
431 |
|
* @param mixed $data The data received with the request |
432 |
|
* @param string $id The consultation ID |
433 |
|
* @return string OK on success, KO otherwise |
434 |
|
*/ |
435 |
|
|
436 |
|
function storeDecisionFile(&$fichier_base64, $basename, $dossier, $prefix = '') { |
437 |
|
|
438 |
|
if (empty($fichier_base64)) { |
439 |
|
$this -> addToMessage("error", _("Le fichier est vide")); |
440 |
|
return false; |
441 |
|
} |
442 |
|
$dir = $this->getPathFolderTrs().$dossier; |
443 |
|
|
444 |
|
// if a file already exists by that name and it |
445 |
|
// is not a directory, back out |
446 |
|
/*if (file_exists($dir) AND is_dir($dir)) { |
447 |
|
$this -> addToMessage("error", _("Le repertoire n'existe pas, le fichier ne peut pas etre enregistre.")); |
448 |
|
return false; |
449 |
|
}*/ |
450 |
|
// if a dirextory by that name exists, make sure it does |
451 |
|
// not already contain an avis de consultation, MAYBE WE DON'T NEED THIS |
452 |
|
if (file_exists($dir) AND is_dir($dir)) { |
453 |
|
$dir_contents = trim(shell_exec('ls '.$dir)); |
454 |
|
if (strpos($dir_contents, ' ') != false) { |
455 |
|
$dir_contents = explode(' ', $dir_contents); |
456 |
|
} else { |
457 |
|
$dir_contents = array($dir_contents); |
458 |
|
} |
459 |
|
foreach ($dir_contents as $basefname) { // very useful for consultation |
460 |
|
if (strpos($basefname, $prefix)!==false) { |
461 |
|
return _("Un retour d'avis existe deja."); |
462 |
|
|
463 |
|
} |
464 |
|
} |
465 |
|
} else { |
466 |
|
return _("Le dossier n'existe pas."); |
467 |
|
} |
468 |
|
// if no file by that name exists, create the directory |
469 |
|
|
470 |
|
if (!file_exists($dir)) { |
471 |
|
if (!mkdir($dir, 0775)) { |
472 |
|
return _("Erreur dans la création de répertoire."); |
473 |
|
} |
474 |
|
} |
475 |
|
|
476 |
|
|
477 |
|
// store the file contents into the file named: |
478 |
|
// consultation_<ID>_<file_name_received> |
479 |
|
$file_len = strlen($fichier_base64); |
480 |
|
|
481 |
|
$filename = $dir."/".$prefix.$basename; |
482 |
|
|
483 |
|
$file = fopen($filename, 'w'); |
484 |
|
if (!$file) { |
485 |
|
return _("Echec a la creation du fichier."); |
486 |
|
} |
487 |
|
// check that the number of bytes written is equal to the length |
488 |
|
// of the data received |
489 |
|
$num_written = fwrite($file, $fichier_base64, $file_len); |
490 |
|
|
491 |
|
if (!$num_written) { |
492 |
|
// remove the file |
493 |
|
// the return value from shell can't be used for checking since |
494 |
|
// one can not know if the NULL returned is because there was no |
495 |
|
// output or because there was an error |
496 |
|
$ret = shell_exec("rm -f $filename 2>&1"); |
497 |
|
//if ($ret == NULL) { // an error occured while deleting the file |
498 |
|
//} |
499 |
|
return _("La sauvegarde du fichier a echoue"); |
500 |
|
} |
501 |
|
fclose($file); |
502 |
|
return true; |
503 |
|
} |
504 |
|
|
505 |
|
/** |
506 |
|
* |
507 |
|
*/ |
508 |
|
function notExistsError ($explanation = NULL) { |
509 |
|
// message |
510 |
|
$message_class = "error"; |
511 |
|
$message = _("Cette page n'existe pas."); |
512 |
|
$this->addToMessage ($message_class, $message); |
513 |
|
// |
514 |
|
$this->setFlag(NULL); |
515 |
|
$this->display(); |
516 |
|
|
517 |
|
// |
518 |
|
die(); |
519 |
|
} |
520 |
} |
} |
521 |
|
|
522 |
?> |
?> |