92 lines
3.0 KiB
PHP
92 lines
3.0 KiB
PHP
<?php
|
|
|
|
// Copyright (C) 2002-2006 Balint Kis (balint@k-i-s.net)
|
|
// Copyright (C) 2005-2013 Solomon Peachy (pizza@shaftnet.org)
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation; either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to the Free Software
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
include_once "include/config.php";
|
|
include_once "include/site.php";
|
|
|
|
$album_id = pg_escape_string($database, $_REQUEST['album']);
|
|
|
|
$database = site_prolog(PO_USER_TYPE_CLIENT);
|
|
$go = TRUE;
|
|
|
|
/* Ensure mere users don't erase an album that isn't theirs! */
|
|
if ($po_user['type'] != PO_USER_TYPE_ADMIN) {
|
|
$result = pg_query($database, "select identifier from album where identifier='$album_id' and users = $po_user[id]");
|
|
if (pg_num_rows($result) <= 0) {
|
|
site_referer_error('not_owner');
|
|
site_epilog($database);
|
|
exit();
|
|
}
|
|
}
|
|
|
|
/* Clean up sub-albums properly */
|
|
if ($go && ($album_id!="")) {
|
|
pg_query($database, "begin");
|
|
|
|
/* Find all albums with us as their parent... */
|
|
$result = pg_query($database, "select parent_album from album where identifier='$album_id'");
|
|
if (pg_num_rows($result)) {
|
|
$parent_album = pg_fetch_row($result);
|
|
if ($parent_album[0] == "")
|
|
$parent_album[0] = FALSE;
|
|
|
|
} else {
|
|
$parent_album = array(FALSE);
|
|
}
|
|
|
|
if ($result && $parent_album[0] != FALSE) {
|
|
/* And make them ours! */
|
|
$result = pg_query($database, "update album set parent_album = $parent_album[0] where parent_album = $album_id");
|
|
}
|
|
|
|
if ($result) {
|
|
$result = pg_query($database, "delete from album_content where album='$album_id'");
|
|
}
|
|
|
|
if ($result) {
|
|
$result = pg_query($database, "delete from album where identifier='$album_id'");
|
|
}
|
|
|
|
if ($result) {
|
|
pg_query($database, "commit");
|
|
if ($memcache) {
|
|
po_log("memcache: delete allalbum.$po_user[id]", PEAR_LOG_DEBUG);
|
|
$memcache->delete("allalbum.$po_user[id]");
|
|
po_log("memcache: delete path_album.0.$album_id", PEAR_LOG_DEBUG);
|
|
$memcache->delete("path_album.0.$album_id");
|
|
po_log("memcache: delete path_album.1.$album_id", PEAR_LOG_DEBUG);
|
|
$memcache->delete("path_album.1.$album_id");
|
|
}
|
|
} else {
|
|
pg_query($database, "abort");
|
|
site_push_error($strings['errors_db_insert_failed']);
|
|
}
|
|
}
|
|
|
|
site_epilog($database);
|
|
|
|
if (isset($_REQUEST['return'])) {
|
|
header("Location: $_REQUEST[return]");
|
|
} elseif ($parent_album[0] == FALSE) {
|
|
header("Location: ".generate_link('user', $po_user['id'], array(), TRUE));
|
|
} else {
|
|
header("Location: ".generate_link('album', $parent_album[0], array(), TRUE));
|
|
}
|
|
?>
|