1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* sysPass |
4
|
|
|
* |
5
|
|
|
* @author nuxsmin |
6
|
|
|
* @link https://syspass.org |
7
|
|
|
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org |
8
|
|
|
* |
9
|
|
|
* This file is part of sysPass. |
10
|
|
|
* |
11
|
|
|
* sysPass is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU General Public License as published by |
13
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
14
|
|
|
* (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* sysPass is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU General Public License for more details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU General Public License |
22
|
|
|
* along with sysPass. If not, see <http://www.gnu.org/licenses/>. |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace SP\DataModel; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class UserPreferencesData |
29
|
|
|
* |
30
|
|
|
* @package SP\DataModel |
31
|
|
|
*/ |
32
|
|
|
class UserPreferencesData |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @var int |
36
|
|
|
*/ |
37
|
|
|
public $user_id = 0; |
38
|
|
|
/** |
39
|
|
|
* Lenguaje del usuario |
40
|
|
|
* |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
public $lang = ''; |
44
|
|
|
/** |
45
|
|
|
* Tema del usuario |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
public $theme = ''; |
50
|
|
|
/** |
51
|
|
|
* @var int |
52
|
|
|
*/ |
53
|
|
|
public $resultsPerPage = 0; |
54
|
|
|
/** |
55
|
|
|
* @var bool |
56
|
|
|
*/ |
57
|
|
|
public $accountLink; |
58
|
|
|
/** |
59
|
|
|
* @var bool |
60
|
|
|
*/ |
61
|
|
|
public $sortViews = false; |
62
|
|
|
/** |
63
|
|
|
* @var bool |
64
|
|
|
*/ |
65
|
|
|
public $topNavbar = false; |
66
|
|
|
/** |
67
|
|
|
* @var bool |
68
|
|
|
*/ |
69
|
|
|
public $optionalActions = false; |
70
|
|
|
/** |
71
|
|
|
* @var bool |
72
|
|
|
*/ |
73
|
|
|
public $resultsAsCards = false; |
74
|
|
|
/** |
75
|
|
|
* @var bool |
76
|
|
|
*/ |
77
|
|
|
public $checkNotifications = true; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
|
|
public function getLang() |
83
|
|
|
{ |
84
|
|
|
return $this->lang; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param string $lang |
89
|
|
|
*/ |
90
|
|
|
public function setLang($lang) |
91
|
|
|
{ |
92
|
|
|
$this->lang = $lang; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return string |
97
|
|
|
*/ |
98
|
|
|
public function getTheme() |
99
|
|
|
{ |
100
|
|
|
return $this->theme; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param string $theme |
105
|
|
|
*/ |
106
|
|
|
public function setTheme($theme) |
107
|
|
|
{ |
108
|
|
|
$this->theme = $theme; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return int |
113
|
|
|
*/ |
114
|
|
|
public function getResultsPerPage() |
115
|
|
|
{ |
116
|
|
|
return $this->resultsPerPage; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param int $resultsPerPage |
121
|
|
|
*/ |
122
|
|
|
public function setResultsPerPage($resultsPerPage) |
123
|
|
|
{ |
124
|
|
|
$this->resultsPerPage = $resultsPerPage; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return boolean |
129
|
|
|
*/ |
130
|
|
|
public function isAccountLink() |
131
|
|
|
{ |
132
|
|
|
return $this->accountLink; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param boolean $accountLink |
137
|
|
|
*/ |
138
|
|
|
public function setAccountLink($accountLink) |
139
|
|
|
{ |
140
|
|
|
$this->accountLink = $accountLink; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @return boolean |
145
|
|
|
*/ |
146
|
|
|
public function isSortViews() |
147
|
|
|
{ |
148
|
|
|
return $this->sortViews; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @param boolean $sortViews |
153
|
|
|
*/ |
154
|
|
|
public function setSortViews($sortViews) |
155
|
|
|
{ |
156
|
|
|
$this->sortViews = $sortViews; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return boolean |
161
|
|
|
*/ |
162
|
|
|
public function isTopNavbar() |
163
|
|
|
{ |
164
|
|
|
return $this->topNavbar; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @param boolean $topNavbar |
169
|
|
|
*/ |
170
|
|
|
public function setTopNavbar($topNavbar) |
171
|
|
|
{ |
172
|
|
|
$this->topNavbar = $topNavbar; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @return boolean |
177
|
|
|
*/ |
178
|
|
|
public function isOptionalActions() |
179
|
|
|
{ |
180
|
|
|
return $this->optionalActions; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @param boolean $optionalActions |
185
|
|
|
*/ |
186
|
|
|
public function setOptionalActions($optionalActions) |
187
|
|
|
{ |
188
|
|
|
$this->optionalActions = $optionalActions; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @return int |
193
|
|
|
*/ |
194
|
|
|
public function getUserId() |
195
|
|
|
{ |
196
|
|
|
return $this->user_id; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @param int $user_id |
201
|
|
|
*/ |
202
|
|
|
public function setUserId($user_id) |
203
|
|
|
{ |
204
|
|
|
$this->user_id = $user_id; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* unserialize() checks for the presence of a function with the magic name __wakeup. |
209
|
|
|
* If present, this function can reconstruct any resources that the object may have. |
210
|
|
|
* The intended use of __wakeup is to reestablish any database connections that may have been lost during |
211
|
|
|
* serialization and perform other reinitialization tasks. |
212
|
|
|
* |
213
|
|
|
* @return void |
214
|
|
|
* @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep |
215
|
|
|
*/ |
216
|
|
|
public function __wakeup() |
217
|
|
|
{ |
218
|
|
|
// Para realizar la conversión de nombre de propiedades que empiezan por _ |
219
|
|
|
foreach (get_object_vars($this) as $name => $value) { |
220
|
|
|
if (strpos($name, '_') === 0) { |
221
|
|
|
$newName = substr($name, 1); |
222
|
|
|
$this->$newName = $value; |
223
|
|
|
|
224
|
|
|
// Borrar la variable anterior |
225
|
|
|
unset($this->$name); |
226
|
|
|
} |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @return bool |
232
|
|
|
*/ |
233
|
|
|
public function isResultsAsCards() |
234
|
|
|
{ |
235
|
|
|
return $this->resultsAsCards; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @param bool $resultsAsCards |
240
|
|
|
*/ |
241
|
|
|
public function setResultsAsCards($resultsAsCards) |
242
|
|
|
{ |
243
|
|
|
$this->resultsAsCards = $resultsAsCards; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @return bool |
248
|
|
|
*/ |
249
|
|
|
public function isCheckNotifications(): bool |
250
|
|
|
{ |
251
|
|
|
return $this->checkNotifications; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* @param bool $checkNotifications |
256
|
|
|
*/ |
257
|
|
|
public function setCheckNotifications(bool $checkNotifications) |
258
|
|
|
{ |
259
|
|
|
$this->checkNotifications = $checkNotifications; |
260
|
|
|
} |
261
|
|
|
} |