[8771] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | global $template, $page; |
---|
[20320] | 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 | |
---|
[20254] | 12 | $configuration['nb_max_recipients'] = $_POST['ecard_nb_max_recipients']; |
---|
| 13 | |
---|
| 14 | if (intval($configuration['nb_max_recipients']) == 0) { |
---|
| 15 | $configuration['nb_max_recipients'] = 1; |
---|
| 16 | $piwecard->config['nb_max_recipients'] = $configuration['nb_max_recipients']; |
---|
| 17 | } else { |
---|
| 18 | $piwecard->config['nb_max_recipients'] = intval($configuration['nb_max_recipients']); |
---|
| 19 | } |
---|
| 20 | |
---|
[20162] | 21 | $configuration['validity'] = $_POST['ecard_validity_list']; |
---|
| 22 | $configuration['validity'] = explode(',', $configuration['validity']); |
---|
| 23 | |
---|
| 24 | $configuration['validity_default'] = isset($_POST['ecard_validity_default']) ? $_POST['ecard_validity_default'] : null; |
---|
| 25 | |
---|
| 26 | if ($configuration['validity'][0] == null) { |
---|
| 27 | $errors['validity'] = array( |
---|
| 28 | 'style_error_text' => 'display: block;', |
---|
| 29 | 'style_error_input' => 'class="ecard_error_input"', |
---|
| 30 | ); |
---|
| 31 | } elseif (!in_array($configuration['validity_default'], $configuration['validity'])) { |
---|
| 32 | $configuration['validity_default'] = $configuration['validity']; |
---|
| 33 | } |
---|
| 34 | $conf_validity = array(); |
---|
| 35 | foreach ($configuration['validity'] as $validity) { |
---|
| 36 | array_push($conf_validity, intval($validity)); |
---|
| 37 | } |
---|
| 38 | $configuration['validity'] = array_unique($conf_validity, SORT_NUMERIC); |
---|
| 39 | asort($configuration['validity']); |
---|
| 40 | |
---|
| 41 | $configuration['validity_choice'] = ((isset($_POST['ecard_validity_choice']) && $_POST['ecard_validity_choice'] == '1') ? true : false); |
---|
[25071] | 42 | $configuration['sender_copy'] = isset($_POST['ecard_sender_copy']); |
---|
[20103] | 43 | $configuration['image_size'] = $_POST['ecard_image_size']; |
---|
[20202] | 44 | |
---|
| 45 | $configuration['image_border']['display'] = ((isset($_POST['ecard_image_border']) && $_POST['ecard_image_border'] == '1') ? true : false); |
---|
| 46 | $configuration['image_border']['style'] = $_POST['ecard_image_border_style']; |
---|
| 47 | $configuration['image_border']['width'] = ((isset($_POST['ecard_image_border_width']) && $_POST['ecard_image_border_width'] != '1') ? $_POST['ecard_image_border_width'] : $piwecard->get_default_config_param('ecard_image_border_width')); |
---|
| 48 | $configuration['image_border']['color'] = ((isset($_POST['ecard_image_border_color']) && $_POST['ecard_image_border_color'] != '1') ? $_POST['ecard_image_border_color'] : $piwecard->get_default_config_param('ecard_image_border_color')); |
---|
[8771] | 49 | |
---|
[25071] | 50 | $configuration['sender_email_change'] = isset($_POST['ecard_sender_email_change']); |
---|
[20202] | 51 | |
---|
[20013] | 52 | $ecard_email_format_array = array(); |
---|
| 53 | foreach($_POST['ecard_email_format'] as $ecard_email_format) { |
---|
| 54 | array_push($ecard_email_format_array, $ecard_email_format); |
---|
| 55 | } |
---|
[20047] | 56 | $configuration['email_format_authorized'] = $ecard_email_format_array; |
---|
| 57 | $configuration['email_format_default'] = $_POST['ecard_email_format_default']; |
---|
| 58 | if (!in_array($configuration['email_format_default'], $configuration['email_format_authorized'])) |
---|
| 59 | $errors['email_format_default'] = array( |
---|
[20162] | 60 | 'style_error_text' => 'display: block;', |
---|
[20047] | 61 | ); |
---|
[20162] | 62 | $configuration['show_image_infos'] = ((isset($_POST['ecard_show_image_infos']) && $_POST['ecard_show_image_infos'] == '1') ? true : false); |
---|
[20047] | 63 | $configuration['default_guest_email'] = $_POST['ecard_default_guest_email']; |
---|
[20162] | 64 | if ($configuration['default_guest_email'] != '' && !$piwecard->is_valid_email($configuration['default_guest_email'])) |
---|
[20047] | 65 | $errors['default_guest_email'] = array( |
---|
[20162] | 66 | 'style_error_text' => 'display: block;', |
---|
| 67 | 'style_error_input' => 'class="ecard_error_input"', |
---|
[20047] | 68 | ); |
---|
| 69 | $configuration['email_subject'] = htmlspecialchars($_POST['ecard_email_subject']); |
---|
| 70 | if ($configuration['email_subject'] == '') |
---|
| 71 | $errors['email_subject'] = array( |
---|
[20162] | 72 | 'style_error_text' => 'display: block;', |
---|
| 73 | 'style_error_input' => 'class="ecard_error_input"', |
---|
[20047] | 74 | ); |
---|
| 75 | $configuration['email_message']['text'] = htmlspecialchars($_POST['ecard_email_message_text']); |
---|
| 76 | if ($configuration['email_message']['text'] == '') |
---|
| 77 | $errors['email_message']['text'] = array( |
---|
[20162] | 78 | 'style_error_text' => 'display: block;', |
---|
| 79 | 'style_error_input' => 'class="ecard_error_input"', |
---|
[20047] | 80 | ); |
---|
| 81 | $configuration['email_message']['html'] = stripslashes($_POST['ecard_email_message_html']); |
---|
| 82 | if ($configuration['email_message']['html'] == '') |
---|
| 83 | $errors['email_message']['html'] = array( |
---|
[20162] | 84 | 'style_error_text' => 'display: block;', |
---|
| 85 | 'style_error_input' => 'class="ecard_error_input"', |
---|
[20047] | 86 | ); |
---|
| 87 | |
---|
| 88 | foreach ($configuration as $key => $item) { |
---|
| 89 | if (!array_key_exists($key, $errors)) { |
---|
[20088] | 90 | $piwecard->config[$key] = $configuration[$key]; |
---|
[20047] | 91 | } |
---|
| 92 | } |
---|
[20032] | 93 | $piwecard->set_config(); |
---|
[20047] | 94 | |
---|
| 95 | if (empty($errors)) { |
---|
[20059] | 96 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[20047] | 97 | } else { |
---|
| 98 | $template->assign('ecard_errors', $errors); |
---|
| 99 | array_push($page['errors'], l10n('piwecard_errors')); |
---|
| 100 | } |
---|
[8771] | 101 | } |
---|
| 102 | |
---|
[20162] | 103 | if (isset($_POST['reset'])) { |
---|
[20202] | 104 | $piwecard->config['email_subject'] = $piwecard->get_default_config_param('email_subject'); |
---|
| 105 | $email_message = $piwecard->get_default_config_param('email_message'); |
---|
| 106 | $piwecard->config['email_message']['text'] = $email_message['text']; |
---|
| 107 | $piwecard->config['email_message']['html'] = $email_message['html']; |
---|
[20162] | 108 | |
---|
| 109 | $piwecard->set_config(); |
---|
| 110 | |
---|
| 111 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
| 112 | } |
---|
| 113 | |
---|
[20254] | 114 | $template->assign('ecard_nb_max_recipients',((isset($configuration['nb_max_recipients'])) ? $configuration['nb_max_recipients'] : $piwecard->config['nb_max_recipients'])); |
---|
| 115 | |
---|
[20162] | 116 | if (isset($errors['validity'])) { |
---|
| 117 | $piwecard->config['validity'] = null; |
---|
| 118 | $configuration['validity'] = null; |
---|
| 119 | } |
---|
| 120 | $template->assign('ecard_validity_list',((isset($configuration['validity'])) ? $configuration['validity'] : $piwecard->config['validity'])); |
---|
| 121 | |
---|
| 122 | if (isset($piwecard->config['validity'])) { |
---|
| 123 | foreach($piwecard->config['validity'] as $validity) { |
---|
| 124 | $template->append('ecard_validity', array( |
---|
| 125 | 'id' => $validity, |
---|
| 126 | 'name' => ($validity == 0) ? l10n('piwecard_nolimit') : $validity.' '.l10n('piwecard_days'), |
---|
| 127 | 'selected' => (($piwecard->config['validity_default'] == $validity) ? 'selected' : ''), |
---|
| 128 | ) |
---|
| 129 | ); |
---|
| 130 | } |
---|
| 131 | } |
---|
| 132 | $template->assign('ecard_validity_choice', $piwecard->config['validity_choice'] ? 'checked="checked"' : ''); |
---|
| 133 | |
---|
[20103] | 134 | $derivative_map = array(); |
---|
| 135 | foreach(ImageStdParams::get_defined_type_map() as $params) { |
---|
| 136 | $derivative_map[$params->type]['name'] = l10n($params->type); |
---|
| 137 | if ($params->type == $piwecard->config['image_size']) |
---|
| 138 | $derivative_map[$params->type]['selected'] = 'checked="checked"'; |
---|
| 139 | else |
---|
| 140 | $derivative_map[$params->type]['selected'] = ''; |
---|
| 141 | } |
---|
| 142 | $template->assign('generate_derivatives_types', $derivative_map); |
---|
| 143 | |
---|
[20202] | 144 | $template->assign('ecard_image_border', (($piwecard->config['image_border']['display']) ? 'checked="checked"' : '')); |
---|
| 145 | $template->assign('ecard_image_border_style', array( |
---|
| 146 | 'solid' => (($piwecard->config['image_border']['style'] == 'solid') ? 'checked="checked"' : ''), |
---|
| 147 | 'dashed' => (($piwecard->config['image_border']['style'] == 'dashed') ? 'checked="checked"' : ''), |
---|
| 148 | 'dotted' => (($piwecard->config['image_border']['style'] == 'dotted') ? 'checked="checked"' : ''), |
---|
| 149 | 'double' => (($piwecard->config['image_border']['style'] == 'double') ? 'checked="checked"' : ''), |
---|
| 150 | ) |
---|
| 151 | ); |
---|
| 152 | $template->assign('ecard_image_border_width', $piwecard->config['image_border']['width']); |
---|
| 153 | $template->assign('ecard_image_border_color', $piwecard->config['image_border']['color']); |
---|
| 154 | |
---|
[20088] | 155 | $template->assign('ecard_sender_copy', $piwecard->config['sender_copy'] ? 'checked="checked"' : ''); |
---|
| 156 | $template->assign('ecard_sender_email_change', $piwecard->config['sender_email_change'] ? 'checked="checked"' : ''); |
---|
[20032] | 157 | $email_format_array = array(); |
---|
[20088] | 158 | foreach($piwecard->config['email_format'] as $email_format) { |
---|
[20032] | 159 | array_push($email_format_array, array( |
---|
[20013] | 160 | 'id' => $email_format, |
---|
[20088] | 161 | 'selected' => (in_array($email_format, $piwecard->config['email_format_authorized']) ? 'checked="checked"' : ''), |
---|
| 162 | 'selected_default' => (($piwecard->config['email_format_default'] == $email_format) ? 'checked="checked"' : ''), |
---|
[20059] | 163 | 'language_string' => 'piwecard_email_format_'.$email_format, |
---|
[20013] | 164 | ) |
---|
| 165 | ); |
---|
| 166 | } |
---|
[20032] | 167 | $template->assign('ecard_email_format', $email_format_array); |
---|
| 168 | $template->assign('ecard_email_format_default', $email_format_array); |
---|
[20088] | 169 | $template->assign('ecard_show_image_infos', $piwecard->config['show_image_infos'] ? 'checked="checked"' : ''); |
---|
| 170 | $template->assign('ecard_default_guest_email', ((isset($configuration['default_guest_email'])) ? $configuration['default_guest_email'] : $piwecard->config['default_guest_email'])); |
---|
| 171 | $template->assign('ecard_email_subject', ((isset($configuration['email_subject'])) ? $configuration['email_subject'] : htmlspecialchars_decode($piwecard->config['email_subject']))); |
---|
| 172 | $template->assign('ecard_email_message_text', ((isset($configuration['email_message']['text'])) ? $configuration['email_message']['text'] : htmlspecialchars_decode($piwecard->config['email_message']['text']))); |
---|
| 173 | $template->assign('ecard_email_message_html', ((isset($configuration['email_message']['html'])) ? $configuration['email_message']['html'] : htmlspecialchars_decode($piwecard->config['email_message']['html']))); |
---|
[20229] | 174 | $template->assign('preview_image', get_root_url().PIWECARD_PATH.'admin/images/image.jpg'); |
---|
[20341] | 175 | |
---|
[20032] | 176 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/admin_configuration.tpl'); |
---|
[8771] | 177 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 178 | ?> |
---|