diff options
Diffstat (limited to 'src/Wallabag')
5 files changed, 42 insertions, 327 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/UserRestController.php b/src/Wallabag/ApiBundle/Controller/UserRestController.php index a1b78e3f..8f675b8d 100644 --- a/src/Wallabag/ApiBundle/Controller/UserRestController.php +++ b/src/Wallabag/ApiBundle/Controller/UserRestController.php | |||
@@ -43,16 +43,18 @@ class UserRestController extends WallabagRestController | |||
43 | */ | 43 | */ |
44 | public function putUserAction(Request $request) | 44 | public function putUserAction(Request $request) |
45 | { | 45 | { |
46 | if (!$this->container->getParameter('fosuser_registration')) { | 46 | if (!$this->getParameter('fosuser_registration') || !$this->get('craue_config')->get('api_user_registration')) { |
47 | $json = $this->get('serializer')->serialize(['error' => "Server doesn't allow registrations"], 'json'); | 47 | $json = $this->get('serializer')->serialize(['error' => "Server doesn't allow registrations"], 'json'); |
48 | 48 | ||
49 | return (new JsonResponse())->setJson($json)->setStatusCode(403); | 49 | return (new JsonResponse()) |
50 | ->setJson($json) | ||
51 | ->setStatusCode(JsonResponse::HTTP_FORBIDDEN); | ||
50 | } | 52 | } |
51 | 53 | ||
52 | $userManager = $this->get('fos_user.user_manager'); | 54 | $userManager = $this->get('fos_user.user_manager'); |
53 | $user = $userManager->createUser(); | 55 | $user = $userManager->createUser(); |
54 | // enable created user by default | 56 | // user will be disabled BY DEFAULT to avoid spamming account to be enabled |
55 | $user->setEnabled(true); | 57 | $user->setEnabled(false); |
56 | 58 | ||
57 | $form = $this->createForm('Wallabag\UserBundle\Form\NewUserType', $user, [ | 59 | $form = $this->createForm('Wallabag\UserBundle\Form\NewUserType', $user, [ |
58 | 'csrf_protection' => false, | 60 | 'csrf_protection' => false, |
@@ -90,7 +92,9 @@ class UserRestController extends WallabagRestController | |||
90 | 92 | ||
91 | $json = $this->get('serializer')->serialize(['error' => $errors], 'json'); | 93 | $json = $this->get('serializer')->serialize(['error' => $errors], 'json'); |
92 | 94 | ||
93 | return (new JsonResponse())->setJson($json)->setStatusCode(400); | 95 | return (new JsonResponse()) |
96 | ->setJson($json) | ||
97 | ->setStatusCode(JsonResponse::HTTP_BAD_REQUEST); | ||
94 | } | 98 | } |
95 | 99 | ||
96 | $userManager->updateUser($user); | 100 | $userManager->updateUser($user); |
@@ -99,17 +103,18 @@ class UserRestController extends WallabagRestController | |||
99 | $event = new UserEvent($user, $request); | 103 | $event = new UserEvent($user, $request); |
100 | $this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event); | 104 | $this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event); |
101 | 105 | ||
102 | return $this->sendUser($user); | 106 | return $this->sendUser($user, JsonResponse::HTTP_CREATED); |
103 | } | 107 | } |
104 | 108 | ||
105 | /** | 109 | /** |
106 | * Send user response. | 110 | * Send user response. |
107 | * | 111 | * |
108 | * @param User $user | 112 | * @param User $user |
113 | * @param int $status HTTP Status code to send | ||
109 | * | 114 | * |
110 | * @return JsonResponse | 115 | * @return JsonResponse |
111 | */ | 116 | */ |
112 | private function sendUser(User $user) | 117 | private function sendUser(User $user, $status = JsonResponse::HTTP_OK) |
113 | { | 118 | { |
114 | $json = $this->get('serializer')->serialize( | 119 | $json = $this->get('serializer')->serialize( |
115 | $user, | 120 | $user, |
@@ -117,7 +122,9 @@ class UserRestController extends WallabagRestController | |||
117 | SerializationContext::create()->setGroups(['user_api']) | 122 | SerializationContext::create()->setGroups(['user_api']) |
118 | ); | 123 | ); |
119 | 124 | ||
120 | return (new JsonResponse())->setJson($json); | 125 | return (new JsonResponse()) |
126 | ->setJson($json) | ||
127 | ->setStatusCode($status); | ||
121 | } | 128 | } |
122 | 129 | ||
123 | /** | 130 | /** |
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index d9608246..0f119377 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php | |||
@@ -292,165 +292,7 @@ class InstallCommand extends ContainerAwareCommand | |||
292 | // cleanup before insert new stuff | 292 | // cleanup before insert new stuff |
293 | $em->createQuery('DELETE FROM CraueConfigBundle:Setting')->execute(); | 293 | $em->createQuery('DELETE FROM CraueConfigBundle:Setting')->execute(); |
294 | 294 | ||
295 | $settings = [ | 295 | foreach ($this->getContainer()->getParameter('wallabag_core.default_internal_settings') as $setting) { |
296 | [ | ||
297 | 'name' => 'share_public', | ||
298 | 'value' => '1', | ||
299 | 'section' => 'entry', | ||
300 | ], | ||
301 | [ | ||
302 | 'name' => 'carrot', | ||
303 | 'value' => '1', | ||
304 | 'section' => 'entry', | ||
305 | ], | ||
306 | [ | ||
307 | 'name' => 'share_diaspora', | ||
308 | 'value' => '1', | ||
309 | 'section' => 'entry', | ||
310 | ], | ||
311 | [ | ||
312 | 'name' => 'diaspora_url', | ||
313 | 'value' => 'http://diasporapod.com', | ||
314 | 'section' => 'entry', | ||
315 | ], | ||
316 | [ | ||
317 | 'name' => 'share_unmark', | ||
318 | 'value' => '1', | ||
319 | 'section' => 'entry', | ||
320 | ], | ||
321 | [ | ||
322 | 'name' => 'unmark_url', | ||
323 | 'value' => 'https://unmark.it', | ||
324 | 'section' => 'entry', | ||
325 | ], | ||
326 | [ | ||
327 | 'name' => 'share_shaarli', | ||
328 | 'value' => '1', | ||
329 | 'section' => 'entry', | ||
330 | ], | ||
331 | [ | ||
332 | 'name' => 'shaarli_url', | ||
333 | 'value' => 'http://myshaarli.com', | ||
334 | 'section' => 'entry', | ||
335 | ], | ||
336 | [ | ||
337 | 'name' => 'share_scuttle', | ||
338 | 'value' => '1', | ||
339 | 'section' => 'entry', | ||
340 | ], | ||
341 | [ | ||
342 | 'name' => 'scuttle_url', | ||
343 | 'value' => 'http://scuttle.org', | ||
344 | 'section' => 'entry', | ||
345 | ], | ||
346 | [ | ||
347 | 'name' => 'share_mail', | ||
348 | 'value' => '1', | ||
349 | 'section' => 'entry', | ||
350 | ], | ||
351 | [ | ||
352 | 'name' => 'share_twitter', | ||
353 | 'value' => '1', | ||
354 | 'section' => 'entry', | ||
355 | ], | ||
356 | [ | ||
357 | 'name' => 'export_epub', | ||
358 | 'value' => '1', | ||
359 | 'section' => 'export', | ||
360 | ], | ||
361 | [ | ||
362 | 'name' => 'export_mobi', | ||
363 | 'value' => '1', | ||
364 | 'section' => 'export', | ||
365 | ], | ||
366 | [ | ||
367 | 'name' => 'export_pdf', | ||
368 | 'value' => '1', | ||
369 | 'section' => 'export', | ||
370 | ], | ||
371 | [ | ||
372 | 'name' => 'export_csv', | ||
373 | 'value' => '1', | ||
374 | 'section' => 'export', | ||
375 | ], | ||
376 | [ | ||
377 | 'name' => 'export_json', | ||
378 | 'value' => '1', | ||
379 | 'section' => 'export', | ||
380 | ], | ||
381 | [ | ||
382 | 'name' => 'export_txt', | ||
383 | 'value' => '1', | ||
384 | 'section' => 'export', | ||
385 | ], | ||
386 | [ | ||
387 | 'name' => 'export_xml', | ||
388 | 'value' => '1', | ||
389 | 'section' => 'export', | ||
390 | ], | ||
391 | [ | ||
392 | 'name' => 'import_with_redis', | ||
393 | 'value' => '0', | ||
394 | 'section' => 'import', | ||
395 | ], | ||
396 | [ | ||
397 | 'name' => 'import_with_rabbitmq', | ||
398 | 'value' => '0', | ||
399 | 'section' => 'import', | ||
400 | ], | ||
401 | [ | ||
402 | 'name' => 'show_printlink', | ||
403 | 'value' => '1', | ||
404 | 'section' => 'entry', | ||
405 | ], | ||
406 | [ | ||
407 | 'name' => 'wallabag_support_url', | ||
408 | 'value' => 'https://www.wallabag.org/pages/support.html', | ||
409 | 'section' => 'misc', | ||
410 | ], | ||
411 | [ | ||
412 | 'name' => 'wallabag_url', | ||
413 | 'value' => '', | ||
414 | 'section' => 'misc', | ||
415 | ], | ||
416 | [ | ||
417 | 'name' => 'piwik_enabled', | ||
418 | 'value' => '0', | ||
419 | 'section' => 'analytics', | ||
420 | ], | ||
421 | [ | ||
422 | 'name' => 'piwik_host', | ||
423 | 'value' => 'v2.wallabag.org', | ||
424 | 'section' => 'analytics', | ||
425 | ], | ||
426 | [ | ||
427 | 'name' => 'piwik_site_id', | ||
428 | 'value' => '1', | ||
429 | 'section' => 'analytics', | ||
430 | ], | ||
431 | [ | ||
432 | 'name' => 'demo_mode_enabled', | ||
433 | 'value' => '0', | ||
434 | 'section' => 'misc', | ||
435 | ], | ||
436 | [ | ||
437 | 'name' => 'demo_mode_username', | ||
438 | 'value' => 'wallabag', | ||
439 | 'section' => 'misc', | ||
440 | ], | ||
441 | [ | ||
442 | 'name' => 'download_images_enabled', | ||
443 | 'value' => '0', | ||
444 | 'section' => 'misc', | ||
445 | ], | ||
446 | [ | ||
447 | 'name' => 'restricted_access', | ||
448 | 'value' => '0', | ||
449 | 'section' => 'entry', | ||
450 | ], | ||
451 | ]; | ||
452 | |||
453 | foreach ($settings as $setting) { | ||
454 | $newSetting = new Setting(); | 296 | $newSetting = new Setting(); |
455 | $newSetting->setName($setting['name']); | 297 | $newSetting->setName($setting['name']); |
456 | $newSetting->setValue($setting['value']); | 298 | $newSetting->setValue($setting['value']); |
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php index aaeb9ee9..a52288e6 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php | |||
@@ -6,173 +6,27 @@ use Doctrine\Common\DataFixtures\AbstractFixture; | |||
6 | use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | 6 | use Doctrine\Common\DataFixtures\OrderedFixtureInterface; |
7 | use Doctrine\Common\Persistence\ObjectManager; | 7 | use Doctrine\Common\Persistence\ObjectManager; |
8 | use Craue\ConfigBundle\Entity\Setting; | 8 | use Craue\ConfigBundle\Entity\Setting; |
9 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
10 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | 11 | ||
10 | class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface | 12 | class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface |
11 | { | 13 | { |
12 | /** | 14 | /** |
15 | * @var ContainerInterface | ||
16 | */ | ||
17 | private $container; | ||
18 | |||
19 | public function setContainer(ContainerInterface $container = null) | ||
20 | { | ||
21 | $this->container = $container; | ||
22 | } | ||
23 | |||
24 | /** | ||
13 | * {@inheritdoc} | 25 | * {@inheritdoc} |
14 | */ | 26 | */ |
15 | public function load(ObjectManager $manager) | 27 | public function load(ObjectManager $manager) |
16 | { | 28 | { |
17 | $settings = [ | 29 | foreach ($this->container->getParameter('wallabag_core.default_internal_settings') as $setting) { |
18 | [ | ||
19 | 'name' => 'share_public', | ||
20 | 'value' => '1', | ||
21 | 'section' => 'entry', | ||
22 | ], | ||
23 | [ | ||
24 | 'name' => 'carrot', | ||
25 | 'value' => '1', | ||
26 | 'section' => 'entry', | ||
27 | ], | ||
28 | [ | ||
29 | 'name' => 'share_diaspora', | ||
30 | 'value' => '1', | ||
31 | 'section' => 'entry', | ||
32 | ], | ||
33 | [ | ||
34 | 'name' => 'diaspora_url', | ||
35 | 'value' => 'http://diasporapod.com', | ||
36 | 'section' => 'entry', | ||
37 | ], | ||
38 | [ | ||
39 | 'name' => 'share_unmark', | ||
40 | 'value' => '1', | ||
41 | 'section' => 'entry', | ||
42 | ], | ||
43 | [ | ||
44 | 'name' => 'unmark_url', | ||
45 | 'value' => 'https://unmark.it', | ||
46 | 'section' => 'entry', | ||
47 | ], | ||
48 | [ | ||
49 | 'name' => 'share_shaarli', | ||
50 | 'value' => '1', | ||
51 | 'section' => 'entry', | ||
52 | ], | ||
53 | [ | ||
54 | 'name' => 'share_scuttle', | ||
55 | 'value' => '1', | ||
56 | 'section' => 'entry', | ||
57 | ], | ||
58 | [ | ||
59 | 'name' => 'shaarli_url', | ||
60 | 'value' => 'http://myshaarli.com', | ||
61 | 'section' => 'entry', | ||
62 | ], | ||
63 | [ | ||
64 | 'name' => 'scuttle_url', | ||
65 | 'value' => 'http://scuttle.org', | ||
66 | 'section' => 'entry', | ||
67 | ], | ||
68 | [ | ||
69 | 'name' => 'share_mail', | ||
70 | 'value' => '1', | ||
71 | 'section' => 'entry', | ||
72 | ], | ||
73 | [ | ||
74 | 'name' => 'share_twitter', | ||
75 | 'value' => '1', | ||
76 | 'section' => 'entry', | ||
77 | ], | ||
78 | [ | ||
79 | 'name' => 'export_epub', | ||
80 | 'value' => '1', | ||
81 | 'section' => 'export', | ||
82 | ], | ||
83 | [ | ||
84 | 'name' => 'export_mobi', | ||
85 | 'value' => '1', | ||
86 | 'section' => 'export', | ||
87 | ], | ||
88 | [ | ||
89 | 'name' => 'export_pdf', | ||
90 | 'value' => '1', | ||
91 | 'section' => 'export', | ||
92 | ], | ||
93 | [ | ||
94 | 'name' => 'export_csv', | ||
95 | 'value' => '1', | ||
96 | 'section' => 'export', | ||
97 | ], | ||
98 | [ | ||
99 | 'name' => 'export_json', | ||
100 | 'value' => '1', | ||
101 | 'section' => 'export', | ||
102 | ], | ||
103 | [ | ||
104 | 'name' => 'export_txt', | ||
105 | 'value' => '1', | ||
106 | 'section' => 'export', | ||
107 | ], | ||
108 | [ | ||
109 | 'name' => 'export_xml', | ||
110 | 'value' => '1', | ||
111 | 'section' => 'export', | ||
112 | ], | ||
113 | [ | ||
114 | 'name' => 'import_with_redis', | ||
115 | 'value' => '0', | ||
116 | 'section' => 'import', | ||
117 | ], | ||
118 | [ | ||
119 | 'name' => 'import_with_rabbitmq', | ||
120 | 'value' => '0', | ||
121 | 'section' => 'import', | ||
122 | ], | ||
123 | [ | ||
124 | 'name' => 'show_printlink', | ||
125 | 'value' => '1', | ||
126 | 'section' => 'entry', | ||
127 | ], | ||
128 | [ | ||
129 | 'name' => 'wallabag_support_url', | ||
130 | 'value' => 'https://www.wallabag.org/pages/support.html', | ||
131 | 'section' => 'misc', | ||
132 | ], | ||
133 | [ | ||
134 | 'name' => 'wallabag_url', | ||
135 | 'value' => 'http://v2.wallabag.org', | ||
136 | 'section' => 'misc', | ||
137 | ], | ||
138 | [ | ||
139 | 'name' => 'piwik_enabled', | ||
140 | 'value' => '0', | ||
141 | 'section' => 'analytics', | ||
142 | ], | ||
143 | [ | ||
144 | 'name' => 'piwik_host', | ||
145 | 'value' => 'v2.wallabag.org', | ||
146 | 'section' => 'analytics', | ||
147 | ], | ||
148 | [ | ||
149 | 'name' => 'piwik_site_id', | ||
150 | 'value' => '1', | ||
151 | 'section' => 'analytics', | ||
152 | ], | ||
153 | [ | ||
154 | 'name' => 'demo_mode_enabled', | ||
155 | 'value' => '0', | ||
156 | 'section' => 'misc', | ||
157 | ], | ||
158 | [ | ||
159 | 'name' => 'demo_mode_username', | ||
160 | 'value' => 'wallabag', | ||
161 | 'section' => 'misc', | ||
162 | ], | ||
163 | [ | ||
164 | 'name' => 'download_images_enabled', | ||
165 | 'value' => '0', | ||
166 | 'section' => 'misc', | ||
167 | ], | ||
168 | [ | ||
169 | 'name' => 'restricted_access', | ||
170 | 'value' => '0', | ||
171 | 'section' => 'entry', | ||
172 | ], | ||
173 | ]; | ||
174 | |||
175 | foreach ($settings as $setting) { | ||
176 | $newSetting = new Setting(); | 30 | $newSetting = new Setting(); |
177 | $newSetting->setName($setting['name']); | 31 | $newSetting->setName($setting['name']); |
178 | $newSetting->setValue($setting['value']); | 32 | $newSetting->setValue($setting['value']); |
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index 8b5b5744..33df92d3 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php | |||
@@ -52,6 +52,17 @@ class Configuration implements ConfigurationInterface | |||
52 | ->scalarNode('api_limit_mass_actions') | 52 | ->scalarNode('api_limit_mass_actions') |
53 | ->defaultValue(10) | 53 | ->defaultValue(10) |
54 | ->end() | 54 | ->end() |
55 | ->arrayNode('default_internal_settings') | ||
56 | ->prototype('array') | ||
57 | ->children() | ||
58 | ->scalarNode('name')->end() | ||
59 | ->scalarNode('value')->end() | ||
60 | ->enumNode('section') | ||
61 | ->values(['entry', 'misc', 'api', 'analytics', 'export', 'import']) | ||
62 | ->end() | ||
63 | ->end() | ||
64 | ->end() | ||
65 | ->end() | ||
55 | ->end() | 66 | ->end() |
56 | ; | 67 | ; |
57 | 68 | ||
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index a2a703cb..b4d8a386 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php | |||
@@ -28,6 +28,7 @@ class WallabagCoreExtension extends Extension | |||
28 | $container->setParameter('wallabag_core.fetching_error_message', $config['fetching_error_message']); | 28 | $container->setParameter('wallabag_core.fetching_error_message', $config['fetching_error_message']); |
29 | $container->setParameter('wallabag_core.fetching_error_message_title', $config['fetching_error_message_title']); | 29 | $container->setParameter('wallabag_core.fetching_error_message_title', $config['fetching_error_message_title']); |
30 | $container->setParameter('wallabag_core.api_limit_mass_actions', $config['api_limit_mass_actions']); | 30 | $container->setParameter('wallabag_core.api_limit_mass_actions', $config['api_limit_mass_actions']); |
31 | $container->setParameter('wallabag_core.default_internal_settings', $config['default_internal_settings']); | ||
31 | 32 | ||
32 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | 33 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
33 | $loader->load('services.yml'); | 34 | $loader->load('services.yml'); |