1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
4
|
|
|
|
5
|
|
|
namespace Chamilo\CoreBundle\Entity; |
6
|
|
|
|
7
|
|
|
use Chamilo\CoreBundle\Traits\UserTrait; |
8
|
|
|
use Doctrine\ORM\Mapping as ORM; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* SessionRelUser. |
12
|
|
|
* |
13
|
|
|
* @ORM\Table( |
14
|
|
|
* name="session_rel_user", |
15
|
|
|
* indexes={ |
16
|
|
|
* @ORM\Index(name="idx_session_rel_user_id_user_moved", columns={"user_id", "moved_to"}) |
17
|
|
|
* } |
18
|
|
|
* ) |
19
|
|
|
* @ORM\Entity |
20
|
|
|
*/ |
21
|
|
|
class SessionRelUser |
22
|
|
|
{ |
23
|
|
|
use UserTrait; |
24
|
|
|
|
25
|
|
|
public $relationTypeList = [ |
26
|
|
|
0 => 'student', |
27
|
|
|
1 => 'drh', |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var int |
32
|
|
|
* |
33
|
|
|
* @ORM\Column(name="id", type="integer") |
34
|
|
|
* @ORM\Id |
35
|
|
|
* @ORM\GeneratedValue |
36
|
|
|
*/ |
37
|
|
|
protected $id; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var Session |
41
|
|
|
* |
42
|
|
|
* @ORM\ManyToOne(targetEntity="Session", inversedBy="users", cascade={"persist"}) |
43
|
|
|
* @ORM\JoinColumn(name="session_id", referencedColumnName="id") |
44
|
|
|
*/ |
45
|
|
|
protected $session; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="sessions", cascade={"persist"}) |
49
|
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id") |
50
|
|
|
*/ |
51
|
|
|
protected $user; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var int |
55
|
|
|
* |
56
|
|
|
* @ORM\Column(name="relation_type", type="integer", nullable=false, unique=false) |
57
|
|
|
*/ |
58
|
|
|
protected $relationType; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var int |
62
|
|
|
* |
63
|
|
|
* @ORM\Column(name="duration", type="integer", nullable=true) |
64
|
|
|
*/ |
65
|
|
|
protected $duration; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var int |
69
|
|
|
* |
70
|
|
|
* @ORM\Column(name="moved_to", type="integer", nullable=true, unique=false) |
71
|
|
|
*/ |
72
|
|
|
protected $movedTo; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var int |
76
|
|
|
* |
77
|
|
|
* @ORM\Column(name="moved_status", type="integer", nullable=true, unique=false) |
78
|
|
|
*/ |
79
|
|
|
protected $movedStatus; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var \DateTime |
83
|
|
|
* |
84
|
|
|
* @ORM\Column(name="moved_at", type="datetime", nullable=true, unique=false) |
85
|
|
|
*/ |
86
|
|
|
protected $movedAt; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @var \DateTime |
90
|
|
|
* |
91
|
|
|
* @ORM\Column(name="registered_at", type="datetime", nullable=false, unique=false) |
92
|
|
|
*/ |
93
|
|
|
protected $registeredAt; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Constructor. |
97
|
|
|
*/ |
98
|
|
|
public function __construct() |
99
|
|
|
{ |
100
|
|
|
$this->movedTo = null; |
101
|
|
|
$this->movedStatus = null; |
102
|
|
|
$this->movedAt = null; |
103
|
|
|
$this->registeredAt = new \DateTime('now', new \DateTimeZone('UTC')); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Set Session. |
108
|
|
|
* |
109
|
|
|
* @param Session $session |
110
|
|
|
* |
111
|
|
|
* @return SessionRelUser |
112
|
|
|
*/ |
113
|
|
|
public function setSession($session) |
114
|
|
|
{ |
115
|
|
|
$this->session = $session; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function getSession(): Session |
121
|
|
|
{ |
122
|
|
|
return $this->session; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Set relationType. |
127
|
|
|
* |
128
|
|
|
* @param int $relationType |
129
|
|
|
* |
130
|
|
|
* @return SessionRelUser |
131
|
|
|
*/ |
132
|
|
|
public function setRelationType($relationType) |
133
|
|
|
{ |
134
|
|
|
$this->relationType = $relationType; |
135
|
|
|
|
136
|
|
|
return $this; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Set relationTypeByName. |
141
|
|
|
* |
142
|
|
|
* @param string $relationType |
143
|
|
|
* |
144
|
|
|
* @return SessionRelUser |
145
|
|
|
*/ |
146
|
|
|
public function setRelationTypeByName($relationType) |
147
|
|
|
{ |
148
|
|
|
if (isset($this->relationTypeList[$relationType])) { |
149
|
|
|
$this->setRelationType($this->relationTypeList[$relationType]); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Get relationType. |
157
|
|
|
* |
158
|
|
|
* @return int |
159
|
|
|
*/ |
160
|
|
|
public function getRelationType() |
161
|
|
|
{ |
162
|
|
|
return $this->relationType; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Set movedTo. |
167
|
|
|
* |
168
|
|
|
* @param int $movedTo |
169
|
|
|
* |
170
|
|
|
* @return SessionRelUser |
171
|
|
|
*/ |
172
|
|
|
public function setMovedTo($movedTo) |
173
|
|
|
{ |
174
|
|
|
$this->movedTo = $movedTo; |
175
|
|
|
|
176
|
|
|
return $this; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Get movedTo. |
181
|
|
|
* |
182
|
|
|
* @return int |
183
|
|
|
*/ |
184
|
|
|
public function getMovedTo() |
185
|
|
|
{ |
186
|
|
|
return $this->movedTo; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Set movedStatus. |
191
|
|
|
* |
192
|
|
|
* @param int $movedStatus |
193
|
|
|
* |
194
|
|
|
* @return SessionRelUser |
195
|
|
|
*/ |
196
|
|
|
public function setMovedStatus($movedStatus) |
197
|
|
|
{ |
198
|
|
|
$this->movedStatus = $movedStatus; |
199
|
|
|
|
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Get movedStatus. |
205
|
|
|
* |
206
|
|
|
* @return int |
207
|
|
|
*/ |
208
|
|
|
public function getMovedStatus() |
209
|
|
|
{ |
210
|
|
|
return $this->movedStatus; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Set movedAt. |
215
|
|
|
* |
216
|
|
|
* @param \DateTime $movedAt |
217
|
|
|
* |
218
|
|
|
* @return SessionRelUser |
219
|
|
|
*/ |
220
|
|
|
public function setMovedAt($movedAt) |
221
|
|
|
{ |
222
|
|
|
$this->movedAt = $movedAt; |
223
|
|
|
|
224
|
|
|
return $this; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* Get movedAt. |
229
|
|
|
* |
230
|
|
|
* @return \DateTime |
231
|
|
|
*/ |
232
|
|
|
public function getMovedAt() |
233
|
|
|
{ |
234
|
|
|
return $this->movedAt; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Set registeredAt. |
239
|
|
|
* |
240
|
|
|
* @return $this |
241
|
|
|
*/ |
242
|
|
|
public function setRegisteredAt(\DateTime $registeredAt) |
243
|
|
|
{ |
244
|
|
|
$this->registeredAt = $registeredAt; |
245
|
|
|
|
246
|
|
|
return $this; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* Get registeredAt. |
251
|
|
|
* |
252
|
|
|
* @return \DateTime |
253
|
|
|
*/ |
254
|
|
|
public function getRegisteredAt() |
255
|
|
|
{ |
256
|
|
|
return $this->registeredAt; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @return int |
261
|
|
|
*/ |
262
|
|
|
public function getDuration() |
263
|
|
|
{ |
264
|
|
|
return $this->duration; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @param int $duration |
269
|
|
|
* |
270
|
|
|
* @return SessionRelUser |
271
|
|
|
*/ |
272
|
|
|
public function setDuration($duration) |
273
|
|
|
{ |
274
|
|
|
$this->duration = $duration; |
275
|
|
|
|
276
|
|
|
return $this; |
277
|
|
|
} |
278
|
|
|
} |
279
|
|
|
|