[12560] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | /** |
---|
| 5 | * detect 'subscriptions' section and load page |
---|
| 6 | */ |
---|
| 7 | function stc_detect_section() { |
---|
| 8 | global $tokens, $page; |
---|
| 9 | |
---|
| 10 | if ($tokens[0] == 'subscriptions') |
---|
| 11 | { |
---|
| 12 | $page['section'] = 'subscriptions'; |
---|
| 13 | } |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | function stc_load_section() { |
---|
| 17 | global $page; |
---|
| 18 | |
---|
| 19 | if (isset($page['section']) and $page['section'] == 'subscriptions') |
---|
| 20 | { |
---|
| 21 | include(SUBSCRIBE_TO_PATH.'include/subscribtions_page.inc.php'); |
---|
| 22 | } |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | /** |
---|
| 27 | * send notifications and/or add subscriber |
---|
| 28 | */ |
---|
| 29 | function stc_comment_insertion($comm) |
---|
| 30 | { |
---|
| 31 | global $page; |
---|
| 32 | |
---|
| 33 | if ($comm['action'] == 'validate') |
---|
| 34 | { |
---|
| 35 | send_comment_to_subscribers($comm); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | if ( !empty($_POST['stc_check']) and ( $comm['action'] == 'validate' or $comm['action'] == 'moderate' ) ) |
---|
| 39 | { |
---|
| 40 | if (isset($comm['image_id'])) |
---|
| 41 | { |
---|
| 42 | subscribe_to_comments($comm['image_id'], @$_POST['stc_mail'], 'image'); |
---|
| 43 | } |
---|
| 44 | else if (isset($comm['category_id'])) |
---|
| 45 | { |
---|
| 46 | subscribe_to_comments($comm['category_id'], @$_POST['stc_mail'], 'category'); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | function stc_comment_validation($comm_id, $type='image') |
---|
| 52 | { |
---|
| 53 | switch ($type) |
---|
| 54 | { |
---|
| 55 | case 'image': |
---|
| 56 | { |
---|
| 57 | $query = ' |
---|
| 58 | SELECT |
---|
| 59 | id, |
---|
| 60 | image_id, |
---|
| 61 | author, |
---|
| 62 | content |
---|
| 63 | FROM '.COMMENTS_TABLE.' |
---|
| 64 | WHERE id = '.$comm_id.' |
---|
| 65 | ;'; |
---|
| 66 | break; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | case 'category': |
---|
| 70 | { |
---|
| 71 | $query = ' |
---|
| 72 | SELECT |
---|
| 73 | id, |
---|
| 74 | category_id, |
---|
| 75 | author, |
---|
| 76 | content |
---|
| 77 | FROM '.COA_TABLE.' |
---|
| 78 | WHERE id = '.$comm_id.' |
---|
| 79 | ;'; |
---|
| 80 | break; |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | $comm = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 85 | send_comment_to_subscribers($comm); |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | /** |
---|
| 90 | * adds fields on picture page |
---|
| 91 | */ |
---|
| 92 | function stc_on_picture() |
---|
| 93 | { |
---|
| 94 | global $template; |
---|
| 95 | |
---|
| 96 | $template->set_prefilter('picture', 'stc_on_picture_prefilter'); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | function stc_on_picture_prefilter($template, &$smarty) |
---|
| 100 | { |
---|
| 101 | $search = '<input type="submit" value="{\'Submit\'|@translate}">'; |
---|
| 102 | |
---|
| 103 | $replace = ' |
---|
| 104 | <label>{\'Subscribe to new comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label> |
---|
| 105 | <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> |
---|
| 106 | {footer_script require="jquery"}{literal} |
---|
| 107 | jQuery(document).ready(function() { |
---|
| 108 | $("input[name=stc_check]").change(function() { |
---|
| 109 | if ($(this).is(":checked")) $("#stc_mail").css("display", ""); |
---|
| 110 | else $("#stc_mail").css("display", "none"); |
---|
| 111 | }); |
---|
| 112 | }); |
---|
| 113 | {/literal} |
---|
| 114 | {/footer_script} |
---|
| 115 | '.$search; |
---|
| 116 | |
---|
| 117 | return str_replace($search, $replace, $template); |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | ?> |
---|