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

Last change on this file since 28618 was 28324, checked in by mistic100, 10 years ago

add $confcontact_form_show_ip option

File size: 2.5 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: auto
7Author: Piwigo Team
8Author URI: http://piwigo.org
9*/
10
11/*
12 * $conf['contact_form_show_ip'] = true;
13 */
14
15if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
16
17global $prefixeTable;
18
19defined('CONTACT_FORM_ID') or define('CONTACT_FORM_ID', basename(dirname(__FILE__)));
20define('CONTACT_FORM_PATH',    PHPWG_PLUGINS_PATH . CONTACT_FORM_ID . '/');
21define('CONTACT_FORM_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . CONTACT_FORM_ID);
22define('CONTACT_FORM_PUBLIC',  get_absolute_root_url() . make_index_url(array('section' => 'contact')) . '/');
23define('CONTACT_FORM_TABLE',   $prefixeTable .'contact_form');
24define('CONTACT_FORM_VERSION', 'auto');
25
26
27add_event_handler('init', 'contact_form_init');
28
29if (defined('IN_ADMIN'))
30{
31  add_event_handler('get_admin_plugin_menu_links', 'contact_form_admin_menu');
32}
33else
34{
35  add_event_handler('loc_end_section_init', 'contact_form_section_init');
36  add_event_handler('loc_end_index', 'contact_form_page');
37}
38
39add_event_handler('blockmanager_apply', 'contact_form_applymenu', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
40add_event_handler('before_parse_mail_template', 'contact_form_mail_template', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
41
42include(CONTACT_FORM_PATH . 'include/functions.inc.php');
43
44
45/**
46 * update & unserialize conf & load language & init emails
47 */
48function contact_form_init()
49{
50  global $conf, $template, $pwg_loaded_plugins;
51
52  include_once(CONTACT_FORM_PATH . 'maintain.inc.php');
53  $maintain = new ContactForm_maintain(CONTACT_FORM_ID);
54  $maintain->autoUpdate(CONTACT_FORM_VERSION, 'install');
55
56  $conf['ContactForm'] = unserialize($conf['ContactForm']);
57  load_language('plugin.lang', CONTACT_FORM_PATH);
58  load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true));
59
60  if ($conf['ContactForm']['cf_must_initialize'])
61  {
62    contact_form_initialize_emails();
63  }
64
65  $conf['ContactForm_ready'] = count(get_contact_emails());
66
67  if ($conf['ContactForm_ready'] && (!is_a_guest() || $conf['ContactForm']['cf_allow_guest']))
68  {
69    $template->assign(array(
70      'CONTACT_MAIL' => true,
71      'CONTACT_FORM_PUBLIC' => CONTACT_FORM_PUBLIC,
72      ));
73    $template->set_prefilter('tail', 'contact_form_footer_link');
74  }
75}
76
77/**
78 * admin plugins menu link
79 */
80function contact_form_admin_menu($menu)
81{
82  $menu[] = array(
83    'URL' => CONTACT_FORM_ADMIN,
84    'NAME' => 'Contact Form',
85  );
86  return $menu;
87}
Note: See TracBrowser for help on using the repository browser.