234 lines
7.6 KiB
PHP
234 lines
7.6 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/orderby.php";
|
|
include_once "include/site.php";
|
|
|
|
$database = site_prolog();
|
|
|
|
$album_id = pg_escape_string($database, $_REQUEST['album']);
|
|
$offset = pg_escape_string($database, isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0);
|
|
|
|
if ($offset && !is_numeric($offset)) {
|
|
$offset = 0;
|
|
}
|
|
|
|
$album = FALSE;
|
|
|
|
if ($album_id && is_numeric($album_id)) {
|
|
$album = pg_fetch_row(pg_query($database, "select caption, access_rights, users, description, can_access_album(album.identifier, $po_user[id], '{".$passwords."}'), orderby from album, users where album.identifier=$album_id and users.identifier = album.users"));
|
|
}
|
|
|
|
if (!$album) {
|
|
header("HTTP/1.1 404 Not found");
|
|
site_header($strings['generic_display_album']);
|
|
site_navigator(5);
|
|
site_navigator_status(disp_user_string($database, 0). " : ". $strings['errors_no_such_album'], "");
|
|
site_footer($database);
|
|
site_epilog($database);
|
|
exit();
|
|
}
|
|
|
|
if ($album[4] == 'f') {
|
|
if ($album[1] == $access['private']) {
|
|
header("HTTP/1.1 403 Forbidden");
|
|
site_header($strings['generic_display_folder']);
|
|
site_navigator(1);
|
|
site_navigator_status(disp_user_string($database, 0). " : ". $strings['errors_private'], "");
|
|
site_footer($database);
|
|
site_epilog($database);
|
|
} else {
|
|
site_push_error($strings['errors_protected']);
|
|
header("Location: $site_url/login.php?reason=protected&orig=".urlencode(generate_link('album', $album_id)));
|
|
}
|
|
exit();
|
|
}
|
|
|
|
/* get the last value from the database */
|
|
$album_name = $album[0];
|
|
$owner_id = $album[2];
|
|
|
|
$order_by = $po_options['order_by'];
|
|
|
|
/* Set up album order/view */
|
|
$order_by = $album[5];
|
|
if (isset($po_options["album_".$album_id."_order"])) {
|
|
$order_by = $po_options["album_".$album_id."_order"];
|
|
}
|
|
if ($order_by === FALSE || !isset($order_by_string[$order_by])) {
|
|
$order_by = $po_options['order_by'];
|
|
}
|
|
$photo_view = FALSE;
|
|
if (isset($po_options["album_".$album_id."_view"])) {
|
|
$photo_view = $po_options["album_".$album_id."_view"];
|
|
}
|
|
if ($photo_view === FALSE) {
|
|
$photo_view = $po_options['photo_view'];
|
|
}
|
|
|
|
$rss = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"$site_title : $album_name - RSS\" href=\"$site_url/feed.php?type=photos&subtype=album&id=$album_id\" />";
|
|
$rss .= "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"$site_title : $album_name - RSS Albums\" href=\"$site_url/feed.php?type=album&subtype=user&id=$owner_id\" />";
|
|
|
|
site_header($album_name, "", $rss);
|
|
|
|
$user_display_string = disp_user_string($database, $owner_id);
|
|
|
|
if ($po_user['id'] == $owner_id) {
|
|
site_navigator(5);
|
|
} else {
|
|
site_navigator(1);
|
|
}
|
|
|
|
$froms = array('album_content');
|
|
$filter = "photo_version.identifier = album_content.version
|
|
and photo.identifier = album_content.photo
|
|
and album_content.album = $album_id";
|
|
|
|
$num_of_photos = get_photo_count($database, $froms, $filter);
|
|
|
|
if ($photo_view == "slide") {
|
|
$limit = $po_options['photos_per_page'];
|
|
} else {
|
|
$limit = $po_options['rows_list_view'];
|
|
}
|
|
|
|
/* Sanity checks */
|
|
if ($limit > $num_of_photos) {
|
|
$limit = $num_of_photos;
|
|
}
|
|
while ($num_of_photos && $offset >= $num_of_photos) {
|
|
$offset -= $limit;
|
|
}
|
|
if ($offset < 0) {
|
|
$offset = 0;
|
|
}
|
|
if (($offset + $limit) > $num_of_photos) {
|
|
$items = $num_of_photos - $offset;
|
|
} else {
|
|
$items = $limit;
|
|
}
|
|
|
|
$path_to_album = get_path_to_album($database, $album_id);
|
|
|
|
if (($po_user['id'] == $owner_id) &&
|
|
($album_id != $po_user['spool_album']))
|
|
$edit_album = "[<a href=\"album.edit.php?album=$album_id\">".$strings['generic_edit']."</a>]";
|
|
else
|
|
$edit_album = "";
|
|
|
|
if ($num_of_photos == 0) {
|
|
site_navigator_status("$user_display_string $path_to_album $edit_album", $strings['generic_is_empty']);
|
|
} else {
|
|
site_navigator_status("$user_display_string $path_to_album $edit_album", $strings['generic_displaying'] . " " . display_photo_index_status($offset, $limit, $num_of_photos));
|
|
}
|
|
|
|
if ($album[3]) {
|
|
print emit_folder_comment($album[3]);
|
|
}
|
|
|
|
if ($album_id != $po_user['spool_album']) {
|
|
display_albums($database, "$album_id", $album[2]);
|
|
}
|
|
|
|
if ($num_of_photos == 0) {
|
|
site_footer($database);
|
|
site_epilog($database);
|
|
exit();
|
|
}
|
|
|
|
$album_photo = get_photo_query($database, array(), $froms, $filter, $offset, $limit, $order_by);
|
|
|
|
print "<form name=\"photoList\" method=\"post\" action=\"folder.content.php\" accept-charset=\"".$strings['formats_encoding']."\">";
|
|
print "<input type=\"hidden\" name=\"user\" value=\"$owner_id\"/>";
|
|
print "<input type=\"hidden\" name=\"return\" value=\"".generate_link('album', $album_id, array('offset'=>$offset))."\"/>";
|
|
print "<input type=\"hidden\" name=\"photo_view\" value=\"$photo_view\"/>";
|
|
print "<input type=\"hidden\" name=\"source_album\" value=\"$album_id\"/>";
|
|
|
|
display_photo_navigator(generate_link('album', $album_id), $offset, $limit, $num_of_photos);
|
|
if ($photo_view == "slide") {
|
|
$checkboxes = display_photo_slides("album", $album_id, $album_photo, 0, $items, true, true);
|
|
} else {
|
|
$checkboxes = display_photo_list("album", $album_id, $album_photo, 0, $items);
|
|
}
|
|
display_photo_navigator(generate_link('album', $album_id), $offset, $limit, $num_of_photos);
|
|
|
|
site_navigator_status("$user_display_string $path_to_album : $album[0]", $strings['generic_displaying'] . " " . display_photo_index_status($offset, $limit, $num_of_photos));
|
|
|
|
print "<div class=\"actions\">";
|
|
|
|
if ($checkboxes !== FALSE) {
|
|
display_order_by_combo_with_button($order_by);
|
|
if ($photo_view == 'slide') {
|
|
print emit_photos_per_page_combo('photos_per_page', $po_options['photos_per_page']);
|
|
} else {
|
|
print emit_photos_per_page_combo('rows_list_view', $po_options['rows_list_view']);
|
|
}
|
|
print emit_transform_actions();
|
|
}
|
|
|
|
print "<span>\n";
|
|
|
|
|
|
if ($checkboxes !== FALSE) {
|
|
display_list_slide_option($photo_view, generate_link('album', $album_id, array('offset'=>$offset)));
|
|
}
|
|
|
|
if ($checkboxes && ($po_user['type'] >= PO_USER_TYPE_CLIENT)) {
|
|
theme_display_selectButton();
|
|
if ($album_id != $po_user['spool_album']) {
|
|
print $thm_elem['button.add.to.spool'];
|
|
}
|
|
}
|
|
|
|
if ($checkboxes && (($po_user['id'] == $owner_id) ||
|
|
($po_user['type'] == PO_USER_TYPE_ADMIN))) {
|
|
print $thm_elem['button.bulk.update'];
|
|
print $thm_elem['button.delete_s'];
|
|
}
|
|
|
|
print "</span>";
|
|
|
|
if ($checkboxes) {
|
|
if (($po_user['id'] == $owner_id) ||
|
|
($po_user['type'] == PO_USER_TYPE_ADMIN)) {
|
|
$folder_all = get_users_folder($database);
|
|
print emit_folder_actions($folder_all, "");
|
|
}
|
|
$album_all = get_users_album($database);
|
|
if (count($album_all)) {
|
|
print emit_album_actions($album_all, $album_id);
|
|
}
|
|
}
|
|
|
|
if ($po_user['type'] >= PO_USER_TYPE_CLIENT) {
|
|
print emit_spool_actions($database, $po_user['id']);
|
|
print emit_import_actions($database, $po_user['id']);
|
|
print emit_print_actions($database, $po_user['id']);
|
|
}
|
|
|
|
print "</div>";
|
|
|
|
print "</form>\n";
|
|
|
|
site_footer($database);
|
|
site_epilog($database);
|
|
?>
|