source: extensions/ContactForm/include/contact_form.inc.php @ 28458

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

fix unused content type, send copy as Bcc

File size: 3.2 KB
RevLine 
[17483]1<?php
2if (!defined('CONTACT_FORM_PATH')) die('Hacking attempt!');
3
4global $template, $user, $conf, $page, $pwg_loaded_plugins;
5
[25872]6if ( (!is_classic_user() and !$conf['ContactForm']['cf_allow_guest']) or !$conf['ContactForm_ready'] )
[17483]7{
[23207]8  redirect(get_absolute_root_url());
[17483]9}
10
[27846]11$contact = array();
12
[17483]13// +-----------------------------------------------------------------------+
14// |                                send email                             |
15// +-----------------------------------------------------------------------+
16if (isset($_POST['send_mail']))
17{
18  $contact = array(
[28458]19    'author' =>  stripslashes(trim($_POST['author'])),
20    'email' =>   stripslashes(trim($_POST['email'])),
[17945]21    'group' =>   @$_POST['group'],
[28458]22    'subject' => stripslashes(trim($_POST['subject'])),
23    'content' => stripslashes($_POST['content']),
[19180]24    'send_copy' => isset($_POST['send_copy']),
[17483]25   );
[25872]26
[17483]27  $comment_action = send_contact_form($contact, @$_POST['key']);
28
29  switch ($comment_action)
30  {
31    case 'validate':
[18331]32      $_SESSION['page_infos'][] = l10n('E-mail sent successfully');
33      if (!empty($conf['ContactForm']['cf_redirect_url']))
34      {
35        redirect($conf['ContactForm']['cf_redirect_url']);
36      }
37      else
38      {
39        redirect(CONTACT_FORM_PUBLIC);
40      }
[17483]41      break;
42    case 'moderate':
43    case 'reject':
44      break;
45    default:
[18331]46      trigger_error('Invalid action '.$comment_action, E_USER_WARNING);
[17483]47  }
48}
49
50// +-----------------------------------------------------------------------+
51// |                                template                               |
52// +-----------------------------------------------------------------------+
53if (is_classic_user())
54{
[27846]55  if (empty($contact))
[17483]56  {
57    $contact = array(
58      'author' => $user['username'],
59      'email' => $user['email'],
[17945]60      'group' => null,
[17483]61      'subject' => l10n($conf['ContactForm']['cf_default_subject']),
62      'content' => null,
63      );
64  }
65  $contact['is_logged'] = true;
66}
67if ($conf['ContactForm']['cf_mandatory_mail'])
68{
69  $contact['mandatory_mail'] = true;
70}
71if ($conf['ContactForm']['cf_mandatory_name'])
72{
73  $contact['mandatory_name'] = true;
74}
75
76if (!empty($pwg_loaded_plugins['ExtendedDescription']))
77{
[22665]78  add_event_handler('render_contact_form', 'get_extended_desc');
[17483]79}
80
[17945]81$query = '
82SELECT DISTINCT group_name
83  FROM '. CONTACT_FORM_TABLE .'
84  ORDER BY group_name
85;';
86$result = pwg_query($query);
87
88$groups = array();
89while ($data = pwg_db_fetch_assoc($result))
90{
91  $groups[ $data['group_name'] ] = !empty($data['group_name']) ? l10n($data['group_name']) : l10n('Default');
92}
93
94if (count($groups) > 1)
95{
96  $template->assign('GROUPS', $groups);
97}
98
[17483]99$template->assign(array(
100  'contact' => $contact,
[18315]101  'ContactForm_before' => trigger_event('render_contact_form', nl2br($conf['ContactForm_before'])),
102  'ContactForm_after' => trigger_event('render_contact_form', nl2br($conf['ContactForm_after'])),
[17483]103  'KEY' => get_ephemeral_key(3),
104  'CONTACT_FORM_PATH' => CONTACT_FORM_PATH,
[20441]105  'CONTACT_FORM_ABS_PATH'=> realpath(CONTACT_FORM_PATH).'/',
[17483]106  'F_ACTION' => CONTACT_FORM_PUBLIC,
107  ));
108
[25872]109$template->set_filename('contactform', realpath(CONTACT_FORM_PATH . 'template/contact_form.tpl'));
110$template->assign_var_from_handle('CONTENT', 'contactform');
Note: See TracBrowser for help on using the repository browser.