Code Duplication    Length = 14-22 lines in 2 locations

main/inc/lib/tracking.lib.php 1 location

@@ 1445-1466 (lines=22) @@
1442
     *
1443
     * @return    string|bool Date format long without day or false if there are no connections
1444
     */
1445
    public static function get_first_connection_date($student_id)
1446
    {
1447
    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448
    	$sql = 'SELECT login_date
1449
    	        FROM ' . $tbl_track_login . '
1450
                WHERE login_user_id = ' . intval($student_id) . '
1451
                ORDER BY login_date ASC
1452
                LIMIT 0,1';
1453
1454
    	$rs = Database::query($sql);
1455
    	if (Database::num_rows($rs)>0) {
1456
    		if ($first_login_date = Database::result($rs, 0, 0)) {
1457
                return api_convert_and_format_date(
1458
                    $first_login_date,
1459
                    DATE_FORMAT_SHORT,
1460
                    date_default_timezone_get()
1461
                );
1462
    		}
1463
    	}
1464
1465
    	return false;
1466
    }
1467
1468
    /**
1469
     * Get las connection date for a student

main/inc/lib/api.lib.php 1 location

@@ 7081-7094 (lines=14) @@
7078
 * @return array $user_info user_id, lastname, firstname, username, email, ...
7079
 * @author Yannick Warnier <[email protected]>
7080
 */
7081
function api_get_user_info_from_official_code($officialCode)
7082
{
7083
    if (empty($officialCode)) {
7084
        return false;
7085
    }
7086
    $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)."
7087
            WHERE official_code ='".Database::escape_string($officialCode)."'";
7088
    $result = Database::query($sql);
7089
    if (Database::num_rows($result) > 0) {
7090
        $result_array = Database::fetch_array($result);
7091
        return _api_format_user($result_array);
7092
    }
7093
    return false;
7094
}
7095
7096
/**
7097
 * @param string $usernameInputId