| @@ 1445-1466 (lines=22) @@ | ||
| 1442 | * |
|
| 1443 | * @return string|bool Date format long without day or false if there are no connections |
|
| 1444 | */ |
|
| 1445 | public static function get_first_connection_date($student_id) |
|
| 1446 | { |
|
| 1447 | $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
| 1448 | $sql = 'SELECT login_date |
|
| 1449 | FROM ' . $tbl_track_login . ' |
|
| 1450 | WHERE login_user_id = ' . intval($student_id) . ' |
|
| 1451 | ORDER BY login_date ASC |
|
| 1452 | LIMIT 0,1'; |
|
| 1453 | ||
| 1454 | $rs = Database::query($sql); |
|
| 1455 | if (Database::num_rows($rs)>0) { |
|
| 1456 | if ($first_login_date = Database::result($rs, 0, 0)) { |
|
| 1457 | return api_convert_and_format_date( |
|
| 1458 | $first_login_date, |
|
| 1459 | DATE_FORMAT_SHORT, |
|
| 1460 | date_default_timezone_get() |
|
| 1461 | ); |
|
| 1462 | } |
|
| 1463 | } |
|
| 1464 | ||
| 1465 | return false; |
|
| 1466 | } |
|
| 1467 | ||
| 1468 | /** |
|
| 1469 | * Get las connection date for a student |
|
| @@ 1486-1501 (lines=16) @@ | ||
| 1483 | * @return array $user_info array user_id, lastname, firstname, username, email |
|
| 1484 | * @author Yannick Warnier <[email protected]> |
|
| 1485 | */ |
|
| 1486 | function api_get_user_info_from_username($username = '') |
|
| 1487 | { |
|
| 1488 | if (empty($username)) { |
|
| 1489 | return false; |
|
| 1490 | } |
|
| 1491 | $username = trim($username); |
|
| 1492 | ||
| 1493 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1494 | WHERE username='".Database::escape_string($username)."'"; |
|
| 1495 | $result = Database::query($sql); |
|
| 1496 | if (Database::num_rows($result) > 0) { |
|
| 1497 | $result_array = Database::fetch_array($result); |
|
| 1498 | return _api_format_user($result_array); |
|
| 1499 | } |
|
| 1500 | return false; |
|
| 1501 | } |
|
| 1502 | ||
| 1503 | /** |
|
| 1504 | * Get first user with an email |
|
| @@ 1508-1522 (lines=15) @@ | ||
| 1505 | * @param string $email |
|
| 1506 | * @return array|bool |
|
| 1507 | */ |
|
| 1508 | function api_get_user_info_from_email($email = '') |
|
| 1509 | { |
|
| 1510 | if (empty($email)) { |
|
| 1511 | return false; |
|
| 1512 | } |
|
| 1513 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1514 | WHERE email ='".Database::escape_string($email)."' LIMIT 1"; |
|
| 1515 | $result = Database::query($sql); |
|
| 1516 | if (Database::num_rows($result) > 0) { |
|
| 1517 | $result_array = Database::fetch_array($result); |
|
| 1518 | return _api_format_user($result_array); |
|
| 1519 | } |
|
| 1520 | ||
| 1521 | return false; |
|
| 1522 | } |
|
| 1523 | ||
| 1524 | /** |
|
| 1525 | * @return string |
|
| @@ 7068-7081 (lines=14) @@ | ||
| 7065 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
|
| 7066 | * @author Yannick Warnier <[email protected]> |
|
| 7067 | */ |
|
| 7068 | function api_get_user_info_from_official_code($officialCode) |
|
| 7069 | { |
|
| 7070 | if (empty($officialCode)) { |
|
| 7071 | return false; |
|
| 7072 | } |
|
| 7073 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 7074 | WHERE official_code ='".Database::escape_string($officialCode)."'"; |
|
| 7075 | $result = Database::query($sql); |
|
| 7076 | if (Database::num_rows($result) > 0) { |
|
| 7077 | $result_array = Database::fetch_array($result); |
|
| 7078 | return _api_format_user($result_array); |
|
| 7079 | } |
|
| 7080 | return false; |
|
| 7081 | } |
|
| 7082 | ||
| 7083 | /** |
|
| 7084 | * @param string $usernameInputId |
|