+$save_data = array();
+foreach ($a_save_cols as $col)
+{
+ $fname = '_'.$col;
+ if (isset($_POST[$fname]))
+ $save_data[$col] = get_input_value($fname, RCUBE_INPUT_POST, in_array($col, $a_html_cols));
+}
+
+// set "off" values for checkboxes that were not checked, and therefore
+// not included in the POST body.
+foreach ($a_boolean_cols as $col)
+{
+ $fname = '_' . $col;
+ if (!isset($_POST[$fname]))
+ $save_data[$col] = 0;
+}
+
+// unset email address if user has no rights to change it
+if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3)
+ unset($save_data['email']);
+
+// Validate e-mail addresses
+foreach (array('email', 'reply-to', 'bcc') as $item) {
+ if ($email = $save_data[$item]) {
+ $ascii_email = rcube_idn_to_ascii($email);
+ if (!check_email($ascii_email)) {
+ // show error message
+ $OUTPUT->show_message('emailformaterror', 'error', array('email' => $email), false);
+ rcmail_overwrite_action('edit-identity');
+ return;
+ }
+ }
+}
+