function deleteFlight() { global $db; global $flightsTable, $deletedFlightsTable; global $CONF_photosPerFlight, $CONF_server_id; if ($this->filename) { // save a copy $newfilename = $this->filename . "_DELETED_" . $this->flightID . ".igc"; // echo "renaming igc file to back it up: $newfilename<br>"; $this->renameTracklog($newfilename); } $query = "INSERT INTO {$deletedFlightsTable} SELECT {$flightsTable}.* from {$flightsTable} WHERE {$flightsTable}.ID=" . $this->flightID . " "; //echo $query; $res = $db->sql_query($query); $query = "UPDATE {$deletedFlightsTable} Set dateUpdated='" . gmdate("Y-m-d H:i:s") . "' where ID=" . $this->flightID . " "; //echo $query; $res = $db->sql_query($query); $query = "DELETE from {$flightsTable} WHERE ID=" . $this->flightID . " "; // echo $query; $res = $db->sql_query($query); # Error checking if ($res <= 0) { echo "<H3> Error in delete Flight query! </H3>\n"; exit; } $this->flightScore = new flightScore($this->flightID); $this->flightScore->getFromDB(); $flightScore = new flightScore($this->flightID); $flightScore->deleteFromDB(); // Now delete the files if (1) { $this->deleteFile($this->getIGCFilename(0)); $this->deleteFile($this->getIGCFilename(0) . ".olc"); $this->deleteFile($this->getIGCFilename(1)); $this->deleteFile($this->getIGCFilename(2)); $this->deleteSecondaryFiles(); $this->deleteFile($this->getMapFilename()); for ($metric_system = 1; $metric_system <= 2; $metric_system++) { for ($raw = 0; $raw <= 1; $raw++) { # martin jursa 28.05.2008: delete using the deleteFile() method to avoid log flooding $this->deleteFile($this->getChartFilename("alt", $metric_system, $raw)); $this->deleteFile($this->getChartFilename("speed", $metric_system, $raw)); $this->deleteFile($this->getChartFilename("vario", $metric_system, $raw)); $this->deleteFile($this->getChartFilename("takeoff_distance", $metric_system, $raw)); } } } if ($this->hasPhotos) { $flightPhotos = new flightPhotos($this->flightID); $flightPhotos->deleteAllPhotos(0); } if ($this->commentsNum) { require_once dirname(__FILE__) . '/CL_comments.php'; $comments = new flightComments($this->flightID); $comments->deleteAllComments(0); // dont update the flights table } // Now also hide/unhide same flights $this->hideSameFlights(); require_once dirname(__FILE__) . '/CL_actionLogger.php'; $log = new Logger(); $log->userID = $this->userID; $log->ItemType = 1; // flight; $log->ItemID = $this->serverID && $this->serverID != $CONF_server_id ? $this->original_ID : $this->flightID; // 0 at start will fill in later if successfull $log->ServerItemID = $this->serverID ? $this->serverID : $CONF_server_id; $log->ActionID = 4; //1 => add 2 => edit; 4 => delete $log->ActionXML = $this->toXML(); $log->Modifier = 0; $log->ModifierID = 0; $log->ServerModifierID = 0; $log->Result = 1; if (!$log->Result) { $log->ResultDescription = "Problem in deleting flight {$query}"; } if (!$log->put()) { echo "Problem in logger<BR>"; } }