po/src/folder.del.php

83 lines
3.2 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/common.php";
include_once "include/site.php";
$database = site_prolog(PO_USER_TYPE_USER);
$folder_id = pg_escape_string($database, $_REQUEST['folder']);
$folder_data = pg_fetch_row(pg_query($database, "select caption, date_of_creation, access_rights, parent_folder, users from folder where folder.identifier='$folder_id'"));
if (($folder_data[4] != $po_user['id']) &&
($po_user['type'] != PO_USER_TYPE_ADMIN)) {
site_referer_error('not_owner');
site_epilog($database);
exit();
}
$folder_stats = pg_fetch_assoc(pg_query($database, "select count_subfolders_by_folder($folder_id, $po_user[id], '{".$passwords."}') as folders, count_photos_by_folder($folder_id, $po_user[id], '{".$passwords."}') as photos"));
$path_to_folder = get_path_to_folder($database, $folder_id);
site_header($strings['generic_delete_folder']);
site_navigator(5);
site_navigator_status(disp_user_string($database, $po_user['id'])." $path_to_folder : ".$strings['generic_delete_folder'], "");
print "&nbsp;<br/>\n";
print "<table class=\"folder\">\n";
print "<tr>";
print emit_th($strings['generic_folder_name'], "width=\"28%\"");
print emit_th($strings['generic_subfolders'], "width=\"5%\"");
print emit_th($strings['generic_photos'], "width=\"5%\"");
print emit_th($strings['generic_created'], "width=\"12%\"");
print emit_th($strings['generic_access'], "width=\"10%\"");
print "</tr>";
print "<tr>";
print emit_td(emit_a(generate_link('folder', $folder_id), $folder_data[0]));
print "<td>$folder_stats[folders]</td>\n";
print "<td>$folder_stats[photos]</td>\n";
print "<td>".emit_date_html($folder_data[1], 'date'). "</td>";
print emit_td($strings['generic_'.$access[$folder_data[2]]]);
print "</tr>";
print "</table>";
print "&nbsp;<br/>\n";
print "<center>\n";
if (($folder_stats['folders'] > 0) || ($folder_stats['photos'] > 0)) {
print $thm_elem['button.cancel'];
} else {
print "<form method=\"post\" action=\"folder.del.2.php\" accept-charset=\"".$strings['formats_encoding']."\">";
print "<input type=\"hidden\" name=\"folder\" value=\"$folder_id\"/>";
print "<input type=\"hidden\" name=\"parent\" value=\"$folder_data[3]\"/>";
print "<input type=\"hidden\" name=\"return\" value=\"$_SERVER[HTTP_REFERER]\"/>";
print $thm_elem['button.confirm.delete'];
print $thm_elem['button.cancel'];
print "</form>";
}
print "</center>\n";
site_footer($database);
site_epilog($database);
?>