aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Entity/Activity.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/Activity.php')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Activity.php295
1 files changed, 295 insertions, 0 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
3namespace Wallabag\CoreBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6use 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 */
16class 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}