|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// ------------------------------------------------------------------------- |
|
4
|
|
|
// OVIDENTIA http://www.ovidentia.org |
|
5
|
|
|
// Ovidentia 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 2, or (at your option) |
|
8
|
|
|
// any later version. |
|
9
|
|
|
// |
|
10
|
|
|
// This program is distributed in the hope that it will be useful, but |
|
11
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
// See the 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, write to the Free Software |
|
17
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
18
|
|
|
// USA. |
|
19
|
|
|
// ------------------------------------------------------------------------- |
|
20
|
|
|
/** |
|
21
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) |
|
22
|
|
|
* @copyright Copyright (c) 2022 by SI4YOU ({@link https://www.siforyou.com}) |
|
23
|
|
|
*/ |
|
24
|
|
|
namespace Capwelton\LibApp\Set; |
|
25
|
|
|
|
|
26
|
|
|
use Capwelton\LibApp\Func_App; |
|
27
|
|
|
use function Capwelton\LibOrm\ORM_UserField; |
|
|
|
|
|
|
28
|
|
|
use function Capwelton\LibOrm\ORM_StringField; |
|
|
|
|
|
|
29
|
|
|
use function Capwelton\LibOrm\ORM_BoolField; |
|
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @property ORM_UserField $user |
|
33
|
|
|
* @property ORM_StringField $title |
|
34
|
|
|
* @property ORM_StringField $description |
|
35
|
|
|
* @property ORM_StringField $action |
|
36
|
|
|
* @property ORM_StringField $imagePath |
|
37
|
|
|
* @property ORM_BoolField $seen |
|
38
|
|
|
* |
|
39
|
|
|
* @method app_Notification get() |
|
40
|
|
|
* @method app_Notification request() |
|
41
|
|
|
* @method app_Notification[]|\ORM_Iterator select() |
|
42
|
|
|
* @method app_Notification newRecord() |
|
43
|
|
|
* @method Func_App App() |
|
44
|
|
|
*/ |
|
45
|
|
|
class AppNotificationSet extends AppTraceableRecordSet |
|
46
|
|
|
{ |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param Func_App $App |
|
50
|
|
|
*/ |
|
51
|
|
|
public function __construct(Func_App $App) |
|
52
|
|
|
{ |
|
53
|
|
|
parent::__construct($App); |
|
54
|
|
|
|
|
55
|
|
|
$App = $this->App(); |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
$this->setPrimaryKey('id'); |
|
58
|
|
|
|
|
59
|
|
|
$this->addFields( |
|
60
|
|
|
ORM_UserField('user'), |
|
61
|
|
|
ORM_StringField('title'), |
|
62
|
|
|
ORM_StringField('description'), |
|
63
|
|
|
ORM_StringField('action'), |
|
64
|
|
|
ORM_StringField('imagePath'), |
|
65
|
|
|
ORM_BoolField('seen') |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function selectUserNotifications($user = null, $seen = false) |
|
70
|
|
|
{ |
|
71
|
|
|
if(! isset($user)){ |
|
72
|
|
|
$App = $this->App(); |
|
73
|
|
|
$user = $App->getCurrentUser(); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
return $this->select($this->user->is($user)->_AND_($this->seen->is($seen))); |
|
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
} |