Gazelle/sections/userhistory/subscribed_collages.php

282 lines
10 KiB
PHP
Raw Normal View History

<?
/*
User collage subscription page
*/
2013-04-17 08:00:58 +00:00
if (!check_perms('site_collages_subscribe')) {
error(403);
}
2012-10-11 08:00:15 +00:00
View::show_header('Subscribed collages','browse,collage');
$ShowAll = !empty($_GET['showall']);
if (!$ShowAll) {
2013-05-01 08:00:16 +00:00
$sql = "
SELECT
c.ID,
c.Name,
c.NumTorrents,
s.LastVisit
FROM collages AS c
JOIN users_collage_subs AS s ON s.CollageID = c.ID
JOIN collages_torrents AS ct ON ct.CollageID = c.ID
2013-07-04 08:00:56 +00:00
WHERE s.UserID = $LoggedUser[ID] AND c.Deleted = '0'
AND ct.AddedOn > s.LastVisit
2013-05-01 08:00:16 +00:00
GROUP BY c.ID";
} else {
2013-05-01 08:00:16 +00:00
$sql = "
SELECT
c.ID,
c.Name,
c.NumTorrents,
s.LastVisit
FROM collages AS c
JOIN users_collage_subs AS s ON s.CollageID = c.ID
LEFT JOIN collages_torrents AS ct ON ct.CollageID = c.ID
2013-07-04 08:00:56 +00:00
WHERE s.UserID = $LoggedUser[ID] AND c.Deleted = '0'
2013-05-01 08:00:16 +00:00
GROUP BY c.ID";
}
$DB->query($sql);
$NumResults = $DB->record_count();
$CollageSubs = $DB->to_array();
?>
<div class="thin">
2012-08-19 08:00:19 +00:00
<div class="header">
2013-04-17 08:00:58 +00:00
<h2>Subscribed collages<?=($ShowAll ? '' : ' with new additions')?></h2>
2012-08-19 08:00:19 +00:00
<div class="linkbox">
<?
2013-04-17 08:00:58 +00:00
if ($ShowAll) {
?>
<br /><br />
2013-02-09 08:01:01 +00:00
<a href="userhistory.php?action=subscribed_collages&amp;showall=0" class="brackets">Only display collages with new additions</a>&nbsp;&nbsp;&nbsp;
<?
} else {
?>
<br /><br />
2013-02-09 08:01:01 +00:00
<a href="userhistory.php?action=subscribed_collages&amp;showall=1" class="brackets">Show all subscribed collages</a>&nbsp;&nbsp;&nbsp;
<?
}
?>
2013-02-09 08:01:01 +00:00
<a href="userhistory.php?action=catchup_collages&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;
2012-08-19 08:00:19 +00:00
</div>
</div>
<?
2013-04-17 08:00:58 +00:00
if (!$NumResults) {
?>
<div class="center">
2013-02-25 21:16:55 +00:00
No subscribed collages<?=($ShowAll ? '' : ' with new additions')?>
</div>
<?
} else {
2013-05-01 08:00:16 +00:00
$HideGroup = '';
$ActionTitle = 'Hide';
$ActionURL = 'hide';
$ShowGroups = 0;
2013-02-15 08:00:35 +00:00
foreach ($CollageSubs as $Collage) {
unset($TorrentTable);
2013-02-15 08:00:35 +00:00
list($CollageID, $CollageName, $CollageSize, $LastVisit) = $Collage;
2013-07-04 08:00:56 +00:00
$RS = $DB->query("
SELECT GroupID
FROM collages_torrents
WHERE CollageID = $CollageID
AND AddedOn > '" . db_string($LastVisit) . "'
ORDER BY AddedOn");
$NewTorrentCount = $DB->record_count();
2013-02-15 08:00:35 +00:00
2013-09-13 08:00:53 +00:00
$GroupIDs = $DB->collect('GroupID', false);
2013-04-17 08:00:58 +00:00
if (count($GroupIDs) > 0) {
2012-10-11 08:00:15 +00:00
$TorrentList = Torrents::get_groups($GroupIDs);
} else {
$TorrentList = array();
}
2013-02-15 08:00:35 +00:00
2012-10-11 08:00:15 +00:00
$Artists = Artists::get_artists($GroupIDs);
$Number = 0;
2013-02-15 08:00:35 +00:00
2014-05-07 08:00:45 +00:00
foreach ($GroupIDs as $GroupID) {
if (!isset($TorrentList[$GroupID])) {
continue;
}
$Group = $TorrentList[$GroupID];
2013-02-25 21:16:55 +00:00
extract(Torrents::array_group($Group));
2013-02-25 21:16:55 +00:00
$DisplayName = '';
2013-02-15 08:00:35 +00:00
2013-02-25 21:16:55 +00:00
$TorrentTags = new Tags($TagList);
2013-02-15 08:00:35 +00:00
2011-11-21 08:00:23 +00:00
if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) {
unset($ExtendedArtists[2]);
unset($ExtendedArtists[3]);
2012-10-11 08:00:15 +00:00
$DisplayName .= Artists::display_artists($ExtendedArtists);
2013-04-17 08:00:58 +00:00
} elseif (count($Artists) > 0) {
2013-07-04 08:00:56 +00:00
$DisplayName .= Artists::display_artists(array('1' => $Artists));
}
2013-10-26 08:00:58 +00:00
$DisplayName .= "<a href=\"torrents.php?id=$GroupID\" class=\"tooltip\" title=\"View torrent group\" dir=\"ltr\">$GroupName</a>";
2013-04-17 08:00:58 +00:00
if ($GroupYear > 0) {
2013-07-04 08:00:56 +00:00
$DisplayName = "$DisplayName [$GroupYear]";
2013-04-17 08:00:58 +00:00
}
if ($GroupVanityHouse) {
2013-10-26 08:00:58 +00:00
$DisplayName .= ' [<abbr class="tooltip" title="This is a Vanity House release">VH</abbr>]';
2013-04-17 08:00:58 +00:00
}
2012-12-06 08:00:17 +00:00
$SnatchedGroupClass = $GroupFlags['IsSnatched'] ? ' snatched_group' : '';
2013-02-15 08:00:35 +00:00
// Start an output buffer, so we can store this output in $TorrentTable
2013-02-15 08:00:35 +00:00
ob_start();
2013-04-17 08:00:58 +00:00
if (count($Torrents) > 1 || $GroupCategoryID == 1) {
?>
2012-12-06 08:00:17 +00:00
<tr class="group discog<?=$SnatchedGroupClass?>" id="group_<?=$CollageID?><?=$GroupID?>">
<td class="center">
2013-08-28 23:08:41 +00:00
<div id="showimg_<?=$CollageID?><?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
<a href="#" class="tooltip show_torrents_link" onclick="toggle_group(<?=$CollageID?><?=$GroupID?>, this, event);" title="Expand this group. Hold &quot;Ctrl&quot; while clicking to expand all groups on this page."></a>
</div>
</td>
2013-02-25 21:16:55 +00:00
<td colspan="5" class="big_info">
2013-08-28 23:08:41 +00:00
<? if ($LoggedUser['CoverArt']) { ?>
2013-02-25 21:16:55 +00:00
<div class="group_image float_left clear">
2013-04-30 18:18:07 +00:00
<? ImageTools::cover_thumb($WikiImage, $GroupCategoryID) ?>
2013-02-25 21:16:55 +00:00
</div>
2013-08-28 23:08:41 +00:00
<? } ?>
2013-02-25 21:16:55 +00:00
<div class="group_info clear">
<strong><?=$DisplayName?></strong>
<div class="tags"><?=$TorrentTags->format()?></tags>
</div>
</td>
</tr>
<?
$LastRemasterYear = '-';
$LastRemasterTitle = '';
$LastRemasterRecordLabel = '';
$LastRemasterCatalogueNumber = '';
$LastMedia = '';
2013-02-15 08:00:35 +00:00
$EditionID = 0;
unset($FirstUnknown);
2013-02-15 08:00:35 +00:00
foreach ($Torrents as $TorrentID => $Torrent) {
if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) {
$FirstUnknown = !isset($FirstUnknown);
}
2012-12-06 08:00:17 +00:00
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
2013-02-15 08:00:35 +00:00
2013-07-04 08:00:56 +00:00
if ($Torrent['RemasterTitle'] != $LastRemasterTitle
|| $Torrent['RemasterYear'] != $LastRemasterYear
|| $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel
|| $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber
|| $FirstUnknown
|| $Torrent['Media'] != $LastMedia
) {
2013-03-17 08:00:17 +00:00
$EditionID++;
?>
2012-12-06 08:00:17 +00:00
<tr class="group_torrent groupid_<?=$CollageID . $GroupID?> edition<?=$SnatchedGroupClass?> hidden">
2013-08-28 23:08:41 +00:00
<td colspan="6" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$CollageID?><?=$GroupID?>, <?=$EditionID?>, this, event);" class="tooltip" title="Collapse this edition. Hold &quot;Ctrl&quot; while clicking to collapse all editions in this torrent group.">&minus;</a> <?=Torrents::edition_string($Torrent, $Group)?></strong></td>
</tr>
<?
}
$LastRemasterTitle = $Torrent['RemasterTitle'];
$LastRemasterYear = $Torrent['RemasterYear'];
$LastRemasterRecordLabel = $Torrent['RemasterRecordLabel'];
$LastRemasterCatalogueNumber = $Torrent['RemasterCatalogueNumber'];
$LastMedia = $Torrent['Media'];
?>
2012-12-06 08:00:17 +00:00
<tr class="group_torrent groupid_<?=$CollageID . $GroupID?> edition_<?=$EditionID?> hidden<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
2013-02-25 21:16:55 +00:00
<td colspan="2">
<span>
2013-10-26 08:00:58 +00:00
<a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download" class="brackets tooltip">DL</a>
</span>
2012-10-11 08:00:15 +00:00
&nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
</td>
2013-08-28 23:08:41 +00:00
<td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
<td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
<td class="number_column<?=($Torrent['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Torrent['Seeders'])?></td>
<td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
</tr>
<?
}
} else {
// Viewing a type that does not require grouping
2013-02-15 08:00:35 +00:00
list($TorrentID, $Torrent) = each($Torrents);
2013-02-15 08:00:35 +00:00
2013-10-26 08:00:58 +00:00
$DisplayName = "<a href=\"torrents.php?id=$GroupID\" class=\"tooltip\" title=\"View torrent group\" dir=\"ltr\">$GroupName</a>";
2013-02-15 08:00:35 +00:00
2013-04-17 08:00:58 +00:00
if ($Torrent['IsSnatched']) {
2013-07-04 08:00:56 +00:00
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
2012-11-04 08:00:20 +00:00
}
2013-04-17 08:00:58 +00:00
if (!empty($Torrent['FreeTorrent'])) {
2013-07-04 08:00:56 +00:00
$DisplayName .= ' ' . Format::torrent_label('Freeleech!');
}
2012-12-06 08:00:17 +00:00
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>
2012-12-06 08:00:17 +00:00
<tr class="torrent<?=$SnatchedTorrentClass?>" id="group_<?=$CollageID . $GroupID?>">
<td></td>
<td class="center">
2013-10-26 08:00:58 +00:00
<div title="<?=$TorrentTags->title()?>" class="tooltip <?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>">
</div>
</td>
2013-02-25 21:16:55 +00:00
<td class="big_info">
2013-08-28 23:08:41 +00:00
<? if ($LoggedUser['CoverArt']) { ?>
2013-02-25 21:16:55 +00:00
<div class="group_image float_left clear">
2013-04-30 18:18:07 +00:00
<? ImageTools::cover_thumb($WikiImage, $GroupCategoryID) ?>
2013-02-25 21:16:55 +00:00
</div>
2013-08-28 23:08:41 +00:00
<? } ?>
2013-02-25 21:16:55 +00:00
<div class="group_info clear">
<span>
2013-10-26 08:00:58 +00:00
[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
2013-02-25 21:16:55 +00:00
</span>
<strong><?=$DisplayName?></strong>
<div class="tags"><?=$TorrentTags->format()?></div>
</div>
</td>
2013-08-28 23:08:41 +00:00
<td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
<td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
<td class="number_column<?=($Torrent['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Torrent['Seeders'])?></td>
<td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
</tr>
<?
}
2013-08-28 23:08:41 +00:00
$TorrentTable .= ob_get_clean();
} ?>
<!-- I hate that proton is making me do it like this -->
2013-05-01 08:00:16 +00:00
<!--<div class="head colhead_dark" style="margin-top: 8px;">-->
<table style="margin-top: 8px;" class="subscribed_collages_table">
<tr class="colhead_dark">
<td>
2013-05-01 08:00:16 +00:00
<span style="float: left;">
<strong><a href="collage.php?id=<?=$CollageID?>"><?=$CollageName?></a></strong> (<?=$NewTorrentCount?> new torrent<?=($NewTorrentCount == 1 ? '' : 's')?>)
</span>&nbsp;
2013-05-01 08:00:16 +00:00
<span style="float: right;">
2013-06-17 08:01:02 +00:00
<a href="#" onclick="$('#discog_table_<?=$CollageID?>').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets"><?=($ShowAll ? 'Show' : 'Hide')?></a>&nbsp;&nbsp;&nbsp;<a href="userhistory.php?action=catchup_collages&amp;auth=<?=$LoggedUser['AuthKey']?>&amp;collageid=<?=$CollageID?>" class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;<a href="#" onclick="CollageSubscribe(<?=$CollageID?>); return false;" id="subscribelink<?=$CollageID?>" class="brackets">Unsubscribe</a>
</span>
</td>
</tr>
</table>
<!--</div>-->
2013-07-04 08:00:56 +00:00
<table class="torrent_table<?=$ShowAll ? ' hidden' : ''?>" id="discog_table_<?=$CollageID?>">
<tr class="colhead">
<td width="1%"><!-- expand/collapse --></td>
<td width="70%"><strong>Torrents</strong></td>
<td>Size</td>
2013-11-01 08:01:02 +00:00
<td class="sign snatches"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/snatched.png" class="tooltip" alt="Snatches" title="Snatches" /></td>
<td class="sign seeders"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/seeders.png" class="tooltip" alt="Seeders" title="Seeders" /></td>
<td class="sign leechers"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/leechers.png" class="tooltip" alt="Leechers" title="Leechers" /></td>
2013-07-04 08:00:56 +00:00
</tr>
<?=$TorrentTable?>
2013-07-04 08:00:56 +00:00
</table>
<?
2013-07-04 08:00:56 +00:00
} // foreach ()
} // else -- if (empty($NumResults))
?>
</div>
<?
2012-10-11 08:00:15 +00:00
View::show_footer();
?>