Issues (493)

lib/SP/DataModel/AccountData.php (2 issues)

1
<?php
2
/**
3
 * sysPass
4
 *
5
 * @author    nuxsmin
6
 * @link      https://syspass.org
7
 * @copyright 2012-2019, 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
defined('APP_ROOT') || die();
28
29
use JsonSerializable;
30
use SP\Http\Json;
31
32
/**
33
 * Class AccountData
34
 *
35
 * @package SP\Account
36
 */
37
class AccountData extends DataModelBase implements JsonSerializable, DataModelInterface
38
{
39
    /**
40
     * @var int Id de la cuenta.
41
     */
42
    public $id = 0;
43
    /**
44
     * @var int Id del usuario principal de la cuenta.
45
     */
46
    public $userId = 0;
47
    /**
48
     * @var int Id del grupo principal de la cuenta.
49
     */
50
    public $userGroupId = 0;
51
    /**
52
     * @var int Id del usuario que editó la cuenta.
53
     */
54
    public $userEditId = 0;
55
    /**
56
     * @var string El nombre de la cuenta.
57
     */
58
    public $name = '';
59
    /**
60
     * @var int Id del cliente de la cuenta.
61
     */
62
    public $clientId = 0;
63
    /**
64
     * @var int Id de la categoría de la cuenta.
65
     */
66
    public $categoryId = 0;
67
    /**
68
     * @var string El nombre de usuario de la cuenta.
69
     */
70
    public $login = '';
71
    /**
72
     * @var string La URL de la cuenta.
73
     */
74
    public $url = '';
75
    /**
76
     * @var string La clave de la cuenta.
77
     */
78
    public $pass = '';
79
    /**
80
     * @var string La clave de encriptación de la cuenta
81
     */
82
    public $key = '';
83
    /**
84
     * @var string Las nosta de la cuenta.
85
     */
86
    public $notes = '';
87
    /**
88
     * @var bool Si se permite la edición por los usuarios secundarios.
89
     */
90
    public $otherUserEdit = false;
91
    /**
92
     * @var bool Si se permita la edición por los grupos secundarios.
93
     */
94
    public $otherUserGroupEdit = false;
95
    /**
96
     * @var int
97
     */
98
    public $dateAdd = 0;
99
    /**
100
     * @var int
101
     */
102
    public $dateEdit = 0;
103
    /**
104
     * @var int
105
     */
106
    public $countView = 0;
107
    /**
108
     * @var int
109
     */
110
    public $countDecrypt = 0;
111
    /**
112
     * @var int
113
     */
114
    public $isPrivate = 0;
115
    /**
116
     * @var int
117
     */
118
    public $isPrivateGroup = 0;
119
    /**
120
     * @var int
121
     */
122
    public $passDate = 0;
123
    /**
124
     * @var int
125
     */
126
    public $passDateChange = 0;
127
    /**
128
     * @var int
129
     */
130
    public $parentId = 0;
131
132
133
    /**
134
     * AccountData constructor.
135
     *
136
     * @param int $accountId
137
     */
138
    public function __construct($accountId = 0)
139
    {
140
        $this->id = (int)$accountId;
141
    }
142
143
    /**
144
     * @return int
145
     */
146
    public function getDateAdd()
147
    {
148
        return $this->dateAdd;
149
    }
150
151
    /**
152
     * @param int $dateAdd
153
     */
154
    public function setDateAdd($dateAdd)
155
    {
156
        $this->dateAdd = $dateAdd;
157
    }
158
159
    /**
160
     * @return int
161
     */
162
    public function getDateEdit()
163
    {
164
        return $this->dateEdit;
165
    }
166
167
    /**
168
     * @param int $dateEdit
169
     */
170
    public function setDateEdit($dateEdit)
171
    {
172
        $this->dateEdit = $dateEdit;
173
    }
174
175
    /**
176
     * @return int
177
     */
178
    public function getUserEditId()
179
    {
180
        return (int)$this->userEditId;
181
    }
182
183
    /**
184
     * @param int $userEditId
185
     */
186
    public function setUserEditId($userEditId)
187
    {
188
        $this->userEditId = (int)$userEditId;
189
    }
190
191
    /**
192
     * @return string
193
     */
194
    public function getPass()
195
    {
196
        return $this->pass;
197
    }
198
199
    /**
200
     * @param string $pass
201
     */
202
    public function setPass($pass)
203
    {
204
        $this->pass = $pass;
205
    }
206
207
    /**
208
     * @return string
209
     */
210
    public function getKey()
211
    {
212
        return $this->key;
213
    }
214
215
    /**
216
     * @param string $key
217
     */
218
    public function setKey($key)
219
    {
220
        $this->key = $key;
221
    }
222
223
    /**
224
     * @return int|null
225
     */
226
    public function getId()
227
    {
228
        return (int)$this->id;
229
    }
230
231
    /**
232
     * @param int $id
233
     */
234
    public function setId($id)
235
    {
236
        $this->id = (int)$id;
237
    }
238
239
    /**
240
     * @return int
241
     */
242
    public function getUserId()
243
    {
244
        return (int)$this->userId;
245
    }
246
247
    /**
248
     * @param int $userId
249
     */
250
    public function setUserId($userId)
251
    {
252
        $this->userId = (int)$userId;
253
    }
254
255
    /**
256
     * @return int
257
     */
258
    public function getUserGroupId()
259
    {
260
        return (int)$this->userGroupId;
261
    }
262
263
    /**
264
     * @param int $userGroupId
265
     */
266
    public function setUserGroupId($userGroupId)
267
    {
268
        $this->userGroupId = (int)$userGroupId;
269
    }
270
271
    /**
272
     * @return int
273
     */
274
    public function getOtherUserEdit()
275
    {
276
        return (int)$this->otherUserEdit;
277
    }
278
279
    /**
280
     * @param bool $otherUserEdit
281
     */
282
    public function setOtherUserEdit($otherUserEdit)
283
    {
284
        $this->otherUserEdit = (int)$otherUserEdit;
0 ignored issues
show
Documentation Bug introduced by
The property $otherUserEdit was declared of type boolean, but (int)$otherUserEdit is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
285
    }
286
287
    /**
288
     * @return int
289
     */
290
    public function getOtherUserGroupEdit()
291
    {
292
        return (int)$this->otherUserGroupEdit;
293
    }
294
295
    /**
296
     * @param bool $otherUserGroupEdit
297
     */
298
    public function setOtherUserGroupEdit($otherUserGroupEdit)
299
    {
300
        $this->otherUserGroupEdit = (int)$otherUserGroupEdit;
0 ignored issues
show
Documentation Bug introduced by
The property $otherUserGroupEdit was declared of type boolean, but (int)$otherUserGroupEdit is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
301
    }
302
303
    /**
304
     * @return string
305
     */
306
    public function getName()
307
    {
308
        return $this->name;
309
    }
310
311
    /**
312
     * @param string $name
313
     */
314
    public function setName($name)
315
    {
316
        $this->name = $name;
317
    }
318
319
    /**
320
     * @return int
321
     */
322
    public function getCategoryId()
323
    {
324
        return (int)$this->categoryId;
325
    }
326
327
    /**
328
     * @param int $categoryId
329
     */
330
    public function setCategoryId($categoryId)
331
    {
332
        $this->categoryId = (int)$categoryId;
333
    }
334
335
    /**
336
     * @return int
337
     */
338
    public function getClientId()
339
    {
340
        return (int)$this->clientId;
341
    }
342
343
    /**
344
     * @param int $clientId
345
     */
346
    public function setClientId($clientId)
347
    {
348
        $this->clientId = (int)$clientId;
349
    }
350
351
    /**
352
     * @return string
353
     */
354
    public function getLogin()
355
    {
356
        return $this->login;
357
    }
358
359
    /**
360
     * @param string $login
361
     */
362
    public function setLogin($login)
363
    {
364
        $this->login = $login;
365
    }
366
367
    /**
368
     * @return string
369
     */
370
    public function getUrl()
371
    {
372
        return $this->url;
373
    }
374
375
    /**
376
     * @param string $url
377
     */
378
    public function setUrl($url)
379
    {
380
        $this->url = $url;
381
    }
382
383
    /**
384
     * @return string
385
     */
386
    public function getNotes()
387
    {
388
        return $this->notes;
389
    }
390
391
    /**
392
     * @param string $notes
393
     */
394
    public function setNotes($notes)
395
    {
396
        $this->notes = $notes;
397
    }
398
399
    /**
400
     * Specify data which should be serialized to JSON
401
     *
402
     * @link  http://php.net/manual/en/jsonserializable.jsonserialize.php
403
     * @return mixed data which can be serialized by <b>json_encode</b>,
404
     *        which is a value of any type other than a resource.
405
     * @since 5.4.0
406
     */
407
    public function jsonSerialize()
408
    {
409
        $data = get_object_vars($this);
410
411
        unset($data['accountPass'], $data['accountIV']);
412
413
        return Json::safeJson($data);
414
    }
415
416
    /**
417
     * @return int
418
     */
419
    public function getCountView()
420
    {
421
        return (int)$this->countView;
422
    }
423
424
    /**
425
     * @param int $countView
426
     */
427
    public function setCountView($countView)
428
    {
429
        $this->countView = (int)$countView;
430
    }
431
432
    /**
433
     * @return int
434
     */
435
    public function getCountDecrypt()
436
    {
437
        return (int)$this->countDecrypt;
438
    }
439
440
    /**
441
     * @param int $countDecrypt
442
     */
443
    public function setCountDecrypt($countDecrypt)
444
    {
445
        $this->countDecrypt = (int)$countDecrypt;
446
    }
447
448
    /**
449
     * @return int
450
     */
451
    public function getIsPrivate()
452
    {
453
        return (int)$this->isPrivate;
454
    }
455
456
    /**
457
     * @param int $isPrivate
458
     */
459
    public function setIsPrivate($isPrivate)
460
    {
461
        $this->isPrivate = (int)$isPrivate;
462
    }
463
464
    /**
465
     * @return int
466
     */
467
    public function getPassDate()
468
    {
469
        return (int)$this->passDate;
470
    }
471
472
    /**
473
     * @param int $passDate
474
     */
475
    public function setPassDate($passDate)
476
    {
477
        $this->passDate = (int)$passDate;
478
    }
479
480
    /**
481
     * @return int
482
     */
483
    public function getPassDateChange()
484
    {
485
        return (int)$this->passDateChange;
486
    }
487
488
    /**
489
     * @param int $passDateChange
490
     */
491
    public function setPassDateChange($passDateChange)
492
    {
493
        $this->passDateChange = (int)$passDateChange;
494
    }
495
496
    /**
497
     * @return int
498
     */
499
    public function getParentId()
500
    {
501
        return (int)$this->parentId;
502
    }
503
504
    /**
505
     * @param int $parentId
506
     */
507
    public function setParentId($parentId)
508
    {
509
        $this->parentId = (int)$parentId;
510
    }
511
512
    /**
513
     * @return int
514
     */
515
    public function getIsPrivateGroup()
516
    {
517
        return (int)$this->isPrivateGroup;
518
    }
519
520
    /**
521
     * @param int $isPrivateGroup
522
     */
523
    public function setIsPrivateGroup($isPrivateGroup)
524
    {
525
        $this->isPrivateGroup = (int)$isPrivateGroup;
526
    }
527
}