| @@ 1434-1455 (lines=22) @@ | ||
| 1431 | * |
|
| 1432 | * @return string|bool Date format long without day or false if there are no connections |
|
| 1433 | */ |
|
| 1434 | public static function get_first_connection_date($student_id) |
|
| 1435 | { |
|
| 1436 | $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
| 1437 | $sql = 'SELECT login_date |
|
| 1438 | FROM ' . $tbl_track_login . ' |
|
| 1439 | WHERE login_user_id = ' . intval($student_id) . ' |
|
| 1440 | ORDER BY login_date ASC |
|
| 1441 | LIMIT 0,1'; |
|
| 1442 | ||
| 1443 | $rs = Database::query($sql); |
|
| 1444 | if (Database::num_rows($rs)>0) { |
|
| 1445 | if ($first_login_date = Database::result($rs, 0, 0)) { |
|
| 1446 | return api_convert_and_format_date( |
|
| 1447 | $first_login_date, |
|
| 1448 | DATE_FORMAT_SHORT, |
|
| 1449 | date_default_timezone_get() |
|
| 1450 | ); |
|
| 1451 | } |
|
| 1452 | } |
|
| 1453 | ||
| 1454 | return false; |
|
| 1455 | } |
|
| 1456 | ||
| 1457 | /** |
|
| 1458 | * Get las connection date for a student |
|
| @@ 1425-1440 (lines=16) @@ | ||
| 1422 | * @return array $user_info array user_id, lastname, firstname, username, email |
|
| 1423 | * @author Yannick Warnier <[email protected]> |
|
| 1424 | */ |
|
| 1425 | function api_get_user_info_from_username($username = '') |
|
| 1426 | { |
|
| 1427 | if (empty($username)) { |
|
| 1428 | return false; |
|
| 1429 | } |
|
| 1430 | $username = trim($username); |
|
| 1431 | ||
| 1432 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1433 | WHERE username='".Database::escape_string($username)."'"; |
|
| 1434 | $result = Database::query($sql); |
|
| 1435 | if (Database::num_rows($result) > 0) { |
|
| 1436 | $result_array = Database::fetch_array($result); |
|
| 1437 | return _api_format_user($result_array); |
|
| 1438 | } |
|
| 1439 | return false; |
|
| 1440 | } |
|
| 1441 | ||
| 1442 | /** |
|
| 1443 | * Get first user with an email |
|
| @@ 1447-1461 (lines=15) @@ | ||
| 1444 | * @param string $email |
|
| 1445 | * @return array|bool |
|
| 1446 | */ |
|
| 1447 | function api_get_user_info_from_email($email = '') |
|
| 1448 | { |
|
| 1449 | if (empty($email)) { |
|
| 1450 | return false; |
|
| 1451 | } |
|
| 1452 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1453 | WHERE email ='".Database::escape_string($email)."' LIMIT 1"; |
|
| 1454 | $result = Database::query($sql); |
|
| 1455 | if (Database::num_rows($result) > 0) { |
|
| 1456 | $result_array = Database::fetch_array($result); |
|
| 1457 | return _api_format_user($result_array); |
|
| 1458 | } |
|
| 1459 | ||
| 1460 | return false; |
|
| 1461 | } |
|
| 1462 | ||
| 1463 | /** |
|
| 1464 | * @return string |
|
| @@ 7125-7138 (lines=14) @@ | ||
| 7122 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
|
| 7123 | * @author Yannick Warnier <[email protected]> |
|
| 7124 | */ |
|
| 7125 | function api_get_user_info_from_official_code($official_code = '') |
|
| 7126 | { |
|
| 7127 | if (empty($official_code)) { |
|
| 7128 | return false; |
|
| 7129 | } |
|
| 7130 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 7131 | WHERE official_code ='".Database::escape_string($official_code)."'"; |
|
| 7132 | $result = Database::query($sql); |
|
| 7133 | if (Database::num_rows($result) > 0) { |
|
| 7134 | $result_array = Database::fetch_array($result); |
|
| 7135 | return _api_format_user($result_array); |
|
| 7136 | } |
|
| 7137 | return false; |
|
| 7138 | } |
|
| 7139 | ||
| 7140 | /** |
|
| 7141 | * |
|