1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (C) 2022-2023 Rafael San José Tovar <[email protected]> |
4
|
|
|
* |
5
|
|
|
* This program is free software; you can redistribute it and/or modify |
6
|
|
|
* it under the terms of the GNU General Public License as published by |
7
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
8
|
|
|
* (at your option) any later version. |
9
|
|
|
* |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU General Public License |
16
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Alxarafe\Models; |
20
|
|
|
|
21
|
|
|
use Alxarafe\Core\Base\Table; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class User |
25
|
|
|
* |
26
|
|
|
* @package Modules\Main\Models |
27
|
|
|
*/ |
28
|
|
|
class User extends Table |
29
|
|
|
{ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* User constructor. |
33
|
|
|
*/ |
34
|
|
|
public function __construct() |
35
|
|
|
{ |
36
|
|
|
parent::__construct('users', ['create' => true]); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* TODO: Undocumented |
41
|
|
|
*/ |
42
|
|
|
public function getFields(): array |
43
|
|
|
{ |
44
|
|
|
return [ |
45
|
|
|
'rowid' => [ |
46
|
|
|
'label' => 'id', |
47
|
|
|
'type' => 'int', |
48
|
|
|
'extra' => 'auto_increment', // It is assumed to be the primary key |
49
|
|
|
], |
50
|
|
|
'login' => [ |
51
|
|
|
'label' => 'username', |
52
|
|
|
'type' => 'varchar', |
53
|
|
|
], |
54
|
|
|
'personal_email' => [ |
55
|
|
|
'label' => 'email', |
56
|
|
|
'type' => 'varchar', |
57
|
|
|
], |
58
|
|
|
'pass_crypted' => [ |
59
|
|
|
'label' => 'password', |
60
|
|
|
'type' => 'varchar', |
61
|
|
|
], |
62
|
|
|
'datec' => [ |
63
|
|
|
'label' => 'Fecha de registro', |
64
|
|
|
'type' => 'timestamp', |
65
|
|
|
'default' => 'CURRENT_TIMESTAMP', |
66
|
|
|
], |
67
|
|
|
'statut' => [ |
68
|
|
|
'label' => 'Activo', |
69
|
|
|
'type' => 'tinyint', |
70
|
|
|
'null' => 'YES', |
71
|
|
|
'default' => 0, |
72
|
|
|
], |
73
|
|
|
]; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* TODO: Undocumented |
78
|
|
|
* |
79
|
|
|
* @return array |
80
|
|
|
*/ |
81
|
|
|
public function getKeys(): array |
82
|
|
|
{ |
83
|
|
|
return [ |
84
|
|
|
'user_name' => [ |
85
|
|
|
'INDEX' => 'username', |
86
|
|
|
], |
87
|
|
|
]; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* TODO: Undocumented |
92
|
|
|
* |
93
|
|
|
* @return array |
94
|
|
|
*/ |
95
|
|
|
public function getDefaultValues(): array |
96
|
|
|
{ |
97
|
|
|
return [ |
98
|
|
|
[ |
99
|
|
|
'id' => 1, |
100
|
|
|
'username' => 'admin', |
101
|
|
|
'email' => '[email protected]', |
102
|
|
|
'password' => md5('admin'), |
103
|
|
|
'active' => 1, |
104
|
|
|
], |
105
|
|
|
[ |
106
|
|
|
'id' => 2, |
107
|
|
|
'username' => 'user', |
108
|
|
|
'email' => '[email protected]', |
109
|
|
|
'password' => md5('user'), |
110
|
|
|
'active' => 1, |
111
|
|
|
], |
112
|
|
|
]; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|