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

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