|
@@ -53,13 +53,24 @@ class ModerateController extends Controller
|
53
|
53
|
|
54
|
54
|
public function tagAcceptAction($tag_id)
|
55
|
55
|
{
|
56
|
|
- if (($response = $this->mustBeConnected()))
|
|
56
|
+ if (($response = $this->mustBeConnected(true)))
|
57
|
57
|
{
|
58
|
58
|
return $response;
|
59
|
59
|
}
|
60
|
60
|
|
|
61
|
+ if (!($tag = $doctrine->getRepository('MuzichCoreBundle:Tag')->findOneBy(array(
|
|
62
|
+ 'id' => $tag_id,
|
|
63
|
+ 'tomoderate' => true
|
|
64
|
+ ))))
|
|
65
|
+ {
|
|
66
|
+ return $this->jsonResponse(array(
|
|
67
|
+ 'status' => 'error',
|
|
68
|
+ 'message' => 'NotFound'
|
|
69
|
+ ));
|
|
70
|
+ }
|
|
71
|
+
|
61
|
72
|
$tagManager = new TagManager();
|
62
|
|
- if (!$tagManager->moderateTag($this->getDoctrine(), $tag_id, true))
|
|
73
|
+ if (!$tagManager->moderateTag($this->getDoctrine(), $tag, true))
|
63
|
74
|
{
|
64
|
75
|
return $this->jsonResponse(array(
|
65
|
76
|
'status' => 'error',
|
|
@@ -74,13 +85,24 @@ class ModerateController extends Controller
|
74
|
85
|
|
75
|
86
|
public function tagRefuseAction($tag_id)
|
76
|
87
|
{
|
77
|
|
- if (($response = $this->mustBeConnected()))
|
|
88
|
+ if (($response = $this->mustBeConnected(true)))
|
78
|
89
|
{
|
79
|
90
|
return $response;
|
80
|
91
|
}
|
81
|
92
|
|
|
93
|
+ if (!($tag = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneBy(array(
|
|
94
|
+ 'id' => $tag_id,
|
|
95
|
+ 'tomoderate' => true
|
|
96
|
+ ))))
|
|
97
|
+ {
|
|
98
|
+ return $this->jsonResponse(array(
|
|
99
|
+ 'status' => 'error',
|
|
100
|
+ 'message' => 'NotFound'
|
|
101
|
+ ));
|
|
102
|
+ }
|
|
103
|
+
|
82
|
104
|
$tagManager = new TagManager();
|
83
|
|
- if (!$tagManager->moderateTag($this->getDoctrine(), $tag_id, false))
|
|
105
|
+ if (!$tagManager->moderateTag($this->getDoctrine(), $tag, false))
|
84
|
106
|
{
|
85
|
107
|
return $this->jsonResponse(array(
|
86
|
108
|
'status' => 'error',
|
|
@@ -88,6 +110,29 @@ class ModerateController extends Controller
|
88
|
110
|
));
|
89
|
111
|
}
|
90
|
112
|
|
|
113
|
+ // Tout c'est bien passé, on incremente ceci dit le compteur
|
|
114
|
+ // de tag refusés par la modération pour le ou les utilisateurs
|
|
115
|
+ // ayant fait la demande d'ajout
|
|
116
|
+ $uids = json_decode($tag->getPrivateids(), true);
|
|
117
|
+
|
|
118
|
+ $users = $this->getDoctrine()->getEntityManager()
|
|
119
|
+ ->createQuery('
|
|
120
|
+ SELECT u FROM MuzichCoreBundle:User u
|
|
121
|
+ WHERE u.id IN (:uids)'
|
|
122
|
+ )
|
|
123
|
+ ->setParameter('uids', $uids)
|
|
124
|
+ ->getResult()
|
|
125
|
+ ;
|
|
126
|
+
|
|
127
|
+ // Pour chacun on augmente le compteur
|
|
128
|
+ foreach ($users as $user)
|
|
129
|
+ {
|
|
130
|
+ $user->addModeratedTagCount();
|
|
131
|
+ $this->getDoctrine()->getEntityManager()->persist($user);
|
|
132
|
+ }
|
|
133
|
+
|
|
134
|
+ $this->getDoctrine()->getEntityManager()->flush();
|
|
135
|
+
|
91
|
136
|
return $this->jsonResponse(array(
|
92
|
137
|
'status' => 'success'
|
93
|
138
|
));
|
|
@@ -103,11 +148,22 @@ class ModerateController extends Controller
|
103
|
148
|
*/
|
104
|
149
|
public function tagReplaceAction($tag_id, $tag_new_id)
|
105
|
150
|
{
|
106
|
|
- if (($response = $this->mustBeConnected()))
|
|
151
|
+ if (($response = $this->mustBeConnected(true)))
|
107
|
152
|
{
|
108
|
153
|
return $response;
|
109
|
154
|
}
|
110
|
155
|
|
|
156
|
+ if (!($tag = $doctrine->getRepository('MuzichCoreBundle:Tag')->findOneBy(array(
|
|
157
|
+ 'id' => $tag_id,
|
|
158
|
+ 'tomoderate' => true
|
|
159
|
+ ))))
|
|
160
|
+ {
|
|
161
|
+ return $this->jsonResponse(array(
|
|
162
|
+ 'status' => 'error',
|
|
163
|
+ 'message' => 'NotFound'
|
|
164
|
+ ));
|
|
165
|
+ }
|
|
166
|
+
|
111
|
167
|
$tag_array = json_decode($tag_new_id);
|
112
|
168
|
if (!array_key_exists(0, $tag_array))
|
113
|
169
|
{
|
|
@@ -119,7 +175,7 @@ class ModerateController extends Controller
|
119
|
175
|
$tag_new_id = $tag_array[0];
|
120
|
176
|
|
121
|
177
|
$tagManager = new TagManager();
|
122
|
|
- if (!$tagManager->moderateTag($this->getDoctrine(), $tag_id, false, $tag_new_id))
|
|
178
|
+ if (!$tagManager->moderateTag($this->getDoctrine(), $tag, false, $tag_new_id))
|
123
|
179
|
{
|
124
|
180
|
return $this->jsonResponse(array(
|
125
|
181
|
'status' => 'error',
|
|
@@ -170,6 +226,7 @@ class ModerateController extends Controller
|
170
|
226
|
|
171
|
227
|
$event = new EventElement($this->container);
|
172
|
228
|
$event->elementRemoved($element);
|
|
229
|
+ $element->getOwner()->addModeratedElementCount();
|
173
|
230
|
|
174
|
231
|
$this->getDoctrine()->getEntityManager()->persist($element->getOwner());
|
175
|
232
|
$this->getDoctrine()->getEntityManager()->remove($element);
|
|
@@ -344,11 +401,22 @@ class ModerateController extends Controller
|
344
|
401
|
}
|
345
|
402
|
|
346
|
403
|
$cm = new CommentsManager($element->getComments());
|
|
404
|
+ $comment = $cm->get($cm->getIndexWithDate($date));
|
347
|
405
|
// On supprime le commentaire
|
348
|
406
|
$cm->deleteWithDate($date);
|
349
|
407
|
$element->setComments($cm->get());
|
350
|
408
|
$element->setCountCommentReport($cm->countCommentAlert());
|
351
|
409
|
|
|
410
|
+ // On récupère l'auteur du commentaire pour lui incrémenté son compteur
|
|
411
|
+ // de contenu modéré
|
|
412
|
+ $user = $this->getDoctrine()->getEntityManager()->getRepository('MuzichCoreBundle:User')
|
|
413
|
+ ->findOneBy(array(
|
|
414
|
+ 'id' => $comment['u']['i']
|
|
415
|
+ ));
|
|
416
|
+
|
|
417
|
+ $user->addModeratedCommentCount();
|
|
418
|
+
|
|
419
|
+ $this->getDoctrine()->getEntityManager()->persist($user);
|
352
|
420
|
$this->getDoctrine()->getEntityManager()->persist($element);
|
353
|
421
|
$this->getDoctrine()->getEntityManager()->flush();
|
354
|
422
|
|