// +----------------------------------------------------------------------+
// | Copyright (c) 2004 |
// | author: Jason Taylor |
// | Neo-era : mofocases |
// | view_images.php |
// +----------------------------------------------------------------------+
/**
* Displays images for a case
*
* @package www
*/
/**
*/
/* $Id: view_gallery_images.php,v 1.1 2010/10/30 21:48:35 catherine Exp $*/
$GALLERY = true;
include "../../includes/config.inc.php";
include BASEDIR . "includes/bike_gallery.inc.php";
$image_id = nBase::get_value("image_id", $_GET, NULL, 0, 1, null, 'xss');
$single = nBase::get_value("single", $_GET, NULL, 0, null, null, 'xss');
$limit = nBase::get_value("limit", $_GET, NULL, 0, \nBase::VALIDATE_POSITIVE_INT, null, 'xss');
$order = nBase::get_value("order", $_GET, NULL, "new", null, null, 'xss');
$submit = nBase::get_value("submit", $_GET, NULL, false);
$image = db_get_image($image_id);
db_add_popular_image($image_id);
if ($image->status != "approved" && USERID !=$image->user_id && !ISADMIN) {
$smarty->assign("error","You can not view this non approved image.");
$smarty->display(TEMPLATE_DIR . "gallery_template.tpl.smrt");
die();
}
if ($submit && $vote = nBase::get_value("vote", $_GET, NULL, 0, 1)) {
if (!USERID) {
$smarty->assign("error","You must be logged in as a registered user to vote on an image.");
}
elseif ($image->user_id == USERID) {
$smarty->assign("error","You can not vote for a case you own.");
} else {
db_save_image_vote($image_id, USERID, $vote);
$smarty->assign("message","Vote Accepted.
");
// need to reupdate vote fields
$image = db_get_image($image_id);
}
}
// we want to add next/previous buttons and thumbnails for images
if (!$single) {
$closelimit = $limit - 2;
if ($closelimit < 0) {
$closelimit = 0;
}
list ($closeimages, $imagenum) = db_get_images($image->type, 0, $closelimit, $order);
}
if ($image->rank - floor($image->rank) > .5) {
$rank_image = "rank_" . floor($image->rank) . "_5.jpg";
} else {
$rank_image = "rank_" . floor($image->rank) . "_0.jpg";
}
$smarty->assign("rank_image", $rank_image);
$smarty->assign("CASEDISPLAY", true);
$smarty->assign("limit",$limit);
$smarty->assign("page",floor($limit/20) + 1);
$smarty->assign("order",$order);
$smarty->assign("closelimit",$closelimit);
$smarty->assign("closeimages",$closeimages);
$smarty->assign("single",$single);
$smarty->assign("image", $image);
$smarty->assign("PAGETITLE","View Gallery Images");
$smarty->assign("page_tpl",TEMPLATE_DIR . "gallery/view_gallery_images.tpl.smrt");
$smarty->display(TEMPLATE_DIR . "gallery_template.tpl.smrt");