| @@ 1555-1570 (lines=16) @@ | ||
| 1552 | * @return array $user_info array user_id, lastname, firstname, username, email |
|
| 1553 | * @author Yannick Warnier <[email protected]> |
|
| 1554 | */ |
|
| 1555 | function api_get_user_info_from_username($username = '') |
|
| 1556 | { |
|
| 1557 | if (empty($username)) { |
|
| 1558 | return false; |
|
| 1559 | } |
|
| 1560 | $username = trim($username); |
|
| 1561 | ||
| 1562 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1563 | WHERE username='".Database::escape_string($username)."'"; |
|
| 1564 | $result = Database::query($sql); |
|
| 1565 | if (Database::num_rows($result) > 0) { |
|
| 1566 | $result_array = Database::fetch_array($result); |
|
| 1567 | return _api_format_user($result_array); |
|
| 1568 | } |
|
| 1569 | return false; |
|
| 1570 | } |
|
| 1571 | ||
| 1572 | /** |
|
| 1573 | * Get first user with an email |
|
| @@ 1577-1591 (lines=15) @@ | ||
| 1574 | * @param string $email |
|
| 1575 | * @return array|bool |
|
| 1576 | */ |
|
| 1577 | function api_get_user_info_from_email($email = '') |
|
| 1578 | { |
|
| 1579 | if (empty($email)) { |
|
| 1580 | return false; |
|
| 1581 | } |
|
| 1582 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 1583 | WHERE email ='".Database::escape_string($email)."' LIMIT 1"; |
|
| 1584 | $result = Database::query($sql); |
|
| 1585 | if (Database::num_rows($result) > 0) { |
|
| 1586 | $result_array = Database::fetch_array($result); |
|
| 1587 | return _api_format_user($result_array); |
|
| 1588 | } |
|
| 1589 | ||
| 1590 | return false; |
|
| 1591 | } |
|
| 1592 | ||
| 1593 | /** |
|
| 1594 | * @return string |
|
| @@ 7249-7262 (lines=14) @@ | ||
| 7246 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
|
| 7247 | * @author Yannick Warnier <[email protected]> |
|
| 7248 | */ |
|
| 7249 | function api_get_user_info_from_official_code($official_code = '') |
|
| 7250 | { |
|
| 7251 | if (empty($official_code)) { |
|
| 7252 | return false; |
|
| 7253 | } |
|
| 7254 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
| 7255 | WHERE official_code ='".Database::escape_string($official_code)."'"; |
|
| 7256 | $result = Database::query($sql); |
|
| 7257 | if (Database::num_rows($result) > 0) { |
|
| 7258 | $result_array = Database::fetch_array($result); |
|
| 7259 | return _api_format_user($result_array); |
|
| 7260 | } |
|
| 7261 | return false; |
|
| 7262 | } |
|
| 7263 | ||
| 7264 | /** |
|
| 7265 | * |
|
| @@ 1395-1416 (lines=22) @@ | ||
| 1392 | * |
|
| 1393 | * @return string|bool Date format long without day or false if there are no connections |
|
| 1394 | */ |
|
| 1395 | public static function get_first_connection_date($student_id) |
|
| 1396 | { |
|
| 1397 | $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
| 1398 | $sql = 'SELECT login_date |
|
| 1399 | FROM ' . $tbl_track_login . ' |
|
| 1400 | WHERE login_user_id = ' . intval($student_id) . ' |
|
| 1401 | ORDER BY login_date ASC |
|
| 1402 | LIMIT 0,1'; |
|
| 1403 | ||
| 1404 | $rs = Database::query($sql); |
|
| 1405 | if (Database::num_rows($rs)>0) { |
|
| 1406 | if ($first_login_date = Database::result($rs, 0, 0)) { |
|
| 1407 | return api_convert_and_format_date( |
|
| 1408 | $first_login_date, |
|
| 1409 | DATE_FORMAT_SHORT, |
|
| 1410 | date_default_timezone_get() |
|
| 1411 | ); |
|
| 1412 | } |
|
| 1413 | } |
|
| 1414 | ||
| 1415 | return false; |
|
| 1416 | } |
|
| 1417 | ||
| 1418 | /** |
|
| 1419 | * Get las connection date for a student |
|