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