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
8414af92
Commit
8414af92
authored
Feb 04, 2020
by
tguillon
Browse files
correction : de la validation des champs
parent
8b5f5a89
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/Controller/FichesController.php
View file @
8414af92
...
...
@@ -243,8 +243,6 @@ class FichesController extends AppController
$this
->
redirect
(
$this
->
Referers
->
get
());
}
// debug($this->request->data);//die;
$success
=
true
;
$this
->
Fiche
->
begin
();
...
...
@@ -622,8 +620,6 @@ class FichesController extends AppController
$this
->
redirect
(
$this
->
Referers
->
get
());
}
// debug($this->request->data);die;
$success
=
true
;
$this
->
Valeur
->
begin
();
...
...
@@ -729,7 +725,13 @@ class FichesController extends AppController
foreach
(
$valeurs
as
$value
)
{
if
(
$this
->
Fiche
->
isJson
(
$value
[
'Valeur'
][
'valeur'
]))
{
$this
->
request
->
data
[
'Fiche'
][
$value
[
'Valeur'
][
'champ_name'
]]
=
json_decode
(
$value
[
'Valeur'
][
'valeur'
]);
$valueDecode
=
json_decode
(
$value
[
'Valeur'
][
'valeur'
]);
if
(
is_object
(
$valueDecode
))
{
$valueDecode
=
json_decode
(
json_encode
(
$valueDecode
),
true
);
}
$this
->
request
->
data
[
'Fiche'
][
$value
[
'Valeur'
][
'champ_name'
]]
=
$valueDecode
;
}
else
{
$this
->
request
->
data
[
'Fiche'
][
$value
[
'Valeur'
][
'champ_name'
]]
=
$value
[
'Valeur'
][
'valeur'
];
}
...
...
@@ -804,7 +806,13 @@ class FichesController extends AppController
foreach
(
$valeurs
as
$key
=>
$value
)
{
if
(
$this
->
Fiche
->
isJson
(
$value
[
'Valeur'
][
'valeur'
]))
{
$this
->
request
->
data
[
'Fiche'
][
$value
[
'Valeur'
][
'champ_name'
]]
=
json_decode
(
$value
[
'Valeur'
][
'valeur'
]);
$valueDecode
=
json_decode
(
$value
[
'Valeur'
][
'valeur'
]);
if
(
is_object
(
$valueDecode
))
{
$valueDecode
=
json_decode
(
json_encode
(
$valueDecode
),
true
);
}
$this
->
request
->
data
[
'Fiche'
][
$value
[
'Valeur'
][
'champ_name'
]]
=
$valueDecode
;
}
else
{
$this
->
request
->
data
[
'Fiche'
][
$value
[
'Valeur'
][
'champ_name'
]]
=
$value
[
'Valeur'
][
'valeur'
];
}
...
...
app/Model/WebdpoFiche.php
View file @
8414af92
...
...
@@ -262,18 +262,26 @@ class WebdpoFiche extends AppModel {
$dynamicValidationErrors
=
[];
$originalData
=
$this
->
data
;
$originalValidationErrors
=
$this
->
validationErrors
;
// @todo: vérifier dans les règles de validation dynamiquement quels sont les champs dont on dépend pour les insérer dans les données lors de la validation
foreach
([
'horsue'
=>
'transfertHorsUe'
,
'donneessensibles'
=>
'donneesSensible'
]
as
$fieldIndex
=>
$fieldName
)
{
foreach
([
'horsue'
,
'donneessensibles'
]
as
$fieldIndex
)
{
if
(
isset
(
$originalData
[
$this
->
alias
][
$fieldIndex
])
===
true
&&
empty
(
$originalData
[
$this
->
alias
][
$fieldIndex
])
===
false
)
{
foreach
(
$originalData
[
$this
->
alias
][
$fieldIndex
]
as
$key
=>
$organisme
)
{
$dynamicData
=
[
$this
->
alias
=>
$organisme
+
[
$fieldName
=>
$originalData
[
$this
->
alias
][
$fieldName
],
'coresponsable'
=>
$originalData
[
$this
->
alias
][
'coresponsable'
]
]
];
// Ajout de la valeur des champs pour les règles de validation dynamiques checkNotBlankIf
foreach
(
array_keys
(
$organisme
)
as
$tmp
)
{
$validate
=
(
array
)
Hash
::
get
(
$this
->
validate
,
$tmp
);
foreach
(
$validate
as
$validationRule
)
{
if
(
isset
(
$validationRule
[
'rule'
][
0
])
===
true
&&
$validationRule
[
'rule'
][
0
]
===
'checkNotBlankIf'
)
{
$dynamicData
[
$this
->
alias
][
$validationRule
[
'rule'
][
1
]]
=
$originalData
[
$this
->
alias
][
$validationRule
[
'rule'
][
1
]];
}
}
}
$this
->
create
(
$dynamicData
);
if
(
$this
->
validates
()
!==
true
)
{
foreach
(
$this
->
validationErrors
as
$idx
=>
$errors
)
{
...
...
@@ -285,9 +293,8 @@ class WebdpoFiche extends AppModel {
}
$this
->
data
=
$originalData
;
$this
->
validationErrors
=
$originalValidationErrors
;
$this
->
create
([
$this
->
alias
=>
$this
->
data
[
$this
->
alias
]]);
$success
=
$this
->
validates
()
&&
$success
;
$success
=
$this
->
validates
()
&&
$success
&&
empty
(
$dynamicValidationErrors
)
===
true
;
$Fiche
->
validationErrors
=
$Fiche
->
validationErrors
+
$this
->
validationErrors
;
$Fiche
->
validationErrors
=
Hash
::
merge
(
$Fiche
->
validationErrors
,
$dynamicValidationErrors
);
...
...
app/View/Elements/Fiches/ongletComplementaire.ctp
View file @
8414af92
<?php
$idSousFinalite
=
null
;
$afterSousFinalite
=
'<a href="#" class="removeclass"><span class="fa fa-trash fa-lg fa-danger"><!----></span></a></div>'
;
$viewBtn
AddSousFinalite
=
true
;
$viewBtn
=
true
;
if
(
$this
->
request
->
params
[
'action'
]
===
'show'
)
{
$afterSousFinalite
=
'</div>'
;
$viewBtn
AddSousFinalite
=
false
;
$viewBtn
=
false
;
}
?>
...
...
@@ -48,7 +48,7 @@ if ($this->request->params['action'] === 'show') {
?>
</div>
<?php
if
(
$viewBtn
AddSousFinalite
===
true
)
{
if
(
$viewBtn
===
true
)
{
?>
<div
id=
"AddMoreFileId"
>
<a
id=
"AddMoreFileBox"
class=
"btn btn-info"
>
Ajouter une sous-finalité
</a>
...
...
@@ -142,7 +142,7 @@ if ($this->request->params['action'] === 'show') {
$trash
=
false
;
$classTrash
=
''
;
if
(
$i
>
1
)
{
if
(
$i
>
1
&&
$viewBtn
===
true
)
{
$trash
=
true
;
$classTrash
=
'removeHorsUE'
;
}
...
...
@@ -178,7 +178,7 @@ if ($this->request->params['action'] === 'show') {
<div
id=
"InputsHorsUE"
></div>
<?php
if
(
$viewBtn
AddSousFinalite
===
true
)
{
if
(
$viewBtn
===
true
)
{
?>
<div
id=
"AddOrganismeHorsUE"
>
<a
id=
"AddOrganismeHorsUEFileBox"
class=
"btn btn-info"
>
Ajouter un organisme hors de l'UE
</a>
...
...
@@ -217,7 +217,7 @@ if ($this->request->params['action'] === 'show') {
$trash
=
false
;
$classTrash
=
''
;
if
(
$nb
>
1
)
{
if
(
$nb
>
1
&&
$viewBtn
===
true
)
{
$trash
=
true
;
$classTrash
=
'removeDonneeSensible'
;
}
...
...
@@ -251,7 +251,7 @@ if ($this->request->params['action'] === 'show') {
<div
id=
"InputsDonneesSensibles"
></div>
<?php
if
(
$viewBtn
AddSousFinalite
===
true
)
{
if
(
$viewBtn
===
true
)
{
?>
<div
id=
"AddDonneesSensibles"
>
<a
id=
"AddDonneesSensiblesFileBox"
class=
"btn btn-info"
>
Ajouter données sensibles
</a>
...
...
app/View/Fiches/edit.ctp
View file @
8414af92
...
...
@@ -4,7 +4,7 @@ echo $this->Html->script('jquery-mask-plugin/dist/jquery.mask.min.js');
if
(
isset
(
$this
->
validationErrors
[
'Fiche'
])
&&
!
empty
(
$this
->
validationErrors
[
'Fiche'
]))
{
?>
<div
class=
"alert alert-danger"
role=
"alert"
>
<span
class=
"
glyphicon glyphicon
-exclamation-
sign
"
aria-hidden=
"true"
>
<!---->
</span>
<span
class=
"
fa fa
-exclamation-
circle fa-fw
"
aria-hidden=
"true"
>
<!---->
</span>
<span
class=
"sr-only"
>
Error:
</span>
Ces erreurs se sont produites sur les champs suivants :
<ul>
...
...
app/View/Users/login.ctp
View file @
8414af92
<ls-lib-login
logo="/img/web-dpo
-login_2020
.svg"
logo="/img/web-dpo.svg"
visual-configuration='<?php echo ($configLoginExistante); ?>'
login-username-input-name="data[User][username]"
login-password-input-name="data[User][password]"
...
...
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