| @@ 1576-1591 (lines=16) @@ | ||
| 1573 | * @return array $user_info array user_id, lastname, firstname, username, email |
|
| 1574 | * @author Yannick Warnier <[email protected]> |
|
| 1575 | */ |
|
| 1576 | function api_get_user_info_from_username($username = '') |
|
| 1577 | { |
|
| 1578 | if (empty($username)) { |
|
| 1579 | return false; |
|
| 1580 | } |
|
| 1581 | $username = trim($username); |
|
| 1582 | ||
| 1583 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1584 | WHERE username='".Database::escape_string($username)."'"; |
|
| 1585 | $result = Database::query($sql); |
|
| 1586 | if (Database::num_rows($result) > 0) { |
|
| 1587 | $result_array = Database::fetch_array($result); |
|
| 1588 | return _api_format_user($result_array); |
|
| 1589 | } |
|
| 1590 | return false; |
|
| 1591 | } |
|
| 1592 | ||
| 1593 | /** |
|
| 1594 | * Get first user with an email |
|
| @@ 1598-1612 (lines=15) @@ | ||
| 1595 | * @param string $email |
|
| 1596 | * @return array|bool |
|
| 1597 | */ |
|
| 1598 | function api_get_user_info_from_email($email = '') |
|
| 1599 | { |
|
| 1600 | if (empty($email)) { |
|
| 1601 | return false; |
|
| 1602 | } |
|
| 1603 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1604 | WHERE email ='".Database::escape_string($email)."' LIMIT 1"; |
|
| 1605 | $result = Database::query($sql); |
|
| 1606 | if (Database::num_rows($result) > 0) { |
|
| 1607 | $result_array = Database::fetch_array($result); |
|
| 1608 | return _api_format_user($result_array); |
|
| 1609 | } |
|
| 1610 | ||
| 1611 | return false; |
|
| 1612 | } |
|
| 1613 | ||
| 1614 | /** |
|
| 1615 | * @return string |
|
| @@ 7344-7357 (lines=14) @@ | ||
| 7341 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
|
| 7342 | * @author Yannick Warnier <[email protected]> |
|
| 7343 | */ |
|
| 7344 | function api_get_user_info_from_official_code($official_code = '') |
|
| 7345 | { |
|
| 7346 | if (empty($official_code)) { |
|
| 7347 | return false; |
|
| 7348 | } |
|
| 7349 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 7350 | WHERE official_code ='".Database::escape_string($official_code)."'"; |
|
| 7351 | $result = Database::query($sql); |
|
| 7352 | if (Database::num_rows($result) > 0) { |
|
| 7353 | $result_array = Database::fetch_array($result); |
|
| 7354 | return _api_format_user($result_array); |
|
| 7355 | } |
|
| 7356 | return false; |
|
| 7357 | } |
|
| 7358 | ||
| 7359 | /** |
|
| 7360 | * |
|
| @@ 1451-1472 (lines=22) @@ | ||
| 1448 | * |
|
| 1449 | * @return string|bool Date format long without day or false if there are no connections |
|
| 1450 | */ |
|
| 1451 | public static function get_first_connection_date($student_id) |
|
| 1452 | { |
|
| 1453 | $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
| 1454 | $sql = 'SELECT login_date |
|
| 1455 | FROM ' . $tbl_track_login . ' |
|
| 1456 | WHERE login_user_id = ' . intval($student_id) . ' |
|
| 1457 | ORDER BY login_date ASC |
|
| 1458 | LIMIT 0,1'; |
|
| 1459 | ||
| 1460 | $rs = Database::query($sql); |
|
| 1461 | if (Database::num_rows($rs)>0) { |
|
| 1462 | if ($first_login_date = Database::result($rs, 0, 0)) { |
|
| 1463 | return api_convert_and_format_date( |
|
| 1464 | $first_login_date, |
|
| 1465 | DATE_FORMAT_SHORT, |
|
| 1466 | date_default_timezone_get() |
|
| 1467 | ); |
|
| 1468 | } |
|
| 1469 | } |
|
| 1470 | ||
| 1471 | return false; |
|
| 1472 | } |
|
| 1473 | ||
| 1474 | /** |
|
| 1475 | * Get las connection date for a student |
|