source: extensions/ContactForm/admin/emails.php @ 18393

Last change on this file since 18393 was 18331, checked in by mistic100, 12 years ago
  • add redirect url option
  • remove test code
  • fix fatal error at first installation
File size: 1.6 KB
Line 
1<?php
2if (!defined('CONTACT_FORM_PATH')) die('Hacking attempt!');
3
4// save emails
5if (isset($_POST['save_emails']))
6{
7  $emails = array();
8  foreach ($_POST['emails'] as $entry)
9  {
10    if (isset($entry['delete'])) continue;
11   
12    if ( empty($entry['email']) or !check_email_validity($entry['email']) )
13    {
14      array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));
15    }
16    else
17    {
18      if ($entry['group_name'] == -1) $entry['group_name'] = null;
19     
20      array_push($emails, array(
21        'name' => $entry['name'],
22        'email' => $entry['email'],
23        'group_name' => $entry['group_name'],
24        'active' => boolean_to_string(isset($entry['active'])),
25        ));
26    }
27  }
28 
29  pwg_query('TRUNCATE TABLE `'. CONTACT_FORM_TABLE. '`');
30 
31  mass_inserts(
32    CONTACT_FORM_TABLE,
33    array('name','email','group_name','active'),
34    $emails
35    );
36 
37  array_push($page['infos'], l10n('Information data registered in database'));
38}
39
40
41// display emails
42$query = '
43SELECT *
44  FROM '. CONTACT_FORM_TABLE .'
45  ORDER BY
46    group_name ASC,
47    name ASC
48';
49$result = pwg_query($query);
50
51$emails = $groups = array();
52while ($data = pwg_db_fetch_assoc($result))
53{
54  $data['active'] = get_boolean($data['active']);
55  array_push($emails, $data);
56  if (!empty($data['group_name']))
57  {
58    array_push($groups, $data['group_name']);
59  }
60}
61
62$template->assign(array(
63  'EMAILS' => $emails,
64  'GROUPS' => array_unique($groups),
65  ));
66
67$template->set_filename('contact_form', realpath(CONTACT_FORM_PATH . 'admin/template/emails.tpl'));
68
69?>
Note: See TracBrowser for help on using the repository browser.