1 <?php
2
3 /*
4 * This file is part of the Icybee package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
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 Icybee\Modules\Views\View;
15
16 use ICanBoogie\Exception;
17 use ICanBoogie\I18n;
18 use ICanBoogie\Operation;
19
20 use Brickrouge\Button;
21 use Brickrouge\Element;
22 use Brickrouge\Form;
23
24 class Module extends \Icybee\Module
25 {
26 const OPERATION_LOGIN = 'login';
27 const OPERATION_LOGOUT = 'logout';
28 const OPERATION_ACTIVATE = 'activate';
29 const OPERATION_DEACTIVATE = 'deactivate';
30 const OPERATION_IS_UNIQUE = 'is_unique';
31
32 static $config_default = [
33
34 'notifies' => [
35
36 /*
37 'password' => [
38
39 'subject' => 'Vos paramètres de connexion à Icybee',
40 'from' => 'no-reply@example.com',
41 'template' => 'Bonjour,
42
43 Voici vos paramètres de connexion au système de gestion de contenu Icybee :
44
45 Identifiant : "#{@username}" ou "#{@email}"
46 Mot de passe : "#{@password}"
47
48 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.
49
50 Cordialement'
51 ]
52 */
53
54 ]
55
56 ];
57
58 protected function resolve_primary_model_tags($tags)
59 {
60 return parent::resolve_model_tags($tags, 'primary') + [
61
62 Model::T_CONSTRUCTOR => $this->id
63
64 ];
65 }
66
67 protected function block_connect()
68 {
69 global $core;
70
71 $core->document->css->add(DIR . 'public/authenticate.css');
72
73 return new \Icybee\Modules\Users\LoginComboElement;
74 }
75
76 protected function block_logout()
77 {
78 return new Form([
79
80 Form::HIDDENS => [
81
82 Operation::NAME => self::OPERATION_LOGOUT,
83 Operation::DESTINATION => $this->id
84
85 ],
86
87 Element::CHILDREN => [
88
89 new Button('logout', [ 'type' => 'submit' ])
90
91 ]
92
93 ]);
94 }
95
96 protected function block_profile()
97 {
98 global $core;
99
100 $core->document->page_title = I18n\t('My profile');
101
102 $module = $this;
103 $user = $core->user;
104 $constructor = $user->constructor;
105
106 if ($constructor != $this->id)
107 {
108 $module = $core->modules[$user->constructor];
109 }
110
111 return $module->getBlock('edit', $user->uid);
112 }
113 }