| @@ 1471-1486 (lines=16) @@ | ||
| 1468 | * @return array $user_info array user_id, lastname, firstname, username, email |
|
| 1469 | * @author Yannick Warnier <[email protected]> |
|
| 1470 | */ |
|
| 1471 | function api_get_user_info_from_username($username = '') |
|
| 1472 | { |
|
| 1473 | if (empty($username)) { |
|
| 1474 | return false; |
|
| 1475 | } |
|
| 1476 | $username = trim($username); |
|
| 1477 | ||
| 1478 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1479 | WHERE username='".Database::escape_string($username)."'"; |
|
| 1480 | $result = Database::query($sql); |
|
| 1481 | if (Database::num_rows($result) > 0) { |
|
| 1482 | $result_array = Database::fetch_array($result); |
|
| 1483 | return _api_format_user($result_array); |
|
| 1484 | } |
|
| 1485 | return false; |
|
| 1486 | } |
|
| 1487 | ||
| 1488 | /** |
|
| 1489 | * Get first user with an email |
|
| @@ 1493-1507 (lines=15) @@ | ||
| 1490 | * @param string $email |
|
| 1491 | * @return array|bool |
|
| 1492 | */ |
|
| 1493 | function api_get_user_info_from_email($email = '') |
|
| 1494 | { |
|
| 1495 | if (empty($email)) { |
|
| 1496 | return false; |
|
| 1497 | } |
|
| 1498 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1499 | WHERE email ='".Database::escape_string($email)."' LIMIT 1"; |
|
| 1500 | $result = Database::query($sql); |
|
| 1501 | if (Database::num_rows($result) > 0) { |
|
| 1502 | $result_array = Database::fetch_array($result); |
|
| 1503 | return _api_format_user($result_array); |
|
| 1504 | } |
|
| 1505 | ||
| 1506 | return false; |
|
| 1507 | } |
|
| 1508 | ||
| 1509 | /** |
|
| 1510 | * @return string |
|
| @@ 6998-7011 (lines=14) @@ | ||
| 6995 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
|
| 6996 | * @author Yannick Warnier <[email protected]> |
|
| 6997 | */ |
|
| 6998 | function api_get_user_info_from_official_code($officialCode) |
|
| 6999 | { |
|
| 7000 | if (empty($officialCode)) { |
|
| 7001 | return false; |
|
| 7002 | } |
|
| 7003 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 7004 | WHERE official_code ='".Database::escape_string($officialCode)."'"; |
|
| 7005 | $result = Database::query($sql); |
|
| 7006 | if (Database::num_rows($result) > 0) { |
|
| 7007 | $result_array = Database::fetch_array($result); |
|
| 7008 | return _api_format_user($result_array); |
|
| 7009 | } |
|
| 7010 | return false; |
|
| 7011 | } |
|
| 7012 | ||
| 7013 | /** |
|
| 7014 | * @param string $usernameInputId |
|
| @@ 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 |
|