mirror of
https://github.com/WhatCD/Gazelle.git
synced 2025-01-31 02:21:36 +00:00
Empty commit
This commit is contained in:
parent
57987ff48e
commit
6cbf7e6beb
33
classes/class_collages.php
Normal file
33
classes/class_collages.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?
|
||||
class Collages {
|
||||
public static function get_comment_count($CollageID) {
|
||||
global $DB, $Cache;
|
||||
$NumComments = $Cache->get_value('collage_comments_'.$CollageID);
|
||||
if ($NumComments === false) {
|
||||
$DB->query("SELECT COUNT(ID) FROM collages_comments WHERE CollageID = '$CollageID'");
|
||||
list($NumComments) = $DB->next_record();
|
||||
$Cache->cache_value('collage_comments_'.$CollageID, $NumComments, 0);
|
||||
}
|
||||
return $NumComments;
|
||||
}
|
||||
|
||||
public static function get_comment_catalogue($CollageID, $CatalogueID) {
|
||||
global $DB, $Cache;
|
||||
$Catalogue = $Cache->get_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID);
|
||||
if ($Catalogue === false) {
|
||||
$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
|
||||
$DB->query("
|
||||
SELECT
|
||||
ID,
|
||||
UserID,
|
||||
Time,
|
||||
Body
|
||||
FROM collages_comments
|
||||
WHERE CollageID = '$CollageID'
|
||||
LIMIT $CatalogueLimit");
|
||||
$Catalogue = $DB->to_array(false, MYSQLI_ASSOC);
|
||||
$Cache->cache_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
|
||||
}
|
||||
return $Catalogue;
|
||||
}
|
||||
}
|
@ -105,7 +105,7 @@ public static function get_requests($RequestIDs, $Return = true) {
|
||||
$Requests = $DB->to_array();
|
||||
foreach ($Requests as $Request) {
|
||||
unset($NotFound[$Request['ID']]);
|
||||
$Request['Tags'] = get_request_tags($Request['ID']);
|
||||
$Request['Tags'] = self::get_tags($Request['ID']);
|
||||
$Found[$Request['ID']] = $Request;
|
||||
$Cache->cache_value('request_'.$Request['ID'], $Request, 0);
|
||||
}
|
||||
@ -117,5 +117,122 @@ public static function get_requests($RequestIDs, $Return = true) {
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_comment_count($RequestID) {
|
||||
global $Cache, $DB;
|
||||
$NumComments = $Cache->get_value('request_comments_'.$RequestID);
|
||||
if ($NumComments === false) {
|
||||
$DB->query("SELECT COUNT(ID) FROM requests_comments WHERE RequestID = '$RequestID'");
|
||||
list($NumComments) = $DB->next_record();
|
||||
$Cache->cache_value('request_comments_'.$RequestID, $NumComments, 0);
|
||||
}
|
||||
return $NumComments;
|
||||
}
|
||||
|
||||
public static function get_comment_catalogue($RequestID, $CatalogueID) {
|
||||
global $Cache, $DB;
|
||||
$Catalogue = $Cache->get_value('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID);
|
||||
if ($Catalogue === false) {
|
||||
$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
|
||||
$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);
|
||||
}
|
||||
return $Catalogue;
|
||||
}
|
||||
|
||||
public static function get_artists($RequestID) {
|
||||
global $Cache, $DB;
|
||||
$Artists = $Cache->get_value('request_artists_'.$RequestID);
|
||||
if (is_array($Artists)) {
|
||||
$Results = $Artists;
|
||||
} else {
|
||||
$Results = array();
|
||||
$DB->query("
|
||||
SELECT
|
||||
ra.ArtistID,
|
||||
aa.Name,
|
||||
ra.Importance
|
||||
FROM requests_artists AS ra
|
||||
JOIN artists_alias AS aa ON ra.AliasID = aa.AliasID
|
||||
WHERE ra.RequestID = $RequestID
|
||||
ORDER BY ra.Importance ASC, aa.Name ASC;");
|
||||
|
||||
$ArtistRaw = $DB->to_array();
|
||||
foreach ($ArtistRaw as $ArtistRow) {
|
||||
list($ArtistID, $ArtistName, $ArtistImportance) = $ArtistRow;
|
||||
$Results[$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName);
|
||||
}
|
||||
$Cache->cache_value('request_artists_'.$RequestID, $Results);
|
||||
}
|
||||
return $Results;
|
||||
}
|
||||
|
||||
public static function get_tags($RequestID) {
|
||||
global $DB;
|
||||
$DB->query("
|
||||
SELECT
|
||||
rt.TagID,
|
||||
t.Name
|
||||
FROM requests_tags AS rt
|
||||
JOIN tags AS t ON rt.TagID=t.ID
|
||||
WHERE rt.RequestID = $RequestID
|
||||
ORDER BY rt.TagID ASC");
|
||||
$Tags = $DB->to_array();
|
||||
$Results = array();
|
||||
foreach ($Tags as $TagsRow) {
|
||||
list($TagID, $TagName) = $TagsRow;
|
||||
$Results[$TagID]= $TagName;
|
||||
}
|
||||
return $Results;
|
||||
}
|
||||
|
||||
public static function get_votes_array($RequestID) {
|
||||
global $Cache, $DB;
|
||||
|
||||
$RequestVotes = $Cache->get_value('request_votes_'.$RequestID);
|
||||
if (!is_array($RequestVotes)) {
|
||||
$DB->query("
|
||||
SELECT
|
||||
rv.UserID,
|
||||
rv.Bounty,
|
||||
u.Username
|
||||
FROM requests_votes as rv
|
||||
LEFT JOIN users_main AS u ON u.ID=rv.UserID
|
||||
WHERE rv.RequestID = $RequestID
|
||||
ORDER BY rv.Bounty DESC");
|
||||
if ($DB->record_count() < 1) {
|
||||
error(0);
|
||||
} else {
|
||||
$Votes = $DB->to_array();
|
||||
|
||||
$RequestVotes = array();
|
||||
$RequestVotes['TotalBounty'] = array_sum($DB->collect('Bounty'));
|
||||
|
||||
foreach ($Votes as $Vote) {
|
||||
list($UserID, $Bounty, $Username) = $Vote;
|
||||
$VoteArray = array();
|
||||
$VotesArray[] = array('UserID' => $UserID, 'Username' => $Username, 'Bounty' => $Bounty);
|
||||
}
|
||||
|
||||
$RequestVotes['Voters'] = $VotesArray;
|
||||
$Cache->cache_value('request_votes_'.$RequestID, $RequestVotes);
|
||||
}
|
||||
}
|
||||
return $RequestVotes;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
@ -98,6 +98,9 @@
|
||||
case 'Bookmarks':
|
||||
$FileName = 'bookmarks.class';
|
||||
break;
|
||||
case 'Collages':
|
||||
$FileName = 'class_collages';
|
||||
break;
|
||||
case 'Format':
|
||||
$FileName = 'class_format';
|
||||
break;
|
||||
|
@ -4,7 +4,6 @@ function compare($X, $Y) {
|
||||
return($Y['count'] - $X['count']);
|
||||
}
|
||||
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
|
||||
$Text = new TEXT;
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
require(SERVER_ROOT.'/sections/ajax/collages/browse.php');
|
||||
break;
|
||||
case 'requests':
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
$_GET['type'] = 'bookmarks';
|
||||
require(SERVER_ROOT.'/sections/ajax/requests/requests.php');
|
||||
break;
|
||||
|
@ -10,7 +10,6 @@
|
||||
* This is the page that displays the request to the end user after being created.
|
||||
*/
|
||||
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
include(SERVER_ROOT.'/classes/class_text.php');
|
||||
$Text = new TEXT;
|
||||
|
||||
@ -43,7 +42,7 @@
|
||||
|
||||
//Do we need to get artists?
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistName = Artists::display_artists($ArtistForm, false, true);
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
|
||||
@ -79,7 +78,7 @@
|
||||
}
|
||||
|
||||
//Votes time
|
||||
$RequestVotes = get_votes_array($RequestID);
|
||||
$RequestVotes = Requests::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);
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?
|
||||
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
|
||||
$Queries = array();
|
||||
|
||||
$OrderWays = array('year', 'votes', 'bounty', 'created', 'lastvote', 'filled');
|
||||
@ -309,7 +307,7 @@
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber,
|
||||
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request;
|
||||
|
||||
$RequestVotes = get_votes_array($RequestID);
|
||||
$RequestVotes = Requests::get_votes_array($RequestID);
|
||||
|
||||
$VoteCount = count($RequestVotes['Voters']);
|
||||
|
||||
@ -321,7 +319,7 @@
|
||||
|
||||
$JsonArtists = array();
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$JsonArtists = array_values($ArtistForm);
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
|
||||
$Text = new TEXT;
|
||||
|
||||
require(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
|
||||
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||
json_die("failure", "bad id parameter");
|
||||
}
|
||||
|
@ -9,8 +9,6 @@ function compare($X, $Y) {
|
||||
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
|
||||
$Text = new TEXT;
|
||||
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
|
||||
// Similar artist map
|
||||
include(SERVER_ROOT.'/classes/class_artists_similar.php');
|
||||
|
||||
@ -738,7 +736,7 @@ function compare($X, $Y) {
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
$FullName = $ArtistLink."<a href=\"requests.php?action=view&id=".$RequestID."\">$Title [$Year]</a>";
|
||||
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
|
||||
@ -749,7 +747,7 @@ function compare($X, $Y) {
|
||||
|
||||
$Row = ($Row == 'a') ? 'b' : 'a';
|
||||
|
||||
$Tags = get_request_tags($RequestID);
|
||||
$Tags = Requests::get_tags($RequestID);
|
||||
$ReqTagList = array();
|
||||
foreach ($Tags as $TagID => $TagName) {
|
||||
$ReqTagList[] = "<a href=\"requests.php?tags=".$TagName.'">'.display_str($TagName).'</a>';
|
||||
|
@ -61,7 +61,6 @@
|
||||
require(SERVER_ROOT.'/sections/collages/browse.php');
|
||||
break;
|
||||
case 'requests':
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
$_GET['type'] = 'bookmarks';
|
||||
require(SERVER_ROOT.'/sections/requests/requests.php');
|
||||
break;
|
||||
|
@ -10,13 +10,25 @@
|
||||
error('Your posting privileges have been removed'); // Should this be logged?
|
||||
}
|
||||
|
||||
$DB->query("
|
||||
SELECT
|
||||
CEIL((
|
||||
SELECT COUNT(ID)+1
|
||||
FROM collages_comments
|
||||
WHERE CollageID='".db_string($CollageID)."')/".TORRENT_COMMENTS_PER_PAGE."
|
||||
) AS Pages");
|
||||
list($Pages) = $DB->next_record();
|
||||
|
||||
$DB->query("INSERT INTO collages_comments
|
||||
(CollageID, Body, UserID, Time)
|
||||
VALUES
|
||||
('$CollageID', '".db_string($_POST['body'])."', '$LoggedUser[ID]', '".sqltime()."')");
|
||||
|
||||
$Cache->delete_value('collage_'.$CollageID.'_catalogue_0');
|
||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||
|
||||
$Cache->delete_value('collage_'.$CollageID);
|
||||
$Cache->delete_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID);
|
||||
$Cache->increment('collage_comments_'.$CollageID);
|
||||
header('Location: collages.php?id='.$CollageID);
|
||||
|
||||
?>
|
||||
|
@ -19,33 +19,28 @@
|
||||
error(0);
|
||||
}
|
||||
|
||||
list($Page,$Limit) = Format::page_limit(POSTS_PER_PAGE);
|
||||
// gets the amount of comments for this collage
|
||||
$NumComments = Collages::get_comment_count($CollageID);
|
||||
|
||||
if (isset($_GET['postid']) && is_number($_GET['postid']) && $NumComments > TORRENT_COMMENTS_PER_PAGE) {
|
||||
$DB->query("SELECT COUNT(ID) FROM collages_comments WHERE CollageID = $CollageID AND ID <= $_GET[postid]");
|
||||
list($PostNum) = $DB->next_record();
|
||||
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
|
||||
} else {
|
||||
list($Page, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $NumComments);
|
||||
}
|
||||
|
||||
//Get the cache catalogue
|
||||
$CatalogueID = floor((POSTS_PER_PAGE*$Page-POSTS_PER_PAGE)/THREAD_CATALOGUE);
|
||||
$CatalogueLimit=$CatalogueID*THREAD_CATALOGUE . ', ' . THREAD_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
|
||||
if (!list($Catalogue,$Posts) = $Cache->get_value('collage_'.$CollageID.'_catalogue_'.$CatalogueID)) {
|
||||
$DB->query("
|
||||
SELECT SQL_CALC_FOUND_ROWS
|
||||
ID,
|
||||
UserID,
|
||||
Time,
|
||||
Body
|
||||
FROM collages_comments
|
||||
WHERE CollageID = '$CollageID'
|
||||
LIMIT $CatalogueLimit");
|
||||
$Catalogue = $DB->to_array();
|
||||
$DB->query("SELECT FOUND_ROWS()");
|
||||
list($Posts) = $DB->next_record();
|
||||
$Cache->cache_value('collage_'.$CollageID.'_catalogue_'.$CatalogueID, array($Catalogue,$Posts), 0);
|
||||
}
|
||||
$Catalogue = Collages::get_comment_catalogue($CollageID, $CatalogueID);
|
||||
|
||||
//This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
|
||||
$Thread = array_slice($Catalogue, ((POSTS_PER_PAGE * $Page - POSTS_PER_PAGE) % THREAD_CATALOGUE), POSTS_PER_PAGE, true);
|
||||
$Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
|
||||
|
||||
$DB->query("SELECT Name FROM collages WHERE ID='$CollageID'");
|
||||
list($Name) = $DB->next_record();
|
||||
@ -61,7 +56,7 @@
|
||||
</h2>
|
||||
<div class="linkbox">
|
||||
<?
|
||||
$Pages = Format::get_pages($Page, $Posts, POSTS_PER_PAGE, 9);
|
||||
$Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9);
|
||||
echo $Pages;
|
||||
?>
|
||||
</div>
|
||||
@ -70,7 +65,7 @@
|
||||
|
||||
//---------- Begin printing
|
||||
foreach ($Thread as $Post) {
|
||||
list($PostID, $AuthorID, $AddedTime, $Body) = $Post;
|
||||
list($PostID, $AuthorID, $AddedTime, $Body) = array_values($Post);
|
||||
list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
|
||||
?>
|
||||
<table class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '')?>" id="post<?=$PostID?>">
|
||||
|
@ -15,11 +15,27 @@
|
||||
error(403);
|
||||
}
|
||||
|
||||
$DB->query("SELECT CollageID FROM collages_comments WHERE ID='$PostID'");
|
||||
list($CollageID) = $DB->next_record();
|
||||
// Get number of pages
|
||||
// $Pages = number of pages in the thread
|
||||
// $Page = which page the post is on
|
||||
$DB->query("SELECT
|
||||
CollageID,
|
||||
CEIL(COUNT(ID)/" . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
|
||||
CEIL(SUM(IF(ID<='$PostID',1,0))/" . TORRENT_COMMENTS_PER_PAGE . ") AS Page
|
||||
FROM collages_comments
|
||||
WHERE CollageID=(SELECT CollageID FROM collages_comments WHERE ID='$PostID')
|
||||
GROUP BY CollageID");
|
||||
list($CollageID, $Pages, $Page) = $DB->next_record();
|
||||
|
||||
$DB->query("DELETE FROM collages_comments WHERE ID='$PostID'");
|
||||
|
||||
$Cache->delete_value('collage_'.$CollageID);
|
||||
$Cache->delete_value('collage_'.$CollageID.'_catalogue_0'); //Because these never exceed 500 posts, and I'm really tired right now.
|
||||
$Cache->increment_value('collage_comments_'.$CollageID, -1);
|
||||
|
||||
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
|
||||
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
|
||||
$Cache->delete('collage_comments_'.$CollageID.'_catalogue_'.$i);
|
||||
}
|
||||
?>
|
||||
|
@ -51,8 +51,8 @@
|
||||
|
||||
|
||||
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
|
||||
$CatalogueID = floor((POSTS_PER_PAGE * $PageNum - POSTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||
$Cache->delete_value('collage_'.$CollageID.'_catalogue_'.$CatalogueID);
|
||||
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $PageNum - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
|
||||
$Cache->delete_value('collage_comments_'.$CollageID.'_catalogue_'.$CatalogueID);
|
||||
|
||||
$DB->query("
|
||||
INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
|
||||
|
@ -1,8 +1,4 @@
|
||||
<?php
|
||||
// using the requests functions.php because we need get_request_artists()
|
||||
// TODO: move that function to class_artists?
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
|
||||
<?
|
||||
/*
|
||||
* $_REQUEST['type']:
|
||||
* created = comments left on one's requests
|
||||
@ -87,7 +83,7 @@
|
||||
<?
|
||||
if ($Count > 0) {
|
||||
while (list($UserID, $RequestID, $Title, $PostID, $Body, $AddedTime, $EditedTime, $EditorID) = $DB->next_record()) {
|
||||
$Artists = get_request_artists($RequestID);
|
||||
$Artists = Requests::get_artists($RequestID);
|
||||
$permalink = "requests.php?action=view&id=$RequestID&postid=$PostID#post$PostID";
|
||||
$postheader = " on " . Artists::display_artists($Artists) . " <a href=\"requests.php?action=view&id=$RequestID\">$Title</a>";
|
||||
comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorID, $AddedTime, $EditedTime);
|
||||
|
@ -1,85 +0,0 @@
|
||||
<?
|
||||
enforce_login();
|
||||
function get_request_artists($RequestID) {
|
||||
global $Cache, $DB;
|
||||
$Artists = $Cache->get_value('request_artists_'.$RequestID);
|
||||
if (is_array($Artists)) {
|
||||
$Results = $Artists;
|
||||
} else {
|
||||
$Results = array();
|
||||
$DB->query("
|
||||
SELECT
|
||||
ra.ArtistID,
|
||||
aa.Name,
|
||||
ra.Importance
|
||||
FROM requests_artists AS ra
|
||||
JOIN artists_alias AS aa ON ra.AliasID = aa.AliasID
|
||||
WHERE ra.RequestID = ".$RequestID."
|
||||
ORDER BY ra.Importance ASC, aa.Name ASC;");
|
||||
|
||||
$ArtistRaw = $DB->to_array();
|
||||
foreach ($ArtistRaw as $ArtistRow) {
|
||||
list($ArtistID, $ArtistName, $ArtistImportance) = $ArtistRow;
|
||||
$Results[$ArtistImportance][] = array('id' => $ArtistID, 'name' => $ArtistName);
|
||||
}
|
||||
$Cache->cache_value('request_artists_'.$RequestID, $Results);
|
||||
}
|
||||
return $Results;
|
||||
}
|
||||
|
||||
function get_request_tags($RequestID) {
|
||||
global $DB;
|
||||
$DB->query("
|
||||
SELECT
|
||||
rt.TagID,
|
||||
t.Name
|
||||
FROM requests_tags AS rt
|
||||
JOIN tags AS t ON rt.TagID=t.ID
|
||||
WHERE rt.RequestID = ".$RequestID."
|
||||
ORDER BY rt.TagID ASC");
|
||||
$Tags = $DB->to_array();
|
||||
$Results = array();
|
||||
foreach ($Tags as $TagsRow) {
|
||||
list($TagID, $TagName) = $TagsRow;
|
||||
$Results[$TagID]= $TagName;
|
||||
}
|
||||
return $Results;
|
||||
}
|
||||
|
||||
function get_votes_array($RequestID) {
|
||||
global $Cache, $DB;
|
||||
|
||||
$RequestVotes = $Cache->get_value('request_votes_'.$RequestID);
|
||||
if (!is_array($RequestVotes)) {
|
||||
$DB->query("
|
||||
SELECT
|
||||
rv.UserID,
|
||||
rv.Bounty,
|
||||
u.Username
|
||||
FROM requests_votes as rv
|
||||
LEFT JOIN users_main AS u ON u.ID=rv.UserID
|
||||
WHERE rv.RequestID = ".$RequestID."
|
||||
ORDER BY rv.Bounty DESC");
|
||||
if ($DB->record_count() < 1) {
|
||||
error(0);
|
||||
} else {
|
||||
$Votes = $DB->to_array();
|
||||
|
||||
$RequestVotes = array();
|
||||
$RequestVotes['TotalBounty'] = array_sum($DB->collect('Bounty'));
|
||||
|
||||
foreach ($Votes as $Vote) {
|
||||
list($UserID, $Bounty, $Username) = $Vote;
|
||||
$VoteArray = array();
|
||||
$VotesArray[] = array('UserID' => $UserID,
|
||||
'Username' => $Username,
|
||||
'Bounty' => $Bounty);
|
||||
}
|
||||
|
||||
$RequestVotes['Voters'] = $VotesArray;
|
||||
$Cache->cache_value('request_votes_'.$RequestID, $RequestVotes);
|
||||
}
|
||||
}
|
||||
return $RequestVotes;
|
||||
}
|
||||
?>
|
@ -1,6 +1,5 @@
|
||||
<?
|
||||
enforce_login();
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
|
||||
$RequestTax = 0.1;
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
|
||||
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled, $GroupID, $OCLC) = $Request;
|
||||
$VoteArray = get_votes_array($RequestID);
|
||||
$VoteArray = Requests::get_votes_array($RequestID);
|
||||
$VoteCount = count($VoteArray['Voters']);
|
||||
|
||||
$NeedCue = (strpos($LogCue, 'Cue') !== false);
|
||||
@ -55,7 +55,7 @@
|
||||
}
|
||||
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
|
||||
$BitrateArray = array();
|
||||
if ($BitrateList == 'Any') {
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
//Do we need to get artists?
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistName = Artists::display_artists($ArtistForm, false, true);
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
}
|
||||
|
||||
//Votes time
|
||||
$RequestVotes = get_votes_array($RequestID);
|
||||
$RequestVotes = Requests::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);
|
||||
@ -462,15 +462,7 @@
|
||||
</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);
|
||||
}
|
||||
$Results = Requests::get_comment_count($RequestID);
|
||||
|
||||
if (isset($_GET['postid']) && is_number($_GET['postid']) && $Results > TORRENT_COMMENTS_PER_PAGE) {
|
||||
$DB->query("SELECT COUNT(ID) FROM requests_comments WHERE RequestID = $RequestID AND ID <= $_GET[postid]");
|
||||
@ -482,29 +474,11 @@
|
||||
|
||||
//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);
|
||||
}
|
||||
$Catalogue = Requests::get_comment_catalogue($RequestID, $CatalogueID);
|
||||
|
||||
//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);
|
||||
|
@ -596,7 +596,7 @@
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
|
||||
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request;
|
||||
|
||||
$RequestVotes = get_votes_array($RequestID);
|
||||
$RequestVotes = Requests::get_votes_array($RequestID);
|
||||
|
||||
$VoteCount = count($RequestVotes['Voters']);
|
||||
|
||||
@ -609,7 +609,7 @@
|
||||
$IsFilled = ($TorrentID != 0);
|
||||
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
$FullName = $ArtistLink."<a href=\"requests.php?action=view&id=".$RequestID."\">$Title [$Year]</a>";
|
||||
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
|
||||
|
@ -420,7 +420,7 @@ foreach ($Categories as $CatKey => $CatName) {
|
||||
$IsFilled = ($TorrentID != 0);
|
||||
|
||||
if ($CategoryName == "Music") {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistLink = display_artists($ArtistForm, true, true);
|
||||
$FullName = $ArtistLink."<a href='requests.php?action=view&id=".$RequestID."'>".$Title." [".$Year."]</a>";
|
||||
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
|
||||
@ -431,7 +431,7 @@ foreach ($Categories as $CatKey => $CatName) {
|
||||
|
||||
$Row = ($Row == 'a') ? 'b' : 'a';
|
||||
|
||||
$Tags = get_request_tags($RequestID);
|
||||
$Tags = Requests::get_tags($RequestID);
|
||||
?>
|
||||
<tr class="row<?=$Row?>">
|
||||
<td>
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
//Do we need to get artists?
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistName = Artists::display_artists($ArtistForm, false, true);
|
||||
$FullName = $ArtistName.$Title;
|
||||
} else {
|
||||
|
@ -171,7 +171,7 @@
|
||||
WHERE ID = $RequestID");
|
||||
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistName = Artists::display_artists($ArtistForm, false, true);
|
||||
$FullName = $ArtistName.$Title;
|
||||
} else {
|
||||
@ -185,7 +185,7 @@
|
||||
Misc::send_pm($VoterID, 0, "The request \"$FullName\" has been filled", 'One of your requests — [url=https://'.SSL_SITE_URL.'/requests.php?action=view&id='.$RequestID.']'.$FullName.'[/url] — has been filled. You can view it here: [url]https://'.SSL_SITE_URL.'/torrents.php?torrentid='.$TorrentID.'[/url]');
|
||||
}
|
||||
|
||||
$RequestVotes = get_votes_array($RequestID);
|
||||
$RequestVotes = Requests::get_votes_array($RequestID);
|
||||
Misc::write_log("Request $RequestID (".$FullName.") was filled by user $FillerID (".$FillerUsername.") with the torrent $TorrentID for a ".Format::get_size($RequestVotes['TotalBounty']).' bounty.');
|
||||
|
||||
// Give bounty
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
|
||||
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled, $GroupID, $OCLC) = $Request;
|
||||
$VoteArray = get_votes_array($RequestID);
|
||||
$VoteArray = Requests::get_votes_array($RequestID);
|
||||
$VoteCount = count($VoteArray['Voters']);
|
||||
|
||||
$IsFilled = !empty($TorrentID);
|
||||
|
@ -38,14 +38,14 @@
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistName = Artists::display_artists($ArtistForm, false, true);
|
||||
$FullName = $ArtistName.$Title;
|
||||
} else {
|
||||
$FullName = $Title;
|
||||
}
|
||||
|
||||
$RequestVotes = get_votes_array($RequestID);
|
||||
$RequestVotes = Requests::get_votes_array($RequestID);
|
||||
|
||||
if ($RequestVotes['TotalBounty'] > $Uploaded) {
|
||||
// If we can't take it all out of upload, zero that out and add whatever is left as download.
|
||||
|
@ -52,7 +52,7 @@
|
||||
$Cache->delete_value('request_'.$RequestID);
|
||||
$Cache->delete_value('request_votes_'.$RequestID);
|
||||
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
foreach ($ArtistForm as $Importance) {
|
||||
foreach ($Importance as $Artist) {
|
||||
$Cache->delete_value('artists_requests_'.$Artist['id']);
|
||||
|
@ -619,7 +619,7 @@ function filelist($Str) {
|
||||
<td>Bounty</td>
|
||||
</tr>
|
||||
<? foreach ($Requests as $Request) {
|
||||
$RequestVotes = get_votes_array($Request['ID']);
|
||||
$RequestVotes = Requests::get_votes_array($Request['ID']);
|
||||
|
||||
if ($Request['BitrateList'] != "") {
|
||||
$BitrateString = implode(", ", explode("|", $Request['BitrateList']));
|
||||
|
@ -1,6 +1,4 @@
|
||||
<?
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php'); // get_request_tags()
|
||||
|
||||
function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProperties = true, $ApiCall = false) {
|
||||
global $Cache, $DB;
|
||||
if (!$RevisionID) {
|
||||
|
@ -50,7 +50,6 @@
|
||||
$Properties['RequestID'] = $_GET['requestid'];
|
||||
}
|
||||
} elseif (empty($Properties) && !empty($_GET['requestid']) && is_number($_GET['requestid'])) {
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
$DB->query('
|
||||
SELECT
|
||||
r.ID AS RequestID,
|
||||
@ -67,8 +66,8 @@
|
||||
list($Properties) = $DB->to_array(false,MYSQLI_BOTH);
|
||||
$UploadForm = $Categories[$Properties['CategoryID'] - 1];
|
||||
$Properties['CategoryName'] = $Categories[$Properties['CategoryID'] - 1];
|
||||
$Properties['Artists'] = get_request_artists($_GET['requestid']);
|
||||
$Properties['TagList'] = implode(', ', get_request_tags($_GET['requestid']));
|
||||
$Properties['Artists'] = Requests::get_artists($_GET['requestid']);
|
||||
$Properties['TagList'] = implode(', ', Requests::get_tags($_GET['requestid']));
|
||||
}
|
||||
|
||||
if (!empty($ArtistForm)) {
|
||||
|
@ -3,8 +3,6 @@
|
||||
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
|
||||
$Text = new TEXT;
|
||||
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
|
||||
if (empty($_GET['id']) || !is_numeric($_GET['id']))
|
||||
error(404);
|
||||
|
||||
@ -720,7 +718,7 @@ function check_paranoia_here($Setting) {
|
||||
$CategoryName = $Categories[$CategoryID - 1];
|
||||
|
||||
if ($CategoryName == 'Music') {
|
||||
$ArtistForm = get_request_artists($RequestID);
|
||||
$ArtistForm = Requests::get_artists($RequestID);
|
||||
$ArtistLink = Artists::display_artists($ArtistForm, true, true);
|
||||
$FullName = $ArtistLink."<a href=\"requests.php?action=view&id=".$RequestID."\">$Title [$Year]</a>";
|
||||
} elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
|
||||
|
Loading…
Reference in New Issue
Block a user