Exemplo n.º 1
0
$petListingId = filter_input(INPUT_GET, 'petListingId', FILTER_VALIDATE_INT, array("options" => array("default" => 0)));
if (isset($_SESSION['listingBeingEdited'])) {
    $listing = $_SESSION['listingBeingEdited'];
    unset($_SESSION['listingBeingEdited']);
} elseif ($petListingId) {
    try {
        $listing = PetListing::$objects->get($petListingId);
    } catch (DoesNotExist $e) {
        $listing = new PetListing();
    }
} else {
    $listing = new PetListing();
}
if ($listing->id) {
    $pageTitle = "Edit Pet Listing";
    $user = $listing->getUser();
} else {
    $pageTitle = "Add Pet Listing";
    $user = new RegisteredUser();
}
if ($listing->approved && $listing->approvedById) {
    $approvedByUser = $listing->getApprovedByUser();
} else {
    $approvedByUser = new RegisteredUser();
}
/**
 * Generate and echo a set of radio buttons with the given name, values, labels, 
 * and selected value.
 */
function makeRadioButtons($name, $values, $labels, $selectedValue)
{