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

Revision 28458, 3.2 KB checked in by mistic100, 5 years ago (diff)

fix unused content type, send copy as Bcc

Line 
1<?php
2if (!defined('CONTACT_FORM_PATH')) die('Hacking attempt!');
3
4global $template, $user, $conf, $page, $pwg_loaded_plugins;
5
6if ( (!is_classic_user() and !$conf['ContactForm']['cf_allow_guest']) or !$conf['ContactForm_ready'] )
7{
8  redirect(get_absolute_root_url());
9}
10
11$contact = array();
12
13// +-----------------------------------------------------------------------+
14// |                                send email                             |
15// +-----------------------------------------------------------------------+
16if (isset($_POST['send_mail']))
17{
18  $contact = array(
19    'author' =>  stripslashes(trim($_POST['author'])),
20    'email' =>   stripslashes(trim($_POST['email'])),
21    'group' =>   @$_POST['group'],
22    'subject' => stripslashes(trim($_POST['subject'])),
23    'content' => stripslashes($_POST['content']),
24    'send_copy' => isset($_POST['send_copy']),
25   );
26
27  $comment_action = send_contact_form($contact, @$_POST['key']);
28
29  switch ($comment_action)
30  {
31    case 'validate':
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      }
41      break;
42    case 'moderate':
43    case 'reject':
44      break;
45    default:
46      trigger_error('Invalid action '.$comment_action, E_USER_WARNING);
47  }
48}
49
50// +-----------------------------------------------------------------------+
51// |                                template                               |
52// +-----------------------------------------------------------------------+
53if (is_classic_user())
54{
55  if (empty($contact))
56  {
57    $contact = array(
58      'author' => $user['username'],
59      'email' => $user['email'],
60      'group' => null,
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{
78  add_event_handler('render_contact_form', 'get_extended_desc');
79}
80
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
99$template->assign(array(
100  'contact' => $contact,
101  'ContactForm_before' => trigger_event('render_contact_form', nl2br($conf['ContactForm_before'])),
102  'ContactForm_after' => trigger_event('render_contact_form', nl2br($conf['ContactForm_after'])),
103  'KEY' => get_ephemeral_key(3),
104  'CONTACT_FORM_PATH' => CONTACT_FORM_PATH,
105  'CONTACT_FORM_ABS_PATH'=> realpath(CONTACT_FORM_PATH).'/',
106  'F_ACTION' => CONTACT_FORM_PUBLIC,
107  ));
108
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.