diff options
author | Thomas Citharel <tcit@tcit.fr> | 2017-05-31 09:31:18 +0200 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2017-06-23 10:08:54 +0200 |
commit | bf6c0346d8d35a719dd1bff1cb4d573d422f99ff (patch) | |
tree | 04fb80e20ad1cffacb72357a632a9afe2ec058cb /src/Wallabag/CoreBundle/Entity | |
parent | d6d3f4ec3698effd1d4b063e295341791bdcf7d7 (diff) | |
download | wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.tar.gz wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.tar.zst wallabag-bf6c0346d8d35a719dd1bff1cb4d573d422f99ff.zip |
WIPfederation
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Activity.php | 295 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Config.php | 2 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 26 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Notification.php | 1 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Share.php | 140 |
5 files changed, 462 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Activity.php b/src/Wallabag/CoreBundle/Entity/Activity.php new file mode 100644 index 00000000..08a3f1fb --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Activity.php | |||
@@ -0,0 +1,295 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Entity; | ||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; | ||
6 | use Wallabag\FederationBundle\Entity\Account; | ||
7 | |||
8 | /** | ||
9 | * Change. | ||
10 | * | ||
11 | * This entity stores a datetime for each activity. | ||
12 | * | ||
13 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\ChangeRepository") | ||
14 | * @ORM\Table(name="`activity`") | ||
15 | */ | ||
16 | class Activity | ||
17 | { | ||
18 | /** | ||
19 | * Object types | ||
20 | */ | ||
21 | const ENTRY_OBJECT = 1; | ||
22 | const TAG_OBJECT = 2; | ||
23 | const USER_OBJECT = 3; | ||
24 | const SHARE_OBJECT = 4; | ||
25 | const GROUP_OBJECT = 5; | ||
26 | const ANNOTATION_OBJECT = 6; | ||
27 | const CONFIG_OBJECT = 7; | ||
28 | const ACCOUNT_OBJECT = 8; | ||
29 | |||
30 | /** | ||
31 | * Events | ||
32 | */ | ||
33 | |||
34 | /** | ||
35 | * Entry events | ||
36 | */ | ||
37 | const ENTRY_ADD = 10; // done | ||
38 | const ENTRY_EDIT = 11; // done | ||
39 | const ENTRY_READ = 12; // done | ||
40 | const ENTRY_UNREAD = 13; // done | ||
41 | const ENTRY_FAVOURITE = 14; // done | ||
42 | const ENTRY_UNFAVOURITE = 15; // done | ||
43 | const ENTRY_DELETE = 19; // done | ||
44 | |||
45 | /** | ||
46 | * Tag events | ||
47 | */ | ||
48 | const TAG_CREATE = 20; // not yet implemented | ||
49 | const TAG_EDIT = 21; // not yet implemented | ||
50 | const TAG_REMOVE = 29; // not yet implemented | ||
51 | |||
52 | /** | ||
53 | * Entry - Tag events | ||
54 | */ | ||
55 | const ENTRY_ADD_TAG = 30; // done | ||
56 | const ENTRY_REMOVE_TAG = 39; // done | ||
57 | |||
58 | /** | ||
59 | * Entry - Annotation events | ||
60 | */ | ||
61 | const ANNOTATION_ADD = 40; // done | ||
62 | const ANNOTATION_EDIT = 41; // done | ||
63 | const ANNOTATION_REMOVE = 49; // done | ||
64 | |||
65 | /** | ||
66 | * User events | ||
67 | */ | ||
68 | const USER_CREATE = 50; // done | ||
69 | const USER_EDIT = 51; // done | ||
70 | const USER_REMOVE = 59; // done | ||
71 | |||
72 | /** | ||
73 | * Federation events | ||
74 | */ | ||
75 | const FOLLOW_ACCOUNT = 61; | ||
76 | const UNFOLLOW_ACCOUNT = 62; | ||
77 | const RECOMMEND_ENTRY = 63; | ||
78 | |||
79 | /** | ||
80 | * Share events | ||
81 | */ | ||
82 | const USER_SHARE_CREATED = 70; // done | ||
83 | const USER_SHARE_ACCEPTED = 71; // done | ||
84 | const USER_SHARE_REFUSED = 72; // done | ||
85 | const USER_SHARE_CANCELLED = 79; // not implemented yet | ||
86 | |||
87 | /** | ||
88 | * Group events | ||
89 | */ | ||
90 | const GROUP_CREATE = 80; | ||
91 | const GROUP_EDIT = 81; | ||
92 | const GROUP_ADD_MEMBER = 82; | ||
93 | const GROUP_EDIT_MEMBER = 83; | ||
94 | const GROUP_REMOVE_MEMBER = 84; | ||
95 | const GROUP_SHARE_ENTRY = 85; | ||
96 | const GROUP_DELETE = 89; | ||
97 | |||
98 | /** | ||
99 | * @var int | ||
100 | * | ||
101 | * @ORM\Column(type="integer") | ||
102 | * @ORM\Id | ||
103 | * @ORM\GeneratedValue(strategy="AUTO") | ||
104 | */ | ||
105 | private $id; | ||
106 | |||
107 | /** | ||
108 | * @var int | ||
109 | * | ||
110 | * @ORM\Column(type="integer") | ||
111 | */ | ||
112 | private $activityType; | ||
113 | |||
114 | /** | ||
115 | * @var Account | ||
116 | */ | ||
117 | private $user; | ||
118 | |||
119 | /** | ||
120 | * @var int | ||
121 | * | ||
122 | * @ORM\Column(type="integer") | ||
123 | */ | ||
124 | private $primaryObjectType; | ||
125 | |||
126 | /** | ||
127 | * @var int | ||
128 | * | ||
129 | * @ORM\Column(type="integer") | ||
130 | */ | ||
131 | private $primaryObjectId; | ||
132 | |||
133 | /** | ||
134 | * @var int | ||
135 | * | ||
136 | * @ORM\Column(type="integer", nullable=true) | ||
137 | */ | ||
138 | private $secondaryObjectType; | ||
139 | |||
140 | /** | ||
141 | * @var int | ||
142 | * | ||
143 | * @ORM\Column(type="integer", nullable=true) | ||
144 | */ | ||
145 | private $secondaryObjectId; | ||
146 | |||
147 | /** | ||
148 | * @var \DateTime | ||
149 | * | ||
150 | * @ORM\Column(name="created_at", type="datetime") | ||
151 | */ | ||
152 | private $createdAt; | ||
153 | |||
154 | public function __construct($activityType, $primaryObjectType, $primaryObjectId) | ||
155 | { | ||
156 | $this->activityType = $activityType; | ||
157 | $this->primaryObjectType = $primaryObjectType; | ||
158 | $this->primaryObjectId = $primaryObjectId; | ||
159 | $this->createdAt = new \DateTime(); | ||
160 | } | ||
161 | |||
162 | /** | ||
163 | * @return int | ||
164 | */ | ||
165 | public function getId() | ||
166 | { | ||
167 | return $this->id; | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * @return int | ||
172 | */ | ||
173 | public function getActivityType() | ||
174 | { | ||
175 | return $this->activityType; | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * @param int $activityType | ||
180 | * @return Activity | ||
181 | */ | ||
182 | public function setActivityType($activityType) | ||
183 | { | ||
184 | $this->activityType = $activityType; | ||
185 | return $this; | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * @return \DateTime | ||
190 | */ | ||
191 | public function getCreatedAt() | ||
192 | { | ||
193 | return $this->createdAt; | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * @param \DateTime $createdAt | ||
198 | * @return Activity | ||
199 | */ | ||
200 | public function setCreatedAt(\DateTime $createdAt) | ||
201 | { | ||
202 | $this->createdAt = $createdAt; | ||
203 | return $this; | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * @return int | ||
208 | */ | ||
209 | public function getPrimaryObjectId() | ||
210 | { | ||
211 | return $this->primaryObjectId; | ||
212 | } | ||
213 | |||
214 | /** | ||
215 | * @param $primaryObjectId | ||
216 | * @return Activity | ||
217 | */ | ||
218 | public function setPrimaryObjectId($primaryObjectId) | ||
219 | { | ||
220 | $this->primaryObjectId = $primaryObjectId; | ||
221 | return $this; | ||
222 | } | ||
223 | |||
224 | /** | ||
225 | * @return Account | ||
226 | */ | ||
227 | public function getUser() | ||
228 | { | ||
229 | return $this->user; | ||
230 | } | ||
231 | |||
232 | /** | ||
233 | * @param Account $user | ||
234 | * @return Activity | ||
235 | */ | ||
236 | public function setUser($user) | ||
237 | { | ||
238 | $this->user = $user; | ||
239 | return $this; | ||
240 | } | ||
241 | |||
242 | /** | ||
243 | * @return int | ||
244 | */ | ||
245 | public function getPrimaryObjectType() | ||
246 | { | ||
247 | return $this->primaryObjectType; | ||
248 | } | ||
249 | |||
250 | /** | ||
251 | * @param int $primaryObjectType | ||
252 | * @return Activity | ||
253 | */ | ||
254 | public function setPrimaryObjectType($primaryObjectType) | ||
255 | { | ||
256 | $this->primaryObjectType = $primaryObjectType; | ||
257 | return $this; | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * @return int | ||
262 | */ | ||
263 | public function getSecondaryObjectType() | ||
264 | { | ||
265 | return $this->secondaryObjectType; | ||
266 | } | ||
267 | |||
268 | /** | ||
269 | * @param int $secondaryObjectType | ||
270 | * @return Activity | ||
271 | */ | ||
272 | public function setSecondaryObjectType($secondaryObjectType) | ||
273 | { | ||
274 | $this->secondaryObjectType = $secondaryObjectType; | ||
275 | return $this; | ||
276 | } | ||
277 | |||
278 | /** | ||
279 | * @return int | ||
280 | */ | ||
281 | public function getSecondaryObjectId() | ||
282 | { | ||
283 | return $this->secondaryObjectId; | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * @param int $secondaryObjectId | ||
288 | * @return Activity | ||
289 | */ | ||
290 | public function setSecondaryObjectId($secondaryObjectId) | ||
291 | { | ||
292 | $this->secondaryObjectId = $secondaryObjectId; | ||
293 | return $this; | ||
294 | } | ||
295 | } | ||
diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index b902ae2c..f42a49b3 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php | |||
@@ -8,7 +8,7 @@ use Symfony\Component\Validator\Constraints as Assert; | |||
8 | use Wallabag\UserBundle\Entity\User; | 8 | use Wallabag\UserBundle\Entity\User; |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * Config. | 11 | * config. |
12 | * | 12 | * |
13 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\ConfigRepository") | 13 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\ConfigRepository") |
14 | * @ORM\Table(name="`config`") | 14 | * @ORM\Table(name="`config`") |
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index a0503c39..6ca17126 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -233,13 +233,21 @@ class Entry | |||
233 | */ | 233 | */ |
234 | private $tags; | 234 | private $tags; |
235 | 235 | ||
236 | /* | 236 | /** |
237 | * @var boolean | ||
238 | * | ||
239 | * @ORM\Column(name="recommended", type="boolean", nullable=true) | ||
240 | */ | ||
241 | private $recommended; | ||
242 | |||
243 | /** | ||
237 | * @param User $user | 244 | * @param User $user |
238 | */ | 245 | */ |
239 | public function __construct(User $user) | 246 | public function __construct(User $user) |
240 | { | 247 | { |
241 | $this->user = $user; | 248 | $this->user = $user; |
242 | $this->tags = new ArrayCollection(); | 249 | $this->tags = new ArrayCollection(); |
250 | $this->changes = new ArrayCollection(); | ||
243 | } | 251 | } |
244 | 252 | ||
245 | /** | 253 | /** |
@@ -778,4 +786,20 @@ class Entry | |||
778 | 786 | ||
779 | return $this; | 787 | return $this; |
780 | } | 788 | } |
789 | |||
790 | /** | ||
791 | * @return bool | ||
792 | */ | ||
793 | public function isRecommended() | ||
794 | { | ||
795 | return $this->recommended; | ||
796 | } | ||
797 | |||
798 | /** | ||
799 | * @param bool $recommended | ||
800 | */ | ||
801 | public function setRecommended($recommended) | ||
802 | { | ||
803 | $this->recommended = $recommended; | ||
804 | } | ||
781 | } | 805 | } |
diff --git a/src/Wallabag/CoreBundle/Entity/Notification.php b/src/Wallabag/CoreBundle/Entity/Notification.php index aa4c03c3..d4304f39 100644 --- a/src/Wallabag/CoreBundle/Entity/Notification.php +++ b/src/Wallabag/CoreBundle/Entity/Notification.php | |||
@@ -91,6 +91,7 @@ class Notification implements NotificationInterface | |||
91 | const TYPE_ADMIN = 0; | 91 | const TYPE_ADMIN = 0; |
92 | const TYPE_USER = 1; | 92 | const TYPE_USER = 1; |
93 | const TYPE_RELEASE = 2; | 93 | const TYPE_RELEASE = 2; |
94 | const TYPE_SHARE = 3; | ||
94 | 95 | ||
95 | public function __construct(User $user = null) | 96 | public function __construct(User $user = null) |
96 | { | 97 | { |
diff --git a/src/Wallabag/CoreBundle/Entity/Share.php b/src/Wallabag/CoreBundle/Entity/Share.php new file mode 100644 index 00000000..a55b4e67 --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Share.php | |||
@@ -0,0 +1,140 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Entity; | ||
4 | |||
5 | use Wallabag\FederationBundle\Entity\Account; | ||
6 | use Wallabag\UserBundle\Entity\User; | ||
7 | use Doctrine\ORM\Mapping as ORM; | ||
8 | |||
9 | /** | ||
10 | * Share. | ||
11 | * | ||
12 | * @ORM\Entity | ||
13 | */ | ||
14 | class Share | ||
15 | { | ||
16 | /** | ||
17 | * @var int | ||
18 | * | ||
19 | * @ORM\Column(name="id", type="integer") | ||
20 | * @ORM\Id | ||
21 | * @ORM\GeneratedValue(strategy="AUTO") | ||
22 | */ | ||
23 | private $id; | ||
24 | |||
25 | /** | ||
26 | * @var Account | ||
27 | * | ||
28 | * @ORM\ManyToOne(targetEntity="Wallabag\FederationBundle\Entity\Account") | ||
29 | */ | ||
30 | private $userOrigin; | ||
31 | |||
32 | /** | ||
33 | * @var Account | ||
34 | * | ||
35 | * @ORM\ManyToOne(targetEntity="Wallabag\FederationBundle\Entity\Account") | ||
36 | */ | ||
37 | private $userDestination; | ||
38 | |||
39 | /** | ||
40 | * @var Entry | ||
41 | * | ||
42 | * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry") | ||
43 | */ | ||
44 | private $entry; | ||
45 | |||
46 | /** | ||
47 | * @var boolean | ||
48 | * | ||
49 | * @ORM\Column(name="accepted", type="boolean") | ||
50 | */ | ||
51 | private $accepted; | ||
52 | |||
53 | /** | ||
54 | * Share constructor. | ||
55 | */ | ||
56 | public function __construct() | ||
57 | { | ||
58 | $this->accepted = false; | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * @return int | ||
63 | */ | ||
64 | public function getId() | ||
65 | { | ||
66 | return $this->id; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * @return Account | ||
71 | */ | ||
72 | public function getUserOrigin() | ||
73 | { | ||
74 | return $this->userOrigin; | ||
75 | } | ||
76 | |||
77 | /** | ||
78 | * @param User $userOrigin | ||
79 | * @return Share | ||
80 | */ | ||
81 | public function setUserOrigin(User $userOrigin) | ||
82 | { | ||
83 | $this->userOrigin = $userOrigin; | ||
84 | return $this; | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * @return Account | ||
89 | */ | ||
90 | public function getUserDestination() | ||
91 | { | ||
92 | return $this->userDestination; | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * @param User $userDestination | ||
97 | * @return Share | ||
98 | */ | ||
99 | public function setUserDestination(User $userDestination) | ||
100 | { | ||
101 | $this->userDestination = $userDestination; | ||
102 | return $this; | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * @return bool | ||
107 | */ | ||
108 | public function isAccepted() | ||
109 | { | ||
110 | return $this->accepted; | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * @param bool $accepted | ||
115 | * @return Share | ||
116 | */ | ||
117 | public function setAccepted($accepted) | ||
118 | { | ||
119 | $this->accepted = $accepted; | ||
120 | return $this; | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * @return Entry | ||
125 | */ | ||
126 | public function getEntry() | ||
127 | { | ||
128 | return $this->entry; | ||
129 | } | ||
130 | |||
131 | /** | ||
132 | * @param Entry $entry | ||
133 | * @return Share | ||
134 | */ | ||
135 | public function setEntry(Entry $entry) | ||
136 | { | ||
137 | $this->entry = $entry; | ||
138 | return $this; | ||
139 | } | ||
140 | } | ||