Gazelle/sections/artist/notify.php

57 lines
1.5 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
2013-04-13 08:00:19 +00:00
if (!check_perms('site_torrents_notify')) {
error(403);
}
2011-03-28 14:21:28 +00:00
$ArtistID = $_GET['artistid'];
2013-04-13 08:00:19 +00:00
if (!is_number($ArtistID)) {
error(0);
}
2011-03-28 14:21:28 +00:00
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT GROUP_CONCAT(Name SEPARATOR '|')
FROM artists_alias
WHERE ArtistID = '$ArtistID'
AND Redirect = 0
GROUP BY ArtistID");
2011-03-28 14:21:28 +00:00
list($ArtistAliases) = $DB->next_record(MYSQLI_NUM, FALSE);
$Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID']);
2013-04-13 08:00:19 +00:00
if (empty($Notify)) {
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT ID, Artists
FROM users_notify_filters
2013-07-10 00:08:53 +00:00
WHERE Label = 'Artist notifications'
AND UserID = '$LoggedUser[ID]'
2013-05-27 08:00:58 +00:00
ORDER BY ID
LIMIT 1");
2011-03-28 14:21:28 +00:00
} else {
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT ID, Artists
FROM users_notify_filters
2013-07-10 00:08:53 +00:00
WHERE ID = '$Notify[ID]'");
2011-03-28 14:21:28 +00:00
}
2013-07-10 00:08:53 +00:00
if (empty($Notify) && !$DB->has_results()) {
2013-05-27 08:00:58 +00:00
$DB->query("
2013-07-10 00:08:53 +00:00
INSERT INTO users_notify_filters
(UserID, Label, Artists)
VALUES
('$LoggedUser[ID]', 'Artist notifications', '|".db_string($ArtistAliases)."|')");
2011-03-28 14:21:28 +00:00
$FilterID = $DB->inserted_id();
$Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
$Cache->delete_value('notify_artists_'.$LoggedUser['ID']);
} else {
list($ID, $ArtistNames) = $DB->next_record(MYSQLI_NUM, FALSE);
2013-12-07 08:00:49 +00:00
if (stripos($ArtistNames, "|$ArtistAliases|") === false) {
2013-07-10 00:08:53 +00:00
$ArtistNames .= "$ArtistAliases|";
2013-05-27 08:00:58 +00:00
$DB->query("
UPDATE users_notify_filters
2013-07-10 00:08:53 +00:00
SET Artists = '".db_string($ArtistNames)."'
WHERE ID = '$ID'");
2011-03-28 14:21:28 +00:00
$Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
$Cache->delete_value('notify_artists_'.$LoggedUser['ID']);
}
}
header('Location: '.$_SERVER['HTTP_REFERER']);
?>