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

Last change on this file since 20461 was 20441, checked in by mistic100, 11 years ago

change $BODY_ID

File size: 2.8 KB
RevLine 
[6547]1<?php
2/*
[7135]3Plugin Name: Contact Form
[8909]4Version: auto
[7135]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
[17483]7Author: Piwigo Team
8Author URI: http://piwigo.org
[6547]9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
[17945]13global $prefixeTable;
[6547]14
[17945]15defined('CONTACT_FORM_ID') or define('CONTACT_FORM_ID', basename(dirname(__FILE__)));
16define('CONTACT_FORM_PATH',    PHPWG_PLUGINS_PATH . CONTACT_FORM_ID . '/');
17define('CONTACT_FORM_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . CONTACT_FORM_ID);
18define('CONTACT_FORM_PUBLIC',  get_absolute_root_url() . make_index_url(array('section' => 'contact')) . '/');
19define('CONTACT_FORM_TABLE',   $prefixeTable .'contact_form');
[18315]20define('CONTACT_FORM_VERSION', 'auto');
[17483]21
[17945]22
[17483]23add_event_handler('init', 'contact_form_init');
[17658]24
[17483]25if (defined('IN_ADMIN'))
26{
27  add_event_handler('get_admin_plugin_menu_links', 'contact_form_admin_menu');
[6547]28}
[17945]29else
30{
31  add_event_handler('loc_end_section_init', 'contact_form_section_init');
[20441]32  add_event_handler('loc_end_page_header', 'contact_form_header');
[17945]33  add_event_handler('loc_end_index', 'contact_form_page');
34  add_event_handler('blockmanager_apply', 'contact_form_applymenu', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
35}
[17483]36
37include(CONTACT_FORM_PATH . 'include/functions.inc.php');
38
39
[17658]40/**
41 * update & unserialize conf & load language & init emails
42 */
[17483]43function contact_form_init()
44{
[17658]45  global $conf, $template,  $pwg_loaded_plugins;
46 
47  if (
[18649]48    CONTACT_FORM_VERSION == 'auto' or
[17945]49    $pwg_loaded_plugins[CONTACT_FORM_ID]['version'] == 'auto' or
50    version_compare($pwg_loaded_plugins[CONTACT_FORM_ID]['version'], CONTACT_FORM_VERSION, '<')
[17658]51  )
52  {
53    include_once(CONTACT_FORM_PATH . 'include/install.inc.php');
54    contact_form_install();
55   
[18649]56    if ( $pwg_loaded_plugins[CONTACT_FORM_ID]['version'] != 'auto' and CONTACT_FORM_VERSION != 'auto' )
[17658]57    {
58      $query = '
59UPDATE '. PLUGINS_TABLE .'
60SET version = "'. CONTACT_FORM_VERSION .'"
[17945]61WHERE id = "'. CONTACT_FORM_ID .'"';
[17658]62      pwg_query($query);
63     
[17945]64      $pwg_loaded_plugins[CONTACT_FORM_ID]['version'] = CONTACT_FORM_VERSION;
[17658]65     
66      if (defined('IN_ADMIN'))
67      {
68        $_SESSION['page_infos'][] = 'ContactForm updated to version '. CONTACT_FORM_VERSION;
69      }
70    }
71  }
72 
[17483]73  $conf['ContactForm'] = unserialize($conf['ContactForm']);
74  load_language('plugin.lang', CONTACT_FORM_PATH);
[18891]75  load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true));
[17483]76 
77  if ($conf['ContactForm']['cf_must_initialize'])
78  {
79    contact_form_initialize_emails();
80  }
[17491]81 
82  $template->set_prefilter('tail', 'contact_form_footer_link');
[17483]83}
84
[17658]85/**
86 * admin plugins menu link
87 */
88function contact_form_admin_menu($menu) 
89{
90  array_push($menu, array(
91    'URL' => CONTACT_FORM_ADMIN,
92    'NAME' => 'Contact Form',
93  ));
94  return $menu;
95}
96
[6547]97?>
Note: See TracBrowser for help on using the repository browser.