#
# $Id: save_gallery.php,v 1.7 2005/05/09 05:54:38 filetreefrog Exp $
##################################################
if (!defined('PATHOS')) {
    exit('');
}
$gallery = null;
if (isset($_POST['id'])) {
    $gallery = $db->selectObject('imagegallery_gallery', 'id=' . $_POST['id']);
    $loc = unserialize($gallery->location_data);
    $loc->int = $gallery->id;
} else {
    $gallery->location_data = serialize($loc);
}
if (pathos_permissions_check('edit', $loc)) {
    $gallery = imagegallery_gallery::update($_POST, $gallery);
    if (isset($gallery->id)) {
        $db->updateObject($gallery, 'imagegallery_gallery');
    } else {
        $id = $db->insertObject($gallery, 'imagegallery_gallery');
        if (!defined('SYS_FILES')) {
            require_once BASE . 'subsystems/files.php';
        }
        $directory = 'files/imagegallerymodule/' . $loc->src . '/gallery' . $id;
        #.'/.thumbs';
        if (!file_exists(BASE . $directory)) {
            $err = pathos_files_makeDirectory($directory);
            if ($err != SYS_FILES_SUCCESS) {
                echo '<div class="error">';
                if ($err == SYS_FILES_FOUNDFILE) {
                    echo TR_FILEMANAGER_FILEFOUNDINPATH;
# for more details.
#
# You should have received a copy of the GNU
# General Public License along with Exponent; if
# not, write to:
#
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307  USA
#
# $Id: edit_gallery.php,v 1.4 2005/02/24 20:14:14 filetreefrog Exp $
##################################################
if (!defined("PATHOS")) {
    exit("");
}
$gallery = null;
if (isset($_GET['id'])) {
    $gallery = $db->selectObject("imagegallery_gallery", "id=" . $_GET['id']);
    $loc = unserialize($gallery->location_data);
    $loc->int = $gallery->id;
}
if (pathos_permissions_check("edit", $loc)) {
    $form = imagegallery_gallery::form($gallery);
    $form->location($loc);
    $form->meta("action", "save_gallery");
    $template = new template("imagegallerymodule", "_form_editgallery", $loc);
    $template->assign("is_edit", isset($gallery->id) ? 1 : 0);
    $template->assign("form_html", $form->toHTML());
    $template->output();
}