1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
|
<?php
/*
* This file is part of Zoph.
*
* Zoph 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 2 of the License, or
* (at your option) any later version.
*
* Zoph 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 Zoph; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once("include.inc.php");
$photo_id = getvar("photo_id");
$_off = getvar("_off");
/*
Before deciding to include the Prev and Next links, it was as
simple as this. But now we go through get_photos().
$photo = new photo($photo_id);
*/
$_qs=getvar("_qs");
if($user->prefs->get("auto_edit") && $_qs && $_action == "update") {
header("Location: photo.php?" . $_qs);
}
$qs = preg_replace('/_crumb=\d+&?/', '', $QUERY_STRING);
$qs = preg_replace('/_action=\w+&?/', '', $qs);
$encoded_qs = urlencode(htmlentities($_qs));
if (empty($encoded_qs)) {
$encoded_qs = urlencode(htmlentities($qs));
}
if ($photo_id) { // would be passed for edit or delete
$photo = new photo($photo_id);
}
else { // for display
if (!$_off) { $_off = 0; }
$offset = $_off;
$thumbnails;
$num_photos = get_photos($request_vars, $offset, 1, $thumbnails, $user);
$num_thumbnails = sizeof($thumbnails);
if ($num_thumbnails) {
$photo = $thumbnails[0];
$photo_id = $photo->get("photo_id");
if ($offset > 0) {
$newoffset = $offset - 1;
$prev_link = "<a href=\"$PHP_SELF?" . htmlentities(str_replace("_off=$offset", "_off=$newoffset", $qs)) . "\">" . translate("Prev") . "</a>";
}
if ($offset + 1 < $num_photos) {
$newoffset = $offset + 1;
$next_link = "<a href=\"$PHP_SELF?" . htmlentities(str_replace("_off=$offset", "_off=$newoffset", $qs)) . "\">" . translate("Next") . "</a>";
}
}
else {
$photo = new photo();
}
}
if (isset($offset)) {
$ignore = array("_off", "_action");
# To fix bug #1259152:
# get $_off, round it down to a multiple of cols x rows.
$_cols = getvar("_cols");
$_rows = getvar("_rows");
$_off = getvar("_off");
if (!$_cols) { $_cols = $DEFAULT_COLS; }
if (!$_rows) { $_rows = $DEFAULT_ROWS; }
if (!$_off) { $_off = 0; }
$cells = $_cols * $_rows;
$up_qs = update_query_string($request_vars, null, null, $ignore);
if ($cells) {
$_off = $cells * floor($_off / ($cells));
$up_qs .= "&_off=" . $_off;
}
$up_link = "<a href=\"photos.php?$up_qs\">" . translate("Up", 0) . "</a>";
}
$return_qs=$_qs;
if(empty($return_qs)) {
if ($user->prefs->get("auto_edit")) {
$return_qs=$qs;
} else {
$return_qs = "_action=display&photo_id=" . $photo->get("photo_id");
}
}
if (!$user->is_admin()) {
if ($_action == "new" || $_action == "insert" ||
$_action == "delete" || $_action == "confirm") {
// only an admin can do these
$_action = "display"; // in case redirect fails
header("Location: " . add_sid("zoph.php"));
}
$permissions = $user->get_permissions_for_photo($photo_id);
if (!$permissions) {
$photo = new photo(-1); // in case redirect fails
header("Location: " . add_sid("zoph.php"));
}
else if ($permissions->get("writable") == 0) {
$_action = "display";
}
}
if (EMAIL_PHOTOS) {
$actionlinks["email"]="mail.php?_action=compose&photo_id=" . $photo->get("photo_id");
}
if ($user->is_admin() || $permissions->get("writable")) {
$actionlinks["edit"]="photo.php?_action=edit&photo_id=" . $photo->get("photo_id") . "&_qs=" . $encoded_qs;
}
if ($user->get("lightbox_id")) {
$actionlinks["lightbox"]="photo.php?_action=lightbox&" . $qs;
}
if ((ALLOW_COMMENTS) && ($user->is_admin() || $user->get("leave_comments"))) {
$actionlinks["add comment"]="comment.php?_action=new&photo_id=" . $photo->get("photo_id");
}
if (!$user->prefs->get("auto_edit") && $_action=="edit" ) {
$actionlinks["return"]="photo.php?" . $return_qs;
}
if ($user->is_admin() && $_action!="delete") {
$actionlinks["select"]="photo.php?_action=select&" . $qs;
$actionlinks["delete"]="photo.php?_action=delete&photo_id=" . $photo->get("photo_id") . "&_qs=" . $encoded_qs;
} else if ($_action=="delete") {
unset($actionlinks);
$actionlinks["delete"]="photo.php?_action=confirm&photo_id=" . $photo->get("photo_id") . "&_qs=" . $encoded_qs;
$actionlinks["cancel"]="photo.php?" . $_qs;
}
// jump to edit screen if auto edit pref is set
// permission to edit checked below
if ((!$_action || $_action == "search") && $user->prefs->get("auto_edit")) {
$actionlinks["return"]="photo.php?_action=display&" . $return_qs;
$_action = "edit";
}
// 2005-04-10 --JCT
//
// moved from below so they are allowed
// prior to $user->is_admin() check
//
if ($_action == "lightbox") {
$photo->add_to_album($user->get("lightbox_id"));
$action = "display";
}
else if ($_action == "rate") {
if (ALLOW_RATINGS) {
$rating = getvar("rating");
$photo->rate($user->get("user_id"), $rating);
}
$action = "display";
}
if ($_action == "edit") {
$actionlinks["return"]="photo.php?_action=display&" . $return_qs;
unset($actionlinks["cancel"]);
unset($actionlinks["edit"]);
$action = "update";
}
else if ($_action == "update") {
unset($actionlinks["cancel"]);
unset($actionlinks["edit"]);
$photo->set_fields($request_vars);
$photo->update($request_vars); // pass again for add people, cats, etc
$action = "update";
}
else if ($_action == "new") {
unset($actionlinks);
$actionlinks["cancel"]="photos.php?" . $_qs;
$action = "insert";
}
else if ($_action == "insert") {
$photo->set_fields($request_vars);
$photo->insert();
$action = "update";
unset($actionlinks["email"]);
unset($actionlinks["lightbox"]);
unset($actionlinks["add comment"]);
unset($actionlinks["select"]);
unset($actionlinks["delete"]);
}
else if ($_action == "delete") {
$action = "confirm";
}
else if ($_action == "confirm") {
$photo->delete();
//if (!$user->prefs->get("auto_edit")) {
$user->eat_crumb();
//}
$link = strip_href($user->get_last_crumb());
if (!$link) { $link = "zoph.php"; }
header("Location: " . add_sid($link));
} else if ($_action == "select") {
$sel_key=false;
if(is_array($_SESSION["selected_photo"])) {
$sel_key=array_search($photo_id, $_SESSION["selected_photo"]);
}
if($sel_key === false) {
$_SESSION["selected_photo"][]=$photo->get("photo_id");
}
$action="display";
} else if ($_action == "deselect") {
$sel_key=array_search($photo_id, $_SESSION["selected_photo"]);
if($sel_key !== false) {
unset($_SESSION["selected_photo"][$sel_key]);
}
header("Location: photo.php?" . html_entity_decode(urldecode($_qs)));
// 2005-04-10 --JCT
//
// lightbox and rate actions moved
// to prior to $user->is_admin() check
//
} else {
$action = "display";
}
if ($action != "insert") {
$found = $photo->lookup($user);
$title = $photo->get("name");
$_deg = getvar("_deg");
$_thumbnail = getvar("_thumbnail");
if ($_deg && $_deg != 0) {
if (ALLOW_ROTATIONS) {
$photo->rotate($_deg);
}
} // thumbnails already recreated for rotations
else if ($_thumbnail) {
$photo->thumbnail();
}
}
else {
$title = translate("New Photo");
}
require_once("header.inc.php");
// no photo was found and this isn't a new record
if ($action != "insert" && !$found) {
?>
<h1>
<?php echo translate("photo") ?>
</h1>
<div class="main">
<?php echo translate("No photo was found.") ?>
</div>
<?php
}
else if ($action == "display") {
unset($actionlinks["cancel"]);
unset($actionlinks["return"]);
$title_bar = translate("photo");
if ($num_photos) {
$title_bar .= " " . ($offset + 1) . " of $num_photos";
}
?>
<h1>
<?php
echo create_actionlinks($actionlinks);
?>
<?php echo $title_bar ?>
</h1>
<?php
require_once("selection.inc.php");
?>
<div class="main">
<?php
if (ALLOW_ROTATIONS && ($user->is_admin() || $permissions->get("writable"))) {
?>
<div id="rotate">
<form action="<?php echo $PHP_SELF ?>" method="POST">
<input type="hidden" name="photo_id" value="<?php echo $photo->get("photo_id") ?>">
<select name="_deg">
<option>90</option>
<option>180</option>
<option>270</option>
</select>
<input type="submit" name="_button" value="<?php echo translate("rotate", 0) ?>">
</form>
</div>
<?php
}
?>
<div id="prev"><?php echo $prev_link ? "[ $prev_link ]" : " " ?></div>
<div id="photohdr">
<?php
if ($up_link) {
?>
[ <?php echo $up_link ?> ]<br>
<?php
}
?>
<?php echo $photo->get_fullsize_link($photo->get("name"),$FULLSIZE_NEW_WIN) ?> :
<?php echo $photo->get("width") ?> x <?php echo $photo->get("height") ?>,
<?php echo $photo->get("size") ?> <?php echo translate("bytes") ?>
</div>
<div id="next"><?php echo $next_link ? "[ $next_link ]" : " " ?></div>
<?php echo $photo->get_fullsize_link($photo->get_midsize_img(),$FULLSIZE_NEW_WIN) ?>
<?php
if (($user->is_admin() || $user->get("browse_people")) && $people_links = get_photo_person_links($photo)) {
?>
<div id="personlink">
<?php echo $people_links ?>
</div>
<?php
}
?>
<table id="photo">
<?php echo create_field_html($photo->get_display_array(), 2) ?>
<?php
if (ALLOW_RATINGS || $photo->get("rating")) {
?>
<tr>
<td class="fieldtitle"><?php echo translate("rating") ?></td>
<td class="field">
<form action="<?php echo $PHP_SELF ?>" method="POST">
<?php echo $photo->get("rating") != 0 ? $photo->get("rating") . " / 10" : ""; ?>
<?php
if (ALLOW_RATINGS) {
?>
<input type="hidden" name="_action" value="rate">
<input type="hidden" name="photo_id" value="<?php echo $photo->get("photo_id") ?>">
<input type="submit" name="_button" value="<?php echo translate("rate", 0) ?>">
<?php echo create_rating_pulldown($photo->get_rating($user->get("user_id"))); ?>
<?php
}
?>
</form>
</td>
</tr>
<?php
}
if ($album_links = create_link_list($photo->lookup_albums($user))) {
?>
<tr>
<td class="fieldtitle"><?php echo translate("albums") ?></td>
<td class="field"><?php echo $album_links ?></td>
</tr>
<?php
}
if ($category_links = create_link_list($photo->lookup_categories())) {
?>
<tr>
<td class="fieldtitle"><?php echo translate("categories") ?></td>
<td class="field"><?php echo $category_links ?></td>
</tr>
<?php
}
?>
<tr>
<td class="fieldtitle"><?php echo translate("last modified") ?></td>
<td class="field"><?php echo format_timestamp($photo->get("timestamp")) ?></td>
</tr>
<tr>
<td colspan="2" class="photodesc">
<?php
if ($photo->get("description")) {
echo $photo->get("description");
}
?>
</td>
</tr>
<?php
if ($user->prefs->get("camera_info")) {
echo create_field_html($photo->get_camera_display_array(), 2);
echo "</table>\n";
}
$related=$photo->get_related();
if ($related) {
$header="<h2>" . translate("related photos") . "</h2>";
$i=0;
foreach($related as $rel_photo) {
$rel_photo->lookup();
if ($user->get_permissions_for_photo($rel_photo->get("photo_id")) || $user->is_admin()) {
echo $header; // Makes sure that header is only
unset($header); // displayed when there are photos
echo "<div class=\"thumbnail\">";
if($user->is_admin()) {
echo "<span class=\"actionlink\">";
echo "<a href=\"relation.php?photo_id_1=" .
$photo->get("photo_id") . "&" . "photo_id_2=" .
$rel_photo->get("photo_id") . "\">edit</a>";
echo "</span>";
}
echo $rel_photo->get_thumbnail_link() . "<br>";
echo $photo->get_relation_desc($rel_photo->get("photo_id"));
echo "</div>";
$i++;
if($i>=5) { echo "<br>"; $i=0; }
}
}
echo "<br>";
}
if (ALLOW_COMMENTS) {
$comments=$photo->get_comments();
if($comments) {
echo "<h2>" . translate("comments") . "</h2>\n";
foreach($comments as $comment) {
echo $comment->to_html($user) . "\n";
}
echo "<br> \n";
}
}
}
else if ($action == "confirm") {
?>
<h1><?php echo translate("photo") ?></h1>
<div class="main">
<?php
echo create_actionlinks($actionlinks);
?>
<?php echo sprintf(translate("Confirm deletion of '%s'"), $photo->get("name")) ?>
<?php
}
else {
require_once("edit_photo.inc.php");
}
?>
</div>
<?php require_once("footer.inc.php"); ?>
|