po/src/folder.edit.2.php

78 lines
3.1 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";
$folder_id = pg_escape_string($database, $_REQUEST['folder']);
$folder_name = pg_escape_string($database, $_REQUEST['folder_caption']);
$folder_description = pg_escape_string($database, $_REQUEST['folder_description']);
$folder_access_rights = pg_escape_string($database, $_REQUEST['folder_access_rights']);
$parent_folder = pg_escape_string($database, $_REQUEST['parent']);
$password = pg_escape_string($database, $_REQUEST['password']);
$event = pg_escape_string($database, $_REQUEST['event']);
$orderby = pg_escape_string($database, $_REQUEST['order_by']);
$keep_thumb = $_REQUEST['keep_thumb'];
if ($event != "null") $event = "'$event'";
$database = site_prolog(PO_USER_TYPE_USER);
/* Ensure mere users don't edit an folder that isn't theirs! */
if ($po_user['type'] != PO_USER_TYPE_ADMIN) {
$result = pg_query($database, "select identifier from folder where identifier='$folder_id' and users = $po_user[id]");
if (pg_num_rows($result) <= 0) {
site_referer_error('not_owner');
site_epilog($database);
exit();
}
}
if ($keep_thumb != 't') {
$extra = ", thumb_ver = null ";
} else {
$extra = "";
}
if (($folder_id!="") && ($folder_name!="")) {
$result = pg_query($database, "update folder set caption='$folder_name', description='$folder_description', access_rights=$folder_access_rights, parent_folder=$parent_folder, password='$password', event=$event, orderby=$orderby $extra where identifier='$folder_id'");
if (!$result) {
site_push_error($strings['errors_db_insert_failed']);
}
if ($memcache) {
po_log("memcache: delete allfolder.$po_user[id]", PEAR_LOG_DEBUG);
$memcache->delete("allfolder.$po_user[id]");
po_log("memcache: delete path_folder.1.$folder_id", PEAR_LOG_DEBUG);
$memcache->delete("path_folder.1.$folder_id");
po_log("memcache: delete path_folder.0.$folder_id", PEAR_LOG_DEBUG);
$memcache->delete("path_folder.0.$folder_id");
}
}
site_epilog($database);
if (isset($_REQUEST['return'])) {
header("Location: $_REQUEST[return]");
} elseif ($parent_folder == "null") {
header("Location: ".generate_link('user', $po_user['id'], array(), TRUE));
} else {
header("Location: ".generate_link('folder', $parent_folder, array(), TRUE));
}
?>