set_prefilter('picture', 'stc_on_picture_prefilter'); } function stc_on_picture_prefilter($template, &$smarty) { global $user, $picture; ## subscribe while add a comment ## $search[0] = ''; $replace[0] = ' '; if (is_a_guest()) { $replace[0].= ' {footer_script require="jquery"}{literal} jQuery(document).ready(function() { $("input[name=stc_check]").change(function() { if ($(this).is(":checked")) $("#stc_mail").css("display", ""); else $("#stc_mail").css("display", "none"); }); }); {/literal}{/footer_script}'; } $replace[0].= $search[0]; ## subscribe at any moment ## $search[1] = '{if isset($comment_add)}'; $replace[1] = $search[1].'
'; // if registered user we check if already subscribed if (!is_a_guest()) { $query = ' SELECT id FROM '.SUBSCRIBE_TO_TABLE.' WHERE email = "'.$user['email'].'" AND image_id = '.$picture['current']['id'].' ;'; if (pwg_db_num_rows(pwg_query($query))) { $replace[1].= ' {\'You are currently subscribed to comments of this picture.\'|@translate} {\'Unsubscribe\'|@translate}'; $no_form = true; } } if (!isset($no_form)) { $replace[1].= ' {\'Subscribe to new comments\'|@translate} '; // form for guests if (is_a_guest()) { $replace[1].= ' {footer_script require="jquery"}{literal} jQuery(document).ready(function() { $("a#stc_check_stdl").click(function() { $("input[name=stc_check_stdl]").prop("checked", true); $("#stc_standalone label").toggle(); return false; }); }); {/literal}{/footer_script}'; } // simple link for registered users else { $replace[1].= ' {footer_script require="jquery"}{literal} jQuery(document).ready(function() { $("a#stc_check_stdl").click(function() { $("input[name=stc_check_stdl]").prop("checked", true); $(this).parents("form#stc_standalone").submit(); return false; }); }); {/literal}{/footer_script}'; } } $replace[1].= '
'; return str_replace($search, $replace, $template); } /** * add field and on album page */ function stc_on_album() { global $page, $template, $pwg_loaded_plugins; if ( script_basename() != 'index' or !isset($page['section']) or !isset($pwg_loaded_plugins['Comments_on_Albums']) or $page['section'] != 'categories' or !isset($page['category']) ) { return; } if (isset($_POST['stc_check_stdl'])) { subscribe_to_comments($page['category']['id'], @$_POST['stc_mail_stdl'], 'category'); } $template->set_prefilter('comments_on_albums', 'stc_on_album_prefilter'); } function stc_on_album_prefilter($template, &$smarty) { global $user, $page; ## subscribe while add a comment ## $search[0] = ''; $replace[0] = ' '; if (is_a_guest()) { $replace[0].= ' {footer_script require="jquery"}{literal} jQuery(document).ready(function() { $("input[name=stc_check]").change(function() { if ($(this).is(":checked")) $("#stc_mail").css("display", ""); else $("#stc_mail").css("display", "none"); }); }); {/literal}{/footer_script}'; } $replace[0].= $search[0]; ## subscribe at any moment ## $search[1] = '{if isset($comment_add)}'; $replace[1] = $search[1].'
'; // if registered user we check if already subscribed if (!is_a_guest()) { $query = ' SELECT id FROM '.SUBSCRIBE_TO_TABLE.' WHERE email = "'.$user['email'].'" AND category_id = '.$page['category']['id'].' ;'; if (pwg_db_num_rows(pwg_query($query))) { $replace[1].= ' {\'You are currently subscribed to comments of this album.\'|@translate} {\'Unsubscribe\'|@translate}'; $no_form = true; } } if (!isset($no_form)) { $replace[1].= ' {\'Subscribe to new comments\'|@translate} '; // form for guests if (is_a_guest()) { $replace[1].= ' {footer_script require="jquery"}{literal} jQuery(document).ready(function() { $("a#stc_check_stdl").click(function() { $("input[name=stc_check_stdl]").prop("checked", true); $("#stc_standalone label").toggle(); return false; }); }); {/literal}{/footer_script}'; } // simple link for registered users else { $replace[1].= ' {footer_script require="jquery"}{literal} jQuery(document).ready(function() { $("a#stc_check_stdl").click(function() { $("input[name=stc_check_stdl]").prop("checked", true); $(this).parents("form#stc_standalone").submit(); return false; }); }); {/literal}{/footer_script}'; } } $replace[1].= '
'; return str_replace($search, $replace, $template); } ?>