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
Pixel Humain
survey
Commits
af10b0e7
Commit
af10b0e7
authored
Apr 07, 2020
by
Tibor Katelbach
Browse files
delete a form
parent
02ed6162
Changes
2
Hide whitespace changes
Inline
Side-by-side
controllers/form/DeleteAction.php
View file @
af10b0e7
...
...
@@ -10,18 +10,17 @@ class DeleteAction extends CAction
//check form et session exist
if
(
$form
=
PHDB
::
findOne
(
Form
::
COLLECTION
,
array
(
"_id"
=>
new
MongoId
((
$id
))))
)
{
// if( $form["creator"] == Yii::app()->session["userId"] ||
// Authorisation::isElementAdmin($id, Form::ANSWER_COLLECTION, Yii::app()->session["userId"], false)) {
// if( Authorisation::isElementAdmin($id, Form::ANSWER_COLLECTION, Yii::app()->session["userId"], false)) {
//
if(isset($form["ids"])){
//
$formId = implode("|", $form["ids"]);
//
PHDB::remove( Form::ANSWER_COLLECTION, ["formId" => $formId]);
//
}
//
PHDB::remove( Form::COLLECTION, ["_id" => new MongoId($id)] );
//
echo Rest::json(['result' => true ]);
if
(
isset
(
$form
[
"ids"
])){
$formId
=
implode
(
"|"
,
$form
[
"ids"
]);
PHDB
::
remove
(
Form
::
ANSWER_COLLECTION
,
[
"formId"
=>
$formId
]);
}
PHDB
::
remove
(
Form
::
COLLECTION
,
[
"_id"
=>
new
MongoId
(
$id
)]
);
echo
Rest
::
json
([
'result'
=>
true
]);
// } else
//
$ctrl->render("co2.views.default.unTpl",array(
"msg"=>Yii::t("project", "Unauthorized Access."),"icon"=>"fa-lock"
)
);
//
echo Rest::json(['result' => false,
"msg"=>Yii::t("project", "Unauthorized Access."),"icon"=>"fa-lock"
]
);
}
else
echo
Rest
::
json
([
'result'
=>
false
,
"msg"
=>
"Formulaire introuvable"
,
"icon"
=>
"fa-search"
]);
}
...
...
views/tpls/forms/oforms.php
View file @
af10b0e7
...
...
@@ -60,8 +60,7 @@ jQuery(document).ready(function() {
});
$
(
'
.deleteFormBtn
'
).
off
().
click
(
function
(){
formId
=
$
(
this
).
data
(
"
id
"
);
collection
=
"
forms
"
;
tplCtx
.
id
=
$
(
this
).
data
(
"
id
"
);
bootbox
.
dialog
({
title
:
"
Confirmez la suppression
"
,
message
:
"
<span class='text-red bold'><i class='fa fa-warning'></i> Cette action sera irréversible</span>
"
,
...
...
@@ -70,9 +69,12 @@ jQuery(document).ready(function() {
label
:
"
Ok
"
,
className
:
"
btn btn-primary pull-left
"
,
callback
:
function
()
{
getAjax
(
""
,
baseUrl
+
"
/survey/form/delete/id/
"
+
id
,
function
(){
toastr
.
success
(
"
Le form été supprimée avec succès
"
);
$
(
"
#formline
"
+
id
).
remove
();
getAjax
(
""
,
baseUrl
+
"
/survey/form/delete/id/
"
+
tplCtx
.
id
,
function
(
res
){
if
(
res
.
result
)
toastr
.
success
(
"
Le form été supprimée avec succès
"
);
else
toastr
.
error
(
res
.
msg
);
urlCtrl
.
loadByHash
(
location
.
hash
);
},
"
html
"
);
}
},
...
...
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