#
# $Id: edit_image.php,v 1.4 2005/02/24 20:14:14 filetreefrog Exp $
##################################################
if (!defined("PATHOS")) {
    exit("");
}
$image = null;
if (isset($_GET['id'])) {
    $image = $db->selectObject("imagegallery_image", "id=" . $_GET['id']);
}
if (!$image) {
    $image->gallery_id = $_GET['gid'];
}
$gallery = $db->selectObject("imagegallery_gallery", "id=" . $image->gallery_id);
if ($gallery) {
    $loc = unserialize($gallery->location_data);
    $loc->int = $gallery->id;
    if (pathos_permissions_check("manage", $loc)) {
        $form = imagegallery_image::form($image);
        $form->location($loc);
        $form->meta("action", "save_image");
        $template = new template("imagegallerymodule", "_form_editimage", $loc);
        $template->assign("is_edit", isset($image->id) ? 1 : 0);
        $template->assign("form_html", $form->toHTML());
        $template->output();
    } else {
        echo SITE_403_HTML;
    }
} else {
    echo SITE_404_HTML;
}