Ignore:
Timestamp:
Dec 23, 2013, 9:17:28 PM (10 years ago)
Author:
mistic100
Message:

update for 2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Subscribe_to_comments/main.inc.php

    r21608 r26139  
    1 <?php 
     1<?php
    22/*
    33Plugin Name: Subscribe To Comments
    44Version: auto
    55Description: This plugin allows to subscribe to comments by email.
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=587
     6Plugin URI: auto
    77Author: Mistic
    88Author URI: http://www.strangeplanet.fr
    99*/
    1010
    11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    1212
    1313global $prefixeTable;
    1414
    15 defined('SUBSCRIBE_TO_ID') or define('SUBSCRIBE_TO_ID', basename(dirname(__FILE__)));
     15define('SUBSCRIBE_TO_ID',      basename(dirname(__FILE__)));
    1616define('SUBSCRIBE_TO_PATH' ,   PHPWG_PLUGINS_PATH . SUBSCRIBE_TO_ID . '/');
    1717define('SUBSCRIBE_TO_TABLE',   $prefixeTable . 'subscribe_to_comments');
     
    2525function stc_init()
    2626{
    27   global $conf, $user, $pwg_loaded_plugins;
    28  
     27  global $conf, $user;
     28
    2929  // no comments on luciano
    30   if ($user['theme'] == 'luciano') return;
    31  
    32   // apply upgrade if needed
    33   if (
    34     SUBSCRIBE_TO_VERSION == 'auto' or
    35     $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] == 'auto' or
    36     version_compare($pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'], SUBSCRIBE_TO_VERSION, '<')
    37   )
     30  if ($user['theme'] == 'luciano')
    3831  {
    39     include_once(SUBSCRIBE_TO_PATH . 'include/install.inc.php');
    40     stc_install();
    41    
    42     if ( $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] != 'auto' and SUBSCRIBE_TO_VERSION != 'auto' )
    43     {
    44       $query = '
    45 UPDATE '. PLUGINS_TABLE .'
    46 SET version = "'. SUBSCRIBE_TO_VERSION .'"
    47 WHERE id = "'. SUBSCRIBE_TO_ID .'"';
    48       pwg_query($query);
    49      
    50       $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] = SUBSCRIBE_TO_VERSION;
    51      
    52       if (defined('IN_ADMIN'))
    53       {
    54         $_SESSION['page_infos'][] = 'Subscribe to comments updated to version '. SUBSCRIBE_TO_VERSION;
    55       }
    56     }
     32    return;
    5733  }
    58  
    59   // load language and conf
     34
     35  include_once(SUBSCRIBE_TO_PATH . 'maintain.inc.php');
     36  $maintain = new Subscribe_to_Comments_maintain(SUBSCRIBE_TO_ID);
     37  $maintain->autoUpdate(SUBSCRIBE_TO_VERSION, 'install');
     38
     39
    6040  load_language('plugin.lang', SUBSCRIBE_TO_PATH);
    6141  $conf['Subscribe_to_Comments'] = unserialize($conf['Subscribe_to_Comments']);
    62  
    63  
     42
     43
    6444  include_once(SUBSCRIBE_TO_PATH.'include/functions.inc.php');
    65   include_once(SUBSCRIBE_TO_PATH.'include/subscribe_to_comments.inc.php');
     45  include_once(SUBSCRIBE_TO_PATH.'include/events.inc.php');
    6646
    67  
     47
     48  if (!defined('IN_ADMIN'))
     49  {
     50    // subscribe
     51    add_event_handler('loc_end_picture', 'stc_on_picture');
     52    add_event_handler('loc_begin_coa', 'stc_on_album');
     53
     54    // management
     55    add_event_handler('loc_end_section_init', 'stc_detect_section');
     56    add_event_handler('loc_begin_page_header', 'stc_load_section');
     57
     58    // profile link
     59    add_event_handler('loc_begin_profile', 'stc_profile_link');
     60  }
     61  else
     62  {
     63    // config page
     64    add_event_handler('get_admin_plugin_menu_links', 'stc_admin_menu');
     65  }
     66
    6867  // send mails
    6968  add_event_handler('user_comment_insertion', 'stc_comment_insertion');
    7069  add_event_handler('user_comment_validation', 'stc_comment_validation', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    7170
    72   // subscribe
    73   add_event_handler('loc_end_picture', 'stc_on_picture');
    74   add_event_handler('loc_begin_coa', 'stc_on_album');
    75 
    76   // management
    77   add_event_handler('loc_end_section_init', 'stc_detect_section');
    78   add_event_handler('loc_begin_page_header', 'stc_load_section');
    79  
    8071  // items deletion
    8172  add_event_handler('begin_delete_elements', 'stc_delete_elements');
    8273  add_event_handler('delete_categories', 'stc_delete_categories');
    83 
    84   // profile link
    85   add_event_handler('loc_begin_profile', 'stc_profile_link');
    86  
    87   // config page
    88   add_event_handler('get_admin_plugin_menu_links', 'stc_admin_menu');
    8974}
    9075
    9176
    92 function stc_admin_menu($menu) 
     77function stc_admin_menu($menu)
    9378{
    94   array_push($menu, array(
     79  $menu[] = array(
    9580    'NAME' => 'Subscribe to Comments',
    9681    'URL' => SUBSCRIBE_TO_ADMIN,
    97   ));
     82    );
    9883  return $menu;
    9984}
    100 
    101 ?>
Note: See TracChangeset for help on using the changeset viewer.