From ef45b77859c347ff727c6a446b8c2bcc67c5765c Mon Sep 17 00:00:00 2001 From: Git Date: Tue, 5 Mar 2013 08:00:26 +0000 Subject: [PATCH] Empty commit --- artist.php | 6 +- classes/class_image_tools.php | 12 +- classes/class_misc.php | 19 +++ gazelle.sql | 7 ++ sections/ajax/get_friends.php | 13 +++ sections/ajax/index.php | 6 + sections/ajax/send_recommendation.php | 56 +++++++++ sections/artist/artist.php | 11 +- sections/collages/collage.php | 11 +- sections/reportsv2/ajax_grab_report.php | 2 +- sections/reportsv2/ajax_new_report.php | 10 +- sections/reportsv2/static.php | 14 +-- sections/reportsv2/views.php | 2 +- sections/rules/upload.php | 16 +-- sections/tools/data/suggestions.php | 149 ------------------------ sections/torrents/details.php | 6 +- sections/user/edit.php | 13 +++ sections/user/takeedit.php | 18 +++ static/functions/delays.js | 60 ---------- static/functions/recommend.js | 73 ++++++++++++ 20 files changed, 256 insertions(+), 248 deletions(-) create mode 100644 sections/ajax/get_friends.php create mode 100644 sections/ajax/send_recommendation.php delete mode 100644 sections/tools/data/suggestions.php delete mode 100644 static/functions/delays.js create mode 100644 static/functions/recommend.js diff --git a/artist.php b/artist.php index 3bccec6b..e004aa1a 100644 --- a/artist.php +++ b/artist.php @@ -1,5 +1,7 @@ +
class="center"> +
+ Recommend to: + + +
+

+
+ diff --git a/gazelle.sql b/gazelle.sql index b10c1df7..7ea8fd15 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -1214,6 +1214,13 @@ CREATE TABLE `users_dupes` ( CONSTRAINT `users_dupes_ibfk_2` FOREIGN KEY (`GroupID`) REFERENCES `dupe_groups` (`ID`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +CREATE TABLE `users_enable_recommendations` ( + `ID` int(10) NOT NULL, + `Enable` tinyint(1) DEFAULT NULL, + PRIMARY KEY (`ID`), + KEY `Enable` (`Enable`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE `users_freeleeches` ( `UserID` int(10) NOT NULL, `TorrentID` int(10) NOT NULL, diff --git a/sections/ajax/get_friends.php b/sections/ajax/get_friends.php new file mode 100644 index 00000000..0b9d7407 --- /dev/null +++ b/sections/ajax/get_friends.php @@ -0,0 +1,13 @@ +query("SELECT + f.FriendID, u.Username + FROM friends AS f + RIGHT JOIN users_enable_recommendations AS r + ON r.ID = f.FriendID AND r.Enable = 1 + RIGHT JOIN users_main AS u + ON u.ID = f.FriendID + WHERE f.UserID = '$LoggedUser[ID]' + ORDER BY u.Username ASC"); +echo json_encode($DB->to_array(false, MYSQLI_ASSOC)); +die(); diff --git a/sections/ajax/index.php b/sections/ajax/index.php index 999635de..dcf0334d 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -135,6 +135,12 @@ case 'wiki': require(SERVER_ROOT . '/sections/ajax/wiki.php'); break; + case 'send_recommendation': + require(SERVER_ROOT . '/sections/ajax/send_recommendation.php'); + break; + case 'get_friends': + require(SERVER_ROOT . '/sections/ajax/get_friends.php'); + break; default: // If they're screwing around with the query string print json_encode(array('status' => 'failure')); diff --git a/sections/ajax/send_recommendation.php b/sections/ajax/send_recommendation.php new file mode 100644 index 00000000..101e0598 --- /dev/null +++ b/sections/ajax/send_recommendation.php @@ -0,0 +1,56 @@ + "error", "response" => "Error.")); + die(); +} +// Make sure the recipient is on your friends list and not some random dude. +$DB->query("SELECT + f.FriendID, u.Username + FROM friends AS f + JOIN users_enable_recommendations AS r + ON r.ID = f.FriendID AND r.Enable = 1 + LEFT JOIN users_main AS u + ON u.ID = f.FriendID + WHERE f.UserID = '$LoggedUser[ID]' AND f.FriendID = '$FriendID'"); + +if($DB->record_count() == 0) { + echo json_encode(array("status" => "error", "response" => "Not on friend list.")); + die(); +} + +$Type = strtolower($Type); +$Link = ""; +// "a" vs "an", english language is so confusing. +// http://en.wikipedia.org/wiki/English_articles#Distinction_between_a_and_an +$Article = "a"; +switch($Type) { + case 'torrent': + $Link = "torrents.php?id=".$ID; + $DB->query("SELECT Name FROM torrents_group WHERE ID = '$ID'"); + break; + case 'artist': + $Article = "an"; + $Link = "artist.php?id=".$ID; + $DB->query("SELECT Name FROM artists_group WHERE ArtistID = '$ID'"); + break; + case 'collage': + $Link = "collages.php?id=".$ID; + $DB->query("SELECT Name FROM collages WHERE ID = '$ID'"); + break; +} +list($Name) = $DB->next_record(); +$Subject = $LoggedUser['Username'] . " recommended you $Article " . $Type . "!"; +$Body = $LoggedUser['Username'] . " recommended you the ".$Type." [url=https://".NONSSL_SITE_URL."/".$Link."]".$Name."[/url]."; +if(!empty($Note)) { + $Body = $Body . "\n\n". $Note; +} + +Misc::send_pm($FriendID, $LoggedUser['ID'], $Subject, $Body); +echo json_encode(array("status" => "success", "response" => "Sent!")); +die(); + diff --git a/sections/artist/artist.php b/sections/artist/artist.php index 6a8905ab..f2951438 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -472,7 +472,7 @@ function compare($X, $Y){ //----------------- End building list and getting stats -View::show_header($Name, 'browse,requests,bbcode,comments,voting,jquery'); +View::show_header($Name, 'browse,requests,bbcode,comments,voting,jquery,recommend'); ?>
@@ -509,7 +509,9 @@ function compare($X, $Y){ Bookmark + Recommend + Edit @@ -531,8 +533,9 @@ function compare($X, $Y){
-
- + +