source: extensions/Subscribe_to_comments/main.inc.php @ 21340

Last change on this file since 21340 was 21340, checked in by mistic100, 11 years ago

too many changes

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