Gazelle/sections/requests/request.php

633 lines
22 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
/*
* This is the page that displays the request to the end user after being created.
*/
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
2011-03-28 14:21:28 +00:00
include(SERVER_ROOT.'/classes/class_text.php');
2012-06-22 08:00:10 +00:00
include(SERVER_ROOT.'/classes/class_image_tools.php');
2011-03-28 14:21:28 +00:00
$Text = new TEXT;
if(empty($_GET['id']) || !is_number($_GET['id'])) {
error(0);
}
$RequestID = $_GET['id'];
//First things first, lets get the data for the request.
2012-10-11 08:00:15 +00:00
$Request = Requests::get_requests(array($RequestID));
2011-03-28 14:21:28 +00:00
$Request = $Request['matches'][$RequestID];
if(empty($Request)) {
error(404);
}
2012-02-03 08:00:22 +00:00
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel, $ReleaseType,
2012-06-02 08:00:16 +00:00
$BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled, $GroupID, $OCLC) = $Request;
2011-03-28 14:21:28 +00:00
//Convenience variables
$IsFilled = !empty($TorrentID);
$CanVote = (empty($TorrentID) && check_perms('site_vote'));
if($CategoryID == 0) {
$CategoryName = "Unknown";
} else {
$CategoryName = $Categories[$CategoryID - 1];
}
//Do we need to get artists?
if($CategoryName == "Music") {
$ArtistForm = get_request_artists($RequestID);
2012-10-11 08:00:15 +00:00
$ArtistName = Artists::display_artists($ArtistForm, false, true);
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
2011-03-28 14:21:28 +00:00
if($IsFilled) {
$DisplayLink = $ArtistLink."<a href='torrents.php?torrentid=".$TorrentID."'>".$Title."</a> [".$Year."]";
} else {
$DisplayLink = $ArtistLink.$Title." [".$Year."]";
}
$FullName = $ArtistName.$Title." [".$Year."]";
if($BitrateList != "") {
$BitrateString = implode(", ", explode("|", $BitrateList));
$FormatString = implode(", ", explode("|", $FormatList));
$MediaString = implode(", ", explode("|", $MediaList));
} else {
$BitrateString = "Unknown, please read the description.";
$FormatString = "Unknown, please read the description.";
$MediaString = "Unknown, please read the description.";
}
if(empty($ReleaseType)) {
$ReleaseName = "Unknown";
} else {
$ReleaseName = $ReleaseTypes[$ReleaseType];
}
} else if($CategoryName == "Audiobooks" || $CategoryName == "Comedy") {
$FullName = $Title." [".$Year."]";
$DisplayLink = $Title." [".$Year."]";
} else {
$FullName = $Title;
$DisplayLink = $Title;
}
//Votes time
$RequestVotes = get_votes_array($RequestID);
$VoteCount = count($RequestVotes['Voters']);
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID == 0) || ($CategoryName == "Music" && $Year == 0)));
$UserCanEdit = (!$IsFilled && $LoggedUser['ID'] == $RequestorID && $VoteCount < 2);
$CanEdit = ($UserCanEdit || $ProjectCanEdit || check_perms('site_moderate_requests'));
2012-10-11 08:00:15 +00:00
View::show_header('View request: '.$FullName, 'comments,requests,bbcode');
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
2012-08-19 08:00:19 +00:00
<div class="header">
<h2><a href="requests.php">Requests</a> &gt; <?=$CategoryName?> &gt; <?=$DisplayLink?></h2>
<div class="linkbox">
2011-03-28 14:21:28 +00:00
<? if($CanEdit) { ?>
2012-08-19 08:00:19 +00:00
<a href="requests.php?action=edit&amp;id=<?=$RequestID?>">[Edit]</a>
2011-03-28 14:21:28 +00:00
<? }
if($UserCanEdit || check_perms('users_mod')) { //check_perms('site_moderate_requests')) { ?>
2012-08-19 08:00:19 +00:00
<a href="requests.php?action=delete&amp;id=<?=$RequestID?>">[Delete]</a>
2011-03-28 14:21:28 +00:00
<? } ?>
<? if(has_bookmarked('request', $RequestID)) { ?>
2012-08-19 08:00:19 +00:00
<a href="#" id="bookmarklink_request_<?=$RequestID?>" onclick="Unbookmark('request', <?=$RequestID?>,'[Bookmark]');return false;">[Remove bookmark]</a>
<? } else { ?>
2012-08-19 08:00:19 +00:00
<a href="#" id="bookmarklink_request_<?=$RequestID?>" onclick="Bookmark('request', <?=$RequestID?>,'[Remove bookmark]');return false;">[Bookmark]</a>
<? } ?>
2012-10-27 08:00:09 +00:00
<a href="reports.php?action=report&amp;type=request&amp;id=<?=$RequestID?>">[Report Request]</a>
2012-04-22 08:00:26 +00:00
<? if(!$IsFilled) { ?>
2012-10-27 08:00:09 +00:00
<a href="upload.php?requestid=<?=$RequestID?><?=($GroupID?"&groupid=$GroupID":'')?>">[Upload Request]</a>
2012-04-22 08:00:26 +00:00
<? }
if(!$IsFilled && (($CategoryID == 0) || ($CategoryName == "Music" && $Year == 0))) { ?>
2012-10-27 08:00:09 +00:00
<a href="reports.php?action=report&amp;type=request_update&amp;id=<?=$RequestID?>">[Request Update]</a>
2011-03-28 14:21:28 +00:00
<? } ?>
2012-06-23 08:00:13 +00:00
<?
//create a search url to worldcat and google based on title
$encoded_title = urlencode(preg_replace("/\([^\)]+\)/", "", $Title));
$encoded_artist = substr(str_replace("&amp;","and",$ArtistName), 0, -3);
$encoded_artist = str_ireplace("Performed By", "", $encoded_artist);
$encoded_artist = preg_replace("/\([^\)]+\)/", "", $encoded_artist);
$encoded_artist = urlencode($encoded_artist);
$worldcat_url = "http://worldcat.org/search?q=" . $encoded_artist . " " . $encoded_title;
2012-10-27 08:00:09 +00:00
$google_url = "https://www.google.com/search?&tbm=shop&q=" . $encoded_artist . " " . $encoded_title;
2012-06-23 08:00:13 +00:00
?>
2012-10-27 08:00:09 +00:00
<a href="<? echo $worldcat_url; ?>">[Find in Library]</a>
<a href="<? echo $google_url; ?>">[Find in Stores]</a>
2012-08-19 08:00:19 +00:00
</div>
</div>
2011-03-28 14:21:28 +00:00
<div class="sidebar">
<? if($CategoryID != 0) { ?>
2012-08-17 08:00:13 +00:00
<div class="box box_image box_image_albumart box_albumart"><!-- .box_albumart deprecated -->
2011-03-28 14:21:28 +00:00
<div class="head"><strong>Cover</strong></div>
2012-05-04 08:00:14 +00:00
<?
if (!empty($Image)) {
if(check_perms('site_proxy_images')) {
$Image = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($Image);
}
?>
2012-06-22 08:00:10 +00:00
<p align="center"><img style="max-width: 220px;" src="<?=to_thumbnail($Image)?>" alt="<?=$FullName?>" onclick="lightbox.init('<?=$Image?>',220);" /></p>
2011-03-28 14:21:28 +00:00
<? } else { ?>
<p align="center"><img src="<?=STATIC_SERVER?>common/noartwork/<?=$CategoryIcons[$CategoryID-1]?>" alt="<?=$CategoryName?>" title="<?=$CategoryName?>" width="220" height="220" border="0" /></p>
<? } ?>
</div>
<? }
if($CategoryName == "Music") { ?>
<div class="box box_artists">
<div class="head"><strong>Artists</strong></div>
<ul class="stats nobullet">
<?
2011-11-20 08:00:18 +00:00
if(!empty($ArtistForm[4]) && count($ArtistForm[4]) > 0) {
?>
<li class="artists_composer"><strong>Composers:</strong></li>
<? foreach($ArtistForm[4] as $Artist) {
?>
<li class="artists_composer">
2012-10-11 08:00:15 +00:00
<?=Artists::display_artist($Artist)?>
2011-11-20 08:00:18 +00:00
</li>
<? }
}
if(!empty($ArtistForm[6]) && count($ArtistForm[6]) > 0) {
?>
<li class="artists_dj"><strong>DJ / Compiler:</strong></li>
<? foreach($ArtistForm[6] as $Artist) {
2011-03-28 14:21:28 +00:00
?>
2011-11-20 08:00:18 +00:00
<li class="artists_dj">
2012-10-11 08:00:15 +00:00
<?=Artists::display_artist($Artist)?>
2011-03-28 14:21:28 +00:00
</li>
<?
2011-11-20 08:00:18 +00:00
}
2011-03-28 14:21:28 +00:00
}
2011-11-20 08:00:18 +00:00
if ((count($ArtistForm[6]) > 0) && (count($ArtistForm[1]) > 0)) {
print ' <li class="artists_main"><strong>Artists:</strong></li>';
} elseif ((count($ArtistForm[4]) > 0) && (count($ArtistForm[1]) > 0)) {
print ' <li class="artists_main"><strong>Performers:</strong></li>';
}
foreach($ArtistForm[1] as $Artist) {
?>
<li class="artists_main">
2012-10-11 08:00:15 +00:00
<?=Artists::display_artist($Artist)?>
2011-11-20 08:00:18 +00:00
</li>
<? }
2011-03-28 14:21:28 +00:00
if(!empty($ArtistForm[2]) && count($ArtistForm[2]) > 0) {
?>
<li class="artists_with"><strong>With:</strong></li>
<? foreach($ArtistForm[2] as $Artist) {
2011-11-20 08:00:18 +00:00
?>
<li class="artists_with">
2012-10-11 08:00:15 +00:00
<?=Artists::display_artist($Artist)?>
2011-11-20 08:00:18 +00:00
</li>
<? }
}
if(!empty($ArtistForm[5]) && count($ArtistForm[5]) > 0) {
?>
<li class="artists_conductor"><strong>Conducted by:</strong></li>
<? foreach($ArtistForm[5] as $Artist) {
2011-03-28 14:21:28 +00:00
?>
<li class="artist_guest">
2012-10-11 08:00:15 +00:00
<?=Artists::display_artist($Artist)?>
2011-03-28 14:21:28 +00:00
</li>
2011-11-20 08:00:18 +00:00
<? }
2011-03-28 14:21:28 +00:00
}
if(!empty($ArtistForm[3]) && count($ArtistForm[3]) > 0) {
?>
<li class="artists_remix"><strong>Remixed by:</strong></li>
<? foreach($ArtistForm[3] as $Artist) {
2012-02-19 08:00:19 +00:00
?>
<li class="artists_remix">
2012-10-11 08:00:15 +00:00
<?=Artists::display_artist($Artist)?>
2012-02-19 08:00:19 +00:00
</li>
<?
}
}
if(!empty($ArtistForm[7]) && count($ArtistForm[7]) > 0) {
?>
<li class="artists_producer"><strong>Produced by:</strong></li>
<? foreach($ArtistForm[7] as $Artist) {
2011-03-28 14:21:28 +00:00
?>
2011-11-20 08:00:18 +00:00
<li class="artists_remix">
2012-10-11 08:00:15 +00:00
<?=Artists::display_artist($Artist)?>
2011-03-28 14:21:28 +00:00
</li>
<?
}
}
?>
</ul>
</div>
<? } ?>
<div class="box box_tags">
<div class="head"><strong>Tags</strong></div>
<ul class="stats nobullet">
<? foreach($Request['Tags'] as $TagID => $TagName) { ?>
<li>
<a href="torrents.php?taglist=<?=$TagName?>"><?=display_str($TagName)?></a>
<br style="clear:both" />
</li>
<? } ?>
</ul>
</div>
<div class="box box_votes">
2012-10-27 08:00:09 +00:00
<div class="head"><strong>Top Contributors</strong></div>
2012-09-01 08:00:24 +00:00
<table class="layout">
2011-03-28 14:21:28 +00:00
<? $VoteMax = ($VoteCount < 5 ? $VoteCount : 5);
2011-11-13 08:00:16 +00:00
$ViewerVote = false;
2011-03-28 14:21:28 +00:00
for($i = 0; $i < $VoteMax; $i++) {
$User = array_shift($RequestVotes['Voters']);
2011-11-13 08:00:16 +00:00
$Boldify = false;
if ($User['UserID'] == $LoggedUser['ID']) {
$ViewerVote = true;
$Boldify = true;
}
2011-03-28 14:21:28 +00:00
?>
<tr>
<td>
2011-11-13 08:00:16 +00:00
<a href="user.php?id=<?=$User['UserID']?>"><?=$Boldify?'<strong>':''?><?=display_str($User['Username'])?><?=$Boldify?'</strong>':''?></a>
2011-03-28 14:21:28 +00:00
</td>
<td>
2012-10-11 08:00:15 +00:00
<?=$Boldify?'<strong>':''?><?=Format::get_size($User['Bounty'])?><?=$Boldify?'</strong>':''?>
2011-03-28 14:21:28 +00:00
</td>
</tr>
<? }
reset($RequestVotes['Voters']);
2011-11-13 08:00:16 +00:00
if (!$ViewerVote) {
foreach ($RequestVotes['Voters'] as $User) {
if ($User['UserID'] == $LoggedUser['ID']) { ?>
<tr>
<td>
<a href="user.php?id=<?=$User['UserID']?>"><strong><?=display_str($User['Username'])?></strong></a>
</td>
<td>
2012-10-11 08:00:15 +00:00
<strong><?=Format::get_size($User['Bounty'])?></strong>
2011-11-13 08:00:16 +00:00
</td>
</tr>
<? }
}
}
2011-03-28 14:21:28 +00:00
?>
</table>
</div>
</div>
<div class="main_column">
2012-09-01 08:00:24 +00:00
<table class="layout">
2011-03-28 14:21:28 +00:00
<tr>
<td class="label">Created</td>
<td>
2012-10-11 08:00:15 +00:00
<?=time_diff($TimeAdded)?> by <strong><?=Users::format_username($RequestorID, false, false, false)?></strong>
2011-03-28 14:21:28 +00:00
</td>
2012-07-08 08:00:09 +00:00
</tr>
2011-03-28 14:21:28 +00:00
<? if($CategoryName == "Music") {
2012-02-03 08:00:22 +00:00
if(!empty($RecordLabel)) { ?>
<tr>
2012-10-27 08:00:09 +00:00
<td class="label">Record Label</td>
2012-02-03 08:00:22 +00:00
<td>
<?=$RecordLabel?>
</td>
</tr>
<? }
2011-03-28 14:21:28 +00:00
if(!empty($CatalogueNumber)) { ?>
<tr>
2012-10-27 08:00:09 +00:00
<td class="label">Catalogue Number</td>
2011-03-28 14:21:28 +00:00
<td>
<?=$CatalogueNumber?>
</td>
</tr>
<? } ?>
<tr>
2012-10-27 08:00:09 +00:00
<td class="label">Release Type</td>
2011-03-28 14:21:28 +00:00
<td>
<?=$ReleaseName?>
</td>
</tr>
<tr>
2012-10-27 08:00:09 +00:00
<td class="label">Acceptable Bitrates</td>
2011-03-28 14:21:28 +00:00
<td>
<?=$BitrateString?>
</td>
</tr>
<tr>
2012-10-27 08:00:09 +00:00
<td class="label">Acceptable Formats</td>
2011-03-28 14:21:28 +00:00
<td>
<?=$FormatString?>
</td>
</tr>
<tr>
2012-10-27 08:00:09 +00:00
<td class="label">Acceptable Media</td>
2011-03-28 14:21:28 +00:00
<td>
<?=$MediaString?>
</td>
</tr>
<? if(!empty($LogCue)) { ?>
<tr>
2012-10-27 08:00:09 +00:00
<td class="label">Required FLAC only extra(s)</td>
2011-03-28 14:21:28 +00:00
<td>
<?=$LogCue?>
</td>
</tr>
<? }
2012-06-02 08:00:16 +00:00
}
$Worldcat = "";
$OCLC = str_replace(" ", "", $OCLC);
if ($OCLC != "") {
$OCLCs = explode(",", $OCLC);
for ($i = 0; $i < count($OCLCs); $i++) {
if (!empty($Worldcat)) {
$Worldcat .= ', <a href="http://www.worldcat.org/oclc/'.$OCLCs[$i].'">'.$OCLCs[$i].'</a>';
} else {
$Worldcat = '<a href="http://www.worldcat.org/oclc/'.$OCLCs[$i].'">'.$OCLCs[$i].'</a>';
}
}
}
if (!empty($Worldcat)) { ?>
<tr>
<td class="label">WorldCat (OCLC) ID</td>
<td>
<?=$Worldcat?>
</td>
</tr>
<? }
if ($GroupID) {
2012-10-11 08:00:15 +00:00
/*$Groups = Torrents::get_groups(array($GroupID), true, true, false);
2012-02-20 08:00:22 +00:00
$Group = $Groups['matches'][$GroupID];
2012-10-11 08:00:15 +00:00
$GroupLink = Artists::display_artists($Group['ExtendedArtists']).'<a href="torrents.php?id='.$GroupID.'">'.$Group['Name'].'</a>';*/
2012-02-20 08:00:22 +00:00
?>
<tr>
2012-10-27 08:00:09 +00:00
<td class="label">Torrent Group</td>
<td><a href="torrents.php?id=<?=$GroupID?>">torrents.php?id=<?=$GroupID?></td>
2012-02-20 08:00:22 +00:00
</tr>
<? } ?>
2011-03-28 14:21:28 +00:00
<tr>
<td class="label">Votes</td>
<td>
<span id="votecount"><?=$VoteCount?></span>
<? if($CanVote) { ?>
&nbsp;<a href="javascript:Vote(0)"><strong>(+)</strong></a>
2012-10-11 08:00:15 +00:00
<strong>Costs <?=Format::get_size($MinimumVote, 0)?></strong>
2011-03-28 14:21:28 +00:00
<? } ?>
</td>
</tr>
2012-07-08 08:00:09 +00:00
<? if ($LastVote > $TimeAdded) { ?>
<tr>
2012-10-27 08:00:09 +00:00
<td class="label">Last Voted</td>
2012-07-08 08:00:09 +00:00
<td>
<?=time_diff($LastVote)?>
</td>
</tr>
<? } ?>
2011-03-28 14:21:28 +00:00
<? if($CanVote) { ?>
<tr id="voting">
2012-10-14 08:00:20 +00:00
<td class="label" title="These units are in base 2, not base 10. For example, there are 1,024 MB in 1 GB.">Custom vote (MB)</td>
2011-03-28 14:21:28 +00:00
<td>
<input type="text" id="amount_box" size="8" onchange="Calculate();" />
<select id="unit" name="unit" onchange="Calculate();">
<option value='mb'>MB</option>
<option value='gb'>GB</option>
</select>
2012-09-19 08:00:35 +00:00
<input type="button" value="Preview" onclick="Calculate();" />
2011-03-28 14:21:28 +00:00
<strong><?=($RequestTax * 100)?>% of this is deducted as tax by the system.</strong>
</td>
</tr>
<tr>
<td class="label">Post vote information</td>
<td>
2012-09-15 08:00:25 +00:00
<form class="add_form" name="request" action="requests.php" method="get" id="request_form">
2011-03-28 14:21:28 +00:00
<input type="hidden" name="action" value="vote" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" id="request_tax" value="<?=$RequestTax?>" />
<input type="hidden" id="requestid" name="id" value="<?=$RequestID?>" />
<input type="hidden" id="auth" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
2012-09-19 08:00:35 +00:00
<input type="hidden" id="amount" name="amount" value="0" />
2011-03-28 14:21:28 +00:00
<input type="hidden" id="current_uploaded" value="<?=$LoggedUser['BytesUploaded']?>" />
<input type="hidden" id="current_downloaded" value="<?=$LoggedUser['BytesDownloaded']?>" />
2012-04-10 08:00:20 +00:00
<input type="hidden" id="current_rr" value="<?=(float)$LoggedUser['RequiredRatio']?>" />
2011-03-28 14:21:28 +00:00
<input id="total_bounty" type="hidden" value="<?=$RequestVotes['TotalBounty']?>" />
If you add the entered <strong><span id="new_bounty">0.00 MB</span></strong> of bounty, your new stats will be: <br/>
2012-10-11 08:00:15 +00:00
Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span>
Ratio: <span id="new_ratio"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'],$LoggedUser['BytesDownloaded'])?></span>
2012-09-19 08:00:35 +00:00
<input type="button" id="button" value="Vote!" disabled="disabled" onclick="Vote();" />
2011-03-28 14:21:28 +00:00
</form>
</td>
</tr>
<? }?>
<tr id="bounty">
<td class="label">Bounty</td>
2012-10-11 08:00:15 +00:00
<td id="formatted_bounty"><?=Format::get_size($RequestVotes['TotalBounty'])?></td>
2011-03-28 14:21:28 +00:00
</tr>
<?
if($IsFilled) {
$TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
?>
<tr>
<td class="label">Filled</td>
<td>
<strong><a href="torrents.php?<?=(strtotime($TimeFilled)<$TimeCompare?'id=':'torrentid=').$TorrentID?>">Yes</a></strong>,
2012-10-11 08:00:15 +00:00
by user <?=Users::format_username($FillerID, false, false, false)?>
2011-03-28 14:21:28 +00:00
<? if($LoggedUser['ID'] == $RequestorID || $LoggedUser['ID'] == $FillerID || check_perms('site_moderate_requests')) { ?>
<strong><a href="requests.php?action=unfill&amp;id=<?=$RequestID?>">(Unfill)</a></strong> Unfilling a request without a valid, nontrivial reason will result in a warning.
<? } ?>
</td>
</tr>
<? } else { ?>
<tr>
<td class="label" valign="top">Fill request</td>
<td>
2012-09-15 08:00:25 +00:00
<form class="edit_form" name="request" action="" method="post">
2011-03-28 14:21:28 +00:00
<div>
<input type="hidden" name="action" value="takefill" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="requestid" value="<?=$RequestID?>" />
<input type="text" size="50" name="link" <?=(!empty($Link) ? "value='$Link' " : '')?>/>
<strong>Should be the permalink (PL) to the torrent (e.g. http://<?=NONSSL_SITE_URL?>/torrents.php?torrentid=xxxx).</strong>
<br />
<br />
<? if(check_perms('site_moderate_requests')) { ?> For User: <input type="text" size="25" name="user" <?=(!empty($FillerUsername) ? "value='$FillerUsername' " : '')?>/>
<br />
<? } ?>
<input type="submit" value="Fill request" />
<br />
</div>
</form>
</td>
</tr>
<? } ?>
<tr>
<td colspan="2" class="center"><strong>Description</strong></td>
</tr>
<tr>
<td colspan="2"><?=$Text->full_format($Description)?></td>
</tr>
</table>
<?
$Results = $Cache->get_value('request_comments_'.$RequestID);
if($Results === false) {
$DB->query("SELECT
COUNT(c.ID)
FROM requests_comments as c
WHERE c.RequestID = '$RequestID'");
list($Results) = $DB->next_record();
$Cache->cache_value('request_comments_'.$RequestID, $Results, 0);
}
2012-10-11 08:00:15 +00:00
list($Page,$Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE,$Results);
2011-03-28 14:21:28 +00:00
//Get the cache catalogue
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
$CatalogueLimit=$CatalogueID*THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
//---------- Get some data to start processing
// Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
$Catalogue = $Cache->get_value('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID);
if($Catalogue === false) {
$DB->query("SELECT
c.ID,
c.AuthorID,
c.AddedTime,
c.Body,
c.EditedUserID,
c.EditedTime,
u.Username
FROM requests_comments as c
LEFT JOIN users_main AS u ON u.ID=c.EditedUserID
WHERE c.RequestID = '$RequestID'
ORDER BY c.ID
LIMIT $CatalogueLimit");
$Catalogue = $DB->to_array(false,MYSQLI_ASSOC);
$Cache->cache_value('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
}
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
$Thread = array_slice($Catalogue,((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)%THREAD_CATALOGUE),TORRENT_COMMENTS_PER_PAGE,true);
?>
<div class="linkbox"><a name="comments"></a>
<?
2012-10-11 08:00:15 +00:00
$Pages=Format::get_pages($Page,$Results,TORRENT_COMMENTS_PER_PAGE,9,'#comments');
2011-03-28 14:21:28 +00:00
echo $Pages;
?>
</div>
<?
//---------- Begin printing
2012-10-29 08:00:20 +00:00
foreach($Thread as $Key => $Post) {
2011-03-28 14:21:28 +00:00
list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
2012-10-11 08:00:15 +00:00
list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
2011-03-28 14:21:28 +00:00
?>
<table class="forum_post box vertical_margin<?=$HeavyInfo['DisableAvatars'] ? ' noavatar' : ''?>" id="post<?=$PostID?>">
2012-10-29 08:00:20 +00:00
<colgroup>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?>
<col class="col_avatar" />
<? } ?>
<col class="col_post_body" />
</colgroup>
2011-03-28 14:21:28 +00:00
<tr class="colhead_dark">
2012-10-29 08:00:20 +00:00
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>">
<div style="float:left;"><a href='#post<?=$PostID?>'>#<?=$PostID?></a>
by <strong><?=Users::format_username($AuthorID, true, true, true, true)?></strong> <?=time_diff($AddedTime)?>
2011-03-28 14:21:28 +00:00
- <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$Username?>');">[Quote]</a>
2012-10-29 08:00:20 +00:00
<? if ($AuthorID == $LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?>
- <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>','<?=$Key?>');">[Edit]</a>
<? }
if (check_perms('site_moderate_forums')) { ?>
- <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');">[Delete]</a>
<? } ?>
</div>
<div id="bar<?=$PostID?>" style="float:right;">
<a href="reports.php?action=report&amp;type=requests_comment&amp;id=<?=$PostID?>">[Report]</a>
&nbsp;
2011-03-28 14:21:28 +00:00
<a href="#">&uarr;</a>
2012-10-29 08:00:20 +00:00
</div>
2011-03-28 14:21:28 +00:00
</td>
</tr>
<tr>
2012-10-29 08:00:20 +00:00
<? if (empty($HeavyInfo['DisableAvatars'])) { ?>
2011-03-28 14:21:28 +00:00
<td class="avatar" valign="top">
2012-10-29 08:00:20 +00:00
<? if ($Avatar) { ?>
2011-03-28 14:21:28 +00:00
<img src="<?=$Avatar?>" width="150" alt="<?=$Username ?>'s avatar" />
2012-10-29 08:00:20 +00:00
<? } else { ?>
2011-03-28 14:21:28 +00:00
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
2012-10-29 08:00:20 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</td>
2012-10-29 08:00:20 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
<td class="body" valign="top">
<div id="content<?=$PostID?>">
<?=$Text->full_format($Body)?>
2012-10-29 08:00:20 +00:00
<? if ($EditedUserID) { ?>
2011-03-28 14:21:28 +00:00
<br />
<br />
2012-10-29 08:00:20 +00:00
<? if(check_perms('site_moderate_forums')) { ?>
2011-03-28 14:21:28 +00:00
<a href="#content<?=$PostID?>" onclick="LoadEdit('requests', <?=$PostID?>, 1); return false;">&laquo;</a>
2012-10-29 08:00:20 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
Last edited by
2012-10-11 08:00:15 +00:00
<?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime,2,true,true)?>
2012-10-29 08:00:20 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</div>
</td>
</tr>
</table>
2012-10-29 08:00:20 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
<div class="linkbox">
<?=$Pages?>
</div>
2012-10-29 08:00:20 +00:00
<? if (!$LoggedUser['DisablePosting']) { ?>
2011-03-28 14:21:28 +00:00
<br />
2012-10-27 08:00:09 +00:00
<div id="reply_box">
<h3>Post comment</h3>
<div class="box pad" style="padding:20px 10px 10px 10px;">
<table id="quickreplypreview" class="hidden forum_post box vertical_margin" id="preview">
2012-10-29 08:00:20 +00:00
<colgroup>
<? if(empty($HeavyInfo['DisableAvatars'])) { ?>
<col class="col_avatar" />
<? } ?>
<col class="col_post_body" />
</colgroup>
2012-10-27 08:00:09 +00:00
<tr class="colhead_dark">
2012-10-29 08:00:20 +00:00
<td colspan="<?=empty($HeavyInfo['DisableAvatars']) ? 2 : 1?>">
<div style="float:left;"><a href='#quickreplypreview'>#XXXXXX</a>
by <strong><?=Users::format_username($LoggedUser['ID'], true, true, true, true)?></strong> Just now
</div>
<div style="float:right;">
<a href="#quickreplypreview">[Report]</a>
&nbsp;
2012-10-27 08:00:09 +00:00
<a href="#">&uarr;</a>
2012-10-29 08:00:20 +00:00
</div>
2012-10-27 08:00:09 +00:00
</td>
</tr>
<tr>
2012-10-29 08:00:20 +00:00
<? if(empty($HeavyInfo['DisableAvatars'])) { ?>
2012-10-27 08:00:09 +00:00
<td class="avatar" valign="top">
2012-10-29 08:00:20 +00:00
<? if (!empty($LoggedUser['Avatar'])) { ?>
2012-10-27 08:00:09 +00:00
<img src="<?=$LoggedUser['Avatar']?>" width="150" alt="<?=$LoggedUser['Username']?>'s avatar" />
2012-10-29 08:00:20 +00:00
<? } else { ?>
2012-10-27 08:00:09 +00:00
<img src="<?=STATIC_SERVER?>common/avatars/default.png" width="150" alt="Default avatar" />
2012-10-29 08:00:20 +00:00
<? } ?>
2012-10-27 08:00:09 +00:00
</td>
2012-10-29 08:00:20 +00:00
<? } ?>
2012-10-27 08:00:09 +00:00
<td class="body" valign="top">
<div id="contentpreview" style="text-align:left;"></div>
</td>
</tr>
</table>
2012-10-29 08:00:20 +00:00
<form class="send_form center" name="reply" id="quickpostform" action="" onsubmit="quickpostform.submit_button.disabled=true;" method="post">
2012-10-27 08:00:09 +00:00
<div id="quickreplytext">
<input type="hidden" name="action" value="reply" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="requestid" value="<?=$RequestID?>" />
<textarea id="quickpost" name="body" cols="70" rows="8"></textarea> <br />
</div>
<input id="post_preview" type="button" value="Preview" onclick="if(this.preview){Quick_Edit();}else{Quick_Preview();}" />
<input type="submit" id="submit_button" value="Post reply" />
</form>
</div>
2011-03-28 14:21:28 +00:00
</div>
<? } ?>
</div>
</div>
2012-10-11 08:00:15 +00:00
<? View::show_footer(); ?>