Changeset 3016 in subversion


Ignore:
Timestamp:
Oct 5, 2009 3:20:36 AM (4 years ago)
Author:
alec
Message:
  • Fix bugs in unused addressbook copy contact function (#1486199)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/steps/addressbook/copy.inc

    r2758 r3016  
    2626$cid = get_input_value('_cid', RCUBE_INPUT_POST); 
    2727$target = get_input_value('_to', RCUBE_INPUT_POST); 
    28 if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) && strlen($target) && $target != $source) 
     28 
     29if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) && strlen($target) && $target !== $source) 
    2930{ 
    30   $success = false; 
     31  $success = 0; 
    3132  $TARGET = $RCMAIL->get_address_book($target); 
    3233 
    3334  if ($TARGET && $TARGET->ready && !$TARGET->readonly) { 
    34     $plugin = $RCMAIL->plugins->exec_hook('create_contact', array('record' => $CONTACTS->search($CONTACTS->primary_key, $cid), 'source' => $target)); 
     35    $arr_cids = split(',', $cid); 
     36    foreach ($arr_cids as $cid) { 
     37      $plugin = $RCMAIL->plugins->exec_hook('create_contact', array('record' => $CONTACTS->get_record($cid, true), 'source' => $target)); 
    3538    $a_record = $plugin['record']; 
    3639 
    3740    if (!$plugin['abort']) 
    38       $success = $TARGET->insert($CONTACTS->search($a_record, true)); 
     41        if ($TARGET->insert($a_record, true)) 
     42          $success++; 
     43    } 
    3944  } 
    4045 
    41   if (empty($success)) 
     46  if ($success == 0) 
    4247    $OUTPUT->show_message('copyerror', 'error'); 
    4348  else 
    44     $OUTPUT->show_message('copysuccess', 'notice', array('nr' => count($success))); 
     49    $OUTPUT->show_message('copysuccess', 'notice', array('nr' => $success)); 
    4550     
    4651  // close connection to second address directory 
Note: See TracChangeset for help on using the changeset viewer.