Passed
Branch main (9d419d)
by Jonathan
04:01
created
app/Module/Certificates/Http/RequestHandlers/CertificatePage.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -35,79 +35,79 @@
 block discarded – undo
35 35
  */
36 36
 class CertificatePage implements RequestHandlerInterface
37 37
 {
38
-    use ViewResponseTrait;
39
-
40
-    /**
41
-     * @var CertificatesModule|null $module
42
-     */
43
-    private $module;
44
-
45
-    /**
46
-     * @var CertificateFilesystemService $certif_filesystem
47
-     */
48
-    private $certif_filesystem;
49
-
50
-    /**
51
-     * @var CertificateDataService $certif_data_service
52
-     */
53
-    private $certif_data_service;
54
-
55
-    /**
56
-     * @var UrlObfuscatorService $url_obfuscator_service
57
-     */
58
-    private $url_obfuscator_service;
59
-
60
-
61
-    /**
62
-     * Constructor for CertificatePage Request Handler
63
-     *
64
-     * @param ModuleService $module_service
65
-     * @param CertificateFilesystemService $certif_filesystem
66
-     * @param CertificateDataService $certif_data_service
67
-     * @param UrlObfuscatorService $url_obfuscator_service
68
-     */
69
-    public function __construct(
70
-        ModuleService $module_service,
71
-        CertificateFilesystemService $certif_filesystem,
72
-        CertificateDataService $certif_data_service,
73
-        UrlObfuscatorService $url_obfuscator_service
74
-    ) {
75
-        $this->module = $module_service->findByInterface(CertificatesModule::class)->first();
76
-        $this->certif_filesystem = $certif_filesystem;
77
-        $this->certif_data_service = $certif_data_service;
78
-        $this->url_obfuscator_service = $url_obfuscator_service;
79
-    }
80
-
81
-    /**
82
-     * {@inheritDoc}
83
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
84
-     */
85
-    public function handle(ServerRequestInterface $request): ResponseInterface
86
-    {
87
-        if ($this->module === null) {
88
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
89
-        }
90
-
91
-        $tree = Validator::attributes($request)->tree();
92
-
93
-        $certif_path = Validator::attributes($request)->string('cid', '');
94
-        if ($certif_path !== '' && $this->url_obfuscator_service->tryDeobfuscate($certif_path)) {
95
-            $certificate = $this->certif_filesystem->certificate($tree, $certif_path);
96
-        }
97
-
98
-        if (!isset($certificate)) {
99
-            FlashMessages::addMessage('The requested certificate is not valid.');
100
-            return Registry::responseFactory()->redirect(TreePage::class, ['tree' => $tree->name()]);
101
-        }
102
-
103
-        return $this->viewResponse($this->module->name() . '::certificate-page', [
104
-            'title'                     =>  I18N::translate('Certificate - %s', $certificate->name()),
105
-            'tree'                      =>  $tree,
106
-            'module_name'               =>  $this->module->name(),
107
-            'certificate'               =>  $certificate,
108
-            'url_obfuscator_service'    =>  $this->url_obfuscator_service,
109
-            'linked_individuals'        =>  $this->certif_data_service->linkedIndividuals($certificate),
110
-            'linked_families'           =>  $this->certif_data_service->linkedFamilies($certificate)
111
-        ]);
112
-    }
38
+	use ViewResponseTrait;
39
+
40
+	/**
41
+	 * @var CertificatesModule|null $module
42
+	 */
43
+	private $module;
44
+
45
+	/**
46
+	 * @var CertificateFilesystemService $certif_filesystem
47
+	 */
48
+	private $certif_filesystem;
49
+
50
+	/**
51
+	 * @var CertificateDataService $certif_data_service
52
+	 */
53
+	private $certif_data_service;
54
+
55
+	/**
56
+	 * @var UrlObfuscatorService $url_obfuscator_service
57
+	 */
58
+	private $url_obfuscator_service;
59
+
60
+
61
+	/**
62
+	 * Constructor for CertificatePage Request Handler
63
+	 *
64
+	 * @param ModuleService $module_service
65
+	 * @param CertificateFilesystemService $certif_filesystem
66
+	 * @param CertificateDataService $certif_data_service
67
+	 * @param UrlObfuscatorService $url_obfuscator_service
68
+	 */
69
+	public function __construct(
70
+		ModuleService $module_service,
71
+		CertificateFilesystemService $certif_filesystem,
72
+		CertificateDataService $certif_data_service,
73
+		UrlObfuscatorService $url_obfuscator_service
74
+	) {
75
+		$this->module = $module_service->findByInterface(CertificatesModule::class)->first();
76
+		$this->certif_filesystem = $certif_filesystem;
77
+		$this->certif_data_service = $certif_data_service;
78
+		$this->url_obfuscator_service = $url_obfuscator_service;
79
+	}
80
+
81
+	/**
82
+	 * {@inheritDoc}
83
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
84
+	 */
85
+	public function handle(ServerRequestInterface $request): ResponseInterface
86
+	{
87
+		if ($this->module === null) {
88
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
89
+		}
90
+
91
+		$tree = Validator::attributes($request)->tree();
92
+
93
+		$certif_path = Validator::attributes($request)->string('cid', '');
94
+		if ($certif_path !== '' && $this->url_obfuscator_service->tryDeobfuscate($certif_path)) {
95
+			$certificate = $this->certif_filesystem->certificate($tree, $certif_path);
96
+		}
97
+
98
+		if (!isset($certificate)) {
99
+			FlashMessages::addMessage('The requested certificate is not valid.');
100
+			return Registry::responseFactory()->redirect(TreePage::class, ['tree' => $tree->name()]);
101
+		}
102
+
103
+		return $this->viewResponse($this->module->name() . '::certificate-page', [
104
+			'title'                     =>  I18N::translate('Certificate - %s', $certificate->name()),
105
+			'tree'                      =>  $tree,
106
+			'module_name'               =>  $this->module->name(),
107
+			'certificate'               =>  $certificate,
108
+			'url_obfuscator_service'    =>  $this->url_obfuscator_service,
109
+			'linked_individuals'        =>  $this->certif_data_service->linkedIndividuals($certificate),
110
+			'linked_families'           =>  $this->certif_data_service->linkedFamilies($certificate)
111
+		]);
112
+	}
113 113
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
             return Registry::responseFactory()->redirect(TreePage::class, ['tree' => $tree->name()]);
101 101
         }
102 102
 
103
-        return $this->viewResponse($this->module->name() . '::certificate-page', [
103
+        return $this->viewResponse($this->module->name().'::certificate-page', [
104 104
             'title'                     =>  I18N::translate('Certificate - %s', $certificate->name()),
105 105
             'tree'                      =>  $tree,
106 106
             'module_name'               =>  $this->module->name(),
Please login to merge, or discard this patch.
app/Module/MiscExtensions/Http/RequestHandlers/AdminConfigAction.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -29,50 +29,50 @@
 block discarded – undo
29 29
  */
30 30
 class AdminConfigAction implements RequestHandlerInterface
31 31
 {
32
-    private ?MiscExtensionsModule $module;
32
+	private ?MiscExtensionsModule $module;
33 33
 
34
-    /**
35
-     * Constructor for AdminConfigPage Request Handler
36
-     *
37
-     * @param ModuleService $module_service
38
-     */
39
-    public function __construct(ModuleService $module_service)
40
-    {
41
-        $this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
42
-    }
34
+	/**
35
+	 * Constructor for AdminConfigPage Request Handler
36
+	 *
37
+	 * @param ModuleService $module_service
38
+	 */
39
+	public function __construct(ModuleService $module_service)
40
+	{
41
+		$this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first();
42
+	}
43 43
 
44
-    /**
45
-     * {@inheritDoc}
46
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
47
-     */
48
-    public function handle(ServerRequestInterface $request): ResponseInterface
49
-    {
50
-        if ($this->module === null) {
51
-            FlashMessages::addMessage(
52
-                I18N::translate('The attached module could not be found.'),
53
-                'danger'
54
-            );
55
-            return Registry::responseFactory()->redirect(AdminConfigPage::class);
56
-        }
44
+	/**
45
+	 * {@inheritDoc}
46
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
47
+	 */
48
+	public function handle(ServerRequestInterface $request): ResponseInterface
49
+	{
50
+		if ($this->module === null) {
51
+			FlashMessages::addMessage(
52
+				I18N::translate('The attached module could not be found.'),
53
+				'danger'
54
+			);
55
+			return Registry::responseFactory()->redirect(AdminConfigPage::class);
56
+		}
57 57
 
58
-        $this->module->setPreference(
59
-            'MAJ_TITLE_PREFIX',
60
-            Validator::parsedBody($request)->string('MAJ_TITLE_PREFIX', '')
61
-        );
62
-        $this->module->setPreference(
63
-            'MAJ_DISPLAY_CNIL',
64
-            Validator::parsedBody($request)->string('MAJ_DISPLAY_CNIL', '')
65
-        );
66
-        $this->module->setPreference(
67
-            'MAJ_CNIL_REFERENCE',
68
-            Validator::parsedBody($request)->string('MAJ_CNIL_REFERENCE', '')
69
-        );
58
+		$this->module->setPreference(
59
+			'MAJ_TITLE_PREFIX',
60
+			Validator::parsedBody($request)->string('MAJ_TITLE_PREFIX', '')
61
+		);
62
+		$this->module->setPreference(
63
+			'MAJ_DISPLAY_CNIL',
64
+			Validator::parsedBody($request)->string('MAJ_DISPLAY_CNIL', '')
65
+		);
66
+		$this->module->setPreference(
67
+			'MAJ_CNIL_REFERENCE',
68
+			Validator::parsedBody($request)->string('MAJ_CNIL_REFERENCE', '')
69
+		);
70 70
 
71
-        FlashMessages::addMessage(
72
-            I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()),
73
-            'success'
74
-        );
71
+		FlashMessages::addMessage(
72
+			I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()),
73
+			'success'
74
+		);
75 75
 
76
-        return Registry::responseFactory()->redirect(AdminConfigPage::class);
77
-    }
76
+		return Registry::responseFactory()->redirect(AdminConfigPage::class);
77
+	}
78 78
 }
Please login to merge, or discard this patch.
app/Module/Hooks/Http/RequestHandlers/ModulesHooksAction.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -31,58 +31,58 @@
 block discarded – undo
31 31
  */
32 32
 class ModulesHooksAction extends AbstractModuleComponentAction
33 33
 {
34
-    protected HookService $hook_service;
34
+	protected HookService $hook_service;
35 35
 
36
-    /**
37
-     * Constructor for ModulesHooksAction Request Handler
38
-     *
39
-     * @param ModuleService $module_service
40
-     * @param TreeService $tree_service
41
-     * @param HookService $hook_service
42
-     */
43
-    public function __construct(ModuleService $module_service, TreeService $tree_service, HookService $hook_service)
44
-    {
45
-        parent::__construct($module_service, $tree_service);
46
-        $this->hook_service = $hook_service;
47
-    }
36
+	/**
37
+	 * Constructor for ModulesHooksAction Request Handler
38
+	 *
39
+	 * @param ModuleService $module_service
40
+	 * @param TreeService $tree_service
41
+	 * @param HookService $hook_service
42
+	 */
43
+	public function __construct(ModuleService $module_service, TreeService $tree_service, HookService $hook_service)
44
+	{
45
+		parent::__construct($module_service, $tree_service);
46
+		$this->hook_service = $hook_service;
47
+	}
48 48
 
49
-    /**
50
-     * {@inheritDoc}
51
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
52
-     */
53
-    public function handle(ServerRequestInterface $request): ResponseInterface
54
-    {
55
-        $hook_name = Validator::attributes($request)->string('hook_name', '');
56
-        $hook_collector = $this->hook_service->find($hook_name, true);
57
-        if ($hook_collector === null) {
58
-            FlashMessages::addMessage(I18N::translate('The hook with name “%s” does not exist.', $hook_name), 'danger');
59
-            return Registry::responseFactory()->redirect(AdminConfigPage::class);
60
-        }
49
+	/**
50
+	 * {@inheritDoc}
51
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
52
+	 */
53
+	public function handle(ServerRequestInterface $request): ResponseInterface
54
+	{
55
+		$hook_name = Validator::attributes($request)->string('hook_name', '');
56
+		$hook_collector = $this->hook_service->find($hook_name, true);
57
+		if ($hook_collector === null) {
58
+			FlashMessages::addMessage(I18N::translate('The hook with name “%s” does not exist.', $hook_name), 'danger');
59
+			return Registry::responseFactory()->redirect(AdminConfigPage::class);
60
+		}
61 61
 
62
-        foreach ($hook_collector->hooks() as $hook) {
63
-            $this->updateStatus(get_class($hook->module()), $request);
64
-        }
62
+		foreach ($hook_collector->hooks() as $hook) {
63
+			$this->updateStatus(get_class($hook->module()), $request);
64
+		}
65 65
 
66
-        $this->updateHookOrder($hook_collector, $request);
66
+		$this->updateHookOrder($hook_collector, $request);
67 67
 
68
-        FlashMessages::addMessage(I18N::translate('The hook preferences have been updated.'), 'success');
68
+		FlashMessages::addMessage(I18N::translate('The hook preferences have been updated.'), 'success');
69 69
 
70
-        return Registry::responseFactory()->redirect(ModulesHooksPage::class, ['hook_name' => $hook_name]);
71
-    }
70
+		return Registry::responseFactory()->redirect(ModulesHooksPage::class, ['hook_name' => $hook_name]);
71
+	}
72 72
 
73
-    /**
74
-     * Update the order of modules for a hook interface.
75
-     *
76
-     * @param HookCollectorInterface $hook_collector
77
-     * @param ServerRequestInterface $request
78
-     */
79
-    protected function updateHookOrder(HookCollectorInterface $hook_collector, ServerRequestInterface $request): void
80
-    {
81
-        $order = Validator::parsedBody($request)->array('order');
82
-        $order = array_flip($order);
73
+	/**
74
+	 * Update the order of modules for a hook interface.
75
+	 *
76
+	 * @param HookCollectorInterface $hook_collector
77
+	 * @param ServerRequestInterface $request
78
+	 */
79
+	protected function updateHookOrder(HookCollectorInterface $hook_collector, ServerRequestInterface $request): void
80
+	{
81
+		$order = Validator::parsedBody($request)->array('order');
82
+		$order = array_flip($order);
83 83
 
84
-        foreach ($hook_collector->hooks() as $hook) {
85
-            $this->hook_service->updateOrder($hook_collector, $hook->module(), $order[$hook->module()->name()] ?? 0);
86
-        }
87
-    }
84
+		foreach ($hook_collector->hooks() as $hook) {
85
+			$this->hook_service->updateOrder($hook_collector, $hook->module(), $order[$hook->module()->name()] ?? 0);
86
+		}
87
+	}
88 88
 }
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/SosaComputeAction.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -31,54 +31,54 @@
 block discarded – undo
31 31
  */
32 32
 class SosaComputeAction implements RequestHandlerInterface
33 33
 {
34
-    private UserService $user_service;
34
+	private UserService $user_service;
35 35
 
36
-    /**
37
-     * Constructor for SosaConfigAction Request Handler
38
-     *
39
-     * @param UserService $user_service
40
-     */
41
-    public function __construct(UserService $user_service)
42
-    {
43
-        $this->user_service = $user_service;
44
-    }
36
+	/**
37
+	 * Constructor for SosaConfigAction Request Handler
38
+	 *
39
+	 * @param UserService $user_service
40
+	 */
41
+	public function __construct(UserService $user_service)
42
+	{
43
+		$this->user_service = $user_service;
44
+	}
45 45
 
46
-    /**
47
-     * {@inheritDoc}
48
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
49
-     */
50
-    public function handle(ServerRequestInterface $request): ResponseInterface
51
-    {
52
-        $tree = Validator::attributes($request)->tree();
46
+	/**
47
+	 * {@inheritDoc}
48
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
49
+	 */
50
+	public function handle(ServerRequestInterface $request): ResponseInterface
51
+	{
52
+		$tree = Validator::attributes($request)->tree();
53 53
 
54
-        $user_id = Validator::parsedBody($request)->integer('user_id', Auth::id() ?? 0);
55
-        $partial_from = Validator::parsedBody($request)->isXref()->string('partial_from', '');
54
+		$user_id = Validator::parsedBody($request)->integer('user_id', Auth::id() ?? 0);
55
+		$partial_from = Validator::parsedBody($request)->isXref()->string('partial_from', '');
56 56
 
57
-        if (($user_id === -1 && Auth::isManager($tree)) || Auth::id() === $user_id) {
58
-            $user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id);
57
+		if (($user_id === -1 && Auth::isManager($tree)) || Auth::id() === $user_id) {
58
+			$user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id);
59 59
 
60
-            /** @var SosaCalculatorService $sosa_calc_service */
61
-            $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]);
60
+			/** @var SosaCalculatorService $sosa_calc_service */
61
+			$sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]);
62 62
 
63
-            if (
64
-                $partial_from !== '' &&
65
-                ($sosa_from = Registry::individualFactory()->make($partial_from, $tree)) !== null
66
-            ) {
67
-                $res = $sosa_calc_service->computeFromIndividual($sosa_from);
68
-            } else {
69
-                $res = $sosa_calc_service->computeAll();
70
-            }
63
+			if (
64
+				$partial_from !== '' &&
65
+				($sosa_from = Registry::individualFactory()->make($partial_from, $tree)) !== null
66
+			) {
67
+				$res = $sosa_calc_service->computeFromIndividual($sosa_from);
68
+			} else {
69
+				$res = $sosa_calc_service->computeAll();
70
+			}
71 71
 
72
-            return $res ?
73
-                Registry::responseFactory()->response() :
74
-                Registry::responseFactory()->response(
75
-                    I18N::translate('An error occurred while computing Sosa ancestors.'),
76
-                    StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR
77
-                );
78
-        }
79
-        return Registry::responseFactory()->response(
80
-            I18N::translate('You do not have permission to modify the user.'),
81
-            StatusCodeInterface::STATUS_FORBIDDEN
82
-        );
83
-    }
72
+			return $res ?
73
+				Registry::responseFactory()->response() :
74
+				Registry::responseFactory()->response(
75
+					I18N::translate('An error occurred while computing Sosa ancestors.'),
76
+					StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR
77
+				);
78
+		}
79
+		return Registry::responseFactory()->response(
80
+			I18N::translate('You do not have permission to modify the user.'),
81
+			StatusCodeInterface::STATUS_FORBIDDEN
82
+		);
83
+	}
84 84
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             $user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id);
59 59
 
60 60
             /** @var SosaCalculatorService $sosa_calc_service */
61
-            $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]);
61
+            $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, ['tree' => $tree, 'user' => $user]);
62 62
 
63 63
             if (
64 64
                 $partial_from !== '' &&
@@ -70,8 +70,7 @@  discard block
 block discarded – undo
70 70
             }
71 71
 
72 72
             return $res ?
73
-                Registry::responseFactory()->response() :
74
-                Registry::responseFactory()->response(
73
+                Registry::responseFactory()->response() : Registry::responseFactory()->response(
75 74
                     I18N::translate('An error occurred while computing Sosa ancestors.'),
76 75
                     StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR
77 76
                 );
Please login to merge, or discard this patch.
app/Module/Sosa/Http/RequestHandlers/SosaConfigAction.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -31,51 +31,51 @@
 block discarded – undo
31 31
  */
32 32
 class SosaConfigAction implements RequestHandlerInterface
33 33
 {
34
-    private UserService $user_service;
35
-    private SosaRecordsService $sosa_record_service;
34
+	private UserService $user_service;
35
+	private SosaRecordsService $sosa_record_service;
36 36
 
37
-    /**
38
-     * Constructor for SosaConfigAction Request Handler
39
-     *
40
-     * @param UserService $user_service
41
-     * @param SosaRecordsService $sosa_records_service
42
-     */
43
-    public function __construct(UserService $user_service, SosaRecordsService $sosa_records_service)
44
-    {
45
-        $this->user_service = $user_service;
46
-        $this->sosa_record_service = $sosa_records_service;
47
-    }
37
+	/**
38
+	 * Constructor for SosaConfigAction Request Handler
39
+	 *
40
+	 * @param UserService $user_service
41
+	 * @param SosaRecordsService $sosa_records_service
42
+	 */
43
+	public function __construct(UserService $user_service, SosaRecordsService $sosa_records_service)
44
+	{
45
+		$this->user_service = $user_service;
46
+		$this->sosa_record_service = $sosa_records_service;
47
+	}
48 48
 
49
-    /**
50
-     * {@inheritDoc}
51
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
52
-     */
53
-    public function handle(ServerRequestInterface $request): ResponseInterface
54
-    {
55
-        $tree = Validator::attributes($request)->tree();
49
+	/**
50
+	 * {@inheritDoc}
51
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
52
+	 */
53
+	public function handle(ServerRequestInterface $request): ResponseInterface
54
+	{
55
+		$tree = Validator::attributes($request)->tree();
56 56
 
57
-        $user_id = Validator::parsedBody($request)->integer('sosa-userid', -1);
58
-        $root_id = Validator::parsedBody($request)->isXref()->string('sosa-rootid', '');
59
-        $max_gen = Validator::parsedBody($request)->integer(
60
-            'sosa-maxgen',
61
-            $this->sosa_record_service->maxSystemGenerations()
62
-        );
57
+		$user_id = Validator::parsedBody($request)->integer('sosa-userid', -1);
58
+		$root_id = Validator::parsedBody($request)->isXref()->string('sosa-rootid', '');
59
+		$max_gen = Validator::parsedBody($request)->integer(
60
+			'sosa-maxgen',
61
+			$this->sosa_record_service->maxSystemGenerations()
62
+		);
63 63
 
64
-        if (Auth::id() === $user_id || ($user_id === -1 && Auth::isManager($tree))) {
65
-            $user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id);
66
-            if ($user !== null && ($root_indi = Registry::individualFactory()->make($root_id, $tree)) !== null) {
67
-                $tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref());
68
-                $tree->setUserPreference($user, 'MAJ_SOSA_MAX_GEN', (string) $max_gen);
69
-                FlashMessages::addMessage(I18N::translate('The root individual has been updated.'));
70
-                return Registry::responseFactory()->redirect(SosaConfig::class, [
71
-                    'tree' => $tree->name(),
72
-                    'compute' => 'yes',
73
-                    'user_id' => $user_id
74
-                ]);
75
-            }
76
-        }
64
+		if (Auth::id() === $user_id || ($user_id === -1 && Auth::isManager($tree))) {
65
+			$user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id);
66
+			if ($user !== null && ($root_indi = Registry::individualFactory()->make($root_id, $tree)) !== null) {
67
+				$tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref());
68
+				$tree->setUserPreference($user, 'MAJ_SOSA_MAX_GEN', (string) $max_gen);
69
+				FlashMessages::addMessage(I18N::translate('The root individual has been updated.'));
70
+				return Registry::responseFactory()->redirect(SosaConfig::class, [
71
+					'tree' => $tree->name(),
72
+					'compute' => 'yes',
73
+					'user_id' => $user_id
74
+				]);
75
+			}
76
+		}
77 77
 
78
-        FlashMessages::addMessage(I18N::translate('The root individual could not be updated.'), 'danger');
79
-        return Registry::responseFactory()->redirect(SosaConfig::class, ['tree' => $tree->name()]);
80
-    }
78
+		FlashMessages::addMessage(I18N::translate('The root individual could not be updated.'), 'danger');
79
+		return Registry::responseFactory()->redirect(SosaConfig::class, ['tree' => $tree->name()]);
80
+	}
81 81
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
             $user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id);
66 66
             if ($user !== null && ($root_indi = Registry::individualFactory()->make($root_id, $tree)) !== null) {
67 67
                 $tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref());
68
-                $tree->setUserPreference($user, 'MAJ_SOSA_MAX_GEN', (string) $max_gen);
68
+                $tree->setUserPreference($user, 'MAJ_SOSA_MAX_GEN', (string)$max_gen);
69 69
                 FlashMessages::addMessage(I18N::translate('The root individual has been updated.'));
70 70
                 return Registry::responseFactory()->redirect(SosaConfig::class, [
71 71
                     'tree' => $tree->name(),
Please login to merge, or discard this patch.
app/Common/GeoDispersion/Config/GenericPlaceMapperConfig.php 2 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -25,105 +25,105 @@
 block discarded – undo
25 25
  */
26 26
 class GenericPlaceMapperConfig implements PlaceMapperConfigInterface
27 27
 {
28
-    /** @var array<string, mixed> $config */
29
-    private array $config = [];
28
+	/** @var array<string, mixed> $config */
29
+	private array $config = [];
30 30
 
31
-    /**
32
-     * Get the generic mapper's config
33
-     *
34
-     * @return array<string, mixed>
35
-     */
36
-    public function config(): array
37
-    {
38
-        return $this->config;
39
-    }
31
+	/**
32
+	 * Get the generic mapper's config
33
+	 *
34
+	 * @return array<string, mixed>
35
+	 */
36
+	public function config(): array
37
+	{
38
+		return $this->config;
39
+	}
40 40
 
41
-    /**
42
-     * Set the generic mapper's config
43
-     *
44
-     * @param array<string, mixed> $config
45
-     * @return $this
46
-     */
47
-    public function setConfig(array $config): self
48
-    {
49
-        $this->config = $config;
50
-        return $this;
51
-    }
41
+	/**
42
+	 * Set the generic mapper's config
43
+	 *
44
+	 * @param array<string, mixed> $config
45
+	 * @return $this
46
+	 */
47
+	public function setConfig(array $config): self
48
+	{
49
+		$this->config = $config;
50
+		return $this;
51
+	}
52 52
 
53
-    /**
54
-     * {@inheritDoc}
55
-     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::get()
56
-     */
57
-    public function get(string $key, $default = null)
58
-    {
59
-        return $this->config[$key] ?? $default;
60
-    }
53
+	/**
54
+	 * {@inheritDoc}
55
+	 * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::get()
56
+	 */
57
+	public function get(string $key, $default = null)
58
+	{
59
+		return $this->config[$key] ?? $default;
60
+	}
61 61
 
62
-    /**
63
-     * {@inheritDoc}
64
-     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::has()
65
-     */
66
-    public function has(string $key): bool
67
-    {
68
-        return key_exists($key, $this->config);
69
-    }
62
+	/**
63
+	 * {@inheritDoc}
64
+	 * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::has()
65
+	 */
66
+	public function has(string $key): bool
67
+	{
68
+		return key_exists($key, $this->config);
69
+	}
70 70
 
71
-    /**
72
-     * {@inheritDoc}
73
-     * @see \JsonSerializable::jsonSerialize()
74
-     */
75
-    public function jsonSerialize()
76
-    {
77
-        return [
78
-            'class'     =>  get_class($this),
79
-            'config'    =>  $this->jsonSerializeConfig()
80
-        ];
81
-    }
71
+	/**
72
+	 * {@inheritDoc}
73
+	 * @see \JsonSerializable::jsonSerialize()
74
+	 */
75
+	public function jsonSerialize()
76
+	{
77
+		return [
78
+			'class'     =>  get_class($this),
79
+			'config'    =>  $this->jsonSerializeConfig()
80
+		];
81
+	}
82 82
 
83
-    /**
84
-     * Returns a representation of the mapper config compatible with Json serialisation
85
-     *
86
-     * @return mixed
87
-     */
88
-    public function jsonSerializeConfig()
89
-    {
90
-        return $this->config;
91
-    }
83
+	/**
84
+	 * Returns a representation of the mapper config compatible with Json serialisation
85
+	 *
86
+	 * @return mixed
87
+	 */
88
+	public function jsonSerializeConfig()
89
+	{
90
+		return $this->config;
91
+	}
92 92
 
93
-    /**
94
-     * {@inheritDoc}
95
-     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::jsonDeserialize()
96
-     *
97
-     * @param mixed $config
98
-     * @return $this
99
-     */
100
-    public function jsonDeserialize($config): self
101
-    {
102
-        if (is_string($config)) {
103
-            return $this->jsonDeserialize((array) json_decode($config));
104
-        }
105
-        if (is_array($config)) {
106
-            return $this->setConfig($config);
107
-        }
108
-        return $this;
109
-    }
93
+	/**
94
+	 * {@inheritDoc}
95
+	 * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::jsonDeserialize()
96
+	 *
97
+	 * @param mixed $config
98
+	 * @return $this
99
+	 */
100
+	public function jsonDeserialize($config): self
101
+	{
102
+		if (is_string($config)) {
103
+			return $this->jsonDeserialize((array) json_decode($config));
104
+		}
105
+		if (is_array($config)) {
106
+			return $this->setConfig($config);
107
+		}
108
+		return $this;
109
+	}
110 110
 
111
-    /**
112
-     * {@inheritDoc}
113
-     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::configContent()
114
-     */
115
-    public function configContent(ModuleInterface $module, Tree $tree): string
116
-    {
117
-        return '';
118
-    }
111
+	/**
112
+	 * {@inheritDoc}
113
+	 * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::configContent()
114
+	 */
115
+	public function configContent(ModuleInterface $module, Tree $tree): string
116
+	{
117
+		return '';
118
+	}
119 119
 
120
-    /**
121
-     * {@inheritDoc}
122
-     * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::withConfigUpdate()
123
-     * @return $this
124
-     */
125
-    public function withConfigUpdate(ServerRequestInterface $request): self
126
-    {
127
-        return $this;
128
-    }
120
+	/**
121
+	 * {@inheritDoc}
122
+	 * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface::withConfigUpdate()
123
+	 * @return $this
124
+	 */
125
+	public function withConfigUpdate(ServerRequestInterface $request): self
126
+	{
127
+		return $this;
128
+	}
129 129
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
     public function jsonDeserialize($config): self
101 101
     {
102 102
         if (is_string($config)) {
103
-            return $this->jsonDeserialize((array) json_decode($config));
103
+            return $this->jsonDeserialize((array)json_decode($config));
104 104
         }
105 105
         if (is_array($config)) {
106 106
             return $this->setConfig($config);
Please login to merge, or discard this patch.