Aleksander Machniak
2013-12-31 d575e46067c06f1165adb249865f3812e270df12
program/steps/settings/save_identity.inc
@@ -5,7 +5,7 @@
 | program/steps/settings/save_identity.inc                              |
 |                                                                       |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2005-2009, The Roundcube Dev Team                       |
 | Copyright (C) 2005-2013, The Roundcube Dev Team                       |
 |                                                                       |
 | Licensed under the GNU General Public License version 3 or            |
 | any later version with exceptions for skins & plugins.                |
@@ -35,16 +35,18 @@
$save_data = array();
foreach ($a_save_cols as $col) {
  $fname = '_'.$col;
  if (isset($_POST[$fname]))
    if (isset($_POST[$fname])) {
    $save_data[$col] = rcube_utils::get_input_value($fname, rcube_utils::INPUT_POST, true);
    }
}
// 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]))
    if (!isset($_POST[$fname])) {
    $save_data[$col] = 0;
    }
}
// unset email address if user has no rights to change it
@@ -63,8 +65,9 @@
// Validate e-mail addresses
$email_checks = array(rcube_utils::idn_to_ascii($save_data['email']));
foreach (array('reply-to', 'bcc') as $item) {
  foreach (rcube_mime::decode_address_list($save_data[$item], null, false) as $rcpt)
    foreach (rcube_mime::decode_address_list($save_data[$item], null, false) as $rcpt) {
    $email_checks[] = rcube_utils::idn_to_ascii($rcpt['mailto']);
    }
}
foreach ($email_checks as $email) {
@@ -93,14 +96,17 @@
    // merge with old identity data, fixes #1488834
    $identity  = $RCMAIL->user->get_identity($iid);
    $save_data = array_merge($identity, $save_data);
    unset($save_data['changed'], $save_data['del'], $save_data['user_id'], $save_data['identity_id']);
  }
  $plugin = $RCMAIL->plugins->exec_hook('identity_update', array('id' => $iid, 'record' => $save_data));
  $save_data = $plugin['record'];
  if ($save_data['email'])
    if ($save_data['email']) {
    $save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']);
    }
  if (!$plugin['abort'])
    $updated = $RCMAIL->user->update_identity($iid, $save_data);
  else
@@ -109,12 +115,14 @@
  if ($updated) {
    $OUTPUT->show_message('successfullysaved', 'confirmation');
    if (!empty($save_data['standard']))
        if (!empty($save_data['standard'])) {
      $default_id = $iid;
        }
    if ($_POST['_framed']) {
      // update the changed col in list
      $OUTPUT->command('parent.update_identity_row', $iid, rcube::Q(trim($save_data['name'] . ' <' . rcube_utils::idn_to_utf8($save_data['email']) .'>')));
            $name = $save_data['name'] . ' <' . rcube_utils::idn_to_utf8($save_data['email']) .'>';
            $OUTPUT->command('parent.update_identity_row', $iid, rcube::Q(trim($name)));
    }
  }
  else {
@@ -124,7 +132,6 @@
    return;
  }
}
// insert a new identity record
else if (IDENTITIES_LEVEL < 2) {
  if (IDENTITIES_LEVEL == 1) {
@@ -134,8 +141,9 @@
  $plugin = $RCMAIL->plugins->exec_hook('identity_create', array('record' => $save_data));
  $save_data = $plugin['record'];
  if ($save_data['email'])
    if ($save_data['email']) {
    $save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']);
    }
  if (!$plugin['abort'])
    $insert_id = $save_data['email'] ? $RCMAIL->user->insert_identity($save_data) : null;
@@ -147,12 +155,14 @@
    $_GET['_iid'] = $insert_id;
    if (!empty($save_data['standard']))
        if (!empty($save_data['standard'])) {
      $default_id = $insert_id;
        }
    if ($_POST['_framed']) {
      // add a new row to the list
      $OUTPUT->command('parent.update_identity_row', $insert_id, rcube::Q(trim($save_data['name'] . ' <' . rcube_utils::idn_to_utf8($save_data['email']) .'>')), true);
            $name = $save_data['name'] . ' <' . rcube_utils::idn_to_utf8($save_data['email']) .'>';
            $OUTPUT->command('parent.update_identity_row', $insert_id, rcube::Q(trim($name)), true);
    }
  }
  else {
@@ -162,20 +172,22 @@
    return;
  }
}
else
else {
  $OUTPUT->show_message('opnotpermitted', 'error');
}
// mark all other identities as 'not-default'
if ($default_id)
if ($default_id) {
  $RCMAIL->user->set_default($default_id);
}
// go to next step
if (!empty($_REQUEST['_framed'])) {
  $RCMAIL->overwrite_action('edit-identity');
}
else
else {
  $RCMAIL->overwrite_action('identities');
}
/**