Ignore:
Timestamp:
09/16/12 17:20:39 (7 years ago)
Author:
mistic100
Message:
  • stores emails in database (/!\ update only from published version, not from trunk)
  • allow emails to be categorized
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ContactForm/admin/emails.php

    r17483 r17945  
    55if (isset($_POST['save_emails'])) 
    66{ 
     7  var_dump($_POST); 
    78  $emails = array(); 
    89  foreach ($_POST['emails'] as $entry) 
     
    1617    else 
    1718    { 
     19      if ($entry['group_name'] == -1) $entry['group_name'] = null; 
     20       
    1821      array_push($emails, array( 
    1922        'name' => $entry['name'], 
    2023        'email' => $entry['email'], 
    21         'active' => isset($entry['active']), 
     24        'group_name' => $entry['group_name'], 
     25        'active' => boolean_to_string(isset($entry['active'])), 
    2226        )); 
    2327    } 
    2428  } 
    2529   
    26   $conf['ContactForm']['cf_admin_mails'] = $emails; 
    27   conf_update_param('ContactForm', serialize($conf['ContactForm'])); 
     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   
    2838  array_push($page['infos'], l10n('Information data registered in database')); 
    2939} 
     
    3141 
    3242// display emails 
    33 $template->assign('EMAILS', $conf['ContactForm']['cf_admin_mails']); 
     43$query = ' 
     44SELECT * 
     45  FROM '. CONTACT_FORM_TABLE .' 
     46  ORDER BY 
     47    group_name ASC, 
     48    name ASC 
     49'; 
     50$result = pwg_query($query); 
    3451 
    35 $template->set_filename('contact_form', dirname(__FILE__).'/template/emails.tpl'); 
     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')); 
    3669 
    3770?> 
Note: See TracChangeset for help on using the changeset viewer.