[8771] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | global $template, $page; |
---|
| 5 | |
---|
[20010] | 6 | $piwecard = get_plugin_data($plugin_id); |
---|
[8771] | 7 | |
---|
[20013] | 8 | if (isset($_POST['submit'])) { |
---|
[20047] | 9 | $errors = array(); |
---|
| 10 | $configuration = array(); |
---|
| 11 | |
---|
| 12 | $configuration['validity_default'] = $_POST['ecard_validity_default']; |
---|
| 13 | $configuration['sender_copy'] = isset($_POST['ecard_sender_copy']); |
---|
| 14 | $configuration['sender_email_change'] = isset($_POST['ecard_sender_email_change']); |
---|
[8771] | 15 | |
---|
[20013] | 16 | $ecard_email_format_array = array(); |
---|
| 17 | foreach($_POST['ecard_email_format'] as $ecard_email_format) { |
---|
| 18 | array_push($ecard_email_format_array, $ecard_email_format); |
---|
| 19 | } |
---|
[20047] | 20 | $configuration['email_format_authorized'] = $ecard_email_format_array; |
---|
| 21 | $configuration['email_format_default'] = $_POST['ecard_email_format_default']; |
---|
| 22 | if (!in_array($configuration['email_format_default'], $configuration['email_format_authorized'])) |
---|
| 23 | $errors['email_format_default'] = array( |
---|
| 24 | 'style_error_text' => 'display: inline;', |
---|
| 25 | ); |
---|
| 26 | $configuration['show_image_infos'] = $_POST['ecard_show_image_infos']; |
---|
| 27 | $configuration['default_guest_email'] = $_POST['ecard_default_guest_email']; |
---|
| 28 | if ($configuration['default_guest_email'] !='' && !$piwecard->is_valid_email($configuration['default_guest_email'])) |
---|
| 29 | $errors['default_guest_email'] = array( |
---|
| 30 | 'style_error_text' => 'display: inline;', |
---|
| 31 | 'style_error_input' => 'class="ecard_admin_error_input"', |
---|
| 32 | ); |
---|
| 33 | $configuration['email_subject'] = htmlspecialchars($_POST['ecard_email_subject']); |
---|
| 34 | if ($configuration['email_subject'] == '') |
---|
| 35 | $errors['email_subject'] = array( |
---|
| 36 | 'style_error_text' => 'display: inline;', |
---|
| 37 | 'style_error_input' => 'class="ecard_admin_error_input"', |
---|
| 38 | ); |
---|
| 39 | $configuration['email_message']['text'] = htmlspecialchars($_POST['ecard_email_message_text']); |
---|
| 40 | if ($configuration['email_message']['text'] == '') |
---|
| 41 | $errors['email_message']['text'] = array( |
---|
| 42 | 'style_error_text' => 'display: inline;', |
---|
| 43 | 'style_error_input' => 'class="ecard_admin_error_input"', |
---|
| 44 | ); |
---|
| 45 | $configuration['email_message']['html'] = stripslashes($_POST['ecard_email_message_html']); |
---|
| 46 | if ($configuration['email_message']['html'] == '') |
---|
| 47 | $errors['email_message']['html'] = array( |
---|
| 48 | 'style_error_text' => 'display: inline;', |
---|
| 49 | 'style_error_input' => 'class="ecard_admin_error_input"', |
---|
| 50 | ); |
---|
| 51 | |
---|
| 52 | foreach ($configuration as $key => $item) { |
---|
| 53 | if (!array_key_exists($key, $errors)) { |
---|
| 54 | $piwecard->my_config[$key] = $configuration[$key]; |
---|
| 55 | } |
---|
| 56 | } |
---|
[20032] | 57 | $piwecard->set_config(); |
---|
[20047] | 58 | |
---|
| 59 | if (empty($errors)) { |
---|
[20059] | 60 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[20047] | 61 | } else { |
---|
| 62 | $template->assign('ecard_errors', $errors); |
---|
| 63 | array_push($page['errors'], l10n('piwecard_errors')); |
---|
| 64 | } |
---|
[8771] | 65 | } |
---|
| 66 | |
---|
[20010] | 67 | foreach($piwecard->my_config['validity'] as $validity) { |
---|
[20013] | 68 | $template->append('ecard_validity', array( |
---|
| 69 | 'id' => $validity, |
---|
[20047] | 70 | 'name' => ($validity == 0) ? l10n('piwecard_nolimit') : $validity.' '.l10n('piwecard_days'), |
---|
[20013] | 71 | 'selected' => (($piwecard->my_config['validity_default'] == $validity) ? 'selected' : ''), |
---|
[20010] | 72 | ) |
---|
| 73 | ); |
---|
[8771] | 74 | } |
---|
[20013] | 75 | $template->assign('ecard_sender_copy', $piwecard->my_config['sender_copy'] ? 'checked="checked"' : ''); |
---|
| 76 | $template->assign('ecard_sender_email_change', $piwecard->my_config['sender_email_change'] ? 'checked="checked"' : ''); |
---|
[20032] | 77 | $email_format_array = array(); |
---|
[20013] | 78 | foreach($piwecard->my_config['email_format'] as $email_format) { |
---|
[20032] | 79 | array_push($email_format_array, array( |
---|
[20013] | 80 | 'id' => $email_format, |
---|
[20047] | 81 | 'selected' => (in_array($email_format, $piwecard->my_config['email_format_authorized']) ? 'checked="checked"' : ''), |
---|
[20032] | 82 | 'selected_default' => (($piwecard->my_config['email_format_default'] == $email_format) ? 'checked="checked"' : ''), |
---|
[20059] | 83 | 'language_string' => 'piwecard_email_format_'.$email_format, |
---|
[20013] | 84 | ) |
---|
| 85 | ); |
---|
| 86 | } |
---|
[20032] | 87 | $template->assign('ecard_email_format', $email_format_array); |
---|
| 88 | $template->assign('ecard_email_format_default', $email_format_array); |
---|
[20013] | 89 | $template->assign('ecard_show_image_infos', $piwecard->my_config['show_image_infos'] ? 'checked="checked"' : ''); |
---|
[20047] | 90 | $template->assign('ecard_default_guest_email', ((isset($configuration['default_guest_email'])) ? $configuration['default_guest_email'] : $piwecard->my_config['default_guest_email'])); |
---|
| 91 | $template->assign('ecard_email_subject', ((isset($configuration['email_subject'])) ? $configuration['email_subject'] : htmlspecialchars_decode($piwecard->my_config['email_subject']))); |
---|
| 92 | $template->assign('ecard_email_message_text', ((isset($configuration['email_message']['text'])) ? $configuration['email_message']['text'] : htmlspecialchars_decode($piwecard->my_config['email_message']['text']))); |
---|
| 93 | $template->assign('ecard_email_message_html', ((isset($configuration['email_message']['html'])) ? $configuration['email_message']['html'] : htmlspecialchars_decode($piwecard->my_config['email_message']['html']))); |
---|
[8812] | 94 | |
---|
[20032] | 95 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/admin_configuration.tpl'); |
---|
[8771] | 96 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 97 | ?> |
---|