aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2016-09-08 14:07:36 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-08 13:27:18 +0200
commitbb0c78f4a636fcc8f60dd3b42ad733e7f31e0bb4 (patch)
treec9209d37cf5db197e2fa45e7164b55af7a92e374 /src
parentabb5291cd5dc98211273e5d3b516a6a0ed8b980f (diff)
downloadwallabag-bb0c78f4a636fcc8f60dd3b42ad733e7f31e0bb4.tar.gz
wallabag-bb0c78f4a636fcc8f60dd3b42ad733e7f31e0bb4.tar.zst
wallabag-bb0c78f4a636fcc8f60dd3b42ad733e7f31e0bb4.zip
Added check if there is only one user
Added translations and documentation
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php14
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig3
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig5
-rw-r--r--src/Wallabag/UserBundle/Repository/UserRepository.php14
15 files changed, 46 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 3cafd1bc..70a641f7 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -7,6 +7,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\JsonResponse; 7use Symfony\Component\HttpFoundation\JsonResponse;
8use Symfony\Component\HttpFoundation\RedirectResponse; 8use Symfony\Component\HttpFoundation\RedirectResponse;
9use Symfony\Component\HttpFoundation\Request; 9use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
10use Wallabag\CoreBundle\Entity\Config; 11use Wallabag\CoreBundle\Entity\Config;
11use Wallabag\CoreBundle\Entity\TaggingRule; 12use Wallabag\CoreBundle\Entity\TaggingRule;
12use Wallabag\CoreBundle\Form\Type\ConfigType; 13use Wallabag\CoreBundle\Form\Type\ConfigType;
@@ -148,6 +149,9 @@ class ConfigController extends Controller
148 'token' => $config->getRssToken(), 149 'token' => $config->getRssToken(),
149 ], 150 ],
150 'twofactor_auth' => $this->getParameter('twofactor_auth'), 151 'twofactor_auth' => $this->getParameter('twofactor_auth'),
152 'enabled_users' => $this->getDoctrine()
153 ->getRepository('WallabagUserBundle:User')
154 ->getSumEnabledUsers(),
151 ]); 155 ]);
152 } 156 }
153 157
@@ -257,10 +261,20 @@ class ConfigController extends Controller
257 * 261 *
258 * @Route("/account/delete", name="delete_account") 262 * @Route("/account/delete", name="delete_account")
259 * 263 *
264 * @throws AccessDeniedHttpException
265 *
260 * @return \Symfony\Component\HttpFoundation\RedirectResponse 266 * @return \Symfony\Component\HttpFoundation\RedirectResponse
261 */ 267 */
262 public function deleteAccountAction() 268 public function deleteAccountAction()
263 { 269 {
270 $enabledUsers = $this->getDoctrine()
271 ->getRepository('WallabagUserBundle:User')
272 ->getSumEnabledUsers();
273
274 if ($enabledUsers <= 1) {
275 throw new AccessDeniedHttpException();
276 }
277
264 $em = $this->get('fos_user.user_manager'); 278 $em = $this->get('fos_user.user_manager');
265 $em->deleteUser($this->getUser()); 279 $em->deleteUser($this->getUser());
266 280
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index 69bfe7b3..4c412592 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'Navn' 88 name_label: 'Navn'
89 email_label: 'Emailadresse' 89 email_label: 'Emailadresse'
90 # twoFactorAuthentication_label: 'Two factor authentication' 90 # twoFactorAuthentication_label: 'Two factor authentication'
91 # delete_account: 'Delete my account'
91 form_password: 92 form_password:
92 old_password_label: 'Gammel adgangskode' 93 old_password_label: 'Gammel adgangskode'
93 new_password_label: 'Ny adgangskode' 94 new_password_label: 'Ny adgangskode'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index f4d13442..99b79bce 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'Name' 88 name_label: 'Name'
89 email_label: 'E-Mail-Adresse' 89 email_label: 'E-Mail-Adresse'
90 twoFactorAuthentication_label: 'Zwei-Faktor-Authentifizierung' 90 twoFactorAuthentication_label: 'Zwei-Faktor-Authentifizierung'
91 # delete_account: 'Delete my account'
91 form_password: 92 form_password:
92 old_password_label: 'Altes Kennwort' 93 old_password_label: 'Altes Kennwort'
93 new_password_label: 'Neues Kennwort' 94 new_password_label: 'Neues Kennwort'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index 6ddb38a0..94144ed4 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'Name' 88 name_label: 'Name'
89 email_label: 'Email' 89 email_label: 'Email'
90 twoFactorAuthentication_label: 'Two factor authentication' 90 twoFactorAuthentication_label: 'Two factor authentication'
91 delete_account: 'Delete my account'
91 form_password: 92 form_password:
92 old_password_label: 'Current password' 93 old_password_label: 'Current password'
93 new_password_label: 'New password' 94 new_password_label: 'New password'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index 05b03938..a5e8d722 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'Nombre' 88 name_label: 'Nombre'
89 email_label: 'Direccion e-mail' 89 email_label: 'Direccion e-mail'
90 twoFactorAuthentication_label: 'Autentificación de dos factores' 90 twoFactorAuthentication_label: 'Autentificación de dos factores'
91 # delete_account: 'Delete my account'
91 form_password: 92 form_password:
92 old_password_label: 'Contraseña actual' 93 old_password_label: 'Contraseña actual'
93 new_password_label: 'Nueva contraseña' 94 new_password_label: 'Nueva contraseña'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index 3a01a8ed..4b8d9689 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'نام' 88 name_label: 'نام'
89 email_label: 'نشانی ایمیل' 89 email_label: 'نشانی ایمیل'
90 twoFactorAuthentication_label: 'تأیید ۲مرحله‌ای' 90 twoFactorAuthentication_label: 'تأیید ۲مرحله‌ای'
91 # delete_account: 'Delete my account'
91 form_password: 92 form_password:
92 old_password_label: 'رمز قدیمی' 93 old_password_label: 'رمز قدیمی'
93 new_password_label: 'رمز تازه' 94 new_password_label: 'رمز تازه'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index 09445836..67cd5f0e 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'Nom' 88 name_label: 'Nom'
89 email_label: 'Adresse e-mail' 89 email_label: 'Adresse e-mail'
90 twoFactorAuthentication_label: 'Double authentification' 90 twoFactorAuthentication_label: 'Double authentification'
91 delete_account: 'Supprimer mon compte'
91 form_password: 92 form_password:
92 old_password_label: 'Mot de passe actuel' 93 old_password_label: 'Mot de passe actuel'
93 new_password_label: 'Nouveau mot de passe' 94 new_password_label: 'Nouveau mot de passe'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
index 93a11aee..55d961f3 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'Nome' 88 name_label: 'Nome'
89 email_label: 'E-mail' 89 email_label: 'E-mail'
90 twoFactorAuthentication_label: 'Two factor authentication' 90 twoFactorAuthentication_label: 'Two factor authentication'
91 # delete_account: 'Delete my account'
91 form_password: 92 form_password:
92 old_password_label: 'Password corrente' 93 old_password_label: 'Password corrente'
93 new_password_label: 'Nuova password' 94 new_password_label: 'Nuova password'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
index 8cadf9a3..5c6b4247 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'Nom' 88 name_label: 'Nom'
89 email_label: 'Adreça de corrièl' 89 email_label: 'Adreça de corrièl'
90 twoFactorAuthentication_label: 'Dobla autentificacion' 90 twoFactorAuthentication_label: 'Dobla autentificacion'
91 # delete_account: 'Delete my account'
91 form_password: 92 form_password:
92 old_password_label: 'Senhal actual' 93 old_password_label: 'Senhal actual'
93 new_password_label: 'Senhal novèl' 94 new_password_label: 'Senhal novèl'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index d392272f..be966427 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'Nazwa' 88 name_label: 'Nazwa'
89 email_label: 'Adres email' 89 email_label: 'Adres email'
90 twoFactorAuthentication_label: 'Autoryzacja dwuetapowa' 90 twoFactorAuthentication_label: 'Autoryzacja dwuetapowa'
91 # delete_account: 'Delete my account'
91 form_password: 92 form_password:
92 old_password_label: 'Stare hasło' 93 old_password_label: 'Stare hasło'
93 new_password_label: 'Nowe hasło' 94 new_password_label: 'Nowe hasło'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index f2bce442..1e52cf0b 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'Nume' 88 name_label: 'Nume'
89 email_label: 'E-mail' 89 email_label: 'E-mail'
90 # twoFactorAuthentication_label: 'Two factor authentication' 90 # twoFactorAuthentication_label: 'Two factor authentication'
91 # delete_account: 'Delete my account'
91 form_password: 92 form_password:
92 old_password_label: 'Parola veche' 93 old_password_label: 'Parola veche'
93 new_password_label: 'Parola nouă' 94 new_password_label: 'Parola nouă'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
index d2bf0504..ef5477e1 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
@@ -88,6 +88,7 @@ config:
88 name_label: 'İsim' 88 name_label: 'İsim'
89 email_label: 'E-posta' 89 email_label: 'E-posta'
90 twoFactorAuthentication_label: 'İki adımlı doğrulama' 90 twoFactorAuthentication_label: 'İki adımlı doğrulama'
91 # delete_account: 'Delete my account'
91 form_password: 92 form_password:
92 old_password_label: 'Eski şifre' 93 old_password_label: 'Eski şifre'
93 new_password_label: 'Yeni şifre' 94 new_password_label: 'Yeni şifre'
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
index ff7ef73a..29575272 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig
@@ -148,6 +148,9 @@
148 148
149 {{ form_widget(form.user._token) }} 149 {{ form_widget(form.user._token) }}
150 {{ form_widget(form.user.save) }} 150 {{ form_widget(form.user.save) }}
151 {% if enabled_users > 1 %}
152 <a class='btn red' href='{{ path('delete_account') }}'>{{ 'config.form_user.delete_account' | trans }}</a>
153 {% endif %}
151 </form> 154 </form>
152 155
153 <h2>{{ 'config.tab_menu.password'|trans }}</h2> 156 <h2>{{ 'config.tab_menu.password'|trans }}</h2>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
index cebde1ac..5aa3eabe 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig
@@ -167,7 +167,10 @@
167 {{ form_widget(form.user.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} 167 {{ form_widget(form.user.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
168 {{ form_widget(form.user._token) }} 168 {{ form_widget(form.user._token) }}
169 </form> 169 </form>
170 <a class='btn red' href='{{ path('delete_account') }}'>{{ 'config.user.delete_account' | trans }}</a> 170
171 {% if enabled_users > 1 %}
172 <a class='btn red' href='{{ path('delete_account') }}'>{{ 'config.form_user.delete_account' | trans }}</a>
173 {% endif %}
171 </div> 174 </div>
172 175
173 <div id="set4" class="col s12"> 176 <div id="set4" class="col s12">
diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php
index 009c4881..178761e6 100644
--- a/src/Wallabag/UserBundle/Repository/UserRepository.php
+++ b/src/Wallabag/UserBundle/Repository/UserRepository.php
@@ -38,4 +38,18 @@ class UserRepository extends EntityRepository
38 ->getQuery() 38 ->getQuery()
39 ->getSingleResult(); 39 ->getSingleResult();
40 } 40 }
41
42 /**
43 * Count how many users are enabled.
44 *
45 * @return int
46 */
47 public function getSumEnabledUsers()
48 {
49 return $this->createQueryBuilder('u')
50 ->select('count(u)')
51 ->andWhere('u.expired = 0')
52 ->getQuery()
53 ->getSingleScalarResult();
54 }
41} 55}