3
3
4
4
use Chamilo \CourseBundle \Entity \CLp ;
5
5
use Chamilo \CourseBundle \Entity \CLpCategory ;
6
+ use Chamilo \CoreBundle \Entity \Message ;
6
7
7
8
/**
8
9
* Implements the tracking of students in the Reporting pages
17
18
$ origin = isset ($ _GET ['origin ' ]) ? Security::remove_XSS ($ _GET ['origin ' ]) : '' ;
18
19
$ course_code = isset ($ _GET ['course ' ]) ? Security::remove_XSS ($ _GET ['course ' ]) : '' ;
19
20
$ courseInfo = api_get_course_info ($ course_code );
20
- $ student_id = intval ($ _GET ['student ' ]);
21
+ $ student_id = isset ($ _GET ['student ' ]) ? ( int ) $ _GET [ ' student ' ] : 0 ;
21
22
22
- $ allowedToTrackUser = true ;
23
+ $ currentUrl = api_get_self ().'?student= ' .$ student_id .'&course= ' .$ course_code .'&id_session= ' .$ sessionId .'&origin= ' .$ origin ;
24
+
25
+ if (empty ($ student_id )) {
26
+ api_not_allowed (true );
27
+ }
23
28
29
+ // user info
30
+ $ user_info = api_get_user_info ($ student_id );
31
+
32
+ $ allowedToTrackUser = true ;
24
33
if (!api_is_session_admin () &&
25
34
!api_is_drh () &&
26
35
!api_is_student_boss () &&
@@ -184,11 +193,23 @@ function show_image(image,width,height) {
184
193
$ tbl_course_user = Database::get_main_table (TABLE_MAIN_COURSE_USER );
185
194
$ tbl_stats_exercices = Database::get_main_table (TABLE_STATISTIC_TRACK_E_EXERCISES );
186
195
$ user_id = isset ($ _GET ['user_id ' ]) && !empty ($ _GET ['user_id ' ]) ? (int ) $ _GET ['user_id ' ] : api_get_user_id ();
187
-
188
- // Action behaviour
189
196
$ action = isset ($ _GET ['action ' ]) ? $ _GET ['action ' ] : '' ;
190
197
191
198
switch ($ action ) {
199
+ case 'send_message ' :
200
+ $ subject = isset ($ _POST ['subject ' ]) ? $ _POST ['subject ' ] : '' ;
201
+ $ message = isset ($ _POST ['message ' ]) ? $ _POST ['message ' ] : '' ;
202
+
203
+ MessageManager::sendMessageAboutUser (
204
+ $ user_info ,
205
+ api_get_user_info (),
206
+ $ subject ,
207
+ $ message
208
+ );
209
+ Display::addFlash (Display::return_message (get_lang ('MessageSent ' )));
210
+ header ('Location: ' .$ currentUrl );
211
+ exit ;
212
+ break ;
192
213
case 'send_legal ' :
193
214
$ subject = get_lang ('SendLegalSubject ' );
194
215
$ content = sprintf (
@@ -225,18 +246,15 @@ function show_image(image,width,height) {
225
246
226
247
// @todo delete the stats.track_e_exercises records.
227
248
// First implement this http://support.chamilo.org/issues/1334
228
- $ message = Display::return_message (
249
+ Display:: addFlash ( Display::return_message (
229
250
get_lang ('LPWasReset ' ),
230
251
'success '
231
- );
252
+ )) ;
232
253
}
233
254
break ;
234
255
default :
235
256
break ;
236
257
}
237
-
238
- // user info
239
- $ user_info = api_get_user_info ($ student_id );
240
258
$ courses_in_session = array ();
241
259
242
260
//See #4676
@@ -252,11 +270,15 @@ function show_image(image,width,height) {
252
270
// RRHH or session admin
253
271
if (api_is_session_admin () || api_is_drh ()) {
254
272
$ courses = CourseManager::get_courses_followed_by_drh (api_get_user_id ());
255
- $ session_by_session_admin = SessionManager::get_sessions_followed_by_drh (api_get_user_id ());
273
+ $ session_by_session_admin = SessionManager::get_sessions_followed_by_drh (
274
+ api_get_user_id ()
275
+ );
256
276
257
277
if (!empty ($ session_by_session_admin )) {
258
278
foreach ($ session_by_session_admin as $ session_coached_by_user ) {
259
- $ courses_followed_by_coach = Tracking :: get_courses_list_from_session ($ session_coached_by_user ['id ' ]);
279
+ $ courses_followed_by_coach = Tracking::get_courses_list_from_session (
280
+ $ session_coached_by_user ['id ' ]
281
+ );
260
282
$ courses_in_session_by_coach [$ session_coached_by_user ['id ' ]] = $ courses_followed_by_coach ;
261
283
}
262
284
}
@@ -278,7 +300,7 @@ function show_image(image,width,height) {
278
300
user_id = " .intval ($ user_info ['user_id ' ]);
279
301
$ rs = Database::query ($ sql );
280
302
281
- while ($ row = Database :: fetch_array ($ rs )) {
303
+ while ($ row = Database:: fetch_array ($ rs )) {
282
304
if ($ drh_can_access_all_courses ) {
283
305
$ courses_in_session [0 ][] = $ row ['c_id ' ];
284
306
} else {
@@ -294,7 +316,7 @@ function show_image(image,width,height) {
294
316
WHERE user_id= ' . intval ($ user_info ['user_id ' ]);
295
317
$ rs = Database::query ($ sql );
296
318
$ tmp_sessions = array ();
297
- while ($ row = Database :: fetch_array ($ rs , 'ASSOC ' )) {
319
+ while ($ row = Database:: fetch_array ($ rs , 'ASSOC ' )) {
298
320
$ tmp_sessions [] = $ row ['session_id ' ];
299
321
if ($ drh_can_access_all_courses ) {
300
322
if (in_array ($ row ['session_id ' ], $ tmp_sessions )) {
@@ -339,17 +361,8 @@ function show_image(image,width,height) {
339
361
}
340
362
341
363
Display::display_header ($ nameTools );
342
-
343
- if (isset ($ message )) {
344
- echo $ message ;
345
- }
346
-
347
364
$ token = Security::get_token ();
348
365
349
- if (empty ($ student_id )) {
350
- api_not_allowed ();
351
- }
352
-
353
366
// Actions bar
354
367
echo '<div class="actions"> ' ;
355
368
echo '<a href="javascript: window.history.go(-1);"> ' .
@@ -980,7 +993,7 @@ function show_image(image,width,height) {
980
993
$lps = $query->getResult();
981
994
*/
982
995
if (true ) {
983
- $ categoriesTempList = learnpath::getCategories (api_get_course_int_id () );
996
+ $ categoriesTempList = learnpath::getCategories ($ courseInfo [ ' real_id ' ] );
984
997
$ categoryTest = new CLpCategory ();
985
998
$ categoryTest ->setId (0 );
986
999
$ categoryTest ->setName (get_lang ('WithOutCategory ' ));
@@ -1002,7 +1015,7 @@ function show_image(image,width,height) {
1002
1015
1003
1016
$ list = new LearnpathList (
1004
1017
api_get_user_id (),
1005
- null ,
1018
+ $ courseInfo [ ' code ' ] ,
1006
1019
null ,
1007
1020
null ,
1008
1021
false ,
@@ -1567,6 +1580,60 @@ function show_image(image,width,height) {
1567
1580
$ sessionId
1568
1581
);
1569
1582
1583
+ $ allowMessages = api_get_configuration_value ('private_messages_about_user ' );
1584
+ if ($ allowMessages === true ) {
1585
+ // Messages
1586
+ echo Display::page_subheader2 (get_lang ('Messages ' ));
1587
+ $ messages = MessageManager::getMessagesAboutUser ($ user_info );
1588
+
1589
+ if (!empty ($ messages )) {
1590
+ /** @var Message $message */
1591
+ foreach ($ messages as $ message ) {
1592
+ $ tag = 'message_ ' .$ message ->getId ();
1593
+ $ tagAccordion = 'accordion_ ' .$ message ->getId ();
1594
+ $ tagCollapse = 'collapse_ ' .$ message ->getId ();
1595
+ $ date = Display::dateToStringAgoAndLongDate (
1596
+ $ message ->getSendDate ()
1597
+ );
1598
+ $ senderId = $ message ->getUserSenderId ();
1599
+ $ senderInfo = api_get_user_info ($ senderId );
1600
+ echo Display::panelCollapse (
1601
+ $ message ->getTitle (),
1602
+ $ message ->getContent ().'<br /> ' .$ date .'<br /> ' .get_lang (
1603
+ 'Author '
1604
+ ).': ' .$ senderInfo ['complete_name_with_message_link ' ],
1605
+ $ tag ,
1606
+ null ,
1607
+ $ tagAccordion ,
1608
+ $ tagCollapse ,
1609
+ false
1610
+ );
1611
+ }
1612
+ }
1613
+
1614
+ echo Display::url (
1615
+ get_lang ('NewMessage ' ),
1616
+ 'javascript: void(0); ' ,
1617
+ [
1618
+ 'onClick ' => "$('#compose_message').show(); " ,
1619
+ 'class ' => 'btn btn-default '
1620
+ ]
1621
+ );
1622
+
1623
+ $ form = new FormValidator (
1624
+ 'messages ' ,
1625
+ 'post ' ,
1626
+ api_get_self ().'?action=send_message&student= ' .$ student_id
1627
+ );
1628
+ $ form ->addHtml ('<div id="compose_message" style="display:none;"> ' );
1629
+ $ form ->addText ('subject ' , get_lang ('Subject ' ));
1630
+ $ form ->addHtmlEditor ('message ' , get_lang ('Message ' ));
1631
+ $ form ->addButtonSend (get_lang ('Send ' ));
1632
+ $ form ->addHidden ('sec_token ' , $ token );
1633
+ $ form ->addHtml ('</div> ' );
1634
+ $ form ->display ();
1635
+ }
1636
+
1570
1637
if ($ export ) {
1571
1638
ob_end_clean ();
1572
1639
switch ($ export ) {
0 commit comments