@@ 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 |
|
@@ 7264-7277 (lines=14) @@ | ||
7261 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
|
7262 | * @author Yannick Warnier <[email protected]> |
|
7263 | */ |
|
7264 | function api_get_user_info_from_official_code($official_code = '') |
|
7265 | { |
|
7266 | if (empty($official_code)) { |
|
7267 | return false; |
|
7268 | } |
|
7269 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
7270 | WHERE official_code ='".Database::escape_string($official_code)."'"; |
|
7271 | $result = Database::query($sql); |
|
7272 | if (Database::num_rows($result) > 0) { |
|
7273 | $result_array = Database::fetch_array($result); |
|
7274 | return _api_format_user($result_array); |
|
7275 | } |
|
7276 | return false; |
|
7277 | } |
|
7278 | ||
7279 | /** |
|
7280 | * |
@@ 1434-1455 (lines=22) @@ | ||
1431 | * |
|
1432 | * @return string|bool Date format long without day or false if there are no connections |
|
1433 | */ |
|
1434 | public static function get_first_connection_date($student_id) |
|
1435 | { |
|
1436 | $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1437 | $sql = 'SELECT login_date |
|
1438 | FROM ' . $tbl_track_login . ' |
|
1439 | WHERE login_user_id = ' . intval($student_id) . ' |
|
1440 | ORDER BY login_date ASC |
|
1441 | LIMIT 0,1'; |
|
1442 | ||
1443 | $rs = Database::query($sql); |
|
1444 | if (Database::num_rows($rs)>0) { |
|
1445 | if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1446 | return api_convert_and_format_date( |
|
1447 | $first_login_date, |
|
1448 | DATE_FORMAT_SHORT, |
|
1449 | date_default_timezone_get() |
|
1450 | ); |
|
1451 | } |
|
1452 | } |
|
1453 | ||
1454 | return false; |
|
1455 | } |
|
1456 | ||
1457 | /** |
|
1458 | * Get las connection date for a student |