Completed
Pull Request — 1.11.x (#1318)
by José
66:27 queued 30:05
created
main/inc/lib/tracking.lib.php 1 patch
Indentation   +861 added lines, -861 removed lines patch added patch discarded remove patch
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
                     $extend_link = '';
312 312
                     if (!empty($inter_num)) {
313 313
                         $extend_link = Display::url(
314
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
314
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
316 316
                         );
317 317
                     }
318 318
                     $title = $row['mytitle'];
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
             case 'last_30_days':
1366 1366
                 $new_date = date('Y-m-d H:i:s', strtotime('-30 day'));
1367 1367
                 $condition_time = ' AND (login_date >= "'.$new_date.'" AND logout_date <= "'.$today.'") ';
1368
-               break;
1368
+                break;
1369 1369
             case 'custom':
1370 1370
                 if (!empty($start_date) && !empty($end_date)) {
1371 1371
                     $start_date = Database::escape_string($start_date);
@@ -1375,10 +1375,10 @@  discard block
 block discarded – undo
1375 1375
                 break;
1376 1376
         }
1377 1377
 
1378
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1378
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1379 1379
     	        FROM '.$tbl_track_login.'
1380 1380
                 WHERE '.$userCondition.$condition_time;
1381
-    	$rs = Database::query($sql);
1381
+        $rs = Database::query($sql);
1382 1382
         $row = Database::fetch_array($rs, 'ASSOC');
1383 1383
         $diff = $row['diff'];
1384 1384
 
@@ -1400,18 +1400,18 @@  discard block
 block discarded – undo
1400 1400
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1401 1401
     {
1402 1402
         $courseId = intval($courseId);
1403
-    	$session_id  = intval($session_id);
1404
-
1405
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1406
-    	if (is_array($user_id)) {
1407
-    	    $user_id = array_map('intval', $user_id);
1408
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1409
-    	} else {
1410
-    		$user_id = intval($user_id);
1411
-    		$condition_user = " AND user_id = $user_id ";
1412
-    	}
1413
-
1414
-    	$sql = "SELECT
1403
+        $session_id  = intval($session_id);
1404
+
1405
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1406
+        if (is_array($user_id)) {
1407
+            $user_id = array_map('intval', $user_id);
1408
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1409
+        } else {
1410
+            $user_id = intval($user_id);
1411
+            $condition_user = " AND user_id = $user_id ";
1412
+        }
1413
+
1414
+        $sql = "SELECT
1415 1415
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1416 1416
                 FROM $tbl_track_course
1417 1417
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1426,9 +1426,9 @@  discard block
 block discarded – undo
1426 1426
 
1427 1427
         $sql .= $condition_user;
1428 1428
         $rs = Database::query($sql);
1429
-    	$row = Database::fetch_array($rs);
1429
+        $row = Database::fetch_array($rs);
1430 1430
 
1431
-    	return $row['nb_seconds'];
1431
+        return $row['nb_seconds'];
1432 1432
     }
1433 1433
 
1434 1434
     /**
@@ -1439,25 +1439,25 @@  discard block
 block discarded – undo
1439 1439
      */
1440 1440
     public static function get_first_connection_date($student_id)
1441 1441
     {
1442
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1443
-    	$sql = 'SELECT login_date
1442
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1443
+        $sql = 'SELECT login_date
1444 1444
     	        FROM ' . $tbl_track_login . '
1445 1445
                 WHERE login_user_id = ' . intval($student_id) . '
1446 1446
                 ORDER BY login_date ASC
1447 1447
                 LIMIT 0,1';
1448 1448
 
1449
-    	$rs = Database::query($sql);
1450
-    	if (Database::num_rows($rs)>0) {
1451
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1449
+        $rs = Database::query($sql);
1450
+        if (Database::num_rows($rs)>0) {
1451
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1452 1452
                 return api_convert_and_format_date(
1453 1453
                     $first_login_date,
1454 1454
                     DATE_FORMAT_SHORT,
1455 1455
                     date_default_timezone_get()
1456 1456
                 );
1457
-    		}
1458
-    	}
1457
+            }
1458
+        }
1459 1459
 
1460
-    	return false;
1460
+        return false;
1461 1461
     }
1462 1462
 
1463 1463
     /**
@@ -1470,38 +1470,38 @@  discard block
 block discarded – undo
1470 1470
      */
1471 1471
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1472 1472
     {
1473
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1474
-    	$sql = 'SELECT login_date
1473
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1474
+        $sql = 'SELECT login_date
1475 1475
     	        FROM ' . $table . '
1476 1476
                 WHERE login_user_id = ' . intval($student_id) . '
1477 1477
                 ORDER BY login_date
1478 1478
                 DESC LIMIT 0,1';
1479 1479
 
1480
-    	$rs = Database::query($sql);
1481
-    	if (Database::num_rows($rs) > 0) {
1482
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1483
-    			$last_login_date = api_get_local_time($last_login_date);
1484
-    			if ($return_timestamp) {
1485
-    				return api_strtotime($last_login_date,'UTC');
1486
-    			} else {
1487
-    				if (!$warning_message) {
1488
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1489
-    				} else {
1490
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1491
-    					$currentTimestamp = time();
1492
-
1493
-    					//If the last connection is > than 7 days, the text is red
1494
-    					//345600 = 7 days in seconds
1495
-    					if ($currentTimestamp - $timestamp > 604800) {
1496
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1497
-    					} else {
1498
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1499
-    					}
1500
-    				}
1501
-    			}
1502
-    		}
1503
-    	}
1504
-    	return false;
1480
+        $rs = Database::query($sql);
1481
+        if (Database::num_rows($rs) > 0) {
1482
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1483
+                $last_login_date = api_get_local_time($last_login_date);
1484
+                if ($return_timestamp) {
1485
+                    return api_strtotime($last_login_date,'UTC');
1486
+                } else {
1487
+                    if (!$warning_message) {
1488
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1489
+                    } else {
1490
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1491
+                        $currentTimestamp = time();
1492
+
1493
+                        //If the last connection is > than 7 days, the text is red
1494
+                        //345600 = 7 days in seconds
1495
+                        if ($currentTimestamp - $timestamp > 604800) {
1496
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1497
+                        } else {
1498
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1499
+                        }
1500
+                    }
1501
+                }
1502
+            }
1503
+        }
1504
+        return false;
1505 1505
     }
1506 1506
 
1507 1507
     /**
@@ -1555,30 +1555,30 @@  discard block
 block discarded – undo
1555 1555
         $session_id = 0,
1556 1556
         $convert_date = true
1557 1557
     ) {
1558
-    	$student_id  = intval($student_id);
1558
+        $student_id  = intval($student_id);
1559 1559
         $courseId = intval($courseId);
1560
-    	$session_id  = intval($session_id);
1560
+        $session_id  = intval($session_id);
1561 1561
 
1562
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1563
-    	$sql = 'SELECT login_course_date
1562
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1563
+        $sql = 'SELECT login_course_date
1564 1564
     	        FROM '.$tbl_track_login.'
1565 1565
                 WHERE
1566 1566
                     user_id = '.$student_id.' AND
1567 1567
                     c_id = '.$courseId.' AND
1568 1568
                     session_id = '.$session_id.'
1569 1569
                 ORDER BY login_course_date ASC LIMIT 0,1';
1570
-    	$rs = Database::query($sql);
1571
-    	if (Database::num_rows($rs) > 0) {
1572
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1573
-    			if ($convert_date) {
1574
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1575
-    			} else {
1576
-    				return $first_login_date;
1577
-    			}
1578
-    		}
1579
-    	}
1580
-
1581
-    	return false;
1570
+        $rs = Database::query($sql);
1571
+        if (Database::num_rows($rs) > 0) {
1572
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1573
+                if ($convert_date) {
1574
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1575
+                } else {
1576
+                    return $first_login_date;
1577
+                }
1578
+            }
1579
+        }
1580
+
1581
+        return false;
1582 1582
     }
1583 1583
 
1584 1584
     /**
@@ -1594,13 +1594,13 @@  discard block
 block discarded – undo
1594 1594
         $session_id = 0,
1595 1595
         $convert_date = true
1596 1596
     ) {
1597
-    	// protect data
1598
-    	$student_id  = intval($student_id);
1597
+        // protect data
1598
+        $student_id  = intval($student_id);
1599 1599
         $courseId = $courseInfo['real_id'];
1600
-    	$session_id  = intval($session_id);
1600
+        $session_id  = intval($session_id);
1601 1601
 
1602
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1603
-    	$sql = 'SELECT access_date
1602
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1603
+        $sql = 'SELECT access_date
1604 1604
                 FROM '.$tbl_track_e_access.'
1605 1605
                 WHERE   access_user_id = '.$student_id.' AND
1606 1606
                         c_id = "'.$courseId.'" AND
@@ -1608,39 +1608,39 @@  discard block
 block discarded – undo
1608 1608
                 ORDER BY access_date DESC
1609 1609
                 LIMIT 0,1';
1610 1610
 
1611
-    	$rs = Database::query($sql);
1612
-    	if (Database::num_rows($rs) > 0) {
1613
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1611
+        $rs = Database::query($sql);
1612
+        if (Database::num_rows($rs) > 0) {
1613
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1614 1614
                 if (empty($last_login_date)) {
1615 1615
                     return false;
1616 1616
                 }
1617 1617
                 //see #5736
1618 1618
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1619
-    			$now = time();
1620
-    			//If the last connection is > than 7 days, the text is red
1621
-    			//345600 = 7 days in seconds
1622
-    			if ($now - $last_login_date_timestamp > 604800) {
1623
-    				if ($convert_date) {
1619
+                $now = time();
1620
+                //If the last connection is > than 7 days, the text is red
1621
+                //345600 = 7 days in seconds
1622
+                if ($now - $last_login_date_timestamp > 604800) {
1623
+                    if ($convert_date) {
1624 1624
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1625 1625
                         $icon = api_is_allowed_to_edit() ?
1626 1626
                             '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1627 1627
                               '.Display::return_icon('messagebox_warning.gif').'
1628 1628
                              </a>'
1629 1629
                             : null;
1630
-    					return $icon. Display::label($last_login_date, 'warning');
1631
-    				} else {
1632
-    					return $last_login_date;
1633
-    				}
1634
-    			} else {
1635
-    				if ($convert_date) {
1636
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1637
-    				} else {
1638
-    					return $last_login_date;
1639
-    				}
1640
-    			}
1641
-    		}
1642
-    	}
1643
-    	return false;
1630
+                        return $icon. Display::label($last_login_date, 'warning');
1631
+                    } else {
1632
+                        return $last_login_date;
1633
+                    }
1634
+                } else {
1635
+                    if ($convert_date) {
1636
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1637
+                    } else {
1638
+                        return $last_login_date;
1639
+                    }
1640
+                }
1641
+            }
1642
+        }
1643
+        return false;
1644 1644
     }
1645 1645
 
1646 1646
     /**
@@ -1653,36 +1653,36 @@  discard block
 block discarded – undo
1653 1653
      */
1654 1654
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1655 1655
     {
1656
-    	if ($start < 0) {
1657
-    		$start = 0;
1658
-    	}
1659
-    	if (!isset($stop) or ($stop < 0)) {
1660
-    		$stop = api_get_utc_datetime();
1661
-    	}
1656
+        if ($start < 0) {
1657
+            $start = 0;
1658
+        }
1659
+        if (!isset($stop) or ($stop < 0)) {
1660
+            $stop = api_get_utc_datetime();
1661
+        }
1662 1662
 
1663 1663
         $start = Database::escape_string($start);
1664 1664
         $stop = Database::escape_string($stop);
1665 1665
 
1666
-    	$month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
1666
+        $month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
1667 1667
 
1668 1668
         $courseId = intval($courseId);
1669
-    	$session_id  = intval($session_id);
1670
-    	$count = 0;
1669
+        $session_id  = intval($session_id);
1670
+        $count = 0;
1671 1671
 
1672
-    	$tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1673
-    	$sql = "SELECT count(*) as count_connections
1672
+        $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1673
+        $sql = "SELECT count(*) as count_connections
1674 1674
                 FROM $tbl_track_e_course_access
1675 1675
                 WHERE
1676 1676
                     c_id = $courseId AND
1677 1677
                     session_id = $session_id
1678 1678
                     $month_filter";
1679
-    	$rs = Database::query($sql);
1680
-    	if (Database::num_rows($rs)>0) {
1681
-    		$row = Database::fetch_object($rs);
1682
-    		$count = $row->count_connections;
1683
-    	}
1679
+        $rs = Database::query($sql);
1680
+        if (Database::num_rows($rs)>0) {
1681
+            $row = Database::fetch_object($rs);
1682
+            $count = $row->count_connections;
1683
+        }
1684 1684
 
1685
-    	return $count;
1685
+        return $count;
1686 1686
     }
1687 1687
 
1688 1688
     /**
@@ -1693,25 +1693,25 @@  discard block
 block discarded – undo
1693 1693
      */
1694 1694
     public static function count_course_per_student($user_id, $include_sessions = true)
1695 1695
     {
1696
-    	$user_id = intval($user_id);
1697
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1698
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1696
+        $user_id = intval($user_id);
1697
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1698
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1699 1699
 
1700
-    	$sql = 'SELECT DISTINCT c_id
1700
+        $sql = 'SELECT DISTINCT c_id
1701 1701
                 FROM ' . $tbl_course_rel_user . '
1702 1702
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1703
-    	$rs = Database::query($sql);
1704
-    	$nb_courses = Database::num_rows($rs);
1703
+        $rs = Database::query($sql);
1704
+        $nb_courses = Database::num_rows($rs);
1705 1705
 
1706
-    	if ($include_sessions) {
1707
-    		$sql = 'SELECT DISTINCT c_id
1706
+        if ($include_sessions) {
1707
+            $sql = 'SELECT DISTINCT c_id
1708 1708
                     FROM ' . $tbl_session_course_rel_user . '
1709 1709
                     WHERE user_id = ' . $user_id;
1710
-    		$rs = Database::query($sql);
1711
-    		$nb_courses += Database::num_rows($rs);
1712
-    	}
1710
+            $rs = Database::query($sql);
1711
+            $nb_courses += Database::num_rows($rs);
1712
+        }
1713 1713
 
1714
-    	return $nb_courses;
1714
+        return $nb_courses;
1715 1715
     }
1716 1716
 
1717 1717
     /**
@@ -1742,25 +1742,25 @@  discard block
 block discarded – undo
1742 1742
         $into_lp = 0
1743 1743
     ) {
1744 1744
         $course_code = Database::escape_string($course_code);
1745
-    	$course_info = api_get_course_info($course_code);
1746
-    	if (!empty($course_info)) {
1747
-    		// table definition
1748
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1749
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1750
-
1751
-    		// Compose a filter based on optional exercise given
1752
-    		$condition_quiz = "";
1753
-    		if (!empty($exercise_id)) {
1754
-    			$exercise_id = intval($exercise_id);
1755
-    			$condition_quiz =" AND id = $exercise_id ";
1756
-    		}
1757
-
1758
-    		// Compose a filter based on optional session id given
1759
-    		$condition_session = "";
1760
-    		if (isset($session_id)) {
1761
-    			$session_id = intval($session_id);
1762
-    			$condition_session = " AND session_id = $session_id ";
1763
-    		}
1745
+        $course_info = api_get_course_info($course_code);
1746
+        if (!empty($course_info)) {
1747
+            // table definition
1748
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1749
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1750
+
1751
+            // Compose a filter based on optional exercise given
1752
+            $condition_quiz = "";
1753
+            if (!empty($exercise_id)) {
1754
+                $exercise_id = intval($exercise_id);
1755
+                $condition_quiz =" AND id = $exercise_id ";
1756
+            }
1757
+
1758
+            // Compose a filter based on optional session id given
1759
+            $condition_session = "";
1760
+            if (isset($session_id)) {
1761
+                $session_id = intval($session_id);
1762
+                $condition_session = " AND session_id = $session_id ";
1763
+            }
1764 1764
             if ($active_filter == 1) {
1765 1765
                 $condition_active = 'AND active <> -1';
1766 1766
             } elseif ($active_filter == 0) {
@@ -1776,7 +1776,7 @@  discard block
 block discarded – undo
1776 1776
                 $select_lp_id = ', orig_lp_id as lp_id ';
1777 1777
             }
1778 1778
 
1779
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1779
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1780 1780
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1781 1781
             $count_quiz = 0;
1782 1782
             $countQuizResult = Database::query($sql);
@@ -1784,21 +1784,21 @@  discard block
 block discarded – undo
1784 1784
                 $count_quiz = Database::fetch_row($countQuizResult);
1785 1785
             }
1786 1786
 
1787
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1788
-    			if (is_array($student_id)) {
1787
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1788
+                if (is_array($student_id)) {
1789 1789
                     $student_id = array_map('intval', $student_id);
1790
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1791
-    			} else {
1790
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1791
+                } else {
1792 1792
                     $student_id = intval($student_id);
1793
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1794
-    			}
1793
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1794
+                }
1795 1795
 
1796
-    			if (empty($exercise_id)) {
1797
-    				$sql = "SELECT id FROM $tbl_course_quiz
1796
+                if (empty($exercise_id)) {
1797
+                    $sql = "SELECT id FROM $tbl_course_quiz
1798 1798
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1799 1799
                     $result = Database::query($sql);
1800 1800
                     $exercise_list = array();
1801
-    				$exercise_id = null;
1801
+                    $exercise_id = null;
1802 1802
                     if (!empty($result) && Database::num_rows($result)) {
1803 1803
                         while ($row = Database::fetch_array($result)) {
1804 1804
                             $exercise_list[] = $row['id'];
@@ -1807,11 +1807,11 @@  discard block
 block discarded – undo
1807 1807
                     if (!empty($exercise_list)) {
1808 1808
                         $exercise_id = implode("','",$exercise_list);
1809 1809
                     }
1810
-    			}
1810
+                }
1811 1811
 
1812
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1812
+                $count_quiz = Database::fetch_row(Database::query($sql));
1813 1813
 
1814
-    			$sql = "SELECT
1814
+                $sql = "SELECT
1815 1815
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1816 1816
     			        COUNT(*) as num_attempts
1817 1817
     			        $select_lp_id
@@ -1825,20 +1825,20 @@  discard block
 block discarded – undo
1825 1825
                             $condition_into_lp
1826 1826
                         ORDER BY exe_date DESC";
1827 1827
 
1828
-    			$res = Database::query($sql);
1829
-    			$row = Database::fetch_array($res);
1830
-    			$quiz_avg_score = null;
1828
+                $res = Database::query($sql);
1829
+                $row = Database::fetch_array($res);
1830
+                $quiz_avg_score = null;
1831 1831
 
1832
-    			if (!empty($row['avg_score'])) {
1833
-    				$quiz_avg_score = round($row['avg_score'],2);
1834
-    			}
1832
+                if (!empty($row['avg_score'])) {
1833
+                    $quiz_avg_score = round($row['avg_score'],2);
1834
+                }
1835 1835
 
1836
-    			if(!empty($row['num_attempts'])) {
1837
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1838
-    			}
1839
-    			if (is_array($student_id)) {
1840
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1841
-    			}
1836
+                if(!empty($row['num_attempts'])) {
1837
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1838
+                }
1839
+                if (is_array($student_id)) {
1840
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1841
+                }
1842 1842
                 if ($into_lp == 0) {
1843 1843
                     return $quiz_avg_score;
1844 1844
                 } else {
@@ -1861,9 +1861,9 @@  discard block
 block discarded – undo
1861 1861
                         return array($quiz_avg_score, null);
1862 1862
                     }
1863 1863
                 }
1864
-    		}
1865
-    	}
1866
-    	return null;
1864
+            }
1865
+        }
1866
+        return null;
1867 1867
     }
1868 1868
 
1869 1869
     /**
@@ -1896,15 +1896,15 @@  discard block
 block discarded – undo
1896 1896
         $find_all_lp = 0
1897 1897
     ) {
1898 1898
         $courseId = intval($courseId);
1899
-    	$student_id  = intval($student_id);
1900
-    	$exercise_id = intval($exercise_id);
1901
-    	$session_id  = intval($session_id);
1899
+        $student_id  = intval($student_id);
1900
+        $exercise_id = intval($exercise_id);
1901
+        $session_id  = intval($session_id);
1902 1902
 
1903
-    	$lp_id = intval($lp_id);
1903
+        $lp_id = intval($lp_id);
1904 1904
         $lp_item_id = intval($lp_item_id);
1905
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1905
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1906 1906
 
1907
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1907
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1908 1908
                 WHERE  ex.c_id = $courseId
1909 1909
                 AND ex.exe_exo_id = $exercise_id
1910 1910
                 AND status = ''
@@ -1919,11 +1919,11 @@  discard block
 block discarded – undo
1919 1919
                 AND orig_lp_item_id = $lp_item_id";
1920 1920
         }
1921 1921
 
1922
-    	$rs = Database::query($sql);
1923
-    	$row = Database::fetch_row($rs);
1924
-    	$count_attempts = $row[0];
1922
+        $rs = Database::query($sql);
1923
+        $row = Database::fetch_row($rs);
1924
+        $count_attempts = $row[0];
1925 1925
 
1926
-    	return $count_attempts;
1926
+        return $count_attempts;
1927 1927
     }
1928 1928
 
1929 1929
     /**
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
      * @param int    $user_id
1934 1934
      * @param int    $courseId
1935 1935
      * @param int    $session_id
1936
-    */
1936
+     */
1937 1937
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1938 1938
     {
1939 1939
         $courseId = intval($courseId);
@@ -3597,8 +3597,8 @@  discard block
 block discarded – undo
3597 3597
 
3598 3598
         $condition_session = '';
3599 3599
         if (isset($session_id)) {
3600
-             $session_id = intval($session_id);
3601
-             $condition_session = ' AND f.session_id = '. $session_id;
3600
+                $session_id = intval($session_id);
3601
+                $condition_session = ' AND f.session_id = '. $session_id;
3602 3602
         }
3603 3603
 
3604 3604
         $groupId = intval($groupId);
@@ -5503,9 +5503,9 @@  discard block
 block discarded – undo
5503 5503
     }
5504 5504
 
5505 5505
     /**
5506
-    * @param FormValidator $form
5507
-    * @return mixed
5508
-    */
5506
+     * @param FormValidator $form
5507
+     * @return mixed
5508
+     */
5509 5509
     public static function setUserSearchForm($form)
5510 5510
     {
5511 5511
         global $_configuration;
@@ -5785,26 +5785,26 @@  discard block
 block discarded – undo
5785 5785
         $session_id = api_get_session_id();
5786 5786
         $course_id = api_get_course_int_id();
5787 5787
 
5788
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5789
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5788
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5789
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5790 5790
 
5791
-    	$sql = "SELECT count(tool) AS total_number_of_items
5791
+        $sql = "SELECT count(tool) AS total_number_of_items
5792 5792
     	        FROM $table_item_property track_resource, $table_user user
5793 5793
     	        WHERE
5794 5794
                     track_resource.c_id = $course_id AND
5795 5795
                     track_resource.insert_user_id = user.user_id AND
5796 5796
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5797 5797
 
5798
-    	if (isset($_GET['keyword'])) {
5799
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5800
-    		$sql .= " AND (
5798
+        if (isset($_GET['keyword'])) {
5799
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5800
+            $sql .= " AND (
5801 5801
     		            user.username LIKE '%".$keyword."%' OR
5802 5802
     		            lastedit_type LIKE '%".$keyword."%' OR
5803 5803
     		            tool LIKE '%".$keyword."%'
5804 5804
                     )";
5805
-    	}
5805
+        }
5806 5806
 
5807
-    	$sql .= " AND tool IN (
5807
+        $sql .= " AND tool IN (
5808 5808
     	            'document',
5809 5809
     	            'learnpath',
5810 5810
     	            'quiz',
@@ -5816,10 +5816,10 @@  discard block
 block discarded – undo
5816 5816
     	            'thematic_advance',
5817 5817
     	            'thematic_plan'
5818 5818
                 )";
5819
-    	$res = Database::query($sql);
5820
-    	$obj = Database::fetch_object($res);
5819
+        $res = Database::query($sql);
5820
+        $obj = Database::fetch_object($res);
5821 5821
 
5822
-    	return $obj->total_number_of_items;
5822
+        return $obj->total_number_of_items;
5823 5823
     }
5824 5824
 
5825 5825
     /**
@@ -5834,12 +5834,12 @@  discard block
 block discarded – undo
5834 5834
         $session_id = api_get_session_id();
5835 5835
         $course_id = api_get_course_int_id();
5836 5836
 
5837
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5838
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5839
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5840
-    	$session_id = intval($session_id);
5837
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5838
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5839
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5840
+        $session_id = intval($session_id);
5841 5841
 
5842
-    	$sql = "SELECT
5842
+        $sql = "SELECT
5843 5843
                     tool as col0,
5844 5844
                     lastedit_type as col1,
5845 5845
                     ref as ref,
@@ -5853,16 +5853,16 @@  discard block
 block discarded – undo
5853 5853
                   track_resource.insert_user_id = user.user_id AND
5854 5854
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5855 5855
 
5856
-    	if (isset($_GET['keyword'])) {
5857
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5858
-    		$sql .= " AND (
5856
+        if (isset($_GET['keyword'])) {
5857
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5858
+            $sql .= " AND (
5859 5859
     		            user.username LIKE '%".$keyword."%' OR
5860 5860
     		            lastedit_type LIKE '%".$keyword."%' OR
5861 5861
     		            tool LIKE '%".$keyword."%'
5862 5862
                      ) ";
5863
-    	}
5863
+        }
5864 5864
 
5865
-    	$sql .= " AND tool IN (
5865
+        $sql .= " AND tool IN (
5866 5866
     	            'document',
5867 5867
     	            'learnpath',
5868 5868
     	            'quiz',
@@ -5875,41 +5875,41 @@  discard block
 block discarded – undo
5875 5875
     	            'thematic_plan'
5876 5876
                 )";
5877 5877
 
5878
-    	if ($column == 0) {
5879
-    		$column = '0';
5880
-    	}
5881
-    	if ($column != '' && $direction != '') {
5882
-    		if ($column != 2 && $column != 4) {
5883
-    			$sql .= " ORDER BY col$column $direction";
5884
-    		}
5885
-    	} else {
5886
-    		$sql .= " ORDER BY col5 DESC ";
5887
-    	}
5878
+        if ($column == 0) {
5879
+            $column = '0';
5880
+        }
5881
+        if ($column != '' && $direction != '') {
5882
+            if ($column != 2 && $column != 4) {
5883
+                $sql .= " ORDER BY col$column $direction";
5884
+            }
5885
+        } else {
5886
+            $sql .= " ORDER BY col5 DESC ";
5887
+        }
5888 5888
 
5889 5889
         $from = intval($from);
5890 5890
         $number_of_items = intval($number_of_items);
5891 5891
 
5892
-    	$sql .= " LIMIT $from, $number_of_items ";
5893
-
5894
-    	$res = Database::query($sql);
5895
-    	$resources = array();
5896
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5897
-    	while ($row = Database::fetch_array($res)) {
5898
-    		$ref = $row['ref'];
5899
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5900
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
5901
-
5902
-    		$id = $table_name['id_tool'];
5903
-    		$recorset = false;
5892
+        $sql .= " LIMIT $from, $number_of_items ";
5904 5893
 
5905
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5906
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5907
-    			$sql = "SELECT thematic_id FROM $table_tool
5894
+        $res = Database::query($sql);
5895
+        $resources = array();
5896
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5897
+        while ($row = Database::fetch_array($res)) {
5898
+            $ref = $row['ref'];
5899
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5900
+            $table_tool = Database :: get_course_table($table_name['table_name']);
5901
+
5902
+            $id = $table_name['id_tool'];
5903
+            $recorset = false;
5904
+
5905
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5906
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5907
+                $sql = "SELECT thematic_id FROM $table_tool
5908 5908
     			        WHERE c_id = $course_id AND id = $ref";
5909
-    			$rs_thematic  = Database::query($sql);
5910
-    			if (Database::num_rows($rs_thematic)) {
5911
-    				$row_thematic = Database::fetch_array($rs_thematic);
5912
-    				$thematic_id = $row_thematic['thematic_id'];
5909
+                $rs_thematic  = Database::query($sql);
5910
+                if (Database::num_rows($rs_thematic)) {
5911
+                    $row_thematic = Database::fetch_array($rs_thematic);
5912
+                    $thematic_id = $row_thematic['thematic_id'];
5913 5913
 
5914 5914
                     $sql = "SELECT session.id, session.name, user.username
5915 5915
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -5918,9 +5918,9 @@  discard block
 block discarded – undo
5918 5918
                               t.session_id = session.id AND
5919 5919
                               session.id_coach = user.user_id AND
5920 5920
                               t.id = $thematic_id";
5921
-    				$recorset = Database::query($sql);
5922
-    			}
5923
-    		} else {
5921
+                    $recorset = Database::query($sql);
5922
+                }
5923
+            } else {
5924 5924
                 $sql = "SELECT session.id, session.name, user.username
5925 5925
                           FROM $table_tool tool, $table_session session, $table_user user
5926 5926
     			          WHERE
@@ -5928,127 +5928,127 @@  discard block
 block discarded – undo
5928 5928
     			              tool.session_id = session.id AND
5929 5929
     			              session.id_coach = user.user_id AND
5930 5930
     			              tool.$id = $ref";
5931
-    			$recorset = Database::query($sql);
5932
-    		}
5933
-
5934
-    		if (!empty($recorset)) {
5935
-    			$obj = Database::fetch_object($recorset);
5936
-
5937
-    			$name_session = '';
5938
-    			$coach_name = '';
5939
-    			if (!empty($obj)) {
5940
-    				$name_session = $obj->name;
5941
-    				$coach_name   = $obj->username;
5942
-    			}
5943
-
5944
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5945
-    			$row[0] = '';
5946
-    			if ($row['col6'] != 2) {
5947
-    				if (in_array($row['col0'], $thematic_tools)) {
5948
-
5949
-    					$exp_thematic_tool = explode('_', $row['col0']);
5950
-    					$thematic_tool_title = '';
5951
-    					if (is_array($exp_thematic_tool)) {
5952
-    						foreach ($exp_thematic_tool as $exp) {
5953
-    							$thematic_tool_title .= api_ucfirst($exp);
5954
-    						}
5955
-    					} else {
5956
-    						$thematic_tool_title = api_ucfirst($row['col0']);
5957
-    					}
5958
-
5959
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
5960
-    				} else {
5961
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
5962
-    				}
5963
-    			} else {
5964
-    				$row[0] = api_ucfirst($row['col0']);
5965
-    			}
5966
-    			$row[1] = get_lang($row[1]);
5967
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
5968
-    			$row[5] = '';
5969
-    			//@todo Improve this code please
5970
-    			switch ($table_name['table_name']) {
5971
-    				case 'document' :
5972
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
5931
+                $recorset = Database::query($sql);
5932
+            }
5933
+
5934
+            if (!empty($recorset)) {
5935
+                $obj = Database::fetch_object($recorset);
5936
+
5937
+                $name_session = '';
5938
+                $coach_name = '';
5939
+                if (!empty($obj)) {
5940
+                    $name_session = $obj->name;
5941
+                    $coach_name   = $obj->username;
5942
+                }
5943
+
5944
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5945
+                $row[0] = '';
5946
+                if ($row['col6'] != 2) {
5947
+                    if (in_array($row['col0'], $thematic_tools)) {
5948
+
5949
+                        $exp_thematic_tool = explode('_', $row['col0']);
5950
+                        $thematic_tool_title = '';
5951
+                        if (is_array($exp_thematic_tool)) {
5952
+                            foreach ($exp_thematic_tool as $exp) {
5953
+                                $thematic_tool_title .= api_ucfirst($exp);
5954
+                            }
5955
+                        } else {
5956
+                            $thematic_tool_title = api_ucfirst($row['col0']);
5957
+                        }
5958
+
5959
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
5960
+                    } else {
5961
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
5962
+                    }
5963
+                } else {
5964
+                    $row[0] = api_ucfirst($row['col0']);
5965
+                }
5966
+                $row[1] = get_lang($row[1]);
5967
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
5968
+                $row[5] = '';
5969
+                //@todo Improve this code please
5970
+                switch ($table_name['table_name']) {
5971
+                    case 'document' :
5972
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
5973 5973
                                 WHERE c_id = $course_id AND id = $ref";
5974
-    					$rs_document = Database::query($sql);
5975
-    					$obj_document = Database::fetch_object($rs_document);
5976
-    					$row[5] = $obj_document->title;
5974
+                        $rs_document = Database::query($sql);
5975
+                        $obj_document = Database::fetch_object($rs_document);
5976
+                        $row[5] = $obj_document->title;
5977 5977
 
5978
-    					break;
5979
-    				case 'announcement':
5978
+                        break;
5979
+                    case 'announcement':
5980 5980
                         $sql = "SELECT title FROM $table_tool
5981 5981
                                 WHERE c_id = $course_id AND id = $ref";
5982
-    					$rs_document = Database::query($sql);
5983
-    					$obj_document = Database::fetch_object($rs_document);
5982
+                        $rs_document = Database::query($sql);
5983
+                        $obj_document = Database::fetch_object($rs_document);
5984 5984
                         if ($obj_document) {
5985 5985
                             $row[5] = $obj_document->title;
5986 5986
                         }
5987
-    					break;
5988
-    				case 'glossary':
5987
+                        break;
5988
+                    case 'glossary':
5989 5989
                         $sql = "SELECT name FROM $table_tool
5990 5990
     					        WHERE c_id = $course_id AND glossary_id = $ref";
5991
-    					$rs_document = Database::query($sql);
5992
-    					$obj_document = Database::fetch_object($rs_document);
5991
+                        $rs_document = Database::query($sql);
5992
+                        $obj_document = Database::fetch_object($rs_document);
5993 5993
                         if ($obj_document) {
5994 5994
                             $row[5] = $obj_document->name;
5995 5995
                         }
5996
-    					break;
5997
-    				case 'lp':
5996
+                        break;
5997
+                    case 'lp':
5998 5998
                         $sql = "SELECT name
5999 5999
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
6000
-    					$rs_document = Database::query($sql);
6001
-    					$obj_document = Database::fetch_object($rs_document);
6002
-    					$row[5] = $obj_document->name;
6003
-    					break;
6004
-    				case 'quiz':
6000
+                        $rs_document = Database::query($sql);
6001
+                        $obj_document = Database::fetch_object($rs_document);
6002
+                        $row[5] = $obj_document->name;
6003
+                        break;
6004
+                    case 'quiz':
6005 6005
                         $sql = "SELECT title FROM $table_tool
6006 6006
                                 WHERE c_id = $course_id AND id = $ref";
6007
-    					$rs_document = Database::query($sql);
6008
-    					$obj_document = Database::fetch_object($rs_document);
6007
+                        $rs_document = Database::query($sql);
6008
+                        $obj_document = Database::fetch_object($rs_document);
6009 6009
                         if ($obj_document) {
6010 6010
                             $row[5] = $obj_document->title;
6011 6011
                         }
6012
-    					break;
6013
-    				case 'course_description':
6012
+                        break;
6013
+                    case 'course_description':
6014 6014
                         $sql = "SELECT title FROM $table_tool
6015 6015
                                 WHERE c_id = $course_id AND id = $ref";
6016
-    					$rs_document = Database::query($sql);
6017
-    					$obj_document = Database::fetch_object($rs_document);
6016
+                        $rs_document = Database::query($sql);
6017
+                        $obj_document = Database::fetch_object($rs_document);
6018 6018
                         if ($obj_document) {
6019 6019
                             $row[5] = $obj_document->title;
6020 6020
                         }
6021
-    					break;
6022
-    				case 'thematic':
6023
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6024
-    					if (Database::num_rows($rs) > 0) {
6025
-    						$obj = Database::fetch_object($rs);
6026
-    						$row[5] = $obj->title;
6027
-    					}
6028
-    					break;
6029
-    				case 'thematic_advance':
6030
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6031
-    					if (Database::num_rows($rs) > 0) {
6032
-    						$obj = Database::fetch_object($rs);
6033
-    						$row[5] = $obj->content;
6034
-    					}
6035
-    					break;
6036
-    				case 'thematic_plan':
6037
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6038
-    					if (Database::num_rows($rs) > 0) {
6039
-    						$obj = Database::fetch_object($rs);
6040
-    						$row[5] = $obj->title;
6041
-    					}
6042
-    					break;
6043
-    				default:
6044
-    					break;
6045
-    			}
6046
-
6047
-    			$row2 = $name_session;
6048
-    			if (!empty($coach_name)) {
6049
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6050
-    			}
6051
-    			$row[2] = $row2;
6021
+                        break;
6022
+                    case 'thematic':
6023
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6024
+                        if (Database::num_rows($rs) > 0) {
6025
+                            $obj = Database::fetch_object($rs);
6026
+                            $row[5] = $obj->title;
6027
+                        }
6028
+                        break;
6029
+                    case 'thematic_advance':
6030
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6031
+                        if (Database::num_rows($rs) > 0) {
6032
+                            $obj = Database::fetch_object($rs);
6033
+                            $row[5] = $obj->content;
6034
+                        }
6035
+                        break;
6036
+                    case 'thematic_plan':
6037
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6038
+                        if (Database::num_rows($rs) > 0) {
6039
+                            $obj = Database::fetch_object($rs);
6040
+                            $row[5] = $obj->title;
6041
+                        }
6042
+                        break;
6043
+                    default:
6044
+                        break;
6045
+                }
6046
+
6047
+                $row2 = $name_session;
6048
+                if (!empty($coach_name)) {
6049
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6050
+                }
6051
+                $row[2] = $row2;
6052 6052
                 if (!empty($row['col3'])) {
6053 6053
                     $userInfo = api_get_user_info($row['user_id']);
6054 6054
 
@@ -6065,11 +6065,11 @@  discard block
 block discarded – undo
6065 6065
                     $row[4] = $ip;
6066 6066
                 }
6067 6067
 
6068
-    			$resources[] = $row;
6069
-    		}
6070
-    	}
6068
+                $resources[] = $row;
6069
+            }
6070
+        }
6071 6071
 
6072
-    	return $resources;
6072
+        return $resources;
6073 6073
     }
6074 6074
 
6075 6075
     /**
@@ -6079,63 +6079,63 @@  discard block
 block discarded – undo
6079 6079
      */
6080 6080
     public static function get_tool_name_table($tool)
6081 6081
     {
6082
-    	switch ($tool) {
6083
-    		case 'document':
6084
-    			$table_name = TABLE_DOCUMENT;
6085
-    			$link_tool = 'document/document.php';
6086
-    			$id_tool = 'id';
6087
-    			break;
6088
-    		case 'learnpath':
6089
-    			$table_name = TABLE_LP_MAIN;
6090
-    			$link_tool = 'lp/lp_controller.php';
6091
-    			$id_tool = 'id';
6092
-    			break;
6093
-    		case 'quiz':
6094
-    			$table_name = TABLE_QUIZ_TEST;
6095
-    			$link_tool = 'exercise/exercise.php';
6096
-    			$id_tool = 'id';
6097
-    			break;
6098
-    		case 'glossary':
6099
-    			$table_name = TABLE_GLOSSARY;
6100
-    			$link_tool = 'glossary/index.php';
6101
-    			$id_tool = 'glossary_id';
6102
-    			break;
6103
-    		case 'link':
6104
-    			$table_name = TABLE_LINK;
6105
-    			$link_tool = 'link/link.php';
6106
-    			$id_tool = 'id';
6107
-    			break;
6108
-    		case 'course_description':
6109
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6110
-    			$link_tool = 'course_description/';
6111
-    			$id_tool = 'id';
6112
-    			break;
6113
-    		case 'announcement':
6114
-    			$table_name = TABLE_ANNOUNCEMENT;
6115
-    			$link_tool = 'announcements/announcements.php';
6116
-    			$id_tool = 'id';
6117
-    			break;
6118
-    		case 'thematic':
6119
-    			$table_name = TABLE_THEMATIC;
6120
-    			$link_tool = 'course_progress/index.php';
6121
-    			$id_tool = 'id';
6122
-    			break;
6123
-    		case 'thematic_advance':
6124
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6125
-    			$link_tool = 'course_progress/index.php';
6126
-    			$id_tool = 'id';
6127
-    			break;
6128
-    		case 'thematic_plan':
6129
-    			$table_name = TABLE_THEMATIC_PLAN;
6130
-    			$link_tool = 'course_progress/index.php';
6131
-    			$id_tool = 'id';
6132
-    			break;
6133
-    		default:
6134
-    			$table_name = $tool;
6135
-    		break;
6136
-    	}
6137
-
6138
-    	return array(
6082
+        switch ($tool) {
6083
+            case 'document':
6084
+                $table_name = TABLE_DOCUMENT;
6085
+                $link_tool = 'document/document.php';
6086
+                $id_tool = 'id';
6087
+                break;
6088
+            case 'learnpath':
6089
+                $table_name = TABLE_LP_MAIN;
6090
+                $link_tool = 'lp/lp_controller.php';
6091
+                $id_tool = 'id';
6092
+                break;
6093
+            case 'quiz':
6094
+                $table_name = TABLE_QUIZ_TEST;
6095
+                $link_tool = 'exercise/exercise.php';
6096
+                $id_tool = 'id';
6097
+                break;
6098
+            case 'glossary':
6099
+                $table_name = TABLE_GLOSSARY;
6100
+                $link_tool = 'glossary/index.php';
6101
+                $id_tool = 'glossary_id';
6102
+                break;
6103
+            case 'link':
6104
+                $table_name = TABLE_LINK;
6105
+                $link_tool = 'link/link.php';
6106
+                $id_tool = 'id';
6107
+                break;
6108
+            case 'course_description':
6109
+                $table_name = TABLE_COURSE_DESCRIPTION;
6110
+                $link_tool = 'course_description/';
6111
+                $id_tool = 'id';
6112
+                break;
6113
+            case 'announcement':
6114
+                $table_name = TABLE_ANNOUNCEMENT;
6115
+                $link_tool = 'announcements/announcements.php';
6116
+                $id_tool = 'id';
6117
+                break;
6118
+            case 'thematic':
6119
+                $table_name = TABLE_THEMATIC;
6120
+                $link_tool = 'course_progress/index.php';
6121
+                $id_tool = 'id';
6122
+                break;
6123
+            case 'thematic_advance':
6124
+                $table_name = TABLE_THEMATIC_ADVANCE;
6125
+                $link_tool = 'course_progress/index.php';
6126
+                $id_tool = 'id';
6127
+                break;
6128
+            case 'thematic_plan':
6129
+                $table_name = TABLE_THEMATIC_PLAN;
6130
+                $link_tool = 'course_progress/index.php';
6131
+                $id_tool = 'id';
6132
+                break;
6133
+            default:
6134
+                $table_name = $tool;
6135
+            break;
6136
+        }
6137
+
6138
+        return array(
6139 6139
             'table_name' => $table_name,
6140 6140
             'link_tool' => $link_tool,
6141 6141
             'id_tool' => $id_tool
@@ -6144,45 +6144,45 @@  discard block
 block discarded – undo
6144 6144
 
6145 6145
     public static function display_additional_profile_fields()
6146 6146
     {
6147
-    	// getting all the extra profile fields that are defined by the platform administrator
6148
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6149
-
6150
-    	// creating the form
6151
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6152
-
6153
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6154
-    	// the information the users have entered or selected.
6155
-    	$return .= '<select name="additional_profile_field">';
6156
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6157
-    	$extra_fields_to_show = 0;
6158
-    	foreach ($extra_fields as $key=>$field) {
6159
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6160
-    		if ($field[6]==1 && $field[8] == 1) {
6161
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6162
-    				$selected = 'selected="selected"';
6163
-    			} else {
6164
-    				$selected = '';
6165
-    			}
6166
-    			$extra_fields_to_show++;
6167
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6168
-    		}
6169
-    	}
6170
-    	$return .= '</select>';
6171
-
6172
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6173
-    	foreach ($_GET as $key=>$value){
6174
-    		if ($key <> 'additional_profile_field')    {
6175
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6176
-    		}
6177
-    	}
6178
-    	// the submit button
6179
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6180
-    	$return .= '</form>';
6181
-    	if ($extra_fields_to_show > 0) {
6182
-    		return $return;
6183
-    	} else {
6184
-    		return '';
6185
-    	}
6147
+        // getting all the extra profile fields that are defined by the platform administrator
6148
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6149
+
6150
+        // creating the form
6151
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6152
+
6153
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6154
+        // the information the users have entered or selected.
6155
+        $return .= '<select name="additional_profile_field">';
6156
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6157
+        $extra_fields_to_show = 0;
6158
+        foreach ($extra_fields as $key=>$field) {
6159
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6160
+            if ($field[6]==1 && $field[8] == 1) {
6161
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6162
+                    $selected = 'selected="selected"';
6163
+                } else {
6164
+                    $selected = '';
6165
+                }
6166
+                $extra_fields_to_show++;
6167
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6168
+            }
6169
+        }
6170
+        $return .= '</select>';
6171
+
6172
+        // the form elements for the $_GET parameters (because the form is passed through GET
6173
+        foreach ($_GET as $key=>$value){
6174
+            if ($key <> 'additional_profile_field')    {
6175
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6176
+            }
6177
+        }
6178
+        // the submit button
6179
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6180
+        $return .= '</form>';
6181
+        if ($extra_fields_to_show > 0) {
6182
+            return $return;
6183
+        } else {
6184
+            return '';
6185
+        }
6186 6186
     }
6187 6187
 
6188 6188
     /**
@@ -6201,31 +6201,31 @@  discard block
 block discarded – undo
6201 6201
      */
6202 6202
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6203 6203
     {
6204
-    	// Database table definition
6205
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6206
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6204
+        // Database table definition
6205
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6206
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6207 6207
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6208
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6209
-
6210
-    	if (!empty($users)) {
6211
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6212
-    			foreach($users as $user_id) {
6213
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6214
-    				$tag_list = array();
6215
-    				foreach($user_result as $item) {
6216
-    					$tag_list[] = $item['tag'];
6217
-    				}
6218
-    				$return[$user_id][] = implode(', ',$tag_list);
6219
-    			}
6220
-    		} else {
6221
-    			$new_user_array = array();
6222
-    			foreach ($users as $user_id) {
6223
-    				$new_user_array[]= "'".$user_id."'";
6224
-    			}
6225
-    			$users = implode(',',$new_user_array);
6208
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6209
+
6210
+        if (!empty($users)) {
6211
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6212
+                foreach($users as $user_id) {
6213
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6214
+                    $tag_list = array();
6215
+                    foreach($user_result as $item) {
6216
+                        $tag_list[] = $item['tag'];
6217
+                    }
6218
+                    $return[$user_id][] = implode(', ',$tag_list);
6219
+                }
6220
+            } else {
6221
+                $new_user_array = array();
6222
+                foreach ($users as $user_id) {
6223
+                    $new_user_array[]= "'".$user_id."'";
6224
+                }
6225
+                $users = implode(',',$new_user_array);
6226 6226
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6227
-    			// Selecting only the necessary information NOT ALL the user list
6228
-    			$sql = "SELECT user.user_id, v.value
6227
+                // Selecting only the necessary information NOT ALL the user list
6228
+                $sql = "SELECT user.user_id, v.value
6229 6229
     			        FROM $table_user user
6230 6230
     			        INNER JOIN $table_user_field_values v
6231 6231
                         ON (user.user_id = v.item_id)
@@ -6236,27 +6236,27 @@  discard block
 block discarded – undo
6236 6236
                             v.field_id=".intval($field_id)." AND
6237 6237
                             user.user_id IN ($users)";
6238 6238
 
6239
-    			$result = Database::query($sql);
6240
-    			while($row = Database::fetch_array($result)) {
6241
-    				// get option value for field type double select by id
6242
-    				if (!empty($row['value'])) {
6243
-    					if ($result_extra_field['field_type'] ==
6239
+                $result = Database::query($sql);
6240
+                while($row = Database::fetch_array($result)) {
6241
+                    // get option value for field type double select by id
6242
+                    if (!empty($row['value'])) {
6243
+                        if ($result_extra_field['field_type'] ==
6244 6244
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6245 6245
                         ) {
6246
-    						$id_double_select = explode(';', $row['value']);
6247
-    						if (is_array($id_double_select)) {
6248
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6249
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6250
-    							$row['value'] = ($value1.';'.$value2);
6251
-    						}
6252
-    					}
6253
-    				}
6254
-    				// get other value from extra field
6255
-    				$return[$row['user_id']][] = $row['value'];
6256
-    			}
6257
-    		}
6258
-    	}
6259
-    	return $return;
6246
+                            $id_double_select = explode(';', $row['value']);
6247
+                            if (is_array($id_double_select)) {
6248
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6249
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6250
+                                $row['value'] = ($value1.';'.$value2);
6251
+                            }
6252
+                        }
6253
+                    }
6254
+                    // get other value from extra field
6255
+                    $return[$row['user_id']][] = $row['value'];
6256
+                }
6257
+            }
6258
+        }
6259
+        return $return;
6260 6260
     }
6261 6261
 
6262 6262
     /**
@@ -6265,18 +6265,18 @@  discard block
 block discarded – undo
6265 6265
      */
6266 6266
     public function count_student_in_course()
6267 6267
     {
6268
-    	global $nbStudents;
6269
-    	return $nbStudents;
6268
+        global $nbStudents;
6269
+        return $nbStudents;
6270 6270
     }
6271 6271
 
6272 6272
     public function sort_users($a, $b)
6273 6273
     {
6274
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6274
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6275 6275
     }
6276 6276
 
6277 6277
     public function sort_users_desc($a, $b)
6278 6278
     {
6279
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6279
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6280 6280
     }
6281 6281
 
6282 6282
     /**
@@ -6285,8 +6285,8 @@  discard block
 block discarded – undo
6285 6285
      */
6286 6286
     public static function get_number_of_users()
6287 6287
     {
6288
-    	global $user_ids;
6289
-    	return count($user_ids);
6288
+        global $user_ids;
6289
+        return count($user_ids);
6290 6290
     }
6291 6291
 
6292 6292
     /**
@@ -6302,37 +6302,37 @@  discard block
 block discarded – undo
6302 6302
     {
6303 6303
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6304 6304
 
6305
-    	$course_code = Database::escape_string($course_code);
6306
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6307
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6305
+        $course_code = Database::escape_string($course_code);
6306
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6307
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6308 6308
 
6309
-    	$access_url_id = api_get_current_access_url_id();
6309
+        $access_url_id = api_get_current_access_url_id();
6310 6310
 
6311
-    	// get all users data from a course for sortable with limit
6312
-    	if (is_array($user_ids)) {
6313
-    		$user_ids = array_map('intval', $user_ids);
6314
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6315
-    	} else {
6316
-    		$user_ids = intval($user_ids);
6317
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6318
-    	}
6311
+        // get all users data from a course for sortable with limit
6312
+        if (is_array($user_ids)) {
6313
+            $user_ids = array_map('intval', $user_ids);
6314
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6315
+        } else {
6316
+            $user_ids = intval($user_ids);
6317
+            $condition_user = " WHERE user.user_id = $user_ids ";
6318
+        }
6319 6319
 
6320
-    	if (!empty($_GET['user_keyword'])) {
6321
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6322
-    		$condition_user .=  " AND (
6320
+        if (!empty($_GET['user_keyword'])) {
6321
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6322
+            $condition_user .=  " AND (
6323 6323
                 user.firstname LIKE '%".$keyword."%' OR
6324 6324
                 user.lastname LIKE '%".$keyword."%'  OR
6325 6325
                 user.username LIKE '%".$keyword."%'  OR
6326 6326
                 user.email LIKE '%".$keyword."%'
6327 6327
              ) ";
6328
-    	}
6328
+        }
6329 6329
 
6330 6330
         $url_table = null;
6331 6331
         $url_condition = null;
6332
-    	if (api_is_multiple_url_enabled()) {
6333
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6334
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6335
-    	}
6332
+        if (api_is_multiple_url_enabled()) {
6333
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6334
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6335
+        }
6336 6336
 
6337 6337
         $invitedUsersCondition = '';
6338 6338
 
@@ -6340,7 +6340,7 @@  discard block
 block discarded – undo
6340 6340
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6341 6341
         }
6342 6342
 
6343
-    	$sql = "SELECT  user.user_id as user_id,
6343
+        $sql = "SELECT  user.user_id as user_id,
6344 6344
                     user.official_code  as col0,
6345 6345
                     user.lastname       as col1,
6346 6346
                     user.firstname      as col2,
@@ -6348,17 +6348,17 @@  discard block
 block discarded – undo
6348 6348
                 FROM $tbl_user as user $url_table
6349 6349
     	        $condition_user $url_condition $invitedUsersCondition";
6350 6350
 
6351
-    	if (!in_array($direction, array('ASC','DESC'))) {
6352
-    		$direction = 'ASC';
6353
-    	}
6351
+        if (!in_array($direction, array('ASC','DESC'))) {
6352
+            $direction = 'ASC';
6353
+        }
6354 6354
 
6355
-    	$column = intval($column);
6355
+        $column = intval($column);
6356 6356
 
6357
-    	$from = intval($from);
6358
-    	$number_of_items = intval($number_of_items);
6357
+        $from = intval($from);
6358
+        $number_of_items = intval($number_of_items);
6359 6359
 
6360
-    	$sql .= " ORDER BY col$column $direction ";
6361
-    	$sql .= " LIMIT $from,$number_of_items";
6360
+        $sql .= " ORDER BY col$column $direction ";
6361
+        $sql .= " LIMIT $from,$number_of_items";
6362 6362
 
6363 6363
         $res = Database::query($sql);
6364 6364
         $users = array();
@@ -6392,7 +6392,7 @@  discard block
 block discarded – undo
6392 6392
             }
6393 6393
         }
6394 6394
 
6395
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6395
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6396 6396
             $courseInfo = api_get_course_info($course_code);
6397 6397
             $courseId = $courseInfo['real_id'];
6398 6398
 
@@ -6423,10 +6423,10 @@  discard block
 block discarded – undo
6423 6423
                 $session_id
6424 6424
             );
6425 6425
 
6426
-    		if (empty($avg_student_progress)) {
6426
+            if (empty($avg_student_progress)) {
6427 6427
                 $avg_student_progress = 0;
6428
-    		}
6429
-    		$user['average_progress'] = $avg_student_progress.'%';
6428
+            }
6429
+            $user['average_progress'] = $avg_student_progress.'%';
6430 6430
 
6431 6431
             $total_user_exercise = Tracking::get_exercise_student_progress(
6432 6432
                 $total_exercises,
@@ -6446,11 +6446,11 @@  discard block
 block discarded – undo
6446 6446
 
6447 6447
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6448 6448
 
6449
-    		if (is_numeric($avg_student_score)) {
6450
-    			$user['student_score']  = $avg_student_score.'%';
6451
-    		} else {
6452
-    			$user['student_score']  = $avg_student_score;
6453
-    		}
6449
+            if (is_numeric($avg_student_score)) {
6450
+                $user['student_score']  = $avg_student_score.'%';
6451
+            } else {
6452
+                $user['student_score']  = $avg_student_score;
6453
+            }
6454 6454
 
6455 6455
             $user['count_assignments'] = Tracking::count_student_assignments(
6456 6456
                 $user['user_id'],
@@ -6473,29 +6473,29 @@  discard block
 block discarded – undo
6473 6473
                 $session_id
6474 6474
             );
6475 6475
 
6476
-    		// we need to display an additional profile field
6477
-    		$user['additional'] = '';
6476
+            // we need to display an additional profile field
6477
+            $user['additional'] = '';
6478 6478
 
6479
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6480
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6479
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6480
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6481 6481
                     is_array($additional_user_profile_info[$user['user_id']])
6482 6482
                 ) {
6483
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6484
-    			}
6485
-    		}
6483
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6484
+                }
6485
+            }
6486 6486
 
6487 6487
             if (empty($session_id)) {
6488 6488
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6489 6489
             }
6490 6490
 
6491
-    		$user['link'] = '<center>
6491
+            $user['link'] = '<center>
6492 6492
                              <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'">
6493 6493
     		                 '.Display::return_icon('2rightarrow.png').'
6494 6494
     		                 </a>
6495 6495
                          </center>';
6496 6496
 
6497
-    		// store columns in array $users
6498
-    		$is_western_name_order = api_is_western_name_order();
6497
+            // store columns in array $users
6498
+            $is_western_name_order = api_is_western_name_order();
6499 6499
             $user_row = array();
6500 6500
             $user_row[]= $user['official_code']; //0
6501 6501
             if ($is_western_name_order) {
@@ -6531,21 +6531,21 @@  discard block
 block discarded – undo
6531 6531
 
6532 6532
             $users[] = $user_row;
6533 6533
 
6534
-    		if ($export_csv) {
6535
-    		    if (empty($session_id)) {
6534
+            if ($export_csv) {
6535
+                if (empty($session_id)) {
6536 6536
                     $user_row = array_map('strip_tags', $user_row);
6537
-    			    unset($user_row[14]);
6538
-    			    unset($user_row[15]);
6537
+                    unset($user_row[14]);
6538
+                    unset($user_row[15]);
6539 6539
                 } else {
6540 6540
                     $user_row = array_map('strip_tags', $user_row);
6541 6541
                     unset($user_row[13]);
6542 6542
                     unset($user_row[14]);
6543 6543
                 }
6544 6544
 
6545
-    			$csv_content[] = $user_row;
6546
-    		}
6547
-    	}
6548
-    	return $users;
6545
+                $csv_content[] = $user_row;
6546
+            }
6547
+        }
6548
+        return $users;
6549 6549
     }
6550 6550
 }
6551 6551
 
@@ -6563,18 +6563,18 @@  discard block
 block discarded – undo
6563 6563
      */
6564 6564
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6565 6565
     {
6566
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6567
-
6568
-    	// protected data
6569
-    	$user_id = intval($user_id);
6570
-    	$session_id = intval($session_id);
6571
-    	$course_id = Database::escape_string($course_id);
6572
-
6573
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6574
-    	$tempView = $view;
6575
-    	if(substr($view,0,1) == '1') {
6576
-    		$new_view = substr_replace($view,'0',0,1);
6577
-    		echo "
6566
+        $MonthsLong = $GLOBALS['MonthsLong'];
6567
+
6568
+        // protected data
6569
+        $user_id = intval($user_id);
6570
+        $session_id = intval($session_id);
6571
+        $course_id = Database::escape_string($course_id);
6572
+
6573
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6574
+        $tempView = $view;
6575
+        if(substr($view,0,1) == '1') {
6576
+            $new_view = substr_replace($view,'0',0,1);
6577
+            echo "
6578 6578
                 <tr>
6579 6579
                     <td valign='top'>
6580 6580
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6582,9 +6582,9 @@  discard block
 block discarded – undo
6582 6582
                     </td>
6583 6583
                 </tr>
6584 6584
                 ";
6585
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6585
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6586 6586
 
6587
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6587
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6588 6588
                         FROM $track_access_table
6589 6589
                         WHERE access_user_id = $user_id
6590 6590
                         AND c_id = $course_id
@@ -6592,11 +6592,11 @@  discard block
 block discarded – undo
6592 6592
                         GROUP BY YEAR(access_date),MONTH(access_date)
6593 6593
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6594 6594
 
6595
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6596
-    		$results = getManyResults3Col($sql);
6595
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6596
+            $results = getManyResults3Col($sql);
6597 6597
 
6598
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6599
-    		echo "<tr>
6598
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6599
+            echo "<tr>
6600 6600
                     <td class='secLine'>
6601 6601
                     ".get_lang('LoginsTitleMonthColumn')."
6602 6602
                     </td>
@@ -6604,36 +6604,36 @@  discard block
 block discarded – undo
6604 6604
                     ".get_lang('LoginsTitleCountColumn')."
6605 6605
                     </td>
6606 6606
                 </tr>";
6607
-    		$total = 0;
6608
-    		if (is_array($results)) {
6609
-    			for($j = 0 ; $j < count($results) ; $j++) {
6610
-    				echo "<tr>";
6611
-    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6612
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6613
-    				echo"</tr>";
6614
-    				$total = $total + $results[$j][1];
6615
-    			}
6616
-    			echo "<tr>";
6617
-    			echo "<td>".get_lang('Total')."</td>";
6618
-    			echo "<td align='right' class='content'>".$total."</td>";
6619
-    			echo"</tr>";
6620
-    		} else {
6621
-    			echo "<tr>";
6622
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6623
-    			echo"</tr>";
6624
-    		}
6625
-    		echo "</table>";
6626
-    		echo "</td></tr>";
6627
-    	} else {
6628
-    		$new_view = substr_replace($view,'1',0,1);
6629
-    		echo "
6607
+            $total = 0;
6608
+            if (is_array($results)) {
6609
+                for($j = 0 ; $j < count($results) ; $j++) {
6610
+                    echo "<tr>";
6611
+                    echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6612
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6613
+                    echo"</tr>";
6614
+                    $total = $total + $results[$j][1];
6615
+                }
6616
+                echo "<tr>";
6617
+                echo "<td>".get_lang('Total')."</td>";
6618
+                echo "<td align='right' class='content'>".$total."</td>";
6619
+                echo"</tr>";
6620
+            } else {
6621
+                echo "<tr>";
6622
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6623
+                echo"</tr>";
6624
+            }
6625
+            echo "</table>";
6626
+            echo "</td></tr>";
6627
+        } else {
6628
+            $new_view = substr_replace($view,'1',0,1);
6629
+            echo "
6630 6630
                 <tr>
6631 6631
                     <td valign='top'>
6632 6632
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a>
6633 6633
                     </td>
6634 6634
                 </tr>
6635 6635
             ";
6636
-    	}
6636
+        }
6637 6637
     }
6638 6638
 
6639 6639
     /**
@@ -6646,38 +6646,38 @@  discard block
 block discarded – undo
6646 6646
      */
6647 6647
     public function display_exercise_tracking_info($view, $user_id, $courseCode)
6648 6648
     {
6649
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6649
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6650 6650
         $courseId = api_get_course_int_id($courseCode);
6651
-    	if(substr($view,1,1) == '1') {
6652
-    		$new_view = substr_replace($view,'0',1,1);
6653
-    		echo "<tr>
6651
+        if(substr($view,1,1) == '1') {
6652
+            $new_view = substr_replace($view,'0',1,1);
6653
+            echo "<tr>
6654 6654
                     <td valign='top'>
6655 6655
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
6656 6656
                     </td>
6657 6657
                 </tr>";
6658
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6658
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6659 6659
 
6660
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6660
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6661 6661
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6662 6662
                     WHERE te.c_id = $courseId
6663 6663
                         AND te.exe_user_id = ".intval($user_id)."
6664 6664
                         AND te.exe_exo_id = ce.id
6665 6665
                     ORDER BY ce.title ASC, te.exe_date ASC";
6666 6666
 
6667
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6667
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6668 6668
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6669 6669
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6670 6670
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6671 6671
 
6672
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6672
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6673 6673
 
6674
-    		$NoTestRes = 0;
6675
-    		$NoHPTestRes = 0;
6674
+            $NoTestRes = 0;
6675
+            $NoHPTestRes = 0;
6676 6676
 
6677
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6678
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6679
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6680
-    		echo "
6677
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6678
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6679
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6680
+            echo "
6681 6681
                 <tr bgcolor='#E6E6E6'>
6682 6682
                     <td>
6683 6683
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6690,28 +6690,28 @@  discard block
 block discarded – undo
6690 6690
                     </td>
6691 6691
                 </tr>";
6692 6692
 
6693
-    		if (is_array($results)) {
6694
-    			for($i = 0; $i < sizeof($results); $i++) {
6695
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6696
-    				echo "<tr>\n";
6697
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6698
-    				echo "<td class='content'>".$display_date."</td>\n";
6699
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6700
-    				echo "</tr>\n";
6701
-    			}
6702
-    		} else {
6703
-    			// istvan begin
6704
-    			$NoTestRes = 1;
6705
-    		}
6706
-
6707
-    		// The Result of Tests
6708
-    		if (is_array($hpresults)) {
6709
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6710
-    				$title = GetQuizName($hpresults[$i][0],'');
6711
-    				if ($title == '')
6712
-    				$title = basename($hpresults[$i][0]);
6713
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6714
-    				?>
6693
+            if (is_array($results)) {
6694
+                for($i = 0; $i < sizeof($results); $i++) {
6695
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6696
+                    echo "<tr>\n";
6697
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6698
+                    echo "<td class='content'>".$display_date."</td>\n";
6699
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6700
+                    echo "</tr>\n";
6701
+                }
6702
+            } else {
6703
+                // istvan begin
6704
+                $NoTestRes = 1;
6705
+            }
6706
+
6707
+            // The Result of Tests
6708
+            if (is_array($hpresults)) {
6709
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6710
+                    $title = GetQuizName($hpresults[$i][0],'');
6711
+                    if ($title == '')
6712
+                    $title = basename($hpresults[$i][0]);
6713
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6714
+                    ?>
6715 6715
                     <tr>
6716 6716
                         <td class="content"><?php echo $title; ?></td>
6717 6717
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6721,26 +6721,26 @@  discard block
 block discarded – undo
6721 6721
 
6722 6722
                     <?php
6723 6723
                 }
6724
-    		} else {
6725
-    			$NoHPTestRes = 1;
6726
-    		}
6727
-
6728
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6729
-    			echo "<tr>\n";
6730
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6731
-    			echo "</tr>\n";
6732
-    		}
6733
-    		echo "</table>";
6734
-    		echo "</td>\n</tr>\n";
6735
-    	} else {
6736
-    		$new_view = substr_replace($view,'1',1,1);
6737
-    		echo "
6724
+            } else {
6725
+                $NoHPTestRes = 1;
6726
+            }
6727
+
6728
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6729
+                echo "<tr>\n";
6730
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6731
+                echo "</tr>\n";
6732
+            }
6733
+            echo "</table>";
6734
+            echo "</td>\n</tr>\n";
6735
+        } else {
6736
+            $new_view = substr_replace($view,'1',1,1);
6737
+            echo "
6738 6738
                 <tr>
6739 6739
                     <td valign='top'>
6740 6740
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6741 6741
                     </td>
6742 6742
                 </tr>";
6743
-    	}
6743
+        }
6744 6744
     }
6745 6745
 
6746 6746
     /**
@@ -6749,27 +6749,27 @@  discard block
 block discarded – undo
6749 6749
      */
6750 6750
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
6751 6751
     {
6752
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6752
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6753 6753
         $_course = api_get_course_info_by_id($course_id);
6754 6754
 
6755
-    	if (substr($view,2,1) == '1') {
6756
-    		$new_view = substr_replace($view,'0',2,1);
6757
-    		echo "<tr>
6755
+        if (substr($view,2,1) == '1') {
6756
+            $new_view = substr_replace($view,'0',2,1);
6757
+            echo "<tr>
6758 6758
                     <td valign='top'>
6759 6759
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
6760 6760
                     </td>
6761 6761
                 </tr>";
6762
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6763
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6762
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6763
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6764 6764
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6765 6765
                     WHERE u.upload_work_id = w.id
6766 6766
                         AND u.upload_user_id = '".intval($user_id)."'
6767 6767
                         AND u.c_id = '".intval($course_id)."'
6768 6768
                     ORDER BY u.upload_date DESC";
6769
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6770
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6771
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6772
-    		echo "<tr>
6769
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6770
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6771
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6772
+            echo "<tr>
6773 6773
                     <td class='secLine' width='40%'>
6774 6774
                     ".get_lang('WorkTitle')."
6775 6775
                     </td>
@@ -6780,35 +6780,35 @@  discard block
 block discarded – undo
6780 6780
                     ".get_lang('Date')."
6781 6781
                     </td>
6782 6782
                 </tr>";
6783
-    		if (is_array($results)) {
6784
-    			for($j = 0 ; $j < count($results) ; $j++) {
6785
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6786
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6787
-    				echo "<tr>";
6788
-    				echo "<td class='content'>"
6789
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6790
-    				."</td>";
6791
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6792
-    				echo "<td class='content'>".$beautifulDate."</td>";
6793
-    				echo"</tr>";
6794
-    			}
6795
-    		} else {
6796
-    			echo "<tr>";
6797
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6798
-    			echo"</tr>";
6799
-    		}
6800
-    		echo "</table>";
6801
-    		echo "</td></tr>";
6802
-    	} else {
6803
-    		$new_view = substr_replace($view,'1',2,1);
6804
-    		echo "
6783
+            if (is_array($results)) {
6784
+                for($j = 0 ; $j < count($results) ; $j++) {
6785
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6786
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6787
+                    echo "<tr>";
6788
+                    echo "<td class='content'>"
6789
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6790
+                    ."</td>";
6791
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6792
+                    echo "<td class='content'>".$beautifulDate."</td>";
6793
+                    echo"</tr>";
6794
+                }
6795
+            } else {
6796
+                echo "<tr>";
6797
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6798
+                echo"</tr>";
6799
+            }
6800
+            echo "</table>";
6801
+            echo "</td></tr>";
6802
+        } else {
6803
+            $new_view = substr_replace($view,'1',2,1);
6804
+            echo "
6805 6805
                 <tr>
6806 6806
                     <td valign='top'>
6807 6807
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a>
6808 6808
                     </td>
6809 6809
                 </tr>
6810 6810
             ";
6811
-    	}
6811
+        }
6812 6812
     }
6813 6813
 
6814 6814
     /**
@@ -6817,55 +6817,55 @@  discard block
 block discarded – undo
6817 6817
      */
6818 6818
     public function display_links_tracking_info($view, $user_id, $courseCode)
6819 6819
     {
6820
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6820
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6821 6821
         $courseId = api_get_course_int_id($courseCode);
6822
-    	if (substr($view,3,1) == '1') {
6823
-    		$new_view = substr_replace($view,'0',3,1);
6824
-    		echo "
6822
+        if (substr($view,3,1) == '1') {
6823
+            $new_view = substr_replace($view,'0',3,1);
6824
+            echo "
6825 6825
                 <tr>
6826 6826
                         <td valign='top'>
6827 6827
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('LinksAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>]
6828 6828
                         </td>
6829 6829
                 </tr>
6830 6830
             ";
6831
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6832
-    		$sql = "SELECT cl.title, cl.url
6831
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6832
+            $sql = "SELECT cl.title, cl.url
6833 6833
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
6834 6834
                     WHERE sl.links_link_id = cl.id
6835 6835
                         AND sl.c_id = $courseId
6836 6836
                         AND sl.links_user_id = ".intval($user_id)."
6837 6837
                     GROUP BY cl.title, cl.url";
6838
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6839
-    		$results = StatsUtils::getManyResults2Col($sql);
6840
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6841
-    		echo "<tr>
6838
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6839
+            $results = StatsUtils::getManyResults2Col($sql);
6840
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6841
+            echo "<tr>
6842 6842
                     <td class='secLine'>
6843 6843
                     ".get_lang('LinksTitleLinkColumn')."
6844 6844
                     </td>
6845 6845
                 </tr>";
6846
-    		if (is_array($results)) {
6847
-    			for($j = 0 ; $j < count($results) ; $j++) {
6848
-    				echo "<tr>";
6849
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6850
-    				echo"</tr>";
6851
-    			}
6852
-    		} else {
6853
-    			echo "<tr>";
6854
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
6855
-    			echo"</tr>";
6856
-    		}
6857
-    		echo "</table>";
6858
-    		echo "</td></tr>";
6859
-    	} else {
6860
-    		$new_view = substr_replace($view,'1',3,1);
6861
-    		echo "
6846
+            if (is_array($results)) {
6847
+                for($j = 0 ; $j < count($results) ; $j++) {
6848
+                    echo "<tr>";
6849
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6850
+                    echo"</tr>";
6851
+                }
6852
+            } else {
6853
+                echo "<tr>";
6854
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
6855
+                echo"</tr>";
6856
+            }
6857
+            echo "</table>";
6858
+            echo "</td></tr>";
6859
+        } else {
6860
+            $new_view = substr_replace($view,'1',3,1);
6861
+            echo "
6862 6862
                 <tr>
6863 6863
                     <td valign='top'>
6864 6864
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a>
6865 6865
                     </td>
6866 6866
                 </tr>
6867 6867
             ";
6868
-    	}
6868
+        }
6869 6869
     }
6870 6870
 
6871 6871
     /**
@@ -6878,61 +6878,61 @@  discard block
 block discarded – undo
6878 6878
      */
6879 6879
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
6880 6880
     {
6881
-    	// protect data
6881
+        // protect data
6882 6882
         $user_id = intval($user_id);
6883 6883
         $courseId = api_get_course_int_id($course_code);
6884
-    	$session_id = intval($session_id);
6884
+        $session_id = intval($session_id);
6885 6885
 
6886
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6887
-    	if(substr($view,4,1) == '1') {
6888
-    		$new_view = substr_replace($view,'0',4,1);
6889
-    		echo "
6886
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6887
+        if(substr($view,4,1) == '1') {
6888
+            $new_view = substr_replace($view,'0',4,1);
6889
+            echo "
6890 6890
                 <tr>
6891 6891
                     <td valign='top'>
6892 6892
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('DocumentsAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>]
6893 6893
                     </td>
6894 6894
                 </tr>
6895 6895
             ";
6896
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6896
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6897 6897
 
6898
-    		$sql = "SELECT down_doc_path
6898
+            $sql = "SELECT down_doc_path
6899 6899
                     FROM $downloads_table
6900 6900
                     WHERE c_id = $courseId
6901 6901
                         AND down_user_id = $user_id
6902 6902
                         AND down_session_id = $session_id
6903 6903
                     GROUP BY down_doc_path";
6904 6904
 
6905
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6906
-    		$results = StatsUtils::getManyResults1Col($sql);
6907
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6908
-    		echo "<tr>
6905
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6906
+            $results = StatsUtils::getManyResults1Col($sql);
6907
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6908
+            echo "<tr>
6909 6909
                     <td class='secLine'>
6910 6910
                     ".get_lang('DocumentsTitleDocumentColumn')."
6911 6911
                     </td>
6912 6912
                 </tr>";
6913
-    		if (is_array($results)) {
6914
-    			for($j = 0 ; $j < count($results) ; $j++) {
6915
-    				echo "<tr>";
6916
-    				echo "<td class='content'>".$results[$j]."</td>";
6917
-    				echo"</tr>";
6918
-    			}
6919
-    		} else {
6920
-    			echo "<tr>";
6921
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
6922
-    			echo"</tr>";
6923
-    		}
6924
-    		echo "</table>";
6925
-    		echo "</td></tr>";
6926
-    	} else {
6927
-    		$new_view = substr_replace($view,'1',4,1);
6928
-    		echo "
6913
+            if (is_array($results)) {
6914
+                for($j = 0 ; $j < count($results) ; $j++) {
6915
+                    echo "<tr>";
6916
+                    echo "<td class='content'>".$results[$j]."</td>";
6917
+                    echo"</tr>";
6918
+                }
6919
+            } else {
6920
+                echo "<tr>";
6921
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
6922
+                echo"</tr>";
6923
+            }
6924
+            echo "</table>";
6925
+            echo "</td></tr>";
6926
+        } else {
6927
+            $new_view = substr_replace($view,'1',4,1);
6928
+            echo "
6929 6929
                 <tr>
6930 6930
                     <td valign='top'>
6931 6931
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a>
6932 6932
                     </td>
6933 6933
                 </tr>
6934 6934
             ";
6935
-    	}
6935
+        }
6936 6936
     }
6937 6937
 
6938 6938
     /**
@@ -6989,43 +6989,43 @@  discard block
 block discarded – undo
6989 6989
      */
6990 6990
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6991 6991
     {
6992
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6993
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6994
-
6995
-    	// protected data
6996
-    	$user_id    = intval($user_id);
6997
-    	$session_id = intval($session_id);
6998
-    	$course_id  = intval($course_id);
6999
-
7000
-    	$tempView = $view;
7001
-    	if (substr($view,0,1) == '1') {
7002
-    		$new_view = substr_replace($view,'0',0,1);
7003
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7004
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6992
+        $MonthsLong = $GLOBALS['MonthsLong'];
6993
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6994
+
6995
+        // protected data
6996
+        $user_id    = intval($user_id);
6997
+        $session_id = intval($session_id);
6998
+        $course_id  = intval($course_id);
6999
+
7000
+        $tempView = $view;
7001
+        if (substr($view,0,1) == '1') {
7002
+            $new_view = substr_replace($view,'0',0,1);
7003
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7004
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7005 7005
                     FROM $track_access_table
7006 7006
                     WHERE access_user_id = $user_id
7007 7007
                     AND c_id = $course_id
7008 7008
                     AND access_session_id = $session_id
7009 7009
                     GROUP BY YEAR(access_date),MONTH(access_date)
7010 7010
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7011
-    		//$results = getManyResults2Col($sql);
7012
-    		$results = getManyResults3Col($sql);
7013
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7014
-    		$line='';
7015
-    		$total = 0;
7016
-    		if (is_array($results)) {
7017
-    			for($j = 0 ; $j < count($results) ; $j++) {
7018
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7019
-    				$total = $total + $results[$j][1];
7020
-    			}
7021
-    			$line .= get_lang('Total').";".$total."\n";
7022
-    		} else {
7023
-    			$line= get_lang('NoResult')."</center></td>";
7024
-    		}
7025
-    	} else {
7026
-    		$new_view = substr_replace($view,'1',0,1);
7027
-    	}
7028
-    	return array($title_line, $line);
7011
+            //$results = getManyResults2Col($sql);
7012
+            $results = getManyResults3Col($sql);
7013
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7014
+            $line='';
7015
+            $total = 0;
7016
+            if (is_array($results)) {
7017
+                for($j = 0 ; $j < count($results) ; $j++) {
7018
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
7019
+                    $total = $total + $results[$j][1];
7020
+                }
7021
+                $line .= get_lang('Total').";".$total."\n";
7022
+            } else {
7023
+                $line= get_lang('NoResult')."</center></td>";
7024
+            }
7025
+        } else {
7026
+            $new_view = substr_replace($view,'1',0,1);
7027
+        }
7028
+        return array($title_line, $line);
7029 7029
     }
7030 7030
 
7031 7031
     /**
@@ -7038,67 +7038,67 @@  discard block
 block discarded – undo
7038 7038
      */
7039 7039
     public function display_exercise_tracking_info($view, $userId, $courseCode)
7040 7040
     {
7041
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7041
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7042 7042
         $courseId = api_get_course_int_id($courseCode);
7043 7043
         $userId = intval($userId);
7044
-    	if (substr($view,1,1) == '1') {
7045
-    		$new_view = substr_replace($view,'0',1,1);
7046
-    		$title[1] = get_lang('ExercicesDetails');
7047
-    		$line = '';
7048
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7044
+        if (substr($view,1,1) == '1') {
7045
+            $new_view = substr_replace($view,'0',1,1);
7046
+            $title[1] = get_lang('ExercicesDetails');
7047
+            $line = '';
7048
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7049 7049
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
7050 7050
                     WHERE te.c_id = $courseId
7051 7051
                         AND te.exe_user_id = $userId
7052 7052
                         AND te.exe_exo_id = ce.id
7053 7053
                     ORDER BY ce.title ASC, te.exe_date ASC";
7054 7054
 
7055
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7055
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7056 7056
                         FROM $TABLETRACK_HOTPOTATOES AS te
7057 7057
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
7058 7058
                         ORDER BY te.c_id ASC, te.exe_date ASC";
7059 7059
 
7060
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7060
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7061 7061
 
7062
-    		$NoTestRes = 0;
7063
-    		$NoHPTestRes = 0;
7062
+            $NoTestRes = 0;
7063
+            $NoHPTestRes = 0;
7064 7064
 
7065
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7066
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7065
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
7066
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7067 7067
 
7068
-    		if (is_array($results)) {
7069
-    			for($i = 0; $i < sizeof($results); $i++)
7070
-    			{
7071
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7072
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7073
-    			}
7074
-    		} else {
7068
+            if (is_array($results)) {
7069
+                for($i = 0; $i < sizeof($results); $i++)
7070
+                {
7071
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7072
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7073
+                }
7074
+            } else {
7075 7075
                 // istvan begin
7076
-    			$NoTestRes = 1;
7077
-    		}
7078
-
7079
-    		// The Result of Tests
7080
-    		if (is_array($hpresults)) {
7081
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7082
-    				$title = GetQuizName($hpresults[$i][0],'');
7083
-
7084
-    				if ($title == '')
7085
-    				$title = basename($hpresults[$i][0]);
7086
-
7087
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7088
-
7089
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7090
-    			}
7091
-    		} else {
7092
-    			$NoHPTestRes = 1;
7093
-    		}
7094
-
7095
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7096
-    			$line=get_lang('NoResult');
7097
-    		}
7098
-    	} else {
7099
-    		$new_view = substr_replace($view,'1',1,1);
7100
-    	}
7101
-    	return array($title_line, $line);
7076
+                $NoTestRes = 1;
7077
+            }
7078
+
7079
+            // The Result of Tests
7080
+            if (is_array($hpresults)) {
7081
+                for($i = 0; $i < sizeof($hpresults); $i++) {
7082
+                    $title = GetQuizName($hpresults[$i][0],'');
7083
+
7084
+                    if ($title == '')
7085
+                    $title = basename($hpresults[$i][0]);
7086
+
7087
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7088
+
7089
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7090
+                }
7091
+            } else {
7092
+                $NoHPTestRes = 1;
7093
+            }
7094
+
7095
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7096
+                $line=get_lang('NoResult');
7097
+            }
7098
+        } else {
7099
+            $new_view = substr_replace($view,'1',1,1);
7100
+        }
7101
+        return array($title_line, $line);
7102 7102
     }
7103 7103
 
7104 7104
     /**
@@ -7107,37 +7107,37 @@  discard block
 block discarded – undo
7107 7107
      */
7108 7108
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7109 7109
     {
7110
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7110
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7111 7111
         $_course = api_get_course_info();
7112 7112
         $user_id = intval($user_id);
7113 7113
         $course_id = intval($course_id);
7114 7114
 
7115
-    	if (substr($view,2,1) == '1') {
7116
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7115
+        if (substr($view,2,1) == '1') {
7116
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7117 7117
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7118 7118
                     WHERE
7119 7119
                         u.upload_work_id = w.id AND
7120 7120
                         u.upload_user_id = '$user_id' AND
7121 7121
                         u.c_id = '$course_id'
7122 7122
                     ORDER BY u.upload_date DESC";
7123
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7124
-
7125
-    		$title[1]=get_lang('WorksDetails');
7126
-    		$line='';
7127
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7128
-
7129
-    		if (is_array($results)) {
7130
-    			for($j = 0 ; $j < count($results) ; $j++) {
7131
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7132
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7133
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7134
-    			}
7135
-
7136
-    		} else {
7137
-    			$line= get_lang('NoResult');
7138
-    		}
7139
-    	}
7140
-    	return array($title_line, $line);
7123
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7124
+
7125
+            $title[1]=get_lang('WorksDetails');
7126
+            $line='';
7127
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7128
+
7129
+            if (is_array($results)) {
7130
+                for($j = 0 ; $j < count($results) ; $j++) {
7131
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7132
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7133
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7134
+                }
7135
+
7136
+            } else {
7137
+                $line= get_lang('NoResult');
7138
+            }
7139
+        }
7140
+        return array($title_line, $line);
7141 7141
     }
7142 7142
 
7143 7143
     /**
@@ -7146,32 +7146,32 @@  discard block
 block discarded – undo
7146 7146
      */
7147 7147
     public function display_links_tracking_info($view, $userId, $courseCode)
7148 7148
     {
7149
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7149
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7150 7150
         $courseId = api_get_course_int_id($courseCode);
7151 7151
         $userId = intval($userId);
7152 7152
         $line = null;
7153
-    	if (substr($view,3,1) == '1') {
7154
-    		$new_view = substr_replace($view,'0',3,1);
7155
-    		$title[1]=get_lang('LinksDetails');
7156
-    		$sql = "SELECT cl.title, cl.url
7153
+        if (substr($view,3,1) == '1') {
7154
+            $new_view = substr_replace($view,'0',3,1);
7155
+            $title[1]=get_lang('LinksDetails');
7156
+            $sql = "SELECT cl.title, cl.url
7157 7157
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7158 7158
                         WHERE sl.links_link_id = cl.id
7159 7159
                             AND sl.c_id = $courseId
7160 7160
                             AND sl.links_user_id = $userId
7161 7161
                         GROUP BY cl.title, cl.url";
7162
-    		$results = StatsUtils::getManyResults2Col($sql);
7163
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7164
-    		if (is_array($results)) {
7165
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7166
-    				$line .= $results[$j][0]."\n";
7167
-    			}
7168
-    		} else {
7169
-    			$line=get_lang('NoResult');
7170
-    		}
7171
-    	} else {
7172
-    		$new_view = substr_replace($view,'1',3,1);
7173
-    	}
7174
-    	return array($title_line, $line);
7162
+            $results = StatsUtils::getManyResults2Col($sql);
7163
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7164
+            if (is_array($results)) {
7165
+                for ($j = 0 ; $j < count($results) ; $j++) {
7166
+                    $line .= $results[$j][0]."\n";
7167
+                }
7168
+            } else {
7169
+                $line=get_lang('NoResult');
7170
+            }
7171
+        } else {
7172
+            $new_view = substr_replace($view,'1',3,1);
7173
+        }
7174
+        return array($title_line, $line);
7175 7175
     }
7176 7176
 
7177 7177
     /**
@@ -7184,38 +7184,38 @@  discard block
 block discarded – undo
7184 7184
      */
7185 7185
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7186 7186
     {
7187
-    	// protect data
7188
-    	$user_id     = intval($user_id);
7187
+        // protect data
7188
+        $user_id     = intval($user_id);
7189 7189
         $courseId = api_get_course_int_id($courseCode);
7190
-    	$session_id = intval($session_id);
7190
+        $session_id = intval($session_id);
7191 7191
 
7192
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7192
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7193 7193
 
7194
-    	if (substr($view,4,1) == '1') {
7195
-    		$new_view = substr_replace($view,'0',4,1);
7196
-    		$title[1]= get_lang('DocumentsDetails');
7194
+        if (substr($view,4,1) == '1') {
7195
+            $new_view = substr_replace($view,'0',4,1);
7196
+            $title[1]= get_lang('DocumentsDetails');
7197 7197
 
7198
-    		$sql = "SELECT down_doc_path
7198
+            $sql = "SELECT down_doc_path
7199 7199
                         FROM $downloads_table
7200 7200
                         WHERE c_id = $courseId
7201 7201
                             AND down_user_id = $user_id
7202 7202
                             AND down_session_id = $session_id
7203 7203
                         GROUP BY down_doc_path";
7204 7204
 
7205
-    		$results = StatsUtils::getManyResults1Col($sql);
7206
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7205
+            $results = StatsUtils::getManyResults1Col($sql);
7206
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7207 7207
             $line = null;
7208
-    		if (is_array($results)) {
7209
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7210
-    				$line .= $results[$j]."\n";
7211
-    			}
7212
-    		} else {
7213
-    			$line = get_lang('NoResult');
7214
-    		}
7215
-    	} else {
7216
-    		$new_view = substr_replace($view,'1',4,1);
7217
-    	}
7218
-    	return array($title_line, $line);
7208
+            if (is_array($results)) {
7209
+                for ($j = 0 ; $j < count($results) ; $j++) {
7210
+                    $line .= $results[$j]."\n";
7211
+                }
7212
+            } else {
7213
+                $line = get_lang('NoResult');
7214
+            }
7215
+        } else {
7216
+            $new_view = substr_replace($view,'1',4,1);
7217
+        }
7218
+        return array($title_line, $line);
7219 7219
     }
7220 7220
 
7221 7221
     /**
Please login to merge, or discard this patch.
main/search/index.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 $this_section =  SECTION_COURSES;
11 11
 
12 12
 if (extension_loaded('xapian')) {
13
-	require '../lp/lp_list_search.php';
13
+    require '../lp/lp_list_search.php';
14 14
 } else {
15 15
     Display::display_header(get_lang('Search'));
16 16
     Display::display_error_message(get_lang('SearchXapianModuleNotInstalled'));
Please login to merge, or discard this patch.
main/lp/resourcelinker.inc.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
             $ext = strtolower($ext[sizeof($ext)-1]);
289 289
             $myrow['path'] = rawurlencode($myrow['path']);
290 290
 
291
-			$array_ext = array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png');
291
+            $array_ext = array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png');
292 292
 
293
-			if (api_browser_support('svg')) {
294
-				$array_ext[] = 'svg';
295
-			}
296
-			if (api_browser_support('ogg')) {
297
-				$array_ext[] = 'ogg';
298
-			}
293
+            if (api_browser_support('svg')) {
294
+                $array_ext[] = 'svg';
295
+            }
296
+            if (api_browser_support('ogg')) {
297
+                $array_ext[] = 'ogg';
298
+            }
299 299
 
300 300
             $in_frames = in_array($ext, $array_ext);
301 301
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
             $result = Database::query($sql);
403 403
             $row = Database::fetch_array($result);
404 404
             if ($row['title'] != '') {
405
-                 $myrow['content'] = $row['title'];
405
+                    $myrow['content'] = $row['title'];
406 406
             }
407 407
             $desc = $row['description'];
408 408
             $ann_id = $row['item_id'];
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
             $myrow = Database::fetch_array($result);
509 509
 
510 510
             if ($builder == 'builder') { $origin = 'builder'; }
511
-              // This is needed for the exercise_submit.php can delete the session info about tests.
511
+                // This is needed for the exercise_submit.php can delete the session info about tests.
512 512
 
513 513
             $sql = "select * from $tbl_lp_item where id=$id_in_path";
514 514
             $result = Database::query($sql);
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
             $name = GetQuizName($path, $documentPath);
560 560
 
561 561
             if ($builder == 'builder') { $origin='builder'; }
562
-              // This is needed for the exercise_submit.php can delete the session info about tests.
562
+                // This is needed for the exercise_submit.php can delete the session info about tests.
563 563
 
564 564
             $sql = "select * from $tbl_lp_item where id=$id_in_path";
565 565
             $result = Database::query($sql);	$row = Database::fetch_array($result);
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
             $myrow = Database::fetch_array($result);
1123 1123
 
1124 1124
             if ($builder == 'builder') { $origin = 'builder'; }
1125
-              // This is needed for the exercise_submit.php can delete the session info about tests.
1125
+                // This is needed for the exercise_submit.php can delete the session info about tests.
1126 1126
 
1127 1127
             $sql = "select * from $tbl_lp_item where c_id = $course_id AND id=$id_in_path";
1128 1128
             $result = Database::query($sql);	$row = Database::fetch_array($result);
@@ -1352,10 +1352,10 @@  discard block
 block discarded – undo
1352 1352
  */
1353 1353
 function delete_all_resources_type($type)
1354 1354
 {
1355
-  $course_id = api_get_course_int_id();
1356
-  $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
1357
-  $sql = "DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type'";
1358
-  Database::query($sql);
1355
+    $course_id = api_get_course_int_id();
1356
+    $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
1357
+    $sql = "DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type'";
1358
+    Database::query($sql);
1359 1359
 }
1360 1360
 
1361 1361
 /**
Please login to merge, or discard this patch.
main/inc/ajax/course_home.ajax.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
             echo json_encode($response_data);
64 64
         }
65 65
         break;
66
-	case 'show_course_information' :
67
-		require_once '../global.inc.php';
66
+    case 'show_course_information' :
67
+        require_once '../global.inc.php';
68 68
 
69
-		// Get the name of the database course.
70
-		$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
71
-		$course_info = api_get_course_info($_GET['code']);
69
+        // Get the name of the database course.
70
+        $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
71
+        $course_info = api_get_course_info($_GET['code']);
72 72
 
73 73
         if (
74 74
             api_get_setting('course_catalog_hide_private') === 'true' &&
@@ -78,24 +78,24 @@  discard block
 block discarded – undo
78 78
             break;
79 79
         }
80 80
 
81
-		$sql = "SELECT * FROM $tbl_course_description
81
+        $sql = "SELECT * FROM $tbl_course_description
82 82
 		        WHERE c_id = ".$course_info['real_id']." AND session_id = 0
83 83
 		        ORDER BY id";
84
-		$result = Database::query($sql);
85
-		if (Database::num_rows($result) > 0 ) {
86
-		    while ($description = Database::fetch_object($result)) {
87
-			    $descriptions[$description->id] = $description;
88
-		    }
84
+        $result = Database::query($sql);
85
+        if (Database::num_rows($result) > 0 ) {
86
+            while ($description = Database::fetch_object($result)) {
87
+                $descriptions[$description->id] = $description;
88
+            }
89 89
             // Function that displays the details of the course description in html.
90
-		    echo CourseManager::get_details_course_description_html(
90
+            echo CourseManager::get_details_course_description_html(
91 91
                 $descriptions,
92 92
                 api_get_system_encoding(),
93 93
                 false
94 94
             );
95
-		} else {
96
-		    echo get_lang('NoDescription');
97
-		}
98
-	    break;
95
+        } else {
96
+            echo get_lang('NoDescription');
97
+        }
98
+        break;
99 99
     case 'session_courses_lp_default':
100 100
         /**
101 101
          * @todo this functions need to belong to a class or a special
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         $sidx  = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'id';
111 111
         $sord  = $_REQUEST['sord'];    //asc or desc
112 112
         if (!in_array($sord, array('asc','desc'))) {
113
-        	$sord = 'desc';
113
+            $sord = 'desc';
114 114
         }
115 115
         $session_id  = intval($_REQUEST['session_id']);
116 116
         $course_id   = intval($_REQUEST['course_id']);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                     $my_session_list[] = $item['id_session'];
125 125
             }
126 126
             if (!in_array($session_id, $my_session_list)) {
127
-            	break;
127
+                break;
128 128
             }
129 129
         }
130 130
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
                     $date = '-';
446 446
                 }
447 447
 
448
-                 //Checking LP publicated and expired_on dates
448
+                    //Checking LP publicated and expired_on dates
449 449
                 if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') {
450 450
                     if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {
451 451
                         continue;
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 
500 500
         echo json_encode($response);
501 501
         break;
502
-	default:
503
-		echo '';
502
+    default:
503
+        echo '';
504 504
 }
505 505
 exit;
Please login to merge, or discard this patch.
main/gradebook/gradebook_add_user.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 $newstudents = $evaluation[0]->get_not_subscribed_students();
19 19
 
20 20
 if (count($newstudents) == '0') {
21
-	header('Location: gradebook_view_result.php?nouser=&selecteval=' . Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
22
-	exit;
21
+    header('Location: gradebook_view_result.php?nouser=&selecteval=' . Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
22
+    exit;
23 23
 }
24 24
 $add_user_form = new EvalForm(
25 25
     EvalForm :: TYPE_ADD_USERS_TO_EVAL,
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 
68 68
 $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('Gradebook'));
69 69
 $interbreadcrumb[]= array(
70
-	'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(),
71
-	'name' => get_lang('ViewResult')
70
+    'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(),
71
+    'name' => get_lang('ViewResult')
72 72
 );
73 73
 Display :: display_header(get_lang('AddUserToEval'));
74 74
 if (isset ($_GET['erroroneuser'])){
75
-	Display :: display_warning_message(get_lang('AtLeastOneUser'),false);
75
+    Display :: display_warning_message(get_lang('AtLeastOneUser'),false);
76 76
 }
77 77
 DisplayGradebook :: display_header_result($evaluation[0], null, 0,0);
78 78
 echo '<div class="main">';
Please login to merge, or discard this patch.
main/dropbox/dropbox_class.inc.php 1 patch
Indentation   +422 added lines, -422 removed lines patch added patch discarded remove patch
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
         }
79 79
     }
80 80
 
81
-	/**
82
-	 * private function creating a new work object
83
-	 *
84
-	 * @param int $uploader_id
85
-	 * @param string $title
86
-	 * @param string $description
87
-	 * @param string $author
88
-	 * @param string $filename
89
-	 * @param int $filesize
90
-	 *
91
-	 * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
92
-	 * 			As a consequence this parameter can be removed
93
-	 */
94
-	public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
81
+    /**
82
+     * private function creating a new work object
83
+     *
84
+     * @param int $uploader_id
85
+     * @param string $title
86
+     * @param string $description
87
+     * @param string $author
88
+     * @param string $filename
89
+     * @param int $filesize
90
+     *
91
+     * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
92
+     * 			As a consequence this parameter can be removed
93
+     */
94
+    public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
95 95
     {
96 96
         $dropbox_cnf = getDropboxConf();
97 97
 
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
         // Check if object exists already. If it does, the old object is used
110 110
         // with updated information (authors, description, upload_date)
111 111
         $this->isOldWork = false;
112
-		$sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
112
+        $sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
113 113
 				WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
114 114
         $result = Database::query($sql);
115
-		$res = Database::fetch_array($result);
116
-		if ($res) {
117
-			$this->isOldWork = true;
118
-		}
119
-		// Insert or update the dropbox_file table and set the id property
120
-		if ($this->isOldWork) {
121
-			$this->id = $res['id'];
122
-			$this->upload_date = $res['upload_date'];
115
+        $res = Database::fetch_array($result);
116
+        if ($res) {
117
+            $this->isOldWork = true;
118
+        }
119
+        // Insert or update the dropbox_file table and set the id property
120
+        if ($this->isOldWork) {
121
+            $this->id = $res['id'];
122
+            $this->upload_date = $res['upload_date'];
123 123
 
124 124
             $params = [
125 125
                 'filesize' => $this->filesize,
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
                 ['c_id = ? AND id = ?' => [$course_id, $this->id]]
137 137
             );
138 138
 
139
-		} else {
140
-			$this->upload_date = $this->last_upload_date;
141
-			$params = [
139
+        } else {
140
+            $this->upload_date = $this->last_upload_date;
141
+            $params = [
142 142
                 'c_id' => $course_id,
143 143
                 'uploader_id' => $this->uploader_id,
144 144
                 'filename' => $this->filename,
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
                 'last_upload_date' => $this->last_upload_date,
151 151
                 'session_id' => api_get_session_id(),
152 152
                 'cat_id' => 0
153
-			];
153
+            ];
154 154
 
155
-			$this->id = Database::insert($dropbox_cnf['tbl_file'], $params);
156
-			if ($this->id) {
157
-				$sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}";
158
-				Database::query($sql);
159
-			}
160
-		}
155
+            $this->id = Database::insert($dropbox_cnf['tbl_file'], $params);
156
+            if ($this->id) {
157
+                $sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}";
158
+                Database::query($sql);
159
+            }
160
+        }
161 161
 
162 162
         $sql = "SELECT count(file_id) as count
163 163
         		FROM ".$dropbox_cnf['tbl_person']."
@@ -171,16 +171,16 @@  discard block
 block discarded – undo
171 171
                     VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
172 172
             Database::query($sql);
173 173
         }
174
-	}
175
-
176
-	/**
177
-	 * private function creating existing object by retreiving info from db
178
-	 *
179
-	 * @param int $id
180
-	 */
181
-	public function _createExistingWork($id)
174
+    }
175
+
176
+    /**
177
+     * private function creating existing object by retreiving info from db
178
+     *
179
+     * @param int $id
180
+     */
181
+    public function _createExistingWork($id)
182 182
     {
183
-	    $course_id = api_get_course_int_id();
183
+        $course_id = api_get_course_int_id();
184 184
         $dropbox_cnf = getDropboxConf();
185 185
 
186 186
         $action = isset($_GET['action']) ? $_GET['action'] : null;
@@ -231,52 +231,52 @@  discard block
 block discarded – undo
231 231
             }
232 232
             $this->feedback2= $feedback2;
233 233
         }
234
-	}
234
+    }
235 235
 }
236 236
 
237 237
 class Dropbox_SentWork extends Dropbox_Work
238 238
 {
239
-	public $recipients;	//array of ['id']['name'] arrays
240
-
241
-	/**
242
-	 * Constructor calls private functions to create a new work or retreive an existing work from DB
243
-	 * depending on the number of parameters
244
-	 *
245
-	 * @param unknown_type $arg1
246
-	 * @param unknown_type $arg2
247
-	 * @param unknown_type $arg3
248
-	 * @param unknown_type $arg4
249
-	 * @param unknown_type $arg5
250
-	 * @param unknown_type $arg6
251
-	 * @param unknown_type $arg7
252
-	 * @return Dropbox_SentWork
253
-	 */
254
-	public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
239
+    public $recipients;	//array of ['id']['name'] arrays
240
+
241
+    /**
242
+     * Constructor calls private functions to create a new work or retreive an existing work from DB
243
+     * depending on the number of parameters
244
+     *
245
+     * @param unknown_type $arg1
246
+     * @param unknown_type $arg2
247
+     * @param unknown_type $arg3
248
+     * @param unknown_type $arg4
249
+     * @param unknown_type $arg5
250
+     * @param unknown_type $arg6
251
+     * @param unknown_type $arg7
252
+     * @return Dropbox_SentWork
253
+     */
254
+    public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
255 255
     {
256
-		if (func_num_args() > 1) {
257
-		    $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
258
-		} else {
259
-			$this->_createExistingSentWork($arg1);
260
-		}
261
-	}
262
-
263
-	/**
264
-	 * private function creating a new SentWork object
265
-	 *
266
-	 * @param int $uploader_id
267
-	 * @param string $title
268
-	 * @param string $description
269
-	 * @param string $author
270
-	 * @param string $filename
271
-	 * @param int $filesize
272
-	 * @param array $recipient_ids
273
-	 */
274
-	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
256
+        if (func_num_args() > 1) {
257
+            $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
258
+        } else {
259
+            $this->_createExistingSentWork($arg1);
260
+        }
261
+    }
262
+
263
+    /**
264
+     * private function creating a new SentWork object
265
+     *
266
+     * @param int $uploader_id
267
+     * @param string $title
268
+     * @param string $description
269
+     * @param string $author
270
+     * @param string $filename
271
+     * @param int $filesize
272
+     * @param array $recipient_ids
273
+     */
274
+    public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
275 275
     {
276 276
         $dropbox_cnf = getDropboxConf();
277 277
         $_course = api_get_course_info();
278 278
 
279
-		// Call constructor of Dropbox_Work object
279
+        // Call constructor of Dropbox_Work object
280 280
         parent::__construct(
281 281
             $uploader_id,
282 282
             $title,
@@ -286,31 +286,31 @@  discard block
 block discarded – undo
286 286
             $filesize
287 287
         );
288 288
 
289
-		$course_id = api_get_course_int_id();
290
-
291
-		// Do sanity checks on recipient_ids array & property fillin
292
-		// The sanity check for ex-coursemembers is already done in base constructor
293
-		settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
289
+        $course_id = api_get_course_int_id();
294 290
 
295
-		$justSubmit = false;
296
-		if ( is_int($recipient_ids)) {
297
-			$justSubmit = true;
298
-			$recipient_ids = array($recipient_ids + $this->id);
299
-		} elseif ( count($recipient_ids) == 0) {
300
-			$justSubmit = true;
301
-			$recipient_ids = array($uploader_id);
302
-		}
291
+        // Do sanity checks on recipient_ids array & property fillin
292
+        // The sanity check for ex-coursemembers is already done in base constructor
293
+        settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
294
+
295
+        $justSubmit = false;
296
+        if ( is_int($recipient_ids)) {
297
+            $justSubmit = true;
298
+            $recipient_ids = array($recipient_ids + $this->id);
299
+        } elseif ( count($recipient_ids) == 0) {
300
+            $justSubmit = true;
301
+            $recipient_ids = array($uploader_id);
302
+        }
303 303
 
304
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
305
-			die(get_lang('GeneralError').' (code 209)');
306
-		}
304
+        if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
305
+            die(get_lang('GeneralError').' (code 209)');
306
+        }
307 307
 
308
-		foreach ($recipient_ids as $rec) {
309
-			if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
310
-			//if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
311
-				//this check is done when validating submitted data
312
-			$this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
313
-		}
308
+        foreach ($recipient_ids as $rec) {
309
+            if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
310
+            //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
311
+                //this check is done when validating submitted data
312
+            $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
313
+        }
314 314
 
315 315
         $table_post = $dropbox_cnf['tbl_post'];
316 316
         $table_person = $dropbox_cnf['tbl_person'];
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
         $user  = api_get_user_id();
320 320
         $now = api_get_utc_datetime();
321 321
 
322
-		// Insert data in dropbox_post and dropbox_person table for each recipient
323
-		foreach ($this->recipients as $rec) {
322
+        // Insert data in dropbox_post and dropbox_person table for each recipient
323
+        foreach ($this->recipients as $rec) {
324 324
             $file_id = (int)$this->id;
325 325
             $user_id = (int)$rec['id'];
326
-			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
326
+            $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
327 327
                     VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
328
-	        Database::query($sql);
328
+            Database::query($sql);
329 329
             // If work already exists no error is generated
330 330
 
331 331
             /**
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
                 }
343 343
             }
344 344
 
345
-			// Update item_property table for each recipient
346
-			if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
347
-			    $ownerid = getUserOwningThisMailing($ownerid);
348
-			}
349
-			if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
350
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
351
-			}
345
+            // Update item_property table for each recipient
346
+            if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
347
+                $ownerid = getUserOwningThisMailing($ownerid);
348
+            }
349
+            if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
350
+                $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
351
+            }
352 352
             api_item_property_update(
353 353
                 $_course,
354 354
                 TOOL_DROPBOX,
@@ -358,91 +358,91 @@  discard block
 block discarded – undo
358 358
                 null,
359 359
                 $recipid
360 360
             );
361
-		}
362
-	}
363
-
364
-	/**
365
-	 * private function creating existing object by retreiving info from db
366
-	 *
367
-	 * @param unknown_type $id
368
-	 */
369
-	public function _createExistingSentWork($id)
361
+        }
362
+    }
363
+
364
+    /**
365
+     * private function creating existing object by retreiving info from db
366
+     *
367
+     * @param unknown_type $id
368
+     */
369
+    public function _createExistingSentWork($id)
370 370
     {
371 371
         $dropbox_cnf = getDropboxConf();
372 372
         $id = intval($id);
373 373
 
374
-		$course_id = api_get_course_int_id();
374
+        $course_id = api_get_course_int_id();
375 375
 
376
-		// Call constructor of Dropbox_Work object
377
-		parent::__construct($id);
376
+        // Call constructor of Dropbox_Work object
377
+        parent::__construct($id);
378 378
 
379
-		// Fill in recipients array
380
-		$this->recipients = array();
381
-		$sql = "SELECT dest_user_id, feedback_date, feedback
379
+        // Fill in recipients array
380
+        $this->recipients = array();
381
+        $sql = "SELECT dest_user_id, feedback_date, feedback
382 382
 				FROM ".$dropbox_cnf['tbl_post']."
383 383
 				WHERE c_id = $course_id AND file_id = ".intval($id)."";
384 384
         $result = Database::query($sql);
385
-		while ($res = Database::fetch_array($result, 'ASSOC')) {
386
-			// Check for deleted users
387
-			$dest_user_id = $res['dest_user_id'];
388
-			$user_info = api_get_user_info($dest_user_id);
389
-			//$this->category = $res['cat_id'];
390
-			if (!$user_info) {
391
-				$this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
392
-			} else {
393
-				$this->recipients[] = array(
385
+        while ($res = Database::fetch_array($result, 'ASSOC')) {
386
+            // Check for deleted users
387
+            $dest_user_id = $res['dest_user_id'];
388
+            $user_info = api_get_user_info($dest_user_id);
389
+            //$this->category = $res['cat_id'];
390
+            if (!$user_info) {
391
+                $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
392
+            } else {
393
+                $this->recipients[] = array(
394 394
                     'id' => $dest_user_id,
395 395
                     'name' => $user_info['complete_name'],
396 396
                     'user_id' => $dest_user_id,
397
-				    'feedback_date' => $res['feedback_date'],
397
+                    'feedback_date' => $res['feedback_date'],
398 398
                     'feedback' => $res['feedback']
399 399
                 );
400
-			}
401
-		}
402
-	}
400
+            }
401
+        }
402
+    }
403 403
 }
404 404
 
405 405
 class Dropbox_Person
406 406
 {
407
-	// The receivedWork and the sentWork arrays are sorted.
408
-	public $receivedWork;	// an array of Dropbox_Work objects
409
-	public $sentWork;		// an array of Dropbox_SentWork objects
410
-
411
-	public $userId = 0;
412
-	public $isCourseAdmin = false;
413
-	public $isCourseTutor = false;
414
-	public $_orderBy = '';	// private property that determines by which field
415
-
416
-	/**
417
-	 * Constructor for recreating the Dropbox_Person object
418
-	 *
419
-	 * @param int $userId
420
-	 * @param bool $isCourseAdmin
421
-	 * @param bool $isCourseTutor
422
-	 * @return Dropbox_Person
423
-	 */
424
-	public function __construct($userId, $isCourseAdmin, $isCourseTutor)
407
+    // The receivedWork and the sentWork arrays are sorted.
408
+    public $receivedWork;	// an array of Dropbox_Work objects
409
+    public $sentWork;		// an array of Dropbox_SentWork objects
410
+
411
+    public $userId = 0;
412
+    public $isCourseAdmin = false;
413
+    public $isCourseTutor = false;
414
+    public $_orderBy = '';	// private property that determines by which field
415
+
416
+    /**
417
+     * Constructor for recreating the Dropbox_Person object
418
+     *
419
+     * @param int $userId
420
+     * @param bool $isCourseAdmin
421
+     * @param bool $isCourseTutor
422
+     * @return Dropbox_Person
423
+     */
424
+    public function __construct($userId, $isCourseAdmin, $isCourseTutor)
425 425
     {
426
-	    $course_id = api_get_course_int_id();
426
+        $course_id = api_get_course_int_id();
427 427
 
428
-		// Fill in properties
428
+        // Fill in properties
429 429
         $this->userId = $userId;
430 430
         $this->isCourseAdmin = $isCourseAdmin;
431 431
         $this->isCourseTutor = $isCourseTutor;
432 432
         $this->receivedWork = array();
433 433
         $this->sentWork = array();
434 434
 
435
-		// Note: perhaps include an ex coursemember check to delete old files
435
+        // Note: perhaps include an ex coursemember check to delete old files
436 436
 
437
-		$session_id = api_get_session_id();
438
-		$condition_session = api_get_session_condition($session_id);
437
+        $session_id = api_get_session_id();
438
+        $condition_session = api_get_session_condition($session_id);
439 439
 
440
-		$post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
441
-		$person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
442
-		$file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
440
+        $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
441
+        $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
442
+        $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
443 443
 
444 444
         // Find all entries where this person is the recipient
445
-		$sql = "SELECT DISTINCT r.file_id, r.cat_id
445
+        $sql = "SELECT DISTINCT r.file_id, r.cat_id
446 446
                 FROM $post_tbl r
447 447
                 INNER JOIN $person_tbl p
448 448
                     ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
                      r.dest_user_id = ".intval($this->userId)." $condition_session ";
452 452
 
453 453
         $result = Database::query($sql);
454
-		while ($res = Database::fetch_array($result)) {
455
-			$temp = new Dropbox_Work($res['file_id']);
456
-			$temp->category = $res['cat_id'];
457
-			$this->receivedWork[] = $temp;
458
-		}
459
-		// Find all entries where this person is the sender/uploader
454
+        while ($res = Database::fetch_array($result)) {
455
+            $temp = new Dropbox_Work($res['file_id']);
456
+            $temp->category = $res['cat_id'];
457
+            $this->receivedWork[] = $temp;
458
+        }
459
+        // Find all entries where this person is the sender/uploader
460 460
         $sql = "SELECT DISTINCT f.id
461 461
 				FROM $file_tbl f
462 462
 				INNER JOIN $person_tbl p
@@ -467,261 +467,261 @@  discard block
 block discarded – undo
467 467
                     $condition_session
468 468
                 ";
469 469
         $result = Database::query($sql);
470
-		while ($res = Database::fetch_array($result)) {
471
-			$this->sentWork[] = new Dropbox_SentWork($res['id']);
472
-		}
473
-	}
474
-
475
-	/**
476
-	 * This private method is used by the usort function in  the
477
-	 * orderSentWork and orderReceivedWork methods.
478
-	 * It compares 2 work-objects by 1 of the properties of that object, dictated by the
479
-	 * private property _orderBy
480
-	 *
481
-	 * @param unknown_type $a
482
-	 * @param unknown_type $b
483
-	 * @return int -1, 0 or 1 dependent of the result of the comparison.
484
-	 */
485
-	function _cmpWork($a, $b)
470
+        while ($res = Database::fetch_array($result)) {
471
+            $this->sentWork[] = new Dropbox_SentWork($res['id']);
472
+        }
473
+    }
474
+
475
+    /**
476
+     * This private method is used by the usort function in  the
477
+     * orderSentWork and orderReceivedWork methods.
478
+     * It compares 2 work-objects by 1 of the properties of that object, dictated by the
479
+     * private property _orderBy
480
+     *
481
+     * @param unknown_type $a
482
+     * @param unknown_type $b
483
+     * @return int -1, 0 or 1 dependent of the result of the comparison.
484
+     */
485
+    function _cmpWork($a, $b)
486 486
     {
487
-		$sort = $this->_orderBy;
488
-		$aval = $a->$sort;
489
-		$bval = $b->$sort;
490
-		if ($sort == 'recipients') {
491
-		    // The recipients property is an array so we do the comparison based
492
-		    // on the first item of the recipients array
493
-		    $aval = $aval[0]['name'];
494
-			$bval = $bval[0]['name'];
495
-		}
496
-		if ($sort == 'filesize') {    // Filesize is not a string, so we use other comparison technique
497
-			return $aval < $bval ? -1 : 1;
498
-		} elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly"
499
-			return api_strnatcmp($aval, $bval);
500
-		} else {
501
-		    return api_strcasecmp($aval, $bval);
502
-		}
503
-	}
504
-
505
-	/**
506
-	 * A method that sorts the objects in the sentWork array, dependent on the $sort parameter.
507
-	 * $sort can be lastDate, firstDate, title, size, ...
508
-	 *
509
-	 * @param unknown_type $sort
510
-	 */
511
-	function orderSentWork($sort)
487
+        $sort = $this->_orderBy;
488
+        $aval = $a->$sort;
489
+        $bval = $b->$sort;
490
+        if ($sort == 'recipients') {
491
+            // The recipients property is an array so we do the comparison based
492
+            // on the first item of the recipients array
493
+            $aval = $aval[0]['name'];
494
+            $bval = $bval[0]['name'];
495
+        }
496
+        if ($sort == 'filesize') {    // Filesize is not a string, so we use other comparison technique
497
+            return $aval < $bval ? -1 : 1;
498
+        } elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly"
499
+            return api_strnatcmp($aval, $bval);
500
+        } else {
501
+            return api_strcasecmp($aval, $bval);
502
+        }
503
+    }
504
+
505
+    /**
506
+     * A method that sorts the objects in the sentWork array, dependent on the $sort parameter.
507
+     * $sort can be lastDate, firstDate, title, size, ...
508
+     *
509
+     * @param unknown_type $sort
510
+     */
511
+    function orderSentWork($sort)
512 512
     {
513
-		switch($sort) {
514
-			case 'lastDate':
515
-				$this->_orderBy = 'last_upload_date';
516
-				break;
517
-			case 'firstDate':
518
-				$this->_orderBy = 'upload_date';
519
-				break;
520
-			case 'title':
521
-				$this->_orderBy = 'title';
522
-				break;
523
-			case 'size':
524
-				$this->_orderBy = 'filesize';
525
-				break;
526
-			case 'author':
527
-				$this->_orderBy = 'author';
528
-				break;
529
-			case 'recipient':
530
-				$this->_orderBy = 'recipients';
531
-				break;
532
-			default:
533
-				$this->_orderBy = 'last_upload_date';
534
-		}
535
-
536
-		usort($this->sentWork, array($this, '_cmpWork'));
537
-	}
538
-
539
-	/**
540
-	 * method that sorts the objects in the receivedWork array, dependent on the $sort parameter.
541
-	 * $sort can be lastDate, firstDate, title, size, ...
542
-	 * @param unknown_type $sort
543
-	 */
544
-	function orderReceivedWork($sort)
513
+        switch($sort) {
514
+            case 'lastDate':
515
+                $this->_orderBy = 'last_upload_date';
516
+                break;
517
+            case 'firstDate':
518
+                $this->_orderBy = 'upload_date';
519
+                break;
520
+            case 'title':
521
+                $this->_orderBy = 'title';
522
+                break;
523
+            case 'size':
524
+                $this->_orderBy = 'filesize';
525
+                break;
526
+            case 'author':
527
+                $this->_orderBy = 'author';
528
+                break;
529
+            case 'recipient':
530
+                $this->_orderBy = 'recipients';
531
+                break;
532
+            default:
533
+                $this->_orderBy = 'last_upload_date';
534
+        }
535
+
536
+        usort($this->sentWork, array($this, '_cmpWork'));
537
+    }
538
+
539
+    /**
540
+     * method that sorts the objects in the receivedWork array, dependent on the $sort parameter.
541
+     * $sort can be lastDate, firstDate, title, size, ...
542
+     * @param unknown_type $sort
543
+     */
544
+    function orderReceivedWork($sort)
545 545
     {
546
-		switch($sort) {
547
-			case 'lastDate':
548
-				$this->_orderBy = 'last_upload_date';
549
-				break;
550
-			case 'firstDate':
551
-				$this->_orderBy = 'upload_date';
552
-				break;
553
-			case 'title':
554
-				$this->_orderBy = 'title';
555
-				break;
556
-			case 'size':
557
-				$this->_orderBy = 'filesize';
558
-				break;
559
-			case 'author':
560
-				$this->_orderBy = 'author';
561
-				break;
562
-			case 'sender':
563
-				$this->_orderBy = 'uploaderName';
564
-				break;
565
-			default:
566
-				$this->_orderBy = 'last_upload_date';
567
-		}
568
-
569
-		usort($this->receivedWork, array($this, '_cmpWork'));
570
-	}
571
-
572
-	/**
573
-	 * Deletes all the received work of this person
574
-	 */
575
-	public function deleteAllReceivedWork()
546
+        switch($sort) {
547
+            case 'lastDate':
548
+                $this->_orderBy = 'last_upload_date';
549
+                break;
550
+            case 'firstDate':
551
+                $this->_orderBy = 'upload_date';
552
+                break;
553
+            case 'title':
554
+                $this->_orderBy = 'title';
555
+                break;
556
+            case 'size':
557
+                $this->_orderBy = 'filesize';
558
+                break;
559
+            case 'author':
560
+                $this->_orderBy = 'author';
561
+                break;
562
+            case 'sender':
563
+                $this->_orderBy = 'uploaderName';
564
+                break;
565
+            default:
566
+                $this->_orderBy = 'last_upload_date';
567
+        }
568
+
569
+        usort($this->receivedWork, array($this, '_cmpWork'));
570
+    }
571
+
572
+    /**
573
+     * Deletes all the received work of this person
574
+     */
575
+    public function deleteAllReceivedWork()
576 576
     {
577
-	    $course_id = api_get_course_int_id();
577
+        $course_id = api_get_course_int_id();
578 578
         $dropbox_cnf = getDropboxConf();
579
-		// Delete entries in person table concerning received works
580
-		foreach ($this->receivedWork as $w) {
579
+        // Delete entries in person table concerning received works
580
+        foreach ($this->receivedWork as $w) {
581 581
             $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
582 582
 			        WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
583
-			Database::query($sql);
584
-		}
583
+            Database::query($sql);
584
+        }
585 585
         // Check for unused files
586
-		removeUnusedFiles();
587
-	}
588
-
589
-	/**
590
-	 * Deletes all the received categories and work of this person
591
-	 * @param integer $id
592
-	 */
593
-	public function deleteReceivedWorkFolder($id)
586
+        removeUnusedFiles();
587
+    }
588
+
589
+    /**
590
+     * Deletes all the received categories and work of this person
591
+     * @param integer $id
592
+     */
593
+    public function deleteReceivedWorkFolder($id)
594 594
     {
595 595
         $dropbox_cnf = getDropboxConf();
596 596
         $course_id = api_get_course_int_id();
597 597
 
598
-		$id = intval($id);
599
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
598
+        $id = intval($id);
599
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
600 600
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
601
-		if (!Database::query($sql)) return false;
602
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
601
+        if (!Database::query($sql)) return false;
602
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
603 603
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
604
-		if (!Database::query($sql)) return false;
605
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
604
+        if (!Database::query($sql)) return false;
605
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
606 606
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
607
-		if (!Database::query($sql)) return false;
608
-		return true;
609
-	}
610
-
611
-	/**
612
-	 * Deletes a received dropbox file of this person with id=$id
613
-	 *
614
-	 * @param integer $id
615
-	 */
616
-	public function deleteReceivedWork($id)
607
+        if (!Database::query($sql)) return false;
608
+        return true;
609
+    }
610
+
611
+    /**
612
+     * Deletes a received dropbox file of this person with id=$id
613
+     *
614
+     * @param integer $id
615
+     */
616
+    public function deleteReceivedWork($id)
617 617
     {
618
-	    $course_id = api_get_course_int_id();
618
+        $course_id = api_get_course_int_id();
619 619
         $dropbox_cnf = getDropboxConf();
620
-		$id = intval($id);
621
-
622
-		// index check
623
-		$found = false;
624
-		foreach ($this->receivedWork as $w) {
625
-			if ($w->id == $id) {
626
-			   $found = true;
627
-			   break;
628
-			}
629
-		}
630
-
631
-		if (!$found) {
632
-			if (!$this->deleteReceivedWorkFolder($id)) {
633
-				die(get_lang('GeneralError').' (code 216)');
634
-			}
635
-		}
636
-		// Delete entries in person table concerning received works
620
+        $id = intval($id);
621
+
622
+        // index check
623
+        $found = false;
624
+        foreach ($this->receivedWork as $w) {
625
+            if ($w->id == $id) {
626
+                $found = true;
627
+                break;
628
+            }
629
+        }
630
+
631
+        if (!$found) {
632
+            if (!$this->deleteReceivedWorkFolder($id)) {
633
+                die(get_lang('GeneralError').' (code 216)');
634
+            }
635
+        }
636
+        // Delete entries in person table concerning received works
637 637
         $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
638 638
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
639
-		Database::query($sql);
640
-		removeUnusedFiles();	// Check for unused files
641
-	}
642
-
643
-	/**
644
-	 * Deletes all the sent dropbox files of this person
645
-	 */
646
-	public function deleteAllSentWork()
639
+        Database::query($sql);
640
+        removeUnusedFiles();	// Check for unused files
641
+    }
642
+
643
+    /**
644
+     * Deletes all the sent dropbox files of this person
645
+     */
646
+    public function deleteAllSentWork()
647 647
     {
648
-	    $course_id = api_get_course_int_id();
648
+        $course_id = api_get_course_int_id();
649 649
         $dropbox_cnf = getDropboxConf();
650
-		//delete entries in person table concerning sent works
651
-		foreach ($this->sentWork as $w) {
650
+        //delete entries in person table concerning sent works
651
+        foreach ($this->sentWork as $w) {
652 652
             $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
653 653
                     WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
654
-			Database::query($sql);
655
-			removeMoreIfMailing($w->id);
656
-		}
657
-		removeUnusedFiles();	// Check for unused files
658
-	}
659
-
660
-	/**
661
-	 * Deletes a sent dropbox file of this person with id=$id
662
-	 *
663
-	 * @param unknown_type $id
664
-	 */
665
-	public function deleteSentWork($id)
654
+            Database::query($sql);
655
+            removeMoreIfMailing($w->id);
656
+        }
657
+        removeUnusedFiles();	// Check for unused files
658
+    }
659
+
660
+    /**
661
+     * Deletes a sent dropbox file of this person with id=$id
662
+     *
663
+     * @param unknown_type $id
664
+     */
665
+    public function deleteSentWork($id)
666 666
     {
667
-	    $course_id = api_get_course_int_id();
667
+        $course_id = api_get_course_int_id();
668 668
         $dropbox_cnf = getDropboxConf();
669 669
 
670
-		$id = intval($id);
671
-
672
-		// index check
673
-		$found = false;
674
-		foreach ($this->sentWork as $w) {
675
-			if ($w->id == $id) {
676
-			   $found = true;
677
-			   break;
678
-			}
679
-		}
680
-		if (!$found) {
681
-			if (!$this->deleteReceivedWorkFolder($id)) {
682
-				die(get_lang('GeneralError').' (code 219)');
683
-			}
684
-		}
685
-		//$file_id = $this->sentWork[$index]->id;
686
-		// Delete entries in person table concerning sent works
670
+        $id = intval($id);
671
+
672
+        // index check
673
+        $found = false;
674
+        foreach ($this->sentWork as $w) {
675
+            if ($w->id == $id) {
676
+                $found = true;
677
+                break;
678
+            }
679
+        }
680
+        if (!$found) {
681
+            if (!$this->deleteReceivedWorkFolder($id)) {
682
+                die(get_lang('GeneralError').' (code 219)');
683
+            }
684
+        }
685
+        //$file_id = $this->sentWork[$index]->id;
686
+        // Delete entries in person table concerning sent works
687 687
         $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
688 688
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
689
-		Database::query($sql);
690
-		removeMoreIfMailing($id);
691
-		removeUnusedFiles();	// Check for unused files
692
-	}
693
-
694
-	/**
695
-	 * Updates feedback for received work of this person with id=$id
696
-	 *
697
-	 * @param string $id
698
-	 * @param string $text
699
-	 */
700
-	public function updateFeedback($id, $text)
689
+        Database::query($sql);
690
+        removeMoreIfMailing($id);
691
+        removeUnusedFiles();	// Check for unused files
692
+    }
693
+
694
+    /**
695
+     * Updates feedback for received work of this person with id=$id
696
+     *
697
+     * @param string $id
698
+     * @param string $text
699
+     */
700
+    public function updateFeedback($id, $text)
701 701
     {
702
-	    $course_id = api_get_course_int_id();
702
+        $course_id = api_get_course_int_id();
703 703
         $_course = api_get_course_info();
704 704
         $dropbox_cnf = getDropboxConf();
705 705
 
706
-		$id = intval($id);
707
-
708
-		// index check
709
-		$found = false;
710
-		$wi = -1;
711
-		foreach ($this->receivedWork as $w) {
712
-			$wi++;
713
-			if ($w->id == $id){
714
-			   $found = true;
715
-			   break;
716
-			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
717
-		}
718
-		if (!$found) {
719
-			die(get_lang('GeneralError').' (code 221)');
720
-		}
721
-
722
-		$feedback_date = api_get_utc_datetime();
723
-		$this->receivedWork[$wi]->feedback_date = $feedback_date;
724
-		$this->receivedWork[$wi]->feedback = $text;
706
+        $id = intval($id);
707
+
708
+        // index check
709
+        $found = false;
710
+        $wi = -1;
711
+        foreach ($this->receivedWork as $w) {
712
+            $wi++;
713
+            if ($w->id == $id){
714
+                $found = true;
715
+                break;
716
+            }  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
717
+        }
718
+        if (!$found) {
719
+            die(get_lang('GeneralError').' (code 221)');
720
+        }
721
+
722
+        $feedback_date = api_get_utc_datetime();
723
+        $this->receivedWork[$wi]->feedback_date = $feedback_date;
724
+        $this->receivedWork[$wi]->feedback = $text;
725 725
 
726 726
         $params = [
727 727
             'feedback_date' => $feedback_date,
@@ -739,11 +739,11 @@  discard block
 block discarded – undo
739 739
             ]
740 740
         );
741 741
 
742
-		// Update item_property table
742
+        // Update item_property table
743 743
 
744
-		if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) {
745
-		    $ownerid = getUserOwningThisMailing($ownerid);
746
-		}
744
+        if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) {
745
+            $ownerid = getUserOwningThisMailing($ownerid);
746
+        }
747 747
         api_item_property_update(
748 748
             $_course,
749 749
             TOOL_DROPBOX,
@@ -754,31 +754,31 @@  discard block
 block discarded – undo
754 754
             $ownerid
755 755
         );
756 756
 
757
-	}
757
+    }
758 758
 
759
-	/**
760
-	 * Filter the received work
761
-	 * @param string $type
762
-	 * @param string $value
763
-	 */
764
-	public function filter_received_work($type, $value)
759
+    /**
760
+     * Filter the received work
761
+     * @param string $type
762
+     * @param string $value
763
+     */
764
+    public function filter_received_work($type, $value)
765 765
     {
766 766
         $dropbox_cnf = getDropboxConf();
767
-    	$new_received_work = array();
768
-		foreach ($this->receivedWork as $work) {
769
-			switch ($type) {
770
-				case 'uploader_id':
771
-					if ($work->uploader_id == $value ||
772
-						($work->uploader_id > $dropbox_cnf['mailingIdBase'] &&
767
+        $new_received_work = array();
768
+        foreach ($this->receivedWork as $work) {
769
+            switch ($type) {
770
+                case 'uploader_id':
771
+                    if ($work->uploader_id == $value ||
772
+                        ($work->uploader_id > $dropbox_cnf['mailingIdBase'] &&
773 773
                         getUserOwningThisMailing($work->uploader_id) == $value)
774 774
                     ) {
775
-						$new_received_work[] = $work;
776
-					}
777
-					break;
778
-				default:
779
-					$new_received_work[] = $work;
780
-			}
781
-		}
782
-		$this->receivedWork = $new_received_work;
783
-	}
775
+                        $new_received_work[] = $work;
776
+                    }
777
+                    break;
778
+                default:
779
+                    $new_received_work[] = $work;
780
+            }
781
+        }
782
+        $this->receivedWork = $new_received_work;
783
+    }
784 784
 }
Please login to merge, or discard this patch.
main/messages/view_message.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
 require_once '../inc/global.inc.php';
8 8
 api_block_anonymous_users();
9 9
 if (api_get_setting('allow_message_tool')!='true') {
10
-	api_not_allowed();
10
+    api_not_allowed();
11 11
 }
12 12
 
13 13
 if (isset($_REQUEST['f']) && $_REQUEST['f'] == 'social') {
14
-	$this_section = SECTION_SOCIAL;
15
-	$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
16
-	$interbreadcrumb[]= array ('url' => 'inbox.php?f=social','name' => get_lang('Inbox'));
14
+    $this_section = SECTION_SOCIAL;
15
+    $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
16
+    $interbreadcrumb[]= array ('url' => 'inbox.php?f=social','name' => get_lang('Inbox'));
17 17
 } else {
18
-	$this_section = SECTION_MYPROFILE;
19
-	$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
18
+    $this_section = SECTION_MYPROFILE;
19
+    $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
20 20
 }
21 21
 
22 22
 $social_right_content = '';
23 23
 
24 24
 if (isset($_GET['f']) && $_GET['f']=='social') {
25
-	$social_parameter = '?f=social';
25
+    $social_parameter = '?f=social';
26 26
 } else {
27
-	if (api_get_setting('extended_profile') == 'true') {
28
-		$social_right_content .= '<div class="actions">';
27
+    if (api_get_setting('extended_profile') == 'true') {
28
+        $social_right_content .= '<div class="actions">';
29 29
 
30
-		if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
31
-			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
30
+        if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
31
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
32 32
                 Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
33
-		}
34
-		if (api_get_setting('allow_message_tool') === 'true') {
35
-		    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
33
+        }
34
+        if (api_get_setting('allow_message_tool') === 'true') {
35
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
36 36
                 Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
37 37
             $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
38 38
                 Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
39 39
             $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
40 40
                 Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
41
-		}
42
-		$social_right_content .= '</div>';
43
-	}
41
+        }
42
+        $social_right_content .= '</div>';
43
+    }
44 44
 }
45 45
 
46 46
 if (empty($_GET['id'])) {
Please login to merge, or discard this patch.
main/messages/new_message.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -67,37 +67,37 @@  discard block
 block discarded – undo
67 67
 * Shows the compose area + a list of users to select from.
68 68
 */
69 69
 function show_compose_to_any($user_id) {
70
-	$online_user_list = MessageManager::get_online_user_list($user_id);
71
-	$default['user_list'] = 0;
72
-	$online_user_list=null;
73
-	$html = manage_form($default, $online_user_list);
70
+    $online_user_list = MessageManager::get_online_user_list($user_id);
71
+    $default['user_list'] = 0;
72
+    $online_user_list=null;
73
+    $html = manage_form($default, $online_user_list);
74 74
     return $html;
75 75
 }
76 76
 
77 77
 function show_compose_reply_to_message($message_id, $receiver_id)
78 78
 {
79
-	$table_message = Database::get_main_table(TABLE_MESSAGE);
80
-	$query = "SELECT user_sender_id FROM $table_message
79
+    $table_message = Database::get_main_table(TABLE_MESSAGE);
80
+    $query = "SELECT user_sender_id FROM $table_message
81 81
 			  WHERE user_receiver_id=".intval($receiver_id)." AND id='".intval($message_id)."';";
82
-	$result = Database::query($query);
83
-	$row = Database::fetch_array($result,'ASSOC');
84
-	if (!isset($row['user_sender_id'])) {
85
-		$html = get_lang('InvalidMessageId');
82
+    $result = Database::query($query);
83
+    $row = Database::fetch_array($result,'ASSOC');
84
+    if (!isset($row['user_sender_id'])) {
85
+        $html = get_lang('InvalidMessageId');
86 86
 
87
-		return $html;
88
-	}
89
-	$userInfo = api_get_user_info($row['user_sender_id']);
90
-	$default['users'] = array($row['user_sender_id']);
91
-	$html = manage_form($default, null, $userInfo['complete_name']);
87
+        return $html;
88
+    }
89
+    $userInfo = api_get_user_info($row['user_sender_id']);
90
+    $default['users'] = array($row['user_sender_id']);
91
+    $html = manage_form($default, null, $userInfo['complete_name']);
92 92
 
93 93
     return $html;
94 94
 }
95 95
 
96 96
 function show_compose_to_user ($receiver_id) {
97
-	$html = get_lang('To').':&nbsp;<strong>'.GetFullUserName($receiver_id).'</strong>';
98
-	$default['title'] = api_xml_http_response_encode(get_lang('EnterTitle'));
99
-	$default['users'] = array($receiver_id);
100
-	$html .= manage_form($default);
97
+    $html = get_lang('To').':&nbsp;<strong>'.GetFullUserName($receiver_id).'</strong>';
98
+    $default['title'] = api_xml_http_response_encode(get_lang('EnterTitle'));
99
+    $default['users'] = array($receiver_id);
100
+    $html .= manage_form($default);
101 101
     return $html;
102 102
 }
103 103
 
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 
253 253
 /* MAIN SECTION */
254 254
 if ($socialToolIsActive) {
255
-	$this_section = SECTION_SOCIAL;
255
+    $this_section = SECTION_SOCIAL;
256 256
     $interbreadcrumb[] = array(
257 257
         'url' => api_get_path(WEB_PATH).'main/social/home.php',
258 258
         'name' => get_lang('SocialNetwork'),
259 259
     );
260 260
 } else {
261
-	$this_section = SECTION_MYPROFILE;
261
+    $this_section = SECTION_MYPROFILE;
262 262
     $interbreadcrumb[] = array(
263 263
         'url' => api_get_path(WEB_PATH).'main/auth/profile.php',
264 264
         'name' => get_lang('Profile'),
@@ -268,30 +268,30 @@  discard block
 block discarded – undo
268 268
 $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
269 269
 $social_right_content = null;
270 270
 if ($group_id != 0) {
271
-	$social_right_content .= '<div class=actions>';
272
-	$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/group_view.php?id='.$group_id.'">'.
273
-		Display::return_icon('back.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
274
-	$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'.
275
-		Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
276
-	$social_right_content .= '</div>';
271
+    $social_right_content .= '<div class=actions>';
272
+    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/group_view.php?id='.$group_id.'">'.
273
+        Display::return_icon('back.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
274
+    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'.
275
+        Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
276
+    $social_right_content .= '</div>';
277 277
 } else {
278
-	if ($socialToolIsActive) {
279
-	} else {
280
-		$social_right_content .= '<div class=actions>';
281
-		if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
282
-			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
278
+    if ($socialToolIsActive) {
279
+    } else {
280
+        $social_right_content .= '<div class=actions>';
281
+        if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
282
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
283 283
                 Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
284
-		}
285
-		if (api_get_setting('allow_message_tool') === 'true') {
286
-			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
284
+        }
285
+        if (api_get_setting('allow_message_tool') === 'true') {
286
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
287 287
                 Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
288
-			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
288
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
289 289
                 Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
290 290
             $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
291 291
                 Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
292
-		}
293
-		$social_right_content .= '</div>';
294
-	}
292
+        }
293
+        $social_right_content .= '</div>';
294
+    }
295 295
 }
296 296
 
297 297
 // LEFT COLUMN
Please login to merge, or discard this patch.
main/course_info/delete_course.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     $message .= '<p><a class="btn btn-primary" href="'.api_get_path(WEB_CODE_PATH).'course_info/maintenance.php?'.api_get_cidreq().'">'.
45 45
         get_lang('No').'</a>&nbsp;<a class="btn btn-danger" href="'.api_get_self().'?delete=yes&'.api_get_cidreq().'">'.
46 46
         get_lang('Yes').'</a></p>';
47
-	$interbreadcrumb[] = array('url' => 'maintenance.php', 'name' => get_lang('Maintenance'));
47
+    $interbreadcrumb[] = array('url' => 'maintenance.php', 'name' => get_lang('Maintenance'));
48 48
 }
49 49
 Display :: display_header($tool_name, 'Settings');
50 50
 echo Display::page_header($tool_name);
Please login to merge, or discard this patch.