2011-03-28 14:21:28 +00:00
< ?
2013-04-13 08:00:19 +00:00
if ( ! check_perms ( 'site_torrents_notify' )) {
error ( 403 );
}
2013-06-09 08:01:21 +00:00
View :: show_header ( 'Manage notifications' , 'jquery,jquery.validate,form_validate' );
2011-03-28 14:21:28 +00:00
?>
< div class = " thin " >
2012-08-19 08:00:19 +00:00
< div class = " header " >
2013-02-16 08:00:57 +00:00
< h2 > Notify me of all new torrents with ...</ h2 >
< div class = " linkbox " >
< a href = " torrents.php?action=notify " class = " brackets " > View notifications </ a >
</ div >
2012-08-19 08:00:19 +00:00
</ div >
2011-03-28 14:21:28 +00:00
< ?
2013-05-15 08:00:54 +00:00
$DB -> query ( "
2013-05-23 08:01:12 +00:00
SELECT
ID ,
Label ,
Artists ,
ExcludeVA ,
NewGroupsOnly ,
Tags ,
NotTags ,
ReleaseTypes ,
Categories ,
Formats ,
Encodings ,
Media ,
FromYear ,
ToYear ,
Users
2013-05-15 08:00:54 +00:00
FROM users_notify_filters
2013-06-06 08:01:03 +00:00
WHERE UserID = $LoggedUser [ ID ] " );
$NumFilters = $DB -> record_count ();
2011-03-28 14:21:28 +00:00
$Notifications = $DB -> to_array ();
2013-06-06 08:01:03 +00:00
$Notifications [] = array (
'ID' => false ,
'Label' => '' ,
'Artists' => '' ,
'ExcludeVA' => false ,
'NewGroupsOnly' => true ,
'Tags' => '' ,
'NotTags' => '' ,
'ReleaseTypes' => '' ,
'Categories' => '' ,
'Formats' => '' ,
'Encodings' => '' ,
'Media' => '' ,
'FromYear' => '' ,
'ToYear' => '' ,
'Users' => ''
);
2011-03-28 14:21:28 +00:00
2013-06-06 08:01:03 +00:00
$i = 0 ;
2013-05-23 08:01:12 +00:00
foreach ( $Notifications as $N ) { // $N stands for Notifications
2013-06-06 08:01:03 +00:00
$i ++ ;
$NewFilter = $N [ 'ID' ] === false ;
2013-05-15 08:00:54 +00:00
$N [ 'Artists' ] = implode ( ', ' , explode ( '|' , substr ( $N [ 'Artists' ], 1 , - 1 )));
$N [ 'Tags' ] = implode ( ', ' , explode ( '|' , substr ( $N [ 'Tags' ], 1 , - 1 )));
$N [ 'NotTags' ] = implode ( ', ' , explode ( '|' , substr ( $N [ 'NotTags' ], 1 , - 1 )));
$N [ 'ReleaseTypes' ] = explode ( '|' , substr ( $N [ 'ReleaseTypes' ], 1 , - 1 ));
$N [ 'Categories' ] = explode ( '|' , substr ( $N [ 'Categories' ], 1 , - 1 ));
$N [ 'Formats' ] = explode ( '|' , substr ( $N [ 'Formats' ], 1 , - 1 ));
$N [ 'Encodings' ] = explode ( '|' , substr ( $N [ 'Encodings' ], 1 , - 1 ));
2013-05-23 08:01:12 +00:00
$N [ 'Media' ] = explode ( '|' , substr ( $N [ 'Media' ], 1 , - 1 ));
$N [ 'Users' ] = explode ( '|' , substr ( $N [ 'Users' ], 1 , - 1 ));
2013-05-30 08:00:30 +00:00
$Usernames = '' ;
2013-05-24 08:00:59 +00:00
foreach ( $N [ 'Users' ] as $UserID ) {
2013-05-23 08:01:12 +00:00
$UserInfo = Users :: user_info ( $UserID );
$Usernames .= $UserInfo [ 'Username' ] . ', ' ;
}
$Usernames = rtrim ( $Usernames , ', ' );
if ( $N [ 'FromYear' ] == 0 ) {
2013-05-15 08:00:54 +00:00
$N [ 'FromYear' ] = '' ;
}
if ( $N [ 'ToYear' ] == 0 ) {
$N [ 'ToYear' ] = '' ;
}
2013-06-06 08:01:03 +00:00
if ( $NewFilter && $NumFilters > 0 ) {
?>
< br />< br />
< h3 > Create a new notification filter </ h3 >
2013-05-15 08:00:54 +00:00
< ? } elseif ( $NumFilters > 0 ) { ?>
2013-06-06 08:01:03 +00:00
< h3 >
< a href = " feeds.php?feed=torrents_notify_<?= $N['ID'] ?>_<?= $LoggedUser['torrent_pass'] ?>&user=<?= $LoggedUser['ID'] ?>&auth=<?= $LoggedUser['RSS_Auth'] ?>&passkey=<?= $LoggedUser['torrent_pass'] ?>&authkey=<?= $LoggedUser['AuthKey'] ?>&name=<?=urlencode( $N['Label'] )?> " >< img src = " <?=STATIC_SERVER?>/common/symbols/rss.png " alt = " RSS feed " /></ a >
< ? = display_str ( $N [ 'Label' ]) ?>
< a href = " user.php?action=notify_delete&id=<?= $N['ID'] ?>&auth=<?= $LoggedUser['AuthKey'] ?> " onclick = " return confirm('Are you sure you want to delete this notification filter?') " class = " brackets " > Delete </ a >
< a href = " # " onclick = " $ ('#filter_<?= $N['ID'] ?>').toggle(); return false; " class = " brackets " > Show </ a >
</ h3 >
2011-03-28 14:21:28 +00:00
< ? } ?>
2013-06-09 08:01:21 +00:00
< form class = " <?=( $NewFilter ? 'create_form' : 'edit_form')?> " id = " <?=( $NewFilter ? 'filter_form' : '')?> " name = " notification " action = " user.php " method = " post " >
2012-06-16 08:00:18 +00:00
< input type = " hidden " name = " formid " value = " <?= $i ?> " />
2011-03-28 14:21:28 +00:00
< input type = " hidden " name = " action " value = " notify_handle " />
< input type = " hidden " name = " auth " value = " <?= $LoggedUser['AuthKey'] ?> " />
2013-06-06 08:01:03 +00:00
< ? if ( ! $NewFilter ) { ?>
< input type = " hidden " name = " id<?= $i ?> " value = " <?= $N['ID'] ?> " />
< ? } ?>
< table < ? = ( ! $NewFilter ? 'id="filter_' . $N [ 'ID' ] . '" class="layout hidden"' : 'class="layout"' ) ?> >
< ? if ( $NewFilter ) { ?>
2011-03-28 14:21:28 +00:00
< tr >
2013-05-15 08:00:54 +00:00
< td class = " label " >< strong > Notification filter name </ strong ></ td >
2011-03-28 14:21:28 +00:00
< td >
2013-06-09 08:01:21 +00:00
< input type = " text " class = " required " name = " label<?= $i ?> " style = " width: 100%; " />
2013-05-15 08:00:54 +00:00
< p class = " min_padding " > A name for the notification filter set to tell different filters apart .</ p >
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
< tr >
< td colspan = " 2 " class = " center " >
< strong > All fields below here are optional </ strong >
</ td >
</ tr >
< ? } ?>
< tr >
< td class = " label " >< strong > One of these artists </ strong ></ td >
< td >
2013-05-15 08:00:54 +00:00
< textarea name = " artists<?= $i ?> " style = " width: 100%; " rows = " 5 " >< ? = display_str ( $N [ 'Artists' ]) ?> </textarea>
2013-02-16 08:00:57 +00:00
< p class = " min_padding " > Comma - separated list & mdash ; e . g . < em > Pink Floyd , Led Zeppelin , Neil Young </ em ></ p >
2013-04-13 08:00:19 +00:00
< input type = " checkbox " name = " excludeva<?= $i ?> " id = " excludeva_<?= $N['ID'] ?> " < ? if ( $N [ 'ExcludeVA' ] == '1' ) { echo ' checked="checked"' ;} ?> />
2011-03-28 14:21:28 +00:00
< label for = " excludeva_<?= $N['ID'] ?> " > Exclude Various Artists releases </ label >
2013-05-30 08:00:30 +00:00
</ td >
</ tr >
2013-05-23 08:01:12 +00:00
< tr >
< td class = " label " >< strong > One of these users </ strong ></ td >
< td >
2013-05-25 08:01:03 +00:00
< textarea name = " users<?= $i ?> " style = " width: 100%; " rows = " 5 " >< ? = display_str ( $Usernames ) ?> </textarea>
2013-06-06 08:01:03 +00:00
< p class = " min_padding " > Comma - separated list of usernames </ p >
2011-03-28 14:21:28 +00:00
</ td >
2013-05-23 08:01:12 +00:00
</ tr >
< tr >
2011-03-28 14:21:28 +00:00
< td class = " label " >< strong > At least one of these tags </ strong ></ td >
< td >
2013-05-15 08:00:54 +00:00
< textarea name = " tags<?= $i ?> " style = " width: 100%; " rows = " 2 " >< ? = display_str ( $N [ 'Tags' ]) ?> </textarea>
2013-02-16 08:00:57 +00:00
< p class = " min_padding " > Comma - separated list & mdash ; e . g . < em > rock , jazz , pop </ em ></ p >
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
< tr >
< td class = " label " >< strong > None of these tags </ strong ></ td >
< td >
2013-05-15 08:00:54 +00:00
< textarea name = " nottags<?= $i ?> " style = " width: 100%; " rows = " 2 " >< ? = display_str ( $N [ 'NotTags' ]) ?> </textarea>
2013-02-16 08:00:57 +00:00
< p class = " min_padding " > Comma - separated list & mdash ; e . g . < em > rock , jazz , pop </ em ></ p >
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
< tr >
< td class = " label " >< strong > Only these categories </ strong ></ td >
< td >
2013-04-13 08:00:19 +00:00
< ? foreach ( $Categories as $Category ) { ?>
< input type = " checkbox " name = " categories<?= $i ?>[] " id = " <?= $Category ?>_<?= $N['ID'] ?> " value = " <?= $Category ?> " < ? if ( in_array ( $Category , $N [ 'Categories' ])) { echo ' checked="checked"' ;} ?> />
2011-03-28 14:21:28 +00:00
< label for = " <?= $Category ?>_<?= $N['ID'] ?> " >< ? = $Category ?> </label>
< ? } ?>
</ td >
</ tr >
< tr >
< td class = " label " >< strong > Only these types </ strong ></ td >
< td >
2013-04-13 08:00:19 +00:00
< ? foreach ( $ReleaseTypes as $ReleaseType ) { ?>
< input type = " checkbox " name = " releasetypes<?= $i ?>[] " id = " <?= $ReleaseType ?>_<?= $N['ID'] ?> " value = " <?= $ReleaseType ?> " < ? if ( in_array ( $ReleaseType , $N [ 'ReleaseTypes' ])) { echo ' checked="checked"' ;} ?> />
2011-03-28 14:21:28 +00:00
< label for = " <?= $ReleaseType ?>_<?= $N['ID'] ?> " >< ? = $ReleaseType ?> </label>
< ? } ?>
</ td >
</ tr >
< tr >
< td class = " label " >< strong > Only these formats </ strong ></ td >
< td >
2013-04-13 08:00:19 +00:00
< ? foreach ( $Formats as $Format ) { ?>
< input type = " checkbox " name = " formats<?= $i ?>[] " id = " <?= $Format ?>_<?= $N['ID'] ?> " value = " <?= $Format ?> " < ? if ( in_array ( $Format , $N [ 'Formats' ])) { echo ' checked="checked"' ;} ?> />
2011-03-28 14:21:28 +00:00
< label for = " <?= $Format ?>_<?= $N['ID'] ?> " >< ? = $Format ?> </label>
< ? } ?>
</ td >
</ tr >
< tr >
< td class = " label " >< strong > Only these bitrates </ strong ></ td >
< td >
2013-04-13 08:00:19 +00:00
< ? foreach ( $Bitrates as $Bitrate ) { ?>
< input type = " checkbox " name = " bitrates<?= $i ?>[] " id = " <?= $Bitrate ?>_<?= $N['ID'] ?> " value = " <?= $Bitrate ?> " < ? if ( in_array ( $Bitrate , $N [ 'Encodings' ])) { echo ' checked="checked"' ;} ?> />
2011-03-28 14:21:28 +00:00
< label for = " <?= $Bitrate ?>_<?= $N['ID'] ?> " >< ? = $Bitrate ?> </label>
< ? } ?>
</ td >
</ tr >
< tr >
< td class = " label " >< strong > Only these media </ strong ></ td >
< td >
2013-04-13 08:00:19 +00:00
< ? foreach ( $Media as $Medium ) { ?>
< input type = " checkbox " name = " media<?= $i ?>[] " id = " <?= $Medium ?>_<?= $N['ID'] ?> " value = " <?= $Medium ?> " < ? if ( in_array ( $Medium , $N [ 'Media' ])) { echo ' checked="checked"' ;} ?> />
2011-03-28 14:21:28 +00:00
< label for = " <?= $Medium ?>_<?= $N['ID'] ?> " >< ? = $Medium ?> </label>
< ? } ?>
</ td >
</ tr >
< tr >
< td class = " label " >< strong > Between the years </ strong ></ td >
< td >
2012-06-16 08:00:18 +00:00
< input type = " text " name = " fromyear<?= $i ?> " value = " <?= $N['FromYear'] ?> " size = " 6 " />
2011-03-28 14:21:28 +00:00
and
2012-06-16 08:00:18 +00:00
< input type = " text " name = " toyear<?= $i ?> " value = " <?= $N['ToYear'] ?> " size = " 6 " />
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
< tr >
< td class = " label " >< strong > Only new releases </ strong ></ td >
< td >
2013-04-13 08:00:19 +00:00
< input type = " checkbox " name = " newgroupsonly<?= $i ?> " id = " newgroupsonly_<?= $N['ID'] ?> " < ? if ( $N [ 'NewGroupsOnly' ] == '1' ) { echo ' checked="checked"' ;} ?> />
2011-03-28 14:21:28 +00:00
< label for = " newgroupsonly_<?= $N['ID'] ?> " > Only notify for new releases , not new formats </ label >
</ td >
</ tr >
< tr >
< td colspan = " 2 " class = " center " >
2013-06-06 08:01:03 +00:00
< input type = " submit " value = " <?=( $NewFilter ? 'Create filter' : 'Update filter')?> " />
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
</ table >
</ form >
2013-06-06 08:01:03 +00:00
< ? } ?>
2011-03-28 14:21:28 +00:00
</ div >
2013-02-16 08:00:57 +00:00
< ? View :: show_footer (); ?>