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