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

Last change on this file since 17945 was 17945, checked in by mistic100, 12 years ago
  • stores emails in database (/!\ update only from published version, not from trunk)
  • allow emails to be categorized
File size: 2.6 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');
20define('CONTACT_FORM_VERSION', '2.5.0');
[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');
32  add_event_handler('loc_end_index', 'contact_form_page');
33  add_event_handler('blockmanager_apply', 'contact_form_applymenu', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
34}
[17483]35
36include(CONTACT_FORM_PATH . 'include/functions.inc.php');
37
38
[17658]39/**
40 * update & unserialize conf & load language & init emails
41 */
[17483]42function contact_form_init()
43{
[17658]44  global $conf, $template,  $pwg_loaded_plugins;
45 
46  if (
[17945]47    $pwg_loaded_plugins[CONTACT_FORM_ID]['version'] == 'auto' or
48    version_compare($pwg_loaded_plugins[CONTACT_FORM_ID]['version'], CONTACT_FORM_VERSION, '<')
[17658]49  )
50  {
51    include_once(CONTACT_FORM_PATH . 'include/install.inc.php');
52    contact_form_install();
53   
[17945]54    if ($pwg_loaded_plugins[CONTACT_FORM_ID]['version'] != 'auto')
[17658]55    {
56      $query = '
57UPDATE '. PLUGINS_TABLE .'
58SET version = "'. CONTACT_FORM_VERSION .'"
[17945]59WHERE id = "'. CONTACT_FORM_ID .'"';
[17658]60      pwg_query($query);
61     
[17945]62      $pwg_loaded_plugins[CONTACT_FORM_ID]['version'] = CONTACT_FORM_VERSION;
[17658]63     
64      if (defined('IN_ADMIN'))
65      {
66        $_SESSION['page_infos'][] = 'ContactForm updated to version '. CONTACT_FORM_VERSION;
67      }
68    }
69  }
70 
[17483]71  $conf['ContactForm'] = unserialize($conf['ContactForm']);
72  load_language('plugin.lang', CONTACT_FORM_PATH);
73 
74  if ($conf['ContactForm']['cf_must_initialize'])
75  {
76    contact_form_initialize_emails();
77  }
[17491]78 
79  $template->set_prefilter('tail', 'contact_form_footer_link');
[17483]80}
81
[17658]82/**
83 * admin plugins menu link
84 */
85function contact_form_admin_menu($menu) 
86{
87  array_push($menu, array(
88    'URL' => CONTACT_FORM_ADMIN,
89    'NAME' => 'Contact Form',
90  ));
91  return $menu;
92}
93
[6547]94?>
Note: See TracBrowser for help on using the repository browser.