| @@ 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 |
|
| @@ 7330-7343 (lines=14) @@ | ||
| 7327 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
|
| 7328 | * @author Yannick Warnier <[email protected]> |
|
| 7329 | */ |
|
| 7330 | function api_get_user_info_from_official_code($official_code = '') |
|
| 7331 | { |
|
| 7332 | if (empty($official_code)) { |
|
| 7333 | return false; |
|
| 7334 | } |
|
| 7335 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 7336 | WHERE official_code ='".Database::escape_string($official_code)."'"; |
|
| 7337 | $result = Database::query($sql); |
|
| 7338 | if (Database::num_rows($result) > 0) { |
|
| 7339 | $result_array = Database::fetch_array($result); |
|
| 7340 | return _api_format_user($result_array); |
|
| 7341 | } |
|
| 7342 | return false; |
|
| 7343 | } |
|
| 7344 | ||
| 7345 | /** |
|
| 7346 | * |
|
| @@ 1441-1462 (lines=22) @@ | ||
| 1438 | * |
|
| 1439 | * @return string|bool Date format long without day or false if there are no connections |
|
| 1440 | */ |
|
| 1441 | public static function get_first_connection_date($student_id) |
|
| 1442 | { |
|
| 1443 | $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
| 1444 | $sql = 'SELECT login_date |
|
| 1445 | FROM ' . $tbl_track_login . ' |
|
| 1446 | WHERE login_user_id = ' . intval($student_id) . ' |
|
| 1447 | ORDER BY login_date ASC |
|
| 1448 | LIMIT 0,1'; |
|
| 1449 | ||
| 1450 | $rs = Database::query($sql); |
|
| 1451 | if (Database::num_rows($rs)>0) { |
|
| 1452 | if ($first_login_date = Database::result($rs, 0, 0)) { |
|
| 1453 | return api_convert_and_format_date( |
|
| 1454 | $first_login_date, |
|
| 1455 | DATE_FORMAT_SHORT, |
|
| 1456 | date_default_timezone_get() |
|
| 1457 | ); |
|
| 1458 | } |
|
| 1459 | } |
|
| 1460 | ||
| 1461 | return false; |
|
| 1462 | } |
|
| 1463 | ||
| 1464 | /** |
|
| 1465 | * Get las connection date for a student |
|