Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libriciel
web-DPO
Commits
6a355dc6
Commit
6a355dc6
authored
Apr 23, 2020
by
Théo GUILLON
Browse files
Correction : récupération dans l'ordre de dépot des fichiers pour la modification
parent
cd532333
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/Controller/FichesController.php
View file @
6a355dc6
...
...
@@ -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
)
{
...
...
app/Model/Fichier.php
View file @
6a355dc6
...
...
@@ -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
:
[];
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment