[12560] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Subscribe To Comments |
---|
| 4 | Version: auto |
---|
[15641] | 5 | Description: This plugin allows to subscribe to comments by email. |
---|
[12561] | 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=587 |
---|
[12560] | 7 | Author: Mistic |
---|
| 8 | Author URI: http://www.strangeplanet.fr |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 12 | |
---|
| 13 | global $prefixeTable; |
---|
| 14 | |
---|
[17922] | 15 | define('SUBSCRIBE_TO_PATH' , PHPWG_PLUGINS_PATH . 'Subscribe_to_comments/'); |
---|
[12560] | 16 | define('SUBSCRIBE_TO_TABLE', $prefixeTable . 'subscribe_to_comments'); |
---|
[17922] | 17 | define('SUBSCRIBE_TO_VERSION', '2.0.3'); |
---|
[12560] | 18 | |
---|
[17922] | 19 | |
---|
[12702] | 20 | add_event_handler('init', 'stc_init'); |
---|
[12560] | 21 | |
---|
[17922] | 22 | |
---|
[12702] | 23 | function stc_init() |
---|
| 24 | { |
---|
[17922] | 25 | global $conf, $user, $pwg_loaded_plugins; |
---|
[15641] | 26 | |
---|
| 27 | // no comments on luciano |
---|
| 28 | if ($user['theme'] == 'luciano') return; |
---|
| 29 | |
---|
[17922] | 30 | // apply upgrade if needed |
---|
| 31 | if ( |
---|
| 32 | $pwg_loaded_plugins['Subscribe_to_comments']['version'] == 'auto' or |
---|
| 33 | version_compare($pwg_loaded_plugins['Subscribe_to_comments']['version'], SUBSCRIBE_TO_VERSION, '<') |
---|
| 34 | ) |
---|
| 35 | { |
---|
| 36 | include_once(SUBSCRIBE_TO_PATH . 'include/install.inc.php'); |
---|
| 37 | stc_install(); |
---|
| 38 | |
---|
| 39 | if ($pwg_loaded_plugins['Subscribe_to_comments']['version'] != 'auto') |
---|
| 40 | { |
---|
| 41 | $query = ' |
---|
| 42 | UPDATE '. PLUGINS_TABLE .' |
---|
| 43 | SET version = "'. SUBSCRIBE_TO_VERSION .'" |
---|
| 44 | WHERE id = "Subscribe_to_comments"'; |
---|
| 45 | pwg_query($query); |
---|
| 46 | |
---|
| 47 | $pwg_loaded_plugins['Subscribe_to_comments']['version'] = SUBSCRIBE_TO_VERSION; |
---|
| 48 | |
---|
| 49 | if (defined('IN_ADMIN')) |
---|
| 50 | { |
---|
| 51 | $_SESSION['page_infos'][] = 'Subscribe to comments updated to version '. SUBSCRIBE_TO_VERSION; |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | // load language and conf |
---|
[15641] | 57 | load_language('plugin.lang', SUBSCRIBE_TO_PATH); |
---|
| 58 | $conf['Subscribe_to_Comments'] = unserialize($conf['Subscribe_to_Comments']); |
---|
| 59 | |
---|
[17922] | 60 | |
---|
[12702] | 61 | include_once(SUBSCRIBE_TO_PATH.'include/functions.inc.php'); |
---|
| 62 | include_once(SUBSCRIBE_TO_PATH.'include/subscribe_to_comments.inc.php'); |
---|
[12561] | 63 | |
---|
[17922] | 64 | |
---|
[12702] | 65 | // send mails |
---|
| 66 | add_event_handler('user_comment_insertion', 'stc_comment_insertion'); |
---|
| 67 | add_event_handler('user_comment_validation', 'stc_comment_validation', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
[12561] | 68 | |
---|
[12702] | 69 | // subscribe |
---|
| 70 | add_event_handler('loc_end_picture', 'stc_on_picture'); |
---|
[15641] | 71 | add_event_handler('loc_begin_coa', 'stc_on_album'); |
---|
[12560] | 72 | |
---|
[12702] | 73 | // management |
---|
| 74 | add_event_handler('loc_end_section_init', 'stc_detect_section'); |
---|
[15641] | 75 | add_event_handler('loc_begin_page_header', 'stc_load_section'); |
---|
[16105] | 76 | |
---|
| 77 | // items deletion |
---|
| 78 | add_event_handler('begin_delete_elements', 'stc_delete_elements'); |
---|
[16106] | 79 | add_event_handler('delete_categories', 'stc_delete_categories'); |
---|
[12600] | 80 | |
---|
[12702] | 81 | // profile link |
---|
| 82 | add_event_handler('loc_begin_profile', 'stc_profile_link'); |
---|
[15641] | 83 | |
---|
| 84 | // config page |
---|
| 85 | add_event_handler('get_admin_plugin_menu_links', 'stc_admin_menu'); |
---|
[12702] | 86 | } |
---|
[15641] | 87 | |
---|
[17922] | 88 | |
---|
[15641] | 89 | function stc_admin_menu($menu) |
---|
| 90 | { |
---|
| 91 | array_push($menu, array( |
---|
| 92 | 'NAME' => 'Subscribe to Comments', |
---|
| 93 | 'URL' => get_root_url().'admin.php?page=plugin-' . basename(dirname(__FILE__)) |
---|
| 94 | )); |
---|
| 95 | return $menu; |
---|
| 96 | } |
---|
[17922] | 97 | |
---|
[12560] | 98 | ?> |
---|