@@ 1466-1487 (lines=22) @@ | ||
1463 | * |
|
1464 | * @return string|bool Date format long without day or false if there are no connections |
|
1465 | */ |
|
1466 | public static function get_first_connection_date($student_id) |
|
1467 | { |
|
1468 | $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1469 | $sql = 'SELECT login_date |
|
1470 | FROM ' . $tbl_track_login . ' |
|
1471 | WHERE login_user_id = ' . intval($student_id) . ' |
|
1472 | ORDER BY login_date ASC |
|
1473 | LIMIT 0,1'; |
|
1474 | ||
1475 | $rs = Database::query($sql); |
|
1476 | if (Database::num_rows($rs)>0) { |
|
1477 | if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1478 | return api_convert_and_format_date( |
|
1479 | $first_login_date, |
|
1480 | DATE_FORMAT_SHORT, |
|
1481 | date_default_timezone_get() |
|
1482 | ); |
|
1483 | } |
|
1484 | } |
|
1485 | ||
1486 | return false; |
|
1487 | } |
|
1488 | ||
1489 | /** |
|
1490 | * Get las connection date for a student |
@@ 1556-1571 (lines=16) @@ | ||
1553 | * @return array $user_info array user_id, lastname, firstname, username, email |
|
1554 | * @author Yannick Warnier <[email protected]> |
|
1555 | */ |
|
1556 | function api_get_user_info_from_username($username = '') |
|
1557 | { |
|
1558 | if (empty($username)) { |
|
1559 | return false; |
|
1560 | } |
|
1561 | $username = trim($username); |
|
1562 | ||
1563 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
1564 | WHERE username='".Database::escape_string($username)."'"; |
|
1565 | $result = Database::query($sql); |
|
1566 | if (Database::num_rows($result) > 0) { |
|
1567 | $result_array = Database::fetch_array($result); |
|
1568 | return _api_format_user($result_array); |
|
1569 | } |
|
1570 | return false; |
|
1571 | } |
|
1572 | ||
1573 | /** |
|
1574 | * Get first user with an email |
|
@@ 1578-1592 (lines=15) @@ | ||
1575 | * @param string $email |
|
1576 | * @return array|bool |
|
1577 | */ |
|
1578 | function api_get_user_info_from_email($email = '') |
|
1579 | { |
|
1580 | if (empty($email)) { |
|
1581 | return false; |
|
1582 | } |
|
1583 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
1584 | WHERE email ='".Database::escape_string($email)."' LIMIT 1"; |
|
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 | ||
1591 | return false; |
|
1592 | } |
|
1593 | ||
1594 | /** |
|
1595 | * @return string |
|
@@ 7123-7136 (lines=14) @@ | ||
7120 | * @return array $user_info user_id, lastname, firstname, username, email, ... |
|
7121 | * @author Yannick Warnier <[email protected]> |
|
7122 | */ |
|
7123 | function api_get_user_info_from_official_code($officialCode) |
|
7124 | { |
|
7125 | if (empty($officialCode)) { |
|
7126 | return false; |
|
7127 | } |
|
7128 | $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." |
|
7129 | WHERE official_code ='".Database::escape_string($officialCode)."'"; |
|
7130 | $result = Database::query($sql); |
|
7131 | if (Database::num_rows($result) > 0) { |
|
7132 | $result_array = Database::fetch_array($result); |
|
7133 | return _api_format_user($result_array); |
|
7134 | } |
|
7135 | return false; |
|
7136 | } |
|
7137 | ||
7138 | /** |
|
7139 | * @param string $usernameInputId |