|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
namespace Chamilo\UserBundle\Repository; |
|
6
|
|
|
|
|
7
|
|
|
use Chamilo\CoreBundle\Entity\AccessUrlRelUser; |
|
8
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
9
|
|
|
use Chamilo\CoreBundle\Entity\GradebookCertificate; |
|
10
|
|
|
use Chamilo\CoreBundle\Entity\GradebookResult; |
|
11
|
|
|
use Chamilo\CoreBundle\Entity\Message; |
|
12
|
|
|
use Chamilo\CoreBundle\Entity\Session; |
|
13
|
|
|
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser; |
|
14
|
|
|
use Chamilo\CoreBundle\Entity\SkillRelUser; |
|
15
|
|
|
use Chamilo\CoreBundle\Entity\SkillRelUserComment; |
|
16
|
|
|
use Chamilo\CoreBundle\Entity\TrackEAccess; |
|
17
|
|
|
use Chamilo\CoreBundle\Entity\TrackEAttempt; |
|
18
|
|
|
use Chamilo\CoreBundle\Entity\TrackECourseAccess; |
|
19
|
|
|
use Chamilo\CoreBundle\Entity\TrackEDefault; |
|
20
|
|
|
use Chamilo\CoreBundle\Entity\TrackEDownloads; |
|
21
|
|
|
use Chamilo\CoreBundle\Entity\TrackEExercises; |
|
22
|
|
|
use Chamilo\CoreBundle\Entity\TrackELastaccess; |
|
23
|
|
|
use Chamilo\CoreBundle\Entity\TrackELogin; |
|
24
|
|
|
use Chamilo\CoreBundle\Entity\TrackEOnline; |
|
25
|
|
|
use Chamilo\CoreBundle\Entity\TrackEUploads; |
|
26
|
|
|
use Chamilo\CoreBundle\Entity\UserApiKey; |
|
27
|
|
|
use Chamilo\CoreBundle\Entity\UserCourseCategory; |
|
28
|
|
|
use Chamilo\CoreBundle\Entity\UserRelCourseVote; |
|
29
|
|
|
use Chamilo\CourseBundle\Entity\CAttendanceResult; |
|
30
|
|
|
use Chamilo\CourseBundle\Entity\CAttendanceSheet; |
|
31
|
|
|
use Chamilo\CourseBundle\Entity\CBlogPost; |
|
32
|
|
|
use Chamilo\CourseBundle\Entity\CDropboxFeedback; |
|
33
|
|
|
use Chamilo\CourseBundle\Entity\CDropboxFile; |
|
34
|
|
|
use Chamilo\CourseBundle\Entity\CDropboxPerson; |
|
35
|
|
|
use Chamilo\CourseBundle\Entity\CForumPost; |
|
36
|
|
|
use Chamilo\CourseBundle\Entity\CForumThread; |
|
37
|
|
|
use Chamilo\CourseBundle\Entity\CGroupRelUser; |
|
38
|
|
|
use Chamilo\CourseBundle\Entity\CLpView; |
|
39
|
|
|
use Chamilo\CourseBundle\Entity\CNotebook; |
|
40
|
|
|
use Chamilo\CourseBundle\Entity\CStudentPublication; |
|
41
|
|
|
use Chamilo\CourseBundle\Entity\CStudentPublicationComment; |
|
42
|
|
|
use Chamilo\CourseBundle\Entity\CSurveyAnswer; |
|
43
|
|
|
use Chamilo\CourseBundle\Entity\CWiki; |
|
44
|
|
|
use Chamilo\TicketBundle\Entity\Ticket; |
|
45
|
|
|
use Chamilo\UserBundle\Entity\User; |
|
46
|
|
|
use Doctrine\ORM\EntityRepository; |
|
47
|
|
|
use Doctrine\ORM\Query\Expr\Join; |
|
48
|
|
|
use Symfony\Component\Finder\Finder; |
|
49
|
|
|
use Symfony\Component\Serializer\Encoder\JsonEncoder; |
|
50
|
|
|
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; |
|
51
|
|
|
use Symfony\Component\Serializer\Serializer; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Class UserRepository. |
|
55
|
|
|
* |
|
56
|
|
|
* All functions that query the database (selects) |
|
57
|
|
|
* Functions should return query builders. |
|
58
|
|
|
*/ |
|
59
|
|
|
class UserRepository extends EntityRepository |
|
60
|
|
|
{ |
|
61
|
|
|
/** |
|
62
|
|
|
* @param string $keyword |
|
63
|
|
|
* |
|
64
|
|
|
* @return mixed |
|
65
|
|
|
*/ |
|
66
|
|
|
public function searchUserByKeyword($keyword) |
|
67
|
|
|
{ |
|
68
|
|
|
$qb = $this->createQueryBuilder('a'); |
|
69
|
|
|
|
|
70
|
|
|
// Selecting user info |
|
71
|
|
|
$qb->select('DISTINCT b'); |
|
72
|
|
|
|
|
73
|
|
|
$qb->from('Chamilo\UserBundle\Entity\User', 'b'); |
|
74
|
|
|
|
|
75
|
|
|
// Selecting courses for users |
|
76
|
|
|
//$qb->innerJoin('u.courses', 'c'); |
|
77
|
|
|
|
|
78
|
|
|
//@todo check app settings |
|
79
|
|
|
$qb->add('orderBy', 'b.firstname ASC'); |
|
80
|
|
|
$qb->where('b.firstname LIKE :keyword OR b.lastname LIKE :keyword '); |
|
81
|
|
|
$qb->setParameter('keyword', "%$keyword%"); |
|
82
|
|
|
$query = $qb->getQuery(); |
|
83
|
|
|
|
|
84
|
|
|
return $query->execute(); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param string $role |
|
89
|
|
|
* |
|
90
|
|
|
* @return array |
|
91
|
|
|
*/ |
|
92
|
|
|
public function findByRole($role) |
|
93
|
|
|
{ |
|
94
|
|
|
$em = $this->getEntityManager(); |
|
95
|
|
|
$qb = $em->createQueryBuilder(); |
|
96
|
|
|
|
|
97
|
|
|
$qb->select('u') |
|
98
|
|
|
->from($this->_entityName, 'u') |
|
99
|
|
|
->where('u.roles LIKE :roles') |
|
100
|
|
|
->setParameter('roles', '%"'.$role.'"%'); |
|
101
|
|
|
|
|
102
|
|
|
return $qb->getQuery()->getResult(); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Get course user relationship based in the course_rel_user table. |
|
107
|
|
|
* |
|
108
|
|
|
* @return array |
|
109
|
|
|
*/ |
|
110
|
|
|
/*public function getCourses(User $user) |
|
111
|
|
|
{ |
|
112
|
|
|
$queryBuilder = $this->createQueryBuilder('user'); |
|
113
|
|
|
|
|
114
|
|
|
// Selecting course info. |
|
115
|
|
|
$queryBuilder->select('c'); |
|
116
|
|
|
|
|
117
|
|
|
// Loading User. |
|
118
|
|
|
//$qb->from('Chamilo\UserBundle\Entity\User', 'u'); |
|
119
|
|
|
|
|
120
|
|
|
// Selecting course |
|
121
|
|
|
$queryBuilder->innerJoin('Chamilo\CoreBundle\Entity\Course', 'c'); |
|
122
|
|
|
|
|
123
|
|
|
//@todo check app settings |
|
124
|
|
|
//$qb->add('orderBy', 'u.lastname ASC'); |
|
125
|
|
|
|
|
126
|
|
|
$wherePart = $queryBuilder->expr()->andx(); |
|
127
|
|
|
|
|
128
|
|
|
// Get only users subscribed to this course |
|
129
|
|
|
$wherePart->add($queryBuilder->expr()->eq('user.userId', $user->getUserId())); |
|
130
|
|
|
|
|
131
|
|
|
$queryBuilder->where($wherePart); |
|
132
|
|
|
$query = $queryBuilder->getQuery(); |
|
133
|
|
|
|
|
134
|
|
|
return $query->execute(); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function getTeachers() |
|
138
|
|
|
{ |
|
139
|
|
|
$queryBuilder = $this->createQueryBuilder('u'); |
|
140
|
|
|
|
|
141
|
|
|
// Selecting course info. |
|
142
|
|
|
$queryBuilder |
|
143
|
|
|
->select('u') |
|
144
|
|
|
->where('u.groups.id = :groupId') |
|
145
|
|
|
->setParameter('groupId', 1); |
|
146
|
|
|
|
|
147
|
|
|
$query = $queryBuilder->getQuery(); |
|
148
|
|
|
|
|
149
|
|
|
return $query->execute(); |
|
150
|
|
|
}*/ |
|
151
|
|
|
|
|
152
|
|
|
/*public function getUsers($group) |
|
153
|
|
|
{ |
|
154
|
|
|
$queryBuilder = $this->createQueryBuilder('u'); |
|
155
|
|
|
|
|
156
|
|
|
// Selecting course info. |
|
157
|
|
|
$queryBuilder |
|
158
|
|
|
->select('u') |
|
159
|
|
|
->where('u.groups = :groupId') |
|
160
|
|
|
->setParameter('groupId', $group); |
|
161
|
|
|
|
|
162
|
|
|
$query = $queryBuilder->getQuery(); |
|
163
|
|
|
|
|
164
|
|
|
return $query->execute(); |
|
165
|
|
|
}*/ |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Get a filtered list of user by status and (optionally) access url. |
|
169
|
|
|
* |
|
170
|
|
|
* @param string $query The query to filter |
|
171
|
|
|
* @param int $status The status |
|
172
|
|
|
* @param int $accessUrlId The access URL ID |
|
173
|
|
|
* |
|
174
|
|
|
* @return array |
|
175
|
|
|
*/ |
|
176
|
|
|
public function searchUsersByStatus($query, $status, $accessUrlId = 0) |
|
177
|
|
|
{ |
|
178
|
|
|
$accessUrlId = (int) $accessUrlId; |
|
179
|
|
|
$queryBuilder = $this->createQueryBuilder('u'); |
|
180
|
|
|
|
|
181
|
|
|
if ($accessUrlId > 0) { |
|
182
|
|
|
$queryBuilder->innerJoin( |
|
183
|
|
|
'ChamiloCoreBundle:AccessUrlRelUser', |
|
184
|
|
|
'auru', |
|
185
|
|
|
Join::WITH, |
|
186
|
|
|
'u.id = auru.userId' |
|
187
|
|
|
); |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
$queryBuilder |
|
191
|
|
|
->where('u.status = :status') |
|
192
|
|
|
->andWhere('u.username LIKE :query OR u.firstname LIKE :query OR u.lastname LIKE :query') |
|
193
|
|
|
->setParameter('status', $status) |
|
194
|
|
|
->setParameter('query', "$query%"); |
|
195
|
|
|
|
|
196
|
|
|
if ($accessUrlId > 0) { |
|
197
|
|
|
$queryBuilder |
|
198
|
|
|
->andWhere('auru.accessUrlId = :url') |
|
199
|
|
|
->setParameter(':url', $accessUrlId); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
return $queryBuilder->getQuery()->getResult(); |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* Get the coaches for a course within a session. |
|
207
|
|
|
* |
|
208
|
|
|
* @param Session $session The session |
|
209
|
|
|
* @param Course $course The course |
|
210
|
|
|
* |
|
211
|
|
|
* @return array |
|
212
|
|
|
*/ |
|
213
|
|
|
public function getCoachesForSessionCourse(Session $session, Course $course) |
|
214
|
|
|
{ |
|
215
|
|
|
$queryBuilder = $this->createQueryBuilder('u'); |
|
216
|
|
|
|
|
217
|
|
|
$queryBuilder |
|
218
|
|
|
->select('u') |
|
219
|
|
|
->innerJoin( |
|
220
|
|
|
'ChamiloCoreBundle:SessionRelCourseRelUser', |
|
221
|
|
|
'scu', |
|
222
|
|
|
Join::WITH, |
|
223
|
|
|
'scu.user = u' |
|
224
|
|
|
) |
|
225
|
|
|
->where( |
|
226
|
|
|
$queryBuilder->expr()->andX( |
|
227
|
|
|
$queryBuilder->expr()->eq('scu.session', $session->getId()), |
|
228
|
|
|
$queryBuilder->expr()->eq('scu.course', $course->getId()), |
|
229
|
|
|
$queryBuilder->expr()->eq('scu.status', SessionRelCourseRelUser::STATUS_COURSE_COACH) |
|
230
|
|
|
) |
|
231
|
|
|
); |
|
232
|
|
|
|
|
233
|
|
|
return $queryBuilder->getQuery()->getResult(); |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
/** |
|
237
|
|
|
* Get course user relationship based in the course_rel_user table. |
|
238
|
|
|
* |
|
239
|
|
|
* @return array |
|
240
|
|
|
*/ |
|
241
|
|
|
/*public function getCourses(User $user) |
|
242
|
|
|
{ |
|
243
|
|
|
$queryBuilder = $this->createQueryBuilder('user'); |
|
244
|
|
|
|
|
245
|
|
|
// Selecting course info. |
|
246
|
|
|
$queryBuilder->select('c'); |
|
247
|
|
|
|
|
248
|
|
|
// Loading User. |
|
249
|
|
|
//$qb->from('Chamilo\UserBundle\Entity\User', 'u'); |
|
250
|
|
|
|
|
251
|
|
|
// Selecting course |
|
252
|
|
|
$queryBuilder->innerJoin('Chamilo\CoreBundle\Entity\Course', 'c'); |
|
253
|
|
|
|
|
254
|
|
|
//@todo check app settings |
|
255
|
|
|
//$qb->add('orderBy', 'u.lastname ASC'); |
|
256
|
|
|
|
|
257
|
|
|
$wherePart = $queryBuilder->expr()->andx(); |
|
258
|
|
|
|
|
259
|
|
|
// Get only users subscribed to this course |
|
260
|
|
|
$wherePart->add($queryBuilder->expr()->eq('user.userId', $user->getUserId())); |
|
261
|
|
|
|
|
262
|
|
|
$queryBuilder->where($wherePart); |
|
263
|
|
|
$query = $queryBuilder->getQuery(); |
|
264
|
|
|
|
|
265
|
|
|
return $query->execute(); |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
public function getTeachers() |
|
269
|
|
|
{ |
|
270
|
|
|
$queryBuilder = $this->createQueryBuilder('u'); |
|
271
|
|
|
|
|
272
|
|
|
// Selecting course info. |
|
273
|
|
|
$queryBuilder |
|
274
|
|
|
->select('u') |
|
275
|
|
|
->where('u.groups.id = :groupId') |
|
276
|
|
|
->setParameter('groupId', 1); |
|
277
|
|
|
|
|
278
|
|
|
$query = $queryBuilder->getQuery(); |
|
279
|
|
|
|
|
280
|
|
|
return $query->execute(); |
|
281
|
|
|
}*/ |
|
282
|
|
|
|
|
283
|
|
|
/*public function getUsers($group) |
|
284
|
|
|
{ |
|
285
|
|
|
$queryBuilder = $this->createQueryBuilder('u'); |
|
286
|
|
|
|
|
287
|
|
|
// Selecting course info. |
|
288
|
|
|
$queryBuilder |
|
289
|
|
|
->select('u') |
|
290
|
|
|
->where('u.groups = :groupId') |
|
291
|
|
|
->setParameter('groupId', $group); |
|
292
|
|
|
|
|
293
|
|
|
$query = $queryBuilder->getQuery(); |
|
294
|
|
|
|
|
295
|
|
|
return $query->execute(); |
|
296
|
|
|
}*/ |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* Get the sessions admins for a user. |
|
300
|
|
|
* |
|
301
|
|
|
* @return array |
|
302
|
|
|
*/ |
|
303
|
|
|
public function getSessionAdmins(User $user) |
|
304
|
|
|
{ |
|
305
|
|
|
$queryBuilder = $this->createQueryBuilder('u'); |
|
306
|
|
|
$queryBuilder |
|
307
|
|
|
->distinct() |
|
308
|
|
|
->innerJoin( |
|
309
|
|
|
'ChamiloCoreBundle:SessionRelUser', |
|
310
|
|
|
'su', |
|
311
|
|
|
Join::WITH, |
|
312
|
|
|
$queryBuilder->expr()->eq('u', 'su.user') |
|
313
|
|
|
) |
|
314
|
|
|
->innerJoin( |
|
315
|
|
|
'ChamiloCoreBundle:SessionRelCourseRelUser', |
|
316
|
|
|
'scu', |
|
317
|
|
|
Join::WITH, |
|
318
|
|
|
$queryBuilder->expr()->eq('su.session', 'scu.session') |
|
319
|
|
|
) |
|
320
|
|
|
->where( |
|
321
|
|
|
$queryBuilder->expr()->eq('scu.user', $user->getId()) |
|
322
|
|
|
) |
|
323
|
|
|
->andWhere( |
|
324
|
|
|
$queryBuilder->expr()->eq('su.relationType', SESSION_RELATION_TYPE_RRHH) |
|
325
|
|
|
); |
|
326
|
|
|
|
|
327
|
|
|
return $queryBuilder->getQuery()->getResult(); |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
/** |
|
331
|
|
|
* Get the student bosses for a user. |
|
332
|
|
|
* |
|
333
|
|
|
* @return array |
|
334
|
|
|
*/ |
|
335
|
|
|
public function getStudentBosses(User $user) |
|
336
|
|
|
{ |
|
337
|
|
|
$queryBuilder = $this->createQueryBuilder('u'); |
|
338
|
|
|
$queryBuilder |
|
339
|
|
|
->distinct() |
|
340
|
|
|
->innerJoin( |
|
341
|
|
|
'ChamiloCoreBundle:UserRelUser', |
|
342
|
|
|
'uu', |
|
343
|
|
|
Join::WITH, |
|
344
|
|
|
$queryBuilder->expr()->eq('u.id', 'uu.friendUserId') |
|
345
|
|
|
) |
|
346
|
|
|
->where( |
|
347
|
|
|
$queryBuilder->expr()->eq('uu.relationType', USER_RELATION_TYPE_BOSS) |
|
348
|
|
|
) |
|
349
|
|
|
->andWhere( |
|
350
|
|
|
$queryBuilder->expr()->eq('uu.userId', $user->getId()) |
|
351
|
|
|
); |
|
352
|
|
|
|
|
353
|
|
|
return $queryBuilder->getQuery()->getResult(); |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
/** |
|
357
|
|
|
* Find potential users to send a message. |
|
358
|
|
|
* |
|
359
|
|
|
* @param int $currentUserId The current user ID |
|
360
|
|
|
* @param string $search The search text to filter the user list |
|
361
|
|
|
* @param int $limit Optional. Sets the maximum number of results to retrieve |
|
362
|
|
|
* |
|
363
|
|
|
* @return mixed |
|
364
|
|
|
*/ |
|
365
|
|
|
public function findUsersToSendMessage($currentUserId, $search, $limit = 10) |
|
366
|
|
|
{ |
|
367
|
|
|
$allowSendMessageToAllUsers = api_get_setting('allow_send_message_to_all_platform_users'); |
|
368
|
|
|
$accessUrlId = api_get_multiple_access_url() ? api_get_current_access_url_id() : 1; |
|
369
|
|
|
|
|
370
|
|
|
if (api_get_setting('allow_social_tool') === 'true' && |
|
371
|
|
|
api_get_setting('allow_message_tool') === 'true' |
|
372
|
|
|
) { |
|
373
|
|
|
// All users |
|
374
|
|
|
if ($allowSendMessageToAllUsers === 'true' || api_is_platform_admin()) { |
|
375
|
|
|
$dql = "SELECT DISTINCT U |
|
376
|
|
|
FROM ChamiloUserBundle:User U |
|
377
|
|
|
LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R |
|
378
|
|
|
WITH U = R.user |
|
379
|
|
|
WHERE |
|
380
|
|
|
U.active = 1 AND |
|
381
|
|
|
U.status != 6 AND |
|
382
|
|
|
U.id != $currentUserId AND |
|
383
|
|
|
R.portal = $accessUrlId"; |
|
384
|
|
|
} else { |
|
385
|
|
|
$dql = "SELECT DISTINCT U |
|
386
|
|
|
FROM ChamiloCoreBundle:AccessUrlRelUser R, ChamiloCoreBundle:UserRelUser UF |
|
387
|
|
|
INNER JOIN ChamiloUserBundle:User AS U |
|
388
|
|
|
WITH UF.friendUserId = U |
|
389
|
|
|
WHERE |
|
390
|
|
|
U.active = 1 AND |
|
391
|
|
|
U.status != 6 AND |
|
392
|
|
|
UF.relationType NOT IN(".USER_RELATION_TYPE_DELETED.", ".USER_RELATION_TYPE_RRHH.") AND |
|
393
|
|
|
UF.userId = $currentUserId AND |
|
394
|
|
|
UF.friendUserId != $currentUserId AND |
|
395
|
|
|
U = R.user AND |
|
396
|
|
|
R.portal = $accessUrlId"; |
|
397
|
|
|
} |
|
398
|
|
|
} elseif ( |
|
399
|
|
|
api_get_setting('allow_social_tool') === 'false' && |
|
400
|
|
|
api_get_setting('allow_message_tool') === 'true' |
|
401
|
|
|
) { |
|
402
|
|
|
if ($allowSendMessageToAllUsers === 'true') { |
|
403
|
|
|
$dql = "SELECT DISTINCT U |
|
404
|
|
|
FROM ChamiloUserBundle:User U |
|
405
|
|
|
LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R |
|
406
|
|
|
WITH U = R.user |
|
407
|
|
|
WHERE |
|
408
|
|
|
U.active = 1 AND |
|
409
|
|
|
U.status != 6 AND |
|
410
|
|
|
U.id != $currentUserId AND |
|
411
|
|
|
R.portal = $accessUrlId"; |
|
412
|
|
|
} else { |
|
413
|
|
|
$time_limit = api_get_setting('time_limit_whosonline'); |
|
414
|
|
|
$online_time = time() - $time_limit * 60; |
|
415
|
|
|
$limit_date = api_get_utc_datetime($online_time); |
|
416
|
|
|
$dql = "SELECT DISTINCT U |
|
417
|
|
|
FROM ChamiloUserBundle:User U |
|
418
|
|
|
LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R |
|
419
|
|
|
WITH U = R.user |
|
420
|
|
|
INNER JOIN ChamiloCoreBundle:TrackEOnline T |
|
421
|
|
|
WITH U.id = T.loginUserId |
|
422
|
|
|
WHERE |
|
423
|
|
|
R.portal = $accessUrlId AND |
|
424
|
|
|
U.active = 1 AND |
|
425
|
|
|
T.loginDate >= '".$limit_date."'"; |
|
426
|
|
|
} |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
|
|
$dql .= ' AND (U.firstname LIKE :search OR U.lastname LIKE :search OR U.email LIKE :search OR U.username LIKE :search)'; |
|
|
|
|
|
|
430
|
|
|
|
|
431
|
|
|
return $this->getEntityManager() |
|
432
|
|
|
->createQuery($dql) |
|
433
|
|
|
->setMaxResults($limit) |
|
434
|
|
|
->setParameters(['search' => "%$search%"]) |
|
435
|
|
|
->getResult(); |
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
/** |
|
439
|
|
|
* Get the list of HRM who have assigned this user. |
|
440
|
|
|
* |
|
441
|
|
|
* @param int $userId |
|
442
|
|
|
* @param int $urlId |
|
443
|
|
|
* |
|
444
|
|
|
* @return array |
|
445
|
|
|
*/ |
|
446
|
|
|
public function getAssignedHrmUserList($userId, $urlId) |
|
447
|
|
|
{ |
|
448
|
|
|
$qb = $this->createQueryBuilder('user'); |
|
449
|
|
|
|
|
450
|
|
|
$hrmList = $qb |
|
451
|
|
|
->select('uru') |
|
452
|
|
|
->innerJoin('ChamiloCoreBundle:UserRelUser', 'uru', Join::WITH, 'uru.userId = user.id') |
|
453
|
|
|
->innerJoin('ChamiloCoreBundle:AccessUrlRelUser', 'auru', Join::WITH, 'auru.userId = uru.friendUserId') |
|
454
|
|
|
->where( |
|
455
|
|
|
$qb->expr()->eq('auru.accessUrlId', $urlId) |
|
456
|
|
|
) |
|
457
|
|
|
->andWhere( |
|
458
|
|
|
$qb->expr()->eq('uru.userId', $userId) |
|
459
|
|
|
) |
|
460
|
|
|
->andWhere( |
|
461
|
|
|
$qb->expr()->eq('uru.relationType', USER_RELATION_TYPE_RRHH) |
|
462
|
|
|
) |
|
463
|
|
|
->getQuery() |
|
464
|
|
|
->getResult(); |
|
465
|
|
|
|
|
466
|
|
|
return $hrmList; |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
/** |
|
470
|
|
|
* Serialize the whole entity to an array. |
|
471
|
|
|
* |
|
472
|
|
|
* @param int $userId |
|
473
|
|
|
* @param array $substitutionTerms Substitute terms for some elements |
|
474
|
|
|
* |
|
475
|
|
|
* @return string |
|
476
|
|
|
*/ |
|
477
|
|
|
public function getPersonalDataToJson($userId, array $substitutionTerms) |
|
478
|
|
|
{ |
|
479
|
|
|
$em = $this->getEntityManager(); |
|
480
|
|
|
$dateFormat = \Datetime::ATOM; |
|
481
|
|
|
|
|
482
|
|
|
/** @var User $user */ |
|
483
|
|
|
$dbUser = $this->find($userId); |
|
484
|
|
|
|
|
485
|
|
|
$user = new User(); |
|
486
|
|
|
$user->setUserId($userId); |
|
487
|
|
|
$user->setPassword($substitutionTerms['password']); |
|
488
|
|
|
$user->setSalt($substitutionTerms['salt']); |
|
489
|
|
|
$noDataLabel = $substitutionTerms['empty']; |
|
490
|
|
|
|
|
491
|
|
|
// Dummy content |
|
492
|
|
|
$user->setDateOfBirth(null); |
|
493
|
|
|
//$user->setBiography($noDataLabel); |
|
494
|
|
|
$user->setFacebookData($noDataLabel); |
|
495
|
|
|
$user->setFacebookName($noDataLabel); |
|
496
|
|
|
$user->setFacebookUid($noDataLabel); |
|
497
|
|
|
//$user->setImageName($noDataLabel); |
|
498
|
|
|
//$user->setTwoStepVerificationCode($noDataLabel); |
|
499
|
|
|
$user->setGender($noDataLabel); |
|
500
|
|
|
$user->setGplusData($noDataLabel); |
|
501
|
|
|
$user->setGplusName($noDataLabel); |
|
502
|
|
|
$user->setGplusUid($noDataLabel); |
|
503
|
|
|
$user->setLocale($noDataLabel); |
|
504
|
|
|
$user->setTimezone($noDataLabel); |
|
505
|
|
|
$user->setTwitterData($noDataLabel); |
|
506
|
|
|
$user->setTwitterName($noDataLabel); |
|
507
|
|
|
$user->setTwitterUid($noDataLabel); |
|
508
|
|
|
$user->setWebsite($noDataLabel); |
|
509
|
|
|
$user->setToken($noDataLabel); |
|
510
|
|
|
|
|
511
|
|
|
$user->setFirstname($dbUser->getFirstname()); |
|
512
|
|
|
$user->setLastname($dbUser->getLastname()); |
|
513
|
|
|
$user->setAuthSource($dbUser->getAuthSource()); |
|
514
|
|
|
$user->setEmail($dbUser->getEmail()); |
|
515
|
|
|
$user->setStatus($dbUser->getStatus()); |
|
516
|
|
|
$user->setOfficialCode($dbUser->getOfficialCode()); |
|
517
|
|
|
$user->setPhone($dbUser->getPhone()); |
|
518
|
|
|
$user->setAddress($dbUser->getAddress()); |
|
519
|
|
|
$user->setPictureUri($dbUser->getPictureUri()); |
|
520
|
|
|
$user->setCreatorId($dbUser->getCreatorId()); |
|
521
|
|
|
$user->setCompetences($dbUser->getCompetences()); |
|
522
|
|
|
$user->setDiplomas($dbUser->getDiplomas()); |
|
523
|
|
|
$user->setOpenarea($dbUser->getOpenarea()); |
|
524
|
|
|
$user->setTeach($dbUser->getTeach()); |
|
525
|
|
|
$user->setProductions($dbUser->getProductions()); |
|
526
|
|
|
$user->setLanguage($dbUser->getLanguage()); |
|
527
|
|
|
$user->setRegistrationDate($dbUser->getRegistrationDate()); |
|
528
|
|
|
$user->setExpirationDate($dbUser->getExpirationDate()); |
|
529
|
|
|
$user->setActive($dbUser->getActive()); |
|
530
|
|
|
$user->setOpenid($dbUser->getOpenid()); |
|
531
|
|
|
$user->setTheme($dbUser->getTheme()); |
|
532
|
|
|
$user->setHrDeptId($dbUser->getHrDeptId()); |
|
533
|
|
|
$user->setSlug($dbUser->getSlug()); |
|
534
|
|
|
$user->setLastLogin($dbUser->getLastLogin()); |
|
535
|
|
|
//$user->setExtraFieldList($dbUser->getExtraFields()); |
|
536
|
|
|
$user->setUsername($dbUser->getUsername()); |
|
537
|
|
|
$user->setPasswordRequestedAt($dbUser->getPasswordRequestedAt()); |
|
538
|
|
|
$user->setCreatorId($dbUser->getCreatorId()); |
|
539
|
|
|
$user->setUpdatedAt($dbUser->getUpdatedAt()); |
|
540
|
|
|
|
|
541
|
|
|
if ($dbUser->getExpiresAt()) { |
|
542
|
|
|
$user->setExpiresAt($dbUser->getExpiresAt()); |
|
543
|
|
|
} |
|
544
|
|
|
|
|
545
|
|
|
$user->setExpirationDate($dbUser->getExpirationDate()); |
|
546
|
|
|
$user->setCredentialsExpireAt($dbUser->getCredentialsExpireAt()); |
|
547
|
|
|
//$user->setBiography($dbUser->getBiography()); |
|
548
|
|
|
//$user->setDateOfBirth($dbUser->getDateOfBirth()); |
|
549
|
|
|
//$user->setGender($dbUser->getGender()); |
|
550
|
|
|
//$user->setLocale($dbUser->getLocale()); |
|
551
|
|
|
//$user->setTimezone($dbUser->getTimezone()); |
|
552
|
|
|
//$user->setWebsite($dbUser->getWebsite()); |
|
553
|
|
|
$user->setUsernameCanonical($dbUser->getUsernameCanonical()); |
|
554
|
|
|
$user->setEmailCanonical($dbUser->getEmailCanonical()); |
|
555
|
|
|
$user->setRoles($dbUser->getRoles()); |
|
556
|
|
|
$user->setLocked($dbUser->getLocked()); |
|
557
|
|
|
$user->setProfileCompleted($dbUser->isProfileCompleted()); |
|
558
|
|
|
|
|
559
|
|
|
$courses = $dbUser->getCourses(); |
|
560
|
|
|
$list = []; |
|
561
|
|
|
$chatFiles = []; |
|
562
|
|
|
foreach ($courses as $course) { |
|
563
|
|
|
$list[] = $course->getCourse()->getCode(); |
|
564
|
|
|
$course->getCourse()->setToolList(null); |
|
565
|
|
|
$courseDir = api_get_path(SYS_COURSE_PATH).$course->getCourse()->getDirectory(); |
|
566
|
|
|
$documentDir = $courseDir.'/document/chat_files/'; |
|
567
|
|
|
if (is_dir($documentDir)) { |
|
568
|
|
|
$fs = new Finder(); |
|
569
|
|
|
$fs->files()->in($documentDir); |
|
570
|
|
|
foreach ($fs as $file) { |
|
571
|
|
|
$chatFiles[] = |
|
572
|
|
|
$course->getCourse()->getDirectory().'/document/chat_files/'.$file->getFilename().' - '. |
|
573
|
|
|
get_lang('ContentNotAccessibleRequestFromDataPrivacyOfficer'); |
|
574
|
|
|
} |
|
575
|
|
|
} |
|
576
|
|
|
} |
|
577
|
|
|
|
|
578
|
|
|
$user->setCourses($list); |
|
579
|
|
|
|
|
580
|
|
|
$classes = $dbUser->getClasses(); |
|
581
|
|
|
$list = []; |
|
582
|
|
|
foreach ($classes as $class) { |
|
583
|
|
|
$name = $class->getUsergroup()->getName(); |
|
584
|
|
|
$list[$class->getUsergroup()->getGroupType()][] = $name.' - Status: '.$class->getRelationType(); |
|
585
|
|
|
} |
|
586
|
|
|
$user->setClasses($list); |
|
587
|
|
|
|
|
588
|
|
|
$collection = $dbUser->getSessionCourseSubscriptions(); |
|
589
|
|
|
$list = []; |
|
590
|
|
|
foreach ($collection as $item) { |
|
591
|
|
|
$list[$item->getSession()->getName()][] = $item->getCourse()->getCode(); |
|
592
|
|
|
} |
|
593
|
|
|
$user->setSessionCourseSubscriptions($list); |
|
594
|
|
|
|
|
595
|
|
|
$documents = \DocumentManager::getAllDocumentsCreatedByUser($userId); |
|
596
|
|
|
$friends = \SocialManager::get_friends($userId); |
|
597
|
|
|
$friendList = []; |
|
598
|
|
|
if (!empty($friends)) { |
|
599
|
|
|
foreach ($friends as $friend) { |
|
600
|
|
|
$friendList[] = $friend['user_info']['complete_name']; |
|
601
|
|
|
} |
|
602
|
|
|
} |
|
603
|
|
|
|
|
604
|
|
|
$agenda = new \Agenda('personal'); |
|
605
|
|
|
$events = $agenda->getEvents('', '', null, null, $userId, 'array'); |
|
606
|
|
|
$eventList = []; |
|
607
|
|
|
if (!empty($events)) { |
|
608
|
|
|
foreach ($events as $event) { |
|
609
|
|
|
$eventList[] = $event['title'].' '.$event['start_date_localtime'].' / '.$event['end_date_localtime']; |
|
610
|
|
|
} |
|
611
|
|
|
} |
|
612
|
|
|
|
|
613
|
|
|
// GradebookCertificate |
|
614
|
|
|
$criteria = [ |
|
615
|
|
|
'userId' => $userId, |
|
616
|
|
|
]; |
|
617
|
|
|
$result = $em->getRepository('ChamiloCoreBundle:GradebookCertificate')->findBy($criteria); |
|
618
|
|
|
$gradebookCertificate = []; |
|
619
|
|
|
/** @var GradebookCertificate $item */ |
|
620
|
|
|
foreach ($result as $item) { |
|
621
|
|
|
$createdAt = $item->getCreatedAt() ? $item->getCreatedAt()->format($dateFormat) : ''; |
|
622
|
|
|
$list = [ |
|
623
|
|
|
'Score: '.$item->getScoreCertificate(), |
|
624
|
|
|
'Path: '.$item->getPathCertificate(), |
|
625
|
|
|
'Created at: '.$createdAt, |
|
626
|
|
|
]; |
|
627
|
|
|
$gradebookCertificate[] = implode(', ', $list); |
|
628
|
|
|
} |
|
629
|
|
|
|
|
630
|
|
|
// TrackEExercises |
|
631
|
|
|
$criteria = [ |
|
632
|
|
|
'exeUserId' => $userId, |
|
633
|
|
|
]; |
|
634
|
|
|
$result = $em->getRepository('ChamiloCoreBundle:TrackEExercises')->findBy($criteria); |
|
635
|
|
|
$trackEExercises = []; |
|
636
|
|
|
/** @var TrackEExercises $item */ |
|
637
|
|
|
foreach ($result as $item) { |
|
638
|
|
|
$date = $item->getExeDate() ? $item->getExeDate()->format($dateFormat) : ''; |
|
639
|
|
|
$list = [ |
|
640
|
|
|
'IP: '.$item->getUserIp(), |
|
641
|
|
|
'Start: '.$date, |
|
642
|
|
|
'Status: '.$item->getStatus(), |
|
643
|
|
|
// 'Result: '.$item->getExeResult(), |
|
644
|
|
|
// 'Weighting: '.$item->getExeWeighting(), |
|
645
|
|
|
]; |
|
646
|
|
|
$trackEExercises[] = implode(', ', $list); |
|
647
|
|
|
} |
|
648
|
|
|
|
|
649
|
|
|
// TrackEAttempt |
|
650
|
|
|
$criteria = [ |
|
651
|
|
|
'userId' => $userId, |
|
652
|
|
|
]; |
|
653
|
|
|
$result = $em->getRepository('ChamiloCoreBundle:TrackEAttempt')->findBy($criteria); |
|
654
|
|
|
$trackEAttempt = []; |
|
655
|
|
|
/** @var TrackEAttempt $item */ |
|
656
|
|
|
foreach ($result as $item) { |
|
657
|
|
|
$date = $item->getTms() ? $item->getTms()->format($dateFormat) : ''; |
|
658
|
|
|
$list = [ |
|
659
|
|
|
'Attempt #'.$item->getExeId(), |
|
660
|
|
|
'Course # '.$item->getCId(), |
|
661
|
|
|
//'Answer: '.$item->getAnswer(), |
|
662
|
|
|
'Session #'.$item->getSessionId(), |
|
663
|
|
|
//'Marks: '.$item->getMarks(), |
|
664
|
|
|
'Position: '.$item->getPosition(), |
|
665
|
|
|
'Date: '.$date, |
|
666
|
|
|
]; |
|
667
|
|
|
$trackEAttempt[] = implode(', ', $list); |
|
668
|
|
|
} |
|
669
|
|
|
|
|
670
|
|
|
// TrackECourseAccess |
|
671
|
|
|
$criteria = [ |
|
672
|
|
|
'userId' => $userId, |
|
673
|
|
|
]; |
|
674
|
|
|
$result = $em->getRepository('ChamiloCoreBundle:TrackECourseAccess')->findBy($criteria); |
|
675
|
|
|
$trackECourseAccessList = []; |
|
676
|
|
|
/** @var TrackECourseAccess $item */ |
|
677
|
|
|
foreach ($result as $item) { |
|
678
|
|
|
$startDate = $item->getLoginCourseDate() ? $item->getLoginCourseDate()->format($dateFormat) : ''; |
|
679
|
|
|
$endDate = $item->getLogoutCourseDate() ? $item->getLogoutCourseDate()->format($dateFormat) : ''; |
|
680
|
|
|
$list = [ |
|
681
|
|
|
'IP: '.$item->getUserIp(), |
|
682
|
|
|
'Start: '.$startDate, |
|
683
|
|
|
'End: '.$endDate, |
|
684
|
|
|
]; |
|
685
|
|
|
$trackECourseAccessList[] = implode(', ', $list); |
|
686
|
|
|
} |
|
687
|
|
|
|
|
688
|
|
|
$checkEntities = [ |
|
689
|
|
|
'ChamiloCoreBundle:TrackELogin' => 'loginUserId', |
|
690
|
|
|
'ChamiloCoreBundle:TrackEAccess' => 'accessUserId', |
|
691
|
|
|
'ChamiloCoreBundle:TrackEOnline' => 'loginUserId', |
|
692
|
|
|
'ChamiloCoreBundle:TrackEDefault' => 'defaultUserId', |
|
693
|
|
|
'ChamiloCoreBundle:TrackELastaccess' => 'accessUserId', |
|
694
|
|
|
'ChamiloCoreBundle:TrackEUploads' => 'uploadUserId', |
|
695
|
|
|
'ChamiloCoreBundle:GradebookResult' => 'userId', |
|
696
|
|
|
'ChamiloCoreBundle:TrackEDownloads' => 'downUserId', |
|
697
|
|
|
]; |
|
698
|
|
|
|
|
699
|
|
|
$maxResults = 1000; |
|
700
|
|
|
$trackResults = []; |
|
701
|
|
|
foreach ($checkEntities as $entity => $field) { |
|
702
|
|
|
$qb = $em->createQueryBuilder(); |
|
703
|
|
|
$qb->select($qb->expr()->count('l')) |
|
704
|
|
|
->from($entity, 'l') |
|
705
|
|
|
->where("l.$field = :login") |
|
706
|
|
|
->setParameter('login', $userId); |
|
707
|
|
|
$query = $qb->getQuery(); |
|
708
|
|
|
$count = $query->getSingleScalarResult(); |
|
709
|
|
|
|
|
710
|
|
|
if ($count > $maxResults) { |
|
711
|
|
|
$qb = $em->getRepository($entity)->createQueryBuilder('l'); |
|
712
|
|
|
$qb |
|
713
|
|
|
->select('l') |
|
714
|
|
|
->where("l.$field = :login") |
|
715
|
|
|
->setParameter('login', $userId); |
|
716
|
|
|
$qb |
|
717
|
|
|
->setFirstResult(0) |
|
718
|
|
|
->setMaxResults($maxResults) |
|
719
|
|
|
; |
|
720
|
|
|
$result = $qb->getQuery()->getResult(); |
|
721
|
|
|
} else { |
|
722
|
|
|
$criteria = [ |
|
723
|
|
|
$field => $userId, |
|
724
|
|
|
]; |
|
725
|
|
|
$result = $em->getRepository($entity)->findBy($criteria); |
|
726
|
|
|
} |
|
727
|
|
|
$trackResults[$entity] = $result; |
|
728
|
|
|
} |
|
729
|
|
|
|
|
730
|
|
|
$trackELoginList = []; |
|
731
|
|
|
/** @var TrackELogin $item */ |
|
732
|
|
|
foreach ($trackResults['ChamiloCoreBundle:TrackELogin'] as $item) { |
|
733
|
|
|
$startDate = $item->getLoginDate() ? $item->getLoginDate()->format($dateFormat) : ''; |
|
734
|
|
|
$endDate = $item->getLogoutDate() ? $item->getLogoutDate()->format($dateFormat) : ''; |
|
735
|
|
|
$list = [ |
|
736
|
|
|
'IP: '.$item->getUserIp(), |
|
737
|
|
|
'Start: '.$startDate, |
|
738
|
|
|
'End: '.$endDate, |
|
739
|
|
|
]; |
|
740
|
|
|
$trackELoginList[] = implode(', ', $list); |
|
741
|
|
|
} |
|
742
|
|
|
|
|
743
|
|
|
// TrackEAccess |
|
744
|
|
|
$trackEAccessList = []; |
|
745
|
|
|
/** @var TrackEAccess $item */ |
|
746
|
|
|
foreach ($trackResults['ChamiloCoreBundle:TrackEAccess'] as $item) { |
|
747
|
|
|
$date = $item->getAccessDate() ? $item->getAccessDate()->format($dateFormat) : ''; |
|
748
|
|
|
$list = [ |
|
749
|
|
|
'IP: '.$item->getUserIp(), |
|
750
|
|
|
'Tool: '.$item->getAccessTool(), |
|
751
|
|
|
'End: '.$date, |
|
752
|
|
|
]; |
|
753
|
|
|
$trackEAccessList[] = implode(', ', $list); |
|
754
|
|
|
} |
|
755
|
|
|
|
|
756
|
|
|
// TrackEOnline |
|
757
|
|
|
$trackEOnlineList = []; |
|
758
|
|
|
/** @var TrackEOnline $item */ |
|
759
|
|
|
foreach ($trackResults['ChamiloCoreBundle:TrackEOnline'] as $item) { |
|
760
|
|
|
$date = $item->getLoginDate() ? $item->getLoginDate()->format($dateFormat) : ''; |
|
761
|
|
|
$list = [ |
|
762
|
|
|
'IP: '.$item->getUserIp(), |
|
763
|
|
|
'Login date: '.$date, |
|
764
|
|
|
'Course # '.$item->getCId(), |
|
765
|
|
|
'Session # '.$item->getSessionId(), |
|
766
|
|
|
]; |
|
767
|
|
|
$trackEOnlineList[] = implode(', ', $list); |
|
768
|
|
|
} |
|
769
|
|
|
|
|
770
|
|
|
// TrackEDefault |
|
771
|
|
|
$trackEDefault = []; |
|
772
|
|
|
/** @var TrackEDefault $item */ |
|
773
|
|
|
foreach ($trackResults['ChamiloCoreBundle:TrackEDefault'] as $item) { |
|
774
|
|
|
$date = $item->getDefaultDate() ? $item->getDefaultDate()->format($dateFormat) : ''; |
|
775
|
|
|
$list = [ |
|
776
|
|
|
'Type: '.$item->getDefaultEventType(), |
|
777
|
|
|
'Value: '.$item->getDefaultValue(), |
|
778
|
|
|
'Value type: '.$item->getDefaultValueType(), |
|
779
|
|
|
'Date: '.$date, |
|
780
|
|
|
'Course #'.$item->getCId(), |
|
781
|
|
|
'Session # '.$item->getSessionId(), |
|
782
|
|
|
]; |
|
783
|
|
|
$trackEDefault[] = implode(', ', $list); |
|
784
|
|
|
} |
|
785
|
|
|
|
|
786
|
|
|
// TrackELastaccess |
|
787
|
|
|
$trackELastaccess = []; |
|
788
|
|
|
/** @var TrackELastaccess $item */ |
|
789
|
|
|
foreach ($trackResults['ChamiloCoreBundle:TrackELastaccess'] as $item) { |
|
790
|
|
|
$date = $item->getAccessDate() ? $item->getAccessDate()->format($dateFormat) : ''; |
|
791
|
|
|
$list = [ |
|
792
|
|
|
'Course #'.$item->getCId(), |
|
793
|
|
|
'Session # '.$item->getAccessSessionId(), |
|
794
|
|
|
'Tool: '.$item->getAccessTool(), |
|
795
|
|
|
'Access date: '.$date, |
|
796
|
|
|
]; |
|
797
|
|
|
$trackELastaccess[] = implode(', ', $list); |
|
798
|
|
|
} |
|
799
|
|
|
|
|
800
|
|
|
// TrackEUploads |
|
801
|
|
|
$trackEUploads = []; |
|
802
|
|
|
/** @var TrackEUploads $item */ |
|
803
|
|
|
foreach ($trackResults['ChamiloCoreBundle:TrackEUploads'] as $item) { |
|
804
|
|
|
$date = $item->getUploadDate() ? $item->getUploadDate()->format($dateFormat) : ''; |
|
805
|
|
|
$list = [ |
|
806
|
|
|
'Course #'.$item->getCId(), |
|
807
|
|
|
'Uploaded at: '.$date, |
|
808
|
|
|
'Upload id # '.$item->getUploadId(), |
|
809
|
|
|
]; |
|
810
|
|
|
$trackEUploads[] = implode(', ', $list); |
|
811
|
|
|
} |
|
812
|
|
|
|
|
813
|
|
|
$gradebookResult = []; |
|
814
|
|
|
/** @var GradebookResult $item */ |
|
815
|
|
|
foreach ($trackResults['ChamiloCoreBundle:GradebookResult'] as $item) { |
|
816
|
|
|
$date = $item->getCreatedAt() ? $item->getCreatedAt()->format($dateFormat) : ''; |
|
817
|
|
|
$list = [ |
|
818
|
|
|
'Evaluation id# '.$item->getEvaluationId(), |
|
819
|
|
|
//'Score: '.$item->getScore(), |
|
820
|
|
|
'Creation date: '.$date, |
|
821
|
|
|
]; |
|
822
|
|
|
$gradebookResult[] = implode(', ', $list); |
|
823
|
|
|
} |
|
824
|
|
|
|
|
825
|
|
|
$trackEDownloads = []; |
|
826
|
|
|
/** @var TrackEDownloads $item */ |
|
827
|
|
|
foreach ($trackResults['ChamiloCoreBundle:TrackEDownloads'] as $item) { |
|
828
|
|
|
$date = $item->getDownDate() ? $item->getDownDate()->format($dateFormat) : ''; |
|
829
|
|
|
$list = [ |
|
830
|
|
|
'File: '.$item->getDownDocPath(), |
|
831
|
|
|
'Download at: '.$date, |
|
832
|
|
|
]; |
|
833
|
|
|
$trackEDownloads[] = implode(', ', $list); |
|
834
|
|
|
} |
|
835
|
|
|
|
|
836
|
|
|
// UserCourseCategory |
|
837
|
|
|
$criteria = [ |
|
838
|
|
|
'userId' => $userId, |
|
839
|
|
|
]; |
|
840
|
|
|
$result = $em->getRepository('ChamiloCoreBundle:UserCourseCategory')->findBy($criteria); |
|
841
|
|
|
$userCourseCategory = []; |
|
842
|
|
|
/** @var UserCourseCategory $item */ |
|
843
|
|
|
foreach ($result as $item) { |
|
844
|
|
|
$list = [ |
|
845
|
|
|
'Title: '.$item->getTitle(), |
|
846
|
|
|
]; |
|
847
|
|
|
$userCourseCategory[] = implode(', ', $list); |
|
848
|
|
|
} |
|
849
|
|
|
|
|
850
|
|
|
// Forum |
|
851
|
|
|
$criteria = [ |
|
852
|
|
|
'posterId' => $userId, |
|
853
|
|
|
]; |
|
854
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CForumPost')->findBy($criteria); |
|
855
|
|
|
$cForumPostList = []; |
|
856
|
|
|
/** @var CForumPost $item */ |
|
857
|
|
|
foreach ($result as $item) { |
|
858
|
|
|
$date = $item->getPostDate() ? $item->getPostDate()->format($dateFormat) : ''; |
|
859
|
|
|
$list = [ |
|
860
|
|
|
'Title: '.$item->getPostTitle(), |
|
861
|
|
|
'Creation date: '.$date, |
|
862
|
|
|
]; |
|
863
|
|
|
$cForumPostList[] = implode(', ', $list); |
|
864
|
|
|
} |
|
865
|
|
|
|
|
866
|
|
|
// CForumThread |
|
867
|
|
|
$criteria = [ |
|
868
|
|
|
'threadPosterId' => $userId, |
|
869
|
|
|
]; |
|
870
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CForumThread')->findBy($criteria); |
|
871
|
|
|
$cForumThreadList = []; |
|
872
|
|
|
/** @var CForumThread $item */ |
|
873
|
|
|
foreach ($result as $item) { |
|
874
|
|
|
$date = $item->getThreadDate() ? $item->getThreadDate()->format($dateFormat) : ''; |
|
875
|
|
|
$list = [ |
|
876
|
|
|
'Title: '.$item->getThreadTitle(), |
|
877
|
|
|
'Creation date: '.$date, |
|
878
|
|
|
]; |
|
879
|
|
|
$cForumThreadList[] = implode(', ', $list); |
|
880
|
|
|
} |
|
881
|
|
|
|
|
882
|
|
|
// CForumAttachment |
|
883
|
|
|
/*$criteria = [ |
|
884
|
|
|
'threadPosterId' => $userId, |
|
885
|
|
|
]; |
|
886
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CForumAttachment')->findBy($criteria); |
|
887
|
|
|
$cForumThreadList = []; |
|
888
|
|
|
* @var CForumThread $item |
|
889
|
|
|
foreach ($result as $item) { |
|
890
|
|
|
$list = [ |
|
891
|
|
|
'Title: '.$item->getThreadTitle(), |
|
892
|
|
|
'Creation date: '.$item->getThreadDate()->format($dateFormat), |
|
893
|
|
|
]; |
|
894
|
|
|
$cForumThreadList[] = implode(', ', $list); |
|
895
|
|
|
}*/ |
|
896
|
|
|
|
|
897
|
|
|
// cGroupRelUser |
|
898
|
|
|
$criteria = [ |
|
899
|
|
|
'userId' => $userId, |
|
900
|
|
|
]; |
|
901
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CGroupRelUser')->findBy($criteria); |
|
902
|
|
|
$cGroupRelUser = []; |
|
903
|
|
|
/** @var CGroupRelUser $item */ |
|
904
|
|
|
foreach ($result as $item) { |
|
905
|
|
|
$list = [ |
|
906
|
|
|
'Course # '.$item->getCId(), |
|
907
|
|
|
'Group #'.$item->getGroupId(), |
|
908
|
|
|
'Role: '.$item->getStatus(), |
|
909
|
|
|
]; |
|
910
|
|
|
$cGroupRelUser[] = implode(', ', $list); |
|
911
|
|
|
} |
|
912
|
|
|
|
|
913
|
|
|
// CAttendanceSheet |
|
914
|
|
|
$criteria = [ |
|
915
|
|
|
'userId' => $userId, |
|
916
|
|
|
]; |
|
917
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CAttendanceSheet')->findBy($criteria); |
|
918
|
|
|
$cAttendanceSheetList = []; |
|
919
|
|
|
/** @var CAttendanceSheet $item */ |
|
920
|
|
|
foreach ($result as $item) { |
|
921
|
|
|
$list = [ |
|
922
|
|
|
'Presence: '.$item->getPresence(), |
|
923
|
|
|
'Calendar id: '.$item->getAttendanceCalendarId(), |
|
924
|
|
|
]; |
|
925
|
|
|
$cAttendanceSheetList[] = implode(', ', $list); |
|
926
|
|
|
} |
|
927
|
|
|
|
|
928
|
|
|
// CBlogPost |
|
929
|
|
|
$criteria = [ |
|
930
|
|
|
'authorId' => $userId, |
|
931
|
|
|
]; |
|
932
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CBlogPost')->findBy($criteria); |
|
933
|
|
|
$cBlog = []; |
|
934
|
|
|
/** @var CBlogPost $item */ |
|
935
|
|
|
foreach ($result as $item) { |
|
936
|
|
|
$date = $item->getDateCreation() ? $item->getDateCreation()->format($dateFormat) : ''; |
|
937
|
|
|
$list = [ |
|
938
|
|
|
'Title: '.$item->getTitle(), |
|
939
|
|
|
'Date: '.$date, |
|
940
|
|
|
]; |
|
941
|
|
|
$cBlog[] = implode(', ', $list); |
|
942
|
|
|
} |
|
943
|
|
|
|
|
944
|
|
|
// CAttendanceResult |
|
945
|
|
|
$criteria = [ |
|
946
|
|
|
'userId' => $userId, |
|
947
|
|
|
]; |
|
948
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CAttendanceResult')->findBy($criteria); |
|
949
|
|
|
$cAttendanceResult = []; |
|
950
|
|
|
/** @var CAttendanceResult $item */ |
|
951
|
|
|
foreach ($result as $item) { |
|
952
|
|
|
$list = [ |
|
953
|
|
|
'Score : '.$item->getScore(), |
|
954
|
|
|
'Calendar id: '.$item->getAttendanceId(), |
|
955
|
|
|
]; |
|
956
|
|
|
$cAttendanceResult[] = implode(', ', $list); |
|
957
|
|
|
} |
|
958
|
|
|
|
|
959
|
|
|
// Message |
|
960
|
|
|
$criteria = [ |
|
961
|
|
|
'userSenderId' => $userId, |
|
962
|
|
|
]; |
|
963
|
|
|
$result = $em->getRepository('ChamiloCoreBundle:Message')->findBy($criteria); |
|
964
|
|
|
$messageList = []; |
|
965
|
|
|
/** @var Message $item */ |
|
966
|
|
|
foreach ($result as $item) { |
|
967
|
|
|
$date = $item->getSendDate() ? $item->getSendDate()->format($dateFormat) : ''; |
|
968
|
|
|
$list = [ |
|
969
|
|
|
'Title: '.$item->getTitle(), |
|
970
|
|
|
'Sent date: '.$date, |
|
971
|
|
|
'To user # '.$item->getUserReceiverId(), |
|
972
|
|
|
'Status'.$item->getMsgStatus(), |
|
973
|
|
|
]; |
|
974
|
|
|
$messageList[] = implode(', ', $list); |
|
975
|
|
|
} |
|
976
|
|
|
|
|
977
|
|
|
// CSurveyAnswer |
|
978
|
|
|
$criteria = [ |
|
979
|
|
|
'user' => $userId, |
|
980
|
|
|
]; |
|
981
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CSurveyAnswer')->findBy($criteria); |
|
982
|
|
|
$cSurveyAnswer = []; |
|
983
|
|
|
/** @var CSurveyAnswer $item */ |
|
984
|
|
|
foreach ($result as $item) { |
|
985
|
|
|
$list = [ |
|
986
|
|
|
'Answer # '.$item->getAnswerId(), |
|
987
|
|
|
'Value: '.$item->getValue(), |
|
988
|
|
|
]; |
|
989
|
|
|
$cSurveyAnswer[] = implode(', ', $list); |
|
990
|
|
|
} |
|
991
|
|
|
|
|
992
|
|
|
// CDropboxFile |
|
993
|
|
|
$criteria = [ |
|
994
|
|
|
'uploaderId' => $userId, |
|
995
|
|
|
]; |
|
996
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CDropboxFile')->findBy($criteria); |
|
997
|
|
|
$cDropboxFile = []; |
|
998
|
|
|
/** @var CDropboxFile $item */ |
|
999
|
|
|
foreach ($result as $item) { |
|
1000
|
|
|
$date = $item->getUploadDate() ? $item->getUploadDate()->format($dateFormat) : ''; |
|
1001
|
|
|
$list = [ |
|
1002
|
|
|
'Title: '.$item->getTitle(), |
|
1003
|
|
|
'Uploaded date: '.$date, |
|
1004
|
|
|
'File: '.$item->getFilename(), |
|
1005
|
|
|
]; |
|
1006
|
|
|
$cDropboxFile[] = implode(', ', $list); |
|
1007
|
|
|
} |
|
1008
|
|
|
|
|
1009
|
|
|
// CDropboxPerson |
|
1010
|
|
|
$criteria = [ |
|
1011
|
|
|
'userId' => $userId, |
|
1012
|
|
|
]; |
|
1013
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CDropboxPerson')->findBy($criteria); |
|
1014
|
|
|
$cDropboxPerson = []; |
|
1015
|
|
|
/** @var CDropboxPerson $item */ |
|
1016
|
|
|
foreach ($result as $item) { |
|
1017
|
|
|
$list = [ |
|
1018
|
|
|
'File #'.$item->getFileId(), |
|
1019
|
|
|
'Course #'.$item->getCId(), |
|
1020
|
|
|
]; |
|
1021
|
|
|
$cDropboxPerson[] = implode(', ', $list); |
|
1022
|
|
|
} |
|
1023
|
|
|
|
|
1024
|
|
|
// CDropboxPerson |
|
1025
|
|
|
$criteria = [ |
|
1026
|
|
|
'authorUserId' => $userId, |
|
1027
|
|
|
]; |
|
1028
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CDropboxFeedback')->findBy($criteria); |
|
1029
|
|
|
$cDropboxFeedback = []; |
|
1030
|
|
|
/** @var CDropboxFeedback $item */ |
|
1031
|
|
|
foreach ($result as $item) { |
|
1032
|
|
|
$date = $item->getFeedbackDate() ? $item->getFeedbackDate()->format($dateFormat) : ''; |
|
1033
|
|
|
$list = [ |
|
1034
|
|
|
'File #'.$item->getFileId(), |
|
1035
|
|
|
'Feedback: '.$item->getFeedback(), |
|
1036
|
|
|
'Date: '.$date, |
|
1037
|
|
|
]; |
|
1038
|
|
|
$cDropboxFeedback[] = implode(', ', $list); |
|
1039
|
|
|
} |
|
1040
|
|
|
|
|
1041
|
|
|
// CNotebook |
|
1042
|
|
|
$criteria = [ |
|
1043
|
|
|
'userId' => $userId, |
|
1044
|
|
|
]; |
|
1045
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CNotebook')->findBy($criteria); |
|
1046
|
|
|
$cNotebook = []; |
|
1047
|
|
|
/** @var CNotebook $item */ |
|
1048
|
|
|
foreach ($result as $item) { |
|
1049
|
|
|
$date = $item->getUpdateDate() ? $item->getUpdateDate()->format($dateFormat) : ''; |
|
1050
|
|
|
$list = [ |
|
1051
|
|
|
'Title: '.$item->getTitle(), |
|
1052
|
|
|
'Date: '.$date, |
|
1053
|
|
|
]; |
|
1054
|
|
|
$cNotebook[] = implode(', ', $list); |
|
1055
|
|
|
} |
|
1056
|
|
|
|
|
1057
|
|
|
// CLpView |
|
1058
|
|
|
$criteria = [ |
|
1059
|
|
|
'userId' => $userId, |
|
1060
|
|
|
]; |
|
1061
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CLpView')->findBy($criteria); |
|
1062
|
|
|
$cLpView = []; |
|
1063
|
|
|
/** @var CLpView $item */ |
|
1064
|
|
|
foreach ($result as $item) { |
|
1065
|
|
|
$list = [ |
|
1066
|
|
|
//'Id #'.$item->getId(), |
|
1067
|
|
|
'LP #'.$item->getLpId(), |
|
1068
|
|
|
'Progress: '.$item->getProgress(), |
|
1069
|
|
|
'Course #'.$item->getCId(), |
|
1070
|
|
|
'Session #'.$item->getSessionId(), |
|
1071
|
|
|
]; |
|
1072
|
|
|
$cLpView[] = implode(', ', $list); |
|
1073
|
|
|
} |
|
1074
|
|
|
|
|
1075
|
|
|
// CStudentPublication |
|
1076
|
|
|
$criteria = [ |
|
1077
|
|
|
'userId' => $userId, |
|
1078
|
|
|
]; |
|
1079
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CStudentPublication')->findBy($criteria); |
|
1080
|
|
|
$cStudentPublication = []; |
|
1081
|
|
|
/** @var CStudentPublication $item */ |
|
1082
|
|
|
foreach ($result as $item) { |
|
1083
|
|
|
$list = [ |
|
1084
|
|
|
'Title: '.$item->getTitle(), |
|
1085
|
|
|
'URL: '.$item->getUrl(), |
|
1086
|
|
|
]; |
|
1087
|
|
|
$cStudentPublication[] = implode(', ', $list); |
|
1088
|
|
|
} |
|
1089
|
|
|
|
|
1090
|
|
|
// CStudentPublicationComment |
|
1091
|
|
|
$criteria = [ |
|
1092
|
|
|
'userId' => $userId, |
|
1093
|
|
|
]; |
|
1094
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CStudentPublicationComment')->findBy($criteria); |
|
1095
|
|
|
$cStudentPublicationComment = []; |
|
1096
|
|
|
/** @var CStudentPublicationComment $item */ |
|
1097
|
|
|
foreach ($result as $item) { |
|
1098
|
|
|
$date = $item->getSentAt() ? $item->getSentAt()->format($dateFormat) : ''; |
|
1099
|
|
|
$list = [ |
|
1100
|
|
|
'Commment: '.$item->getComment(), |
|
1101
|
|
|
'File '.$item->getFile(), |
|
1102
|
|
|
'Course # '.$item->getCId(), |
|
1103
|
|
|
'Date: '.$date, |
|
1104
|
|
|
]; |
|
1105
|
|
|
$cStudentPublicationComment[] = implode(', ', $list); |
|
1106
|
|
|
} |
|
1107
|
|
|
|
|
1108
|
|
|
// CWiki |
|
1109
|
|
|
$criteria = [ |
|
1110
|
|
|
'userId' => $userId, |
|
1111
|
|
|
]; |
|
1112
|
|
|
$result = $em->getRepository('ChamiloCourseBundle:CWiki')->findBy($criteria); |
|
1113
|
|
|
$cWiki = []; |
|
1114
|
|
|
/** @var CWiki $item */ |
|
1115
|
|
|
foreach ($result as $item) { |
|
1116
|
|
|
$list = [ |
|
1117
|
|
|
'Title: '.$item->getTitle(), |
|
1118
|
|
|
'Progress: '.$item->getProgress(), |
|
1119
|
|
|
'IP: '.$item->getUserIp(), |
|
1120
|
|
|
]; |
|
1121
|
|
|
$cWiki[] = implode(', ', $list); |
|
1122
|
|
|
} |
|
1123
|
|
|
|
|
1124
|
|
|
// Ticket |
|
1125
|
|
|
$criteria = [ |
|
1126
|
|
|
'insertUserId' => $userId, |
|
1127
|
|
|
]; |
|
1128
|
|
|
$result = $em->getRepository('ChamiloTicketBundle:Ticket')->findBy($criteria); |
|
1129
|
|
|
$ticket = []; |
|
1130
|
|
|
/** @var Ticket $item */ |
|
1131
|
|
|
foreach ($result as $item) { |
|
1132
|
|
|
$list = [ |
|
1133
|
|
|
'Code: '.$item->getCode(), |
|
1134
|
|
|
'Subject: '.$item->getSubject(), |
|
1135
|
|
|
]; |
|
1136
|
|
|
$ticket[] = implode(', ', $list); |
|
1137
|
|
|
} |
|
1138
|
|
|
|
|
1139
|
|
|
// Message |
|
1140
|
|
|
$criteria = [ |
|
1141
|
|
|
'insertUserId' => $userId, |
|
1142
|
|
|
]; |
|
1143
|
|
|
$result = $em->getRepository('ChamiloTicketBundle:Message')->findBy($criteria); |
|
1144
|
|
|
$ticketMessage = []; |
|
1145
|
|
|
/** @var \Chamilo\TicketBundle\Entity\Message $item */ |
|
1146
|
|
|
foreach ($result as $item) { |
|
1147
|
|
|
$date = $item->getInsertDateTime() ? $item->getInsertDateTime()->format($dateFormat) : ''; |
|
1148
|
|
|
$list = [ |
|
1149
|
|
|
'Subject: '.$item->getSubject(), |
|
1150
|
|
|
'IP: '.$item->getIpAddress(), |
|
1151
|
|
|
'Status: '.$item->getStatus(), |
|
1152
|
|
|
'Creation date: '.$date, |
|
1153
|
|
|
]; |
|
1154
|
|
|
$ticketMessage[] = implode(', ', $list); |
|
1155
|
|
|
} |
|
1156
|
|
|
|
|
1157
|
|
|
// SkillRelUserComment |
|
1158
|
|
|
$criteria = [ |
|
1159
|
|
|
'feedbackGiver' => $userId, |
|
1160
|
|
|
]; |
|
1161
|
|
|
$result = $em->getRepository('ChamiloCoreBundle:SkillRelUserComment')->findBy($criteria); |
|
1162
|
|
|
$skillRelUserComment = []; |
|
1163
|
|
|
/** @var SkillRelUserComment $item */ |
|
1164
|
|
|
foreach ($result as $item) { |
|
1165
|
|
|
$date = $item->getFeedbackDateTime() ? $item->getFeedbackDateTime()->format($dateFormat) : ''; |
|
1166
|
|
|
$list = [ |
|
1167
|
|
|
'Feedback: '.$item->getFeedbackText(), |
|
1168
|
|
|
'Value: '.$item->getFeedbackValue(), |
|
1169
|
|
|
'Created at: '.$date, |
|
1170
|
|
|
]; |
|
1171
|
|
|
$skillRelUserComment[] = implode(', ', $list); |
|
1172
|
|
|
} |
|
1173
|
|
|
|
|
1174
|
|
|
// UserRelCourseVote |
|
1175
|
|
|
$criteria = [ |
|
1176
|
|
|
'userId' => $userId, |
|
1177
|
|
|
]; |
|
1178
|
|
|
$result = $em->getRepository('ChamiloCoreBundle:UserRelCourseVote')->findBy($criteria); |
|
1179
|
|
|
$userRelCourseVote = []; |
|
1180
|
|
|
/** @var UserRelCourseVote $item */ |
|
1181
|
|
|
foreach ($result as $item) { |
|
1182
|
|
|
$list = [ |
|
1183
|
|
|
'Course #'.$item->getCId(), |
|
1184
|
|
|
'Session #'.$item->getSessionId(), |
|
1185
|
|
|
'Vote: '.$item->getVote(), |
|
1186
|
|
|
]; |
|
1187
|
|
|
$userRelCourseVote[] = implode(', ', $list); |
|
1188
|
|
|
} |
|
1189
|
|
|
|
|
1190
|
|
|
// UserApiKey |
|
1191
|
|
|
$criteria = [ |
|
1192
|
|
|
'userId' => $userId, |
|
1193
|
|
|
]; |
|
1194
|
|
|
$result = $em->getRepository('ChamiloCoreBundle:UserApiKey')->findBy($criteria); |
|
1195
|
|
|
$userApiKey = []; |
|
1196
|
|
|
/** @var UserApiKey $item */ |
|
1197
|
|
|
foreach ($result as $item) { |
|
1198
|
|
|
$validityStart = $item->getValidityStartDate() ? $item->getValidityStartDate()->format($dateFormat) : ''; |
|
1199
|
|
|
$validityEnd = $item->getValidityEndDate() ? $item->getValidityEndDate()->format($dateFormat) : ''; |
|
1200
|
|
|
$created = $item->getCreatedDate() ? $item->getCreatedDate()->format($dateFormat) : ''; |
|
1201
|
|
|
|
|
1202
|
|
|
$list = [ |
|
1203
|
|
|
'ApiKey #'.$item->getApiKey(), |
|
1204
|
|
|
'Service: '.$item->getApiService(), |
|
1205
|
|
|
'EndPoint: '.$item->getApiEndPoint(), |
|
1206
|
|
|
'Validity start date: '.$validityStart, |
|
1207
|
|
|
'Validity enddate: '.$validityEnd, |
|
1208
|
|
|
'Created at: '.$created, |
|
1209
|
|
|
]; |
|
1210
|
|
|
$userApiKey[] = implode(', ', $list); |
|
1211
|
|
|
} |
|
1212
|
|
|
|
|
1213
|
|
|
$user->setDropBoxSentFiles( |
|
1214
|
|
|
[ |
|
1215
|
|
|
'Friends' => $friendList, |
|
1216
|
|
|
'Events' => $eventList, |
|
1217
|
|
|
'GradebookCertificate' => $gradebookCertificate, |
|
1218
|
|
|
'TrackECourseAccess' => $trackECourseAccessList, |
|
1219
|
|
|
'TrackELogin' => $trackELoginList, |
|
1220
|
|
|
'TrackEAccess' => $trackEAccessList, |
|
1221
|
|
|
'TrackEDefault' => $trackEDefault, |
|
1222
|
|
|
'TrackEOnline' => $trackEOnlineList, |
|
1223
|
|
|
'TrackEUploads' => $trackEUploads, |
|
1224
|
|
|
'TrackELastaccess' => $trackELastaccess, |
|
1225
|
|
|
'GradebookResult' => $gradebookResult, |
|
1226
|
|
|
'Downloads' => $trackEDownloads, |
|
1227
|
|
|
'UserCourseCategory' => $userCourseCategory, |
|
1228
|
|
|
'SkillRelUserComment' => $skillRelUserComment, |
|
1229
|
|
|
'UserRelCourseVote' => $userRelCourseVote, |
|
1230
|
|
|
'UserApiKey' => $userApiKey, |
|
1231
|
|
|
|
|
1232
|
|
|
// courses |
|
1233
|
|
|
'AttendanceResult' => $cAttendanceResult, |
|
1234
|
|
|
'Blog' => $cBlog, |
|
1235
|
|
|
'DocumentsAdded' => $documents, |
|
1236
|
|
|
'Chat' => $chatFiles, |
|
1237
|
|
|
'ForumPost' => $cForumPostList, |
|
1238
|
|
|
'ForumThread' => $cForumThreadList, |
|
1239
|
|
|
'TrackEExercises' => $trackEExercises, |
|
1240
|
|
|
'TrackEAttempt' => $trackEAttempt, |
|
1241
|
|
|
|
|
1242
|
|
|
'GroupRelUser' => $cGroupRelUser, |
|
1243
|
|
|
'Message' => $messageList, |
|
1244
|
|
|
'Survey' => $cSurveyAnswer, |
|
1245
|
|
|
'StudentPublication' => $cStudentPublication, |
|
1246
|
|
|
'StudentPublicationComment' => $cStudentPublicationComment, |
|
1247
|
|
|
'DropboxFile' => $cDropboxFile, |
|
1248
|
|
|
'DropboxPerson' => $cDropboxPerson, |
|
1249
|
|
|
'DropboxFeedback' => $cDropboxFeedback, |
|
1250
|
|
|
|
|
1251
|
|
|
'LpView' => $cLpView, |
|
1252
|
|
|
'Notebook' => $cNotebook, |
|
1253
|
|
|
|
|
1254
|
|
|
'Wiki' => $cWiki, |
|
1255
|
|
|
// Tickets |
|
1256
|
|
|
'Ticket' => $ticket, |
|
1257
|
|
|
'TicketMessage' => $ticketMessage, |
|
1258
|
|
|
] |
|
1259
|
|
|
); |
|
1260
|
|
|
|
|
1261
|
|
|
$user->setDropBoxReceivedFiles([]); |
|
1262
|
|
|
$user->setCurriculumItems([]); |
|
1263
|
|
|
|
|
1264
|
|
|
$portals = $dbUser->getPortals(); |
|
1265
|
|
|
if (!empty($portals)) { |
|
1266
|
|
|
$list = []; |
|
1267
|
|
|
/** @var AccessUrlRelUser $portal */ |
|
1268
|
|
|
foreach ($portals as $portal) { |
|
1269
|
|
|
$portalInfo = \UrlManager::get_url_data_from_id($portal->getAccessUrlId()); |
|
1270
|
|
|
$list[] = $portalInfo['url']; |
|
1271
|
|
|
} |
|
1272
|
|
|
} |
|
1273
|
|
|
$user->setPortals($list); |
|
1274
|
|
|
|
|
1275
|
|
|
$coachList = $dbUser->getSessionAsGeneralCoach(); |
|
1276
|
|
|
$list = []; |
|
1277
|
|
|
/** @var Session $session */ |
|
1278
|
|
|
foreach ($coachList as $session) { |
|
1279
|
|
|
$list[] = $session->getName(); |
|
1280
|
|
|
} |
|
1281
|
|
|
$user->setSessionAsGeneralCoach($list); |
|
1282
|
|
|
|
|
1283
|
|
|
$skillRelUserList = $dbUser->getAchievedSkills(); |
|
1284
|
|
|
$list = []; |
|
1285
|
|
|
/** @var SkillRelUser $skillRelUser */ |
|
1286
|
|
|
foreach ($skillRelUserList as $skillRelUser) { |
|
1287
|
|
|
$list[] = $skillRelUser->getSkill()->getName(); |
|
1288
|
|
|
} |
|
1289
|
|
|
$user->setAchievedSkills($list); |
|
1290
|
|
|
$user->setCommentedUserSkills([]); |
|
1291
|
|
|
|
|
1292
|
|
|
$extraFieldValues = new \ExtraFieldValue('user'); |
|
1293
|
|
|
$items = $extraFieldValues->getAllValuesByItem($userId); |
|
1294
|
|
|
$user->setExtraFields($items); |
|
1295
|
|
|
|
|
1296
|
|
|
$lastLogin = $dbUser->getLastLogin(); |
|
1297
|
|
|
if (empty($lastLogin)) { |
|
1298
|
|
|
$login = $this->getLastLogin($dbUser); |
|
1299
|
|
|
if ($login) { |
|
1300
|
|
|
$lastLogin = $login->getLoginDate(); |
|
1301
|
|
|
} |
|
1302
|
|
|
} |
|
1303
|
|
|
|
|
1304
|
|
|
if (!empty($lastLogin)) { |
|
1305
|
|
|
$user->setLastLogin($lastLogin); |
|
1306
|
|
|
} |
|
1307
|
|
|
|
|
1308
|
|
|
$dateNormalizer = new GetSetMethodNormalizer(); |
|
1309
|
|
|
$dateNormalizer->setCircularReferenceHandler(function ($object) { |
|
1310
|
|
|
return get_class($object); |
|
1311
|
|
|
}); |
|
1312
|
|
|
|
|
1313
|
|
|
$ignore = [ |
|
1314
|
|
|
'id', |
|
1315
|
|
|
'twoStepVerificationCode', |
|
1316
|
|
|
'biography', |
|
1317
|
|
|
'dateOfBirth', |
|
1318
|
|
|
'gender', |
|
1319
|
|
|
'facebookData', |
|
1320
|
|
|
'facebookName', |
|
1321
|
|
|
'facebookUid', |
|
1322
|
|
|
'gplusData', |
|
1323
|
|
|
'gplusName', |
|
1324
|
|
|
'gplusUid', |
|
1325
|
|
|
'locale', |
|
1326
|
|
|
'timezone', |
|
1327
|
|
|
'twitterData', |
|
1328
|
|
|
'twitterName', |
|
1329
|
|
|
'twitterUid', |
|
1330
|
|
|
'gplusUid', |
|
1331
|
|
|
'token', |
|
1332
|
|
|
'website', |
|
1333
|
|
|
'plainPassword', |
|
1334
|
|
|
'completeNameWithUsername', |
|
1335
|
|
|
'completeName', |
|
1336
|
|
|
'completeNameWithClasses', |
|
1337
|
|
|
'salt', |
|
1338
|
|
|
]; |
|
1339
|
|
|
|
|
1340
|
|
|
$dateNormalizer->setIgnoredAttributes($ignore); |
|
1341
|
|
|
|
|
1342
|
|
|
$callback = function ($dateTime) { |
|
1343
|
|
|
return $dateTime instanceof \DateTime ? $dateTime->format(\DateTime::ISO8601) : ''; |
|
1344
|
|
|
}; |
|
1345
|
|
|
|
|
1346
|
|
|
$dateNormalizer->setCallbacks( |
|
1347
|
|
|
[ |
|
1348
|
|
|
'createdAt' => $callback, |
|
1349
|
|
|
'lastLogin' => $callback, |
|
1350
|
|
|
'registrationDate' => $callback, |
|
1351
|
|
|
'memberSince' => $callback, |
|
1352
|
|
|
] |
|
1353
|
|
|
); |
|
1354
|
|
|
|
|
1355
|
|
|
$serializer = new Serializer([$dateNormalizer], [new JsonEncoder()]); |
|
1356
|
|
|
|
|
1357
|
|
|
return $serializer->serialize($user, 'json'); |
|
1358
|
|
|
} |
|
1359
|
|
|
|
|
1360
|
|
|
/** |
|
1361
|
|
|
* Get the last login from the track_e_login table. |
|
1362
|
|
|
* This might be different from user.last_login in the case of legacy users |
|
1363
|
|
|
* as user.last_login was only implemented in 1.10 version with a default |
|
1364
|
|
|
* value of NULL (not the last record from track_e_login). |
|
1365
|
|
|
* |
|
1366
|
|
|
* @throws \Exception |
|
1367
|
|
|
* |
|
1368
|
|
|
* @return TrackELogin|null |
|
1369
|
|
|
*/ |
|
1370
|
|
|
public function getLastLogin(User $user) |
|
1371
|
|
|
{ |
|
1372
|
|
|
$repo = $this->getEntityManager()->getRepository('ChamiloCoreBundle:TrackELogin'); |
|
1373
|
|
|
$qb = $repo->createQueryBuilder('l'); |
|
1374
|
|
|
|
|
1375
|
|
|
return $qb |
|
1376
|
|
|
->select('l') |
|
1377
|
|
|
->where( |
|
1378
|
|
|
$qb->expr()->eq('l.loginUserId', $user->getId()) |
|
1379
|
|
|
) |
|
1380
|
|
|
->setMaxResults(1) |
|
1381
|
|
|
->orderBy('l.loginDate', 'DESC') |
|
1382
|
|
|
->getQuery() |
|
1383
|
|
|
->getOneOrNullResult(); |
|
1384
|
|
|
} |
|
1385
|
|
|
|
|
1386
|
|
|
public function findByAuthSource(string $authSource): array |
|
1387
|
|
|
{ |
|
1388
|
|
|
return $this->findBy(['authSource' => $authSource]); |
|
1389
|
|
|
} |
|
1390
|
|
|
} |
|
1391
|
|
|
|