| @@ 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 |
|
| @@ 1488-1503 (lines=16) @@ | ||
| 1485 | * @return array $user_info array user_id, lastname, firstname, username, email |
|
| 1486 | * @author Yannick Warnier <[email protected]> |
|
| 1487 | */ |
|
| 1488 | function api_get_user_info_from_username($username = '') |
|
| 1489 | { |
|
| 1490 | if (empty($username)) { |
|
| 1491 | return false; |
|
| 1492 | } |
|
| 1493 | $username = trim($username); |
|
| 1494 | ||
| 1495 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1496 | WHERE username='".Database::escape_string($username)."'"; |
|
| 1497 | $result = Database::query($sql); |
|
| 1498 | if (Database::num_rows($result) > 0) { |
|
| 1499 | $result_array = Database::fetch_array($result); |
|
| 1500 | return _api_format_user($result_array); |
|
| 1501 | } |
|
| 1502 | return false; |
|
| 1503 | } |
|
| 1504 | ||
| 1505 | /** |
|
| 1506 | * Get first user with an email |
|
| @@ 1510-1524 (lines=15) @@ | ||
| 1507 | * @param string $email |
|
| 1508 | * @return array|bool |
|
| 1509 | */ |
|
| 1510 | function api_get_user_info_from_email($email = '') |
|
| 1511 | { |
|
| 1512 | if (empty($email)) { |
|
| 1513 | return false; |
|
| 1514 | } |
|
| 1515 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1516 | WHERE email ='".Database::escape_string($email)."' LIMIT 1"; |
|
| 1517 | $result = Database::query($sql); |
|
| 1518 | if (Database::num_rows($result) > 0) { |
|
| 1519 | $result_array = Database::fetch_array($result); |
|
| 1520 | return _api_format_user($result_array); |
|
| 1521 | } |
|
| 1522 | ||
| 1523 | return false; |
|
| 1524 | } |
|
| 1525 | ||
| 1526 | /** |
|
| 1527 | * @return string |
|
| @@ 7083-7096 (lines=14) @@ | ||
| 7080 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
|
| 7081 | * @author Yannick Warnier <[email protected]> |
|
| 7082 | */ |
|
| 7083 | function api_get_user_info_from_official_code($officialCode) |
|
| 7084 | { |
|
| 7085 | if (empty($officialCode)) { |
|
| 7086 | return false; |
|
| 7087 | } |
|
| 7088 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 7089 | WHERE official_code ='".Database::escape_string($officialCode)."'"; |
|
| 7090 | $result = Database::query($sql); |
|
| 7091 | if (Database::num_rows($result) > 0) { |
|
| 7092 | $result_array = Database::fetch_array($result); |
|
| 7093 | return _api_format_user($result_array); |
|
| 7094 | } |
|
| 7095 | return false; |
|
| 7096 | } |
|
| 7097 | ||
| 7098 | /** |
|
| 7099 | * @param string $usernameInputId |
|