Commit 6a355dc6 authored by Théo GUILLON's avatar Théo GUILLON
Browse files

Correction : récupération dans l'ordre de dépot des fichiers pour la modification

parent cd532333
......@@ -122,7 +122,7 @@ class FichesController extends AppController
if (in_array($mime, $accepted) === true) {
move_uploaded_file($tmpFile, $path);
$allTmpFiles = $files = $this->scan_dir($dir);
$allTmpFiles = $files = $this->Fichier->scan_dir($dir);
$last_key_file = key(array_slice( $allTmpFiles, -1, 1, true ));
$selectType = '';
......@@ -215,22 +215,6 @@ class FichesController extends AppController
}
}
private function scan_dir($dir) {
$ignored = ['.', '..', '.svn', '.htaccess'];
$files = [];
foreach (scandir($dir) as $file) {
if (in_array($file, $ignored)) continue;
$files[$file] = filemtime($dir . '/' . $file);
}
// ksort($files);
asort($files);
$files = array_keys($files);
return ($files) ? $files : [];
}
/**
* Gère l'ajout de fiches
*
......@@ -252,7 +236,7 @@ class FichesController extends AppController
if (empty($this->Session->read($this->Session->read('Auth.User.uuid')))) {
$dir = CHEMIN_PIECE_JOINT_TMP . $this->Session->read('Auth.User.id') . DS . $this->Session->read('Auth.User.uuid');
$files = $this->scan_dir($dir);
$files = $this->Fichier->scan_dir($dir);
$this->set('files', $files);
}
......@@ -564,8 +548,10 @@ class FichesController extends AppController
}
if (empty($this->Session->read($this->Session->read('Auth.User.uuid')))) {
$files = array_diff(scandir(CHEMIN_PIECE_JOINT_TMP . $this->Session->read('Auth.User.id') . DS . $this->Session->read('Auth.User.uuid')), array('..', '.'));
$this->set('files', $files);
$dir = CHEMIN_PIECE_JOINT_TMP . $this->Session->read('Auth.User.id') . DS . $this->Session->read('Auth.User.uuid');
$files = $this->Fichier->scan_dir($dir);
$this->set(compact('files'));
}
if ($this->Droits->existDPO() === false) {
......
......@@ -148,6 +148,11 @@ class Fichier extends AppModel {
if (!empty($uuidDossier)){
$files = array_diff(scandir(CHEMIN_PIECE_JOINT_TMP . $idUser . DS . $uuidDossier), array('..', '.'));
$dir = CHEMIN_PIECE_JOINT_TMP . $idUser . DS . $uuidDossier;
$files = $this->scan_dir($dir);
$this->set('files', $files);
if (isset($files) && !empty($files)) {
$success = true;
if ($transaction == true) {
......@@ -256,4 +261,20 @@ class Fichier extends AppModel {
}
}
public function scan_dir($dir) {
$ignored = ['.', '..', '.svn', '.htaccess'];
$files = [];
foreach (scandir($dir) as $file) {
if (in_array($file, $ignored)) continue;
$files[$file] = filemtime($dir . '/' . $file);
}
// ksort($files);
asort($files);
$files = array_keys($files);
return ($files) ? $files : [];
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment