function movePilotFlights($newServerID, $newUserID) { $newPilot = new pilot($newServerID, $newUserID); if (!$newPilot->pilotExists()) { echo "movePilotFlights({$newServerID},{$newUserID}): The target pilot does not exist<BR>"; return 0; } global $db, $flightsTable; // first see if a mapping exists $query = "SELECT ID FROM {$flightsTable} WHERE userID=" . $this->pilotID . " AND userServerID=" . $this->serverID . " "; $res = $db->sql_query($query); if ($res <= 0) { echo "<H3> Error in movePilotFlights query! {$query}</H3>\n"; return 0; } while ($row = $db->sql_fetchrow($res)) { echo "moving flight " . $row['ID'] . '<BR>'; // continue; $flight2move = new flight(); $flight2move->getFlightFromDB($row['ID']); $flight2move->changeUser($newUserID, $newServerID); } }
} echo "<pre>"; echo "<table>"; echo "<tr><td>#</td><td>FlightID</td><td>user</td><td>Name</td><td>localUser</td><td>Name</td></tr>\n"; $i = 1; while ($row = $db->sql_fetchrow($res)) { $pilotID1 = $row['serverID'] . '_' . $row['userID']; fillPilotInfo($pilotID1, $row['serverID'], $row['userID']); $pilotID2 = $row['localServerID'] . '_' . $row['localUserID']; fillPilotInfo($pilotID2, $row['localServerID'], $row['localUserID']); echo "<tr><td>{$i}</td>\n\t\t\t\t<td><a href='" . CONF_MODULE_ARG . "&op=show_flight&flightID=" . $row['ID'] . "'>" . $row['ID'] . "</a></td>\n\t\t\t\t<td>" . $pilotID1 . "</td>\n\t\t\t\n\t\t\t<td><a href='" . CONF_MODULE_ARG . "&op=list_flights&year=0&month=0&pilotID={$pilotID1}'>" . $pilotNames[$pilotID1]['lname'] . " " . $pilotNames[$pilotID1]['fname'] . " [ " . $pilotNames[$pilotID1]['country'] . " ] CIVLID: " . $pilotNames[$pilotID1]['CIVL_ID'] . "</td>\n\t\t\t<td>" . $pilotID2 . "</td>\t\t\n\t\t\t<td><a href='" . CONF_MODULE_ARG . "&op=list_flights&year=0&month=0&pilotID={$pilotID2}'>" . $pilotNames[$pilotID2]['lname'] . " " . $pilotNames[$pilotID2]['fname'] . " [ " . $pilotNames[$pilotID2]['country'] . " ] CIVLID: " . $pilotNames[$pilotID2]['CIVL_ID'] . "</td>\n</tr>\n\t\t\n"; // move the flight from one pilot to another: if ($confirmMove) { $flight2move = new flight(); $flight2move->getFlightFromDB($row['ID']); $flight2move->changeUser($row['localUserID'], $row['localServerID']); if ($i > 1000) { echo 'We are doing this in batches of 1000 , repeat unitil none left, exiting now !'; exit; } } $i++; } echo "</table><BR><BR>"; echo "</pre>"; closeMain(); return; } //----------------------------------------------------------------------------------------------------------- ?>
$newUserIDStr=$_POST["newUserID"]; if ($newUserIDStr) { // move this flight to a new userID $newUserIDStrPart=split('_',$newUserIDStr); $newUserServerID=0; if (count($newUserIDStrPart)>1) { $newUserServerID=$newUserIDStrPart[0]; $newUserID=$newUserIDStrPart[1]; } else if (is_numeric($newUserIDStr) ){ $newUserID=$newUserIDStr; } else { echo "Not correct format for new user ID<BR>"; $inError=1; } if (!$inError) { $flight->changeUser($newUserID,$newUserServerID); } } else { $flight->cat=$_REQUEST["gliderCat"]+0; $flight->category=$_REQUEST["category"]+0; $flight->gliderCertCategory=$_REQUEST["gliderCertCategory"]+0; $flight->startType=$_REQUEST["startType"]+0; $flight->gliderBrandID=$_REQUEST["gliderBrandID"]; $flight->glider=$_REQUEST["glider"]; $flight->grecord=$_REQUEST["grecord"]+0; $flight->validated=$_REQUEST["validated"]+0; $flight->airspaceCheck=$_REQUEST["airspaceCheck"]+0;