Ignore:
Timestamp:
Aug 29, 2012, 5:33:08 PM (12 years ago)
Author:
mistic100
Message:

consolidate upgrade process

File:
1 edited

Legend:

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

    r17518 r17658  
    1111if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1212
    13 define('CONTACT_FORM_PATH',   PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    14 define('CONTACT_FORM_ADMIN',  get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
     13define('CONTACT_FORM_PATH',   PHPWG_PLUGINS_PATH . 'ContactForm/');
     14define('CONTACT_FORM_ADMIN',  get_root_url() . 'admin.php?page=plugin-ContactForm');
    1515define('CONTACT_FORM_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'contact')) . '/');
     16define('CONTACT_FORM_VERSION', '2.4.d');
    1617
    1718
    1819add_event_handler('init', 'contact_form_init');
     20
    1921add_event_handler('loc_end_section_init', 'contact_form_section_init');
    2022add_event_handler('loc_end_index', 'contact_form_page');
    2123add_event_handler('blockmanager_apply', 'contact_form_applymenu', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
     24
    2225if (defined('IN_ADMIN'))
    2326{
     
    2831
    2932
     33/**
     34 * update & unserialize conf & load language & init emails
     35 */
    3036function contact_form_init()
    3137{
    32   global $conf, $template;
     38  global $conf, $template,  $pwg_loaded_plugins;
     39 
     40  if (
     41    $pwg_loaded_plugins['ContactForm']['version'] == 'auto' or
     42    version_compare($pwg_loaded_plugins['ContactForm']['version'], CONTACT_FORM_VERSION, '<')
     43  )
     44  {
     45    include_once(CONTACT_FORM_PATH . 'include/install.inc.php');
     46    contact_form_install();
     47   
     48    if ($pwg_loaded_plugins['ContactForm']['version'] != 'auto')
     49    {
     50      $query = '
     51UPDATE '. PLUGINS_TABLE .'
     52SET version = "'. CONTACT_FORM_VERSION .'"
     53WHERE id = "ContactForm"';
     54      pwg_query($query);
     55     
     56      $pwg_loaded_plugins['ContactForm']['version'] = CONTACT_FORM_VERSION;
     57     
     58      if (defined('IN_ADMIN'))
     59      {
     60        $_SESSION['page_infos'][] = 'ContactForm updated to version '. CONTACT_FORM_VERSION;
     61      }
     62    }
     63  }
     64 
    3365  $conf['ContactForm'] = unserialize($conf['ContactForm']);
    34  
    3566  load_language('plugin.lang', CONTACT_FORM_PATH);
    3667 
     
    4374}
    4475
     76/**
     77 * admin plugins menu link
     78 */
     79function contact_form_admin_menu($menu)
     80{
     81  array_push($menu, array(
     82    'URL' => CONTACT_FORM_ADMIN,
     83    'NAME' => 'Contact Form',
     84  ));
     85  return $menu;
     86}
     87
    4588?>
Note: See TracChangeset for help on using the changeset viewer.