diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Command')
-rw-r--r-- | src/Wallabag/CoreBundle/Command/InstallCommand.php | 160 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Command/ShowUserCommand.php | 77 |
2 files changed, 78 insertions, 159 deletions
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/Command/ShowUserCommand.php b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php new file mode 100644 index 00000000..0eeaabc4 --- /dev/null +++ b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php | |||
@@ -0,0 +1,77 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Command; | ||
4 | |||
5 | use Doctrine\ORM\NoResultException; | ||
6 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
7 | use Symfony\Component\Console\Input\InputArgument; | ||
8 | use Symfony\Component\Console\Input\InputInterface; | ||
9 | use Symfony\Component\Console\Output\OutputInterface; | ||
10 | use Wallabag\UserBundle\Entity\User; | ||
11 | |||
12 | class ShowUserCommand extends ContainerAwareCommand | ||
13 | { | ||
14 | /** @var OutputInterface */ | ||
15 | protected $output; | ||
16 | |||
17 | protected function configure() | ||
18 | { | ||
19 | $this | ||
20 | ->setName('wallabag:user:show') | ||
21 | ->setDescription('Show user details') | ||
22 | ->setHelp('This command shows the details for an user') | ||
23 | ->addArgument( | ||
24 | 'username', | ||
25 | InputArgument::REQUIRED, | ||
26 | 'User to show details for' | ||
27 | ); | ||
28 | } | ||
29 | |||
30 | protected function execute(InputInterface $input, OutputInterface $output) | ||
31 | { | ||
32 | $this->output = $output; | ||
33 | |||
34 | $username = $input->getArgument('username'); | ||
35 | |||
36 | try { | ||
37 | $user = $this->getUser($username); | ||
38 | $this->showUser($user); | ||
39 | } catch (NoResultException $e) { | ||
40 | $output->writeln(sprintf('<error>User "%s" not found.</error>', $username)); | ||
41 | |||
42 | return 1; | ||
43 | } | ||
44 | |||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * @param User $user | ||
50 | */ | ||
51 | private function showUser(User $user) | ||
52 | { | ||
53 | $this->output->writeln(sprintf('Username : %s', $user->getUsername())); | ||
54 | $this->output->writeln(sprintf('Email : %s', $user->getEmail())); | ||
55 | $this->output->writeln(sprintf('Display name : %s', $user->getName())); | ||
56 | $this->output->writeln(sprintf('Creation date : %s', $user->getCreatedAt()->format('Y-m-d H:i:s'))); | ||
57 | $this->output->writeln(sprintf('Last login : %s', $user->getLastLogin() !== null ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never')); | ||
58 | $this->output->writeln(sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no')); | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Fetches a user from its username. | ||
63 | * | ||
64 | * @param string $username | ||
65 | * | ||
66 | * @return \Wallabag\UserBundle\Entity\User | ||
67 | */ | ||
68 | private function getUser($username) | ||
69 | { | ||
70 | return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username); | ||
71 | } | ||
72 | |||
73 | private function getDoctrine() | ||
74 | { | ||
75 | return $this->getContainer()->get('doctrine'); | ||
76 | } | ||
77 | } | ||