private LogbookEntryDisplay LoadFlight(int idFlight) { // Check to see if the requested flight belongs to the current user, or if they're authorized. // It's an extra database hit (or more, if viewing a student flight), but will let us figure out next/previous string szFlightOwner = LogbookEntry.OwnerForFlight(idFlight); if (String.IsNullOrEmpty(szFlightOwner)) { throw new MyFlightbookException(Resources.LogbookEntry.errNoSuchFlight); } bool fIsAdmin = (util.GetIntParam(Request, "a", 0) != 0 && MyFlightbook.Profile.GetUser(Page.User.Identity.Name).CanSupport); // Check that you own the flight, or are admin. If not either of these, check to see if you are authorized if (String.Compare(szFlightOwner, Page.User.Identity.Name, StringComparison.OrdinalIgnoreCase) != 0 && !fIsAdmin) { // check for authorized by student CFIStudentMap sm = new CFIStudentMap(Page.User.Identity.Name); InstructorStudent student = sm.GetInstructorStudent(sm.Students, szFlightOwner); if (student == null || !student.CanViewLogbook) { throw new MyFlightbookException(Resources.SignOff.ViewStudentLogbookUnauthorized); } // At this point, we're viewing a student's flight. Change the return link. mvReturn.SetActiveView(vwReturnStudent); lnkReturnStudent.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/StudentLogbook.aspx?student={0}", szFlightOwner); lnkReturnStudent.Text = String.Format(CultureInfo.CurrentCulture, Resources.Profile.ReturnToStudent, MyFlightbook.Profile.GetUser(szFlightOwner).UserFullName); popmenu.Visible = false; } // If we're here, we're authorized LogbookEntryDisplay led = new LogbookEntryDisplay(idFlight, szFlightOwner, LogbookEntry.LoadTelemetryOption.LoadAll); if (!led.HasFlightData) { led.FlightData = string.Empty; } if (String.IsNullOrEmpty(led.FlightData)) { apcChart.Visible = apcDownload.Visible = apcRaw.Visible = false; } lblFlightDate.Text = led.Date.ToShortDateString(); lblFlightAircraft.Text = led.TailNumDisplay ?? string.Empty; lblCatClass.Text = String.Format(CultureInfo.CurrentCulture, "({0})", led.CatClassDisplay); lblCatClass.CssClass = led.IsOverridden ? "ExceptionData" : string.Empty; litDesc.Text = led.CommentWithReplacedApproaches; lblRoute.Text = led.Route.ToUpper(CultureInfo.CurrentCulture); Page.Title = String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.FlightDetailsTitle, led.Date); return(led); }