# Suite 330,
# Boston, MA 02111-1307  USA
#
# $Id: edit_report.php,v 1.2 2005/02/19 00:32:32 filetreefrog Exp $
##################################################
if (!defined("PATHOS")) {
    exit("");
}
$f = null;
$rept = null;
if (isset($_GET['id'])) {
    $f = $db->selectObject("formbuilder_form", "id=" . $_GET['id']);
}
if ($f) {
    if (pathos_permissions_check("editreport", unserialize($f->location_data))) {
        $floc = unserialize($f->location_data);
        $rept = $db->selectObject("formbuilder_report", "form_id=" . $f->id);
        $form = formbuilder_report::form($rept);
        $form->location($loc);
        $form->meta("action", "save_report");
        $form->meta("id", $rept->id);
        $form->meta("m", $floc->mod);
        $form->meta("s", $floc->src);
        $form->meta("i", $floc->int);
        echo $form->toHTML();
    } else {
        echo SITE_403_HTML;
    }
} else {
    echo SITE_404_HTML;
}
# not, write to:
#
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307  USA
#
# $Id: save_report.php,v 1.2 2005/02/19 00:32:32 filetreefrog Exp $
##################################################
if (!defined("PATHOS")) {
    exit("");
}
$rpt = null;
if (isset($_POST['id'])) {
    $rpt = $db->selectObject("formbuilder_report", "id=" . $_POST['id']);
}
if ($rpt) {
    if (pathos_permissions_check("editreport", unserialize($f->location_data))) {
        $rpt = formbuilder_report::update($_POST, $rpt);
        if (isset($rpt->id)) {
            $db->updateObject($rpt, "formbuilder_report");
        } else {
            $db->insertObject($rpt, "formbuilder_report");
        }
        pathos_flow_redirect();
    } else {
        echo SITE_403_HTML;
    }
} else {
    echo SITE_404_HTML;
}