|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+<?php
|
|
|
2
|
+
|
|
|
3
|
+namespace Muzich\AdminBundle\Controller\Moderate_tag;
|
|
|
4
|
+
|
|
|
5
|
+use Admingenerated\MuzichAdminBundle\BaseModerate_tagController\EditController as BaseEditController;
|
|
|
6
|
+use Muzich\CoreBundle\Managers\TagManager;
|
|
|
7
|
+use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
|
8
|
+
|
|
|
9
|
+class EditController extends BaseEditController
|
|
|
10
|
+{
|
|
|
11
|
+
|
|
|
12
|
+ protected function getTagContext($pk)
|
|
|
13
|
+ {
|
|
|
14
|
+ //$Tag = $this->getObject($pk); Error ?!
|
|
|
15
|
+ $Tag = $tag = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneBy(array(
|
|
|
16
|
+ 'id' => $pk,
|
|
|
17
|
+ 'tomoderate' => true
|
|
|
18
|
+ ));
|
|
|
19
|
+ if (!$Tag) {
|
|
|
20
|
+ throw new NotFoundHttpException("The Muzich\CoreBundle\Entity\Tag with id $pk can't be found");
|
|
|
21
|
+ }
|
|
|
22
|
+ return $Tag;
|
|
|
23
|
+ }
|
|
|
24
|
+
|
|
|
25
|
+ public function acceptAction($pk)
|
|
|
26
|
+ {
|
|
|
27
|
+ $tag = $this->getTagContext($pk);
|
|
|
28
|
+ $tagManager = new TagManager();
|
|
|
29
|
+ $tagManager->moderateTag($this->getDoctrine(), $tag, true);
|
|
|
30
|
+
|
|
|
31
|
+ $this->get('session')->setFlash('success', $this->get('translator')->trans("object.edit.success", array(), 'Admingenerator') );
|
|
|
32
|
+ return new RedirectResponse($this->generateUrl("Muzich_AdminBundle_Moderate_tag_list" ));
|
|
|
33
|
+ }
|
|
|
34
|
+
|
|
|
35
|
+ public function refuseAction($pk)
|
|
|
36
|
+ {
|
|
|
37
|
+ $tag = $this->getTagContext($pk);
|
|
|
38
|
+ $tagManager = new TagManager();
|
|
|
39
|
+ $tagManager->moderateTag($this->getDoctrine(), $tag, false);
|
|
|
40
|
+
|
|
|
41
|
+ $uids = json_decode($tag->getPrivateids(), true);
|
|
|
42
|
+
|
|
|
43
|
+ $users = $this->getDoctrine()->getEntityManager()
|
|
|
44
|
+ ->createQuery('
|
|
|
45
|
+ SELECT u FROM MuzichCoreBundle:User u
|
|
|
46
|
+ WHERE u.id IN (:uids)'
|
|
|
47
|
+ )
|
|
|
48
|
+ ->setParameter('uids', $uids)
|
|
|
49
|
+ ->getResult()
|
|
|
50
|
+ ;
|
|
|
51
|
+
|
|
|
52
|
+ foreach ($users as $user)
|
|
|
53
|
+ {
|
|
|
54
|
+ $user->addModeratedTagCount();
|
|
|
55
|
+ $this->getDoctrine()->getEntityManager()->persist($user);
|
|
|
56
|
+ }
|
|
|
57
|
+
|
|
|
58
|
+ $this->getDoctrine()->getEntityManager()->flush();
|
|
|
59
|
+
|
|
|
60
|
+ $this->get('session')->setFlash('success', $this->get('translator')->trans("object.edit.success", array(), 'Admingenerator') );
|
|
|
61
|
+ return new RedirectResponse($this->generateUrl("Muzich_AdminBundle_Moderate_tag_list" ));
|
|
|
62
|
+ }
|
|
|
63
|
+
|
|
|
64
|
+}
|