}
    list($login, $postfix) = split('[@]', $row['login_name']);
    $user = new stdClass();
    $user->originid = $row['userid'];
    $user->login = $login;
    $user->mail = $row['login_name'];
    $user->firstname = $firstname;
    $user->lastname = $lastname;
    $user->language = "en";
    $user->mail_notification = "0";
    $user->status = $status;
    $user->admin = 'false';
    $user->hashed_password = "";
    // PASSWORD EQUAL TO LOGIN NAME
    $user->utype = "User";
    if (($id = existIn($user->login)) > 0) {
        $user->newid = $id;
    } else {
        $largestId++;
        $user->newid = $largestId;
    }
    $users[$row['userid']] = $user;
}
echo "Part 1: extract data from Bugzilla database, construct users and user_email tables</br>";
//var_dump($users);
//up to now the user data is complete and compitable with LDAP, the original
//user data in Redmine PostgreSQL.
//The next step is write the extra user data into Redmine PostgreSQL
writeUser($users);
//add content to table, email_address, which indicates the email address of
//each user
while ($row = mysqli_fetch_array($result)) {
    $projectmap = new stdClass();
    $projectmap->originid = $row['id'];
    $projectmap->newid = mapprojectid($row['name']);
    $projectmaps[] = $projectmap;
}
// 3. construct the originuserid and newuserid map
$useridmaps = array();
$sql = "SELECT userid, login_name FROM profiles";
$result = mysqli_query($mysqlCon, $sql) or die(mysqli_error() . $sql);
while ($row = mysqli_fetch_array($result)) {
    list($login, $postfix) = split('[@]', $row['login_name']);
    $useridmap = new stdClass();
    $useridmap->originid = $row['userid'];
    $useridmap->login = $login;
    $useridmap->newid = existIn($useridmap->login);
    $useridmaps[] = $useridmap;
}
// 4. construct Version table, the query is in MySQL bugzilla
$versions = array();
$versionNames = array();
$sql = "SELECT versions.id, \r\n\t\t       product_id AS project_id, \r\n\t\t       value AS name \r\n\t\t    FROM versions\r\n\t\t    WHERE versions.product_id";
$result = mysqli_query($mysqlCon, $sql) or die(mysqli_error() . $sql);
while ($row = mysqli_fetch_array($result)) {
    foreach ($projectmaps as $index => $projectmap) {
        if ($projectmap->originid == $row['project_id']) {
            $temp_project_id = $projectmap->newid;
        }
    }
    $versionNames[$temp_project_id][$row['name']] = $row['id'];
    $version = new stdClass();