[6547] | 1 | <?php |
---|
| 2 | /* |
---|
[7135] | 3 | Plugin Name: Contact Form |
---|
[8909] | 4 | Version: auto |
---|
[7135] | 5 | Description: Add a "Contact" item in the Menu block to offer a contact form to users |
---|
[23375] | 6 | Plugin URI: auto |
---|
[17483] | 7 | Author: Piwigo Team |
---|
| 8 | Author URI: http://piwigo.org |
---|
[6547] | 9 | */ |
---|
| 10 | |
---|
[28324] | 11 | /* |
---|
| 12 | * $conf['contact_form_show_ip'] = true; |
---|
| 13 | */ |
---|
| 14 | |
---|
[28839] | 15 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
[6547] | 16 | |
---|
[28882] | 17 | global $conf, $prefixeTable; |
---|
[6547] | 18 | |
---|
[28839] | 19 | define('CONTACT_FORM_ID', basename(dirname(__FILE__))); |
---|
| 20 | define('CONTACT_FORM_PATH', PHPWG_PLUGINS_PATH . CONTACT_FORM_ID . '/'); |
---|
| 21 | define('CONTACT_FORM_ADMIN', get_root_url() . 'admin.php?page=plugin-' . CONTACT_FORM_ID); |
---|
| 22 | define('CONTACT_FORM_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'contact')) . '/'); |
---|
| 23 | define('CONTACT_FORM_TABLE', $prefixeTable .'contact_form'); |
---|
[17483] | 24 | |
---|
[28882] | 25 | $conf['ContactForm'] = safe_unserialize($conf['ContactForm']); |
---|
| 26 | |
---|
[28839] | 27 | include(CONTACT_FORM_PATH . 'include/functions.inc.php'); |
---|
[17945] | 28 | |
---|
[28839] | 29 | |
---|
[17483] | 30 | add_event_handler('init', 'contact_form_init'); |
---|
[17658] | 31 | |
---|
[17483] | 32 | if (defined('IN_ADMIN')) |
---|
| 33 | { |
---|
| 34 | add_event_handler('get_admin_plugin_menu_links', 'contact_form_admin_menu'); |
---|
[6547] | 35 | } |
---|
[17945] | 36 | else |
---|
| 37 | { |
---|
| 38 | add_event_handler('loc_end_section_init', 'contact_form_section_init'); |
---|
| 39 | add_event_handler('loc_end_index', 'contact_form_page'); |
---|
| 40 | } |
---|
[17483] | 41 | |
---|
[28882] | 42 | if ($conf['ContactForm']['cf_menu_link']) |
---|
| 43 | { |
---|
| 44 | add_event_handler('blockmanager_apply', 'contact_form_applymenu', EVENT_HANDLER_PRIORITY_NEUTRAL+10); |
---|
| 45 | } |
---|
[25872] | 46 | |
---|
[28882] | 47 | add_event_handler('before_parse_mail_template', 'contact_form_mail_template'); |
---|
[17483] | 48 | |
---|
[28882] | 49 | |
---|
[17658] | 50 | /** |
---|
| 51 | * update & unserialize conf & load language & init emails |
---|
| 52 | */ |
---|
[17483] | 53 | function contact_form_init() |
---|
| 54 | { |
---|
[28839] | 55 | global $conf, $template; |
---|
[25872] | 56 | |
---|
[17483] | 57 | load_language('plugin.lang', CONTACT_FORM_PATH); |
---|
[18891] | 58 | load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true)); |
---|
[25872] | 59 | |
---|
[17483] | 60 | if ($conf['ContactForm']['cf_must_initialize']) |
---|
| 61 | { |
---|
| 62 | contact_form_initialize_emails(); |
---|
| 63 | } |
---|
[25872] | 64 | |
---|
| 65 | $conf['ContactForm_ready'] = count(get_contact_emails()); |
---|
| 66 | |
---|
| 67 | if ($conf['ContactForm_ready'] && (!is_a_guest() || $conf['ContactForm']['cf_allow_guest'])) |
---|
[24347] | 68 | { |
---|
[25872] | 69 | $template->assign(array( |
---|
| 70 | 'CONTACT_MAIL' => true, |
---|
| 71 | 'CONTACT_FORM_PUBLIC' => CONTACT_FORM_PUBLIC, |
---|
| 72 | )); |
---|
[24347] | 73 | $template->set_prefilter('tail', 'contact_form_footer_link'); |
---|
| 74 | } |
---|
[17483] | 75 | } |
---|
| 76 | |
---|
[17658] | 77 | /** |
---|
[25872] | 78 | * admin plugins menu link |
---|
[17658] | 79 | */ |
---|
[25872] | 80 | function contact_form_admin_menu($menu) |
---|
[17658] | 81 | { |
---|
[25872] | 82 | $menu[] = array( |
---|
[17658] | 83 | 'URL' => CONTACT_FORM_ADMIN, |
---|
| 84 | 'NAME' => 'Contact Form', |
---|
[25872] | 85 | ); |
---|
[17658] | 86 | return $menu; |
---|
| 87 | } |
---|