mirror of
https://github.com/WhatCD/Gazelle.git
synced 2025-01-18 12:11:36 +00:00
Empty commit
This commit is contained in:
parent
328ef8b77a
commit
c10474d592
95
classes/bookmarks.class.php
Normal file
95
classes/bookmarks.class.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?
|
||||
class Bookmarks {
|
||||
|
||||
/**
|
||||
* Check if can bookmark
|
||||
*
|
||||
* @param string $Type
|
||||
* @return boolean
|
||||
*/
|
||||
public static function can_bookmark($Type) {
|
||||
return in_array($Type, array(
|
||||
'torrent',
|
||||
'artist',
|
||||
'collage',
|
||||
'request'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bookmark schema.
|
||||
* Recommended usage:
|
||||
* list($Table, $Col) = bookmark_schema('torrent');
|
||||
*
|
||||
* @param string $Type the type to get the schema for
|
||||
*/
|
||||
public static function bookmark_schema($Type) {
|
||||
switch ($Type) {
|
||||
case 'torrent':
|
||||
return array(
|
||||
'bookmarks_torrents',
|
||||
'GroupID'
|
||||
);
|
||||
break;
|
||||
case 'artist':
|
||||
return array(
|
||||
'bookmarks_artists',
|
||||
'ArtistID'
|
||||
);
|
||||
break;
|
||||
case 'collage':
|
||||
return array(
|
||||
'bookmarks_collages',
|
||||
'CollageID'
|
||||
);
|
||||
break;
|
||||
case 'request':
|
||||
return array(
|
||||
'bookmarks_requests',
|
||||
'RequestID'
|
||||
);
|
||||
break;
|
||||
default:
|
||||
die('HAX');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if something is bookmarked
|
||||
*
|
||||
* @param string $Type
|
||||
* type of bookmarks to check
|
||||
* @param int $ID
|
||||
* bookmark's id
|
||||
* @return boolean
|
||||
*/
|
||||
public static function has_bookmarked($Type, $ID) {
|
||||
return in_array($ID, self::all_bookmarks($Type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all bookmarks of a certain type for a user.
|
||||
* If UserID is false than defaults to $LoggedUser['ID']
|
||||
*
|
||||
* @param string $Type
|
||||
* type of bookmarks to fetch
|
||||
* @param int $UserID
|
||||
* userid whose bookmarks to get
|
||||
* @return array the bookmarks
|
||||
*/
|
||||
public static function all_bookmarks($Type, $UserID = false) {
|
||||
global $DB, $Cache, $LoggedUser;
|
||||
if ($UserID === false) {
|
||||
$UserID = $LoggedUser['ID'];
|
||||
}
|
||||
$CacheKey = 'bookmarks_' . $Type . '_' . $UserID;
|
||||
if (($Bookmarks = $Cache->get_value($CacheKey)) === FALSE) {
|
||||
list ($Table, $Col) = self::bookmark_schema($Type);
|
||||
$DB->query("SELECT $Col FROM $Table WHERE UserID = '$UserID'");
|
||||
$Bookmarks = $DB->collect($Col);
|
||||
$Cache->cache_value($CacheKey, $Bookmarks, 0);
|
||||
}
|
||||
return $Bookmarks;
|
||||
}
|
||||
}
|
||||
?>
|
@ -96,6 +96,9 @@
|
||||
case 'BencodeTorrent':
|
||||
$FileName = 'class_bencodetorrent';
|
||||
break;
|
||||
case 'Bookmarks':
|
||||
$FileName = 'bookmarks.class';
|
||||
break;
|
||||
case 'Format':
|
||||
$FileName = 'class_format';
|
||||
break;
|
||||
|
@ -4,7 +4,7 @@ function compare($X, $Y){
|
||||
return($Y['count'] - $X['count']);
|
||||
}
|
||||
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
|
||||
// Bookmarks::has_bookmarked()
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
|
||||
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
|
||||
@ -225,7 +225,7 @@ function compare($X, $Y){
|
||||
'releaseType' => (int) $ReleaseType,
|
||||
'wikiImage' => $WikiImage,
|
||||
'groupVanityHouse' => $GroupVanityHouse == 1,
|
||||
'hasBookmarked' => $hasBookmarked = has_bookmarked('torrent', $GroupID),
|
||||
'hasBookmarked' => $hasBookmarked = Bookmarks::has_bookmarked('torrent', $GroupID),
|
||||
'torrent' => $InnerTorrents
|
||||
);
|
||||
}
|
||||
@ -295,7 +295,7 @@ function compare($X, $Y){
|
||||
'id' => (int) $ArtistID,
|
||||
'name' => $Name,
|
||||
'notificationsEnabled' => $notificationsEnabled,
|
||||
'hasBookmarked' => has_bookmarked('artist', $ArtistID),
|
||||
'hasBookmarked' => Bookmarks::has_bookmarked('artist', $ArtistID),
|
||||
'image' => $Image,
|
||||
'body' => $Text->full_format($Body),
|
||||
'vanityHouse' => $VanityHouseArtist == 1,
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
$Sneaky = ($UserID != $LoggedUser['ID']);
|
||||
|
||||
//$ArtistList = all_bookmarks('artist', $UserID);
|
||||
//$ArtistList = Bookmarks::all_bookmarks('artist', $UserID);
|
||||
|
||||
$DB->query('SELECT ag.ArtistID, ag.Name
|
||||
FROM bookmarks_artists AS ba
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php');
|
||||
|
||||
|
||||
// Number of users per page
|
||||
define('BOOKMARKS_PER_PAGE', '20');
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?
|
||||
|
||||
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php');
|
||||
|
||||
include(SERVER_ROOT.'/sections/torrents/functions.php');
|
||||
|
||||
// The "order by x" links on columns headers
|
||||
@ -525,7 +525,7 @@ function header_link($SortKey,$DefaultWay="desc") {
|
||||
die();
|
||||
}
|
||||
|
||||
$Bookmarks = all_bookmarks('torrent');
|
||||
$Bookmarks = Bookmarks::all_bookmarks('torrent');
|
||||
|
||||
$JsonGroups = array();
|
||||
foreach ($Results as $Result) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
include(SERVER_ROOT.'/sections/requests/functions.php');
|
||||
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
|
||||
// Bookmarks::has_bookmarked()
|
||||
include(SERVER_ROOT.'/classes/class_text.php');
|
||||
$Text = new TEXT;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
require(SERVER_ROOT.'/sections/torrents/functions.php');
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php');
|
||||
|
||||
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
|
||||
$Text = new TEXT;
|
||||
|
||||
@ -51,7 +51,7 @@
|
||||
'categoryName' => $CategoryName,
|
||||
'time' => $TorrentDetails['Time'],
|
||||
'vanityHouse' => $TorrentDetails['VanityHouse'] == 1,
|
||||
'isBookmarked' => has_bookmarked('torrent', $GroupID),
|
||||
'isBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID),
|
||||
'musicInfo' => $JsonMusicInfo
|
||||
);
|
||||
|
||||
|
@ -6,7 +6,7 @@ function compare($X, $Y){
|
||||
return($Y['count'] - $X['count']);
|
||||
}
|
||||
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
|
||||
// Bookmarks::has_bookmarked()
|
||||
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
|
||||
$Text = new TEXT;
|
||||
|
||||
@ -383,7 +383,13 @@ function compare($X, $Y){
|
||||
</div>
|
||||
<? endif; ?>
|
||||
<div class="group_info clear">
|
||||
<strong><?=$DisplayName?></strong> <?Votes::vote_link($GroupID,$UserVotes[$GroupID]['Type']);?>
|
||||
<strong><?=$DisplayName?></strong>
|
||||
<? if (Bookmarks::has_bookmarked('torrent', $GroupID)) {
|
||||
echo " <a style = \"float: right;\" href=\"#\" id=\"bookmarklink_torrent_$GroupID\" class=\"remove_bookmark brackets\" title=\"Unbookmark\" onclick=\"Unbookmark('torrent',$GroupID,'Bookmark');return false;\">Unbookmark</a>";
|
||||
} else {
|
||||
echo " <a style = \"float: right;\" href=\"#\" id=\"bookmarklink_torrent_$GroupID\" class=\"add_bookmark brackets\" title=\"Bookmark\" onclick=\"Bookmark('torrent',$GroupID,'Unbookmark');return false;\">Bookmark</a>";
|
||||
} ?>
|
||||
<?Votes::vote_link($GroupID,$UserVotes[$GroupID]['Type']);?>
|
||||
<div class="tags"><?=$TorrentTags->format()?></div>
|
||||
</div>
|
||||
</td>
|
||||
@ -475,7 +481,7 @@ function compare($X, $Y){
|
||||
}
|
||||
}
|
||||
|
||||
if (has_bookmarked('artist', $ArtistID)) {
|
||||
if (Bookmarks::has_bookmarked('artist', $ArtistID)) {
|
||||
?>
|
||||
<a href="#" id="bookmarklink_artist_<?=$ArtistID?>" onclick="Unbookmark('artist', <?=$ArtistID?>,'Bookmark');return false;" class="brackets">Remove bookmark</a>
|
||||
|
||||
|
@ -4,13 +4,13 @@
|
||||
|
||||
authorize();
|
||||
|
||||
if (!can_bookmark($_GET['type'])) { error(404); }
|
||||
if (!Bookmarks::can_bookmark($_GET['type'])) { error(404); }
|
||||
$Feed = new FEED;
|
||||
$Text = new TEXT;
|
||||
|
||||
$Type = $_GET['type'];
|
||||
|
||||
list($Table, $Col) = bookmark_schema($Type);
|
||||
list($Table, $Col) = Bookmarks::bookmark_schema($Type);
|
||||
|
||||
if(!is_number($_GET['id'])) {
|
||||
error(0);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
$Sneaky = ($UserID != $LoggedUser['ID']);
|
||||
|
||||
//$ArtistList = all_bookmarks('artist', $UserID);
|
||||
//$ArtistList = Bookmarks::all_bookmarks('artist', $UserID);
|
||||
|
||||
$DB->query('SELECT ag.ArtistID, ag.Name
|
||||
FROM bookmarks_artists AS ba
|
||||
|
@ -1,44 +0,0 @@
|
||||
<?
|
||||
|
||||
function can_bookmark($Type) {
|
||||
return in_array($Type, array('torrent', 'artist', 'collage', 'request'));
|
||||
}
|
||||
|
||||
// Recommended usage:
|
||||
// list($Table, $Col) = bookmark_schema('torrent');
|
||||
function bookmark_schema($Type) {
|
||||
switch ($Type) {
|
||||
case 'torrent':
|
||||
return array('bookmarks_torrents', 'GroupID');
|
||||
break;
|
||||
case 'artist':
|
||||
return array('bookmarks_artists', 'ArtistID');
|
||||
break;
|
||||
case 'collage':
|
||||
return array('bookmarks_collages', 'CollageID');
|
||||
break;
|
||||
case 'request':
|
||||
return array('bookmarks_requests', 'RequestID');
|
||||
break;
|
||||
default:
|
||||
die('HAX');
|
||||
}
|
||||
}
|
||||
|
||||
function has_bookmarked($Type, $ID) {
|
||||
return in_array($ID, all_bookmarks($Type));
|
||||
}
|
||||
|
||||
function all_bookmarks($Type, $UserID = false) {
|
||||
global $DB, $Cache, $LoggedUser;
|
||||
if ($UserID === false) { $UserID = $LoggedUser['ID']; }
|
||||
$CacheKey = 'bookmarks_'.$Type.'_'.$UserID;
|
||||
if(($Bookmarks = $Cache->get_value($CacheKey)) === FALSE) {
|
||||
list($Table, $Col) = bookmark_schema($Type);
|
||||
$DB->query("SELECT $Col FROM $Table WHERE UserID = '$UserID'");
|
||||
$Bookmarks = $DB->collect($Col);
|
||||
$Cache->cache_value($CacheKey, $Bookmarks, 0);
|
||||
}
|
||||
return $Bookmarks;
|
||||
}
|
||||
?>
|
@ -1,6 +1,6 @@
|
||||
<?
|
||||
enforce_login();
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php');
|
||||
|
||||
|
||||
// Number of users per page
|
||||
define('BOOKMARKS_PER_PAGE', '20');
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
authorize();
|
||||
|
||||
if ($UserID != $LoggedUser['ID'] || !can_bookmark('torrent')) error(403);
|
||||
if ($UserID != $LoggedUser['ID'] || !Bookmarks::can_bookmark('torrent')) error(403);
|
||||
|
||||
if ($_POST['type'] === 'torrents') {
|
||||
// require_once SERVER_ROOT.'/classes/class_mass_user_bookmarks_editor.php'; //Bookmark Updater Class
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?
|
||||
authorize();
|
||||
|
||||
if (!can_bookmark($_GET['type'])) { error(404); }
|
||||
if (!Bookmarks::can_bookmark($_GET['type'])) { error(404); }
|
||||
|
||||
$Type = $_GET['type'];
|
||||
|
||||
list($Table, $Col) = bookmark_schema($Type);
|
||||
list($Table, $Col) = Bookmarks::bookmark_schema($Type);
|
||||
|
||||
if(!is_number($_GET['id'])) {
|
||||
error(0);
|
||||
|
@ -7,7 +7,7 @@ function compare($X, $Y){
|
||||
return($Y['count'] - $X['count']);
|
||||
}
|
||||
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
|
||||
// Bookmarks::has_bookmarked()
|
||||
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
|
||||
|
||||
$Text = new TEXT;
|
||||
@ -340,7 +340,7 @@ function compare($X, $Y){
|
||||
<? } else { ?>
|
||||
<span class="brackets">Locked</span>
|
||||
<? }
|
||||
if(has_bookmarked('collage', $CollageID)) {
|
||||
if(Bookmarks::has_bookmarked('collage', $CollageID)) {
|
||||
?>
|
||||
<a href="#" id="bookmarklink_collage_<?=$CollageID?>" class="brackets" onclick="Unbookmark('collage', <?=$CollageID?>,'Bookmark');return false;">Remove bookmark</a>
|
||||
<? } else { ?>
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is the page that displays the request to the end user after being created.
|
||||
*/
|
||||
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
|
||||
// Bookmarks::has_bookmarked()
|
||||
include(SERVER_ROOT.'/classes/class_text.php');
|
||||
|
||||
$Text = new TEXT;
|
||||
@ -93,7 +93,7 @@
|
||||
if($UserCanEdit || check_perms('users_mod')) { //check_perms('site_moderate_requests')) { ?>
|
||||
<a href="requests.php?action=delete&id=<?=$RequestID?>" class="brackets">Delete</a>
|
||||
<? } ?>
|
||||
<? if(has_bookmarked('request', $RequestID)) { ?>
|
||||
<? if(Bookmarks::has_bookmarked('request', $RequestID)) { ?>
|
||||
<a href="#" id="bookmarklink_request_<?=$RequestID?>" onclick="Unbookmark('request', <?=$RequestID?>,'Bookmark');return false;" class="brackets">Remove bookmark</a>
|
||||
<? } else { ?>
|
||||
<a href="#" id="bookmarklink_request_<?=$RequestID?>" onclick="Bookmark('request', <?=$RequestID?>,'Remove bookmark');return false;" class="brackets">Bookmark</a>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
|
||||
// Bookmarks::has_bookmarked()
|
||||
|
||||
$Where = array();
|
||||
|
||||
@ -420,7 +420,7 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
|
||||
$Format,$Encoding,$Media,$Scene,$HasLog,$HasCue,$LogScore,$Year,$GroupYear,
|
||||
$RemasterTitle,$Snatched,$Seeders,$Leechers,$Data,$ReleaseType,$Size) = $Detail;
|
||||
|
||||
$IsBookmarked = has_bookmarked('torrent', $GroupID);
|
||||
$IsBookmarked = Bookmarks::has_bookmarked('torrent', $GroupID);
|
||||
$IsSnatched = Torrents::has_snatched($TorrentID);
|
||||
|
||||
// highlight every other row
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?
|
||||
// We need these to do our rankification
|
||||
include(SERVER_ROOT.'/sections/torrents/ranking_funcs.php');
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php');
|
||||
|
||||
|
||||
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
|
||||
|
||||
@ -125,7 +125,7 @@
|
||||
<?
|
||||
}
|
||||
|
||||
$Bookmarks = all_bookmarks('torrent');
|
||||
$Bookmarks = Bookmarks::all_bookmarks('torrent');
|
||||
?>
|
||||
<h3>Top <?=$Limit.' '.$Caption?>
|
||||
<?
|
||||
|
@ -20,7 +20,7 @@
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php');
|
||||
|
||||
include(SERVER_ROOT.'/sections/torrents/functions.php');
|
||||
|
||||
|
||||
@ -871,7 +871,7 @@ function header_link($SortKey,$DefaultWay="desc") {
|
||||
// List of pages
|
||||
$Pages = Format::get_pages($Page, $TorrentCount, TORRENTS_PER_PAGE);
|
||||
|
||||
$Bookmarks = all_bookmarks('torrent');
|
||||
$Bookmarks = Bookmarks::all_bookmarks('torrent');
|
||||
?>
|
||||
|
||||
<div class="linkbox"><?=$Pages?></div>
|
||||
|
@ -7,7 +7,7 @@ function compare($X, $Y){
|
||||
define('MAX_PERS_COLLAGES', 3); // How many personal collages should be shown by default
|
||||
define('MAX_COLLAGES', 5); // How many normal collages should be shown by default
|
||||
|
||||
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
|
||||
// Bookmarks::has_bookmarked()
|
||||
include(SERVER_ROOT.'/classes/class_text.php');
|
||||
|
||||
$Text = NEW TEXT;
|
||||
@ -93,7 +93,7 @@ function compare($X, $Y){
|
||||
<? if($RevisionID && check_perms('site_edit_wiki')) { ?>
|
||||
<a href="/torrents.php?action=revert&groupid=<?=$GroupID ?>&revisionid=<?=$RevisionID ?>&auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Revert to this revision</a>
|
||||
<? }
|
||||
if(has_bookmarked('torrent', $GroupID)) {
|
||||
if(Bookmarks::has_bookmarked('torrent', $GroupID)) {
|
||||
?>
|
||||
<a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="remove_bookmark brackets" title="Remove bookmark" onclick="Unbookmark('torrent',<?=$GroupID?>,'Bookmark');return false;">Unbookmark</a>
|
||||
<? } else { ?>
|
||||
|
Loading…
Reference in New Issue
Block a user