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