Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
framadate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nounous
framadate
Commits
94a125ca
Commit
94a125ca
authored
10 years ago
by
Olivier PEREZ
Browse files
Options
Downloads
Patches
Plain Diff
Display confirmation page before to delete all comments of one poll.
parent
3829402a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
adminstuds.php
+25
-14
25 additions, 14 deletions
adminstuds.php
app/classes/Framadate/Services/PollService.php
+14
-2
14 additions, 2 deletions
app/classes/Framadate/Services/PollService.php
tpl/confirm/delete_comment.tpl
+11
-0
11 additions, 0 deletions
tpl/confirm/delete_comment.tpl
with
50 additions
and
16 deletions
adminstuds.php
+
25
−
14
View file @
94a125ca
...
...
@@ -52,20 +52,6 @@ if (!$poll) {
exit
;
}
// -------------------------------
// Remove all votes
// -------------------------------
if
(
isset
(
$_POST
[
'remove_all_votes'
]))
{
$pollService
->
cleanVotes
(
$poll_id
);
}
// -------------------------------
// Remove all comments
// -------------------------------
if
(
isset
(
$_POST
[
'remove_all_comments'
]))
{
$pollService
->
cleanComments
(
$poll_id
);
}
// -------------------------------
// Update poll info
// -------------------------------
...
...
@@ -136,6 +122,30 @@ if (!empty($_POST['delete_comment'])) {
}
}
// -------------------------------
// Remove all votes
// -------------------------------
if
(
isset
(
$_POST
[
'remove_all_votes'
]))
{
$pollService
->
cleanVotes
(
$poll_id
);
}
// -------------------------------
// Remove all comments
// -------------------------------
if
(
isset
(
$_POST
[
'remove_all_comments'
]))
{
$smarty
->
assign
(
'poll_id'
,
$poll_id
);
$smarty
->
assign
(
'admin_poll_id'
,
$admin_poll_id
);
$smarty
->
assign
(
'title'
,
_
(
'Poll'
)
.
' - '
.
$poll
->
title
);
$smarty
->
display
(
'confirm/delete_comment.tpl'
);
exit
;
}
if
(
isset
(
$_POST
[
'confirm_remove_all_comments'
]))
{
if
(
$pollService
->
cleanComments
(
$poll_id
))
{
$message
=
new
Message
(
'success'
,
_
(
'All comments deleted.'
));
}
else
{
$message
=
new
Message
(
'danger'
,
_
(
'Failed to delete all comments.'
));
}
}
// -------------------------------
// Delete the entire poll
...
...
@@ -144,6 +154,7 @@ if (!empty($_POST['delete_comment'])) {
if
(
isset
(
$_POST
[
'delete_poll'
]))
{
$smarty
->
assign
(
'poll_id'
,
$poll_id
);
$smarty
->
assign
(
'admin_poll_id'
,
$admin_poll_id
);
$smarty
->
assign
(
'title'
,
_
(
'Poll'
)
.
' - '
.
$poll
->
title
);
$smarty
->
display
(
'confirm/delete_poll.tpl'
);
exit
;
}
...
...
This diff is collapsed.
Click to expand it.
app/classes/Framadate/Services/PollService.php
+
14
−
2
View file @
94a125ca
...
...
@@ -60,8 +60,14 @@ class PollService {
return
$this
->
connect
->
insertVote
(
$poll_id
,
$name
,
$choices
);
}
/**
* Remove all votes of a poll.
*
* @param $poll_id int The ID a the poll
* @return bool|null true is action succeeded
*/
function
cleanVotes
(
$poll_id
)
{
$this
->
connect
->
deleteVotesByAdminPollId
(
$poll_id
);
return
$this
->
connect
->
deleteVotesByAdminPollId
(
$poll_id
);
}
function
addComment
(
$poll_id
,
$name
,
$comment
)
{
...
...
@@ -72,8 +78,14 @@ class PollService {
return
$this
->
connect
->
deleteComment
(
$poll_id
,
$comment_id
);
}
/**
* Remove all comments of a poll.
*
* @param $poll_id int The ID a the poll
* @return bool|null true is action succeeded
*/
function
cleanComments
(
$poll_id
)
{
$this
->
connect
->
deleteCommentssByAdminPollId
(
$poll_id
);
return
$this
->
connect
->
deleteCommentssByAdminPollId
(
$poll_id
);
}
function
computeBestMoments
(
$votes
)
{
...
...
This diff is collapsed.
Click to expand it.
tpl/confirm/delete_comment.tpl
0 → 100644
+
11
−
0
View file @
94a125ca
{
extends
file
=
'page.tpl'
}
{
block
name
=
main
}
<form
action=
"
{
$admin_poll_id
|
poll_url
:
true
}
"
method=
"POST"
>
<div
class=
"alert alert-danger text-center"
>
<h2>
{_("Confirm removal of all comments of the poll")}
</h2>
<p><button
class=
"btn btn-default"
type=
"submit"
name=
"cancel"
>
{_("Keep comments")}
</button>
<button
type=
"submit"
name=
"confirm_remove_all_comments"
class=
"btn btn-danger"
>
{_("Remove all comments!")}
</button></p>
</div>
</form>
{/
block
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment