Changeset 17654


Ignore:
Timestamp:
Aug 29, 2012, 4:50:30 PM (8 years ago)
Author:
mistic100
Message:

remove useless file install.inc.php, search for update everytime

Location:
extensions/header_manager
Files:
1 deleted
2 edited

Legend:

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

    r17644 r17654  
    1818define('HEADER_MANAGER_VERSION', '1.0.3');
    1919
     20
    2021add_event_handler('init', 'header_manager_init');
     22 
     23if (defined('IN_ADMIN'))
     24{
     25  add_event_handler('get_admin_plugin_menu_links', 'header_manager_admin_menu');
     26  add_event_handler('tabsheet_before_select', 'header_manager_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     27  add_event_handler('delete_categories', 'header_manager_delete_categories');
     28}
     29else if (!defined('PWG_HELP'))
     30{
     31  add_event_handler('render_page_banner', 'header_manager_render');
     32}
    2133
     34include_once(HEADER_MANAGER_PATH . 'include/functions.inc.php');
     35include_once(HEADER_MANAGER_PATH . 'include/header_manager.inc.php');
     36
     37
     38/**
     39 * update plugin & unserialize conf
     40 */
    2241function header_manager_init()
    2342{
    24   if (defined('PWG_HELP')) return;
     43  global $conf, $pwg_loaded_plugins, $page;
    2544 
    26   global $conf;
     45  if (
     46    $pwg_loaded_plugins['header_manager']['version'] == 'auto' or
     47    version_compare($pwg_loaded_plugins['header_manager']['version'], HEADER_MANAGER_VERSION, '<')
     48  )
     49  {
     50    include_once(HEADER_MANAGER_PATH . 'maintain.inc.php');
     51    plugin_install();
     52   
     53    if ($pwg_loaded_plugins['header_manager']['version'] != 'auto')
     54    {
     55      $query = '
     56UPDATE '. PLUGINS_TABLE .'
     57SET version = "'. HEADER_MANAGER_VERSION .'"
     58WHERE id = "header_manager"';
     59      pwg_query($query);
     60     
     61      $pwg_loaded_plugins['header_manager']['version'] = HEADER_MANAGER_VERSION;
     62     
     63      if (defined('IN_ADMIN'))
     64      {
     65        $_SESSION['page_infos'][] = 'Header Manager updated to version '. HEADER_MANAGER_VERSION;
     66      }
     67    }
     68  }
     69 
    2770  $conf['header_manager'] = unserialize($conf['header_manager']);
    28    
    29   include_once(HEADER_MANAGER_PATH . 'include/functions.inc.php');
    30   include_once(HEADER_MANAGER_PATH . 'include/header_manager.inc.php');
    31  
    32   if (!defined('IN_ADMIN'))
    33   {
    34     add_event_handler('render_page_banner', 'header_manager_render');
    35   }
    36   else
    37   {
    38     add_event_handler('loc_begin_admin_page', 'header_manager_check_version');
    39     add_event_handler('get_admin_plugin_menu_links', 'header_manager_admin_menu');
    40     add_event_handler('tabsheet_before_select', 'header_manager_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    41     add_event_handler('delete_categories', 'header_manager_delete_categories');
    42   }
    4371}
    4472
     
    73101}
    74102
    75 /**
    76  * updating the plugin
    77  */
    78 function header_manager_check_version()
    79 {
    80   global $pwg_loaded_plugins, $page;
    81  
    82   if (
    83     (
    84       @$page['page'] == 'intro' or
    85       @$_GET['section'] == 'header_manager/admin.php'
    86     )
    87     and
    88     (
    89       $pwg_loaded_plugins['header_manager']['version'] == 'auto' or
    90       version_compare($pwg_loaded_plugins['header_manager']['version'], HEADER_MANAGER_VERSION, '<')
    91     )
    92   )
    93   {
    94     include_once(HEADER_MANAGER_PATH . 'include/install.inc.php');
    95     header_manager_install();
    96    
    97     if ($pwg_loaded_plugins['header_manager']['version'] != 'auto')
    98     {
    99       $query = '
    100 UPDATE '. PLUGINS_TABLE .'
    101 SET version = "'. HEADER_MANAGER_VERSION .'"
    102 WHERE id = "header_manager"';
    103       pwg_query($query);
    104     }
    105   }
    106 }
    107 
    108103?>
  • extensions/header_manager/maintain.inc.php

    r17644 r17654  
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    33 
    4 include_once(PHPWG_PLUGINS_PATH . 'header_manager/include/install.inc.php');
    5 
    64function plugin_install()
    75{
    8   header_manager_install();
     6  global $conf, $prefixeTable;
     7
     8  // configuration
     9  if (empty($conf['header_manager']))
     10  {
     11    $header_manager_default_config = serialize(array(
     12      'width' => 1000,
     13      'height' => 150,
     14      'image' => 'random',
     15      'display' => 'image_only'
     16      ));
     17   
     18    conf_update_param('header_manager', $header_manager_default_config);
     19    $conf['header_manager'] = $header_manager_default_config;
     20  }
     21
     22  // banners directory
     23  if (!file_exists(PWG_LOCAL_DIR . 'banners/'))
     24  {
     25    mkdir(PWG_LOCAL_DIR . 'banners/', 0755);
     26  }
     27
     28  // banners table
     29  $query = '
     30CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` (
     31  `category_id` smallint(5) unsigned NOT NULL,
     32  `image` varchar(255) NOT NULL,
     33  `deep` tinyint(1) DEFAULT 1,
     34  PRIMARY KEY (`category_id`)
     35) ENGINE=MyISAM DEFAULT CHARSET=utf8
     36;';
     37  pwg_query($query);
     38 
    939  define('header_manager_installed', true);
    1040}
     
    1444  if (!defined('header_manager_installed'))
    1545  {
    16     header_manager_install()
     46    plugin_install();
    1747  }
    1848}
Note: See TracChangeset for help on using the changeset viewer.