2012-01-28 08:00:29 +00:00
|
|
|
<?
|
|
|
|
$RequestTax = 0.1;
|
|
|
|
|
|
|
|
// Minimum and default amount of upload to remove from the user when they vote.
|
|
|
|
// Also change in static/functions/requests.js
|
2013-04-19 08:00:55 +00:00
|
|
|
$MinimumVote = 20 * 1024 * 1024;
|
2012-01-28 08:00:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the page that displays the request to the end user after being created.
|
|
|
|
*/
|
|
|
|
|
2013-05-27 08:00:58 +00:00
|
|
|
include(SERVER_ROOT.'/classes/text.class.php');
|
2012-01-28 08:00:29 +00:00
|
|
|
$Text = new TEXT;
|
|
|
|
|
2013-05-05 08:00:31 +00:00
|
|
|
if (empty($_GET['id']) || !is_number($_GET['id'])) {
|
2013-05-11 08:00:29 +00:00
|
|
|
json_die("failure");
|
2012-01-28 08:00:29 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 23:08:41 +00:00
|
|
|
$RequestID = (int)$_GET['id'];
|
2012-01-28 08:00:29 +00:00
|
|
|
|
|
|
|
//First things first, lets get the data for the request.
|
|
|
|
|
2013-09-13 08:00:53 +00:00
|
|
|
$Request = Requests::get_request($RequestID);
|
|
|
|
if ($Request === false) {
|
2013-04-24 08:00:23 +00:00
|
|
|
json_die("failure");
|
2012-01-28 08:00:29 +00:00
|
|
|
}
|
|
|
|
|
2013-09-13 08:00:53 +00:00
|
|
|
$CategoryID = $Request['CategoryID'];
|
|
|
|
$Requestor = Users::user_info($Request['UserID']);
|
|
|
|
$Filler = $Request['FillerID'] ? Users::user_info($Request['FillerID']) : null;
|
2012-01-28 08:00:29 +00:00
|
|
|
//Convenience variables
|
2013-09-13 08:00:53 +00:00
|
|
|
$IsFilled = !empty($Request['TorrentID']);
|
|
|
|
$CanVote = !$IsFilled && check_perms('site_vote');
|
2012-01-28 08:00:29 +00:00
|
|
|
|
2013-04-15 08:00:54 +00:00
|
|
|
if ($CategoryID == 0) {
|
|
|
|
$CategoryName = 'Unknown';
|
2012-01-28 08:00:29 +00:00
|
|
|
} else {
|
|
|
|
$CategoryName = $Categories[$CategoryID - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
//Do we need to get artists?
|
2013-04-15 08:00:54 +00:00
|
|
|
if ($CategoryName == 'Music') {
|
2013-05-13 08:00:33 +00:00
|
|
|
$ArtistForm = Requests::get_artists($RequestID);
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2013-09-13 08:00:53 +00:00
|
|
|
if (empty($Request['ReleaseType'])) {
|
2013-04-15 08:00:54 +00:00
|
|
|
$ReleaseName = 'Unknown';
|
2012-01-28 08:00:29 +00:00
|
|
|
} else {
|
2013-09-13 08:00:53 +00:00
|
|
|
$ReleaseName = $ReleaseTypes[$Request['ReleaseType']];
|
2012-01-28 08:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Votes time
|
2013-05-13 08:00:33 +00:00
|
|
|
$RequestVotes = Requests::get_votes_array($RequestID);
|
2012-01-28 08:00:29 +00:00
|
|
|
$VoteCount = count($RequestVotes['Voters']);
|
2013-09-13 08:00:53 +00:00
|
|
|
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID == 0) || ($CategoryName == 'Music' && $Request['Year'] == 0)));
|
|
|
|
$UserCanEdit = (!$IsFilled && $LoggedUser['ID'] == $Request['UserID'] && $VoteCount < 2);
|
2012-01-28 08:00:29 +00:00
|
|
|
$CanEdit = ($UserCanEdit || $ProjectCanEdit || check_perms('site_moderate_requests'));
|
|
|
|
|
|
|
|
if ($CategoryName == "Music") {
|
|
|
|
$JsonMusicInfo = array(
|
|
|
|
/*'composers' => $ArtistForm[4] != null ? $ArtistForm[4] : array(),
|
2013-05-21 08:01:09 +00:00
|
|
|
'dj' => $ArtistForm[6] != null ? $ArtistForm[6] : array(),
|
|
|
|
'artists' => $ArtistForm[1] != null ? $ArtistForm[1] : array(),
|
|
|
|
'with' => $ArtistForm[2] != null ? $ArtistForm[2] : array(),
|
2012-01-28 08:00:29 +00:00
|
|
|
'conductor' => $ArtistForm[5] != null ? $ArtistForm[5] : array(),
|
|
|
|
'remixedBy' => $ArtistForm[3] != null ? $ArtistForm[3] : array()*/
|
2013-09-13 08:00:53 +00:00
|
|
|
'composers' => isset($ArtistForm[4]) ? pullmediainfo($ArtistForm[4]) : array(),
|
|
|
|
'dj' => isset($ArtistForm[6]) ? pullmediainfo($ArtistForm[6]) : array(),
|
|
|
|
'artists' => isset($ArtistForm[1]) ? pullmediainfo($ArtistForm[1]) : array(),
|
|
|
|
'with' => isset($ArtistForm[2]) ? pullmediainfo($ArtistForm[2]) : array(),
|
|
|
|
'conductor' => isset($ArtistForm[5]) ? pullmediainfo($ArtistForm[5]) : array(),
|
|
|
|
'remixedBy' => isset($ArtistForm[3]) ? pullmediainfo($ArtistForm[3]) : array(),
|
|
|
|
'producer' => isset($ArtistForm[7]) ? pullmediainfo($ArtistForm[7]) : array()
|
2012-01-28 08:00:29 +00:00
|
|
|
);
|
2013-04-24 08:00:23 +00:00
|
|
|
} else {
|
2013-05-14 08:00:34 +00:00
|
|
|
$JsonMusicInfo = new stdClass; //json_encodes into an empty object: {}
|
2012-01-28 08:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$JsonTopContributors = array();
|
|
|
|
$VoteMax = ($VoteCount < 5 ? $VoteCount : 5);
|
2013-04-19 08:00:55 +00:00
|
|
|
for ($i = 0; $i < $VoteMax; $i++) {
|
2012-01-28 08:00:29 +00:00
|
|
|
$User = array_shift($RequestVotes['Voters']);
|
|
|
|
$JsonTopContributors[] = array(
|
2013-10-30 08:01:19 +00:00
|
|
|
'userId' => (int)$User['UserID'],
|
2012-01-28 08:00:29 +00:00
|
|
|
'userName' => $User['Username'],
|
2013-10-30 08:01:19 +00:00
|
|
|
'bounty' => (int)$User['Bounty']
|
2012-01-28 08:00:29 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
reset($RequestVotes['Voters']);
|
|
|
|
|
2013-08-28 23:08:41 +00:00
|
|
|
list($NumComments, $Page, $Thread) = Comments::load('requests', $RequestID, false);
|
2012-01-28 08:00:29 +00:00
|
|
|
|
|
|
|
$JsonRequestComments = array();
|
2013-05-04 08:00:48 +00:00
|
|
|
foreach ($Thread as $Key => $Post) {
|
2012-01-28 08:00:29 +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));
|
2012-01-28 08:00:29 +00:00
|
|
|
$JsonRequestComments[] = array(
|
2013-09-13 08:00:53 +00:00
|
|
|
'postId' => (int)$PostID,
|
|
|
|
'authorId' => (int)$AuthorID,
|
2012-01-28 08:00:29 +00:00
|
|
|
'name' => $Username,
|
|
|
|
'donor' => $Donor == 1,
|
2013-09-13 08:00:53 +00:00
|
|
|
'warned' => ($Warned != '0000-00-00 00:00:00'),
|
2012-01-28 08:00:29 +00:00
|
|
|
'enabled' => ($Enabled == 2 ? false : true),
|
2012-10-11 08:00:15 +00:00
|
|
|
'class' => Users::make_class_string($PermissionID),
|
2012-01-28 08:00:29 +00:00
|
|
|
'addedTime' => $AddedTime,
|
|
|
|
'avatar' => $Avatar,
|
|
|
|
'comment' => $Text->full_format($Body),
|
2013-09-13 08:00:53 +00:00
|
|
|
'editedUserId' => (int)$EditedUserID,
|
2012-01-28 08:00:29 +00:00
|
|
|
'editedUsername' => $EditedUsername,
|
|
|
|
'editedTime' => $EditedTime
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$JsonTags = array();
|
2013-04-15 08:00:54 +00:00
|
|
|
foreach ($Request['Tags'] as $Tag) {
|
2012-01-28 08:00:29 +00:00
|
|
|
$JsonTags[] = $Tag;
|
|
|
|
}
|
2013-09-13 08:00:53 +00:00
|
|
|
json_die('success', array(
|
|
|
|
'requestId' => (int)$RequestID,
|
|
|
|
'requestorId' => (int)$Request['UserID'],
|
|
|
|
'requestorName' => $Requestor['Username'],
|
2013-05-11 08:00:29 +00:00
|
|
|
'isBookmarked' => Bookmarks::has_bookmarked('request', $RequestID),
|
2013-05-14 08:00:34 +00:00
|
|
|
'requestTax' => $RequestTax,
|
2013-09-13 08:00:53 +00:00
|
|
|
'timeAdded' => $Request['TimeAdded'],
|
2013-05-14 08:00:34 +00:00
|
|
|
'canEdit' => $CanEdit,
|
|
|
|
'canVote' => $CanVote,
|
|
|
|
'minimumVote' => $MinimumVote,
|
|
|
|
'voteCount' => $VoteCount,
|
2013-09-13 08:00:53 +00:00
|
|
|
'lastVote' => $Request['LastVote'],
|
2013-05-14 08:00:34 +00:00
|
|
|
'topContributors' => $JsonTopContributors,
|
2013-09-13 08:00:53 +00:00
|
|
|
'totalBounty' => (int)$RequestVotes['TotalBounty'],
|
|
|
|
'categoryId' => (int)$CategoryID,
|
2013-05-14 08:00:34 +00:00
|
|
|
'categoryName' => $CategoryName,
|
2013-09-13 08:00:53 +00:00
|
|
|
'title' => $Request['Title'],
|
|
|
|
'year' => (int)$Request['Year'],
|
|
|
|
'image' => $Request['Image'],
|
|
|
|
'bbDescription' => $Request['Description'],
|
|
|
|
'description' => $Text->full_format($Request['Description']),
|
2013-05-14 08:00:34 +00:00
|
|
|
'musicInfo' => $JsonMusicInfo,
|
2013-09-13 08:00:53 +00:00
|
|
|
'catalogueNumber' => $Request['CatalogueNumber'],
|
|
|
|
'releaseType' => (int)$Request['ReleaseType'],
|
2013-05-14 08:00:34 +00:00
|
|
|
'releaseName' => $ReleaseName,
|
2013-10-15 08:01:05 +00:00
|
|
|
'bitrateList' => preg_split('/\|/', $Request['BitrateList'], null, PREG_SPLIT_NO_EMPTY),
|
|
|
|
'formatList' => preg_split('/\|/', $Request['FormatList'], null, PREG_SPLIT_NO_EMPTY),
|
|
|
|
'mediaList' => preg_split('/\|/', $Request['MediaList'], null, PREG_SPLIT_NO_EMPTY),
|
2013-09-13 08:00:53 +00:00
|
|
|
'logCue' => html_entity_decode($Request['LogCue']),
|
2013-05-14 08:00:34 +00:00
|
|
|
'isFilled' => $IsFilled,
|
2013-09-13 08:00:53 +00:00
|
|
|
'fillerId' => (int)$Request['FillerID'],
|
|
|
|
'fillerName' => ($Filler ? $Filler['Username'] : ''),
|
|
|
|
'torrentId' => (int)$Request['TorrentID'],
|
|
|
|
'timeFilled' => $Request['TimeFilled'],
|
2013-05-14 08:00:34 +00:00
|
|
|
'tags' => $JsonTags,
|
|
|
|
'comments' => $JsonRequestComments,
|
2013-09-13 08:00:53 +00:00
|
|
|
'commentPage' => (int)$Page,
|
|
|
|
'commentPages' => (int)ceil($NumComments / TORRENT_COMMENTS_PER_PAGE),
|
|
|
|
'recordLabel' => $Request['RecordLabel'],
|
|
|
|
'oclc' => $Request['OCLC']
|
2013-04-24 08:00:23 +00:00
|
|
|
));
|
2012-01-28 08:00:29 +00:00
|
|
|
?>
|