Ignore:
Timestamp:
Sep 15, 2012, 11:14:27 AM (8 years ago)
Author:
mistic100
Message:

use new upgrade process

File:
1 edited

Legend:

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

    r16106 r17922  
    1313global $prefixeTable;
    1414
    15 define('SUBSCRIBE_TO_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
     15define('SUBSCRIBE_TO_PATH' , PHPWG_PLUGINS_PATH . 'Subscribe_to_comments/');
    1616define('SUBSCRIBE_TO_TABLE', $prefixeTable . 'subscribe_to_comments');
     17define('SUBSCRIBE_TO_VERSION', '2.0.3');
     18
    1719
    1820add_event_handler('init', 'stc_init');
    1921
     22
    2023function stc_init()
    2124{
    22   global $conf, $user;
     25  global $conf, $user, $pwg_loaded_plugins;
    2326 
    2427  // no comments on luciano
    2528  if ($user['theme'] == 'luciano') return;
    2629 
     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 = '
     42UPDATE '. PLUGINS_TABLE .'
     43SET version = "'. SUBSCRIBE_TO_VERSION .'"
     44WHERE 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
    2757  load_language('plugin.lang', SUBSCRIBE_TO_PATH);
    2858  $conf['Subscribe_to_Comments'] = unserialize($conf['Subscribe_to_Comments']);
     59 
    2960 
    3061  include_once(SUBSCRIBE_TO_PATH.'include/functions.inc.php');
    3162  include_once(SUBSCRIBE_TO_PATH.'include/subscribe_to_comments.inc.php');
    3263
     64 
    3365  // send mails
    3466  add_event_handler('user_comment_insertion', 'stc_comment_insertion');
     
    5486}
    5587
     88
    5689function stc_admin_menu($menu)
    5790{
     
    6295  return $menu;
    6396}
     97
    6498?>
Note: See TracChangeset for help on using the changeset viewer.