@@ 1570-1585 (lines=16) @@ | ||
1567 | * @return array $user_info array user_id, lastname, firstname, username, email |
|
1568 | * @author Yannick Warnier <[email protected]> |
|
1569 | */ |
|
1570 | function api_get_user_info_from_username($username = '') |
|
1571 | { |
|
1572 | if (empty($username)) { |
|
1573 | return false; |
|
1574 | } |
|
1575 | $username = trim($username); |
|
1576 | ||
1577 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
1578 | WHERE username='".Database::escape_string($username)."'"; |
|
1579 | $result = Database::query($sql); |
|
1580 | if (Database::num_rows($result) > 0) { |
|
1581 | $result_array = Database::fetch_array($result); |
|
1582 | return _api_format_user($result_array); |
|
1583 | } |
|
1584 | return false; |
|
1585 | } |
|
1586 | ||
1587 | /** |
|
1588 | * Get first user with an email |
|
@@ 1592-1606 (lines=15) @@ | ||
1589 | * @param string $email |
|
1590 | * @return array|bool |
|
1591 | */ |
|
1592 | function api_get_user_info_from_email($email = '') |
|
1593 | { |
|
1594 | if (empty($email)) { |
|
1595 | return false; |
|
1596 | } |
|
1597 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
1598 | WHERE email ='".Database::escape_string($email)."' LIMIT 1"; |
|
1599 | $result = Database::query($sql); |
|
1600 | if (Database::num_rows($result) > 0) { |
|
1601 | $result_array = Database::fetch_array($result); |
|
1602 | return _api_format_user($result_array); |
|
1603 | } |
|
1604 | ||
1605 | return false; |
|
1606 | } |
|
1607 | ||
1608 | /** |
|
1609 | * @return string |
|
@@ 7283-7296 (lines=14) @@ | ||
7280 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
|
7281 | * @author Yannick Warnier <[email protected]> |
|
7282 | */ |
|
7283 | function api_get_user_info_from_official_code($official_code = '') |
|
7284 | { |
|
7285 | if (empty($official_code)) { |
|
7286 | return false; |
|
7287 | } |
|
7288 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
7289 | WHERE official_code ='".Database::escape_string($official_code)."'"; |
|
7290 | $result = Database::query($sql); |
|
7291 | if (Database::num_rows($result) > 0) { |
|
7292 | $result_array = Database::fetch_array($result); |
|
7293 | return _api_format_user($result_array); |
|
7294 | } |
|
7295 | return false; |
|
7296 | } |
|
7297 | ||
7298 | /** |
|
7299 | * |
@@ 1437-1458 (lines=22) @@ | ||
1434 | * |
|
1435 | * @return string|bool Date format long without day or false if there are no connections |
|
1436 | */ |
|
1437 | public static function get_first_connection_date($student_id) |
|
1438 | { |
|
1439 | $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1440 | $sql = 'SELECT login_date |
|
1441 | FROM ' . $tbl_track_login . ' |
|
1442 | WHERE login_user_id = ' . intval($student_id) . ' |
|
1443 | ORDER BY login_date ASC |
|
1444 | LIMIT 0,1'; |
|
1445 | ||
1446 | $rs = Database::query($sql); |
|
1447 | if (Database::num_rows($rs)>0) { |
|
1448 | if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1449 | return api_convert_and_format_date( |
|
1450 | $first_login_date, |
|
1451 | DATE_FORMAT_SHORT, |
|
1452 | date_default_timezone_get() |
|
1453 | ); |
|
1454 | } |
|
1455 | } |
|
1456 | ||
1457 | return false; |
|
1458 | } |
|
1459 | ||
1460 | /** |
|
1461 | * Get las connection date for a student |