source: extensions/ContactForm/main.inc.php @ 17658

Last change on this file since 17658 was 17658, checked in by mistic100, 12 years ago

consolidate upgrade process

File size: 2.4 KB
Line 
1<?php
2/*
3Plugin Name: Contact Form
4Version: auto
5Description: Add a "Contact" item in the Menu block to offer a contact form to users
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=304
7Author: Piwigo Team
8Author URI: http://piwigo.org
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13define('CONTACT_FORM_PATH',   PHPWG_PLUGINS_PATH . 'ContactForm/');
14define('CONTACT_FORM_ADMIN',  get_root_url() . 'admin.php?page=plugin-ContactForm');
15define('CONTACT_FORM_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'contact')) . '/');
16define('CONTACT_FORM_VERSION', '2.4.d');
17
18
19add_event_handler('init', 'contact_form_init');
20
21add_event_handler('loc_end_section_init', 'contact_form_section_init');
22add_event_handler('loc_end_index', 'contact_form_page');
23add_event_handler('blockmanager_apply', 'contact_form_applymenu', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
24
25if (defined('IN_ADMIN'))
26{
27  add_event_handler('get_admin_plugin_menu_links', 'contact_form_admin_menu');
28}
29
30include(CONTACT_FORM_PATH . 'include/functions.inc.php');
31
32
33/**
34 * update & unserialize conf & load language & init emails
35 */
36function contact_form_init()
37{
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 
65  $conf['ContactForm'] = unserialize($conf['ContactForm']);
66  load_language('plugin.lang', CONTACT_FORM_PATH);
67 
68  if ($conf['ContactForm']['cf_must_initialize'])
69  {
70    contact_form_initialize_emails();
71  }
72 
73  $template->set_prefilter('tail', 'contact_form_footer_link');
74}
75
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
88?>
Note: See TracBrowser for help on using the repository browser.