|
@@ -15,6 +15,7 @@ use Muzich\UserBundle\Form\Type\RegistrationFormType;
|
15
|
15
|
use Muzich\CoreBundle\Entity\User;
|
16
|
16
|
use Muzich\CoreBundle\Form\User\PasswordForm;
|
17
|
17
|
use Muzich\CoreBundle\Form\User\PrivacyForm;
|
|
18
|
+use Muzich\CoreBundle\Form\User\DeleteForm;
|
18
|
19
|
|
19
|
20
|
class UserController extends Controller
|
20
|
21
|
{
|
|
@@ -50,6 +51,11 @@ class UserController extends Controller
|
50
|
51
|
return $this->createForm(new PrivacyForm(), $this->getUser());
|
51
|
52
|
}
|
52
|
53
|
|
|
54
|
+ protected function getDeleteForm()
|
|
55
|
+ {
|
|
56
|
+ return $this->createForm(new DeleteForm(), $this->getUser());
|
|
57
|
+ }
|
|
58
|
+
|
53
|
59
|
protected function getTagsFavoritesForm($user)
|
54
|
60
|
{
|
55
|
61
|
$ids = array();
|
|
@@ -98,7 +104,8 @@ class UserController extends Controller
|
98
|
104
|
'change_email_form' => $change_email_form->createView(),
|
99
|
105
|
'avatar_form' => $this->getAvatarForm()->createView(),
|
100
|
106
|
'preferences_form' => $this->getPreferencesForm()->createView(),
|
101
|
|
- 'privacy_form' => $this->getPrivacyForm()->createView()
|
|
107
|
+ 'privacy_form' => $this->getPrivacyForm()->createView(),
|
|
108
|
+ 'delete_form' => $this->getDeleteForm()->createView()
|
102
|
109
|
);
|
103
|
110
|
}
|
104
|
111
|
|
|
@@ -257,7 +264,6 @@ class UserController extends Controller
|
257
|
264
|
}
|
258
|
265
|
|
259
|
266
|
$form_tags_favorites = $this->getTagsFavoritesForm($user);
|
260
|
|
- $change_email_form = $this->getChangeEmailForm();
|
261
|
267
|
|
262
|
268
|
return $this->container->get('templating')->renderResponse(
|
263
|
269
|
'MuzichUserBundle:User:account.html.twig',
|
|
@@ -268,10 +274,11 @@ class UserController extends Controller
|
268
|
274
|
'form_tags_favorites' => $form_tags_favorites->createView(),
|
269
|
275
|
'form_tags_favorites_name' => $form_tags_favorites->getName(),
|
270
|
276
|
'favorite_tags_id' => $this->getTagsFavorites(),
|
271
|
|
- 'change_email_form' => $change_email_form->createView(),
|
|
277
|
+ 'change_email_form' => $this->getChangeEmailForm()->createView(),
|
272
|
278
|
'avatar_form' => $this->getAvatarForm()->createView(),
|
273
|
279
|
'preferences_form' => $this->getPreferencesForm()->createView(),
|
274
|
|
- 'privacy_form' => $this->getPrivacyForm()->createView()
|
|
280
|
+ 'privacy_form' => $this->getPrivacyForm()->createView(),
|
|
281
|
+ 'delete_form' => $this->getDeleteForm()->createView()
|
275
|
282
|
)
|
276
|
283
|
);
|
277
|
284
|
}
|
|
@@ -450,7 +457,8 @@ class UserController extends Controller
|
450
|
457
|
'change_email_form' => $change_email_form->createView(),
|
451
|
458
|
'avatar_form' => $this->getAvatarForm()->createView(),
|
452
|
459
|
'preferences_form' => $this->getPreferencesForm()->createView(),
|
453
|
|
- 'privacy_form' => $this->getPrivacyForm()->createView()
|
|
460
|
+ 'privacy_form' => $this->getPrivacyForm()->createView(),
|
|
461
|
+ 'delete_form' => $this->getDeleteForm()->createView()
|
454
|
462
|
)
|
455
|
463
|
);
|
456
|
464
|
}
|
|
@@ -783,4 +791,36 @@ class UserController extends Controller
|
783
|
791
|
));
|
784
|
792
|
}
|
785
|
793
|
|
|
794
|
+ public function deleteAction(Request $request)
|
|
795
|
+ {
|
|
796
|
+ $form = $this->getDeleteForm();
|
|
797
|
+ $form->bind($request);
|
|
798
|
+
|
|
799
|
+ if ($form->isValid())
|
|
800
|
+ {
|
|
801
|
+ $this->getUserManager()->disableUser($form->getData());
|
|
802
|
+ $this->setFlash('success', 'user.delete.success');
|
|
803
|
+ return $this->redirect($this->generateUrl('fos_user_security_logout'));
|
|
804
|
+ }
|
|
805
|
+
|
|
806
|
+ $this->setFlash('error', 'user.delete.fail');
|
|
807
|
+ $form_tags_favorites = $this->getTagsFavoritesForm($form->getData());
|
|
808
|
+ return $this->container->get('templating')->renderResponse(
|
|
809
|
+ 'MuzichUserBundle:User:account.html.twig',
|
|
810
|
+ array(
|
|
811
|
+ 'form_password' => $this->getChangePasswordForm($form->getData())->createView(),
|
|
812
|
+ 'errors_pers' => array(),
|
|
813
|
+ 'user' => $form->getData(),
|
|
814
|
+ 'form_tags_favorites' => $form_tags_favorites->createView(),
|
|
815
|
+ 'form_tags_favorites_name' => $form_tags_favorites->getName(),
|
|
816
|
+ 'favorite_tags_id' => $this->getTagsFavorites(),
|
|
817
|
+ 'change_email_form' => $this->getChangeEmailForm()->createView(),
|
|
818
|
+ 'avatar_form' => $this->getAvatarForm()->createView(),
|
|
819
|
+ 'preferences_form' => $this->getPreferencesForm()->createView(),
|
|
820
|
+ 'privacy_form' => $this->getPrivacyForm()->createView(),
|
|
821
|
+ 'delete_form' => $form->createView()
|
|
822
|
+ )
|
|
823
|
+ );
|
|
824
|
+ }
|
|
825
|
+
|
786
|
826
|
}
|