Module   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 5
c 7
b 0
f 0
lcom 1
cbo 4
dl 0
loc 87
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve_primary_model_tags() 0 8 1
A block_connect() 0 6 1
A block_logout() 0 19 1
A block_profile() 0 16 2
1
<?php
2
3
/*
4
 * This file is part of the Icybee package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Icybee\Modules\Users;
13
14
use ICanBoogie\I18n;
15
use ICanBoogie\Operation;
16
17
use Brickrouge\Button;
18
use Brickrouge\Element;
19
use Brickrouge\Form;
20
21
class Module extends \Icybee\Module
22
{
23
	const OPERATION_LOGIN = 'login';
24
	const OPERATION_LOGOUT = 'logout';
25
	const OPERATION_ACTIVATE = 'activate';
26
	const OPERATION_DEACTIVATE = 'deactivate';
27
	const OPERATION_IS_UNIQUE = 'is_unique';
28
29
	static public $config_default = [
30
31
		'notifies' => [
32
33
			/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
			'password' => [
35
36
				'subject' => 'Vos paramètres de connexion à Icybee',
37
				'from' => '[email protected]',
38
				'template' => 'Bonjour,
39
40
Voici vos paramètres de connexion au système de gestion de contenu Icybee :
41
42
Identifiant : "#{@username}" ou "#{@email}"
43
Mot de passe : "#{@password}"
44
45
Une fois connecté vous pourrez modifier votre mot de passe. Pour cela cliquez sur votre nom dans la barre de titre et éditez votre profil.
46
47
Cordialement'
48
			]
49
			*/
50
51
		]
52
53
	];
54
55
	protected function resolve_primary_model_tags($tags)
56
	{
57
		return parent::resolve_model_tags($tags, 'primary') + [
58
59
			UserModel::CONSTRUCTOR => $this->id
60
61
		];
62
	}
63
64
	protected function block_connect()
65
	{
66
		$this->app->document->css->add(DIR . 'public/authenticate.css');
67
68
		return new \Icybee\Modules\Users\LoginComboElement;
69
	}
70
71
	protected function block_logout()
72
	{
73
		return new Form([
74
75
			Form::HIDDENS => [
76
77
				Operation::NAME => self::OPERATION_LOGOUT,
78
				Operation::DESTINATION => $this->id
79
80
			],
81
82
			Element::CHILDREN => [
83
84
				new Button('logout', [ 'type' => 'submit' ])
85
86
			]
87
88
		]);
89
	}
90
91
	protected function block_profile()
92
	{
93
		$app = $this->app;
94
		$app->document->page_title = $app->translate('My profile');
95
96
		$module = $this;
97
		$user = $app->user;
98
		$constructor = $user->constructor;
99
100
		if ($constructor != $this->id)
101
		{
102
			$module = $app->modules[$user->constructor];
103
		}
104
105
		return $module->getBlock('edit', $user->uid);
106
	}
107
}
108