Ignore:
Timestamp:
Sep 3, 2012, 3:06:50 PM (12 years ago)
Author:
mistic100
Message:

consolidate upgrade process

File:
1 edited

Legend:

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

    r17207 r17716  
    1212global $prefixeTable;
    1313
    14 define('SMART_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
     14define('SMART_PATH',    PHPWG_PLUGINS_PATH . 'SmartAlbums/');
    1515define('CATEGORY_FILTERS_TABLE', $prefixeTable . 'category_filters');
    16 define('SMART_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
     16define('SMART_ADMIN',   get_root_url() . 'admin.php?page=plugin-SmartAlbums');
     17define('SMART_VERSION', '2.0.3');
     18
    1719
    1820add_event_handler('invalidate_user_cache', 'smart_make_all_associations');
    1921add_event_handler('init', 'smart_init');
    2022
     23if (defined('IN_ADMIN'))
     24{
     25  include_once(SMART_PATH.'include/cat_list.php');
     26  add_event_handler('loc_begin_cat_list', 'smart_cat_list');
     27  add_event_handler('tabsheet_before_select','smart_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     28  add_event_handler('get_admin_plugin_menu_links', 'smart_admin_menu');
     29  add_event_handler('delete_categories', 'smart_delete_categories');
     30}
     31
    2132include_once(SMART_PATH.'include/functions.inc.php');
    2233
     34
     35/**
     36 * update plugin & unserialize conf & load language
     37 */
    2338function smart_init()
    2439{
    25   global $conf;
     40  global $conf, $pwg_loaded_plugins;
    2641 
    27   load_language('plugin.lang', SMART_PATH);
     42  if (
     43    $pwg_loaded_plugins['SmartAlbums']['version'] == 'auto' or
     44    version_compare($pwg_loaded_plugins['SmartAlbums']['version'], SMART_VERSION, '<')
     45  )
     46  {
     47    include_once(SMART_PATH . 'include/install.inc.php');
     48    smart_albums_install();
     49   
     50    if ($pwg_loaded_plugins['SmartAlbums']['version'] != 'auto')
     51    {
     52      $query = '
     53UPDATE '. PLUGINS_TABLE .'
     54SET version = "'. SMART_VERSION .'"
     55WHERE id = "SmartAlbums"';
     56      pwg_query($query);
     57     
     58      $pwg_loaded_plugins['SmartAlbums']['version'] = SMART_VERSION;
     59     
     60      if (defined('IN_ADMIN'))
     61      {
     62        $_SESSION['page_infos'][] = 'Smart Albums updated to version '. SMART_VERSION;
     63      }
     64    }
     65  }
     66 
     67  if (defined('IN_ADMIN'))
     68  {
     69    load_language('plugin.lang', SMART_PATH);
     70  }
    2871  $conf['SmartAlbums'] = unserialize($conf['SmartAlbums']);
    2972 
     
    3376    include_once(SMART_PATH.'include/page_items.php');
    3477  }
    35   else if (script_basename() == 'admin')
    36   {
    37     include_once(SMART_PATH.'include/cat_list.php');
    38    
    39     add_event_handler('loc_begin_cat_list', 'smart_cat_list');
    40     add_event_handler('tabsheet_before_select','smart_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    41     add_event_handler('get_admin_plugin_menu_links', 'smart_admin_menu');
    42     add_event_handler('delete_categories', 'smart_delete_categories');
    43   }
    4478}
    4579
     80/**
     81 * new tab on album properties page
     82 */
    4683function smart_tab($sheets, $id)
    4784{
     
    6198}
    6299
     100
     101/**
     102 * admin plugins menu link
     103 */
    63104function smart_admin_menu($menu)
    64105{
Note: See TracChangeset for help on using the changeset viewer.