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

Last change on this file since 31071 was 25872, checked in by mistic100, 11 years ago

update for 2.6

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 !email_check_format($entry['email']) )
13    {
14      $page['errors'][] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)');
15    }
16    else
17    {
18      if (empty($entry['name'])) $entry['name'] = $entry['email'];
19      if ($entry['group_name'] == -1) $entry['group_name'] = null;
20
21      $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  $conf['ContactForm_ready'] = count($emails);
39
40  $page['infos'][] = l10n('Information data registered in database');
41}
42
43
44// display emails
45$query = '
46SELECT *
47  FROM '. CONTACT_FORM_TABLE .'
48  ORDER BY
49    group_name ASC,
50    name ASC
51';
52$result = pwg_query($query);
53
54$emails = $groups = array();
55while ($data = pwg_db_fetch_assoc($result))
56{
57  $data['active'] = get_boolean($data['active']);
58  $emails[] = $data;
59  if (!empty($data['group_name']))
60  {
61    $groups[] = $data['group_name'];
62  }
63}
64
65$template->assign(array(
66  'EMAILS' => $emails,
67  'GROUPS' => array_unique($groups),
68  ));
69
70$template->set_filename('contact_form', realpath(CONTACT_FORM_PATH . 'admin/template/emails.tpl'));
Note: See TracBrowser for help on using the repository browser.